]> git.sur5r.net Git - freertos/blobdiff - Demo/CORTEX_MPU_LM3Sxxxx_Rowley/main.c
Add the tests performed by prvOldStyleUserModeTask().
[freertos] / Demo / CORTEX_MPU_LM3Sxxxx_Rowley / main.c
index 046b65b4791bceb688ac635d55e85002762cf944..3c7f5fb0974b42e2f911700c43d9dd8d9c1908ca 100644 (file)
@@ -107,7 +107,11 @@ static void prvRegTest2Task( void *pvParameters );
  */\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
@@ -298,6 +302,16 @@ int main( void )
     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
@@ -596,6 +610,104 @@ xQueueHandle xQueue = ( xQueueHandle ) pvParameters;
 }\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