Compare commits

...

49 Commits

Author SHA1 Message Date
openharmony_ci 3d8536b450
!1122 liteos_m cpup 中断索引值越界修复
Merge pull request !1122 from hw_llm/master
2024-09-02 12:36:22 +00:00
hw_llm 413b08295d Description: liteos_m cpup 中断索引值越界修复
IssueNo: https://gitee.com/openharmony/kernel_liteos_m/issues/I9RHZ7
Feature Or Bugfix: Bugfix
Binary Source: No
Signed-off-by: hw_llm <liu.limin@huawei.com>
2024-08-29 15:28:16 +08:00
openharmony_ci 10e00b3047
!1120 【修复】OAT告警
Merge pull request !1120 from 石子怡/master
2024-06-05 08:04:36 +00:00
石子怡 88fd668b8f
修复OAT告警
Signed-off-by: 石子怡 <z15319797139@163.com>
2024-06-05 06:47:40 +00:00
openharmony_ci ddaad05097
!1116 clear systick pending status
Merge pull request !1116 from hw_llm/master
2024-05-29 05:00:53 +00:00
openharmony_ci c739d4a164
!1114 【修复】OAT告警
Merge pull request !1114 from 石子怡/master
2024-05-27 11:39:31 +00:00
hw_llm 92fbcaf074 Description: clear systick pending status
IssueNo: https://gitee.com/openharmony/kernel_liteos_m/issues/I93ZUQ
Feature Or Bugfix: Feature
Binary Source: No
Signed-off-by: hw_llm <liu.limin@huawei.com>
2024-05-25 11:03:53 +08:00
石子怡 441d552355
修复OAT告警
Signed-off-by: 石子怡 <z15319797139@163.com>
2024-05-25 02:21:53 +00:00
石子怡 e151e8369b
修复OAT告警
Signed-off-by: 石子怡 <z15319797139@163.com>
2024-05-25 01:17:11 +00:00
openharmony_ci e539a6c951
!1102 fix:设置LOSCFG_PLATFORM_HWI_WITH_ARG为1后,编译失败问题修复
Merge pull request !1102 from zhangkt/master
2024-03-26 06:58:35 +00:00
openharmony_ci e19155f49f
!1108 删除bundle.json中的syscap信息,确保与架构信息平台设计信息一致
Merge pull request !1108 from hw_llm/master
2024-02-05 07:22:45 +00:00
hw_llm 76562c376c Description: 删除bundle.json中syscap信息
IssueNo: https://gitee.com/openharmony/kernel_liteos_a/issues/I90PKD
Feature Or Bugfix: Feature
Binary Source: No
Signed-off-by: hw_llm <liu.limin@huawei.com>
2024-02-02 15:40:05 +08:00
openharmony_ci 954c855528
!1107 cortex-m7支持iccarm 编译
Merge pull request !1107 from hw_llm/master
2024-01-27 08:20:41 +00:00
hw_llm 80f3e0f6b2 Description: cortex-m7支持iccarm 编译
IssueNo: https://gitee.com/openharmony/kernel_liteos_m/issues/I8ZCYS
Feature Or Bugfix: Feature
Binary Source: No
Signed-off-by: hw_llm <liu.limin@huawei.com>
2024-01-27 15:38:28 +08:00
zhangkt 36c0634ff5 fix:设置LOSCFG_PLATFORM_HWI_WITH_ARG为1后,编译失败问题修复
Signed-off-by: zhangkt <zhangkt1995@gmail.com>
2023-11-23 11:15:09 +08:00
openharmony_ci e22e8525e9
!1094 增加内核queue可以在中断中进行读写操作的接口
Merge pull request !1094 from libnew/master
2023-09-12 11:36:36 +00:00
zengwenlong 1b778c4267 feat: 增加内核queue在中断中进行读写操作的接口
方案描述:
1,基于 OsQueueOperate增加支持queue在中断中进行读写操作的接口。
BREAKING CHANGE:
增加支持queue在中断中进行读写操作的接口,需要适配接口描述:
适配API:

新增API:
UINT32 LOS_QueueReadCopyIsr(UINT32 queueID,   VOID *bufferAddr, UINT32 *bufferSize);
UINT32 LOS_QueueWriteCopyIsr(UINT32 queueID, VOID *bufferAddr, UINT32 bufferSize);
UINT32 LOS_QueueReadIsr(UINT32 queueID,VOID *bufferAddr,  UINT32 bufferSize);
UINT32 LOS_QueueWriteIsr(UINT32 queueID, VOID *bufferAddr,  UINT32 bufferSize);
UINT32 LOS_QueueWriteHeadIsr(UINT32 queueID, VOID *bufferAddr,UINT32 bufferSize);
UINT32 LOS_QueueWriteHeadCopyIsr(UINT32 queueID,  VOID *bufferAddr,UINT32 bufferSize);

Signed-off-by: zengwenlong <zengwenlong@openvalley.net>
2023-09-11 20:47:44 -07:00
openharmony_ci c70295cc30
!1096 xts用例
Merge pull request !1096 from 乔克叔叔/wxliu
2023-08-31 09:10:48 +00:00
liuwenxin c19dc1bc94 fix:xts用例
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
Change-Id: I2d3f856eb94e5ced0bc5a9c0211f10f453a4ad03
2023-08-31 16:49:50 +08:00
openharmony_ci d2bf535696
!1091 支持可配置是否生成asm文件
Merge pull request !1091 from wangchen/0817_m
2023-08-18 01:52:50 +00:00
wangchen bda25829af Fix: 支持可配置是否生成asm文件
Close #I7U2V4
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-08-17 21:41:43 +08:00
openharmony_ci a1e215f16a
!1090 liteos_m内核xts用例补齐cmsis中task剩余
Merge pull request !1090 from zwx1232718/master
2023-08-17 02:14:08 +00:00
zwx1232718 5e36b8b599 test:xts用例,task补充
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-08-17 09:06:40 +08:00
openharmony_ci 954aa6fb70
!1087 liteos_m内核xts用例补齐cmsis剩余task部分
Merge pull request !1087 from zwx1232718/master
2023-08-16 01:18:57 +00:00
zwx1232718 64a73724b3 test:xts用例补齐,cmsis中task部分
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-08-15 10:40:53 +08:00
openharmony_ci 2a49ac7323
!1084 readme翻译问题修改
Merge pull request !1084 from wangchen/0804_m
2023-08-14 13:38:45 +00:00
openharmony_ci cde26d8d68
!1080 Kconfig清理冗余代码
Merge pull request !1080 from 乔克叔叔/master
2023-08-11 02:49:30 +00:00
openharmony_ci 4140bd673e
!1081 liteos_m内核xts用例补齐部分cmsis
Merge pull request !1081 from zwx1232718/master
2023-08-09 06:58:11 +00:00
openharmony_ci 2b81e524a1
!1085 Fix : 内核告警清理
Merge pull request !1085 from yinjiaming/fix
2023-08-09 02:14:05 +00:00
zwx1232718 1dae9259ef test:xts用例补齐,部分cmsis
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-08-09 09:58:58 +08:00
yinjiaming 3ce50a610c fix:内核代码告警清理
内核代码经工具检测有告警,现予清理

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I3bf6c421296dfccd9c78cc6af47dcb1879da5cea
2023-08-08 16:22:32 +08:00
wangchen cf980647d6 Fix: readme翻译问题修改
Close #I7QAKU
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-08-04 10:28:10 +08:00
openharmony_ci ab131703be
!1079 liteos_m内核xts用例补齐net、time以及部分cmsis
Merge pull request !1079 from zwx1232718/master
2023-07-30 09:27:23 +00:00
liuwenxin f42c36ac8e fix:kconfig清理冗余代码
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
Change-Id: I45b8185b87b9c6cb03a470c9969239fdda5f6b4d
2023-07-29 15:57:26 +08:00
zwx1232718 f2ddeaebfd test:net、time以及部分cmsis
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-07-28 17:36:06 +08:00
openharmony_ci 5d5e155f31
!1078 liteos_m内核xts用例补齐mem、process、sched、sys部分
Merge pull request !1078 from zwx1232718/master
2023-07-21 01:53:13 +00:00
zwx1232718 0c3dbb4c01 test:xts用例补齐,mem、process、sched、sys部分
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-07-19 14:41:06 +08:00
openharmony_ci 873255af51
!1077 liteos_m内核xts用例补齐math部分及ipc中msg部分
Merge pull request !1077 from zwx1232718/master
2023-07-14 01:39:23 +00:00
zwx1232718 22702a27fc test:xts用例补齐,math及ipc中msg部分
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-07-13 10:02:43 +08:00
openharmony_ci b37358cb47
!1076 liteos_m内核xts用例补齐io部分
Merge pull request !1076 from zwx1232718/master
2023-07-10 02:07:07 +00:00
zwx1232718 b73eb72ba6 test:xts用力补齐,io部分
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-07-08 14:22:06 +08:00
openharmony_ci e98de4489f
!1074 liteos_m内核xts用例补齐ipc部分
Merge pull request !1074 from zwx1232718/master
2023-06-30 07:46:54 +00:00
zwx1232718 4cfb20d7e9 test:测试用力补齐
Signed-off-by: zwx1232718 <zhenghui23@huawei.com>
2023-06-28 17:52:39 +08:00
openharmony_ci 9248d46457
!1073 fix:三方软件名称整改
Merge pull request !1073 from zhangdengyu/componentization_0627
2023-06-28 01:29:47 +00:00
zhangdengyu 808b9de5b8 fix:三方软件名称整改
Close:#I7G9O9

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I026d94ae8f068134d4047902203ea56122574bec
2023-06-27 20:58:18 +08:00
openharmony_ci cfdad0f44b
!1071 refactor:csky/xtensa/riscv中断管理框架重构
Merge pull request !1071 from zhangdengyu/IMF_0615
2023-06-16 07:45:56 +00:00
zhangdengyu 81c25c6d54 refactor: 优化csky/xtensa/riscv架构中断管理框架
方案描述:
1、在最外层arch/include/los_interrupt.h中定义数据结构、声明对外接口;
2、在arch/xxx/common实现xxx架构中断通用的接口定义与声明;
3、在arch/xxx/yyy中实现针对xxx架构的差异化实现;
4、修改宏数值,适配整个中断管理框架

BREAKING CHANGE:
优化csky/xtensa/riscv架构中断管理框架对外变更描述:
1、宏OS_ERRNO_HWI_OPS_FUNC_NULL数值改为0x0200090c

Close: #I7DRTP

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: Ic7cab8222ceab846b2557ff9047f7c6cd34b2b44
2023-06-15 21:37:31 +08:00
openharmony_ci 222960f6de
!1067 refactor:中断管理框架完善
Merge pull request !1067 from zhangdengyu/IMF0523
2023-06-14 09:24:58 +00:00
zhangdengyu eb7e307355 refactor:重构ARM架构下的中断管理框架
方案描述:
1、在最外层arch/include/los_interrupt.h中定义数据结构、声明对外接口;
2、在arch/arm/common实现arm架构中断通用的接口定义与声明;
3、在arch/arm/xxx中实现针对xxx架构的差异化实现;
4、在cortex-m7/gcc中未实现SysTickHandler函数,现将其实现

Close: #I76K6S

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I741df02efb808ac64568b591e7ff460d99e21c30
2023-06-14 16:15:37 +08:00
177 changed files with 17090 additions and 5685 deletions

View File

