Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / build / magpie_1_1 / sboot / athos / src / xtos / user-vector-min.S
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 $
4
5 // Copyright (c) 2003-2004, 2006-2007, 2010 Tensilica Inc.
6 //
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:
14 //
15 // The above copyright notice and this permission notice shall be included
16 // in all copies or substantial portions of the Software.
17 //
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.
25
26 #include <xtensa/coreasm.h>
27 #include <xtensa/config/system.h>
28 #include "xtos-internal.h"
29
30 #if XCHAL_HAVE_EXCEPTIONS
31
32         //  Vector code
33         .begin  literal_prefix  .UserExceptionVector
34         .section                .UserExceptionVector.text, "ax"
35         .align 4
36         .global _UserExceptionVector
37 _UserExceptionVector:
38 # if ((XSHAL_USER_VECTOR_SIZE >= 28) && XCHAL_HAVE_DENSITY) || XSHAL_VECTORS_PACKED
39
40         addi    a1, a1, -ESF_TOTALSIZE  // allocate exception stack frame, etc.
41         s32i    a2, a1, UEXC_a2
42         s32i    a3, a1, UEXC_a3
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
47 1:      l32i    a3, a3, 0
48         s32i    a4, a1, UEXC_a4
49         jx      a3                      // jump to cause-specific handler
50
51         .size   _UserExceptionVector, . - _UserExceptionVector
52         .end    literal_prefix
53
54 # else /*vector as small as 12 bytes:*/
55
56         addi    a1, a1, -ESF_TOTALSIZE          // allocate exception stack frame, etc.
57         s32i    a2, a1, UEXC_a2
58         movi    a2, _UserExceptionFromVector    // load user exception handler address
59         //interlock
60         jx      a2                              // jump to handler
61
62         .size   _UserExceptionVector, . - _UserExceptionVector
63         .end    literal_prefix
64
65         //  Dispatch outside vector:
66         .text
67         .align  4
68         .global _UserExceptionFromVector
69 _UserExceptionFromVector:
70         rsr     a2, EXCCAUSE            // get exception cause
71         s32i    a3, a1, UEXC_a3
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
75 1:      l32i    a3, a3, 0
76         s32i    a4, a1, UEXC_a4
77         jx      a3                      // jump to cause-specific handler
78         .size   _UserExceptionFromVector, . - _UserExceptionFromVector
79
80 # endif /*XEA2*/
81
82
83         /*
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.
87          */
88         .section .rodata, "a"
89         .global _xtos_min_handler_table
90         .align 4
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
98 # else
99         .word   _xtos_unhandled_exception       // 4 Level-1 Interrupt (not configured)
100 # endif
101         .word   _xtos_alloca_handler            // 5 Alloca (MOVSP Instruction)
102         .text
103
104 #endif /* XCHAL_HAVE_EXCEPTIONS */
105