Merge branch 'master' of gitee.com:openharmony/kernel_liteos_m into master
Signed-off-by: LiteOS2021 <dinglu@huawei.com>
This commit is contained in:
commit
39558ae1a3
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
### 是否需要同步至release(如:3.0LTS ... )分支?
|
### 是否需要同步至release(如:3.0LTS ... )分支?
|
||||||
|
|
||||||
必须选择一项:
|
必须选择一项(在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
|
||||||
- [ ] 是,需要同步的分支:
|
- [ ] 是,需要同步的分支:
|
||||||
- [ ] 否
|
- [ ] 否
|
||||||
|
|
||||||
|
|
1
BUILD.gn
1
BUILD.gn
|
@ -143,6 +143,7 @@ config("kconfig_config") {
|
||||||
"$LITEOS_MENUCONFIG_H",
|
"$LITEOS_MENUCONFIG_H",
|
||||||
]
|
]
|
||||||
asmflags = cflags
|
asmflags = cflags
|
||||||
|
cflags_cc = cflags
|
||||||
}
|
}
|
||||||
|
|
||||||
config("warn_config") {
|
config("warn_config") {
|
||||||
|
|
|
@ -97,7 +97,8 @@ extern UINT32 g_intCount;
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -147,7 +148,8 @@ extern UINT32 g_intCount;
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -157,7 +159,8 @@ extern UINT32 g_intCount;
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -48,9 +48,6 @@
|
||||||
#define OS_INT_ENABLE_ADDR (OS_INT_REG_BASE)
|
#define OS_INT_ENABLE_ADDR (OS_INT_REG_BASE)
|
||||||
#define OS_INT_STATUS_ADDR (OS_INT_REG_BASE + 12)
|
#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_INSTR_SET_MASK 0x01000020U
|
||||||
#define OS_ARM_INSTR_LEN 4
|
#define OS_ARM_INSTR_LEN 4
|
||||||
#define OS_THUMB_INSTR_LEN 2
|
#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
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
UINT32 status;
|
UINT32 status;
|
||||||
|
|
||||||
READ_UINT32(status, OS_INT_STATUS_ADDR);
|
READ_UINT32(status, OS_INT_STATUS_ADDR);
|
||||||
|
|
||||||
return (31 - CLZ(status));
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -140,8 +166,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +201,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
OsSchedUpdateSleepTime();
|
OsSchedUpdateSleepTime();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -237,7 +263,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
OS_INT_ENABLE(hwiNum);
|
HwiUnmask(hwiNum);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
@ -258,7 +284,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
OS_INT_DISABLE(hwiNum);
|
HwiMask(hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -108,17 +108,85 @@ WEAK VOID SysTick_Handler(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -133,8 +201,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +236,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -234,8 +302,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
@ -257,7 +325,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
HwiMask((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
|
||||||
|
#define DEF_HANDLER_START_INDEX 2
|
||||||
/*lint -save -e40 -e522 -e533*/
|
/*lint -save -e40 -e522 -e533*/
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
|
@ -98,17 +99,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -123,8 +192,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +227,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -224,8 +293,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
@ -247,7 +316,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
HwiMask((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
|
@ -493,7 +562,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
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;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_membox.h"
|
#include "los_membox.h"
|
||||||
|
|
||||||
|
#define DEF_HANDLER_START_INDEX 2
|
||||||
/*lint -save -e40 -e522 -e533*/
|
/*lint -save -e40 -e522 -e533*/
|
||||||
UINT32 g_intCount = 0;
|
UINT32 g_intCount = 0;
|
||||||
|
|
||||||
|
@ -98,17 +99,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -123,8 +192,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +227,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -224,8 +293,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
@ -491,9 +560,9 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||||
{
|
{
|
||||||
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
g_hwiForm[0] = 0; /* [0] Top of Stack */
|
||||||
g_hwiForm[1] = 0; /* [1] reset */
|
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;
|
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
|
||||||
}
|
}
|
||||||
/* Exception handler register */
|
/* Exception handler register */
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_hwi
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -105,17 +105,85 @@ WEAK VOID SysTick_Handler(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -130,8 +198,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +235,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -233,8 +301,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_hwi
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -105,17 +105,85 @@ WEAK VOID SysTick_Handler(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -130,8 +198,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +235,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -233,8 +301,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -103,17 +103,85 @@ WEAK VOID SysTick_Handler(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -128,8 +196,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +231,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -229,8 +297,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
@ -252,7 +320,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
NVIC_DisableIRQ((IRQn_Type)hwiNum);
|
HwiMask((IRQn_Type)hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -109,17 +109,85 @@ WEAK VOID SysTick_Handler(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -134,8 +202,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +237,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -235,8 +303,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -98,17 +98,85 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -123,8 +191,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +226,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -224,8 +292,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000900
|
* 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)
|
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
|
||||||
|
|
||||||
|
@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000905
|
* 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)
|
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
|
||||||
*
|
*
|
||||||
* Value: 0x02000906
|
* 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)
|
#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);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -105,17 +105,85 @@ WEAK VOID SysTick_Handler(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return __get_IPSR();
|
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)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -130,8 +198,8 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
/*lint -e529*/
|
/*lint -e529*/
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +233,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -231,8 +299,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
NVIC_EnableIRQ((IRQn_Type)hwiNum);
|
HwiUnmask((IRQn_Type)hwiNum);
|
||||||
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
|
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
|
|
@ -251,25 +251,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
|
||||||
*/
|
*/
|
||||||
extern VOID HalInterrupt(VOID);
|
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
|
* @ingroup los_arch_interrupt
|
||||||
* @brief: Default vector handling function.
|
* @brief: Default vector handling function.
|
||||||
|
|
|
@ -117,64 +117,79 @@ UINT32 ArchIntLocked(VOID)
|
||||||
return !(intSave & (1 << INT_OFFSET));
|
return !(intSave & (1 << INT_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 HalIrqUnmask(UINT32 hwiNum)
|
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
if (!HwiNumValid(hwiNum)) {
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->ISER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
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));
|
VIC_REG->ISSR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 HalIrqSetPriority(UINT32 hwiNum, UINT8 priority)
|
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
if (!HwiNumValid(hwiNum)) {
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HWI_PRI_VALID(priority)) {
|
if (!HWI_PRI_VALID(priority)) {
|
||||||
return OS_ERRNO_HWI_PRIO_INVALID;
|
return OS_ERRNO_HWI_PRIO_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT);
|
VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 HalIrqMask(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
if (!HwiNumValid(hwiNum)) {
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 HalIrqPending(UINT32 hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
if (!HwiNumValid(hwiNum)) {
|
if (!HwiNumValid(hwiNum)) {
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 HalIrqClear(UINT32 hwiNum)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (!HwiNumValid(hwiNum)) {
|
if (!HwiNumValid(hwiNum)) {
|
||||||
return LOS_ERRNO_HWI_NUM_INVALID;
|
return LOS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIC_REG->ICPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
VIC_REG->ICPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
|
||||||
|
|
||||||
return LOS_OK;
|
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_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].pfnHandler = vector;
|
||||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
|
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) {
|
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
|
||||||
g_hwiForm[num + OS_SYS_VECTOR_CNT] = IrqEntry;
|
g_hwiForm[num + OS_SYS_VECTOR_CNT] = IrqEntry;
|
||||||
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
|
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
|
||||||
HalIrqUnmask(num);
|
HwiUnmask(num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
return HalGetPsr();
|
return HalGetPsr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.setIrqPriority = HwiSetPriority,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
inline UINT32 ArchIsIntActive(VOID)
|
inline UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -258,7 +282,7 @@ inline UINT32 ArchIsIntActive(VOID)
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
irqNum = (irqNum >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
irqNum = (irqNum >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||||
PRINT_ERR("%s irqnum:%x\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%x\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
|
@ -290,7 +314,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
hwiIndex = (hwiIndex >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
hwiIndex = (hwiIndex >> PSR_VEC_OFFSET) & MASK_8_BITS;
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -355,8 +379,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
HalIrqUnmask(hwiNum);
|
HwiUnmask(hwiNum);
|
||||||
(VOID)HalIrqSetPriority(hwiNum, (UINT8)hwiPrio);
|
(VOID)HwiSetPriority(hwiNum, (UINT8)hwiPrio);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
@ -376,7 +400,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||||
if (hwiNum >= OS_HWI_MAX_NUM) {
|
if (hwiNum >= OS_HWI_MAX_NUM) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
HalIrqMask(hwiNum);
|
HwiMask(hwiNum);
|
||||||
intSave = LOS_IntLock();
|
intSave = LOS_IntLock();
|
||||||
g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
|
@ -54,6 +54,17 @@ typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
|
||||||
typedef VOID (*HWI_PROC_FUNC)(void);
|
typedef VOID (*HWI_PROC_FUNC)(void);
|
||||||
#endif
|
#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 */
|
/* stack protector */
|
||||||
extern UINT32 __stack_chk_guard;
|
extern UINT32 __stack_chk_guard;
|
||||||
|
|
||||||
|
@ -64,6 +75,11 @@ UINT32 ArchIsIntActive(VOID);
|
||||||
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
|
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
|
||||||
#define LOS_HwiCreate ArchHwiCreate
|
#define LOS_HwiCreate ArchHwiCreate
|
||||||
#define LOS_HwiDelete ArchHwiDelete
|
#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);
|
UINT32 ArchIntLock(VOID);
|
||||||
#define LOS_IntLock ArchIntLock
|
#define LOS_IntLock ArchIntLock
|
||||||
|
@ -74,6 +90,8 @@ VOID ArchIntRestore(UINT32 intSave);
|
||||||
UINT32 ArchIntUnLock(VOID);
|
UINT32 ArchIntUnLock(VOID);
|
||||||
#define LOS_IntUnLock ArchIntUnLock
|
#define LOS_IntUnLock ArchIntUnLock
|
||||||
|
|
||||||
|
#define LOS_HwiOpsGet ArchIntOpsGet
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_interrupt
|
* @ingroup los_interrupt
|
||||||
* @brief Delete hardware interrupt.
|
* @brief Delete hardware interrupt.
|
||||||
|
@ -135,6 +153,51 @@ UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC handler,
|
||||||
HWI_ARG_T arg);
|
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
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,43 @@
|
||||||
|
|
||||||
UINT32 g_intCount = 0;
|
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)
|
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||||
{
|
{
|
||||||
// already setup interrupt vectors
|
// already setup interrupt vectors
|
||||||
|
@ -59,11 +95,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||||
Output : None
|
Output : None
|
||||||
Return : LOS_OK on success or error code on failure
|
Return : LOS_OK on success or error code on failure
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
HWI_PRIOR_T hwiPrio,
|
HWI_PRIOR_T hwiPrio,
|
||||||
HWI_MODE_T mode,
|
HWI_MODE_T mode,
|
||||||
HWI_PROC_FUNC handler,
|
HWI_PROC_FUNC handler,
|
||||||
HWI_ARG_T arg)
|
HWI_ARG_T arg)
|
||||||
{
|
{
|
||||||
if (hwiNum > SOC_INT_MAX) {
|
if (hwiNum > SOC_INT_MAX) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
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);
|
ECLIC_SetVector(hwiNum, (rv_csr_t)handler);
|
||||||
}
|
}
|
||||||
/* enable interrupt */
|
/* enable interrupt */
|
||||||
ECLIC_EnableIRQ(hwiNum);
|
HwiUnmask(hwiNum);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +144,7 @@ LITE_OS_SEC_TEXT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||||
// change func to default func
|
// change func to default func
|
||||||
ECLIC_SetVector(hwiNum, (rv_csr_t)HalHwiDefaultHandler);
|
ECLIC_SetVector(hwiNum, (rv_csr_t)HalHwiDefaultHandler);
|
||||||
// disable interrupt
|
// disable interrupt
|
||||||
ECLIC_DisableIRQ(hwiNum);
|
HwiMask(hwiNum);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,3 +218,8 @@ __attribute__((always_inline)) inline UINT32 ArchIsIntActive(VOID)
|
||||||
return (g_intCount > 0);
|
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
|
#endif
|
||||||
|
|
||||||
VOID HalInterrupt(VOID);
|
VOID HalInterrupt(VOID);
|
||||||
UINT32 HalIntNumGet(VOID);
|
|
||||||
VOID HalHwiDefaultHandler(VOID);
|
VOID HalHwiDefaultHandler(VOID);
|
||||||
VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
|
VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
|
||||||
VOID HalHwiInit(VOID);
|
VOID HalHwiInit(VOID);
|
||||||
|
|
|
@ -142,6 +142,7 @@ UINT32 ArchIntUnLock(VOID)
|
||||||
STATIC INLINE UINT32 ArchIntLocked(VOID)
|
STATIC INLINE UINT32 ArchIntLocked(VOID)
|
||||||
{
|
{
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
|
||||||
__asm__ volatile("rsr %0, ps " : "=r"(intSave) : : "memory");
|
__asm__ volatile("rsr %0, ps " : "=r"(intSave) : : "memory");
|
||||||
|
|
||||||
return (intSave & SPREG_PS_DI_MASK);
|
return (intSave & SPREG_PS_DI_MASK);
|
||||||
|
@ -151,7 +152,7 @@ STATIC INLINE UINT32 ArchIntLocked(VOID)
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* Trigger the interrupt
|
* Trigger the interrupt
|
||||||
*/
|
*/
|
||||||
UINT32 HalIrqPending(HWI_HANDLE_T hwiNum)
|
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
|
||||||
{
|
{
|
||||||
if (!HwiNumValid(hwiNum)) {
|
if (!HwiNumValid(hwiNum)) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
@ -162,11 +163,7 @@ UINT32 HalIrqPending(HWI_HANDLE_T hwiNum)
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *
|
UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
|
||||||
* @ingroup los_hwi
|
|
||||||
* Unmask the interrupt
|
|
||||||
*/
|
|
||||||
UINT32 HalIrqUnmask(HWI_HANDLE_T hwiNum)
|
|
||||||
{
|
{
|
||||||
UINT32 ier;
|
UINT32 ier;
|
||||||
|
|
||||||
|
@ -180,11 +177,7 @@ UINT32 HalIrqUnmask(HWI_HANDLE_T hwiNum)
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *
|
UINT32 HwiMask(HWI_HANDLE_T hwiNum)
|
||||||
* @ingroup los_hwi
|
|
||||||
* Mask the interrupt
|
|
||||||
*/
|
|
||||||
UINT32 HalIrqMask(HWI_HANDLE_T hwiNum)
|
|
||||||
{
|
{
|
||||||
UINT32 ier;
|
UINT32 ier;
|
||||||
|
|
||||||
|
@ -199,13 +192,13 @@ UINT32 HalIrqMask(HWI_HANDLE_T hwiNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ****************************************************************************
|
/* ****************************************************************************
|
||||||
Function : HalIntNumGet
|
Function : HwiNumGet
|
||||||
Description : Get an interrupt number
|
Description : Get an interrupt number
|
||||||
Input : None
|
Input : None
|
||||||
Output : None
|
Output : None
|
||||||
Return : Interrupt Indexes number
|
Return : Interrupt Indexes number
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
UINT32 HalIntNumGet(VOID)
|
STATIC UINT32 HwiNumGet(VOID)
|
||||||
{
|
{
|
||||||
UINT32 ier;
|
UINT32 ier;
|
||||||
UINT32 intenable;
|
UINT32 intenable;
|
||||||
|
@ -223,7 +216,7 @@ UINT32 HalIntNumGet(VOID)
|
||||||
* @ingroup los_hwi
|
* @ingroup los_hwi
|
||||||
* Clear the interrupt
|
* Clear the interrupt
|
||||||
*/
|
*/
|
||||||
UINT32 HalIrqClear(HWI_HANDLE_T vector)
|
STATIC UINT32 HwiClear(HWI_HANDLE_T vector)
|
||||||
{
|
{
|
||||||
if (!HwiNumValid(vector)) {
|
if (!HwiNumValid(vector)) {
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
|
@ -234,6 +227,14 @@ UINT32 HalIrqClear(HWI_HANDLE_T vector)
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HwiControllerOps g_archHwiOps = {
|
||||||
|
.triggerIrq = HwiPending,
|
||||||
|
.enableIrq = HwiUnmask,
|
||||||
|
.disableIrq = HwiMask,
|
||||||
|
.getCurIrqNum = HwiNumGet,
|
||||||
|
.clearIrq = HwiClear,
|
||||||
|
};
|
||||||
|
|
||||||
INLINE UINT32 ArchIsIntActive(VOID)
|
INLINE UINT32 ArchIsIntActive(VOID)
|
||||||
{
|
{
|
||||||
return (g_intCount > 0);
|
return (g_intCount > 0);
|
||||||
|
@ -248,8 +249,8 @@ INLINE UINT32 ArchIsIntActive(VOID)
|
||||||
**************************************************************************** */
|
**************************************************************************** */
|
||||||
VOID HalHwiDefaultHandler(VOID)
|
VOID HalHwiDefaultHandler(VOID)
|
||||||
{
|
{
|
||||||
UINT32 irqNum = HalIntNumGet();
|
UINT32 irqNum = HwiNumGet();
|
||||||
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
|
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
|
||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,8 +280,8 @@ VOID HalInterrupt(VOID)
|
||||||
g_intCount++;
|
g_intCount++;
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
hwiIndex = HalIntNumGet();
|
hwiIndex = HwiNumGet();
|
||||||
HalIrqClear(hwiIndex);
|
HwiClear(hwiIndex);
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
|
||||||
|
|
||||||
|
@ -347,7 +348,7 @@ UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
|
||||||
#else
|
#else
|
||||||
OsSetVector(hwiNum, handler);
|
OsSetVector(hwiNum, handler);
|
||||||
#endif
|
#endif
|
||||||
HalIrqUnmask(hwiNum);
|
HwiUnmask(hwiNum);
|
||||||
|
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
|
@ -369,7 +370,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum)
|
||||||
return OS_ERRNO_HWI_NUM_INVALID;
|
return OS_ERRNO_HWI_NUM_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
HalIrqMask(hwiNum);
|
HwiMask(hwiNum);
|
||||||
|
|
||||||
intSave = LOS_IntLock();
|
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))) {
|
if ((taskCB == NULL) || (taskCB == OS_TCB_FROM_TID(g_taskMaxNum))) {
|
||||||
g_excInfo.phase = OS_EXC_IN_INIT;
|
g_excInfo.phase = OS_EXC_IN_INIT;
|
||||||
g_excInfo.thrdPid = OS_NULL_INT;
|
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.phase = OS_EXC_IN_HWI;
|
||||||
g_excInfo.thrdPid = HalIntNumGet();
|
g_excInfo.thrdPid = HwiNumGet();
|
||||||
} else {
|
} else {
|
||||||
g_excInfo.phase = OS_EXC_IN_TASK;
|
g_excInfo.phase = OS_EXC_IN_TASK;
|
||||||
g_excInfo.thrdPid = g_losTask.runTask->taskID;
|
g_excInfo.thrdPid = g_losTask.runTask->taskID;
|
||||||
|
@ -551,7 +552,7 @@ VOID HalHwiInit(VOID)
|
||||||
EnableExceptionInterface();
|
EnableExceptionInterface();
|
||||||
for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) {
|
for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) {
|
||||||
g_hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler;
|
g_hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler;
|
||||||
HalIrqMask(i);
|
HwiMask(i);
|
||||||
}
|
}
|
||||||
asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START));
|
asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -73,7 +73,7 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
|
||||||
__asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0));
|
__asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0));
|
||||||
__asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0));
|
__asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0));
|
||||||
|
|
||||||
HalIrqUnmask(tick->irqNum);
|
HwiUnmask(tick->irqNum);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,12 +109,12 @@ STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||||
|
|
||||||
STATIC VOID SysTickLock(VOID)
|
STATIC VOID SysTickLock(VOID)
|
||||||
{
|
{
|
||||||
HalIrqMask(OS_TICK_INT_NUM);
|
HwiMask(OS_TICK_INT_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC VOID SysTickUnlock(VOID)
|
STATIC VOID SysTickUnlock(VOID)
|
||||||
{
|
{
|
||||||
HalIrqUnmask(OS_TICK_INT_NUM);
|
HwiUnmask(OS_TICK_INT_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
ArchTickTimer *ArchSysTickTimerGet(VOID)
|
ArchTickTimer *ArchSysTickTimerGet(VOID)
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
{
|
||||||
|
"name": "@ohos/liteos_m",
|
||||||
|
"version": "3.1.0",
|
||||||
|
"description": "liteos-m kernel",
|
||||||
|
"publishAs": "code-segment",
|
||||||
|
"homePage": "https://gitee.com/openharmony",
|
||||||
|
"repository": "https://gitee.com/openharmony/kernel_liteos_m",
|
||||||
|
"license": "BSD 3-clause",
|
||||||
|
"domain": "os",
|
||||||
|
"language": "",
|
||||||
|
"private": false,
|
||||||
|
"scripts": {},
|
||||||
|
"tags": [
|
||||||
|
"kernel"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"kernel",
|
||||||
|
"liteos-m"
|
||||||
|
],
|
||||||
|
"envs": [],
|
||||||
|
"dirs": [],
|
||||||
|
"author": {},
|
||||||
|
"contributors": [],
|
||||||
|
"segment": {
|
||||||
|
"destPath": "kernel/liteos_m"
|
||||||
|
},
|
||||||
|
"component": {
|
||||||
|
"name": "liteos_m",
|
||||||
|
"subsystem": "kernel",
|
||||||
|
"syscap": [
|
||||||
|
"SystemCapability.Kernel.liteos-m"
|
||||||
|
],
|
||||||
|
"features": [],
|
||||||
|
"adapted_system_type": [
|
||||||
|
"mini"
|
||||||
|
],
|
||||||
|
"rom": "300KB",
|
||||||
|
"ram": "100KB",
|
||||||
|
"deps": {
|
||||||
|
"components": [
|
||||||
|
"utils_lite"
|
||||||
|
],
|
||||||
|
"third_party": [
|
||||||
|
"bounds_checking_function",
|
||||||
|
"cmsis",
|
||||||
|
"fatfs",
|
||||||
|
"littlefs",
|
||||||
|
"lwip",
|
||||||
|
"musl"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"build": {
|
||||||
|
"sub_component": [
|
||||||
|
"//kernel/liteos_m:kernel",
|
||||||
|
"//kernel/liteos_m:build_kernel_image"
|
||||||
|
],
|
||||||
|
"inner_kits": [],
|
||||||
|
"test": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,21 +28,15 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_m/liteos.gni")
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
import("//third_party/FatFs/FatFs.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_FAT)
|
module_switch = defined(LOSCFG_FS_FAT)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
|
||||||
"$LITEOSTHIRDPARTY/FatFs/source/diskio.c",
|
|
||||||
"$LITEOSTHIRDPARTY/FatFs/source/ff.c",
|
|
||||||
"$LITEOSTHIRDPARTY/FatFs/source/ffsystem.c",
|
|
||||||
"$LITEOSTHIRDPARTY/FatFs/source/ffunicode.c",
|
|
||||||
"fatfs.c",
|
|
||||||
]
|
|
||||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
sources = FATFS_SRC_FILES + [ "fatfs.c" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
include_dirs = [ "." ]
|
include_dirs = FATFS_INCLUDE_DIRS + [ "." ]
|
||||||
include_dirs += [ "$LITEOSTHIRDPARTY/FatFs/source" ]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,28 +32,21 @@
|
||||||
#ifndef _FATFS_H
|
#ifndef _FATFS_H
|
||||||
#define _FATFS_H
|
#define _FATFS_H
|
||||||
|
|
||||||
#include "fcntl.h"
|
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
#include "unistd.h"
|
#include "fatfs_conf.h"
|
||||||
|
#include "fcntl.h"
|
||||||
|
#include "fs_config.h"
|
||||||
#include "sys/mount.h"
|
#include "sys/mount.h"
|
||||||
#include "sys/stat.h"
|
#include "sys/stat.h"
|
||||||
#include "sys/statfs.h"
|
#include "sys/statfs.h"
|
||||||
#include "fs_config.h"
|
#include "unistd.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifndef FAT_MAX_OPEN_FILES
|
|
||||||
#define FAT_MAX_OPEN_FILES 50
|
|
||||||
#endif /* FAT_MAX_OPEN_FILES */
|
|
||||||
|
|
||||||
/* Format options */
|
|
||||||
#define FMT_FAT 0x01
|
|
||||||
#define FMT_FAT32 0x02
|
|
||||||
#define FMT_ANY 0x07
|
|
||||||
|
|
||||||
int fatfs_mount(const char *source, const char *target,
|
int fatfs_mount(const char *source, const char *target,
|
||||||
const char *filesystemtype, unsigned long mountflags,
|
const char *filesystemtype, unsigned long mountflags,
|
||||||
const void *data);
|
const void *data);
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _FATFS_CONF_H
|
||||||
|
#define _FATFS_CONF_H
|
||||||
|
|
||||||
|
#ifndef FAT_MAX_OPEN_FILES
|
||||||
|
#define FAT_MAX_OPEN_FILES 50
|
||||||
|
#endif /* FAT_MAX_OPEN_FILES */
|
||||||
|
|
||||||
|
/* Format options */
|
||||||
|
#define FMT_FAT 0x01
|
||||||
|
#define FMT_FAT32 0x02
|
||||||
|
#define FMT_ANY 0x07
|
||||||
|
|
||||||
|
#endif // _FATFS_CONF_H
|
|
@ -28,21 +28,15 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_m/liteos.gni")
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
import("//third_party/littlefs/littlefs.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_FS_LITTLEFS)
|
module_switch = defined(LOSCFG_FS_LITTLEFS)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
|
||||||
"$LITEOSTHIRDPARTY/littlefs/bd/lfs_rambd.c",
|
|
||||||
"$LITEOSTHIRDPARTY/littlefs/lfs.c",
|
|
||||||
"$LITEOSTHIRDPARTY/littlefs/lfs_util.c",
|
|
||||||
"lfs_api.c",
|
|
||||||
]
|
|
||||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
sources = LITTLEFS_SRC_FILES_FOR_KERNEL_MODULE + [ "lfs_api.c" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
include_dirs = [ "." ]
|
include_dirs = LITTLEFS_INCLUDE_DIRS + [ "." ]
|
||||||
include_dirs += [ "$LITEOSTHIRDPARTY/littlefs" ]
|
|
||||||
include_dirs += [ "$LITEOSTHIRDPARTY/littlefs/bd" ]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "errno.h"
|
#include "errno.h"
|
||||||
#include "fs_operations.h"
|
#include "fs_operations.h"
|
||||||
#include "lfs.h"
|
#include "lfs.h"
|
||||||
|
#include "lfs_conf.h"
|
||||||
#include "lfs_util.h"
|
#include "lfs_util.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "pthread.h"
|
#include "pthread.h"
|
||||||
|
@ -74,20 +75,6 @@ typedef struct {
|
||||||
lfs_dir_t dir;
|
lfs_dir_t dir;
|
||||||
} FileDirInfo;
|
} FileDirInfo;
|
||||||
|
|
||||||
#define LITTLE_FS_MAX_OPEN_FILES 100
|
|
||||||
#define LITTLE_FS_STANDARD_NAME_LENGTH 50
|
|
||||||
#define LITTLE_FS_MAX_NAME_LEN 255
|
|
||||||
|
|
||||||
#define MAX_DEF_BUF_NUM 21
|
|
||||||
#define MAX_BUFFER_LEN 100
|
|
||||||
#define MAX_WRITE_FILE_LEN 500
|
|
||||||
#define MAX_READ_FILE_LEN 500
|
|
||||||
#define LITTLEFS_MAX_LFN_LEN 255
|
|
||||||
|
|
||||||
#ifndef LFS_MAX_OPEN_DIRS
|
|
||||||
#define LFS_MAX_OPEN_DIRS 10
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LittleFsHandleStruct *GetFreeFd(int *fd);
|
LittleFsHandleStruct *GetFreeFd(int *fd);
|
||||||
|
|
||||||
int LfsMount(const char *source, const char *target, const char *fileSystemType, unsigned long mountflags,
|
int LfsMount(const char *source, const char *target, const char *fileSystemType, unsigned long mountflags,
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _LFS_CONF_H
|
||||||
|
#define _LFS_CONF_H
|
||||||
|
|
||||||
|
#define LITTLE_FS_MAX_OPEN_FILES 100
|
||||||
|
#define LITTLE_FS_STANDARD_NAME_LENGTH 50
|
||||||
|
#define LITTLE_FS_MAX_NAME_LEN 255
|
||||||
|
|
||||||
|
#define MAX_DEF_BUF_NUM 21
|
||||||
|
#define MAX_WRITE_FILE_LEN 500
|
||||||
|
#define MAX_READ_FILE_LEN 500
|
||||||
|
#define LITTLEFS_MAX_LFN_LEN 255
|
||||||
|
|
||||||
|
#ifndef LFS_MAX_OPEN_DIRS
|
||||||
|
#define LFS_MAX_OPEN_DIRS 10
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _LFS_CONF_H
|
|
@ -98,14 +98,14 @@
|
||||||
/* max numbers of other descriptors except socket descriptors */
|
/* max numbers of other descriptors except socket descriptors */
|
||||||
|
|
||||||
#ifdef LOSCFG_FS_FAT
|
#ifdef LOSCFG_FS_FAT
|
||||||
#include "fatfs.h"
|
#include "fatfs_conf.h"
|
||||||
#define __FAT_NFILE FAT_MAX_OPEN_FILES
|
#define __FAT_NFILE FAT_MAX_OPEN_FILES
|
||||||
#else
|
#else
|
||||||
#define __FAT_NFILE 0
|
#define __FAT_NFILE 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOSCFG_FS_LITTLEFS
|
#ifdef LOSCFG_FS_LITTLEFS
|
||||||
#include "lfs_api.h"
|
#include "lfs_conf.h"
|
||||||
#define __LFS_NFILE LITTLE_FS_MAX_OPEN_FILES
|
#define __LFS_NFILE LITTLE_FS_MAX_OPEN_FILES
|
||||||
#else
|
#else
|
||||||
#define __LFS_NFILE 0
|
#define __LFS_NFILE 0
|
||||||
|
@ -123,12 +123,10 @@
|
||||||
|
|
||||||
#define CONFIG_NQUEUE_DESCRIPTORS 256
|
#define CONFIG_NQUEUE_DESCRIPTORS 256
|
||||||
|
|
||||||
#undef FD_SETSIZE
|
#define TIMER_FD_OFFSET (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)
|
||||||
#define FD_SETSIZE (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)
|
|
||||||
#define CONFIG_NEXPANED_DESCRIPTORS (CONFIG_NTIME_DESCRIPTORS + CONFIG_NQUEUE_DESCRIPTORS)
|
#define CONFIG_NEXPANED_DESCRIPTORS (CONFIG_NTIME_DESCRIPTORS + CONFIG_NQUEUE_DESCRIPTORS)
|
||||||
#define FD_SET_TOTAL_SIZE (FD_SETSIZE + CONFIG_NEXPANED_DESCRIPTORS)
|
#define FD_SET_TOTAL_SIZE (TIMER_FD_OFFSET + CONFIG_NEXPANED_DESCRIPTORS)
|
||||||
#define TIMER_FD_OFFSET FD_SETSIZE
|
#define MQUEUE_FD_OFFSET (TIMER_FD_OFFSET + CONFIG_NTIME_DESCRIPTORS)
|
||||||
#define MQUEUE_FD_OFFSET (FD_SETSIZE + CONFIG_NTIME_DESCRIPTORS)
|
|
||||||
|
|
||||||
/* directory configure */
|
/* directory configure */
|
||||||
|
|
||||||
|
|
|
@ -134,10 +134,6 @@
|
||||||
#define LWIP_NETIF_LOOPBACK 1
|
#define LWIP_NETIF_LOOPBACK 1
|
||||||
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
|
||||||
#define LWIP_RAW 1
|
#define LWIP_RAW 1
|
||||||
#ifdef LOSCFG_FS_VFS
|
|
||||||
#include "vfs_config.h"
|
|
||||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
|
||||||
#endif
|
|
||||||
#define LWIP_SO_RCVBUF 1
|
#define LWIP_SO_RCVBUF 1
|
||||||
#define LWIP_SO_RCVTIMEO 1
|
#define LWIP_SO_RCVTIMEO 1
|
||||||
#define LWIP_SO_SNDTIMEO 1
|
#define LWIP_SO_SNDTIMEO 1
|
||||||
|
@ -234,4 +230,9 @@
|
||||||
// use PBUF_RAM instead of PBUF_POOL in udp_input
|
// use PBUF_RAM instead of PBUF_POOL in udp_input
|
||||||
#define USE_PBUF_RAM_UDP_INPUT 1
|
#define USE_PBUF_RAM_UDP_INPUT 1
|
||||||
|
|
||||||
|
#ifdef LOSCFG_FS_VFS
|
||||||
|
#include "vfs_config.h"
|
||||||
|
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
||||||
|
|
|
@ -31,6 +31,7 @@ import("//kernel/liteos_m/liteos.gni")
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [ "los_signal.c" ]
|
sources = [ "los_signal.c" ]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
config KERNEL_SIGNAL
|
config KERNEL_SIGNAL
|
||||||
bool "Enable Signal"
|
bool "Enable Signal"
|
||||||
default n
|
default y
|
||||||
depends on KERNEL_EXTKERNEL
|
depends on KERNEL_EXTKERNEL
|
||||||
help
|
help
|
||||||
Select y to build LiteOS with signal.
|
Select y to build LiteOS with signal.
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_m/liteos.gni")
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
import("//third_party/cmsis/cmsis.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_KAL_CMSIS)
|
module_switch = defined(LOSCFG_KAL_CMSIS)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
@ -37,9 +38,5 @@ kernel_module(module_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
include_dirs = [
|
include_dirs = CMSIS_INCLUDE_DIRS + [ "." ]
|
||||||
".",
|
|
||||||
"$LITEOSTHIRDPARTY/cmsis/CMSIS/RTOS2/Include",
|
|
||||||
"$LITEOSTHIRDPARTY/cmsis/CMSIS/Core/Include",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,6 +28,7 @@
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
import("//kernel/liteos_m/liteos.gni")
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
import("//third_party/musl/porting/liteos_m/kernel/musl.gni")
|
||||||
|
|
||||||
module_switch = defined(LOSCFG_LIBC_MUSL)
|
module_switch = defined(LOSCFG_LIBC_MUSL)
|
||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
|
@ -43,5 +44,5 @@ kernel_module(module_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
include_dirs = [ "//third_party/musl/porting/liteos_m/kernel/include" ]
|
include_dirs = MUSL_INCLUDE_DIRS
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ kernel_module(module_name) {
|
||||||
"porting/src/malloc.c",
|
"porting/src/malloc.c",
|
||||||
"porting/src/network/htonl.c",
|
"porting/src/network/htonl.c",
|
||||||
"porting/src/network/htons.c",
|
"porting/src/network/htons.c",
|
||||||
|
"porting/src/network/ntohl.c",
|
||||||
"porting/src/network/ntohs.c",
|
"porting/src/network/ntohs.c",
|
||||||
"porting/src/other_adapt.c",
|
"porting/src/other_adapt.c",
|
||||||
"porting/src/time.c",
|
"porting/src/time.c",
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ADAPT_SYS_SELECT_H
|
||||||
|
#define _ADAPT_SYS_SELECT_H
|
||||||
|
|
||||||
|
#ifdef LOSCFG_FS_VFS
|
||||||
|
#include "vfs_config.h"
|
||||||
|
|
||||||
|
#undef FD_SETSIZE
|
||||||
|
#define FD_SETSIZE TIMER_FD_OFFSET
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#undef FD_SETSIZE
|
||||||
|
#define FD_SETSIZE 1024
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include_next <sys/select.h>
|
||||||
|
|
||||||
|
#endif //_ADAPT_SYS_SELECT_H
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/features.h>
|
||||||
|
#include <byteswap.h>
|
||||||
|
|
||||||
|
uint32_t ntohl(uint32_t n)
|
||||||
|
{
|
||||||
|
union { int i; char c; } u = { 1 };
|
||||||
|
return u.c ? bswap_32(n) : n;
|
||||||
|
}
|
|
@ -62,13 +62,13 @@ config POSIX_MQUEUE_API
|
||||||
|
|
||||||
config POSIX_PIPE_API
|
config POSIX_PIPE_API
|
||||||
bool "Enable POSIX Pipe API"
|
bool "Enable POSIX Pipe API"
|
||||||
default n
|
default y
|
||||||
help
|
help
|
||||||
Answer Y to enable LiteOS support POSIX Pipe API.
|
Answer Y to enable LiteOS support POSIX Pipe API.
|
||||||
|
|
||||||
config POSIX_SIGNAL_API
|
config POSIX_SIGNAL_API
|
||||||
bool "Enable POSIX Signal API"
|
bool "Enable POSIX Signal API"
|
||||||
default n
|
default y
|
||||||
depends on KERNEL_SIGNAL
|
depends on KERNEL_SIGNAL
|
||||||
help
|
help
|
||||||
Answer Y to enable LiteOS support POSIX Signal API.
|
Answer Y to enable LiteOS support POSIX Signal API.
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_fs.h"
|
#include "los_fs.h"
|
||||||
|
|
|
@ -77,60 +77,6 @@ void (*signal(int sig, void (*func)(int)))(int)
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sigemptyset(sigset_t *set)
|
|
||||||
{
|
|
||||||
if (set == NULL) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*set = 0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sigfillset(sigset_t *set)
|
|
||||||
{
|
|
||||||
if (set == NULL) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*set = ~0;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sigaddset(sigset_t *set, int sig)
|
|
||||||
{
|
|
||||||
if ((set == NULL) || !OS_SIGNAL_VALID(sig)) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*set |= LOS_SIGNAL_MASK(sig);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sigdelset(sigset_t *set, int sig)
|
|
||||||
{
|
|
||||||
if ((set == NULL) || !OS_SIGNAL_VALID(sig)) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*set &= ~LOS_SIGNAL_MASK(sig);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int sigismember(const sigset_t *set, int sig)
|
|
||||||
{
|
|
||||||
if ((set == NULL) || !OS_SIGNAL_VALID(sig)) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ((*set & LOS_SIGNAL_MASK(sig)) != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
|
int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
|
||||||
{
|
{
|
||||||
unsigned int ret = LOS_SignalMask(how, set, oset);
|
unsigned int ret = LOS_SignalMask(how, set, oset);
|
||||||
|
|
|
@ -31,12 +31,7 @@ import("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
config("include") {
|
config("include") {
|
||||||
defines = []
|
defines = []
|
||||||
include_dirs = [
|
include_dirs = [ "include" ]
|
||||||
"include",
|
|
||||||
"//kernel/liteos_m/kernel/include",
|
|
||||||
"//kernel/liteos_m/kernel/arch/include",
|
|
||||||
"//kernel/liteos_m/components/cpup",
|
|
||||||
]
|
|
||||||
|
|
||||||
if (defined(LOSCFG_KERNEL_TEST_FULL)) {
|
if (defined(LOSCFG_KERNEL_TEST_FULL)) {
|
||||||
defines += [ "LOS_KERNEL_TEST_FULL=1" ]
|
defines += [ "LOS_KERNEL_TEST_FULL=1" ]
|
||||||
|
|
|
@ -42,35 +42,35 @@ static UINT32 TestCase(VOID)
|
||||||
{
|
{
|
||||||
volatile INT64 value = 0;
|
volatile INT64 value = 0;
|
||||||
UINT64 ret;
|
UINT64 ret;
|
||||||
UINT64 uwNewVal;
|
UINT64 newVal;
|
||||||
|
|
||||||
uwNewVal = 0xff;
|
newVal = 0xff;
|
||||||
ret = LOS_AtomicXchg64bits(&value, uwNewVal);
|
ret = LOS_AtomicXchg64bits(&value, newVal);
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||||
ICUNIT_ASSERT_EQUAL(value, 0xff, value);
|
ICUNIT_ASSERT_EQUAL(value, 0xff, value);
|
||||||
|
|
||||||
uwNewVal = 0xffff;
|
newVal = 0xffff;
|
||||||
ret = LOS_AtomicXchg64bits(&value, uwNewVal);
|
ret = LOS_AtomicXchg64bits(&value, newVal);
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0xff, ret);
|
ICUNIT_ASSERT_EQUAL(ret, 0xff, ret);
|
||||||
ICUNIT_ASSERT_EQUAL(value, 0xffff, value);
|
ICUNIT_ASSERT_EQUAL(value, 0xffff, value);
|
||||||
|
|
||||||
uwNewVal = 0xffffff;
|
newVal = 0xffffff;
|
||||||
ret = LOS_AtomicXchg64bits(&value, uwNewVal);
|
ret = LOS_AtomicXchg64bits(&value, newVal);
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0xffff, ret);
|
ICUNIT_ASSERT_EQUAL(ret, 0xffff, ret);
|
||||||
ICUNIT_ASSERT_EQUAL(value, 0xffffff, value);
|
ICUNIT_ASSERT_EQUAL(value, 0xffffff, value);
|
||||||
|
|
||||||
uwNewVal = 0xffffffff;
|
newVal = 0xffffffff;
|
||||||
ret = LOS_AtomicXchg64bits(&value, uwNewVal);
|
ret = LOS_AtomicXchg64bits(&value, newVal);
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0xffffff, ret);
|
ICUNIT_ASSERT_EQUAL(ret, 0xffffff, ret);
|
||||||
ICUNIT_ASSERT_EQUAL(value, 0xffffffff, value);
|
ICUNIT_ASSERT_EQUAL(value, 0xffffffff, value);
|
||||||
|
|
||||||
uwNewVal = 0xffffffffffff;
|
newVal = 0xffffffffffff;
|
||||||
ret = LOS_AtomicXchg64bits(&value, uwNewVal);
|
ret = LOS_AtomicXchg64bits(&value, newVal);
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0xffffffff, ret);
|
ICUNIT_ASSERT_EQUAL(ret, 0xffffffff, ret);
|
||||||
ICUNIT_ASSERT_EQUAL(value, 0xffffffffffff, value);
|
ICUNIT_ASSERT_EQUAL(value, 0xffffffffffff, value);
|
||||||
|
|
||||||
uwNewVal = 0xffffffffffffffff;
|
newVal = 0xffffffffffffffff;
|
||||||
ret = LOS_AtomicXchg64bits(&value, uwNewVal);
|
ret = LOS_AtomicXchg64bits(&value, newVal);
|
||||||
ICUNIT_ASSERT_EQUAL(ret, 0xffffffffffff, ret);
|
ICUNIT_ASSERT_EQUAL(ret, 0xffffffffffff, ret);
|
||||||
ICUNIT_ASSERT_EQUAL(value, 0xffffffffffffffff, value);
|
ICUNIT_ASSERT_EQUAL(value, 0xffffffffffffffff, value);
|
||||||
|
|
||||||
|
|
|
@ -302,16 +302,12 @@ UINT64 LosCpuCycleGet(VOID)
|
||||||
#define HWI_BIT 2
|
#define HWI_BIT 2
|
||||||
VOID TestHwiTrigger(UINT32 hwiNum)
|
VOID TestHwiTrigger(UINT32 hwiNum)
|
||||||
{
|
{
|
||||||
#if defined(__CSKY_V2__) || defined(__XTENSA_LX6__)
|
LOS_HwiTrigger(hwiNum);
|
||||||
HalIrqPending(hwiNum);
|
|
||||||
#else
|
|
||||||
*(volatile UINT32 *)(OS_NVIC_SETPEND + ((hwiNum >> HWI_SHIFT_NUM) << HWI_BIT)) = 1 << (hwiNum & 0x1F);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID TestHwiUnTrigger(UINT32 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 OS_NVIC_CLRENA_BASE 0xE000E180
|
||||||
#define NVIC_CLR_IRQ(uwHwiNum) \
|
#define NVIC_CLR_IRQ(uwHwiNum) \
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef KERNEL_TEST_H
|
#ifndef COMMON_TEST_H
|
||||||
#define KERNEL_TEST_H
|
#define COMMON_TEST_H
|
||||||
|
|
||||||
#define TESTCOUNT_NUM_1 1
|
#define TESTCOUNT_NUM_1 1
|
||||||
#define TESTCOUNT_NUM_2 2
|
#define TESTCOUNT_NUM_2 2
|
||||||
|
@ -83,6 +83,14 @@
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define ICUNIT_ASSERT_NOT_EQUAL_VOID(param, value, retcode) \
|
||||||
|
do { \
|
||||||
|
if ((param) == (value)) { \
|
||||||
|
TEST_ASSERT_EQUAL(param, value); \
|
||||||
|
return; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define ICUNIT_TRACK_EQUAL(param, value, retcode) \
|
#define ICUNIT_TRACK_EQUAL(param, value, retcode) \
|
||||||
do { \
|
do { \
|
||||||
if ((param) != (value)) { \
|
if ((param) != (value)) { \
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
LITE_TEST_SUIT(Posix, PosixFs, PosixFsFuncTestSuite);
|
LITE_TEST_SUIT(Posix, PosixFs, PosixFsFuncTestSuite);
|
||||||
|
|
||||||
/* Corresponding to different platforms, only need to modify TEST_ROOT */
|
/* Corresponding to different platforms, only need to modify TEST_ROOT */
|
||||||
#define TEST_ROOT "/ram"
|
#define TEST_ROOT "/littlefs"
|
||||||
|
|
||||||
#define TEST_FILE_PTAH_RIGHT TEST_ROOT"/FILE0" /* file path, to open/rd/close */
|
#define TEST_FILE_PTAH_RIGHT TEST_ROOT"/FILE0" /* file path, to open/rd/close */
|
||||||
|
|
||||||
|
@ -1459,6 +1459,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat003, Function | MediumTest | Leve
|
||||||
ssize_t size;
|
ssize_t size;
|
||||||
char writeBuf[TEST_BUF_SIZE] = "write test";
|
char writeBuf[TEST_BUF_SIZE] = "write test";
|
||||||
|
|
||||||
|
(void)memset_s(&buf, sizeof(buf), 0, sizeof(buf));
|
||||||
fd = open(tmpFileName, O_CREAT | O_RDWR, 0777);
|
fd = open(tmpFileName, O_CREAT | O_RDWR, 0777);
|
||||||
TEST_ASSERT_TRUE(ret != -1);
|
TEST_ASSERT_TRUE(ret != -1);
|
||||||
|
|
||||||
|
|
|
@ -276,8 +276,8 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow002, Function | MediumTest | L
|
||||||
LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow003, Function | MediumTest | Level1)
|
LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow003, Function | MediumTest | Level1)
|
||||||
{
|
{
|
||||||
double testValues[][TEST_EXPECTED + 1] = {
|
double testValues[][TEST_EXPECTED + 1] = {
|
||||||
{0.0, -7, -HUGE_VAL},
|
{0.0, -7, HUGE_VAL},
|
||||||
{-0.0, -6.22, -HUGE_VAL},
|
{-0.0, -6.22, HUGE_VAL},
|
||||||
{-7.23, 3.57, NAN},
|
{-7.23, 3.57, NAN},
|
||||||
{121223, 5674343, HUGE_VAL}
|
{121223, 5674343, HUGE_VAL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,8 +34,10 @@
|
||||||
#include <mqueue.h>
|
#include <mqueue.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "common_test.h"
|
#include "common_test.h"
|
||||||
|
#include "kernel_test.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#define MQUEUE_STANDARD_NAME_LENGTH 50
|
#define MQUEUE_STANDARD_NAME_LENGTH 52
|
||||||
#define MQUEUE_NO_ERROR 0
|
#define MQUEUE_NO_ERROR 0
|
||||||
#define MQUEUE_SEND_STRING_TEST "mq_test"
|
#define MQUEUE_SEND_STRING_TEST "mq_test"
|
||||||
#define MQUEUE_SHORT_ARRAY_LENGTH strlen(MQUEUE_SEND_STRING_TEST)
|
#define MQUEUE_SHORT_ARRAY_LENGTH strlen(MQUEUE_SEND_STRING_TEST)
|
||||||
|
@ -49,7 +51,7 @@ const int MQ_MAX_MSG = 16; // mqueue message number
|
||||||
const char MQ_MSG[] = "MessageToSend"; // mqueue message to send
|
const char MQ_MSG[] = "MessageToSend"; // mqueue message to send
|
||||||
const int MQ_MSG_LEN = sizeof(MQ_MSG); // mqueue message len to send
|
const int MQ_MSG_LEN = sizeof(MQ_MSG); // mqueue message len to send
|
||||||
|
|
||||||
const int MAX_MQ_NUMBER = 1024; // max mqueue number
|
const int MAX_MQ_NUMBER = LOSCFG_BASE_IPC_QUEUE_LIMIT - 1; // max mqueue number
|
||||||
const int MAX_MQ_NAME_LEN = 256; // max mqueue name length
|
const int MAX_MQ_NAME_LEN = 256; // max mqueue name length
|
||||||
const int MAX_MQ_MSG_SIZE = 65530; // max mqueue message size
|
const int MAX_MQ_MSG_SIZE = 65530; // max mqueue message size
|
||||||
|
|
||||||
|
@ -289,6 +291,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
|
||||||
mqd_t queue[MAX_MQ_NUMBER + 1];
|
mqd_t queue[MAX_MQ_NUMBER + 1];
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
int i;
|
int i;
|
||||||
|
(void)memset_s(queue, sizeof(queue), 0, sizeof(queue));
|
||||||
for (i=0; i<MAX_MQ_NUMBER + 1; i++) {
|
for (i=0; i<MAX_MQ_NUMBER + 1; i++) {
|
||||||
sprintf_s(qName[i], MQ_NAME_LEN, "testMqOpenENFILE_%d", i);
|
sprintf_s(qName[i], MQ_NAME_LEN, "testMqOpenENFILE_%d", i);
|
||||||
}
|
}
|
||||||
|
@ -301,7 +304,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
|
||||||
printf("break: i = %d", i);
|
printf("break: i = %d", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ICUNIT_TRACK_EQUAL(queue[i], (mqd_t)-1, queue[i]);
|
ICUNIT_TRACK_NOT_EQUAL(queue[i], (mqd_t)-1, queue[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("func: i = %d", i);
|
printf("func: i = %d", i);
|
||||||
|
@ -368,7 +371,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEAGAIN, Function | MediumTest | Le
|
||||||
attr.mq_msgsize = MQ_MSG_SIZE;
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
attr.mq_maxmsg = 1;
|
attr.mq_maxmsg = 1;
|
||||||
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
ICUNIT_ASSERT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
ICUNIT_ASSERT_NOT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
||||||
|
|
||||||
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, 0);
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, 0);
|
||||||
ICUNIT_TRACK_EQUAL(ret, 0, ret);
|
ICUNIT_TRACK_EQUAL(ret, 0, ret);
|
||||||
|
@ -400,7 +403,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
|
||||||
attr.mq_msgsize = 1;
|
attr.mq_msgsize = 1;
|
||||||
attr.mq_maxmsg = MQ_MAX_MSG;
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
ICUNIT_ASSERT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
ICUNIT_ASSERT_NOT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
||||||
|
|
||||||
ret = mq_send(NULL, MQ_MSG, 1, MQ_MSG_PRIO);
|
ret = mq_send(NULL, MQ_MSG, 1, MQ_MSG_PRIO);
|
||||||
ICUNIT_TRACK_EQUAL(ret, -1, ret);
|
ICUNIT_TRACK_EQUAL(ret, -1, ret);
|
||||||
|
@ -419,7 +422,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
|
||||||
attr.mq_msgsize = MQ_MSG_SIZE;
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
attr.mq_maxmsg = MQ_MAX_MSG;
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
queue = mq_open(qName, O_CREAT | O_RDONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
queue = mq_open(qName, O_CREAT | O_RDONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
ICUNIT_ASSERT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
ICUNIT_ASSERT_NOT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
||||||
|
|
||||||
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
ICUNIT_TRACK_EQUAL(ret, -1, ret);
|
ICUNIT_TRACK_EQUAL(ret, -1, ret);
|
||||||
|
@ -456,7 +459,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEINVAL, Function | MediumTest | Le
|
||||||
attr.mq_msgsize = MQ_MSG_SIZE;
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
attr.mq_maxmsg = MQ_MAX_MSG;
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
ICUNIT_ASSERT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
ICUNIT_ASSERT_NOT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
||||||
|
|
||||||
ret = mq_send(queue, MQ_MSG, 0, MQ_MSG_PRIO);
|
ret = mq_send(queue, MQ_MSG, 0, MQ_MSG_PRIO);
|
||||||
ICUNIT_TRACK_EQUAL(ret, -1, ret);
|
ICUNIT_TRACK_EQUAL(ret, -1, ret);
|
||||||
|
@ -487,7 +490,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqReceiveEAGAIN, Function | MediumTest |
|
||||||
attr.mq_msgsize = MQ_MSG_SIZE;
|
attr.mq_msgsize = MQ_MSG_SIZE;
|
||||||
attr.mq_maxmsg = MQ_MAX_MSG;
|
attr.mq_maxmsg = MQ_MAX_MSG;
|
||||||
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
ICUNIT_ASSERT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
ICUNIT_ASSERT_NOT_EQUAL_VOID(queue, (mqd_t)-1, queue);
|
||||||
|
|
||||||
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO);
|
||||||
ICUNIT_TRACK_EQUAL(ret, 0, ret);
|
ICUNIT_TRACK_EQUAL(ret, 0, ret);
|
||||||
|
|
|
@ -35,9 +35,13 @@
|
||||||
#include "los_config.h"
|
#include "los_config.h"
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include "common_test.h"
|
#include "common_test.h"
|
||||||
|
#include "kernel_test.h"
|
||||||
|
#include "pthread.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#define PTHREAD_TASK_DELAY 10
|
#define PTHREAD_TASK_DELAY 10
|
||||||
|
#define TASK_PRIO_TEST LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO
|
||||||
|
#define OS_TSK_TEST_STACK_SIZE 0x1000
|
||||||
static UINT32 g_testCount;
|
static UINT32 g_testCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -239,11 +239,11 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime001, Function | MediumTe
|
||||||
|
|
||||||
struct tm *tmStart = localtime(&tStart);
|
struct tm *tmStart = localtime(&tStart);
|
||||||
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmStart);
|
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmStart);
|
||||||
TEST_ASSERT_EQUAL_STRING("23:59:59", cTime);
|
TEST_ASSERT_EQUAL_STRING("07:59:59", cTime);
|
||||||
LOG("\n time_t=%lld, first time:%s", tStart, cTime);
|
LOG("\n time_t=%lld, first time:%s", tStart, cTime);
|
||||||
struct tm *tmEnd = localtime(&tEnd);
|
struct tm *tmEnd = localtime(&tEnd);
|
||||||
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmEnd);
|
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmEnd);
|
||||||
TEST_ASSERT_EQUAL_STRING("00:00:01", cTime);
|
TEST_ASSERT_EQUAL_STRING("08:00:01", cTime);
|
||||||
LOG("\n time_t=%lld, first time:%s", tEnd, cTime);
|
LOG("\n time_t=%lld, first time:%s", tEnd, cTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,13 +307,13 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltimer001, Function | MediumT
|
||||||
struct tm *tmrEndPtr = localtime_r(&tEnd, &tmrEnd);
|
struct tm *tmrEndPtr = localtime_r(&tEnd, &tmrEnd);
|
||||||
|
|
||||||
strftime(cTime, sizeof(cTime), "%H:%M:%S", &tmrStart);
|
strftime(cTime, sizeof(cTime), "%H:%M:%S", &tmrStart);
|
||||||
TEST_ASSERT_EQUAL_STRING("23:59:59", cTime);
|
TEST_ASSERT_EQUAL_STRING("07:59:59", cTime);
|
||||||
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmrStartPtr);
|
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmrStartPtr);
|
||||||
TEST_ASSERT_EQUAL_STRING("23:59:59", cTime);
|
TEST_ASSERT_EQUAL_STRING("07:59:59", cTime);
|
||||||
strftime(cTime, sizeof(cTime), "%H:%M:%S", &tmrEnd);
|
strftime(cTime, sizeof(cTime), "%H:%M:%S", &tmrEnd);
|
||||||
TEST_ASSERT_EQUAL_STRING("00:00:01", cTime);
|
TEST_ASSERT_EQUAL_STRING("08:00:01", cTime);
|
||||||
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmrEndPtr);
|
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmrEndPtr);
|
||||||
TEST_ASSERT_EQUAL_STRING("00:00:01", cTime);
|
TEST_ASSERT_EQUAL_STRING("08:00:01", cTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *
|
/* *
|
||||||
|
@ -366,12 +366,12 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime001, Function | MediumTest
|
||||||
INIT_TM(timeptr, 2020, 7, 9, 18, 10, 0, 7);
|
INIT_TM(timeptr, 2020, 7, 9, 18, 10, 0, 7);
|
||||||
time_t timeRet = mktime(&timeptr);
|
time_t timeRet = mktime(&timeptr);
|
||||||
LOG("\n 2020-7-9 18:10:00, mktime Ret = %lld", timeRet);
|
LOG("\n 2020-7-9 18:10:00, mktime Ret = %lld", timeRet);
|
||||||
TEST_ASSERT_EQUAL_INT(1596967800, timeRet);
|
TEST_ASSERT_EQUAL_INT(1596996600, timeRet);
|
||||||
|
|
||||||
INIT_TM(timeptr, 1970, 0, 1, 8, 0, 0, 0);
|
INIT_TM(timeptr, 1970, 0, 1, 8, 0, 0, 0);
|
||||||
timeRet = mktime(&timeptr);
|
timeRet = mktime(&timeptr);
|
||||||
LOG("\n 1970-1-1 08:00:00, mktime Ret = %lld", timeRet);
|
LOG("\n 1970-1-1 08:00:00, mktime Ret = %lld", timeRet);
|
||||||
TEST_ASSERT_EQUAL_INT(0, timeRet);
|
TEST_ASSERT_EQUAL_INT(28800, timeRet);
|
||||||
|
|
||||||
struct tm *stm = localtime(&testTime);
|
struct tm *stm = localtime(&testTime);
|
||||||
LOG("\n testTime 18880, tm : %s", TmToStr(stm, timeStr, TIME_STR_LEN));
|
LOG("\n testTime 18880, tm : %s", TmToStr(stm, timeStr, TIME_STR_LEN));
|
||||||
|
@ -406,7 +406,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime002, Function | MediumTest
|
||||||
INIT_TM(timeptr, 1969, 7, 9, 10, 10, 0, 7);
|
INIT_TM(timeptr, 1969, 7, 9, 10, 10, 0, 7);
|
||||||
time_t timeRet = mktime(&timeptr);
|
time_t timeRet = mktime(&timeptr);
|
||||||
LOG("\n 1800-8-9 10:10:00, mktime Ret lld = %lld", timeRet);
|
LOG("\n 1800-8-9 10:10:00, mktime Ret lld = %lld", timeRet);
|
||||||
TEST_ASSERT_EQUAL_INT(0, timeRet);
|
TEST_ASSERT_EQUAL_INT(-1, timeRet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -503,8 +503,9 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime003, Function | MediumTes
|
||||||
TEST_ASSERT_EQUAL_STRING("1970-01-01 13:14:40", buffer);
|
TEST_ASSERT_EQUAL_STRING("1970-01-01 13:14:40", buffer);
|
||||||
LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40");
|
LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40");
|
||||||
|
|
||||||
|
tmTime->__tm_zone = "UTC+8";
|
||||||
ftime = strftime(buffer, 80, "%F %T %Z", tmTime);
|
ftime = strftime(buffer, 80, "%F %T %Z", tmTime);
|
||||||
TEST_ASSERT_EQUAL_INT(0, ftime);
|
TEST_ASSERT_EQUAL_INT(20, ftime);
|
||||||
LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40");
|
LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -546,7 +547,7 @@ RUN_TEST_SUITE(PosixTimeFuncTestSuite);
|
||||||
|
|
||||||
void PosixTimeFuncTest()
|
void PosixTimeFuncTest()
|
||||||
{
|
{
|
||||||
LOG("begin PosixTimeFuncTest....");
|
LOG("begin PosixTimeFuncTest....\n");
|
||||||
|
|
||||||
RUN_ONE_TESTCASE(testTimeUSleep001);
|
RUN_ONE_TESTCASE(testTimeUSleep001);
|
||||||
RUN_ONE_TESTCASE(testTimeUSleep002);
|
RUN_ONE_TESTCASE(testTimeUSleep002);
|
||||||
|
|
Loading…
Reference in New Issue