2 * FreeRTOS Kernel <DEVELOPMENT BRANCH>
\r
3 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * SPDX-License-Identifier: MIT AND BSD-3-Clause
\r
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
8 * this software and associated documentation files (the "Software"), to deal in
\r
9 * the Software without restriction, including without limitation the rights to
\r
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
11 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
12 * subject to the following conditions:
\r
14 * The above copyright notice and this permission notice shall be included in all
\r
15 * copies or substantial portions of the Software.
\r
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
24 * https://www.FreeRTOS.org
\r
25 * https://github.com/FreeRTOS
\r
29 /*This file is prepared for Doxygen automatic documentation generation.*/
\r
30 /*! \file *********************************************************************
\r
32 * \brief Exception and interrupt vectors.
\r
34 * This file maps all events supported by an AVR32UC.
\r
36 * - Compiler: IAR EWAVR32
\r
37 * - Supported devices: All AVR32UC devices with an INTC module can be used.
\r
40 * \author Atmel Corporation (Now Microchip):
\r
41 https://www.microchip.com \n
\r
42 * Support and FAQ: https://www.microchip.com/support
\r
44 ******************************************************************************/
\r
47 * Copyright (c) 2007, Atmel Corporation All rights reserved.
\r
49 * Redistribution and use in source and binary forms, with or without
\r
50 * modification, are permitted provided that the following conditions are met:
\r
52 * 1. Redistributions of source code must retain the above copyright notice,
\r
53 * this list of conditions and the following disclaimer.
\r
55 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
56 * this list of conditions and the following disclaimer in the documentation
\r
57 * and/or other materials provided with the distribution.
\r
59 * 3. The name of ATMEL may not be used to endorse or promote products derived
\r
60 * from this software without specific prior written permission.
\r
62 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
\r
63 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
64 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
\r
65 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
\r
66 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
\r
67 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
\r
68 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
\r
69 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
70 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
\r
71 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
75 #include <avr32/io.h>
\r
83 // Start of Exception Vector Table.
\r
85 // EVBA must be aligned with a power of two strictly greater than the EVBA-
\r
86 // relative offset of the last vector.
\r
87 COMMON EVTAB:CODE:ROOT(9)
\r
90 // Force EVBA initialization.
\r
101 // Unrecoverable Exception.
\r
102 _handle_Unrecoverable_Exception:
\r
106 // TLB Multiple Hit: UNUSED IN AVR32UC.
\r
107 _handle_TLB_Multiple_Hit:
\r
111 // Bus Error Data Fetch.
\r
112 _handle_Bus_Error_Data_Fetch:
\r
116 // Bus Error Instruction Fetch.
\r
117 _handle_Bus_Error_Instruction_Fetch:
\r
126 // Instruction Address.
\r
127 _handle_Instruction_Address:
\r
131 // ITLB Protection.
\r
132 _handle_ITLB_Protection:
\r
137 _handle_Breakpoint:
\r
142 _handle_Illegal_Opcode:
\r
146 // Unimplemented Instruction.
\r
147 _handle_Unimplemented_Instruction:
\r
151 // Privilege Violation.
\r
152 _handle_Privilege_Violation:
\r
156 // Floating-Point: UNUSED IN AVR32UC.
\r
157 _handle_Floating_Point:
\r
161 // Coprocessor Absent: UNUSED IN AVR32UC.
\r
162 _handle_Coprocessor_Absent:
\r
166 // Data Address (Read).
\r
167 _handle_Data_Address_Read:
\r
171 // Data Address (Write).
\r
172 _handle_Data_Address_Write:
\r
176 // DTLB Protection (Read).
\r
177 _handle_DTLB_Protection_Read:
\r
181 // DTLB Protection (Write).
\r
182 _handle_DTLB_Protection_Write:
\r
186 // DTLB Modified: UNUSED IN AVR32UC.
\r
187 _handle_DTLB_Modified:
\r
191 // ITLB Miss: UNUSED IN AVR32UC.
\r
196 // DTLB Miss (Read): UNUSED IN AVR32UC.
\r
197 _handle_DTLB_Miss_Read:
\r
201 // DTLB Miss (Write): UNUSED IN AVR32UC.
\r
202 _handle_DTLB_Miss_Write:
\r
206 // Supervisor Call.
\r
207 _handle_Supervisor_Call:
\r
208 lddpc pc, __SCALLYield
\r
211 // Interrupt support.
\r
212 // The interrupt controller must provide the offset address relative to EVBA.
\r
214 // All interrupts call a C function named _get_interrupt_handler.
\r
215 // This function will read group and interrupt line number to then return in
\r
216 // R12 a pointer to a user-provided interrupt handler.
\r
221 // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the
\r
222 // CPU upon interrupt entry.
\r
223 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.
\r
225 bfextu r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE
\r
228 lddsp r12, sp[0 * 4]
\r
229 stdsp sp[6 * 4], r12
\r
230 lddsp r12, sp[1 * 4]
\r
231 stdsp sp[7 * 4], r12
\r
232 lddsp r12, sp[3 * 4]
\r
237 mov r12, 0 // Pass the int_lev parameter to the _get_interrupt_handler function.
\r
238 mcall __get_interrupt_handler
\r
239 cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function.
\r
240 movne pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.
\r
241 rete // If this was a spurious interrupt (R12 == NULL), return from event handler.
\r
244 // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the
\r
245 // CPU upon interrupt entry.
\r
246 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.
\r
248 bfextu r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE
\r
251 lddsp r12, sp[0 * 4]
\r
252 stdsp sp[6 * 4], r12
\r
253 lddsp r12, sp[1 * 4]
\r
254 stdsp sp[7 * 4], r12
\r
255 lddsp r12, sp[3 * 4]
\r
260 mov r12, 1 // Pass the int_lev parameter to the _get_interrupt_handler function.
\r
261 mcall __get_interrupt_handler
\r
262 cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function.
\r
263 movne pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.
\r
264 rete // If this was a spurious interrupt (R12 == NULL), return from event handler.
\r
267 // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the
\r
268 // CPU upon interrupt entry.
\r
269 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.
\r
271 bfextu r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE
\r
274 lddsp r12, sp[0 * 4]
\r
275 stdsp sp[6 * 4], r12
\r
276 lddsp r12, sp[1 * 4]
\r
277 stdsp sp[7 * 4], r12
\r
278 lddsp r12, sp[3 * 4]
\r
283 mov r12, 2 // Pass the int_lev parameter to the _get_interrupt_handler function.
\r
284 mcall __get_interrupt_handler
\r
285 cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function.
\r
286 movne pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.
\r
287 rete // If this was a spurious interrupt (R12 == NULL), return from event handler.
\r
290 // R8-R12, LR, PC and SR are automatically pushed onto the system stack by the
\r
291 // CPU upon interrupt entry.
\r
292 #if 1 // B1832: interrupt stack changed to exception stack if exception is detected.
\r
294 bfextu r12, r12, AVR32_SR_M0_OFFSET, AVR32_SR_M0_SIZE + AVR32_SR_M1_SIZE + AVR32_SR_M2_SIZE
\r
297 lddsp r12, sp[0 * 4]
\r
298 stdsp sp[6 * 4], r12
\r
299 lddsp r12, sp[1 * 4]
\r
300 stdsp sp[7 * 4], r12
\r
301 lddsp r12, sp[3 * 4]
\r
306 mov r12, 3 // Pass the int_lev parameter to the _get_interrupt_handler function.
\r
307 mcall __get_interrupt_handler
\r
308 cp.w r12, 0 // Get the pointer to the interrupt handler returned by the function.
\r
309 movne pc, r12 // If this was not a spurious interrupt (R12 != NULL), jump to the handler.
\r
310 rete // If this was a spurious interrupt (R12 == NULL), return from event handler.
\r
313 // Constant data area.
\r
319 EXTERN _get_interrupt_handler
\r
322 __get_interrupt_handler:
\r
323 DC32 _get_interrupt_handler
\r
325 // Values to store in the interrupt priority registers for the various interrupt priority levels.
\r
326 // The interrupt priority registers contain the interrupt priority level and
\r
327 // the EVBA-relative interrupt vector offset.
\r
330 DC32 (INT0 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int0 - _evba),\
\r
331 (INT1 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int1 - _evba),\
\r
332 (INT2 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int2 - _evba),\
\r
333 (INT3 << AVR32_INTC_IPR0_INTLEV_OFFSET) | (_int3 - _evba)
\r