@ -44,6 +44,10 @@ if (defined(LOSCFG_COMPILER_ICCARM)) {
} }
} }
declare_args() {
liteos_build_asm = true
}
config("arch_config") { config("arch_config") {
cflags = arch_config_cflags cflags = arch_config_cflags
asmflags = arch_config_asmflags asmflags = arch_config_asmflags
@ -215,4 +219,7 @@ build_ext_component("build_kernel_image") {
exec_path = rebase_path(root_out_dir) exec_path = rebase_path(root_out_dir)
command = toochain_config_command command = toochain_config_command
if (liteos_build_asm) {
command += toochain_asm_command
}
} }

170
Kconfig
View File

@ -39,19 +39,9 @@ choice
config COMPILER_GCC config COMPILER_GCC
bool "GCC" bool "GCC"
config CROSS_COMPILE
string "GCC cross-compile toolchain prefix"
depends on COMPILER_GCC
default "arm-none-eabi-" if ARCH_ARM_AARCH32
config COMPILER_CLANG_LLVM config COMPILER_CLANG_LLVM
bool "Clang" bool "Clang"
config LLVM_TARGET
string "Clang LLVM target"
depends on COMPILER_CLANG_LLVM
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
config COMPILER_ICCARM config COMPILER_ICCARM
bool "ICCARM" bool "ICCARM"
@ -96,15 +86,6 @@ config PLATFORM
string string
default "virt" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32 default "virt" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
config PRODUCT_NAME
string
default "arm_virt" if PRODUCT_QEMU_ARM
default "arm_mps2_an386" if PRODUCT_QEMU_ARM_MPS2_AN386
default "arm_mps3_an547" if PRODUCT_QEMU_ARM_MPS3_AN547
default "riscv32_virt" if PRODUCT_QEMU_RISCV32_VIRT
default "csky_smartl_e802" if PRODUCT_QEMU_CSKY_SMARTL_E802
default "xtensa_esp32" if PRODUCT_QEMU_XTENSA_ESP32
config DEVICE_COMPANY config DEVICE_COMPANY
string string
default "qemu" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32 default "qemu" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
@ -163,24 +144,9 @@ choice
help help
Select your target board. Select your target board.
config PRODUCT_QEMU_ARM
bool "arm_virt" if PLATFORM_QEMU_ARM_VIRT_CM7
config PRODUCT_QEMU_ARM_MPS2_AN386
bool "arm_mps2_an386" if PLATFORM_QEMU_ARM_VIRT_CM4
config PRODUCT_QEMU_ARM_MPS3_AN547
bool "arm_mps3_an547" if PLATFORM_QEMU_ARM_VIRT_CM55
config PRODUCT_QEMU_RISCV32_VIRT config PRODUCT_QEMU_RISCV32_VIRT
bool "riscv32_virt" if PLATFORM_QEMU_RISCV32_VIRT bool "riscv32_virt" if PLATFORM_QEMU_RISCV32_VIRT
config PRODUCT_QEMU_CSKY_SMARTL_E802
bool "csky_smartl_e802" if PLATFORM_QEMU_CSKY_SMARTL
config PRODUCT_QEMU_XTENSA_ESP32
bool "xtensa_esp32" if PLATFORM_QEMU_XTENSA_ESP32
endchoice endchoice
@ -219,12 +185,6 @@ endchoice
orsource "../../device/soc/*/Kconfig.liteos_m.soc" orsource "../../device/soc/*/Kconfig.liteos_m.soc"
config QUICK_START
bool "Enable QUICK_START"
default n
depends on DRIVERS && FS_VFS
help
Answer Y to enable LiteOS support quick start.
endmenu endmenu
######################### config options of kernel ##################### ######################### config options of kernel #####################
@ -343,21 +303,6 @@ config KERNEL_PM_IDLE
Configuration item for low power frame tailoring. Configuration item for low power frame tailoring.
If you wish to build LiteOS with support for power management idle. If you wish to build LiteOS with support for power management idle.
config KERNEL_PM_TASK_PTIORITY
int "Power Management Task Priority"
default 1
range 1 31
depends on KERNEL_PM
help
Configuration item for priority of low-power task.
config KERNEL_PM_TASK_STACKSIZE
int "Power Management Task Stack Size"
default 1024
depends on KERNEL_PM
help
Configuration item for stack size of low-power task.
config KERNEL_PM_DEBUG config KERNEL_PM_DEBUG
bool "Power Management Debug" bool "Power Management Debug"
default n default n
@ -393,17 +338,6 @@ source "components/lms/Kconfig"
endmenu endmenu
######################### config options of lib ########################
menu "Lib"
config LIB_LIBC
bool "Enable Libc"
default y
help
Answer Y to enable libc for full code.
endmenu
######################### config options of compatibility ############## ######################### config options of compatibility ##############
menu "Compat" menu "Compat"
@ -436,43 +370,6 @@ endmenu
######################## config options of debug ######################## ######################## config options of debug ########################
menu "Debug" menu "Debug"
config GDB
bool "Enable gdb functions"
default n
help
Answer Y to enable gdb functions.
config PLATFORM_ADAPT
bool "Enable Os_adapt"
default y
help
Answer Y to add os_adapt.c to LiteOS.
config ENABLE_OOM_LOOP_TASK
bool "Enable Oom loop task"
default n
depends on KERNEL_VM
help
Answer Y to enable oom loop kthread to check system out of memory.
config DO_ALIGN
bool "Enable do align for hi3518e"
default y
depends on PLATFORM_HI3518EV200
help
Answer Y to enable do align for hi3518e.
config ENABLE_MAGICKEY
bool "Enable MAGIC KEY"
default y
help
Answer Y to enable LiteOS Magic key.
ctrl + r : Magic key check switch;
ctrl + z : Show all magic op key;
ctrl + t : Show task information;
ctrl + p : System panic;
ctrl + e : Check system memory pool.
config THUMB config THUMB
bool "Enable Thumb" bool "Enable Thumb"
@ -481,20 +378,6 @@ config THUMB
help help
Answer Y to build thumb version. This will make LiteOS smaller. Answer Y to build thumb version. This will make LiteOS smaller.
config PLATFORM_DVFS
bool "Enable Dvfs"
default n
depends on COMPAT_LINUXKPI
help
Answer Y to enable LiteOS support dynamic voltage and frequency scaling feature for
low power consumption.
config SAVE_EXCINFO
bool "Enable Saving Exception Information"
default n
help
Answer Y to enable LiteOS support saving exception information to storage medium.
config DEBUG_VERSION config DEBUG_VERSION
bool "Enable a Debug Version" bool "Enable a Debug Version"
default y default y
@ -514,13 +397,6 @@ config DEBUG_KERNEL
It also means you want to get queue, mutex, semaphore, memory debug information. It also means you want to get queue, mutex, semaphore, memory debug information.
That means you want a opposite behaviour compared to release version. That means you want a opposite behaviour compared to release version.
config DEBUG_QUEUE
bool "Enable Queue Debugging"
default n
depends on DEBUG_KERNEL
help
Answer Y to enable debug queue.
config MUTEX_CREATE_TRACE config MUTEX_CREATE_TRACE
bool "Enable Mutex Trace Debugging" bool "Enable Mutex Trace Debugging"
default n default n
@ -529,20 +405,6 @@ config MUTEX_CREATE_TRACE
help help
Answer Y to enable debug mutex trace. Answer Y to enable debug mutex trace.
config DEBUG_DEADLOCK
bool "Enable Mutex Deadlock Debugging"
default n
depends on DEBUG_KERNEL
help
Answer Y to enable debug mutex deadlock.
config DEBUG_SEMAPHORE
bool "Enable Semaphore Debugging"
default n
depends on DEBUG_KERNEL
help
Answer Y to enable debug semaphore.
config NET_LWIP_SACK_TFTP config NET_LWIP_SACK_TFTP
bool "Enable Tftp" bool "Enable Tftp"
default y default y
@ -557,18 +419,6 @@ config DEBUG_HOOK
help help
Enable the kernel hook framework to support customized trace information capture. Enable the kernel hook framework to support customized trace information capture.
config SCHED_DEBUG
bool "Enable sched debug Feature"
default n
depends on DEBUG_VERSION
help
If you wish to build LiteOS with support for sched debug.
config USER_INIT_DEBUG
bool "Enable user init Debug"
default n
depends on DEBUG_VERSION
config SHELL_CMD_DEBUG config SHELL_CMD_DEBUG
bool "Enable shell cmd Debug" bool "Enable shell cmd Debug"
default n default n
@ -581,13 +431,6 @@ config DEBUG_TOOLS
help help
Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack. Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack.
config USB_DEBUG
bool "Enable USB Debug"
default n
depends on SHELL && DRIVERS_USB && DEBUG_VERSION
help
Answer Y to enable LiteOS support usb debug.
use shell command to open the specified debug level print.
config MEM_DEBUG config MEM_DEBUG
bool "Enable MEM Debug" bool "Enable MEM Debug"
default n default n
@ -611,13 +454,6 @@ config MEM_WATERLINE
default n default n
depends on DEBUG_VERSION && MEM_DEBUG depends on DEBUG_VERSION && MEM_DEBUG
config VM_OVERLAP_CHECK
bool "Enable VM overlap check or not"
default n
depends on DEBUG_VERSION && MEM_DEBUG
help
Answer Y to enable vm overlap check.
config TASK_MEM_USED config TASK_MEM_USED
bool "Enable show task mem used or not" bool "Enable show task mem used or not"
default n default n
@ -643,12 +479,6 @@ config SECURE_HEAP_SIZE
int "TrustZone Heap Size (bytes)" int "TrustZone Heap Size (bytes)"
default 2048 default 2048
depends on SECURE_TRUSTZONE depends on SECURE_TRUSTZONE
config SECURE_STACK_DEFAULT_SIZE
int "TrustZone Stack Size (bytes)"
default 512
depends on SECURE_TRUSTZONE
help
The secure stack must be allocated before the task calls non-secure functions.
config SECURE config SECURE
bool "Enable Security" bool "Enable Security"
default n default n

View File

@ -23,6 +23,7 @@
<policylist> <policylist>
<policy name="projectPolicy" desc=""> <policy name="projectPolicy" desc="">
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/> <policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="copyright" name="Hunan OpenValley Digital Industry Development Co., Ltd." path=".*" desc="Developed By OpenValley Digital Co., Ltd."/>
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/> <policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/> <policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
</policy> </policy>
@ -66,6 +67,9 @@
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/--> <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter> </filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies"> <filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filepath"
name="figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png" desc="architecture-of-openharmony-the-liteos-cortex-m-kernel"/>
<filteritem type="filepath" name="figures/OpenHarmony-LiteOS-M核内核架构图.png" desc="内核驱动架构"/>
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/--> <!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/--> <!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/--> <!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->

View File

@ -35,7 +35,7 @@ The directory structure is as follows. For more details, see [arch_spec.md](arch
│ ├── include # APIs exposed externally │ ├── include # APIs exposed externally
│ ├── risc-v # Code of the risc-v architecture │ ├── risc-v # Code of the risc-v architecture
│ │ ├── nuclei # Code of the nuclei system technology risc-v architecture │ │ ├── nuclei # Code of the nuclei system technology risc-v architecture
│ │ └── riscv32 # Code of the risc-v architecture │ │ └── riscv32 # Code of the risc-v official common architecture
│ └── xtensa # Code of the xtensa architecture │ └── xtensa # Code of the xtensa architecture
│ └── lx6 # Code of the lx6 xtensa architecture │ └── lx6 # Code of the lx6 xtensa architecture
├── components # Optional components ├── components # Optional components

View File

@ -24,27 +24,6 @@ config ARCH_FPU_DISABLE
help help
This option will bypass floating procedure in system. This option will bypass floating procedure in system.
config ARCH_SECURE_MONITOR_MODE
bool "Run On Secure Monitor Mode"
default n
depends on ARCH_ARM_AARCH64
help
This option will make the system run on EL3.
config ARCH_INTERRUPT_PREEMPTION
bool "Enable Interrupt Preemption"
default n
depends on ARCH_ARM_AARCH64
help
This option will support high priority interrupt preemption.
config IRQ_USE_STANDALONE_STACK
bool "Use Interrupt Stack"
default y
depends on ARCH_ARM_AARCH64 || ARCH_ARM_AARCH32
help
This option will support using standalone interrupt stack.
config ARCH_UNALIGNED_EXC config ARCH_UNALIGNED_EXC
bool "Enable Unaligned Exception" bool "Enable Unaligned Exception"
default y default y

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. # 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, # Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met: # are permitted provided that the following conditions are met:
@ -34,10 +34,11 @@ config("arm_config") {
} }
module_group("arm") { module_group("arm") {
modules = [ "common" ]
if (defined(LOSCFG_COMPILER_ICCARM)) { if (defined(LOSCFG_COMPILER_ICCARM)) {
modules = [ "$board_cpu/iar" ] modules += [ "$board_cpu/iar" ]
} else { } else {
modules = [ "$board_cpu/gcc" ] modules += [ "$board_cpu/gcc" ]
} }
configs = [ ":arm_config" ] configs = [ ":arm_config" ]
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,19 +56,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #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 * @ingroup los_arch_interrupt
* Count of arm9 system interrupt vector. * 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) #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 * @ingroup los_arch_interrupt
* Set interrupt vector table. * Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/ */
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg); #define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
#else
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -207,35 +180,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li
></ul>
* @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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -325,7 +269,6 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_intCount;
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -42,7 +40,6 @@
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1) #if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h" #include "los_cpup.h"
#endif #endif
#include "los_reg.h"
#define OS_INT_IRQ_ENABLE (1U << 0) #define OS_INT_IRQ_ENABLE (1U << 0)
#define OS_INT_FIQ_ENABLE (1U << 1) #define OS_INT_FIQ_ENABLE (1U << 1)
@ -55,86 +52,8 @@
#define OS_ARM_INSTR_LEN 4 #define OS_ARM_INSTR_LEN 4
#define OS_THUMB_INSTR_LEN 2 #define OS_THUMB_INSTR_LEN 2
UINT32 g_intCount = 0;
ExcInfo g_excInfo = {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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -153,10 +72,6 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) 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)); *((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (hwiNum));
return LOS_OK; return LOS_OK;
@ -164,48 +79,28 @@ STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
STATIC UINT32 HwiMask(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)); *((volatile UINT32 *)OS_INT_ENABLE_ADDR) &= ~(1U << (hwiNum));
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -264,87 +159,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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) #if (LOSCFG_KERNEL_PRINTF != 0)
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo) 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 reg; UINT32 reg;
UINT32 val; UINT32 val;
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
for (val = OS_SYS_VECTOR_CNT; val < OS_VECTOR_CNT; val++) { for (val = OS_SYS_VECTOR_CNT; val < OS_VECTOR_CNT; val++) {
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1) #if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
g_hwiForm[val].pfnHook = HalHwiDefaultHandler; hwiForm[val].pfnHook = HalHwiDefaultHandler;
g_hwiForm[val].uwParam = 0; hwiForm[val].uwParam = 0;
#else #else
g_hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler; hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
#endif #endif
} }
@ -560,4 +375,3 @@ UINT32 ArchIntUnLock(VOID)
: "memory"); : "memory");
return intSave; return intSave;
} }

39
arch/arm/common/BUILD.gn Normal file
View File

@ -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 = [ "." ]
}

View File

