2 ; * FreeRTOS Kernel V10.0.0
\r
3 ; * Copyright (C) 2017 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. If you wish to use our Amazon
\r
14 ; * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 ; * http://www.FreeRTOS.org
\r
24 ; * http://aws.amazon.com/freertos
\r
26 ; * 1 tab == 4 spaces!
\r
31 .ref vTaskSwitchContext
\r
32 .ref xTaskIncrementTick
\r
33 .ref ulTaskHasFPUContext
\r
36 ;/*-----------------------------------------------------------*/
\r
40 portSAVE_CONTEXT .macro
\r
43 ; Push R0 as we are going to use it
\r
46 ; Set R0 to point to the task stack pointer.
\r
51 ; Push the return address onto the stack.
\r
54 ; Now LR has been saved, it can be used instead of R0.
\r
57 ; Pop R0 so it can be saved onto the task stack.
\r
60 ; Push all the system mode registers onto the task stack.
\r
64 ; Push the SPSR onto the task stack.
\r
68 .if (__TI_VFP_SUPPORT__)
\r
69 ;Determine if the task maintains an FPU context.
\r
70 LDR R0, ulFPUContextConst
\r
76 ; If the task is not using a floating point context then skip the
\r
77 ; saving of the FPU registers.
\r
79 FSTMDBD LR!, {D0-D15}
\r
87 ; Store the new top of stack for the task.
\r
88 LDR R0, pxCurrentTCBConst
\r
94 ;/*-----------------------------------------------------------*/
\r
96 ; Restore Task Context
\r
98 portRESTORE_CONTEXT .macro
\r
99 LDR R0, pxCurrentTCBConst
\r
103 .if (__TI_VFP_SUPPORT__)
\r
104 ; The floating point context flag is the first thing on the stack.
\r
105 LDR R0, ulFPUContextConst
\r
112 ; If the task is not using a floating point context then skip the
\r
113 ; VFP register loads.
\r
116 ; Restore the floating point context.
\r
118 FLDMIAD LR!, {D0-D15}
\r
122 ; Get the SPSR from the stack.
\r
126 ; Restore all system mode registers for the task.
\r
127 LDMFD LR, {R0-R14}^
\r
129 ; Restore the return address.
\r
132 ; And return - correcting the offset in the LR to obtain the
\r
137 ;/*-----------------------------------------------------------*/
\r
138 ; Start the first task by restoring its context.
\r
140 .def vPortStartFirstTask
\r
142 vPortStartFirstTask:
\r
143 portRESTORE_CONTEXT
\r
145 ;/*-----------------------------------------------------------*/
\r
146 ; Yield to another task.
\r
148 .def vPortYieldProcessor
\r
150 vPortYieldProcessor:
\r
151 ; Within an IRQ ISR the link register has an offset from the true return
\r
152 ; address. SWI doesn't do this. Add the offset manually so the ISR
\r
153 ; return code can be used.
\r
156 ; First save the context of the current task.
\r
159 ; Select the next task to execute. */
\r
160 BL vTaskSwitchContext
\r
162 ; Restore the context of the task selected to execute.
\r
163 portRESTORE_CONTEXT
\r
165 ;/*-----------------------------------------------------------*/
\r
166 ; Yield to another task from within the FreeRTOS API
\r
168 .def vPortYeildWithinAPI
\r
170 vPortYeildWithinAPI:
\r
171 ; Save the context of the current task.
\r
179 ; Select the next task to execute. */
\r
180 BL vTaskSwitchContext
\r
182 ; Restore the context of the task selected to execute.
\r
183 portRESTORE_CONTEXT
\r
185 ;/*-----------------------------------------------------------*/
\r
188 .def vPortPreemptiveTick
\r
190 vPortPreemptiveTick:
\r
192 ; Save the context of the current task.
\r
195 ; Clear interrupt flag
\r
201 ; Increment the tick count, making any adjustments to the blocked lists
\r
202 ; that may be necessary.
\r
203 BL xTaskIncrementTick
\r
205 ; Select the next task to execute.
\r
207 BLNE vTaskSwitchContext
\r
209 ; Restore the context of the task selected to execute.
\r
210 portRESTORE_CONTEXT
\r
212 ;-------------------------------------------------------------------------------
\r
214 .if (__TI_VFP_SUPPORT__)
\r
216 .def vPortInitialiseFPSCR
\r
218 vPortInitialiseFPSCR:
\r
224 .endif ;__TI_VFP_SUPPORT__
\r
227 pxCurrentTCBConst .word pxCurrentTCB
\r
228 ulFPUContextConst .word ulTaskHasFPUContext
\r
229 ;-------------------------------------------------------------------------------
\r