]> begriffs open source - freertos/blob - FreeRTOS/Source/portable/ThirdParty/GCC/Xtensa_ESP32/xtensa_intr_asm.S
sync from github to svn: Xtensa GCC as-is.
[freertos] / FreeRTOS / Source / portable / ThirdParty / GCC / Xtensa_ESP32 / 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 #include "FreeRTOSConfig.h"\r
34 \r
35 #if XCHAL_HAVE_INTERRUPTS\r
36 \r
37 /*\r
38 -------------------------------------------------------------------------------\r
39   INTENABLE virtualization information.\r
40 -------------------------------------------------------------------------------\r
41 */\r
42 \r
43 \r
44 #if XT_USE_SWPRI\r
45 /* Warning - this is not multicore-compatible. */\r
46     .data\r
47     .global _xt_intdata\r
48     .align  8\r
49 _xt_intdata:\r
50     .global _xt_intenable\r
51     .type   _xt_intenable,@object\r
52     .size   _xt_intenable,4\r
53     .global _xt_vpri_mask\r
54     .type   _xt_vpri_mask,@object\r
55     .size   _xt_vpri_mask,4\r
56 \r
57 _xt_intenable:     .word   0             /* Virtual INTENABLE     */\r
58 _xt_vpri_mask:     .word   0xFFFFFFFF    /* Virtual priority mask */\r
59 #endif\r
60 \r
61 /*\r
62 -------------------------------------------------------------------------------\r
63   Table of C-callable interrupt handlers for each interrupt. Note that not all\r
64   slots can be filled, because interrupts at level > EXCM_LEVEL will not be\r
65   dispatched to a C handler by default.\r
66 \r
67   Stored as:\r
68   int 0 cpu 0\r
69   int 0 cpu 1\r
70   ...\r
71   int 0 cpu n\r
72   int 1 cpu 0\r
73   int 1 cpu 1\r
74   etc\r
75 -------------------------------------------------------------------------------\r
76 */\r
77 \r
78     .data\r
79     .global _xt_interrupt_table\r
80     .align  8\r
81 \r
82 _xt_interrupt_table:\r
83 \r
84     .set    i, 0\r
85     .rept   XCHAL_NUM_INTERRUPTS*portNUM_PROCESSORS\r
86     .word   xt_unhandled_interrupt      /* handler address               */\r
87     .word   i                           /* handler arg (default: intnum) */\r
88     .set    i, i+1\r
89     .endr\r
90 \r
91 #endif /* XCHAL_HAVE_INTERRUPTS */\r
92 \r
93 \r
94 #if XCHAL_HAVE_EXCEPTIONS\r
95 \r
96 /*\r
97 -------------------------------------------------------------------------------\r
98   Table of C-callable exception handlers for each exception. Note that not all\r
99   slots will be active, because some exceptions (e.g. coprocessor exceptions)\r
100   are always handled by the OS and cannot be hooked by user handlers.\r
101 \r
102   Stored as:\r
103   exc 0 cpu 0\r
104   exc 0 cpu 1\r
105   ...\r
106   exc 0 cpu n\r
107   exc 1 cpu 0\r
108   exc 1 cpu 1\r
109   etc\r
110 -------------------------------------------------------------------------------\r
111 */\r
112 \r
113     .data\r
114     .global _xt_exception_table\r
115     .align  4\r
116 \r
117 _xt_exception_table:\r
118     .rept   XCHAL_EXCCAUSE_NUM * portNUM_PROCESSORS\r
119     .word   xt_unhandled_exception    /* handler address */\r
120     .endr\r
121 \r
122 #endif\r
123 \r
124 \r
125 /*\r
126 -------------------------------------------------------------------------------\r
127   unsigned int xt_ints_on ( unsigned int mask )\r
128 \r
129   Enables a set of interrupts. Does not simply set INTENABLE directly, but\r
130   computes it as a function of the current virtual priority if XT_USE_SWPRI is\r
131   enabled.\r
132   Can be called from interrupt handlers.\r
133 -------------------------------------------------------------------------------\r
134 */\r
135 \r
136     .text\r
137     .align  4\r
138     .global xt_ints_on\r
139     .type   xt_ints_on,@function\r
140 \r
141 xt_ints_on:\r
142 \r
143     ENTRY0\r
144 \r
145 #if XCHAL_HAVE_INTERRUPTS\r
146 #if XT_USE_SWPRI\r
147     movi    a3, 0\r
148     movi    a4, _xt_intdata\r
149     xsr     a3, INTENABLE        /* Disables all interrupts   */\r
150     rsync\r
151     l32i    a3, a4, 0            /* a3 = _xt_intenable        */\r
152     l32i    a6, a4, 4            /* a6 = _xt_vpri_mask        */\r
153     or      a5, a3, a2           /* a5 = _xt_intenable | mask */\r
154     s32i    a5, a4, 0            /* _xt_intenable |= mask     */\r
155     and     a5, a5, a6           /* a5 = _xt_intenable & _xt_vpri_mask */\r
156     wsr     a5, INTENABLE        /* Reenable interrupts       */\r
157     mov     a2, a3               /* Previous mask             */\r
158 #else\r
159     movi    a3, 0\r
160     xsr     a3, INTENABLE        /* Disables all interrupts   */\r
161     rsync\r
162     or      a2, a3, a2           /* set bits in mask */\r
163     wsr     a2, INTENABLE        /* Re-enable ints */\r
164     rsync\r
165     mov     a2, a3               /* return prev mask */\r
166 #endif\r
167 #else\r
168     movi    a2, 0                /* Return zero */\r
169 #endif\r
170     RET0\r
171 \r
172     .size   xt_ints_on, . - xt_ints_on\r
173 \r
174 \r
175 /*\r
176 -------------------------------------------------------------------------------\r
177   unsigned int xt_ints_off ( unsigned int mask )\r
178 \r
179   Disables a set of interrupts. Does not simply set INTENABLE directly,\r
180   but computes it as a function of the current virtual priority if XT_USE_SWPRI is\r
181   enabled.\r
182   Can be called from interrupt handlers.\r
183 -------------------------------------------------------------------------------\r
184 */\r
185 \r
186     .text\r
187     .align  4\r
188     .global xt_ints_off\r
189     .type   xt_ints_off,@function\r
190 \r
191 xt_ints_off:\r
192 \r
193     ENTRY0\r
194 #if XCHAL_HAVE_INTERRUPTS\r
195 #if XT_USE_SWPRI\r
196     movi    a3, 0\r
197     movi    a4, _xt_intdata\r
198     xsr     a3, INTENABLE        /* Disables all interrupts    */\r
199     rsync\r
200     l32i    a3, a4, 0            /* a3 = _xt_intenable         */\r
201     l32i    a6, a4, 4            /* a6 = _xt_vpri_mask         */\r
202     or      a5, a3, a2           /* a5 = _xt_intenable | mask  */\r
203     xor     a5, a5, a2           /* a5 = _xt_intenable & ~mask */\r
204     s32i    a5, a4, 0            /* _xt_intenable &= ~mask     */\r
205     and     a5, a5, a6           /* a5 = _xt_intenable & _xt_vpri_mask */\r
206     wsr     a5, INTENABLE        /* Reenable interrupts        */\r
207     mov     a2, a3               /* Previous mask              */\r
208 #else\r
209     movi    a4, 0\r
210     xsr     a4, INTENABLE        /* Disables all interrupts   */\r
211     rsync\r
212     or      a3, a4, a2           /* set bits in mask */\r
213     xor     a3, a3, a2           /* invert bits in mask set in mask, essentially clearing them */\r
214     wsr     a3, INTENABLE        /* Re-enable ints */\r
215     rsync\r
216     mov     a2, a4               /* return prev mask */\r
217 #endif\r
218 #else\r
219     movi    a2, 0                /* return zero */\r
220 #endif\r
221     RET0\r
222 \r
223     .size   xt_ints_off, . - xt_ints_off\r
224 \r
225 \r