@ -0,0 +1,324 @@
/*
* 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)
/* *
* @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);
}

View File

@ -0,0 +1,123 @@
/*
* 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)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @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 */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -42,14 +42,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,19 +58,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #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 * @ingroup los_arch_interrupt
* Count of M-Core system interrupt vector. * 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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +301,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +320,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,17 +359,12 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #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_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +446,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -668,7 +610,6 @@ typedef struct TagExcInfo {
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount; extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32]; extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -43,95 +41,6 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -146,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -297,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -610,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -655,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -86,7 +86,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function. * AIRCR register priority group parameter .
*/ */
typedef VOID (**HWI_VECTOR_FUNC)(void); #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of interrupts. * Boot interrupt vector table.
*/ */
extern UINT32 g_intCount; extern UINT32 _BootVectors[];
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #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 * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,84 +42,6 @@
#endif #endif
#define DEF_HANDLER_START_INDEX 2 #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 Function : HwiNumGet
@ -137,99 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{ {
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = 0; /* [1] reset */ hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) { 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler; hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -85,7 +85,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function. * AIRCR register priority group parameter .
*/ */
typedef VOID (**HWI_VECTOR_FUNC)(void); #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of interrupts. * Boot interrupt vector table.
*/ */
extern UINT32 g_intCount; extern UINT32 _BootVectors[];
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #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 * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,83 +42,6 @@
#endif #endif
#define DEF_HANDLER_START_INDEX 2 #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 Function : HwiNumGet
@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{ {
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = 0; /* [1] reset */ hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) { 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler; hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef _LOS_EXC_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_EXC_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* * /* *
* @ingroup los_hwi * @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_hwi
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_HIGHEST #ifndef OS_HWI_PRIO_HIGHEST
@ -59,63 +49,50 @@ extern "C" {
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt. * Lowest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_LOWEST #ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* 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
* AIRCR register priority group parameter . * AIRCR register priority group parameter .
*/ */
#define OS_NVIC_AIRCR_PRIGROUP 7 #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Boot interrupt vector table. * Boot interrupt vector table.
*/ */
extern UINT32 _BootVectors[]; 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. * Hardware interrupt error code: Invalid interrupt number.
* *
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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. * Hardware interrupt error code: Null hardware interrupt handling function.
* *
* Value: 0x02000901 * Value: 0x02000901
@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) #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. * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
* *
* Value: 0x02000902 * Value: 0x02000902
@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) #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. * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
* *
* Value: 0x02000903 * Value: 0x02000903
@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) #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. * Hardware interrupt error code: The interrupt has already been created.
* *
* Value: 0x02000904 * Value: 0x02000904
@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) #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. * Hardware interrupt error code: Invalid interrupt priority.
* *
* Value: 0x02000905 * Value: 0x02000905
@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode. * Hardware interrupt error code: Incorrect interrupt creation mode.
* *
* Value: 0x02000906 * Value: 0x02000906
@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) #define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt. * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
* *
* Value: 0x02000907 * Value: 0x02000907
@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
*/ */
#define OS_SYSTICK_CONTROL_REG 0xE000E010 #define OS_SYSTICK_CONTROL_REG 0xE000E010
@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018 #define OS_SYSTICK_CURRENT_REG 0xE000E018
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers. * Interrupt Priority-Level Registers.
*/ */
#define OS_NVIC_PRI_BASE 0xE000E400 #define OS_NVIC_PRI_BASE 0xE000E400
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31. * Interrupt enable register for 0-31.
*/ */
#define OS_NVIC_SETENA_BASE 0xE000E100 #define OS_NVIC_SETENA_BASE 0xE000E100
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* interrupt pending register. * interrupt pending register.
*/ */
#define OS_NVIC_SETPEND_BASE 0xE000E200 #define OS_NVIC_SETPEND_BASE 0xE000E200
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt active register. * Interrupt active register.
*/ */
#define OS_NVIC_INT_ACT_BASE 0xE000E300 #define OS_NVIC_INT_ACT_BASE 0xE000E300
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31. * Interrupt disable register for 0-31.
*/ */
#define OS_NVIC_CLRENA_BASE 0xE000E180 #define OS_NVIC_CLRENA_BASE 0xE000E180
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt control and status register. * Interrupt control and status register.
*/ */
#define OS_NVIC_INT_CTRL 0xE000ED04 #define OS_NVIC_INT_CTRL 0xE000ED04
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Vector table offset register. * Vector table offset register.
*/ */
#define OS_NVIC_VTOR 0xE000ED08 #define OS_NVIC_VTOR 0xE000ED08
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Application interrupt and reset control register * Application interrupt and reset control register
*/ */
#define OS_NVIC_AIRCR 0xE000ED0C #define OS_NVIC_AIRCR 0xE000ED0C
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* System exception priority register. * System exception priority register.
*/ */
#define OS_NVIC_EXCPRI_BASE 0xE000ED18 #define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset. * Interrupt No. 1 :reset.
*/ */
#define OS_EXC_RESET 1 #define OS_EXC_RESET 1
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt. * Interrupt No. 2 :Non-Maskable Interrupt.
*/ */
#define OS_EXC_NMI 2 #define OS_EXC_NMI 2
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault. * Interrupt No. 3 :(hard)fault.
*/ */
#define OS_EXC_HARD_FAULT 3 #define OS_EXC_HARD_FAULT 3
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault. * Interrupt No. 4 :MemManage fault.
*/ */
#define OS_EXC_MPU_FAULT 4 #define OS_EXC_MPU_FAULT 4
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault. * Interrupt No. 5 :Bus fault.
*/ */
#define OS_EXC_BUS_FAULT 5 #define OS_EXC_BUS_FAULT 5
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault. * Interrupt No. 6 :Usage fault.
*/ */
#define OS_EXC_USAGE_FAULT 6 #define OS_EXC_USAGE_FAULT 6
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall. * Interrupt No. 11 :SVCall.
*/ */
#define OS_EXC_SVC_CALL 11 #define OS_EXC_SVC_CALL 11
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor. * Interrupt No. 12 :Debug monitor.
*/ */
#define OS_EXC_DBG_MONITOR 12 #define OS_EXC_DBG_MONITOR 12
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV. * Interrupt No. 14 :PendSV.
*/ */
#define OS_EXC_PEND_SV 14 #define OS_EXC_PEND_SV 14
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick. * Interrupt No. 15 :SysTick.
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_hwi
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID); extern VOID HalInterrupt(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li
></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* *
* @ingroup los_hwi
* @brief: Reset the vector table. * @brief: Reset the vector table.
* *
* @par Description: * @par Description:
@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID Reset_Handler(VOID); extern VOID Reset_Handler(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Pended System Call. * @brief: Pended System Call.
* *
* @par Description: * @par Description:
@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR; UINT32 FPSCR;
UINT32 NO_NAME; UINT32 NO_NAME;
#endif #endif
}EXC_CONTEXT_S; } EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc * @ingroup los_exc
* Exception information structure * 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 { typedef struct TagExcInfo {
@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)
@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* _LOS_EXC_H */ #endif /* _LOS_ARCH_INTERRUPT_H */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h> #include <stdarg.h>
#include "los_arch_interrupt.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_debug.h" #include "los_arch_interrupt.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,93 +42,6 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef _LOS_EXC_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_EXC_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* * /* *
* @ingroup los_hwi * @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_hwi
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_HIGHEST #ifndef OS_HWI_PRIO_HIGHEST
@ -59,63 +49,50 @@ extern "C" {
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt. * Lowest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_LOWEST #ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* 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
* AIRCR register priority group parameter . * AIRCR register priority group parameter .
*/ */
#define OS_NVIC_AIRCR_PRIGROUP 7 #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Boot interrupt vector table. * Boot interrupt vector table.
*/ */
extern UINT32 _BootVectors[]; 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. * Hardware interrupt error code: Invalid interrupt number.
* *
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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. * Hardware interrupt error code: Null hardware interrupt handling function.
* *
* Value: 0x02000901 * Value: 0x02000901
@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) #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. * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
* *
* Value: 0x02000902 * Value: 0x02000902
@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) #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. * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
* *
* Value: 0x02000903 * Value: 0x02000903
@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) #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. * Hardware interrupt error code: The interrupt has already been created.
* *
* Value: 0x02000904 * Value: 0x02000904
@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) #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. * Hardware interrupt error code: Invalid interrupt priority.
* *
* Value: 0x02000905 * Value: 0x02000905
@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode. * Hardware interrupt error code: Incorrect interrupt creation mode.
* *
* Value: 0x02000906 * Value: 0x02000906
@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) #define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt. * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
* *
* Value: 0x02000907 * Value: 0x02000907
@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
*/ */
#define OS_SYSTICK_CONTROL_REG 0xE000E010 #define OS_SYSTICK_CONTROL_REG 0xE000E010
@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018 #define OS_SYSTICK_CURRENT_REG 0xE000E018
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers. * Interrupt Priority-Level Registers.
*/ */
#define OS_NVIC_PRI_BASE 0xE000E400 #define OS_NVIC_PRI_BASE 0xE000E400
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31. * Interrupt enable register for 0-31.
*/ */
#define OS_NVIC_SETENA_BASE 0xE000E100 #define OS_NVIC_SETENA_BASE 0xE000E100
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* interrupt pending register. * interrupt pending register.
*/ */
#define OS_NVIC_SETPEND_BASE 0xE000E200 #define OS_NVIC_SETPEND_BASE 0xE000E200
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt active register. * Interrupt active register.
*/ */
#define OS_NVIC_INT_ACT_BASE 0xE000E300 #define OS_NVIC_INT_ACT_BASE 0xE000E300
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31. * Interrupt disable register for 0-31.
*/ */
#define OS_NVIC_CLRENA_BASE 0xE000E180 #define OS_NVIC_CLRENA_BASE 0xE000E180
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt control and status register. * Interrupt control and status register.
*/ */
#define OS_NVIC_INT_CTRL 0xE000ED04 #define OS_NVIC_INT_CTRL 0xE000ED04
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Vector table offset register. * Vector table offset register.
*/ */
#define OS_NVIC_VTOR 0xE000ED08 #define OS_NVIC_VTOR 0xE000ED08
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Application interrupt and reset control register * Application interrupt and reset control register
*/ */
#define OS_NVIC_AIRCR 0xE000ED0C #define OS_NVIC_AIRCR 0xE000ED0C
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* System exception priority register. * System exception priority register.
*/ */
#define OS_NVIC_EXCPRI_BASE 0xE000ED18 #define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset. * Interrupt No. 1 :reset.
*/ */
#define OS_EXC_RESET 1 #define OS_EXC_RESET 1
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt. * Interrupt No. 2 :Non-Maskable Interrupt.
*/ */
#define OS_EXC_NMI 2 #define OS_EXC_NMI 2
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault. * Interrupt No. 3 :(hard)fault.
*/ */
#define OS_EXC_HARD_FAULT 3 #define OS_EXC_HARD_FAULT 3
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault. * Interrupt No. 4 :MemManage fault.
*/ */
#define OS_EXC_MPU_FAULT 4 #define OS_EXC_MPU_FAULT 4
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault. * Interrupt No. 5 :Bus fault.
*/ */
#define OS_EXC_BUS_FAULT 5 #define OS_EXC_BUS_FAULT 5
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault. * Interrupt No. 6 :Usage fault.
*/ */
#define OS_EXC_USAGE_FAULT 6 #define OS_EXC_USAGE_FAULT 6
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall. * Interrupt No. 11 :SVCall.
*/ */
#define OS_EXC_SVC_CALL 11 #define OS_EXC_SVC_CALL 11
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor. * Interrupt No. 12 :Debug monitor.
*/ */
#define OS_EXC_DBG_MONITOR 12 #define OS_EXC_DBG_MONITOR 12
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV. * Interrupt No. 14 :PendSV.
*/ */
#define OS_EXC_PEND_SV 14 #define OS_EXC_PEND_SV 14
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick. * Interrupt No. 15 :SysTick.
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_hwi
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID); extern VOID HalInterrupt(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li
></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* *
* @ingroup los_hwi
* @brief: Reset the vector table. * @brief: Reset the vector table.
* *
* @par Description: * @par Description:
@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID Reset_Handler(VOID); extern VOID Reset_Handler(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Pended System Call. * @brief: Pended System Call.
* *
* @par Description: * @par Description:
@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR; UINT32 FPSCR;
UINT32 NO_NAME; UINT32 NO_NAME;
#endif #endif
}EXC_CONTEXT_S; } EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc * @ingroup los_exc
* Exception information structure * 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 { typedef struct TagExcInfo {
@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)
@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* _LOS_EXC_H */ #endif /* _LOS_ARCH_INTERRUPT_H */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h> #include <stdarg.h>
#include "los_arch_interrupt.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_debug.h" #include "los_arch_interrupt.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,93 +42,6 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -85,7 +85,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function. * AIRCR register priority group parameter .
*/ */
typedef VOID (**HWI_VECTOR_FUNC)(void); #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of interrupts. * Boot interrupt vector table.
*/ */
extern UINT32 g_intCount; extern UINT32 _BootVectors[];
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #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 * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -43,89 +42,6 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -140,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -291,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -614,6 +394,11 @@ WEAK VOID __stack_chk_fail(VOID)
__builtin_return_address(0)); __builtin_return_address(0));
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -659,4 +445,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function. * AIRCR register priority group parameter .
*/ */
typedef VOID (**HWI_VECTOR_FUNC)(void); #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of interrupts. * Boot interrupt vector table.
*/ */
extern UINT32 g_intCount; extern UINT32 _BootVectors[];
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #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 * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h> #include <stdarg.h>
#include "los_arch_interrupt.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_debug.h" #include "los_arch_interrupt.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,95 +42,6 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -147,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -299,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -612,6 +384,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -657,4 +435,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -31,9 +31,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -41,14 +39,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -65,18 +55,11 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #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 * @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 * @ingroup los_arch_interrupt
@ -90,12 +73,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #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 * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -103,7 +80,7 @@ extern UINT32 g_intCount;
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -154,7 +131,7 @@ extern UINT32 g_intCount;
* Value: 0x02000905 * Value: 0x02000905
* *
* Solution: Ensure that the interrupt priority is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -305,20 +292,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -338,25 +311,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -396,34 +350,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -496,7 +436,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -654,7 +593,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc * @ingroup los_exc
* Exception information structure * 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 { typedef struct TagExcInfo {
@ -677,10 +616,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -43,89 +41,6 @@
#endif #endif
#define DEF_HANDLER_START_INDEX 2 #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 Function : HwiNumGet
@ -141,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -292,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -609,6 +388,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = 0; /* [1] reset */ hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) { 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler; hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -654,4 +439,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function. * AIRCR register priority group parameter .
*/ */
typedef VOID (**HWI_VECTOR_FUNC)(void); #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of interrupts. * Boot interrupt vector table.
*/ */
extern UINT32 g_intCount; extern UINT32 _BootVectors[];
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #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 * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -644,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc * @ingroup los_exc
* Exception information structure * 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 { typedef struct TagExcInfo {
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
#include "los_memory.h" #include "los_memory.h"
#include "los_membox.h" #include "los_membox.h"
#include "los_hook.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1) #if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h" #include "los_cpup.h"
#endif #endif
#define DEF_HANDLER_START_INDEX 2 #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 Function : HwiNumGet
@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{ {
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = 0; /* [1] reset */ hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) { 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler; hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef _LOS_EXC_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_EXC_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* * /* *
* @ingroup los_hwi * @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_hwi
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_HIGHEST #ifndef OS_HWI_PRIO_HIGHEST
@ -59,63 +49,50 @@ extern "C" {
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt. * Lowest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_LOWEST #ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* 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
* AIRCR register priority group parameter . * AIRCR register priority group parameter .
*/ */
#define OS_NVIC_AIRCR_PRIGROUP 7 #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Boot interrupt vector table. * Boot interrupt vector table.
*/ */
extern UINT32 _BootVectors[]; 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. * Hardware interrupt error code: Invalid interrupt number.
* *
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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. * Hardware interrupt error code: Null hardware interrupt handling function.
* *
* Value: 0x02000901 * Value: 0x02000901
@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) #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. * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
* *
* Value: 0x02000902 * Value: 0x02000902
@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) #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. * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
* *
* Value: 0x02000903 * Value: 0x02000903
@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) #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. * Hardware interrupt error code: The interrupt has already been created.
* *
* Value: 0x02000904 * Value: 0x02000904
@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) #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. * Hardware interrupt error code: Invalid interrupt priority.
* *
* Value: 0x02000905 * Value: 0x02000905
@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode. * Hardware interrupt error code: Incorrect interrupt creation mode.
* *
* Value: 0x02000906 * Value: 0x02000906
@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) #define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt. * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
* *
* Value: 0x02000907 * Value: 0x02000907
@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
*/ */
#define OS_SYSTICK_CONTROL_REG 0xE000E010 #define OS_SYSTICK_CONTROL_REG 0xE000E010
@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018 #define OS_SYSTICK_CURRENT_REG 0xE000E018
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers. * Interrupt Priority-Level Registers.
*/ */
#define OS_NVIC_PRI_BASE 0xE000E400 #define OS_NVIC_PRI_BASE 0xE000E400
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31. * Interrupt enable register for 0-31.
*/ */
#define OS_NVIC_SETENA_BASE 0xE000E100 #define OS_NVIC_SETENA_BASE 0xE000E100
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* interrupt pending register. * interrupt pending register.
*/ */
#define OS_NVIC_SETPEND_BASE 0xE000E200 #define OS_NVIC_SETPEND_BASE 0xE000E200
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt active register. * Interrupt active register.
*/ */
#define OS_NVIC_INT_ACT_BASE 0xE000E300 #define OS_NVIC_INT_ACT_BASE 0xE000E300
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31. * Interrupt disable register for 0-31.
*/ */
#define OS_NVIC_CLRENA_BASE 0xE000E180 #define OS_NVIC_CLRENA_BASE 0xE000E180
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt control and status register. * Interrupt control and status register.
*/ */
#define OS_NVIC_INT_CTRL 0xE000ED04 #define OS_NVIC_INT_CTRL 0xE000ED04
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Vector table offset register. * Vector table offset register.
*/ */
#define OS_NVIC_VTOR 0xE000ED08 #define OS_NVIC_VTOR 0xE000ED08
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Application interrupt and reset control register * Application interrupt and reset control register
*/ */
#define OS_NVIC_AIRCR 0xE000ED0C #define OS_NVIC_AIRCR 0xE000ED0C
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* System exception priority register. * System exception priority register.
*/ */
#define OS_NVIC_EXCPRI_BASE 0xE000ED18 #define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset. * Interrupt No. 1 :reset.
*/ */
#define OS_EXC_RESET 1 #define OS_EXC_RESET 1
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt. * Interrupt No. 2 :Non-Maskable Interrupt.
*/ */
#define OS_EXC_NMI 2 #define OS_EXC_NMI 2
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault. * Interrupt No. 3 :(hard)fault.
*/ */
#define OS_EXC_HARD_FAULT 3 #define OS_EXC_HARD_FAULT 3
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault. * Interrupt No. 4 :MemManage fault.
*/ */
#define OS_EXC_MPU_FAULT 4 #define OS_EXC_MPU_FAULT 4
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault. * Interrupt No. 5 :Bus fault.
*/ */
#define OS_EXC_BUS_FAULT 5 #define OS_EXC_BUS_FAULT 5
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault. * Interrupt No. 6 :Usage fault.
*/ */
#define OS_EXC_USAGE_FAULT 6 #define OS_EXC_USAGE_FAULT 6
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall. * Interrupt No. 11 :SVCall.
*/ */
#define OS_EXC_SVC_CALL 11 #define OS_EXC_SVC_CALL 11
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor. * Interrupt No. 12 :Debug monitor.
*/ */
#define OS_EXC_DBG_MONITOR 12 #define OS_EXC_DBG_MONITOR 12
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV. * Interrupt No. 14 :PendSV.
*/ */
#define OS_EXC_PEND_SV 14 #define OS_EXC_PEND_SV 14
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick. * Interrupt No. 15 :SysTick.
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_hwi
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID); extern VOID HalInterrupt(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li
></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* *
* @ingroup los_hwi
* @brief: Reset the vector table. * @brief: Reset the vector table.
* *
* @par Description: * @par Description:
@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID Reset_Handler(VOID); extern VOID Reset_Handler(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Pended System Call. * @brief: Pended System Call.
* *
* @par Description: * @par Description:
@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR; UINT32 FPSCR;
UINT32 NO_NAME; UINT32 NO_NAME;
#endif #endif
}EXC_CONTEXT_S; } EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc * @ingroup los_exc
* Exception information structure * 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 { typedef struct TagExcInfo {
@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)
@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* _LOS_EXC_H */ #endif /* _LOS_ARCH_INTERRUPT_H */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h> #include <stdarg.h>
#include "los_arch_interrupt.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_debug.h" #include "los_arch_interrupt.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,93 +42,6 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. # 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, # Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met: # are permitted provided that the following conditions are met:
@ -32,15 +32,21 @@ import("//kernel/liteos_m/liteos.gni")
module_name = "arch" module_name = "arch"
kernel_module(module_name) { kernel_module(module_name) {
sources = [ sources = [
"los_context.c", "non_secure/los_context.c",
"los_dispatch.S", "non_secure/los_dispatch.S",
"los_exc.S", "non_secure/los_exc.S",
"los_interrupt.c", "non_secure/los_interrupt.c",
"los_timer.c", "non_secure/los_timer.c",
"non_secure/los_trustzone.c",
] ]
configs += [ "$LITEOSTOPDIR:warn_config" ] configs += [ "$LITEOSTOPDIR:warn_config" ]
include_dirs = [
"non_secure",
"secure",
]
} }
config("public") { config("public") {
include_dirs = [ "." ] include_dirs = [ "non_secure" ]
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef _LOS_EXC_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_EXC_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -43,15 +41,7 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* * /* *
* @ingroup los_hwi * @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_hwi
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_HIGHEST #ifndef OS_HWI_PRIO_HIGHEST
@ -59,63 +49,50 @@ extern "C" {
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt. * Lowest priority of a hardware interrupt.
*/ */
#ifndef OS_HWI_PRIO_LOWEST #ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* 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
* AIRCR register priority group parameter . * AIRCR register priority group parameter .
*/ */
#define OS_NVIC_AIRCR_PRIGROUP 7 #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Boot interrupt vector table. * Boot interrupt vector table.
*/ */
extern UINT32 _BootVectors[]; 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. * Hardware interrupt error code: Invalid interrupt number.
* *
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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. * Hardware interrupt error code: Null hardware interrupt handling function.
* *
* Value: 0x02000901 * Value: 0x02000901
@ -125,7 +102,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01) #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. * Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
* *
* Value: 0x02000902 * Value: 0x02000902
@ -135,7 +112,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02) #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. * Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
* *
* Value: 0x02000903 * Value: 0x02000903
@ -145,7 +122,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03) #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. * Hardware interrupt error code: The interrupt has already been created.
* *
* Value: 0x02000904 * Value: 0x02000904
@ -155,7 +132,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04) #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. * Hardware interrupt error code: Invalid interrupt priority.
* *
* Value: 0x02000905 * Value: 0x02000905
@ -166,7 +143,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode. * Hardware interrupt error code: Incorrect interrupt creation mode.
* *
* Value: 0x02000906 * Value: 0x02000906
@ -177,7 +154,7 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06) #define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt. * Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
* *
* Value: 0x02000907 * Value: 0x02000907
@ -187,7 +164,17 @@ extern UINT32 _BootVectors[];
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
*/ */
#define OS_SYSTICK_CONTROL_REG 0xE000E010 #define OS_SYSTICK_CONTROL_REG 0xE000E010
@ -199,133 +186,119 @@ extern UINT32 _BootVectors[];
#define OS_SYSTICK_CURRENT_REG 0xE000E018 #define OS_SYSTICK_CURRENT_REG 0xE000E018
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers. * Interrupt Priority-Level Registers.
*/ */
#define OS_NVIC_PRI_BASE 0xE000E400 #define OS_NVIC_PRI_BASE 0xE000E400
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt enable register for 0-31. * Interrupt enable register for 0-31.
*/ */
#define OS_NVIC_SETENA_BASE 0xE000E100 #define OS_NVIC_SETENA_BASE 0xE000E100
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* interrupt pending register. * interrupt pending register.
*/ */
#define OS_NVIC_SETPEND_BASE 0xE000E200 #define OS_NVIC_SETPEND_BASE 0xE000E200
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt active register. * Interrupt active register.
*/ */
#define OS_NVIC_INT_ACT_BASE 0xE000E300 #define OS_NVIC_INT_ACT_BASE 0xE000E300
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt disable register for 0-31. * Interrupt disable register for 0-31.
*/ */
#define OS_NVIC_CLRENA_BASE 0xE000E180 #define OS_NVIC_CLRENA_BASE 0xE000E180
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt control and status register. * Interrupt control and status register.
*/ */
#define OS_NVIC_INT_CTRL 0xE000ED04 #define OS_NVIC_INT_CTRL 0xE000ED04
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Vector table offset register. * Vector table offset register.
*/ */
#define OS_NVIC_VTOR 0xE000ED08 #define OS_NVIC_VTOR 0xE000ED08
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Application interrupt and reset control register * Application interrupt and reset control register
*/ */
#define OS_NVIC_AIRCR 0xE000ED0C #define OS_NVIC_AIRCR 0xE000ED0C
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* System exception priority register. * System exception priority register.
*/ */
#define OS_NVIC_EXCPRI_BASE 0xE000ED18 #define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 1 :reset. * Interrupt No. 1 :reset.
*/ */
#define OS_EXC_RESET 1 #define OS_EXC_RESET 1
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt. * Interrupt No. 2 :Non-Maskable Interrupt.
*/ */
#define OS_EXC_NMI 2 #define OS_EXC_NMI 2
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault. * Interrupt No. 3 :(hard)fault.
*/ */
#define OS_EXC_HARD_FAULT 3 #define OS_EXC_HARD_FAULT 3
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault. * Interrupt No. 4 :MemManage fault.
*/ */
#define OS_EXC_MPU_FAULT 4 #define OS_EXC_MPU_FAULT 4
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault. * Interrupt No. 5 :Bus fault.
*/ */
#define OS_EXC_BUS_FAULT 5 #define OS_EXC_BUS_FAULT 5
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault. * Interrupt No. 6 :Usage fault.
*/ */
#define OS_EXC_USAGE_FAULT 6 #define OS_EXC_USAGE_FAULT 6
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall. * Interrupt No. 11 :SVCall.
*/ */
#define OS_EXC_SVC_CALL 11 #define OS_EXC_SVC_CALL 11
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor. * Interrupt No. 12 :Debug monitor.
*/ */
#define OS_EXC_DBG_MONITOR 12 #define OS_EXC_DBG_MONITOR 12
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV. * Interrupt No. 14 :PendSV.
*/ */
#define OS_EXC_PEND_SV 14 #define OS_EXC_PEND_SV 14
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick. * Interrupt No. 15 :SysTick.
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_hwi
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -346,27 +319,7 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern VOID HalInterrupt(VOID); extern VOID HalInterrupt(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li
></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* *
* @ingroup los_hwi
* @brief: Reset the vector table. * @brief: Reset the vector table.
* *
* @par Description: * @par Description:
@ -379,13 +332,13 @@ extern VOID HalHwiDefaultHandler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID Reset_Handler(VOID); extern VOID Reset_Handler(VOID);
/* * /* *
* @ingroup los_hwi * @ingroup los_arch_interrupt
* @brief: Pended System Call. * @brief: Pended System Call.
* *
* @par Description: * @par Description:
@ -399,39 +352,25 @@ extern VOID Reset_Handler(VOID);
* *
* @retval:None. * @retval:None.
* @par Dependency: * @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -500,11 +439,10 @@ typedef struct TagExcContext {
UINT32 FPSCR; UINT32 FPSCR;
UINT32 NO_NAME; UINT32 NO_NAME;
#endif #endif
}EXC_CONTEXT_S; } EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -645,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc * @ingroup los_exc
* Exception information structure * 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 { typedef struct TagExcInfo {
@ -668,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)
@ -681,4 +618,4 @@ extern ExcInfo g_excInfo;
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* _LOS_EXC_H */ #endif /* _LOS_ARCH_INTERRUPT_H */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h> #include <stdarg.h>
#include "los_arch_interrupt.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_debug.h" #include "los_arch_interrupt.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,92 +41,7 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #endif
/*lint -save -e40 -e522 -e533*/ #define DEF_HANDLER_START_INDEX 2
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 Function : HwiNumGet
@ -145,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -299,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -622,23 +397,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{ {
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +427,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -85,7 +85,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,19 +56,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #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 * @ingroup los_arch_interrupt
* Count of M-Core system interrupt vector. * Count of M-Core system interrupt vector.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_arch_interrupt.h" #include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -43,84 +41,6 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #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 Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -135,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -286,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -599,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -644,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -0,0 +1,47 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2024 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 = "arch"
kernel_module(module_name) {
sources = [
"los_context.c",
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_mpu.c",
"los_timer.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function. * AIRCR register priority group parameter .
*/ */
typedef VOID (**HWI_VECTOR_FUNC)(void); #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of interrupts. * Boot interrupt vector table.
*/ */
extern UINT32 g_intCount; extern UINT32 _BootVectors[];
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #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 * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * 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) #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) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/ */
#define OS_EXC_SYS_TICK 15 #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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(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_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_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 * @ingroup los_exc
* the struct of register files * the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, 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 HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h> #include <stdarg.h>
#include "los_arch_interrupt.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
#include "los_debug.h" #include "los_arch_interrupt.h"
#include "los_hook.h" #include "los_hook.h"
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
@ -44,90 +42,8 @@
#include "los_cpup.h" #include "los_cpup.h"
#endif #endif
UINT32 g_intCount = 0;
#pragma location = ".data.vector" #pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN #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 Function : HwiNumGet
@ -143,100 +59,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum); NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum); NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority) 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); NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum); NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum); NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK; 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, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -295,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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 FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18) #define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17) #define BUSFAULT (1 << 17)
@ -608,6 +387,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit(); ArchSysExit();
} }
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* **************************************************************************** /* ****************************************************************************
Function : HalHwiInit Function : HalHwiInit
Description : initialization of the hardware interrupt 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) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */ 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 */ 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 */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI; hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault; hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault; hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault; hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault; hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall; hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV; 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[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif #endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */ #if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP); NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -649,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return; return;
} }

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk; SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */ SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn); SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk; SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime; return nextResponseTime;
} }

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. # 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, # Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met: # are permitted provided that the following conditions are met:
@ -30,5 +30,8 @@
import("//kernel/liteos_m/liteos.gni") import("//kernel/liteos_m/liteos.gni")
module_group("csky") { module_group("csky") {
modules = [ "v2/gcc" ] modules = [
"common",
"v2/gcc",
]
} }

