|
|
|
@ -25,7 +25,7 @@
|
|
|
|
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
* --------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
//定义了一些与硬件中断处理相关的数据结构和函数接口,用于操作和管理系统中的硬件中断。
|
|
|
|
|
#ifndef _LOS_HWI_PRI_H
|
|
|
|
|
#define _LOS_HWI_PRI_H
|
|
|
|
|
|
|
|
|
@ -67,9 +67,11 @@ typedef struct {
|
|
|
|
|
} HwiControllerOps;
|
|
|
|
|
|
|
|
|
|
extern const HwiControllerOps *g_hwiOps;
|
|
|
|
|
|
|
|
|
|
//用于初始化硬件中断
|
|
|
|
|
extern VOID OsHwiInit(VOID);
|
|
|
|
|
//用于获取当前中断嵌套的计数值,可以用于检查当前是否处于中断嵌套状态。
|
|
|
|
|
extern size_t OsIrqNestingCntGet(VOID);
|
|
|
|
|
//用于设置中断嵌套的计数值。
|
|
|
|
|
extern VOID OsIrqNestingCntSet(size_t val);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -77,8 +79,9 @@ extern VOID OsIrqNestingCntSet(size_t val);
|
|
|
|
|
* by the kernel. The handleIrq hook function MUST be registered in the interrupt controller driver layer, otherwise it
|
|
|
|
|
* will not respond. eg: Used for arm(cortex-a/r)/arm64.
|
|
|
|
|
*/
|
|
|
|
|
//一个汇编入口函数,由汇编代码在dispatch.S中调用,用于统一处理外部中断的入口,由内核接管中断处理流程。
|
|
|
|
|
extern VOID OsIntEntry(VOID);
|
|
|
|
|
|
|
|
|
|
//根据中断号获取中断处理信息的指针
|
|
|
|
|
STATIC INLINE HwiHandleInfo *OsGetHwiForm(UINT32 hwiNum)
|
|
|
|
|
{
|
|
|
|
|
if ((g_hwiOps == NULL) || (g_hwiOps->getHandleForm == NULL)) {
|
|
|
|
@ -86,7 +89,7 @@ STATIC INLINE HwiHandleInfo *OsGetHwiForm(UINT32 hwiNum)
|
|
|
|
|
}
|
|
|
|
|
return g_hwiOps->getHandleForm(hwiNum);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//用于获取指定中断的响应计数值
|
|
|
|
|
STATIC INLINE UINT32 OsGetHwiFormCnt(UINT32 hwiNum)
|
|
|
|
|
{
|
|
|
|
|
HwiHandleInfo *hwiForm = OsGetHwiForm(hwiNum);
|
|
|
|
@ -96,7 +99,7 @@ STATIC INLINE UINT32 OsGetHwiFormCnt(UINT32 hwiNum)
|
|
|
|
|
}
|
|
|
|
|
return hwiForm->respCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//用于获取当前正在处理的中断号。
|
|
|
|
|
STATIC INLINE UINT32 OsIntNumGet(VOID)
|
|
|
|
|
{
|
|
|
|
|
if ((g_hwiOps == NULL) || (g_hwiOps->getCurIrqNum == NULL)) {
|
|
|
|
@ -104,7 +107,7 @@ STATIC INLINE UINT32 OsIntNumGet(VOID)
|
|
|
|
|
}
|
|
|
|
|
return g_hwiOps->getCurIrqNum();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//用于判断指定的中断号是否已经注册了相应的处理函数。
|
|
|
|
|
STATIC INLINE BOOL OsIntIsRegisted(UINT32 num)
|
|
|
|
|
{
|
|
|
|
|
HwiHandleInfo *hwiForm = OsGetHwiForm(num);
|
|
|
|
@ -118,7 +121,7 @@ STATIC INLINE BOOL OsIntIsRegisted(UINT32 num)
|
|
|
|
|
return (hwiForm->hook != NULL);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//用于获取指定中断的注册参数信息。
|
|
|
|
|
STATIC INLINE HWI_ARG_T OsIntGetPara(UINT32 num)
|
|
|
|
|
{
|
|
|
|
|
HwiHandleInfo *hwiForm = OsGetHwiForm(num);
|
|
|
|
@ -128,7 +131,7 @@ STATIC INLINE HWI_ARG_T OsIntGetPara(UINT32 num)
|
|
|
|
|
}
|
|
|
|
|
return hwiForm->registerInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//用于获取中断版本信息。
|
|
|
|
|
STATIC INLINE CHAR *OsIntVersionGet(VOID)
|
|
|
|
|
{
|
|
|
|
|
if ((g_hwiOps == NULL) || (g_hwiOps->getIrqVersion == NULL)) {
|
|
|
|
@ -143,6 +146,7 @@ STATIC INLINE CHAR *OsIntVersionGet(VOID)
|
|
|
|
|
* handleForm to this interface.
|
|
|
|
|
* eg: Used for arm(cortex-m),xtensa,riscv.
|
|
|
|
|
*/
|
|
|
|
|
//在中断控制器驱动层实现通用的中断处理入口,用于传递中断号和处理信息给相应的处理函数。
|
|
|
|
|
extern VOID OsIntHandle(UINT32 hwiNum, HwiHandleInfo *handleForm);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -151,6 +155,7 @@ extern VOID OsIntHandle(UINT32 hwiNum, HwiHandleInfo *handleForm);
|
|
|
|
|
* HwiControllerOps need to be registered. If this function is not supported, you can call the LOS_Panic interface in
|
|
|
|
|
* the implementation of the stub function to report an error in time.
|
|
|
|
|
*/
|
|
|
|
|
//用于注册中断控制器相关的操作函数,需要在中断控制器初始化时被调用。
|
|
|
|
|
STATIC INLINE VOID OsHwiControllerReg(const HwiControllerOps *ops)
|
|
|
|
|
{
|
|
|
|
|
g_hwiOps = ops;
|
|
|
|
|