10d163575Sopenharmony_ci/* 20d163575Sopenharmony_ci * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 30d163575Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 40d163575Sopenharmony_ci * 50d163575Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 60d163575Sopenharmony_ci * are permitted provided that the following conditions are met: 70d163575Sopenharmony_ci * 80d163575Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 90d163575Sopenharmony_ci * conditions and the following disclaimer. 100d163575Sopenharmony_ci * 110d163575Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 120d163575Sopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 130d163575Sopenharmony_ci * provided with the distribution. 140d163575Sopenharmony_ci * 150d163575Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 160d163575Sopenharmony_ci * to endorse or promote products derived from this software without specific prior written 170d163575Sopenharmony_ci * permission. 180d163575Sopenharmony_ci * 190d163575Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 200d163575Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 210d163575Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 220d163575Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 230d163575Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 240d163575Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 250d163575Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 260d163575Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 270d163575Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 280d163575Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 290d163575Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 300d163575Sopenharmony_ci */ 310d163575Sopenharmony_ci 320d163575Sopenharmony_ci/** 330d163575Sopenharmony_ci * @defgroup los_hwi Hardware interrupt 340d163575Sopenharmony_ci * @ingroup kernel 350d163575Sopenharmony_ci */ 360d163575Sopenharmony_ci#ifndef _LOS_HWI_H 370d163575Sopenharmony_ci#define _LOS_HWI_H 380d163575Sopenharmony_ci 390d163575Sopenharmony_ci#include "los_base.h" 400d163575Sopenharmony_ci#include "los_hw_cpu.h" 410d163575Sopenharmony_ci#include "hal_hwi.h" 420d163575Sopenharmony_ci 430d163575Sopenharmony_ci#ifdef __cplusplus 440d163575Sopenharmony_ci#if __cplusplus 450d163575Sopenharmony_ciextern "C" { 460d163575Sopenharmony_ci#endif /* __cplusplus */ 470d163575Sopenharmony_ci#endif /* __cplusplus */ 480d163575Sopenharmony_ci 490d163575Sopenharmony_ci/** 500d163575Sopenharmony_ci * @ingroup los_hwi 510d163575Sopenharmony_ci * Count of interrupts. 520d163575Sopenharmony_ci */ 530d163575Sopenharmony_ciextern size_t g_intCount[]; 540d163575Sopenharmony_ci 550d163575Sopenharmony_ci/** 560d163575Sopenharmony_ci * @ingroup los_hwi 570d163575Sopenharmony_ci * An interrupt is active. 580d163575Sopenharmony_ci */ 590d163575Sopenharmony_ci#define OS_INT_ACTIVE ({ \ 600d163575Sopenharmony_ci size_t intCount; \ 610d163575Sopenharmony_ci UINT32 intSave_ = LOS_IntLock(); \ 620d163575Sopenharmony_ci intCount = g_intCount[ArchCurrCpuid()]; \ 630d163575Sopenharmony_ci LOS_IntRestore(intSave_); \ 640d163575Sopenharmony_ci intCount; \ 650d163575Sopenharmony_ci}) 660d163575Sopenharmony_ci 670d163575Sopenharmony_ci/** 680d163575Sopenharmony_ci * @ingroup los_hwi 690d163575Sopenharmony_ci * An interrupt is inactive. 700d163575Sopenharmony_ci */ 710d163575Sopenharmony_ci#define OS_INT_INACTIVE (!(OS_INT_ACTIVE)) 720d163575Sopenharmony_ci 730d163575Sopenharmony_ci/** 740d163575Sopenharmony_ci * @ingroup los_hwi 750d163575Sopenharmony_ci * Highest priority of a hardware interrupt. 760d163575Sopenharmony_ci */ 770d163575Sopenharmony_ci#define OS_HWI_PRIO_HIGHEST 0 780d163575Sopenharmony_ci 790d163575Sopenharmony_ci/** 800d163575Sopenharmony_ci * @ingroup los_hwi 810d163575Sopenharmony_ci * Lowest priority of a hardware interrupt. 820d163575Sopenharmony_ci */ 830d163575Sopenharmony_ci#define OS_HWI_PRIO_LOWEST 31 840d163575Sopenharmony_ci 850d163575Sopenharmony_ci/** 860d163575Sopenharmony_ci * @ingroup los_hwi 870d163575Sopenharmony_ci * Max name length of a hardware interrupt. 880d163575Sopenharmony_ci */ 890d163575Sopenharmony_ci#define OS_HWI_MAX_NAMELEN 10 900d163575Sopenharmony_ci 910d163575Sopenharmony_ci/** 920d163575Sopenharmony_ci * @ingroup los_hwi 930d163575Sopenharmony_ci * Hardware interrupt error code: Invalid interrupt number. 940d163575Sopenharmony_ci * 950d163575Sopenharmony_ci * Value: 0x02000900 960d163575Sopenharmony_ci * 970d163575Sopenharmony_ci * Solution: Ensure that the interrupt number is valid. 980d163575Sopenharmony_ci */ 990d163575Sopenharmony_ci#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00) 1000d163575Sopenharmony_ci 1010d163575Sopenharmony_ci/** 1020d163575Sopenharmony_ci * @ingroup los_hwi 1030d163575Sopenharmony_ci * Hardware interrupt error code: Null hardware interrupt handling function. 1040d163575Sopenharmony_ci * 1050d163575Sopenharmony_ci * Value: 0x02000901 1060d163575Sopenharmony_ci * 1070d163575Sopenharmony_ci * Solution: Pass in a valid non-null hardware interrupt handling function. 1080d163575Sopenharmony_ci */ 1090d163575Sopenharmony_ci#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) 1100d163575Sopenharmony_ci 1110d163575Sopenharmony_ci/** 1120d163575Sopenharmony_ci * @ingroup los_hwi 1130d163575Sopenharmony_ci * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation. 1140d163575Sopenharmony_ci * 1150d163575Sopenharmony_ci * Value: 0x02000902 1160d163575Sopenharmony_ci * 1170d163575Sopenharmony_ci * Solution: Increase the configured maximum number of supported hardware interrupts. 1180d163575Sopenharmony_ci */ 1190d163575Sopenharmony_ci#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) 1200d163575Sopenharmony_ci 1210d163575Sopenharmony_ci/** 1220d163575Sopenharmony_ci * @ingroup los_hwi 1230d163575Sopenharmony_ci * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization. 1240d163575Sopenharmony_ci * 1250d163575Sopenharmony_ci * Value: 0x02000903 1260d163575Sopenharmony_ci * 1270d163575Sopenharmony_ci * Solution: Expand the configured memory. 1280d163575Sopenharmony_ci */ 1290d163575Sopenharmony_ci#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) 1300d163575Sopenharmony_ci 1310d163575Sopenharmony_ci/** 1320d163575Sopenharmony_ci * @ingroup los_hwi 1330d163575Sopenharmony_ci * Hardware interrupt error code: The interrupt has already been created. 1340d163575Sopenharmony_ci * 1350d163575Sopenharmony_ci * Value: 0x02000904 1360d163575Sopenharmony_ci * 1370d163575Sopenharmony_ci * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 1380d163575Sopenharmony_ci */ 1390d163575Sopenharmony_ci#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) 1400d163575Sopenharmony_ci 1410d163575Sopenharmony_ci/** 1420d163575Sopenharmony_ci * @ingroup los_hwi 1430d163575Sopenharmony_ci * Hardware interrupt error code: Invalid interrupt priority. 1440d163575Sopenharmony_ci * 1450d163575Sopenharmony_ci * Value: 0x02000905 1460d163575Sopenharmony_ci * 1470d163575Sopenharmony_ci * Solution: Ensure that the interrupt priority is valid. 1480d163575Sopenharmony_ci */ 1490d163575Sopenharmony_ci#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) 1500d163575Sopenharmony_ci 1510d163575Sopenharmony_ci/** 1520d163575Sopenharmony_ci * @ingroup los_hwi 1530d163575Sopenharmony_ci * Hardware interrupt error code: Incorrect interrupt creation mode. 1540d163575Sopenharmony_ci * 1550d163575Sopenharmony_ci * Value: 0x02000906 1560d163575Sopenharmony_ci * 1570d163575Sopenharmony_ci * Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of 1580d163575Sopenharmony_ci * which the value can be 0 or 1. 1590d163575Sopenharmony_ci */ 1600d163575Sopenharmony_ci#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) 1610d163575Sopenharmony_ci 1620d163575Sopenharmony_ci/** 1630d163575Sopenharmony_ci * @ingroup los_hwi 1640d163575Sopenharmony_ci * Hardware interrupt error code: The interrupt has already been created as a fast interrupt. 1650d163575Sopenharmony_ci * 1660d163575Sopenharmony_ci * Value: 0x02000907 1670d163575Sopenharmony_ci * 1680d163575Sopenharmony_ci * Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created. 1690d163575Sopenharmony_ci */ 1700d163575Sopenharmony_ci#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) 1710d163575Sopenharmony_ci 1720d163575Sopenharmony_ci/** 1730d163575Sopenharmony_ci * @ingroup los_hwi 1740d163575Sopenharmony_ci * Hardware interrupt error code: The API is called during an interrupt, which is forbidden. 1750d163575Sopenharmony_ci * 1760d163575Sopenharmony_ci * Value: 0x02000908 1770d163575Sopenharmony_ci * 1780d163575Sopenharmony_ci * * Solution: Do not call the API during an interrupt. 1790d163575Sopenharmony_ci */ 1800d163575Sopenharmony_ci#define OS_ERRNO_HWI_INTERR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08) 1810d163575Sopenharmony_ci 1820d163575Sopenharmony_ci/** 1830d163575Sopenharmony_ci * @ingroup los_hwi 1840d163575Sopenharmony_ci * Hardware interrupt error code:the hwi support SHARED error. 1850d163575Sopenharmony_ci * 1860d163575Sopenharmony_ci * Value: 0x02000909 1870d163575Sopenharmony_ci * 1880d163575Sopenharmony_ci * * Solution: Check the input params hwiMode and irqParam of LOS_HwiCreate or 1890d163575Sopenharmony_ci * LOS_HwiDelete whether adapt the current hwi. 1900d163575Sopenharmony_ci */ 1910d163575Sopenharmony_ci#define OS_ERRNO_HWI_SHARED_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x09) 1920d163575Sopenharmony_ci 1930d163575Sopenharmony_ci/** 1940d163575Sopenharmony_ci * @ingroup los_hwi 1950d163575Sopenharmony_ci * Hardware interrupt error code:Invalid interrupt Arg when interrupt mode is IRQF_SHARED. 1960d163575Sopenharmony_ci * 1970d163575Sopenharmony_ci * Value: 0x0200090a 1980d163575Sopenharmony_ci * 1990d163575Sopenharmony_ci * * Solution: Check the interrupt Arg, Arg should not be NULL and pDevId should not be NULL. 2000d163575Sopenharmony_ci */ 2010d163575Sopenharmony_ci#define OS_ERRNO_HWI_ARG_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0a) 2020d163575Sopenharmony_ci 2030d163575Sopenharmony_ci/** 2040d163575Sopenharmony_ci * @ingroup los_hwi 2050d163575Sopenharmony_ci * Hardware interrupt error code:The interrupt corresponded to the hwi number or devid has not been created. 2060d163575Sopenharmony_ci * 2070d163575Sopenharmony_ci * Value: 0x0200090b 2080d163575Sopenharmony_ci * 2090d163575Sopenharmony_ci * * Solution: Check the hwi number or devid, make sure the hwi number or devid need to delete. 2100d163575Sopenharmony_ci */ 2110d163575Sopenharmony_ci#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b) 2120d163575Sopenharmony_ci 2130d163575Sopenharmony_ci/** 2140d163575Sopenharmony_ci * @ingroup los_hwi 2150d163575Sopenharmony_ci * Define the type of a hardware interrupt number. 2160d163575Sopenharmony_ci */ 2170d163575Sopenharmony_citypedef UINT32 HWI_HANDLE_T; 2180d163575Sopenharmony_ci 2190d163575Sopenharmony_ci/** 2200d163575Sopenharmony_ci * @ingroup los_hwi 2210d163575Sopenharmony_ci * Define the type of a hardware interrupt priority. 2220d163575Sopenharmony_ci */ 2230d163575Sopenharmony_citypedef UINT16 HWI_PRIOR_T; 2240d163575Sopenharmony_ci 2250d163575Sopenharmony_ci/** 2260d163575Sopenharmony_ci * @ingroup los_hwi 2270d163575Sopenharmony_ci * Define the type of hardware interrupt mode configurations. 2280d163575Sopenharmony_ci */ 2290d163575Sopenharmony_citypedef UINT16 HWI_MODE_T; 2300d163575Sopenharmony_ci 2310d163575Sopenharmony_ci/** 2320d163575Sopenharmony_ci * @ingroup los_hwi 2330d163575Sopenharmony_ci * Define the type of the parameter used for the hardware interrupt creation function. 2340d163575Sopenharmony_ci * The function of this parameter varies among platforms. 2350d163575Sopenharmony_ci */ 2360d163575Sopenharmony_citypedef UINTPTR HWI_ARG_T; 2370d163575Sopenharmony_ci 2380d163575Sopenharmony_ci/** 2390d163575Sopenharmony_ci * @ingroup los_hwi 2400d163575Sopenharmony_ci * Define the type of a hardware interrupt handling function. 2410d163575Sopenharmony_ci */ 2420d163575Sopenharmony_citypedef VOID (*HWI_PROC_FUNC)(VOID); 2430d163575Sopenharmony_ci 2440d163575Sopenharmony_ci/* 2450d163575Sopenharmony_ci * These flags used only by the kernel as part of the 2460d163575Sopenharmony_ci * irq handling routines. 2470d163575Sopenharmony_ci * 2480d163575Sopenharmony_ci * IRQF_SHARED - allow sharing the irq among several devices 2490d163575Sopenharmony_ci */ 2500d163575Sopenharmony_ci#define IRQF_SHARED 0x8000U 2510d163575Sopenharmony_ci 2520d163575Sopenharmony_citypedef struct tagHwiHandleForm { 2530d163575Sopenharmony_ci HWI_PROC_FUNC pfnHook; 2540d163575Sopenharmony_ci HWI_ARG_T uwParam; 2550d163575Sopenharmony_ci struct tagHwiHandleForm *pstNext; 2560d163575Sopenharmony_ci} HwiHandleForm; 2570d163575Sopenharmony_ci 2580d163575Sopenharmony_citypedef struct tagIrqParam { 2590d163575Sopenharmony_ci int swIrq; 2600d163575Sopenharmony_ci VOID *pDevId; 2610d163575Sopenharmony_ci const CHAR *pName; 2620d163575Sopenharmony_ci} HwiIrqParam; 2630d163575Sopenharmony_ci 2640d163575Sopenharmony_ciextern HwiHandleForm g_hwiForm[OS_HWI_MAX_NUM]; 2650d163575Sopenharmony_ci 2660d163575Sopenharmony_ci/** 2670d163575Sopenharmony_ci * @ingroup los_hwi 2680d163575Sopenharmony_ci * @brief Disable all interrupts. 2690d163575Sopenharmony_ci * 2700d163575Sopenharmony_ci * @par Description: 2710d163575Sopenharmony_ci * <ul> 2720d163575Sopenharmony_ci * <li>This API is used to disable all IRQ and FIQ interrupts in the CPSR.</li> 2730d163575Sopenharmony_ci * </ul> 2740d163575Sopenharmony_ci * @attention 2750d163575Sopenharmony_ci * <ul> 2760d163575Sopenharmony_ci * <li>None.</li> 2770d163575Sopenharmony_ci * </ul> 2780d163575Sopenharmony_ci * 2790d163575Sopenharmony_ci * @param None. 2800d163575Sopenharmony_ci * 2810d163575Sopenharmony_ci * @retval #UINT32 CPSR value obtained before all interrupts are disabled. 2820d163575Sopenharmony_ci * @par Dependency: 2830d163575Sopenharmony_ci * <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> 2840d163575Sopenharmony_ci * @see LOS_IntRestore 2850d163575Sopenharmony_ci */ 2860d163575Sopenharmony_ciSTATIC INLINE UINT32 LOS_IntLock(VOID) 2870d163575Sopenharmony_ci{ 2880d163575Sopenharmony_ci return ArchIntLock(); 2890d163575Sopenharmony_ci} 2900d163575Sopenharmony_ci 2910d163575Sopenharmony_ci/** 2920d163575Sopenharmony_ci * @ingroup los_hwi 2930d163575Sopenharmony_ci * @brief Enable all interrupts. 2940d163575Sopenharmony_ci * 2950d163575Sopenharmony_ci * @par Description: 2960d163575Sopenharmony_ci * <ul> 2970d163575Sopenharmony_ci * <li>This API is used to enable all IRQ and FIQ interrupts in the CPSR.</li> 2980d163575Sopenharmony_ci * </ul> 2990d163575Sopenharmony_ci * @attention 3000d163575Sopenharmony_ci * <ul> 3010d163575Sopenharmony_ci * <li>None.</li> 3020d163575Sopenharmony_ci * </ul> 3030d163575Sopenharmony_ci * 3040d163575Sopenharmony_ci * @param None. 3050d163575Sopenharmony_ci * 3060d163575Sopenharmony_ci * @retval #UINT32 CPSR value obtained after all interrupts are enabled. 3070d163575Sopenharmony_ci * @par Dependency: 3080d163575Sopenharmony_ci * <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> 3090d163575Sopenharmony_ci * @see LOS_IntLock 3100d163575Sopenharmony_ci */ 3110d163575Sopenharmony_ciSTATIC INLINE UINT32 LOS_IntUnLock(VOID) 3120d163575Sopenharmony_ci{ 3130d163575Sopenharmony_ci return ArchIntUnlock(); 3140d163575Sopenharmony_ci} 3150d163575Sopenharmony_ci 3160d163575Sopenharmony_ci/** 3170d163575Sopenharmony_ci * @ingroup los_hwi 3180d163575Sopenharmony_ci * @brief Restore interrupts. 3190d163575Sopenharmony_ci * 3200d163575Sopenharmony_ci * @par Description: 3210d163575Sopenharmony_ci * <ul> 3220d163575Sopenharmony_ci * <li>This API is used to restore the CPSR value obtained before all interrupts are disabled.</li> 3230d163575Sopenharmony_ci * </ul> 3240d163575Sopenharmony_ci * @attention 3250d163575Sopenharmony_ci * <ul> 3260d163575Sopenharmony_ci * <li>This API can be called only after all interrupts are disabled, and the input parameter value should be 3270d163575Sopenharmony_ci * the value returned by LOS_IntLock.</li> 3280d163575Sopenharmony_ci * </ul> 3290d163575Sopenharmony_ci * 3300d163575Sopenharmony_ci * @param intSave [IN] Type #UINT32 : CPSR value obtained before all interrupts are disabled. 3310d163575Sopenharmony_ci * 3320d163575Sopenharmony_ci * @retval None. 3330d163575Sopenharmony_ci * @par Dependency: 3340d163575Sopenharmony_ci * <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> 3350d163575Sopenharmony_ci * @see LOS_IntLock 3360d163575Sopenharmony_ci */ 3370d163575Sopenharmony_ciSTATIC INLINE VOID LOS_IntRestore(UINT32 intSave) 3380d163575Sopenharmony_ci{ 3390d163575Sopenharmony_ci ArchIntRestore(intSave); 3400d163575Sopenharmony_ci} 3410d163575Sopenharmony_ci 3420d163575Sopenharmony_ci/** 3430d163575Sopenharmony_ci * @ingroup los_hwi 3440d163575Sopenharmony_ci * @brief Gets the maximum number of interrupts supported by the system. 3450d163575Sopenharmony_ci * 3460d163575Sopenharmony_ci * @par Description: 3470d163575Sopenharmony_ci * <ul> 3480d163575Sopenharmony_ci * <li>This API is used to gets the maximum number of interrupts supported by the system.</li> 3490d163575Sopenharmony_ci * </ul> 3500d163575Sopenharmony_ci * 3510d163575Sopenharmony_ci * @param None. 3520d163575Sopenharmony_ci * 3530d163575Sopenharmony_ci * @retval None. 3540d163575Sopenharmony_ci * @par Dependency: 3550d163575Sopenharmony_ci * <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> 3560d163575Sopenharmony_ci */ 3570d163575Sopenharmony_ciextern UINT32 LOS_GetSystemHwiMaximum(VOID); 3580d163575Sopenharmony_ci 3590d163575Sopenharmony_ci/** 3600d163575Sopenharmony_ci * @ingroup los_hwi 3610d163575Sopenharmony_ci * @brief Create a hardware interrupt. 3620d163575Sopenharmony_ci * 3630d163575Sopenharmony_ci * @par Description: 3640d163575Sopenharmony_ci * This API is used to configure a hardware interrupt and register a hardware interrupt handling function. 3650d163575Sopenharmony_ci * 3660d163575Sopenharmony_ci * @attention 3670d163575Sopenharmony_ci * <ul> 3680d163575Sopenharmony_ci * <li>The hardware interrupt module is usable only when the configuration item for 3690d163575Sopenharmony_ci * hardware interrupt tailoring is enabled.</li> 3700d163575Sopenharmony_ci * <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. </li> 3710d163575Sopenharmony_ci * <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li> 3720d163575Sopenharmony_ci * <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li> 3730d163575Sopenharmony_ci * <li>The parameter handler of this interface is a interrupt handler, it should be correct, otherwise, 3740d163575Sopenharmony_ci * the system may be abnormal.</li> 3750d163575Sopenharmony_ci * <li>The input irqParam could be NULL, if not, it should be address which point to a struct HwiIrqParam</li> 3760d163575Sopenharmony_ci * </ul> 3770d163575Sopenharmony_ci * 3780d163575Sopenharmony_ci * @param hwiNum [IN] Type #HWI_HANDLE_T: hardware interrupt number. 3790d163575Sopenharmony_ci * for an ARM926 platform is [0,31]. 3800d163575Sopenharmony_ci * @param hwiPrio [IN] Type #HWI_PRIOR_T: hardware interrupt priority. The value range is 3810d163575Sopenharmony_ci * [0, GIC_MAX_INTERRUPT_PREEMPTION_LEVEL - 1] << PRIORITY_SHIFT. 3820d163575Sopenharmony_ci * @param hwiMode [IN] Type #HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily. 3830d163575Sopenharmony_ci * @param hwiHandler [IN] Type #HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered. 3840d163575Sopenharmony_ci * @param irqParam [IN] Type #HwiIrqParam: input parameter of the interrupt handler used when 3850d163575Sopenharmony_ci * a hardware interrupt is triggered. 3860d163575Sopenharmony_ci * 3870d163575Sopenharmony_ci * @retval #OS_ERRNO_HWI_PROC_FUNC_NULL Null hardware interrupt handling function. 3880d163575Sopenharmony_ci * @retval #OS_ERRNO_HWI_NUM_INVALID Invalid interrupt number. 3890d163575Sopenharmony_ci * @retval #OS_ERRNO_HWI_NO_MEMORY Insufficient memory for hardware interrupt creation. 3900d163575Sopenharmony_ci * @retval #OS_ERRNO_HWI_ALREADY_CREATED The interrupt handler being created has already been created. 3910d163575Sopenharmony_ci * @retval #LOS_OK The interrupt is successfully created. 3920d163575Sopenharmony_ci * @par Dependency: 3930d163575Sopenharmony_ci * <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> 3940d163575Sopenharmony_ci * @see None. 3950d163575Sopenharmony_ci */ 3960d163575Sopenharmony_ciextern UINT32 LOS_HwiCreate(HWI_HANDLE_T hwiNum, 3970d163575Sopenharmony_ci HWI_PRIOR_T hwiPrio, 3980d163575Sopenharmony_ci HWI_MODE_T hwiMode, 3990d163575Sopenharmony_ci HWI_PROC_FUNC hwiHandler, 4000d163575Sopenharmony_ci HwiIrqParam *irqParam); 4010d163575Sopenharmony_ci 4020d163575Sopenharmony_ci/** 4030d163575Sopenharmony_ci * @ingroup los_hwi 4040d163575Sopenharmony_ci * @brief delete a hardware interrupt. 4050d163575Sopenharmony_ci * 4060d163575Sopenharmony_ci * @par Description: 4070d163575Sopenharmony_ci * This API is used to delete a hardware interrupt. 4080d163575Sopenharmony_ci * 4090d163575Sopenharmony_ci * @attention 4100d163575Sopenharmony_ci * <ul> 4110d163575Sopenharmony_ci * <li>The hardware interrupt module is usable only when the configuration item for 4120d163575Sopenharmony_ci * hardware interrupt tailoring is enabled.</li> 4130d163575Sopenharmony_ci * <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX].</li> 4140d163575Sopenharmony_ci * <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li> 4150d163575Sopenharmony_ci * <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li> 4160d163575Sopenharmony_ci * </ul> 4170d163575Sopenharmony_ci * 4180d163575Sopenharmony_ci * @param hwiNum [IN] Type #HWI_HANDLE_T: hardware interrupt number. 4190d163575Sopenharmony_ci * @param irqParam [IN] Type #HwiIrqParam *: id of hardware interrupt which will base on 4200d163575Sopenharmony_ci * when delete the hardware interrupt. 4210d163575Sopenharmony_ci * 4220d163575Sopenharmony_ci * @retval #OS_ERRNO_HWI_NUM_INVALID Invalid interrupt number. 4230d163575Sopenharmony_ci * @retval #OS_ERRNO_HWI_SHARED_ERROR Invalid interrupt mode. 4240d163575Sopenharmony_ci * @retval #LOS_OK The interrupt is successfully deleted. 4250d163575Sopenharmony_ci * @retval #LOS_NOK The interrupt is failed deleted based on the pDev_ID. 4260d163575Sopenharmony_ci 4270d163575Sopenharmony_ci * @par Dependency: 4280d163575Sopenharmony_ci * <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> 4290d163575Sopenharmony_ci * @see None. 4300d163575Sopenharmony_ci */ 4310d163575Sopenharmony_ciextern UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam); 4320d163575Sopenharmony_ci 4330d163575Sopenharmony_ci#ifdef __cplusplus 4340d163575Sopenharmony_ci#if __cplusplus 4350d163575Sopenharmony_ci} 4360d163575Sopenharmony_ci#endif /* __cplusplus */ 4370d163575Sopenharmony_ci#endif /* __cplusplus */ 4380d163575Sopenharmony_ci 4390d163575Sopenharmony_ci#endif /* _LOS_HWI_H */ 440