39
arch/csky/common/BUILD.gn Normal file
View File

@ -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 = [ "." ]
}

View File

@ -0,0 +1,285 @@
/*
* 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"
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
HWI_PROC_FUNC __attribute__((aligned(HWI_ALIGNSIZE))) g_hwiForm[OS_VECTOR_CNT] = {0};
VOID *ArchGetHwiFrom(VOID)
{
return g_hwiForm;
}
UINT32 volatile 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:%x\n", __FUNCTION__, ArchIntCurIrqNum());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
STATIC UINT32 HwiNumValid(UINT32 num)
{
return ((num) >= OS_USER_HWI_MIN) && ((num) <= OS_USER_HWI_MAX);
}
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return LOS_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 (!HwiNumValid(hwiNum)) {
return LOS_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 (!HwiNumValid(hwiNum)) {
return LOS_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 (!HwiNumValid(hwiNum)) {
return LOS_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 (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
if (!HWI_PRI_VALID(priority)) {
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();
}
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @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)IrqEntry;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
ArchIntEnable(num);
}
}
#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] = IrqEntry;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
ArchIntEnable(num);
}
}
#endif
/* ****************************************************************************
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_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
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
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_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
LOS_IntRestore(intSave);
return LOS_OK;
}
UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}

View File

@ -0,0 +1,121 @@
/*
* 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 volatile 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)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @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_IMPRECISE_ACCESS_ADDR 0xABABABAB
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @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 */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -72,18 +62,6 @@ extern "C" {
*/ */
#define HWI_PRI_VALID(pri) (((pri) >= OS_HWI_PRIO_HIGHEST) && ((pri) <= OS_HWI_PRIO_LOWEST)) #define HWI_PRI_VALID(pri) (((pri) >= OS_HWI_PRIO_HIGHEST) && ((pri) <= OS_HWI_PRIO_LOWEST))
/* *
* @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 volatile UINT32 g_intCount;
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of C-sky system interrupt vector. * Count of C-sky system interrupt vector.
@ -96,6 +74,11 @@ extern volatile UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
#define OS_USER_HWI_MIN 0
#define OS_USER_HWI_MAX (LOSCFG_PLATFORM_HWI_LIMIT - 1)
#define HWI_ALIGNSIZE 0x400
#define PSR_VEC_OFFSET 16U #define PSR_VEC_OFFSET 16U
#define VIC_REG_BASE 0xE000E100UL #define VIC_REG_BASE 0xE000E100UL
@ -208,6 +191,16 @@ extern VIC_TYPE *VIC_REG;
*/ */
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) #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: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -218,20 +211,6 @@ extern VIC_TYPE *VIC_REG;
*/ */
#define LOS_ERRNO_HWI_NUM_INVALID OS_ERRNO_HWI_NUM_INVALID #define LOS_ERRNO_HWI_NUM_INVALID OS_ERRNO_HWI_NUM_INVALID
#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 * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -251,29 +230,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); 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:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @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_VIC_INT_ENABLE_SIZE 0x4 #define OS_VIC_INT_ENABLE_SIZE 0x4
#define OS_VIC_INT_WAKER_SIZE 0x4 #define OS_VIC_INT_WAKER_SIZE 0x4
#define OS_VIC_INT_ICER_SIZE 0x4 #define OS_VIC_INT_ICER_SIZE 0x4
@ -283,10 +239,6 @@ extern VOID HalHwiDefaultHandler(VOID);
#define OS_VIC_INT_ISR_SIZE 0x4 #define OS_VIC_INT_ISR_SIZE 0x4
#define OS_VIC_INT_IPTR_SIZE 0x4 #define OS_VIC_INT_IPTR_SIZE 0x4
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
/** /**
* @ingroup los_exc * @ingroup los_exc
* the struct of register files * the struct of register files

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
@ -53,20 +52,10 @@
#define MASK_32_BITS 0xFFFFFFFF #define MASK_32_BITS 0xFFFFFFFF
#define BYTES_OF_128_INT 4 #define BYTES_OF_128_INT 4
#define OS_USER_HWI_MIN 0
#define OS_USER_HWI_MAX (LOSCFG_PLATFORM_HWI_LIMIT - 1)
#define HWI_ALIGNSIZE 0x400
UINT32 volatile g_intCount = 0;
CHAR g_trapStackBase[OS_TRAP_STACK_SIZE]; CHAR g_trapStackBase[OS_TRAP_STACK_SIZE];
VIC_TYPE *VIC_REG = (VIC_TYPE *)VIC_REG_BASE; VIC_TYPE *VIC_REG = (VIC_TYPE *)VIC_REG_BASE;
UINT32 HwiNumValid(UINT32 num)
{
return ((num) >= OS_USER_HWI_MIN) && ((num) <= OS_USER_HWI_MAX);
}
UINT32 HalGetPsr(VOID) UINT32 HalGetPsr(VOID)
{ {
UINT32 intSave; UINT32 intSave;
@ -120,10 +109,6 @@ STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
UINT32 intSave; UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
intSave = LOS_IntLock(); intSave = LOS_IntLock();
VIC_REG->ISER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT)); VIC_REG->ISER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
VIC_REG->ISSR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT)); VIC_REG->ISSR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
@ -136,14 +121,6 @@ STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{ {
UINT32 intSave; UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
if (!HWI_PRI_VALID(priority)) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock(); intSave = LOS_IntLock();
VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT); VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT);
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
@ -155,10 +132,6 @@ STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
UINT32 intSave; UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
intSave = LOS_IntLock(); intSave = LOS_IntLock();
VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT)); VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
@ -170,10 +143,6 @@ STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
UINT32 intSave; UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
intSave = LOS_IntLock(); intSave = LOS_IntLock();
VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT)); VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
LOS_IntRestore(intSave); LOS_IntRestore(intSave);
@ -183,69 +152,11 @@ STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
VIC_REG->ICPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT)); VIC_REG->ICPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
return LOS_OK; return LOS_OK;
} }
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(HWI_ALIGNSIZE))) g_hwiForm[OS_VECTOR_CNT] = {0};
#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)IrqEntry;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
HwiUnmask(num);
}
}
#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] = IrqEntry;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
HwiUnmask(num);
}
}
#endif
/* **************************************************************************** /* ****************************************************************************
Function : HwiNumGet Function : HwiNumGet
Description : Get an interrupt number Description : Get an interrupt number
@ -258,43 +169,26 @@ STATIC UINT32 HwiNumGet(VOID)
return (HalGetPsr() >> PSR_VEC_OFFSET) & MASK_8_BITS; return (HalGetPsr() >> PSR_VEC_OFFSET) & MASK_8_BITS;
} }
HwiControllerOps g_archHwiOps = { STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
.triggerIrq = HwiPending, {
HwiSetPriority(hwiNum, (UINT8)hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
inline UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
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:%x\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
} }
/* **************************************************************************** /* ****************************************************************************
@ -339,83 +233,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave); 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_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
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
HwiUnmask(hwiNum);
(VOID)HwiSetPriority(hwiNum, (UINT8)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(hwiNum);
intSave = LOS_IntLock();
g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
LOS_IntRestore(intSave);
return LOS_OK;
}
ExcInfo g_excInfo = {0}; ExcInfo g_excInfo = {0};
#if (LOSCFG_KERNEL_PRINTF != 0) #if (LOSCFG_KERNEL_PRINTF != 0)
@ -602,16 +419,17 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{ {
UINT32 i; UINT32 i;
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
for (i = 1; i < OS_SYS_VECTOR_CNT; i++) { for (i = 1; i < OS_SYS_VECTOR_CNT; i++) {
g_hwiForm[i] = (HWI_PROC_FUNC)HandleEntry; hwiForm[i] = (HWI_PROC_FUNC)HandleEntry;
} }
for (i = OS_SYS_VECTOR_CNT; i < (LOSCFG_PLATFORM_HWI_LIMIT + OS_SYS_VECTOR_CNT); i++) { for (i = OS_SYS_VECTOR_CNT; i < (LOSCFG_PLATFORM_HWI_LIMIT + OS_SYS_VECTOR_CNT); i++) {
g_hwiForm[i] = (HWI_PROC_FUNC)IrqEntry; hwiForm[i] = (HWI_PROC_FUNC)IrqEntry;
} }
HalHwiHandleReInit((UINT32)&g_hwiForm); HalHwiHandleReInit((UINT32)hwiForm);
HalSetVbr((UINT32)&g_hwiForm); HalSetVbr((UINT32)hwiForm);
for (i = 0; i < BYTES_OF_128_INT; i++) { for (i = 0; i < BYTES_OF_128_INT; i++) {
VIC_REG->IABR[i] = 0x0; VIC_REG->IABR[i] = 0x0;
VIC_REG->ICPR[i] = MASK_32_BITS; VIC_REG->ICPR[i] = MASK_32_BITS;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -31,6 +31,7 @@
#ifndef _LOS_INTERRUPT_H #ifndef _LOS_INTERRUPT_H
#define _LOS_INTERRUPT_H #define _LOS_INTERRUPT_H
#include "los_config.h" #include "los_config.h"
#include "los_compiler.h" #include "los_compiler.h"
@ -41,11 +42,8 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
typedef UINT32 HWI_HANDLE_T; typedef UINT32 HWI_HANDLE_T;
typedef UINT16 HWI_PRIOR_T; typedef UINT16 HWI_PRIOR_T;
typedef UINT16 HWI_MODE_T; typedef UINT16 HWI_MODE_T;
typedef UINT32 HWI_ARG_T; typedef UINT32 HWI_ARG_T;
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1) #if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
@ -53,6 +51,7 @@ typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
#else #else
typedef VOID (*HWI_PROC_FUNC)(void); typedef VOID (*HWI_PROC_FUNC)(void);
#endif #endif
typedef struct tagIrqParam { typedef struct tagIrqParam {
int swIrq; /**< The interrupt number */ int swIrq; /**< The interrupt number */
VOID *pDevId; /**< The pointer to the device ID that launches the interrupt */ 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 (*disableIrq)(HWI_HANDLE_T hwiNum);
UINT32 (*setIrqPriority)(HWI_HANDLE_T hwiNum, UINT8 priority); UINT32 (*setIrqPriority)(HWI_HANDLE_T hwiNum, UINT8 priority);
UINT32 (*getCurIrqNum)(VOID); UINT32 (*getCurIrqNum)(VOID);
UINT32 (*createIrq)(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio);
} HwiControllerOps; } HwiControllerOps;
extern HwiControllerOps g_archHwiOps;
/* stack protector */ /* stack protector */
extern UINT32 __stack_chk_guard; extern UINT32 __stack_chk_guard;
extern VOID __stack_chk_fail(VOID); extern VOID __stack_chk_fail(VOID);
#if (LOSCFG_DEBUG_TOOLS == 1)
UINT32 ArchIsIntActive(VOID); extern UINT32 OsGetHwiFormCnt(UINT32 index);
#define OS_INT_ACTIVE (ArchIsIntActive()) extern CHAR *OsGetHwiFormName(UINT32 index);
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE)) extern BOOL OsHwiIsCreated(UINT32 index);
#define LOS_HwiCreate ArchHwiCreate #endif
#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
/** /**
* @ingroup los_interrupt * @ingroup los_interrupt
@ -162,70 +141,34 @@ UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam);
* <ul><li>los_interrupt.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None. * @see None.
*/ */
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio, HWI_MODE_T mode,
HWI_PRIOR_T hwiPrio, HWI_PROC_FUNC handler, HwiIrqParam *irqParam);
HWI_MODE_T mode, UINT32 ArchIsIntActive(VOID);
HWI_PROC_FUNC handler, UINT32 ArchIntLock(VOID);
HwiIrqParam *irqParam); UINT32 ArchIntUnLock(VOID);
VOID ArchIntRestore(UINT32 intSave);
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);
STATIC INLINE UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum) #define OS_INT_ACTIVE (ArchIsIntActive())
{ #define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
if (g_archHwiOps.triggerIrq == NULL) { #define LOS_IntLock ArchIntLock
return LOS_NOK; #define LOS_IntRestore ArchIntRestore
} #define LOS_IntUnLock ArchIntUnLock
return g_archHwiOps.triggerIrq(hwiNum); #define LOS_HwiDelete ArchHwiDelete
} #define LOS_HwiCreate ArchHwiCreate
#define LOS_HwiTrigger ArchIntTrigger
STATIC INLINE UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum) #define LOS_HwiEnable ArchIntEnable
{ #define LOS_HwiDisable ArchIntDisable
if (g_archHwiOps.enableIrq == NULL) { #define LOS_HwiClear ArchIntClear
return LOS_NOK; #define LOS_HwiSetPriority ArchIntSetPriority
} #define LOS_HwiCurIrqNum ArchIntCurIrqNum
return g_archHwiOps.enableIrq(hwiNum); #define LOS_HwiOpsGet ArchIntOpsGet
}
STATIC INLINE UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
{
if (g_archHwiOps.disableIrq == NULL) {
return LOS_NOK;
}
return g_archHwiOps.disableIrq(hwiNum);
}
STATIC INLINE UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
{
if (g_archHwiOps.clearIrq == NULL) {
return LOS_NOK;
}
return g_archHwiOps.clearIrq(hwiNum);
}
STATIC INLINE UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
{
if (g_archHwiOps.setIrqPriority == NULL) {
return LOS_NOK;
}
return g_archHwiOps.setIrqPriority(hwiNum, priority);
}
STATIC INLINE UINT32 ArchIntCurIrqNum(VOID)
{
if (g_archHwiOps.getCurIrqNum == NULL) {
return LOS_NOK;
}
return g_archHwiOps.getCurIrqNum();
}
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 #ifdef __cplusplus
#if __cplusplus #if __cplusplus

