00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00017 /* Copyright (c) 2009 Atmel Corporation. All rights reserved. 00018 * 00019 * Redistribution and use in source and binary forms, with or without 00020 * modification, are permitted provided that the following conditions are met: 00021 * 00022 * 1. Redistributions of source code must retain the above copyright notice, this 00023 * list of conditions and the following disclaimer. 00024 * 00025 * 2. Redistributions in binary form must reproduce the above copyright notice, 00026 * this list of conditions and the following disclaimer in the documentation 00027 * and/or other materials provided with the distribution. 00028 * 00029 * 3. The name of Atmel may not be used to endorse or promote products derived 00030 * from this software without specific prior written permission. 00031 * 00032 * 4. This software may only be redistributed and used in connection with an Atmel 00033 * AVR product. 00034 * 00035 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00037 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 00038 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR 00039 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00040 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00041 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00042 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00043 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00044 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE 00045 * 00046 */ 00047 00048 #if !__AVR32_UC__ && !__AVR32_AP__ 00049 #error Implementation of the AVR32 architecture not supported by the INTC driver. 00050 #endif 00051 00052 00053 #include <avr32/io.h> 00054 00055 00058 00059 00060 .section .exception, "ax", @progbits 00061 00062 00063 // Start of Exception Vector Table. 00064 00065 // EVBA must be aligned with a power of two strictly greater than the EVBA- 00066 // relative offset of the last vector. 00067 .balign 0x200 00068 00069 // Export symbol. 00070 .global _evba 00071 .type _evba, @function 00072 _evba: 00073 00074 .org 0x000 00075 // Unrecoverable Exception. 00076 _handle_Unrecoverable_Exception: 00077 rjmp $ 00078 00079 .org 0x004 00080 // TLB Multiple Hit. 00081 _handle_TLB_Multiple_Hit: 00082 rjmp $ 00083 00084 .org 0x008 00085 // Bus Error Data Fetch. 00086 _handle_Bus_Error_Data_Fetch: 00087 rjmp $ 00088 00089 .org 0x00C 00090 // Bus Error Instruction Fetch. 00091 _handle_Bus_Error_Instruction_Fetch: 00092 rjmp $ 00093 00094 .org 0x010 00095 // NMI. 00096 _handle_NMI: 00097 rjmp $ 00098 00099 .org 0x014 00100 // Instruction Address. 00101 _handle_Instruction_Address: 00102 rjmp $ 00103 00104 .org 0x018 00105 // ITLB Protection. 00106 _handle_ITLB_Protection: 00107 rjmp $ 00108 00109 .org 0x01C 00110 // Breakpoint. 00111 _handle_Breakpoint: 00112 rjmp $ 00113 00114 .org 0x020 00115 // Illegal Opcode. 00116 _handle_Illegal_Opcode: 00117 rjmp $ 00118 00119 .org 0x024 00120 // Unimplemented Instruction. 00121 _handle_Unimplemented_Instruction: 00122 rjmp $ 00123 00124 .org 0x028 00125 // Privilege Violation. 00126 _handle_Privilege_Violation: 00127 rjmp $ 00128 00129 .org 0x02C 00130 // Floating-Point: UNUSED IN AVR32UC and AVR32AP. 00131 _handle_Floating_Point: 00132 rjmp $ 00133 00134 .org 0x030 00135 // Coprocessor Absent: UNUSED IN AVR32UC. 00136 _handle_Coprocessor_Absent: 00137 rjmp $ 00138 00139 .org 0x034 00140 // Data Address (Read). 00141 _handle_Data_Address_Read: 00142 rjmp $ 00143 00144 .org 0x038 00145 // Data Address (Write). 00146 _handle_Data_Address_Write: 00147 rjmp $ 00148 00149 .org 0x03C 00150 // DTLB Protection (Read). 00151 _handle_DTLB_Protection_Read: 00152 rjmp $ 00153 00154 .org 0x040 00155 // DTLB Protection (Write). 00156 _handle_DTLB_Protection_Write: 00157 rjmp $ 00158 00159 .org 0x044 00160 // DTLB Modified: UNUSED IN AVR32UC. 00161 _handle_DTLB_Modified: 00162 rjmp $ 00163 00164 .org 0x050 00165 // ITLB Miss. 00166 _handle_ITLB_Miss: 00167 rjmp $ 00168 00169 .org 0x060 00170 // DTLB Miss (Read). 00171 _handle_DTLB_Miss_Read: 00172 rjmp $ 00173 00174 .org 0x070 00175 // DTLB Miss (Write). 00176 _handle_DTLB_Miss_Write: 00177 rjmp $ 00178 00179 .org 0x100 00180 // Supervisor Call. 00181 _handle_Supervisor_Call: 00182 rjmp $ 00183 00184 00185 // Interrupt support. 00186 // The interrupt controller must provide the offset address relative to EVBA. 00187 // Important note: 00188 // All interrupts call a C function named _get_interrupt_handler. 00189 // This function will read group and interrupt line number to then return in 00190 // R12 a pointer to a user-provided interrupt handler. 00191 00192 .balign 4 00193 00194 .irp priority, 0, 1, 2, 3 00195 _int\priority: 00196 #if __AVR32_UC__ 00197 // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the 00198 // CPU upon interrupt entry. No other register is saved by hardware. 00199 #elif __AVR32_AP__ 00200 // PC and SR are automatically saved in respectively RAR_INTx and RSR_INTx by 00201 // the CPU upon interrupt entry. No other register is saved by hardware. 00202 pushm r8-r12, lr 00203 #endif 00204 mov r12, \priority // Pass the int_level parameter to the _get_interrupt_handler function. 00205 call _get_interrupt_handler 00206 cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function. 00207 #if __AVR32_UC__ 00208 movne pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler. 00209 #elif __AVR32_AP__ 00210 breq spint\priority // If this was a spurious interrupt (R12 == NULL), branch. 00211 st.w --sp, r12 // Push the pointer to the interrupt handler onto the system stack since no register may be altered. 00212 popm r8-r12, lr, pc // Restore registers and jump to the handler. 00213 spint\priority: 00214 popm r8-r12, lr 00215 #endif 00216 rete // If this was a spurious interrupt (R12 == NULL), return from event handler. 00217 .endr 00218 00219 00220 // Constant data area. 00221 00222 .balign 4 00223 00224 // Values to store in the interrupt priority registers for the various interrupt priority levels. 00225 // The interrupt priority registers contain the interrupt priority level and 00226 // the EVBA-relative interrupt vector offset. 00227 .global ipr_val 00228 .type ipr_val, @object 00229 ipr_val: 00230 .word (AVR32_INTC_INT0 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int0 - _evba),\ 00231 (AVR32_INTC_INT1 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int1 - _evba),\ 00232 (AVR32_INTC_INT2 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int2 - _evba),\ 00233 (AVR32_INTC_INT3 << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (_int3 - _evba) 00234 00235