2 FreeRTOS.org V4.8.0 - Copyright (C) 2003-2008 Richard Barry.
\r
4 This file is part of the FreeRTOS.org distribution.
\r
6 FreeRTOS.org is free software; you can redistribute it and/or modify
\r
7 it under the terms of the GNU General Public License as published by
\r
8 the Free Software Foundation; either version 2 of the License, or
\r
9 (at your option) any later version.
\r
11 FreeRTOS.org is distributed in the hope that it will be useful,
\r
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 GNU General Public License for more details.
\r
16 You should have received a copy of the GNU General Public License
\r
17 along with FreeRTOS.org; if not, write to the Free Software
\r
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
20 A special exception to the GPL can be applied should you wish to distribute
\r
21 a combined work that includes FreeRTOS.org, without being obliged to provide
\r
22 the source code for any proprietary components. See the licensing section
\r
23 of http://www.FreeRTOS.org for full details of how and when the exception
\r
26 ***************************************************************************
\r
27 ***************************************************************************
\r
29 * SAVE TIME AND MONEY! Why not get us to quote to get FreeRTOS.org *
\r
30 * running on your hardware - or even write all or part of your application*
\r
31 * for you? See http://www.OpenRTOS.com for details. *
\r
33 ***************************************************************************
\r
34 ***************************************************************************
\r
36 Please ensure to read the configuration and relevant port sections of the
\r
37 online documentation.
\r
39 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
42 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
45 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
46 licensing and training services.
\r
49 #include <p32xxxx.h>
\r
50 #include <sys/asm.h>
\r
51 #include "ISR_Support.h"
\r
53 #define portEXC_CODE_MASK ( 0x1f << 2 )
\r
58 .extern pxCurrentTCB
\r
59 .extern uxCriticalNesting
\r
60 .extern vTaskSwitchContext
\r
61 .extern vTaskIncrementTick
\r
62 .extern vApplicationGeneralExceptionHandler
\r
63 .extern xISRStackTop
\r
65 .global vPortStartFirstTask
\r
66 .global _general_exception_context
\r
67 .global vT1InterruptHandler
\r
70 /******************************************************************/
\r
72 .section .FreeRTOS, "ax", @progbits
\r
75 .ent vT1InterruptHandler
\r
77 vT1InterruptHandler:
\r
81 jal vTaskIncrementTick
\r
84 /* If we are using the preemptive scheduler then we might want to select
\r
85 a different task to execute. */
\r
86 #if configUSE_PREEMPTION == 1
\r
87 jal vTaskSwitchContext
\r
89 #endif /* configUSE_PREEMPTION */
\r
91 /* Clear timer 0 interrupt. */
\r
93 addiu s0,zero,_IFS0_T1IF_MASK
\r
98 .end vT1InterruptHandler
\r
100 /******************************************************************/
\r
102 .section .FreeRTOS, "ax", @progbits
\r
105 .ent xPortStartScheduler
\r
107 vPortStartFirstTask:
\r
109 /* Simply restore the context of the highest priority task that has been
\r
111 portRESTORE_CONTEXT
\r
113 .end xPortStartScheduler
\r
115 /*******************************************************************/
\r
117 .section .FreeRTOS, "ax", @progbits
\r
120 .ent _general_exception_context
\r
122 _general_exception_context:
\r
124 /* Save the context of the current task. */
\r
127 /* Was this handler caused by a syscall? The original Cause
\r
128 value was saved to the stack as it could change as interrupts
\r
129 nest. Use of k registers must be protected from use by nesting
\r
131 lw s7, portCAUSE_STACK_LOCATION(s5)
\r
132 andi s7, s7, portEXC_CODE_MASK
\r
133 addi s7, s7, -( _EXCCODE_SYS << 2 )
\r
135 /* Yes - call the SYSCALL handler to select a new task to execute. */
\r
136 beq s7, zero, SyscallHandler
\r
139 /* No - call the application handler to handle all other types of
\r
140 exception. Pass the status and cause to the application provided
\r
141 handler. Interrupts are disabled during the execution of the user
\r
142 defined handler. */
\r
144 lw a1, portSTATUS_STACK_LOCATION(s5)
\r
145 lw a0, portCAUSE_STACK_LOCATION(s5)
\r
146 jal vApplicationGeneralExceptionHandler
\r
149 beq zero, zero, FinishExceptionHandler
\r
154 /* Adjust the return that was placed onto the stack to be the
\r
155 address of the instruction following the syscall. s6 already
\r
156 contains the EPC value. */
\r
158 sw s6, portEPC_STACK_LOCATION(s5)
\r
160 jal vTaskSwitchContext
\r
163 FinishExceptionHandler:
\r
164 portRESTORE_CONTEXT
\r
166 .end _general_exception_context
\r