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