2 ; * FreeRTOS Kernel <DEVELOPMENT BRANCH>
\r
3 ; * Copyright (C) 2021 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 ; * https://www.FreeRTOS.org
\r
23 ; * https://github.com/FreeRTOS
\r
29 .ref vTaskSwitchContext
\r
30 .ref xTaskIncrementTick
\r
31 .ref ulTaskHasFPUContext
\r
34 ;/*-----------------------------------------------------------*/
\r
38 portSAVE_CONTEXT .macro
\r
41 ; Push R0 as we are going to use it
\r
44 ; Set R0 to point to the task stack pointer.
\r
49 ; Push the return address onto the stack.
\r
52 ; Now LR has been saved, it can be used instead of R0.
\r
55 ; Pop R0 so it can be saved onto the task stack.
\r
58 ; Push all the system mode registers onto the task stack.
\r
62 ; Push the SPSR onto the task stack.
\r
66 .if (__TI_VFP_SUPPORT__)
\r
67 ;Determine if the task maintains an FPU context.
\r
68 LDR R0, ulFPUContextConst
\r
74 ; If the task is not using a floating point context then skip the
\r
75 ; saving of the FPU registers.
\r
77 FSTMDBD LR!, {D0-D15}
\r
85 ; Store the new top of stack for the task.
\r
86 LDR R0, pxCurrentTCBConst
\r
92 ;/*-----------------------------------------------------------*/
\r
94 ; Restore Task Context
\r
96 portRESTORE_CONTEXT .macro
\r
97 LDR R0, pxCurrentTCBConst
\r
101 .if (__TI_VFP_SUPPORT__)
\r
102 ; The floating point context flag is the first thing on the stack.
\r
103 LDR R0, ulFPUContextConst
\r
110 ; If the task is not using a floating point context then skip the
\r
111 ; VFP register loads.
\r
114 ; Restore the floating point context.
\r
116 FLDMIAD LR!, {D0-D15}
\r
120 ; Get the SPSR from the stack.
\r
124 ; Restore all system mode registers for the task.
\r
125 LDMFD LR, {R0-R14}^
\r
127 ; Restore the return address.
\r
130 ; And return - correcting the offset in the LR to obtain the
\r
135 ;/*-----------------------------------------------------------*/
\r
136 ; Start the first task by restoring its context.
\r
138 .def vPortStartFirstTask
\r
140 vPortStartFirstTask:
\r
141 portRESTORE_CONTEXT
\r
143 ;/*-----------------------------------------------------------*/
\r
144 ; Yield to another task.
\r
146 .def vPortYieldProcessor
\r
148 vPortYieldProcessor:
\r
149 ; Within an IRQ ISR the link register has an offset from the true return
\r
150 ; address. SWI doesn't do this. Add the offset manually so the ISR
\r
151 ; return code can be used.
\r
154 ; First save the context of the current task.
\r
157 ; Select the next task to execute. */
\r
158 BL vTaskSwitchContext
\r
160 ; Restore the context of the task selected to execute.
\r
161 portRESTORE_CONTEXT
\r
163 ;/*-----------------------------------------------------------*/
\r
164 ; Yield to another task from within the FreeRTOS API
\r
166 .def vPortYeildWithinAPI
\r
168 vPortYeildWithinAPI:
\r
169 ; Save the context of the current task.
\r
177 ; Select the next task to execute. */
\r
178 BL vTaskSwitchContext
\r
180 ; Restore the context of the task selected to execute.
\r
181 portRESTORE_CONTEXT
\r
183 ;/*-----------------------------------------------------------*/
\r
186 .def vPortPreemptiveTick
\r
188 vPortPreemptiveTick:
\r
190 ; Save the context of the current task.
\r
193 ; Clear interrupt flag
\r
199 ; Increment the tick count, making any adjustments to the blocked lists
\r
200 ; that may be necessary.
\r
201 BL xTaskIncrementTick
\r
203 ; Select the next task to execute.
\r
205 BLNE vTaskSwitchContext
\r
207 ; Restore the context of the task selected to execute.
\r
208 portRESTORE_CONTEXT
\r
210 ;-------------------------------------------------------------------------------
\r
212 .if (__TI_VFP_SUPPORT__)
\r
214 .def vPortInitialiseFPSCR
\r
216 vPortInitialiseFPSCR:
\r
222 .endif ;__TI_VFP_SUPPORT__
\r
225 pxCurrentTCBConst .word pxCurrentTCB
\r
226 ulFPUContextConst .word ulTaskHasFPUContext
\r
227 ;-------------------------------------------------------------------------------
\r