2 * Copyright (c) 2015-2019 Cadence Design Systems, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include <xtensa/config/core-isa.h>
27 //#define PS_OWB_SHIFT 8
28 //#define PS_OWB_BITS 4
29 //#define EXCCAUSE_ALLOCA 5 /* Stack Extension Assist (MOVSP instruction) for alloca */
34 .ascii "PANIC: Unhandled exception!\n"
35 _sim_panic_msg_len = . - _sim_panic_msg
38 .literal .Lpanic_msg, _sim_panic_msg
39 .literal .Lpanic_msg_len, _sim_panic_msg_len
45 l32r a5, .Lpanic_msg_len
55 --------------------------------------------------------------------------------
56 Handle alloca exception generated by interruptee executing 'movsp'.
57 This uses space between the window vectors, so is essentially "free".
58 All interruptee's regs are intact except a0 which is saved in EXCSAVE_1,
59 and PS.EXCM has been set by the exception hardware (can't be interrupted).
60 The fact the alloca exception was taken means the registers associated with
61 the base-save area have been spilled and will be restored by the underflow
62 handler, so those 4 registers are available for scratch.
63 The code is optimized to avoid unaligned branches and minimize cache misses.
64 --------------------------------------------------------------------------------
67 #if XCHAL_HAVE_WINDOWED
69 .global _xt_alloca_exc
73 rsr a0, WINDOWBASE /* grab WINDOWBASE before rotw changes it */
74 rotw -1 /* WINDOWBASE goes to a4, new a0-a3 are scratch */
76 extui a3, a2, 8/*PS_OWB_BITS*/, 4/*PS_OWB_BITS*/
77 xor a3, a3, a4 /* bits changed from old to current windowbase */
78 rsr a4, EXCSAVE1 /* restore original a0 (now in a4) */
80 xor a2, a2, a3 /* flip changed bits in old window base */
81 wsr a2, PS /* update PS.OWB to new window base */
84 bbci.l a4, 31, _WindowUnderflow4
85 rotw -1 /* original a0 goes to a8 */
86 bbci.l a8, 30, _WindowUnderflow8
93 --------------------------------------------------------------------------------
94 User exception handler.
95 --------------------------------------------------------------------------------
98 #if XCHAL_HAVE_WINDOWED
102 j _xt_alloca_exc /* in window vectors section */
105 .type _xt_user_exc,@function
110 /* Handle alloca and syscall exceptions */
111 #if XCHAL_HAVE_WINDOWED
112 beqi a0, 5/*EXCCAUSE_ALLOCA*/, _xt_to_alloca_exc
118 --------------------------------------------------------------------------------
120 --------------------------------------------------------------------------------
123 .begin literal_prefix .NMIExceptionVector
124 .section .NMIExceptionVector.text, "ax"
125 .global NMIExceptionVector
126 .type NMIExceptionVector,@function
135 --------------------------------------------------------------------------------
137 --------------------------------------------------------------------------------
140 .begin literal_prefix .KernelExceptionVector
141 .section .KernelExceptionVector.text, "ax"
142 .global KernelExceptionVector
143 .type KernelExceptionVector,@function
146 KernelExceptionVector:
152 --------------------------------------------------------------------------------
154 --------------------------------------------------------------------------------
157 .begin literal_prefix .UserExceptionVector
158 .section .UserExceptionVector.text, "ax"
159 .global _UserExceptionVector
160 .type _UserExceptionVector,@function
163 _UserExceptionVector:
165 wsr a0, EXCSAVE1 /* preserve a0 */
166 j _xt_user_exc /* user exception handler */
167 /* never returns here - call0 is used as a jump (see note at top) */
172 --------------------------------------------------------------------------------
174 --------------------------------------------------------------------------------
177 .begin literal_prefix .DoubleExceptionVector
178 .section .DoubleExceptionVector.text, "ax"
179 .global DoubleExceptionVector
180 .type DoubleExceptionVector,@function
183 DoubleExceptionVector: