Compare commits

...

57 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
openharmony_ci 16dae422eb
!1051 Fix : 修复gettimeofday对RTC钩子依赖的问题
Merge pull request !1051 from yinjiaming/fix
2023-06-06 00:59:38 +00:00
yinjiaming 96c16b0cbf fix: 修复gettimeofday接口获取时间方式依赖RTC钩子
gettimeofday 接口获取时间的方式依赖于RTC钩子,造成了精度的差异,
现去掉其依赖

BREAKING CHANGE:
修复gettimeofday接口获取时间方式依赖RTC钩子对外变更描述:
修改API:
int gettimeofday(struct timeval *tv, void *ptz);

Close #I6WV3V

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I87f46661a2b6edf9fd179e8c6e2cfe72da0c0c61
2023-05-29 17:27:55 +08:00
openharmony_ci 748e0a4447
!1036 fix: 修改一些拼写错误
Merge pull request !1036 from 程子丘/master
2023-05-24 04:03:47 +00:00
openharmony_ci a1989614f4
!1068 GN绝对路径修改
Merge pull request !1068 from zhushengle/GN
2023-05-23 12:33:40 +00:00
zhushengle 3241a67dc6 feat: GN绝对路径修改
Close #I77PSG
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I095e5d0aac99eda1a8c238701e560655477b04d2
2023-05-23 20:08:02 +08:00
openharmony_ci 14868aebdc
!1064 feat:内核time模块RTC与settimeofday接口逻辑修复
Merge pull request !1064 from zhangdengyu/RTC0515
2023-05-18 06:28:49 +00:00
zhangdengyu b4873b06e8 feat: 修复time中TIMEZONE优先使用RTC模块的问题
方案描述:
1、time中timezone全局变量修改为优先从RTC获取
2、settimeofday接口,linux和posix标准有差异,m核中对齐posix标准,具体如下:
int settimeofday(const struct timeval *tv, const struct timezone *tz)
2.1、linux中:
        tz参数已弃用,一般设置为NULL;
        tv参数,为NULL时返回0,不设置错误码,表示不修改当前时间;
2.2、posix中:
        tv或tz全部为NULL时,返回-1,设置错误码EFAULT;
        tv或tz有一个不为NULL时,不设置相应的参数,返回0;不设置错误码;
3、新增settimeofday接口设置timezone相关测试用例

BREAKING CHANGE:
修复time中TIMEZONE优先使用RTC模块的问题对外变更描述:
修改int settimeofday(const struct timeval *tv, const struct timezone *tz)接口
settimeofday接口对入参的判断逻辑修改:
1、tv或tz全部为NULL时,返回-1,设置错误码EFAULT;
2、tv或tz有一个不为NULL时,不设置相应的参数,返回0;不设置错误码;

Close: #I73G40

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: Id536fc27d8bf0697765ac1543776e8105e6f62f4
2023-05-18 11:50:38 +08:00
Cheng Ziqiu 8b11135135 fix: 修改注释中的一些拼写错误
Signed-off-by: Cheng Ziqiu <chengziqiu@hust.edu.cn>
Change-Id: Icc152031144f9756f4da018e24d338c0d28a8fa9
2023-03-15 22:01:50 +08:00
197 changed files with 17219 additions and 5755 deletions

View File

