2 ; * FreeRTOS Kernel V11.2.0
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
31 .ref vTaskSwitchContext
32 .ref xTaskIncrementTick
33 .ref ulTaskHasFPUContext
36 ;/*-----------------------------------------------------------*/
40 portSAVE_CONTEXT .macro
43 ; Push R0 as we are going to use it
46 ; Set R0 to point to the task stack pointer.
51 ; Push the return address onto the stack.
54 ; Now LR has been saved, it can be used instead of R0.
57 ; Pop R0 so it can be saved onto the task stack.
60 ; Push all the system mode registers onto the task stack.
64 ; Push the SPSR onto the task stack.
68 .if (__TI_VFP_SUPPORT__)
69 ;Determine if the task maintains an FPU context.
70 LDR R0, ulFPUContextConst
76 ; If the task is not using a floating point context then skip the
77 ; saving of the FPU registers.
87 ; Store the new top of stack for the task.
88 LDR R0, pxCurrentTCBConst
94 ;/*-----------------------------------------------------------*/
96 ; Restore Task Context
98 portRESTORE_CONTEXT .macro
99 LDR R0, pxCurrentTCBConst
103 .if (__TI_VFP_SUPPORT__)
104 ; The floating point context flag is the first thing on the stack.
105 LDR R0, ulFPUContextConst
112 ; If the task is not using a floating point context then skip the
113 ; VFP register loads.
116 ; Restore the floating point context.
118 FLDMIAD LR!, {D0-D15}
122 ; Get the SPSR from the stack.
126 ; Restore all system mode registers for the task.
129 ; Restore the return address.
132 ; And return - correcting the offset in the LR to obtain the
137 ;/*-----------------------------------------------------------*/
138 ; Start the first task by restoring its context.
140 .def vPortStartFirstTask
145 ;/*-----------------------------------------------------------*/
146 ; Yield to another task.
148 .def vPortYieldProcessor
151 ; Within an IRQ ISR the link register has an offset from the true return
152 ; address. SWI doesn't do this. Add the offset manually so the ISR
153 ; return code can be used.
156 ; First save the context of the current task.
159 ; Select the next task to execute. */
160 BL vTaskSwitchContext
162 ; Restore the context of the task selected to execute.
165 ;/*-----------------------------------------------------------*/
166 ; Yield to another task from within the FreeRTOS API
168 .def vPortYeildWithinAPI
171 ; Save the context of the current task.
179 ; Select the next task to execute. */
180 BL vTaskSwitchContext
182 ; Restore the context of the task selected to execute.
185 ;/*-----------------------------------------------------------*/
188 .def vPortPreemptiveTick
192 ; Save the context of the current task.
195 ; Clear interrupt flag
201 ; Increment the tick count, making any adjustments to the blocked lists
202 ; that may be necessary.
203 BL xTaskIncrementTick
205 ; Select the next task to execute.
207 BLNE vTaskSwitchContext
209 ; Restore the context of the task selected to execute.
212 ;-------------------------------------------------------------------------------
214 .if (__TI_VFP_SUPPORT__)
216 .def vPortInitialiseFPSCR
218 vPortInitialiseFPSCR:
224 .endif ;__TI_VFP_SUPPORT__
227 pxCurrentTCBConst .word pxCurrentTCB
228 ulFPUContextConst .word ulTaskHasFPUContext
229 ;-------------------------------------------------------------------------------