Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / athos / src / xtos / interrupt-table.S
1 // interrupt-table.S - Interrupt handler table and default handler
2
3 // Copyright (c) 2004-2010 Tensilica Inc.
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining
6 // a copy of this software and associated documentation files (the
7 // "Software"), to deal in the Software without restriction, including
8 // without limitation the rights to use, copy, modify, merge, publish,
9 // distribute, sublicense, and/or sell copies of the Software, and to
10 // permit persons to whom the Software is furnished to do so, subject to
11 // the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included
14 // in all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 #include <xtensa/coreasm.h>
25 #include <xtensa/config/specreg.h>
26 #include "xtos-internal.h"
27 #ifdef SIMULATOR
28 #include <xtensa/simcall.h>
29 #endif
30
31
32 #if XCHAL_HAVE_INTERRUPTS
33
34         .data
35
36         .global _xtos_intstruct
37         .align  8
38 _xtos_intstruct:
39 # if XTOS_VIRTUAL_INTENABLE
40         .global _xtos_enabled
41         .type   _xtos_enabled,@object
42         .size   _xtos_enabled,4
43         .global _xtos_vpri_enabled
44         .type   _xtos_vpri_enabled,@object
45         .size   _xtos_vpri_enabled,4
46 _xtos_enabled:          .word   0
47 _xtos_vpri_enabled:     .word   0xFFFFFFFF
48 # endif
49 # if XTOS_VIRTUAL_INTERRUPT
50 #  error Virtualized INTERRUPT register not yet supported.
51         .global _xtos_pending
52         .type   _xtos_pending,@object
53         .size   _xtos_pending,4
54 _xtos_pending:          .word   0
55 # endif
56
57         /*
58          *  Table of C-level interrupt handlers (and args, etc) for each interrupt.
59          *  NOTE:  if the NSA/NSAU instructions are configured, then to save a few
60          *  cycles in the interrupt dispatcher code, this table is filled in reverse.
61          *  C code uses the MAPINT() macro defined in xtos-internal.h to index entries.
62          *  NOTE:  Under some conditions (turned off by default in xtos-params.h),
63          *  this table gets properly initialized by the _xtos_init() function in
64          *  init.c .  NOTA:  A future enhancement may be to always configure
65          *  and build this table at build-time rather than ever doing it at run-time.
66          */
67 #define i       .Li     /* workaround a silly GDB testsuite regression */
68         .data
69         .global _xtos_interrupt_table
70         .align  8
71 _xtos_interrupt_table:
72         .set    i, XCHAL_HAVE_NSA*(XCHAL_NUM_INTERRUPTS-1)
73         .rept   XCHAL_NUM_INTERRUPTS
74          .word  _xtos_unhandled_interrupt
75          .word  i                       // parameter: interrupt number
76          .set   i, i+1-(XCHAL_HAVE_NSA*2)
77         .endr
78
79 # if XIE_EXTEND
80         /*  MUST *IMMEDIATELY* follow _xtos_interrupt_table:  */
81         .global _xtos_interrupt_mask_table
82 _xtos_interrupt_mask_table:
83         .set    i, XCHAL_HAVE_NSA*(XCHAL_NUM_INTERRUPTS-1)
84         .rept   XCHAL_NUM_INTERRUPTS
85         /*  Default to all low-priority (level-one) interrupts at their own virtual priority:  */
86 #  if XTOS_SUBPRI_ORDER == XTOS_SPO_ZERO_HI
87          .word  ((1<<i)-1) | ~XCHAL_LOWPRI_MASK // vpri_mask default - lower-numbered ints (and high/medium-pri ints) pre-empt other low-pri ints
88 #  else
89          .word  (-2*(1<<i)) | ~XCHAL_LOWPRI_MASK // vpri_mask default - higher-numbered ints (and high/medium-pri ints) pre-empt other low-pri ints
90 #  endif
91          .word  (1<<i)          // level_mask default - each low-pri (level-one) interrupt at its own subpriority
92          .set   i, i+1-(XCHAL_HAVE_NSA*2)
93         .endr
94 # endif /*XIE_EXTEND*/
95
96 #endif /* XCHAL_HAVE_INTERRUPTS */
97
98         .text
99
100
101
102 #if XCHAL_HAVE_INTERRUPTS
103
104         //
105         // void _xtos_unhandled_interrupt( int n );
106         // 
107         //  Default/empty interrupt handler.
108         //  This is used for interrupts with no registered handler.
109         //  Parameter n is the interrupt number (0 thru 31).
110         //
111         .text 
112         .align 4 
113         .global _xtos_unhandled_interrupt
114         .type _xtos_unhandled_interrupt,@function
115 _xtos_unhandled_interrupt:
116         abi_entry
117 # if XCHAL_HAVE_DEBUG
118         //  Break into the debugger if one is present and active:
119 #  if XCHAL_NUM_INTLEVELS > XCHAL_DEBUGLEVEL
120         rsil    a3, XCHAL_DEBUGLEVEL-1  // ensure break takes effect
121 #  endif
122         break   1, 15           // unhandled (unregistered) interrupt $a2
123 //# elif defined(SIMULATOR)
124 //      addmi   a2, a2, SYS_unhandled_interrupt ...
125 //      simcall                 // unhandled interrupt
126 # else
127 1:      j       1b              // unhandled interrupt - loop forever
128 # endif
129         abi_return
130
131         .size   _xtos_unhandled_interrupt, . - _xtos_unhandled_interrupt
132
133 #endif /* XCHAL_HAVE_INTERRUPTS */
134