2 * FreeRTOS Kernel V10.4.5
\r
3 * Copyright (C) 2006-2015 Cadence Design Systems, Inc.
\r
4 * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
6 * SPDX-License-Identifier: MIT
\r
8 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
9 * this software and associated documentation files (the "Software"), to deal in
\r
10 * the Software without restriction, including without limitation the rights to
\r
11 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
12 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
13 * subject to the following conditions:
\r
15 * The above copyright notice and this permission notice shall be included in all
\r
16 * copies or substantial portions of the Software.
\r
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
20 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
21 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
22 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
25 * https://www.FreeRTOS.org
\r
26 * https://github.com/FreeRTOS
\r
30 /******************************************************************************
\r
31 Xtensa interrupt handling data and assembly routines.
\r
32 Also see xtensa_intr.c and xtensa_vectors.S.
\r
33 ******************************************************************************/
\r
35 #include <xtensa/hal.h>
\r
36 #include <xtensa/config/core.h>
\r
38 #include "xtensa_context.h"
\r
39 #include "FreeRTOSConfig.h"
\r
41 #if XCHAL_HAVE_INTERRUPTS
\r
44 -------------------------------------------------------------------------------
\r
45 INTENABLE virtualization information.
\r
46 -------------------------------------------------------------------------------
\r
51 /* Warning - this is not multicore-compatible. */
\r
56 .global _xt_intenable
\r
57 .type _xt_intenable,@object
\r
58 .size _xt_intenable,4
\r
59 .global _xt_vpri_mask
\r
60 .type _xt_vpri_mask,@object
\r
61 .size _xt_vpri_mask,4
\r
63 _xt_intenable: .word 0 /* Virtual INTENABLE */
\r
64 _xt_vpri_mask: .word 0xFFFFFFFF /* Virtual priority mask */
\r
68 -------------------------------------------------------------------------------
\r
69 Table of C-callable interrupt handlers for each interrupt. Note that not all
\r
70 slots can be filled, because interrupts at level > EXCM_LEVEL will not be
\r
71 dispatched to a C handler by default.
\r
81 -------------------------------------------------------------------------------
\r
85 .global _xt_interrupt_table
\r
88 _xt_interrupt_table:
\r
91 .rept XCHAL_NUM_INTERRUPTS*portNUM_PROCESSORS
\r
92 .word xt_unhandled_interrupt /* handler address */
\r
93 .word i /* handler arg (default: intnum) */
\r
97 #endif /* XCHAL_HAVE_INTERRUPTS */
\r
100 #if XCHAL_HAVE_EXCEPTIONS
\r
103 -------------------------------------------------------------------------------
\r
104 Table of C-callable exception handlers for each exception. Note that not all
\r
105 slots will be active, because some exceptions (e.g. coprocessor exceptions)
\r
106 are always handled by the OS and cannot be hooked by user handlers.
\r
116 -------------------------------------------------------------------------------
\r
120 .global _xt_exception_table
\r
123 _xt_exception_table:
\r
124 .rept XCHAL_EXCCAUSE_NUM * portNUM_PROCESSORS
\r
125 .word xt_unhandled_exception /* handler address */
\r
132 -------------------------------------------------------------------------------
\r
133 unsigned int xt_ints_on ( unsigned int mask )
\r
135 Enables a set of interrupts. Does not simply set INTENABLE directly, but
\r
136 computes it as a function of the current virtual priority if XT_USE_SWPRI is
\r
138 Can be called from interrupt handlers.
\r
139 -------------------------------------------------------------------------------
\r
145 .type xt_ints_on,@function
\r
151 #if XCHAL_HAVE_INTERRUPTS
\r
154 movi a4, _xt_intdata
\r
155 xsr a3, INTENABLE /* Disables all interrupts */
\r
157 l32i a3, a4, 0 /* a3 = _xt_intenable */
\r
158 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
\r
159 or a5, a3, a2 /* a5 = _xt_intenable | mask */
\r
160 s32i a5, a4, 0 /* _xt_intenable |= mask */
\r
161 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
\r
162 wsr a5, INTENABLE /* Reenable interrupts */
\r
163 mov a2, a3 /* Previous mask */
\r
166 xsr a3, INTENABLE /* Disables all interrupts */
\r
168 or a2, a3, a2 /* set bits in mask */
\r
169 wsr a2, INTENABLE /* Re-enable ints */
\r
171 mov a2, a3 /* return prev mask */
\r
174 movi a2, 0 /* Return zero */
\r
178 .size xt_ints_on, . - xt_ints_on
\r
182 -------------------------------------------------------------------------------
\r
183 unsigned int xt_ints_off ( unsigned int mask )
\r
185 Disables a set of interrupts. Does not simply set INTENABLE directly,
\r
186 but computes it as a function of the current virtual priority if XT_USE_SWPRI is
\r
188 Can be called from interrupt handlers.
\r
189 -------------------------------------------------------------------------------
\r
194 .global xt_ints_off
\r
195 .type xt_ints_off,@function
\r
200 #if XCHAL_HAVE_INTERRUPTS
\r
203 movi a4, _xt_intdata
\r
204 xsr a3, INTENABLE /* Disables all interrupts */
\r
206 l32i a3, a4, 0 /* a3 = _xt_intenable */
\r
207 l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
\r
208 or a5, a3, a2 /* a5 = _xt_intenable | mask */
\r
209 xor a5, a5, a2 /* a5 = _xt_intenable & ~mask */
\r
210 s32i a5, a4, 0 /* _xt_intenable &= ~mask */
\r
211 and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
\r
212 wsr a5, INTENABLE /* Reenable interrupts */
\r
213 mov a2, a3 /* Previous mask */
\r
216 xsr a4, INTENABLE /* Disables all interrupts */
\r
218 or a3, a4, a2 /* set bits in mask */
\r
219 xor a3, a3, a2 /* invert bits in mask set in mask, essentially clearing them */
\r
220 wsr a3, INTENABLE /* Re-enable ints */
\r
222 mov a2, a4 /* return prev mask */
\r
225 movi a2, 0 /* return zero */
\r
229 .size xt_ints_off, . - xt_ints_off
\r