1 /* 2 * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2021 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 #ifndef _LOS_HWI_H 33 #define _LOS_HWI_H 34 35 #include "nuclei_sdk_soc.h" 36 #include "los_compiler.h" 37 #include "los_config.h" 38 #include "los_interrupt.h" 39 #include "los_arch_context.h" 40 41 #ifdef __cplusplus 42 #if __cplusplus 43 extern "C" { 44 #endif /* __cplusplus */ 45 #endif /* __cplusplus */ 46 /** 47 * @ingroup los_hwi 48 * Count of Nuclei system interrupt vector. 49 */ 50 #define OS_RISCV_SYS_VECTOR_CNT 19 51 52 /** 53 * @ingroup los_hwi 54 * Count of Nuclei interrupt vector maximum, which is configurable. 55 */ 56 #define OS_RISCV_CUSTOM_IRQ_VECTOR_CNT SOC_INT_MAX 57 58 /** 59 * @ingroup los_hwi 60 * Count of Nuclei interrupt vector. 61 */ 62 #define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT) 63 64 /** 65 * Maximum number of supported hardware devices that generate hardware interrupts. 66 */ 67 #define OS_HWI_MAX_NUM (OS_RISCV_VECTOR_CNT-1) 68 69 extern VOID HalHwiDefaultHandler(VOID); 70 71 /** 72 * @ingroup los_hwi 73 * Hardware interrupt error code: Invalid interrupt number. 74 * 75 * Value: 0x02000900 76 * 77 * Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable 78 * for a risc-v platform is [0, OS_RISCV_VECTOR_CNT]. 79 */ 80 #define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00) 81 82 /** 83 * @ingroup los_hwi 84 * Hardware interrupt error code: Null hardware interrupt handling function. 85 * 86 * Value: 0x02000901 87 * 88 * Solution: Pass in a valid non-null hardware interrupt handling function. 89 */ 90 #define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) 91 92 /** 93 * @ingroup los_hwi 94 * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation. 95 * 96 * Value: 0x02000902 97 * 98 * Solution: Increase the configured maximum number of supported hardware interrupts. 99 */ 100 #define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) 101 102 /** 103 * @ingroup los_hwi 104 * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization. 105 * 106 * Value: 0x02000903 107 * 108 * Solution: Expand the configured memory. 109 */ 110 #define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) 111 112 /** 113 * @ingroup los_hwi 114 * Hardware interrupt error code: The interrupt has already been created. 115 * 116 * Value: 0x02000904 117 * 118 * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 119 */ 120 #define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) 121 122 /** 123 * @ingroup los_hwi 124 * Hardware interrupt error code: Invalid interrupt priority. 125 * 126 * Value: 0x02000905 127 * 128 * Solution: Ensure that the interrupt priority is valid. 129 */ 130 #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) 131 132 /** 133 * @ingroup los_hwi 134 * Hardware interrupt error code: Incorrect interrupt creation mode. 135 * 136 * Value: 0x02000906 137 * 138 * Solution: The interrupt creation mode can be only set to ECLIC_NON_VECTOR_INTERRUPT or ECLIC_VECTOR_INTERRUPT of which the 139 * value can be 0 or 1. 140 */ 141 #define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) 142 143 /** 144 * @ingroup los_hwi 145 * Hardware interrupt error code: The interrupt has already been created as a fast interrupt. 146 * 147 * Value: 0x02000907 148 * 149 * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 150 */ 151 #define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) 152 153 /** 154 * @ingroup los_hwi 155 * Hardware interrupt error code: The API is called during an interrupt, which is forbidden. 156 * 157 * Value: 0x02000908 158 * 159 * * Solution: Do not call the API during an interrupt. 160 */ 161 #define OS_ERRNO_HWI_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08) 162 163 /** 164 * @ingroup los_hwi 165 * Hardware interrupt error code:the hwi support SHARED error. 166 * 167 * Value: 0x02000909 168 * 169 * * Solution:check the input params hwiMode and irqParam of ArchHwiCreate or ArchHwiDelete whether adapt the current 170 * hwi. 171 */ 172 #define OS_ERRNO_HWI_SHARED_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x09) 173 174 /** 175 * @ingroup los_hwi 176 * Hardware interrupt error code:Invalid interrupt Arg. 177 * 178 * Value: 0x0200090a 179 * 180 * * Solution:check the interrupt Arg, Arg should only be ECLIC_LEVEL_TRIGGER, ECLIC_POSTIVE_EDGE_TRIGGER or 181 * ECLIC_NEGTIVE_EDGE_TRIGGER. 182 */ 183 #define OS_ERRNO_HWI_ARG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0a) 184 185 /** 186 * @ingroup los_hwi 187 * Hardware interrupt error code:The interrupt corresponded to the hwi number or devid has not been created. 188 * 189 * Value: 0x0200090b 190 * 191 * * Solution:check the hwi number or devid, make sure the hwi number or devid need to delete. 192 */ 193 #define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b) 194 195 extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp); 196 197 extern VOID DisplayTaskInfo(VOID); 198 199 #ifdef __cplusplus 200 #if __cplusplus 201 } 202 #endif /* __cplusplus */ 203 #endif /* __cplusplus */ 204 205 #endif /* _LOS_HWI_H */ 206