2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\r
13 * Purchasing FreeRTOS documentation will not only help you, by *
\r
14 * ensuring you get running as quickly as possible and with an *
\r
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
16 * the FreeRTOS project to continue with its mission of providing *
\r
17 * professional grade, cross platform, de facto standard solutions *
\r
18 * for microcontrollers - completely free of charge! *
\r
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\r
29 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
30 the terms of the GNU General Public License (version 2) as published by the
\r
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
32 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
69 #include "FreeRTOSConfig.h"
\r
71 .extern pxCurrentTCB
\r
72 .extern vTaskSwitchContext
\r
73 .extern vTaskIncrementTick
\r
74 .extern vPortISRHandler
\r
76 .global vPortStartFirstTask
\r
78 .global vPortTickISR
\r
79 .global vPortISRWrapper
\r
80 .global vPortSaveFPURegisters
\r
81 .global vPortRestoreFPURegisters
\r
84 .set NextLRField, BChainField + 4
\r
85 .set MSRField, NextLRField + 4
\r
86 .set PCField, MSRField + 4
\r
87 .set LRField, PCField + 4
\r
88 .set CTRField, LRField + 4
\r
89 .set XERField, CTRField + 4
\r
90 .set CRField, XERField + 4
\r
91 .set USPRG0Field, CRField + 4
\r
92 .set r0Field, USPRG0Field + 4
\r
93 .set r2Field, r0Field + 4
\r
94 .set r3r31Field, r2Field + 4
\r
95 .set IFrameSize, r3r31Field + ( ( 31 - 3 ) + 1 ) * 4
\r
98 .macro portSAVE_STACK_POINTER_AND_LR
\r
100 /* Get the address of the TCB. */
\r
102 addis R2, R0, pxCurrentTCB@ha
\r
103 lwz R2, pxCurrentTCB@l( R2 )
\r
105 /* Store the stack pointer into the TCB */
\r
108 /* Save the link register */
\r
117 .macro portRESTORE_STACK_POINTER_AND_LR
\r
119 /* Restore the link register */
\r
126 /* Get the address of the TCB. */
\r
128 addis SP, R0, pxCurrentTCB@ha
\r
129 lwz SP, pxCurrentTCB@l( R1 )
\r
131 /* Get the task stack pointer from the TCB. */
\r
137 vPortStartFirstTask:
\r
139 /* Get the address of the TCB. */
\r
141 addis SP, R0, pxCurrentTCB@ha
\r
142 lwz SP, pxCurrentTCB@l( SP )
\r
144 /* Get the task stack pointer from the TCB. */
\r
147 /* Restore MSR register to SRR1. */
\r
148 lwz R0, MSRField(R1)
\r
151 /* Restore current PC location to SRR0. */
\r
152 lwz R0, PCField(R1)
\r
155 /* Save USPRG0 register */
\r
156 lwz R0, USPRG0Field(R1)
\r
159 /* Restore Condition register */
\r
160 lwz R0, CRField(R1)
\r
163 /* Restore Fixed Point Exception register */
\r
164 lwz R0, XERField(R1)
\r
167 /* Restore Counter register */
\r
168 lwz R0, CTRField(R1)
\r
171 /* Restore Link register */
\r
172 lwz R0, LRField(R1)
\r
175 /* Restore remaining GPR registers. */
\r
176 lmw R3,r3r31Field(R1)
\r
178 /* Restore r0 and r2. */
\r
179 lwz R0, r0Field(R1)
\r
180 lwz R2, r2Field(R1)
\r
182 /* Remove frame from stack */
\r
183 addi R1,R1,IFrameSize
\r
185 /* Return into the first task */
\r
192 portSAVE_STACK_POINTER_AND_LR
\r
193 bl vTaskSwitchContext
\r
194 portRESTORE_STACK_POINTER_AND_LR
\r
199 portSAVE_STACK_POINTER_AND_LR
\r
200 bl vTaskIncrementTick
\r
202 #if configUSE_PREEMPTION == 1
\r
203 bl vTaskSwitchContext
\r
206 /* Clear the interrupt */
\r
210 portRESTORE_STACK_POINTER_AND_LR
\r
215 portSAVE_STACK_POINTER_AND_LR
\r
217 portRESTORE_STACK_POINTER_AND_LR
\r
220 #if configUSE_FPU == 1
\r
222 vPortSaveFPURegisters:
\r
224 /* Enable APU and mark FPU as present. */
\r
234 /* Buffer address is in r3. Save each flop register into an offset from
\r
235 this buffer address. */
\r
269 /* Also save the FPSCR. */
\r
275 /* Buffer address is in r3. Save each flop register into an offset from
\r
276 this buffer address. */
\r
310 /* Also save the FPSCR. */
\r
318 #endif /* configUSE_FPU. */
\r
321 #if configUSE_FPU == 1
\r
323 vPortRestoreFPURegisters:
\r
325 /* Enable APU and mark FPU as present. */
\r
335 /* Buffer address is in r3. Restore each flop register from an offset
\r
338 First the FPSCR. */
\r
377 /* Buffer address is in r3. Restore each flop register from an offset
\r
380 First the FPSCR. */
\r
421 #endif /* configUSE_FPU. */
\r