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
75 /* The first item in pxCurrentTCB is the task top of stack. */
79 /* Pop the core registers. */
80 ldmia r0!, {r4-r11, r14}
82 /* Is the task using the FPU context? If so, pop the high vfp registers
86 vldmiaeq r0!, {s16-s31}
90 #ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata */
91 #if WORKAROUND_PMU_CM001 == 1
100 /*-----------------------------------------------------------*/
103 /* Get the location of the current TCB. */
104 ldr r3, =pxCurrentTCB
107 /* Pop the core registers. */
108 ldmia r0!, {r4-r11, r14}
115 /*-----------------------------------------------------------*/
118 /* Use the NVIC offset register to locate the stack. */
122 /* Set the msp back to the start of the stack. */
124 /* Clear the bit that indicates the FPU is in use in case the FPU was used
125 before the scheduler was started - which would otherwise result in the
126 unnecessary leaving of space in the SVC stack for lazy saving of FPU
130 /* Call SVC to start the first task. */
137 /*-----------------------------------------------------------*/
140 /* The FPU enable bits are in the CPACR. */
141 ldr.w r0, =0xE000ED88
144 /* Enable CP10 and CP11 coprocessors, then save back. */
145 orr r1, r1, #( 0xf << 20 )