2 * FreeRTOS Kernel V10.2.0
\r
3 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\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
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\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
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
28 /* FreeRTOS include. */
\r
29 #include "FreeRTOS.h"
\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
37 #include "clock_config.h"
\r
39 /* Demo includes. */
\r
40 #include "tz_demo.h"
\r
41 #include "mpu_demo.h"
\r
42 /*-----------------------------------------------------------*/
\r
45 * @brief Create all demo tasks.
\r
47 static void prvCreateTasks( void );
\r
50 * @brief Application-specific implementation of the SystemInit() weak
\r
53 void SystemInit( void );
\r
56 * @brief The mem fault handler.
\r
58 * It calls a function called vHandleMemoryFault.
\r
60 void MemManage_Handler( void ) __attribute__ ( ( naked ) );
\r
61 /*-----------------------------------------------------------*/
\r
63 static void prvCreateTasks( void )
\r
65 /* Create tasks for the MPU Demo. */
\r
68 /* Create tasks for the TZ Demo. */
\r
72 /*-----------------------------------------------------------*/
\r
74 void SystemInit( void )
\r
76 /* Nothing needs to be initialized for Non-Secure project. */
\r
78 /*-----------------------------------------------------------*/
\r
80 /* Stack overflow hook. */
\r
81 void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
\r
83 /* Force an assert. */
\r
84 configASSERT( pcTaskName == 0 );
\r
86 /*-----------------------------------------------------------*/
\r
88 /* Non-Secure main. */
\r
94 /* Start scheduler. */
\r
95 vTaskStartScheduler();
\r
97 /* Should not reach here as the scheduler is already started. */
\r
102 /*-----------------------------------------------------------*/
\r
104 /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
\r
105 * implementation of vApplicationGetIdleTaskMemory() to provide the memory that
\r
106 * is used by the Idle task. */
\r
107 void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
\r
108 StackType_t ** ppxIdleTaskStackBuffer,
\r
109 uint32_t * pulIdleTaskStackSize )
\r
111 /* If the buffers to be provided to the Idle task are declared inside this
\r
112 * function then they must be declared static - otherwise they will be
\r
113 * allocated on the stack and so not exists after this function exits. */
\r
114 static StaticTask_t xIdleTaskTCB;
\r
115 static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
\r
117 /* Pass out a pointer to the StaticTask_t structure in which the Idle
\r
118 * task's state will be stored. */
\r
119 *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
\r
121 /* Pass out the array that will be used as the Idle task's stack. */
\r
122 *ppxIdleTaskStackBuffer = uxIdleTaskStack;
\r
124 /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
\r
125 * Note that, as the array is necessarily of type StackType_t,
\r
126 * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
\r
127 *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
\r
129 /*-----------------------------------------------------------*/
\r
131 /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
\r
132 * application must provide an implementation of vApplicationGetTimerTaskMemory()
\r
133 * to provide the memory that is used by the Timer service task. */
\r
134 void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
\r
135 StackType_t ** ppxTimerTaskStackBuffer,
\r
136 uint32_t * pulTimerTaskStackSize )
\r
138 /* If the buffers to be provided to the Timer task are declared inside this
\r
139 * function then they must be declared static - otherwise they will be
\r
140 * allocated on the stack and so not exists after this function exits. */
\r
141 static StaticTask_t xTimerTaskTCB;
\r
142 static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ] __attribute__( ( aligned( 32 ) ) );
\r
144 /* Pass out a pointer to the StaticTask_t structure in which the Timer
\r
145 * task's state will be stored. */
\r
146 *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
\r
148 /* Pass out the array that will be used as the Timer task's stack. */
\r
149 *ppxTimerTaskStackBuffer = uxTimerTaskStack;
\r
151 /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
\r
152 * Note that, as the array is necessarily of type StackType_t,
\r
153 * configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
\r
154 *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
\r
156 /*-----------------------------------------------------------*/
\r
158 void MemManage_Handler( void )
\r
164 " mrseq r0, msp \n"
\r
165 " mrsne r0, psp \n"
\r
166 " ldr r1, handler_address_const \n"
\r
169 " handler_address_const: .word vHandleMemoryFault \n"
\r
172 /*-----------------------------------------------------------*/
\r