2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 * SPDX-License-Identifier: MIT
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * https://www.FreeRTOS.org
25 * https://github.com/FreeRTOS
29 #include <FreeRTOSConfig.h>
35 EXTERN vTaskSwitchContext
37 PUBLIC xPortPendSVHandler
38 PUBLIC vPortSVCHandler
39 PUBLIC vPortStartFirstTask
43 /*-----------------------------------------------------------*/
48 /* Get the location of the current TCB. */
52 /* Is the task using the FPU context? If so, push high vfp registers. */
55 vstmdbeq r0!, {s16-s31}
57 /* Save the core registers. */
58 stmdb r0!, {r4-r11, r14}
60 /* Save the new top of stack into the first member of the TCB. */
64 mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
73 /* The first item in pxCurrentTCB is the task top of stack. */
77 /* Pop the core registers. */
78 ldmia r0!, {r4-r11, r14}
80 /* Is the task using the FPU context? If so, pop the high vfp registers
84 vldmiaeq r0!, {s16-s31}
88 #ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata */
89 #if WORKAROUND_PMU_CM001 == 1
98 /*-----------------------------------------------------------*/
101 /* Get the location of the current TCB. */
102 ldr r3, =pxCurrentTCB
105 /* Pop the core registers. */
106 ldmia r0!, {r4-r11, r14}
113 /*-----------------------------------------------------------*/
116 /* Use the NVIC offset register to locate the stack. */
120 /* Set the msp back to the start of the stack. */
122 /* Clear the bit that indicates the FPU is in use in case the FPU was used
123 before the scheduler was started - which would otherwise result in the
124 unnecessary leaving of space in the SVC stack for lazy saving of FPU
128 /* Call SVC to start the first task. */
135 /*-----------------------------------------------------------*/
138 /* The FPU enable bits are in the CPACR. */
139 ldr.w r0, =0xE000ED88
142 /* Enable CP10 and CP11 coprocessors, then save back. */
143 orr r1, r1, #( 0xf << 20 )