View File

@ -30,5 +30,8 @@
import("//kernel/liteos_m/liteos.gni") import("//kernel/liteos_m/liteos.gni")
module_group("risc-v") { module_group("risc-v") {
modules = [ "riscv32/gcc" ] modules = [
"common",
"riscv32/gcc",
]
} }

View File

@ -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 = [ "." ]
}

View File

@ -0,0 +1,103 @@
/*
* 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"
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
{
(VOID)arg;
PRINT_ERR("default handler\n");
while (1) {
}
}
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->triggerIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->triggerIrq(hwiNum);
}
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->enableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->enableIrq(hwiNum);
}
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->disableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->disableIrq(hwiNum);
}
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
{
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)
{
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();
}

View File

@ -0,0 +1,60 @@
/*
* 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_arch_context.h"
#include "los_error.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
extern VOID HalHwiDefaultHandler(VOID *arg);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_COMMON_INTERRUPT_H */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2020, 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.
* Copyright (c) 2021 Nuclei Limited. All rights reserved. * Copyright (c) 2021 Nuclei Limited. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
@ -29,14 +29,12 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef _LOS_HWI_H
#define _LOS_HWI_H
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_common_interrupt.h"
#include "nuclei_sdk_soc.h" #include "nuclei_sdk_soc.h"
#include "los_compiler.h"
#include "los_config.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -192,6 +190,16 @@ extern VOID HalHwiDefaultHandler(VOID);
*/ */
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b) #define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp); extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp);
extern VOID DisplayTaskInfo(VOID); extern VOID DisplayTaskInfo(VOID);
@ -202,4 +210,4 @@ extern VOID DisplayTaskInfo(VOID);
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* _LOS_HWI_H */ #endif /* _LOS_ARCH_INTERRUPT_H */

