]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso/Projects/MCUXpresso/NonSecure/main_ns.c
Delete the Release configuration from the NXP project.
[freertos] / FreeRTOS / Demo / CORTEX_MPU_M33F_NXP_LPC55S69_MCUXpresso / Projects / MCUXpresso / NonSecure / main_ns.c
1 /*\r
2  * FreeRTOS Kernel V10.2.0\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /* FreeRTOS include. */\r
29 #include "FreeRTOS.h"\r
30 #include "task.h"\r
31 \r
32 /* Device includes. */\r
33 #include "fsl_device_registers.h"\r
34 #include "fsl_debug_console.h"\r
35 #include "pin_mux.h"\r
36 #include "board.h"\r
37 #include "clock_config.h"\r
38 \r
39 /* Demo includes. */\r
40 #include "tz_demo.h"\r
41 #include "mpu_demo.h"\r
42 /*-----------------------------------------------------------*/\r
43 \r
44 /**\r
45  * @brief Create all demo tasks.\r
46  */\r
47 static void prvCreateTasks( void );\r
48 \r
49 /**\r
50  * @brief Application-specific implementation of the SystemInit() weak\r
51  * function.\r
52  */\r
53 void SystemInit( void );\r
54 \r
55 /**\r
56  * @brief The mem fault handler.\r
57  *\r
58  * It calls a function called vHandleMemoryFault.\r
59  */\r
60 void MemManage_Handler( void ) __attribute__ ( ( naked ) );\r
61 /*-----------------------------------------------------------*/\r
62 \r
63 /* For instructions on how to build and run this demo, visit the following link:\r
64  * https://www.freertos.org/RTOS-Cortex-M33-LPC55S69-MCUXpresso-GCC.html\r
65  */\r
66 \r
67 /* Non-Secure main. */\r
68 int main( void )\r
69 {\r
70         /* Create tasks. */\r
71         prvCreateTasks();\r
72 \r
73         /* Start scheduler. */\r
74         vTaskStartScheduler();\r
75 \r
76         /* Should not reach here as the scheduler is already started. */\r
77         for( ; ; )\r
78         {\r
79         }\r
80 }\r
81 /*-----------------------------------------------------------*/\r
82 \r
83 static void prvCreateTasks( void )\r
84 {\r
85         /* Create tasks for the MPU Demo. */\r
86         vStartMPUDemo();\r
87 \r
88         /* Create tasks for the TZ Demo. */\r
89         vStartTZDemo();\r
90 \r
91 }\r
92 /*-----------------------------------------------------------*/\r
93 \r
94 void SystemInit( void )\r
95 {\r
96         /* Nothing needs to be initialized for Non-Secure project. */\r
97 }\r
98 /*-----------------------------------------------------------*/\r
99 \r
100 /* Stack overflow hook. */\r
101 void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )\r
102 {\r
103         /* Force an assert. */\r
104         configASSERT( pcTaskName == 0 );\r
105 }\r
106 /*-----------------------------------------------------------*/\r
107 \r
108 /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an\r
109  * implementation of vApplicationGetIdleTaskMemory() to provide the memory that\r
110  * is used by the Idle task. */\r
111 void vApplicationGetIdleTaskMemory(     StaticTask_t ** ppxIdleTaskTCBBuffer,\r
112                                                                         StackType_t ** ppxIdleTaskStackBuffer,\r
113                                                                         uint32_t * pulIdleTaskStackSize )\r
114 {\r
115         /* If the buffers to be provided to the Idle task are declared inside this\r
116          * function then they must be declared static - otherwise they will be\r
117          * allocated on the stack and so not exists after this function exits. */\r
118         static StaticTask_t xIdleTaskTCB;\r
119         static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );\r
120 \r
121         /* Pass out a pointer to the StaticTask_t structure in which the Idle\r
122          * task's state will be stored. */\r
123         *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;\r
124 \r
125         /* Pass out the array that will be used as the Idle task's stack. */\r
126         *ppxIdleTaskStackBuffer = uxIdleTaskStack;\r
127 \r
128         /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.\r
129          * Note that, as the array is necessarily of type StackType_t,\r
130          * configMINIMAL_STACK_SIZE is specified in words, not bytes. */\r
131         *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;\r
132 }\r
133 /*-----------------------------------------------------------*/\r
134 \r
135 /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the\r
136  * application must provide an implementation of vApplicationGetTimerTaskMemory()\r
137  * to provide the memory that is used by the Timer service task. */\r
138 void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,\r
139                                                                          StackType_t ** ppxTimerTaskStackBuffer,\r
140                                                                          uint32_t * pulTimerTaskStackSize )\r
141 {\r
142         /* If the buffers to be provided to the Timer task are declared inside this\r
143          * function then they must be declared static - otherwise they will be\r
144          * allocated on the stack and so not exists after this function exits. */\r
145         static StaticTask_t xTimerTaskTCB;\r
146         static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__( ( aligned( 32 ) ) );\r
147 \r
148         /* Pass out a pointer to the StaticTask_t structure in which the Timer\r
149          * task's state will be stored. */\r
150         *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;\r
151 \r
152         /* Pass out the array that will be used as the Timer task's stack. */\r
153         *ppxTimerTaskStackBuffer = uxTimerTaskStack;\r
154 \r
155         /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.\r
156          * Note that, as the array is necessarily of type StackType_t,\r
157          * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */\r
158         *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
159 }\r
160 /*-----------------------------------------------------------*/\r
161 \r
162 void MemManage_Handler( void )\r
163 {\r
164         __asm volatile\r
165         (\r
166                 " tst lr, #4                                                                            \n"\r
167                 " ite eq                                                                                        \n"\r
168                 " mrseq r0, msp                                                                         \n"\r
169                 " mrsne r0, psp                                                                         \n"\r
170                 " ldr r1, handler_address_const                                         \n"\r
171                 " bx r1                                                                                         \n"\r
172                 "                                                                                                       \n"\r
173                 " handler_address_const: .word vHandleMemoryFault       \n"\r
174         );\r
175 }\r
176 /*-----------------------------------------------------------*/\r