3 * Copyright (c) 2015-2019 Cadence Design Systems, Inc.
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
26 * Xtensa interrupt handling data and assembly routines.
27 * Also see xtensa_intr.c and xtensa_vectors.S.
30 #include <xtensa/hal.h>
31 #include <xtensa/config/core.h>
33 #include "xtensa_context.h"
35 #if XCHAL_HAVE_INTERRUPTS
38 -------------------------------------------------------------------------------
39 INTENABLE virtualization information.
40 -------------------------------------------------------------------------------
48 .type _xt_intenable,@object
51 .type _xt_vpri_mask,@object
54 _xt_intenable: .word 0 /* Virtual INTENABLE */
55 _xt_vpri_mask: .word 0xFFFFFFFF /* Virtual priority mask */
59 -------------------------------------------------------------------------------
60 Table of C-callable interrupt handlers for each interrupt. Note that not all
61 slots can be filled, because interrupts at level > EXCM_LEVEL will not be
62 dispatched to a C handler by default.
63 -------------------------------------------------------------------------------
67 .global _xt_interrupt_table
73 .rept XCHAL_NUM_INTERRUPTS
74 .word xt_unhandled_interrupt /* handler address */
75 .word i /* handler arg (default: intnum) */
79 #endif /* XCHAL_HAVE_INTERRUPTS */
82 #if XCHAL_HAVE_EXCEPTIONS
85 -------------------------------------------------------------------------------
86 Table of C-callable exception handlers for each exception. Note that not all
87 slots will be active, because some exceptions (e.g. coprocessor exceptions)
88 are always handled by the OS and cannot be hooked by user handlers.
89 -------------------------------------------------------------------------------
93 .global _xt_exception_table
97 .rept XCHAL_EXCCAUSE_NUM
98 .word xt_unhandled_exception /* handler address */
105 -------------------------------------------------------------------------------
106 unsigned int xt_ints_on ( unsigned int mask )
108 Enables a set of interrupts. Does not simply set INTENABLE directly, but
109 computes it as a function of the current virtual priority.
110 Can be called from interrupt handlers.
111 -------------------------------------------------------------------------------
117 .type xt_ints_on,@function
122 #if XCHAL_HAVE_INTERRUPTS
125 xsr a3, INTENABLE /* Disables all interrupts */
127 l32i a3, a4, 0 /* a3 = _xt_intenable */
128 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
129 or a5, a3, a2 /* a5 = _xt_intenable | mask */
130 s32i a5, a4, 0 /* _xt_intenable |= mask */
131 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
132 wsr a5, INTENABLE /* Reenable interrupts */
133 mov a2, a3 /* Previous mask */
135 movi a2, 0 /* Return zero */
139 .size xt_ints_on, . - xt_ints_on
143 -------------------------------------------------------------------------------
144 unsigned int xt_ints_off ( unsigned int mask )
146 Disables a set of interrupts. Does not simply set INTENABLE directly,
147 but computes it as a function of the current virtual priority.
148 Can be called from interrupt handlers.
149 -------------------------------------------------------------------------------
155 .type xt_ints_off,@function
160 #if XCHAL_HAVE_INTERRUPTS
163 xsr a3, INTENABLE /* Disables all interrupts */
165 l32i a3, a4, 0 /* a3 = _xt_intenable */
166 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
167 or a5, a3, a2 /* a5 = _xt_intenable | mask */
168 xor a5, a5, a2 /* a5 = _xt_intenable & ~mask */
169 s32i a5, a4, 0 /* _xt_intenable &= ~mask */
170 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
171 wsr a5, INTENABLE /* Reenable interrupts */
172 mov a2, a3 /* Previous mask */
174 movi a2, 0 /* return zero */
178 .size xt_ints_off, . - xt_ints_off