]> git.sur5r.net Git - freertos/blob - FreeRTOS/Source/portable/ThirdParty/XCC/Xtensa/xtensa_intr_asm.S
Add Xtensa port
[freertos] / FreeRTOS / Source / portable / ThirdParty / XCC / Xtensa / xtensa_intr_asm.S
1 /*******************************************************************************\r
2 Copyright (c) 2006-2015 Cadence Design Systems Inc.\r
3 \r
4 Permission is hereby granted, free of charge, to any person obtaining\r
5 a copy of this software and associated documentation files (the\r
6 "Software"), to deal in the Software without restriction, including\r
7 without limitation the rights to use, copy, modify, merge, publish,\r
8 distribute, sublicense, and/or sell copies of the Software, and to\r
9 permit persons to whom the Software is furnished to do so, subject to\r
10 the following conditions:\r
11 \r
12 The above copyright notice and this permission notice shall be included\r
13 in all copies or substantial portions of the Software.\r
14 \r
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
16 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
17 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\r
18 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\r
19 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\r
20 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\r
21 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
22 ******************************************************************************/\r
23 \r
24 /******************************************************************************\r
25   Xtensa interrupt handling data and assembly routines.\r
26   Also see xtensa_intr.c and xtensa_vectors.S.\r
27 ******************************************************************************/\r
28 \r
29 #include <xtensa/hal.h>\r
30 #include <xtensa/config/core.h>\r
31 \r
32 #include "xtensa_context.h"\r
33 \r
34 #if XCHAL_HAVE_INTERRUPTS\r
35 \r
36 /*\r
37 -------------------------------------------------------------------------------\r
38   INTENABLE virtualization information.\r
39 -------------------------------------------------------------------------------\r
40 */\r
41 \r
42     .data\r
43     .global _xt_intdata\r
44     .align  8\r
45 _xt_intdata:\r
46     .global _xt_intenable\r
47     .type   _xt_intenable,@object\r
48     .size   _xt_intenable,4\r
49     .global _xt_vpri_mask\r
50     .type   _xt_vpri_mask,@object\r
51     .size   _xt_vpri_mask,4\r
52 \r
53 _xt_intenable:     .word   0             /* Virtual INTENABLE     */\r
54 _xt_vpri_mask:     .word   0xFFFFFFFF    /* Virtual priority mask */\r
55 \r
56 \r
57 /*\r
58 -------------------------------------------------------------------------------\r
59   Table of C-callable interrupt handlers for each interrupt. Note that not all\r
60   slots can be filled, because interrupts at level > EXCM_LEVEL will not be\r
61   dispatched to a C handler by default.\r
62 -------------------------------------------------------------------------------\r
63 */\r
64 \r
65     .data\r
66     .global _xt_interrupt_table\r
67     .align  8\r
68 \r
69 _xt_interrupt_table:\r
70 \r
71     .set    i, 0\r
72     .rept   XCHAL_NUM_INTERRUPTS\r
73     .word   xt_unhandled_interrupt      /* handler address               */\r
74     .word   i                           /* handler arg (default: intnum) */\r
75     .set    i, i+1\r
76     .endr\r
77 \r
78 #endif /* XCHAL_HAVE_INTERRUPTS */\r
79 \r
80 \r
81 #if XCHAL_HAVE_EXCEPTIONS\r
82 \r
83 /*\r
84 -------------------------------------------------------------------------------\r
85   Table of C-callable exception handlers for each exception. Note that not all\r
86   slots will be active, because some exceptions (e.g. coprocessor exceptions)\r
87   are always handled by the OS and cannot be hooked by user handlers.\r
88 -------------------------------------------------------------------------------\r
89 */\r
90 \r
91     .data\r
92     .global _xt_exception_table\r
93     .align  4\r
94 \r
95 _xt_exception_table:\r
96     .rept   XCHAL_EXCCAUSE_NUM\r
97     .word   xt_unhandled_exception    /* handler address */\r
98     .endr\r
99 \r
100 #endif\r
101 \r
102 \r
103 /*\r
104 -------------------------------------------------------------------------------\r
105   unsigned int xt_ints_on ( unsigned int mask )\r
106 \r
107   Enables a set of interrupts. Does not simply set INTENABLE directly, but\r
108   computes it as a function of the current virtual priority.\r
109   Can be called from interrupt handlers.\r
110 -------------------------------------------------------------------------------\r
111 */\r
112 \r
113     .text\r
114     .align  4\r
115     .global xt_ints_on\r
116     .type   xt_ints_on,@function\r
117 \r
118 xt_ints_on:\r
119 \r
120     ENTRY0\r
121 #if XCHAL_HAVE_INTERRUPTS\r
122     movi    a3, 0\r
123     movi    a4, _xt_intdata\r
124     xsr     a3, INTENABLE        /* Disables all interrupts   */\r
125     rsync\r
126     l32i    a3, a4, 0            /* a3 = _xt_intenable        */\r
127     l32i    a6, a4, 4            /* a6 = _xt_vpri_mask        */\r
128     or      a5, a3, a2           /* a5 = _xt_intenable | mask */\r
129     s32i    a5, a4, 0            /* _xt_intenable |= mask     */\r
130     and     a5, a5, a6           /* a5 = _xt_intenable & _xt_vpri_mask */\r
131     wsr     a5, INTENABLE        /* Reenable interrupts       */\r
132     mov     a2, a3               /* Previous mask             */\r
133 #else\r
134     movi    a2, 0                /* Return zero */\r
135 #endif\r
136     RET0\r
137 \r
138     .size   xt_ints_on, . - xt_ints_on\r
139 \r
140 \r
141 /*\r
142 -------------------------------------------------------------------------------\r
143   unsigned int xt_ints_off ( unsigned int mask )\r
144 \r
145   Disables a set of interrupts. Does not simply set INTENABLE directly,\r
146   but computes it as a function of the current virtual priority.\r
147   Can be called from interrupt handlers.\r
148 -------------------------------------------------------------------------------\r
149 */\r
150 \r
151     .text\r
152     .align  4\r
153     .global xt_ints_off\r
154     .type   xt_ints_off,@function\r
155 \r
156 xt_ints_off:\r
157 \r
158     ENTRY0\r
159 #if XCHAL_HAVE_INTERRUPTS\r
160     movi    a3, 0\r
161     movi    a4, _xt_intdata\r
162     xsr     a3, INTENABLE        /* Disables all interrupts    */\r
163     rsync\r
164     l32i    a3, a4, 0            /* a3 = _xt_intenable         */\r
165     l32i    a6, a4, 4            /* a6 = _xt_vpri_mask         */\r
166     or      a5, a3, a2           /* a5 = _xt_intenable | mask  */\r
167     xor     a5, a5, a2           /* a5 = _xt_intenable & ~mask */\r
168     s32i    a5, a4, 0            /* _xt_intenable &= ~mask     */\r
169     and     a5, a5, a6           /* a5 = _xt_intenable & _xt_vpri_mask */\r
170     wsr     a5, INTENABLE        /* Reenable interrupts        */\r
171     mov     a2, a3               /* Previous mask              */\r
172 #else\r
173     movi    a2, 0                /* return zero */\r
174 #endif\r
175     RET0\r
176 \r
177     .size   xt_ints_off, . - xt_ints_off\r
178 \r
179 \r