summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure
diff options
context:
space:
mode:
Diffstat (limited to 'FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure')
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject2
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project33
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.settings/org.eclipse.core.resources.prefs2
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/fault_handler.c (renamed from FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.h)27
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c198
-rw-r--r--FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.c446
6 files changed, 53 insertions, 655 deletions
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject
index e5ea92f11..9d63c2c65 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.cproject
@@ -115,6 +115,8 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.compiler.option.include.paths.88237135" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../../Config"/>
<listOptionValue builtIn="false" value="../../Secure"/>
+ <listOptionValue builtIn="false" value="../../../../NSC_Functions"/>
+ <listOptionValue builtIn="false" value="../../../../RegTests"/>
<listOptionValue builtIn="false" value="../../../../NXP_Code"/>
<listOptionValue builtIn="false" value="../../../../NXP_Code/board"/>
<listOptionValue builtIn="false" value="../../../../NXP_Code/source"/>
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project
index 4afbd6e4e..8588fa7ec 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.project
@@ -83,19 +83,24 @@
<locationURI>PARENT-4-PROJECT_LOC/Common/ARMv8M/tz_demo/tz_demo.h</locationURI>
</link>
<link>
+ <name>User/fault_handler.c</name>
+ <type>1</type>
+ <locationURI>PROJECT_LOC/fault_handler.c</locationURI>
+ </link>
+ <link>
<name>User/main_ns.c</name>
<type>1</type>
- <locationURI>PROJECT_LOC/main_ns.c</locationURI>
+ <locationURI>DEMO_ROOT/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/User/NonSecure/main_ns.c</locationURI>
</link>
<link>
- <name>User/res_tests.c</name>
+ <name>User/reg_tests.c</name>
<type>1</type>
- <locationURI>PROJECT_LOC/reg_tests.c</locationURI>
+ <locationURI>DEMO_ROOT/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/RegTests/reg_tests.c</locationURI>
</link>
</linkedResources>
<filteredResources>
<filter>
- <id>1681724631111</id>
+ <id>1682451970778</id>
<name></name>
<type>6</type>
<matcher>
@@ -104,7 +109,7 @@
</matcher>
</filter>
<filter>
- <id>1681724631147</id>
+ <id>1682451970814</id>
<name></name>
<type>6</type>
<matcher>
@@ -113,6 +118,15 @@
</matcher>
</filter>
<filter>
+ <id>1682451751797</id>
+ <name>NXP_Code</name>
+ <type>10</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-trustzone</arguments>
+ </matcher>
+ </filter>
+ <filter>
<id>1681721788469</id>
<name>reg_tests</name>
<type>9</type>
@@ -158,6 +172,15 @@
</matcher>
</filter>
<filter>
+ <id>1682451733052</id>
+ <name>NXP_Code/startup</name>
+ <type>6</type>
+ <matcher>
+ <id>org.eclipse.ui.ide.multiFilter</id>
+ <arguments>1.0-name-matches-false-false-startup_LPC55S69_cm33_core0.s</arguments>
+ </matcher>
+ </filter>
+ <filter>
<id>1681721804811</id>
<name>reg_tests/GCC</name>
<type>9</type>
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.settings/org.eclipse.core.resources.prefs b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..99f26c020
--- /dev/null
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.h b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/fault_handler.c
index 0837aad72..0a6d1b9ab 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.h
+++ b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/fault_handler.c
@@ -24,12 +24,27 @@
*
*/
-#ifndef REG_TESTS_H
-#define REG_TESTS_H
-
/**
- * @brief Creates all the tasks for reg tests.
+ * @brief The mem fault handler.
+ *
+ * It calls a function called vHandleMemoryFault.
*/
-void vStartRegTests( void );
+void MemManage_Handler( void ) __attribute__ ( ( naked ) );
+/*-----------------------------------------------------------*/
-#endif /* REG_TESTS_H */
+void MemManage_Handler( void ) /* __attribute__ ( ( naked ) ) */
+{
+ __asm volatile
+ (
+ " tst lr, #4 \n"
+ " ite eq \n"
+ " mrseq r0, msp \n"
+ " mrsne r0, psp \n"
+ " ldr r1, handler_address_const \n"
+ " bx r1 \n"
+ " \n"
+ " .align 4 \n"
+ " handler_address_const: .word vHandleMemoryFault \n"
+ );
+}
+/*-----------------------------------------------------------*/
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c
deleted file mode 100644
index 7967a3c68..000000000
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * 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
- *
- */
-
-/* FreeRTOS include. */
-#include "FreeRTOS.h"
-#include "task.h"
-
-/* Device includes. */
-#include "fsl_device_registers.h"
-#include "fsl_debug_console.h"
-#include "pin_mux.h"
-#include "board.h"
-#include "clock_config.h"
-#include "fsl_power.h"
-
-/* Demo includes. */
-#include "tz_demo.h"
-#include "mpu_demo.h"
-#include "reg_tests.h"
-/*-----------------------------------------------------------*/
-
-/**
- * @brief Create all demo tasks.
- */
-static void prvCreateTasks( void );
-
-/**
- * @brief Setup hardware.
- */
-static void prvSetupHardware( void );
-
-/**
- * @brief Application-specific implementation of the SystemInit() weak
- * function.
- */
-void SystemInit( void );
-
-/**
- * @brief The mem fault handler.
- *
- * It calls a function called vHandleMemoryFault.
- */
-void MemManage_Handler( void ) __attribute__ ( ( naked ) );
-/*-----------------------------------------------------------*/
-
-/* For instructions on how to build and run this demo, visit the following link:
- * https://www.freertos.org/RTOS-Cortex-M33-LPC55S69-MCUXpresso-GCC.html
- */
-
-/* Non-Secure main. */
-int main( void )
-{
- /* Setup hardware. */
- prvSetupHardware();
-
- /* Create tasks. */
- prvCreateTasks();
-
- /* Start scheduler. */
- vTaskStartScheduler();
-
- /* Will not get here if the scheduler starts successfully. If you do end up
- here then there wasn't enough heap memory available to start either the idle
- task or the timer/daemon task. https://www.freertos.org/a00111.html */
-
- for( ; ; )
- {
- }
-}
-/*-----------------------------------------------------------*/
-
-static void prvCreateTasks( void )
-{
- /* Create tasks for the MPU Demo. */
- vStartMPUDemo();
-
- /* Create tasks for the TZ Demo. */
- vStartTZDemo();
-
- /* Create tasks for reg tests. */
- vStartRegTests();
-}
-/*-----------------------------------------------------------*/
-
-static void prvSetupHardware( void )
-{
- /* Set BOD VBAT level to 1.65V. */
- POWER_SetBodVbatLevel( kPOWER_BodVbatLevel1650mv, kPOWER_BodHystLevel50mv, false );
-}
-/*-----------------------------------------------------------*/
-
-void SystemInit( void )
-{
- /* Nothing needs to be initialized for Non-Secure project. */
-}
-/*-----------------------------------------------------------*/
-
-/* Stack overflow hook. */
-void vApplicationStackOverflowHook( TaskHandle_t xTask, char *pcTaskName )
-{
- /* Force an assert. */
- configASSERT( pcTaskName == 0 );
-}
-/*-----------------------------------------------------------*/
-
-/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
- * implementation of vApplicationGetIdleTaskMemory() to provide the memory that
- * is used by the Idle task. */
-void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
- StackType_t ** ppxIdleTaskStackBuffer,
- uint32_t * pulIdleTaskStackSize )
-{
- /* If the buffers to be provided to the Idle task are declared inside this
- * function then they must be declared static - otherwise they will be
- * allocated on the stack and so not exists after this function exits. */
- static StaticTask_t xIdleTaskTCB;
- static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
-
- /* Pass out a pointer to the StaticTask_t structure in which the Idle
- * task's state will be stored. */
- *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
-
- /* Pass out the array that will be used as the Idle task's stack. */
- *ppxIdleTaskStackBuffer = uxIdleTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
- * Note that, as the array is necessarily of type StackType_t,
- * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
- *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
-}
-/*-----------------------------------------------------------*/
-
-/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
- * application must provide an implementation of vApplicationGetTimerTaskMemory()
- * to provide the memory that is used by the Timer service task. */
-void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
- StackType_t ** ppxTimerTaskStackBuffer,
- uint32_t * pulTimerTaskStackSize )
-{
- /* If the buffers to be provided to the Timer task are declared inside this
- * function then they must be declared static - otherwise they will be
- * allocated on the stack and so not exists after this function exits. */
- static StaticTask_t xTimerTaskTCB;
- static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__( ( aligned( 32 ) ) );
-
- /* Pass out a pointer to the StaticTask_t structure in which the Timer
- * task's state will be stored. */
- *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
-
- /* Pass out the array that will be used as the Timer task's stack. */
- *ppxTimerTaskStackBuffer = uxTimerTaskStack;
-
- /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
- * Note that, as the array is necessarily of type StackType_t,
- * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
- *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
-}
-/*-----------------------------------------------------------*/
-
-void MemManage_Handler( void )
-{
- __asm volatile
- (
- " tst lr, #4 \n"
- " ite eq \n"
- " mrseq r0, msp \n"
- " mrsne r0, psp \n"
- " ldr r1, handler_address_const \n"
- " bx r1 \n"
- " \n"
- " .align 4 \n"
- " handler_address_const: .word vHandleMemoryFault \n"
- );
-}
-/*-----------------------------------------------------------*/
diff --git a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.c b/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.c
deleted file mode 100644
index 831ec6479..000000000
--- a/FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/reg_tests.c
+++ /dev/null
@@ -1,446 +0,0 @@
-/*
- * 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"
-
-/* Printf includes. */
-#include "nsc_printf.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;
-
- /* This task is going to call secure side functions for
- * printing messages. */
- portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE );
-
- /* 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 )
- {
- /* An error has been detected in one of the tasks. */
- xDelayPeriod = ERROR_CHECK_TASK_PERIOD;
-
- NSC_Printf( "ERROR detected!\r\n" );
-
- /* Increment error detection count. */
- ulCheckTaskLoops++;
- }
- else
- {
- NSC_Printf( "No errors.\r\n" );
- }
- }
-}
-/*-----------------------------------------------------------*/