1 /*******************************************************************************
\r
2 Copyright (c) 2006-2015 Cadence Design Systems Inc.
\r
4 Permission is hereby granted, free of charge, to any person obtaining
\r
5 a copy of this software and associated documentation files (the
\r
6 "Software"), to deal in the Software without restriction, including
\r
7 without limitation the rights to use, copy, modify, merge, publish,
\r
8 distribute, sublicense, and/or sell copies of the Software, and to
\r
9 permit persons to whom the Software is furnished to do so, subject to
\r
10 the following conditions:
\r
12 The above copyright notice and this permission notice shall be included
\r
13 in all copies or substantial portions of the Software.
\r
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
\r
18 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
\r
19 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
\r
20 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
\r
21 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 ******************************************************************************/
\r
24 /******************************************************************************
\r
25 Xtensa interrupt handling data and assembly routines.
\r
26 Also see xtensa_intr.c and xtensa_vectors.S.
\r
27 ******************************************************************************/
\r
29 #include <xtensa/hal.h>
\r
30 #include <xtensa/config/core.h>
\r
32 #include "xtensa_context.h"
\r
33 #include "FreeRTOSConfig.h"
\r
35 #if XCHAL_HAVE_INTERRUPTS
\r
38 -------------------------------------------------------------------------------
\r
39 INTENABLE virtualization information.
\r
40 -------------------------------------------------------------------------------
\r
45 /* Warning - this is not multicore-compatible. */
\r
50 .global _xt_intenable
\r
51 .type _xt_intenable,@object
\r
52 .size _xt_intenable,4
\r
53 .global _xt_vpri_mask
\r
54 .type _xt_vpri_mask,@object
\r
55 .size _xt_vpri_mask,4
\r
57 _xt_intenable: .word 0 /* Virtual INTENABLE */
\r
58 _xt_vpri_mask: .word 0xFFFFFFFF /* Virtual priority mask */
\r
62 -------------------------------------------------------------------------------
\r
63 Table of C-callable interrupt handlers for each interrupt. Note that not all
\r
64 slots can be filled, because interrupts at level > EXCM_LEVEL will not be
\r
65 dispatched to a C handler by default.
\r
75 -------------------------------------------------------------------------------
\r
79 .global _xt_interrupt_table
\r
82 _xt_interrupt_table:
\r
85 .rept XCHAL_NUM_INTERRUPTS*portNUM_PROCESSORS
\r
86 .word xt_unhandled_interrupt /* handler address */
\r
87 .word i /* handler arg (default: intnum) */
\r
91 #endif /* XCHAL_HAVE_INTERRUPTS */
\r
94 #if XCHAL_HAVE_EXCEPTIONS
\r
97 -------------------------------------------------------------------------------
\r
98 Table of C-callable exception handlers for each exception. Note that not all
\r
99 slots will be active, because some exceptions (e.g. coprocessor exceptions)
\r
100 are always handled by the OS and cannot be hooked by user handlers.
\r
110 -------------------------------------------------------------------------------
\r
114 .global _xt_exception_table
\r
117 _xt_exception_table:
\r
118 .rept XCHAL_EXCCAUSE_NUM * portNUM_PROCESSORS
\r
119 .word xt_unhandled_exception /* handler address */
\r
126 -------------------------------------------------------------------------------
\r
127 unsigned int xt_ints_on ( unsigned int mask )
\r
129 Enables a set of interrupts. Does not simply set INTENABLE directly, but
\r
130 computes it as a function of the current virtual priority if XT_USE_SWPRI is
\r
132 Can be called from interrupt handlers.
\r
133 -------------------------------------------------------------------------------
\r
139 .type xt_ints_on,@function
\r
145 #if XCHAL_HAVE_INTERRUPTS
\r
148 movi a4, _xt_intdata
\r
149 xsr a3, INTENABLE /* Disables all interrupts */
\r
151 l32i a3, a4, 0 /* a3 = _xt_intenable */
\r
152 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
\r
153 or a5, a3, a2 /* a5 = _xt_intenable | mask */
\r
154 s32i a5, a4, 0 /* _xt_intenable |= mask */
\r
155 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
\r
156 wsr a5, INTENABLE /* Reenable interrupts */
\r
157 mov a2, a3 /* Previous mask */
\r
160 xsr a3, INTENABLE /* Disables all interrupts */
\r
162 or a2, a3, a2 /* set bits in mask */
\r
163 wsr a2, INTENABLE /* Re-enable ints */
\r
165 mov a2, a3 /* return prev mask */
\r
168 movi a2, 0 /* Return zero */
\r
172 .size xt_ints_on, . - xt_ints_on
\r
176 -------------------------------------------------------------------------------
\r
177 unsigned int xt_ints_off ( unsigned int mask )
\r
179 Disables a set of interrupts. Does not simply set INTENABLE directly,
\r
180 but computes it as a function of the current virtual priority if XT_USE_SWPRI is
\r
182 Can be called from interrupt handlers.
\r
183 -------------------------------------------------------------------------------
\r
188 .global xt_ints_off
\r
189 .type xt_ints_off,@function
\r
194 #if XCHAL_HAVE_INTERRUPTS
\r
197 movi a4, _xt_intdata
\r
198 xsr a3, INTENABLE /* Disables all interrupts */
\r
200 l32i a3, a4, 0 /* a3 = _xt_intenable */
\r
201 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
\r
202 or a5, a3, a2 /* a5 = _xt_intenable | mask */
\r
203 xor a5, a5, a2 /* a5 = _xt_intenable & ~mask */
\r
204 s32i a5, a4, 0 /* _xt_intenable &= ~mask */
\r
205 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
\r
206 wsr a5, INTENABLE /* Reenable interrupts */
\r
207 mov a2, a3 /* Previous mask */
\r
210 xsr a4, INTENABLE /* Disables all interrupts */
\r
212 or a3, a4, a2 /* set bits in mask */
\r
213 xor a3, a3, a2 /* invert bits in mask set in mask, essentially clearing them */
\r
214 wsr a3, INTENABLE /* Re-enable ints */
\r
216 mov a2, a4 /* return prev mask */
\r
219 movi a2, 0 /* return zero */
\r
223 .size xt_ints_off, . - xt_ints_off
\r