1 /* ---------------------------------------------------------------------------- 2 * Copyright (c) Huawei Technologies Co., Ltd. 2013-2019. All rights reserved. 3 * Description: Hwi Implementation HeadFile 4 * Author: Huawei LiteOS Team 5 * Create: 2013-01-01 6 * Redistribution and use in source and binary forms, with or without modification, 7 * are permitted provided that the following conditions are met: 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 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 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 14 * to endorse or promote products derived from this software without specific prior written 15 * permission. 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 26 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * --------------------------------------------------------------------------- */ 28 /* ---------------------------------------------------------------------------- 29 * This file has been modified in accordance with Misra-C specifications. 30 * ---------------------------------------------------------------------------- */ 31 32 #ifndef HAL_HWI_H 33 #define HAL_HWI_H 34 35 #include "los_typedef.h" 36 37 #if defined(LOSCFG_LINGLONG_IC) 38 #include "linglong_ic.h" 39 #endif 40 41 #ifdef __cplusplus 42 extern "C" { 43 #endif /* __cplusplus */ 44 45 #if defined(LOSCFG_CORTEX_M_NVIC) 46 #define OS_USER_HWI_MIN 16 47 #elif defined(LOSCFG_ARCH_LINGLONG) 48 #define OS_USER_HWI_MIN 1 /* 0: NMI */ 49 #else 50 #define OS_USER_HWI_MIN 0 51 #endif 52 53 #if defined(LOSCFG_LINGLONG_IC) 54 #define OS_HWI_IPI_BASE LLIC_INTERNAL_SWI_MIN 55 #else 56 #define OS_HWI_IPI_BASE 0 57 #endif 58 59 #if (OS_USER_HWI_MIN == 0) 60 #define HWI_NUM_GE_MIN(num) TRUE 61 #else 62 #define HWI_NUM_GE_MIN(num) ((num) >= (UINT32)OS_USER_HWI_MIN) 63 #endif 64 65 #define OS_USER_HWI_MAX (LOSCFG_PLATFORM_HWI_LIMIT - 1) 66 #ifdef LOSCFG_ARM_GIC_LPI_ENABLE 67 #define HWI_NUM_VALID(num) ((HWI_NUM_GE_MIN(num) && ((num) < (UINT32)OS_HWI_SPI_MAX)) || \ 68 (((num) >= (UINT32)OS_HWI_LPI_MIN) && ((num) <= (UINT32)OS_USER_HWI_MAX))) 69 #else 70 #define HWI_NUM_VALID(num) (HWI_NUM_GE_MIN(num) && ((num) <= (UINT32)OS_USER_HWI_MAX)) 71 #endif 72 extern VOID HalIrqInit(VOID); 73 extern VOID HalIrqInitPercpu(VOID); 74 extern UINT32 HalIrqMask(UINT32 hwiNum); 75 extern UINT32 HalIrqUnmask(UINT32 hwiNum); 76 extern UINT32 HalIrqTrigger(UINT32 hwiNum); 77 extern UINT32 HalIrqClear(UINT32 hwiNum); 78 extern CHAR *HalIrqVersion(VOID); 79 extern UINT32 HalCurIrqGet(VOID); 80 extern UINT32 HalIrqSetPrio(UINT32 hwiNum, UINT16 priority); 81 extern UINT32 HalIrqPendingGet(UINT32 hwiNum, UINT8 *isPending); 82 extern UINT32 HalIrqSetAffinity(UINT32 hwiNum, UINT32 cpuMask); 83 #ifdef LOSCFG_KERNEL_SMP 84 extern UINT32 HalIrqSendIpi(UINT32 target, UINT32 ipi); 85 #endif 86 #ifdef LOSCFG_HWI_CONTROLLER_DIRECT_CALL 87 extern VOID HalIrqHandler(UINT32 hwiNum); 88 #endif 89 #ifdef LOSCFG_RISCV_LCMP_CLIC 90 extern UINT32 HalIrqSetClicIntAttr(UINT32 hwiNum, UINT8 clicintattr); 91 #endif 92 93 typedef VOID (*GIC_PROC_FUNC)(VOID); 94 GIC_PROC_FUNC HalGetGicdHook(VOID); 95 VOID HalSetGicdHook(GIC_PROC_FUNC gicdHook); 96 97 #ifdef LOSCFG_ARM_GIC_LPI_ENABLE 98 GIC_PROC_FUNC HalGetGicLpiHook(VOID); 99 VOID HalSetGicLpiHook(GIC_PROC_FUNC gicLpiHook); 100 #endif 101 /* 102 * NOTE: HalIrqPending() is DEPRECATED and will be deleted in the future. 103 * Please use HalIrqTrigger() or LOS_HwiTrigger() instead. 104 */ 105 #define HalIrqPending HalIrqTrigger 106 107 #ifdef __cplusplus 108 } 109 #endif /* __cplusplus */ 110 111 #endif /* _HAL_HWI_H */ 112