diff --git a/arch/arm/BUILD.gn b/arch/arm/BUILD.gn
index 917a005b..128f3a57 100644
--- a/arch/arm/BUILD.gn
+++ b/arch/arm/BUILD.gn
@@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
-# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2023 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:
@@ -34,10 +34,11 @@ config("arm_config") {
}
module_group("arm") {
+ modules = [ "common" ]
if (defined(LOSCFG_COMPILER_ICCARM)) {
- modules = [ "$board_cpu/iar" ]
+ modules += [ "$board_cpu/iar" ]
} else {
- modules = [ "$board_cpu/gcc" ]
+ modules += [ "$board_cpu/gcc" ]
}
configs = [ ":arm_config" ]
}
diff --git a/arch/arm/arm9/gcc/los_arch_interrupt.h b/arch/arm/arm9/gcc/los_arch_interrupt.h
index 588cf60b..5c16c386 100644
--- a/arch/arm/arm9/gcc/los_arch_interrupt.h
+++ b/arch/arm/arm9/gcc/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,19 +56,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
-/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_arch_interrupt
- * Count of interrupts.
- */
-extern UINT32 g_intCount;
-
/* *
* @ingroup los_arch_interrupt
* Count of arm9 system interrupt vector.
@@ -174,19 +151,15 @@ extern UINT32 g_intCount;
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
*/
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
/* *
* @ingroup los_arch_interrupt
@@ -207,35 +180,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
/**
* @ingroup los_exc
* the struct of register files
@@ -325,7 +269,6 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_intCount;
extern ExcInfo g_excInfo;
#ifdef __cplusplus
diff --git a/arch/arm/arm9/gcc/los_interrupt.c b/arch/arm/arm9/gcc/los_interrupt.c
index d0f20ec7..995546a6 100644
--- a/arch/arm/arm9/gcc/los_interrupt.c
+++ b/arch/arm/arm9/gcc/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -42,7 +40,6 @@
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
-#include "los_reg.h"
#define OS_INT_IRQ_ENABLE (1U << 0)
#define OS_INT_FIQ_ENABLE (1U << 1)
@@ -55,86 +52,8 @@
#define OS_ARM_INSTR_LEN 4
#define OS_THUMB_INSTR_LEN 2
-UINT32 g_intCount = 0;
ExcInfo g_excInfo = {0};
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -153,10 +72,6 @@ STATIC UINT32 HwiNumGet(VOID)
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;
@@ -164,48 +79,28 @@ STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ (VOID)hwiPrio;
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.getCurIrqNum = HwiNumGet,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -264,87 +159,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
- HwiUnmask(hwiNum);
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- HwiMask(hwiNum);
-
- intSave = LOS_IntLock();
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#if (LOSCFG_KERNEL_PRINTF != 0)
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
@@ -511,13 +325,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 reg;
UINT32 val;
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
for (val = OS_SYS_VECTOR_CNT; val < OS_VECTOR_CNT; val++) {
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- g_hwiForm[val].pfnHook = HalHwiDefaultHandler;
- g_hwiForm[val].uwParam = 0;
+ hwiForm[val].pfnHook = HalHwiDefaultHandler;
+ hwiForm[val].uwParam = 0;
#else
- g_hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
#endif
}
@@ -560,4 +375,3 @@ UINT32 ArchIntUnLock(VOID)
: "memory");
return intSave;
}
-
diff --git a/arch/arm/common/BUILD.gn b/arch/arm/common/BUILD.gn
new file mode 100644
index 00000000..763b9c9d
--- /dev/null
+++ b/arch/arm/common/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright (c) 2023-2023 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.
+
+import("//kernel/liteos_m/liteos.gni")
+
+module_name = "common"
+kernel_module(module_name) {
+ sources = [ "los_common_interrupt.c" ]
+ configs += [ "$LITEOSTOPDIR:warn_config" ]
+}
+
+config("public") {
+ include_dirs = [ "." ]
+}
diff --git a/arch/arm/common/los_common_interrupt.c b/arch/arm/common/los_common_interrupt.c
new file mode 100644
index 00000000..b90dc5e4
--- /dev/null
+++ b/arch/arm/common/los_common_interrupt.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright (c) 2023-2023 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 "los_arch_interrupt.h"
+#include "los_debug.h"
+
+#ifdef __ICCARM__
+#pragma location = ".data.vector"
+#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt form mapping handling function array.
+ */
+HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
+#elif defined(__CC_ARM) || defined(__GNUC__)
+LITE_OS_SEC_VEC
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt form mapping handling function array.
+ */
+HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
+#endif
+
+VOID *ArchGetHwiFrom(VOID)
+{
+ return g_hwiForm;
+}
+
+UINT32 g_intCount = 0;
+
+/* ****************************************************************************
+ Function : HalHwiDefaultHandler
+ Description : default handler of the hardware interrupt
+ Input : None
+ Output : None
+ Return : None
+ **************************************************************************** */
+LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
+{
+ PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, ArchIntCurIrqNum());
+ while (1) {}
+}
+
+WEAK VOID HalPreInterruptHandler(UINT32 arg)
+{
+ (VOID)arg;
+ return;
+}
+
+WEAK VOID HalAftInterruptHandler(UINT32 arg)
+{
+ (VOID)arg;
+ return;
+}
+
+#if (LOSCFG_DEBUG_TOOLS == 1)
+STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
+STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
+
+UINT32 OsGetHwiFormCnt(UINT32 index)
+{
+ return g_hwiFormCnt[index];
+}
+
+CHAR *OsGetHwiFormName(UINT32 index)
+{
+ return g_hwiFormName[index];
+}
+
+BOOL OsHwiIsCreated(UINT32 index)
+{
+ if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+#endif
+
+#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_HANDLER_FUNC;
+
+/* *
+ * @ingroup los_hwi
+ * Hardware interrupt handler form mapping handling function array.
+ */
+HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
+ }
+}
+#else
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
+ }
+}
+#endif
+
+UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
+{
+ if (hwiNum >= OS_HWI_MAX_NUM) {
+ return OS_ERRNO_HWI_NUM_INVALID;
+ }
+
+ HwiControllerOps *hwiOps = ArchIntOpsGet();
+ if (hwiOps->triggerIrq == NULL) {
+ return OS_ERRNO_HWI_OPS_FUNC_NULL;
+ }
+
+ return hwiOps->triggerIrq(hwiNum);
+}
+
+UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
+{
+ if (hwiNum >= OS_HWI_MAX_NUM) {
+ return OS_ERRNO_HWI_NUM_INVALID;
+ }
+
+ HwiControllerOps *hwiOps = ArchIntOpsGet();
+ if (hwiOps->enableIrq == NULL) {
+ return OS_ERRNO_HWI_OPS_FUNC_NULL;
+ }
+
+ return hwiOps->enableIrq(hwiNum);
+}
+
+UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
+{
+ if (hwiNum >= OS_HWI_MAX_NUM) {
+ return OS_ERRNO_HWI_NUM_INVALID;
+ }
+
+ HwiControllerOps *hwiOps = ArchIntOpsGet();
+ if (hwiOps->disableIrq == NULL) {
+ return OS_ERRNO_HWI_OPS_FUNC_NULL;
+ }
+
+ return hwiOps->disableIrq(hwiNum);
+}
+
+UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
+{
+ if (hwiNum >= OS_HWI_MAX_NUM) {
+ return OS_ERRNO_HWI_NUM_INVALID;
+ }
+
+ HwiControllerOps *hwiOps = ArchIntOpsGet();
+ if (hwiOps->clearIrq == NULL) {
+ return OS_ERRNO_HWI_OPS_FUNC_NULL;
+ }
+
+ return hwiOps->clearIrq(hwiNum);
+}
+
+UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T 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;
+ }
+
+ HwiControllerOps *hwiOps = ArchIntOpsGet();
+ if (hwiOps->setIrqPriority == NULL) {
+ return OS_ERRNO_HWI_OPS_FUNC_NULL;
+ }
+
+ return hwiOps->setIrqPriority(hwiNum, priority);
+}
+
+UINT32 ArchIntCurIrqNum(VOID)
+{
+ HwiControllerOps *hwiOps = ArchIntOpsGet();
+ return hwiOps->getCurIrqNum();
+}
+
+/* ****************************************************************************
+ Function : ArchHwiCreate
+ Description : create hardware interrupt
+ Input : hwiNum --- hwi num to create
+ hwiPrio --- priority of the hwi
+ hwiMode --- unused
+ hwiHandler --- hwi handler
+ irqParam --- param of the hwi handler
+ Output : None
+ Return : LOS_OK on success or error code on failure
+ **************************************************************************** */
+LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio,
+ HWI_MODE_T hwiMode, HWI_PROC_FUNC hwiHandler,
+ HwiIrqParam *irqParam)
+{
+ (VOID)hwiMode;
+ UINT32 intSave;
+
+ if (hwiHandler == NULL) {
+ return OS_ERRNO_HWI_PROC_FUNC_NULL;
+ }
+
+ if (hwiNum >= OS_HWI_MAX_NUM) {
+ return OS_ERRNO_HWI_NUM_INVALID;
+ }
+
+ if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
+ return OS_ERRNO_HWI_ALREADY_CREATED;
+ }
+
+ if (hwiPrio > OS_HWI_PRIO_LOWEST) {
+ return OS_ERRNO_HWI_PRIO_INVALID;
+ }
+
+ intSave = LOS_IntLock();
+
+#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
+ if (irqParam != NULL) {
+ OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
+ } else {
+ OsSetVector(hwiNum, hwiHandler, NULL);
+ }
+#else
+ (VOID)irqParam;
+ OsSetVector(hwiNum, hwiHandler);
+#endif
+
+#if (LOSCFG_DEBUG_TOOLS == 1)
+ if ((irqParam != NULL) && (irqParam->pName != NULL)) {
+ g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
+ }
+ g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
+#endif
+
+ HwiControllerOps *hwiOps = ArchIntOpsGet();
+ if (hwiOps->createIrq == NULL) {
+ LOS_IntRestore(intSave);
+ return OS_ERRNO_HWI_OPS_FUNC_NULL;
+ }
+ hwiOps->createIrq(hwiNum, hwiPrio);
+
+ LOS_IntRestore(intSave);
+
+ return LOS_OK;
+}
+
+/* ****************************************************************************
+ Function : ArchHwiDelete
+ Description : Delete hardware interrupt
+ Input : hwiNum --- hwi num to delete
+ irqParam --- param of the hwi handler
+ Output : None
+ Return : LOS_OK on success or error code on failure
+ **************************************************************************** */
+LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
+{
+ (VOID)irqParam;
+ UINT32 intSave;
+
+ if (hwiNum >= OS_HWI_MAX_NUM) {
+ return OS_ERRNO_HWI_NUM_INVALID;
+ }
+
+ ArchIntDisable((IRQn_Type)hwiNum);
+
+ intSave = LOS_IntLock();
+
+ g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+
+ LOS_IntRestore(intSave);
+
+ return LOS_OK;
+}
+
+INLINE UINT32 ArchIsIntActive(VOID)
+{
+ return (g_intCount > 0);
+}
diff --git a/arch/arm/common/los_common_interrupt.h b/arch/arm/common/los_common_interrupt.h
new file mode 100644
index 00000000..180a00d5
--- /dev/null
+++ b/arch/arm/common/los_common_interrupt.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2023-2023 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 _LOS_COMMON_INTERRUPT_H
+#define _LOS_COMMON_INTERRUPT_H
+
+#include "los_config.h"
+#include "los_compiler.h"
+#include "los_interrupt.h"
+#include "los_error.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+/* *
+ * @ingroup los_arch_interrupt
+ * Define the type of a hardware interrupt vector table function.
+ */
+typedef VOID (**HWI_VECTOR_FUNC)(VOID);
+
+/* *
+ * @ingroup los_arch_interrupt
+ * Count of interrupts.
+ */
+extern UINT32 g_intCount;
+
+/* *
+ * @ingroup los_arch_interrupt
+ * Maximum number of used hardware interrupts.
+ */
+#ifndef OS_HWI_MAX_NUM
+#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
+#endif
+
+#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
+/* *
+ * @ingroup los_arch_interrupt
+ * Set interrupt vector table.
+ */
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
+extern HWI_HANDLER_FUNC g_hwiHandlerForm[];
+#else
+/* *
+ * @ingroup los_arch_interrupt
+ * Set interrupt vector table.
+ */
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
+extern HWI_PROC_FUNC g_hwiHandlerForm[];
+#endif
+
+#define OS_EXC_IN_INIT 0
+#define OS_EXC_IN_TASK 1
+#define OS_EXC_IN_HWI 2
+#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
+#define OS_EXC_FLAG_IN_HWI 0x02
+#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
+#define OS_EXC_EVENT 0x00000001
+
+/* *
+ * @ingroup los_arch_interrupt
+ * @brief: Default vector handling function.
+ *
+ * @par Description:
+ * This API is used to configure interrupt for null function.
+ *
+ * @attention:
+ *
+ *
+ * @param:None.
+ *
+ * @retval:None.
+ * @par Dependency:
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
+ * @see None.
+ */
+extern VOID HalHwiDefaultHandler(VOID);
+
+VOID HalPreInterruptHandler(UINT32 arg);
+VOID HalAftInterruptHandler(UINT32 arg);
+VOID *ArchGetHwiFrom(VOID);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#endif /* _LOS_COMMON_INTERRUPT_H */
diff --git a/arch/arm/cortex-m3/keil/los_arch_interrupt.h b/arch/arm/cortex-m3/keil/los_arch_interrupt.h
index 665a7a96..951a875d 100644
--- a/arch/arm/cortex-m3/keil/los_arch_interrupt.h
+++ b/arch/arm/cortex-m3/keil/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -42,14 +42,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,19 +58,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
-/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_arch_interrupt
- * Count of interrupts.
- */
-extern UINT32 g_intCount;
-
/* *
* @ingroup los_arch_interrupt
* Count of M-Core system interrupt vector.
@@ -186,6 +165,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +301,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +320,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,17 +359,12 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
@@ -423,14 +374,6 @@ extern VOID HalPendSV(VOID);
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +446,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -668,7 +610,6 @@ typedef struct TagExcInfo {
} ExcInfo;
extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
diff --git a/arch/arm/cortex-m3/keil/los_interrupt.c b/arch/arm/cortex-m3/keil/los_interrupt.c
index 47a3e368..c44a667a 100644
--- a/arch/arm/cortex-m3/keil/los_interrupt.c
+++ b/arch/arm/cortex-m3/keil/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -43,95 +41,6 @@
#include "los_cpup.h"
#endif
-UINT32 g_intCount = 0;
-
-#ifdef __ICCARM__
-#pragma location = ".data.vector"
-#elif defined(__CC_ARM) || defined(__GNUC__)
-#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
-LITE_OS_SEC_VEC
-#endif
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -146,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -297,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- HwiMask((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -610,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -621,23 +399,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -655,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h b/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h
index dd9a4f22..d5139441 100644
--- a/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h
+++ b/arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
+ * @ingroup los_arch_interrupt
+ * AIRCR register priority group parameter .
*/
-typedef VOID (**HWI_VECTOR_FUNC)(void);
+#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
- * Count of interrupts.
+ * Boot interrupt vector table.
*/
-extern UINT32 g_intCount;
+extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-/* *
- * @ingroup los_arch_interrupt
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_arch_interrupt
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* 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].
+ * 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)
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c b/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c
index 30709d21..a7557def 100644
--- a/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c
+++ b/arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,84 +42,6 @@
#endif
#define DEF_HANDLER_START_INDEX 2
-UINT32 g_intCount = 0;
-
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
/* ****************************************************************************
Function : HwiNumGet
@@ -137,99 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- HwiMask((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = 0; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h b/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h
index dd9a4f22..d5139441 100644
--- a/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h
+++ b/arch/arm/cortex-m33/gcc/TZ/non_secure/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
+ * @ingroup los_arch_interrupt
+ * AIRCR register priority group parameter .
*/
-typedef VOID (**HWI_VECTOR_FUNC)(void);
+#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
- * Count of interrupts.
+ * Boot interrupt vector table.
*/
-extern UINT32 g_intCount;
+extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-/* *
- * @ingroup los_arch_interrupt
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_arch_interrupt
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* 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].
+ * 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)
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c b/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c
index dbcbeb8a..eb033f17 100644
--- a/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c
+++ b/arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,83 +42,6 @@
#endif
#define DEF_HANDLER_START_INDEX 2
-UINT32 g_intCount = 0;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
/* ****************************************************************************
Function : HwiNumGet
@@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = 0; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m33/iar/NTZ/los_arch_interrupt.h b/arch/arm/cortex-m33/iar/NTZ/los_arch_interrupt.h
index ae51bace..71b61dd0 100644
--- a/arch/arm/cortex-m33/iar/NTZ/los_arch_interrupt.h
+++ b/arch/arm/cortex-m33/iar/NTZ/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _LOS_EXC_H
-#define _LOS_EXC_H
+#ifndef _LOS_ARCH_INTERRUPT_H
+#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */
/* *
- * @ingroup los_hwi
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_HIGHEST
@@ -59,63 +49,50 @@ extern "C" {
#endif
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_hwi
- * Count of interrupts.
- */
-extern UINT32 g_intCount;
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core system interrupt vector.
- */
-#define OS_SYS_VECTOR_CNT 16
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core interrupt vector.
- */
-#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Count of M-Core system interrupt vector.
+ */
+#define OS_SYS_VECTOR_CNT 16
+
+/* *
+ * @ingroup los_arch_interrupt
+ * Count of M-Core interrupt vector.
+ */
+#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
+
+/* *
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
*
* Value: 0x02000900
*
* 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].
+ * 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)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Null hardware interrupt handling function.
*
* Value: 0x02000901
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
*
* Value: 0x02000902
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
*
* Value: 0x02000903
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created.
*
* Value: 0x02000904
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt priority.
*
* Value: 0x02000905
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode.
*
* Value: 0x02000906
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
*
* Value: 0x02000907
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
+/* *
+ * @ingroup los_arch_interrupt
* SysTick control and status register.
*/
#define OS_SYSTICK_CONTROL_REG 0xE000E010
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers.
*/
#define OS_NVIC_PRI_BASE 0xE000E400
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31.
*/
#define OS_NVIC_SETENA_BASE 0xE000E100
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* interrupt pending register.
*/
#define OS_NVIC_SETPEND_BASE 0xE000E200
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt active register.
*/
#define OS_NVIC_INT_ACT_BASE 0xE000E300
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31.
*/
#define OS_NVIC_CLRENA_BASE 0xE000E180
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt control and status register.
*/
#define OS_NVIC_INT_CTRL 0xE000ED04
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Vector table offset register.
*/
#define OS_NVIC_VTOR 0xE000ED08
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Application interrupt and reset control register
*/
#define OS_NVIC_AIRCR 0xE000ED0C
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* System exception priority register.
*/
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset.
*/
#define OS_EXC_RESET 1
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt.
*/
#define OS_EXC_NMI 2
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault.
*/
#define OS_EXC_HARD_FAULT 3
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault.
*/
#define OS_EXC_MPU_FAULT 4
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault.
*/
#define OS_EXC_BUS_FAULT 5
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault.
*/
#define OS_EXC_USAGE_FAULT 6
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall.
*/
#define OS_EXC_SVC_CALL 11
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor.
*/
#define OS_EXC_DBG_MONITOR 12
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV.
*/
#define OS_EXC_PEND_SV 14
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick.
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_hwi
* @brief: Hardware interrupt entry function.
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID);
/* *
- * @ingroup los_hwi
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Reset the vector table.
*
* @par Description:
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID Reset_Handler(VOID);
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Pended System Call.
*
* @par Description:
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
-}EXC_CONTEXT_S;
+} EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
- * Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
+ * Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
*
*/
typedef struct TagExcInfo {
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */
#endif /* __cplusplus */
-#endif /* _LOS_EXC_H */
+#endif /* _LOS_ARCH_INTERRUPT_H */
diff --git a/arch/arm/cortex-m33/iar/NTZ/los_interrupt.c b/arch/arm/cortex-m33/iar/NTZ/los_interrupt.c
index b609908e..b8c0e8c0 100644
--- a/arch/arm/cortex-m33/iar/NTZ/los_interrupt.c
+++ b/arch/arm/cortex-m33/iar/NTZ/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
-#include "securec.h"
#include
-#include "los_arch_interrupt.h"
+#include "securec.h"
#include "los_context.h"
-#include "los_debug.h"
+#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,93 +42,6 @@
#include "los_cpup.h"
#endif
-/*lint -save -e40 -e522 -e533*/
-UINT32 g_intCount = 0;
-
-/*lint -restore*/
-#pragma location = ".data.vector"
-#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINTPTR intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -622,23 +401,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m33/iar/TZ/non_secure/los_arch_interrupt.h b/arch/arm/cortex-m33/iar/TZ/non_secure/los_arch_interrupt.h
index ae51bace..71b61dd0 100644
--- a/arch/arm/cortex-m33/iar/TZ/non_secure/los_arch_interrupt.h
+++ b/arch/arm/cortex-m33/iar/TZ/non_secure/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _LOS_EXC_H
-#define _LOS_EXC_H
+#ifndef _LOS_ARCH_INTERRUPT_H
+#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */
/* *
- * @ingroup los_hwi
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_HIGHEST
@@ -59,63 +49,50 @@ extern "C" {
#endif
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_hwi
- * Count of interrupts.
- */
-extern UINT32 g_intCount;
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core system interrupt vector.
- */
-#define OS_SYS_VECTOR_CNT 16
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core interrupt vector.
- */
-#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Count of M-Core system interrupt vector.
+ */
+#define OS_SYS_VECTOR_CNT 16
+
+/* *
+ * @ingroup los_arch_interrupt
+ * Count of M-Core interrupt vector.
+ */
+#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
+
+/* *
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
*
* Value: 0x02000900
*
* 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].
+ * 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)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Null hardware interrupt handling function.
*
* Value: 0x02000901
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
*
* Value: 0x02000902
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
*
* Value: 0x02000903
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created.
*
* Value: 0x02000904
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt priority.
*
* Value: 0x02000905
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode.
*
* Value: 0x02000906
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
*
* Value: 0x02000907
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
+/* *
+ * @ingroup los_arch_interrupt
* SysTick control and status register.
*/
#define OS_SYSTICK_CONTROL_REG 0xE000E010
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers.
*/
#define OS_NVIC_PRI_BASE 0xE000E400
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31.
*/
#define OS_NVIC_SETENA_BASE 0xE000E100
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* interrupt pending register.
*/
#define OS_NVIC_SETPEND_BASE 0xE000E200
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt active register.
*/
#define OS_NVIC_INT_ACT_BASE 0xE000E300
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31.
*/
#define OS_NVIC_CLRENA_BASE 0xE000E180
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt control and status register.
*/
#define OS_NVIC_INT_CTRL 0xE000ED04
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Vector table offset register.
*/
#define OS_NVIC_VTOR 0xE000ED08
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Application interrupt and reset control register
*/
#define OS_NVIC_AIRCR 0xE000ED0C
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* System exception priority register.
*/
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset.
*/
#define OS_EXC_RESET 1
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt.
*/
#define OS_EXC_NMI 2
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault.
*/
#define OS_EXC_HARD_FAULT 3
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault.
*/
#define OS_EXC_MPU_FAULT 4
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault.
*/
#define OS_EXC_BUS_FAULT 5
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault.
*/
#define OS_EXC_USAGE_FAULT 6
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall.
*/
#define OS_EXC_SVC_CALL 11
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor.
*/
#define OS_EXC_DBG_MONITOR 12
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV.
*/
#define OS_EXC_PEND_SV 14
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick.
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_hwi
* @brief: Hardware interrupt entry function.
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID);
/* *
- * @ingroup los_hwi
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Reset the vector table.
*
* @par Description:
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID Reset_Handler(VOID);
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Pended System Call.
*
* @par Description:
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
-}EXC_CONTEXT_S;
+} EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
- * Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
+ * Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
*
*/
typedef struct TagExcInfo {
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */
#endif /* __cplusplus */
-#endif /* _LOS_EXC_H */
+#endif /* _LOS_ARCH_INTERRUPT_H */
diff --git a/arch/arm/cortex-m33/iar/TZ/non_secure/los_interrupt.c b/arch/arm/cortex-m33/iar/TZ/non_secure/los_interrupt.c
index b609908e..b8c0e8c0 100644
--- a/arch/arm/cortex-m33/iar/TZ/non_secure/los_interrupt.c
+++ b/arch/arm/cortex-m33/iar/TZ/non_secure/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
-#include "securec.h"
#include
-#include "los_arch_interrupt.h"
+#include "securec.h"
#include "los_context.h"
-#include "los_debug.h"
+#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,93 +42,6 @@
#include "los_cpup.h"
#endif
-/*lint -save -e40 -e522 -e533*/
-UINT32 g_intCount = 0;
-
-/*lint -restore*/
-#pragma location = ".data.vector"
-#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINTPTR intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -622,23 +401,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m4/gcc/los_arch_interrupt.h b/arch/arm/cortex-m4/gcc/los_arch_interrupt.h
index 326b72f2..046f789a 100644
--- a/arch/arm/cortex-m4/gcc/los_arch_interrupt.h
+++ b/arch/arm/cortex-m4/gcc/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
+ * @ingroup los_arch_interrupt
+ * AIRCR register priority group parameter .
*/
-typedef VOID (**HWI_VECTOR_FUNC)(void);
+#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
- * Count of interrupts.
+ * Boot interrupt vector table.
*/
-extern UINT32 g_intCount;
+extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-/* *
- * @ingroup los_arch_interrupt
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_arch_interrupt
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* 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].
+ * 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)
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m4/gcc/los_interrupt.c b/arch/arm/cortex-m4/gcc/los_interrupt.c
index fd8c1b8b..e5b4a2d8 100644
--- a/arch/arm/cortex-m4/gcc/los_interrupt.c
+++ b/arch/arm/cortex-m4/gcc/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,12 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
+
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -43,89 +42,6 @@
#include "los_cpup.h"
#endif
-UINT32 g_intCount = 0;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -140,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -291,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- HwiMask((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -614,6 +394,11 @@ WEAK VOID __stack_chk_fail(VOID)
__builtin_return_address(0));
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -625,23 +410,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -659,4 +445,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m4/iar/los_arch_interrupt.h b/arch/arm/cortex-m4/iar/los_arch_interrupt.h
index 326b72f2..0bb41f38 100644
--- a/arch/arm/cortex-m4/iar/los_arch_interrupt.h
+++ b/arch/arm/cortex-m4/iar/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
+ * @ingroup los_arch_interrupt
+ * AIRCR register priority group parameter .
*/
-typedef VOID (**HWI_VECTOR_FUNC)(void);
+#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
- * Count of interrupts.
+ * Boot interrupt vector table.
*/
-extern UINT32 g_intCount;
+extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-/* *
- * @ingroup los_arch_interrupt
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_arch_interrupt
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* 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].
+ * The value range of the interrupt number applicable for a Cortex-M4 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m4/iar/los_interrupt.c b/arch/arm/cortex-m4/iar/los_interrupt.c
index 3c2037df..3a7760ba 100644
--- a/arch/arm/cortex-m4/iar/los_interrupt.c
+++ b/arch/arm/cortex-m4/iar/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
-#include "securec.h"
#include
-#include "los_arch_interrupt.h"
+#include "securec.h"
#include "los_context.h"
-#include "los_debug.h"
+#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,95 +42,6 @@
#include "los_cpup.h"
#endif
-UINT32 g_intCount = 0;
-
-#ifdef __ICCARM__
-#pragma location = ".data.vector"
-#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
-#elif defined(__CC_ARM) || defined(__GNUC__)
-LITE_OS_SEC_VEC
-#endif
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -147,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -299,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -612,6 +384,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -623,23 +400,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -657,4 +435,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m55/gcc/NTZ/los_arch_interrupt.h b/arch/arm/cortex-m55/gcc/NTZ/los_arch_interrupt.h
index 4838306b..c498aaf4 100644
--- a/arch/arm/cortex-m55/gcc/NTZ/los_arch_interrupt.h
+++ b/arch/arm/cortex-m55/gcc/NTZ/los_arch_interrupt.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2022-2023 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:
@@ -31,9 +31,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -41,14 +39,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -65,18 +55,11 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
-/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
/* *
* @ingroup los_arch_interrupt
- * Count of interrupts.
+ * AIRCR register priority group parameter .
*/
-extern UINT32 g_intCount;
+#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
@@ -90,12 +73,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-/* *
- * @ingroup los_arch_interrupt
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@@ -103,7 +80,7 @@ extern UINT32 g_intCount;
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
- * The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
+ * The value range of the interrupt number applicable for a Cortex-M55 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -154,7 +131,7 @@ extern UINT32 g_intCount;
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid.
- * The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
+ * The value range of the interrupt priority applicable for a Cortex-M55 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -179,6 +156,16 @@ extern UINT32 g_intCount;
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -305,20 +292,6 @@ extern UINT32 g_intCount;
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -338,25 +311,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -396,34 +350,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -496,7 +436,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -654,7 +593,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
- * Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
+ * Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
*
*/
typedef struct TagExcInfo {
@@ -677,10 +616,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m55/gcc/NTZ/los_interrupt.c b/arch/arm/cortex-m55/gcc/NTZ/los_interrupt.c
index 8507f8ee..9ee1fd73 100644
--- a/arch/arm/cortex-m55/gcc/NTZ/los_interrupt.c
+++ b/arch/arm/cortex-m55/gcc/NTZ/los_interrupt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2022-2023 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:
@@ -27,12 +27,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -43,89 +41,6 @@
#endif
#define DEF_HANDLER_START_INDEX 2
-UINT32 g_intCount = 0;
-
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
/* ****************************************************************************
Function : HwiNumGet
@@ -141,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -292,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- HwiMask((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -609,6 +388,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -620,23 +404,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = 0; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -654,4 +439,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m55/gcc/TZ/non_secure/los_arch_interrupt.h b/arch/arm/cortex-m55/gcc/TZ/non_secure/los_arch_interrupt.h
index dd9a4f22..77b3bda4 100644
--- a/arch/arm/cortex-m55/gcc/TZ/non_secure/los_arch_interrupt.h
+++ b/arch/arm/cortex-m55/gcc/TZ/non_secure/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
+ * @ingroup los_arch_interrupt
+ * AIRCR register priority group parameter .
*/
-typedef VOID (**HWI_VECTOR_FUNC)(void);
+#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
- * Count of interrupts.
+ * Boot interrupt vector table.
*/
-extern UINT32 g_intCount;
+extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-/* *
- * @ingroup los_arch_interrupt
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_arch_interrupt
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* 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].
+ * 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)
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -644,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
- * Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
+ * Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
*
*/
typedef struct TagExcInfo {
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m55/gcc/TZ/non_secure/los_interrupt.c b/arch/arm/cortex-m55/gcc/TZ/non_secure/los_interrupt.c
index dbcbeb8a..a9aea8d9 100644
--- a/arch/arm/cortex-m55/gcc/TZ/non_secure/los_interrupt.c
+++ b/arch/arm/cortex-m55/gcc/TZ/non_secure/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,99 +28,20 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
-#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
+#include "los_hook.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
-UINT32 g_intCount = 0;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
/* ****************************************************************************
Function : HwiNumGet
@@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = 0; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m55/iar/NTZ/los_arch_interrupt.h b/arch/arm/cortex-m55/iar/NTZ/los_arch_interrupt.h
index ae51bace..70c8754f 100644
--- a/arch/arm/cortex-m55/iar/NTZ/los_arch_interrupt.h
+++ b/arch/arm/cortex-m55/iar/NTZ/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _LOS_EXC_H
-#define _LOS_EXC_H
+#ifndef _LOS_ARCH_INTERRUPT_H
+#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */
/* *
- * @ingroup los_hwi
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_HIGHEST
@@ -59,63 +49,50 @@ extern "C" {
#endif
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_hwi
- * Count of interrupts.
- */
-extern UINT32 g_intCount;
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core system interrupt vector.
- */
-#define OS_SYS_VECTOR_CNT 16
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core interrupt vector.
- */
-#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Count of M-Core system interrupt vector.
+ */
+#define OS_SYS_VECTOR_CNT 16
+
+/* *
+ * @ingroup los_arch_interrupt
+ * Count of M-Core interrupt vector.
+ */
+#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
+
+/* *
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
*
* Value: 0x02000900
*
* 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].
+ * 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)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Null hardware interrupt handling function.
*
* Value: 0x02000901
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
*
* Value: 0x02000902
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
*
* Value: 0x02000903
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created.
*
* Value: 0x02000904
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt priority.
*
* Value: 0x02000905
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode.
*
* Value: 0x02000906
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
*
* Value: 0x02000907
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
+/* *
+ * @ingroup los_arch_interrupt
* SysTick control and status register.
*/
#define OS_SYSTICK_CONTROL_REG 0xE000E010
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers.
*/
#define OS_NVIC_PRI_BASE 0xE000E400
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31.
*/
#define OS_NVIC_SETENA_BASE 0xE000E100
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* interrupt pending register.
*/
#define OS_NVIC_SETPEND_BASE 0xE000E200
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt active register.
*/
#define OS_NVIC_INT_ACT_BASE 0xE000E300
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31.
*/
#define OS_NVIC_CLRENA_BASE 0xE000E180
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt control and status register.
*/
#define OS_NVIC_INT_CTRL 0xE000ED04
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Vector table offset register.
*/
#define OS_NVIC_VTOR 0xE000ED08
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Application interrupt and reset control register
*/
#define OS_NVIC_AIRCR 0xE000ED0C
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* System exception priority register.
*/
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset.
*/
#define OS_EXC_RESET 1
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt.
*/
#define OS_EXC_NMI 2
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault.
*/
#define OS_EXC_HARD_FAULT 3
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault.
*/
#define OS_EXC_MPU_FAULT 4
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault.
*/
#define OS_EXC_BUS_FAULT 5
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault.
*/
#define OS_EXC_USAGE_FAULT 6
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall.
*/
#define OS_EXC_SVC_CALL 11
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor.
*/
#define OS_EXC_DBG_MONITOR 12
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV.
*/
#define OS_EXC_PEND_SV 14
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick.
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_hwi
* @brief: Hardware interrupt entry function.
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID);
/* *
- * @ingroup los_hwi
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Reset the vector table.
*
* @par Description:
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID Reset_Handler(VOID);
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Pended System Call.
*
* @par Description:
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
-}EXC_CONTEXT_S;
+} EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
- * Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
+ * Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
*
*/
typedef struct TagExcInfo {
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */
#endif /* __cplusplus */
-#endif /* _LOS_EXC_H */
+#endif /* _LOS_ARCH_INTERRUPT_H */
diff --git a/arch/arm/cortex-m55/iar/NTZ/los_interrupt.c b/arch/arm/cortex-m55/iar/NTZ/los_interrupt.c
index b609908e..b8c0e8c0 100644
--- a/arch/arm/cortex-m55/iar/NTZ/los_interrupt.c
+++ b/arch/arm/cortex-m55/iar/NTZ/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
-#include "securec.h"
#include
-#include "los_arch_interrupt.h"
+#include "securec.h"
#include "los_context.h"
-#include "los_debug.h"
+#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,93 +42,6 @@
#include "los_cpup.h"
#endif
-/*lint -save -e40 -e522 -e533*/
-UINT32 g_intCount = 0;
-
-/*lint -restore*/
-#pragma location = ".data.vector"
-#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINTPTR intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -622,23 +401,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m55/iar/TZ/BUILD.gn b/arch/arm/cortex-m55/iar/TZ/BUILD.gn
index a155665a..8a4bf3f4 100644
--- a/arch/arm/cortex-m55/iar/TZ/BUILD.gn
+++ b/arch/arm/cortex-m55/iar/TZ/BUILD.gn
@@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
-# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2023 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:
@@ -32,15 +32,21 @@ import("//kernel/liteos_m/liteos.gni")
module_name = "arch"
kernel_module(module_name) {
sources = [
- "los_context.c",
- "los_dispatch.S",
- "los_exc.S",
- "los_interrupt.c",
- "los_timer.c",
+ "non_secure/los_context.c",
+ "non_secure/los_dispatch.S",
+ "non_secure/los_exc.S",
+ "non_secure/los_interrupt.c",
+ "non_secure/los_timer.c",
+ "non_secure/los_trustzone.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
+
+ include_dirs = [
+ "non_secure",
+ "secure",
+ ]
}
config("public") {
- include_dirs = [ "." ]
+ include_dirs = [ "non_secure" ]
}
diff --git a/arch/arm/cortex-m55/iar/TZ/non_secure/los_arch_interrupt.h b/arch/arm/cortex-m55/iar/TZ/non_secure/los_arch_interrupt.h
index ae51bace..70c8754f 100644
--- a/arch/arm/cortex-m55/iar/TZ/non_secure/los_arch_interrupt.h
+++ b/arch/arm/cortex-m55/iar/TZ/non_secure/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef _LOS_EXC_H
-#define _LOS_EXC_H
+#ifndef _LOS_ARCH_INTERRUPT_H
+#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */
/* *
- * @ingroup los_hwi
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_HIGHEST
@@ -59,63 +49,50 @@ extern "C" {
#endif
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_hwi
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_hwi
- * Count of interrupts.
- */
-extern UINT32 g_intCount;
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core system interrupt vector.
- */
-#define OS_SYS_VECTOR_CNT 16
-
-/* *
- * @ingroup los_hwi
- * Count of M-Core interrupt vector.
- */
-#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Count of M-Core system interrupt vector.
+ */
+#define OS_SYS_VECTOR_CNT 16
+
+/* *
+ * @ingroup los_arch_interrupt
+ * Count of M-Core interrupt vector.
+ */
+#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
+
+/* *
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
*
* Value: 0x02000900
*
* 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].
+ * 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)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Null hardware interrupt handling function.
*
* Value: 0x02000901
@@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
*
* Value: 0x02000902
@@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
*
* Value: 0x02000903
@@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created.
*
* Value: 0x02000904
@@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt priority.
*
* Value: 0x02000905
@@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode.
*
* Value: 0x02000906
@@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
*
* Value: 0x02000907
@@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
+/* *
+ * @ingroup los_arch_interrupt
* SysTick control and status register.
*/
#define OS_SYSTICK_CONTROL_REG 0xE000E010
@@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers.
*/
#define OS_NVIC_PRI_BASE 0xE000E400
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31.
*/
#define OS_NVIC_SETENA_BASE 0xE000E100
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* interrupt pending register.
*/
#define OS_NVIC_SETPEND_BASE 0xE000E200
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt active register.
*/
#define OS_NVIC_INT_ACT_BASE 0xE000E300
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31.
*/
#define OS_NVIC_CLRENA_BASE 0xE000E180
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt control and status register.
*/
#define OS_NVIC_INT_CTRL 0xE000ED04
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Vector table offset register.
*/
#define OS_NVIC_VTOR 0xE000ED08
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Application interrupt and reset control register
*/
#define OS_NVIC_AIRCR 0xE000ED0C
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* System exception priority register.
*/
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset.
*/
#define OS_EXC_RESET 1
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt.
*/
#define OS_EXC_NMI 2
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault.
*/
#define OS_EXC_HARD_FAULT 3
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault.
*/
#define OS_EXC_MPU_FAULT 4
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault.
*/
#define OS_EXC_BUS_FAULT 5
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault.
*/
#define OS_EXC_USAGE_FAULT 6
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall.
*/
#define OS_EXC_SVC_CALL 11
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor.
*/
#define OS_EXC_DBG_MONITOR 12
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV.
*/
#define OS_EXC_PEND_SV 14
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick.
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_hwi
* @brief: Hardware interrupt entry function.
@@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID);
/* *
- * @ingroup los_hwi
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
-/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Reset the vector table.
*
* @par Description:
@@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID Reset_Handler(VOID);
/* *
- * @ingroup los_hwi
+ * @ingroup los_arch_interrupt
* @brief: Pended System Call.
*
* @par Description:
@@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
*
* @retval:None.
* @par Dependency:
- * - los_hwi.h: the header file that contains the API declaration.
+ * - los_arch_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
-}EXC_CONTEXT_S;
+} EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
- * Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
+ * Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
*
*/
typedef struct TagExcInfo {
@@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
@@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */
#endif /* __cplusplus */
-#endif /* _LOS_EXC_H */
+#endif /* _LOS_ARCH_INTERRUPT_H */
diff --git a/arch/arm/cortex-m55/iar/TZ/non_secure/los_interrupt.c b/arch/arm/cortex-m55/iar/TZ/non_secure/los_interrupt.c
index b609908e..d45b53de 100644
--- a/arch/arm/cortex-m55/iar/TZ/non_secure/los_interrupt.c
+++ b/arch/arm/cortex-m55/iar/TZ/non_secure/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,13 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include "los_interrupt.h"
-#include "securec.h"
#include
-#include "los_arch_interrupt.h"
+#include "securec.h"
#include "los_context.h"
-#include "los_debug.h"
+#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,92 +41,7 @@
#include "los_cpup.h"
#endif
-/*lint -save -e40 -e522 -e533*/
-UINT32 g_intCount = 0;
-
-/*lint -restore*/
-#pragma location = ".data.vector"
-#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
+#define DEF_HANDLER_START_INDEX 2
/* ****************************************************************************
Function : HwiNumGet
@@ -145,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -299,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINTPTR intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -622,23 +397,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -651,4 +427,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m7/gcc/los_arch_interrupt.h b/arch/arm/cortex-m7/gcc/los_arch_interrupt.h
index 7e8dde0e..fbe8698b 100644
--- a/arch/arm/cortex-m7/gcc/los_arch_interrupt.h
+++ b/arch/arm/cortex-m7/gcc/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,19 +56,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
-/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
- */
-typedef VOID (**HWI_VECTOR_FUNC)(void);
-
-/* *
- * @ingroup los_arch_interrupt
- * Count of interrupts.
- */
-extern UINT32 g_intCount;
-
/* *
* @ingroup los_arch_interrupt
* Count of M-Core system interrupt vector.
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* 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].
+ * The value range of the interrupt number applicable for a Cortex-M7 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m7/gcc/los_interrupt.c b/arch/arm/cortex-m7/gcc/los_interrupt.c
index 9fd51c3d..c44a667a 100644
--- a/arch/arm/cortex-m7/gcc/los_interrupt.c
+++ b/arch/arm/cortex-m7/gcc/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
#include
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -43,84 +41,6 @@
#include "los_cpup.h"
#endif
-UINT32 g_intCount = 0;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@@ -135,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -286,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -599,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -610,23 +399,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -644,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/arm/cortex-m7/iar/los_arch_interrupt.h b/arch/arm/cortex-m7/iar/los_arch_interrupt.h
index 7e8dde0e..e0896865 100644
--- a/arch/arm/cortex-m7/iar/los_arch_interrupt.h
+++ b/arch/arm/cortex-m7/iar/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
-#include "los_config.h"
-#include "los_compiler.h"
-#include "los_interrupt.h"
+#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
-/* *
- * @ingroup los_arch_interrupt
- * Maximum number of used hardware interrupts.
- */
-#ifndef OS_HWI_MAX_NUM
-#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
-#endif
-
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
-
/* *
- * @ingroup los_arch_interrupt
- * Define the type of a hardware interrupt vector table function.
+ * @ingroup los_arch_interrupt
+ * AIRCR register priority group parameter .
*/
-typedef VOID (**HWI_VECTOR_FUNC)(void);
+#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
- * Count of interrupts.
+ * Boot interrupt vector table.
*/
-extern UINT32 g_intCount;
+extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
-/* *
- * @ingroup los_arch_interrupt
- * AIRCR register priority group parameter .
- */
-#define OS_NVIC_AIRCR_PRIGROUP 7
-
-/* *
- * @ingroup los_arch_interrupt
- * Boot interrupt vector table.
- */
-extern UINT32 _BootVectors[];
-
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* 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].
+ * The value range of the interrupt number applicable for a Cortex-M7 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
+/* *
+ * @ingroup los_arch_interrupt
+ * Hardware interrupt error code: Invalid interrupt operation function.
+ *
+ * Value: 0x02000908
+ *
+ * Solution: Set a valid interrupt operation function
+ */
+#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x08)
+
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
@@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
-#else
-/* *
- * @ingroup los_arch_interrupt
- * Set interrupt vector table.
- */
-extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
-#endif
-
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
-/* *
- * @ingroup los_arch_interrupt
- * @brief: Default vector handling function.
- *
- * @par Description:
- * This API is used to configure interrupt for null function.
- *
- * @attention:
- *
- *
- * @param:None.
- *
- * @retval:None.
- * @par Dependency:
- * - los_arch_interrupt.h: the header file that contains the API declaration.
- * @see None.
- */
-extern VOID HalHwiDefaultHandler(VOID);
-
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
@@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
-
-#define OS_EXC_IN_INIT 0
-#define OS_EXC_IN_TASK 1
-#define OS_EXC_IN_HWI 2
-
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
+#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
-
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
-
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
-#define OS_EXC_FLAG_NO_FLOAT 0x10000000
-#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
-#define OS_EXC_FLAG_IN_HWI 0x02
-
-#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
-
-#define OS_EXC_EVENT 0x00000001
-
/**
* @ingroup los_exc
* the struct of register files
@@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
-
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
-extern UINT32 g_curNestCount;
-extern UINT32 g_intCount;
-extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
+extern UINT32 g_curNestCount;
+extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)
diff --git a/arch/arm/cortex-m7/iar/los_interrupt.c b/arch/arm/cortex-m7/iar/los_interrupt.c
index faa6b161..e6ec70a4 100644
--- a/arch/arm/cortex-m7/iar/los_interrupt.c
+++ b/arch/arm/cortex-m7/iar/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_interrupt.h"
-#include "securec.h"
#include
-#include "los_arch_interrupt.h"
+#include "securec.h"
#include "los_context.h"
-#include "los_debug.h"
+#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@@ -44,90 +42,8 @@
#include "los_cpup.h"
#endif
-UINT32 g_intCount = 0;
-
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
-/* *
- * @ingroup los_hwi
- * Hardware interrupt form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
-STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
-
-UINT32 OsGetHwiFormCnt(UINT32 index)
-{
- return g_hwiFormCnt[index];
-}
-
-CHAR *OsGetHwiFormName(UINT32 index)
-{
- return g_hwiFormName[index];
-}
-
-BOOL OsGetHwiCreated(UINT32 index)
-{
- if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
-
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_HANDLER_FUNC;
-
-/* *
- * @ingroup los_hwi
- * Hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
- }
-}
-
-#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt handler form mapping handling function array.
- */
-STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
-
-/* *
- * @ingroup los_hwi
- * Set interrupt vector table.
- */
-VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
-{
- if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
- g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
- }
-}
-#endif
-
-WEAK VOID SysTick_Handler(VOID)
-{
- return;
-}
/* ****************************************************************************
Function : HwiNumGet
@@ -143,100 +59,54 @@ STATIC UINT32 HwiNumGet(VOID)
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 = {
+STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
+{
+ HwiSetPriority(hwiNum, hwiPrio);
+ HwiUnmask(hwiNum);
+ return LOS_OK;
+}
+
+STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
+ .createIrq = HwiCreate,
};
-inline UINT32 ArchIsIntActive(VOID)
+HwiControllerOps *ArchIntOpsGet(VOID)
{
- return (g_intCount > 0);
-}
-/* ****************************************************************************
- Function : HalHwiDefaultHandler
- Description : default handler of the hardware interrupt
- Input : None
- Output : None
- Return : None
- **************************************************************************** */
-/*lint -e529*/
-LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
-{
- PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
- while (1) {}
-}
-
-WEAK VOID HalPreInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
-}
-
-WEAK VOID HalAftInterruptHandler(UINT32 arg)
-{
- (VOID)arg;
- return;
+ return &g_archHwiOps;
}
/* ****************************************************************************
@@ -295,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
-/* ****************************************************************************
- Function : ArchHwiCreate
- Description : create hardware interrupt
- Input : hwiNum --- hwi num to create
- hwiPrio --- priority of the hwi
- hwiMode --- unused
- hwiHandler --- hwi handler
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T hwiMode,
- HWI_PROC_FUNC hwiHandler,
- HwiIrqParam *irqParam)
-{
- (VOID)hwiMode;
- UINT32 intSave;
-
- if (hwiHandler == NULL) {
- return OS_ERRNO_HWI_PROC_FUNC_NULL;
- }
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
- return OS_ERRNO_HWI_ALREADY_CREATED;
- }
-
- if (hwiPrio > OS_HWI_PRIO_LOWEST) {
- return OS_ERRNO_HWI_PRIO_INVALID;
- }
-
- intSave = LOS_IntLock();
-#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
- if (irqParam != NULL) {
- OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
- } else {
- OsSetVector(hwiNum, hwiHandler, NULL);
- }
-#else
- (VOID)irqParam;
- OsSetVector(hwiNum, hwiHandler);
-#endif
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
- if ((irqParam != NULL) && (irqParam->pName != NULL)) {
- g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
- }
- g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
-#endif
-
- HwiUnmask((IRQn_Type)hwiNum);
- HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
-/* ****************************************************************************
- Function : ArchHwiDelete
- Description : Delete hardware interrupt
- Input : hwiNum --- hwi num to delete
- irqParam --- param of the hwi handler
- Output : None
- Return : LOS_OK on success or error code on failure
- **************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
-{
- (VOID)irqParam;
- UINT32 intSave;
-
- if (hwiNum >= OS_HWI_MAX_NUM) {
- return OS_ERRNO_HWI_NUM_INVALID;
- }
-
- NVIC_DisableIRQ((IRQn_Type)hwiNum);
-
- intSave = LOS_IntLock();
-
- g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
-
- LOS_IntRestore(intSave);
-
- return LOS_OK;
-}
-
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -608,6 +387,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -619,23 +403,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
- g_hwiForm[0] = 0; /* [0] Top of Stack */
- g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
+ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
+ hwiForm[0] = 0; /* [0] Top of Stack */
+ hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
- g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
+ hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
- g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
- g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
- g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
- g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
- g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
- g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
- g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
- g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
+ hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
+ hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
+ hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
+ hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
+ hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
+ hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
+ hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
+ hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
- SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
+ SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@@ -649,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
-
diff --git a/arch/include/los_interrupt.h b/arch/include/los_interrupt.h
index fcb1d880..4e496322 100644
--- a/arch/include/los_interrupt.h
+++ b/arch/include/los_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2023 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:
@@ -31,6 +31,7 @@
#ifndef _LOS_INTERRUPT_H
#define _LOS_INTERRUPT_H
+
#include "los_config.h"
#include "los_compiler.h"
@@ -41,11 +42,8 @@ extern "C" {
#endif /* __cplusplus */
typedef UINT32 HWI_HANDLE_T;
-
typedef UINT16 HWI_PRIOR_T;
-
typedef UINT16 HWI_MODE_T;
-
typedef UINT32 HWI_ARG_T;
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
@@ -53,6 +51,7 @@ typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
#else
typedef VOID (*HWI_PROC_FUNC)(void);
#endif
+
typedef struct tagIrqParam {
int swIrq; /**< The interrupt number */
VOID *pDevId; /**< The pointer to the device ID that launches the interrupt */
@@ -66,37 +65,17 @@ typedef struct {
UINT32 (*disableIrq)(HWI_HANDLE_T hwiNum);
UINT32 (*setIrqPriority)(HWI_HANDLE_T hwiNum, UINT8 priority);
UINT32 (*getCurIrqNum)(VOID);
+ UINT32 (*createIrq)(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio);
} HwiControllerOps;
-extern HwiControllerOps g_archHwiOps;
-
/* stack protector */
extern UINT32 __stack_chk_guard;
-
extern VOID __stack_chk_fail(VOID);
-
-UINT32 ArchIsIntActive(VOID);
-#define OS_INT_ACTIVE (ArchIsIntActive())
-#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
-#define LOS_HwiCreate ArchHwiCreate
-#define LOS_HwiDelete ArchHwiDelete
-#define LOS_HwiTrigger ArchIntTrigger
-#define LOS_HwiEnable ArchIntEnable
-#define LOS_HwiDisable ArchIntDisable
-#define LOS_HwiClear ArchIntClear
-#define LOS_HwiSetPriority ArchIntSetPriority
-#define LOS_HwiCurIrqNum ArchIntCurIrqNum
-
-UINT32 ArchIntLock(VOID);
-#define LOS_IntLock ArchIntLock
-
-VOID ArchIntRestore(UINT32 intSave);
-#define LOS_IntRestore ArchIntRestore
-
-UINT32 ArchIntUnLock(VOID);
-#define LOS_IntUnLock ArchIntUnLock
-
-#define LOS_HwiOpsGet ArchIntOpsGet
+#if (LOSCFG_DEBUG_TOOLS == 1)
+extern UINT32 OsGetHwiFormCnt(UINT32 index);
+extern CHAR *OsGetHwiFormName(UINT32 index);
+extern BOOL OsHwiIsCreated(UINT32 index);
+#endif
/**
* @ingroup los_interrupt
@@ -162,11 +141,40 @@ UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam);
* - los_interrupt.h: the header file that contains the API declaration.
* @see None.
*/
-UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T mode,
- HWI_PROC_FUNC handler,
- HwiIrqParam *irqParam);
+UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio, HWI_MODE_T mode,
+ HWI_PROC_FUNC handler, HwiIrqParam *irqParam);
+UINT32 ArchIsIntActive(VOID);
+UINT32 ArchIntLock(VOID);
+UINT32 ArchIntUnLock(VOID);
+VOID ArchIntRestore(UINT32 intSave);
+
+#if (LOSCFG_ARCH_ARM == 1)
+UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum);
+UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum);
+UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum);
+UINT32 ArchIntClear(HWI_HANDLE_T hwiNum);
+UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority);
+UINT32 ArchIntCurIrqNum(VOID);
+HwiControllerOps *ArchIntOpsGet(VOID);
+#endif
+
+#define OS_INT_ACTIVE (ArchIsIntActive())
+#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
+#define LOS_IntLock ArchIntLock
+#define LOS_IntRestore ArchIntRestore
+#define LOS_IntUnLock ArchIntUnLock
+#define LOS_HwiDelete ArchHwiDelete
+#define LOS_HwiCreate ArchHwiCreate
+#define LOS_HwiTrigger ArchIntTrigger
+#define LOS_HwiEnable ArchIntEnable
+#define LOS_HwiDisable ArchIntDisable
+#define LOS_HwiClear ArchIntClear
+#define LOS_HwiSetPriority ArchIntSetPriority
+#define LOS_HwiCurIrqNum ArchIntCurIrqNum
+#define LOS_HwiOpsGet ArchIntOpsGet
+
+#if (LOSCFG_ARCH_ARM == 0)
+extern HwiControllerOps g_archHwiOps;
STATIC INLINE UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
@@ -220,11 +228,6 @@ STATIC INLINE HwiControllerOps *ArchIntOpsGet(VOID)
{
return &g_archHwiOps;
}
-
-#if (LOSCFG_DEBUG_TOOLS == 1)
-extern UINT32 OsGetHwiFormCnt(UINT32 index);
-extern CHAR *OsGetHwiFormName(UINT32 index);
-extern BOOL OsGetHwiCreated(UINT32 index);
#endif
#ifdef __cplusplus
diff --git a/components/debugtools/los_hwidump.c b/components/debugtools/los_hwidump.c
index d72edc40..33c83530 100644
--- a/components/debugtools/los_hwidump.c
+++ b/components/debugtools/los_hwidump.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2022-2023 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:
@@ -63,7 +63,7 @@ STATIC VOID ShellCmdHwiInfoShow(OsIrqCpupCB *irqData, CPUP_INFO_S *hwiCpup1s,
}
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
- if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
+ if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue;
}
@@ -118,9 +118,9 @@ STATIC VOID HwiInfoDump(VOID)
{
INT32 i;
- PRINTK(" InterruptNo Count Name\n");
+ PRINTK(" InterruptNo Count Name\n");
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
- if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
+ if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue;
}
@@ -128,8 +128,8 @@ STATIC VOID HwiInfoDump(VOID)
PRINTK(" %8d:%10d %-s\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i), OsGetHwiFormName(i));
} else {
PRINTK(" %8d:%10d\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i));
- }
- }
+ }
+ }
return;
}
#endif
@@ -144,6 +144,6 @@ UINT32 OsShellCmdHwiDump(INT32 argc, const CHAR **argv)
}
HwiInfoDump();
- return LOS_OK;
+ return LOS_OK;
}
#endif /* LOSCFG_STACK_DUMP == 1 */
diff --git a/components/exchook/los_exc_info.h b/components/exchook/los_exc_info.h
index c2840abd..b9124506 100644
--- a/components/exchook/los_exc_info.h
+++ b/components/exchook/los_exc_info.h
@@ -59,7 +59,7 @@ extern "C" {
#else
#define MAX_SWITCH_INFO_SIZE (0)
#endif
-
+
#define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM)
#define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE \
+ MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE)