2 * FreeRTOS Kernel V11.1.0
3 * Copyright (C) 2015-2019 Cadence Design Systems, Inc.
4 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: MIT
8 * Permission is hereby granted, free of charge, to any person obtaining a copy of
9 * this software and associated documentation files (the "Software"), to deal in
10 * the Software without restriction, including without limitation the rights to
11 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
12 * the Software, and to permit persons to whom the Software is furnished to do so,
13 * subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in all
16 * copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
20 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
21 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * https://www.FreeRTOS.org
26 * https://github.com/FreeRTOS
31 * Xtensa interrupt handling data and assembly routines.
32 * Also see xtensa_intr.c and xtensa_vectors.S.
35 #include <xtensa/hal.h>
36 #include <xtensa/config/core.h>
38 #include "xtensa_context.h"
40 #if XCHAL_HAVE_INTERRUPTS
43 -------------------------------------------------------------------------------
44 INTENABLE virtualization information.
45 -------------------------------------------------------------------------------
53 .type _xt_intenable,@object
56 .type _xt_vpri_mask,@object
59 _xt_intenable: .word 0 /* Virtual INTENABLE */
60 _xt_vpri_mask: .word 0xFFFFFFFF /* Virtual priority mask */
64 -------------------------------------------------------------------------------
65 Table of C-callable interrupt handlers for each interrupt. Note that not all
66 slots can be filled, because interrupts at level > EXCM_LEVEL will not be
67 dispatched to a C handler by default.
68 -------------------------------------------------------------------------------
72 .global _xt_interrupt_table
78 .rept XCHAL_NUM_INTERRUPTS
79 .word xt_unhandled_interrupt /* handler address */
80 .word i /* handler arg (default: intnum) */
84 #endif /* XCHAL_HAVE_INTERRUPTS */
87 #if XCHAL_HAVE_EXCEPTIONS
90 -------------------------------------------------------------------------------
91 Table of C-callable exception handlers for each exception. Note that not all
92 slots will be active, because some exceptions (e.g. coprocessor exceptions)
93 are always handled by the OS and cannot be hooked by user handlers.
94 -------------------------------------------------------------------------------
98 .global _xt_exception_table
102 .rept XCHAL_EXCCAUSE_NUM
103 .word xt_unhandled_exception /* handler address */
110 -------------------------------------------------------------------------------
111 unsigned int xt_ints_on ( unsigned int mask )
113 Enables a set of interrupts. Does not simply set INTENABLE directly, but
114 computes it as a function of the current virtual priority.
115 Can be called from interrupt handlers.
116 -------------------------------------------------------------------------------
122 .type xt_ints_on,@function
127 #if XCHAL_HAVE_INTERRUPTS
130 xsr a3, INTENABLE /* Disables all interrupts */
132 l32i a3, a4, 0 /* a3 = _xt_intenable */
133 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
134 or a5, a3, a2 /* a5 = _xt_intenable | mask */
135 s32i a5, a4, 0 /* _xt_intenable |= mask */
136 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
137 wsr a5, INTENABLE /* Reenable interrupts */
138 mov a2, a3 /* Previous mask */
140 movi a2, 0 /* Return zero */
144 .size xt_ints_on, . - xt_ints_on
148 -------------------------------------------------------------------------------
149 unsigned int xt_ints_off ( unsigned int mask )
151 Disables a set of interrupts. Does not simply set INTENABLE directly,
152 but computes it as a function of the current virtual priority.
153 Can be called from interrupt handlers.
154 -------------------------------------------------------------------------------
160 .type xt_ints_off,@function
165 #if XCHAL_HAVE_INTERRUPTS
168 xsr a3, INTENABLE /* Disables all interrupts */
170 l32i a3, a4, 0 /* a3 = _xt_intenable */
171 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
172 or a5, a3, a2 /* a5 = _xt_intenable | mask */
173 xor a5, a5, a2 /* a5 = _xt_intenable & ~mask */
174 s32i a5, a4, 0 /* _xt_intenable &= ~mask */
175 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
176 wsr a5, INTENABLE /* Reenable interrupts */
177 mov a2, a3 /* Previous mask */
179 movi a2, 0 /* return zero */
183 .size xt_ints_off, . - xt_ints_off