View File

@ -1,4 +1,5 @@
/* /*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021 Nuclei Limited. All rights reserved. * Copyright (c) 2021 Nuclei Limited. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
@ -37,8 +38,6 @@
#include "los_debug.h" #include "los_debug.h"
#include "nuclei_sdk_hal.h" #include "nuclei_sdk_hal.h"
UINT32 g_intCount = 0;
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
if (hwiNum >= OS_HWI_MAX_NUM) { if (hwiNum >= OS_HWI_MAX_NUM) {
@ -150,20 +149,6 @@ LITE_OS_SEC_TEXT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam
return LOS_OK; return LOS_OK;
} }
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("default handler\n");
while (1) {
}
}
/* **************************************************************************** /* ****************************************************************************
Function : HalDisplayTaskInfo Function : HalDisplayTaskInfo
Description : display the task list Description : display the task list
@ -215,13 +200,13 @@ __attribute__((always_inline)) inline VOID HalIntExit(VOID)
g_intCount -= 1; g_intCount -= 1;
} }
__attribute__((always_inline)) inline UINT32 ArchIsIntActive(VOID) STATIC HwiControllerOps g_archHwiOps = {
{
return (g_intCount > 0);
}
const HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority, .setIrqPriority = HwiSetPriority,
}; };
HwiControllerOps *ArchIntOpsGet(VOID)
{
return &g_archHwiOps;
}

View File

@ -31,11 +31,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_compiler.h" #include "los_common_interrupt.h"
#include "los_config.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#include "los_error.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -114,6 +110,12 @@ typedef struct {
*/ */
#define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT) #define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT)
/**
* @ingroup los_arch_interrupt
* Count of risc-v system interrupt vector.
*/
#define OS_SYS_VECTOR_CNT 0
/** /**
* Maximum number of supported hardware devices that generate hardware interrupts. * Maximum number of supported hardware devices that generate hardware interrupts.
* The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32. * The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32.
@ -146,9 +148,6 @@ extern VOID HalHwiInit(VOID);
extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum); extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum);
extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID); extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID);
extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum); extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum);
extern VOID HalHwiDefaultHandler(VOID *arg);
extern UINT32 g_intCount;
/** /**
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -273,6 +272,16 @@ extern UINT32 g_intCount;
*/ */
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b) #define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp); extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -40,7 +40,6 @@
#include "los_hook.h" #include "los_hook.h"
#include "riscv_hal.h" #include "riscv_hal.h"
LosExcInfo g_excInfo; LosExcInfo g_excInfo;
#define RISCV_EXC_TYPE_NUM 16 #define RISCV_EXC_TYPE_NUM 16
#define RISCV_EXC_LOAD_MISALIGNED 4 #define RISCV_EXC_LOAD_MISALIGNED 4
@ -64,7 +63,6 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
{ "Store/AMO page fault!" }, { "Store/AMO page fault!" },
}; };
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM]; LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM];
LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = { LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
{ .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler { .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler
@ -95,14 +93,6 @@ LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
{ .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved { .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved
}; };
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
{
(VOID)arg;
PRINT_ERR("default handler\n");
while (1) {
}
}
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID) LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{ {
UINT32 index; UINT32 index;
@ -144,12 +134,6 @@ LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *HalGetHwiForm(VOID)
return g_hwiForm; return g_hwiForm;
} }
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
/***************************************************************************** /*****************************************************************************
Function : ArchHwiCreate Function : ArchHwiCreate
Description : create hardware interrupt Description : create hardware interrupt
@ -348,3 +332,9 @@ SYSTEM_DEATH:
} }
} }
LITE_OS_SEC_BSS STATIC HwiControllerOps g_archHwiOps;
HwiControllerOps *ArchIntOpsGet(VOID)
{
return &g_archHwiOps;
}

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. # 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, # Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met: # are permitted provided that the following conditions are met:
@ -30,5 +30,8 @@
import("//kernel/liteos_m/liteos.gni") import("//kernel/liteos_m/liteos.gni")
module_group("xtensa") { module_group("xtensa") {
modules = [ "lx6/gcc" ] modules = [
"common",
"lx6/gcc",
]
} }

View File

@ -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 = [ "." ]
}

View File

@ -0,0 +1,271 @@
/*
* 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"
UINT32 g_intCount = 0;
/* *
* @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};
VOID *ArchGetHwiFrom(VOID)
{
return g_hwiForm;
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
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;
}
STATIC UINT32 HwiNumValid(UINT32 num)
{
return (num >= OS_SYS_VECTOR_CNT) && (num <= OS_VECTOR_CNT);
}
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
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 (!HwiNumValid(hwiNum)) {
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 (!HwiNumValid(hwiNum)) {
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 (!HwiNumValid(hwiNum)) {
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 ArchIntCurIrqNum(VOID)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
return hwiOps->getCurIrqNum();
}
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @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
/* ****************************************************************************
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
**************************************************************************** */
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
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(hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}

View File

@ -0,0 +1,102 @@
/*
* 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)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @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
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 */

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -67,14 +65,6 @@ typedef struct {
extern CHAR *VECTOR_START; extern CHAR *VECTOR_START;
#define INIT_VECTOR_START ((UINTPTR)&VECTOR_START) #define INIT_VECTOR_START ((UINTPTR)&VECTOR_START)
/* *
* @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 * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -91,22 +81,6 @@ extern CHAR *VECTOR_START;
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
/* *
* @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 * @ingroup los_arch_interrupt
* Count of Xtensa system interrupt vector. * Count of Xtensa system interrupt vector.
@ -199,22 +173,17 @@ extern UINT32 g_intCount;
*/ */
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) #define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Set interrupt vector table. * Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/ */
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg); #define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
VOID HalInterrupt(VOID); VOID HalInterrupt(VOID);
VOID HalHwiDefaultHandler(VOID);
VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type); VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
VOID HalHwiInit(VOID); VOID HalHwiInit(VOID);

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
@ -42,65 +41,6 @@
#include "los_membox.h" #include "los_membox.h"
#include "los_arch_regs.h" #include "los_arch_regs.h"
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_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
UINT32 HwiNumValid(UINT32 num)
{
return (num >= OS_SYS_VECTOR_CNT) && (num <= OS_VECTOR_CNT);
}
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* Lock all interrupt. * Lock all interrupt.
@ -154,37 +94,24 @@ STATIC INLINE UINT32 ArchIntLocked(VOID)
*/ */
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("wsr %0, intset; rsync" : : "a"(0x1U << hwiNum)); __asm__ __volatile__("wsr %0, intset; rsync" : : "a"(0x1U << hwiNum));
return LOS_OK; return LOS_OK;
} }
UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
UINT32 ier; UINT32 ier;
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory"); __asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier | ((UINT32)0x1U << hwiNum))); __asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier | ((UINT32)0x1U << hwiNum)));
return LOS_OK; return LOS_OK;
} }
UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
UINT32 ier; UINT32 ier;
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory"); __asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier & ~((UINT32)0x1U << hwiNum))); __asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier & ~((UINT32)0x1U << hwiNum)));
@ -216,53 +143,32 @@ STATIC UINT32 HwiNumGet(VOID)
* @ingroup los_hwi * @ingroup los_hwi
* Clear the interrupt * Clear the interrupt
*/ */
STATIC UINT32 HwiClear(HWI_HANDLE_T vector) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (!HwiNumValid(vector)) { __asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << hwiNum));
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << vector));
return LOS_OK; 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 = {
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.enableIrq = HwiUnmask, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
INLINE UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
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;
} }
/* **************************************************************************** /* ****************************************************************************
@ -308,88 +214,6 @@ VOID HalInterrupt(VOID)
HalIrqEndCheckNeedSched(); HalIrqEndCheckNeedSched();
} }
/* ****************************************************************************
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
**************************************************************************** */
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
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;
}
ExcInfo g_excInfo = {0}; ExcInfo g_excInfo = {0};
#if (LOSCFG_KERNEL_PRINTF != 0) #if (LOSCFG_KERNEL_PRINTF != 0)
@ -559,8 +383,9 @@ WEAK VOID __stack_chk_fail(VOID)
VOID HalHwiInit(VOID) VOID HalHwiInit(VOID)
{ {
EnableExceptionInterface(); EnableExceptionInterface();
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) { for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) {
g_hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler; hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler;
HwiMask(i); HwiMask(i);
} }
asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START)); asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START));

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -74,7 +74,7 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
__asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0)); __asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0));
__asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0)); __asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0));
HwiUnmask(tick->irqNum); LOS_HwiEnable(tick->irqNum);
return LOS_OK; return LOS_OK;
} }
@ -115,12 +115,12 @@ STATIC UINT64 SysTickCycleGet(UINT32 *period)
STATIC VOID SysTickLock(VOID) STATIC VOID SysTickLock(VOID)
{ {
HwiMask(OS_TICK_INT_NUM); LOS_HwiDisable(OS_TICK_INT_NUM);
} }
STATIC VOID SysTickUnlock(VOID) STATIC VOID SysTickUnlock(VOID)
{ {
HwiUnmask(OS_TICK_INT_NUM); LOS_HwiEnable(OS_TICK_INT_NUM);
} }
ArchTickTimer *ArchSysTickTimerGet(VOID) ArchTickTimer *ArchSysTickTimerGet(VOID)