@ -44,6 +44,10 @@ if (defined(LOSCFG_COMPILER_ICCARM)) {
}
}
declare_args() {
liteos_build_asm = true
}
config("arch_config") {
cflags = arch_config_cflags
asmflags = arch_config_asmflags
@ -137,8 +141,8 @@ config("public") {
]
if (BOARD_SOC_FEATURE) {
configs += [ "//device/board/$device_company:public" ]
configs += [ "//device/soc/$LOSCFG_SOC_COMPANY:public" ]
configs += [ "$DEVICE_BOARD_DIR/$device_company:public" ]
configs += [ "$DEVICE_SOC_DIR/$LOSCFG_SOC_COMPANY:public" ]
} else {
if (HAVE_DEVICE_SDK) {
configs += [ "$device_path:public" ]
@ -158,8 +162,8 @@ group("modules") {
]
if (BOARD_SOC_FEATURE) {
deps += [ "//device/board/$device_company" ]
deps += [ "//device/soc/$LOSCFG_SOC_COMPANY" ]
deps += [ "$DEVICE_BOARD_DIR/$device_company" ]
deps += [ "$DEVICE_SOC_DIR/$LOSCFG_SOC_COMPANY" ]
} else {
if (HAVE_DEVICE_SDK) {
deps += [ device_path ]
@ -215,4 +219,7 @@ build_ext_component("build_kernel_image") {
exec_path = rebase_path(root_out_dir)
command = toochain_config_command
if (liteos_build_asm) {
command += toochain_asm_command
}
}

170
Kconfig
View File

@ -39,19 +39,9 @@ choice
config COMPILER_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
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
bool "ICCARM"
@ -96,15 +86,6 @@ config PLATFORM
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
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
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
@ -163,24 +144,9 @@ choice
help
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
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
@ -219,12 +185,6 @@ endchoice
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
######################### config options of kernel #####################
@ -343,21 +303,6 @@ config KERNEL_PM_IDLE
Configuration item for low power frame tailoring.
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
bool "Power Management Debug"
default n
@ -393,17 +338,6 @@ source "components/lms/Kconfig"
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 ##############
menu "Compat"
@ -436,43 +370,6 @@ endmenu
######################## config options of 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
bool "Enable Thumb"
@ -481,20 +378,6 @@ config THUMB
help
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
bool "Enable a Debug Version"
default y
@ -514,13 +397,6 @@ config DEBUG_KERNEL
It also means you want to get queue, mutex, semaphore, memory debug information.
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
bool "Enable Mutex Trace Debugging"
default n
@ -529,20 +405,6 @@ config MUTEX_CREATE_TRACE
help
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
bool "Enable Tftp"
default y
@ -557,18 +419,6 @@ config DEBUG_HOOK
help
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
bool "Enable shell cmd Debug"
default n
@ -581,13 +431,6 @@ config DEBUG_TOOLS
help
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
bool "Enable MEM Debug"
default n
@ -611,13 +454,6 @@ config MEM_WATERLINE
default n
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
bool "Enable show task mem used or not"
default n
@ -643,12 +479,6 @@ config SECURE_HEAP_SIZE
int "TrustZone Heap Size (bytes)"
default 2048
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
bool "Enable Security"
default n

View File

@ -23,6 +23,7 @@
<policylist>
<policy name="projectPolicy" desc="">
<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"/>
</policy>
@ -66,6 +67,9 @@
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<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="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"/-->

View File

@ -35,7 +35,7 @@ The directory structure is as follows. For more details, see [arch_spec.md](arch
│ ├── include # APIs exposed externally
│ ├── risc-v # Code of the 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
│ └── lx6 # Code of the lx6 xtensa architecture
├── components # Optional components

View File

@ -24,27 +24,6 @@ config ARCH_FPU_DISABLE
help
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
bool "Enable Unaligned Exception"
default y

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,19 +56,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt
* Count of arm9 system interrupt vector.
@ -174,19 +151,15 @@ extern UINT32 g_intCount;
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Set interrupt vector table.
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* *
* @ingroup los_arch_interrupt
@ -207,35 +180,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* the struct of register files
@ -325,7 +269,6 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_intCount;
extern ExcInfo g_excInfo;
#ifdef __cplusplus

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -42,7 +40,6 @@
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#include "los_reg.h"
#define OS_INT_IRQ_ENABLE (1U << 0)
#define OS_INT_FIQ_ENABLE (1U << 1)
@ -55,86 +52,8 @@
#define OS_ARM_INSTR_LEN 4
#define OS_THUMB_INSTR_LEN 2
UINT32 g_intCount = 0;
ExcInfo g_excInfo = {0};
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -153,10 +72,6 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (hwiNum));
return LOS_OK;
@ -164,48 +79,28 @@ STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) &= ~(1U << (hwiNum));
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
(VOID)hwiPrio;
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.getCurIrqNum = HwiNumGet,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -264,87 +159,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask(hwiNum);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiMask(hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#if (LOSCFG_KERNEL_PRINTF != 0)
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
@ -511,13 +325,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 reg;
UINT32 val;
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
for (val = OS_SYS_VECTOR_CNT; val < OS_VECTOR_CNT; val++) {
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
g_hwiForm[val].pfnHook = HalHwiDefaultHandler;
g_hwiForm[val].uwParam = 0;
hwiForm[val].pfnHook = HalHwiDefaultHandler;
hwiForm[val].uwParam = 0;
#else
g_hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[val] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
#endif
}
@ -560,4 +375,3 @@ UINT32 ArchIntUnLock(VOID)
: "memory");
return intSave;
}

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) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -42,14 +42,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,19 +58,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt
* Count of M-Core system interrupt vector.
@ -186,6 +165,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +301,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +320,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,17 +359,12 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
@ -423,14 +374,6 @@ extern VOID HalPendSV(VOID);
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +446,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -668,7 +610,6 @@ typedef struct TagExcInfo {
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -43,95 +41,6 @@
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
#ifdef __ICCARM__
#pragma location = ".data.vector"
#elif defined(__CC_ARM) || defined(__GNUC__)
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
LITE_OS_SEC_VEC
#endif
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -146,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -297,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiMask((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -610,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -621,23 +399,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -655,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
* Boot interrupt vector table.
*/
extern UINT32 g_intCount;
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,84 +42,6 @@
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
Function : HwiNumGet
@ -137,99 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiMask((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = 0; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
* Boot interrupt vector table.
*/
extern UINT32 g_intCount;
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,83 +42,6 @@
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
Function : HwiNumGet
@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = 0; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h>
#include "los_arch_interrupt.h"
#include "securec.h"
#include "los_context.h"
#include "los_debug.h"
#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,93 +42,6 @@
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINTPTR intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -622,23 +401,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h>
#include "los_arch_interrupt.h"
#include "securec.h"
#include "los_context.h"
#include "los_debug.h"
#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,93 +42,6 @@
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINTPTR intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -622,23 +401,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
* Boot interrupt vector table.
*/
extern UINT32 g_intCount;
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,12 +28,11 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -43,89 +42,6 @@
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -140,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -291,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiMask((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -614,6 +394,11 @@ WEAK VOID __stack_chk_fail(VOID)
__builtin_return_address(0));
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -625,23 +410,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -659,4 +445,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
* Boot interrupt vector table.
*/
extern UINT32 g_intCount;
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M4 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h>
#include "los_arch_interrupt.h"
#include "securec.h"
#include "los_context.h"
#include "los_debug.h"
#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,95 +42,6 @@
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
#ifdef __ICCARM__
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
#endif
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -147,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -299,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -612,6 +384,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -623,23 +400,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -657,4 +435,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
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,
* are permitted provided that the following conditions are met:
@ -31,9 +31,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -41,14 +39,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -65,18 +55,11 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
* AIRCR register priority group parameter .
*/
extern UINT32 g_intCount;
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
@ -90,12 +73,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@ -103,7 +80,7 @@ extern UINT32 g_intCount;
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M55 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -154,7 +131,7 @@ extern UINT32 g_intCount;
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
* The value range of the interrupt priority applicable for a Cortex-M55 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@ -179,6 +156,16 @@ extern UINT32 g_intCount;
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -305,20 +292,6 @@ extern UINT32 g_intCount;
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -338,25 +311,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -396,34 +350,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -496,7 +436,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -654,7 +593,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
* Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
*
*/
typedef struct TagExcInfo {
@ -677,10 +616,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

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,
* are permitted provided that the following conditions are met:
@ -27,12 +27,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -43,89 +41,6 @@
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
@ -141,99 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -292,97 +162,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiMask((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -609,6 +388,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -620,23 +404,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = 0; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -654,4 +439,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
* Boot interrupt vector table.
*/
extern UINT32 g_intCount;
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -644,7 +583,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc
* Exception information structure
*
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
* Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
*
*/
typedef struct TagExcInfo {
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,99 +28,20 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#include "los_hook.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
Function : HwiNumGet
@ -136,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -288,97 +163,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -612,23 +396,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = 0; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -646,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h>
#include "los_arch_interrupt.h"
#include "securec.h"
#include "los_context.h"
#include "los_debug.h"
#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,93 +42,6 @@
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -145,100 +56,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -299,97 +164,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINTPTR intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -611,6 +385,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -622,23 +401,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +431,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,13 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h>
#include "los_arch_interrupt.h"
#include "securec.h"
#include "los_context.h"
#include "los_debug.h"
#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,92 +41,7 @@
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
#define DEF_HANDLER_START_INDEX 2
/* ****************************************************************************
Function : HwiNumGet
@ -145,100 +57,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -299,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINTPTR intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -622,23 +397,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -651,4 +427,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,19 +56,6 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt
* Count of M-Core system interrupt vector.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M7 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -28,12 +28,10 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -43,84 +41,6 @@
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
@ -135,99 +55,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -286,97 +161,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -599,6 +383,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -610,23 +399,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -644,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

@ -84,7 +84,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
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) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -66,18 +56,17 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
* Boot interrupt vector table.
*/
extern UINT32 g_intCount;
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
@ -91,18 +80,6 @@ extern UINT32 g_intCount;
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
@ -110,7 +87,7 @@ extern UINT32 _BootVectors[];
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* The value range of the interrupt number applicable for a Cortex-M7 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -186,6 +163,16 @@ extern UINT32 _BootVectors[];
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 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.
@ -312,20 +299,6 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -345,25 +318,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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
* @brief: Reset the vector table.
@ -403,34 +357,20 @@ extern VOID Reset_Handler(VOID);
*/
extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
@ -503,7 +443,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
@ -667,10 +606,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -29,12 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include "securec.h"
#include <stdarg.h>
#include "los_arch_interrupt.h"
#include "securec.h"
#include "los_context.h"
#include "los_debug.h"
#include "los_arch_interrupt.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
@ -44,90 +42,8 @@
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
@ -143,100 +59,54 @@ STATIC UINT32 HwiNumGet(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -295,97 +165,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@ -608,6 +387,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
ArchSysExit();
}
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@ -619,23 +403,24 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
hwiForm[0] = 0; /* [0] Top of Stack */
hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
SCB->VTOR = (UINT32)(UINTPTR)hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
@ -649,4 +434,3 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}

View File

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

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -30,5 +30,8 @@
import("//kernel/liteos_m/liteos.gni")
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) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -42,14 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
@ -72,18 +62,6 @@ extern "C" {
*/
#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
* 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_USER_HWI_MIN 0
#define OS_USER_HWI_MAX (LOSCFG_PLATFORM_HWI_LIMIT - 1)
#define HWI_ALIGNSIZE 0x400
#define PSR_VEC_OFFSET 16U
#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)
/* *
* @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
* 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
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
@ -251,29 +230,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <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_WAKER_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_IPTR_SIZE 0x4
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
/**
* @ingroup los_exc
* the struct of register files

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
@ -53,20 +52,10 @@
#define MASK_32_BITS 0xFFFFFFFF
#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];
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 intSave;
@ -120,10 +109,6 @@ STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
intSave = LOS_IntLock();
VIC_REG->ISER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
VIC_REG->ISSR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
@ -136,14 +121,6 @@ STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
if (!HWI_PRI_VALID(priority)) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
VIC_REG->IPR[hwiNum / PRI_PER_REG] |= (((priority << PRI_OFF_IN_REG) << (hwiNum % PRI_PER_REG)) * PRI_OFF_PER_INT);
LOS_IntRestore(intSave);
@ -155,10 +132,6 @@ STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
intSave = LOS_IntLock();
VIC_REG->ICER[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
LOS_IntRestore(intSave);
@ -170,10 +143,6 @@ STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
UINT32 intSave;
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
intSave = LOS_IntLock();
VIC_REG->ISPR[hwiNum / OS_SYS_VECTOR_CNT] = (UINT32)(1UL << (hwiNum % OS_SYS_VECTOR_CNT));
LOS_IntRestore(intSave);
@ -183,69 +152,11 @@ STATIC UINT32 HwiPending(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));
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
Description : Get an interrupt number
@ -258,43 +169,26 @@ STATIC UINT32 HwiNumGet(VOID)
return (HalGetPsr() >> PSR_VEC_OFFSET) & MASK_8_BITS;
}
HwiControllerOps g_archHwiOps = {
.triggerIrq = HwiPending,
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
HwiSetPriority(hwiNum, (UINT8)hwiPrio);
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
inline UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%x\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -339,83 +233,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_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};
#if (LOSCFG_KERNEL_PRINTF != 0)
@ -602,16 +419,17 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
UINT32 i;
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
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++) {
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++) {
VIC_REG->IABR[i] = 0x0;
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) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -31,6 +31,7 @@
#ifndef _LOS_INTERRUPT_H
#define _LOS_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
@ -41,11 +42,8 @@ extern "C" {
#endif /* __cplusplus */
typedef UINT32 HWI_HANDLE_T;
typedef UINT16 HWI_PRIOR_T;
typedef UINT16 HWI_MODE_T;
typedef UINT32 HWI_ARG_T;
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
@ -53,6 +51,7 @@ typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
#else
typedef VOID (*HWI_PROC_FUNC)(void);
#endif
typedef struct tagIrqParam {
int swIrq; /**< The interrupt number */
VOID *pDevId; /**< The pointer to the device ID that launches the interrupt */
@ -66,37 +65,17 @@ typedef struct {
UINT32 (*disableIrq)(HWI_HANDLE_T hwiNum);
UINT32 (*setIrqPriority)(HWI_HANDLE_T hwiNum, UINT8 priority);
UINT32 (*getCurIrqNum)(VOID);
UINT32 (*createIrq)(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio);
} HwiControllerOps;
extern HwiControllerOps g_archHwiOps;
/* stack protector */
extern UINT32 __stack_chk_guard;
extern VOID __stack_chk_fail(VOID);
UINT32 ArchIsIntActive(VOID);
#define OS_INT_ACTIVE (ArchIsIntActive())
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
#define LOS_HwiCreate ArchHwiCreate
#define LOS_HwiDelete ArchHwiDelete
#define LOS_HwiTrigger ArchIntTrigger
#define LOS_HwiEnable ArchIntEnable
#define LOS_HwiDisable ArchIntDisable
#define LOS_HwiClear ArchIntClear
#define LOS_HwiSetPriority ArchIntSetPriority
#define LOS_HwiCurIrqNum ArchIntCurIrqNum
UINT32 ArchIntLock(VOID);
#define LOS_IntLock ArchIntLock
VOID ArchIntRestore(UINT32 intSave);
#define LOS_IntRestore ArchIntRestore
UINT32 ArchIntUnLock(VOID);
#define LOS_IntUnLock ArchIntUnLock
#define LOS_HwiOpsGet ArchIntOpsGet
#if (LOSCFG_DEBUG_TOOLS == 1)
extern UINT32 OsGetHwiFormCnt(UINT32 index);
extern CHAR *OsGetHwiFormName(UINT32 index);
extern BOOL OsHwiIsCreated(UINT32 index);
#endif
/**
* @ingroup los_interrupt
@ -162,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>
* @see None.
*/
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HwiIrqParam *irqParam);
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio, HWI_MODE_T mode,
HWI_PROC_FUNC handler, HwiIrqParam *irqParam);
UINT32 ArchIsIntActive(VOID);
UINT32 ArchIntLock(VOID);
UINT32 ArchIntUnLock(VOID);
VOID ArchIntRestore(UINT32 intSave);
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)
{
if (g_archHwiOps.triggerIrq == NULL) {
return LOS_NOK;
}
return g_archHwiOps.triggerIrq(hwiNum);
}
STATIC INLINE UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
{
if (g_archHwiOps.enableIrq == NULL) {
return LOS_NOK;
}
return g_archHwiOps.enableIrq(hwiNum);
}
STATIC INLINE UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
{
if (g_archHwiOps.disableIrq == NULL) {
return LOS_NOK;
}
return g_archHwiOps.disableIrq(hwiNum);
}
STATIC INLINE UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
{
if (g_archHwiOps.clearIrq == NULL) {
return LOS_NOK;
}
return g_archHwiOps.clearIrq(hwiNum);
}
STATIC INLINE UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
{
if (g_archHwiOps.setIrqPriority == NULL) {
return LOS_NOK;
}
return g_archHwiOps.setIrqPriority(hwiNum, priority);
}
STATIC INLINE 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
#define OS_INT_ACTIVE (ArchIsIntActive())
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
#define LOS_IntLock ArchIntLock
#define LOS_IntRestore ArchIntRestore
#define LOS_IntUnLock ArchIntUnLock
#define LOS_HwiDelete ArchHwiDelete
#define LOS_HwiCreate ArchHwiCreate
#define LOS_HwiTrigger ArchIntTrigger
#define LOS_HwiEnable ArchIntEnable
#define LOS_HwiDisable ArchIntDisable
#define LOS_HwiClear ArchIntClear
#define LOS_HwiSetPriority ArchIntSetPriority
#define LOS_HwiCurIrqNum ArchIntCurIrqNum
#define LOS_HwiOpsGet ArchIntOpsGet
#ifdef __cplusplus
#if __cplusplus

View File

@ -30,5 +30,8 @@
import("//kernel/liteos_m/liteos.gni")
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) 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.
*
* 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
* 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 "los_compiler.h"
#include "los_config.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#ifdef __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)
/* *
* @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 VOID DisplayTaskInfo(VOID);
@ -202,4 +210,4 @@ extern VOID DisplayTaskInfo(VOID);
#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.
*
* Redistribution and use in source and binary forms, with or without modification,
@ -37,8 +38,6 @@
#include "los_debug.h"
#include "nuclei_sdk_hal.h"
UINT32 g_intCount = 0;
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
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;
}
/* ****************************************************************************
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
Description : display the task list
@ -215,13 +200,13 @@ __attribute__((always_inline)) inline VOID HalIntExit(VOID)
g_intCount -= 1;
}
__attribute__((always_inline)) inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
const HwiControllerOps g_archHwiOps = {
STATIC HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
};
HwiControllerOps *ArchIntOpsGet(VOID)
{
return &g_archHwiOps;
}

View File

@ -31,11 +31,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_compiler.h"
#include "los_config.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#include "los_error.h"
#include "los_common_interrupt.h"
#ifdef __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)
/**
* @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.
* 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 HWI_HANDLE_FORM_S *HalGetHwiForm(VOID);
extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum);
extern VOID HalHwiDefaultHandler(VOID *arg);
extern UINT32 g_intCount;
/**
* @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)
/* *
* @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);
#ifdef __cplusplus

View File

@ -40,7 +40,6 @@
#include "los_hook.h"
#include "riscv_hal.h"
LosExcInfo g_excInfo;
#define RISCV_EXC_TYPE_NUM 16
#define RISCV_EXC_LOAD_MISALIGNED 4
@ -64,7 +63,6 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
{ "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_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
{ .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
};
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)
{
UINT32 index;
@ -144,12 +134,6 @@ LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *HalGetHwiForm(VOID)
return g_hwiForm;
}
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
/*****************************************************************************
Function : ArchHwiCreate
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) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -30,5 +30,8 @@
import("//kernel/liteos_m/liteos.gni")
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) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -32,9 +32,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_common_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
@ -67,14 +65,6 @@ typedef struct {
extern CHAR *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
* Highest priority of a hardware interrupt.
@ -91,22 +81,6 @@ extern CHAR *VECTOR_START;
#define OS_HWI_PRIO_LOWEST 7
#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
* 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)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @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);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
VOID HalInterrupt(VOID);
VOID HalHwiDefaultHandler(VOID);
VOID HalExcHandleEntry(UINTPTR faultAddr, EXC_CONTEXT_S *excBufAddr, UINT32 type);
VOID HalHwiInit(VOID);

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
@ -42,65 +41,6 @@
#include "los_membox.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
* Lock all interrupt.
@ -154,37 +94,24 @@ STATIC INLINE UINT32 ArchIntLocked(VOID)
*/
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));
return LOS_OK;
}
UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
UINT32 ier;
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier | ((UINT32)0x1U << hwiNum)));
return LOS_OK;
}
UINT32 HwiMask(HWI_HANDLE_T hwiNum)
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
UINT32 ier;
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier & ~((UINT32)0x1U << hwiNum)));
@ -216,53 +143,32 @@ STATIC UINT32 HwiNumGet(VOID)
* @ingroup los_hwi
* Clear the interrupt
*/
STATIC UINT32 HwiClear(HWI_HANDLE_T vector)
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(vector)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << vector));
__asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << hwiNum));
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
(VOID)hwiPrio;
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.triggerIrq = HwiPending,
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.getCurIrqNum = HwiNumGet,
.clearIrq = HwiClear,
.createIrq = HwiCreate,
};
INLINE UINT32 ArchIsIntActive(VOID)
HwiControllerOps *ArchIntOpsGet(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
return &g_archHwiOps;
}
/* ****************************************************************************
@ -308,88 +214,6 @@ VOID HalInterrupt(VOID)
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};
#if (LOSCFG_KERNEL_PRINTF != 0)
@ -559,8 +383,9 @@ WEAK VOID __stack_chk_fail(VOID)
VOID HalHwiInit(VOID)
{
EnableExceptionInterface();
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
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);
}
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) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -74,7 +74,7 @@ STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
__asm__ __volatile__("wsr %0, ccompare1; rsync" : : "a"(0));
__asm__ __volatile__("wsr %0, ccompare2; rsync" : : "a"(0));
HwiUnmask(tick->irqNum);
LOS_HwiEnable(tick->irqNum);
return LOS_OK;
}
@ -115,12 +115,12 @@ STATIC UINT64 SysTickCycleGet(UINT32 *period)
STATIC VOID SysTickLock(VOID)
{
HwiMask(OS_TICK_INT_NUM);
LOS_HwiDisable(OS_TICK_INT_NUM);
}
STATIC VOID SysTickUnlock(VOID)
{
HwiUnmask(OS_TICK_INT_NUM);
LOS_HwiEnable(OS_TICK_INT_NUM);
}
ArchTickTimer *ArchSysTickTimerGet(VOID)

View File

@ -27,9 +27,6 @@
"component": {
"name": "liteos_m",
"subsystem": "kernel",
"syscap": [
"SystemCapability.Kernel.Liteos-M"
],
"features": [],
"adapted_system_type": [
"mini"
@ -43,7 +40,7 @@
"third_party": [
"bounds_checking_function",
"cmsis",
"fatfs",
"FatFs",
"littlefs",
"lwip",
"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)
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum)
{
if (g_irqCpupInitFlg == 0) {
if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
return;
}
g_irqCpup[intNum].startTime = CpupTimeUsGet();
UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
g_irqCpup[cpupIntNum].startTime = CpupTimeUsGet();
return;
}
@ -629,33 +629,34 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
UINT64 cpuTime;
UINT64 usedTime;
if (g_irqCpupInitFlg == 0) {
if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
return;
}
if (g_irqCpup[intNum].startTime == 0) {
UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
if (g_irqCpup[cpupIntNum].startTime == 0) {
return;
}
cpuTime = CpupTimeUsGet();
if (cpuTime < g_irqCpup[intNum].startTime) {
if (cpuTime < g_irqCpup[cpupIntNum].startTime) {
cpuTime += OS_US_PER_TICK;
}
g_irqCpup[intNum].cpupID = intNum;
g_irqCpup[intNum].status = OS_CPUP_USED;
usedTime = cpuTime - g_irqCpup[intNum].startTime;
g_irqCpup[cpupIntNum].cpupID = intNum;
g_irqCpup[cpupIntNum].status = OS_CPUP_USED;
usedTime = cpuTime - g_irqCpup[cpupIntNum].startTime;
if (g_irqCpup[intNum].count <= 1000) { /* 1000, Take 1000 samples */
g_irqCpup[intNum].allTime += usedTime;
g_irqCpup[intNum].count++;
if (g_irqCpup[cpupIntNum].count <= 1000) { /* 1000, Take 1000 samples */
g_irqCpup[cpupIntNum].allTime += usedTime;
g_irqCpup[cpupIntNum].count++;
} else {
g_irqCpup[intNum].allTime = 0;
g_irqCpup[intNum].count = 0;
g_irqCpup[cpupIntNum].allTime = 0;
g_irqCpup[cpupIntNum].count = 0;
}
g_irqCpup[intNum].startTime = 0;
if (usedTime > g_irqCpup[intNum].timeMax) {
g_irqCpup[intNum].timeMax = usedTime;
g_irqCpup[cpupIntNum].startTime = 0;
if (usedTime > g_irqCpup[cpupIntNum].timeMax) {
g_irqCpup[cpupIntNum].timeMax = usedTime;
}
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,
* are permitted provided that the following conditions are met:
@ -63,7 +63,7 @@ STATIC VOID ShellCmdHwiInfoShow(OsIrqCpupCB *irqData, CPUP_INFO_S *hwiCpup1s,
}
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue;
}
@ -118,9 +118,9 @@ STATIC VOID HwiInfoDump(VOID)
{
INT32 i;
PRINTK(" InterruptNo Count Name\n");
PRINTK(" InterruptNo Count Name\n");
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue;
}
@ -128,8 +128,8 @@ STATIC VOID HwiInfoDump(VOID)
PRINTK(" %8d:%10d %-s\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i), OsGetHwiFormName(i));
} else {
PRINTK(" %8d:%10d\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i));
}
}
}
}
return;
}
#endif
@ -144,6 +144,6 @@ UINT32 OsShellCmdHwiDump(INT32 argc, const CHAR **argv)
}
HwiInfoDump();
return LOS_OK;
return LOS_OK;
}
#endif /* LOSCFG_STACK_DUMP == 1 */

