2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 * Copyright 2024 Arm Limited and/or its affiliates
5 * <open-source-office@arm.com>
7 * SPDX-License-Identifier: MIT
9 * Permission is hereby granted, free of charge, to any person obtaining a copy of
10 * this software and associated documentation files (the "Software"), to deal in
11 * the Software without restriction, including without limitation the rights to
12 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
13 * the Software, and to permit persons to whom the Software is furnished to do so,
14 * subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in all
17 * copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
21 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
22 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * https://www.FreeRTOS.org
27 * https://github.com/FreeRTOS
30 /* Including FreeRTOSConfig.h here will cause build errors if the header file
31 contains code not understood by the assembler - for example the 'extern' keyword.
32 To avoid errors place any such code inside a #ifdef __ICCARM__/#endif block so
33 the code is included in C files but excluded by the preprocessor in assembly
34 files (__ICCARM__ is defined by the IAR C compiler but not by the IAR assembler. */
35 #include "FreeRTOSConfig.h"
37 /* System call numbers includes. */
38 #include "mpu_syscall_numbers.h"
40 #ifndef configUSE_MPU_WRAPPERS_V1
41 #define configUSE_MPU_WRAPPERS_V1 0
46 EXTERN vTaskSwitchContext
47 EXTERN vPortSVCHandler_C
48 EXTERN SecureContext_SaveContext
49 EXTERN SecureContext_LoadContext
50 #if ( ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )
51 EXTERN vSystemCallEnter
52 EXTERN vSystemCallExit
56 PUBLIC vResetPrivilege
57 PUBLIC vPortAllocateSecureContext
58 PUBLIC vRestoreContextOfFirstTask
59 PUBLIC vRaisePrivilege
60 PUBLIC vStartFirstTask
61 PUBLIC ulSetInterruptMask
62 PUBLIC vClearInterruptMask
65 PUBLIC vPortFreeSecureContext
66 /*-----------------------------------------------------------*/
68 /*---------------- Unprivileged Functions -------------------*/
70 /*-----------------------------------------------------------*/
72 SECTION .text:CODE:NOROOT(2)
74 /*-----------------------------------------------------------*/
77 mrs r0, control /* r0 = CONTROL. */
78 tst r0, #1 /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */
80 movne r0, #0 /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */
81 moveq r0, #1 /* CONTROL[0]==0. Return true to indicate that the processor is not privileged. */
83 /*-----------------------------------------------------------*/
86 mrs r0, control /* r0 = CONTROL. */
87 orr r0, r0, #1 /* r0 = r0 | 1. */
88 msr control, r0 /* CONTROL = r0. */
89 bx lr /* Return to the caller. */
90 /*-----------------------------------------------------------*/
92 vPortAllocateSecureContext:
93 svc 100 /* Secure context is allocated in the supervisor call. portSVC_ALLOCATE_SECURE_CONTEXT = 100. */
95 /*-----------------------------------------------------------*/
97 /*----------------- Privileged Functions --------------------*/
99 /*-----------------------------------------------------------*/
101 SECTION privileged_functions:CODE:NOROOT(2)
103 /*-----------------------------------------------------------*/
105 #if ( configENABLE_MPU == 1 )
107 vRestoreContextOfFirstTask:
108 program_mpu_first_task:
109 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
110 ldr r0, [r3] /* r0 = pxCurrentTCB. */
112 dmb /* Complete outstanding transfers before disabling MPU. */
113 ldr r1, =0xe000ed94 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
114 ldr r2, [r1] /* Read the value of MPU_CTRL. */
115 bic r2, #1 /* r2 = r2 & ~1 i.e. Clear the bit 0 in r2. */
116 str r2, [r1] /* Disable MPU. */
118 adds r0, #4 /* r0 = r0 + 4. r0 now points to MAIR0 in TCB. */
119 ldr r1, [r0] /* r1 = *r0 i.e. r1 = MAIR0. */
120 ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */
121 str r1, [r2] /* Program MAIR0. */
123 adds r0, #4 /* r0 = r0 + 4. r0 now points to first RBAR in TCB. */
124 ldr r1, =0xe000ed98 /* r1 = 0xe000ed98 [Location of RNR]. */
125 ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */
127 movs r3, #4 /* r3 = 4. */
128 str r3, [r1] /* Program RNR = 4. */
129 ldmia r0!, {r4-r11} /* Read 4 set of RBAR/RLAR registers from TCB. */
130 stmia r2, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */
132 #if ( configTOTAL_MPU_REGIONS == 16 )
133 movs r3, #8 /* r3 = 8. */
134 str r3, [r1] /* Program RNR = 8. */
135 ldmia r0!, {r4-r11} /* Read 4 set of RBAR/RLAR registers from TCB. */
136 stmia r2, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */
137 movs r3, #12 /* r3 = 12. */
138 str r3, [r1] /* Program RNR = 12. */
139 ldmia r0!, {r4-r11} /* Read 4 set of RBAR/RLAR registers from TCB. */
140 stmia r2, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */
141 #endif /* configTOTAL_MPU_REGIONS == 16 */
143 ldr r1, =0xe000ed94 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
144 ldr r2, [r1] /* Read the value of MPU_CTRL. */
145 orr r2, #1 /* r2 = r1 | 1 i.e. Set the bit 0 in r2. */
146 str r2, [r1] /* Enable MPU. */
147 dsb /* Force memory writes before continuing. */
149 restore_context_first_task:
150 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
151 ldr r1, [r3] /* r1 = pxCurrentTCB.*/
152 ldr r2, [r1] /* r2 = Location of saved context in TCB. */
154 restore_special_regs_first_task:
155 ldmdb r2!, {r0, r3-r5, lr} /* r0 = xSecureContext, r3 = original PSP, r4 = PSPLIM, r5 = CONTROL, LR restored. */
159 ldr r4, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */
160 str r0, [r4] /* Restore xSecureContext. */
162 restore_general_regs_first_task:
163 ldmdb r2!, {r4-r11} /* r4-r11 contain hardware saved context. */
164 stmia r3!, {r4-r11} /* Copy the hardware saved context on the task stack. */
165 ldmdb r2!, {r4-r11} /* r4-r11 restored. */
167 restore_context_done_first_task:
168 str r2, [r1] /* Save the location where the context should be saved next as the first member of TCB. */
170 msr basepri, r0 /* Ensure that interrupts are enabled when the first task starts. */
173 #else /* configENABLE_MPU */
175 vRestoreContextOfFirstTask:
176 ldr r2, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
177 ldr r3, [r2] /* Read pxCurrentTCB. */
178 ldr r0, [r3] /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */
180 ldm r0!, {r1-r3} /* Read from stack - r1 = xSecureContext, r2 = PSPLIM and r3 = EXC_RETURN. */
181 ldr r4, =xSecureContext
182 str r1, [r4] /* Set xSecureContext to this task's value for the same. */
183 msr psplim, r2 /* Set this task's PSPLIM value. */
184 mrs r1, control /* Obtain current control register value. */
185 orrs r1, r1, #2 /* r1 = r1 | 0x2 - Set the second bit to use the program stack pointe (PSP). */
186 msr control, r1 /* Write back the new control register value. */
187 adds r0, #32 /* Discard everything up to r0. */
188 msr psp, r0 /* This is now the new top of stack to use in the task. */
191 msr basepri, r0 /* Ensure that interrupts are enabled when the first task starts. */
192 bx r3 /* Finally, branch to EXC_RETURN. */
194 #endif /* configENABLE_MPU */
195 /*-----------------------------------------------------------*/
198 mrs r0, control /* Read the CONTROL register. */
199 bic r0, r0, #1 /* Clear the bit 0. */
200 msr control, r0 /* Write back the new CONTROL value. */
201 bx lr /* Return to the caller. */
202 /*-----------------------------------------------------------*/
205 ldr r0, =0xe000ed08 /* Use the NVIC offset register to locate the stack. */
206 ldr r0, [r0] /* Read the VTOR register which gives the address of vector table. */
207 ldr r0, [r0] /* The first entry in vector table is stack pointer. */
208 msr msp, r0 /* Set the MSP back to the start of the stack. */
209 cpsie i /* Globally enable interrupts. */
213 svc 102 /* System call to start the first task. portSVC_START_SCHEDULER = 102. */
214 /*-----------------------------------------------------------*/
217 mrs r0, basepri /* r0 = basepri. Return original basepri value. */
218 mov r1, #configMAX_SYSCALL_INTERRUPT_PRIORITY
219 msr basepri, r1 /* Disable interrupts up to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
223 /*-----------------------------------------------------------*/
226 msr basepri, r0 /* basepri = ulMask. */
230 /*-----------------------------------------------------------*/
232 #if ( configENABLE_MPU == 1 )
235 ldr r3, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */
236 ldr r0, [r3] /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */
237 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
238 ldr r1, [r3] /* Read pxCurrentTCB - Value of pxCurrentTCB must be in r1 as it is used as a parameter later. */
239 ldr r2, [r1] /* r2 = Location in TCB where the context should be saved. */
241 cbz r0, save_ns_context /* No secure context to save. */
244 bl SecureContext_SaveContext /* Params are in r0 and r1. r0 = xSecureContext and r1 = pxCurrentTCB. */
248 mov r3, lr /* r3 = LR (EXC_RETURN). */
249 lsls r3, r3, #25 /* r3 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
250 bmi save_special_regs /* r3 < 0 ==> Bit[6] in EXC_RETURN is 1 ==> secure stack was used to store the stack frame. */
255 #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
256 add r3, r3, #0x20 /* Move r3 to location where s0 is saved. */
259 vstmiaeq r2!, {s16-s31} /* Store s16-s31. */
260 vldmiaeq r3, {s0-s16} /* Copy hardware saved FP context into s0-s16. */
261 vstmiaeq r2!, {s0-s16} /* Store hardware saved FP context. */
262 sub r3, r3, #0x20 /* Set r3 back to the location of hardware saved context. */
263 #endif /* configENABLE_FPU || configENABLE_MVE */
265 stmia r2!, {r4-r11} /* Store r4-r11. */
266 ldmia r3, {r4-r11} /* Copy the hardware saved context into r4-r11. */
267 stmia r2!, {r4-r11} /* Store the hardware saved context. */
270 mrs r3, psp /* r3 = PSP. */
271 mrs r4, psplim /* r4 = PSPLIM. */
272 mrs r5, control /* r5 = CONTROL. */
273 stmia r2!, {r0, r3-r5, lr} /* Store xSecureContext, original PSP (after hardware has saved context), PSPLIM, CONTROL and LR. */
274 str r2, [r1] /* Save the location from where the context should be restored as the first member of TCB. */
277 mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
278 msr basepri, r0 /* Disable interrupts up to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
281 bl vTaskSwitchContext
282 mov r0, #0 /* r0 = 0. */
283 msr basepri, r0 /* Enable interrupts. */
286 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
287 ldr r0, [r3] /* r0 = pxCurrentTCB.*/
289 dmb /* Complete outstanding transfers before disabling MPU. */
290 ldr r1, =0xe000ed94 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
291 ldr r2, [r1] /* Read the value of MPU_CTRL. */
292 bic r2, #1 /* r2 = r2 & ~1 i.e. Clear the bit 0 in r2. */
293 str r2, [r1] /* Disable MPU. */
295 adds r0, #4 /* r0 = r0 + 4. r0 now points to MAIR0 in TCB. */
296 ldr r1, [r0] /* r1 = *r0 i.e. r1 = MAIR0. */
297 ldr r2, =0xe000edc0 /* r2 = 0xe000edc0 [Location of MAIR0]. */
298 str r1, [r2] /* Program MAIR0. */
300 adds r0, #4 /* r0 = r0 + 4. r0 now points to first RBAR in TCB. */
301 ldr r1, =0xe000ed98 /* r1 = 0xe000ed98 [Location of RNR]. */
302 ldr r2, =0xe000ed9c /* r2 = 0xe000ed9c [Location of RBAR]. */
304 movs r3, #4 /* r3 = 4. */
305 str r3, [r1] /* Program RNR = 4. */
306 ldmia r0!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */
307 stmia r2, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */
309 #if ( configTOTAL_MPU_REGIONS == 16 )
310 movs r3, #8 /* r3 = 8. */
311 str r3, [r1] /* Program RNR = 8. */
312 ldmia r0!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */
313 stmia r2, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */
314 movs r3, #12 /* r3 = 12. */
315 str r3, [r1] /* Program RNR = 12. */
316 ldmia r0!, {r4-r11} /* Read 4 sets of RBAR/RLAR registers from TCB. */
317 stmia r2, {r4-r11} /* Write 4 set of RBAR/RLAR registers using alias registers. */
318 #endif /* configTOTAL_MPU_REGIONS == 16 */
320 ldr r1, =0xe000ed94 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
321 ldr r2, [r1] /* Read the value of MPU_CTRL. */
322 orr r2, #1 /* r2 = r2 | 1 i.e. Set the bit 0 in r2. */
323 str r2, [r1] /* Enable MPU. */
324 dsb /* Force memory writes before continuing. */
327 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
328 ldr r1, [r3] /* r1 = pxCurrentTCB.*/
329 ldr r2, [r1] /* r2 = Location of saved context in TCB. */
331 restore_special_regs:
332 ldmdb r2!, {r0, r3-r5, lr} /* r0 = xSecureContext, r3 = original PSP, r4 = PSPLIM, r5 = CONTROL, LR restored. */
336 ldr r4, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */
337 str r0, [r4] /* Restore xSecureContext. */
338 cbz r0, restore_ns_context /* No secure context to restore. */
342 bl SecureContext_LoadContext /* Params are in r0 and r1. r0 = xSecureContext and r1 = pxCurrentTCB. */
346 mov r0, lr /* r0 = LR (EXC_RETURN). */
347 lsls r0, r0, #25 /* r0 = r0 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
348 bmi restore_context_done /* r0 < 0 ==> Bit[6] in EXC_RETURN is 1 ==> secure stack was used to store the stack frame. */
350 restore_general_regs:
351 ldmdb r2!, {r4-r11} /* r4-r11 contain hardware saved context. */
352 stmia r3!, {r4-r11} /* Copy the hardware saved context on the task stack. */
353 ldmdb r2!, {r4-r11} /* r4-r11 restored. */
355 #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
358 vldmdbeq r2!, {s0-s16} /* s0-s16 contain hardware saved FP context. */
359 vstmiaeq r3!, {s0-s16} /* Copy hardware saved FP context on the task stack. */
360 vldmdbeq r2!, {s16-s31} /* Restore s16-s31. */
361 #endif /* configENABLE_FPU || configENABLE_MVE */
363 restore_context_done:
364 str r2, [r1] /* Save the location where the context should be saved next as the first member of TCB. */
367 #else /* configENABLE_MPU */
370 ldr r3, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */
371 ldr r0, [r3] /* Read xSecureContext - Value of xSecureContext must be in r0 as it is used as a parameter later. */
372 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
373 ldr r1, [r3] /* Read pxCurrentTCB - Value of pxCurrentTCB must be in r1 as it is used as a parameter later. */
374 mrs r2, psp /* Read PSP in r2. */
376 cbz r0, save_ns_context /* No secure context to save. */
378 bl SecureContext_SaveContext /* Params are in r0 and r1. r0 = xSecureContext and r1 = pxCurrentTCB. */
379 pop {r0-r3} /* LR is now in r3. */
380 mov lr, r3 /* LR = r3. */
381 lsls r1, r3, #25 /* r1 = r3 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
382 bpl save_ns_context /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
384 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
385 ldr r1, [r3] /* Read pxCurrentTCB. */
386 subs r2, r2, #12 /* Make space for xSecureContext, PSPLIM and LR on the stack. */
387 str r2, [r1] /* Save the new top of stack in TCB. */
388 mrs r1, psplim /* r1 = PSPLIM. */
389 mov r3, lr /* r3 = LR/EXC_RETURN. */
390 stmia r2!, {r0, r1, r3} /* Store xSecureContext, PSPLIM and LR on the stack. */
394 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
395 ldr r1, [r3] /* Read pxCurrentTCB. */
396 #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
397 tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
399 vstmdbeq r2!, {s16-s31} /* Store the additional FP context registers which are not saved automatically. */
400 #endif /* configENABLE_FPU || configENABLE_MVE */
401 subs r2, r2, #44 /* Make space for xSecureContext, PSPLIM, LR and the remaining registers on the stack. */
402 str r2, [r1] /* Save the new top of stack in TCB. */
403 adds r2, r2, #12 /* r2 = r2 + 12. */
404 stm r2, {r4-r11} /* Store the registers that are not saved automatically. */
405 mrs r1, psplim /* r1 = PSPLIM. */
406 mov r3, lr /* r3 = LR/EXC_RETURN. */
407 subs r2, r2, #12 /* r2 = r2 - 12. */
408 stmia r2!, {r0, r1, r3} /* Store xSecureContext, PSPLIM and LR on the stack. */
411 mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
412 msr basepri, r0 /* Disable interrupts up to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
415 bl vTaskSwitchContext
416 mov r0, #0 /* r0 = 0. */
417 msr basepri, r0 /* Enable interrupts. */
419 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
420 ldr r1, [r3] /* Read pxCurrentTCB. */
421 ldr r2, [r1] /* The first item in pxCurrentTCB is the task top of stack. r2 now points to the top of stack. */
423 ldmia r2!, {r0, r1, r4} /* Read from stack - r0 = xSecureContext, r1 = PSPLIM and r4 = LR. */
424 msr psplim, r1 /* Restore the PSPLIM register value for the task. */
425 mov lr, r4 /* LR = r4. */
426 ldr r3, =xSecureContext /* Read the location of xSecureContext i.e. &( xSecureContext ). */
427 str r0, [r3] /* Restore the task's xSecureContext. */
428 cbz r0, restore_ns_context /* If there is no secure context for the task, restore the non-secure context. */
429 ldr r3, =pxCurrentTCB /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
430 ldr r1, [r3] /* Read pxCurrentTCB. */
432 bl SecureContext_LoadContext /* Restore the secure context. Params are in r0 and r1. r0 = xSecureContext and r1 = pxCurrentTCB. */
434 mov lr, r4 /* LR = r4. */
435 lsls r1, r4, #25 /* r1 = r4 << 25. Bit[6] of EXC_RETURN is 1 if secure stack was used, 0 if non-secure stack was used to store stack frame. */
436 bpl restore_ns_context /* bpl - branch if positive or zero. If r1 >= 0 ==> Bit[6] in EXC_RETURN is 0 i.e. non-secure stack was used. */
437 msr psp, r2 /* Remember the new top of stack for the task. */
441 ldmia r2!, {r4-r11} /* Restore the registers that are not automatically restored. */
442 #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
443 tst lr, #0x10 /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
445 vldmiaeq r2!, {s16-s31} /* Restore the additional FP context registers which are not restored automatically. */
446 #endif /* configENABLE_FPU || configENABLE_MVE */
447 msr psp, r2 /* Remember the new top of stack for the task. */
450 #endif /* configENABLE_MPU */
451 /*-----------------------------------------------------------*/
453 #if ( ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )
463 cmp r2, #NUM_SYSTEM_CALLS
465 cmp r2, #104 /* portSVC_SYSTEM_CALL_EXIT. */
477 #else /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
486 #endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
487 /*-----------------------------------------------------------*/
489 vPortFreeSecureContext:
490 /* r0 = uint32_t *pulTCB. */
491 ldr r2, [r0] /* The first item in the TCB is the top of the stack. */
492 ldr r1, [r2] /* The first item on the stack is the task's xSecureContext. */
493 cmp r1, #0 /* Raise svc if task's xSecureContext is not NULL. */
495 svcne 101 /* Secure context is freed in the supervisor call. portSVC_FREE_SECURE_CONTEXT = 101. */
497 /*-----------------------------------------------------------*/