2 FreeRTOS V6.0.4 - Copyright (C) 2010 Real Time Engineers Ltd.
\r
4 ***************************************************************************
\r
8 * + New to FreeRTOS, *
\r
9 * + Wanting to learn FreeRTOS or multitasking in general quickly *
\r
10 * + Looking for basic training, *
\r
11 * + Wanting to improve your FreeRTOS skills and productivity *
\r
13 * then take a look at the FreeRTOS eBook *
\r
15 * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
\r
16 * http://www.FreeRTOS.org/Documentation *
\r
18 * A pdf reference manual is also available. Both are usually delivered *
\r
19 * to your inbox within 20 minutes to two hours when purchased between 8am *
\r
20 * and 8pm GMT (although please allow up to 24 hours in case of *
\r
21 * exceptional circumstances). Thank you for your support! *
\r
23 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 ***NOTE*** The exception to the GPL is included to allow you to distribute
\r
31 a combined work that includes FreeRTOS without being obliged to provide the
\r
32 source code for proprietary components outside of the FreeRTOS kernel.
\r
33 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
\r
34 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
\r
35 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
54 #include "FreeRTOSConfig.h"
\r
56 .extern pxCurrentTCB
\r
57 .extern vTaskSwitchContext
\r
58 .extern vTaskIncrementTick
\r
59 .extern vPortISRHandler
\r
61 .global vPortStartFirstTask
\r
63 .global vPortTickISR
\r
64 .global vPortISRWrapper
\r
65 .global vPortSaveFPURegisters
\r
66 .global vPortRestoreFPURegisters
\r
69 .set NextLRField, BChainField + 4
\r
70 .set MSRField, NextLRField + 4
\r
71 .set PCField, MSRField + 4
\r
72 .set LRField, PCField + 4
\r
73 .set CTRField, LRField + 4
\r
74 .set XERField, CTRField + 4
\r
75 .set CRField, XERField + 4
\r
76 .set USPRG0Field, CRField + 4
\r
77 .set r0Field, USPRG0Field + 4
\r
78 .set r2Field, r0Field + 4
\r
79 .set r3r31Field, r2Field + 4
\r
80 .set IFrameSize, r3r31Field + ( ( 31 - 3 ) + 1 ) * 4
\r
83 .macro portSAVE_STACK_POINTER_AND_LR
\r
85 /* Get the address of the TCB. */
\r
87 addis R2, R0, pxCurrentTCB@ha
\r
88 lwz R2, pxCurrentTCB@l( R2 )
\r
90 /* Store the stack pointer into the TCB */
\r
93 /* Save the link register */
\r
102 .macro portRESTORE_STACK_POINTER_AND_LR
\r
104 /* Restore the link register */
\r
111 /* Get the address of the TCB. */
\r
113 addis SP, R0, pxCurrentTCB@ha
\r
114 lwz SP, pxCurrentTCB@l( R1 )
\r
116 /* Get the task stack pointer from the TCB. */
\r
122 vPortStartFirstTask:
\r
124 /* Get the address of the TCB. */
\r
126 addis SP, R0, pxCurrentTCB@ha
\r
127 lwz SP, pxCurrentTCB@l( SP )
\r
129 /* Get the task stack pointer from the TCB. */
\r
132 /* Restore MSR register to SRR1. */
\r
133 lwz R0, MSRField(R1)
\r
136 /* Restore current PC location to SRR0. */
\r
137 lwz R0, PCField(R1)
\r
140 /* Save USPRG0 register */
\r
141 lwz R0, USPRG0Field(R1)
\r
144 /* Restore Condition register */
\r
145 lwz R0, CRField(R1)
\r
148 /* Restore Fixed Point Exception register */
\r
149 lwz R0, XERField(R1)
\r
152 /* Restore Counter register */
\r
153 lwz R0, CTRField(R1)
\r
156 /* Restore Link register */
\r
157 lwz R0, LRField(R1)
\r
160 /* Restore remaining GPR registers. */
\r
161 lmw R3,r3r31Field(R1)
\r
163 /* Restore r0 and r2. */
\r
164 lwz R0, r0Field(R1)
\r
165 lwz R2, r2Field(R1)
\r
167 /* Remove frame from stack */
\r
168 addi R1,R1,IFrameSize
\r
170 /* Return into the first task */
\r
177 portSAVE_STACK_POINTER_AND_LR
\r
178 bl vTaskSwitchContext
\r
179 portRESTORE_STACK_POINTER_AND_LR
\r
184 portSAVE_STACK_POINTER_AND_LR
\r
185 bl vTaskIncrementTick
\r
187 #if configUSE_PREEMPTION == 1
\r
188 bl vTaskSwitchContext
\r
191 /* Clear the interrupt */
\r
195 portRESTORE_STACK_POINTER_AND_LR
\r
200 portSAVE_STACK_POINTER_AND_LR
\r
202 portRESTORE_STACK_POINTER_AND_LR
\r
205 #if configUSE_FPU == 1
\r
207 vPortSaveFPURegisters:
\r
209 /* Enable APU and mark FPU as present. */
\r
219 /* Buffer address is in r3. Save each flop register into an offset from
\r
220 this buffer address. */
\r
254 /* Also save the FPSCR. */
\r
260 /* Buffer address is in r3. Save each flop register into an offset from
\r
261 this buffer address. */
\r
295 /* Also save the FPSCR. */
\r
303 #endif /* configUSE_FPU. */
\r
306 #if configUSE_FPU == 1
\r
308 vPortRestoreFPURegisters:
\r
310 /* Enable APU and mark FPU as present. */
\r
320 /* Buffer address is in r3. Restore each flop register from an offset
\r
323 First the FPSCR. */
\r
362 /* Buffer address is in r3. Restore each flop register from an offset
\r
365 First the FPSCR. */
\r
406 #endif /* configUSE_FPU. */
\r