View File

@ -27,9 +27,6 @@
"component": { "component": {
"name": "liteos_m", "name": "liteos_m",
"subsystem": "kernel", "subsystem": "kernel",
"syscap": [
"SystemCapability.Kernel.Liteos-M"
],
"features": [], "features": [],
"adapted_system_type": [ "adapted_system_type": [
"mini" "mini"
@ -43,7 +40,7 @@
"third_party": [ "third_party": [
"bounds_checking_function", "bounds_checking_function",
"cmsis", "cmsis",
"fatfs", "FatFs",
"littlefs", "littlefs",
"lwip", "lwip",
"musl" "musl"

View File

@ -616,11 +616,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1) #if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum) LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum)
{ {
if (g_irqCpupInitFlg == 0) { if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
return; return;
} }
UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
g_irqCpup[intNum].startTime = CpupTimeUsGet(); g_irqCpup[cpupIntNum].startTime = CpupTimeUsGet();
return; return;
} }
@ -629,33 +629,34 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
UINT64 cpuTime; UINT64 cpuTime;
UINT64 usedTime; UINT64 usedTime;
if (g_irqCpupInitFlg == 0) { if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
return; return;
} }
if (g_irqCpup[intNum].startTime == 0) { UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
if (g_irqCpup[cpupIntNum].startTime == 0) {
return; return;
} }
cpuTime = CpupTimeUsGet(); cpuTime = CpupTimeUsGet();
if (cpuTime < g_irqCpup[intNum].startTime) { if (cpuTime < g_irqCpup[cpupIntNum].startTime) {
cpuTime += OS_US_PER_TICK; cpuTime += OS_US_PER_TICK;
} }
g_irqCpup[intNum].cpupID = intNum; g_irqCpup[cpupIntNum].cpupID = intNum;
g_irqCpup[intNum].status = OS_CPUP_USED; g_irqCpup[cpupIntNum].status = OS_CPUP_USED;
usedTime = cpuTime - g_irqCpup[intNum].startTime; usedTime = cpuTime - g_irqCpup[cpupIntNum].startTime;
if (g_irqCpup[intNum].count <= 1000) { /* 1000, Take 1000 samples */ if (g_irqCpup[cpupIntNum].count <= 1000) { /* 1000, Take 1000 samples */
g_irqCpup[intNum].allTime += usedTime; g_irqCpup[cpupIntNum].allTime += usedTime;
g_irqCpup[intNum].count++; g_irqCpup[cpupIntNum].count++;
} else { } else {
g_irqCpup[intNum].allTime = 0; g_irqCpup[cpupIntNum].allTime = 0;
g_irqCpup[intNum].count = 0; g_irqCpup[cpupIntNum].count = 0;
} }
g_irqCpup[intNum].startTime = 0; g_irqCpup[cpupIntNum].startTime = 0;
if (usedTime > g_irqCpup[intNum].timeMax) { if (usedTime > g_irqCpup[cpupIntNum].timeMax) {
g_irqCpup[intNum].timeMax = usedTime; g_irqCpup[cpupIntNum].timeMax = usedTime;
} }
return; return;
} }

View File

@ -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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * 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++) { for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) { if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue; continue;
} }
@ -120,7 +120,7 @@ STATIC VOID HwiInfoDump(VOID)
PRINTK(" InterruptNo Count Name\n"); PRINTK(" InterruptNo Count Name\n");
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) { for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) { if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue; continue;
} }

View File

@ -31,11 +31,4 @@ config LMS_CHECK_STRICT
default n default n
depends on KERNEL_LMS depends on KERNEL_LMS
help help
Select y to enable byte-by-byte check in lms Select y to enable byte-by-byte check in Lms
config LMS_LIBC_FULL_CHECK
bool "Enable libc all function do lms check"
default n
depends on KERNEL_LMS
help
Select y to enable libc full check

View File

@ -162,7 +162,8 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
lmsPoolNode->shadowStart = (UINTPTR)poolAddr + realSize; lmsPoolNode->shadowStart = (UINTPTR)poolAddr + realSize;
lmsPoolNode->shadowSize = poolAddr + size - lmsPoolNode->shadowStart; lmsPoolNode->shadowSize = poolAddr + size - lmsPoolNode->shadowStart;
/* init shadow value */ /* init shadow value */
(VOID)memset_s((VOID *)lmsPoolNode->shadowStart, lmsPoolNode->shadowSize, LMS_SHADOW_AFTERFREE_U8, lmsPoolNode->shadowSize); (VOID)memset_s((VOID *)lmsPoolNode->shadowStart, lmsPoolNode->shadowSize, LMS_SHADOW_AFTERFREE_U8,
lmsPoolNode->shadowSize);
LOS_ListAdd(&g_lmsCheckPoolList, &(lmsPoolNode->node)); LOS_ListAdd(&g_lmsCheckPoolList, &(lmsPoolNode->node));

View File

