Compare commits

..

264 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
openharmony_ci bad1880ccb
!1052 open时可能绕过fatfs 锁
Merge pull request !1052 from wangchen/0423_m
2023-05-15 12:49:09 +00:00
openharmony_ci f996b22137
!1062 部件化整改
Merge pull request !1062 from zhushengle/deps
2023-05-09 14:55:21 +00:00
zhushengle 02147f4613 feat: 部件化整改
Close #I71QQ2

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I247fdc1cbc7cb48c8ff1c1c3e4553ad4e6ef87a9
2023-05-09 21:43:12 +08:00
openharmony_ci da2429a003
!1040 Fix : 内核测试用例框架统一
Merge pull request !1040 from yinjiaming/test_framework
2023-05-09 03:09:42 +00:00
openharmony_ci 3b9e83c6b2
!1060 Fix : 部件化需求整改
Merge pull request !1060 from yinjiaming/bundle
2023-05-05 08:33:30 +00:00
yinjiaming b35d3d952b fix:部件需求整改
修复了脚本扫描出的bundle.json的问题,整改了
不符合规范的路径引用

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ic45ef8f2cc54c071e7104c7c1a6e31fc2ae395d2
2023-04-28 17:11:31 +08:00
openharmony_ci 74e20c6f83
!1058 去除无用头文件
Merge pull request !1058 from 乔克叔叔/master
2023-04-27 09:29:44 +00:00
liuwenxin 24a0b3ca70 fix:去除无用头文件
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-04-25 16:04:31 +08:00
wangchen 062235a60c fix: open时可能绕过fatfs 锁
方案描述:
1, malloc 之后 清空内存,避免使用上次的指针脏数据

fix I6XVKR
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-04-24 15:36:35 +08:00
openharmony_ci bcb4dea119
!1057 fix: 修复文档中的失效链接
Merge pull request !1057 from Hongjin Li/dev1
2023-04-24 02:21:52 +00:00
Hongjin Li 333045d11f fix: 修复文档死链
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2023-04-24 09:53:50 +08:00
openharmony_ci 04d5405d3f
!1056 修复文档中的时效链接
Merge pull request !1056 from Hongjin Li/dev1
2023-04-23 14:19:35 +00:00
Hongjin Li 7028f96f9c fix: 修改文档中的时效链接
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2023-04-23 19:00:29 +08:00
openharmony_ci f34362730a
!1055 修复CHANGELOG.md中的无效超链接
Merge pull request !1055 from wangchen/0424_new
2023-04-23 10:46:47 +00:00
wangchen bc1a352935 fix: 修复CHANGELOG.md中的无效超链接
方案描述:
1, 修改对应链接
fix #I6Y64T
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-04-23 18:34:09 +08:00
openharmony_ci 39391d12e4
!1053 fix: 修复CHANGELOG.md中的无效超链接
Merge pull request !1053 from Hongjin Li/changelog_fix
2023-04-23 10:03:31 +00:00
Hongjin Li 41b73359a4 fix: 修复CHANGELOG.md中的无效超链接
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2023-04-23 16:06:56 +08:00
openharmony_ci 6babf78a8d
!1048 kconfig增加shell StackSize大小的设置
Merge pull request !1048 from 乔克叔叔/cherry-pick-1681111046
2023-04-13 14:27:36 +00:00
openharmony_ci 18d07a809a
!1049 回退los_panic相关修改
Merge pull request !1049 from wangchen/0412_back
2023-04-12 09:15:15 +00:00
wangchen 6d2dbdf0e8 fix: 回退los_panic相关修改
方案描述:
1, 暂时回退https://gitee.com/openharmony/kernel_liteos_m/pulls/1035的修改
fix #I6V3U5
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-04-12 16:27:41 +08:00
nkj ee9d5daeca fixed 088f88c from https://gitee.com/wenxin-liu_admin/kernel_liteos_m/pulls/991
feat: kconfig增加shell StackSize大小的设置

BREAKING CHANGE:

kconfig增加shell StackSize大小的设置:

新增配置项

Close #I6KHRF
Signed-off-by: nkj <tkyl01@yeah.net>
Change-Id: I9d3a7e7933a01a0f1ad2199c82825cc471c623b0

Change-Id: I0d732e0270ae6dc354aec05f2a50f9439550accb
2023-04-10 16:32:23 +08:00
openharmony_ci 556c10121b
!1037 fix: 修复拼写错误
Merge pull request !1037 from Wang Jikai/master
2023-04-10 02:18:27 +00:00
yinjiaming 6c6fddb9a3 fix:统一M核unittest 和 sample所使用的测试框架
liteos_m 测试套中 unittest 和 sample 目录所使用的测试框架不同,
现将其统一,便于维护

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I4b690b621d754725c4d6a93772a043140de0bce1
2023-04-07 10:57:39 +08:00
openharmony_ci fe69c9dd65
!1043 Fix : pthread_cond_timedwait 函数等待的信号丢失问题
Merge pull request !1043 from yinjiaming/fix
2023-03-31 09:11:33 +00:00
yinjiaming 2374c01bb9 fix:pthread_cond_timedwait解锁后清理的问题
该函数解锁mutex 后先清理事件,导致等的事件丢失

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I36f8658b1b850734bc029b486fec103f6bd10588
2023-03-31 16:14:31 +08:00
openharmony_ci 66278102ca
!1035 使用vprintf来打印va_list类型
Merge pull request !1035 from 乔克叔叔/master
2023-03-22 02:40:55 +00:00
liuwenxin ecdd47f0c5 fix:使用vprintf来打印va_list类型
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-03-21 11:14:02 +08:00
openharmony_ci 7dbae99194
!1038 增加los错误码和posix错误码对接接口
Merge pull request !1038 from wangchen/0317_m
2023-03-17 13:02:35 +00:00
root 81784f1c6b fix: 增加los错误码和posix错误码对接接口
方案描述:
1, 增加一个内部接口, 用于los接口返回的错误码转换成posix错误码

BREAKING CHANGE:
无新增接口, 原有接口pthread_create错误时的错误码进行了区分

Close #I6NWNV
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-03-17 16:23:31 +08:00
am009 20693c9424 fix: 修复拼写错误
Signed-off-by: am009 <wangjikai@hust.edu.cn>
2023-03-15 22:10:45 +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
openharmony_ci 5fa299b4aa
!1026 修复task命令打印逻辑问题
Merge pull request !1026 from wangchen/0216_m
2023-03-14 07:54:35 +00:00
root b02c64dc42 fix: posix用例存在mutex资源泄露
方案描述:
1, 对posix中使用锁之后,增加对锁的释放
2, 修改锁后进入shell, 发现task打印线程信息有异常, 又修复了打印相关的逻辑
fix #I64Y7G
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-03-13 21:53:57 +08:00
openharmony_ci c5a39437f7
!1007 fix: risc-v架构编译告警修复
Merge pull request !1007 from zhushengle/codex
2023-03-08 06:02:16 +00:00
zhushengle f211029b12 fix: 修复编译告警
Close #I69TZD

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I5f837b7980b478a02524f8ba056916ca038c544c
2023-03-07 21:37:07 +08:00
openharmony_ci 36d55955ef
!1031 newlib error处理
Merge pull request !1031 from 乔克叔叔/master
2023-03-01 08:13:50 +00:00
openharmony_ci 12f6c5d628
!1032 Fix : 配置LOSCFG_BASE_IPC_QUEUE_STATIC后编译错误
Merge pull request !1032 from yinjiaming/fix-1
2023-03-01 08:09:53 +00:00
openharmony_ci 17309e232a
!1029 Fix : 打开 LWIP_IPV6 时会有编译错误
Merge pull request !1029 from yinjiaming/fix
2023-03-01 08:09:16 +00:00
liuwenxin af1afcec6a fix:newlib error解决
close:#I6HL01

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-03-01 11:52:34 +08:00
yinjiaming 9cef4da850 fix:配置LOSCFG_BASE_IPC_QUEUE_STATIC后编译错误
在target_config.h中配置了LOSCFG_BASE_IPC_QUEUE_STATIC之后编译内核测试套报错
现修复

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Idf99137f822d5040bdb19e489e0a9234f19e93be
2023-02-27 15:12:13 +08:00
yinjiaming d058b640e2 fix:打开LWIP_IPV6时有编译错误
更改了出错的参与算数运算的指针的数据类型

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I6891797cd1afa801faeecf1bfb891f0ac7db7f68
2023-02-27 11:53:54 +08:00
openharmony_ci 4431b587f8
!1027 Panic支持ExcHook
Merge pull request !1027 from zhangdengyu/supportPanicHook
2023-02-22 06:18:48 +00:00
zhangdengyu 809db71acc feat:Panic支持ExcHook
方案描述:
1、在EXC_TYPE枚举中添加EXC_PANIC成员用于Panic支持ExcHook
2、在LOS_Panic接口执行异常处理钩子函数

BREAKING CHANGE:
无

Close: #I6GR6G

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I99d293622ff6ddbc49348c692512e5b7780460e6
2023-02-21 21:55:01 +08:00
openharmony_ci b1a7711e15
!1025 Werror开启产生的告警
Merge pull request !1025 from 乔克叔叔/werrror
2023-02-21 06:58:16 +00:00
liuwenxin 3e83ce79c2 fix:告警清理包含三方库屏蔽
【修改说明】此次开启Werror,解决告警产生的报错,以及屏蔽三方库告警

 close #I6ELI9
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-02-21 10:35:56 +08:00
openharmony_ci 2cadd65301
!1023 fix: pthread_create时序调整
Merge pull request !1023 from Zhaotianyu/20230210pthread_create
2023-02-10 10:31:43 +00:00
arvinzzz f038492dbc fix: pthread_create内部逻辑时序调整
在线程创建成功后,pthread_create内部先将函数返回值设置好,再进行TaskResume就绪调度状态

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I795c115da612123b67f34cdc57e85eac955bbc08
2023-02-10 17:42:17 +08:00
openharmony_ci e74deedba3
!1005 Werror开启告警清理
Merge pull request !1005 from 乔克叔叔/second
2023-02-07 03:08:26 +00:00
openharmony_ci 24f52e0259
!987 LMS特性安全合规整改
Merge pull request !987 from JerryH/lms
2023-02-02 01:42:12 +00:00
huangjieliang d4df4d1e54 feat:LMS模块及堆内存模块非安全函数安全合规整改
Close #I68LEO

Signed-off-by: huangjieliang <huangjieliang@huawei.com>
Change-Id: I38b859dcd1856f27d4577f5311c920d2d8b96385
2023-02-01 16:49:44 +08:00
openharmony_ci 2d1e7e8c29
!1012 Fix : 内核告警清理
Merge pull request !1012 from yinjiaming/warning
2023-02-01 06:33:49 +00:00
liuwenxin a96f535cd3 fix:Werror开启告警清理
清理Werror开启产生的告警

close:#I68YDW

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-01-30 10:10:07 +08:00
openharmony_ci 1669455ba9
!972 feat:新增文件系统测试用例
Merge pull request !972 from zhangdengyu/addFsTestCase
2023-01-29 08:54:33 +00:00
zhangdengyu b637b1d979 test:添加文件系统测试用例
方案描述:
1、对单个接口进行规格测试。
2、对多个接口组合测试模拟上层业务场景。
3、对各接口进行压力测试确保稳定性。

Close: #I62K4B

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I6c45631094884e0300faa994082d16dda6dd3f1d
2023-01-29 16:22:07 +08:00
openharmony_ci c6d021bede
!1016 refactor: 不同C库malloc归一
Merge pull request !1016 from Zhaotianyu/20230117libc_malloc
2023-01-18 09:56:58 +00:00
arvinzzz d7f3aef326 refactor: 不同C库的malloc适配归一
1. 不同C库的malloc实现归一化,由原先//kal/libc/musl、//kal/libc/newlib、
   //../../third_party/musl/porting/liteos_m_iccarm/kernel 各自实现,
   统一至//kal/posix/src/malloc.c实现,并实现对三种C库的兼容

2. Kconfig归一化的配套调整,删除Top->"Compat"->"Choose libc implementation"下
   malloc API的开关控制,统一归入"Top"->"Compat"->"Enable POSIX API"下
   "Enable POSIX MALLOC API"进行能力开关控制

BREAKING CHANGE:
Kconfig变更:
删除:
LOSCFG_LIBC_ICCARM_MALLOC
LOSCFG_LIBC_NEWLIB_MALLOC
新增:
LOSCFG_POSIX_MALLOC_API

close: I6AGOW

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I584e337cdb36184cf40c36c4f7c73ab780c31a42
2023-01-18 11:22:01 +08:00
yinjiaming db32ad90bf Fix:内核告警清理
清除内核代码中的敏感词

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I734525c036fcfe481d0781d459bc273ef8224791
2023-01-16 16:17:09 +08:00
openharmony_ci 59fbe91d8b
!1009 Fix : OsLs 内存泄漏问题
Merge pull request !1009 from yinjiaming/fix
2023-01-13 08:54:49 +00:00
openharmony_ci c7088f4d0f
!1010 告警清理
Merge pull request !1010 from 乔克叔叔/release
2023-01-13 05:42:29 +00:00
liuwenxin 705bfbdc76 fix:release告警清理
release分支告警清理

close:#I6AD15

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-01-13 11:34:52 +08:00
yinjiaming 9a4e9677bd fix:修复OsLs函数内存泄漏问题
当d = NULL时,path没有释放,现释放path所指向的内存

close #I6A07U

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Iee9fd8d2171c6fdcf353a48e7af385bbd1660520
2023-01-12 15:30:19 +08:00
openharmony_ci 6134d4bd22
!989 修复-Werror编译选项产生的告警
Merge pull request !989 from 乔克叔叔/lwx
2023-01-11 07:55:48 +00:00
openharmony_ci c119b7e9e2
!1006 Fix : statfs函数内部判断错误
Merge pull request !1006 from yinjiaming/fix
2023-01-11 07:37:51 +00:00
openharmony_ci dbf0498bab
!1008 fix: 非gcc形态下FUNC_ALIAS编译错误
Merge pull request !1008 from Zhaotianyu/20230111symbol_fix
2023-01-11 06:49:43 +00:00
arvinzzz 68b142cf78 fix: 修复非gcc形态FUNC_ALIAS编译错误
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I7f199366d8173d9fc504f89b26329ea5f7d1eb9e
2023-01-11 10:45:18 +08:00
openharmony_ci 22b7eb87ca
!998 fix: 不同C库下gettimeofday特性规格统一
Merge pull request !998 from Zhaotianyu/20230107gettimeofday
2023-01-11 00:46:21 +00:00
arvinzzz ed50f7e373 fix: 不同libc下gettimeofday特性规格统一
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Iaaf1fed24101f43c636737294dbe870d2f467b0a
2023-01-10 20:36:34 +08:00
yinjiaming 2f2a0b7a75 fix:修复statfs函数内部判断错误
修复函数调用的是statfs却用stat!=NULL来判断,当文件系统是little_fs时导致死机的问题。

close #I69BXB

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib9784c017f4260433c3f12e352470108ea83ec19
2023-01-10 15:49:01 +08:00
openharmony_ci 1ae62ebf2e
!1000 fix:mutex trace中ArchLRGet等接口改变实现方式
Merge pull request !1000 from zhangdengyu/mutexTraceFix
2023-01-10 06:44:48 +00:00
zhangdengyu 25278a02eb fix:mutex trace中ArchLRGet接口改变实现方式
方案描述:
将ArchLRGet接口的实现方式由内联函数修改为宏,
防止产品添加--no_inline等编译选项导致函数无法在调用点展开,
造成由于函数调用过程中函数栈帧的变化带来的LR寄存器中存储的值的变化。

Close #I69D9N

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: If417bc2ec9febf064c63da198faf4ac000d70c52
2023-01-10 14:28:15 +08:00
liuwenxin 52bc16c3db fix:修复-Werror编译选项产生的告警
清理框架定义未使用告警,宏重定义,以及变量定义未使用等告警。

Close #I68RLA

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-01-10 10:26:22 +08:00
openharmony_ci 733b6e6c6c
!988 fix: mktime测试用例不依赖固定时区
Merge pull request !988 from Zhaotianyu/20230104fix_mktime_test
2023-01-04 09:36:32 +00:00
arvinzzz 6562536db7 fix: mktime testcase
Eliminate the effects of different time zones

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I22f0dc7057df642e255bec9a8b663c2b544b107e
2023-01-04 16:39:01 +08:00
openharmony_ci ddf3dc8237
!985 fix: mktime测试用例配套修改
Merge pull request !985 from Zhaotianyu/20230103fix_mktime_test
2023-01-03 07:45:12 +00:00
arvinzzz 399e7647bb fix: mktime testcase
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I50e0252aa8611e9a269b836c552bfdf33ade8f44
2023-01-03 11:27:26 +08:00
openharmony_ci f7af2cdf9b
!983 修复codecheck告警
Merge pull request !983 from 夏不白/codecheck
2022-12-30 06:19:55 +00:00
xiacong 07091c5a75 fix:修复codecheck告警
1、修复空格、空行使用错误告警;
2、将超过10行的inline函数去除内联符号

fix #I685E3

Signed-off-by: xiacong <xiacong4@huawei.com>
2022-12-30 12:11:01 +08:00
openharmony_ci 6633aabf89
!979 fix: mktime获取的时间缺少时区信息
Merge pull request !979 from Zhaotianyu/20221228mktime_fix
2022-12-29 10:21:38 +00:00
arvinzzz 2a4282f912 fix: The tm struct obtained by mktime lacks timezone information
BREAKING CHANGE:
The tm struct obtained by mktime lacks timezone information
变更API:
time_t mktime(struct tm *tmptr)
原先mktime从入参中获取时区信息进行计算,变更后tm结构体和返回值time_t的计算使用系统g_timezone时区环境变量。

Close I67UIA

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I766cffbff3c1a25bb33cbd245225ee117909af3a
2022-12-29 16:26:08 +08:00
openharmony_ci 685688b21c
!977 Fixed compilation problems with niobe407 and neptune100
Merge pull request !977 from 张亚雷/master
2022-12-27 07:21:39 +00:00
mrzhang 67ee38e1e3 fix: Fixed compilation problems with niobe407 and neptune100
Signed-off-by: mrzhang <zhangyalei8@h-partners.com>
2022-12-26 18:25:44 -08:00
openharmony_ci 6cd48f6f90
!965 VfsMpFind接口优化
Merge pull request !965 from Far/vfsmpfind
2022-12-24 03:12:29 +00:00
Far 662aefb700 fix: VfsMpFind optimize
1. provide VfsMpFind which doesn't support mounting recursively;
2. provide a macro to set whether supporting recursive-mount or not.
3. adding path length checking

BREAKING CHANGE:
new config option:
LOSCFG_FS_SUPPORT_MOUNT_TARGET_RECURSIVE

fix #I65XE6
Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I7ae371f0e6fff46db0e2368f905aa22bac864b79
2022-12-24 10:44:11 +08:00
openharmony_ci 83fc93cc84
!974 fix: misc_config中defines未初始化导致编译失败
Merge pull request !974 from Zhaotianyu/20221222misc_config
2022-12-22 07:44:57 +00:00
arvinzzz b817c490ba fix: 修复misc_config中defines未初始化的错误
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I4eecfc1af2b0cdc39922a8ce299eb8ab6b7c6e8c
2022-12-22 11:28:31 +08:00
openharmony_ci 705e4c323a
!973 【重新提交】修复文件系统中不合理的锁操作
Merge pull request !973 from Far/master
2022-12-22 03:10:43 +00:00
Far b7f906ef8a fix: 修复文件系统不合理的锁操作
1. 移除了fatfs和littlefs中冗余的加锁操作。
2. 增加了配置选项FS_LOCK_TIMEOUT(宏LOSCFG_FS_LOCK_TIMEOUT),提供配置
   文件系统获取锁超时能力。
3. 新增对外接口LOS_FsLock()和LOS_FsUnlock()接口,提供HAL层与文件系统的
   互斥操作。

BREAKING CHANGE:
修复文件系统不合理的锁操作
新增API:
los_fs.h:
int LOS_FsLock(void)
int LOS_FsUnlock(void)
新增配置项:
LOSCFG_FS_LOCK_TIMEOUT(menuconfig FS_LOCK_TIMEOUT)

fix #I66S2J

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I2ae9b6b5e2c788b2f4a00d9678a0240d00c335eb
2022-12-22 10:41:31 +08:00
openharmony_ci f9c59d361f
!971 回退 'Pull Request !938 : 修复文件系统不合理的锁操作'
Merge pull request !971 from openharmony_ci/revert-merge-938-master
2022-12-19 09:34:33 +00:00
openharmony_ci fa142daffb
回退 'Pull Request !938 : 修复文件系统不合理的锁操作' 2022-12-19 08:57:11 +00:00
openharmony_ci 4bd0e73512
!969 open接口内存泄漏修复
Merge pull request !969 from wangchen/1217_m
2022-12-17 08:47:28 +00:00
wangchen 0a03a4d875 fix: open接口内存泄漏修复
方案描述:
1, 修改路径正确时打开失败可能的异常

fix #I66KGT
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-12-17 08:16:12 +00:00
openharmony_ci 2a70466456
!963 修复文件系统close中的不合理操作
Merge pull request !963 from Far/NFILE
2022-12-16 03:12:42 +00:00
openharmony_ci b30349d8ed
!938 修复文件系统不合理的锁操作
Merge pull request !938 from Far/master
2022-12-16 03:03:54 +00:00
Far 59ecf4cae8 fix: 修复close接口中无法正常关闭文件的问题
1. close未考虑保留描述符0、1和2,导致fd合法性判断出现错误,这会导致
上限附近的fd不能被正常的关闭
2. 释放file结构体时未在锁的保护中进行,可能存在问题

fix #I65U8S

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Iaa03a70e18fcb352ca3b99232f50b43d8b13ecf0
2022-12-16 10:53:03 +08:00
Far 9038b6522e fix: 修复文件系统不合理的锁操作
1. 移除了fatfs和littlefs中冗余的加锁操作。
2. 增加了配置选项FS_LOCK_TIMEOUT(宏LOSCFG_FS_LOCK_TIMEOUT),提供文件
   系统锁超时判定能力。
3. 新增对外接口LOS_FsLock()和LOS_FsUnlock()接口,提供HAL层与文件系统的
   互斥操作。

BREAKING CHANGE:
修复文件系统不合理的锁操作
新增API:
int LOS_FsLock(void)
int LOS_FsUnlock(void)
新增配置项:
LOSCFG_FS_LOCK_TIMEOUT(menuconfig FS_LOCK_TIMEOUT)

fix #I6355A

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Ia980abfac0ee761088313496c7e3c3e9568450b3
2022-12-16 10:42:03 +08:00
openharmony_ci abb83fd23b
!962 refactor: vfs优化
Merge pull request !962 from Zhaotianyu/20221210vfs_opt
2022-12-16 02:03:04 +00:00
arvinzzz 98da8bbdfb refactor: vfs opt
1. vfs重构优化,统一fs模块的对外接口,减少不必要的冗余调用,由fs组件直接提供posix对外接口
  2. vfs与libc关系整理
  3. fs接口实现规范化

BREAKING CHANGE:
删除API:
int LOS_Open(const char *path, int flags, ...);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
ssize_t LOS_Write(int fd, const void *buff, size_t bytes);
off_t LOS_Lseek(int fd, off_t off, int whence);
int LOS_Stat(const char *path, struct stat *stat);
int LOS_Statfs(const char *path, struct statfs *buf);
int LOS_Unlink(const char *path);
int LOS_Rename(const char *oldpath, const char *newpath);
int LOS_Fsync(int fd);
DIR *LOS_Opendir(const char *path);
struct dirent *LOS_Readdir(DIR *dir);
int LOS_Closedir(DIR *dir);
int LOS_Mkdir(const char *path, mode_t mode);
int LOS_Rmdir(const char *path);
int LOS_Lstat(const char *path, struct stat *buffer);
int LOS_Fstat(int fd, struct stat *buf);
int LOS_Fcntl(int fd, int cmd, ...);
int LOS_Ioctl(int fd, int req, ...);
ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off);
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off);
int LOS_Isatty(int fd);
int LOS_Access(const char *path, int amode);
int LOS_Ftruncate(int fd, off_t length);
int LOS_FsUmount(const char *target);
int LOS_FsUmount2(const char *target, int flag);
int LOS_FsMount(const char *source, const char *target,
                const char *fsType, unsigned long mountflags,
                const void *data);
int OsFcntl(int fd, int cmd, va_list ap);
int OsIoctl(int fd, int req, va_list ap);

Close #I65MNQ

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3d16852ffb87ab061c22b22f5873eba384842101
2022-12-13 16:56:18 +08:00
openharmony_ci c7da881469
!934 fix: 对外提供CONFIG_NFILE_DESCRIPTORS宏表示最大可打开fd数量
Merge pull request !934 from Hongjin Li/fs1
2022-12-06 12:10:31 +00:00
openharmony_ci 9cbddd412d
!955 feat: 优化CPUP计算方式, 解耦系统调频
Merge pull request !955 from zhushengle/cpup
2022-12-06 07:11:08 +00:00
openharmony_ci b50b5e7cba
!953 对内核模块暴露OsMemNodeHead/OsMemPoolHead等结构体
Merge pull request !953 from Far/los_memory
2022-12-06 04:08:13 +00:00
zhushengle 974182d50c feat: 优化CPUP计算方式, 解耦系统调频
Close #I5R9XG

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I07cb388732b1190943374802f792d32bd666c06e
2022-12-06 10:41:20 +08:00
Hongjin Li a3ce436841 fix: 提供CONFIG_NFILE_DESCRIPTORS宏标识最大可打开fd数量
提供CONFIG_NFILE_DESCRIPTORS宏,标识最大可打开fd数量。
提供FAT_MAX_OPEN_FILES宏,标识FAT文件系统中最大可打开fd数量。

如果只有FAT文件系统,那么CONFIG_NFILE_DESCRIPTORS等于FAT_MAX_OPEN_FILES。
如果有多个文件系统,比如fat+little+yaffs,那么CONFIG_NFILE_DESCRIPTORS应该定义为多个文件系统可打开fd数量之和。

BREAKING CHANGE:

对外提供的CONFIG_NFILE_DESCRIPTORS宏,用来标识最大可打开fd数量。

开发者可以在target_config.h中自定义CONFIG_NFILE_DESCRIPTORS和FAT_MAX_OPEN_FILES宏。

Close #I62WDU

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-12-06 10:11:13 +08:00
openharmony_ci 588abc0645
!952 fix: 修复低功耗下时间更新缺陷
Merge pull request !952 from zhushengle/pm_timer
2022-12-05 13:02:02 +00:00
zhushengle 7657aadc20 feat: 修复低功耗下时间更新缺陷
1.注释说明低功耗框架中tickLock和tickUnlock两个钩子函数的要求
2.解决极端情况下OsTickTimerBaseReset断言失败的问题

