2 ; * FreeRTOS Kernel V10.4.3
3 ; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 ; * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 ; * this software and associated documentation files (the "Software"), to deal in
7 ; * the Software without restriction, including without limitation the rights to
8 ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 ; * the Software, and to permit persons to whom the Software is furnished to do so,
10 ; * subject to the following conditions:
12 ; * The above copyright notice and this permission notice shall be included in all
13 ; * copies or substantial portions of the Software.
15 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 ; * https://www.FreeRTOS.org
23 ; * https://github.com/FreeRTOS
25 ; * 1 tab == 4 spaces!
30 .ref vTaskSwitchContext
31 .ref xTaskIncrementTick
32 .ref ulTaskHasFPUContext
35 ;/*-----------------------------------------------------------*/
39 portSAVE_CONTEXT .macro
42 ; Push R0 as we are going to use it
45 ; Set R0 to point to the task stack pointer.
50 ; Push the return address onto the stack.
53 ; Now LR has been saved, it can be used instead of R0.
56 ; Pop R0 so it can be saved onto the task stack.
59 ; Push all the system mode registers onto the task stack.
63 ; Push the SPSR onto the task stack.
67 .if (__TI_VFP_SUPPORT__)
68 ;Determine if the task maintains an FPU context.
69 LDR R0, ulFPUContextConst
75 ; If the task is not using a floating point context then skip the
76 ; saving of the FPU registers.
86 ; Store the new top of stack for the task.
87 LDR R0, pxCurrentTCBConst
93 ;/*-----------------------------------------------------------*/
95 ; Restore Task Context
97 portRESTORE_CONTEXT .macro
98 LDR R0, pxCurrentTCBConst
102 .if (__TI_VFP_SUPPORT__)
103 ; The floating point context flag is the first thing on the stack.
104 LDR R0, ulFPUContextConst
111 ; If the task is not using a floating point context then skip the
112 ; VFP register loads.
115 ; Restore the floating point context.
117 FLDMIAD LR!, {D0-D15}
121 ; Get the SPSR from the stack.
125 ; Restore all system mode registers for the task.
128 ; Restore the return address.
131 ; And return - correcting the offset in the LR to obtain the
136 ;/*-----------------------------------------------------------*/
137 ; Start the first task by restoring its context.
139 .def vPortStartFirstTask
144 ;/*-----------------------------------------------------------*/
145 ; Yield to another task.
147 .def vPortYieldProcessor
150 ; Within an IRQ ISR the link register has an offset from the true return
151 ; address. SWI doesn't do this. Add the offset manually so the ISR
152 ; return code can be used.
155 ; First save the context of the current task.
158 ; Select the next task to execute. */
159 BL vTaskSwitchContext
161 ; Restore the context of the task selected to execute.
164 ;/*-----------------------------------------------------------*/
165 ; Yield to another task from within the FreeRTOS API
167 .def vPortYeildWithinAPI
170 ; Save the context of the current task.
178 ; Select the next task to execute. */
179 BL vTaskSwitchContext
181 ; Restore the context of the task selected to execute.
184 ;/*-----------------------------------------------------------*/
187 .def vPortPreemptiveTick
191 ; Save the context of the current task.
194 ; Clear interrupt flag
200 ; Increment the tick count, making any adjustments to the blocked lists
201 ; that may be necessary.
202 BL xTaskIncrementTick
204 ; Select the next task to execute.
206 BLNE vTaskSwitchContext
208 ; Restore the context of the task selected to execute.
211 ;-------------------------------------------------------------------------------
213 .if (__TI_VFP_SUPPORT__)
215 .def vPortInitialiseFPSCR
217 vPortInitialiseFPSCR:
223 .endif ;__TI_VFP_SUPPORT__
226 pxCurrentTCBConst .word pxCurrentTCB
227 ulFPUContextConst .word ulTaskHasFPUContext
228 ;-------------------------------------------------------------------------------