From: richardbarry Date: Sat, 10 Oct 2009 18:41:14 +0000 (+0000) Subject: Add the tests performed by prvOldStyleUserModeTask(). X-Git-Tag: V6.0.0~17 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dc83bc50e617bc473f200fe4557d4551d354cf67;p=freertos Add the tests performed by prvOldStyleUserModeTask(). git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@912 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/FreeRTOSConfig.h b/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/FreeRTOSConfig.h index 4b4fc644c..19d573dd3 100644 --- a/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/FreeRTOSConfig.h +++ b/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/FreeRTOSConfig.h @@ -62,12 +62,12 @@ *----------------------------------------------------------*/ #define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 +#define configUSE_IDLE_HOOK 1 #define configUSE_TICK_HOOK 1 #define configCPU_CLOCK_HZ ( ( unsigned long ) 50000000 ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 100 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 1024 ) ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 2048 ) ) #define configMAX_TASK_NAME_LEN ( 12 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 diff --git a/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/main.c b/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/main.c index 046b65b47..3c7f5fb09 100644 --- a/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/main.c +++ b/Demo/CORTEX_MPU_LM3Sxxxx_Rowley/main.c @@ -107,7 +107,11 @@ static void prvRegTest2Task( void *pvParameters ); */ static void prvCheckTask( void *pvParameters ); - +/* + * Prototype for the User mode task that is created using the original + * vTaskCreate() API function. + */ +static void prvOldStyleUserModeTask( void *pvParameters ); /*-----------------------------------------------------------*/ /* Prototypes for other misc functions. --------------------*/ @@ -298,6 +302,16 @@ int main( void ) xTaskCreateRestricted( &xRegTest2Parameters, NULL ); xTaskCreateRestricted( &xCheckTaskParameters, NULL ); + /* Create the tasks that are created using the original xTaskCreate() API + function. */ + xTaskCreate( prvOldStyleUserModeTask, /* The function that implements the task. */ + ( signed char * ) "Task1", /* Text name for the task. */ + 100, /* Stack depth in words. */ + NULL, /* Task parameters. */ + 3, /* Priority. */ + NULL /* Handle. */ + ); + /* Print out the amount of free heap space so configTOTAL_HEAP_SIZE can be tuned. The heap size is set to be very small in this example and will need to be increased before many more tasks, queues or semaphores can be @@ -596,6 +610,104 @@ xQueueHandle xQueue = ( xQueueHandle ) pvParameters; } /*-----------------------------------------------------------*/ +void vApplicationIdleHook( void ) +{ +extern unsigned long __SRAM_segment_end__[]; +extern unsigned long __privileged_data_start__[]; +extern unsigned long __privileged_data_end__[]; +extern unsigned long __FLASH_segment_start__[]; +extern unsigned long __FLASH_segment_end__[]; +volatile unsigned long *pul; +volatile unsigned long ulReadData; + + /* The idle task, and therefore this function, run in Supervisor mode and + can therefore access all memory. Try reading from corners of flash and + RAM to ensure a memory fault does not occur. + + Start with the edges of the privileged data area. */ + pul = __privileged_data_start__; + ulReadData = *pul; + pul = __privileged_data_end__ - 1; + ulReadData = *pul; + + /* Next the standard SRAM area. */ + pul = __SRAM_segment_end__ - 1; + ulReadData = *pul; + + /* And the standard Flash area - the start of which is marked for + privileged access only. */ + pul = __FLASH_segment_start__; + ulReadData = *pul; + pul = __FLASH_segment_end__ - 1; + ulReadData = *pul; + + /* Reading off the end of Flash or SRAM space should cause a fault. + Uncomment one of the following two pairs of lines to test. */ + + /* pul = __FLASH_segment_end__ + 4; + ulReadData = *pul; */ + + /* pul = __SRAM_segment_end__ + 1; + ulReadData = *pul; */ +} +/*-----------------------------------------------------------*/ + +static void prvOldStyleUserModeTask( void *pvParameters ) +{ +extern unsigned long __privileged_data_start__[]; +extern unsigned long __privileged_data_end__[]; +extern unsigned long __SRAM_segment_end__[]; +extern unsigned long __privileged_functions_end__[]; +extern unsigned long __FLASH_segment_start__[]; +extern unsigned long __FLASH_segment_end__[]; +volatile unsigned long *pul; +volatile unsigned long ulReadData; + +/* The following line is commented out to prevent the unused variable compiler +warning when the test that uses the variable is commented out. +extern unsigned long __privileged_functions_start__[]; */ + + ( void ) pvParameters; + + /* This task is created in User mode using the original xTaskCreate() API + function. It should have access to all Flash and RAM except that marked + as Privileged access only. Reading from the start and end of the non- + privileged RAM should not cause a problem (the privileged RAM is the first + block at the bottom of the RAM memory). */ + pul = __privileged_data_end__ + 1; + ulReadData = *pul; + pul = __SRAM_segment_end__ - 1; + ulReadData = *pul; + + /* Likewise reading from the start and end of the non-privileged Flash + should not be a problem (the privileged Flash is the first block at the + bottom of the Flash memory). */ + pul = __privileged_functions_end__ + 1; + ulReadData = *pul; + pul = __FLASH_segment_end__ - 1; + ulReadData = *pul; + + /* Reading from anywhere inside the privileged Flash or RAM should cause a + fault. This can be tested by uncommenting any of the following pairs of + lines. */ + + /* pul = __privileged_functions_start__; + ulReadData = *pul; */ + + /* pul = __privileged_functions_end__ - 1; + ulReadData = *pul; */ + + /* pul = __privileged_data_start__; + ulReadData = *pul; */ + + /* pul = __privileged_data_end__ - 1; + ulReadData = *pul; */ + + /* Must not just run off the end of a task function, so delete this task. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + static void prvDeleteMe( void ) { vTaskDelete( NULL );