2 ; FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
6 ; ***************************************************************************
8 ; * FreeRTOS tutorial books are available in pdf and paperback. *
9 ; * Complete, revised, and edited pdf reference manuals are also *
12 ; * Purchasing FreeRTOS documentation will not only help you, by *
13 ; * ensuring you get running as quickly as possible and with an *
14 ; * in-depth knowledge of how to use FreeRTOS, it will also help *
15 ; * the FreeRTOS project to continue with its mission of providing *
16 ; * professional grade, cross platform, de facto standard solutions *
17 ; * for microcontrollers - completely free of charge! *
19 ; * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
21 ; * Thank you for using FreeRTOS, and thank you for your support! *
23 ; ***************************************************************************
26 ; This file is part of the FreeRTOS distribution.
28 ; FreeRTOS is free software; you can redistribute it and/or modify it under
29 ; the terms of the GNU General Public License (version 2) as published by the
30 ; Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
31 ; >>>NOTE<<< The modification to the GPL is included to allow you to
32 ; distribute a combined work that includes FreeRTOS without being obliged to
33 ; provide the source code for proprietary components outside of the FreeRTOS
34 ; kernel. FreeRTOS is distributed in the hope that it will be useful, but
35 ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
36 ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
37 ; more details. You should have received a copy of the GNU General Public
38 ; License and the FreeRTOS license exception along with FreeRTOS; if not it
39 ; can be viewed here: http://www.freertos.org/a00114.html and also obtained
40 ; by writing to Richard Barry, contact details for whom are available on the
45 ; http://www.FreeRTOS.org - Documentation, latest information, license and
48 ; http://www.SafeRTOS.com - A version that is certified for use in safety
51 ; http://www.OpenRTOS.com - Commercial support, development, porting,
52 ; licensing and training services.
57 .ref vTaskSwitchContext
58 .ref xTaskIncrementTick
59 .ref ulTaskHasFPUContext
62 ;/*-----------------------------------------------------------*/
66 portSAVE_CONTEXT .macro
69 ; Push R0 as we are going to use it
72 ; Set R0 to point to the task stack pointer.
77 ; Push the return address onto the stack.
80 ; Now LR has been saved, it can be used instead of R0.
83 ; Pop R0 so it can be saved onto the task stack.
86 ; Push all the system mode registers onto the task stack.
90 ; Push the SPSR onto the task stack.
94 .if (__TI_VFP_SUPPORT__)
95 ;Determine if the task maintains an FPU context.
96 LDR R0, ulFPUContextConst
102 ; If the task is not using a floating point context then skip the
103 ; saving of the FPU registers.
105 FSTMDBD LR!, {D0-D15}
113 ; Store the new top of stack for the task.
114 LDR R0, pxCurrentTCBConst
120 ;/*-----------------------------------------------------------*/
122 ; Restore Task Context
124 portRESTORE_CONTEXT .macro
125 LDR R0, pxCurrentTCBConst
129 .if (__TI_VFP_SUPPORT__)
130 ; The floating point context flag is the first thing on the stack.
131 LDR R0, ulFPUContextConst
138 ; If the task is not using a floating point context then skip the
139 ; VFP register loads.
142 ; Restore the floating point context.
144 FLDMIAD LR!, {D0-D15}
148 ; Get the SPSR from the stack.
152 ; Restore all system mode registers for the task.
155 ; Restore the return address.
158 ; And return - correcting the offset in the LR to obtain the
163 ;/*-----------------------------------------------------------*/
164 ; Start the first task by restoring its context.
166 .def vPortStartFirstTask
171 ;/*-----------------------------------------------------------*/
172 ; Yield to another task.
174 .def vPortYieldProcessor
177 ; Within an IRQ ISR the link register has an offset from the true return
178 ; address. SWI doesn't do this. Add the offset manually so the ISR
179 ; return code can be used.
182 ; First save the context of the current task.
185 ; Select the next task to execute. */
186 BL vTaskSwitchContext
188 ; Restore the context of the task selected to execute.
191 ;/*-----------------------------------------------------------*/
192 ; Yield to another task from within the FreeRTOS API
194 .def vPortYeildWithinAPI
197 ; Save the context of the current task.
205 ; Select the next task to execute. */
206 BL vTaskSwitchContext
208 ; Restore the context of the task selected to execute.
211 ;/*-----------------------------------------------------------*/
214 .def vPortPreemptiveTick
218 ; Save the context of the current task.
221 ; Clear interrupt flag
227 ; Increment the tick count, making any adjustments to the blocked lists
228 ; that may be necessary.
229 BL xTaskIncrementTick
231 ; Select the next task to execute.
233 BLNE vTaskSwitchContext
235 ; Restore the context of the task selected to execute.
238 ;-------------------------------------------------------------------------------
240 .if (__TI_VFP_SUPPORT__)
242 .def vPortInitialiseFPSCR
244 vPortInitialiseFPSCR:
250 .endif ;__TI_VFP_SUPPORT__
253 pxCurrentTCBConst .word pxCurrentTCB
254 ulFPUContextConst .word ulTaskHasFPUContext
255 ;-------------------------------------------------------------------------------