2 FreeRTOS.org V4.7.1 - 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
28 Please ensure to read the configuration and relevant port sections of the
\r
29 online documentation.
\r
31 +++ http://www.FreeRTOS.org +++
\r
32 Documentation, latest information, license and contact details.
\r
34 +++ http://www.SafeRTOS.com +++
\r
35 A version that is certified for use in safety critical systems.
\r
37 +++ http://www.OpenRTOS.com +++
\r
38 Commercial support, development, porting, licensing and training services.
\r
40 ***************************************************************************
\r
43 #include <p32xxxx.h>
\r
44 #include <sys/asm.h>
\r
45 #include "ISR_Support.h"
\r
47 #define portEXC_CODE_MASK ( 0x1f << 2 )
\r
52 .extern pxCurrentTCB
\r
53 .extern uxCriticalNesting
\r
54 .extern vTaskSwitchContext
\r
55 .extern vTaskIncrementTick
\r
56 .extern vApplicationGeneralExceptionHandler
\r
57 .extern xISRStackTop
\r
59 .global vPortStartFirstTask
\r
60 .global _general_exception_context
\r
61 .global vT1InterruptHandler
\r
64 /******************************************************************/
\r
66 .section .FreeRTOS, "ax", @progbits
\r
69 .ent vT1InterruptHandler
\r
71 vT1InterruptHandler:
\r
75 jal vTaskIncrementTick
\r
78 /* If we are using the preemptive scheduler then we might want to select
\r
79 a different task to execute. */
\r
80 #if configUSE_PREEMPTION == 1
\r
81 jal vTaskSwitchContext
\r
83 #endif /* configUSE_PREEMPTION */
\r
85 /* Clear timer 0 interrupt. */
\r
87 addiu s0,zero,_IFS0_T1IF_MASK
92 .end vT1InterruptHandler
\r
94 /******************************************************************/
\r
96 .section .FreeRTOS, "ax", @progbits
\r
99 .ent xPortStartScheduler
\r
101 vPortStartFirstTask:
\r
103 /* Simply restore the context of the highest priority task that has been
\r
105 portRESTORE_CONTEXT
\r
107 .end xPortStartScheduler
\r
109 /*******************************************************************/
\r
111 .section .FreeRTOS, "ax", @progbits
\r
114 .ent _general_exception_context
\r
116 _general_exception_context:
\r
118 /* Save the context of the current task. */
\r
121 /* Was this handler caused by a syscall? The original Cause
\r
122 value was saved to the stack as it could change as interrupts
\r
123 nest. Use of k registers must be protected from use by nesting
\r
125 lw s7, portCAUSE_STACK_LOCATION(s5)
\r
126 andi s7, s7, portEXC_CODE_MASK
\r
127 addi s7, s7, -( _EXCCODE_SYS << 2 )
\r
129 /* Yes - call the SYSCALL handler to select a new task to execute. */
\r
130 beq s7, zero, SyscallHandler
\r
133 /* No - call the application handler to handle all other types of
\r
134 exception. Pass the status and cause to the application provided
\r
135 handler. Interrupts are disabled during the execution of the user
\r
136 defined handler. */
\r
138 lw a1, portSTATUS_STACK_LOCATION(s5)
\r
139 lw a0, portCAUSE_STACK_LOCATION(s5)
\r
140 jal vApplicationGeneralExceptionHandler
143 beq zero, zero, FinishExceptionHandler
\r
148 /* Adjust the return that was placed onto the stack to be the
\r
149 address of the instruction following the syscall. s6 already
\r
150 contains the EPC value. */
\r
152 sw s6, portEPC_STACK_LOCATION(s5)
\r
154 jal vTaskSwitchContext
\r
157 FinishExceptionHandler:
\r
158 portRESTORE_CONTEXT
\r
160 .end _general_exception_context
\r