1 /* 2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this list of 8 * conditions and the following disclaimer. 9 * 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 * of conditions and the following disclaimer in the documentation and/or other materials 12 * provided with the distribution. 13 * 14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef _LOS_COMMON_INTERRUPT_H 32 #define _LOS_COMMON_INTERRUPT_H 33 34 #include "los_config.h" 35 #include "los_compiler.h" 36 #include "los_interrupt.h" 37 #include "los_error.h" 38 39 #ifdef __cplusplus 40 #if __cplusplus 41 extern "C" { 42 #endif /* __cplusplus */ 43 #endif /* __cplusplus */ 44 45 /* * 46 * @ingroup los_arch_interrupt 47 * Define the type of a hardware interrupt vector table function. 48 */ 49 typedef VOID (**HWI_VECTOR_FUNC)(VOID); 50 51 /* * 52 * @ingroup los_arch_interrupt 53 * Count of interrupts. 54 */ 55 extern volatile UINT32 g_intCount; 56 57 /* * 58 * @ingroup los_arch_interrupt 59 * Maximum number of used hardware interrupts. 60 */ 61 #ifndef OS_HWI_MAX_NUM 62 #define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT 63 #endif 64 65 #if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1) 66 typedef struct { 67 HWI_PROC_FUNC pfnHandler; 68 VOID *pParm; 69 } HWI_HANDLER_FUNC; 70 71 /* * 72 * @ingroup los_arch_interrupt 73 * Set interrupt vector table. 74 */ 75 extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg); 76 extern HWI_HANDLER_FUNC g_hwiHandlerForm[]; 77 #else 78 /* * 79 * @ingroup los_arch_interrupt 80 * Set interrupt vector table. 81 */ 82 extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector); 83 extern HWI_PROC_FUNC g_hwiHandlerForm[]; 84 #endif 85 86 #define OS_EXC_IN_INIT 0 87 #define OS_EXC_IN_TASK 1 88 #define OS_EXC_IN_HWI 2 89 #define OS_EXC_FLAG_FAULTADDR_VALID 0x01 90 #define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB 91 92 /* * 93 * @ingroup los_arch_interrupt 94 * @brief: Default vector handling function. 95 * 96 * @par Description: 97 * This API is used to configure interrupt for null function. 98 * 99 * @attention: 100 * <ul><li>None.</li></ul> 101 * 102 * @param:None. 103 * 104 * @retval:None. 105 * @par Dependency: 106 * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul> 107 * @see None. 108 */ 109 extern VOID HalHwiDefaultHandler(VOID); 110 111 VOID HalPreInterruptHandler(UINT32 arg); 112 VOID HalAftInterruptHandler(UINT32 arg); 113 VOID *ArchGetHwiFrom(VOID); 114 115 #ifdef __cplusplus 116 #if __cplusplus 117 } 118 #endif /* __cplusplus */ 119 #endif /* __cplusplus */ 120 121 #endif /* _LOS_COMMON_INTERRUPT_H */ 122