diff options
author | kar-rahul-aws <118818625+kar-rahul-aws@users.noreply.github.com> | 2023-04-19 13:29:00 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-19 13:29:00 +0530 |
commit | 457418a7237ab31e998e98789d49fef811183211 (patch) | |
tree | e3717daadb9a3b4b539f11c0743849f8af160ddd | |
parent | 27cbc7f6a2313894a0a8edf8569856d51eeda32b (diff) | |
download | freertos-git-457418a7237ab31e998e98789d49fef811183211.tar.gz |
Add Reg tests for CORTEX M33F Keil Simulator Project (#991)
* Add Reg tests for CORTEX M33F Keil Simulator Project
* Code review suggestions
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
* Fix hard fault because of main stack overflow
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
---------
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
8 files changed, 581 insertions, 7 deletions
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct index 387a8745c..23ee8abcb 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.sct @@ -53,7 +53,7 @@ ; <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
*----------------------------------------------------------------------------*/
-#define __STACK_SIZE 0x00000200
+#define __STACK_SIZE 0x00001000
#define __HEAP_SIZE 0x00000C00
/*
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvoptx b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvoptx index bbc8f09a0..87d315157 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvoptx +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvoptx @@ -435,6 +435,54 @@ <RteFlg>0</RteFlg> <bShared>0</bShared> </File> + <File> + <GroupNumber>4</GroupNumber> + <FileNumber>19</FileNumber> + <FileType>1</FileType> + <tvExp>0</tvExp> + <tvExpOptDlg>0</tvExpOptDlg> + <bDave2>0</bDave2> + <PathWithFileName>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\non_secure\reg_test_asm.c</PathWithFileName> + <FilenameWithoutPath>reg_test_asm.c</FilenameWithoutPath> + <RteFlg>0</RteFlg> + <bShared>0</bShared> + </File> + <File> + <GroupNumber>4</GroupNumber> + <FileNumber>20</FileNumber> + <FileType>5</FileType> + <tvExp>0</tvExp> + <tvExpOptDlg>0</tvExpOptDlg> + <bDave2>0</bDave2> + <PathWithFileName>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\non_secure\reg_test_asm.h</PathWithFileName> + <FilenameWithoutPath>reg_test_asm.h</FilenameWithoutPath> + <RteFlg>0</RteFlg> + <bShared>0</bShared> + </File> + <File> + <GroupNumber>4</GroupNumber> + <FileNumber>21</FileNumber> + <FileType>1</FileType> + <tvExp>0</tvExp> + <tvExpOptDlg>0</tvExpOptDlg> + <bDave2>0</bDave2> + <PathWithFileName>.\reg_tests.c</PathWithFileName> + <FilenameWithoutPath>reg_tests.c</FilenameWithoutPath> + <RteFlg>0</RteFlg> + <bShared>0</bShared> + </File> + <File> + <GroupNumber>4</GroupNumber> + <FileNumber>22</FileNumber> + <FileType>5</FileType> + <tvExp>0</tvExp> + <tvExpOptDlg>0</tvExpOptDlg> + <bDave2>0</bDave2> + <PathWithFileName>.\reg_tests.h</PathWithFileName> + <FilenameWithoutPath>reg_tests.h</FilenameWithoutPath> + <RteFlg>0</RteFlg> + <bShared>0</bShared> + </File> </Group> <Group> @@ -445,7 +493,7 @@ <RteFlg>0</RteFlg> <File> <GroupNumber>5</GroupNumber> - <FileNumber>19</FileNumber> + <FileNumber>23</FileNumber> <FileType>1</FileType> <tvExp>0</tvExp> <tvExpOptDlg>0</tvExpOptDlg> diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvprojx b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvprojx index 88ad64e9d..4ffd0dd58 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvprojx +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/FreeRTOSDemo_ns.uvprojx @@ -340,7 +340,7 @@ <MiscControls></MiscControls> <Define></Define> <Undefine></Undefine> - <IncludePath>..\Config;..\..\Common\ARMv8M\tz_demo;..\..\Common\ARMv8M\mpu_demo;..\..\..\Source\include;..\..\..\Source\portable\GCC\ARM_CM33\secure;..\..\..\Source\portable\GCC\ARM_CM33\non_secure</IncludePath> + <IncludePath>..\Config;..\..\Common\ARMv8M\tz_demo;..\..\Common\ARMv8M\mpu_demo;..\..\..\Source\include;..\..\..\Source\portable\GCC\ARM_CM33\secure;..\..\..\Source\portable\GCC\ARM_CM33\non_secure;..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\non_secure;..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\secure</IncludePath> </VariousControls> </Cads> <Aads> @@ -489,6 +489,26 @@ <FileType>1</FileType> <FilePath>..\..\Common\ARMv8M\tz_demo\tz_demo.c</FilePath> </File> + <File> + <FileName>reg_test_asm.c</FileName> + <FileType>1</FileType> + <FilePath>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\non_secure\reg_test_asm.c</FilePath> + </File> + <File> + <FileName>reg_test_asm.h</FileName> + <FileType>5</FileType> + <FilePath>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\non_secure\reg_test_asm.h</FilePath> + </File> + <File> + <FileName>reg_tests.c</FileName> + <FileType>1</FileType> + <FilePath>.\reg_tests.c</FilePath> + </File> + <File> + <FileName>reg_tests.h</FileName> + <FileType>5</FileType> + <FilePath>.\reg_tests.h</FilePath> + </File> </Files> </Group> <Group> @@ -568,7 +588,7 @@ <targetInfo name="FVP Simulation Model"/> </targetInfos> </file> - <file attr="config" category="sourceC" name="Device\ARM\ARMCM33\Source\system_ARMCM33.c" version="1.0.0"> + <file attr="config" category="sourceC" name="Device\ARM\ARMCM33\Source\system_ARMCM33.c" version="1.0.1"> <instance index="0">RTE\Device\ARMCM33_DSP_FP_TZ\system_ARMCM33.c</instance> <component Cclass="Device" Cgroup="Startup" Cvariant="C Startup" Cvendor="ARM" Cversion="2.1.0" condition="ARMCM33 CMSIS" isDefaultVariant="1"/> <package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0"/> diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c index 8e8479a05..f9fbc3d52 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/main_ns.c @@ -31,6 +31,7 @@ /* Demo includes. */
#include "tz_demo.h"
#include "mpu_demo.h"
+#include "reg_tests.h"
/* Externs needed by the MPU setup code. These are defined in Scatter-Loading
* description file (FreeRTOSDemo_ns.sct). */
@@ -120,6 +121,9 @@ static void prvCreateTasks( void ) /* Create tasks for the TZ Demo. */
vStartTZDemo();
+
+ /* Create tasks for reg tests. */
+ vStartRegTests();
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/reg_tests.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/reg_tests.c new file mode 100644 index 000000000..ce607bccd --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/reg_tests.c @@ -0,0 +1,433 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +/* Scheduler includes. */ +#include "FreeRTOS.h" +#include "task.h" + +/* Reg test includes. */ +#include "reg_tests.h" +#include "reg_test_asm.h" +#include "secure_reg_test_asm.h" + + +/* + * Functions that implement reg test tasks. + */ +static void prvRegTest1_Task( void * pvParameters ); +static void prvRegTest2_Task( void * pvParameters ); +static void prvRegTest3_Task( void * pvParameters ); +static void prvRegTest4_Task( void * pvParameters ); +static void prvRegTest_Secure_Task( void * pvParameters ); +static void prvRegTest_NonSecureCallback_Task( void * pvParameters ); +/* + * Check task periodically checks that reg tests tasks + * are running fine. + */ +static void prvCheckTask( void * pvParameters ); +/*-----------------------------------------------------------*/ + +/* + * Priority of the check task. + */ +#define CHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) + +/* + * Frequency of check task. + */ +#define NO_ERROR_CHECK_TASK_PERIOD ( pdMS_TO_TICKS( 5000UL ) ) +#define ERROR_CHECK_TASK_PERIOD ( pdMS_TO_TICKS( 200UL ) ) + +/* + * Parameters passed to reg test tasks. + */ +#define REG_TEST_1_TASK_PARAMETER ( ( void * ) 0x12345678 ) +#define REG_TEST_2_TASK_PARAMETER ( ( void * ) 0x87654321 ) +#define REG_TEST_3_TASK_PARAMETER ( ( void * ) 0x12348765 ) +#define REG_TEST_4_TASK_PARAMETER ( ( void * ) 0x43215678 ) +#define REG_TEST_SECURE_TASK_PARAMETER ( ( void * ) 0x1234ABCD ) +#define REG_TEST_NON_SECURE_CALLBACK_TASK_PARAMETER ( ( void * ) 0xABCD1234 ) +/*-----------------------------------------------------------*/ + +/* + * The following variables are used to communicate the status of the register + * test tasks to the check task. If the variables keep incrementing, then the + * register test tasks have not discovered any errors. If a variable stops + * incrementing, then an error has been found. + */ +volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL; +volatile unsigned long ulRegTest3LoopCounter = 0UL, ulRegTest4LoopCounter = 0UL; +volatile unsigned long ulRegTestSecureLoopCounter = 0UL; +volatile unsigned long ulRegTestNonSecureCallbackLoopCounter = 0UL; + +/** + * Counter to keep a count of how may times the check task loop has detected + * error. + */ +volatile unsigned long ulCheckTaskLoops = 0UL; +/*-----------------------------------------------------------*/ + +void vStartRegTests( void ) +{ +static StackType_t xRegTest1TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTest2TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTest3TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTest4TaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTestSecureTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xRegTestNonSecureCallbackTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); +static StackType_t xCheckTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) ); + +TaskParameters_t xRegTest1TaskParameters = +{ + .pvTaskCode = prvRegTest1_Task, + .pcName = "RegTest1", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_1_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest1TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTest2TaskParameters = +{ + .pvTaskCode = prvRegTest2_Task, + .pcName = "RegTest2", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_2_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest2TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTest3TaskParameters = +{ + .pvTaskCode = prvRegTest3_Task, + .pcName = "RegTest3", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_3_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest3TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTest4TaskParameters = +{ + .pvTaskCode = prvRegTest4_Task, + .pcName = "RegTest4", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_4_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTest4TaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTestSecureTaskParameters = +{ + .pvTaskCode = prvRegTest_Secure_Task, + .pcName = "RegTestSecure", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_SECURE_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTestSecureTaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; +TaskParameters_t xRegTestNonSecureCallbackTaskParameters = +{ + .pvTaskCode = prvRegTest_NonSecureCallback_Task, + .pcName = "RegTestNonSecureCallback", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = REG_TEST_NON_SECURE_CALLBACK_TASK_PARAMETER, + .uxPriority = tskIDLE_PRIORITY | portPRIVILEGE_BIT, + .puxStackBuffer = xRegTestNonSecureCallbackTaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; + +TaskParameters_t xCheckTaskParameters = +{ + .pvTaskCode = prvCheckTask, + .pcName = "Check", + .usStackDepth = configMINIMAL_STACK_SIZE, + .pvParameters = NULL, + .uxPriority = ( CHECK_TASK_PRIORITY | portPRIVILEGE_BIT ), + .puxStackBuffer = xCheckTaskStack, + .xRegions = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + } +}; + + xTaskCreateRestricted( &( xRegTest1TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTest2TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTest3TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTest4TaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTestSecureTaskParameters ), NULL ); + xTaskCreateRestricted( &( xRegTestNonSecureCallbackTaskParameters ), NULL ); + xTaskCreateRestricted( &( xCheckTaskParameters ), NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest1_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_1_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest1Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest2_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_2_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest2Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest3_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_3_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest3Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest4_Task( void * pvParameters ) +{ + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_4_TASK_PARAMETER ) + { + /* Start the part of the test that is written in assembler. */ + vRegTest4Asm_NonSecure(); + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest_Secure_Task( void * pvParameters ) +{ + /* This task is going to call secure side functions. */ + portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE ); + + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_SECURE_TASK_PARAMETER ) + { + for( ;; ) + { + /* Call the secure side function. This function populates registers + * with known values, then forces a context switch while on the + * secure side and then verifies that the contents of the registers + * are intact. This ensure that the context restoring mechanism + * works properly when the interrupted task was in the middle of a + * call to a secure side function. */ + vRegTestAsm_Secure(); + + ulRegTestSecureLoopCounter += 1; + } + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvRegTest_NonSecureCallback_Task( void * pvParameters ) +{ + /* This task is going to call secure side functions. */ + portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE ); + + /* Although the reg tests are written in assembly, its entry + * point is written in C for convenience of checking that the + * task parameter is being passed in correctly. */ + if( pvParameters == REG_TEST_NON_SECURE_CALLBACK_TASK_PARAMETER ) + { + for( ;; ) + { + /* Call the secure side function. This function calls the provided + * non-secure callback which in-turn populates registers with + * known values, then forces a context switch while on the + * non-secure side and then verifies that the contents of the + * registers are intact. This ensure that the context restoring + * mechanism works properly when the interrupted task was in the + * middle of a non-secure callback from the secure side. */ + vRegTest_NonSecureCallback( vRegTestAsm_NonSecureCallback ); + + ulRegTestNonSecureCallbackLoopCounter += 1; + } + } + + /* The following line will only execute if the task parameter + * is found to be incorrect. The check task will detect that + * the reg test loop counter is not being incremented and flag + * an error. */ + vTaskDelete( NULL ); +} +/*-----------------------------------------------------------*/ + +static void prvCheckTask( void * pvParameters ) +{ +TickType_t xDelayPeriod = NO_ERROR_CHECK_TASK_PERIOD; +TickType_t xLastExecutionTime; +unsigned long ulErrorFound = pdFALSE; +static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; +static unsigned long ulLastRegTest3Value = 0, ulLastRegTest4Value = 0; +static unsigned long ulLastRegTestSecureValue = 0, ulLastRegTestNonSecureCallbackValue = 0; + + /* Just to stop compiler warnings. */ + ( void ) pvParameters; + + /* Initialize xLastExecutionTime so the first call to vTaskDelayUntil() + * works correctly. */ + xLastExecutionTime = xTaskGetTickCount(); + + /* Cycle for ever, delaying then checking all the other tasks are still + * operating without error. The onboard LED is toggled on each iteration. + * If an error is detected then the delay period is decreased from + * mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD. This has + * the effect of increasing the rate at which the onboard LED toggles, and + * in so doing gives visual feedback of the system status. */ + for( ;; ) + { + /* Delay until it is time to execute again. */ + vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod ); + + /* Check that the register test 1 task is still running. */ + if( ulLastRegTest1Value == ulRegTest1LoopCounter ) + { + ulErrorFound |= 1UL << 0UL; + } + ulLastRegTest1Value = ulRegTest1LoopCounter; + + /* Check that the register test 2 task is still running. */ + if( ulLastRegTest2Value == ulRegTest2LoopCounter ) + { + ulErrorFound |= 1UL << 1UL; + } + ulLastRegTest2Value = ulRegTest2LoopCounter; + + /* Check that the register test 3 task is still running. */ + if( ulLastRegTest3Value == ulRegTest3LoopCounter ) + { + ulErrorFound |= 1UL << 2UL; + } + ulLastRegTest3Value = ulRegTest3LoopCounter; + + /* Check that the register test 4 task is still running. */ + if( ulLastRegTest4Value == ulRegTest4LoopCounter ) + { + ulErrorFound |= 1UL << 3UL; + } + ulLastRegTest4Value = ulRegTest4LoopCounter; + + /* Check that the register test secure task is still running. */ + if( ulLastRegTestSecureValue == ulRegTestSecureLoopCounter ) + { + ulErrorFound |= 1UL << 4UL; + } + ulLastRegTestSecureValue = ulRegTestSecureLoopCounter; + + /* Check that the register test non-secure callback task is + * still running. */ + if( ulLastRegTestNonSecureCallbackValue == ulRegTestNonSecureCallbackLoopCounter ) + { + ulErrorFound |= 1UL << 5UL; + } + ulLastRegTestNonSecureCallbackValue = ulRegTestNonSecureCallbackLoopCounter; + + if( ulErrorFound != pdFALSE ) + { + + /* Increment error detection count. */ + ulCheckTaskLoops++; + } + + } +} +/*-----------------------------------------------------------*/
\ No newline at end of file diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/reg_tests.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/reg_tests.h new file mode 100644 index 000000000..be1426b17 --- /dev/null +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/NonSecure/reg_tests.h @@ -0,0 +1,35 @@ +/* + * FreeRTOS V202212.00 + * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * https://www.FreeRTOS.org + * https://github.com/FreeRTOS + * + */ + +#ifndef REG_TESTS_H +#define REG_TESTS_H + +/** + * @brief Creates all the tasks for reg tests. + */ +void vStartRegTests( void ); + +#endif /* REG_TESTS_H */
\ No newline at end of file diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvoptx b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvoptx index 6cf31dae5..c39d21edc 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvoptx +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvoptx @@ -339,6 +339,30 @@ <RteFlg>0</RteFlg> <bShared>0</bShared> </File> + <File> + <GroupNumber>4</GroupNumber> + <FileNumber>11</FileNumber> + <FileType>1</FileType> + <tvExp>0</tvExp> + <tvExpOptDlg>0</tvExpOptDlg> + <bDave2>0</bDave2> + <PathWithFileName>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\secure\secure_reg_test_asm.c</PathWithFileName> + <FilenameWithoutPath>secure_reg_test_asm.c</FilenameWithoutPath> + <RteFlg>0</RteFlg> + <bShared>0</bShared> + </File> + <File> + <GroupNumber>4</GroupNumber> + <FileNumber>12</FileNumber> + <FileType>5</FileType> + <tvExp>0</tvExp> + <tvExpOptDlg>0</tvExpOptDlg> + <bDave2>0</bDave2> + <PathWithFileName>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\secure\secure_reg_test_asm.h</PathWithFileName> + <FilenameWithoutPath>secure_reg_test_asm.h</FilenameWithoutPath> + <RteFlg>0</RteFlg> + <bShared>0</bShared> + </File> </Group> <Group> @@ -349,7 +373,7 @@ <RteFlg>0</RteFlg> <File> <GroupNumber>5</GroupNumber> - <FileNumber>11</FileNumber> + <FileNumber>13</FileNumber> <FileType>1</FileType> <tvExp>0</tvExp> <tvExpOptDlg>0</tvExpOptDlg> diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvprojx b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvprojx index e779cecaa..1ee4aba4b 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvprojx +++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_Simulator_Keil_GCC/Secure/FreeRTOSDemo_s.uvprojx @@ -449,6 +449,16 @@ <FileType>1</FileType> <FilePath>..\..\Common\ARMv8M\tz_demo\nsc_functions.c</FilePath> </File> + <File> + <FileName>secure_reg_test_asm.c</FileName> + <FileType>1</FileType> + <FilePath>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\secure\secure_reg_test_asm.c</FilePath> + </File> + <File> + <FileName>secure_reg_test_asm.h</FileName> + <FileType>5</FileType> + <FilePath>..\..\Common\ARMv8M\reg_tests\GCC\ARM_CM33\secure\secure_reg_test_asm.h</FilePath> + </File> </Files> </Group> <Group> @@ -496,7 +506,7 @@ <targetInfo name="FVP Simulation Model"/> </targetInfos> </file> - <file attr="config" category="header" condition="TZ Secure" name="Device\ARM\ARMCM33\Include\Template\partition_ARMCM33.h" version="1.1.0"> + <file attr="config" category="header" condition="TZ Secure" name="Device\ARM\ARMCM33\Include\Template\partition_ARMCM33.h" version="1.1.1"> <instance index="0">RTE\Device\ARMCM33_DSP_FP_TZ\partition_ARMCM33.h</instance> <component Cclass="Device" Cgroup="Startup" Cvariant="C Startup" Cvendor="ARM" Cversion="2.1.0" condition="ARMCM33 CMSIS" isDefaultVariant="1"/> <package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0"/> @@ -518,7 +528,7 @@ <targetInfo name="FVP Simulation Model"/> </targetInfos> </file> - <file attr="config" category="sourceC" name="Device\ARM\ARMCM33\Source\system_ARMCM33.c" version="1.0.0"> + <file attr="config" category="sourceC" name="Device\ARM\ARMCM33\Source\system_ARMCM33.c" version="1.0.1"> <instance index="0">RTE\Device\ARMCM33_DSP_FP_TZ\system_ARMCM33.c</instance> <component Cclass="Device" Cgroup="Startup" Cvariant="C Startup" Cvendor="ARM" Cversion="2.1.0" condition="ARMCM33 CMSIS" isDefaultVariant="1"/> <package name="CMSIS" schemaVersion="1.7.7" url="http://www.keil.com/pack/" vendor="ARM" version="5.9.0"/> |