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