1 /* 2 * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved. 4 * Copyright (c) 2021 Nuclei Limited. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without modification, 7 * are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice, this list of 10 * conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 13 * of conditions and the following disclaimer in the documentation and/or other materials 14 * provided with the distribution. 15 * 16 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 17 * to endorse or promote products derived from this software without specific prior written 18 * permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _LOS_ARCH_INTERRUPT_H 34 #define _LOS_ARCH_INTERRUPT_H 35 36 #include "los_common_interrupt.h" 37 #include "nuclei_sdk_soc.h" 38 39 #ifdef __cplusplus 40 #if __cplusplus 41 extern "C" { 42 #endif /* __cplusplus */ 43 #endif /* __cplusplus */ 44 /** 45 * @ingroup los_hwi 46 * Count of Nuclei system interrupt vector. 47 */ 48 #define OS_RISCV_SYS_VECTOR_CNT 19 49 50 /** 51 * @ingroup los_hwi 52 * Count of Nuclei interrupt vector maximum, which is configurable. 53 */ 54 #define OS_RISCV_CUSTOM_IRQ_VECTOR_CNT SOC_INT_MAX 55 56 /** 57 * @ingroup los_hwi 58 * Count of Nuclei interrupt vector. 59 */ 60 #define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT) 61 62 /** 63 * Maximum number of supported hardware devices that generate hardware interrupts. 64 */ 65 #define OS_HWI_MAX_NUM (OS_RISCV_VECTOR_CNT-1) 66 67 extern VOID HalHwiDefaultHandler(VOID); 68 69 /** 70 * @ingroup los_hwi 71 * Hardware interrupt error code: Invalid interrupt number. 72 * 73 * Value: 0x02000900 74 * 75 * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable 76 * for a risc-v platform is [0, OS_RISCV_VECTOR_CNT]. 77 */ 78 #define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00) 79 80 /** 81 * @ingroup los_hwi 82 * Hardware interrupt error code: Null hardware interrupt handling function. 83 * 84 * Value: 0x02000901 85 * 86 * Solution: Pass in a valid non-null hardware interrupt handling function. 87 */ 88 #define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) 89 90 /** 91 * @ingroup los_hwi 92 * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation. 93 * 94 * Value: 0x02000902 95 * 96 * Solution: Increase the configured maximum number of supported hardware interrupts. 97 */ 98 #define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) 99 100 /** 101 * @ingroup los_hwi 102 * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization. 103 * 104 * Value: 0x02000903 105 * 106 * Solution: Expand the configured memory. 107 */ 108 #define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) 109 110 /** 111 * @ingroup los_hwi 112 * Hardware interrupt error code: The interrupt has already been created. 113 * 114 * Value: 0x02000904 115 * 116 * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 117 */ 118 #define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) 119 120 /** 121 * @ingroup los_hwi 122 * Hardware interrupt error code: Invalid interrupt priority. 123 * 124 * Value: 0x02000905 125 * 126 * Solution: Ensure that the interrupt priority is valid. 127 */ 128 #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) 129 130 /** 131 * @ingroup los_hwi 132 * Hardware interrupt error code: Incorrect interrupt creation mode. 133 * 134 * Value: 0x02000906 135 * 136 * Solution: The interrupt creation mode can be only set to ECLIC_NON_VECTOR_INTERRUPT or ECLIC_VECTOR_INTERRUPT of which the 137 * value can be 0 or 1. 138 */ 139 #define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) 140 141 /** 142 * @ingroup los_hwi 143 * Hardware interrupt error code: The interrupt has already been created as a fast interrupt. 144 * 145 * Value: 0x02000907 146 * 147 * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 148 */ 149 #define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) 150 151 /** 152 * @ingroup los_hwi 153 * Hardware interrupt error code: The API is called during an interrupt, which is forbidden. 154 * 155 * Value: 0x02000908 156 * 157 * * Solution: Do not call the API during an interrupt. 158 */ 159 #define OS_ERRNO_HWI_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08) 160 161 /** 162 * @ingroup los_hwi 163 * Hardware interrupt error code:the hwi support SHARED error. 164 * 165 * Value: 0x02000909 166 * 167 * * Solution:check the input params hwiMode and irqParam of ArchHwiCreate or ArchHwiDelete whether adapt the current 168 * hwi. 169 */ 170 #define OS_ERRNO_HWI_SHARED_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x09) 171 172 /** 173 * @ingroup los_hwi 174 * Hardware interrupt error code:Invalid interrupt Arg. 175 * 176 * Value: 0x0200090a 177 * 178 * * Solution:check the interrupt Arg, Arg should only be ECLIC_LEVEL_TRIGGER, ECLIC_POSTIVE_EDGE_TRIGGER or 179 * ECLIC_NEGTIVE_EDGE_TRIGGER. 180 */ 181 #define OS_ERRNO_HWI_ARG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0a) 182 183 /** 184 * @ingroup los_hwi 185 * Hardware interrupt error code:The interrupt corresponded to the hwi number or devid has not been created. 186 * 187 * Value: 0x0200090b 188 * 189 * * Solution:check the hwi number or devid, make sure the hwi number or devid need to delete. 190 */ 191 #define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b) 192 193 /* * 194 * @ingroup los_arch_interrupt 195 * Hardware interrupt error code: Invalid interrupt operation function. 196 * 197 * Value: 0x0200090c 198 * 199 * Solution: Set a valid interrupt operation function 200 */ 201 #define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c) 202 203 extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp); 204 205 extern VOID DisplayTaskInfo(VOID); 206 207 #ifdef __cplusplus 208 #if __cplusplus 209 } 210 #endif /* __cplusplus */ 211 #endif /* __cplusplus */ 212 213 #endif /* _LOS_ARCH_INTERRUPT_H */ 214