/*\r
- FreeRTOS V5.4.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
+ FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.\r
\r
- This file is part of the FreeRTOS distribution.\r
+ This file is part of the FreeRTOS distribution.\r
\r
- FreeRTOS is free software; you can redistribute it and/or modify it under\r
- the terms of the GNU General Public License (version 2) as published by the\r
- Free Software Foundation and modified by the FreeRTOS exception.\r
- **NOTE** The exception to the GPL is included to allow you to distribute a\r
- combined work that includes FreeRTOS without being obliged to provide the\r
- source code for proprietary components outside of the FreeRTOS kernel.\r
- Alternative commercial license and support terms are also available upon\r
- request. See the licensing section of http://www.FreeRTOS.org for full\r
- license details.\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation and modified by the FreeRTOS exception.\r
+ **NOTE** The exception to the GPL is included to allow you to distribute a\r
+ combined work that includes FreeRTOS without being obliged to provide the\r
+ source code for proprietary components outside of the FreeRTOS kernel.\r
+ Alternative commercial license and support terms are also available upon\r
+ request. See the licensing section of http://www.FreeRTOS.org for full\r
+ license details.\r
\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
- more details.\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
+ more details.\r
\r
- You should have received a copy of the GNU General Public License along\r
- with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59\r
- Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
+ You should have received a copy of the GNU General Public License along\r
+ with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59\r
+ Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
\r
\r
- ***************************************************************************\r
- * *\r
- * Looking for a quick start? Then check out the FreeRTOS eBook! *\r
- * See http://www.FreeRTOS.org/Documentation for details *\r
- * *\r
- ***************************************************************************\r
+ ***************************************************************************\r
+ * *\r
+ * The FreeRTOS eBook and reference manual are available to purchase for a *\r
+ * small fee. Help yourself get started quickly while also helping the *\r
+ * FreeRTOS project! See http://www.FreeRTOS.org/Documentation for details *\r
+ * *\r
+ ***************************************************************************\r
\r
- 1 tab == 4 spaces!\r
+ 1 tab == 4 spaces!\r
\r
- Please ensure to read the configuration and relevant port sections of the\r
- online documentation.\r
+ Please ensure to read the configuration and relevant port sections of the\r
+ online documentation.\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and\r
- contact details.\r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
+ contact details.\r
\r
- http://www.SafeRTOS.com - A version that is certified for use in safety\r
- critical systems.\r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
+ critical systems.\r
\r
- http://www.OpenRTOS.com - Commercial support, development, porting,\r
- licensing and training services.\r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
+ licensing and training services.\r
*/\r
\r
/* Standard includes. */\r
*/\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
/*-----------------------------------------------------------*/\r
\r
-void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName )\r
+void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )\r
{\r
/* If configCHECK_FOR_STACK_OVERFLOW is set to either 1 or 2 then this \r
function will automatically get called if a task overflows its stack. */\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