1 // user-vector-min.S - Minimal User Vector for General Exceptions
2 // Takes less table space, but does not allow registering new handlers.
3 // $Id: //depot/rel/Cottonwood/Xtensa/OS/xtos/user-vector-min.S#3 $
5 // Copyright (c) 2003-2004, 2006-2007, 2010 Tensilica Inc.
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
15 // The above copyright notice and this permission notice shall be included
16 // in all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include <xtensa/coreasm.h>
27 #include <xtensa/config/system.h>
28 #include "xtos-internal.h"
30 #if XCHAL_HAVE_EXCEPTIONS
33 .begin literal_prefix .UserExceptionVector
34 .section .UserExceptionVector.text, "ax"
36 .global _UserExceptionVector
38 # if ((XSHAL_USER_VECTOR_SIZE >= 28) && XCHAL_HAVE_DENSITY) || XSHAL_VECTORS_PACKED
40 addi a1, a1, -ESF_TOTALSIZE // allocate exception stack frame, etc.
43 rsr a2, EXCCAUSE // get exception cause
44 movi a3, _xtos_min_handler_table
45 bgeui a2, 6, 1f // causes 6 and above map to zero
46 addx4 a3, a2, a3 // index by cause if 1 .. 5
49 jx a3 // jump to cause-specific handler
51 .size _UserExceptionVector, . - _UserExceptionVector
54 # else /*vector as small as 12 bytes:*/
56 addi a1, a1, -ESF_TOTALSIZE // allocate exception stack frame, etc.
58 movi a2, _UserExceptionFromVector // load user exception handler address
60 jx a2 // jump to handler
62 .size _UserExceptionVector, . - _UserExceptionVector
65 // Dispatch outside vector:
68 .global _UserExceptionFromVector
69 _UserExceptionFromVector:
70 rsr a2, EXCCAUSE // get exception cause
72 movi a3, _xtos_min_handler_table
73 bgeui a2, 6, 1f // causes 6 and above map to zero
74 addx4 a3, a2, a3 // index by cause if 1 .. 5
77 jx a3 // jump to cause-specific handler
78 .size _UserExceptionFromVector, . - _UserExceptionFromVector
84 * Read-only minimal table of assembly-level exception handlers
85 * for user vectored exceptions.
86 * Only provides entries for SYSCALL, MOVSP, and level-1 interrupt causes.
89 .global _xtos_min_handler_table
91 _xtos_min_handler_table:
92 .word _xtos_unhandled_exception // 0 Illegal Instruction, and causes > 5
93 .word _xtos_syscall_handler // 1 SYSCALL Instruction
94 .word _xtos_unhandled_exception // 2 Instruction Fetch Error
95 .word _xtos_unhandled_exception // 3 Load/Store Error
96 # if XCHAL_HAVE_INTERRUPTS
97 .word _xtos_l1int_handler // 4 Level-1 Interrupt
99 .word _xtos_unhandled_exception // 4 Level-1 Interrupt (not configured)
101 .word _xtos_alloca_handler // 5 Alloca (MOVSP Instruction)
104 #endif /* XCHAL_HAVE_EXCEPTIONS */