]> begriffs open source - freertos/blob - portable/IAR/ARM_CM33_NTZ/non_secure/portasm.s
FreeRTOS MPU: Remove MPU region number check (#1261)
[freertos] / portable / IAR / ARM_CM33_NTZ / non_secure / portasm.s
1 /*
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>
6  *
7  * SPDX-License-Identifier: MIT
8  *
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:
15  *
16  * The above copyright notice and this permission notice shall be included in all
17  * copies or substantial portions of the Software.
18  *
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.
25  *
26  * https://www.FreeRTOS.org
27  * https://github.com/FreeRTOS
28  *
29  */
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"
36
37 /* System call numbers includes. */
38 #include "mpu_syscall_numbers.h"
39
40 #ifndef configUSE_MPU_WRAPPERS_V1
41     #define configUSE_MPU_WRAPPERS_V1 0
42 #endif
43
44     EXTERN pxCurrentTCB
45     EXTERN vTaskSwitchContext
46     EXTERN vPortSVCHandler_C
47 #if ( ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )
48     EXTERN vSystemCallEnter
49     EXTERN vSystemCallExit
50 #endif
51
52     PUBLIC xIsPrivileged
53     PUBLIC vResetPrivilege
54     PUBLIC vRestoreContextOfFirstTask
55     PUBLIC vRaisePrivilege
56     PUBLIC vStartFirstTask
57     PUBLIC ulSetInterruptMask
58     PUBLIC vClearInterruptMask
59     PUBLIC PendSV_Handler
60     PUBLIC SVC_Handler
61 /*-----------------------------------------------------------*/
62
63 /*---------------- Unprivileged Functions -------------------*/
64
65 /*-----------------------------------------------------------*/
66
67     SECTION .text:CODE:NOROOT(2)
68     THUMB
69 /*-----------------------------------------------------------*/
70
71 xIsPrivileged:
72     mrs r0, control                         /* r0 = CONTROL. */
73     tst r0, #1                              /* Perform r0 & 1 (bitwise AND) and update the conditions flag. */
74     ite ne
75     movne r0, #0                            /* CONTROL[0]!=0. Return false to indicate that the processor is not privileged. */
76     moveq r0, #1                            /* CONTROL[0]==0. Return true to indicate that the processor is not privileged. */
77     bx lr                                   /* Return. */
78 /*-----------------------------------------------------------*/
79
80 vResetPrivilege:
81     mrs r0, control                         /* r0 = CONTROL. */
82     orr r0, r0, #1                          /* r0 = r0 | 1. */
83     msr control, r0                         /* CONTROL = r0. */
84     bx lr                                   /* Return to the caller. */
85 /*-----------------------------------------------------------*/
86
87 /*----------------- Privileged Functions --------------------*/
88
89 /*-----------------------------------------------------------*/
90
91     SECTION privileged_functions:CODE:NOROOT(2)
92     THUMB
93 /*-----------------------------------------------------------*/
94
95 #if ( configENABLE_MPU == 1 )
96
97 vRestoreContextOfFirstTask:
98     program_mpu_first_task:
99         ldr r2, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
100         ldr r0, [r2]                        /* r0 = pxCurrentTCB. */
101
102         dmb                                 /* Complete outstanding transfers before disabling MPU. */
103         ldr r1, =0xe000ed94                 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
104         ldr r2, [r1]                        /* Read the value of MPU_CTRL. */
105         bic r2, #1                          /* r2 = r2 & ~1 i.e. Clear the bit 0 in r2. */
106         str r2, [r1]                        /* Disable MPU. */
107
108         adds r0, #4                         /* r0 = r0 + 4. r0 now points to MAIR0 in TCB. */
109         ldr r1, [r0]                        /* r1 = *r0 i.e. r1 = MAIR0. */
110         ldr r2, =0xe000edc0                 /* r2 = 0xe000edc0 [Location of MAIR0]. */
111         str r1, [r2]                        /* Program MAIR0. */
112
113         adds r0, #4                         /* r0 = r0 + 4. r0 now points to first RBAR in TCB. */
114         ldr r1, =0xe000ed98                 /* r1 = 0xe000ed98 [Location of RNR]. */
115         ldr r2, =0xe000ed9c                 /* r2 = 0xe000ed9c [Location of RBAR]. */
116
117         movs r3, #4                         /* r3 = 4. */
118         str r3, [r1]                        /* Program RNR = 4. */
119         ldmia r0!, {r4-r11}                 /* Read 4 sets of RBAR/RLAR registers from TCB. */
120         stmia r2, {r4-r11}                  /* Write 4 set of RBAR/RLAR registers using alias registers. */
121
122     #if ( configTOTAL_MPU_REGIONS == 16 )
123         movs r3, #8                         /* r3 = 8. */
124         str r3, [r1]                        /* Program RNR = 8. */
125         ldmia r0!, {r4-r11}                 /* Read 4 sets of RBAR/RLAR registers from TCB. */
126         stmia r2, {r4-r11}                  /* Write 4 set of RBAR/RLAR registers using alias registers. */
127         movs r3, #12                        /* r3 = 12. */
128         str r3, [r1]                        /* Program RNR = 12. */
129         ldmia r0!, {r4-r11}                 /* Read 4 sets of RBAR/RLAR registers from TCB. */
130         stmia r2, {r4-r11}                  /* Write 4 set of RBAR/RLAR registers using alias registers. */
131     #endif /* configTOTAL_MPU_REGIONS == 16 */
132
133         ldr r1, =0xe000ed94                 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
134         ldr r2, [r1]                        /* Read the value of MPU_CTRL. */
135         orr r2, #1                          /* r2 = r2 | 1 i.e. Set the bit 0 in r2. */
136         str r2, [r1]                        /* Enable MPU. */
137         dsb                                 /* Force memory writes before continuing. */
138
139     restore_context_first_task:
140         ldr r2, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
141         ldr r0, [r2]                        /* r0 = pxCurrentTCB.*/
142         ldr r1, [r0]                        /* r1 = Location of saved context in TCB. */
143
144     restore_special_regs_first_task:
145     #if ( configENABLE_PAC == 1 )
146         ldmdb r1!, {r2-r5}                  /* Read task's dedicated PAC key from the task's context. */
147         msr  PAC_KEY_P_0, r2                /* Write the task's dedicated PAC key to the PAC key registers. */
148         msr  PAC_KEY_P_1, r3
149         msr  PAC_KEY_P_2, r4
150         msr  PAC_KEY_P_3, r5
151         clrm {r2-r5}                        /* Clear r2-r5. */
152     #endif /* configENABLE_PAC */
153         ldmdb r1!, {r2-r4, lr}              /* r2 = original PSP, r3 = PSPLIM, r4 = CONTROL, LR restored. */
154         msr psp, r2
155         msr psplim, r3
156         msr control, r4
157
158     restore_general_regs_first_task:
159         ldmdb r1!, {r4-r11}                 /* r4-r11 contain hardware saved context. */
160         stmia r2!, {r4-r11}                 /* Copy the hardware saved context on the task stack. */
161         ldmdb r1!, {r4-r11}                 /* r4-r11 restored. */
162
163     restore_context_done_first_task:
164         str r1, [r0]                        /* Save the location where the context should be saved next as the first member of TCB. */
165         mov r0, #0
166         msr basepri, r0                     /* Ensure that interrupts are enabled when the first task starts. */
167         bx lr
168
169 #else /* configENABLE_MPU */
170
171 vRestoreContextOfFirstTask:
172     ldr  r2, =pxCurrentTCB                  /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
173     ldr  r1, [r2]                           /* Read pxCurrentTCB. */
174     ldr  r0, [r1]                           /* Read top of stack from TCB - The first item in pxCurrentTCB is the task top of stack. */
175
176 #if ( configENABLE_PAC == 1 )
177     ldmia r0!, {r1-r4}                      /* Read task's dedicated PAC key from stack. */
178     msr  PAC_KEY_P_3, r1                    /* Write the task's dedicated PAC key to the PAC key registers. */
179     msr  PAC_KEY_P_2, r2
180     msr  PAC_KEY_P_1, r3
181     msr  PAC_KEY_P_0, r4
182     clrm {r1-r4}                            /* Clear r1-r4. */
183 #endif /* configENABLE_PAC */
184
185     ldm  r0!, {r1-r2}                       /* Read from stack - r1 = PSPLIM and r2 = EXC_RETURN. */
186     msr  psplim, r1                         /* Set this task's PSPLIM value. */
187     mrs  r1, control                        /* Obtain current control register value. */
188     orrs r1, r1, #2                         /* r1 = r1 | 0x2 - Set the second bit to use the program stack pointe (PSP). */
189     msr control, r1                         /* Write back the new control register value. */
190     adds r0, #32                            /* Discard everything up to r0. */
191     msr  psp, r0                            /* This is now the new top of stack to use in the task. */
192     isb
193     mov  r0, #0
194     msr  basepri, r0                        /* Ensure that interrupts are enabled when the first task starts. */
195     bx   r2                                 /* Finally, branch to EXC_RETURN. */
196
197 #endif /* configENABLE_MPU */
198 /*-----------------------------------------------------------*/
199
200 vRaisePrivilege:
201     mrs  r0, control                        /* Read the CONTROL register. */
202     bic r0, r0, #1                          /* Clear the bit 0. */
203     msr  control, r0                        /* Write back the new CONTROL value. */
204     bx lr                                   /* Return to the caller. */
205 /*-----------------------------------------------------------*/
206
207 vStartFirstTask:
208     ldr r0, =0xe000ed08                     /* Use the NVIC offset register to locate the stack. */
209     ldr r0, [r0]                            /* Read the VTOR register which gives the address of vector table. */
210     ldr r0, [r0]                            /* The first entry in vector table is stack pointer. */
211     msr msp, r0                             /* Set the MSP back to the start of the stack. */
212     cpsie i                                 /* Globally enable interrupts. */
213     cpsie f
214     dsb
215     isb
216     svc 102                                 /* System call to start the first task. portSVC_START_SCHEDULER = 102. */
217 /*-----------------------------------------------------------*/
218
219 ulSetInterruptMask:
220     mrs r0, basepri                         /* r0 = basepri. Return original basepri value. */
221     mov r1, #configMAX_SYSCALL_INTERRUPT_PRIORITY
222     msr basepri, r1                         /* Disable interrupts up to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
223     dsb
224     isb
225     bx lr                                   /* Return. */
226 /*-----------------------------------------------------------*/
227
228 vClearInterruptMask:
229     msr basepri, r0                         /* basepri = ulMask. */
230     dsb
231     isb
232     bx lr                                   /* Return. */
233 /*-----------------------------------------------------------*/
234
235 #if ( configENABLE_MPU == 1 )
236
237 PendSV_Handler:
238     ldr r2, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
239     ldr r0, [r2]                            /* r0 = pxCurrentTCB. */
240     ldr r1, [r0]                            /* r1 = Location in TCB where the context should be saved. */
241     mrs r2, psp                             /* r2 = PSP. */
242
243     save_general_regs:
244     #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
245         add r2, r2, #0x20                   /* Move r2 to location where s0 is saved. */
246         tst lr, #0x10
247         ittt eq
248         vstmiaeq r1!, {s16-s31}             /* Store s16-s31. */
249         vldmiaeq r2, {s0-s16}               /* Copy hardware saved FP context into s0-s16. */
250         vstmiaeq r1!, {s0-s16}              /* Store hardware saved FP context. */
251         sub r2, r2, #0x20                   /* Set r2 back to the location of hardware saved context. */
252     #endif /* configENABLE_FPU || configENABLE_MVE */
253         stmia r1!, {r4-r11}                 /* Store r4-r11. */
254         ldmia r2, {r4-r11}                  /* Copy the hardware saved context into r4-r11. */
255         stmia r1!, {r4-r11}                 /* Store the hardware saved context. */
256
257     save_special_regs:
258         mrs r3, psplim                      /* r3 = PSPLIM. */
259         mrs r4, control                     /* r4 = CONTROL. */
260         stmia r1!, {r2-r4, lr}              /* Store original PSP (after hardware has saved context), PSPLIM, CONTROL and LR. */
261     #if ( configENABLE_PAC == 1 )
262         mrs  r2, PAC_KEY_P_0                /* Read task's dedicated PAC key from the PAC key registers. */
263         mrs  r3, PAC_KEY_P_1
264         mrs  r4, PAC_KEY_P_2
265         mrs  r5, PAC_KEY_P_3
266         stmia r1!, {r2-r5}                  /* Store the task's dedicated PAC key on the task's context. */
267         clrm {r2-r5}                        /* Clear r2-r5. */
268     #endif /* configENABLE_PAC */
269
270         str r1, [r0]                        /* Save the location from where the context should be restored as the first member of TCB. */
271
272     select_next_task:
273         mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
274         msr basepri, r0                     /* Disable interrupts up to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
275         dsb
276         isb
277         bl vTaskSwitchContext
278         mov r0, #0                          /* r0 = 0. */
279         msr basepri, r0                     /* Enable interrupts. */
280
281     program_mpu:
282         ldr r2, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
283         ldr r0, [r2]                        /* r0 = pxCurrentTCB. */
284
285         dmb                                 /* Complete outstanding transfers before disabling MPU. */
286         ldr r1, =0xe000ed94                 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
287         ldr r2, [r1]                        /* Read the value of MPU_CTRL. */
288         bic r2, #1                          /* r2 = r2 & ~1 i.e. Clear the bit 0 in r2. */
289         str r2, [r1]                        /* Disable MPU. */
290
291         adds r0, #4                         /* r0 = r0 + 4. r0 now points to MAIR0 in TCB. */
292         ldr r1, [r0]                        /* r1 = *r0 i.e. r1 = MAIR0. */
293         ldr r2, =0xe000edc0                 /* r2 = 0xe000edc0 [Location of MAIR0]. */
294         str r1, [r2]                        /* Program MAIR0. */
295
296         adds r0, #4                         /* r0 = r0 + 4. r0 now points to first RBAR in TCB. */
297         ldr r1, =0xe000ed98                 /* r1 = 0xe000ed98 [Location of RNR]. */
298         ldr r2, =0xe000ed9c                 /* r2 = 0xe000ed9c [Location of RBAR]. */
299
300         movs r3, #4                         /* r3 = 4. */
301         str r3, [r1]                        /* Program RNR = 4. */
302         ldmia r0!, {r4-r11}                 /* Read 4 sets of RBAR/RLAR registers from TCB. */
303         stmia r2, {r4-r11}                  /* Write 4 set of RBAR/RLAR registers using alias registers. */
304
305     #if ( configTOTAL_MPU_REGIONS == 16 )
306         movs r3, #8                         /* r3 = 8. */
307         str r3, [r1]                        /* Program RNR = 8. */
308         ldmia r0!, {r4-r11}                 /* Read 4 sets of RBAR/RLAR registers from TCB. */
309         stmia r2, {r4-r11}                  /* Write 4 set of RBAR/RLAR registers using alias registers. */
310         movs r3, #12                        /* r3 = 12. */
311         str r3, [r1]                        /* Program RNR = 12. */
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     #endif /* configTOTAL_MPU_REGIONS == 16 */
315
316         ldr r1, =0xe000ed94                 /* r1 = 0xe000ed94 [Location of MPU_CTRL]. */
317         ldr r2, [r1]                        /* Read the value of MPU_CTRL. */
318         orr r2, #1                          /* r2 = r2 | 1 i.e. Set the bit 0 in r2. */
319         str r2, [r1]                        /* Enable MPU. */
320         dsb                                 /* Force memory writes before continuing. */
321
322     restore_context:
323         ldr r2, =pxCurrentTCB               /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
324         ldr r0, [r2]                        /* r0 = pxCurrentTCB.*/
325         ldr r1, [r0]                        /* r1 = Location of saved context in TCB. */
326
327     restore_special_regs:
328     #if ( configENABLE_PAC == 1 )
329         ldmdb r1!, {r2-r5}                  /* Read task's dedicated PAC key from the task's context. */
330         msr  PAC_KEY_P_0, r2                /* Write the task's dedicated PAC key to the PAC key registers. */
331         msr  PAC_KEY_P_1, r3
332         msr  PAC_KEY_P_2, r4
333         msr  PAC_KEY_P_3, r5
334         clrm {r2-r5}                        /* Clear r2-r5. */
335     #endif /* configENABLE_PAC */
336         ldmdb r1!, {r2-r4, lr}              /* r2 = original PSP, r3 = PSPLIM, r4 = CONTROL, LR restored. */
337         msr psp, r2
338         msr psplim, r3
339         msr control, r4
340
341     restore_general_regs:
342         ldmdb r1!, {r4-r11}                 /* r4-r11 contain hardware saved context. */
343         stmia r2!, {r4-r11}                 /* Copy the hardware saved context on the task stack. */
344         ldmdb r1!, {r4-r11}                 /* r4-r11 restored. */
345     #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
346         tst lr, #0x10
347         ittt eq
348         vldmdbeq r1!, {s0-s16}              /* s0-s16 contain hardware saved FP context. */
349         vstmiaeq r2!, {s0-s16}              /* Copy hardware saved FP context on the task stack. */
350         vldmdbeq r1!, {s16-s31}             /* Restore s16-s31. */
351     #endif /* configENABLE_FPU || configENABLE_MVE */
352
353     restore_context_done:
354         str r1, [r0]                        /* Save the location where the context should be saved next as the first member of TCB. */
355         bx lr
356
357 #else /* configENABLE_MPU */
358
359 PendSV_Handler:
360     mrs r0, psp                             /* Read PSP in r0. */
361 #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
362     tst lr, #0x10                           /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
363     it eq
364     vstmdbeq r0!, {s16-s31}                 /* Store the additional FP context registers which are not saved automatically. */
365 #endif /* configENABLE_FPU || configENABLE_MVE */
366
367     mrs r2, psplim                          /* r2 = PSPLIM. */
368     mov r3, lr                              /* r3 = LR/EXC_RETURN. */
369     stmdb r0!, {r2-r11}                     /* Store on the stack - PSPLIM, LR and registers that are not automatically. */
370
371 #if ( configENABLE_PAC == 1 )
372     mrs  r1, PAC_KEY_P_3                    /* Read task's dedicated PAC key from the PAC key registers. */
373     mrs  r2, PAC_KEY_P_2
374     mrs  r3, PAC_KEY_P_1
375     mrs  r4, PAC_KEY_P_0
376     stmdb r0!, {r1-r4}                      /* Store the task's dedicated PAC key on the stack. */
377     clrm {r1-r4}                            /* Clear r1-r4. */
378 #endif /* configENABLE_PAC */
379
380     ldr r2, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
381     ldr r1, [r2]                            /* Read pxCurrentTCB. */
382     str r0, [r1]                            /* Save the new top of stack in TCB. */
383
384     mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
385     msr basepri, r0                         /* Disable interrupts up to configMAX_SYSCALL_INTERRUPT_PRIORITY. */
386     dsb
387     isb
388     bl vTaskSwitchContext
389     mov r0, #0                              /* r0 = 0. */
390     msr basepri, r0                         /* Enable interrupts. */
391
392     ldr r2, =pxCurrentTCB                   /* Read the location of pxCurrentTCB i.e. &( pxCurrentTCB ). */
393     ldr r1, [r2]                            /* Read pxCurrentTCB. */
394     ldr r0, [r1]                            /* The first item in pxCurrentTCB is the task top of stack. r0 now points to the top of stack. */
395
396 #if ( configENABLE_PAC == 1 )
397     ldmia r0!, {r2-r5}                      /* Read task's dedicated PAC key from stack. */
398     msr  PAC_KEY_P_3, r2                    /* Write the task's dedicated PAC key to the PAC key registers. */
399     msr  PAC_KEY_P_2, r3
400     msr  PAC_KEY_P_1, r4
401     msr  PAC_KEY_P_0, r5
402     clrm {r2-r5}                            /* Clear r2-r5. */
403 #endif /* configENABLE_PAC */
404
405     ldmia r0!, {r2-r11}                     /* Read from stack - r2 = PSPLIM, r3 = LR and r4-r11 restored. */
406
407 #if ( ( configENABLE_FPU == 1 ) || ( configENABLE_MVE == 1 ) )
408     tst r3, #0x10                           /* Test Bit[4] in LR. Bit[4] of EXC_RETURN is 0 if the Extended Stack Frame is in use. */
409     it eq
410     vldmiaeq r0!, {s16-s31}                 /* Restore the additional FP context registers which are not restored automatically. */
411 #endif /* configENABLE_FPU || configENABLE_MVE */
412
413     msr psplim, r2                          /* Restore the PSPLIM register value for the task. */
414     msr psp, r0                             /* Remember the new top of stack for the task. */
415     bx r3
416
417 #endif /* configENABLE_MPU */
418 /*-----------------------------------------------------------*/
419
420 #if ( ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) )
421
422 SVC_Handler:
423     tst lr, #4
424     ite eq
425     mrseq r0, msp
426     mrsne r0, psp
427
428     ldr r1, [r0, #24]
429     ldrb r2, [r1, #-2]
430     cmp r2, #NUM_SYSTEM_CALLS
431     blt syscall_enter
432     cmp r2, #104            /* portSVC_SYSTEM_CALL_EXIT. */
433     beq syscall_exit
434     b vPortSVCHandler_C
435
436     syscall_enter:
437         mov r1, lr
438         b vSystemCallEnter
439
440     syscall_exit:
441         mov r1, lr
442         b vSystemCallExit
443
444 #else /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
445
446 SVC_Handler:
447     tst lr, #4
448     ite eq
449     mrseq r0, msp
450     mrsne r0, psp
451     b vPortSVCHandler_C
452
453 #endif /* ( configENABLE_MPU == 1 ) && ( configUSE_MPU_WRAPPERS_V1 == 0 ) */
454 /*-----------------------------------------------------------*/
455
456     END