BREAKING CHANGE:
修复低功耗下时间更新缺陷对外变更描述:

低功耗启用另一个低功耗timer时:

LosPmTickTimer 中tickLock函数的功能实现描述由原来的:暂停系统tick timer 修改为:关闭系统tick timer,并将timer的count值清零

LosPmTickTimer 中tickUnlock函数的功能实现描述由原来的:恢复系统tick timer 修改为:重新启动系统tick timer

Close #I5O80Z

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I2ee17518e4a388ff5a1f9e3d8d7c61c81aa3e569
2022-12-05 17:01:37 +08:00
Far 0d1c77c1e0 feat: 对内核模块暴露OsMemNodeHead/OsMemPoolHead
对内核其他模块暴露OsMemNodeHead/OsMemPoolHead等结构体,
以便于对堆内存管理的调测及管理。

fix #I64ONE

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I2e47d90412368dfdc8d82e6b30c9196e1fdf42f1
2022-12-05 16:41:20 +08:00
openharmony_ci 795c2db917
!933 fs增加注册接口
Merge pull request !933 from wangchen/1124_m
2022-12-01 06:18:16 +00:00
wangchen 2f334bed21 feat: fs增加注册接口
方案描述:
增加注册机制, 并增加重复注册判断

BREAKING CHANGE:
fs增加注册接口
新增API:
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
                   const struct FileOps *fsFops, const struct FsManagement *fsMgt);

fix #I611L2
Signed-off-by: wangchen <wangchen240@huawei.com>
https://gitee.com/openharmony/kernel_liteos_m/issues/I611L2
2022-12-01 02:50:05 +00:00
openharmony_ci 9e4978f57f
!947 fix: 使用LOSCFG_FS_FREE_HOOK释放内存
Merge pull request !947 from Hongjin Li/max_open_dirs
2022-12-01 02:50:03 +00:00
Hongjin Li a859329f28 fix: 使用LOSCFG_FS_FREE_HOOK释放内存
文件系统中使用LOSCFG_FS_FREE_HOOK代替free()来释放内存。

close #I6412J

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-12-01 09:33:32 +08:00
openharmony_ci 68b8deea89
!937 添加MAX_OPEN_DIRS宏,标识最大可打开dir数量
Merge pull request !937 from Hongjin Li/max_open_dirs
2022-11-29 11:38:36 +00:00
Hongjin Li a288718c2c fix: 添加LOSCFG_MAX_OPEN_DIRS标识最大可打开dir数量
提供LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。新增g_dirNum静态变量,标识已打开的dir数量。
在opendir成功时g_dirNum++,在closedir成功时g_dirNum--。

BREAKING CHANGE:
新增LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。

fix: I62XEA

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-11-29 19:05:00 +08:00
openharmony_ci 2e7b59b659
!944 feat: 回合liteos_m架构图
Merge pull request !944 from zhushengle/arch
2022-11-29 02:46:53 +00:00
zhushengle 0c577f3e7f feat: 回合liteos_m内核架构图
Close #I63MI5
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I69a978aee465662a9265426975f13e57b41972ab
2022-11-29 10:15:41 +08:00
openharmony_ci 019dab8db4
!941 文件系统提供动态内存分配器钩子
Merge pull request !941 from Far/LOS_FS_MALLOC
2022-11-28 14:36:29 +00:00
openharmony_ci af6863f436
!940 vfs 分区格式化逻辑修改
Merge pull request !940 from wangchen/1128_m_part
2022-11-28 14:17:42 +00:00
Far f190275664 feat: 文件系统提供动态内存分配器钩子
增加LOS_FS_MALLOC/LOS_FS_FREE宏以提供用户配置动态内存分配器的能力。
用户只需要在components/fs/vfs/los_fs.h中修改对应的函数即可。

BREAKING CHANGE:
文件系统提供动态内存分配器钩子
新增宏:
LOS_FS_MALLOC
LOS_FS_FREE

fix #I63IJW

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I20cb41f621a2e22d74749583f546d550ba127b72
2022-11-28 20:02:20 +08:00
openharmony_ci 1bdee9f58e
!939 feat: 更新PR模板, 添加对外变更
Merge pull request !939 from zhushengle/pr
2022-11-28 11:59:22 +00:00
wangchen 97a638bc1c fix: vfs 分区格式化逻辑修改
方案描述:
1,删除fat分区时调用的adddevice的动作
2,修改格式化的判断逻辑

fix #I63FDV
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-28 03:53:54 +00:00
zhushengle 55238c805a feat: 更新PR模板, 添加对外变确认项
在PR模板中添加对外变更的确认选项

fix #I636LO

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I96025b27f771f86cc03c8e60d0e307a9a6c0e404
2022-11-26 17:17:02 +08:00
openharmony_ci 0841ece718
!930 Fix : 内核告警清理
Merge pull request !930 from yinjiaming/fix
2022-11-23 04:09:25 +00:00
yinjiaming a4087a6537 Fix: 内核告警清理
消除了多余的空格

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ibe90fcf8c46ef9a60c0a8f4dbba07d399e139b8c
2022-11-23 10:49:31 +08:00
openharmony_ci 9f19fd2e7a
!918 Fix : POSIX 测试用例补充
Merge pull request !918 from yinjiaming/test-3
2022-11-22 06:58:12 +00:00
openharmony_ci c10037d379
!877 更新liteos_m内核架构图
Merge pull request !877 from zhushengle/arch
2022-11-22 03:44:02 +00:00
yinjiaming b483627ec7 fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix/mqueue 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I64efeb7d3ae3dbd966b716bf8e296a9eb0f5db06
2022-11-21 19:29:44 +08:00
openharmony_ci d120f1e57a
!921 其他分区已mount时会引起格式化失败
Merge pull request !921 from wangchen/1117_m
2022-11-18 09:34:41 +00:00
openharmony_ci 765add9660
!917 告警清理
Merge pull request !917 from 乔克叔叔/master
2022-11-18 09:15:46 +00:00
openharmony_ci a650df0575
!916 修复用例告警
Merge pull request !916 from xuxinyu/1116
2022-11-18 09:14:03 +00:00
wangchen 08436dec9e fix: 其他分区已mount时会引起格式化失败
【背景】其他分区已mount时会引起格式化失败

【修改方案】
1, 格式化时判断方式修改为路径

【影响】
对现有的产品编译不会有影响。
re #I61P4K
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-18 06:31:12 +00:00
openharmony_ci 0818b28aa7
!919 fix:逗号格式错误
Merge pull request !919 from Hongjin Li/warning
2022-11-17 12:57:15 +00:00
Hongjin Li 2dc3998956 fix: add space after comma
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-11-17 20:15:53 +08:00
zhushengle 266a49fb88 feat: 更新liteos_m内核架构图
Close #I61OZZ

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I90afb1c83a9a34597e7b9699a784ad0fbff30f81
2022-11-17 18:41:40 +08:00
liuwenxin fa6f0c393d fix:告警清理
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-17 17:23:44 +08:00
openharmony_ci 3019311435
!910 Fix : POSIX 测试用例补充
Merge pull request !910 from yinjiaming/test-2
2022-11-16 09:50:31 +00:00
xuxinyu b25148107b fix:修复用例告警
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ide6f04adcd3bb12ae296f981cab84f9d7ce867fc
2022-11-16 15:55:34 +08:00
openharmony_ci aee957bb1f
!909 修复mount接口对MS_REMOUNT的支持
Merge pull request !909 from Far/master
2022-11-15 14:17:19 +00:00
Far 64d15df9ea fix: fix the MS_REMOUNT support
The mount interface can't deal with MS_REMOUNT flag now, fix it.

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Id0960c8d92ce767b8d8ef98b3ba2e1d1ab7db15d
2022-11-15 17:05:21 +08:00
yinjiaming 8e58b984ea fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix/mqueue 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I64efeb7d3ae3dbd966b716bf8e296a9eb0f5db06
2022-11-15 16:54:28 +08:00
openharmony_ci be1267fafa
!903 fix: 修复测试用例断言宏使用不规范的问题
Merge pull request !903 from Zhaotianyu/20221110test_fix_assert
2022-11-14 09:41:12 +00:00
openharmony_ci 6cb544b158
!892 m告警清理
Merge pull request !892 from 乔克叔叔/master
2022-11-14 08:50:22 +00:00
openharmony_ci 5e8225273f
!904 Fix : 内核告警清理
Merge pull request !904 from yinjiaming/fix
2022-11-14 08:35:08 +00:00
openharmony_ci aec7a45411
!894 Fix : POSIX 测试用例补充
Merge pull request !894 from yinjiaming/test-1
2022-11-14 08:34:29 +00:00
liuwenxin 2806c4af75 Fix:m核告警清理
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-11 17:40:25 +08:00
yinjiaming 7e442ddd61 fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix/mqueue 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I64efeb7d3ae3dbd966b716bf8e296a9eb0f5db06
2022-11-11 11:56:13 +08:00
openharmony_ci 527cec6e27
!906 RISC-V架构解依赖平台soc.h
Merge pull request !906 from zhushengle/soc
2022-11-10 12:47:40 +00:00
zhushengle d68b5f0ab3 task: RISC-V架构解依赖平台soc.h
Close #I5M7JE

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I98f9f2a5d69576540a270778bf37899594c527f2
2022-11-10 18:45:27 +08:00
openharmony_ci 1cd2ae7b4e
!901 risc-v系统异常时无法输出异常信息
Merge pull request !901 from zhushengle/medeleg
2022-11-10 10:30:50 +00:00
arvinzzz 27ed27eb89 fix: 修复测试用例断言宏使用不规范的问题
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-11-10 17:45:43 +08:00
yinjiaming 098c5ea24d fix: 内核告警清理
Change-Id: Ic6d335964da545bc71edd40669c82b6f85e1bad6
Signed-off-by: yinjiaming <yinjiaming@huawei.com>
2022-11-10 17:32:52 +08:00
zhushengle 914913fab6 task: risc-v系统异常时取消对medeleg寄存器的保存
部分开源架构不支持该寄存器,且非常用寄存器

Close #I60IS5
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I8db31f84a24cc6143513c725691e4ba780ca99e9
2022-11-10 16:29:27 +08:00
openharmony_ci 2f08268983
!895 fix: buffersize paramter type error
Merge pull request !895 from Hongjin Li/fix
2022-11-09 09:29:57 +00:00
Hongjin Li 807c7e64cb fix: buffersize parameter type error
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-11-09 16:49:59 +08:00
openharmony_ci fc87e459d1
!891 在LOS_QueueReadCopy 和 LOS_QueueWriteCopy中增加hook函数
Merge pull request !891 from Hongjin Li/add_hook_call
2022-11-09 08:41:16 +00:00
lihongjin c3d75f64b1 feat: add hook call in LOS_QueueReadCopy and LOS_QueueWriteCopy
Signed-off-by: lihongjin <lihongjin1@huawei.com>
Change-Id: I0c8ecb6e364d8e01b48f78847c25da6bc4cb961c
2022-11-08 18:32:41 +08:00
openharmony_ci f447d15e78
!893 M核fs用例整改
Merge pull request !893 from wangchen/1108_test
2022-11-08 08:04:55 +00:00
wangchen 642d5ef709 fix: M核fs用例整改
【背景】M核fs用例整改

【修改方案】
1,增加部分判断,适配fatfs
2,增加部分接口

【影响】
对现有的产品编译不会有影响。
re #I5Z4DL
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-08 07:26:06 +00:00
openharmony_ci 74bbfa4893
!853 fix:修复文档中失效链接
Merge pull request !853 from zhangdengyu/fix_links_1019
2022-11-08 03:31:18 +00:00
openharmony_ci fe5a091ca2
!864 feat: 支持mutex trace
Merge pull request !864 from zhangdengyu/add_mutex_trace_1028
2022-11-08 03:07:54 +00:00
openharmony_ci c83b98ecbf
!868 告警清理
Merge pull request !868 from 乔克叔叔/master
2022-11-07 10:57:34 +00:00
openharmony_ci c9a96bc4b3
!886 cortex-m4支持iar编译器的gn适配
Merge pull request !886 from yiweiniunan/master
2022-11-07 10:34:19 +00:00
yiweiniunan 62cd8fec46 cortex-m4支持iar编译器的gn适配
Signed-off-by: yiweiniunan <michael.likai@huawei.com>
2022-11-07 16:15:29 +08:00
liuwenxin 8b54493665 fix:告警清理
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-07 14:58:48 +08:00
zhangdengyu a940dda69a feat: 增加mutex trace功能
Close: #I5YJOZ

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: Id36ed4f4d23b9aa59ae9ee8cdb17c06d7e3c151b
2022-11-07 08:42:06 +08:00
openharmony_ci 1bc63d743b
!881 feat: 提供死机场景下dump文件能力
Merge pull request !881 from Zhaotianyu/20221105vfs_lock
2022-11-07 00:41:11 +00:00
arvinzzz 474201593d feat: 提供死机场景下dump文件的能力
死机场景下,vfs层锁会放开,提供dump文件的能力

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Id8c9e63fbf011dbc6690b9b4557bd3370353bf21
2022-11-05 17:58:37 +08:00
openharmony_ci 3f54fdc898
!846 修复shell删除命令误删目录的问题
Merge pull request !846 from 方烨/master
2022-11-04 08:24:17 +00:00
openharmony_ci 8ac6771e0d
!869 Fix : 给LOS_MuxDelete 函数前添加(VOID)
Merge pull request !869 from yinjiaming/fix
2022-11-04 08:23:38 +00:00
openharmony_ci 7101ddbeb8
!874 feat: pm idle添加到menuconfig中
Merge pull request !874 from zhushengle/pm_ilde
2022-11-03 14:10:34 +00:00
openharmony_ci abbed4430e
!847 解决部分平台ping失败
Merge pull request !847 from huohongpeng/ping_checksum
2022-11-03 14:05:50 +00:00
zhushengle 98d20e90ed feat: pm idle添加到menuconfig中
Close #I5ZD5L
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ibdedff3043a0902aa3cd9539497ef97fb6a1ce6c
2022-11-03 21:32:45 +08:00
openharmony_ci 9767191392
!859 Fix : POSIX 测试用例补充
Merge pull request !859 from yinjiaming/test-4
2022-11-03 02:17:32 +00:00
openharmony_ci e540254ed9
!862 feature:支持厂商自定义malloc替换系统默认实现
Merge pull request !862 from Zhaotianyu/20221028iar_malloc
2022-11-01 13:48:15 +00:00
yinjiaming ad4ef11410 fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I65adfd00faec185bcad3c1e38e305ce9e8cb9346
2022-11-01 16:26:56 +08:00
yinjiaming 20ffd89865 fix: 给函数LOS_MutexDelete 前添加(VOID)
Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I49a7c305e955bccca78b80ddeea66330e8b03ac0
2022-11-01 15:43:18 +08:00
arvinzzz ae8d4fd275 feature: 支持厂商定制malloc替换系统默认实现
malloc的相关支持可以通过make menuconfig配置

close: #I5YBPE

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ic40968aa83f43f539f7551c1dcec05f4f9832983
2022-10-28 18:53:53 +08:00
openharmony_ci 972d765c6e
!861 Test : POSIX 测试用例补充
Merge pull request !861 from vincent-zhang/myfeature
2022-10-28 02:09:45 +00:00
vincent 47f883c11a zhangadong@huawei.com
Signed-off-by: vincent <zhangadong@huawei.com>
2022-10-28 09:33:36 +08:00
openharmony_ci 478b41b457
!857 Fix : POSIX 测试用例补充
Merge pull request !857 from yinjiaming/test-2
2022-10-26 06:33:41 +00:00
yinjiaming 69d17d522c fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib8ab772f9893e243ace9319cb7af1486a6bd2937
2022-10-25 15:45:33 +08:00
fangye d4bfb577ef fix: 修复shell删除命令误删目录的问题
Signed-off-by: fangye <fangye@talkweb.com.cn>
Change-Id: Ia8f26ff4b250a6540f5644e2dd38fb22cd85d326
2022-10-25 12:19:46 +08:00
openharmony_ci 6e6cbe5de6
!855 Fix : POSIX 测试用例补充
Merge pull request !855 from yinjiaming/test-1
2022-10-24 11:11:57 +00:00
yinjiaming 383a1d23e9 fix: POSIX 测试用例补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib8ab772f9893e243ace9319cb7af1486a6bd2937
2022-10-24 15:39:20 +08:00
openharmony_ci b24353cf4b
!854 Fix : 使用 newlibc 编译测试用例时报错
Merge pull request !854 from yinjiaming/master
2022-10-21 09:58:50 +00:00
openharmony_ci f1ad086665
!842 cmsis测试用例补充
Merge pull request !842 from 乔克叔叔/branchname
2022-10-21 09:12:17 +00:00
yinjiaming 8fff50f59f fix: newlibc 编译错误修正
【背景】
使用newlibc 编译测试用例时会有编译错误

【修改方案】
删去了 newlibc 中没有的宏定义

【影响】
对现有的产品编译不会有影响。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Id753640253e1b297654b3e523ddd5ca0abdca698
2022-10-20 19:52:32 +08:00
zhangdengyu 373d4f5649 fix: 修复文档中失效链接
Close: #I5WGWU

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I8c37da09e85e823edd59ebf65a3e284596b7bef9
2022-10-19 10:21:05 +08:00
Hongpeng Huo 3c8d20a89e fix: icmp hardware checksum failed for dwc gmac ip core
Signed-off-by: Hongpeng Huo <hongpeng.huo@hpmicro.com>
2022-10-17 20:33:11 +08:00
openharmony_ci e268ef95a9
!851 清除一些静态检查工具发现的问题
Merge pull request !851 from Far/master
2022-10-17 01:38:58 +00:00
Far 296a546bcd fix: 修复一些静态扫描工具发现的问题
Change-Id: I4890de0066f33bf44e913b550edfa3639bce7caf
Signed-off-by: Far <yesiyuan2@huawei.com>
2022-10-15 17:36:26 +08:00
openharmony_ci a7135e252d
!838 fix: 测试用例修复
Merge pull request !838 from Zhaotianyu/20220925iccarm_test_fix
2022-10-13 12:58:17 +00:00
openharmony_ci e76dd685c2
!845 Fix : POSIX测试用例补充
Merge pull request !845 from yinjiaming/test-2
2022-10-10 11:28:30 +00:00
yinjiaming 54a5365a25 fix: POSIX 测试用例后续补充
【背景】
POSIX 测试用例不完善

【修改方案】
继续将 A 核posix 相关的测试用例移植一部分到M核

【影响】
对现有的产品编译不会有影响。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I9a7fff077c5bc00609e51ba9121d93dc67895656
2022-10-10 17:14:45 +08:00
openharmony_ci 2d1160fdc4
!844 Fix : POSIX测试用例补充
Merge pull request !844 from yinjiaming/test-1
2022-10-10 09:10:10 +00:00
yinjiaming f3d606b6dd fix: POSIX测试用例后续补充
【背景】
posix 测试用例补充

【修改方案】
继续将A核 相关POSIX测试用例移植到 M核

【影响】
对现有的产品编译不会有影响。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I91f996a4b4db47a417c9f32c9e04924cc264afbb
2022-10-10 11:46:07 +08:00
openharmony_ci 392e4c2cec
!843 Fix : POSIX测试用例补充
Merge pull request !843 from yinjiaming/test
2022-10-09 08:23:53 +00:00
yinjiaming b334658723 fix: POSIX测试用例补充
【背景】
POSIX测试用例需要补充

【修改方案】
此次修改将部分A核的测试用例移植到M核, 补充到testsuites/sample/posix/pthread
目录下

【影响】
对现有的产品编译不会有影响。

re #I5TIRQ

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: If4c45ca18dec53be809f6309ef1cfb1b9ac0eb20
2022-10-09 10:49:10 +08:00
wenxin-liu_admin a502a0917c :cmsis 测试用例补充
Signed-off-by: wenxin-liu_admin <liuwenxin11@huawei.com>
Change-Id: Iaa133871c465e20170a3bf2204cb1c6ba40fda72
2022-09-30 15:53:58 +08:00
openharmony_ci 2b1f2d554e
!833 解决网络模块封装的ioctl等接口重定义
Merge pull request !833 from wangchen/0923_up_net
2022-09-27 10:54:02 +00:00
wangchen 2cf290bb7c fix: 删除网络模块封装的ioctl等接口
【背景】删除网络模块封装的ioctl等接口

【修改方案】
1, 删除网络模块封装的ioctl等接口

【影响】
对现有的产品编译不会有影响。
re #I5SRE6
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-09-27 09:28:07 +00:00
openharmony_ci 8fc9852e34
!830 lfs_mount 不能多实例
Merge pull request !830 from wangchen/0922_m
2022-09-26 13:09:18 +00:00
openharmony_ci 816d03f5c1
!832 LOS_FsMount 接口存在多处功能问题
Merge pull request !832 from wangchen/0923_m
2022-09-26 13:02:50 +00:00
openharmony_ci 61877ec97a
!831 fix: 修复内核低功耗模式调整后同步问题
Merge pull request !831 from zhushengle/pm
2022-09-26 09:40:24 +00:00
arvinzzz 0f952132c0 fix: iccarm test's problem fix
close: #I5T02Y

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I29385bb25f487adafa2dbc064310817790d831bb
2022-09-25 18:54:03 +08:00
openharmony_ci f94d3ee119
!835 内核告警清理:修复内存泄漏、空指针未判断等问题
Merge pull request !835 from 夏不白/fix_tscan
2022-09-25 08:24:10 +00:00
openharmony_ci 1a764df92a
!816 fix:trace模块编译修复
Merge pull request !816 from Zhaotianyu/20220902trace_fix
2022-09-23 09:39:15 +00:00
wangchen cf50cde1b7 fix: lfs_mount 不能多实例
【背景】最后一个调用lfs_mount()的分区是有效的,前面的会被冲掉

【修改方案】
1, 增加一个存放cfg的空间, 每个mount点有独自的配置存储空间

【影响】
对现有的产品编译不会有影响。
re #I5RIGH
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-09-23 06:44:53 +00:00
wangchen bfef7bfb2e fix: LOS_FsMount 接口存在多处功能问题
【背景】LOS_FsMount 接口存在多处功能问题

【修改方案】
1, 修改goto逻辑
2,把过长的函数重新封装

【影响】
对现有的产品编译不会有影响。
re #I5SP1I
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-09-23 03:45:18 +00:00
zhushengle 5bae8b58c6 fix: 修复内核低功耗模式调整后同步问题
Close #I5SNYA
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I4df212bbf3e522ea371b5340848ba5adf2668ad7
2022-09-23 09:32:32 +08:00
arvinzzz 6377f98e9e fix: trace模块编译修复
close: #I5PD6D

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I727ddaa78c5ca7b6626347659f584f54191efabe
2022-09-02 11:37:42 +08:00
505 changed files with 35395 additions and 9041 deletions

View File

@ -10,6 +10,12 @@
### 测试用例(新增、改动、可能影响的功能) ### 测试用例(新增、改动、可能影响的功能)
### 是否涉及对外变更典型的如对外API规格变更、新增对外接口等等
必须选择一项在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
- [ ] 是,涉及对外变更: 需要在commit message中按【[模板要求](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)】描述变更点
- [ ] 否,不涉及对外变更
### 是否需要同步至release3.0LTS ... )分支? ### 是否需要同步至release3.0LTS ... )分支?
必须选择一项在MarkDown模式下用[x]替换[ ]即可勾选对应选项): 必须选择一项在MarkDown模式下用[x]替换[ ]即可勾选对应选项):

View File

