• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3  * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  *    conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12  *    of conditions and the following disclaimer in the documentation and/or other materials
13  *    provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16  *    to endorse or promote products derived from this software without specific prior written
17  *    permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 #ifndef _LOS_ARCH_INTERRUPT_H
33 #define _LOS_ARCH_INTERRUPT_H
34 
35 #include "los_config.h"
36 #include "los_compiler.h"
37 #include "los_interrupt.h"
38 
39 #ifdef __cplusplus
40 #if __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43 #endif /* __cplusplus */
44 
45 typedef struct {
46     UINT32 pc;
47     UINT32 ps;
48     UINT32 regA[16];
49     UINT32 sar;
50     UINT32 excCause;
51     UINT32 excVaddr;
52     UINT32 lbeg;
53     UINT32 lend;
54     UINT32 lcount;
55 #if (defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U))
56     UINT32 temp;
57     UINT16 cpenable;
58     UINT16 cpstored;
59     UINT32 fcr;
60     UINT32 fsr;
61     UINT32 regF[16];
62 #endif
63     UINT32 res[4];
64 } EXC_CONTEXT_S;
65 
66 /* *
67  * @ingroup los_arch_interrupt
68  * Maximum number of used hardware interrupts.
69  */
70 #ifndef OS_HWI_MAX_NUM
71 #define OS_HWI_MAX_NUM                        LOSCFG_PLATFORM_HWI_LIMIT
72 #endif
73 
74 /* *
75  * @ingroup los_arch_interrupt
76  * Highest priority of a hardware interrupt.
77  */
78 #ifndef OS_HWI_PRIO_HIGHEST
79 #define OS_HWI_PRIO_HIGHEST                   0
80 #endif
81 
82 /* *
83  * @ingroup los_arch_interrupt
84  * Lowest priority of a hardware interrupt.
85  */
86 #ifndef OS_HWI_PRIO_LOWEST
87 #define OS_HWI_PRIO_LOWEST                    7
88 #endif
89 
90 #define OS_EXC_IN_INIT                        0
91 #define OS_EXC_IN_TASK                        1
92 #define OS_EXC_IN_HWI                         2
93 
94 /* *
95  * @ingroup  los_arch_interrupt
96  * Define the type of a hardware interrupt vector table function.
97  */
98 typedef VOID (**HWI_VECTOR_FUNC)(VOID);
99 
100 /* *
101  * @ingroup los_arch_interrupt
102  * Count of interrupts.
103  */
104 extern UINT32 g_intCount;
105 
106 /* *
107  * @ingroup los_arch_interrupt
108  * Count of Xtensa system interrupt vector.
109  */
110 #define OS_SYS_VECTOR_CNT                     0
111 
112 /* *
113  * @ingroup los_arch_interrupt
114  * Count of Xtensa interrupt vector.
115  */
116 #define OS_VECTOR_CNT                         (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
117 
118 /* *
119  * @ingroup los_arch_interrupt
120  * Hardware interrupt error code: Invalid interrupt number.
121  *
122  * Value: 0x02000900
123  *
124  * Solution: Ensure that the interrupt number is valid.
125  */
126 #define OS_ERRNO_HWI_NUM_INVALID              LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
127 
128 /* *
129  * @ingroup los_arch_interrupt
130  * Hardware interrupt error code: Null hardware interrupt handling function.
131  *
132  * Value: 0x02000901
133  *
134  * Solution: Pass in a valid non-null hardware interrupt handling function.
135  */
136 #define OS_ERRNO_HWI_PROC_FUNC_NULL           LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
137 
138 /* *
139  * @ingroup los_arch_interrupt
140  * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
141  *
142  * Value: 0x02000902
143  *
144  * Solution: Increase the configured maximum number of supported hardware interrupts.
145  */
146 #define OS_ERRNO_HWI_CB_UNAVAILABLE           LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
147 
148 /* *
149  * @ingroup los_arch_interrupt
150  * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
151  *
152  * Value: 0x02000903
153  *
154  * Solution: Expand the configured memory.
155  */
156 #define OS_ERRNO_HWI_NO_MEMORY                LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
157 
158 /* *
159  * @ingroup los_arch_interrupt
160  * Hardware interrupt error code: The interrupt has already been created.
161  *
162  * Value: 0x02000904
163  *
164  * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
165  */
166 #define OS_ERRNO_HWI_ALREADY_CREATED          LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
167 
168 /* *
169  * @ingroup los_arch_interrupt
170  * Hardware interrupt error code: Invalid interrupt priority.
171  *
172  * Value: 0x02000905
173  *
174  * Solution: Ensure that the interrupt priority is valid.
175  */
176 #define OS_ERRNO_HWI_PRIO_INVALID             LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
177 
178 /* *
179  * @ingroup los_arch_interrupt
180  * Hardware interrupt error code: Incorrect interrupt creation mode.
181  *
182  * Value: 0x02000906
183  *
184  * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST.
185  */
186 #define OS_ERRNO_HWI_MODE_INVALID             LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
187 
188 /* *
189  * @ingroup los_arch_interrupt
190  * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
191  *
192  * Value: 0x02000907
193  *
194  * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
195  */
196 #define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
197 
198 #if (OS_HWI_WITH_ARG == 1)
199 /* *
200  * @ingroup los_arch_interrupt
201  * Set interrupt vector table.
202  */
203 extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
204 #else
205 /* *
206  * @ingroup los_arch_interrupt
207  * Set interrupt vector table.
208  */
209 extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
210 #endif
211 
212 VOID HalInterrupt(VOID);
213 UINT32 HalIntNumGet(VOID);
214 VOID HalHwiDefaultHandler(VOID);
215 VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
216 VOID HalHwiInit(VOID);
217 
218 /**
219  * @ingroup los_exc
220  * Exception information structure
221  *
222  * Description: Exception information saved when an exception is triggered on the Xtensa platform.
223  *
224  */
225 typedef struct TagExcInfo {
226     UINT16 phase;
227     UINT16 type;
228     UINT32 faultAddr;
229     UINT32 thrdPid;
230     UINT16 nestCnt;
231     UINT16 reserved;
232     EXC_CONTEXT_S *context;
233 } ExcInfo;
234 
235 extern UINT32 g_curNestCount;
236 
237 #define MAX_INT_INFO_SIZE       (8 + 0x164)
238 
239 #ifdef __cplusplus
240 #if __cplusplus
241 }
242 #endif /* __cplusplus */
243 #endif /* __cplusplus */
244 
245 #endif /* _LOS_ARCH_INTERRUPT_H */
246