1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2023 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_common_interrupt.h" 36 37 #ifdef __cplusplus 38 #if __cplusplus 39 extern "C" { 40 #endif /* __cplusplus */ 41 #endif /* __cplusplus */ 42 43 typedef struct { 44 UINT32 pc; 45 UINT32 ps; 46 UINT32 regA[16]; 47 UINT32 sar; 48 UINT32 excCause; 49 UINT32 excVaddr; 50 UINT32 lbeg; 51 UINT32 lend; 52 UINT32 lcount; 53 #if (defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) 54 UINT32 temp; 55 UINT16 cpenable; 56 UINT16 cpstored; 57 UINT32 fcr; 58 UINT32 fsr; 59 UINT32 regF[16]; 60 #endif 61 UINT32 res[4]; 62 } EXC_CONTEXT_S; 63 64 #define VECTOR_START _init_start 65 extern CHAR *VECTOR_START; 66 #define INIT_VECTOR_START ((UINTPTR)&VECTOR_START) 67 68 /* * 69 * @ingroup los_arch_interrupt 70 * Highest priority of a hardware interrupt. 71 */ 72 #ifndef OS_HWI_PRIO_HIGHEST 73 #define OS_HWI_PRIO_HIGHEST 0 74 #endif 75 76 /* * 77 * @ingroup los_arch_interrupt 78 * Lowest priority of a hardware interrupt. 79 */ 80 #ifndef OS_HWI_PRIO_LOWEST 81 #define OS_HWI_PRIO_LOWEST 7 82 #endif 83 84 /* * 85 * @ingroup los_arch_interrupt 86 * Count of Xtensa system interrupt vector. 87 */ 88 #define OS_SYS_VECTOR_CNT 0 89 90 /* * 91 * @ingroup los_arch_interrupt 92 * Count of Xtensa interrupt vector. 93 */ 94 #define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) 95 96 /* * 97 * @ingroup los_arch_interrupt 98 * Hardware interrupt error code: Invalid interrupt number. 99 * 100 * Value: 0x02000900 101 * 102 * Solution: Ensure that the interrupt number is valid. 103 */ 104 #define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00) 105 106 /* * 107 * @ingroup los_arch_interrupt 108 * Hardware interrupt error code: Null hardware interrupt handling function. 109 * 110 * Value: 0x02000901 111 * 112 * Solution: Pass in a valid non-null hardware interrupt handling function. 113 */ 114 #define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) 115 116 /* * 117 * @ingroup los_arch_interrupt 118 * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation. 119 * 120 * Value: 0x02000902 121 * 122 * Solution: Increase the configured maximum number of supported hardware interrupts. 123 */ 124 #define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) 125 126 /* * 127 * @ingroup los_arch_interrupt 128 * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization. 129 * 130 * Value: 0x02000903 131 * 132 * Solution: Expand the configured memory. 133 */ 134 #define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) 135 136 /* * 137 * @ingroup los_arch_interrupt 138 * Hardware interrupt error code: The interrupt has already been created. 139 * 140 * Value: 0x02000904 141 * 142 * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 143 */ 144 #define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) 145 146 /* * 147 * @ingroup los_arch_interrupt 148 * Hardware interrupt error code: Invalid interrupt priority. 149 * 150 * Value: 0x02000905 151 * 152 * Solution: Ensure that the interrupt priority is valid. 153 */ 154 #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) 155 156 /* * 157 * @ingroup los_arch_interrupt 158 * Hardware interrupt error code: Incorrect interrupt creation mode. 159 * 160 * Value: 0x02000906 161 * 162 * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST. 163 */ 164 #define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) 165 166 /* * 167 * @ingroup los_arch_interrupt 168 * Hardware interrupt error code: The interrupt has already been created as a fast interrupt. 169 * 170 * Value: 0x02000907 171 * 172 * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 173 */ 174 #define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) 175 176 /* * 177 * @ingroup los_arch_interrupt 178 * Hardware interrupt error code: Invalid interrupt operation function. 179 * 180 * Value: 0x0200090c 181 * 182 * Solution: Set a valid interrupt operation function 183 */ 184 #define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c) 185 186 VOID HalInterrupt(VOID); 187 VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type); 188 VOID HalHwiInit(VOID); 189 190 /** 191 * @ingroup los_exc 192 * Exception information structure 193 * 194 * Description: Exception information saved when an exception is triggered on the Xtensa platform. 195 * 196 */ 197 typedef struct TagExcInfo { 198 UINT16 phase; 199 UINT16 type; 200 UINT32 faultAddr; 201 UINT32 thrdPid; 202 UINT16 nestCnt; 203 UINT16 reserved; 204 EXC_CONTEXT_S *context; 205 } ExcInfo; 206 207 extern UINT32 g_curNestCount; 208 extern ExcInfo g_excInfo; 209 210 #define MAX_INT_INFO_SIZE (8 + 0x164) 211 212 #ifdef __cplusplus 213 #if __cplusplus 214 } 215 #endif /* __cplusplus */ 216 #endif /* __cplusplus */ 217 218 #endif /* _LOS_ARCH_INTERRUPT_H */ 219