@ -44,6 +44,10 @@ if (defined(LOSCFG_COMPILER_ICCARM)) {
} }
} }
declare_args() {
liteos_build_asm = true
}
config("arch_config") { config("arch_config") {
cflags = arch_config_cflags cflags = arch_config_cflags
asmflags = arch_config_asmflags asmflags = arch_config_asmflags
@ -91,8 +95,9 @@ config("dialect_config") {
} }
config("misc_config") { config("misc_config") {
defines = []
if (!defined(LOSCFG_COMPILER_ICCARM)) { if (!defined(LOSCFG_COMPILER_ICCARM)) {
defines = [ "__LITEOS__" ] defines += [ "__LITEOS__" ]
defines += [ "__LITEOS_M__" ] defines += [ "__LITEOS_M__" ]
} }
if (!defined(LOSCFG_DEBUG_VERSION)) { if (!defined(LOSCFG_DEBUG_VERSION)) {
@ -136,8 +141,8 @@ config("public") {
] ]
if (BOARD_SOC_FEATURE) { if (BOARD_SOC_FEATURE) {
configs += [ "//device/board/$device_company:public" ] configs += [ "$DEVICE_BOARD_DIR/$device_company:public" ]
configs += [ "//device/soc/$LOSCFG_SOC_COMPANY:public" ] configs += [ "$DEVICE_SOC_DIR/$LOSCFG_SOC_COMPANY:public" ]
} else { } else {
if (HAVE_DEVICE_SDK) { if (HAVE_DEVICE_SDK) {
configs += [ "$device_path:public" ] configs += [ "$device_path:public" ]
@ -157,8 +162,8 @@ group("modules") {
] ]
if (BOARD_SOC_FEATURE) { if (BOARD_SOC_FEATURE) {
deps += [ "//device/board/$device_company" ] deps += [ "$DEVICE_BOARD_DIR/$device_company" ]
deps += [ "//device/soc/$LOSCFG_SOC_COMPANY" ] deps += [ "$DEVICE_SOC_DIR/$LOSCFG_SOC_COMPANY" ]
} else { } else {
if (HAVE_DEVICE_SDK) { if (HAVE_DEVICE_SDK) {
deps += [ device_path ] deps += [ device_path ]
@ -214,4 +219,7 @@ build_ext_component("build_kernel_image") {
exec_path = rebase_path(root_out_dir) exec_path = rebase_path(root_out_dir)
command = toochain_config_command command = toochain_config_command
if (liteos_build_asm) {
command += toochain_asm_command
}
} }

465
CHANGELOG.md Normal file
View File

@ -0,0 +1,465 @@
# (2022-03-30)
### Bug Fixes
* c-sky等芯片架构的BUILD.gn优化 ([3311d73](https://gitee.com/openharmony/kernel_liteos_m/commits/3311d73406b68d289b6f715a099e90f62c86abd1)), closes [#I4D129](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D129)
* change the sensitive words ([8e2248c](https://gitee.com/openharmony/kernel_liteos_m/commits/8e2248c062aaca2444cc1001873fe8e8d8cdd3c6)), closes [#I4K7LL](https://gitee.com/openharmony/kernel_liteos_m/issues/I4K7LL)
* cortex-m55栈优化 ([59e9c6e](https://gitee.com/openharmony/kernel_liteos_m/commits/59e9c6ed73caeeed56081a768198eccc7448df6c)), closes [#I4SQIQ](https://gitee.com/openharmony/kernel_liteos_m/issues/I4SQIQ)
* csky等新增模块的HalTickStart函数定义和实现不一致 ([07ab6a5](https://gitee.com/openharmony/kernel_liteos_m/commits/07ab6a5b77c6955f6093beeab976bdc1b32d1db9)), closes [#I4D1HY](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D1HY)
* FD_SETSIZE compatible newlibc ([82c6d5f](https://gitee.com/openharmony/kernel_liteos_m/commits/82c6d5f17478fb47ea5977a32fb76d783ee3e815))
* fix compile warning saying dereference void * pointer ([29126a9](https://gitee.com/openharmony/kernel_liteos_m/commits/29126a98fe7a8f75695910bdf8fa1ccc6ff67288))
* gcc编译testsuite编译问题修复 ([f7d26b8](https://gitee.com/openharmony/kernel_liteos_m/commits/f7d26b8e12fb1ba4bebe6c0fc9ca9e392537419f)), closes [#I4DAOU](https://gitee.com/openharmony/kernel_liteos_m/issues/I4DAOU)
* Kconfig中打开littlefs选项默认关联打开LOSCFG_SUPPORT_LITTLEFS宏 ([b2bcab3](https://gitee.com/openharmony/kernel_liteos_m/commits/b2bcab3a5bd794c86dd4d93b1b5aeca2d097289b)), closes [#I4ENQ1](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ENQ1)
* kernel接口融合添加/修改kernel函数 ([cee9714](https://gitee.com/openharmony/kernel_liteos_m/commits/cee9714a90f2660a0b4455f4f5a2fc42870a6aa5))
* L0 pthread_cond_timedwait接口实现存在的几个问题 ([2219c32](https://gitee.com/openharmony/kernel_liteos_m/commits/2219c32784071b6c37ea57185382e3228ed4b0a7)), closes [#I4N9P8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4N9P8)
* liteos_kernel_only=true编译内核报错 ([adc2105](https://gitee.com/openharmony/kernel_liteos_m/commits/adc21052b2b9b55de9fc493cf74645f470edf9b5)), closes [#I4O204](https://gitee.com/openharmony/kernel_liteos_m/issues/I4O204)
* los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误 ([c51df7a](https://gitee.com/openharmony/kernel_liteos_m/commits/c51df7a94c1f21803db25f46a73a7fb291588eda)), closes [#I4EJI4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4EJI4)
* los_interrupt.c存在未使用的参数编译出错 ([5af4c2e](https://gitee.com/openharmony/kernel_liteos_m/commits/5af4c2e2139cabe49049283f7a4280460bbf353a)), closes [#I4SJPZ](https://gitee.com/openharmony/kernel_liteos_m/issues/I4SJPZ)
* LOS_Panic接口中增加需要增加LOS_BackTrace(),方便定位主动异常位置 ([f51d675](https://gitee.com/openharmony/kernel_liteos_m/commits/f51d675fee217e0ad519f2fa79f70b033f313dce)), closes [#I4IGGY](https://gitee.com/openharmony/kernel_liteos_m/issues/I4IGGY)
* los_trace.h接口注释错误修正 ([693468e](https://gitee.com/openharmony/kernel_liteos_m/commits/693468e5274af310721f5962602a915d701a7bf0)), closes #I4CYPZ
* m4核在任务中异常时backtrace使用的是MSP所在的栈而不是PSP所在的栈 ([3e8aea2](https://gitee.com/openharmony/kernel_liteos_m/commits/3e8aea224e481322efef9397e4aafc3450a09d28)), closes [#I4D7GE](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D7GE)
* M核posix接口fs模块用例完善 ([ee380fb](https://gitee.com/openharmony/kernel_liteos_m/commits/ee380fb9be45ef033979ec3b8875d980b7f13198)), closes [#I4L7BF](https://gitee.com/openharmony/kernel_liteos_m/issues/I4L7BF)
* optimize default configuration ([b2e3849](https://gitee.com/openharmony/kernel_liteos_m/commits/b2e3849bfbd470981602b0dc02f47bffb38bfe11)), closes [#I4FSC9](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FSC9)
* OsGetAllTskInfo调用和异常时无任务回调函数地址 ([1c605a3](https://gitee.com/openharmony/kernel_liteos_m/commits/1c605a338ad2317aeb464bdac85df5b9a79c99fd)), closes [#I4MG2T](https://gitee.com/openharmony/kernel_liteos_m/issues/I4MG2T)
* pm codex告警清零 ([9666380](https://gitee.com/openharmony/kernel_liteos_m/commits/96663805ecfd3248e33b4deb877c8d55cc4e8eec)), closes [#I4OWPE](https://gitee.com/openharmony/kernel_liteos_m/issues/I4OWPE)
* pm模块解冻线程时存在删除空链表且时间片频繁唤醒系统 ([9f185b5](https://gitee.com/openharmony/kernel_liteos_m/commits/9f185b5b52ed9506a4913f233c9ddfe45452ec05)), closes [#I4AKUS](https://gitee.com/openharmony/kernel_liteos_m/issues/I4AKUS)
* **posix unittest:** posix unittest 融合 ([ad6f249](https://gitee.com/openharmony/kernel_liteos_m/commits/ad6f249d1ea878f06864d79bdbed772b21eeac49))
* **posix:** posix兼容回退 ([207efc1](https://gitee.com/openharmony/kernel_liteos_m/commits/207efc15b859fe18d8b1dac2a3da9d7a5831aa6e))
* **posix:** posix接口融合接口规范兼容性修改 ([e0b1275](https://gitee.com/openharmony/kernel_liteos_m/commits/e0b12758da4a25e42110ba32da25b6d18ebed8ef))
* **posix接口融合:** posix接口融合接口规范兼容性修改 ([4b607fd](https://gitee.com/openharmony/kernel_liteos_m/commits/4b607fd0740a5379cd373890482235845d782b62))
* posix线程和LOS_TaskCreate任务不兼容补齐接口防护防止访问野指针 ([60805e1](https://gitee.com/openharmony/kernel_liteos_m/commits/60805e1a7c3736db86695ed86cd03cfaab70a427))
* pr模板补充说明 ([7b86f69](https://gitee.com/openharmony/kernel_liteos_m/commits/7b86f69cc0ccd5512b69fd3a1181b3440747ddb2))
* ReadMe中无对动态加载模块待加载的共享库的限制说明。 ([f86b971](https://gitee.com/openharmony/kernel_liteos_m/commits/f86b97180f97903bb2def271b7b11fc1ae1bf9bb)), closes [#I4ICK8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ICK8)
* shell 输入不识别命令时内存泄漏 ([0245b1a](https://gitee.com/openharmony/kernel_liteos_m/commits/0245b1a7b24fd36d23f9602d0755b274581a84ce)), closes [#I4UR9P](https://gitee.com/openharmony/kernel_liteos_m/issues/I4UR9P)
* **shell:** cat针对大文件无法工作 ([d518bad](https://gitee.com/openharmony/kernel_liteos_m/commits/d518bad0dc7dd9e3fbb45423a7db5cb8c1c922dc)), closes [#I4J4TK](https://gitee.com/openharmony/kernel_liteos_m/issues/I4J4TK)
* shell模块task命令踩内存问题修改 ([6ffd55d](https://gitee.com/openharmony/kernel_liteos_m/commits/6ffd55dcd07ce17b693a97bb678668f763480e4d)), closes [#I4A70V](https://gitee.com/openharmony/kernel_liteos_m/issues/I4A70V)
* switch inet_addr to a function ([b30e913](https://gitee.com/openharmony/kernel_liteos_m/commits/b30e9139d5502acab8c36ae9a56d4cd640786c44)), closes [#I4G4I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4I4)
* **testsuites:** cpup和测试套解耦 ([692651f](https://gitee.com/openharmony/kernel_liteos_m/commits/692651fe40f668f19b479186e52fea34d092b458))
* tick timer时钟频率赋值修改为运行时赋值 ([ae02afc](https://gitee.com/openharmony/kernel_liteos_m/commits/ae02afc8504f64ff6bc09828f55e9602bcbcae56)), closes [#I4PGUR](https://gitee.com/openharmony/kernel_liteos_m/issues/I4PGUR)
* tick中断处理时无挂起任务时应更新当前运行任务的时间片, 并触发一次调度 ([ea12d40](https://gitee.com/openharmony/kernel_liteos_m/commits/ea12d40caf1301b4a7b6d60a2c599ceff4746c90)), closes [#I4LRZG](https://gitee.com/openharmony/kernel_liteos_m/issues/I4LRZG)
* **time_func_test_01.c:** 修复testTimes测试单板配置LOSCFG_BASE_CORE_TICK_PER_SECOND = 1000的问题 ([5c982f1](https://gitee.com/openharmony/kernel_liteos_m/commits/5c982f1087f95174f2836c72648eab58adf37fd7))
* 中断向量表对齐大小支持可配置 ([cf9c838](https://gitee.com/openharmony/kernel_liteos_m/commits/cf9c8387e3785d994aacf948b7c1b61324a3dd63)), closes [#I4M20E](https://gitee.com/openharmony/kernel_liteos_m/issues/I4M20E)
* 优化trace buffer初始化删除swtmr 桩中的无效参数 ([afbc9a5](https://gitee.com/openharmony/kernel_liteos_m/commits/afbc9a593b61461072556cb5531d90b30ce2e394)), closes [#I4DPR7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4DPR7)
* 优化低功耗流程 ([c6600d9](https://gitee.com/openharmony/kernel_liteos_m/commits/c6600d9dddb666f397ba659d47d64f334691af6b)), closes [#I46VXK](https://gitee.com/openharmony/kernel_liteos_m/issues/I46VXK)
* 修复arch目录调整影响到的target目录下的文件 ([d5725b2](https://gitee.com/openharmony/kernel_liteos_m/commits/d5725b22644da8ab3e719169230303e44c7d8750)), closes [#I4JM7Z](https://gitee.com/openharmony/kernel_liteos_m/issues/I4JM7Z)
* 修复cortex-m系列系统提供的timer在低频下时间不准的问题 ([3e569ba](https://gitee.com/openharmony/kernel_liteos_m/commits/3e569bac587d90dcd21aff7d8ec53216dfbb8f1c)), closes [#I4HBGR](https://gitee.com/openharmony/kernel_liteos_m/issues/I4HBGR)
* 修复hook层LOS_HOOK_TYPE_SEM_PEND的runningTask入参可能为空 ([3fd22ac](https://gitee.com/openharmony/kernel_liteos_m/commits/3fd22ac2b0b4c690669a659246aba099fd4311ec)), closes [#I4BU4P](https://gitee.com/openharmony/kernel_liteos_m/issues/I4BU4P)
* 修复irqNum = HwiNumGet()编译错误的问题 ([16e87d7](https://gitee.com/openharmony/kernel_liteos_m/commits/16e87d78d89bec7d85c076fc738ed4ad0614b865)), closes [#I4S81B](https://gitee.com/openharmony/kernel_liteos_m/issues/I4S81B)
* 修复Kconfig信息错误 ([bb04582](https://gitee.com/openharmony/kernel_liteos_m/commits/bb045829104211522cd12a7273d5853400c1ea26)), closes [#I4MZ1F](https://gitee.com/openharmony/kernel_liteos_m/issues/I4MZ1F)
* 修复L0_Emulator 门禁高概率失败的问题 ([7ad2f62](https://gitee.com/openharmony/kernel_liteos_m/commits/7ad2f62a03481a3919fef1f1e46e4c9677b1e65c)), closes [#I4NB0N](https://gitee.com/openharmony/kernel_liteos_m/issues/I4NB0N)
* 修复liteos-m在iar环境下的编译问题 ([4c4784e](https://gitee.com/openharmony/kernel_liteos_m/commits/4c4784e33d7944e7850009be192375aaa6e2b125)), closes [#I4Q5Q5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4Q5Q5)
* 修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题 ([d32e25f](https://gitee.com/openharmony/kernel_liteos_m/commits/d32e25f3ae8e8e5ec24effa98dc8f0b3ba94d0c1)), closes [#I4EJGR](https://gitee.com/openharmony/kernel_liteos_m/issues/I4EJGR)
* 修复newlib缺省PTHREAD_KEYS_MAX 问题 ([65f04bf](https://gitee.com/openharmony/kernel_liteos_m/commits/65f04bf093376a478e9585dadfc1238158cc3641)), closes [#I4OX47](https://gitee.com/openharmony/kernel_liteos_m/issues/I4OX47)
* 修复OsQueueMailFree提早释放内存的问题 ([ec88d16](https://gitee.com/openharmony/kernel_liteos_m/commits/ec88d1628937b3def6dd613246116f6bfa4141eb))
* 修复pm编译告警导致内核编译失败 ([18b0524](https://gitee.com/openharmony/kernel_liteos_m/commits/18b052458e1cea113df7a6bb4798a6d5e1eb751e)), closes [#I49MIN](https://gitee.com/openharmony/kernel_liteos_m/issues/I49MIN)
* 修复pthread 编译告警 ([cc57f81](https://gitee.com/openharmony/kernel_liteos_m/commits/cc57f81ab85a5eb9bb4be9bd7d2863978996bcf3)), closes [#I4U16U](https://gitee.com/openharmony/kernel_liteos_m/issues/I4U16U)
* 修复pthread_create相关问题 ([cd949dd](https://gitee.com/openharmony/kernel_liteos_m/commits/cd949ddae0aa4e7291b0b7f6ba83c2034cdf1301)), closes [#I4P78J](https://gitee.com/openharmony/kernel_liteos_m/issues/I4P78J)
* 修复pthread_create行为与posix不一致问题 ([2b1e5a7](https://gitee.com/openharmony/kernel_liteos_m/commits/2b1e5a7a130fbca1b86a787b54f474e183541d6d)), closes [#I49W9F](https://gitee.com/openharmony/kernel_liteos_m/issues/I49W9F)
* 修复readme中文档链接错误 ([8ee70a0](https://gitee.com/openharmony/kernel_liteos_m/commits/8ee70a0f8f856da29139a36ba6f8589201cdb109)), closes [#I4FD5G](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FD5G)
* 修复risc-v异常时异常信息混乱且backtrace无法输出的问题 ([0fb49d4](https://gitee.com/openharmony/kernel_liteos_m/commits/0fb49d4422245e83c2435468eb7f2690f2e2c6e4)), closes #I4BPHX
* 修复shcmd.h需要用宏包起来的问题 ([a7a8a62](https://gitee.com/openharmony/kernel_liteos_m/commits/a7a8a62bcb7398b4194b37f62098da9cb1ce717e)), closes [#I45FU2](https://gitee.com/openharmony/kernel_liteos_m/issues/I45FU2)
* 修复shell 模块存在大量的编译告警及codeCheck。 ([e0d8b53](https://gitee.com/openharmony/kernel_liteos_m/commits/e0d8b5328f53dcef9427a34e8b0462250bb6a40f)), closes [#I48V2J](https://gitee.com/openharmony/kernel_liteos_m/issues/I48V2J)
* 修复任务栈对齐问题及补充posix和cmsis测试用例 ([ed863e9](https://gitee.com/openharmony/kernel_liteos_m/commits/ed863e90dd9aceb5d3b6d92b0a94703101b83f80))
* 修复公版gcc编译内核调用calloc崩溃 ([8d0ced2](https://gitee.com/openharmony/kernel_liteos_m/commits/8d0ced206951f35d5caab61969344b0ab259e5fb)), closes [#I4OFG6](https://gitee.com/openharmony/kernel_liteos_m/issues/I4OFG6)
* 修复未使用的参数和类型比较编译报错问题 ([21b46e8](https://gitee.com/openharmony/kernel_liteos_m/commits/21b46e82f31030703d052369701f4d6d736a4a86))
* 修复调度时间最大值不一致问题 ([9f393bc](https://gitee.com/openharmony/kernel_liteos_m/commits/9f393bcc6df592efb6940e9864ff93e932ae59ad))
* 修正liteos-m内核README不准确信息 ([0e067b2](https://gitee.com/openharmony/kernel_liteos_m/commits/0e067b239354c28e16b05489274b33051d002508)), closes [#I4PLWP](https://gitee.com/openharmony/kernel_liteos_m/issues/I4PLWP)
* 修正部分编码风格问题 ([91903a3](https://gitee.com/openharmony/kernel_liteos_m/commits/91903a37165ef364750916104be4f7dfd1d8f9a6)), closes [#I4K8M7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4K8M7)
* 内核ERR打印线程信息不方便问题定位。 ([232fec2](https://gitee.com/openharmony/kernel_liteos_m/commits/232fec27ac8cd2f46b5a2f5cfbe4677d0e287314)), closes #I4DAKM
* 内源检视问题修复 ([c24363b](https://gitee.com/openharmony/kernel_liteos_m/commits/c24363bc50364b0be1fba3b993a83c6936fc3d08))
* 删除C文件中无用的__cplusplus ([7fe3aad](https://gitee.com/openharmony/kernel_liteos_m/commits/7fe3aaddf56b300ffcb2b186ae01ed64bef1c069)), closes [#I4D0YK](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D0YK)
* 删除OsMemboxExcInfoGetSub内存调测方法中多余的赋值语句。 ([94db0fe](https://gitee.com/openharmony/kernel_liteos_m/commits/94db0fe7a30edaa10786101f1ef662987a27734a)), closes [#I4CFNX](https://gitee.com/openharmony/kernel_liteos_m/issues/I4CFNX)
* 去掉没有使用的入参consoleid。 ([a627953](https://gitee.com/openharmony/kernel_liteos_m/commits/a62795304da31e13021ea2c675d124afd2594102)), closes [#I43CVE](https://gitee.com/openharmony/kernel_liteos_m/issues/I43CVE)
* 去掉编译选项-fno-short-enums ([b542aab](https://gitee.com/openharmony/kernel_liteos_m/commits/b542aab09dd92397f8c1305ac656ef14a012b5f8)), closes [#I4JY32](https://gitee.com/openharmony/kernel_liteos_m/issues/I4JY32)
* 取消cpu进入低功耗前开中断操作 ([bd39e9e](https://gitee.com/openharmony/kernel_liteos_m/commits/bd39e9e6d67310222c363e132141bb7fee1213f1)), closes [#I4KDP8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4KDP8)
* 告警修复 ([7d2fd01](https://gitee.com/openharmony/kernel_liteos_m/commits/7d2fd01c2d7d6d4c653a307a1419bc094f5332f0))
* 告警修复 ([2d7bf3b](https://gitee.com/openharmony/kernel_liteos_m/commits/2d7bf3b7d8ea84961e802c366899aca891f38377))
* 在头文件中补充LOSCFG_MEM_FREE_BY_TASKID函数的声明 ([ad18026](https://gitee.com/openharmony/kernel_liteos_m/commits/ad18026a59fc2853c9580e040f959f9f42082640)), closes [#I4JBOV](https://gitee.com/openharmony/kernel_liteos_m/issues/I4JBOV)
* 将curl依赖的函数新增至newlib库 ([bd04d9f](https://gitee.com/openharmony/kernel_liteos_m/commits/bd04d9f29a0b77445a71378f88b01ffdae24554f)), closes [#I4RG71](https://gitee.com/openharmony/kernel_liteos_m/issues/I4RG71)
* 将未定义小写"true""false"改为"TRUE""FALSE"。 ([9819eb5](https://gitee.com/openharmony/kernel_liteos_m/commits/9819eb567636adf1774de9fd6039d274bee8f69b)), closes [#I43D20](https://gitee.com/openharmony/kernel_liteos_m/issues/I43D20)
* 当前仓代码编译告警的问题 ([194ac58](https://gitee.com/openharmony/kernel_liteos_m/commits/194ac5898d1e2ffaa17f6dca405614b73da6f8bb)), closes #I4N50W
* 支持硬浮点编译 ([988fd85](https://gitee.com/openharmony/kernel_liteos_m/commits/988fd85fae454a0d9fe01ef1c921b4f3667d5ac8)), closes [#I48KJP](https://gitee.com/openharmony/kernel_liteos_m/issues/I48KJP)
* 测试用例任务栈的宏定义重复定义导致在osTest.h中修改不生效 ([ce6cf68](https://gitee.com/openharmony/kernel_liteos_m/commits/ce6cf6879f4564393765a24c4d65448e0fddc3eb))
* 添加L0 测试门禁 ([5c168fc](https://gitee.com/openharmony/kernel_liteos_m/commits/5c168fc3e0d08dd4a8924696e17a498eb444fa70)), closes #I4C5R4
* 添加newlib对ipv6的支持 ([f7400fb](https://gitee.com/openharmony/kernel_liteos_m/commits/f7400fbcb275cbb3b75f1aef2af1459b794432de)), closes [#I4M1DB](https://gitee.com/openharmony/kernel_liteos_m/issues/I4M1DB)
* 添加文件版权头等信息 ([cf4e017](https://gitee.com/openharmony/kernel_liteos_m/commits/cf4e017970f8a3113bc8b6028d75775f747512c6)), closes [#I4BXBH](https://gitee.com/openharmony/kernel_liteos_m/issues/I4BXBH)
* 清除因g_tm变量没有使用引入的编译告警 ([9689522](https://gitee.com/openharmony/kernel_liteos_m/commits/9689522a8e08b79244ad339dc24074843b99d33b)), closes [#I4LW3H](https://gitee.com/openharmony/kernel_liteos_m/issues/I4LW3H)
* 移除los_arch_interrupt.h文件中冗余声明的函数VOID OsExcInit(VOID) ([136952f](https://gitee.com/openharmony/kernel_liteos_m/commits/136952f193fe97cfd6a88932e71811e12edfa7a5)), closes [#I4D9OO](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D9OO)
* 补充net相关头文件 ([93f616b](https://gitee.com/openharmony/kernel_liteos_m/commits/93f616b64e961013be5c5267e50d58a40b5cc6c9))
* 解决gmtime和localtime接口由于g_tm全局变量导致的竞态问题 ([1454b76](https://gitee.com/openharmony/kernel_liteos_m/commits/1454b76482d42e78c1904028de55d82261e5ecaa)), closes [#I4LW3H](https://gitee.com/openharmony/kernel_liteos_m/issues/I4LW3H)
* 解决los_pm.c:743:19: warning 编译告警 ([0c72c8b](https://gitee.com/openharmony/kernel_liteos_m/commits/0c72c8bf94b053ff90bbf2019006c52adf1eb8df)), closes [#I4D4L8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D4L8)
* 解决定时器超时但还在队列中无法删除的问题 ([ecce17e](https://gitee.com/openharmony/kernel_liteos_m/commits/ecce17ea4878c7bdf7d7de9a6848e6bf871563de)), closes [#I4LFVD](https://gitee.com/openharmony/kernel_liteos_m/issues/I4LFVD)
* 解除net对cmsis的依赖net属于内核模块不应该依赖内核对外接口 ([9982624](https://gitee.com/openharmony/kernel_liteos_m/commits/99826240d979c3aa820ab2aace62e3338978e6d1))
* 调度中将pm相关的部分用LOSCFG_KERNEL_PM包含 ([d7c0059](https://gitee.com/openharmony/kernel_liteos_m/commits/d7c0059dc4fcca3f85d2cad1012353892ce28021)), closes [#I4L00F](https://gitee.com/openharmony/kernel_liteos_m/issues/I4L00F)
* 调用LOS_TaskDetach操作已退出的joinable的任务时未正确回收该任务 ([49c93b3](https://gitee.com/openharmony/kernel_liteos_m/commits/49c93b37c5e215612bbeb4619e73c809f9eb1cac)), closes [#I4DZL7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4DZL7)
* 针对pr是否同步至release分支增加原因说明规则 ([1ee543d](https://gitee.com/openharmony/kernel_liteos_m/commits/1ee543d5d31524d543ffb297b121224dedf8602f))
* 队列相关的API实现中,参数的校验不完全,导致程序异常 ([eef7c80](https://gitee.com/openharmony/kernel_liteos_m/commits/eef7c80a725d68af254ae55091bd36f978cf4284))
### Features
* adapt net ([8594ee4](https://gitee.com/openharmony/kernel_liteos_m/commits/8594ee469ad2d40a363e5d77f94f292ab3cb8c21))
* add option for ioctl ([5e8ac4b](https://gitee.com/openharmony/kernel_liteos_m/commits/5e8ac4b8883f64bbffa5bb3f063a601112058396)), closes [#I4I3W5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4I3W5)
* add option SIOCGIFBRDADDR for ioctl ([33ee492](https://gitee.com/openharmony/kernel_liteos_m/commits/33ee49295329e3c394d1cc7b16f77a23ac2255a8)), closes [#I4EGNG](https://gitee.com/openharmony/kernel_liteos_m/issues/I4EGNG)
* added assembly atomic interface ([1513f50](https://gitee.com/openharmony/kernel_liteos_m/commits/1513f50a474d1227a83fb655ad18c19cd792f235))
* backtrace for arm9 ([03de7f3](https://gitee.com/openharmony/kernel_liteos_m/commits/03de7f37450a8821ea05e60e94a5d1dd359c4f99)), closes [#I4BMLG](https://gitee.com/openharmony/kernel_liteos_m/issues/I4BMLG)
* Board 和 SoC分离编译适配 ([3f1c04d](https://gitee.com/openharmony/kernel_liteos_m/commits/3f1c04dd57bca0379ce37162d9d824801e7d880f))
* **build:** add module_group and comment out arch_cflags ([e5636f7](https://gitee.com/openharmony/kernel_liteos_m/commits/e5636f7acaf7e8b7d14dc07930b2a16c86e63c85))
* **build:** support Kconfig ([7e67343](https://gitee.com/openharmony/kernel_liteos_m/commits/7e673430dc42c55b3a0a6d955ba8fea21d6d58ea))
* **cmsis:** support max_count for osSemaphoreNew ([d478152](https://gitee.com/openharmony/kernel_liteos_m/commits/d478152762013975551e1af154df42987596c9a6))
* cortex-m55支持psplimit ([db7d641](https://gitee.com/openharmony/kernel_liteos_m/commits/db7d641c223db8ab25501d79c2a6331f743d830b)), closes [#I4T7R3](https://gitee.com/openharmony/kernel_liteos_m/issues/I4T7R3)
* littlefs最大打开文件个数修改为可通过menuconfig配置 ([9bc9f3a](https://gitee.com/openharmony/kernel_liteos_m/commits/9bc9f3aa53be7bf392d3da09adcb184dec8e3da2))
* newlib支持pthread_equal ([ce5357e](https://gitee.com/openharmony/kernel_liteos_m/commits/ce5357eee1daf1c1b3a3aa7bdeaef0cc5a8901bf)), closes [#I4QERS](https://gitee.com/openharmony/kernel_liteos_m/issues/I4QERS)
* provide read write for socket by #define ([d044eda](https://gitee.com/openharmony/kernel_liteos_m/commits/d044eda3c3640ae135ef528739d0c9609f40c822)), closes [#I4H8TL](https://gitee.com/openharmony/kernel_liteos_m/issues/I4H8TL)
* synchronizing arch api ([04bf3a6](https://gitee.com/openharmony/kernel_liteos_m/commits/04bf3a682f149482d8ebdbb9ff96d6889edb487a)), closes [#I4N7XV](https://gitee.com/openharmony/kernel_liteos_m/issues/I4N7XV)
* synchronous los_hwicreate interface ([6c68ada](https://gitee.com/openharmony/kernel_liteos_m/commits/6c68adad4db7f6112990764eafe6a3bd5f8759a5))
* 低内存资源回收low memory killer ([ab886d8](https://gitee.com/openharmony/kernel_liteos_m/commits/ab886d848ab809942c11d0e408b8ff76c41b92b2)), closes [#I4ID0M](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ID0M)
* 低功耗支持冻结线程等需求 ([9b5739a](https://gitee.com/openharmony/kernel_liteos_m/commits/9b5739ab11ae7a89d35ba6f54fc62137ddc6d897)), closes [#I49FJF](https://gitee.com/openharmony/kernel_liteos_m/issues/I49FJF)
* 内核提供Interrupt框架支持多架构多平台通用化 ([e8538d0](https://gitee.com/openharmony/kernel_liteos_m/commits/e8538d041a93817cea4ae3914afcfdc6182483e7))
* 内核提供tick timer框架支持多架构多平台通用化 ([f635450](https://gitee.com/openharmony/kernel_liteos_m/commits/f635450d7cf7f674de3803b5eb9d759b6e4d005b)), closes [#I4N7XV](https://gitee.com/openharmony/kernel_liteos_m/issues/I4N7XV)
* 同步调度部分优化至liteos_m ([fb11ab1](https://gitee.com/openharmony/kernel_liteos_m/commits/fb11ab181e69289f7a2edfd5857595b89f1d5d67))
* 支持cortex-m55 ([6e17805](https://gitee.com/openharmony/kernel_liteos_m/commits/6e1780546c173365262c7a50b81896f5b3c46389)), closes [#I4Q9OQ](https://gitee.com/openharmony/kernel_liteos_m/issues/I4Q9OQ)
* 支持Lms ([7b838e8](https://gitee.com/openharmony/kernel_liteos_m/commits/7b838e8a7b8e9f7fb34ca495e5cb46d70d12722b)), closes [#I4HYBG](https://gitee.com/openharmony/kernel_liteos_m/issues/I4HYBG)
* 支持posix 和 cmsis join能力 ([ecfdf7f](https://gitee.com/openharmony/kernel_liteos_m/commits/ecfdf7ff9bf1adf06835968dc6f06b7c45e04862)), closes [#I44V26](https://gitee.com/openharmony/kernel_liteos_m/issues/I44V26)
* 支持posix线程私有数据能力 ([a856303](https://gitee.com/openharmony/kernel_liteos_m/commits/a856303b9cdadcfade33de0d3a335db0332f5761)), closes [#I4ODEB](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ODEB)
* 支持pthread_condattr_setclock ([68dad2c](https://gitee.com/openharmony/kernel_liteos_m/commits/68dad2ccc9856dc2c1ac112bc8f30a703c1af5d9)), closes [#I4ETLN](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ETLN)
* 支持pthread_mutex属性相关接口 ([d2be4d7](https://gitee.com/openharmony/kernel_liteos_m/commits/d2be4d7a460365844a7732df8a3eb59e6bb64897)), closes [#I4G4RQ](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4RQ)
* 支持select.h的FD_SETSIZE宏配置 ([05642f0](https://gitee.com/openharmony/kernel_liteos_m/commits/05642f05ae6b220df977f4402bc31f396bf08603)), closes [#I4RYK4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4RYK4)
* 支持任务栈可配置 ([96cc92d](https://gitee.com/openharmony/kernel_liteos_m/commits/96cc92d03561e1a9f1030c71916068584b349626))
* 调度、任务及pm解耦 ([cc8a794](https://gitee.com/openharmony/kernel_liteos_m/commits/cc8a794229f4236a1611183fd482740b3badbcd7)), closes [#I4JTN6](https://gitee.com/openharmony/kernel_liteos_m/issues/I4JTN6)
* 适配三方库FatFs升级至r0.14a版本 ([92ea355](https://gitee.com/openharmony/kernel_liteos_m/commits/92ea355756ebd92b8809ecb638ffb5355d89c5e9))
### BREAKING CHANGES
* pthread_create 支持任务栈设置
osThreadNew 支持任务栈设置
TSK_INIT_PARAM_S 结构体添加stackAddr 字段
* 涉及接口修改:
LOS_HwiCreate LOS_HwiDelete
改动内容:
中断处理函数参数类型由HWI_ARG_T统一改为HwiIrqParam封装原有arg参数及riscv部分实际使用变量pDevId, 这样一方面统一LiteOS接口也统一了中断处理函数的arg参数
同步LOS_HwiDelete接口入参新增HWI_IRQ_PARAM_S *irqParam参数为后续共享中断功能的添加预留
* 新增接口:
LOS_TaskResRecycle
LOS_CurrNanosec
LOS_MDelay
接口修改:
LOS_QueueCreate第一个入参添加const修饰并增加一种异常情况处理
los_memory.c中 OS_ERROR 修改为LOS_NOK重定义LOS_NOK为UINT32-1。
接口位置转移:
LOS_UDelay 由los_task.h/.c转移到los_tick.h/.c
宏修改:
LOS_ERRNO_MUX_PEND_INTERR 改名为 LOS_ERRNO_MUX_IN_INTERR
* **posix接口融合:**
接口修改:
calloc
pthread_mutex_init
mq_unlink
pthread_join
pthread_exit
pthread_attr_init
pthread_attr_destroy
pthread_condattr_destroy
pthread_cond_timedwait
pthread_mutexattr_init
pthread_mutexattr_settype
pthread_mutex_destroy
pthread_mutex_timedlock
pthread_mutex_trylockk
pthread_mutex_unlock
sem_getvalue
sem_timedwait
pthread_cond_timedwait
nanosleep
timer_create
timer_settime
timer_gettime
testStdlibStrtoull005
testStdlibStrtol011
testStdlibStrtoul007
testPthread004
新增接口:
CheckForCancel
pthread_setcancelstate
pthread_setcanceltype
pthread_once
pthread_setschedprio
pthread_attr_setstack
pthread_attr_getstack
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_condattr_getclock
pthread_mutexattr_gettype
CheckMutexAttr
OsMuxPreCheck
sem_trywait
MuxPendForPosix
MuxPostForPosix
增加overrun功能
接口变化:
mq_getsetattr 改为内部接口MqGetSetAttr
GetTickTimeFromNow->OsGetTickTimeFromNow
接口位置转移:
pthread_equal接口由newlib下转移到kal/posix/src/pthread.c中
* **posix:** 接口修改:
calloc
pthread_mutex_init
mq_unlink
pthread_join
pthread_exit
pthread_attr_init
pthread_attr_destroy
pthread_condattr_destroy
pthread_cond_timedwait
pthread_mutexattr_init
pthread_mutexattr_settype
pthread_mutex_destroy
pthread_mutex_timedlock
pthread_mutex_trylockk
pthread_mutex_unlock
sem_getvalue
新增接口:
CheckForCancel
pthread_setcancelstate
pthread_setcanceltype
pthread_once
pthread_setschedprio
pthread_attr_setstack
pthread_attr_getstack
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_condattr_getclock
pthread_mutexattr_gettype
CheckMutexAttr
OsMuxPreCheck
sem_trywait
接口变化:
mq_getsetattr 改为内部接口OsMqGetSetAttr
接口位置转移:
pthread_equal接口由newlib下转移到kal/posix/src/pthread.c中
* 新增接口:
LOS_HwiTrigger ArchIntTrigger
LOS_HwiEnable ArchIntEnable
LOS_HwiDisable ArchIntDisable
LOS_HwiClear ArchIntClear
LOS_HwiSetPriority ArchIntSetPriority
* Assembly implementation:
ArchAtomicRead
ArchAtomicSet
ArchAtomicAdd
ArchAtomicSub
ArchAtomicInc
ArchAtomicIncRet
ArchAtomicDec
ArchAtomicDecRet
* 原来版本中每个架构下提供的tick timer相关操作函数为弱函数
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler);
WEAK VOID HalSysTickReload(UINT64 nextResponseTime);
WEAK UINT64 HalGetTickCycle(UINT32 *period);
WEAK VOID HalTickLock(VOID);
WEAK VOID HalTickUnlock(VOID);
用户如果需要启用自己的tick timer需要自己实现相关接口(强属性),在 "内核初始化之前" 通过调用:
LOS_TickTimerRegister 接口替换系统默认提供的tick timer相关接口。
无论用户提供的tick timer 还是系统默认提供的,均在内核初始化时启动。
* int pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
int pthread_key_delete(pthread_key_t k)
int pthread_setspecific(pthread_key_t k, const void *x)
void *pthread_getspecific(pthread_key_t k)
* 1.修改arch/include下接口以ArchXX命名函数
2.提取公共函数声明:ArchAtomicXchg32bits、ArchAtomicDecRet、ArchAtomicCmpXchg32bits
3.新增部分原子操作c内联实现
* 增加低内存资源回收注册相关接口LOS_LmkOpsNodeRegister、LOS_LmkOpsNodeUnregister和内存资源释放和任务恢复接口LOS_LmkTasksKill和LOS_LmkTasksRestore.
* SwtmrHandlerItem结构体新增swtmrID字段用于标识超时队列中软件定时器id
* 新增支持API:
LOS_LmsCheckPoolAdd使能检测指定内存池
LOS_LmsCheckPoolDel不检测指定内存池
LOS_LmsAddrProtect为指定内存段上锁不允许访问
LOS_LmsAddrDisableProtect去能指定内存段的访问保护
# (2021-09-30)
### Bug Fixes
* M核代码告警清零 ([cb5f862](https://gitee.com/openharmony/kernel_liteos_m/commits/cb5f862eafd91675bf53d0320616cc8f707a6e5a)), closes [#I4386N](https://gitee.com/openharmony/kernel_liteos_m/issues/I4386N)
* M核告警消除 ([5a9d53b](https://gitee.com/openharmony/kernel_liteos_m/commits/5a9d53b6444a3bbe084f575ef079f0da36c27c2a)), closes [#I46LHG](https://gitee.com/openharmony/kernel_liteos_m/issues/I46LHG)
* M核编译配置修改 ([deff7c9](https://gitee.com/openharmony/kernel_liteos_m/commits/deff7c921f606ed85663f91d21c12163c15aa7f8)), closes [#I46XEA](https://gitee.com/openharmony/kernel_liteos_m/issues/I46XEA)
* shell模块task命令踩内存问题修改 ([b5e84d5](https://gitee.com/openharmony/kernel_liteos_m/commits/b5e84d5516b599257151f88b5a830d6fe9e0e188)), closes #II4
* trustzone 中断适配 ([15a2c17](https://gitee.com/openharmony/kernel_liteos_m/commits/15a2c17f791b7d6703863718d92fa35402c41067)), closes [#I42TFV](https://gitee.com/openharmony/kernel_liteos_m/issues/I42TFV)
* add API LOS_HwiCreate and LOS_HwDelete ([eb668eb](https://gitee.com/openharmony/kernel_liteos_m/commits/eb668eb9e0021961230858f9bfa1599646da9a8f)), closes [#I3R75F](https://gitee.com/openharmony/kernel_liteos_m/issues/I3R75F)
* add liteos_m vfs ([5479dd6](https://gitee.com/openharmony/kernel_liteos_m/commits/5479dd66d7ec96d2206a9890586fe5f07d50fbb9)), closes [#I3R493](https://gitee.com/openharmony/kernel_liteos_m/issues/I3R493)
* backtrace代码段判断函数定义成弱函数如果有多个代码段那么可根据实际情况重定义 ([8692ed3](https://gitee.com/openharmony/kernel_liteos_m/commits/8692ed33a3b975bac7aa5b6ce3c40a84e281f6c5)), closes [#I420PQ](https://gitee.com/openharmony/kernel_liteos_m/issues/I420PQ)
* change cpup retval range ([d00a35b](https://gitee.com/openharmony/kernel_liteos_m/commits/d00a35ba9288047e9eaba06a8ed1d15806bfca40))
* change description according to review ([a38365e](https://gitee.com/openharmony/kernel_liteos_m/commits/a38365ed097fb398f922a5d1a72305933ae3e7b3))
* change queuePosion to queuePosition ([e772ccb](https://gitee.com/openharmony/kernel_liteos_m/commits/e772ccb3ccd3b31269066fa59a434a23af98ce51))
* change to OpenHarmony LiteOS-M ([259fb54](https://gitee.com/openharmony/kernel_liteos_m/commits/259fb54b3c1a208c5672f1f6551ba0424505e4b2))
* comment error ([a37b73d](https://gitee.com/openharmony/kernel_liteos_m/commits/a37b73d7599a62a728dbf564de9d9927f995ec1b))
* compile warning fix ([8dea15c](https://gitee.com/openharmony/kernel_liteos_m/commits/8dea15c4fcaff2957c60351781180f964c0a882d)), closes #I4330
* compile warnings ([75f6187](https://gitee.com/openharmony/kernel_liteos_m/commits/75f61870a002e238385bc9a7632d42b0b2488c9a)), closes [#I3Y57X](https://gitee.com/openharmony/kernel_liteos_m/issues/I3Y57X)
* correct ECB in comment ([e2aeb1f](https://gitee.com/openharmony/kernel_liteos_m/commits/e2aeb1ff1d4cd54a752c9f6ef976ee8e353da620))
* correct spelling ([dd5cefb](https://gitee.com/openharmony/kernel_liteos_m/commits/dd5cefb0dace4b7a7276c880e45d5520950e9844))
* correct spelling ([e7ea50f](https://gitee.com/openharmony/kernel_liteos_m/commits/e7ea50f13142e34a9860e75be051538fe91e234e))
* correct the counter of exception type ([bff6587](https://gitee.com/openharmony/kernel_liteos_m/commits/bff65877a281ac1cdcbefd325dcd3ad4933edac9))
* correct typo ([3ceface](https://gitee.com/openharmony/kernel_liteos_m/commits/3ceface13e1c15d107bc3c8460c17b9dd4c95e26))
* cpup funciton repair ([c842251](https://gitee.com/openharmony/kernel_liteos_m/commits/c842251bab7ea6365f2bee8ae880e6efb60f0c73))
* delete unused symbols for default config ([7ad3a22](https://gitee.com/openharmony/kernel_liteos_m/commits/7ad3a22b4d62c8b00876ff338c4ce8d1e3f3cbe2)), closes [#I45HN3](https://gitee.com/openharmony/kernel_liteos_m/issues/I45HN3)
* fix __cplusplus typo ([c3eb3e5](https://gitee.com/openharmony/kernel_liteos_m/commits/c3eb3e59e692371f67a4e21e4b38004195ce5e10))
* fix backtrace check issue ([b6664e6](https://gitee.com/openharmony/kernel_liteos_m/commits/b6664e66f14d432b02101c883a53cb333dc4c195))
* fix bad params def in HalTickStart ([4443b74](https://gitee.com/openharmony/kernel_liteos_m/commits/4443b74ea63d2e458af69723a7198bbbaeb856ea)), closes [#I48YWT](https://gitee.com/openharmony/kernel_liteos_m/issues/I48YWT)
* fix comment typo issue ([0c2a675](https://gitee.com/openharmony/kernel_liteos_m/commits/0c2a675e2d163eaf05aff7df226404888d78ca37))
* fix destroy typo ([4ba6259](https://gitee.com/openharmony/kernel_liteos_m/commits/4ba6259e94bd677764922b0470fddc2590f6efa5))
* fix function name ([f7d50d0](https://gitee.com/openharmony/kernel_liteos_m/commits/f7d50d0fbf53cdd352e94a387cf707083f1641bb))
* fix length typo ([98d6580](https://gitee.com/openharmony/kernel_liteos_m/commits/98d65801de9e37199b5df9c8734ebcb6ff5d853d))
* fix LOS_MEMBOX_ALIGNED macro name ([fced899](https://gitee.com/openharmony/kernel_liteos_m/commits/fced8992cf4fbc26c9722d528d642a7afe479170))
* fix LOS_TaskNameGet comment ([c70b28b](https://gitee.com/openharmony/kernel_liteos_m/commits/c70b28bf785da12fd60ecc92a5a63fb54e52c22a))
* fix macro typo ([1600360](https://gitee.com/openharmony/kernel_liteos_m/commits/16003604a948d081151ca4fcf0cfeea91c9e1960))
* fix misspell in comments ([4572814](https://gitee.com/openharmony/kernel_liteos_m/commits/457281427ba286e24386d7916c4bc81f112f1c60))
* fix NULL UNUSED redefined issue ([765bd55](https://gitee.com/openharmony/kernel_liteos_m/commits/765bd551990e906f457ec1145aea4f2bf5856547))
* fix OS_TASK_STACK_PROTECT_SIZE undeclared error ([2a5a515](https://gitee.com/openharmony/kernel_liteos_m/commits/2a5a515f50a0f344d416218046bf0880facfb97c)), closes [#I4C5RW](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C5RW)
* fix print format compilation warning ([ef12c89](https://gitee.com/openharmony/kernel_liteos_m/commits/ef12c89c7a79791665125a0b7391f9e533a06a0f))
* fix readme link issue ([9e332c6](https://gitee.com/openharmony/kernel_liteos_m/commits/9e332c69a5813027575786424b78f0ae2f9a4c5a))
* fix some typo issues ([f6b8cab](https://gitee.com/openharmony/kernel_liteos_m/commits/f6b8cab2539e4d1ee9e47ab8e3eb12f1630f7393))
* fix typo in comment ([811d3fa](https://gitee.com/openharmony/kernel_liteos_m/commits/811d3fae8a39686a1c66dfd61c897b7fd3fac2ac))
* fix typos ([191644e](https://gitee.com/openharmony/kernel_liteos_m/commits/191644e4412fccb7142cfcd34316ad8e2d24fcdf))
* Fixed a spelling error in FS_LOCK_TIMEOUT_SEC. ([42dc308](https://gitee.com/openharmony/kernel_liteos_m/commits/42dc3083693be13c5fa8f2ad8213245465e28adf)), closes [#I3TL66](https://gitee.com/openharmony/kernel_liteos_m/issues/I3TL66)
* include file log_config.h in los_mpu.c ([1932d71](https://gitee.com/openharmony/kernel_liteos_m/commits/1932d714a589c9e87258d7c8ed647b6110bde543))
* L0 GN compilation problem ([2f9bfcc](https://gitee.com/openharmony/kernel_liteos_m/commits/2f9bfcc6ee436ee3568d0c8158a8e43c9ef02623)), closes [I3ORHS](https://gitee.com/openharmony/kernel_liteos_m/issues/I3ORHS)
* l0 shell adapt new master ([fd2227e](https://gitee.com/openharmony/kernel_liteos_m/commits/fd2227e5c858c840f63629c27e559580e1cbdf2f))
* littlefs inappropriate return value and errno ([452f364](https://gitee.com/openharmony/kernel_liteos_m/commits/452f36403dd4376572d8b52352d0d8129a4617e4)), closes [I3YIVT](https://gitee.com/openharmony/kernel_liteos_m/issues/I3YIVT)
* littlefs三方源码采用GN编译修改上库 ([bdb614b](https://gitee.com/openharmony/kernel_liteos_m/commits/bdb614bc2b82011d77c7c8ffb95e415d2640d19d))
* LOS_QueueInfoGet函数统计等待读写任务有误 ([215a1f6](https://gitee.com/openharmony/kernel_liteos_m/commits/215a1f6dc06cf2348c5875f7b05193b26ec17dde)), closes [#I4C6P2](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C6P2)
* los_swtmr.h不满足自包含要求对los_config.h存在依赖但未包含los_config.h ([ad8e96a](https://gitee.com/openharmony/kernel_liteos_m/commits/ad8e96a00f2fcaebe57feae4e3f23f99d7f1d066)), closes [#I40DHM](https://gitee.com/openharmony/kernel_liteos_m/issues/I40DHM)
* **mbedtls:** mbedtls l0 support ([761b860](https://gitee.com/openharmony/kernel_liteos_m/commits/761b86096c3cf5642c95e556c11a45a3d5f413e4))
* misspell ([30578a6](https://gitee.com/openharmony/kernel_liteos_m/commits/30578a6a68a0d3a203b9a00e7bd1a946356d13d2))
* modify event API description ([9481f1d](https://gitee.com/openharmony/kernel_liteos_m/commits/9481f1d8406960b8b859cc5a84b3831eadaf040c))
* modify the return type of LOS_IntLock from UINTPTR to UINT32. ([bcc34e2](https://gitee.com/openharmony/kernel_liteos_m/commits/bcc34e22ede5aeccea63aba9f9ce3cb9aa92cbeb))
* modify type INLNIE ([294a6d2](https://gitee.com/openharmony/kernel_liteos_m/commits/294a6d246b6a1f7cba8ce1bc4eeb9ae11f17a003))
* Mutex锁释放后无任务持有的情况下owner未清空 ([c136cfd](https://gitee.com/openharmony/kernel_liteos_m/commits/c136cfdf973ae0068154606afa3a23858822c347)), closes [#I40OC8](https://gitee.com/openharmony/kernel_liteos_m/issues/I40OC8)
* M核littlefs当文件open失败时需要回收fd否则会有fd泄露 ([b458e12](https://gitee.com/openharmony/kernel_liteos_m/commits/b458e12ed54905db6667f9d5db1410f94a3d6c71)), closes [#I3XU6R](https://gitee.com/openharmony/kernel_liteos_m/issues/I3XU6R)
* m核上littlefs新增错误码功能 ([a062378](https://gitee.com/openharmony/kernel_liteos_m/commits/a06237863121816fa6421aed233446a3fa4e2665)), closes [#I3UVMQ](https://gitee.com/openharmony/kernel_liteos_m/issues/#I3UVMQ)
* net compile fix ([299813c](https://gitee.com/openharmony/kernel_liteos_m/commits/299813cdb43ae1e24200f0a6b006e04e4d4fcb05))
* open shell & fix qemu compile ([911a767](https://gitee.com/openharmony/kernel_liteos_m/commits/911a767992ee540a96ee9f67e0b87195656c3eab))
* ping cmd compile fail ([ae05de3](https://gitee.com/openharmony/kernel_liteos_m/commits/ae05de3ffda86d312d33b2e38f237dd76daf4949))
* protect from accssing NULL pointer, access g_handle after fslock ([bc7a914](https://gitee.com/openharmony/kernel_liteos_m/commits/bc7a914bce1b227a4f57265d5ecc3f82d78533e7)), closes [#I3UCX3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3UCX3)
* remove changelog in README ([37ef8ca](https://gitee.com/openharmony/kernel_liteos_m/commits/37ef8ca7ae73bf78f56dfef36c48bcd790afb6ff)), closes [#I3ZECY](https://gitee.com/openharmony/kernel_liteos_m/issues/I3ZECY)
* remove libsec_kernel ([1144b75](https://gitee.com/openharmony/kernel_liteos_m/commits/1144b75f3ff9ce9e8fa114cf614d3deade8ac7c2))
* remove project files ([4ad01ce](https://gitee.com/openharmony/kernel_liteos_m/commits/4ad01ced93684e5c7ba144ca267f8fcc2fe03105))
* remove targets project files ([f39da5a](https://gitee.com/openharmony/kernel_liteos_m/commits/f39da5a6da59a3b1291c6b9ef7c50e6185df5ea1))
* risc-v 锁中断在调度后失效 ([70f3aa1](https://gitee.com/openharmony/kernel_liteos_m/commits/70f3aa1c112e949d9af8e0245af5879140adefba)), closes [#I42OLJ](https://gitee.com/openharmony/kernel_liteos_m/issues/I42OLJ)
* riscv_nuclei 编译失败 ([d3fb23c](https://gitee.com/openharmony/kernel_liteos_m/commits/d3fb23cca06580b6e447a9476a9c16643c4ea8fe)), closes [#I41PQJ](https://gitee.com/openharmony/kernel_liteos_m/issues/I41PQJ)
* rollback resources when opendir failed ([82fad6c](https://gitee.com/openharmony/kernel_liteos_m/commits/82fad6c36f183de93d936dd2007b899c2932bcee)), closes [#I3Y577](https://gitee.com/openharmony/kernel_liteos_m/issues/I3Y577)
* Scheduling module code to join GN compilation. ([8bf166b](https://gitee.com/openharmony/kernel_liteos_m/commits/8bf166b418ce1a6c027dc304d45fc9431923764c)), closes [#I3OA95](https://gitee.com/openharmony/kernel_liteos_m/issues/I3OA95)
* The hook module fails to compile under the c99 compilation standard. ([a078c30](https://gitee.com/openharmony/kernel_liteos_m/commits/a078c3086fa47e05e3ffdc4e94ca202284a1487b)), closes [#I3S4ME](https://gitee.com/openharmony/kernel_liteos_m/issues/I3S4ME)
* tick 动态化计算优化,减小中断执行时间对系统总体时间的影响,保证软件定时器的响应精度。 ([2118c84](https://gitee.com/openharmony/kernel_liteos_m/commits/2118c84616cce5b5d4569d5a82a4d5de02af1e1c)), closes [#I3YGP1](https://gitee.com/openharmony/kernel_liteos_m/issues/I3YGP1)
* timer qemu 头文件缺失 ([12fed74](https://gitee.com/openharmony/kernel_liteos_m/commits/12fed747226c377c656b8acb8346154627845b6f))
* update according to review comments ([4dc0d31](https://gitee.com/openharmony/kernel_liteos_m/commits/4dc0d313d1b4a39ebb62156d0bb6429ebb8b996d))
* update arch_spec.md ([cf43988](https://gitee.com/openharmony/kernel_liteos_m/commits/cf439885234e0955bab09834b3b876d627c81605))
* update doc usage ([5c19fd4](https://gitee.com/openharmony/kernel_liteos_m/commits/5c19fd4beca15a8b7faad847a13943a9abfe3c8c))
* update document description ([954c2fc](https://gitee.com/openharmony/kernel_liteos_m/commits/954c2fcfb531d0da1dcc6354a0c0b14335566ed7))
* update macro to config item ([be57ece](https://gitee.com/openharmony/kernel_liteos_m/commits/be57ece9ce6200c8868164bc0bb2f26e3062cd37))
* 以g_sysSchedStartTime是否为0判断时间轴是否生效存在极限场景导致调度时间不生效 ([509cf59](https://gitee.com/openharmony/kernel_liteos_m/commits/509cf59befb40839a376be31958d615f066c66fd)), closes [#I45HP5](https://gitee.com/openharmony/kernel_liteos_m/issues/I45HP5)
* 修复littlefs的多分区挂载时对pathname的处理逻辑异常 ([b55cfc1](https://gitee.com/openharmony/kernel_liteos_m/commits/b55cfc1ba7fc470b876c555ac7d3be0aa1d3d363)), closes [#I3WWFA](https://gitee.com/openharmony/kernel_liteos_m/issues/I3WWFA)
* 修复littlefs编译fs.c缺少头文件件依赖配置+若干musl库的缺失问题+多分区规格宏配置问题 ([7259289](https://gitee.com/openharmony/kernel_liteos_m/commits/7259289bd98a743f596060bc607f77ab8f149129)), closes [#I3VT11](https://gitee.com/openharmony/kernel_liteos_m/issues/I3VT11)
* 修复M核littlefs GN编译的若干错误 ([d77828e](https://gitee.com/openharmony/kernel_liteos_m/commits/d77828e206f3324424c3b1372332828a0afb84c2))
* 修复M核上musl库缺失strdup,c的问题 ([139f83a](https://gitee.com/openharmony/kernel_liteos_m/commits/139f83af391a4f5e64ab0fccbd783dd651b87e6a)), closes [#I3VZSI](https://gitee.com/openharmony/kernel_liteos_m/issues/I3VZSI)
* 修复QUEUE_INFO_S中waitReadTask无法保存大于32的任务编号 ([704cca9](https://gitee.com/openharmony/kernel_liteos_m/commits/704cca97b17972d1640fd33b1fa0b5917bb92b19)), closes [#I41N78](https://gitee.com/openharmony/kernel_liteos_m/issues/I41N78)
* 修复task命令格式错误增加copyright ([ad15bbd](https://gitee.com/openharmony/kernel_liteos_m/commits/ad15bbd6a4d298aabc05b26d7838de6425dbc5c5))
* 修复timer_settime只设置第一次到期时间时到期时间不准的缺陷 ([a5f4e37](https://gitee.com/openharmony/kernel_liteos_m/commits/a5f4e37e535bff39a333c469e2f1bf1817216fe8)), closes [#I3TCHA](https://gitee.com/openharmony/kernel_liteos_m/issues/I3TCHA)
* 修复timer_settime只设置第一次到期时间时到期时间不准的缺陷 ([e4b5d4e](https://gitee.com/openharmony/kernel_liteos_m/commits/e4b5d4ebe9677d49d490fe74e5ac33c4a29435a2)), closes [#I3TCHA](https://gitee.com/openharmony/kernel_liteos_m/issues/I3TCHA)
* 修复不规范的copyright ([2d9bbd2](https://gitee.com/openharmony/kernel_liteos_m/commits/2d9bbd2769e71e7b464bd22fc335999dd8000682)), closes [#I3SPJ1](https://gitee.com/openharmony/kernel_liteos_m/issues/I3SPJ1)
* 修复中断操作接口头文件位置变更,导致的编译错误 ([013a953](https://gitee.com/openharmony/kernel_liteos_m/commits/013a953926ca7cefd8a2f7c74d23c36c49765b59)), closes [#I4665Z](https://gitee.com/openharmony/kernel_liteos_m/issues/I4665Z)
* 修复文档链接失效问题 ([5d53c84](https://gitee.com/openharmony/kernel_liteos_m/commits/5d53c848124319a95f509b56ba001357c6dd8b05)), closes [#I4529I](https://gitee.com/openharmony/kernel_liteos_m/issues/I4529I)
* 内核模块编译增加-Werror编译选项且清除内核编译告警 ([3798091](https://gitee.com/openharmony/kernel_liteos_m/commits/3798091d87441ea445ec642de57e036dbbc8370e)), closes [#I46E6S](https://gitee.com/openharmony/kernel_liteos_m/issues/I46E6S)
* 删除MQ内冗余的重复宏定义 ([6d72916](https://gitee.com/openharmony/kernel_liteos_m/commits/6d7291660ad04682f05850876f81dfd0cba8ea6b)), closes [#I3U5QQ](https://gitee.com/openharmony/kernel_liteos_m/issues/I3U5QQ)
* 删除延时节点后,存在时间无法有效刷新的场景 ([0a87c04](https://gitee.com/openharmony/kernel_liteos_m/commits/0a87c04d58d11da2082470698de0760d72259533)), closes [#I45I9Y](https://gitee.com/openharmony/kernel_liteos_m/issues/I45I9Y)
* 在内核初始化前期启动tick timer ([b3841ed](https://gitee.com/openharmony/kernel_liteos_m/commits/b3841ed1ddbfb3359c7a0ceca04fc0f645d440c3)), closes [#I410F0](https://gitee.com/openharmony/kernel_liteos_m/issues/I410F0)
* 增加MPU功能的开关宏默认关闭 ([9709d29](https://gitee.com/openharmony/kernel_liteos_m/commits/9709d29b87a3888412ffda586e16eba86adccfe7)), closes [#I3WE0S](https://gitee.com/openharmony/kernel_liteos_m/issues/I3WE0S)
* 宏LOSCFG_SUPPORT_FATFS在fs.c中存在使用问题导致无fatfs的情况下编译出错 ([c1614ce](https://gitee.com/openharmony/kernel_liteos_m/commits/c1614ce2b4d4dfcda9532cbeeff25ad7a6558196)), closes [#I44XNR](https://gitee.com/openharmony/kernel_liteos_m/issues/I44XNR)
* 延时队列为NULL时返回的响应时间为64位最大值导致无法更新tick timer的响应周期 ([bcec32e](https://gitee.com/openharmony/kernel_liteos_m/commits/bcec32e389634097102a203ee7e937ed3193c984)), closes [#I3W1LF](https://gitee.com/openharmony/kernel_liteos_m/issues/I3W1LF)
* 支持smoke 测试用例 ([3ad5942](https://gitee.com/openharmony/kernel_liteos_m/commits/3ad5942301a1094a2c6b6ffee280cf09cfdb2a88)), closes [#I424RX](https://gitee.com/openharmony/kernel_liteos_m/issues/I424RX)
* 新增函数regcomp,regfree和regexec支持 ([86d5544](https://gitee.com/openharmony/kernel_liteos_m/commits/86d5544a3fd5f41f7f2abe3b143e9f1dc9b430f8)), closes [#I3U9LE](https://gitee.com/openharmony/kernel_liteos_m/issues/I3U9LE)
* 清理残留无效的trace代码 ([3c48951](https://gitee.com/openharmony/kernel_liteos_m/commits/3c489518576583ab6bf0d581810ef0a02b6ccd51)), closes [#I3ZMB4](https://gitee.com/openharmony/kernel_liteos_m/issues/I3ZMB4)
* 解决arm9编译冲突问题 ([c1a6245](https://gitee.com/openharmony/kernel_liteos_m/commits/c1a624536887fef44fed37134638bf40191b9aae)), closes [#I420PQ](https://gitee.com/openharmony/kernel_liteos_m/issues/I420PQ)
* 调度过程低概率触发OsSchedTaskEnQueue断言导致系统异常 ([e5e9289](https://gitee.com/openharmony/kernel_liteos_m/commits/e5e9289a08cf1db71c09647b71a864f5a1f8a4a2)), closes [#I3VX9Y](https://gitee.com/openharmony/kernel_liteos_m/issues/I3VX9Y)
* 调整hook类型和位置方便调试 ([369320d](https://gitee.com/openharmony/kernel_liteos_m/commits/369320de3710486f252c55c522e8c06e19541b77)), closes [#I3TGZS](https://gitee.com/openharmony/kernel_liteos_m/issues/I3TGZS)
### Features
* add cmsis ThreadFlags support ([cea551e](https://gitee.com/openharmony/kernel_liteos_m/commits/cea551e99ea0da8eefbaa826de2f68813252fb83))
* add deps to musl and securec ([bfa25fc](https://gitee.com/openharmony/kernel_liteos_m/commits/bfa25fcaa355c28a6139f683c4453f677e23abd7))
* add file type support for LfsStat ([ceaed2d](https://gitee.com/openharmony/kernel_liteos_m/commits/ceaed2dc86de2ed242aab4dd02c1f34e064583b3)), closes [#I3ZCDR](https://gitee.com/openharmony/kernel_liteos_m/issues/I3ZCDR)
* add interface of dhcp_is_bound ([84a180d](https://gitee.com/openharmony/kernel_liteos_m/commits/84a180d585686cda693bf8c6ed6b86f7c5dd5eee)), closes [#I46W08](https://gitee.com/openharmony/kernel_liteos_m/issues/I46W08)
* add L0 shell function ([97283b7](https://gitee.com/openharmony/kernel_liteos_m/commits/97283b7c5dd44b266e94fcf0f5d21e63ee1ec7e0))
* add LOS_ListHeadInsert function ([430b186](https://gitee.com/openharmony/kernel_liteos_m/commits/430b186be7ec1554a29a6d509188eb877d796a7e)), closes [#I3TAQA](https://gitee.com/openharmony/kernel_liteos_m/issues/I3TAQA)
* **kernel:** 补充获取最高、最低优先级接口 ([c24c38b](https://gitee.com/openharmony/kernel_liteos_m/commits/c24c38b084c13a2cdc5616f88bb5f63153600c28)), closes [#I42HM7](https://gitee.com/openharmony/kernel_liteos_m/issues/I42HM7)
* L0 armquem 剥离工具链 ([67d7455](https://gitee.com/openharmony/kernel_liteos_m/commits/67d74559d1bb3820bd51da2e2bf43e41e1224314))
* L0 支持Trace ([56c93a6](https://gitee.com/openharmony/kernel_liteos_m/commits/56c93a641b3c7a3d1ef9293ee3c95cccb559191f)), closes [#I41Y9Y](https://gitee.com/openharmony/kernel_liteos_m/issues/I41Y9Y)
* L0 支持低功耗框架 ([558ce14](https://gitee.com/openharmony/kernel_liteos_m/commits/558ce14becab05102497afca90a43d89abaf5531)), closes [#I3UDNV](https://gitee.com/openharmony/kernel_liteos_m/issues/I3UDNV)
* L0 测试用例支持risc-v qemu 编译运行 ([2dd6c08](https://gitee.com/openharmony/kernel_liteos_m/commits/2dd6c080daab52eaf61e5eefe7b581190670e8a7)), closes [#I3YILG](https://gitee.com/openharmony/kernel_liteos_m/issues/I3YILG)
* **liteos_m:** support backtrace for riscv ([ca1792a](https://gitee.com/openharmony/kernel_liteos_m/commits/ca1792aa4b5a85ca4ea6e41b265858c6b24a6897)), closes [#I3RVXY](https://gitee.com/openharmony/kernel_liteos_m/issues/I3RVXY)
* los_memory.c代码重复率处理 ([475db62](https://gitee.com/openharmony/kernel_liteos_m/commits/475db62db1ac285fc6cab91f09af618870269580)), closes [#I44WNU](https://gitee.com/openharmony/kernel_liteos_m/issues/I44WNU)
* M33平台支持GCC环境的Trustzone ([d469da2](https://gitee.com/openharmony/kernel_liteos_m/commits/d469da29c6d316640eaa7865f98ad8d6e2eb6d44)), closes [#I3Y85I](https://gitee.com/openharmony/kernel_liteos_m/issues/I3Y85I)
* provide getifaddrs for liteos_m ([948501a](https://gitee.com/openharmony/kernel_liteos_m/commits/948501ac73e7887f4585eca156ad760acc2a3b1f)), closes [#I400S5](https://gitee.com/openharmony/kernel_liteos_m/issues/I400S5)
* risc-v gn 编译框架添加汇编编译选项 ([76dc343](https://gitee.com/openharmony/kernel_liteos_m/commits/76dc343c888ec4e65eba43feb49921111b144640)), closes [#I3YS5Y](https://gitee.com/openharmony/kernel_liteos_m/issues/I3YS5Y)
* Support arm9 ([6d7c9df](https://gitee.com/openharmony/kernel_liteos_m/commits/6d7c9dfe597affb260e8bd74fa606b6d68c2b49a)), closes [#I3WLCN](https://gitee.com/openharmony/kernel_liteos_m/issues/I3WLCN)
* Support arm9 fiq swi mode and using system mode. ([97b5b08](https://gitee.com/openharmony/kernel_liteos_m/commits/97b5b0837be4b8df1381af29a6f650f243322840)), closes [#I3WLCN](https://gitee.com/openharmony/kernel_liteos_m/issues/I3WLCN)
* support non-continuous memory regions ([0facb0c](https://gitee.com/openharmony/kernel_liteos_m/commits/0facb0c0179f29a08b037655bbe691c98384dc84)), closes [#I43XOP](https://gitee.com/openharmony/kernel_liteos_m/issues/I43XOP)
* 完善m核qemu串口驱动支持shell输入 ([c4dc5ab](https://gitee.com/openharmony/kernel_liteos_m/commits/c4dc5ab0f8b5caae55efdbedf59ab07f5006f6c2)), closes [#I46N7F](https://gitee.com/openharmony/kernel_liteos_m/issues/I46N7F)
* 按任务统计已经alloc的内存大小 ([53117f9](https://gitee.com/openharmony/kernel_liteos_m/commits/53117f9f47a8dd3023e83dc0cc0de224eab9719f)), closes [#I44WNU](https://gitee.com/openharmony/kernel_liteos_m/issues/I44WNU)
* 支持native动态加载组件 ([d753834](https://gitee.com/openharmony/kernel_liteos_m/commits/d75383400efe5d9ca0ae4093e4f2e65fee03024b)), closes [#I418HJ](https://gitee.com/openharmony/kernel_liteos_m/issues/I418HJ)
* 新增LOSCFG_BASE_CORE_TSK_SWITCH_HOOK 宏定义配置 ([39efd6f](https://gitee.com/openharmony/kernel_liteos_m/commits/39efd6fb30ee7dc9159811f5d37dffcdfe81bae0)), closes [#I40Q9O](https://gitee.com/openharmony/kernel_liteos_m/issues/I40Q9O)
* 新增ROM/RAM分析工具 ([ee3403d](https://gitee.com/openharmony/kernel_liteos_m/commits/ee3403deaf24dc612b51354f31f795fb0b9a49b5))
* 补充fs相关函数用例 ([2a95af5](https://gitee.com/openharmony/kernel_liteos_m/commits/2a95af5bf1b412de27b4518d0abf7c335366d4d7)), closes [#I3UQ4F](https://gitee.com/openharmony/kernel_liteos_m/issues/I3UQ4F)
* 解决fclose等函数工具链重定义问题 ([b244ad4](https://gitee.com/openharmony/kernel_liteos_m/commits/b244ad4ad0da8d151b69071fdd6db808c91f85a5)), closes [#I3UG6O](https://gitee.com/openharmony/kernel_liteos_m/issues/I3UG6O)
### BREAKING CHANGES
* 新增4个对外接口声明在los_dynlink.h文件中分别为
(1) LOS_DynlinkInit: 动态加载模块初始化。
(2) LOS_SoLoad: 加载指定路径的共享库。
(3) LOS_FindSym: 根据共享库句柄查找指定符号。
(4) LOS_SoUnload: 卸载共享库。
* 1.新增一系列trace的对外API位于los_trace.h中.
LOS_TRACE_EASY简易插桩
LOS_TRACE标准插桩
LOS_TraceInit配置Trace缓冲区的地址和大小
LOS_TraceStart开启事件记录
LOS_TraceStop停止事件记录
LOS_TraceRecordDump输出Trace缓冲区数据
LOS_TraceRecordGet获取Trace缓冲区的首地址
LOS_TraceReset清除Trace缓冲区中的事件
LOS_TraceEventMaskSet设置事件掩码仅记录某些模块的事件
LOS_TraceHwiFilterHookReg注册过滤特定中断号事件的钩子函数
* 1.原调度中基于tick timer的低功耗扩展和当前的pm模块合并删除原对外接口LOS_SchedSleepInit,
 变为pm模块统一提供的LOS_PmRegistered接口.
2.原来在arch los_timer.h下提供的低功耗模式为枚举LOS_SysSleepEnum其中OS_SYS_NORMAL_SLEEP
和OS_SYS_DEEP_SLEEP不符合对外定义统一修改为LOS_SYS_NORMAL_SLEEP和LOS_SYS_DEEP_SLEEP,
并移至los_pm.h中.
3.VOID HalEnterSleep(LOS_SysSleepEnum sleep) 变更为UINT32 HalEnterSleep(VOID).

170
Kconfig
View File

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

View File

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

View File

@ -35,7 +35,7 @@ The directory structure is as follows. For more details, see [arch_spec.md](arch
│ ├── include # APIs exposed externally │ ├── include # APIs exposed externally
│ ├── risc-v # Code of the risc-v architecture │ ├── risc-v # Code of the risc-v architecture
│ │ ├── nuclei # Code of the nuclei system technology risc-v architecture │ │ ├── nuclei # Code of the nuclei system technology risc-v architecture
│ │ └── riscv32 # Code of the risc-v architecture │ │ └── riscv32 # Code of the risc-v official common architecture
│ └── xtensa # Code of the xtensa architecture │ └── xtensa # Code of the xtensa architecture
│ └── lx6 # Code of the lx6 xtensa architecture │ └── lx6 # Code of the lx6 xtensa architecture
├── components # Optional components ├── components # Optional components
@ -78,7 +78,7 @@ The OpenHarmony LiteOS-M kernel build system is a modular build system based on
### Setting Up the Environment ### Setting Up the Environment
Before setting up the environment for a development board, you must set up the basic system environment for OpenHarmony first. The basic system environment includes the OpenHarmony build environment and development environment. For details, see [Setting Up Development Environment](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/quick-start/quickstart-lite-env-setup.md). Before setting up the environment for a development board, you must set up the basic system environment for OpenHarmony first. The basic system environment includes the OpenHarmony build environment and development environment. For details, see [Setting Up Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/Readme-EN.md).
### Obtaining the OpenHarmony Source Code ### Obtaining the OpenHarmony Source Code
@ -108,7 +108,7 @@ The LiteOS-M kernel porting projects for specific development boards are provide
## Contribution<a name="section1371123476307"></a> ## Contribution<a name="section1371123476307"></a>
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution.md) [How to involve](https://gitee.com/openharmony/docs/blob/master/en/contribute/how-to-contribute.md)
[Commit message spec](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83) [Commit message spec](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)
@ -116,12 +116,10 @@ The LiteOS-M kernel porting projects for specific development boards are provide
How to contribute a chip based on Liteos-M kernel: How to contribute a chip based on Liteos-M kernel:
[ Board-Level Directory Specifications](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/porting/porting-chip-board-overview.md) [Mini System SoC Porting Guide](https://gitee.com/openharmony/docs/blob/master/en/device-dev/porting/Readme-EN.md)
[Mini System SoC Porting Guide](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/porting/porting-minichip.md)
## Repositories Involved<a name="section1371113476307"></a> ## Repositories Involved<a name="section1371113476307"></a>
[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md) [Kernel Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/kernel.md)
[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md) [kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md)

View File

@ -11,7 +11,7 @@
OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系统内核具有小体积、低功耗、高性能的特点其代码结构简单主要包括内核最小功能集、内核抽象层、可选组件以及工程目录等分为硬件相关层以及硬件无关层硬件相关层提供统一的HALHardware Abstraction Layer接口提升硬件易适配性不同编译工具链和芯片架构的组合分类满足AIoT类型丰富的硬件和编译工具链的拓展。其架构图如图1所示 OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系统内核具有小体积、低功耗、高性能的特点其代码结构简单主要包括内核最小功能集、内核抽象层、可选组件以及工程目录等分为硬件相关层以及硬件无关层硬件相关层提供统一的HALHardware Abstraction Layer接口提升硬件易适配性不同编译工具链和芯片架构的组合分类满足AIoT类型丰富的硬件和编译工具链的拓展。其架构图如图1所示
**图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a> **图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
![](figures/OpenHarmony-LiteOS-M核内核架构图.png "OpenHarmony-LiteOS-M核内核架构图") ![](figures/OpenHarmony-LiteOS-M核内核架构图.png "OpenHarmony-LiteOS-M核内核架构图")
## 目录<a name="section161941989596"></a> ## 目录<a name="section161941989596"></a>
@ -77,7 +77,7 @@ LiteOS-M内核的编译构建系统是一个基于gn和ninja的组件化构建
### 搭建系统基础环境 ### 搭建系统基础环境
在搭建各个开发板环境前需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境详细介绍请参考官方站点[开发环境准备](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md)。开发者需要根据环境搭建文档完成环境搭建。 在搭建各个开发板环境前需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境详细介绍请参考官方站点[开发环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md)。开发者需要根据环境搭建文档完成环境搭建。
### 获取OpenHarmony源码 ### 获取OpenHarmony源码
@ -115,11 +115,7 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供可以
如何基于Liteos-M内核贡献一款芯片: 如何基于Liteos-M内核贡献一款芯片:
[板级目录规范](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/porting/porting-chip-board-overview.md) [轻量系统芯片移植指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/Readme-CN.md)
[轻量系统芯片移植指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/porting-minichip.md)
[轻量系统芯片移植案例](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/porting-minichip-cases.md)
## 相关仓<a name="section1371113476307"></a> ## 相关仓<a name="section1371113476307"></a>

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without modification, # Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met: # are permitted provided that the following conditions are met:
@ -27,13 +26,14 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if LIBC_MUSL import("//kernel/liteos_m/liteos.gni")
config LIBC_MUSL_FS module_name = "common"
bool "Enable POSIX file system API support" kernel_module(module_name) {
default y sources = [ "los_common_interrupt.c" ]
depends on FS_VFS configs += [ "$LITEOSTOPDIR:warn_config" ]
help }
This enables POSIX style file system related APIs.
endif # LIBC_MUSL config("public") {
include_dirs = [ "." ]
}

View File

@ -0,0 +1,324 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_arch_interrupt.h"
#include "los_debug.h"
#ifdef __ICCARM__
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#endif
VOID *ArchGetHwiFrom(VOID)
{
return g_hwiForm;
}
UINT32 g_intCount = 0;
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, ArchIntCurIrqNum());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsHwiIsCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->triggerIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->triggerIrq(hwiNum);
}
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->enableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->enableIrq(hwiNum);
}
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->disableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->disableIrq(hwiNum);
}
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->clearIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->clearIrq(hwiNum);
}
UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->setIrqPriority == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->setIrqPriority(hwiNum, priority);
}
UINT32 ArchIntCurIrqNum(VOID)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
return hwiOps->getCurIrqNum();
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode, HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->createIrq == NULL) {
LOS_IntRestore(intSave);
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
hwiOps->createIrq(hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
ArchIntDisable((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
INLINE UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_COMMON_INTERRUPT_H
#define _LOS_COMMON_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_error.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(VOID);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
extern HWI_HANDLER_FUNC g_hwiHandlerForm[];
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern HWI_PROC_FUNC g_hwiHandlerForm[];
#endif
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
VOID HalPreInterruptHandler(UINT32 arg);
VOID HalAftInterruptHandler(UINT32 arg);
VOID *ArchGetHwiFrom(VOID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_COMMON_INTERRUPT_H */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -31,9 +31,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_config.h" #include "los_common_interrupt.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -41,14 +39,6 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt. * Highest priority of a hardware interrupt.
@ -65,18 +55,11 @@ extern "C" {
#define OS_HWI_PRIO_LOWEST 7 #define OS_HWI_PRIO_LOWEST 7
#endif #endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Count of interrupts. * AIRCR register priority group parameter .
*/ */
extern UINT32 g_intCount; #define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -90,12 +73,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM) #define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_arch_interrupt
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number. * Hardware interrupt error code: Invalid interrupt number.
@ -103,7 +80,7 @@ extern UINT32 g_intCount;
* Value: 0x02000900 * Value: 0x02000900
* *
* Solution: Ensure that the interrupt number is valid. * Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. * The value range of the interrupt number applicable for a Cortex-M55 platformis [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/ */
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00) #define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@ -154,7 +131,7 @@ extern UINT32 g_intCount;
* Value: 0x02000905 * Value: 0x02000905
* *
* Solution: Ensure that the interrupt priority is valid. * Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15]. * The value range of the interrupt priority applicable for a Cortex-M55 platform is [0,15].
*/ */
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05) #define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@ -179,6 +156,16 @@ extern UINT32 g_intCount;
*/ */
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07) #define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* SysTick control and status register. * SysTick control and status register.
@ -305,20 +292,6 @@ extern UINT32 g_intCount;
*/ */
#define OS_EXC_SYS_TICK 15 #define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function. * @brief: Hardware interrupt entry function.
@ -338,25 +311,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/ */
extern VOID HalInterrupt(VOID); extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* * /* *
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* @brief: Reset the vector table. * @brief: Reset the vector table.
@ -396,34 +350,20 @@ extern VOID Reset_Handler(VOID);
*/ */
extern VOID HalPendSV(VOID); extern VOID HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25 #define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1 #define OS_EXC_MAX_NEST_DEPTH 1
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_NVIC_SHCSR 0xE000ED24 #define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14 #define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20 #define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0 #define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC #define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4 #define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4 #define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE #define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE #define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/** /**
* @ingroup los_exc * @ingroup los_exc
* the struct of register files * the struct of register files
@ -496,7 +436,6 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *); typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr); VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID); VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID); VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID); VOID HalExcMemFault(VOID);
@ -654,7 +593,7 @@ VOID HalHwiInit(VOID);
* @ingroup los_exc * @ingroup los_exc
* Exception information structure * Exception information structure
* *
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform. * Description: Exception information saved when an exception is triggered on the Cortex-M55 platform.
* *
*/ */
typedef struct TagExcInfo { typedef struct TagExcInfo {
@ -677,10 +616,9 @@ typedef struct TagExcInfo {
EXC_CONTEXT_S *context; EXC_CONTEXT_S *context;
} ExcInfo; } ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo; extern ExcInfo g_excInfo;
extern UINT32 g_curNestCount;
extern UINT8 g_uwExcTbl[32];
#define MAX_INT_INFO_SIZE (8 + 0x164) #define MAX_INT_INFO_SIZE (8 + 0x164)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,47 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2024 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_name = "arch"
kernel_module(module_name) {
sources = [
"los_context.c",
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_mpu.c",
"los_timer.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. # Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without modification, # Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met: # are permitted provided that the following conditions are met:
@ -27,13 +26,14 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if LIBC_NEWLIB import("//kernel/liteos_m/liteos.gni")
config LIBC_NEWLIB_FS module_name = "common"
bool "Enable POSIX file system API support" kernel_module(module_name) {
default y sources = [ "los_common_interrupt.c" ]
depends on FS_VFS configs += [ "$LITEOSTOPDIR:warn_config" ]
help }
This enables POSIX style file system related APIs.
endif # LIBC_NEWLIB config("public") {
include_dirs = [ "." ]
}

View File

@ -0,0 +1,285 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_arch_interrupt.h"
#include "los_debug.h"
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
HWI_PROC_FUNC __attribute__((aligned(HWI_ALIGNSIZE))) g_hwiForm[OS_VECTOR_CNT] = {0};
VOID *ArchGetHwiFrom(VOID)
{
return g_hwiForm;
}
UINT32 volatile g_intCount = 0;
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%x\n", __FUNCTION__, ArchIntCurIrqNum());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
STATIC UINT32 HwiNumValid(UINT32 num)
{
return ((num) >= OS_USER_HWI_MIN) && ((num) <= OS_USER_HWI_MAX);
}
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->triggerIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->triggerIrq(hwiNum);
}
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->enableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->enableIrq(hwiNum);
}
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->disableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->disableIrq(hwiNum);
}
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->clearIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->clearIrq(hwiNum);
}
UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
{
if (!HwiNumValid(hwiNum)) {
return LOS_ERRNO_HWI_NUM_INVALID;
}
if (!HWI_PRI_VALID(priority)) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->setIrqPriority == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->setIrqPriority(hwiNum, priority);
}
UINT32 ArchIntCurIrqNum(VOID)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
return hwiOps->getCurIrqNum();
}
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)IrqEntry;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
ArchIntEnable(num);
}
}
#else
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = IrqEntry;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
ArchIntEnable(num);
}
}
#endif
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode, HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] != 0) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->createIrq == NULL) {
LOS_IntRestore(intSave);
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
hwiOps->createIrq(hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
ArchIntDisable((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiHandlerForm[hwiNum + OS_SYS_VECTOR_CNT] = 0;
LOS_IntRestore(intSave);
return LOS_OK;
}
UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}

View File

@ -0,0 +1,121 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_COMMON_INTERRUPT_H
#define _LOS_COMMON_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_error.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(VOID);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern volatile UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
extern HWI_HANDLER_FUNC g_hwiHandlerForm[];
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern HWI_PROC_FUNC g_hwiHandlerForm[];
#endif
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
VOID HalPreInterruptHandler(UINT32 arg);
VOID HalAftInterruptHandler(UINT32 arg);
VOID *ArchGetHwiFrom(VOID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_COMMON_INTERRUPT_H */

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -63,12 +63,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
return msp; return msp;
} }
STATIC INLINE UINTPTR ArchLRGet(VOID) #define ARCH_LR_GET() \
{ ({ \
UINTPTR lr; UINTPTR lr; \
__asm("mov %0, lr" : "=r" (lr)); __asm("mov %0, lr" : "=r" (lr)); \
return lr; (lr); \
} })
#define ArchLRGet ARCH_LR_GET
#elif defined(__CLANG_ARM) || defined(__GNUC__) #elif defined(__CLANG_ARM) || defined(__GNUC__)
STATIC INLINE UINTPTR ArchSpGet(VOID) STATIC INLINE UINTPTR ArchSpGet(VOID)
{ {
@ -91,12 +92,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
return msp; return msp;
} }
STATIC INLINE UINTPTR ArchLRGet(VOID) #define ARCH_LR_GET() \
{ ({ \
UINTPTR lr; UINTPTR lr; \
__asm volatile("mov %0, lr" : "=r" (lr)); __asm volatile("mov %0, lr" : "=r" (lr)); \
return lr; (lr); \
} })
#define ArchLRGet ARCH_LR_GET
#else #else
/* Other platforms to be improved */ /* Other platforms to be improved */
#endif #endif

View File

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

View File

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

View File

@ -0,0 +1,39 @@
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_name = "common"
kernel_module(module_name) {
sources = [ "los_common_interrupt.c" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_arch_interrupt.h"
#include "los_debug.h"
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
{
(VOID)arg;
PRINT_ERR("default handler\n");
while (1) {
}
}
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->triggerIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->triggerIrq(hwiNum);
}
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->enableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->enableIrq(hwiNum);
}
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->disableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->disableIrq(hwiNum);
}
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->clearIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->clearIrq(hwiNum);
}
UINT32 ArchIntSetPriority(HWI_HANDLE_T hwiNum, HWI_PRIOR_T priority)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->setIrqPriority == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->setIrqPriority(hwiNum, priority);
}
UINT32 ArchIntCurIrqNum(VOID)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
return hwiOps->getCurIrqNum();
}

View File

@ -0,0 +1,60 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_COMMON_INTERRUPT_H
#define _LOS_COMMON_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#include "los_error.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
extern VOID HalHwiDefaultHandler(VOID *arg);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_COMMON_INTERRUPT_H */

View File

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

View File

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

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -63,6 +63,9 @@
#define RISCV_MIE_MEIE 0x000000800 #define RISCV_MIE_MEIE 0x000000800
/************************** mcause ***********************/ /************************** mcause ***********************/
#ifndef MCAUSE_INT_ID_MASK
#define MCAUSE_INT_ID_MASK 0x7FFFFFF
#endif
#define RISCV_MCAUSE_ECALL_U 8 #define RISCV_MCAUSE_ECALL_U 8
#define RISCV_USER_SOFT_IRQ 0 #define RISCV_USER_SOFT_IRQ 0
@ -72,7 +75,6 @@
#define RISCV_USER_EXT_IRQ 8 #define RISCV_USER_EXT_IRQ 8
#define RISCV_MACH_EXT_IRQ 11 #define RISCV_MACH_EXT_IRQ 11
#define READ_CSR(reg) ({ \ #define READ_CSR(reg) ({ \
UINT32 _tmp; \ UINT32 _tmp; \
__asm__ volatile("csrr %0, " #reg : "=r"(_tmp) : : "memory"); \ __asm__ volatile("csrr %0, " #reg : "=r"(_tmp) : : "memory"); \

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -31,11 +31,7 @@
#ifndef _LOS_ARCH_INTERRUPT_H #ifndef _LOS_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H #define _LOS_ARCH_INTERRUPT_H
#include "los_compiler.h" #include "los_common_interrupt.h"
#include "los_config.h"
#include "los_interrupt.h"
#include "los_arch_context.h"
#include "los_error.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -43,6 +39,10 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* __cplusplus */ #endif /* __cplusplus */
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 0)
#error "LOSCFG_PLATFORM_HWI_WITH_ARG must be set to 1 !!!"
#endif
/** /**
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function. * Define the type of a hardware interrupt vector table function.
@ -110,6 +110,12 @@ typedef struct {
*/ */
#define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT) #define OS_RISCV_VECTOR_CNT (OS_RISCV_SYS_VECTOR_CNT + OS_RISCV_CUSTOM_IRQ_VECTOR_CNT)
/**
* @ingroup los_arch_interrupt
* Count of risc-v system interrupt vector.
*/
#define OS_SYS_VECTOR_CNT 0
/** /**
* Maximum number of supported hardware devices that generate hardware interrupts. * Maximum number of supported hardware devices that generate hardware interrupts.
* The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32. * The maximum number of hardware devices that generate hardware interrupts supported by hi3518ev200 is 32.
@ -142,9 +148,6 @@ extern VOID HalHwiInit(VOID);
extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum); extern UINT32 HalGetHwiFormCnt(HWI_HANDLE_T hwiNum);
extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID); extern HWI_HANDLE_FORM_S *HalGetHwiForm(VOID);
extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum); extern VOID HalHwiInterruptDone(HWI_HANDLE_T hwiNum);
extern VOID HalHwiDefaultHandler(VOID *arg);
extern UINT32 g_intCount;
/** /**
* @ingroup los_arch_interrupt * @ingroup los_arch_interrupt
@ -269,6 +272,16 @@ extern UINT32 g_intCount;
*/ */
#define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b) #define OS_ERRNO_HWI_HWINUM_UNCREATE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0b)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt operation function.
*
* Value: 0x0200090c
*
* Solution: Set a valid interrupt operation function
*/
#define OS_ERRNO_HWI_OPS_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x0c)
extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp); extern UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -35,7 +35,7 @@
#include "los_task.h" #include "los_task.h"
#include "los_sched.h" #include "los_sched.h"
#include "los_memory.h" #include "los_memory.h"
#include "soc.h" #include "soc_common.h"
STATIC UINT32 g_sysNeedSched = FALSE; STATIC UINT32 g_sysNeedSched = FALSE;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "soc.h" #include "soc_common.h"
.global HalEnableIRQ .global HalEnableIRQ
.global HalDisableIRQ .global HalDisableIRQ

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -31,7 +31,7 @@
#ifndef _LOS_EXC_S #ifndef _LOS_EXC_S
#define _LOS_EXC_S #define _LOS_EXC_S
#include "soc.h" #include "soc_common.h"
.macro PUSH_CALLER_REG .macro PUSH_CALLER_REG
addi sp, sp, -(32 * REGBYTES) addi sp, sp, -(32 * REGBYTES)
@ -139,8 +139,7 @@ HalTrapEntry:
sw a0, 0 * REGBYTES(sp) sw a0, 0 * REGBYTES(sp)
csrr t0, mtval csrr t0, mtval
sw t0, 1 * REGBYTES(sp) sw t0, 1 * REGBYTES(sp)
csrr t0, medeleg sw zero, 2 * REGBYTES(sp)
sw t0, 2 * REGBYTES(sp)
sw gp, 3 * REGBYTES(sp) sw gp, 3 * REGBYTES(sp)
mv a0, sp mv a0, sp
csrw mscratch, sp csrw mscratch, sp

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -40,7 +40,6 @@
#include "los_hook.h" #include "los_hook.h"
#include "riscv_hal.h" #include "riscv_hal.h"
LosExcInfo g_excInfo; LosExcInfo g_excInfo;
#define RISCV_EXC_TYPE_NUM 16 #define RISCV_EXC_TYPE_NUM 16
#define RISCV_EXC_LOAD_MISALIGNED 4 #define RISCV_EXC_LOAD_MISALIGNED 4
@ -64,7 +63,6 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
{ "Store/AMO page fault!" }, { "Store/AMO page fault!" },
}; };
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM]; LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM];
LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = { LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
{ .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler { .pfnHook = NULL, .uwParam = 0 }, // 0 User software interrupt handler
@ -95,14 +93,6 @@ LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
{ .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved { .pfnHook = NULL, .uwParam = 0 }, // 25 Reserved
}; };
LITE_OS_SEC_TEXT_INIT VOID HalHwiDefaultHandler(VOID *arg)
{
(VOID)arg;
PRINT_ERR("default handler\n");
while (1) {
}
}
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID) LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{ {
UINT32 index; UINT32 index;
@ -144,12 +134,6 @@ LITE_OS_SEC_TEXT HWI_HANDLE_FORM_S *HalGetHwiForm(VOID)
return g_hwiForm; return g_hwiForm;
} }
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
/***************************************************************************** /*****************************************************************************
Function : ArchHwiCreate Function : ArchHwiCreate
Description : create hardware interrupt Description : create hardware interrupt
@ -167,6 +151,7 @@ LITE_OS_SEC_TEXT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PROC_FUNC hwiHandler, HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam) HwiIrqParam *irqParam)
{ {
(VOID)hwiMode;
UINT32 intSave; UINT32 intSave;
if (hwiHandler == NULL) { if (hwiHandler == NULL) {
@ -283,7 +268,7 @@ STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
ExcBackTrace(taskContext->s0); ExcBackTrace(taskContext->s0);
} }
STATIC VOID ExcInfoDisplay(const LosExcContext *excBufAddr) STATIC VOID ExcInfoDisplay(VOID)
{ {
PRINTK("\nException Information \n"); PRINTK("\nException Information \n");
@ -305,6 +290,11 @@ STATIC VOID ExcInfoDisplay(const LosExcContext *excBufAddr)
WEAK UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp) WEAK UINT32 HalUnalignedAccessFix(UINTPTR mcause, UINTPTR mepc, UINTPTR mtval, VOID *sp)
{ {
(VOID)mcause;
(VOID)mepc;
(VOID)mtval;
(VOID)sp;
/* Unaligned access fixes are not supported by default */ /* Unaligned access fixes are not supported by default */
PRINTK("Unaligned access fixes are not supported by default!\n"); PRINTK("Unaligned access fixes are not supported by default!\n");
return LOS_NOK; return LOS_NOK;
@ -329,7 +319,7 @@ VOID HalExcEntry(const LosExcContext *excBufAddr)
} }
} }
ExcInfoDisplay(excBufAddr); ExcInfoDisplay();
if (LOS_TaskIsRunning()) { if (LOS_TaskIsRunning()) {
PRINTK("----------------All Task information ------------\n"); PRINTK("----------------All Task information ------------\n");
@ -342,3 +332,9 @@ SYSTEM_DEATH:
} }
} }
LITE_OS_SEC_BSS STATIC HwiControllerOps g_archHwiOps;
HwiControllerOps *ArchIntOpsGet(VOID)
{
return &g_archHwiOps;
}

View File

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

View File

@ -0,0 +1,39 @@
# Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_name = "common"
kernel_module(module_name) {
sources = [ "los_common_interrupt.c" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@ -0,0 +1,271 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_arch_interrupt.h"
#include "los_debug.h"
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
VOID *ArchGetHwiFrom(VOID)
{
return g_hwiForm;
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, ArchIntCurIrqNum());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
STATIC UINT32 HwiNumValid(UINT32 num)
{
return (num >= OS_SYS_VECTOR_CNT) && (num <= OS_VECTOR_CNT);
}
UINT32 ArchIntTrigger(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->triggerIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->triggerIrq(hwiNum);
}
UINT32 ArchIntEnable(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->enableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->enableIrq(hwiNum);
}
UINT32 ArchIntDisable(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->disableIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->disableIrq(hwiNum);
}
UINT32 ArchIntClear(HWI_HANDLE_T hwiNum)
{
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->clearIrq == NULL) {
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
return hwiOps->clearIrq(hwiNum);
}
UINT32 ArchIntCurIrqNum(VOID)
{
HwiControllerOps *hwiOps = ArchIntOpsGet();
return hwiOps->getCurIrqNum();
}
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
HwiControllerOps *hwiOps = ArchIntOpsGet();
if (hwiOps->createIrq == NULL) {
LOS_IntRestore(intSave);
return OS_ERRNO_HWI_OPS_FUNC_NULL;
}
hwiOps->createIrq(hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
ArchIntDisable(hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}

View File

@ -0,0 +1,102 @@
/*
* Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_COMMON_INTERRUPT_H
#define _LOS_COMMON_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#include "los_error.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(VOID);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
extern HWI_HANDLER_FUNC g_hwiHandlerForm[];
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
extern HWI_PROC_FUNC g_hwiHandlerForm[];
#endif
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
extern VOID HalHwiDefaultHandler(VOID);
VOID HalPreInterruptHandler(UINT32 arg);
VOID HalAftInterruptHandler(UINT32 arg);
VOID *ArchGetHwiFrom(VOID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_COMMON_INTERRUPT_H */

View File

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

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include "los_interrupt.h"
#include <stdarg.h> #include <stdarg.h>
#include "securec.h" #include "securec.h"
#include "los_context.h" #include "los_context.h"
@ -42,65 +41,6 @@
#include "los_membox.h" #include "los_membox.h"
#include "los_arch_regs.h" #include "los_arch_regs.h"
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
UINT32 HwiNumValid(UINT32 num)
{
return (num >= OS_SYS_VECTOR_CNT) && (num <= OS_VECTOR_CNT);
}
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* Lock all interrupt. * Lock all interrupt.
@ -154,37 +94,24 @@ STATIC INLINE UINT32 ArchIntLocked(VOID)
*/ */
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{ {
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("wsr %0, intset; rsync" : : "a"(0x1U << hwiNum)); __asm__ __volatile__("wsr %0, intset; rsync" : : "a"(0x1U << hwiNum));
return LOS_OK; return LOS_OK;
} }
UINT32 HwiUnmask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{ {
UINT32 ier; UINT32 ier;
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory"); __asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier | ((UINT32)0x1U << hwiNum))); __asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier | ((UINT32)0x1U << hwiNum)));
return LOS_OK; return LOS_OK;
} }
UINT32 HwiMask(HWI_HANDLE_T hwiNum) STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{ {
UINT32 ier; UINT32 ier;
if (!HwiNumValid(hwiNum)) {
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory"); __asm__ __volatile__("rsr %0, intenable" : "=a"(ier) : : "memory");
__asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier & ~((UINT32)0x1U << hwiNum))); __asm__ __volatile__("wsr %0, intenable; rsync" : : "a"(ier & ~((UINT32)0x1U << hwiNum)));
@ -216,53 +143,32 @@ STATIC UINT32 HwiNumGet(VOID)
* @ingroup los_hwi * @ingroup los_hwi
* Clear the interrupt * Clear the interrupt
*/ */
STATIC UINT32 HwiClear(HWI_HANDLE_T vector) STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{ {
if (!HwiNumValid(vector)) { __asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << hwiNum));
return OS_ERRNO_HWI_NUM_INVALID;
}
__asm__ __volatile__("wsr %0, intclear; rsync" : : "a"(0x1U << vector));
return LOS_OK; return LOS_OK;
} }
HwiControllerOps g_archHwiOps = { STATIC UINT32 HwiCreate(HWI_HANDLE_T hwiNum, HWI_PRIOR_T hwiPrio)
{
(VOID)hwiPrio;
HwiUnmask(hwiNum);
return LOS_OK;
}
STATIC HwiControllerOps g_archHwiOps = {
.triggerIrq = HwiPending, .triggerIrq = HwiPending,
.enableIrq = HwiUnmask, .enableIrq = HwiUnmask,
.disableIrq = HwiMask, .disableIrq = HwiMask,
.getCurIrqNum = HwiNumGet, .getCurIrqNum = HwiNumGet,
.clearIrq = HwiClear, .clearIrq = HwiClear,
.createIrq = HwiCreate,
}; };
INLINE UINT32 ArchIsIntActive(VOID) HwiControllerOps *ArchIntOpsGet(VOID)
{ {
return (g_intCount > 0); return &g_archHwiOps;
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
} }
/* **************************************************************************** /* ****************************************************************************
@ -308,88 +214,6 @@ VOID HalInterrupt(VOID)
HalIrqEndCheckNeedSched(); HalIrqEndCheckNeedSched();
} }
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
HwiUnmask(hwiNum);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
HwiMask(hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
ExcInfo g_excInfo = {0}; ExcInfo g_excInfo = {0};
#if (LOSCFG_KERNEL_PRINTF != 0) #if (LOSCFG_KERNEL_PRINTF != 0)
@ -559,8 +383,9 @@ WEAK VOID __stack_chk_fail(VOID)
VOID HalHwiInit(VOID) VOID HalHwiInit(VOID)
{ {
EnableExceptionInterface(); EnableExceptionInterface();
HWI_PROC_FUNC *hwiForm = (HWI_PROC_FUNC *)ArchGetHwiFrom();
for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) { for (UINT32 i = 0; i < OS_HWI_MAX_NUM; i++) {
g_hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler; hwiForm[i + OS_SYS_VECTOR_CNT] = HalHwiDefaultHandler;
HwiMask(i); HwiMask(i);
} }
asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START)); asm volatile ("wsr %0, vecbase" : : "r"(INIT_VECTOR_START));

View File

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

View File

@ -27,9 +27,6 @@
"component": { "component": {
"name": "liteos_m", "name": "liteos_m",
"subsystem": "kernel", "subsystem": "kernel",
"syscap": [
"SystemCapability.Kernel.liteos-m"
],
"features": [], "features": [],
"adapted_system_type": [ "adapted_system_type": [
"mini" "mini"
@ -43,7 +40,7 @@
"third_party": [ "third_party": [
"bounds_checking_function", "bounds_checking_function",
"cmsis", "cmsis",
"fatfs", "FatFs",
"littlefs", "littlefs",
"lwip", "lwip",
"musl" "musl"
@ -58,4 +55,4 @@
"test": [] "test": []
} }
} }
} }

View File

@ -43,7 +43,7 @@
judgment condition to support multiple code sections. */ judgment condition to support multiple code sections. */
WEAK BOOL OsStackDataIsCodeAddr(UINTPTR value) WEAK BOOL OsStackDataIsCodeAddr(UINTPTR value)
{ {
if ((value >= CODE_START_ADDR) && (value < CODE_END_ADDR)) { if ((value > CODE_START_ADDR) && (value < CODE_END_ADDR)) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;

View File

@ -58,6 +58,9 @@
#define OS_CPUP_RECORD_PERIOD (g_sysClock) #define OS_CPUP_RECORD_PERIOD (g_sysClock)
#define OS_SYS_CYCLE_TO_US(cycle) ((cycle) / (g_sysClock)) * OS_SYS_US_PER_SECOND + \
((cycle) % (g_sysClock) * OS_SYS_US_PER_SECOND / (g_sysClock))
LITE_OS_SEC_BSS UINT16 g_cpupInitFlg = 0; LITE_OS_SEC_BSS UINT16 g_cpupInitFlg = 0;
LITE_OS_SEC_BSS OsCpupCB *g_cpup = NULL; LITE_OS_SEC_BSS OsCpupCB *g_cpup = NULL;
LITE_OS_SEC_BSS UINT64 g_lastRecordTime; LITE_OS_SEC_BSS UINT64 g_lastRecordTime;
@ -167,6 +170,15 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit()
return LOS_OK; return LOS_OK;
} }
/* The calculation time unit is changed to us to decouple the influence of
* system frequency modulation on CPUP
*/
STATIC UINT64 CpupTimeUsGet(VOID)
{
UINT64 time = LOS_SysCycleGet();
return OS_SYS_CYCLE_TO_US(time);
}
/***************************************************************************** /*****************************************************************************
Function : OsTskCycleStart Function : OsTskCycleStart
Description: start task to get cycles count in current task beginning Description: start task to get cycles count in current task beginning
@ -183,10 +195,11 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleStart(VOID)
taskID = g_losTask.newTask->taskID; taskID = g_losTask.newTask->taskID;
g_cpup[taskID].cpupID = taskID; g_cpup[taskID].cpupID = taskID;
g_cpup[taskID].startTime = LOS_SysCycleGet(); g_cpup[taskID].startTime = CpupTimeUsGet();
return; return;
} }
/***************************************************************************** /*****************************************************************************
Function : OsTskCycleEnd Function : OsTskCycleEnd
Description: quit task and get cycle count Description: quit task and get cycle count
@ -196,7 +209,7 @@ Return : None
LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID) LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID)
{ {
UINT32 taskID; UINT32 taskID;
UINT64 cpuCycle; UINT64 cpuTime;
if (g_cpupInitFlg == 0) { if (g_cpupInitFlg == 0) {
return; return;
@ -208,16 +221,17 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID)
return; return;
} }
cpuCycle = LOS_SysCycleGet(); cpuTime = CpupTimeUsGet();
if (cpuCycle < g_cpup[taskID].startTime) { if (cpuTime < g_cpup[taskID].startTime) {
cpuCycle += g_cyclesPerTick; cpuTime += OS_US_PER_TICK;
} }
g_cpup[taskID].allTime += (cpuCycle - g_cpup[taskID].startTime); g_cpup[taskID].allTime += (cpuTime - g_cpup[taskID].startTime);
g_cpup[taskID].startTime = 0; g_cpup[taskID].startTime = 0;
return; return;
} }
/***************************************************************************** /*****************************************************************************
Function : OsTskCycleEndStart Function : OsTskCycleEndStart
Description: start task to get cycles count in current task ending Description: start task to get cycles count in current task ending
@ -227,7 +241,7 @@ Return : None
LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID) LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
{ {
UINT32 taskID; UINT32 taskID;
UINT64 cpuCycle; UINT64 cpuTime;
UINT16 loopNum; UINT16 loopNum;
if (g_cpupInitFlg == 0) { if (g_cpupInitFlg == 0) {
@ -235,23 +249,23 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
} }
taskID = g_losTask.runTask->taskID; taskID = g_losTask.runTask->taskID;
cpuCycle = LOS_SysCycleGet(); cpuTime = CpupTimeUsGet();
if (g_cpup[taskID].startTime != 0) { if (g_cpup[taskID].startTime != 0) {
if (cpuCycle < g_cpup[taskID].startTime) { if (cpuTime < g_cpup[taskID].startTime) {
cpuCycle += g_cyclesPerTick; cpuTime += OS_US_PER_TICK;
} }
g_cpup[taskID].allTime += (cpuCycle - g_cpup[taskID].startTime); g_cpup[taskID].allTime += (cpuTime - g_cpup[taskID].startTime);
g_cpup[taskID].startTime = 0; g_cpup[taskID].startTime = 0;
} }
taskID = g_losTask.newTask->taskID; taskID = g_losTask.newTask->taskID;
g_cpup[taskID].cpupID = taskID; g_cpup[taskID].cpupID = taskID;
g_cpup[taskID].startTime = cpuCycle; g_cpup[taskID].startTime = cpuTime;
if ((cpuCycle - g_lastRecordTime) > OS_CPUP_RECORD_PERIOD) { if ((cpuTime - g_lastRecordTime) > OS_CPUP_RECORD_PERIOD) {
g_lastRecordTime = cpuCycle; g_lastRecordTime = cpuTime;
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) { for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
g_cpup[loopNum].historyTime[g_hisPos] = g_cpup[loopNum].allTime; g_cpup[loopNum].historyTime[g_hisPos] = g_cpup[loopNum].allTime;
@ -267,12 +281,12 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
return; return;
} }
LITE_OS_SEC_TEXT_MINOR static inline UINT16 OsGetPrePos(UINT16 curPos) LITE_OS_SEC_TEXT_MINOR STATIC INLINE UINT16 OsGetPrePos(UINT16 curPos)
{ {
return (curPos == 0) ? (OS_CPUP_HISTORY_RECORD_NUM - 1) : (curPos - 1); return (curPos == 0) ? (OS_CPUP_HISTORY_RECORD_NUM - 1) : (curPos - 1);
} }
LITE_OS_SEC_TEXT_MINOR static VOID OsGetPositions(UINT16 mode, UINT16* curPosAddr, UINT16* prePosAddr) LITE_OS_SEC_TEXT_MINOR STATIC VOID OsGetPositions(UINT16 mode, UINT16* curPosAddr, UINT16* prePosAddr)
{ {
UINT16 curPos; UINT16 curPos;
UINT16 prePos = 0; UINT16 prePos = 0;
@ -298,7 +312,7 @@ Return : cpupRet:current CPU usage
*****************************************************************************/ *****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysCpuUsage(VOID) LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysCpuUsage(VOID)
{ {
UINT64 cpuCycleAll = 0; UINT64 cpuTimeAll = 0;
UINT32 cpupRet = 0; UINT32 cpupRet = 0;
UINT16 loopNum; UINT16 loopNum;
UINT32 intSave; UINT32 intSave;
@ -312,12 +326,12 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysCpuUsage(VOID)
OsTskCycleEnd(); OsTskCycleEnd();
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) { for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
cpuCycleAll += g_cpup[loopNum].allTime; cpuTimeAll += g_cpup[loopNum].allTime;
} }
if (cpuCycleAll) { if (cpuTimeAll) {
cpupRet = LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * cpupRet = LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION *
g_cpup[g_idleTaskID].allTime) / cpuCycleAll); g_cpup[g_idleTaskID].allTime) / cpuTimeAll);
} }
OsTskCycleStart(); OsTskCycleStart();
@ -334,7 +348,7 @@ Return : cpupRet:CPU usage history
*****************************************************************************/ *****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode) LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
{ {
UINT64 cpuCycleAll = 0; UINT64 cpuTimeAll = 0;
UINT64 idleCycleAll = 0; UINT64 idleCycleAll = 0;
UINT32 cpupRet = 0; UINT32 cpupRet = 0;
UINT16 loopNum; UINT16 loopNum;
@ -354,9 +368,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) { for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
if (mode == CPUP_IN_1S) { if (mode == CPUP_IN_1S) {
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos]; cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else { } else {
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos]; cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
} }
} }
@ -367,8 +381,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
idleCycleAll += g_cpup[g_idleTaskID].allTime - g_cpup[g_idleTaskID].historyTime[curPos]; idleCycleAll += g_cpup[g_idleTaskID].allTime - g_cpup[g_idleTaskID].historyTime[curPos];
} }
if (cpuCycleAll) { if (cpuTimeAll) {
cpupRet = (LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * idleCycleAll) / cpuCycleAll)); cpupRet = (LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * idleCycleAll) / cpuTimeAll));
} }
OsTskCycleStart(); OsTskCycleStart();
@ -385,7 +399,7 @@ Return : cpupRet:CPU usage of certain task
*****************************************************************************/ *****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuUsage(UINT32 taskID) LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuUsage(UINT32 taskID)
{ {
UINT64 cpuCycleAll = 0; UINT64 cpuTimeAll = 0;
UINT16 loopNum; UINT16 loopNum;
UINT32 intSave; UINT32 intSave;
UINT32 cpupRet = 0; UINT32 cpupRet = 0;
@ -410,11 +424,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuUsage(UINT32 taskID)
if ((g_cpup[loopNum].status & OS_TASK_STATUS_UNUSED) || (g_cpup[loopNum].status == 0)) { if ((g_cpup[loopNum].status & OS_TASK_STATUS_UNUSED) || (g_cpup[loopNum].status == 0)) {
continue; continue;
} }
cpuCycleAll += g_cpup[loopNum].allTime; cpuTimeAll += g_cpup[loopNum].allTime;
} }
if (cpuCycleAll) { if (cpuTimeAll) {
cpupRet = (UINT32)((LOS_CPUP_PRECISION * g_cpup[taskID].allTime) / cpuCycleAll); cpupRet = (UINT32)((LOS_CPUP_PRECISION * g_cpup[taskID].allTime) / cpuTimeAll);
} }
OsTskCycleStart(); OsTskCycleStart();
@ -432,8 +446,8 @@ Return : cpupRet:CPU usage history of task
*****************************************************************************/ *****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode) LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode)
{ {
UINT64 cpuCycleAll = 0; UINT64 cpuTimeAll = 0;
UINT64 cpuCycleCurTsk = 0; UINT64 cpuTimeCurTsk = 0;
UINT16 loopNum, curPos; UINT16 loopNum, curPos;
UINT16 prePos = 0; UINT16 prePos = 0;
UINT32 intSave; UINT32 intSave;
@ -463,19 +477,19 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode
} }
if (mode == CPUP_IN_1S) { if (mode == CPUP_IN_1S) {
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos]; cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else { } else {
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos]; cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
} }
} }
if (mode == CPUP_IN_1S) { if (mode == CPUP_IN_1S) {
cpuCycleCurTsk += g_cpup[taskID].historyTime[curPos] - g_cpup[taskID].historyTime[prePos]; cpuTimeCurTsk += g_cpup[taskID].historyTime[curPos] - g_cpup[taskID].historyTime[prePos];
} else { } else {
cpuCycleCurTsk += g_cpup[taskID].allTime - g_cpup[taskID].historyTime[curPos]; cpuTimeCurTsk += g_cpup[taskID].allTime - g_cpup[taskID].historyTime[curPos];
} }
if (cpuCycleAll) { if (cpuTimeAll) {
cpupRet = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTsk) / cpuCycleAll); cpupRet = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurTsk) / cpuTimeAll);
} }
OsTskCycleStart(); OsTskCycleStart();
@ -490,8 +504,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
UINT16 curPos; UINT16 curPos;
UINT16 prePos = 0; UINT16 prePos = 0;
UINT32 intSave; UINT32 intSave;
UINT64 cpuCycleAll = 0; UINT64 cpuTimeAll = 0;
UINT64 cpuCycleCurTsk = 0; UINT64 cpuTimeCurTsk = 0;
if (g_cpupInitFlg == 0) { if (g_cpupInitFlg == 0) {
return LOS_ERRNO_CPUP_NO_INIT; return LOS_ERRNO_CPUP_NO_INIT;
@ -513,9 +527,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
} }
if (mode == CPUP_IN_1S) { if (mode == CPUP_IN_1S) {
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos]; cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else { } else {
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos]; cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
} }
} }
@ -526,16 +540,16 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
} }
if (mode == CPUP_IN_1S) { if (mode == CPUP_IN_1S) {
cpuCycleCurTsk += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos]; cpuTimeCurTsk += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else { } else {
cpuCycleCurTsk += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos]; cpuTimeCurTsk += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
} }
cpupInfo[loopNum].usStatus = g_cpup[loopNum].status; cpupInfo[loopNum].usStatus = g_cpup[loopNum].status;
if (cpuCycleAll) { if (cpuTimeAll) {
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTsk) / cpuCycleAll); cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurTsk) / cpuTimeAll);
} }
cpuCycleCurTsk = 0; cpuTimeCurTsk = 0;
} }
OsTskCycleStart(); OsTskCycleStart();
@ -602,46 +616,47 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1) #if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum) LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum)
{ {
if (g_irqCpupInitFlg == 0) { if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
return; return;
} }
UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
g_irqCpup[intNum].startTime = LOS_SysCycleGet(); g_irqCpup[cpupIntNum].startTime = CpupTimeUsGet();
return; return;
} }
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum) LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
{ {
UINT64 cpuCycle; UINT64 cpuTime;
UINT64 usedTime; UINT64 usedTime;
if (g_irqCpupInitFlg == 0) { if ((g_irqCpupInitFlg == 0) || (intNum < OS_SYS_VECTOR_CNT)) {
return; return;
} }
if (g_irqCpup[intNum].startTime == 0) { UINT32 cpupIntNum = intNum - OS_SYS_VECTOR_CNT;
if (g_irqCpup[cpupIntNum].startTime == 0) {
return; return;
} }
cpuCycle = LOS_SysCycleGet(); cpuTime = CpupTimeUsGet();
if (cpuCycle < g_irqCpup[intNum].startTime) { if (cpuTime < g_irqCpup[cpupIntNum].startTime) {
cpuCycle += g_cyclesPerTick; cpuTime += OS_US_PER_TICK;
} }
g_irqCpup[intNum].cpupID = intNum; g_irqCpup[cpupIntNum].cpupID = intNum;
g_irqCpup[intNum].status = OS_CPUP_USED; g_irqCpup[cpupIntNum].status = OS_CPUP_USED;
usedTime = cpuCycle - g_irqCpup[intNum].startTime; usedTime = cpuTime - g_irqCpup[cpupIntNum].startTime;
if (g_irqCpup[intNum].count <= 1000) { /* 1000, Take 1000 samples */ if (g_irqCpup[cpupIntNum].count <= 1000) { /* 1000, Take 1000 samples */
g_irqCpup[intNum].allTime += usedTime; g_irqCpup[cpupIntNum].allTime += usedTime;
g_irqCpup[intNum].count++; g_irqCpup[cpupIntNum].count++;
} else { } else {
g_irqCpup[intNum].allTime = 0; g_irqCpup[cpupIntNum].allTime = 0;
g_irqCpup[intNum].count = 0; g_irqCpup[cpupIntNum].count = 0;
} }
g_irqCpup[intNum].startTime = 0; g_irqCpup[cpupIntNum].startTime = 0;
if (usedTime > g_irqCpup[intNum].timeMax) { if (usedTime > g_irqCpup[cpupIntNum].timeMax) {
g_irqCpup[intNum].timeMax = usedTime; g_irqCpup[cpupIntNum].timeMax = usedTime;
} }
return; return;
} }
@ -672,12 +687,12 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsGetIrqPositions(UINT16 mode, UINT16* curPos
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllTime(VOID) LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllTime(VOID)
{ {
INT32 i; INT32 i;
UINT64 cpuCycleAll = 0; UINT64 cpuTimeAll = 0;
for (i = 0; i < OS_CPUP_HISTORY_RECORD_NUM; i++) { for (i = 0; i < OS_CPUP_HISTORY_RECORD_NUM; i++) {
cpuCycleAll += g_cpuHistoryTime[i]; cpuTimeAll += g_cpuHistoryTime[i];
} }
return cpuCycleAll; return cpuTimeAll;
} }
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllHisTime(UINT32 num) LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllHisTime(UINT32 num)
@ -697,8 +712,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
UINT16 curPos; UINT16 curPos;
UINT16 prePos = 0; UINT16 prePos = 0;
UINT32 intSave; UINT32 intSave;
UINT64 cpuCycleAll; UINT64 cpuTimeAll;
UINT64 cpuCycleCurIrq; UINT64 cpuTimeCurIrq;
if (g_irqCpupInitFlg == 0) { if (g_irqCpupInitFlg == 0) {
return LOS_ERRNO_CPUP_NO_INIT; return LOS_ERRNO_CPUP_NO_INIT;
@ -712,9 +727,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
OsGetIrqPositions(mode, &curPos, &prePos); OsGetIrqPositions(mode, &curPos, &prePos);
if (mode == CPUP_IN_10S) { if (mode == CPUP_IN_10S) {
cpuCycleAll = OsGetIrqAllTime(); cpuTimeAll = OsGetIrqAllTime();
} else { } else {
cpuCycleAll = g_cpuHistoryTime[curPos] - g_cpuHistoryTime[prePos]; cpuTimeAll = g_cpuHistoryTime[curPos] - g_cpuHistoryTime[prePos];
} }
for (loopNum = 0; loopNum < LOSCFG_PLATFORM_HWI_LIMIT; loopNum++) { for (loopNum = 0; loopNum < LOSCFG_PLATFORM_HWI_LIMIT; loopNum++) {
@ -725,13 +740,13 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
cpupInfo[loopNum].usStatus = g_irqCpup[loopNum].status; cpupInfo[loopNum].usStatus = g_irqCpup[loopNum].status;
if (mode == CPUP_IN_10S) { if (mode == CPUP_IN_10S) {
cpuCycleCurIrq = OsGetIrqAllHisTime(loopNum); cpuTimeCurIrq = OsGetIrqAllHisTime(loopNum);
} else { } else {
cpuCycleCurIrq = g_irqCpup[loopNum].historyTime[curPos] - g_irqCpup[loopNum].historyTime[prePos]; cpuTimeCurIrq = g_irqCpup[loopNum].historyTime[curPos] - g_irqCpup[loopNum].historyTime[prePos];
} }
if (cpuCycleAll != 0) { if (cpuTimeAll != 0) {
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurIrq) / cpuCycleAll); cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurIrq) / cpuTimeAll);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2022-2023 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -63,7 +63,7 @@ STATIC VOID ShellCmdHwiInfoShow(OsIrqCpupCB *irqData, CPUP_INFO_S *hwiCpup1s,
} }
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) { for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) { if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue; continue;
} }
@ -118,9 +118,9 @@ STATIC VOID HwiInfoDump(VOID)
{ {
INT32 i; INT32 i;
PRINTK(" InterruptNo Count Name\n"); PRINTK(" InterruptNo Count Name\n");
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) { for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) { if ((OsHwiIsCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue; continue;
} }
@ -128,8 +128,8 @@ STATIC VOID HwiInfoDump(VOID)
PRINTK(" %8d:%10d %-s\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i), OsGetHwiFormName(i)); PRINTK(" %8d:%10d %-s\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i), OsGetHwiFormName(i));
} else { } else {
PRINTK(" %8d:%10d\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i)); PRINTK(" %8d:%10d\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i));
} }
} }
return; return;
} }
#endif #endif
@ -144,6 +144,6 @@ UINT32 OsShellCmdHwiDump(INT32 argc, const CHAR **argv)
} }
HwiInfoDump(); HwiInfoDump();
return LOS_OK; return LOS_OK;
} }
#endif /* LOSCFG_STACK_DUMP == 1 */ #endif /* LOSCFG_STACK_DUMP == 1 */

View File

@ -59,7 +59,7 @@ extern "C" {
#else #else
#define MAX_SWITCH_INFO_SIZE (0) #define MAX_SWITCH_INFO_SIZE (0)
#endif #endif
#define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM) #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 \ #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) + 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. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni") import("//kernel/liteos_m/liteos.gni")
import("//third_party/FatFs/FatFs.gni") import("$THIRDPARTY_FATFS_DIR/FatFs.gni")
module_switch = defined(LOSCFG_FS_FAT) module_switch = defined(LOSCFG_FS_FAT)
module_name = get_path_info(rebase_path("."), "name") module_name = get_path_info(rebase_path("."), "name")

View File

@ -32,7 +32,6 @@ config FS_FAT
default n default n
depends on FS_VFS depends on FS_VFS
select SUPPORT_FATFS select SUPPORT_FATFS
select KAL_CMSIS
help help
Answer Y to enable LiteOS support fat filesystem. Answer Y to enable LiteOS support fat filesystem.

View File

@ -60,7 +60,6 @@
#endif /* FS_LOCK_TIMEOUT_SEC */ #endif /* FS_LOCK_TIMEOUT_SEC */
static UINT8 g_workBuffer[FF_MAX_SS]; static UINT8 g_workBuffer[FF_MAX_SS];
static pthread_mutex_t g_fatfsMutex = PTHREAD_MUTEX_INITIALIZER;
static char *g_volPath[FF_VOLUMES] = {FF_VOLUME_STRS}; static char *g_volPath[FF_VOLUMES] = {FF_VOLUME_STRS};
PARTITION VolToPart[] = { PARTITION VolToPart[] = {
@ -70,31 +69,6 @@ PARTITION VolToPart[] = {
{ 0, 0, 4, 0, 0 } { 0, 0, 4, 0, 0 }
}; };
static int FsLock(void)
{
int ret = 0;
struct timespec absTimeout = {0};
if (!OsCheckKernelRunning()) {
return ret;
}
ret = clock_gettime(CLOCK_REALTIME, &absTimeout);
if (ret != 0) {
PRINT_ERR("clock gettime err 0x%x!\r\n", errno);
return errno;
}
absTimeout.tv_sec += FS_LOCK_TIMEOUT_SEC;
ret = pthread_mutex_timedlock(&g_fatfsMutex, &absTimeout);
return ret;
}
static void FsUnlock(void)
{
if (!OsCheckKernelRunning()) {
return;
}
(void)pthread_mutex_unlock(&g_fatfsMutex);
}
static int FsChangeDrive(const char *path) static int FsChangeDrive(const char *path)
{ {
INT32 res; INT32 res;
@ -275,95 +249,69 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
{ {
FRESULT res; FRESULT res;
FATFS *fs = NULL; FATFS *fs = NULL;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (mountflags & MS_REMOUNT) { if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags); return Remount(mp, mountflags);
FsUnlock();
return ret;
} }
char *ldPath = GetLdPath(mp->mDev); char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) { if (ldPath == NULL) {
errno = EFAULT; errno = EFAULT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto ERROUT;
} }
fs = (FATFS *)LOSCFG_FS_MALLOC_HOOK(sizeof(FATFS)); fs = (FATFS *)LOSCFG_FS_MALLOC_HOOK(sizeof(FATFS));
if (fs == NULL) { if (fs == NULL) {
errno = ENOMEM; errno = ENOMEM;
ret = (int)LOS_NOK; PutLdPath(ldPath);
goto ERROUT; return (int)LOS_NOK;
} }
(void)memset_s(fs, sizeof(FATFS), 0, sizeof(FATFS)); (void)memset_s(fs, sizeof(FATFS), 0, sizeof(FATFS));
res = f_mount(fs, ldPath, 1);
if (res != FR_OK) {
LOSCFG_FS_FREE_HOOK(fs);
PutLdPath(ldPath);
errno = FatfsErrno(res);
return (int)LOS_NOK;
}
mp->mData = (void *)fs; mp->mData = (void *)fs;
res = f_mount((FATFS *)mp->mData, ldPath, 1);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto ERROUT;
}
PutLdPath(ldPath); PutLdPath(ldPath);
FsUnlock();
return (int)LOS_OK; return (int)LOS_OK;
ERROUT:
LOSCFG_FS_FREE_HOOK(fs);
mp->mData = NULL;
PutLdPath(ldPath);
FsUnlock();
return ret;
} }
int FatfsUmount(struct MountPoint *mp) int FatfsUmount(struct MountPoint *mp)
{ {
int ret;
int volId; int volId;
FRESULT res; FRESULT res;
char *ldPath = NULL;
FATFS *fatfs = (FATFS *)mp->mData; FATFS *fatfs = (FATFS *)mp->mData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = (int)LOS_NOK;
goto OUT;
}
/* The volume is not mounted */ /* The volume is not mounted */
if (fatfs->fs_type == 0) { if (fatfs->fs_type == 0) {
errno = EINVAL; errno = EINVAL;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
volId = GetPartIdByPartName(mp->mDev); volId = GetPartIdByPartName(mp->mDev);
/* umount is not allowed when a file or directory is opened. */ /* umount is not allowed when a file or directory is opened. */
if (f_checkopenlock(volId) != FR_OK) { if (f_checkopenlock(volId) != FR_OK) {
errno = EBUSY; errno = EBUSY;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT; }
ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
return (int)LOS_NOK;
} }
res = f_mount((FATFS *)NULL, ldPath, 0); res = f_mount((FATFS *)NULL, ldPath, 0);
if (res != FR_OK) { if (res != FR_OK) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; PutLdPath(ldPath);
goto OUT; return (int)LOS_NOK;
} }
if (fatfs->win != NULL) { if (fatfs->win != NULL) {
@ -373,19 +321,15 @@ int FatfsUmount(struct MountPoint *mp)
LOSCFG_FS_FREE_HOOK(mp->mData); LOSCFG_FS_FREE_HOOK(mp->mData);
mp->mData = NULL; mp->mData = NULL;
ret = (int)LOS_OK;
OUT:
PutLdPath(ldPath); PutLdPath(ldPath);
FsUnlock(); return (int)LOS_OK;
return ret;
} }
int FatfsUmount2(struct MountPoint *mp, int flag) int FatfsUmount2(struct MountPoint *mp, int flag)
{ {
int ret;
UINT32 flags; UINT32 flags;
FRESULT res; FRESULT res;
char *ldPath = NULL;
FATFS *fatfs = (FATFS *)mp->mData; FATFS *fatfs = (FATFS *)mp->mData;
flags = MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW; flags = MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW;
@ -394,31 +338,23 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = (int)LOS_NOK;
goto OUT;
}
/* The volume is not mounted */ /* The volume is not mounted */
if (fatfs->fs_type == 0) { if (fatfs->fs_type == 0) {
errno = EINVAL; errno = EINVAL;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT; }
ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
return (int)LOS_NOK;
} }
res = f_mount((FATFS *)NULL, ldPath, 0); res = f_mount((FATFS *)NULL, ldPath, 0);
if (res != FR_OK) { if (res != FR_OK) {
PutLdPath(ldPath);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
if (fatfs->win != NULL) { if (fatfs->win != NULL) {
@ -428,12 +364,8 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
LOSCFG_FS_FREE_HOOK(mp->mData); LOSCFG_FS_FREE_HOOK(mp->mData);
mp->mData = NULL; mp->mData = NULL;
ret = (int)LOS_OK;
OUT:
PutLdPath(ldPath); PutLdPath(ldPath);
FsUnlock(); return (int)LOS_OK;
return ret;
} }
int FatfsOpen(struct File *file, const char *path, int oflag) int FatfsOpen(struct File *file, const char *path, int oflag)
@ -455,21 +387,14 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
errno = ENOMEM; errno = ENOMEM;
return (int)LOS_NOK; return (int)LOS_NOK;
} }
(void)memset_s(fp, sizeof(FIL), 0, sizeof(FIL));
ret = FsLock();
if (ret != 0) {
errno = ret;
LOSCFG_FS_FREE_HOOK(fp);
return (int)LOS_NOK;
}
ret = FsChangeDrive(path); ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) { if (ret != (int)LOS_OK) {
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret); PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK;
LOSCFG_FS_FREE_HOOK(fp); LOSCFG_FS_FREE_HOOK(fp);
goto OUT; return (int)LOS_NOK;
} }
res = f_open(fp, path, fmode); res = f_open(fp, path, fmode);
@ -477,31 +402,20 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
PRINT_ERR("FAT open err 0x%x!\r\n", res); PRINT_ERR("FAT open err 0x%x!\r\n", res);
LOSCFG_FS_FREE_HOOK(fp); LOSCFG_FS_FREE_HOOK(fp);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
file->fData = (void *)fp; file->fData = (void *)fp;
OUT: return (int)LOS_OK;
FsUnlock();
return ret;
} }
int FatfsClose(struct File *file) int FatfsClose(struct File *file)
{ {
FRESULT res; FRESULT res;
FIL *fp = (FIL *)file->fData; FIL *fp = (FIL *)file->fData;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) { if ((fp == NULL) || (fp->obj.fs == NULL)) {
FsUnlock();
errno = ENOENT; errno = ENOENT;
return (int)LOS_NOK; return (int)LOS_NOK;
} }
@ -509,7 +423,6 @@ int FatfsClose(struct File *file)
res = f_close(fp); res = f_close(fp);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT close err 0x%x!\r\n", res); PRINT_ERR("FAT close err 0x%x!\r\n", res);
FsUnlock();
errno = FatfsErrno(res); errno = FatfsErrno(res);
return (int)LOS_NOK; return (int)LOS_NOK;
} }
@ -521,7 +434,6 @@ int FatfsClose(struct File *file)
#endif #endif
LOSCFG_FS_FREE_HOOK(file->fData); LOSCFG_FS_FREE_HOOK(file->fData);
file->fData = NULL; file->fData = NULL;
FsUnlock();
return (int)LOS_OK; return (int)LOS_OK;
} }
@ -531,31 +443,22 @@ ssize_t FatfsRead(struct File *file, char *buf, size_t nbyte)
FRESULT res; FRESULT res;
UINT32 lenRead; UINT32 lenRead;
FIL *fp = (FIL *)file->fData; FIL *fp = (FIL *)file->fData;
int ret;
if (buf == NULL) { if (buf == NULL) {
errno = EFAULT; errno = EFAULT;
return (ssize_t)LOS_NOK; return (ssize_t)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (ssize_t)LOS_NOK;
}
if (fp == NULL) { if (fp == NULL) {
FsUnlock();
errno = ENOENT; errno = ENOENT;
return (ssize_t)LOS_NOK; return (ssize_t)LOS_NOK;
} }
res = f_read(fp, buf, nbyte, &lenRead); res = f_read(fp, buf, nbyte, &lenRead);
if (res != FR_OK) { if (res != FR_OK) {
FsUnlock();
errno = FatfsErrno(res); errno = FatfsErrno(res);
return (ssize_t)LOS_NOK; return (ssize_t)LOS_NOK;
} }
FsUnlock();
return (ssize_t)lenRead; return (ssize_t)lenRead;
} }
@ -566,22 +469,15 @@ ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
UINT32 lenWrite; UINT32 lenWrite;
static BOOL overFlow = FALSE; static BOOL overFlow = FALSE;
FIL *fp = (FIL *)file->fData; FIL *fp = (FIL *)file->fData;
int ret;
if (buf == NULL) { if (buf == NULL) {
errno = EFAULT; errno = EFAULT;
return (ssize_t)LOS_NOK; return (ssize_t)LOS_NOK;
} }
ret = FsLock(); if ((fp == NULL) || (fp->obj.fs == NULL)) {
if (ret != 0) {
errno = ret;
return (ssize_t)LOS_NOK;
}
if ((fp ==NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT; errno = ENOENT;
goto ERROUT; return (ssize_t)LOS_NOK;
} }
res = f_write(fp, buf, nbyte, &lenWrite); res = f_write(fp, buf, nbyte, &lenWrite);
@ -592,15 +488,10 @@ ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
if ((res != FR_OK) || (nbyte != lenWrite)) { if ((res != FR_OK) || (nbyte != lenWrite)) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
goto ERROUT; return (ssize_t)LOS_NOK;
} }
FsUnlock();
return (ssize_t)lenWrite; return (ssize_t)lenWrite;
ERROUT:
FsUnlock();
return (ssize_t)LOS_NOK;
} }
off_t FatfsLseek(struct File *file, off_t offset, int whence) off_t FatfsLseek(struct File *file, off_t offset, int whence)
@ -608,17 +499,10 @@ off_t FatfsLseek(struct File *file, off_t offset, int whence)
FRESULT res; FRESULT res;
off_t pos; off_t pos;
FIL *fp = (FIL *)file->fData; FIL *fp = (FIL *)file->fData;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (off_t)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) { if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT; errno = ENOENT;
goto ERROUT; return (off_t)LOS_NOK;
} }
if (whence == SEEK_SET) { if (whence == SEEK_SET) {
@ -629,22 +513,17 @@ off_t FatfsLseek(struct File *file, off_t offset, int whence)
pos = f_size(fp); pos = f_size(fp);
} else { } else {
errno = EINVAL; errno = EINVAL;
goto ERROUT; return (off_t)LOS_NOK;
} }
res = f_lseek(fp, offset + pos); res = f_lseek(fp, offset + pos);
if (res != FR_OK) { if (res != FR_OK) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
goto ERROUT; return (off_t)LOS_NOK;
} }
pos = f_tell(fp); pos = f_tell(fp);
FsUnlock();
return pos; return pos;
ERROUT:
FsUnlock();
return (off_t)LOS_NOK;
} }
/* Remove the specified FILE */ /* Remove the specified FILE */
@ -658,39 +537,26 @@ int FatfsUnlink(struct MountPoint *mp, const char *path)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) { if (!mp->mWriteEnable) {
errno = EACCES; errno = EACCES;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = FsChangeDrive(path); ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) { if (ret != (int)LOS_OK) {
PRINT_ERR("FAT unlink ChangeDrive err 0x%x!\r\n", ret); PRINT_ERR("FAT unlink ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_unlink(path); res = f_unlink(path);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT unlink err 0x%x!\r\n", res); PRINT_ERR("FAT unlink err 0x%x!\r\n", res);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = (int)LOS_OK; return (int)LOS_OK;
OUT:
FsUnlock();
return ret;
} }
int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf) int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
@ -704,26 +570,18 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path); ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) { if (ret != (int)LOS_OK) {
PRINT_ERR("FAT stat ChangeDrive err 0x%x!\r\n", ret); PRINT_ERR("FAT stat ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_stat(path, &fileInfo); res = f_stat(path, &fileInfo);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT stat err 0x%x!\r\n", res); PRINT_ERR("FAT stat err 0x%x!\r\n", res);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
buf->st_size = fileInfo.fsize; buf->st_size = fileInfo.fsize;
@ -740,43 +598,27 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
buf->st_mode |= S_IFDIR; buf->st_mode |= S_IFDIR;
} }
ret = (int)LOS_OK; return (int)LOS_OK;
OUT:
FsUnlock();
return ret;
} }
/* Synchronize all changes to Flash */ /* Synchronize all changes to Flash */
int FatfsSync(struct File *file) int FatfsSync(struct File *file)
{ {
int ret;
FRESULT res; FRESULT res;
FIL *fp = (FIL *)file->fData; FIL *fp = (FIL *)file->fData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) { if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_sync(fp); res = f_sync(fp);
if (res != FR_OK) { if (res != FR_OK) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = (int)LOS_OK;
OUT: return (int)LOS_OK;
FsUnlock();
return ret;
} }
int FatfsMkdir(struct MountPoint *mp, const char *path) int FatfsMkdir(struct MountPoint *mp, const char *path)
@ -789,38 +631,26 @@ int FatfsMkdir(struct MountPoint *mp, const char *path)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) { if (!mp->mWriteEnable) {
errno = EACCES; errno = EACCES;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = FsChangeDrive(path); ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) { if (ret != (int)LOS_OK) {
PRINT_ERR("FAT mkdir ChangeDrive err 0x%x!\r\n", ret); PRINT_ERR("FAT mkdir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_mkdir(path); res = f_mkdir(path);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT mkdir err 0x%x!\r\n", res); PRINT_ERR("FAT mkdir err 0x%x!\r\n", res);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = (int)LOS_OK;
OUT: return (int)LOS_OK;
FsUnlock();
return ret;
} }
int FatfsOpendir(struct Dir *dir, const char *dirName) int FatfsOpendir(struct Dir *dir, const char *dirName)
@ -831,47 +661,35 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
if (dirName == NULL) { if (dirName == NULL) {
errno = EFAULT; errno = EFAULT;
goto ERROUT; return (int)LOS_NOK;
}
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
if (dp == NULL) {
errno = ENOENT;
goto ERROUT;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
goto ERROUT;
} }
ret = FsChangeDrive(dirName); ret = FsChangeDrive(dirName);
if (ret != (int)LOS_OK) { if (ret != (int)LOS_OK) {
PRINT_ERR("FAT opendir ChangeDrive err 0x%x!\r\n", ret); PRINT_ERR("FAT opendir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT; errno = ENOENT;
goto ERROUT; return (int)LOS_NOK;
} }
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
if (dp == NULL) {
errno = ENOENT;
return (int)LOS_NOK;
}
(void)memset_s(dp, sizeof(DIR), 0, sizeof(DIR));
res = f_opendir(dp, dirName); res = f_opendir(dp, dirName);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT opendir err 0x%x!\r\n", res); PRINT_ERR("FAT opendir err 0x%x!\r\n", res);
LOSCFG_FS_FREE_HOOK(dp);
errno = FatfsErrno(res); errno = FatfsErrno(res);
goto ERROUT; return (int)LOS_NOK;
} }
dir->dData = dp; dir->dData = dp;
dir->dOffset = 0; dir->dOffset = 0;
FsUnlock();
return (int)LOS_OK; return (int)LOS_OK;
ERROUT:
if (dp != NULL) {
LOSCFG_FS_FREE_HOOK(dp);
}
FsUnlock();
return (int)LOS_NOK;
} }
int FatfsReaddir(struct Dir *dir, struct dirent *dent) int FatfsReaddir(struct Dir *dir, struct dirent *dent)
@ -879,7 +697,6 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
FRESULT res; FRESULT res;
FILINFO fileInfo = {0}; FILINFO fileInfo = {0};
DIR *dp = NULL; DIR *dp = NULL;
int ret;
if ((dir == NULL) || (dir->dData == NULL)) { if ((dir == NULL) || (dir->dData == NULL)) {
errno = EBADF; errno = EBADF;
@ -887,18 +704,11 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
} }
dp = (DIR *)dir->dData; dp = (DIR *)dir->dData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
res = f_readdir(dp, &fileInfo); res = f_readdir(dp, &fileInfo);
/* if res not ok or fname is NULL , return NULL */ /* if res not ok or fname is NULL , return NULL */
if ((res != FR_OK) || (fileInfo.fname[0] == 0x0)) { if ((res != FR_OK) || (fileInfo.fname[0] == 0x0)) {
PRINT_ERR("FAT readdir err 0x%x!\r\n", res); PRINT_ERR("FAT readdir err 0x%x!\r\n", res);
errno = FatfsErrno(res); errno = FatfsErrno(res);
FsUnlock();
return (int)LOS_NOK; return (int)LOS_NOK;
} }
@ -909,7 +719,6 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
} else { } else {
dent->d_type = DT_REG; dent->d_type = DT_REG;
} }
FsUnlock();
return (int)LOS_OK; return (int)LOS_OK;
} }
@ -918,7 +727,6 @@ int FatfsClosedir(struct Dir *dir)
{ {
FRESULT res; FRESULT res;
DIR *dp = NULL; DIR *dp = NULL;
int ret;
if ((dir == NULL) || (dir->dData == NULL)) { if ((dir == NULL) || (dir->dData == NULL)) {
errno = EBADF; errno = EBADF;
@ -926,23 +734,15 @@ int FatfsClosedir(struct Dir *dir)
} }
dp = dir->dData; dp = dir->dData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
res = f_closedir(dp); res = f_closedir(dp);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT closedir err 0x%x!\r\n", res); PRINT_ERR("FAT closedir err 0x%x!\r\n", res);
FsUnlock();
errno = FatfsErrno(res); errno = FatfsErrno(res);
return (int)LOS_NOK; return (int)LOS_NOK;
} }
LOSCFG_FS_FREE_HOOK(dir->dData); LOSCFG_FS_FREE_HOOK(dir->dData);
dir->dData = NULL; dir->dData = NULL;
FsUnlock();
return (int)LOS_OK; return (int)LOS_OK;
} }
@ -957,38 +757,26 @@ int FatfsRmdir(struct MountPoint *mp, const char *path)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) { if (!mp->mWriteEnable) {
errno = EACCES; errno = EACCES;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = FsChangeDrive(path); ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) { if (ret != (int)LOS_OK) {
PRINT_ERR("FAT rmdir ChangeDrive err 0x%x!\r\n", ret); PRINT_ERR("FAT rmdir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_rmdir(path); res = f_rmdir(path);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT rmdir err 0x%x!\r\n", res); PRINT_ERR("FAT rmdir err 0x%x!\r\n", res);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = (int)LOS_OK;
OUT: return (int)LOS_OK;
FsUnlock();
return ret;
} }
int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName) int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
@ -1001,38 +789,26 @@ int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) { if (!mp->mWriteEnable) {
errno = EACCES; errno = EACCES;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = FsChangeDrive(oldName); ret = FsChangeDrive(oldName);
if (ret != (int)LOS_OK) { if (ret != (int)LOS_OK) {
PRINT_ERR("FAT f_getfree ChangeDrive err 0x%x!\r\n", ret); PRINT_ERR("FAT f_getfree ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_rename(oldName, newName); res = f_rename(oldName, newName);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT frename err 0x%x!\r\n", res); PRINT_ERR("FAT frename err 0x%x!\r\n", res);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = (int)LOS_OK;
OUT: return (int)LOS_OK;
FsUnlock();
return ret;
} }
int FatfsStatfs(const char *path, struct statfs *buf) int FatfsStatfs(const char *path, struct statfs *buf)
@ -1047,26 +823,18 @@ int FatfsStatfs(const char *path, struct statfs *buf)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path); ret = FsChangeDrive(path);
if (ret != FR_OK) { if (ret != FR_OK) {
PRINT_ERR("FAT f_getfree ChangeDrive err %d.", ret); PRINT_ERR("FAT f_getfree ChangeDrive err %d.", ret);
errno = FatfsErrno(FR_INVALID_PARAMETER); errno = FatfsErrno(FR_INVALID_PARAMETER);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_getfree(path, &freeClust, &fs); res = f_getfree(path, &freeClust, &fs);
if (res != FR_OK) { if (res != FR_OK) {
PRINT_ERR("FAT f_getfree err 0x%x.", res); PRINT_ERR("FAT f_getfree err 0x%x.", res);
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
buf->f_bfree = freeClust; buf->f_bfree = freeClust;
buf->f_bavail = freeClust; buf->f_bavail = freeClust;
@ -1078,11 +846,7 @@ int FatfsStatfs(const char *path, struct statfs *buf)
buf->f_bsize = FF_MIN_SS * fs->csize; buf->f_bsize = FF_MIN_SS * fs->csize;
#endif #endif
ret = (int)LOS_OK; return (int)LOS_OK;
OUT:
FsUnlock();
return ret;
} }
static int DoTruncate(struct File *file, off_t length, UINT32 count) static int DoTruncate(struct File *file, off_t length, UINT32 count)
@ -1090,7 +854,6 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
FRESULT res = FR_OK; FRESULT res = FR_OK;
DWORD csz; DWORD csz;
FIL *fp = (FIL *)file->fData; FIL *fp = (FIL *)file->fData;
int ret = (int)LOS_OK;
csz = (DWORD)(fp->obj.fs)->csize * SS(fp->obj.fs); /* Cluster size */ csz = (DWORD)(fp->obj.fs)->csize * SS(fp->obj.fs); /* Cluster size */
if (length > csz * count) { if (length > csz * count) {
@ -1098,8 +861,7 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
res = f_expand(fp, 0, (FSIZE_t)(length), FALLOC_FL_KEEP_SIZE); res = f_expand(fp, 0, (FSIZE_t)(length), FALLOC_FL_KEEP_SIZE);
#else #else
errno = ENOSYS; errno = ENOSYS;
ret = (int)LOS_NOK; return (int)LOS_NOK;
return ret;
#endif #endif
} else if (length < csz * count) { } else if (length < csz * count) {
res = f_truncate(fp, (FSIZE_t)length); res = f_truncate(fp, (FSIZE_t)length);
@ -1107,14 +869,13 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
if (res != FR_OK) { if (res != FR_OK) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
return ret;
} }
fp->obj.objsize = length; /* Set file size to length */ fp->obj.objsize = length; /* Set file size to length */
fp->flag |= 0x40; /* Set modified flag */ fp->flag |= 0x40; /* Set modified flag */
return ret; return (int)LOS_OK;
} }
int FatfsTruncate(struct File *file, off_t length) int FatfsTruncate(struct File *file, off_t length)
@ -1123,49 +884,30 @@ int FatfsTruncate(struct File *file, off_t length)
UINT count; UINT count;
DWORD fclust; DWORD fclust;
FIL *fp = (FIL *)file->fData; FIL *fp = (FIL *)file->fData;
int ret;
if ((length < 0) || (length > UINT_MAX)) { if ((length < 0) || (length > UINT_MAX)) {
errno = EINVAL; errno = EINVAL;
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) { if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT; errno = ENOENT;
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
res = f_getclustinfo(fp, &fclust, &count); res = f_getclustinfo(fp, &fclust, &count);
if (res != FR_OK) { if (res != FR_OK) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = DoTruncate(file, length, count); return DoTruncate(file, length, count);
if (ret != FR_OK) {
goto OUT;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
} }
int FatfsFdisk(const char *dev, int *partTbl, int arrayNum) int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
{ {
int pdrv; int pdrv;
FRESULT res; FRESULT res;
int ret;
if ((dev == NULL) || (partTbl == NULL)) { if ((dev == NULL) || (partTbl == NULL)) {
errno = EFAULT; errno = EFAULT;
@ -1178,25 +920,13 @@ int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
ret = (int)LOS_NOK;
goto OUT;
}
res = f_fdisk(pdrv, (DWORD const *)partTbl, g_workBuffer); res = f_fdisk(pdrv, (DWORD const *)partTbl, g_workBuffer);
if (res != FR_OK) { if (res != FR_OK) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; return (int)LOS_NOK;
goto OUT;
} }
ret = (int)LOS_OK; return (int)LOS_OK;
OUT:
FsUnlock();
return ret;
} }
int FatfsFormat(const char *partName, void *privData) int FatfsFormat(const char *partName, void *privData)
@ -1205,7 +935,6 @@ int FatfsFormat(const char *partName, void *privData)
MKFS_PARM opt = {0}; MKFS_PARM opt = {0};
int option = *(int *)privData; int option = *(int *)privData;
char *dev = NULL; /* logical driver */ char *dev = NULL; /* logical driver */
int ret;
if (partName == NULL) { if (partName == NULL) {
errno = EFAULT; errno = EFAULT;
@ -1218,29 +947,17 @@ int FatfsFormat(const char *partName, void *privData)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
ret = FsLock();
if (ret != 0) {
errno = ret;
PutLdPath(dev);
return (int)LOS_NOK;
}
opt.fmt = option; opt.fmt = option;
opt.n_sect = 0; /* use default allocation unit size depends on the volume opt.n_sect = 0; /* use default allocation unit size depends on the volume
size. */ size. */
res = f_mkfs(dev, &opt, g_workBuffer, FF_MAX_SS); res = f_mkfs(dev, &opt, g_workBuffer, FF_MAX_SS);
if (res != FR_OK) { if (res != FR_OK) {
errno = FatfsErrno(res); errno = FatfsErrno(res);
ret = (int)LOS_NOK; PutLdPath(dev);
goto OUT; return (int)LOS_NOK;
} }
ret = (int)LOS_OK; return (int)LOS_OK;
OUT:
PutLdPath(dev);
FsUnlock();
return ret;
} }
static struct MountOps g_fatfsMnt = { static struct MountOps g_fatfsMnt = {

View File

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

View File

@ -32,7 +32,6 @@
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#include "lfs_adapter.h" #include "lfs_adapter.h"
#include "los_config.h" #include "los_config.h"
#include "los_fs.h"
#include "vfs_files.h" #include "vfs_files.h"
#include "vfs_operations.h" #include "vfs_operations.h"
#include "vfs_partition.h" #include "vfs_partition.h"
@ -41,8 +40,6 @@
#include "securec.h" #include "securec.h"
#include "los_fs.h" #include "los_fs.h"
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
static struct PartitionCfg g_partitionCfg; static struct PartitionCfg g_partitionCfg;
static struct DeviceDesc *g_lfsDevice = NULL; static struct DeviceDesc *g_lfsDevice = NULL;
@ -378,7 +375,6 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo); ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
if (ret == TRUE) { if (ret == TRUE) {
pthread_mutex_lock(&g_fsLocalMutex);
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1); (void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
if (lfsInfo.type == LFS_TYPE_DIR) { if (lfsInfo.type == LFS_TYPE_DIR) {
dent->d_type = DT_DIR; dent->d_type = DT_DIR;
@ -387,7 +383,6 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
} }
dent->d_reclen = lfsInfo.size; dent->d_reclen = lfsInfo.size;
pthread_mutex_unlock(&g_fsLocalMutex);
return LOS_OK; return LOS_OK;
} }
@ -567,10 +562,7 @@ int LfsClose(struct File *file)
return (int)LOS_NOK; return (int)LOS_NOK;
} }
pthread_mutex_lock(&g_fsLocalMutex);
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle); ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
pthread_mutex_unlock(&g_fsLocalMutex);
if (ret != 0) { if (ret != 0) {
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = (int)LOS_NOK; ret = (int)LOS_NOK;

View File

@ -41,14 +41,14 @@ kernel_module(module_name) {
] ]
include_dirs = [ include_dirs = [
"//kernel/liteos_m/kernel/arch/include", "$LITEOSTOPDIR/kernel/arch/include",
"//kernel/liteos_m/kernel/include", "$LITEOSTOPDIR/kernel/include",
"//kernel/liteos_m/utils", "$LITEOSTOPDIR/utils",
"../", "../",
".", ".",
] ]
deps = [ "//kernel/liteos_m/kal" ] deps = [ "$LITEOSTOPDIR/kal" ]
configs += [ "$LITEOSTOPDIR:warn_config" ] configs += [ "$LITEOSTOPDIR:warn_config" ]
if (!defined(LOSCFG_COMPILER_ICCARM)) { if (!defined(LOSCFG_COMPILER_ICCARM)) {
cflags = [ "-Wno-parentheses" ] cflags = [ "-Wno-parentheses" ]

View File

@ -30,6 +30,23 @@
config FS_VFS config FS_VFS
bool "Enable FS VFS" bool "Enable FS VFS"
default y default y
select POSIX_FS_API
help help
Answer Y to enable LiteOS support VFS. Answer Y to enable LiteOS support VFS.
if FS_VFS
config FS_LOCK_TIMEOUT
int "Filesystem global lock timeout value in tick. -1 for waiting forever"
default -1
help
The timeout value of getting filesystem lock in tick. -1 for waiting forever
config FS_SUPPORT_MOUNT_TARGET_RECURSIVE
bool "Mount target can be recursive"
default n
depends on FS_VFS
help
Answer Y to enable LiteOS support VFS mount recursively. For example, "/system/bin".
endif

View File

@ -46,6 +46,7 @@
#include "sys/uio.h" #include "sys/uio.h"
#include "unistd.h" #include "unistd.h"
#include <stdarg.h> #include <stdarg.h>
#include "vfs_maps.h"
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
@ -61,41 +62,6 @@ extern "C" {
#define LOSCFG_FS_FREE_HOOK(ptr) LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, ptr) #define LOSCFG_FS_FREE_HOOK(ptr) LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, ptr)
#endif #endif
int LOS_Open(const char *path, int flags, ...);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
ssize_t LOS_Write(int fd, const void *buff, size_t bytes);
off_t LOS_Lseek(int fd, off_t off, int whence);
int LOS_Stat(const char *path, struct stat *stat);
int LOS_Statfs(const char *path, struct statfs *buf);
int LOS_Unlink(const char *path);
int LOS_Rename(const char *oldpath, const char *newpath);
int LOS_Fsync(int fd);
DIR *LOS_Opendir(const char *path);
struct dirent *LOS_Readdir(DIR *dir);
int LOS_Closedir(DIR *dir);
int LOS_Mkdir(const char *path, mode_t mode);
int LOS_Rmdir(const char *path);
int LOS_Lstat(const char *path, struct stat *buffer);
int LOS_Fstat(int fd, struct stat *buf);
int LOS_Fcntl(int fd, int cmd, ...);
int LOS_Ioctl(int fd, int req, ...);
ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off);
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off);
int LOS_Isatty(int fd);
int LOS_Access(const char *path, int amode);
int LOS_Ftruncate(int fd, off_t length);
int LOS_FsUmount(const char *target);
int LOS_FsUmount2(const char *target, int flag);
int LOS_FsMount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data);
int OsFcntl(int fd, int cmd, va_list ap);
int OsIoctl(int fd, int req, va_list ap);
struct PartitionCfg { struct PartitionCfg {
/* partition low-level read func */ /* partition low-level read func */
int (*readFunc)(int partition, UINT32 *offset, void *buf, UINT32 size); int (*readFunc)(int partition, UINT32 *offset, void *buf, UINT32 size);
@ -152,6 +118,39 @@ int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int
*/ */
int LOS_PartitionFormat(const char *partName, char *fsType, void *data); int LOS_PartitionFormat(const char *partName, char *fsType, void *data);
/*
* @brief new file system callbacks register.
* These callback functions are the adaptation layer implemented by the developer,
* used to interconnect the vfs with the new file system.
*
* LOS_FsRegister must be called after kernel initialization is complete.
*
* @param fsType file system type, don't register the same type fs more than once.
* @param fsMops mount operation of the fs.
* @param fsFops file operation of the fs.
* @param fsMgt management operation of the fs.
*
* @return Return LOS_OK if success.
* Return LOS_NOK if error.
* errno EINVAL: input errors, such as null pointers.
* errno ENOMEM: memory may malloc failed.
*
*/
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
/*
* @brief Lock the whole filesystem to forbid filesystem access.
*
* @return Return LOS_NOK if error. Return LOS_OK if seccess.
*/
int LOS_FsLock(void);
/*
* @brief Unlock the whole filesystem to allow filesystem access.
*/
void LOS_FsUnlock(void);
#ifdef __cplusplus #ifdef __cplusplus
#if __cplusplus #if __cplusplus
extern "C" { extern "C" {

View File

@ -49,21 +49,17 @@
#ifdef LOSCFG_FS_FAT #ifdef LOSCFG_FS_FAT
#include "fatfs_conf.h" #include "fatfs_conf.h"
#define __FAT_NFILE FAT_MAX_OPEN_FILES
#else
#define __FAT_NFILE 0
#endif #endif
#ifdef LOSCFG_FS_LITTLEFS #ifdef LOSCFG_FS_LITTLEFS
#include "lfs_conf.h" #include "lfs_conf.h"
#define __LFS_NFILE LOSCFG_LFS_MAX_OPEN_FILES
#else
#define __LFS_NFILE 0
#endif #endif
#define CONFIG_NFILE_DESCRIPTORS (__FAT_NFILE + __LFS_NFILE) #ifndef CONFIG_NFILE_DESCRIPTORS
#define CONFIG_NFILE_DESCRIPTORS 256
#endif
#define NR_OPEN_DEFAULT CONFIG_NFILE_DESCRIPTORS #define NR_OPEN_DEFAULT (CONFIG_NFILE_DESCRIPTORS - MIN_START_FD)
/* time configure */ /* time configure */

View File

@ -39,7 +39,7 @@
static struct File g_files[NR_OPEN_DEFAULT]; static struct File g_files[NR_OPEN_DEFAULT];
int FileToFd(struct File *file) int FileToFd(const struct File *file)
{ {
if (file == NULL) { if (file == NULL) {
return (int)LOS_NOK; return (int)LOS_NOK;

View File

@ -78,7 +78,7 @@ struct File {
off_t fOffset; off_t fOffset;
INT32 fOwner; INT32 fOwner;
struct MountPoint *fMp; struct MountPoint *fMp;
void *fData; /* file system opreations handle, fatfs FIL, etc. */ void *fData; /* file system operations handle, fatfs FIL, etc. */
const char *fullPath; const char *fullPath;
}; };
@ -89,7 +89,7 @@ struct Dir {
void *dData; void *dData;
}; };
int FileToFd(struct File *file); int FileToFd(const struct File *file);
struct File *FdToFile(int fd); struct File *FdToFile(int fd);
struct File *VfsFileGet(void); struct File *VfsFileGet(void);
struct File *VfsFileGetSpec(int fd); struct File *VfsFileGetSpec(int fd);

File diff suppressed because it is too large Load Diff

View File

@ -41,31 +41,33 @@ struct FsMap *VfsFsMapGet(const char *fsType)
{ {
struct FsMap *curr = g_fsMap; struct FsMap *curr = g_fsMap;
(void)VfsLock(); (void)LOS_FsLock();
while (curr != NULL) { while (curr != NULL) {
if ((curr->fsType != NULL) && (fsType != NULL) && if ((curr->fsType != NULL) && (fsType != NULL) &&
(strcmp(curr->fsType, fsType) == 0)) { (strcmp(curr->fsType, fsType) == 0)) {
(void)VfsUnlock(); LOS_FsUnlock();
return curr; return curr;
} }
curr = curr->next; curr = curr->next;
} }
VfsUnlock(); LOS_FsUnlock();
return NULL; return NULL;
} }
int OsFsRegister(const char *fsType, struct MountOps *fsMops, int OsFsRegister(const char *fsType, const struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt) const struct FileOps *fsFops, const struct FsManagement *fsMgt)
{ {
size_t len; size_t len;
if ((fsMops == NULL) || (fsFops == NULL)) { if ((fsMops == NULL) || (fsFops == NULL)) {
VFS_ERRNO_SET(EINVAL);
return (int)LOS_NOK; return (int)LOS_NOK;
} }
struct FsMap *newfs = (struct FsMap *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct FsMap)); struct FsMap *newfs = (struct FsMap *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct FsMap));
if (newfs == NULL) { if (newfs == NULL) {
PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType); PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType);
VFS_ERRNO_SET(ENOMEM);
return (int)LOS_NOK; return (int)LOS_NOK;
} }
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap)); (void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
@ -74,6 +76,7 @@ int OsFsRegister(const char *fsType, struct MountOps *fsMops,
newfs->fsType = LOSCFG_FS_MALLOC_HOOK(len); newfs->fsType = LOSCFG_FS_MALLOC_HOOK(len);
if (newfs->fsType == NULL) { if (newfs->fsType == NULL) {
LOSCFG_FS_FREE_HOOK(newfs); LOSCFG_FS_FREE_HOOK(newfs);
VFS_ERRNO_SET(ENOMEM);
return (int)LOS_NOK; return (int)LOS_NOK;
} }
(void)strcpy_s((char *)newfs->fsType, len, fsType); (void)strcpy_s((char *)newfs->fsType, len, fsType);
@ -83,10 +86,22 @@ int OsFsRegister(const char *fsType, struct MountOps *fsMops,
newfs->fsMgt = fsMgt; newfs->fsMgt = fsMgt;
newfs->fsRefs = 0; newfs->fsRefs = 0;
(void)VfsLock(); (void)LOS_FsLock();
newfs->next = g_fsMap; newfs->next = g_fsMap;
g_fsMap = newfs; g_fsMap = newfs;
VfsUnlock(); LOS_FsUnlock();
return LOS_OK; return LOS_OK;
} }
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
const struct FileOps *fsFops, const struct FsManagement *fsMgt)
{
if (VfsFsMapGet(fsType) != NULL) {
PRINT_ERR("fsType has been registered or fsType error\n");
VFS_ERRNO_SET(EINVAL);
return (int)LOS_NOK;
}
return OsFsRegister(fsType, fsMops, fsFops, fsMgt);
}

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