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