]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/IAR/AVR32_UC3/exception.s82
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Source / portable / IAR / AVR32_UC3 / exception.s82
1 /*This file is prepared for Doxygen automatic documentation generation.*/\r
2 /*! \file *********************************************************************\r
3  *\r
4  * \brief Exception and interrupt vectors.\r
5  *\r
6  * This file maps all events supported by an AVR32UC.\r
7  *\r
8  * - Compiler:           IAR EWAVR32\r
9  * - Supported devices:  All AVR32UC devices with an INTC module can be used.\r
10  * - AppNote:\r
11  *\r
12  * \author               Atmel Corporation: http://www.atmel.com \n\r
13  *                       Support and FAQ: http://support.atmel.no/\r
14  *\r
15  ******************************************************************************/\r
16 \r
17 /* Copyright (c) 2007, Atmel Corporation All rights reserved.\r
18  *\r
19  * Redistribution and use in source and binary forms, with or without\r
20  * modification, are permitted provided that the following conditions are met:\r
21  *\r
22  * 1. Redistributions of source code must retain the above copyright notice,\r
23  * this list of conditions and the following disclaimer.\r
24  *\r
25  * 2. Redistributions in binary form must reproduce the above copyright notice,\r
26  * this list of conditions and the following disclaimer in the documentation\r
27  * and/or other materials provided with the distribution.\r
28  *\r
29  * 3. The name of ATMEL may not be used to endorse or promote products derived\r
30  * from this software without specific prior written permission.\r
31  *\r
32  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED\r
33  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
34  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND\r
35  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,\r
36  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
37  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
38  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\r
39  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
40  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
41  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
42  */\r
43 \r
44 \r
45 #include <avr32/io.h>\r
46 #include "intc.h"\r
47 \r
48 \r
49 //! @{\r
50 //! \verbatim\r
51 \r
52 \r
53 // Start of Exception Vector Table.\r
54 \r
55   // EVBA must be aligned with a power of two strictly greater than the EVBA-\r
56   // relative offset of the last vector.\r
57   COMMON  EVTAB:CODE:ROOT(9)\r
58 \r
59 \r
60   // Force EVBA initialization.\r
61   EXTERN  ??init_EVBA\r
62   REQUIRE ??init_EVBA\r
63 \r
64   // Export symbol.\r
65   PUBLIC  ??EVBA\r
66   PUBLIC  _evba\r
67 ??EVBA:\r
68 _evba:\r
69 \r
70         ORG 0x000\r
71         // Unrecoverable Exception.\r
72 _handle_Unrecoverable_Exception:\r
73         rjmp $\r
74 \r
75         ORG 0x004\r
76         // TLB Multiple Hit: UNUSED IN AVR32UC.\r
77 _handle_TLB_Multiple_Hit:\r
78         rjmp $\r
79 \r
80         ORG 0x008\r
81         // Bus Error Data Fetch.\r
82 _handle_Bus_Error_Data_Fetch:\r
83         rjmp $\r
84 \r
85         ORG 0x00C\r
86          // Bus Error Instruction Fetch.\r
87 _handle_Bus_Error_Instruction_Fetch:\r
88         rjmp $\r
89 \r
90         ORG 0x010\r
91         // NMI.\r
92 _handle_NMI:\r
93         rjmp $\r
94 \r
95         ORG 0x014\r
96         // Instruction Address.\r
97 _handle_Instruction_Address:\r
98         rjmp $\r
99 \r
100         ORG 0x018\r
101         // ITLB Protection.\r
102 _handle_ITLB_Protection:\r
103         rjmp $\r
104 \r
105         ORG 0x01C\r
106         // Breakpoint.\r
107 _handle_Breakpoint:\r
108         rjmp $\r
109 \r
110         ORG 0x020\r
111         // Illegal Opcode.\r
112 _handle_Illegal_Opcode:\r
113         rjmp $\r
114 \r
115         ORG 0x024\r
116         // Unimplemented Instruction.\r
117 _handle_Unimplemented_Instruction:\r
118         rjmp $\r
119 \r
120         ORG 0x028\r
121         // Privilege Violation.\r
122 _handle_Privilege_Violation:\r
123         rjmp $\r
124 \r
125         ORG 0x02C\r
126         // Floating-Point: UNUSED IN AVR32UC.\r
127 _handle_Floating_Point:\r
128         rjmp $\r
129 \r
130         ORG 0x030\r
131         // Coprocessor Absent: UNUSED IN AVR32UC.\r
132 _handle_Coprocessor_Absent:\r
133         rjmp $\r
134 \r
135         ORG 0x034\r
136         // Data Address (Read).\r
137 _handle_Data_Address_Read:\r
138         rjmp $\r
139 \r
140         ORG 0x038\r
141         // Data Address (Write).\r
142 _handle_Data_Address_Write:\r
143         rjmp $\r
144 \r
145         ORG 0x03C\r
146         // DTLB Protection (Read).\r
147 _handle_DTLB_Protection_Read:\r
148         rjmp $\r
149 \r
150         ORG 0x040\r
151         // DTLB Protection (Write).\r
152 _handle_DTLB_Protection_Write:\r
153         rjmp $\r
154 \r
155         ORG 0x044\r
156         // DTLB Modified: UNUSED IN AVR32UC.\r
157 _handle_DTLB_Modified:\r
158         rjmp $\r
159 \r
160         ORG 0x050\r
161         // ITLB Miss: UNUSED IN AVR32UC.\r
162 _handle_ITLB_Miss:\r
163         rjmp $\r
164 \r
165         ORG 0x060\r
166         // DTLB Miss (Read): UNUSED IN AVR32UC.\r
167 _handle_DTLB_Miss_Read:\r
168         rjmp $\r
169 \r
170         ORG 0x070\r
171         // DTLB Miss (Write): UNUSED IN AVR32UC.\r
172 _handle_DTLB_Miss_Write:\r
173         rjmp $\r
174 \r
175         ORG 0x100\r
176         // Supervisor Call.\r
177 _handle_Supervisor_Call:\r
178         lddpc   pc, __SCALLYield\r
179 \r
180 \r
181 // Interrupt support.\r
182 // The interrupt controller must provide the offset address relative to EVBA.\r
183 // Important note:\r
184 //   All interrupts call a C function named _get_interrupt_handler.\r
185 //   This function will read group and interrupt line number to then return in\r
186 //   R12 a pointer to a user-provided interrupt handler.\r
187 \r
188   ALIGN 2\r
189 \r
190 _int0:\r
191   // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the\r
192   // CPU upon interrupt entry.\r
193 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.\r
194   mfsr    r12, AVR32_SR\r
195   bfextu  r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE\r
196   cp.w    r12, 110b\r
197   brlo    _int0_normal\r
198   lddsp   r12, sp[0 * 4]\r
199   stdsp   sp[6 * 4], r12\r
200   lddsp   r12, sp[1 * 4]\r
201   stdsp   sp[7 * 4], r12\r
202   lddsp   r12, sp[3 * 4]\r
203   sub     sp, -6 * 4\r
204   rete\r
205 _int0_normal:\r
206 #endif\r
207   mov     r12, 0  // Pass the int_lev parameter to the _get_interrupt_handler function.\r
208   mcall   __get_interrupt_handler\r
209   cp.w    r12, 0  // Get the pointer to the interrupt handler returned by the function.\r
210   movne   pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.\r
211   rete            // If this was a spurious interrupt (R12 == NULL), return from event handler.\r
212 \r
213 _int1:\r
214   // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the\r
215   // CPU upon interrupt entry.\r
216 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.\r
217   mfsr    r12, AVR32_SR\r
218   bfextu  r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE\r
219   cp.w    r12, 110b\r
220   brlo    _int1_normal\r
221   lddsp   r12, sp[0 * 4]\r
222   stdsp   sp[6 * 4], r12\r
223   lddsp   r12, sp[1 * 4]\r
224   stdsp   sp[7 * 4], r12\r
225   lddsp   r12, sp[3 * 4]\r
226   sub     sp, -6 * 4\r
227   rete\r
228 _int1_normal:\r
229 #endif\r
230   mov     r12, 1  // Pass the int_lev parameter to the _get_interrupt_handler function.\r
231   mcall   __get_interrupt_handler\r
232   cp.w    r12, 0  // Get the pointer to the interrupt handler returned by the function.\r
233   movne   pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.\r
234   rete            // If this was a spurious interrupt (R12 == NULL), return from event handler.\r
235 \r
236 _int2:\r
237   // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the\r
238   // CPU upon interrupt entry.\r
239 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.\r
240   mfsr    r12, AVR32_SR\r
241   bfextu  r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE\r
242   cp.w    r12, 110b\r
243   brlo    _int2_normal\r
244   lddsp   r12, sp[0 * 4]\r
245   stdsp   sp[6 * 4], r12\r
246   lddsp   r12, sp[1 * 4]\r
247   stdsp   sp[7 * 4], r12\r
248   lddsp   r12, sp[3 * 4]\r
249   sub     sp, -6 * 4\r
250   rete\r
251 _int2_normal:\r
252 #endif\r
253   mov     r12, 2  // Pass the int_lev parameter to the _get_interrupt_handler function.\r
254   mcall   __get_interrupt_handler\r
255   cp.w    r12, 0  // Get the pointer to the interrupt handler returned by the function.\r
256   movne   pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.\r
257   rete            // If this was a spurious interrupt (R12 == NULL), return from event handler.\r
258 \r
259 _int3:\r
260   // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the\r
261   // CPU upon interrupt entry.\r
262 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.\r
263   mfsr    r12, AVR32_SR\r
264   bfextu  r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE\r
265   cp.w    r12, 110b\r
266   brlo    _int3_normal\r
267   lddsp   r12, sp[0 * 4]\r
268   stdsp   sp[6 * 4], r12\r
269   lddsp   r12, sp[1 * 4]\r
270   stdsp   sp[7 * 4], r12\r
271   lddsp   r12, sp[3 * 4]\r
272   sub     sp, -6 * 4\r
273   rete\r
274 _int3_normal:\r
275 #endif\r
276   mov     r12, 3  // Pass the int_lev parameter to the _get_interrupt_handler function.\r
277   mcall   __get_interrupt_handler\r
278   cp.w    r12, 0  // Get the pointer to the interrupt handler returned by the function.\r
279   movne   pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.\r
280   rete            // If this was a spurious interrupt (R12 == NULL), return from event handler.\r
281 \r
282 \r
283 // Constant data area.\r
284 \r
285   ALIGN 2\r
286 \r
287   // Import symbols.\r
288   EXTERN  SCALLYield\r
289   EXTERN  _get_interrupt_handler\r
290 __SCALLYield:\r
291   DC32  SCALLYield\r
292 __get_interrupt_handler:\r
293   DC32  _get_interrupt_handler\r
294 \r
295   // Values to store in the interrupt priority registers for the various interrupt priority levels.\r
296   // The interrupt priority registers contain the interrupt priority level and\r
297   // the EVBA-relative interrupt vector offset.\r
298   PUBLIC  ipr_val\r
299 ipr_val:\r
300   DC32  (INT0 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int0 - _evba),\\r
301         (INT1 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int1 - _evba),\\r
302         (INT2 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int2 - _evba),\\r
303         (INT3 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int3 - _evba)\r
304 \r
305 \r
306   END\r
307 \r
308 \r
309 //! \endverbatim\r
310 //! @}\r