2 FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 FreeRTOS supports many tools and architectures. V7.0.0 is sponsored by:
\r
6 Atollic AB - Atollic provides professional embedded systems development
\r
7 tools for C/C++ development, code analysis and test automation.
\r
8 See http://www.atollic.com
\r
11 ***************************************************************************
\r
13 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
14 * Complete, revised, and edited pdf reference manuals are also *
\r
17 * Purchasing FreeRTOS documentation will not only help you, by *
\r
18 * ensuring you get running as quickly as possible and with an *
\r
19 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
20 * the FreeRTOS project to continue with its mission of providing *
\r
21 * professional grade, cross platform, de facto standard solutions *
\r
22 * for microcontrollers - completely free of charge! *
\r
24 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
26 * Thank you for using FreeRTOS, and thank you for your support! *
\r
28 ***************************************************************************
\r
31 This file is part of the FreeRTOS distribution.
\r
33 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
34 the terms of the GNU General Public License (version 2) as published by the
\r
35 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
36 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
37 distribute a combined work that includes FreeRTOS without being obliged to
\r
38 provide the source code for proprietary components outside of the FreeRTOS
\r
39 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
40 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
41 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
42 more details. You should have received a copy of the GNU General Public
\r
43 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
44 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
45 by writing to Richard Barry, contact details for whom are available on the
\r
50 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
53 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
56 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
57 licensing and training services.
\r
60 #include "FreeRTOSConfig.h"
\r
62 .extern pxCurrentTCB
\r
63 .extern XIntc_DeviceInterruptHandler
\r
64 .extern vTaskSwitchContext
\r
65 .extern uxCriticalNesting
\r
68 .global _interrupt_handler
\r
69 .global VPortYieldASM
\r
70 .global vPortStartFirstTask
\r
73 .macro portSAVE_CONTEXT
\r
75 /* Make room for the context on the stack. */
\r
78 /* Save r31 so it can then be used as a temporary. */
\r
81 /* Copy the msr into r31 - this is stacked later. */
\r
84 /* Stack general registers. */
\r
114 /* Stack the critical section nesting value. */
\r
115 lwi r3, r0, uxCriticalNesting
\r
118 /* Save the top of stack value to the TCB. */
\r
119 lwi r3, r0, pxCurrentTCB
\r
124 .macro portRESTORE_CONTEXT
\r
126 /* Load the top of stack value from the TCB. */
\r
127 lwi r3, r0, pxCurrentTCB
\r
130 /* Restore the general registers. */
\r
161 /* Reload the rmsr from the stack. */
\r
165 /* Load the critical nesting value. */
\r
167 swi r3, r0, uxCriticalNesting
\r
169 /* Test the critical nesting value. If it is non zero then the task last
\r
170 exited the running state using a yield. If it is zero, then the task
\r
171 last exited the running state through an interrupt. */
\r
173 bnei r3, exit_from_yield
\r
175 /* r3 was being used as a temporary. Now restore its true value from the
\r
179 /* Remove the stack frame. */
\r
182 /* Return using rtid so interrupts are re-enabled as this function is
\r
192 /* This function is used to exit portRESTORE_CONTEXT() if the task being
\r
193 returned to last left the Running state by calling taskYIELD() (rather than
\r
194 being preempted by an interrupt. */
\r
197 /* r3 was being used as a temporary. Now restore its true value from the
\r
201 /* Remove the stack frame. */
\r
204 /* Return to the task. */
\r
209 _interrupt_handler:
\r
216 /* Stack the return address. */
\r
219 /* Switch to the ISR stack. The pulISRStack value has already been set to
\r
220 leave space for the caller function to write back into the stack of this
\r
222 lwi r1, r0, pulISRStack
\r
224 /* The parameter to the interrupt handler. */
\r
225 ori r5, r0, configINTERRUPT_CONTROLLER_TO_USE
\r
227 /* Execute any pending interrupts. */
\r
228 bralid r15, XIntc_DeviceInterruptHandler
\r
231 /* Restore the context of the next task scheduled to execute. */
\r
232 portRESTORE_CONTEXT
\r
242 /* Modify the return address so a return is done to the instruction after
\r
243 the call to VPortYieldASM. */
\r
247 /* Switch to use the ISR stack. */
\r
248 lwi r1, r0, pulISRStack
\r
250 /* Select the next task to execute. */
\r
251 bralid r15, vTaskSwitchContext
\r
254 /* Restore the context of the next task scheduled to execute. */
\r
255 portRESTORE_CONTEXT
\r
257 vPortStartFirstTask:
\r
259 portRESTORE_CONTEXT
\r