View File

@ -59,7 +59,7 @@ extern "C" {
#else
#define MAX_SWITCH_INFO_SIZE (0)
#endif
#define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM)
#define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE \
+ MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE)

View File

@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/FatFs/FatFs.gni")
import("$THIRDPARTY_FATFS_DIR/FatFs.gni")
module_switch = defined(LOSCFG_FS_FAT)
module_name = get_path_info(rebase_path("."), "name")

View File

@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/littlefs/littlefs.gni")
import("$THIRDPARTY_LITTLEFS_DIR/littlefs.gni")
module_switch = defined(LOSCFG_FS_LITTLEFS)
module_name = get_path_info(rebase_path("."), "name")

View File

@ -78,7 +78,7 @@ struct File {
off_t fOffset;
INT32 fOwner;
struct MountPoint *fMp;
void *fData; /* file system opreations handle, fatfs FIL, etc. */
void *fData; /* file system operations handle, fatfs FIL, etc. */
const char *fullPath;
};

View File

@ -184,7 +184,7 @@ STATIC struct MountPoint *VfsMountPointInit(const char *source, const char *targ
return NULL;
}
/* Find fsMap coresponding to the fsType */
/* Find fsMap corresponding to the fsType */
mFs = VfsFsMapGet(fsType);
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
errno = ENODEV;

