更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
Hardware interrupt
Hardware interrupt 的协作图:

类型定义

typedef UINT32 HWI_HANDLE_T
 
typedef UINT16 HWI_PRIOR_T
 
typedef UINT16 HWI_MODE_T
 
typedef UINTPTR HWI_ARG_T
 
typedef VOID(* HWI_PROC_FUNC) (VOID)
 

函数

STATIC INLINE UINT32 LOS_IntLock (VOID)
 Disable all interrupts. | 关闭当前处理器所有中断响应 更多...
 
STATIC INLINE UINT32 LOS_IntUnLock (VOID)
 Enable all interrupts. | 打开当前处理器所有中断响应 更多...
 
STATIC INLINE VOID LOS_IntRestore (UINT32 intSave)
 Restore interrupts. | 恢复到使用LOS_IntLock关闭所有中断之前的状态 更多...
 
UINT32 LOS_GetSystemHwiMaximum (VOID)
 Gets the maximum number of interrupts supported by the system. 更多...
 
UINT32 LOS_HwiCreate (HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio, HWI_MODE_T hwiMode, HWI_PROC_FUNC hwiHandler, HwiIrqParam *irqParam)
 Create a hardware interrupt. 更多...
 
UINT32 LOS_HwiDelete (HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
 delete a hardware interrupt. 更多...
 

变量

size_t g_intCount []
 中断次数,每个CPU都会记录响应中断的次数 更多...
 

详细描述

类型定义说明

◆ HWI_ARG_T

typedef UINTPTR HWI_ARG_T

Define the type of the parameter used for the hardware interrupt creation function. The function of this parameter varies among platforms.

在文件 los_hwi.h236 行定义.

◆ HWI_HANDLE_T

Define the type of a hardware interrupt number. //定义硬件中断号的类型

在文件 los_hwi.h217 行定义.

◆ HWI_MODE_T

typedef UINT16 HWI_MODE_T

Define the type of hardware interrupt mode configurations. //定义硬件中断配置的类型

在文件 los_hwi.h229 行定义.

◆ HWI_PRIOR_T

Define the type of a hardware interrupt priority. //定义硬件中断优先级的类型

在文件 los_hwi.h223 行定义.

◆ HWI_PROC_FUNC

typedef VOID(* HWI_PROC_FUNC) (VOID)

Define the type of a hardware interrupt handling function. //定义硬件中断处理函数的类型

在文件 los_hwi.h242 行定义.

函数说明

◆ LOS_GetSystemHwiMaximum()

UINT32 LOS_GetSystemHwiMaximum ( VOID  )

Gets the maximum number of interrupts supported by the system.

Description:
  • This API is used to gets the maximum number of interrupts supported by the system.
参数
None.
返回值
None.
Dependency:
  • los_hwi.h: the header file that contains the API declaration.

Gets the maximum number of interrupts supported by the system.

在文件 los_hwi.c174 行定义.

175{
176 return OS_HWI_MAX_NUM;
177}

◆ LOS_HwiCreate()

UINT32 LOS_HwiCreate ( HWI_HANDLE_T  hwiNum,
HWI_PRIOR_T  hwiPrio,
HWI_MODE_T  hwiMode,
HWI_PROC_FUNC  hwiHandler,
HwiIrqParam irqParam 
)

Create a hardware interrupt.

Description:
This API is used to configure a hardware interrupt and register a hardware interrupt handling function.
注意
  • The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
  • Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
  • OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
  • Before executing an interrupt on a platform, refer to the chip manual of the platform.
  • The parameter handler of this interface is a interrupt handler, it should be correct, otherwise, the system may be abnormal.
  • The input irqParam could be NULL, if not, it should be address which point to a struct HwiIrqParam
参数
hwiNum[IN] Type HWI_HANDLE_T: hardware interrupt number. for an ARM926 platform is [0,31].
hwiPrio[IN] Type HWI_PRIOR_T: hardware interrupt priority. The value range is [0, GIC_MAX_INTERRUPT_PREEMPTION_LEVEL - 1] << PRIORITY_SHIFT.
hwiMode[IN] Type HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
hwiHandler[IN] Type HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
irqParam[IN] Type HwiIrqParam: input parameter of the interrupt handler used when a hardware interrupt is triggered.
返回值
#OS_ERRNO_HWI_PROC_FUNC_NULLNull hardware interrupt handling function.
#OS_ERRNO_HWI_NUM_INVALIDInvalid interrupt number.
#OS_ERRNO_HWI_NO_MEMORYInsufficient memory for hardware interrupt creation.
#OS_ERRNO_HWI_ALREADY_CREATEDThe interrupt handler being created has already been created.
#LOS_OKThe interrupt is successfully created.
Dependency:
  • los_hwi.h: the header file that contains the API declaration.
参见
None.

Create a hardware interrupt.

参数
hwiNum硬中断句柄编号 默认范围[0-127]
hwiPrio硬中断优先级
hwiMode硬中断模式 共享和非共享
hwiHandler硬中断处理函数
irqParam硬中断处理函数参数
返回
LITE_OS_SEC_TEXT_INIT

在文件 los_hwi.c429 行定义.

434{
435 UINT32 ret;
436
437 (VOID)hwiPrio;
438 if (hwiHandler == NULL) {//中断处理函数不能为NULL
439 return OS_ERRNO_HWI_PROC_FUNC_NULL;
440 }
441 if ((hwiNum > OS_USER_HWI_MAX) || ((INT32)hwiNum < OS_USER_HWI_MIN)) {//中断数区间限制 [32,96]
442 return OS_ERRNO_HWI_NUM_INVALID;
443 }
444
445#ifdef LOSCFG_NO_SHARED_IRQ //不支持共享中断
446 ret = OsHwiCreateNoShared(hwiNum, hwiMode, hwiHandler, irqParam);
447#else
448 ret = OsHwiCreateShared(hwiNum, hwiMode, hwiHandler, irqParam);
449#endif
450 return ret;
451}
STATIC UINT32 OsHwiCreateNoShared(HWI_HANDLE_T hwiNum, HWI_MODE_T hwiMode, HWI_PROC_FUNC hwiHandler, const HwiIrqParam *irqParam)
创建一个不支持共享的中断
Definition: los_hwi.c:258
STATIC UINT32 OsHwiCreateShared(HWI_HANDLE_T hwiNum, HWI_MODE_T hwiMode, HWI_PROC_FUNC hwiHandler, const HwiIrqParam *irqParam)
创建一个共享硬件中断,共享中断就是一个中断能触发多个响应函数
Definition: los_hwi.c:340
signed int INT32
Definition: los_typedef.h:60
unsigned int UINT32
Definition: los_typedef.h:57
函数调用图:
这是这个函数的调用关系图:

◆ LOS_HwiDelete()

UINT32 LOS_HwiDelete ( HWI_HANDLE_T  hwiNum,
HwiIrqParam irqParam 
)

delete a hardware interrupt.

Description:
This API is used to delete a hardware interrupt.
注意
  • The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.
  • Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
  • OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.
  • Before executing an interrupt on a platform, refer to the chip manual of the platform.
参数
hwiNum[IN] Type HWI_HANDLE_T: hardware interrupt number.
irqParam[IN] Type HwiIrqParam *: id of hardware interrupt which will base on when delete the hardware interrupt.
返回值
#OS_ERRNO_HWI_NUM_INVALIDInvalid interrupt number.
#OS_ERRNO_HWI_SHARED_ERRORInvalid interrupt mode.
#LOS_OKThe interrupt is successfully deleted.
#LOS_NOKThe interrupt is failed deleted based on the pDev_ID.
Dependency:
  • los_hwi.h: the header file that contains the API declaration.
参见
None.

delete a hardware interrupt.

在文件 los_hwi.c453 行定义.

454{
455 UINT32 ret;
456
457 if ((hwiNum > OS_USER_HWI_MAX) || ((INT32)hwiNum < OS_USER_HWI_MIN)) {
458 return OS_ERRNO_HWI_NUM_INVALID;
459 }
460
461#ifdef LOSCFG_NO_SHARED_IRQ //不支持共享中断
462 ret = OsHwiDelNoShared(hwiNum);
463#else
464 ret = OsHwiDelShared(hwiNum, irqParam);
465#endif
466 return ret;
467}
STATIC UINT32 OsHwiDelShared(HWI_HANDLE_T hwiNum, const HwiIrqParam *irqParam)
Definition: los_hwi.c:282
STATIC UINT32 OsHwiDelNoShared(HWI_HANDLE_T hwiNum)
Definition: los_hwi.c:243
函数调用图:

◆ LOS_IntLock()

STATIC INLINE UINT32 LOS_IntLock ( VOID  )

Disable all interrupts. | 关闭当前处理器所有中断响应

Description:
  • This API is used to disable all IRQ and FIQ interrupts in the CPSR.
注意
  • None.
参数
None.
返回值
UINT32CPSR value obtained before all interrupts are disabled.
Dependency:
  • los_hwi.h: the header file that contains the API declaration.
参见
LOS_IntRestore

在文件 los_hwi.h286 行定义.

287{//此API用于禁用CPSR中的所有IRQ和FIQ中断。CPSR:程序状态寄存器(current program status register)
288 return ArchIntLock();
289}//IRQ(Interrupt Request):指中断模式。FIQ(Fast Interrupt Request):指快速中断模式。
STATIC INLINE UINT32 ArchIntLock(VOID)
禁止中断
Definition: los_hw_cpu.h:190
函数调用图:
这是这个函数的调用关系图:

◆ LOS_IntRestore()

STATIC INLINE VOID LOS_IntRestore ( UINT32  intSave)

Restore interrupts. | 恢复到使用LOS_IntLock关闭所有中断之前的状态

Description:
  • This API is used to restore the CPSR value obtained before all interrupts are disabled.
注意
  • This API can be called only after all interrupts are disabled, and the input parameter value should be the value returned by LOS_IntLock.
参数
intSave[IN] Type UINT32 : CPSR value obtained before all interrupts are disabled.
返回值
None.
Dependency:
  • los_hwi.h: the header file that contains the API declaration.
参见
LOS_IntLock

在文件 los_hwi.h337 行定义.

338{//只有在禁用所有中断之后才能调用此API,并且输入参数值应为LOS_IntLock返回的值。
339 ArchIntRestore(intSave);
340}
STATIC INLINE VOID ArchIntRestore(UINT32 intSave)
恢复到使用LOS_IntLock关闭所有中断之前的状态
Definition: los_hw_cpu.h:260
函数调用图:
这是这个函数的调用关系图:

◆ LOS_IntUnLock()

STATIC INLINE UINT32 LOS_IntUnLock ( VOID  )

Enable all interrupts. | 打开当前处理器所有中断响应

Description:
  • This API is used to enable all IRQ and FIQ interrupts in the CPSR.
注意
  • None.
参数
None.
返回值
UINT32CPSR value obtained after all interrupts are enabled.
Dependency:
  • los_hwi.h: the header file that contains the API declaration.
参见
LOS_IntLock

在文件 los_hwi.h311 行定义.

312{//此API用于启用CPSR中的所有IRQ和FIQ中断。
313 return ArchIntUnlock();
314}
STATIC INLINE UINT32 ArchIntUnlock(VOID)
打开当前处理器所有中断响应
Definition: los_hw_cpu.h:202
函数调用图:
这是这个函数的调用关系图:

变量说明

◆ g_intCount

size_t g_intCount[]
extern

中断次数,每个CPU都会记录响应中断的次数

Count of interrupts.

中断次数,每个CPU都会记录响应中断的次数

在文件 los_hwi.c153 行定义.