2 ; * FreeRTOS Kernel <DEVELOPMENT BRANCH>
\r
3 ; * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 ; * SPDX-License-Identifier: MIT
7 ; * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
8 ; * this software and associated documentation files (the "Software"), to deal in
\r
9 ; * the Software without restriction, including without limitation the rights to
\r
10 ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
11 ; * the Software, and to permit persons to whom the Software is furnished to do so,
\r
12 ; * subject to the following conditions:
\r
14 ; * The above copyright notice and this permission notice shall be included in all
\r
15 ; * copies or substantial portions of the Software.
\r
17 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
19 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
20 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
21 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 ; * https://www.FreeRTOS.org
\r
25 ; * https://github.com/FreeRTOS
\r
32 .ref vTaskSwitchContext
\r
33 .ref ulMaxSyscallInterruptPriority
\r
35 .def xPortPendSVHandler
\r
37 .def vPortSVCHandler
\r
38 .def vPortStartFirstTask
\r
41 NVICOffsetConst: .word 0xE000ED08
\r
42 CPACRConst: .word 0xE000ED88
\r
43 pxCurrentTCBConst: .word pxCurrentTCB
\r
44 ulMaxSyscallInterruptPriorityConst: .word ulMaxSyscallInterruptPriority
\r
46 ; -----------------------------------------------------------
\r
49 ulPortGetIPSR: .asmfunc
\r
53 ; -----------------------------------------------------------
\r
56 vPortSetInterruptMask: .asmfunc
\r
58 ldr r0, ulMaxSyscallInterruptPriorityConst
\r
63 ; -----------------------------------------------------------
\r
66 xPortPendSVHandler: .asmfunc
\r
70 ;/* Get the location of the current TCB. */
\r
71 ldr r3, pxCurrentTCBConst
\r
74 ;/* Is the task using the FPU context? If so, push high vfp registers. */
\r
77 vstmdbeq r0!, {s16-s31}
\r
79 ;/* Save the core registers. */
\r
80 stmdb r0!, {r4-r11, r14}
\r
82 ;/* Save the new top of stack into the first member of the TCB. */
\r
86 ldr r0, ulMaxSyscallInterruptPriorityConst
\r
91 bl vTaskSwitchContext
\r
96 ;/* The first item in pxCurrentTCB is the task top of stack. */
\r
100 ;/* Pop the core registers. */
\r
101 ldmia r0!, {r4-r11, r14}
\r
103 ;/* Is the task using the FPU context? If so, pop the high vfp registers
\r
107 vldmiaeq r0!, {s16-s31}
\r
114 ; -----------------------------------------------------------
\r
117 vPortSVCHandler: .asmfunc
\r
118 ;/* Get the location of the current TCB. */
\r
119 ldr r3, pxCurrentTCBConst
\r
122 ;/* Pop the core registers. */
\r
123 ldmia r0!, {r4-r11, r14}
\r
131 ; -----------------------------------------------------------
\r
134 vPortStartFirstTask: .asmfunc
\r
135 ;/* Use the NVIC offset register to locate the stack. */
\r
136 ldr r0, NVICOffsetConst
\r
139 ;/* Set the msp back to the start of the stack. */
\r
141 ;/* Clear the bit that indicates the FPU is in use in case the FPU was used
\r
142 ;before the scheduler was started - which would otherwise result in the
\r
143 ;unnecessary leaving of space in the SVC stack for lazy saving of FPU
\r
147 ;/* Call SVC to start the first task. */
\r
155 ; -----------------------------------------------------------
\r
158 vPortEnableVFP: .asmfunc
\r
159 ;/* The FPU enable bits are in the CPACR. */
\r
160 ldr.w r0, CPACRConst
\r
163 ;/* Enable CP10 and CP11 coprocessors, then save back. */
\r
164 orr r1, r1, #( 0xf << 20 )
\r
171 ; -----------------------------------------------------------
\r