View File

@ -31,11 +31,4 @@ config LMS_CHECK_STRICT
default n
depends on KERNEL_LMS
help
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
Select y to enable byte-by-byte check in Lms

View File

@ -162,7 +162,8 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
lmsPoolNode->shadowStart = (UINTPTR)poolAddr + realSize;
lmsPoolNode->shadowSize = poolAddr + size - lmsPoolNode->shadowStart;
/* 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));

View File

@ -27,14 +27,14 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("$LITEOSTHIRDPARTY/lwip/lwip.gni")
import("$LITEOSTOPDIR/components/net/lwip-2.1/lwip_porting.gni")
import("$THIRDPARTY_LWIP_DIR/lwip.gni")
module_switch = defined(LOSCFG_NET_LWIP_SACK)
module_name = "lwip"
kernel_module(module_name) {
sources = LWIP_PORTING_FILES + LWIPNOAPPSFILES - [ "$LWIPDIR/api/sockets.c" ]
include_dirs = [ "//commonlibrary/utils_lite/include" ]
include_dirs = [ "$COMMONLIBRARY_UTILS_LITE_DIR/include" ]
}
config("public") {

View File

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

View File

@ -33,5 +33,5 @@ module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = []
deps = [ "//third_party/musl/porting/liteos_m/user" ]
deps = [ "$THIRDPARTY_MUSL_DIR/porting/liteos_m/user" ]
}

View File

@ -24,18 +24,4 @@ config SHELL_STACK_SIZE
default 4096
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

View File

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

View File

@ -206,5 +206,6 @@ toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
toochain_config_command =
"$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 +=
toochain_asm_command =
" && 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_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

@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/cmsis/cmsis.gni")
import("$THIRDPARTY_CMSIS_DIR/cmsis.gni")
module_switch = defined(LOSCFG_KAL_CMSIS)
module_name = get_path_info(rebase_path("."), "name")

View File

@ -27,14 +27,14 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/musl/porting/liteos_m_iccarm/kernel/iccarm.gni")
import("$THIRDPARTY_MUSL_DIR/porting/liteos_m_iccarm/kernel/iccarm.gni")
module_switch = defined(LOSCFG_LIBC_ICCARM)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
configs += [ "$LITEOSTOPDIR:warn_config" ]
deps = [ "//third_party/musl/porting/liteos_m_iccarm/kernel" ]
deps = [ "$THIRDPARTY_MUSL_DIR/porting/liteos_m_iccarm/kernel" ]
}
config("public") {

View File

@ -28,14 +28,14 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/musl/porting/liteos_m/kernel/musl.gni")
import("$THIRDPARTY_MUSL_DIR/porting/liteos_m/kernel/musl.gni")
module_switch = defined(LOSCFG_LIBC_MUSL)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
configs += [ "$LITEOSTOPDIR:warn_config" ]
deps = [ "//third_party/musl/porting/liteos_m/kernel" ]
deps = [ "$THIRDPARTY_MUSL_DIR/porting/liteos_m/kernel" ]
}
config("public") {

View File

@ -43,7 +43,7 @@ kernel_module(module_name) {
if (defined(LOSCFG_FS_VFS)) {
sources +=
[ "//third_party/musl/porting/liteos_m/kernel/src/misc/realpath.c" ]
[ "$THIRDPARTY_MUSL_DIR/porting/liteos_m/kernel/src/misc/realpath.c" ]
}
}

View File

@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
import("//third_party/bounds_checking_function/libsec_src.gni")
import("$THIRDPARTY_BOUNDS_CHECKING_FUNCTION_DIR/libsec_src.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {

View File

@ -613,11 +613,22 @@ struct tm *gmtime(const time_t *timer)
struct tm *localtime_r(const time_t *timep, struct tm *result)
{
INT32 ret;
if ((timep == NULL) || (result == NULL)) {
errno = EFAULT;
return NULL;
}
if (!ConvertSecs2Utc(*timep, -TIMEZONE, result)) {
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
ret = ConvertSecs2Utc(*timep, -tempTimezone, result);
} else {
ret = ConvertSecs2Utc(*timep, -TIMEZONE, result);
}
if (!ret) {
errno = EINVAL;
return NULL;
}
@ -660,7 +671,14 @@ static time_t ConvertUtc2Secs(struct tm *tm)
seconds += (tm->tm_mday - 1) * SECS_PER_DAY;
seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec;
seconds += TIMEZONE;
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
seconds += tempTimezone;
} else {
seconds += TIMEZONE;
}
return seconds;
}
@ -686,7 +704,14 @@ time_t mktime(struct tm *tmptr)
}
timeInSeconds = ConvertUtc2Secs(tmptr);
/* normalize tm_wday and tm_yday */
ConvertSecs2Utc(timeInSeconds, -TIMEZONE, tmptr);
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
ConvertSecs2Utc(timeInSeconds, -tempTimezone, tmptr);
} else {
ConvertSecs2Utc(timeInSeconds, -TIMEZONE, tmptr);
}
return timeInSeconds;
}
@ -695,20 +720,11 @@ int gettimeofday(struct timeval *tv, void *ptz)
struct timezone *tz = (struct timezone *)ptz;
if (tv != NULL) {
INT32 rtcRet;
UINT64 usec = 0;
UINT64 currentTime;
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
if (rtcRet != 0) {
currentTime = GetCurrentTime();
tv->tv_sec = currentTime / OS_SYS_MS_PER_SECOND;
tv->tv_usec = (currentTime % OS_SYS_MS_PER_SECOND) * OS_SYS_MS_PER_SECOND;
} else {
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
}
if ((g_rtcTimeFunc.RtcGetTimeHook != NULL) && (g_rtcTimeFunc.RtcGetTimeHook(&usec) == 0)) {
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
} else {
struct timespec ts;
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
@ -718,7 +734,7 @@ int gettimeofday(struct timeval *tv, void *ptz)
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
}
}
if (tz != NULL) {
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
INT32 tempTimezone = 0;
@ -740,12 +756,12 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
{
struct timespec ts;
if (tv == NULL) {
if ((tv == NULL) && (tz == NULL)) {
errno = EFAULT;
return -1;
}
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
if ((tv != NULL) && (tv->tv_usec >= OS_SYS_US_PER_SECOND)) {
errno = EINVAL;
return -1;
}
@ -764,18 +780,20 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
}
}
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
UINT64 usec;
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
if (-1 == g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec)) {
return -1;
}
} else {
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
if (-1 == clock_settime(CLOCK_REALTIME, &ts)) {
return -1;
if (tv != NULL) {
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
UINT64 usec;
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
if (g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec) < 0) {
return -1;
}
} else {
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
if (clock_settime(CLOCK_REALTIME, &ts) < 0) {
return -1;
}
}
}

