*/\r
static void prvCheckTask( void *pvParameters );\r
\r
-\r
+/*\r
+ * Prototype for the User mode task that is created using the original \r
+ * vTaskCreate() API function.\r
+ */\r
+static void prvOldStyleUserModeTask( void *pvParameters );\r
\r
/*-----------------------------------------------------------*/\r
/* Prototypes for other misc functions. --------------------*/\r
xTaskCreateRestricted( &xRegTest2Parameters, NULL );\r
xTaskCreateRestricted( &xCheckTaskParameters, NULL );\r
\r
+ /* Create the tasks that are created using the original xTaskCreate() API\r
+ function. */\r
+ xTaskCreate( prvOldStyleUserModeTask, /* The function that implements the task. */\r
+ ( signed char * ) "Task1", /* Text name for the task. */\r
+ 100, /* Stack depth in words. */\r
+ NULL, /* Task parameters. */\r
+ 3, /* Priority. */\r
+ NULL /* Handle. */\r
+ );\r
+\r
+ /* Print out the amount of free heap space so configTOTAL_HEAP_SIZE can be\r
+ tuned. The heap size is set to be very small in this example and will need\r
+ to be increased before many more tasks, queues or semaphores can be \r
+ created. */\r
+ debug_printf( "There are %d bytes of unused heap space, although the idle task is yet to be created.\r\n", xPortGetFreeHeapSize() );\r
+\r
/* Start the scheduler. */\r
vTaskStartScheduler();\r
\r
" BNE prvDeleteMe \n"\r
" CMP R12, #112 \n"\r
" BNE prvDeleteMe \n"\r
+ :::"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r8", "r9", "r10", "r11", "r12"\r
);\r
\r
/* Send mainREG_TEST_1_STILL_EXECUTING to the check task to indicate that this \r
" BNE prvDeleteMe \n"\r
" CMP R12, #12 \n"\r
" BNE prvDeleteMe \n"\r
+ :::"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r8", "r9", "r10", "r11", "r12"\r
);\r
\r
/* Send mainREG_TEST_2_STILL_EXECUTING to the check task to indicate that this \r
}\r
/*-----------------------------------------------------------*/\r
\r
+void vApplicationIdleHook( void )\r
+{\r
+extern unsigned long __SRAM_segment_end__[];\r
+extern unsigned long __privileged_data_start__[];\r
+extern unsigned long __privileged_data_end__[];\r
+extern unsigned long __FLASH_segment_start__[];\r
+extern unsigned long __FLASH_segment_end__[];\r
+volatile unsigned long *pul;\r
+volatile unsigned long ulReadData;\r
+\r
+ /* The idle task, and therefore this function, run in Supervisor mode and\r
+ can therefore access all memory. Try reading from corners of flash and\r
+ RAM to ensure a memory fault does not occur. \r
+ \r
+ Start with the edges of the privileged data area. */\r
+ pul = __privileged_data_start__;\r
+ ulReadData = *pul;\r
+ pul = __privileged_data_end__ - 1;\r
+ ulReadData = *pul;\r
+\r
+ /* Next the standard SRAM area. */\r
+ pul = __SRAM_segment_end__ - 1;\r
+ ulReadData = *pul;\r
+\r
+ /* And the standard Flash area - the start of which is marked for\r
+ privileged access only. */\r
+ pul = __FLASH_segment_start__;\r
+ ulReadData = *pul;\r
+ pul = __FLASH_segment_end__ - 1;\r
+ ulReadData = *pul;\r
+\r
+ /* Reading off the end of Flash or SRAM space should cause a fault. \r
+ Uncomment one of the following two pairs of lines to test. */\r
+ \r
+ /* pul = __FLASH_segment_end__ + 4;\r
+ ulReadData = *pul; */\r
+\r
+ /* pul = __SRAM_segment_end__ + 1;\r
+ ulReadData = *pul; */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvOldStyleUserModeTask( void *pvParameters )\r
+{\r
+extern unsigned long __privileged_data_start__[];\r
+extern unsigned long __privileged_data_end__[];\r
+extern unsigned long __SRAM_segment_end__[];\r
+extern unsigned long __privileged_functions_end__[];\r
+extern unsigned long __FLASH_segment_start__[];\r
+extern unsigned long __FLASH_segment_end__[];\r
+volatile unsigned long *pul;\r
+volatile unsigned long ulReadData;\r
+\r
+/* The following line is commented out to prevent the unused variable compiler\r
+warning when the test that uses the variable is commented out.\r
+extern unsigned long __privileged_functions_start__[]; */\r
+\r
+ ( void ) pvParameters;\r
+\r
+ /* This task is created in User mode using the original xTaskCreate() API\r
+ function. It should have access to all Flash and RAM except that marked\r
+ as Privileged access only. Reading from the start and end of the non-\r
+ privileged RAM should not cause a problem (the privileged RAM is the first\r
+ block at the bottom of the RAM memory). */\r
+ pul = __privileged_data_end__ + 1;\r
+ ulReadData = *pul;\r
+ pul = __SRAM_segment_end__ - 1;\r
+ ulReadData = *pul;\r
+\r
+ /* Likewise reading from the start and end of the non-privileged Flash\r
+ should not be a problem (the privileged Flash is the first block at the\r
+ bottom of the Flash memory). */\r
+ pul = __privileged_functions_end__ + 1;\r
+ ulReadData = *pul;\r
+ pul = __FLASH_segment_end__ - 1;\r
+ ulReadData = *pul;\r
+\r
+ /* Reading from anywhere inside the privileged Flash or RAM should cause a\r
+ fault. This can be tested by uncommenting any of the following pairs of\r
+ lines. */\r
+\r
+ /* pul = __privileged_functions_start__;\r
+ ulReadData = *pul; */\r
+ \r
+ /* pul = __privileged_functions_end__ - 1;\r
+ ulReadData = *pul; */\r
+\r
+ /* pul = __privileged_data_start__;\r
+ ulReadData = *pul; */\r
+ \r
+ /* pul = __privileged_data_end__ - 1;\r
+ ulReadData = *pul; */\r
+\r
+ /* Must not just run off the end of a task function, so delete this task. */\r
+ vTaskDelete( NULL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
static void prvDeleteMe( void )\r
{\r
vTaskDelete( NULL );\r
\r
void hard_fault_handler(unsigned int * hardfault_args)\r
{\r
-unsigned int stacked_r0;\r
-unsigned int stacked_r1;\r
-unsigned int stacked_r2;\r
-unsigned int stacked_r3;\r
-unsigned int stacked_r12;\r
-unsigned int stacked_lr;\r
-unsigned int stacked_pc;\r
-unsigned int stacked_psr;\r
+volatile unsigned int stacked_r0;\r
+volatile unsigned int stacked_r1;\r
+volatile unsigned int stacked_r2;\r
+volatile unsigned int stacked_r3;\r
+volatile unsigned int stacked_r12;\r
+volatile unsigned int stacked_lr;\r
+volatile unsigned int stacked_pc;\r
+volatile unsigned int stacked_psr;\r
\r
stacked_r0 = ((unsigned long) hardfault_args[0]);\r
stacked_r1 = ((unsigned long) hardfault_args[1]);\r