@ -147,7 +147,6 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
realSleepTime = expireTime - currTime; realSleepTime = expireTime - currTime;
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock); sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq); sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
if (sleepCycle == 0) { if (sleepCycle == 0) {
pm->sysMode = LOS_SYS_NORMAL_SLEEP; pm->sysMode = LOS_SYS_NORMAL_SLEEP;
return FALSE; return FALSE;

View File

@ -24,18 +24,4 @@ config SHELL_STACK_SIZE
default 4096 default 4096
depends on SHELL depends on SHELL
config SHELL_LK
bool "Enable Shell lk"
default y
depends on DEBUG_VERSION && SHELL
help
Answer Y to enable LiteOS support shell lk.
config SHELL_DMESG
bool "Enable Shell dmesg"
default n
depends on DEBUG_VERSION && SHELL && SHELL_CMD_DEBUG
help
Answer Y to enable LiteOS support shell dmesg.
endmenu endmenu

View File

@ -72,7 +72,4 @@ config TRACE_CONTROL_VIA_SHELL
config TRACE_CONTROL_AGENT config TRACE_CONTROL_AGENT
bool "Via Trace Agent Task" bool "Via Trace Agent Task"
config TRACE_NO_CONTROL
bool "No Control"
endchoice endchoice

View File

@ -206,5 +206,6 @@ toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
toochain_config_command = toochain_config_command =
"$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin" "$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin"
toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'" toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
toochain_config_command +=
toochain_asm_command =
" && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'" " && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'"

View File

@ -149,4 +149,5 @@ toochain_config_objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
toochain_config_command = toochain_config_command =
"$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin" "$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin"
toochain_config_command += " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"
toochain_asm_command = " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"

View File

@ -39,6 +39,7 @@
#include "los_list.h" #include "los_list.h"
#include "los_config.h" #include "los_config.h"
#include "los_task.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -487,6 +488,50 @@ extern UINT32 LOS_QueueReadCopy(UINT32 queueID,
UINT32 *bufferSize, UINT32 *bufferSize,
UINT32 timeOut); UINT32 timeOut);
/**
* @ingroup los_queue
* @brief Read a queue in interrupt service routine.
*
* @par Description:
* This API is used to read data in a specified queue, and store the obtained data to the address specified
* by bufferAddr. The address and the size of the data to be read are defined by users.
* It is safe to use this API from within an interrupt service routine.
* @attention
* <ul>
* <li>The specific queue should be created firstly.</li>
* <li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is read
* first.</li>
* <li>This API read a queue in unblocking modes.</li>
* <li>bufferAddr stores the obtained data.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* </ul>
*
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
* @param bufferAddr [OUT] Starting address that stores the obtained data. The starting address must not be
* null.
* @param bufferSize [IN/OUT] Where to maintain the buffer expected-size before read, and the real-size after read.
*
* @retval #LOS_OK The queue is successfully read.
* @retval #LOS_ERRNO_QUEUE_INVALID The handle of the queue that is being read is invalid.
* @retval #LOS_ERRNO_QUEUE_READ_PTR_NULL The pointer passed in during queue reading is null.
* @retval #LOS_ERRNO_QUEUE_READSIZE_ISZERO The buffer size passed in during queue reading is 0.
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue to be read is not created.
* @retval #LOS_ERRNO_QUEUE_ISEMPTY No resource is in the queue that is being read when the time for
* waiting to processing the queue expires.
* @retval #LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL The buffer size passed in during queue reading is less than
* the queue size.
* @par Dependency:
* <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
* @see LOS_QueueWriteCopy | LOS_QueueCreate
*/
STATIC INLINE UINT32 LOS_QueueReadCopyIsr(UINT32 queueID,
VOID *bufferAddr,
UINT32 *bufferSize)
{
return LOS_QueueReadCopy(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
}
/** /**
* @ingroup los_queue * @ingroup los_queue
* @brief Write data into a queue. * @brief Write data into a queue.
@ -533,6 +578,47 @@ extern UINT32 LOS_QueueWriteCopy(UINT32 queueID,
UINT32 bufferSize, UINT32 bufferSize,
UINT32 timeOut); UINT32 timeOut);
/**
* @ingroup los_queue
* @brief Write data into a queue in interrupt service routine.
*
* @par Description:
* This API is used to write the data of the size specified by bufferSize and stored at the address specified by
* bufferAddr into a queue.It is safe to use this API from within an interrupt service routine.
* @attention
* <ul>
* <li>The specific queue should be created firstly.</li>
* <li>This API write data into a queue in unblocking modes.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The data to be written is of the size specified by bufferSize and is stored at the address specified by
* BufferAddr.</li>
* </ul>
*
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
* @param bufferAddr [IN] Starting address that stores the data to be written.The starting address must
* not be null.
* @param bufferSize [IN] Passed-in buffer size. The value range is [1,USHRT_MAX - sizeof(UINT32)].
*
* @retval #LOS_OK The data is successfully written into the queue.
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
* the queue size.
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
* @par Dependency:
* <ul><li>los_queue.h: the header file that contains the API declaration.</li></ul>
* @see LOS_QueueReadCopy | LOS_QueueCreate
*/
STATIC INLINE UINT32 LOS_QueueWriteCopyIsr(UINT32 queueID,
VOID *bufferAddr,
UINT32 bufferSize)
{
return LOS_QueueWriteCopy(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
}
/** /**
* @ingroup los_queue * @ingroup los_queue
* @brief Read a queue. * @brief Read a queue.
@ -582,6 +668,50 @@ extern UINT32 LOS_QueueRead(UINT32 queueID,
UINT32 bufferSize, UINT32 bufferSize,
UINT32 timeOut); UINT32 timeOut);
/**
* @ingroup los_queue
* @brief Read a queue in interrupt service routine.
*
* @par Description:
* This API is used to read the address of data in a specified queue, and store it to the address specified by
* bufferAddr.It is safe to use this API from within an interrupt service routine.
* @attention
* <ul>
* <li>The specific queue should be created firstly.</li>
* <li>Queue reading adopts the fist in first out (FIFO) mode. The data that is first stored in the queue is
* read first.</li>
* <li>This API read a queue in unblocking modes.</li>
* <li>bufferAddr stores the obtained data address.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The bufferSize is not really used in LOS_QueueRead, because the interface is only used to
* obtain the address of data.</li>
* <li>The buffer which the bufferAddr pointing to must be greater than or equal to 4 bytes.</li>
* </ul>
*
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
* @param bufferAddr [OUT] Starting address that stores the obtained data. The starting address must
* not be null.
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
*
* @retval #LOS_OK The queue is successfully read.
* @retval #LOS_ERRNO_QUEUE_INVALID The handle of the queue that is being read is invalid.
* @retval #LOS_ERRNO_QUEUE_READ_PTR_NULL The pointer passed in during queue reading is null.
* @retval #LOS_ERRNO_QUEUE_READSIZE_ISZERO The buffer size passed in during queue reading is 0.
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue to be read is not created.
* @retval #LOS_ERRNO_QUEUE_ISEMPTY No resource is in the queue that is being read when the time for
* waiting to processing the queue expires.
* @par Dependency:
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
* @see LOS_QueueWrite | LOS_QueueCreate
*/
STATIC INLINE UINT32 LOS_QueueReadIsr(UINT32 queueID,
VOID *bufferAddr,
UINT32 bufferSize)
{
return LOS_QueueRead(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
}
/** /**
* @ingroup los_queue * @ingroup los_queue
* @brief Write data into a queue. * @brief Write data into a queue.
@ -629,6 +759,49 @@ extern UINT32 LOS_QueueWrite(UINT32 queueID,
UINT32 bufferSize, UINT32 bufferSize,
UINT32 timeOut); UINT32 timeOut);
/**
* @ingroup los_queue
* @brief Write data into a queue in interrupt service routine.
*
* @par Description:
* This API is used to write the address of data specified by bufferAddr into a queue.
* It is safe to use this API from within an interrupt service routine.
* @attention
* <ul>
* <li>The specific queue should be created firstly.</li>
* <li>This API write data into a queue in unblocking modes.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
* BufferAddr is to be written.</li>
* <li>The bufferSize is not really used in LOS_QueueWriteIsr, because the interface is only used to write the address
* of data specified by bufferAddr into a queue.</li>
* </ul>
*
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
* @param bufferAddr [IN] Starting address that stores the data to be written. The starting address
* must not be null.
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
*
* @retval #LOS_OK The data is successfully written into the queue.
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
* the queue size.
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
* @par Dependency:
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
* @see LOS_QueueRead | LOS_QueueCreate
*/
STATIC INLINE UINT32 LOS_QueueWriteIsr(UINT32 queueID,
VOID *bufferAddr,
UINT32 bufferSize)
{
return LOS_QueueWrite(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
}
/** /**
* @ingroup los_queue * @ingroup los_queue
* @brief Write data into a queue header. * @brief Write data into a queue header.
@ -676,6 +849,48 @@ extern UINT32 LOS_QueueWriteHead(UINT32 queueID,
UINT32 bufferSize, UINT32 bufferSize,
UINT32 timeOut); UINT32 timeOut);
/**
* @ingroup los_queue
* @brief Write data into a queue header in interrupt service routine.
*
* @par Description:
* This API is used to write the data of the size specified by bufferSize and stored at the address specified by
* bufferAddr into a queue header.It is safe to use this API from within an interrupt service routine.
* @attention
* <ul>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>This API write data into a queue header in unblocking modes.</li>
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
* BufferAddr is to be written.</li>
* <li>LOS_QueueRead and LOS_QueueWriteHeadIsr are a set of interfaces, and the two groups of interfaces need to be used.
* <li>
* </ul>
*
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
* @param bufferAddr [OUT] Starting address that stores the data to be written. The starting address
* must not be null.
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
*
* @retval #LOS_OK The data is successfully written into the queue.
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
* the queue size.
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
* @par Dependency:
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
* @see LOS_QueueRead | LOS_QueueCreate
*/
STATIC INLINE UINT32 LOS_QueueWriteHeadIsr(UINT32 queueID,
VOID *bufferAddr,
UINT32 bufferSize)
{
return LOS_QueueWriteHead(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
}
/** /**
* @ingroup los_queue * @ingroup los_queue
* @brief Write data into a queue header. * @brief Write data into a queue header.
@ -723,6 +938,48 @@ extern UINT32 LOS_QueueWriteHeadCopy(UINT32 queueID,
UINT32 bufferSize, UINT32 bufferSize,
UINT32 timeOut); UINT32 timeOut);
/**
* @ingroup los_queue
* @brief Write data into a queue header in interrupt service routine.
*
* @par Description:
* This API is used to write the data of the size specified by bufferSize and stored at the address specified by
* bufferAddr into a queue header.It is safe to use this API from within an interrupt service routine.
* @attention
* <ul>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>This API write data into a queue header in unblocking modes.</li>
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
* BufferAddr is to be written.</li>
* <li>LOS_QueueReadCopy and LOS_QueueWriteHeadCopyIsr are a set of interfaces, and the two groups of interfaces need to be
* used.<li>
* </ul>
*
* @param queueID [IN] Queue ID created by LOS_QueueCreate. The value range is
* [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].
* @param bufferAddr [OUT] Starting address that stores the data to be written.
* The starting address must not be null.
* @param bufferSize [IN] Passed-in buffer size, which must not be 0. The value range is [1,0xffffffff].
*
* @retval #LOS_OK The data is successfully written into the queue.
* @retval #LOS_ERRNO_QUEUE_INVALID The queue handle passed in during queue writing is invalid.
* @retval #LOS_ERRNO_QUEUE_WRITE_PTR_NULL The pointer passed in during queue writing is null.
* @retval #LOS_ERRNO_QUEUE_WRITESIZE_ISZERO The buffer size passed in during queue writing is 0.
* @retval #LOS_ERRNO_QUEUE_NOT_CREATE The queue into which the data is written is not created.
* @retval #LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG The buffer size passed in during queue writing is bigger than
* the queue size.
* @retval #LOS_ERRNO_QUEUE_ISFULL No free node is available during queue writing.
* @par Dependency:
* <ul><li>los_queue.h: The header file that contains the API declaration.</li></ul>
* @see LOS_QueueWrite | LOS_QueueWriteHeadIsr
*/
STATIC INLINE UINT32 LOS_QueueWriteHeadCopyIsr(UINT32 queueID,
VOID *bufferAddr,
UINT32 bufferSize)
{
return LOS_QueueWriteHeadCopy(queueID, bufferAddr, bufferSize, LOS_NO_WAIT);
}
/** /**
* @ingroup los_queue * @ingroup los_queue
* @brief Delete a queue. * @brief Delete a queue.

View File

@ -37,7 +37,6 @@
#include "los_interrupt.h" #include "los_interrupt.h"
#include "los_membox.h" #include "los_membox.h"
#include "los_memory.h" #include "los_memory.h"
#include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
#include <stdint.h> #include <stdint.h>

View File

@ -48,7 +48,10 @@ kernel_module("test_init") {
"src/osTest.c", "src/osTest.c",
] ]
include_dirs = [ "unittest/posix/src" ] include_dirs = [
"unittest/posix/src",
"unittest/xts",
]
configs += [ ":include" ] configs += [ ":include" ]
} }
@ -69,6 +72,7 @@ group("testsuites") {
"sample/kernel/task:test_task", "sample/kernel/task:test_task",
"sample/posix:test_posix", "sample/posix:test_posix",
"unittest/posix:posix_test", "unittest/posix:posix_test",
"unittest/xts:xts_test",
] ]
if (defined(LOSCFG_DYNLINK)) { if (defined(LOSCFG_DYNLINK)) {
deps += [ "sample/kernel/dynlink:test_dynlink" ] deps += [ "sample/kernel/dynlink:test_dynlink" ]

View File

@ -96,6 +96,7 @@ extern "C" {
#define LOS_KERNEL_LMK_TEST 0 #define LOS_KERNEL_LMK_TEST 0
#define LOS_KERNEL_SIGNAL_TEST 0 #define LOS_KERNEL_SIGNAL_TEST 0
#define LOS_XTS_TEST 1
#define LOS_POSIX_TEST 1 #define LOS_POSIX_TEST 1
#define LOS_CMSIS_TEST 1 #define LOS_CMSIS_TEST 1
#define LOS_CMSIS2_CORE_TASK_TEST 0 #define LOS_CMSIS2_CORE_TASK_TEST 0

View File

@ -164,6 +164,22 @@ static_library("test_queue") {
"It_los_queue_head_040.c", "It_los_queue_head_040.c",
"It_los_queue_head_041.c", "It_los_queue_head_041.c",
"It_los_queue_head_042.c", "It_los_queue_head_042.c",
"It_los_queue_isr_001.c",
"It_los_queue_isr_002.c",
"It_los_queue_isr_003.c",
"It_los_queue_isr_004.c",
"It_los_queue_isr_005.c",
"It_los_queue_isr_006.c",
"It_los_queue_isr_007.c",
"It_los_queue_isr_008.c",
"It_los_queue_isr_009.c",
"It_los_queue_isr_010.c",
"It_los_queue_isr_011.c",
"It_los_queue_isr_012.c",
"It_los_queue_isr_013.c",
"It_los_queue_isr_014.c",
"It_los_queue_isr_015.c",
"It_los_queue_isr_016.c",
"It_los_queue_static_001.c", "It_los_queue_static_001.c",
"It_los_queue_static_002.c", "It_los_queue_static_002.c",
"It_los_queue_static_003.c", "It_los_queue_static_003.c",

View File

@ -151,7 +151,22 @@ VOID ItSuiteLosQueue(VOID)
ItLosQueueHead040(); ItLosQueueHead040();
ItLosQueueHead041(); ItLosQueueHead041();
ItLosQueueHead042(); ItLosQueueHead042();
ItLosQueueIsr001();
ItLosQueueIsr002();
ItLosQueueIsr003();
ItLosQueueIsr004();
ItLosQueueIsr005();
ItLosQueueIsr006();
ItLosQueueIsr007();
ItLosQueueIsr008();
ItLosQueueIsr009();
ItLosQueueIsr010();
ItLosQueueIsr011();
ItLosQueueIsr012();
ItLosQueueIsr013();
ItLosQueueIsr014();
ItLosQueueIsr015();
ItLosQueueIsr016();
#if (LOS_KERNEL_TEST_FULL == 1) #if (LOS_KERNEL_TEST_FULL == 1)
#if (LOS_KERNEL_HWI_TEST == 1) #if (LOS_KERNEL_HWI_TEST == 1)
ItLosQueue044(); ItLosQueue044();

View File

@ -183,7 +183,22 @@ extern VOID ItLosQueueHead039(VOID);
extern VOID ItLosQueueHead040(VOID); extern VOID ItLosQueueHead040(VOID);
extern VOID ItLosQueueHead041(VOID); extern VOID ItLosQueueHead041(VOID);
extern VOID ItLosQueueHead042(VOID); extern VOID ItLosQueueHead042(VOID);
extern VOID ItLosQueueIsr001(VOID);
extern VOID ItLosQueueIsr002(VOID);
extern VOID ItLosQueueIsr003(VOID);
extern VOID ItLosQueueIsr004(VOID);
extern VOID ItLosQueueIsr005(VOID);
extern VOID ItLosQueueIsr006(VOID);
extern VOID ItLosQueueIsr007(VOID);
extern VOID ItLosQueueIsr008(VOID);
extern VOID ItLosQueueIsr009(VOID);
extern VOID ItLosQueueIsr010(VOID);
extern VOID ItLosQueueIsr011(VOID);
extern VOID ItLosQueueIsr012(VOID);
extern VOID ItLosQueueIsr013(VOID);
extern VOID ItLosQueueIsr014(VOID);
extern VOID ItLosQueueIsr015(VOID);
extern VOID ItLosQueueIsr016(VOID);
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1) #if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
extern VOID ItLosQueueStatic001(VOID); extern VOID ItLosQueueStatic001(VOID);
extern VOID ItLosQueueStatic002(VOID); extern VOID ItLosQueueStatic002(VOID);

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr001(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr001", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_PARA_ISZERO, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_ERRNO_QUEUE_NOT_CREATE, ret);
return LOS_OK;
}
VOID ItLosQueueIsr002(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr002", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, 0);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 1);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, 1, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr003(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr003", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, 0);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, 4);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, 1, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr004(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr004", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr005(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr005", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
CHAR buff1[QUEUE_BASE_MSGSIZE] = "UniDSP";
static VOID HwiF01(VOID)
{
UINT32 ret;
ret = LOS_QueueWriteIsr(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
for (UINT8 index = 0; index < QUEUE_BASE_MSGSIZE - 1; index++) { // 7, QUEUE_BASE_MSGSIZE - 1
ICUNIT_GOTO_EQUAL(*((CHAR *)(intptr_t)buff2 + index), buff1[index],
*((CHAR *)(intptr_t)buff2 + index), EXIT);
}
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr006(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr006", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr((UINT32)-1, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_INVALID, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr007(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr007", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
ret = LOS_QueueWriteIsr(OS_ALL_IPC_QUEUE_LIMIT + 1, &buff1, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_ERRNO_QUEUE_INVALID, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR *buff2 = NULL;
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
TestHwiTrigger(HWI_NUM_TEST);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_ISEMPTY, ret, EXIT);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr008(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr008", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "It_los_queue.h"
static VOID HwiF01(VOID)
{
UINT32 ret;
CHAR *buff2 = NULL;
ret = LOS_QueueReadIsr(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE);
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
HWI_PRIOR_T hwiPrio = 3;
HWI_MODE_T mode = 0;
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
HwiIrqParam irqParam;
ret = LOS_QueueCreate("Q1", QUEUE_BASE_NUM, &g_testQueueID01, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)memset_s(&irqParam, sizeof(HwiIrqParam), 0, sizeof(HwiIrqParam));
irqParam.pDevId = 0;
ret = LOS_HwiCreate(HWI_NUM_TEST, hwiPrio, mode, (HWI_PROC_FUNC)HwiF01, &irqParam);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
TestHwiTrigger(HWI_NUM_TEST);
EXIT:
TestHwiDelete(HWI_NUM_TEST);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
}
VOID ItLosQueueIsr009(VOID)
{
TEST_ADD_CASE("ItLosQueueIsr009", Testcase, TEST_LOS, TEST_QUE, TEST_LEVEL1, TEST_FUNCTION);
}

Some files were not shown because too many files have changed in this diff Show More