!555 feat:内核提供Interrupt框架,支持多架构多平台通用化
Merge pull request !555 from 王树林/master
This commit is contained in:
commit
161e631dcd
|
@ -97,7 +97,8 @@ extern UINT32 g_intCount;
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a arm9 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -147,7 +148,8 @@ extern UINT32 g_intCount;
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a arm9 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -157,7 +159,8 @@ extern UINT32 g_intCount;
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -204,25 +207,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -48,9 +48,6 @@
|
|||
#define OS_INT_ENABLE_ADDR (OS_INT_REG_BASE)
|
||||
#define OS_INT_STATUS_ADDR (OS_INT_REG_BASE + 12)
|
||||
|
||||
#define OS_INT_ENABLE(num) (*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (num)))
|
||||
#define OS_INT_DISABLE(num) (*((volatile UINT32 *)OS_INT_ENABLE_ADDR ) &= ~(1U << (num)))
|
||||
|
||||
#define OS_INSTR_SET_MASK 0x01000020U
|
||||
#define OS_ARM_INSTR_LEN 4
|
||||
#define OS_THUMB_INSTR_LEN 2
|
||||
|
@ -112,20 +109,49 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
UINT32 status;
|
||||
|
||||
READ_UINT32(status, OS_INT_STATUS_ADDR);
|
||||
|
||||
return (31 - CLZ(status));
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (hwiNum));
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) &= ~(1U << (hwiNum));
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -140,8 +166,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -175,7 +201,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
OsSchedUpdateSleepTime();
|
||||
#endif
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -237,7 +263,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
OS_INT_ENABLE(hwiNum);
|
||||
HwiUnmask(hwiNum);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
|
@ -258,7 +284,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
|||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
OS_INT_DISABLE(hwiNum);
|
||||
HwiMask(hwiNum);
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M3 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M3 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -108,17 +108,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -133,8 +201,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -168,7 +236,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -234,8 +302,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
@ -257,7 +325,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
|||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
HwiMask((IRQn_Type)hwiNum);
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "los_memory.h"
|
||||
#include "los_membox.h"
|
||||
|
||||
#define DEF_HANDLER_START_INDEX 2
|
||||
/*lint -save -e40 -e522 -e533*/
|
||||
UINT32 g_intCount = 0;
|
||||
|
||||
|
@ -98,17 +99,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -123,8 +192,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -158,7 +227,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -224,8 +293,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
@ -247,7 +316,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
|||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
HwiMask((IRQn_Type)hwiNum);
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
|
@ -493,7 +562,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||
UINT32 index;
|
||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||
g_hwiForm[1] = 0; /* [1] reset */
|
||||
for (index = 2; index < OS_VECTOR_CNT; index++) {
|
||||
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
}
|
||||
/* Exception handler register */
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "los_memory.h"
|
||||
#include "los_membox.h"
|
||||
|
||||
#define DEF_HANDLER_START_INDEX 2
|
||||
/*lint -save -e40 -e522 -e533*/
|
||||
UINT32 g_intCount = 0;
|
||||
|
||||
|
@ -98,17 +99,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -123,8 +192,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -158,7 +227,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -224,8 +293,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
@ -491,9 +560,9 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||
{
|
||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||
UINT32 index;
|
||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||
g_hwiForm[1] = 0; /* [1] reset */
|
||||
for (index = 2; index < OS_VECTOR_CNT; index++) {
|
||||
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
|
||||
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||
}
|
||||
/* Exception handler register */
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -105,17 +105,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -130,8 +198,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -167,7 +235,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -233,8 +301,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -105,17 +105,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -130,8 +198,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -167,7 +235,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -233,8 +301,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M4 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -103,17 +103,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -128,8 +196,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -163,7 +231,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -229,8 +297,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
@ -252,7 +320,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
|||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
HwiMask((IRQn_Type)hwiNum);
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M4 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -109,17 +109,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -134,8 +202,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -169,7 +237,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -235,8 +303,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M7 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -98,17 +98,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -123,8 +191,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -158,7 +226,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -224,8 +292,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000900
|
||||
*
|
||||
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
* Solution: Ensure that the interrupt number is valid.
|
||||
* The value range of the interrupt number applicable for a Cortex-M7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||
|
||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000905
|
||||
*
|
||||
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
|
||||
* Solution: Ensure that the interrupt priority is valid.
|
||||
* The value range of the interrupt priority applicable for a Cortex-M7 platform is [0,15].
|
||||
*/
|
||||
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||
|
||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
|||
*
|
||||
* Value: 0x02000906
|
||||
*
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
|
||||
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
|
||||
*/
|
||||
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
|
||||
|
||||
|
@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -105,17 +105,85 @@ WEAK VOID SysTick_Handler(VOID)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return __get_IPSR();
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.triggerIrq = HwiPending,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -130,8 +198,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
/*lint -e529*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -165,7 +233,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -231,8 +299,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
HwiUnmask((IRQn_Type)hwiNum);
|
||||
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
|
|
@ -251,25 +251,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
*/
|
||||
extern VOID HalInterrupt(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Get an interrupt number.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to get the current interrupt number.
|
||||
*
|
||||
* @attention:
|
||||
* <ul><li>None.</li></ul>
|
||||
*
|
||||
* @param: None.
|
||||
*
|
||||
* @retval: Interrupt Indexes number.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see None.
|
||||
*/
|
||||
extern UINT32 HalIntNumGet(VOID);
|
||||
|
||||
/* *
|
||||
* @ingroup los_arch_interrupt
|
||||
* @brief: Default vector handling function.
|
||||
|
|
|
@ -117,64 +117,79 @@ UINT32 ArchIntLocked(VOID)
|
|||
return !(intSave & (1 << INT_OFFSET));
|
||||
}
|
||||
|
||||
UINT32 HalIrqUnmask(UINT32 hwiNum)
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if (!HwiNumValid(hwiNum)) {
|
||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
VIC_REG->ISER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||
VIC_REG->ISSR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 HalIrqSetPriority(UINT32 hwiNum, UINT8 priority)
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if (!HwiNumValid(hwiNum)) {
|
||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (!HWI_PRI_VALID(priority)) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 HalIrqMask(HWI_HANDLE_T hwiNum)
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if (!HwiNumValid(hwiNum)) {
|
||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 HalIrqPending(UINT32 hwiNum)
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if (!HwiNumValid(hwiNum)) {
|
||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
UINT32 HalIrqClear(UINT32 hwiNum)
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (!HwiNumValid(hwiNum)) {
|
||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
VIC_REG->ICPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
@ -207,7 +222,7 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
|
|||
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)IrqEntry;
|
||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
|
||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
|
||||
HalIrqUnmask(num);
|
||||
HwiUnmask(num);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,23 +242,32 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
|||
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
|
||||
g_hwiForm[num + OS_SYS_VECTOR_CNT] = IrqEntry;
|
||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
|
||||
HalIrqUnmask(num);
|
||||
HwiUnmask(num);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
return HalGetPsr();
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.triggerIrq = HwiPending,
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
inline UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -258,7 +282,7 @@ inline UINT32 ArchIsIntActive(VOID)
|
|||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
irqNum = (irqNum >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||
PRINT_ERR("%s irqnum:%x\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
|
@ -290,7 +314,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
hwiIndex = HwiNumGet();
|
||||
hwiIndex = (hwiIndex >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -355,8 +379,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HalIrqUnmask(hwiNum);
|
||||
(VOID)HalIrqSetPriority(hwiNum, (UINT8)hwiPrio);
|
||||
HwiUnmask(hwiNum);
|
||||
(VOID)HwiSetPriority(hwiNum, (UINT8)hwiPrio);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
return LOS_OK;
|
||||
|
@ -376,7 +400,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
|||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
HalIrqMask(hwiNum);
|
||||
HwiMask(hwiNum);
|
||||
intSave = LOS_IntLock();
|
||||
g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||
LOS_IntRestore(intSave);
|
||||
|
|
|
@ -54,6 +54,17 @@ typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
|
|||
typedef VOID (*HWI_PROC_FUNC)(void);
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
UINT32 (*triggerIrq)(HWI_HANDLE_T hwiNum);
|
||||
UINT32 (*clearIrq)(HWI_HANDLE_T hwiNum);
|
||||
UINT32 (*enableIrq)(HWI_HANDLE_T hwiNum);
|
||||
UINT32 (*disableIrq)(HWI_HANDLE_T hwiNum);
|
||||
UINT32 (*setIrqPriority)(HWI_HANDLE_T hwiNum, UINT8 priority);
|
||||
UINT32 (*getCurIrqNum)(VOID);
|
||||
} HwiControllerOps;
|
||||
|
||||
extern HwiControllerOps g_archHwiOps;
|
||||
|
||||
/* stack protector */
|
||||
extern UINT32 __stack_chk_guard;
|
||||
|
||||
|
@ -64,6 +75,11 @@ UINT32 ArchIsIntActive(VOID);
|
|||
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
|
||||
#define LOS_HwiCreate ArchHwiCreate
|
||||
#define LOS_HwiDelete ArchHwiDelete
|
||||
#define LOS_HwiTrigger ArchIntTrigger
|
||||
#define LOS_HwiEnable ArchIntEnable
|
||||
#define LOS_HwiDisable ArchIntDisable
|
||||
#define LOS_HwiClear ArchIntClear
|
||||
#define LOS_HwiSetPriority ArchIntSetPriority
|
||||
|
||||
UINT32 ArchIntLock(VOID);
|
||||
#define LOS_IntLock ArchIntLock
|
||||
|
@ -74,6 +90,8 @@ VOID ArchIntRestore(UINT32 intSave);
|
|||
UINT32 ArchIntUnLock(VOID);
|
||||
#define LOS_IntUnLock ArchIntUnLock
|
||||
|
||||
#define LOS_HwiOpsGet ArchIntOpsGet
|
||||
|
||||
/**
|
||||
* @ingroup los_interrupt
|
||||
* @brief Delete hardware interrupt.
|
||||
|
@ -135,6 +153,51 @@ UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg);
|
||||
|
||||
STATIC INLINE UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (g_archHwiOps.triggerIrq == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
return g_archHwiOps.triggerIrq(hwiNum);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (g_archHwiOps.enableIrq == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
return g_archHwiOps.enableIrq(hwiNum);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (g_archHwiOps.disableIrq == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
return g_archHwiOps.disableIrq(hwiNum);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (g_archHwiOps.clearIrq == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
return g_archHwiOps.clearIrq(hwiNum);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
|
||||
{
|
||||
if (g_archHwiOps.setIrqPriority == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
return g_archHwiOps.setIrqPriority(hwiNum, priority);
|
||||
}
|
||||
|
||||
STATIC INLINE HwiControllerOps *ArchIntOpsGet(VOID)
|
||||
{
|
||||
return &g_archHwiOps;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -39,7 +39,43 @@
|
|||
|
||||
UINT32 g_intCount = 0;
|
||||
|
||||
// LosExcInfo g_excInfo;
|
||||
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
ECLIC_EnableIRQ(hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
ECLIC_DisableIRQ(hwiNum);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||
{
|
||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
if (priority > OS_HWI_PRIO_HIGHEST || priority < OS_HWI_PRIO_LOWEST) {
|
||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||
}
|
||||
|
||||
ECLIC_SetPriorityIRQ(hwiNum, (hwiPrio & 0xffff));
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||
{
|
||||
// already setup interrupt vectors
|
||||
|
@ -59,11 +95,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||
Output : None
|
||||
Return : LOS_OK on success or error code on failure
|
||||
*****************************************************************************/
|
||||
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T mode,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||
HWI_PRIOR_T hwiPrio,
|
||||
HWI_MODE_T mode,
|
||||
HWI_PROC_FUNC handler,
|
||||
HWI_ARG_T arg)
|
||||
{
|
||||
if (hwiNum > SOC_INT_MAX) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
|
@ -93,7 +129,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
|||
ECLIC_SetVector(hwiNum, (rv_csr_t)handler);
|
||||
}
|
||||
/* enable interrupt */
|
||||
ECLIC_EnableIRQ(hwiNum);
|
||||
HwiUnmask(hwiNum);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
@ -108,7 +144,7 @@ LITE_OS_SEC_TEXT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
|||
// change func to default func
|
||||
ECLIC_SetVector(hwiNum, (rv_csr_t)HalHwiDefaultHandler);
|
||||
// disable interrupt
|
||||
ECLIC_DisableIRQ(hwiNum);
|
||||
HwiMask(hwiNum);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
@ -182,3 +218,8 @@ __attribute__((always_inline)) inline UINT32 ArchIsIntActive(VOID)
|
|||
return (g_intCount > 0);
|
||||
}
|
||||
|
||||
const HwiControllerOps g_archHwiOps = {
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.setIrqPriority = HwiSetPriority,
|
||||
};
|
||||
|
|
|
@ -214,7 +214,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
|||
#endif
|
||||
|
||||
VOID HalInterrupt(VOID);
|
||||
UINT32 HalIntNumGet(VOID);
|
||||
VOID HalHwiDefaultHandler(VOID);
|
||||
VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
|
||||
VOID HalHwiInit(VOID);
|
||||
|
|
|
@ -142,6 +142,7 @@ UINT32 ArchIntUnLock(VOID)
|
|||
STATIC INLINE UINT32 ArchIntLocked(VOID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
__asm__ volatile("rsr %0, ps " : "=r"(intSave) : : "memory");
|
||||
|
||||
return (intSave & SPREG_PS_DI_MASK);
|
||||
|
@ -151,7 +152,7 @@ STATIC INLINE UINT32 ArchIntLocked(VOID)
|
|||
* @ingroup los_hwi
|
||||
* Trigger the interrupt
|
||||
*/
|
||||
UINT32 HalIrqPending(HWI_HANDLE_T hwiNum)
|
||||
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
if (!HwiNumValid(hwiNum)) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
|
@ -162,11 +163,7 @@ UINT32 HalIrqPending(HWI_HANDLE_T hwiNum)
|
|||
return LOS_OK;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* Unmask the interrupt
|
||||
*/
|
||||
UINT32 HalIrqUnmask(HWI_HANDLE_T hwiNum)
|
||||
UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 ier;
|
||||
|
||||
|
@ -180,11 +177,7 @@ UINT32 HalIrqUnmask(HWI_HANDLE_T hwiNum)
|
|||
return LOS_OK;
|
||||
}
|
||||
|
||||
/* *
|
||||
* @ingroup los_hwi
|
||||
* Mask the interrupt
|
||||
*/
|
||||
UINT32 HalIrqMask(HWI_HANDLE_T hwiNum)
|
||||
UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||
{
|
||||
UINT32 ier;
|
||||
|
||||
|
@ -199,13 +192,13 @@ UINT32 HalIrqMask(HWI_HANDLE_T hwiNum)
|
|||
}
|
||||
|
||||
/* ****************************************************************************
|
||||
Function : HalIntNumGet
|
||||
Function : HwiNumGet
|
||||
Description : Get an interrupt number
|
||||
Input : None
|
||||
Output : None
|
||||
Return : Interrupt Indexes number
|
||||
**************************************************************************** */
|
||||
UINT32 HalIntNumGet(VOID)
|
||||
STATIC UINT32 HwiNumGet(VOID)
|
||||
{
|
||||
UINT32 ier;
|
||||
UINT32 intenable;
|
||||
|
@ -223,7 +216,7 @@ UINT32 HalIntNumGet(VOID)
|
|||
* @ingroup los_hwi
|
||||
* Clear the interrupt
|
||||
*/
|
||||
UINT32 HalIrqClear(HWI_HANDLE_T vector)
|
||||
STATIC UINT32 HwiClear(HWI_HANDLE_T vector)
|
||||
{
|
||||
if (!HwiNumValid(vector)) {
|
||||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
|
@ -234,6 +227,14 @@ UINT32 HalIrqClear(HWI_HANDLE_T vector)
|
|||
return LOS_OK;
|
||||
}
|
||||
|
||||
HwiControllerOps g_archHwiOps = {
|
||||
.triggerIrq = HwiPending,
|
||||
.enableIrq = HwiUnmask,
|
||||
.disableIrq = HwiMask,
|
||||
.getCurIrqNum = HwiNumGet,
|
||||
.clearIrq = HwiClear,
|
||||
};
|
||||
|
||||
INLINE UINT32 ArchIsIntActive(VOID)
|
||||
{
|
||||
return (g_intCount > 0);
|
||||
|
@ -248,8 +249,8 @@ INLINE UINT32 ArchIsIntActive(VOID)
|
|||
**************************************************************************** */
|
||||
VOID HalHwiDefaultHandler(VOID)
|
||||
{
|
||||
UINT32 irqNum = HalIntNumGet();
|
||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
||||
UINT32 irqNum = HwiNumGet();
|
||||
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
|
@ -279,8 +280,8 @@ VOID HalInterrupt(VOID)
|
|||
g_intCount++;
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
hwiIndex = HalIntNumGet();
|
||||
HalIrqClear(hwiIndex);
|
||||
hwiIndex = HwiNumGet();
|
||||
HwiClear(hwiIndex);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||
|
||||
|
@ -347,7 +348,7 @@ UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
|||
#else
|
||||
OsSetVector(hwiNum, handler);
|
||||
#endif
|
||||
HalIrqUnmask(hwiNum);
|
||||
HwiUnmask(hwiNum);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
|
@ -369,7 +370,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
|||
return OS_ERRNO_HWI_NUM_INVALID;
|
||||
}
|
||||
|
||||
HalIrqMask(hwiNum);
|
||||
HwiMask(hwiNum);
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
|
||||
|
@ -514,9 +515,9 @@ VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type
|
|||
if ((taskCB == NULL) || (taskCB == OS_TCB_FROM_TID(g_taskMaxNum))) {
|
||||
g_excInfo.phase = OS_EXC_IN_INIT;
|
||||
g_excInfo.thrdPid = OS_NULL_INT;
|
||||
} else if (HalIntNumGet() != OS_NULL_INT) {
|
||||
} else if (HwiNumGet() != OS_NULL_INT) {
|
||||
g_excInfo.phase = OS_EXC_IN_HWI;
|
||||
g_excInfo.thrdPid = HalIntNumGet();
|
||||
g_excInfo.thrdPid = HwiNumGet();
|
||||
} else {
|
||||
g_excInfo.phase = OS_EXC_IN_TASK;
|
||||
g_excInfo.thrdPid = g_losTask.runTask->taskID;
|
||||
|
@ -551,7 +552,7 @@ VOID HalHwiInit(VOID)
|
|||
EnableExceptionInterface();
|
||||
for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) {
|
||||
g_hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler;
|
||||
HalIrqMask(i);
|
||||
HwiMask(i);
|
||||
}
|
||||
asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START));
|
||||
return;
|
||||
|
|
|
@ -73,7 +73,7 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
|||
__asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0));
|
||||
__asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0));
|
||||
|
||||
HalIrqUnmask(tick->irqNum);
|
||||
HwiUnmask(tick->irqNum);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
@ -109,12 +109,12 @@ STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
|||
|
||||
STATIC VOID SysTickLock(VOID)
|
||||
{
|
||||
HalIrqMask(OS_TICK_INT_NUM);
|
||||
HwiMask(OS_TICK_INT_NUM);
|
||||
}
|
||||
|
||||
STATIC VOID SysTickUnlock(VOID)
|
||||
{
|
||||
HalIrqUnmask(OS_TICK_INT_NUM);
|
||||
HwiUnmask(OS_TICK_INT_NUM);
|
||||
}
|
||||
|
||||
ArchTickTimer *ArchSysTickTimerGet(VOID)
|
||||
|
|
|
@ -302,16 +302,12 @@ UINT64 LosCpuCycleGet(VOID)
|
|||
#define HWI_BIT 2
|
||||
VOID TestHwiTrigger(UINT32 hwiNum)
|
||||
{
|
||||
#if defined(__CSKY_V2__) || defined(__XTENSA_LX6__)
|
||||
HalIrqPending(hwiNum);
|
||||
#else
|
||||
*(volatile UINT32 *)(OS_NVIC_SETPEND + ((hwiNum >> HWI_SHIFT_NUM) << HWI_BIT)) = 1 << (hwiNum & 0x1F);
|
||||
#endif
|
||||
LOS_HwiTrigger(hwiNum);
|
||||
}
|
||||
|
||||
VOID TestHwiUnTrigger(UINT32 hwiNum)
|
||||
{
|
||||
*(volatile UINT32 *)(OS_NVIC_CLRPEND + ((hwiNum >> HWI_SHIFT_NUM) << HWI_BIT)) = 1 << (hwiNum & 0x1F);
|
||||
LOS_HwiClear(hwiNum);
|
||||
}
|
||||
#define OS_NVIC_CLRENA_BASE 0xE000E180
|
||||
#define NVIC_CLR_IRQ(uwHwiNum) \
|
||||
|
|
Loading…
Reference in New Issue