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