View File

@ -39,6 +39,7 @@
#include "los_list.h"
#include "los_config.h"
#include "los_task.h"
#ifdef __cplusplus
#if __cplusplus
@ -487,6 +488,50 @@ extern UINT32 LOS_QueueReadCopy(UINT32 queueID,
UINT32 *bufferSize,
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
* @brief Write data into a queue.
@ -533,6 +578,47 @@ extern UINT32 LOS_QueueWriteCopy(UINT32 queueID,
UINT32 bufferSize,
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
* @brief Read a queue.
@ -582,6 +668,50 @@ extern UINT32 LOS_QueueRead(UINT32 queueID,
UINT32 bufferSize,
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
* @brief Write data into a queue.
@ -629,6 +759,49 @@ extern UINT32 LOS_QueueWrite(UINT32 queueID,
UINT32 bufferSize,
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
* @brief Write data into a queue header.
@ -676,6 +849,48 @@ extern UINT32 LOS_QueueWriteHead(UINT32 queueID,
UINT32 bufferSize,
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
* @brief Write data into a queue header.
@ -723,6 +938,48 @@ extern UINT32 LOS_QueueWriteHeadCopy(UINT32 queueID,
UINT32 bufferSize,
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
* @brief Delete a queue.

View File

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

View File

@ -51,8 +51,19 @@ exec_script("//build/lite/run_shell_cmd.py",
import("$root_out_dir/config.gni")
LITEOSTOPDIR = "//kernel/liteos_m"
LITEOSTHIRDPARTY = "//third_party"
HDFTOPDIR = "//drivers/hdf_core/adapter/khdf/liteos_m"
THIRDPARTY_BOUNDS_CHECKING_FUNCTION_DIR =
"//third_party/bounds_checking_function"
LITEOSTHIRDPARTY = "//third_party"
THIRDPARTY_FATFS_DIR = "//third_party/FatFs"
THIRDPARTY_MUSL_DIR = "//third_party/musl"
THIRDPARTY_LITTLEFS_DIR = "//third_party/littlefs"
THIRDPARTY_CMSIS_DIR = "//third_party/cmsis"
THIRDPARTY_LWIP_DIR = "//third_party/lwip"
DEVICE_BOARD_DIR = "//device/board"
DEVICE_SOC_DIR = "//device/soc"
COMMONLIBRARY_UTILS_LITE_DIR = "//commonlibrary/utils_lite"
TEST_XTS_TOOLS_DIR = "//test/xts/tools"
ARCH = ""
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
@ -163,8 +174,8 @@ set_defaults("kernel_module") {
"$LITEOSTOPDIR:los_config",
]
visibility = [
"$LITEOSTOPDIR:*",
":*",
"$LITEOSTOPDIR:*",
"..:*",
"../..:*",
]

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