+++ /dev/null
-/*\r
- FreeRTOS V9.0.0rc2 - Copyright (C) 2016 Real Time Engineers Ltd.\r
- All rights reserved\r
-\r
- VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
-\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
-\r
- ***************************************************************************\r
- >>! NOTE: The modification to the GPL is included to allow you to !<<\r
- >>! distribute a combined work that includes FreeRTOS without being !<<\r
- >>! obliged to provide the source code for proprietary components !<<\r
- >>! outside of the FreeRTOS kernel. !<<\r
- ***************************************************************************\r
-\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
- FOR A PARTICULAR PURPOSE. Full license text is available on the following\r
- link: http://www.freertos.org/a00114.html\r
-\r
- ***************************************************************************\r
- * *\r
- * FreeRTOS provides completely free yet professionally developed, *\r
- * robust, strictly quality controlled, supported, and cross *\r
- * platform software that is more than just the market leader, it *\r
- * is the industry's de facto standard. *\r
- * *\r
- * Help yourself get started quickly while simultaneously helping *\r
- * to support the FreeRTOS project by purchasing a FreeRTOS *\r
- * tutorial book, reference manual, or both: *\r
- * http://www.FreeRTOS.org/Documentation *\r
- * *\r
- ***************************************************************************\r
-\r
- http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading\r
- the FAQ page "My application does not run, what could be wrong?". Have you\r
- defined configASSERT()?\r
-\r
- http://www.FreeRTOS.org/support - In return for receiving this top quality\r
- embedded software for free we request you assist our global community by\r
- participating in the support forum.\r
-\r
- http://www.FreeRTOS.org/training - Investing in training allows your team to\r
- be as productive as possible as early as possible. Now you can receive\r
- FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
- Ltd, and the world's leading authority on the world's leading RTOS.\r
-\r
- http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
- including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
- compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
-\r
- http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
- Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
-\r
- http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
- Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS\r
- licenses offer ticketed support, indemnification and commercial middleware.\r
-\r
- http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
- engineered and independently SIL3 certified version for use in safety and\r
- mission critical applications that require provable dependability.\r
-\r
- 1 tab == 4 spaces!\r
-*/\r
-\r
-/*\r
- * Tests the floating point context save and restore mechanism.\r
- *\r
- * Two tasks are created - each of which is allocated a buffer of \r
- * portNO_FLOP_REGISTERS_TO_SAVE 32bit variables into which the flop context\r
- * of the task is saved when the task is switched out, and from which the\r
- * flop context of the task is restored when the task is switch in. Prior to \r
- * the tasks being created each position in the two buffers is filled with a \r
- * unique value - this way the flop context of each task is different.\r
- *\r
- * The two test tasks never block so are always in either the Running or\r
- * Ready state. They execute at the lowest priority so will get pre-empted\r
- * regularly, although the yield frequently so will not get much execution\r
- * time. The lack of execution time is not a problem as its only the \r
- * switching in and out that is being tested.\r
- *\r
- * Whenever a task is moved from the Ready to the Running state its flop \r
- * context will be loaded from the buffer, but while the task is in the\r
- * Running state the buffer is not used and can contain any value - in this\r
- * case and for test purposes the task itself clears the buffer to zero. \r
- * The next time the task is moved out of the Running state into the\r
- * Ready state the flop context will once more get saved to the buffer - \r
- * overwriting the zeros.\r
- *\r
- * Therefore whenever the task is not in the Running state its buffer contains\r
- * the most recent values of its floating point registers - the zeroing out\r
- * of the buffer while the task was executing being used to ensure the values \r
- * the buffer contains are not stale.\r
- *\r
- * When neither test task is in the Running state the buffers should contain\r
- * the unique values allocated before the tasks were created. If so then\r
- * the floating point context has been maintained. This check is performed\r
- * by the 'check' task (defined in main.c) by calling \r
- * xAreFlopRegisterTestsStillRunning().\r
- *\r
- * The test tasks also increment a value each time they execute.\r
- * xAreFlopRegisterTestsStillRunning() also checks that this value has changed\r
- * since it last ran to ensure the test tasks are still getting processing time.\r
- */\r
-\r
-/* Standard includes files. */\r
-#include <string.h>\r
-\r
-/* Scheduler include files. */\r
-#include "FreeRTOS.h"\r
-#include "task.h"\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-#define flopNUMBER_OF_TASKS 2\r
-#define flopSTART_VALUE ( 0x1 )\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-/* The two test tasks as described at the top of this file. */\r
-static void vFlopTest1( void *pvParameters );\r
-static void vFlopTest2( void *pvParameters );\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-/* Buffers into which the flop registers will be saved. There is a buffer for \r
-both tasks. */\r
-static volatile unsigned long ulFlopRegisters[ flopNUMBER_OF_TASKS ][ portNO_FLOP_REGISTERS_TO_SAVE ];\r
-\r
-/* Variables that are incremented by the tasks to indicate that they are still\r
-running. */\r
-static volatile unsigned long ulFlop1CycleCount = 0, ulFlop2CycleCount = 0;\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void vStartFlopRegTests( void )\r
-{\r
-TaskHandle_t xTaskJustCreated;\r
-unsigned portBASE_TYPE x, y, z = flopSTART_VALUE;\r
-\r
- /* Fill the arrays into which the flop registers are to be saved with \r
- known values. These are the values that will be written to the flop\r
- registers when the tasks start, and as the tasks do not perform any\r
- flop operations the values should never change. Each position in the\r
- buffer contains a different value so the flop context of each task\r
- will be different. */\r
- for( x = 0; x < flopNUMBER_OF_TASKS; x++ )\r
- {\r
- for( y = 0; y < ( portNO_FLOP_REGISTERS_TO_SAVE - 1); y++ )\r
- {\r
- ulFlopRegisters[ x ][ y ] = z;\r
- z++;\r
- }\r
- }\r
-\r
-\r
- /* Create the first task. */\r
- xTaskCreate( vFlopTest1, "flop1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xTaskJustCreated );\r
-\r
- /* The task tag value is a value that can be associated with a task, but \r
- is not used by the scheduler itself. Its use is down to the application so\r
- it makes a convenient place in this case to store the pointer to the buffer\r
- into which the flop context of the task will be stored. The first created\r
- task uses ulFlopRegisters[ 0 ], the second ulFlopRegisters[ 1 ]. */\r
- vTaskSetApplicationTaskTag( xTaskJustCreated, ( void * ) &( ulFlopRegisters[ 0 ][ 0 ] ) );\r
-\r
- /* Do the same for the second task. */\r
- xTaskCreate( vFlopTest2, "flop2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, &xTaskJustCreated );\r
- vTaskSetApplicationTaskTag( xTaskJustCreated, ( void * ) &( ulFlopRegisters[ 1 ][ 0 ] ) );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void vFlopTest1( void *pvParameters )\r
-{\r
- /* Just to remove compiler warning. */\r
- ( void ) pvParameters;\r
-\r
- for( ;; )\r
- {\r
- /* The values from the buffer should have now been written to the flop\r
- registers. Clear the buffer to ensure the same values then get written\r
- back the next time the task runs. Being preempted during this memset\r
- could cause the test to fail, hence the critical section. */\r
- portENTER_CRITICAL();\r
- memset( ( void * ) ulFlopRegisters[ 0 ], 0x00, ( portNO_FLOP_REGISTERS_TO_SAVE * sizeof( unsigned portBASE_TYPE ) ) );\r
- portEXIT_CRITICAL();\r
-\r
- /* We don't have to do anything other than indicate that we are \r
- still running. */\r
- ulFlop1CycleCount++;\r
- taskYIELD();\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void vFlopTest2( void *pvParameters )\r
-{\r
- /* Just to remove compiler warning. */\r
- ( void ) pvParameters;\r
-\r
- for( ;; )\r
- {\r
- /* The values from the buffer should have now been written to the flop\r
- registers. Clear the buffer to ensure the same values then get written\r
- back the next time the task runs. */\r
- portENTER_CRITICAL();\r
- memset( ( void * ) ulFlopRegisters[ 1 ], 0x00, ( portNO_FLOP_REGISTERS_TO_SAVE * sizeof( unsigned portBASE_TYPE ) ) );\r
- portEXIT_CRITICAL();\r
-\r
- /* We don't have to do anything other than indicate that we are \r
- still running. */\r
- ulFlop2CycleCount++;\r
- taskYIELD();\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-portBASE_TYPE xAreFlopRegisterTestsStillRunning( void )\r
-{\r
-portBASE_TYPE xReturn = pdPASS;\r
-unsigned portBASE_TYPE x, y, z = flopSTART_VALUE;\r
-static unsigned long ulLastFlop1CycleCount = 0, ulLastFlop2CycleCount = 0;\r
-\r
- /* Called from the 'check' task.\r
- \r
- The flop tasks cannot be currently running, check their saved registers\r
- are as expected. The tests tasks do not perform any flop operations so\r
- their registers should be as per their initial setting. */\r
- for( x = 0; x < flopNUMBER_OF_TASKS; x++ )\r
- {\r
- for( y = 0; y < ( portNO_FLOP_REGISTERS_TO_SAVE - 1 ); y++ )\r
- {\r
- if( ulFlopRegisters[ x ][ y ] != z )\r
- {\r
- xReturn = pdFAIL;\r
- break;\r
- }\r
-\r
- z++;\r
- }\r
- }\r
-\r
- /* Check both tasks have actually been swapped in and out since this function\r
- last executed. */\r
- if( ulFlop1CycleCount == ulLastFlop1CycleCount )\r
- {\r
- xReturn = pdFAIL;\r
- }\r
-\r
- if( ulFlop2CycleCount == ulLastFlop2CycleCount )\r
- {\r
- xReturn = pdFAIL;\r
- }\r
-\r
- ulLastFlop1CycleCount = ulFlop1CycleCount;\r
- ulLastFlop2CycleCount = ulFlop2CycleCount;\r
-\r
- return xReturn;\r
-}\r
-\r