Compare commits

..

325 Commits

Author SHA1 Message Date
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
xiacong
784429d0dc <fix>
修复报警信息,为以下修复点
1、修复空指针未判断
2、修复open后未及时close 导致内存泄露
3、修复strdup后未free
4、修复赋值后未使用等问题
5、修复编码中判断条件中无符号变量小于零的情况

Signed-off-by: xiacong <xiacong4@huawei.com>
Change-Id: I13d046141afeb8a116e6a04304a3793bf8e12bee
Signed-off-by: xiacong <xiacong4@huawei.com>
2022-09-24 22:11:27 +08: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
openharmony_ci
044cf59583 !825 M核用例编译问题修复, 内核补充fcntl
Merge pull request !825 from wangchen/0917_m
2022-09-22 09:06:20 +00:00
wangchen
0adbafb9c2 \fix: M核用例编译问题修复
【背景】M核用例编译问题修复

【修改方案】
1, 添加musl缺失的fcntl
2,删除musl下对fcntl和ioctl的依赖
3,修改fs和vfs种fcntl入参的处理

【影响】
对现有的产品编译不会有影响。
re #I5PKBJ
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-09-21 07:20:12 +00:00
openharmony_ci
3398937b1b !822 Fix : 内核告警清理
Merge pull request !822 from yinjiaming/fix
2022-09-21 04:42:39 +00:00
openharmony_ci
3c010b4717 !828 【轻量级 PR】:【OpenHarmony开源贡献者计划2022】fix warning: 'return' with a value, in function returning void
Merge pull request !828 from wangziyi0929/N/A
2022-09-21 03:09:31 +00:00
yinjiaming
c237ff63fa fix: 内核告警修复
【背景】
内核代码经扫描工具检测发现有可以修改的
告警

【修改方案】
1. 对只有单一语句的if, while等添加括号使之符合编程规范
2. 将C 风格的类型转换变为 C++ 风格的

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I0b7659882eec777cade3ee21e76a42a86e2ce822
2022-09-21 10:30:30 +08:00
wangziyi0929
3508110f6d fix warning: 'return' with a value, in function returning void
Signed-off-by: wangziyi0929 <915619048@qq.com>
2022-09-19 07:55:05 +00:00
openharmony_ci
ffa868a81c !827 M核对公共基础类库路径依赖修改
Merge pull request !827 from wangchen/0919_m
2022-09-19 07:06:17 +00:00
wangchen
7d391c9bbf fix: M核对公共基础类库路径依赖修改
【背景】M核对公共基础类库路径依赖修改

【修改方案】
1, 修改lwip依赖的路径

【影响】
对现有的产品编译不会有影响。
re #I5RSMC
Signed-off-by: wangchen <wangchen240@huawei.com>
https://gitee.com/openharmony/kernel_liteos_m/issues/I5RSMC
2022-09-19 06:28:16 +00:00
openharmony_ci
e4a1c18d40 !826 【OpenHarmony开源贡献者计划2022】 删除未初始化的变量ret
Merge pull request !826 from 刘淦/master
2022-09-19 02:38:00 +00:00
liugan
83790f4f9b remove unused variable ret
Signed-off-by: liugan <liugan_public@163.com>
2022-09-17 17:16:17 +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
openharmony_ci
b8f8ab5a36 !807 非安全函数告警清理
Merge pull request !807 from xuxinyu/function_s
2022-08-26 04:45:26 +00:00
xuxinyu
a0b776a709 非安全函数告警清理
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: I45bbaa3568be3679b34b1e8b072d19d878fdbf02
2022-08-25 20:50:48 +08:00
openharmony_ci
f5f18ca669 !812 fix:iccarm下fs的编译错误
Merge pull request !812 from Zhaotianyu/20220824iccarm_fs_fix
2022-08-24 10:49:19 +00:00
arvinzzz
5756d45e84 fix: 修复fs在iccarm下的编译错误
close: #I5NXFL

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-08-24 16:59:42 +08:00
openharmony_ci
8a25f31aa4 !809 unittest关联issue
Merge pull request !809 from Hongjin Li/dev2
2022-08-24 06:36:20 +00:00
Hongjin Li
f7cc6ff14e test: unittest 关联 issue number
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I0a735c85c004ef3171eb170effacc034e3c8cd1a
2022-08-24 11:31:55 +08:00
openharmony_ci
bf9e0c9e2b !805 补充unittest用例描述
Merge pull request !805 from Hongjin Li/dev1
2022-08-23 14:03:19 +00:00
Hongjin Li
e9de74a94a test: testcase description
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I1f8067dfbde2c12c092d5c9570f6ad45430f58ef

Change-Id: Ifad39593d943a29771691b6c23289d9774f5dfab
2022-08-23 21:20:54 +08:00
openharmony_ci
b38f135242 !795 低功耗增加idle选项
Merge pull request !795 from zhushengle/pm
2022-08-23 13:06:03 +00:00
openharmony_ci
0cb50baa55 !801 编译构建规范优化
Merge pull request !801 from Hongjin Li/dev
2022-08-23 12:26:15 +00:00
Hongjin Li
565049f1eb style: string format in python
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I0d6ffb978bf4f96fd546868a6dd5f20d2cefbfd6
2022-08-23 18:52:42 +08:00
zhushengle
9add4b4b92 feat: 低功耗增加idle选项
Close #I5N9J2

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I066ff415709145e585f1eb94e70263361d3d71af
2022-08-22 17:04:08 +08:00
openharmony_ci
5992506c75 !796 feature:允许device_path指向vendor
Merge pull request !796 from Zhaotianyu/20220820build.gn
2022-08-20 08:38:20 +00:00
arvinzzz
d4db5a5a75 feature: BUILD.gn中device_path允许指向vendor
close: #I5N9NC

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: If6a05871a0c78a92d6370b73528674e411642e20
2022-08-20 15:54:44 +08:00
openharmony_ci
fe8b68826a !792 fix: iccarm fatfs编译问题修复
Merge pull request !792 from Zhaotianyu/20220818iccarm_fatfs
2022-08-18 11:38:21 +00:00
arvinzzz
99640e9977 fix: fatfs iccarm编译修复
close: #I5MZ62

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ie3882e443406d5055ff58c780cd376ddd6054bbf
2022-08-18 17:47:34 +08:00
openharmony_ci
0dc3c7ae9e !782 【轻量级 PR】:删除未使用的ret变量
Merge pull request !782 from fanhonglin/N/A
2022-08-17 06:11:28 +00:00
openharmony_ci
699bb81fc3 !721 完善文件系统vfs层初始化函数
Merge pull request !721 from LeonChan/oh
2022-08-17 04:35:45 +00:00
leonchan5
f2c4b59773 feat: liteos-m文件系统初始化函数支持littlefs
VFS初始化函数LOS_DiskPartition及LfsFormat支持littlefs,支持对flash设备进行分区和格式化操作
1,VFS层记录Fat/littlefs设备名称、分区等信息,后续在本层做处理
2,flash设备的相关配置及驱动操作接口通过LOS_DiskPartition配置,产品不用直接面向具体文件系统

close: #I5CYKI

Signed-off-by: leonchan5 <chenwei26@huawei.com>
2022-08-16 18:55:53 +08:00
openharmony_ci
b656553c5c !786 【OpenHarmony开源贡献者计划2022】change LOS_IntLock() to (VOID)LOS_IntLock()
Merge pull request !786 from chianqi/LOS_IntLock
2022-08-16 01:21:18 +00:00
openharmony_ci
7653bd8da1 !780 【OpenHarmony开源贡献者计划2022】remove unnecessary extern "C"
Merge pull request !780 from 宋晓丽/cpp
2022-08-16 01:14:55 +00:00
openharmony_ci
1275ecbc8a !778 【OpenHarmony开源贡献者计划2022】+ store拼写不对
Merge pull request !778 from 虚竹/master
2022-08-16 01:13:02 +00:00
openharmony_ci
ebc57397f0 !785 【OpenHarmony开源贡献者计划2022】change memset to (VOID)memset when not handling the return value
Merge pull request !785 from qian8888/lms
2022-08-16 01:12:07 +00:00
anqi
cce6365f4f change LOS_IntLock() to (VOID)LOS_IntLock()
Signed-off-by: anqi <anqi@liuxiuhai.cn>
2022-08-15 20:51:29 +08:00
zq
04f391d814 change memset to (VOID)memset when not handling the return value
Signed-off-by: zq <zhangqian@liuxiuhai.cn>
2022-08-15 19:56:39 +08:00
openharmony_ci
14e64fc89b !783 修改littlefs readdir在完全读完后,会设置错误码EBADF
Merge pull request !783 from wangchen/0812_m
2022-08-12 09:44:29 +00:00
wangchen
2ce5ce9397 fix: littlefs readdir在完全读完后,会设置错误码EBADF
【背景】littlefs readdir在完全读完后,会设置错误码EBADF

【修改方案】
1,  fsFops->readdir 执行返回非0时,有可能是正常情况,因此删除else赋值错误码

【影响】
对现有的产品编译不会有影响。
re #I5M1OE
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-08-12 09:25:20 +00:00
openharmony_ci
eb40e4a068 !775 【OpenHarmony开源贡献者计划2022】void TcpIpPortingInit()无参数时需要修改为(void)
Merge pull request !775 from sinall/master
2022-08-12 03:50:54 +00:00
openharmony_ci
dc5feb9e19 !774 【OpenHarmony开源贡献者计划2022】fix mempry to memory、satck to stack
Merge pull request !774 from rtos_ding/typo
2022-08-12 02:28:07 +00:00
openharmony_ci
7a61f8d836 !781 【OpenHarmony开源贡献者计划2022】change uwtimeout to timeout
Merge pull request !781 from 红叶电脑/timeout
2022-08-12 02:27:15 +00:00
openharmony_ci
330760dbb3 !779 【OpenHarmony开源贡献者计划2022】+ release拼写错误
Merge pull request !779 from 王小二/master
2022-08-12 02:24:20 +00:00
openharmony_ci
2739a00c55 !777 【OpenHarmony开源贡献者计划2022】+ 信号量 应该是 semaphore
Merge pull request !777 from 哈哈哈/master
2022-08-12 02:23:42 +00:00
openharmony_ci
7f14b060d4 !776 【OpenHarmony开源贡献者计划2022】修复一些规范小问题
Merge pull request !776 from VinceCarter123/void
2022-08-12 02:20:06 +00:00
fanhonglin
8be6e129fc 删除未使用的ret变量
Signed-off-by: fanhonglin <1064581928@qq.com>
2022-08-12 01:34:32 +00:00
wx880216
f465c15d7a change uwtimeout to timeout
Signed-off-by: wx880216 <wx880216@liuxiuhai.cn>
2022-08-12 01:15:13 +08:00
songxiaoli4790
0af2577498 remove unnecessary extern "C"
Signed-off-by: songxiaoli4790 <songxiaoli4790@liuxiuhai.cn>
2022-08-12 00:54:29 +08:00
王小二
238ff396b8 release拼写错误
Signed-off-by: 王小二 <x1234567890801@126.com>

Signed-off-by: 王小二 <x1234567890801@126.com>
2022-08-11 15:33:34 +00:00
虚竹
5917c4b01b store拼写不对
Signed-off-by: 虚竹 <x18919883794@163.com>

Signed-off-by: 虚竹 <x18919883794@163.com>
2022-08-11 15:23:12 +00:00
哈哈哈
5c4edb9b1a 信号量单词不合适
Signed-off-by:哈哈哈 <x16739329869@163.com>

Signed-off-by: 哈哈哈 <x16739329869@163.com>
2022-08-11 15:13:36 +00:00
danhao
ce176e77e6 add VOID to swtmr test function parameter list
Signed-off-by: danhao <danhao@liuxiuhai.cn>
2022-08-11 22:54:14 +08:00
Gao Rui
8ef012bdad Fix TcpIpPortingInit() to TcpIpPortingInit(void)
Signed-off-by: Gao Rui <gaoruinan@163.com>
2022-08-11 22:00:22 +08:00
juan
933efffba7 fix mempry to memory、satck to stack
Signed-off-by: juan <juan@liuxiuhai.cn>
2022-08-11 21:23:46 +08:00
openharmony_ci
ae692bfbc4 !768 feature: C库补充access、remove接口
Merge pull request !768 from Zhaotianyu/20220806fs_add
2022-08-11 11:05:50 +00:00
arvinzzz
ab46b9c836 feature: C库补充fs接口
close: #I5J5YD

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I21c11106b24b6e050d4061a98ad69b2b10a5a318
2022-08-11 15:43:02 +08:00
openharmony_ci
b83d17039e !771 补充cmsis queue测试用例
Merge pull request !771 from xuxinyu/CmsisTestCase
2022-08-11 06:42:40 +00:00
xuxinyu
08404f3252 补充cmsis queue测试用例
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ic717514a92c5b98f247ad7185122722878d16506
2022-08-11 11:43:12 +08:00
openharmony_ci
8b19c3cbe4 !770 新增静态队列用例
Merge pull request !770 from xuxinyu/StaticQueueTest
2022-08-09 11:38:03 +00:00
xuxinyu
192a2a6e61 新增静态队列用例
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ib07ab22ee884475d5bc4de54fb43c89eed2c1305
2022-08-09 16:47:27 +08:00
openharmony_ci
2ec2c369e7 !755 内核告警清理
Merge pull request !755 from yinjiaming/fix
2022-08-09 08:37:39 +00:00
openharmony_ci
f2b280bdbd !769 feature:支持queue地址外部部署共功能及queue名字设置
Merge pull request !769 from xuxinyu/static_by_id
2022-08-08 15:34:36 +00:00
xuxinyu
c09b3a8774 feature:支持queue地址外部部署共功能及queue名字设置
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: I1984014956a92d61d65b68f79279b2aa593a72e1
2022-08-08 23:11:11 +08:00
openharmony_ci
04cded2f0a !765 Fix : 修复了OsTraceInit() 参数错误问题
Merge pull request !765 from yinjiaming/dev
2022-08-05 10:16:12 +00:00
openharmony_ci
ddfb363675 !766 fix: iccarm编译修复
Merge pull request !766 from Zhaotianyu/20220801iccarm_fix
2022-08-02 01:47:08 +00:00
arvinzzz
d0c50a4af0 fix: iccarm编译修复
close: #I5JXMJ

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3fbaf459ad4807a44396f319a4d53d3cc1e7700c
2022-08-01 16:53:18 +08:00
yinjiaming
6affe19d5a fix: OsTraceInit参数错误修正
【背景】
los_init.c 中存在 OsTraceInit()参数不正确的
错误

【修改方案】
修改OsTraceInit()参数错误的地方, 并包含了相应的头文件

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

re #I5H4UT

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I112067819d1850003ba0b36bd344b4ab9a8878d5
2022-07-30 09:17:23 +00:00
yinjiaming
a36d5d9058 fix: 内核告警修复
【背景】
内核代码经代码扫描工具发现存在一些关于代码格式的告警,
现经修改解除掉告警。

【修改方案】
修改了代码中格式不规范的地方,修改的点有:
1.代码中一行过长
2.没有合理的添加空格和空行
3.没有按照规范进行缩进
4.括号的格式没有按照规范
5.注释的格式不对以及存在魔数字
6.函数的声明与定义的格式不一致
并更新了修改文件的版权头时间

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

re #I5H6F5
Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Id8eb0450d03fae537ea4c73190fdadb76b29253d
2022-07-29 08:30:38 +00:00
openharmony_ci
63bf098b0f !758 refactor:Kconfig选项解耦
Merge pull request !758 from Zhaotianyu/20220723Kconfig
2022-07-27 09:11:40 +00:00
openharmony_ci
252052f024 !757 M核time模块支持调用RTC接口
Merge pull request !757 from wangchen/0722_m
2022-07-26 15:05:28 +00:00
wangchen
8c46636052 fix: M核time模块支持调用RTC接口
【背景】M核time模块支持调用RTC接口

【修改方案】
1, 增加注册接口
2, 读写时间时判断是否有rtc

【影响】
对现有的产品编译不会有影响。
re #I5IKMN
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-07-26 14:23:08 +00:00
openharmony_ci
6ff615b9ca !756 拼写错误修正
Merge pull request !756 from yinjiaming/dev
2022-07-25 11:06:31 +00:00
arvinzzz
732a346399 refactor: Kconfig选项解耦
close: #I5I7LX

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ieaf3bc6bf0c345a7d7945abb9133bd40fbe9d5b8
2022-07-23 21:21:59 +08:00
yinjiaming
2931dc6013 fix: 拼写错误修正
【背景】
代码中存在拼写错误

【修改方案】
修改存在拼写错误的地方

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

re #I5IA7P

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Iba87369fef7dbcbcd974e07d4cb279874ff697fb
2022-07-21 11:18:24 +00:00
openharmony_ci
df30bc4e0a !753 M4 qemu newlibc与musl差异用例隔离
Merge pull request !753 from wangchen/0712_m
2022-07-18 06:18:00 +00:00
openharmony_ci
1599669290 !748 Use rv32i substring as RISC-V architecture selector
Merge pull request !748 from Dmytro Kosmii/master
2022-07-18 02:15:55 +00:00
wangchen
d8104f6290 fix: M4 qemu 开启newlibc编译报错
【背景】M4 qemu 开启newlibc编译报错

【修改方案】
删除musl依赖路径

【影响】
对现有的产品编译不会有影响。
re #I5GIAR
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-07-16 10:47:21 +00:00
Dmytro Kosmii
3a190a1a1b Added missed includes.
Signed-off-by: Dmytro Kosmii <dmytro.kosmii@telink-semi.com>
Change-Id: I172a68a1ad6ca194399a6d47d46c54ebcfbd9338
2022-07-12 19:45:07 +03:00
openharmony_ci
e1f986305b !745 iccarm工具链支持
Merge pull request !745 from wish/tag_iccarm
2022-07-12 11:05:34 +00:00
openharmony_ci
0c8b7d2a1b !751 refactor:编译框架对不同工具链的解耦优化
Merge pull request !751 from Zhaotianyu/20220712buildframework_opt
2022-07-12 09:40:58 +00:00
i-wangliangliang
62eb96dd8d iccarm工具链编译适配
Signed-off-by: i-wangliangliang <willfox@126.com>
Change-Id: I9360dc232c35ec4db7a9bee08f3c288e22941e39
2022-07-12 17:01:44 +08:00
arvinzzz
009d2503fb refactor: 编译框架对不同工具链的解耦优化
close: #I5GQ9A

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3e371a67bdab75c53e769e08c1c54ec83c741a69
2022-07-12 16:54:35 +08:00
openharmony_ci
39839d313c !749 feature: 编译框架支持iccarm
Merge pull request !749 from Zhaotianyu/20220711buildframework_iccarm
2022-07-12 08:27:37 +00:00
arvinzzz
d92c10d92d feature: 编译框架支持iccarm
close: #I5GL0C

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I94babac4d748b0c714835522a31f02b4f70de3e9
2022-07-12 14:54:15 +08:00
openharmony_ci
915b97b18e !746 Fix : 删除了不用的库文件
Merge pull request !746 from yinjiaming/master
2022-07-11 11:45:42 +00:00
openharmony_ci
9d0460b546 !741 Fix : 修复了测试用例返回值不匹配的问题
Merge pull request !741 from yinjiaming/fix
2022-07-11 11:19:21 +00:00
yinjiaming
12e8541b6f fix: 内核目录规范整改
【背景】
内核仓库中有一些废弃的二进制文件

【修改方案】
删去已不用的二进制文件与对应的头文件

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

re #I5GHWE

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I62ff61630b08e90022f3b1fb37a569d5b3627aa9
2022-07-11 07:20:06 +00:00
openharmony_ci
8170152730 !743 feature:新增cortex-m55的iar与trustzone支持
Merge pull request !743 from Zhaotianyu/20220707adapt_m55
2022-07-09 07:31:03 +00:00
Dmytro Kosmii
f7d79148b7 Use rv32i substring as RISC-V architecture selector.
Signed-off-by: Dmytro Kosmii <dmytro.kosmii@telink-semi.com>
Change-Id: Ie5b0b2be987f112bc150ec817080b59a332cbac1
2022-07-08 15:37:22 +03:00
arvinzzz
ad29f69777 feature: 新增cortex-m55的iar与trustzone支持
close: #I5G26W

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I1fbcbc6530085902afa86dc04c1760ffe5e97483
2022-07-07 19:45:33 +08:00
openharmony_ci
85663b9258 !739 fix: gcc低版本时BOOL类型重定义
Merge pull request !739 from Zhaotianyu/0630bool_fix
2022-07-06 08:43:43 +00:00
arvinzzz
4bd88ffb1f fix: gcc低版本时兼容与ohos_types.h的类型重定义
close: #I5EW48

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I897803addf5609b2f783d7b89ced9fb039e08f07
2022-07-06 15:37:24 +08:00
yinjiaming
6f92337be2 fix: 修复测试用例返回值不匹配的问题
【背景】
部分测试用例所使用的宏的返回值与函数本身返回值不匹配

【修改方案】
修改不匹配的宏和函数

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

re #I58CP5

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Id7b93e215cd760dbe36caea392db5abe3a1dd5f1
2022-07-05 12:13:58 +00:00
openharmony_ci
7add94de1f !737 【OpenHarmony开源贡献者计划2022】Fixed typos.
Merge pull request !737 from Mr_YX/master
2022-07-04 01:20:36 +00:00
openharmony_ci
dd36f4482c !738 Fix : 修改内核目录不规范的问题
Merge pull request !738 from yinjiaming/targets
2022-06-30 00:10:22 +00:00
yinjiaming
dcb2dbee77 fix: 修复内核目录不规范的问题
【背景】
内核中targets目录的位置不规范

【修改方案】
从内核仓库中删除targets目录

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

re #I5EFBF

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ic77eac4583c4ce141050ed1fe661d837408413ac
2022-06-29 08:13:29 +00:00
openharmony_ci
6a7a18e2d3 !723 Fix: 对测试用例中的POSIX相关的测试用例添加入口
Merge pull request !723 from yinjiaming/master
2022-06-29 07:36:42 +00:00
yinjiaming
7ecdbbe6d7 fix: 对与POSIX相关的测试用例添加入口
【背景】
posix 相关的测试用例中需要添加一个入口

【修改方案】
添加了对应的程序文件,并在该文件中调用所有POSIX相关的测试用例的函数

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I107dd5d7ec2691c8e1d8677b916b4b00c628506f
2022-06-28 08:20:09 +00:00
Mr_YX
e9425d1833 update kernel/src/los_sched.c.
Signed-off-by: mr-yx <496043997@qq.com>
2022-06-27 14:08:10 +00:00
mr-yx
527f6cf86e fixed typos
Signed-off-by: mr-yx <496043997@qq.com>
2022-06-27 22:05:19 +08:00
openharmony_ci
df9387c28f !725 fix: 修复系统时间比RTC时间过快的问题
Merge pull request !725 from zhushengle/tick_master
2022-06-25 09:41:52 +00:00
openharmony_ci
d08a3e3f13 !732 LOSCFG_PLATFORM_HWI_WITH_ARG开启后M核编译失败修改
Merge pull request !732 from wangchen/0623_hwi
2022-06-24 11:49:12 +00:00
openharmony_ci
48ff5189b8 !727 OsShellCmdFreeInfo打印换行修改
Merge pull request !727 from wangchen/0622_m
2022-06-24 10:37:52 +00:00
zhushengle
600283a96f fix: 修复系统时间比RTC时间过快的问题
1.标记在时间接口中更新base后在中断中不再更新base
2.优化tick计算

Close #I5DCRB

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ic3df09142519357353906d40e3fd3cdca5cac71d
2022-06-24 17:47:06 +08:00
openharmony_ci
a333e8f88e !734 删除osTimerNew接口中对传入的定时器类型的重复判断
Merge pull request !734 from Mr.W/dev
2022-06-24 06:41:02 +00:00
wangmeng
ce49331798 删除osTimerNew接口中对传入的定时器类型的重复判断
Signed-off-by: wangmeng <wangmeng90798@talkweb.com.cn>
2022-06-24 10:05:39 +08:00
wangchen
fc8c547b05 fix: LOSCFG_PLATFORM_HWI_WITH_ARG开启后M核编译失败修改
【背景】LOSCFG_PLATFORM_HWI_WITH_ARG开启后M核编译失败

【修改方案】
对涉及的函数指针进行强制转换

【影响】
对现有的产品编译不会有影响。
re #I4W4GM
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-06-23 11:43:29 +00:00
openharmony_ci
8cfadb9b4d !729 禁止导出符号被编译器优化掉
Merge pull request !729 from xuxinyu/master
2022-06-23 11:17:05 +00:00
openharmony_ci
2c5b750a46 !731 so 解析脚本单位表示错误
Merge pull request !731 from xuxinyu/FixdylinkSO_pares
2022-06-23 11:16:40 +00:00
x_xiny
3df936f1a1 禁止导出符号被编译器优化掉
re #I4XQC1

Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: I79a59e70ddaba746a50bd92aea647778c4e90a0c
2022-06-23 17:31:57 +08:00
x_xiny
6fa1fe5993 so 解析脚本单位表示错误
re #I4X3AL

Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Idd6d3c171b785ebd332402d3f29ffb484e644545
2022-06-23 17:18:57 +08:00
openharmony_ci
8a05eb6e08 !722 修复liteos_m仓库中存在的一些拼写错误
Merge pull request !722 from Hongjin Li/dev
2022-06-23 04:10:35 +00:00
lihongjin
243fe55c68 style: Misspelling
Signed-off-by: lihongjin <lihongjin1@huawei.com>
Change-Id: Ie14607b483d31a6efdf17e40e9937fe4bc2484c2
2022-06-23 09:46:16 +08:00
openharmony_ci
a7341d81d1 !702 【OpenHarmony开源贡献者计划2022】更新readme中的目录结构
Merge pull request !702 from yjzhkh/master
2022-06-23 00:51:41 +00:00
wangchen
c8ce65f408 fix: OsShellCmdFreeInfo打印换行格式混用修改
【背景】OsShellCmdFreeInfo打印换行格式混用

【修改方案】
删除\r

【影响】
对现有的产品编译不会有影响。
re #I52MES
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-06-22 07:50:26 +00:00
openharmony_ci
c1e3856bbe !714 eat: normalize drivers framework component and repos
Merge pull request !714 from yuanbo/master
2022-06-17 06:40:26 +00:00
yuanbo
3a887c616a feat: normalize drivers framework component and repos
Signed-off-by: yuanbo <yuanbo@huawei.com>
2022-06-15 20:07:10 +08:00
openharmony_ci
3303cd7bc1 !709 feature: C库适配iar
Merge pull request !709 from xuxinyu/master
2022-06-14 11:57:16 +00:00
x_xiny
7c5a05f352 feature: C库适配iar
re #I5BUG3

Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: I84591c7593622de22a33f411b7011d17034c6d55
2022-06-14 15:46:29 +08:00
openharmony_ci
5df101eae5 !703 TCB结构体扩展宏添加分号
Merge pull request !703 from 方烨/master
2022-06-14 05:47:21 +00:00
fangye
128c3dffb5 TCB结构体扩展宏添加分号
Signed-off-by: fangye <fangye@talkweb.com.cn>
Change-Id: Ic31310a1da1842adb1b19a0afb1448aa0f4720ef
2022-06-14 11:31:18 +08:00
openharmony_ci
e8f3f9674c !708 fix:测试套问题修复
Merge pull request !708 from Zhaotianyu/0613test_fix
2022-06-13 11:10:51 +00:00
arvinzzz
5cfec18d24 fix: 测试套问题修复
CLOCK_REALTIME在musl与newlib中的定义值不一致,测试套中不能写死某一个值,要用CLOCK_REALTIME

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ie88eaf3af2ae938a7c02f7acf08526dcf333fb93
2022-06-13 16:44:59 +08:00
openharmony_ci
def41f8edd !701 内存水线shell命令
Merge pull request !701 from wangchen/0607_water
2022-06-10 06:00:05 +00:00
yangjinzhuang
3387c32b8a 更新readme
Signed-off-by: yangjinzhuang <yangjinzhuang@kaihongdigi.com>
2022-06-10 10:32:37 +08:00
wangchen
6881d3da46 fix: 内存水线shell命令
【背景】内存水线shell命令

【修改方案】
1,添加shell命令, 通过LOS_MemInfoGet获取水线
2, 增加task命令显示任务的alloc情况
影响范围:
【影响】
对现有的产品编译不会有影响。
re #I5B6VT
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-06-09 02:55:32 +00:00
openharmony_ci
e21e8753d1 !700 debugtools 自验问题修复
Merge pull request !700 from wangchen/0607_up
2022-06-07 10:40:24 +00:00
wangchen
397f24dd6f fix: debugtools 自验问题修复
【背景】debugtools 自验问题修复

【修改方案】
1,hwi打印可能存在负数,不能使用%u
2,LOS_SchedTraceStop函数可能被单独调用,导致重复释放

影响范围:
【影响】
对现有的产品编译不会有影响。
re #I5B668
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-06-07 10:17:32 +00:00
openharmony_ci
831d089652 !697 M核函数命名错误
Merge pull request !697 from wangchen/0601_up
2022-06-06 07:02:07 +00:00
wangchen
f5fa92feff fix: M核函数命名错误
【背景】OsRecyleFinishedTask拼写问题

【修改方案】
Recyle -> Recycle

影响范围:
【影响】
对现有的产品编译不会有影响。
re #I56JB1
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-06-01 06:48:13 +00:00
openharmony_ci
bed1d28df8 !689 M核添加维测, 调度信息dump
Merge pull request !689 from wangchen/0512_track
2022-05-28 08:48:37 +00:00
wangchen
efebc00f87 fix: M核添加维测接口
【背景】M核添加维测接口

【修改方案】
1, 添加任务栈dump接口
2, 添加中断dump接口
3, 添加任务调度流程dump
【影响】
对现有的产品编译不会有影响。
re #I55DJV
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-05-28 08:24:30 +00:00
openharmony_ci
28c1529e2f !695 开启cpup后启动挂死
Merge pull request !695 from wangchen/0526_up
2022-05-26 11:55:22 +00:00
wangchen
159d304275 fix: 开启cpup后启动挂死
【背景】开启cpup后启动挂死

【修改方案】
1, cpup开启后,task模块会在g_cpup初始化前赋值。
    因此需提前cpup模块的初始化。
【影响】
对现有的产品编译不会有影响。
re #I59DDE
Signed-off-by: wangchen <wangchen64@huawei.com>
https://gitee.com/openharmony/kernel_liteos_m/issues/I59DDE
2022-05-26 11:42:02 +00:00
openharmony_ci
18f65ae0b3 !694 修复RISCV32 newlib情况下FD_ISSET设置问题
Merge pull request !694 from 大仙/master
2022-05-24 11:08:44 +00:00
openharmony_ci
5363e4b472 !690 【OpenHarmony 开源贡献者计划 2022】fix: fix warning while compiling test suites
Merge pull request !690 from rtos_shang/master
2022-05-23 12:03:34 +00:00
openharmony_ci
c65d908905 !692 【OpenHarmony 开源贡献者计划 2022】fix: fix warning: 'PthreadFuncTestSuiteTearDown' defined but not used
Merge pull request !692 from rtos_shang/warning2
2022-05-23 12:03:08 +00:00
openharmony_ci
1b9d59aa9a !691 【OpenHarmony 开源贡献者计划 2022】fix: fix warning label 'EXIT' defined but not used
Merge pull request !691 from rtos_shang/warning
2022-05-23 12:02:42 +00:00
大仙
c6958aa181 修复SoftBusSocketFdIsset在M核RISCV32架构的newlib情况下设置的问题
fix #I52ACL

Signed-off-by: 大仙 <leicx@digitalchina.com>
2022-05-20 16:55:27 +08:00
zhumingxian
315a448142 fix: fix warning: 'PthreadFuncTestSuiteTearDown' defined but not used
fix warning: 'PthreadFuncTestSuiteTearDown' defined but not used
fix warning: 'PthreadFuncTestSuiteSetUp' defined but not used

close #I58COM

Signed-off-by: zhumingxian <zhuwanshu@ohos.com.cn>
2022-05-19 21:28:46 +08:00
zhumingxian
32a2e193f4 fix: fix warning label 'EXIT' defined but not used
fix testsuites/sample/kernel/hwi/it_los_hwi_039.c:39:1: warning: label 'EXIT' defined but not used [-Wunused-label]

close #I58CNP

Signed-off-by: zhumingxian <zhumingxian@ohos.com.cn>
2022-05-19 21:13:46 +08:00
zhumingxian
b35792fa6c fix: fix warning while compiling test suites
fix testsuites/include/iCunit.h:248:20: warning: 'return' with a value, in function returning void

close #I58CM9

Signed-off-by: zhumingxian <zhumingxian@ohos.com.cn>
2022-05-19 20:59:50 +08:00
openharmony_ci
a5e651cb01 !673 Fix : liteos_m核 内存waterline 缺陷BUG
Merge pull request !673 from yinjiaming/fix
2022-05-19 09:19:42 +00:00
yinjiaming
f12dd8bbe6 fix: 修复liteos_m核 内存waterline 缺陷BUG
【背景】
OsMemWaterUsedRecord的第二个参数错误,导致waterline统计错误

【修改方案】
将OsMemWaterUsedRecord的第二个入参修改为
OS_MEM_NODE_GET_SIZE(node->sizeAndFlag) - nodeSize

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

re #I4QBG2

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I1cc213d98230ec9723c6bf1871b4e46da3b3467d
2022-05-19 02:44:54 +00:00
openharmony_ci
3f41c36926 !686 M核添加维测, 中断信息dump
Merge pull request !686 from wangchen/0505_hwidump
2022-05-12 07:17:01 +00:00
openharmony_ci
a3daa77e53 !688 fix: 修改内核子系统markdown文件目录错误问题
Merge pull request !688 from Kiita/220510_md
2022-05-11 02:17:31 +00:00
wangchen
fb740f9b23 fix: M核添加维测接口
【背景】M核添加维测接口

【修改方案】
1, 添加任务栈dump接口
2, 添加中断dump接口
3, 添加任务调度流程dump
【影响】
对现有的产品编译不会有影响。
re #I5644Y
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-05-11 01:44:36 +00:00
zhangyan
a45bf8797c fix:修改内核子系统markdown文件目录错误问题
re #I535PJ
Signed-off-by: Kiita <zhanyan@huawei.com>
Change-Id: I772ec6ff9cf1d45d9decd0f4f11535fe1dfa5e7b
2022-05-10 07:10:59 +00:00
openharmony_ci
84f89b9660 !683 「OpenHarmony 开源贡献者计划」SWTMR模块无法关闭
Merge pull request !683 from yangzelin/fix_swtmr
2022-05-10 00:51:11 +00:00
openharmony_ci
03b4650a16 !685 M核添加维测, 任务栈dump
Merge pull request !685 from wangchen/0505_stackdump
2022-05-06 08:35:18 +00:00
wangchen
728aca27f5 fix: M核添加维测接口
【背景】M核添加维测接口

【修改方案】
1, 添加任务栈dump接口
2, 添加中断dump接口
3, 添加任务调度流程dump
【影响】
对现有的产品编译不会有影响。
re #I50KLG
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-05-06 07:44:02 +00:00
yangzelin
91743d3ea4 Signed-off-by: yangzelin <yangzelin@talkweb.com.cn>
fix: 解决关闭SWTMR模块后无法编译的问题

关闭SWTMR模块后, 屏蔽相关全局变量以及函数调用
2022-04-28 09:49:15 +08:00
openharmony_ci
fcd677feba !671 在riscv32_virt中新增graphic适配,将riscv32_virt编译从musl调整为newlib
Merge pull request !671 from xiexg-dc/riscv32-virt
2022-04-24 13:23:12 +00:00
openharmony_ci
c4fd9be138 !680 Delete redundancy third party unity
Merge pull request !680 from peitaiyi/master
2022-04-24 12:06:31 +00:00
taiyipei
81249a0384 delete redundancy third party unity deps
Signed-off-by: taiyipei <peitaiyi@huawei.com>
2022-04-24 00:21:25 -07:00
xiexg-dc
8746f5abe5 feat: 在riscv32_virt中新增graphic适配,将musl调整为newlib
在riscv32_virt中新增graphic适配,将riscv32_virt编译从musl调整为newlib。

fix #I52IID

Signed-off-by: xiexg-dc <xiexg@digitalchina.com>
Change-Id: I1a774666609172c5de6310fe43b33185f86ac872
2022-04-13 15:05:51 +08:00
openharmony_ci
56565beeb6 !668 修复fatfs中GetLdPath无法正常返回结果
Merge pull request !668 from xiexg-dc/riscv32-virt
2022-04-11 06:18:21 +00:00
openharmony_ci
a77aa7de98 !670 fix: 告警修复
Merge pull request !670 from Zhaotianyu/0408codex_fix
2022-04-11 02:05:02 +00:00
openharmony_ci
db8c284cd1 !670 fix: 告警修复
Merge pull request !670 from Zhaotianyu/0408codex_fix
2022-04-11 02:05:01 +00:00
arvinzzz
b1daca7f82 fix: 告警修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: If3c36a8b2d3ad3c825bc3e5ef68efa8896d54884
2022-04-08 16:11:12 +08:00
xiexg-dc
46546688c9 fix: 修复fatfs中GetLdPath无法正常返回结果
fix: #I4XBJ6

Signed-off-by: xiexg-dc <xiexg@digitalchina.com>
Change-Id: I919d48de744f01f56b6fb7376b8b770386380197
2022-04-06 10:37:03 +08:00
openharmony_ci
d017af7459 !669 refactor: 优化任务状态,EXIT状态仅表示任务已退出
Merge pull request !669 from zhushengle/exit
2022-04-02 08:10:15 +00:00
zhushengle
4e9f8c71f9 refactor: 优化任务状态,EXIT状态仅表示任务已退出
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I53e98540af4deb44e64f6879df340b27efb201b8
2022-04-02 14:55:20 +08:00
openharmony_ci
e34c4050f9 !666 解决taskCB未定义以及初始化的问题
Merge pull request !666 from 夏不白/master
2022-04-01 03:18:21 +00:00
xia-bubai
67b579161d Description: add initialize of taskCB in function ArchTskStackInit
IssueNo:https://gitee.com/openharmony/kernel_liteos_m/issues/I50NRJ
Feature or Bugfix: Bugfix

Signed-off-by: xia-bubai <xiacong4@huawei.com>
2022-04-01 10:33:45 +08:00
openharmony_ci
d5b90399b7 !622 feat:增加玄铁ck804ef架构内核支持文件
Merge pull request !622 from qubo/master
2022-03-31 06:22:56 +00:00
bob_qu
1ab2ffcd4a fix:按照评审意见,调整目录到V2下,修改代码review问题
合入原因:按照规划增加winnermicro w800芯片OH适配
          需要新增CK804芯片架构支持代码
修改:在kernel/liteos_m、device/soc、device/board、vendor/hihope
       仓下增加CK804芯片架构、芯片SDK、开发板和产品配置文件
影响:由于是新增芯片架构,与其他平台编译隔离,无副作用

Signed-off-by: bob_qu <qu_bo@hoperun.com>
2022-03-30 21:57:04 +08:00
openharmony_ci
ec9f0e47e9 !660 fix: 低功耗tick timer休眠时间计算有误
Merge pull request !660 from zhushengle/pm
2022-03-28 13:27:56 +00:00
zhushengle
8550117b01 fix: 低功耗tick timer休眠时间计算有误
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I3dfa2a8ec7562a1182dae74cc706c7a660ae867a
2022-03-28 15:54:06 +08:00
openharmony_ci
f29973e995 !658 fix: 修复README格式问题
Merge pull request !658 from zhushengle/readme
2022-03-24 13:51:28 +00:00
zhushengle
9e0e39f277 fix: 修复README格式问题
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I35a67592ceaab7bdaaf3c2bf4122f6a4bc4a66bb
2022-03-24 21:40:56 +08:00
openharmony_ci
2f19ba3653 !645 队列支持变长读
Merge pull request !645 from chenliming_kh/master
2022-03-24 01:51:31 +00:00
openharmony_ci
fe7191183e !657 fix:告警修复
Merge pull request !657 from Zhaotianyu/0323codex_fix_1
2022-03-23 09:37:33 +00:00
arvinzzz
d84471ff29 fix: 告警修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I1c00ca1dda35c62b06bff78353737f7943a647e9
2022-03-23 17:15:52 +08:00
openharmony_ci
45654cee93 !635 Fix : menuconfig配置Enable Dynamic Link Feature后编译报错
Merge pull request !635 from yinjiaming/master
2022-03-23 08:49:46 +00:00
openharmony_ci
110ee01118 !635 Fix : menuconfig配置Enable Dynamic Link Feature后编译报错
Merge pull request !635 from yinjiaming/master
2022-03-23 08:49:45 +00:00
openharmony_ci
b51e7f93d4 !637 Fix : 开启lwip后编译失败
Merge pull request !637 from yinjiaming/fix
2022-03-23 08:49:19 +00:00
openharmony_ci
2d9e476c0b !652 fix:告警修复
Merge pull request !652 from Zhaotianyu/0322codex_fix_2
2022-03-22 13:56:49 +00:00
openharmony_ci
9ee49f1bb8 !647 feat: L0支持systick动态调频
Merge pull request !647 from zhushengle/freq
2022-03-22 13:46:21 +00:00
openharmony_ci
befe8ecf9d !647 feat: L0支持systick动态调频
Merge pull request !647 from zhushengle/freq
2022-03-22 13:46:21 +00:00
arvinzzz
637de91170 fix: 告警修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I4c69ab116920db527b39070038d36e7f0bd4e331
2022-03-22 21:39:09 +08:00
zhushengle
390a488a97 feat: L0支持systick动态调频
Close #I4YXW9
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I052fe71e507f76184c8ac5d6349e368494033cde
2022-03-22 20:44:25 +08:00
openharmony_ci
9d3d983376 !650 fix:告警修复
Merge pull request !650 from Zhaotianyu/0322codex_fix_1
2022-03-22 12:06:53 +00:00
arvinzzz
0e2dded346 fix: 告警修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I09d6e86c958838d95297176c235fe1a7ad34c88c
2022-03-22 19:47:03 +08:00
openharmony_ci
b0393151a6 !648 fix: 告警修复
Merge pull request !648 from Zhaotianyu/0322codex_fix
2022-03-22 11:15:34 +00:00
arvinzzz
38f8472ddb fix: 告警修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Iaec45e835737c0ae7eea88408b2a1a4a79f1a40c
2022-03-22 18:29:16 +08:00
chenliming
7167ba7578 chenliming@kaihongdigi.com: 队列支持变长读
Signed-off-by: chenliming <chenliming@kaihongdigi.com>
2022-03-22 17:04:06 +08:00
openharmony_ci
d28c8a0423 !643 fix: 内源检视修复
Merge pull request !643 from Zhaotianyu/0321codex_fix
2022-03-21 03:44:17 +00:00
arvinzzz
17daa50fa2 fix: 内源检视修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ic8f63a512a5b2c88e7abee6c167473f37ecc9f3b
2022-03-21 11:02:16 +08:00
openharmony_ci
57a0002252 !642 fix:3.1内源代码检视问题
Merge pull request !642 from xuxinyu/master
2022-03-19 12:50:08 +00:00
x_xiny
4f12ab9a2a fix:3.1代码检视问题
Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Ib69620ebf3c139b0e69c3fb5347eaf54cab275de
2022-03-19 19:37:23 +08:00
openharmony_ci
e703376d68 !636 修改menuconfig关闭VFS选项后编译无法通过
Merge pull request !636 from wangchen/0317_m
2022-03-19 08:24:14 +00:00
openharmony_ci
8f1dc3a1ff !636 修改menuconfig关闭VFS选项后编译无法通过
Merge pull request !636 from wangchen/0317_m
2022-03-19 08:24:14 +00:00
openharmony_ci
9bf8ff9ce5 !641 fix: 规范整改
Merge pull request !641 from zhushengle/sample
2022-03-19 08:02:11 +00:00
zhushengle
a09d4882c4 fix: 规范整改
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I7be78853291d53636fd199104b4c72bbab222bcd
2022-03-19 15:46:10 +08:00
openharmony_ci
98a82ba357 !640 Fix : 修改了源码检视过程中的一些问题
Merge pull request !640 from yinjiaming/latest
2022-03-18 08:52:24 +00:00
yinjiaming
e7e850a6a6 fix: 修复3.1代码检视中的问题
【背景】
3.1 代码检视中有一些问题需要修改

【修改方案】
在可能内存泄露的地方进行了修改,在安全函数前加void转换

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I8a37ecf7c8d81d24ebe153d0c0a7db008cc3e4b9
2022-03-18 08:14:18 +00:00
wangchen
3ad47afec4 fix: 通过menuconfig关闭VFS选项后,代码编译无法通过
【背景】关闭VFS时,编译无法通过

【修改方案】
1,添加对fs依赖的模块中对fs开启情况的判断

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

re #I4X5DX
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-03-18 06:48:47 +00:00
openharmony_ci
6f04b5345c !639 【liteos_m】线程id判断存在问题
Merge pull request !639 from LiteOS/master
2022-03-18 05:04:13 +00:00
LiteOS2021
83b6331aad fix(线程id判断有误,cmsis优先级创建修改): 线程id判断有误,cmsis优先级创建修改
线程id判断有误,cmsis优先级创建修改

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-03-18 11:16:51 +08:00
yinjiaming
67a5b580f6 fix: 修复配置Enable Dynamic Link Feature后编译报错的问题
【背景】
在menuconfig中开启Enable Dynamic Link Feature后,内核编译报错

【修改方案】
将Kconfig 文件中的DYNLINK 改为 KERNEL_DYNLINK

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

re #I4XZN3

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I0a91b0f48fef78791307810e3780c53c17d7d0c8
2022-03-17 11:10:32 +00:00
yinjiaming
f5ee192962 fix: 修复开启lwip后编译失败的问题
【背景】
LWIP_STATS宏定义为0时开启lwip会有编译失败

【修改方案】
给可能重复定义的宏LWIP_STATS_DISPLAY 添加了相应的条件判断

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

re #I4X2DP

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Id1a4769dbbce4c56e8b681d9174be5aa54e74c02
2022-03-17 10:55:46 +00:00
openharmony_ci
a42ba7aed6 !633 chore:Kconfig调整
Merge pull request !633 from Zhaotianyu/0315Kconfig
2022-03-15 09:37:35 +00:00
arvinzzz
1fc024a158 chore: Kconfig 修改
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3a6839a55cd63cab1493929269df86c19d278a90
2022-03-15 17:10:59 +08:00
openharmony_ci
21ee0b2c1d !631 C库性能优化
Merge pull request !631 from Zhaotianyu/0314libc_opt
2022-03-14 14:13:08 +00:00
openharmony_ci
b0cfa5e52c !632 Fix:内源代码检视用例问题
Merge pull request !632 from xuxinyu/Fixmem
2022-03-14 13:52:53 +00:00
x_xiny
543732f522 fix:根据内源代码检视意见对用例进行整改
【背景】3.1代码review问题修改

    【修改方案】
     修复用例问题

     Signed-off-by: xuiny <xuxinyu6@huawei.com>

Change-Id: I8ee5d8f5f5765e469cf72c810af8a3831a3879f9
2022-03-14 21:38:55 +08:00
arvinzzz
dab1a0d62f feature: libc opt
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I9252c83e5b8a40f23e0df04ea165b9f51a4482b3
2022-03-14 19:47:45 +08:00
openharmony_ci
6a8f24ba01 !626 Fix : 修改了源码检视过程中的一些问题
Merge pull request !626 from yinjiaming/master
2022-03-14 11:08:14 +00:00
openharmony_ci
40bbb4d6c4 !628 fix: 删除测试用例中的工号
Merge pull request !628 from zhushengle/sample
2022-03-14 08:24:05 +00:00
zhushengle
90a027090a fix: 删除测试用例中的工号
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I7f83a26a5bbf2bc53b614e9fce68e26ed2c6352b
2022-03-14 15:15:52 +08:00
yinjiaming
bcd177bbd3 fix: 修复3.1代码检视中的问题
【背景】
3.1 代码检视中有一些问题需要修改

【修改方案】
在README 中添加了文档链接,更改了非可执行文件的权限

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I25eb1a2bfcbfdf7bc40b0516bcf9262c2d67f8b4
2022-03-14 06:57:32 +00:00
openharmony_ci
cde2b3bd31 !627 修复L0 fs Opendir打开失败返回值不为空问题
Merge pull request !627 from 龙幸开/master
2022-03-11 06:53:18 +00:00
longxingkai
e3e9b2f5a5 fix fs opendir bug
Signed-off-by: longxingkai <longxingkai@talkweb.com.cn>
2022-03-11 10:23:38 +08:00
openharmony_ci
536e9b4584 !619 fix: 内源代码检视问题
Merge pull request !619 from xuxinyu/fix
2022-03-10 12:15:52 +00:00
x_xiny
632ea10418 fix:内源代码检视修改
【背景】3.1代码review问题修改

    【修改方案】

     re #I4WV56

     Signed-off-by: xuiny <xuxinyu6@huawei.com>

Change-Id: I1f3d98ab84b739c5d3a924559b1825659dc0ea74
2022-03-10 19:33:41 +08:00
openharmony_ci
73b77d11a1 !625 修复FileSystem menuconfig配置问题
Merge pull request !625 from 方烨/develop
2022-03-10 01:58:53 +00:00
fangye
9aa32ae743 fix: 修复FileSystem menuconfig配置问题
Signed-off-by: fangye <fangye@talkweb.com.cn>
Change-Id: Ibbac507ec290657489e47a708d2926ec709fa6b8
2022-03-10 09:27:16 +08:00
openharmony_ci
133e87b1b1 !380 refactor: liteos-m vfs refactory
Merge pull request !380 from MGY917/m-vfs
2022-03-09 07:34:01 +00:00
Guangyao Ma
09034de68a refactor: liteos-m vfs refactory
close #I4RV26

Change-Id: I76d5d5128d37efa5fbcde6d105c78f4d7be607de
Signed-off-by: Guangyao Ma <guangyao.ma@outlook.com>
2022-03-09 12:07:15 +08:00
openharmony_ci
867a6edcdc !621 M核内源代码检视问题修改
Merge pull request !621 from wangchen/0308_m
2022-03-09 02:27:20 +00:00
bob_qu
3dceae52aa feat:增加玄铁ck804ef架构内核支持文件
合入原因:按照规划增加winnermicro w800芯片OH适配
          需要新增CK804芯片架构支持代码
修改:在kernel/liteos_m、device/soc、device/board、vendor/hihope
       仓下增加CK804芯片架构、芯片SDK、开发板和产品配置文件
影响:由于是新增芯片架构,与其他平台编译隔离,无副作用

Signed-off-by: bob_qu <qu_bo@hoperun.com>
2022-03-08 20:17:49 +08:00
wangchen
43baa4fdc4 fix: 内源代码检视问题
【背景】内源代码检视问题

【修改方案】
1,按检视意见,进行资源泄露等问题的修改

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

re #I4WV56
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-03-08 09:38:03 +00:00
openharmony_ci
bedef30658 !615 fix: 修复codex及合规问题
Merge pull request !615 from Zhaotianyu/0307codex_fix
2022-03-08 08:06:30 +00:00
openharmony_ci
7e284239b3 !613 fix: 文档与实际代码目录保持一致
Merge pull request !613 from Zhaotianyu/0305md_fix
2022-03-07 12:18:31 +00:00
arvinzzz
f34b94e98d fix: codex等问题修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ib2c46be5e117fab5506bb7b5229f31e611195f1b
2022-03-07 16:16:26 +08:00
arvinzzz
bc33bcd319 fix: 文档与实际代码目录不符
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ic07896cac1c32de38d86206a5cae9f419f0cf8dd
2022-03-05 17:14:24 +08:00
openharmony_ci
ae7a374ebb !573 M核安全隔离
Merge pull request !573 from Zhaotianyu/0117sec_init
2022-03-03 13:42:06 +00:00
arvinzzz
fb76350771 feature:M核安全隔离
新增用户态,上层业务进行box隔离,共享C库

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ib6ecc3fcb230a7539f9e0f3663290900198d2ba9
2022-03-03 20:41:15 +08:00
openharmony_ci
ea5b2e8ae4 !612 代码检视意见清零
Merge pull request !612 from JerryH/pipe_poll
2022-03-03 07:01:44 +00:00
JerryH
c5a3ed4fb1 fix: 处理检视出来的代码问题
close #I4VY0A

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I3bc2d3da95ecae53b3d124d086b8296ea4608d3a
2022-03-02 16:02:32 +08:00
openharmony_ci
7688a3f52d !604 fix: 修复任务栈对齐问题及补充posix和cmsis测试用例
Merge pull request !604 from zhushengle/test
2022-02-26 08:09:07 +00:00
openharmony_ci
590ab9182d !609 feature: 补充pread/pwrite接口
Merge pull request !609 from Zhaotianyu/0224fs_pwrite
2022-02-25 09:33:10 +00:00
zhushengle
ed863e90dd fix: 修复任务栈对齐问题及补充posix和cmsis测试用例
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I2075f1821c46aea17bbec498f533905d720621c4
2022-02-25 11:39:57 +08:00
arvinzzz
491cefae76 feature: 补充pread/pwrite接口
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ie31cacd18131113e51a6949dfba57a86ca4eb0e5
2022-02-24 19:57:30 +08:00
openharmony_ci
36887d467d !608 fix: 修复调度时间最大值不一致问题
Merge pull request !608 from zhushengle/time
2022-02-23 08:47:37 +00:00
zhushengle
9f393bcc6d fix: 修复调度时间最大值不一致问题
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I1f31f343aebcc6565eec8bc2456a6dd9dfcde6e9
2022-02-23 12:07:57 +08:00
openharmony_ci
fe4db41b7c !606 【liteos_m】修复testTimes测试
Merge pull request !606 from LiteOS/master
2022-02-22 10:21:55 +00:00
LiteOS2021
5c982f1087 fix(time_func_test_01.c): 修复testTimes测试单板配置LOSCFG_BASE_CORE_TICK_PER_SECOND = 1000的问题
修复testTimes测试单板配置LOSCFG_BASE_CORE_TICK_PER_SECOND = 1000的问题

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-02-22 17:51:22 +08:00
openharmony_ci
9a3745384a !605 shell 输入不识别命令时内存泄漏
Merge pull request !605 from wangchen/shell_free
2022-02-22 09:30:56 +00:00
wangchen
0245b1a7b2 fix: shell 输入不识别命令时内存泄漏
【背景】shell 输入不识别命令时内存泄漏

【修改方案】
1,添加识别命令失败时释放内存

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

re #I4UR9P
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-02-22 08:12:01 +00:00
openharmony_ci
d4d59cf08f !603 cpup和测试套解耦,使用cpup相关宏来管理相关内容。
Merge pull request !603 from LiteOS/master
2022-02-22 07:04:53 +00:00
LiteOS2021
692651fe40 fix(testsuites): cpup和测试套解耦
cpup和测试套解耦,使用相关宏来管理cpup相关内容。

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-02-22 14:22:06 +08:00
openharmony_ci
e4d08ba896 !602 修复irqNum = HwiNumGet()编译错误
Merge pull request !602 from yinjiaming/master
2022-02-21 08:56:35 +00:00
openharmony_ci
021e5299ab !593 feat: 支持任务栈可配置
Merge pull request !593 from zhushengle/task_stack
2022-02-21 06:48:37 +00:00
yinjiaming
16e87d78d8 fix: 修复irqNum = HwiNumGet()编译错误的问题
【背景】
L0,M33内核,编译时返回错误,
irqNum = HwiNumGet()编译错误

【修改方案】
删去引起编译错误的变量,直接用函数的返回值代替

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

re #I4S81B
Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I7dba42cb158cbb969053a83ddd22d76ee30646d1
2022-02-21 03:33:58 +00:00
zhushengle
96cc92d035 feat: 支持任务栈可配置
支持liteos_m 任务栈可配置
支持pthread 任务栈可配置
支持cmsis 任务栈可配置

BREAKING CHANGE:
pthread_create 支持任务栈设置
osThreadNew 支持任务栈设置
TSK_INIT_PARAM_S 结构体添加stackAddr 字段

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ifa2a3581b705631cc83cbde6182a39c28d66de2a
2022-02-21 09:08:05 +08:00
openharmony_ci
4983542b46 !598 feat:统一LOS_HwiCreate接口的中断处理函数参数,与kernel_liteos_a、 liteos一致,保证应用可平滑迁移到鸿蒙,降低用户成本
Merge pull request !598 from LiteOS/master
2022-02-19 10:37:16 +00:00
LiteOS2021
6c68adad4d feat: synchronous los_hwicreate interface
BREAKING CHANGE:
    涉及接口修改:
    LOS_HwiCreate
    LOS_HwiDelete
    改动内容:
    中断处理函数参数类型由HWI_ARG_T统一改为HwiIrqParam,封装原有arg参数及riscv部分实际使用变量pDevId, 这样一方面统一LiteOS接口,也统一了中断处理函数的arg参数
    同步LOS_HwiDelete接口入参,新增HWI_IRQ_PARAM_S *irqParam参数,为后续共享中断功能的添加预留

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-02-18 17:30:29 +08:00
openharmony_ci
6efd469a4f !601 fix: 修复pthread 编译告警
Merge pull request !601 from zhushengle/pthread
2022-02-17 03:36:42 +00:00
zhushengle
cc57f81ab8 fix: 修复pthread 编译告警
Close #I4U16U
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I67ba2469f2a4697bcb6da9f342bd8d18835cc874
2022-02-17 10:06:15 +08:00
openharmony_ci
5dbac3ab4c !599 fix: posix线程和LOS_TaskCreate任务不兼容,补齐接口防护,防止访问野指针
Merge pull request !599 from zhushengle/pthread
2022-02-16 11:15:25 +00:00
zhushengle
60805e1a7c fix: posix线程和LOS_TaskCreate任务不兼容,补齐接口防护,防止访问野指针
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I03040e86a5ac618d3ede671c497a0ae88a3717ae
2022-02-16 14:47:35 +08:00
openharmony_ci
7cf08722a0 !597 修复未使用的参数和类型比较编译报错问题
Merge pull request !597 from 方烨/develop
2022-02-16 06:42:11 +00:00
fangye
21b46e82f3 fix: 修复未使用的参数和类型比较编译报错问题
Signed-off-by: fangye <fangye@talkweb.com.cn>
Change-Id: I64f9e0cd20b62f877f353340b81922ddd45fbf7c
2022-02-15 18:53:30 +08:00
907 changed files with 31857 additions and 48685 deletions

194
BUILD.gn
View File

@@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@@ -31,164 +31,75 @@ import("//build/lite/config/component/lite_component.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
declare_args() {
liteos_name = "OHOS_Image"
liteos_kernel_only = false
}
import("liteos.gni")
liteos_arch_cflags = []
if (defined(LOSCFG_ARCH_ARM)) {
mcpu = LOSCFG_ARCH_CPU
if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) {
mcpu += "+nofp"
}
liteos_arch_cflags += [ "-mcpu=$mcpu" ]
if (defined(LOSCFG_ARCH_ARM_AARCH32) && defined(LOSCFG_ARCH_FPU)) {
liteos_arch_cflags += [ "-mfpu=$LOSCFG_ARCH_FPU" ]
}
}
if (defined(LOSCFG_COMPILER_ICCARM)) {
import("config_iccarm.gni")
} else {
import("config.gni")
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
if (ohos_build_compiler == "clang") {
cc += " --target=$target_triple"
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_config_cflags)
if (ohos_build_compiler == "clang") {
cc += " --target=$target_triple"
}
}
config("arch_config") {
cflags = liteos_arch_cflags
asmflags = cflags
ldflags = cflags
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-mthumb-interwork" ]
}
}
if (defined(LOSCFG_THUMB)) {
cflags += [ "-mthumb" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-mimplicit-it=thumb" ]
} else {
cflags += [ "-Wa,-mimplicit-it=thumb" ]
}
}
cflags = arch_config_cflags
asmflags = arch_config_asmflags
ldflags = arch_config_ldflags
}
config("stdinc_config") {
std_include = exec_script("//build/lite/run_shell_cmd.py",
[ "$cc -print-file-name=include" ],
"trim string")
cflags = [
"-isystem",
std_include,
]
cflags += [ "-nostdinc" ]
asmflags = cflags
if (defined(LOSCFG_LIBC_NEWLIB)) {
cflags -= [ "-nostdinc" ]
cflags = stdinc_config_cflags
asmflags = stdinc_config_asmflags
if (!defined(LOSCFG_COMPILER_ICCARM)) {
std_include = exec_script("//build/lite/run_shell_cmd.py",
[ "$cc -print-file-name=include" ],
"trim string")
cflags += [
"-isystem",
std_include,
]
}
}
config("ssp_config") {
cflags = []
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
cflags += [ "-fstack-protector-all" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
cflags += [ "-fstack-protector-strong" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
cflags += [
"-fstack-protector",
"--param",
"ssp-buffer-size=4",
]
} else {
cflags += [ "-fno-stack-protector" ]
}
asmflags = cflags
cflags = ssp_config_cflags
asmflags = ssp_config_asmflags
}
config("optimize_config") {
cflags = []
if (defined(LOSCFG_COMPILE_DEBUG)) {
cflags += [
"-g",
"-gdwarf-2",
]
optimization_cflag = "-O0"
}
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
optimization_cflag = "-O2"
}
if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
optimization_cflag = "-Oz"
} else {
optimization_cflag = "-Os"
}
}
if (defined(LOSCFG_COMPILE_LTO)) {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-flto=thin" ]
} else {
#cflags += [ "-flto" ]
}
}
cflags += [ optimization_cflag ]
asmflags = cflags
cflags = optimize_config_cflags
asmflags = optimize_config_asmflags
}
config("kconfig_config") {
cflags = [
"-imacros",
"$LITEOS_MENUCONFIG_H",
]
asmflags = cflags
cflags_cc = cflags
cflags = kconfig_config_cflags
asmflags = kconfig_config_asmflags
}
config("warn_config") {
cflags = [
"-Wall",
"-Werror",
"-Wpointer-arith",
"-Wstrict-prototypes",
"-Winvalid-pch",
"-Wno-address-of-packed-member",
]
asmflags = cflags
cflags = warn_config_cflags
asmflags = warn_config_asmflags
}
config("dialect_config") {
cflags_c = [ "-std=c99" ]
cflags_cc = [ "-std=c++11" ]
cflags_c = dialect_config_cflags
cflags_cc = dialect_config_ccflags
asmflags = dialect_config_asmflags
}
config("misc_config") {
defines = [ "__LITEOS__" ]
defines += [ "__LITEOS_M__" ]
if (!defined(LOSCFG_COMPILER_ICCARM)) {
defines = [ "__LITEOS__" ]
defines += [ "__LITEOS_M__" ]
}
if (!defined(LOSCFG_DEBUG_VERSION)) {
defines += [ "NDEBUG" ]
}
cflags = [
"-fno-pic",
"-fno-builtin",
"-fms-extensions",
"-fno-strict-aliasing",
"-fno-common",
"-fsigned-char",
"-ffunction-sections",
"-fdata-sections",
"-fno-exceptions",
"-fno-omit-frame-pointer",
]
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-fno-aggressive-loop-optimizations" ]
}
asmflags = cflags
asmflags += [ "-DCLZ=CLZ" ]
cflags = misc_config_cflags
asmflags = misc_config_asmflags
}
config("los_config") {
@@ -209,8 +120,11 @@ config("los_config") {
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
# board and soc decoupling feature, device_path should contains board
BOARD_SOC_FEATURE = device_path != string_replace(device_path, "/board/", "")
# If device_path points to vendor, use device_path directly,
# otherwise board is decoupled from soc, device_path should contain board
BOARD_SOC_FEATURE =
device_path == string_replace(device_path, "/vendor/", "") &&
device_path != string_replace(device_path, "/board/", "")
config("public") {
configs = [
@@ -258,7 +172,11 @@ not_needed([ "HAVE_DEVICE_SDK" ])
static_library("libkernel") {
deps = [ ":modules" ]
complete_static_lib = false
if (defined(LOSCFG_COMPILER_ICCARM)) {
complete_static_lib = true
} else {
complete_static_lib = false
}
}
group("kernel") {
@@ -274,11 +192,7 @@ executable("liteos") {
":los_config",
]
ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
]
ldflags = executable_config_ldflags
output_dir = target_out_dir
@@ -299,11 +213,5 @@ build_ext_component("build_kernel_image") {
deps = [ ":copy_liteos" ]
exec_path = rebase_path(root_out_dir)
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
command +=
" && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
command = toochain_config_command
}

67
Kconfig
View File

@@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@@ -52,6 +52,9 @@ config LLVM_TARGET
depends on COMPILER_CLANG_LLVM
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
config COMPILER_ICCARM
bool "ICCARM"
endchoice
config COMPILE_DEBUG
@@ -317,7 +320,7 @@ config CPUP_INCLUDE_IRQ
help
If you wish to include irq usage for cpup.
config DYNLINK
config KERNEL_DYNLINK
bool "Enable Dynamic Link Feature"
default n
depends on KERNEL_EXTKERNEL && ARCH_ARM
@@ -332,6 +335,14 @@ config KERNEL_PM
Configuration item for low power frame tailoring.
If you wish to build LiteOS with support for power management.
config KERNEL_PM_IDLE
bool "Enable Power Management Idle"
default n
depends on KERNEL_PM
help
Configuration item for low power frame tailoring.
If you wish to build LiteOS with support for power management idle.
config KERNEL_PM_TASK_PTIORITY
int "Power Management Task Priority"
default 1
@@ -354,22 +365,17 @@ config KERNEL_PM_DEBUG
help
Configuration item for low power frame debug tailoring.
config DEBUG_HOOK
bool
default n
config PLATFORM_EXC
bool "Enable Hook Feature"
bool "Enable Platform Exc Hook"
default n
depends on KERNEL_EXTKERNEL
select DEBUG_HOOK
config KERNEL_LMK
bool "Enable Low Memory Killer"
default n
depends on KERNEL_EXTKERNEL
help
Configuration item for low momery killer tailoring.
Configuration item for low memory killer tailoring.
If you wish to build LiteOS with support for low memory killer.
config KERNEL_LMK_DEBUG
@@ -515,6 +521,14 @@ config DEBUG_QUEUE
help
Answer Y to enable debug queue.
config MUTEX_CREATE_TRACE
bool "Enable Mutex Trace Debugging"
default n
depends on ARCH_ARM
depends on DEBUG_KERNEL
help
Answer Y to enable debug mutex trace.
config DEBUG_DEADLOCK
bool "Enable Mutex Deadlock Debugging"
default n
@@ -529,14 +543,20 @@ config DEBUG_SEMAPHORE
help
Answer Y to enable debug semaphore.
source "components/shell/Kconfig"
config NET_LWIP_SACK_TFTP
bool "Enable Tftp"
default y
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
help
Answer Y to enable LiteOS support tftp cmd and tftp tool.
osource "net/telnet/Kconfig"
config DEBUG_HOOK
bool "Enable Hook Framework"
default n
depends on DEBUG_VERSION
help
Enable the kernel hook framework to support customized trace information capture.
config SCHED_DEBUG
bool "Enable sched debug Feature"
default n
@@ -554,6 +574,13 @@ config SHELL_CMD_DEBUG
default n
depends on DEBUG_VERSION && SHELL
config DEBUG_TOOLS
bool "Enable DEBUG TOOLS"
default n
depends on DEBUG_VERSION
help
Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack.
config USB_DEBUG
bool "Enable USB Debug"
default n
@@ -574,7 +601,7 @@ config MEM_LEAKCHECK
depends on DEBUG_VERSION && MEM_DEBUG
select KERNEL_BACKTRACE
help
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the information of mem node.
config BASE_MEM_NODE_INTEGRITY_CHECK
bool "Enable integrity check or not"
default n
@@ -591,6 +618,13 @@ config VM_OVERLAP_CHECK
help
Answer Y to enable vm overlap check.
config TASK_MEM_USED
bool "Enable show task mem used or not"
default n
depends on DEBUG_VERSION && MEM_DEBUG
source "components/shell/Kconfig"
endmenu
######################## config options os drivers ########################
@@ -600,11 +634,11 @@ endmenu
######################## config options os security #######################
menu "Security"
osource "security/Kconfig"
config SECURE_TRUSTZONE
bool "Enable ARM TrustZone"
default n
depends on ARCH_ARM
depends on ARCH_ARM_V8M
config SECURE_HEAP_SIZE
int "TrustZone Heap Size (bytes)"
default 2048
@@ -615,6 +649,13 @@ config SECURE_STACK_DEFAULT_SIZE
depends on SECURE_TRUSTZONE
help
The secure stack must be allocated before the task calls non-secure functions.
config SECURE
bool "Enable Security"
default n
select MPU_ENABLE
config MPU_ENABLE
bool "Enable MPU"
default n
endmenu
menu "Test"

View File

@@ -59,7 +59,6 @@ The directory structure is as follows. For more details, see [arch_spec.md](arch
├── kernel # Minimum kernel function set
│ ├── include # APIs exposed externally
│ └── src # Source code of the minimum kernel function set
├── targets # Board-level projects
├── testsuites # Kernel testsuites
├── tools # Kernel tools
├── utils # Common directory
@@ -85,11 +84,11 @@ Before setting up the environment for a development board, you must set up the b
For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained.
### Example projects that are already supported
### Example projects
Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`, For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu)
Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`. For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu).
Bestechnic: `bes2600`, For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic)
Bestechnic: `bes2600`. For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic).
### Community Porting Project Links
@@ -107,12 +106,6 @@ The LiteOS-M kernel porting projects for specific development boards are provide
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the STM32F429IGTb development board. The code supports build in Ninja, GCC, and IAR modes.
- Cortex-M7:
- Nucleo-F767ZI https://gitee.com/harylee/nucleo_f767zi
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the Nucleo-F767ZI development board. The code supports build in Ninja, GCC, and IAR modes.
## Contribution<a name="section1371123476307"></a>
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution.md)
@@ -131,4 +124,4 @@ How to contribute a chip based on Liteos-M kernel:
[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md)
**kernel\_liteos\_m**
[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所示
**图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
**图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
![](figures/OpenHarmony-LiteOS-M核内核架构图.png "OpenHarmony-LiteOS-M核内核架构图")
## 目录<a name="section161941989596"></a>
@@ -26,6 +26,7 @@ OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系
│ │ ├── cortex-m3 # cortex-m3架构代码
│ │ ├── cortex-m33 # cortex-m33架构代码
│ │ ├── cortex-m4 # cortex-m4架构代码
│ │ ├── cortex-m55 # cortex-m55架构代码
│ │ ├── cortex-m7 # cortex-m7架构代码
│ │ └── include # arm架构公共头文件目录
│ ├── csky # csky架构代码
@@ -56,7 +57,6 @@ OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系
├── kernel # 内核最小功能集支持
│ ├── include # 对外接口存放目录
│ └── src # 内核最小功能集源码
├── targets # 板级工程目录
├── testsuites # 内核测试用例
├── tools # 内核工具
├── utils # 通用公共目录
@@ -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源码
@@ -105,12 +105,6 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供可以
该仓包含OpenHarmony LiteOS-M内核移植支持`野火挑战者STM32F429IGTb`开发板的工程代码支持Ninja、GCC、IAR等方式进行编译。
- cortex-m7
- Nucleo-F767ZI https://gitee.com/harylee/nucleo_f767zi
该仓包含OpenHarmony LiteOS-M内核移植支持`Nucleo-F767ZI`开发板的工程代码支持Ninja、GCC、IAR等方式进行编译。
## 贡献<a name="section1371123476307"></a>
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
@@ -131,5 +125,5 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供可以
[内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
**kernel\_liteos\_m**
[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README_zh.md)

View File

@@ -39,10 +39,11 @@ module_group("arch") {
"$board_cpu" == "cortex-m4" || "$board_cpu" == "cortex-m7" ||
"$board_cpu" == "cortex-m33" || "$board_cpu" == "cortex-m55") {
modules += [ "arm" ]
} else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802") {
} else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802" ||
"$board_cpu" == "ck804ef") {
modules += [ "csky" ]
} else if ("$board_cpu" == "") {
if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") {
if ("$board_arch" != string_replace("$board_arch", "rv32i", "")) {
modules += [ "risc-v" ]
} else if ("$board" == "esp32") {
modules += [ "xtensa" ]

View File

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

View File

@@ -16,54 +16,76 @@ config ARCH_ARM_AARCH32
config ARCH_ARM_V7M
bool
config ARCH_ARM_V8M
bool
config ARCH_ARM_V5TE
bool
config ARCH_ARM_VER
string
default "armv7-m" if ARCH_ARM_V7M
default "armv8-m" if ARCH_ARM_V8M
default "armv5te" if ARCH_ARM_V5TE
#
# VFP Hardware
#
config ARCH_FPU_VFP_V3
bool
help
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
VFPv3U is a variant of VFPv3 that supports the trapping of floating-point exceptions to support code.
choice
prompt "Choose FPU type"
depends on !ARCH_FPU_DISABLE
config ARCH_FPU_VFP_V4
bool
help
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
VFPv4U is a variant of VFPv4 that supports the trapping of floating-point exceptions to support code.
VFPv4 and VFPv4U add both the Half-precision Extension and the fused multiply-add instructions to the features of VFPv3.
choice
prompt "Choose FPU version"
default ARCH_FPU_VFP_V4
depends on !ARCH_FPU_DISABLE
help
Choose FPU version.
config ARCH_FPU_VFP_V3
bool "VFP_V3"
help
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
VFPv3U is a variant of VFPv3 that supports the trapping of floating-point exceptions to support code.
config ARCH_FPU_VFP_D16
bool
depends on ARCH_ARM_AARCH32
help
VPU implemented with 16 doubleword registers (16 x 64-bit).
config ARCH_FPU_VFP_V4
bool "VFP_V4"
help
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
VFPv4U is a variant of VFPv4 that supports the trapping of floating-point exceptions to support code.
VFPv4 and VFPv4U add both the Half-precision Extension and the fused multiply-add instructions to the features of VFPv3.
endchoice
config ARCH_FPU_VFP_D32
bool
depends on ARCH_ARM_AARCH32
help
VPU implemented with 32 doubleword registers (32 x 64-bit).
choice
prompt "Choose num of FPU doubleword registers"
default ARCH_FPU_VFP_D32
depends on !ARCH_FPU_DISABLE
help
Choose num of FPU doubleword registers.
config ARCH_FPU_VFP_NEON
bool
help
Advanced SIMD extension (NEON) support.
config ARCH_FPU_VFP_D16
bool "FPU_VFP_D16"
depends on ARCH_ARM_AARCH32
help
VPU implemented with 16 doubleword registers (16 x 64-bit).
config ARCH_FPU_VFP_D32
bool "FPU_VFP_D32"
depends on ARCH_ARM_AARCH32
help
VPU implemented with 32 doubleword registers (32 x 64-bit).
endchoice
endchoice
config ARCH_FPU
string
default "vfpv3" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D32
default "vfpv3-d16" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D16
default "neon-vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32 && ARCH_FPU_VFP_NEON
default "vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32
default "vfpv4-d16" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D16
default "vfpv3" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D32 && !COMPILER_ICCARM
default "vfpv3-d16" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D16 && !COMPILER_ICCARM
default "vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32 && !COMPILER_ICCARM
default "vfpv4-d16" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D16 && !COMPILER_ICCARM
default "VFPv3" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D32 && COMPILER_ICCARM
default "VFPv3_D16" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D16 && COMPILER_ICCARM
default "VFPv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32 && COMPILER_ICCARM
default "VFPv4_D16" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D16 && COMPILER_ICCARM
#
# Supported Processor Cores
@@ -82,25 +104,16 @@ config ARCH_CORTEX_M7
bool
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_CORTEX_M33
bool
select ARCH_ARM_V7M
select ARCH_ARM_V8M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_CORTEX_M55
bool
select ARCH_ARM_V7M
select ARCH_ARM_V8M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_ARM9
bool
@@ -109,9 +122,14 @@ config ARCH_ARM9
config ARCH_CPU
string
default "cortex-m3" if ARCH_CORTEX_M3
default "cortex-m4" if ARCH_CORTEX_M4
default "cortex-m7" if ARCH_CORTEX_M7
default "cortex-m33" if ARCH_CORTEX_M33
default "cortex-m55" if ARCH_CORTEX_M55
default "cortex-m3" if ARCH_CORTEX_M3 && !COMPILER_ICCARM
default "cortex-m4" if ARCH_CORTEX_M4 && !COMPILER_ICCARM
default "cortex-m7" if ARCH_CORTEX_M7 && !COMPILER_ICCARM
default "cortex-m33" if ARCH_CORTEX_M33 && !COMPILER_ICCARM
default "cortex-m55" if ARCH_CORTEX_M55 && !COMPILER_ICCARM
default "Cortex-M3" if ARCH_CORTEX_M3 && COMPILER_ICCARM
default "Cortex-M4" if ARCH_CORTEX_M4 && COMPILER_ICCARM
default "Cortex-M7" if ARCH_CORTEX_M7 && COMPILER_ICCARM
default "Cortex-M33" if ARCH_CORTEX_M33 && COMPILER_ICCARM
default "Cortex-M55" if ARCH_CORTEX_M55 && COMPILER_ICCARM
default "arm9" if ARCH_ARM9

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}
@@ -76,6 +76,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
context->r0 = taskID;
context->r1 = 0x01010101L;

View File

@@ -39,6 +39,9 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#include "los_reg.h"
#define OS_INT_IRQ_ENABLE (1U << 0)
@@ -61,6 +64,30 @@ ExcInfo g_excInfo = {0};
*/
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 {
@@ -163,11 +190,9 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -206,6 +231,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -219,8 +247,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -233,22 +269,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -262,10 +298,20 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -277,11 +323,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

0
arch/arm/cortex-m3/keil/los_atomic.S Executable file → Normal file
View File

View File

@@ -60,7 +60,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}

View File

@@ -190,7 +190,7 @@ _hwiActiveCheck
CMP R3, #0
BEQ _hwiActiveCheckNext
; exc occured in IRQ
; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -228,19 +228,19 @@ _hwiActiveCheckNext
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
; exc occured in Task or Init or exc
; exc occurred in Task or Init or exc
; reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch
BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp
; exc occured in Task
; exc occurred in Task
MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@@ -39,15 +39,16 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#ifdef __ICCARM__
#pragma location = ".data.vector"
#elif defined(__CC_ARM) || defined(__GNUC__)
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
LITE_OS_SEC_VEC
#endif
/* *
@@ -56,6 +57,30 @@ LITE_OS_SEC_VEC
*/
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 {
@@ -198,11 +223,9 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -241,6 +264,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -254,8 +280,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -268,22 +302,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -301,11 +335,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -318,11 +364,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -574,19 +622,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@@ -597,7 +645,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

3
arch/arm/cortex-m33/gcc/NTZ/los_arch_atomic.h Executable file → Normal file
View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

0
arch/arm/cortex-m33/gcc/NTZ/los_arch_context.h Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h Executable file → Normal file
View File

View File

@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}

8
arch/arm/cortex-m33/gcc/NTZ/los_exc.S Executable file → Normal file
View File

@@ -263,7 +263,7 @@ _hwiActiveCheck:
CMP R3, #0
BEQ _hwiActiveCheckNext
// exc occured in IRQ
// exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -316,19 +316,19 @@ _hwiActiveCheckNext:
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
// exc occured in Task or Init or exc
// exc occurred in Task or Init or exc
// reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch
BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp
// exc occured in Task
// exc occurred in Task
MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD)

100
arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c Executable file → Normal file
View File

@@ -39,12 +39,13 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
/* *
* @ingroup los_hwi
@@ -52,6 +53,30 @@ UINT32 g_intCount = 0;
*/
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 {
@@ -189,11 +214,9 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -232,6 +255,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -245,8 +271,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -259,22 +293,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -292,11 +326,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -309,11 +355,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -570,14 +618,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@@ -588,7 +636,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

0
arch/arm/cortex-m33/gcc/NTZ/los_timer.c Executable file → Normal file
View File

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

View File

View File

@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}

8
arch/arm/cortex-m33/gcc/TZ/non_secure/los_exc.S Executable file → Normal file
View File

@@ -247,7 +247,7 @@ _hwiActiveCheck:
CMP R3, #0
BEQ _hwiActiveCheckNext
// exc occured in IRQ
// exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -300,19 +300,19 @@ _hwiActiveCheckNext:
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
// exc occured in Task or Init or exc
// exc occurred in Task or Init or exc
// reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch
BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp
// exc occured in Task
// exc occurred in Task
MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD)

100
arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c Executable file → Normal file
View File

@@ -39,19 +39,43 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
/* *
* @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 {
@@ -192,8 +216,7 @@ inline UINT32 ArchIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -232,6 +255,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -245,8 +271,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -259,22 +293,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -292,11 +326,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -309,11 +355,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -570,14 +618,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@@ -588,7 +636,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

2
arch/arm/cortex-m33/gcc/TZ/non_secure/los_timer.c Executable file → Normal file
View File

@@ -91,7 +91,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle = 0
UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;

1
arch/arm/cortex-m33/gcc/TZ/non_secure/los_trustzone.c Executable file → Normal file
View File

@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
HalSecureContextLoad(g_secureContext);
break;
case OS_SVC_FREE_SECURE_CONTEXT:
LOS_ASSERT(g_secureContext != NULL);
HalSecureContextFree(g_secureContext);
break;
default:

0
arch/arm/cortex-m33/gcc/TZ/non_secure/los_trustzone.h Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.c Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.h Executable file → Normal file
View File

View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_heap.c Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_heap.h Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_macros.h Executable file → Normal file
View File

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}

View File

@@ -56,8 +56,8 @@ FLAG_ADDR_VALID EQU 0x10000
FLAG_HWI_ACTIVE EQU 0x20000
FLAG_NO_FLOAT EQU 0x10000000
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Regeister
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Regeister
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Register
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Register
OS_NVIC_BFAR EQU 0xE000ED38
OS_NVIC_MMAR EQU 0xE000ED34
OS_NVIC_ACT_BASE EQU 0xE000E300
@@ -190,7 +190,7 @@ _hwiActiveCheck
CMP R3, #0
BEQ _hwiActiveCheckNext
; exc occured in IRQ
; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -228,19 +228,19 @@ _hwiActiveCheckNext
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
; exc occured in Task or Init or exc
; exc occurred in Task or Init or exc
; reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch
BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp
; exc occured in Task
; exc occurred in Task
MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@@ -40,19 +40,46 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
#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 {
@@ -198,8 +225,7 @@ inline UINT32 ArchIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -240,6 +266,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -253,8 +282,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -267,22 +304,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINTPTR intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -300,11 +337,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -317,11 +366,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -572,19 +623,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}

View File

@@ -55,8 +55,8 @@ FLAG_ADDR_VALID EQU 0x10000
FLAG_HWI_ACTIVE EQU 0x20000
FLAG_NO_FLOAT EQU 0x10000000
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Regeister
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Regeister
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Register
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Register
OS_NVIC_BFAR EQU 0xE000ED38
OS_NVIC_MMAR EQU 0xE000ED34
OS_NVIC_ACT_BASE EQU 0xE000E300
@@ -179,7 +179,7 @@ _hwiActiveCheck
CMP R3, #0
BEQ _hwiActiveCheckNext
; exc occured in IRQ
; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -217,19 +217,19 @@ _hwiActiveCheckNext
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
; exc occured in Task or Init or exc
; exc occurred in Task or Init or exc
; reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch
BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp
; exc occured in Task
; exc occurred in Task
MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@@ -40,19 +40,46 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
#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 {
@@ -198,8 +225,7 @@ inline UINT32 ArchIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -240,6 +266,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -253,8 +282,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -267,22 +304,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINTPTR intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -300,11 +337,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -317,11 +366,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -572,19 +623,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
HalSecureContextLoad(g_secureContext);
break;
case OS_SVC_FREE_SECURE_CONTEXT:
LOS_ASSERT(g_secureContext != NULL);
HalSecureContextFree(g_secureContext);
break;
default:

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -63,5 +63,3 @@ extern VOID HalSecureContextSaveAsm(OsSecureContext *secureContext);
#endif /* __cplusplus */
#endif

View File

@@ -34,7 +34,7 @@
#include "los_config.h"
#include "los_list.h"
#pragma data_alignment=0x4
#pragma data_alignment = 0x4
STATIC UINT8 g_secureHeap[LOSCFG_SECURE_HEAP_SIZE] = {0};
STATIC LOS_DL_LIST g_secureHeapFreeList = {NULL, NULL};

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -121,6 +121,29 @@ typedef struct TagTskContext {
*/
extern VOID HalStartToRun(VOID);
#if (LOSCFG_SECURE == 1)
/**
* @ingroup los_config
* @brief: User Task Stack Initialize.
*
* @par Description:
* This API is used to init a user task stack.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: context [IN] Task context.
* @param: taskEntry [IN] Task entry function address.
* @param: stack [IN] Task stack address.
*
* @retval None.
*
* @par Dependency: <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -58,7 +58,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}
@@ -148,6 +148,15 @@ VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandl
return (VOID *)context;
}
#if (LOSCFG_SECURE == 1)
VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
{
context->uwR0 = stack;
context->uwPC = (UINT32)taskEntry;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
}
#endif
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -40,6 +40,12 @@
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
.equ OS_NVIC_PENDSVSET, 0x10000000
.equ OS_TASK_STATUS_RUNNING, 0x0010
.equ OS_CONTROL_FPCA_ENABLE, 0x4
.equ OS_CONTROL_KERNEL_MODE, 0x2
#if (LOSCFG_SECURE == 1)
.equ OS_CONTROL_USER_MODE, 0x3
.equ OS_TASK_FLAG_USER_TASK, 0x0200
#endif
.section .text
.thumb
@@ -63,7 +69,7 @@ HalStartToRun:
ldr r5, =OS_NVIC_PENDSV_PRI
str r5, [r4]
mov r0, #2
mov r0, #OS_CONTROL_KERNEL_MODE
msr CONTROL, r0
ldr r1, =g_losTask
@@ -141,7 +147,7 @@ ArchTaskSchedule:
bx lr
dsb
isb
.fnend
.fnend
.type HalPendSV, %function
.global HalPendSV
@@ -194,6 +200,14 @@ SignalContextRestore:
vldmia r1!, {d8-d15}
__DisabledFPU2:
#if (LOSCFG_SECURE == 1)
ldrh r7, [r0, #4]
tst r7, #OS_TASK_FLAG_USER_TASK
ite eq
moveq r3, #OS_CONTROL_KERNEL_MODE
movne r3, #OS_CONTROL_USER_MODE
msr CONTROL, r3
#endif
ldmfd r1!, {r4-r12}
msr psp, r1

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -57,15 +57,15 @@
.equ FLAG_ADDR_VALID, 0x10000
.equ FLAG_HWI_ACTIVE, 0x20000
.equ FLAG_NO_FLOAT, 0x10000000
.equ FLAG_NO_FLOAT, 0x10000000
.equ OS_NVIC_FSR , 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
.equ OS_NVIC_HFSR , 0xE000ED2C //HardFault State Register
.equ OS_NVIC_BFAR , 0xE000ED38
.equ OS_NVIC_MMAR , 0xE000ED34
.equ OS_NVIC_ACT_BASE , 0xE000E300
.equ OS_NVIC_SHCSRS , 0xE000ED24
.equ OS_NVIC_SHCSR_MASK , 0xC00
.equ OS_NVIC_FSR, 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
.equ OS_NVIC_HFSR, 0xE000ED2C //HardFault State Register
.equ OS_NVIC_BFAR, 0xE000ED38
.equ OS_NVIC_MMAR, 0xE000ED34
.equ OS_NVIC_ACT_BASE, 0xE000E300
.equ OS_NVIC_SHCSRS, 0xE000ED24
.equ OS_NVIC_SHCSR_MASK, 0xC00
.type HalExcNMI, %function
.global HalExcNMI
@@ -155,10 +155,25 @@ HalExcSvcCall:
.cantunwind
TST LR, #0x4
ITE EQ
MRSEQ R0, MSP
MRSNE R0, PSP
LDR R1, [R0,#24]
LDRB R0, [R1,#-2]
MRSEQ R1, MSP
BNE _svcCallFromPsp
B _svcCall
_svcCallFromPsp:
#ifdef LOSCFG_SECURE
PUSH {R0-R12, LR}
MOV R0, SP
CPSIE I
BL OsSyscallHandle
CPSID I
MRS R12, PSP
STM R12, {R0-R1}
POP {R0-R12, LR}
BX LR
#endif
MRS R1, PSP
_svcCall:
LDR R0, [R1,#24]
LDRB R0, [R0,#-2]
MOV R1, #0
B osExcDispatch
.fnend
@@ -263,7 +278,7 @@ _hwiActiveCheck:
CMP R3, #0
BEQ _hwiActiveCheckNext
// exc occured in IRQ
// exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -284,7 +299,7 @@ _ExcInMSP:
PUSH {R4-R12} // store message-->exc: {R4-R12}
VPUSH {D8-D15} // FPU
B _handleEntry
.fnend
.fnend
.type _NoFloatInMsp, %function
.global _NoFloatInMsp
@@ -298,7 +313,7 @@ _NoFloatInMsp:
PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
.fnend
.type _hwiActiveCheckNext, %function
.global _hwiActiveCheckNext
@@ -316,19 +331,19 @@ _hwiActiveCheckNext:
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
// exc occured in Task or Init or exc
// exc occurred in Task or Init or exc
// reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch
BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp
// exc occured in Task
// exc occurred in Task
MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD)
@@ -347,7 +362,7 @@ _hwiActiveCheckNext:
VSTMDB R2!, {D8-D15} // FPU
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
.fnend
.type _NoFloatInPsp, %function
.global _NoFloatInPsp
@@ -367,7 +382,7 @@ _NoFloatInPsp:
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
STMFD R2!, {R4-R11}
ORR R0, R0, #FLAG_NO_FLOAT
.fnend
.fnend
.type _handleEntry, %function
.global _handleEntry
@@ -380,4 +395,4 @@ _handleEntry:
B HalExcHandleEntry
NOP
.fnend
.fnend

View File

@@ -39,18 +39,42 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
/* *
* @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 {
@@ -193,11 +217,9 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -236,6 +258,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -249,8 +274,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -263,22 +296,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -296,11 +329,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -313,11 +358,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -579,19 +626,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@@ -602,7 +649,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

View File

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

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@@ -61,7 +61,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}

View File

@@ -190,7 +190,7 @@ _hwiActiveCheck
CMP R3, #0
BEQ _hwiActiveCheckNext
; exc occured in IRQ
; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -228,19 +228,19 @@ _hwiActiveCheckNext
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
; exc occured in Task or Init or exc
; exc occurred in Task or Init or exc
; reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch
BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp
; exc occured in Task
; exc occurred in Task
MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@@ -40,14 +40,15 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#ifdef __ICCARM__
#pragma location = ".data.vector"
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
#endif
@@ -57,6 +58,30 @@ LITE_OS_SEC_VEC
*/
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 {
@@ -202,8 +227,7 @@ inline UINT32 ArchIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -242,6 +266,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -255,8 +282,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -269,22 +304,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -302,11 +337,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -319,11 +366,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -575,19 +624,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@@ -598,7 +647,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

0
arch/arm/cortex-m55/gcc/BUILD.gn Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/BUILD.gn Executable file → Normal file
View File

1
arch/arm/cortex-m55/gcc/NTZ/los_arch_atomic.h Executable file → Normal file
View File

@@ -32,6 +32,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

0
arch/arm/cortex-m55/gcc/NTZ/los_arch_context.h Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_arch_interrupt.h Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_arch_timer.h Executable file → Normal file
View File

2
arch/arm/cortex-m55/gcc/NTZ/los_context.c Executable file → Normal file
View File

@@ -58,7 +58,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
(VOID)LOS_IntLock();
while (1) {
}
}

0
arch/arm/cortex-m55/gcc/NTZ/los_dispatch.S Executable file → Normal file
View File

8
arch/arm/cortex-m55/gcc/NTZ/los_exc.S Executable file → Normal file
View File

@@ -260,7 +260,7 @@ _hwiActiveCheck:
CMP R3, #0
BEQ _hwiActiveCheckNext
// exc occured in IRQ
// exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
@@ -313,19 +313,19 @@ _hwiActiveCheckNext:
AND R2, R2, R3
CMP R2, #0
BNE _ExcInMSP
// exc occured in Task or Init or exc
// exc occurred in Task or Init or exc
// reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch
BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp
// exc occured in Task
// exc occurred in Task
MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD)

98
arch/arm/cortex-m55/gcc/NTZ/los_interrupt.c Executable file → Normal file
View File

@@ -38,12 +38,13 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
/* *
* @ingroup los_hwi
@@ -51,6 +52,30 @@ UINT32 g_intCount = 0;
*/
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 {
@@ -193,11 +218,9 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HwiNumGet();
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
@@ -236,6 +259,9 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -249,8 +275,16 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -263,22 +297,22 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
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 mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)mode;
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -296,11 +330,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)arg;
OsSetVector(hwiNum, handler);
(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);
@@ -313,11 +359,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
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)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -578,14 +626,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

0
arch/arm/cortex-m55/gcc/NTZ/los_timer.c Executable file → Normal file
View File

View File

@@ -0,0 +1,52 @@
# Copyright (c) 2013-2019 Huawei Technologies 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,
# 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 = [
"non_secure/los_context.c",
"non_secure/los_dispatch.S",
"non_secure/los_exc.S",
"non_secure/los_interrupt.c",
"non_secure/los_timer.c",
"non_secure/los_trustzone.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
include_dirs = [
"non_secure",
"secure",
]
}
config("public") {
include_dirs = [ "non_secure" ]
}

View File

@@ -0,0 +1,297 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
INT32 val;
__asm__ __volatile__("ldrex %0, [%1]\n"
: "=&r"(val)
: "r"(v)
: "cc");
return val;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 status;
do {
__asm__ __volatile__("ldrex %0, [%1]\n"
"strex %0, %2, [%1]\n"
: "=&r"(status)
: "r"(v), "r"(setVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"add %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(addVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"sub %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(subVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable
* and return the previous value of the atomic variable.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The exchange value.
*
* @retval #INT32 The previous value of the atomic variable
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, [%3]\n"
"strex %1, %4, [%3]"
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
: "r"(v), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal;
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable with compare.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The new value.
* @param oldVal [IN] The old value.
*
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, %2\n"
"mov %1, #0\n"
"cmp %0, %3\n"
"bne 1f\n"
"strex %1, %4, %2\n"
"1:"
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
: "r"(oldVal), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -0,0 +1,133 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_ARCH_CONTEXT_H
#define _LOS_ARCH_CONTEXT_H
#include "los_config.h"
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
typedef struct TagTskContext {
UINT32 secureContext;
UINT32 stackLimit;
UINT32 excReturn;
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S16;
UINT32 S17;
UINT32 S18;
UINT32 S19;
UINT32 S20;
UINT32 S21;
UINT32 S22;
UINT32 S23;
UINT32 S24;
UINT32 S25;
UINT32 S26;
UINT32 S27;
UINT32 S28;
UINT32 S29;
UINT32 S30;
UINT32 S31;
#endif
UINT32 uwR4;
UINT32 uwR5;
UINT32 uwR6;
UINT32 uwR7;
UINT32 uwR8;
UINT32 uwR9;
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
UINT32 uwR0;
UINT32 uwR1;
UINT32 uwR2;
UINT32 uwR3;
UINT32 uwR12;
UINT32 uwLR;
UINT32 uwPC;
UINT32 uwxPSR;
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S0;
UINT32 S1;
UINT32 S2;
UINT32 S3;
UINT32 S4;
UINT32 S5;
UINT32 S6;
UINT32 S7;
UINT32 S8;
UINT32 S9;
UINT32 S10;
UINT32 S11;
UINT32 S12;
UINT32 S13;
UINT32 S14;
UINT32 S15;
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
} TaskContext;
/**
* @ingroup los_config
* @brief: Task start running function.
*
* @par Description:
* This API is used to start a task.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval None.
*
* @par Dependency:
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalStartToRun(VOID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_CONTEXT_H */

View File

@@ -0,0 +1,683 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_ARCH_INTERRUPT_H
#define _LOS_ARCH_INTERRUPT_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_arch_interrupt
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_arch_interrupt
* Highest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_HIGHEST
#define OS_HWI_PRIO_HIGHEST 0
#endif
/* *
* @ingroup los_arch_interrupt
* Lowest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_arch_interrupt
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
/* *
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt
* Count of M-Core system interrupt vector.
*/
#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
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_arch_interrupt
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt number.
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Null hardware interrupt handling function.
*
* Value: 0x02000901
*
* Solution: Pass in a valid non-null hardware interrupt handling function.
*/
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
*
* Value: 0x02000902
*
* Solution: Increase the configured maximum number of supported hardware interrupts.
*/
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
*
* Value: 0x02000903
*
* Solution: Expand the configured memory.
*/
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created.
*
* Value: 0x02000904
*
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
*/
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Invalid interrupt priority.
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: Incorrect interrupt creation mode.
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* *
* @ingroup los_arch_interrupt
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
*
* Value: 0x02000907
*
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_arch_interrupt
* SysTick control and status register.
*/
#define OS_SYSTICK_CONTROL_REG 0xE000E010
/* *
* @ingroup los_hw
* SysTick current value register.
*/
#define OS_SYSTICK_CURRENT_REG 0xE000E018
/* *
* @ingroup los_arch_interrupt
* Interrupt Priority-Level Registers.
*/
#define OS_NVIC_PRI_BASE 0xE000E400
/* *
* @ingroup los_arch_interrupt
* Interrupt enable register for 0-31.
*/
#define OS_NVIC_SETENA_BASE 0xE000E100
/* *
* @ingroup los_arch_interrupt
* interrupt pending register.
*/
#define OS_NVIC_SETPEND_BASE 0xE000E200
/* *
* @ingroup los_arch_interrupt
* Interrupt active register.
*/
#define OS_NVIC_INT_ACT_BASE 0xE000E300
/* *
* @ingroup los_arch_interrupt
* Interrupt disable register for 0-31.
*/
#define OS_NVIC_CLRENA_BASE 0xE000E180
/* *
* @ingroup los_arch_interrupt
* Interrupt control and status register.
*/
#define OS_NVIC_INT_CTRL 0xE000ED04
/* *
* @ingroup los_arch_interrupt
* Vector table offset register.
*/
#define OS_NVIC_VTOR 0xE000ED08
/* *
* @ingroup los_arch_interrupt
* Application interrupt and reset control register
*/
#define OS_NVIC_AIRCR 0xE000ED0C
/* *
* @ingroup los_arch_interrupt
* System exception priority register.
*/
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 1 :reset.
*/
#define OS_EXC_RESET 1
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 2 :Non-Maskable Interrupt.
*/
#define OS_EXC_NMI 2
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 3 :(hard)fault.
*/
#define OS_EXC_HARD_FAULT 3
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 4 :MemManage fault.
*/
#define OS_EXC_MPU_FAULT 4
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 5 :Bus fault.
*/
#define OS_EXC_BUS_FAULT 5
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 6 :Usage fault.
*/
#define OS_EXC_USAGE_FAULT 6
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 11 :SVCall.
*/
#define OS_EXC_SVC_CALL 11
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 12 :Debug monitor.
*/
#define OS_EXC_DBG_MONITOR 12
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 14 :PendSV.
*/
#define OS_EXC_PEND_SV 14
/* *
* @ingroup los_arch_interrupt
* Interrupt No. 15 :SysTick.
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_arch_interrupt
* @brief: Hardware interrupt entry function.
*
* @par Description:
* This API is used as all hardware interrupt handling function entry.
*
* @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 HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Reset the vector table.
*
* @par Description:
* This API is used to reset the vector table.
*
* @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 Reset_Handler(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Pended System Call.
*
* @par Description:
* PendSV can be pended and is useful for an OS to pend an exception
* so that an action can be performed after other important tasks are completed.
*
* @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 HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
*
* description: the register files that saved when exception triggered
*
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
*/
typedef struct TagExcContext {
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
UINT32 S16;
UINT32 S17;
UINT32 S18;
UINT32 S19;
UINT32 S20;
UINT32 S21;
UINT32 S22;
UINT32 S23;
UINT32 S24;
UINT32 S25;
UINT32 S26;
UINT32 S27;
UINT32 S28;
UINT32 S29;
UINT32 S30;
UINT32 S31;
#endif
UINT32 uwR4;
UINT32 uwR5;
UINT32 uwR6;
UINT32 uwR7;
UINT32 uwR8;
UINT32 uwR9;
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
/* auto save */
UINT32 uwSP;
UINT32 uwR0;
UINT32 uwR1;
UINT32 uwR2;
UINT32 uwR3;
UINT32 uwR12;
UINT32 uwLR;
UINT32 uwPC;
UINT32 uwxPSR;
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED) && (__FPU_USED== 1U)))
UINT32 S0;
UINT32 S1;
UINT32 S2;
UINT32 S3;
UINT32 S4;
UINT32 S5;
UINT32 S6;
UINT32 S7;
UINT32 S8;
UINT32 S9;
UINT32 S10;
UINT32 S11;
UINT32 S12;
UINT32 S13;
UINT32 S14;
UINT32 S15;
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
} EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalSVCHandler(VOID);
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the bus status register was being pushed.
*/
#define OS_EXC_BF_STKERR 1
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the bus status register was out of the stack.
*/
#define OS_EXC_BF_UNSTKERR 2
/**
* @ingroup los_exc
* Cortex-M exception types: Bus status register imprecise data access violation.
*/
#define OS_EXC_BF_IMPRECISERR 3
/**
* @ingroup los_exc
* Cortex-M exception types: Bus status register exact data access violation.
*/
#define OS_EXC_BF_PRECISERR 4
/**
* @ingroup los_exc
* Cortex-M exception types: Bus status register access violation while pointing.
*/
#define OS_EXC_BF_IBUSERR 5
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the memory management status register was being pushed.
*/
#define OS_EXC_MF_MSTKERR 6
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the memory management status register was out of the stack.
*/
#define OS_EXC_MF_MUNSTKERR 7
/**
* @ingroup los_exc
* Cortex-M exception types: Memory management status register data access violation.
*/
#define OS_EXC_MF_DACCVIOL 8
/**
* @ingroup los_exc
* Cortex-M exception types: Memory management status register access violation.
*/
#define OS_EXC_MF_IACCVIOL 9
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage indicating that the divisor is zero during the division operation.
*/
#define OS_EXC_UF_DIVBYZERO 10
/**
* @ingroup los_exc
* Cortex-M exception types: Usage error, error caused by unaligned access.
*/
#define OS_EXC_UF_UNALIGNED 11
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage attempting to execute coprocessor related instruction.
*/
#define OS_EXC_UF_NOCP 12
/**
* @ingroup los_exc
* Cortex-M exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
*/
#define OS_EXC_UF_INVPC 13
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage, attempting to cut to ARM state.
*/
#define OS_EXC_UF_INVSTATE 14
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage. Executed instruction whose code is undefined.
*/
#define OS_EXC_UF_UNDEFINSTR 15
/**
* @ingroup los_exc
* Cortex-M exception types: NMI
*/
#define OS_EXC_CAUSE_NMI 16
/**
* @ingroup los_exc
* Cortex-M exception types: hard fault
*/
#define OS_EXC_CAUSE_HARDFAULT 17
/**
* @ingroup los_exc
* Cortex-M exception types: The task handler exits.
*/
#define OS_EXC_CAUSE_TASK_EXIT 18
/**
* @ingroup los_exc
* Cortex-M exception types: A fatal error.
*/
#define OS_EXC_CAUSE_FATAL_ERR 19
/**
* @ingroup los_exc
* Cortex-M exception types: Hard Fault caused by a debug event.
*/
#define OS_EXC_CAUSE_DEBUGEVT 20
/**
* @ingroup los_exc
* Cortex-M exception types: A hard fault that occurs when a quantity is oriented.
*/
#define OS_EXC_CAUSE_VECTBL 21
/**
* @ingroup los_exc
* Exception information structure
*
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;
/**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
#define MAX_INT_INFO_SIZE (8 + 0x164)
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_INTERRUPT_H */

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_ARCH_TIMER_H
#define _LOS_ARCH_TIMER_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_timer.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_TIMER_H */

View File

@@ -0,0 +1,163 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_context.h"
#include "securec.h"
#include "los_arch_context.h"
#include "los_arch_interrupt.h"
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_debug.h"
/* ****************************************************************************
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
HalHwiInit();
}
/* ****************************************************************************
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
(VOID)LOS_IntLock();
while (1) {
}
}
/* ****************************************************************************
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
topStack --- Top of task's stack
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
context->S16 = 0xAA000010;
context->S17 = 0xAA000011;
context->S18 = 0xAA000012;
context->S19 = 0xAA000013;
context->S20 = 0xAA000014;
context->S21 = 0xAA000015;
context->S22 = 0xAA000016;
context->S23 = 0xAA000017;
context->S24 = 0xAA000018;
context->S25 = 0xAA000019;
context->S26 = 0xAA00001A;
context->S27 = 0xAA00001B;
context->S28 = 0xAA00001C;
context->S29 = 0xAA00001D;
context->S30 = 0xAA00001E;
context->S31 = 0xAA00001F;
context->S0 = 0xAA000000;
context->S1 = 0xAA000001;
context->S2 = 0xAA000002;
context->S3 = 0xAA000003;
context->S4 = 0xAA000004;
context->S5 = 0xAA000005;
context->S6 = 0xAA000006;
context->S7 = 0xAA000007;
context->S8 = 0xAA000008;
context->S9 = 0xAA000009;
context->S10 = 0xAA00000A;
context->S11 = 0xAA00000B;
context->S12 = 0xAA00000C;
context->S13 = 0xAA00000D;
context->S14 = 0xAA00000E;
context->S15 = 0xAA00000F;
context->FPSCR = 0x00000000;
context->NO_NAME = 0xAA000011;
#endif
context->secureContext = 0UL;
context->stackLimit = (UINT32)topStack;
context->excReturn = 0xFFFFFFBC;
context->uwR4 = 0x04040404L;
context->uwR5 = 0x05050505L;
context->uwR6 = 0x06060606L;
context->uwR7 = 0x07070707L;
context->uwR8 = 0x08080808L;
context->uwR9 = 0x09090909L;
context->uwR10 = 0x10101010L;
context->uwR11 = 0x11111111L;
context->uwPriMask = 0;
context->uwR0 = taskID;
context->uwR1 = 0x01010101L;
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
{
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
context->uwR0 = param;
context->uwPC = sigHandler;
context->stackLimit = (UINT32)stackTop;
context->excReturn = 0xFFFFFFBC;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();
HalStartToRun();
return LOS_OK; /* never return */
}

View File

@@ -0,0 +1,270 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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.
*/
.syntax unified
.arch armv8.1-m.main
.fpu vfpv3-d16-fp16
.thumb
.equ OS_FPU_CPACR, 0xE000ED88
.equ OS_FPU_CPACR_ENABLE, 0x00F00000
.equ OS_NVIC_INT_CTRL, 0xE000ED04
.equ OS_NVIC_SYSPRI2, 0xE000ED20
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
.equ OS_NVIC_PENDSVSET, 0x10000000
.equ OS_TASK_STATUS_RUNNING, 0x0010
.section .text
.thumb
.macro SIGNAL_CONTEXT_RESTORE
PUSH {R12, LR}
BLX OsSignalTaskContextRestore
POP {R12, LR}
CMP R0, #0
MOV R1, R0
BNE SignalContextRestore
.endm
.type HalStartFirstTask, %function
.global HalStartFirstTask
HalStartFirstTask:
MOV R0, #2
MSR CONTROL, R0
LDR R1, =g_losTask
LDR R0, [R1, #4]
LDR R12, [R0] /* Get the stack pointer of the current task. */
LDMFD R12!, {R1-R3} /* Read from stack: R1 = secureContext, R2 = stackLmit and R3 = excReturn.*/
LDR R4, =g_secureContext
STR R1, [R4] /* Set the secureContext to g_secureContext handler. */
MSR PSPLIM, R2 /* Set the stackLmit for the PSPLIM about current task. */
ISB
LDR.W R1, =OS_FPU_CPACR
LDR R1, [R1]
AND R1, R1, #OS_FPU_CPACR_ENABLE
CMP R1, #OS_FPU_CPACR_ENABLE
BNE __DisabledFPU1
ADD R12, R12, #64
VPUSH {S0}
VPOP {S0}
__DisabledFPU1:
ADD R12, R12, #36
MSR PSP, R12
CPSIE I
BX R3
.type ArchIntLock, %function
.global ArchIntLock
ArchIntLock:
.fnstart
.cantunwind
MRS R0, PRIMASK
CPSID I
BX LR
.fnend
.type ArchIntUnLock, %function
.global ArchIntUnLock
ArchIntUnLock:
.fnstart
.cantunwind
MRS R0, PRIMASK
CPSIE I
BX LR
.fnend
.type ArchIntRestore, %function
.global ArchIntRestore
ArchIntRestore:
.fnstart
.cantunwind
MSR PRIMASK, R0
BX LR
.fnend
.type ArchTaskSchedule, %function
.global ArchTaskSchedule
ArchTaskSchedule:
.fnstart
.cantunwind
ldr r0, =OS_NVIC_INT_CTRL
ldr r1, =OS_NVIC_PENDSVSET
str r1, [r0]
dsb
isb
bx lr
.fnend
.type HalPendSV, %function
.global HalPendSV
HalPendSV:
.fnstart
.cantunwind
mrs r12, PRIMASK
cpsid I
HalTaskSwitch:
SIGNAL_CONTEXT_RESTORE
push {r12, lr}
blx OsSchedTaskSwitch
pop {r12, lr}
cmp r0, #0
mov r0, lr
bne TaskContextSwitch
msr PRIMASK, r12
bx lr
TaskContextSwitch:
mov lr, r0
mrs r0, psp
LDR R2, =g_secureContext
LDR R1, [R2]
CBZ R1, __SaveNSContext /* If the g_secureContext is NULL, so no secure context to save. */
PUSH {R0-R1, R12, R14} /* Store registers, include LR, PRIMASK. */
BL HalSecureContextSave /* Store the secure context to g_secureContext->curStackPointer. */
POP {R0-R3}
MOV LR, R3
MOV R12, R2 /* R2 = PRIMASK. */
__SaveNSContext:
STMFD R0!, {R4-R12}
LDR.W R3, =OS_FPU_CPACR
LDR R3, [R3]
AND R3, R3, #OS_FPU_CPACR_ENABLE
CMP R3, #OS_FPU_CPACR_ENABLE
BNE __DisabledFPU2
VSTMDB R0!, {D8-D15}
__DisabledFPU2:
LDR R5, =g_losTask
LDR R6, [R5] /* Get the stackPointer handler of the current task. */
SUBS R0, R0, #12
STR R0, [R6] /* Save the new top of stack in TCB. */
MRS R2, PSPLIM
MOV R3, LR
STMIA R0!, {R1, R2-R3} /* Store g_secureContext, PSPLIM and LR on the stack of current task. */
LDR R0, [R5, #4]
STR R0, [R5]
LDR R1, [R0]
SignalContextRestore:
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
MSR PSPLIM, R2
MOV LR, R3
LDR R2, =g_secureContext
STR R0, [R2] /* Set the secureContext of the new task to g_secureContext. */
CBZ R0, __RestoreNSContext /* If there is no secure context for the new task, so restore from the non-secure context. */
PUSH {R1, R3}
BL HalSecureContextLoad /* Restore the secure context. */
POP {R1, R3}
MOV LR, R3
__RestoreNSContext:
LDR.W R3, =OS_FPU_CPACR
LDR R3, [R3]
AND R3, R3, #OS_FPU_CPACR_ENABLE
CMP R3, #OS_FPU_CPACR_ENABLE
BNE __DisabledFPU3
VLDMIA R1!, {D8-D15}
__DisabledFPU3:
LDMFD R1!, {R4-R12}
MSR PSP, R1
MSR PRIMASK, R12
BX LR
.fnend
.type HalSVCStartSchedule, %function
.global HalSVCStartSchedule
HalSVCStartSchedule:
.fnstart
.cantunwind
LDR R4, =OS_NVIC_SYSPRI2
LDR R5, =OS_NVIC_PENDSV_PRI
STR R5, [R4]
CPSIE I
DSB
ISB
SVC 2
.fnend
.type HalSVCSecureContextAlloc, %function
.global HalSVCSecureContextAlloc
HalSVCSecureContextAlloc:
.fnstart
.cantunwind
SVC 0
BX LR
.fnend
.type HalSVCSecureContextFree, %function
.global HalSVCSecureContextFree
HalSVCSecureContextFree:
.fnstart
.cantunwind
SVC 1
BX LR
.fnend
.type HalSVCHandler, %function
.global HalSVCHandler
HalSVCHandler:
.fnstart
.cantunwind
TST LR, #0x04
ITE EQ
MRSEQ R1, MSP
MRSNE R1, PSP
LDR R0, [R1, #24]
LDRB R0, [R0, #-2] /* Get the SVC number. */
PUSH {LR}
MOV R2, R1 /* Get the stack for R2. */
LDMFD R2!, {R1} /* Get the input arg for HalSecureSVCHandler. */
STMFD R2!, {R1}
BL HalSecureSVCHandler
POP {LR}
BX LR
.fnend

View File

@@ -0,0 +1,368 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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.
*/
.syntax unified
.arch armv8.1-m.main
.fpu vfpv3-d16-fp16
.thumb
.section .text
.global HalExcNMI
.global HalExcHardFault
.global HalExcMemFault
.global HalExcBusFault
.global HalExcUsageFault
.extern HalExcHandleEntry
.extern g_uwExcTbl
.extern g_taskScheduled
.equ OS_FLG_BGD_ACTIVE, 0x0002
.equ OS_EXC_CAUSE_NMI, 16
.equ OS_EXC_CAUSE_HARDFAULT, 17
.equ HF_DEBUGEVT, 20
.equ HF_VECTBL, 21
.equ FLAG_ADDR_VALID, 0x10000
.equ FLAG_HWI_ACTIVE, 0x20000
.equ FLAG_NO_FLOAT, 0x10000000
.equ OS_NVIC_FSR , 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
.equ OS_NVIC_HFSR , 0xE000ED2C //HardFault State Register
.equ OS_NVIC_BFAR , 0xE000ED38
.equ OS_NVIC_MMAR , 0xE000ED34
.equ OS_NVIC_ACT_BASE , 0xE000E300
.equ OS_NVIC_SHCSRS , 0xE000ED24
.equ OS_NVIC_SHCSR_MASK , 0xC00
.type HalExcNMI, %function
.global HalExcNMI
HalExcNMI:
.fnstart
.cantunwind
MOV R0, #OS_EXC_CAUSE_NMI
MOV R1, #0
B osExcDispatch
.fnend
.type HalExcHardFault, %function
.global HalExcHardFault
HalExcHardFault:
.fnstart
.cantunwind
MOV R0, #OS_EXC_CAUSE_HARDFAULT
LDR R2, =OS_NVIC_HFSR
LDR R2, [R2]
MOV R1, #HF_DEBUGEVT
ORR R0, R0, R1, LSL #0x8
TST R2, #0x80000000
BNE osExcDispatch // DEBUGEVT
AND R0, R0 , #0x000000FF
MOV R1, #HF_VECTBL
ORR R0, R0, R1, LSL #0x8
TST R2, #0x00000002
BNE osExcDispatch // VECTBL
//if not DEBUGEVT and VECTBL then is FORCED
AND R0, R0, #0x000000FF
LDR R2, =OS_NVIC_FSR
LDR R2, [R2]
TST R2, #0x8000 // BFARVALID
BNE _HFBusFault // BusFault
TST R2, #0x80 // MMARVALID
BNE _HFMemFault // MemFault
MOV R12,#0
B osHFExcCommonBMU
.fnend
.type _HFBusFault, %function
_HFBusFault:
.fnstart
.cantunwind
LDR R1, =OS_NVIC_BFAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
B osHFExcCommonBMU
.fnend
.type _HFMemFault, %function
_HFMemFault:
.fnstart
.cantunwind
LDR R1, =OS_NVIC_MMAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
.fnend
.type osHFExcCommonBMU, %function
.global osHFExcCommonBMU
osHFExcCommonBMU:
.fnstart
.cantunwind
CLZ R2, R2
LDR R3, =g_uwExcTbl
ADD R3, R3, R2
LDRB R2, [R3]
ORR R0, R0, R2, LSL #0x8
ORR R0, R0 ,R12
B osExcDispatch
.fnend
.type HalExcBusFault, %function
.global HalExcBusFault
HalExcBusFault:
.fnstart
.cantunwind
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
TST R0, #0x8000 // BFARVALID
BEQ _ExcBusNoADDR
LDR R1, =OS_NVIC_BFAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
AND R0, R0, #0x1F00
B osExcCommonBMU
.fnend
.type _ExcBusNoADDR, %function
.global _ExcBusNoADDR
_ExcBusNoADDR:
.fnstart
.cantunwind
MOV R12,#0
B osExcCommonBMU
.fnend
.type HalExcMemFault, %function
.global HalExcMemFault
HalExcMemFault:
.fnstart
.cantunwind
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
TST R0, #0x80 // MMARVALID
BEQ _ExcMemNoADDR
LDR R1, =OS_NVIC_MMAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
AND R0, R0, #0x1B
B osExcCommonBMU
.fnend
.type _ExcMemNoADDR, %function
.global _ExcMemNoADDR
_ExcMemNoADDR:
.fnstart
.cantunwind
MOV R12,#0
B osExcCommonBMU
.fnend
.type HalExcUsageFault, %function
.global HalExcUsageFault
HalExcUsageFault:
.fnstart
.cantunwind
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
MOVW R1, #0x030F
LSL R1, R1, #16
AND R0, R0, R1
MOV R12, #0
.fnend
.type osExcCommonBMU, %function
.global osExcCommonBMU
osExcCommonBMU:
.fnstart
.cantunwind
CLZ R0, R0
LDR R3, =g_uwExcTbl
ADD R3, R3, R0
LDRB R0, [R3]
ORR R0, R0, R12
.fnend
// R0 -- EXCCAUSE(bit 16 is 1 if EXCADDR valid), R1 -- EXCADDR
.type osExcDispatch, %function
.global osExcDispatch
osExcDispatch:
.fnstart
.cantunwind
LDR R2, =OS_NVIC_ACT_BASE
MOV R12, #8 // R12 is hwi check loop counter
.fnend
.type _hwiActiveCheck, %function
.global _hwiActiveCheck
_hwiActiveCheck:
.fnstart
.cantunwind
LDR R3, [R2] // R3 store active hwi register when exc
CMP R3, #0
BEQ _hwiActiveCheckNext
// exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
AND R12, R12, #1
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as pid
.fnend
.type _ExcInMSP, %function
.global _ExcInMSP
_ExcInMSP:
.fnstart
.cantunwind
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
VPUSH {D8-D15}
B _handleEntry
.fnend
.type _NoFloatInMsp, %function
.global _NoFloatInMsp
_NoFloatInMsp:
.fnstart
.cantunwind
ADD R3, R13, #32
PUSH {R3} // save IRQ SP // store message-->exc: MSP(R13)
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
.type _hwiActiveCheckNext, %function
.global _hwiActiveCheckNext
_hwiActiveCheckNext:
.fnstart
.cantunwind
ADD R2, R2, #4 // next NVIC ACT ADDR
SUBS R12, R12, #1
BNE _hwiActiveCheck
/*NMI interrupt excption*/
LDR R2, =OS_NVIC_SHCSRS
LDRH R2,[R2]
LDR R3,=OS_NVIC_SHCSR_MASK
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
// exc occurred in Task or Init or exc
// reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp
// exc occurred in Task
MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #104
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
VPUSH {D8-D15}
// copy auto saved task register
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
VLDMIA R3!, {D8-D15}
VSTMDB R2!, {D8-D15}
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
.type _NoFloatInPsp, %function
.global _NoFloatInPsp
_NoFloatInPsp:
.fnstart
.cantunwind
MOV R2, R13 // no auto push floating registers
SUB R13, #32 // add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #32
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
STMFD R2!, {R4-R11}
ORR R0, R0, #FLAG_NO_FLOAT
.fnend
.type _handleEntry, %function
.global _handleEntry
_handleEntry:
.fnstart
.cantunwind
MOV R3, R13 // R13:the 4th param
CPSID I
CPSID F
B HalExcHandleEntry
NOP
.fnend

View File

@@ -0,0 +1,649 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_interrupt.h"
#include <stdarg.h>
#include "securec.h"
#include "los_context.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
/* ****************************************************************************
Function : HalInterrupt
Description : Hardware interrupt entry function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
{
UINT32 hwiIndex;
UINT32 intSave;
#if (LOSCFG_KERNEL_RUNSTOP == 1)
SCB->SCR &= (UINT32) ~((UINT32)SCB_SCR_SLEEPDEEP_Msk);
#endif
intSave = LOS_IntLock();
g_intCount++;
LOS_IntRestore(intSave);
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
g_intCount--;
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
#define MEMFAULT (1 << 16)
#define DIV0FAULT (1 << 4)
#define UNALIGNFAULT (1 << 3)
#define HARDFAULT_IRQN (-13)
ExcInfo g_excInfo = {0};
UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
0, 0, 0, 0, OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR,
0, 0, 0, OS_EXC_BF_STKERR, OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR,
0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
};
#if (LOSCFG_KERNEL_PRINTF != 0)
STATIC VOID OsExcNvicDump(VOID)
{
#define OS_NR_NVIC_EXC_DUMP_TYPES 7
UINT32 *base = NULL;
UINT32 len, i, j;
UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_TYPES] = {
OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE, OS_NVIC_INT_ACT_BASE,
OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL
};
UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_TYPES] = {
OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, OS_NVIC_INT_ACT_SIZE,
OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE,
OS_NVIC_INT_CTRL_SIZE
};
CHAR strRgEnable[] = "enable";
CHAR strRgPending[] = "pending";
CHAR strRgActive[] = "active";
CHAR strRgPriority[] = "priority";
CHAR strRgException[] = "exception";
CHAR strRgShcsr[] = "shcsr";
CHAR strRgIntCtrl[] = "control";
CHAR *strRgs[] = {
strRgEnable, strRgPending, strRgActive, strRgPriority,
strRgException, strRgShcsr, strRgIntCtrl
};
PRINTK("\r\nOS exception NVIC dump:\n");
for (i = 0; i < OS_NR_NVIC_EXC_DUMP_TYPES; i++) {
base = (UINT32 *)rgNvicBases[i];
len = rgNvicLens[i];
PRINTK("interrupt %s register, base address: %p, size: 0x%x\n", strRgs[i], base, len);
len = (len >> 2); /* 2: Gets the next register offset */
for (j = 0; j < len; j++) {
PRINTK("0x%x ", *(base + j));
if ((j != 0) && ((j % 16) == 0)) { /* 16: print wrap line */
PRINTK("\n");
}
}
PRINTK("\n");
}
}
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
{
PRINTK("Current task info:\n");
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
} else if (excInfo->phase == OS_EXC_IN_HWI) {
PRINTK("Exception occur in interrupt phase!\n");
} else {
PRINTK("Exception occur in system init phase!\n");
}
}
STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
{
PRINTK("Exception reg dump:\n");
PRINTK("PC = 0x%x\n", excInfo->context->uwPC);
PRINTK("LR = 0x%x\n", excInfo->context->uwLR);
PRINTK("SP = 0x%x\n", excInfo->context->uwSP);
PRINTK("R0 = 0x%x\n", excInfo->context->uwR0);
PRINTK("R1 = 0x%x\n", excInfo->context->uwR1);
PRINTK("R2 = 0x%x\n", excInfo->context->uwR2);
PRINTK("R3 = 0x%x\n", excInfo->context->uwR3);
PRINTK("R4 = 0x%x\n", excInfo->context->uwR4);
PRINTK("R5 = 0x%x\n", excInfo->context->uwR5);
PRINTK("R6 = 0x%x\n", excInfo->context->uwR6);
PRINTK("R7 = 0x%x\n", excInfo->context->uwR7);
PRINTK("R8 = 0x%x\n", excInfo->context->uwR8);
PRINTK("R9 = 0x%x\n", excInfo->context->uwR9);
PRINTK("R10 = 0x%x\n", excInfo->context->uwR10);
PRINTK("R11 = 0x%x\n", excInfo->context->uwR11);
PRINTK("R12 = 0x%x\n", excInfo->context->uwR12);
PRINTK("PriMask = 0x%x\n", excInfo->context->uwPriMask);
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
UINT32 index;
OsBackTraceHookCall(LR, LOSCFG_BACKTRACE_DEPTH, 0, excInfo->context->uwSP);
PRINTK("----- backtrace start -----\n");
for (index = 0; index < LOSCFG_BACKTRACE_DEPTH; index++) {
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
PRINTK("\r\nmemory pools check:\n");
#if (LOSCFG_PLATFORM_EXC == 1)
MemInfoCB memExcInfo[OS_SYS_MEM_NUM];
UINT32 errCnt;
UINT32 i;
(VOID)memset_s(memExcInfo, sizeof(memExcInfo), 0, sizeof(memExcInfo));
errCnt = OsMemExcInfoGet(OS_SYS_MEM_NUM, memExcInfo);
if (errCnt < OS_SYS_MEM_NUM) {
errCnt += OsMemboxExcInfoGet(OS_SYS_MEM_NUM - errCnt, memExcInfo + errCnt);
}
if (errCnt == 0) {
PRINTK("all memory pool check passed!\n");
return;
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
if (ret == LOS_OK) {
PRINTK("system heap memcheck over, all passed!\n");
}
PRINTK("memory pool check end!\n");
}
#endif
STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
{
#if (LOSCFG_KERNEL_PRINTF != 0)
PRINTK("*************Exception Information**************\n");
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
#endif
}
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
{
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; /* 16: Get Exception Type */
g_intCount++;
g_excInfo.nestCnt++;
g_excInfo.type = excType & OS_NULL_SHORT;
if (tmpFlag & OS_EXC_FLAG_FAULTADDR_VALID) {
g_excInfo.faultAddr = faultAddr;
} else {
g_excInfo.faultAddr = OS_EXC_IMPRECISE_ACCESS_ADDR;
}
if (g_losTask.runTask != NULL) {
if (tmpFlag & OS_EXC_FLAG_IN_HWI) {
g_excInfo.phase = OS_EXC_IN_HWI;
g_excInfo.thrdPid = pid;
} else {
g_excInfo.phase = OS_EXC_IN_TASK;
g_excInfo.thrdPid = g_losTask.runTask->taskID;
}
} else {
g_excInfo.phase = OS_EXC_IN_INIT;
g_excInfo.thrdPid = OS_NULL_INT;
}
if (excType & OS_EXC_FLAG_NO_FLOAT) {
g_excInfo.context = (EXC_CONTEXT_S *)((CHAR *)excBufAddr - LOS_OFF_SET_OF(EXC_CONTEXT_S, uwR4));
} else {
g_excInfo.context = excBufAddr;
}
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
ArchSysExit();
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = 0; /* [1] reset */
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
#endif
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
#else
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT);
#endif
return;
}

View File

@@ -0,0 +1,127 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_timer.h"
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = SysTick_IRQn,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 ret;
ArchTickTimer *tick = &g_archTickTimer;
tick->freq = OS_SYS_CLOCK;
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(tick->irqNum, handler, NULL);
#else
OsSetVector(tick->irqNum, handler);
#endif
#endif
ret = SysTick_Config(g_cyclesPerTick);
if (ret == 1) {
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
}
return LOS_OK;
}
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime;
}
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;
if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave);
return (UINT64)hwCycle;
}
STATIC VOID SysTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
STATIC VOID SysTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
__DSB();
__WFI();
__ISB();
return LOS_OK;
}

View File

@@ -29,52 +29,55 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FS_OPERATIONS_H_
#define _FS_OPERATIONS_H_
#include "los_trustzone.h"
#include "los_secure_macros.h"
#include "los_secure_context.h"
#include "los_debug.h"
#include "los_arch_context.h"
#include "los_interrupt.h"
#include "fcntl.h"
#include "dirent.h"
#include "unistd.h"
#include "sys/mount.h"
#include "sys/stat.h"
#include "sys/statfs.h"
OsSecureContext *g_secureContext = NULL;
#define FS_SUCCESS 0
#define FS_FAILURE (-1)
#define MAX_FILESYSTEM_LEN 2
VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
{
switch (svcID) {
case OS_SVC_START_SCHEDULE:
HalSecureContextInit();
HalStartFirstTask();
break;
case OS_SVC_ALLOCATE_SECURE_CONTEXT:
g_secureContext = HalSecureContextAlloc(arg);
LOS_ASSERT(g_secureContext != NULL);
HalSecureContextLoad(g_secureContext);
break;
case OS_SVC_FREE_SECURE_CONTEXT:
LOS_ASSERT(g_secureContext != NULL);
HalSecureContextFree(g_secureContext);
break;
default:
PRINT_ERR("Incorrect svc id = %u\n", svcID);
break;
}
}
struct MountOps {
int (*Mount)(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags,
const void *data);
int (*Umount)(const char* target);
int (*Umount2)(const char* target, int flag);
int (*Statfs)(const char *path, struct statfs *buf);
};
VOID HalStartToRun(VOID)
{
HalSVCStartSchedule();
}
struct FsMap {
const char *fileSystemtype;
const struct MountOps *fsMops;
const struct FileOps *fsFops;
};
VOID LOS_SecureContextAlloc(UINT32 secureStackSize)
{
if (secureStackSize == 0) {
return;
}
struct FileOps {
int (*Open)(const char *path, int openFlag, ...);
int (*Close)(int fd);
int (*Unlink)(const char *fileName);
int (*Rmdir)(const char *dirName);
int (*Mkdir)(const char *dirName, mode_t mode);
struct dirent *(*Readdir)(DIR *dir);
DIR *(*Opendir)(const char *dirName);
int (*Closedir)(DIR *dir);
int (*Read)(int fd, void *buf, size_t len);
int (*Write)(int fd, const void *buf, size_t len);
off_t (*Seek)(int fd, off_t offset, int whence);
int (*Getattr)(const char *path, struct stat *buf);
int (*Rename)(const char *oldName, const char *newName);
int (*Fsync)(int fd);
int (*Fstat)(int fd, struct stat *buf);
int (*Stat)(const char *path, struct stat *buf);
int (*Ftruncate)(int fd, off_t length);
};
LOS_ASSERT((__get_IPSR() == 0) && (__get_PRIMASK() == 0));
secureStackSize = LOS_Align(secureStackSize, sizeof(UINTPTR));
HalSVCSecureContextAlloc(secureStackSize);
}
VOID LOS_SecureContextFree(VOID)
{
HalSVCSecureContextFree();
}
#endif /* _FS_OPERATIONS_H_ */

View File

@@ -1,106 +1,60 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021 Nuclei Limited. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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.
*
* Description: Provide a task example.
*/
#include "task_sample.h"
#include "los_config.h"
#include "los_debug.h"
#include "los_interrupt.h"
#include "los_task.h"
#include "los_tick.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
UINT8 __attribute__ ((aligned (8))) g_memStart[OS_SYS_MEM_SIZE];
VOID TaskSampleEntry2(VOID)
{
while (1) {
printf("TaskSampleEntry2 running...\n");
LOS_TaskDelay(10000); /* 10 Seconds */
}
}
VOID TaskSampleEntry1(VOID)
{
while (1) {
printf("TaskSampleEntry1 running...\n");
LOS_TaskDelay(2000); /* 2 Seconds */
}
}
VOID TaskSample(VOID)
{
UINT32 uwRet;
UINT32 taskID1;
UINT32 taskID2;
TSK_INIT_PARAM_S stTask = {0};
stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry1;
stTask.uwStackSize = 0x1000;
stTask.pcName = "TaskSampleEntry1";
stTask.usTaskPrio = 6; /* Os task priority is 6 */
uwRet = LOS_TaskCreate(&taskID1, &stTask);
if (uwRet != LOS_OK) {
printf("Task1 create failed\n");
}
stTask.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskSampleEntry2;
stTask.uwStackSize = 0x1000;
stTask.pcName = "TaskSampleEntry2";
stTask.usTaskPrio = 7; /* Os task priority is 7 */
uwRet = LOS_TaskCreate(&taskID2, &stTask);
if (uwRet != LOS_OK) {
printf("Task2 create failed\n");
}
}
VOID RunTaskSample(VOID)
{
UINT32 ret;
ret = LOS_KernelInit();
if (ret == LOS_OK) {
TaskSample();
LOS_Start();
}
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_TRUSTZONE_H
#define _LOS_TRUSTZONE_H
#include "los_config.h"
#include "los_task.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
extern VOID LOS_SecureContextAlloc(UINT32 secureStackSize);
extern VOID LOS_SecureContextFree(VOID);
extern VOID HalStartFirstTask(VOID);
extern VOID HalSVCStartSchedule(VOID);
extern VOID HalSVCSecureContextAlloc(UINT32 secureStackSize);
extern VOID HalSVCSecureContextFree(VOID);
extern VOID HalSVCHandler(VOID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,98 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_secure_context.h"
#include "los_secure_macros.h"
#include "los_secure_heap.h"
OS_CMSE_NS_ENTRY VOID HalSecureContextInit(VOID)
{
UINT32 ipsr;
OS_IPSR_READ(ipsr);
if (!ipsr) {
return;
}
HalSecureContextInitAsm();
}
OS_CMSE_NS_ENTRY OsSecureContext *HalSecureContextAlloc(UINT32 size)
{
OsSecureContext *secureContext = NULL;
UINT32 ipsr;
OS_IPSR_READ(ipsr);
if (!ipsr) {
return NULL;
}
secureContext = HalSecureMalloc(sizeof(OsSecureContext));
if (secureContext == NULL) {
return NULL;
}
secureContext->stackLimit = HalSecureMalloc(size);
if (secureContext->stackLimit == NULL) {
HalSecureFree(secureContext);
return NULL;
}
secureContext->stackStart = secureContext->stackLimit + size;
secureContext->curStackPointer = secureContext->stackStart;
return secureContext;
}
OS_CMSE_NS_ENTRY VOID HalSecureContextFree(OsSecureContext *secureContext)
{
UINT32 ipsr;
OS_IPSR_READ(ipsr);
if (!ipsr) {
return;
}
HalSecureFree(secureContext->stackLimit);
secureContext->stackLimit = NULL;
HalSecureFree(secureContext);
}
OS_CMSE_NS_ENTRY VOID HalSecureContextLoad(OsSecureContext *secureContext)
{
HalSecureContextLoadAsm(secureContext);
}
OS_CMSE_NS_ENTRY VOID HalSecureContextSave(OsSecureContext *secureContext)
{
HalSecureContextSaveAsm(secureContext);
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_SECURE_CONTEXT_H
#define _LOS_SECURE_CONTEXT_H
#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
typedef struct {
UINT8 *curStackPointer;
UINT8 *stackLimit;
UINT8 *stackStart;
} OsSecureContext;
extern VOID HalSecureContextInit(VOID);
extern OsSecureContext *HalSecureContextAlloc(UINT32 size);
extern VOID HalSecureContextFree(OsSecureContext *secureContext);
extern VOID HalSecureContextLoad(OsSecureContext *secureContext);
extern VOID HalSecureContextSave(OsSecureContext *secureContext);
extern VOID HalSecureContextInitAsm(VOID);
extern VOID HalSecureContextLoadAsm(OsSecureContext *secureContext);
extern VOID HalSecureContextSaveAsm(OsSecureContext *secureContext);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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.
*/
.syntax unified
.arch armv8.1-m.main
.fpu vfpv3-d16-fp16
.thumb
.equ OS_SECURE_SCB_AIRCR, 0xE000ED0C
.section .text
.thumb
.type HalSecureContextInitAsm, %function
.global HalSecureContextInitAsm
HalSecureContextInitAsm:
.fnstart
.cantunwind
LDR R0, =OS_SECURE_SCB_AIRCR
LDR R1, [R0]
MOV R2, #0xFFFF
LSL R2, R2, #16
BIC R1, R1, R2
MOV R2, #0x05FA
LSL R2, R2, #16
ORR R1, R1, R2
BIC R1, R1, #0x4000
MOV R2, #0x4000
ORR R1, R1, R2
STR R1, [R0]
MOV R0, #0
MSR PSPLIM, R0
MSR PSP, R0
MOV R0, #2
MSR CONTROL, R0
BX LR
.fnend
.type HalSecureContextLoadAsm, %function
.global HalSecureContextLoadAsm
HalSecureContextLoadAsm:
.fnstart
.cantunwind
MRS R1, IPSR
CBZ R1, __ThreadMode
LDMIA R0!, {R1, R2} /* R1 = g_secureContext->curStackPointer, R2 = g_secureContext->stackLimit. */
MSR PSPLIM, R2 /* Restore PSPLIM. */
MSR PSP, R1 /* Restore PSP. */
BX LR
.fnend
.type HalSecureContextSaveAsm, %function
.global HalSecureContextSaveAsm
HalSecureContextSaveAsm:
.fnstart
.cantunwind
MRS R0, IPSR
CBZ R0, __ThreadMode
MRS R0, PSP
STR R0, [R1] /* g_secureContext->curStackPointer = R0. */
MOV R0, #0
MSR PSPLIM, R0 /* No PSPLIM for the current task. */
MSR PSP, R0 /* No secure stack for the current task. */
.fnend
__ThreadMode:
BX LR

View File

@@ -0,0 +1,229 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_secure_heap.h"
#include "los_secure_macros.h"
#include "los_config.h"
#include "los_list.h"
STATIC UINT8 __attribute__((aligned(0x4)))g_secureHeap[LOSCFG_SECURE_HEAP_SIZE] = {0};
STATIC LOS_DL_LIST g_secureHeapFreeList = {NULL, NULL};
struct OsSecureHeapNode {
LOS_DL_LIST freeNode;
struct OsSecureHeapNode *preNode;
UINT32 size : 24;
UINT32 used : 8;
};
#define OS_SECURE_HEAP_NODE_HEAD_SIZE sizeof(struct OsSecureHeapNode)
#define OS_SECURE_HEAP_ALIGN_SIZE sizeof(UINTPTR)
#define OS_SECURE_HEAP_NODE_USED 1
#define OS_SECURE_HEAP_NODE_FREE 0
#define OS_SECURE_HEAP_FIRST_NODE ((struct OsSecureHeapNode *)g_secureHeap)
#define OS_SECURE_HEAP_NEXT_NODE(node) \
((struct OsSecureHeapNode *)((UINT8 *)(node) + (node)->size))
#define OS_SECURE_HEAP_END_NODE \
((struct OsSecureHeapNode *)((UINT8 *)g_secureHeap + LOSCFG_SECURE_HEAP_SIZE - OS_SECURE_HEAP_NODE_HEAD_SIZE))
STATIC INLINE VOID OsSecureHeapListInit(LOS_DL_LIST *head)
{
head->pstPrev = head;
head->pstNext = head;
}
STATIC INLINE VOID OsSecureHeapListDelete(LOS_DL_LIST *node)
{
node->pstNext->pstPrev = node->pstPrev;
node->pstPrev->pstNext = node->pstNext;
node->pstNext = NULL;
node->pstPrev = NULL;
}
STATIC INLINE VOID OsSecureHeapListAdd(LOS_DL_LIST *listNode, LOS_DL_LIST *node)
{
node->pstNext = listNode->pstNext;
node->pstPrev = listNode;
listNode->pstNext->pstPrev = node;
listNode->pstNext = node;
}
STATIC struct OsSecureHeapNode *OsSecureHeapFindSuitableFreeBlock(UINT32 allocSize)
{
LOS_DL_LIST *listNodeHead = &g_secureHeapFreeList;
struct OsSecureHeapNode *tmpNode = NULL;
LOS_DL_LIST_FOR_EACH_ENTRY(tmpNode, listNodeHead, struct OsSecureHeapNode, freeNode) {
if (tmpNode->size >= allocSize) {
return tmpNode;
}
}
return NULL;
}
STATIC INLINE VOID OsSecureHeapClearNode(struct OsSecureHeapNode *node)
{
node->preNode = NULL;
node->size = 0;
node->used = 0;
node->freeNode.pstPrev = NULL;
node->freeNode.pstNext = NULL;
}
STATIC INLINE VOID OsSecureHeapMergeNode(struct OsSecureHeapNode *node)
{
struct OsSecureHeapNode *nextNode = NULL;
node->preNode->size += node->size;
nextNode = (struct OsSecureHeapNode *)((UINTPTR)node + node->size);
nextNode->preNode = node->preNode;
OsSecureHeapClearNode(node);
}
STATIC INLINE VOID OsSecureHeapSplitNode(struct OsSecureHeapNode *allocNode, UINT32 allocSize)
{
struct OsSecureHeapNode *newFreeNode = NULL;
struct OsSecureHeapNode *nextNode = NULL;
newFreeNode = (struct OsSecureHeapNode *)((UINT8 *)allocNode + allocSize);
newFreeNode->preNode = allocNode;
newFreeNode->size = allocNode->size - allocSize;
newFreeNode->used = OS_SECURE_HEAP_NODE_FREE;
allocNode->size = allocSize;
nextNode = OS_SECURE_HEAP_NEXT_NODE(newFreeNode);
nextNode->preNode = newFreeNode;
if (nextNode->used == OS_SECURE_HEAP_NODE_FREE) {
OsSecureHeapListDelete(&nextNode->freeNode);
OsSecureHeapMergeNode(nextNode);
}
OsSecureHeapListAdd(&g_secureHeapFreeList, &newFreeNode->freeNode);
}
STATIC INLINE VOID OsSecureHeapFreeNode(struct OsSecureHeapNode *node)
{
struct OsSecureHeapNode *nextNode = NULL;
if ((node->preNode != NULL) && (node->preNode->used == OS_SECURE_HEAP_NODE_FREE)) {
struct OsSecureHeapNode *preNode = node->preNode;
OsSecureHeapMergeNode(node);
nextNode = OS_SECURE_HEAP_NEXT_NODE(preNode);
if (nextNode->used == OS_SECURE_HEAP_NODE_FREE) {
OsSecureHeapListDelete(&nextNode->freeNode);
OsSecureHeapMergeNode(nextNode);
}
OsSecureHeapListDelete(&preNode->freeNode);
preNode->used = OS_SECURE_HEAP_NODE_FREE;
OsSecureHeapListAdd(&g_secureHeapFreeList, &preNode->freeNode);
} else {
nextNode = OS_SECURE_HEAP_NEXT_NODE(node);
if (nextNode->used == OS_SECURE_HEAP_NODE_FREE) {
OsSecureHeapListDelete(&nextNode->freeNode);
OsSecureHeapMergeNode(nextNode);
}
node->used = OS_SECURE_HEAP_NODE_FREE;
OsSecureHeapListAdd(&g_secureHeapFreeList, &node->freeNode);
}
}
STATIC INLINE VOID *OsSecureHeapAllocNode(UINT32 size)
{
struct OsSecureHeapNode *allocNode = NULL;
UINT32 allocSize;
allocSize = LOS_Align(size + OS_SECURE_HEAP_NODE_HEAD_SIZE, OS_SECURE_HEAP_ALIGN_SIZE);
allocNode = OsSecureHeapFindSuitableFreeBlock(allocSize);
if (allocNode == NULL) {
return NULL;
}
if ((allocSize + OS_SECURE_HEAP_NODE_HEAD_SIZE + OS_SECURE_HEAP_ALIGN_SIZE) <= allocNode->size) {
OsSecureHeapSplitNode(allocNode, allocSize);
}
OsSecureHeapListDelete(&allocNode->freeNode);
allocNode->used = OS_SECURE_HEAP_NODE_USED;
return (allocNode + 1);
}
STATIC INLINE VOID OsSecureHeapInit(VOID)
{
struct OsSecureHeapNode *newNode = NULL;
struct OsSecureHeapNode *endNode = NULL;
newNode = OS_SECURE_HEAP_FIRST_NODE;
newNode->size = LOSCFG_SECURE_HEAP_SIZE - OS_SECURE_HEAP_NODE_HEAD_SIZE;
newNode->preNode = OS_SECURE_HEAP_END_NODE;
newNode->used = OS_SECURE_HEAP_NODE_FREE;
OsSecureHeapListInit(&g_secureHeapFreeList);
OsSecureHeapListAdd(&g_secureHeapFreeList, &newNode->freeNode);
endNode = OS_SECURE_HEAP_END_NODE;
endNode->preNode = newNode;
endNode->size = OS_SECURE_HEAP_NODE_HEAD_SIZE;
endNode->used = OS_SECURE_HEAP_NODE_USED;
}
OS_CMSE_NS_ENTRY VOID *HalSecureMalloc(UINT32 size)
{
if (size == 0) {
return NULL;
}
if ((g_secureHeapFreeList.pstPrev == NULL) &&
(g_secureHeapFreeList.pstNext == NULL)) {
OsSecureHeapInit();
}
return OsSecureHeapAllocNode(size);
}
OS_CMSE_NS_ENTRY VOID HalSecureFree(VOID *ptr)
{
struct OsSecureHeapNode *node = NULL;
if (ptr == NULL) {
return;
}
node = (struct OsSecureHeapNode *)((UINTPTR)ptr - OS_SECURE_HEAP_NODE_HEAD_SIZE);
if (node->used != OS_SECURE_HEAP_NODE_USED) {
return;
}
OsSecureHeapFreeNode(node);
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_SECURE_HEAP_H
#define _LOS_SECURE_HEAP_H
#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
VOID *HalSecureMalloc(UINT32 size);
VOID HalSecureFree(VOID *ptr);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_SECURE_MACROS_H
#define _LOS_SECURE_MACROS_H
#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define OS_CMSE_NS_ENTRY __attribute__((cmse_nonsecure_entry))
#define OS_CMSE_NS_CALL __attribute__((cmse_nonsecure_call))
#define OS_IPSR_READ(ipsr) __asm volatile("MRS %0, IPSR" : "=r" (ipsr))
#define OS_SVC_ALLOCATE_SECURE_CONTEXT 0
#define OS_SVC_FREE_SECURE_CONTEXT 1
#define OS_SVC_START_SCHEDULE 2
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif

View File

@@ -0,0 +1,38 @@
# Copyright (c) 2013-2019 Huawei Technologies 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,
# 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_group("iar") {
if (defined(LOSCFG_SECURE_TRUSTZONE)) {
modules = [ "TZ" ]
} else {
modules = [ "NTZ" ]
}
}

View File

@@ -0,0 +1,46 @@
# Copyright (c) 2013-2019 Huawei Technologies 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,
# 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_timer.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@@ -0,0 +1,297 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
INT32 val;
asm volatile("ldrex %0, [%1]\n"
: "=&r"(val)
: "r"(v)
: "cc");
return val;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 status;
do {
asm volatile("ldrex %0, [%1]\n"
"strex %0, %2, [%1]\n"
: "=&r"(status)
: "r"(v), "r"(setVal)
: "cc");
} while (status != 0);
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 status;
do {
asm volatile("ldrex %1, [%2]\n"
"add %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(addVal)
: "cc");
} while (status != 0);
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 status;
do {
asm volatile("ldrex %1, [%2]\n"
"sub %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(subVal)
: "cc");
} while (status != 0);
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable
* and return the previous value of the atomic variable.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The exchange value.
*
* @retval #INT32 The previous value of the atomic variable
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
asm volatile("ldrex %0, [%2]\n"
"strex %1, %3, [%2]"
: "=&r"(prevVal), "=&r"(status)
: "r"(v), "r"(val)
: "cc");
} while (status != 0);
return prevVal;
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable with compare.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The new value.
* @param oldVal [IN] The old value.
*
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
asm volatile("ldrex %0, [%2]\n"
"mov %1, #0\n"
"cmp %0, %3\n"
"bne 1f\n"
"strex %1, %4, [%2]\n"
"1:"
: "=&r"(prevVal), "=&r"(status)
: "r"(v), "r"(oldVal), "r"(val)
: "cc");
} while (status != 0);
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -0,0 +1,131 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_ARCH_CONTEXT_H
#define _LOS_ARCH_CONTEXT_H
#include "los_config.h"
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
typedef struct TagTskContext {
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S16;
UINT32 S17;
UINT32 S18;
UINT32 S19;
UINT32 S20;
UINT32 S21;
UINT32 S22;
UINT32 S23;
UINT32 S24;
UINT32 S25;
UINT32 S26;
UINT32 S27;
UINT32 S28;
UINT32 S29;
UINT32 S30;
UINT32 S31;
#endif
UINT32 uwR4;
UINT32 uwR5;
UINT32 uwR6;
UINT32 uwR7;
UINT32 uwR8;
UINT32 uwR9;
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
UINT32 uwR0;
UINT32 uwR1;
UINT32 uwR2;
UINT32 uwR3;
UINT32 uwR12;
UINT32 uwLR;
UINT32 uwPC;
UINT32 uwxPSR;
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S0;
UINT32 S1;
UINT32 S2;
UINT32 S3;
UINT32 S4;
UINT32 S5;
UINT32 S6;
UINT32 S7;
UINT32 S8;
UINT32 S9;
UINT32 S10;
UINT32 S11;
UINT32 S12;
UINT32 S13;
UINT32 S14;
UINT32 S15;
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
} TaskContext;
/**
* @ingroup los_config
* @brief: Task start running function.
*
* @par Description:
* This API is used to start a task.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval None.
*
* @par Dependency:
* <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalStartToRun(VOID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_CONTEXT_H */

View File

@@ -0,0 +1,684 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_EXC_H
#define _LOS_EXC_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* *
* @ingroup los_hwi
* Maximum number of used hardware interrupts.
*/
#ifndef OS_HWI_MAX_NUM
#define OS_HWI_MAX_NUM LOSCFG_PLATFORM_HWI_LIMIT
#endif
/* *
* @ingroup los_hwi
* Highest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_HIGHEST
#define OS_HWI_PRIO_HIGHEST 0
#endif
/* *
* @ingroup los_hwi
* Lowest priority of a hardware interrupt.
*/
#ifndef OS_HWI_PRIO_LOWEST
#define OS_HWI_PRIO_LOWEST 7
#endif
/* *
* @ingroup los_hwi
* Define the type of a hardware interrupt vector table function.
*/
typedef VOID (**HWI_VECTOR_FUNC)(void);
/* *
* @ingroup los_hwi
* Count of interrupts.
*/
extern UINT32 g_intCount;
/* *
* @ingroup los_hwi
* Count of M-Core system interrupt vector.
*/
#define OS_SYS_VECTOR_CNT 16
/* *
* @ingroup los_hwi
* Count of M-Core interrupt vector.
*/
#define OS_VECTOR_CNT (OS_SYS_VECTOR_CNT + OS_HWI_MAX_NUM)
/* *
* @ingroup los_hwi
* AIRCR register priority group parameter .
*/
#define OS_NVIC_AIRCR_PRIGROUP 7
/* *
* @ingroup los_hwi
* Boot interrupt vector table.
*/
extern UINT32 _BootVectors[];
/* *
* @ingroup los_hwi
* Hardware interrupt error code: Invalid interrupt number.
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
/* *
* @ingroup los_hwi
* Hardware interrupt error code: Null hardware interrupt handling function.
*
* Value: 0x02000901
*
* Solution: Pass in a valid non-null hardware interrupt handling function.
*/
#define OS_ERRNO_HWI_PROC_FUNC_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x01)
/* *
* @ingroup los_hwi
* Hardware interrupt error code: Insufficient interrupt resources for hardware interrupt creation.
*
* Value: 0x02000902
*
* Solution: Increase the configured maximum number of supported hardware interrupts.
*/
#define OS_ERRNO_HWI_CB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x02)
/* *
* @ingroup los_hwi
* Hardware interrupt error code: Insufficient memory for hardware interrupt initialization.
*
* Value: 0x02000903
*
* Solution: Expand the configured memory.
*/
#define OS_ERRNO_HWI_NO_MEMORY LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x03)
/* *
* @ingroup los_hwi
* Hardware interrupt error code: The interrupt has already been created.
*
* Value: 0x02000904
*
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
*/
#define OS_ERRNO_HWI_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x04)
/* *
* @ingroup los_hwi
* Hardware interrupt error code: Invalid interrupt priority.
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
/* *
* @ingroup los_hwi
* Hardware interrupt error code: Incorrect interrupt creation mode.
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
/* *
* @ingroup los_hwi
* Hardware interrupt error code: The interrupt has already been created as a fast interrupt.
*
* Value: 0x02000907
*
* Solution: Check whether the interrupt specified by the passed-in interrupt number has already been created.
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
/* *
* @ingroup los_hwi
* SysTick control and status register.
*/
#define OS_SYSTICK_CONTROL_REG 0xE000E010
/* *
* @ingroup los_hw
* SysTick current value register.
*/
#define OS_SYSTICK_CURRENT_REG 0xE000E018
/* *
* @ingroup los_hwi
* Interrupt Priority-Level Registers.
*/
#define OS_NVIC_PRI_BASE 0xE000E400
/* *
* @ingroup los_hwi
* Interrupt enable register for 0-31.
*/
#define OS_NVIC_SETENA_BASE 0xE000E100
/* *
* @ingroup los_hwi
* interrupt pending register.
*/
#define OS_NVIC_SETPEND_BASE 0xE000E200
/* *
* @ingroup los_hwi
* Interrupt active register.
*/
#define OS_NVIC_INT_ACT_BASE 0xE000E300
/* *
* @ingroup los_hwi
* Interrupt disable register for 0-31.
*/
#define OS_NVIC_CLRENA_BASE 0xE000E180
/* *
* @ingroup los_hwi
* Interrupt control and status register.
*/
#define OS_NVIC_INT_CTRL 0xE000ED04
/* *
* @ingroup los_hwi
* Vector table offset register.
*/
#define OS_NVIC_VTOR 0xE000ED08
/* *
* @ingroup los_hwi
* Application interrupt and reset control register
*/
#define OS_NVIC_AIRCR 0xE000ED0C
/* *
* @ingroup los_hwi
* System exception priority register.
*/
#define OS_NVIC_EXCPRI_BASE 0xE000ED18
/* *
* @ingroup los_hwi
* Interrupt No. 1 :reset.
*/
#define OS_EXC_RESET 1
/* *
* @ingroup los_hwi
* Interrupt No. 2 :Non-Maskable Interrupt.
*/
#define OS_EXC_NMI 2
/* *
* @ingroup los_hwi
* Interrupt No. 3 :(hard)fault.
*/
#define OS_EXC_HARD_FAULT 3
/* *
* @ingroup los_hwi
* Interrupt No. 4 :MemManage fault.
*/
#define OS_EXC_MPU_FAULT 4
/* *
* @ingroup los_hwi
* Interrupt No. 5 :Bus fault.
*/
#define OS_EXC_BUS_FAULT 5
/* *
* @ingroup los_hwi
* Interrupt No. 6 :Usage fault.
*/
#define OS_EXC_USAGE_FAULT 6
/* *
* @ingroup los_hwi
* Interrupt No. 11 :SVCall.
*/
#define OS_EXC_SVC_CALL 11
/* *
* @ingroup los_hwi
* Interrupt No. 12 :Debug monitor.
*/
#define OS_EXC_DBG_MONITOR 12
/* *
* @ingroup los_hwi
* Interrupt No. 14 :PendSV.
*/
#define OS_EXC_PEND_SV 14
/* *
* @ingroup los_hwi
* Interrupt No. 15 :SysTick.
*/
#define OS_EXC_SYS_TICK 15
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
* @ingroup los_hwi
* @brief: Hardware interrupt entry function.
*
* @par Description:
* This API is used as all hardware interrupt handling function entry.
*
* @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 HalInterrupt(VOID);
/* *
* @ingroup los_hwi
* @brief: Default vector handling function.
*
* @par Description:
* This API is used to configure interrupt for null function.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param:None.
*
* @retval:None.
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li
></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
/* *
* @ingroup los_hwi
* @brief: Reset the vector table.
*
* @par Description:
* This API is used to reset the vector table.
*
* @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 Reset_Handler(VOID);
/* *
* @ingroup los_hwi
* @brief: Pended System Call.
*
* @par Description:
* PendSV can be pended and is useful for an OS to pend an exception
* so that an action can be performed after other important tasks are completed.
*
* @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 HalPendSV(VOID);
#define OS_EXC_IN_INIT 0
#define OS_EXC_IN_TASK 1
#define OS_EXC_IN_HWI 2
#define OS_EXC_MAX_BUF_LEN 25
#define OS_EXC_MAX_NEST_DEPTH 1
#define OS_NVIC_SHCSR 0xE000ED24
#define OS_NVIC_CCR 0xE000ED14
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
#define OS_NVIC_INT_CTRL_SIZE 4
#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
#define OS_EXC_FLAG_NO_FLOAT 0x10000000
#define OS_EXC_FLAG_FAULTADDR_VALID 0x01
#define OS_EXC_FLAG_IN_HWI 0x02
#define OS_EXC_IMPRECISE_ACCESS_ADDR 0xABABABAB
#define OS_EXC_EVENT 0x00000001
/**
* @ingroup los_exc
* the struct of register files
*
* description: the register files that saved when exception triggered
*
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
*/
typedef struct TagExcContext {
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
UINT32 S16;
UINT32 S17;
UINT32 S18;
UINT32 S19;
UINT32 S20;
UINT32 S21;
UINT32 S22;
UINT32 S23;
UINT32 S24;
UINT32 S25;
UINT32 S26;
UINT32 S27;
UINT32 S28;
UINT32 S29;
UINT32 S30;
UINT32 S31;
#endif
UINT32 uwR4;
UINT32 uwR5;
UINT32 uwR6;
UINT32 uwR7;
UINT32 uwR8;
UINT32 uwR9;
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
/* auto save */
UINT32 uwSP;
UINT32 uwR0;
UINT32 uwR1;
UINT32 uwR2;
UINT32 uwR3;
UINT32 uwR12;
UINT32 uwLR;
UINT32 uwPC;
UINT32 uwxPSR;
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED) && (__FPU_USED== 1U)))
UINT32 S0;
UINT32 S1;
UINT32 S2;
UINT32 S3;
UINT32 S4;
UINT32 S5;
UINT32 S6;
UINT32 S7;
UINT32 S8;
UINT32 S9;
UINT32 S10;
UINT32 S11;
UINT32 S12;
UINT32 S13;
UINT32 S14;
UINT32 S15;
UINT32 FPSCR;
UINT32 NO_NAME;
#endif
}EXC_CONTEXT_S;
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalSVCHandler(VOID);
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the bus status register was being pushed.
*/
#define OS_EXC_BF_STKERR 1
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the bus status register was out of the stack.
*/
#define OS_EXC_BF_UNSTKERR 2
/**
* @ingroup los_exc
* Cortex-M exception types: Bus status register imprecise data access violation.
*/
#define OS_EXC_BF_IMPRECISERR 3
/**
* @ingroup los_exc
* Cortex-M exception types: Bus status register exact data access violation.
*/
#define OS_EXC_BF_PRECISERR 4
/**
* @ingroup los_exc
* Cortex-M exception types: Bus status register access violation while pointing.
*/
#define OS_EXC_BF_IBUSERR 5
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the memory management status register was being pushed.
*/
#define OS_EXC_MF_MSTKERR 6
/**
* @ingroup los_exc
* Cortex-M exception types: An error occurred while the memory management status register was out of the stack.
*/
#define OS_EXC_MF_MUNSTKERR 7
/**
* @ingroup los_exc
* Cortex-M exception types: Memory management status register data access violation.
*/
#define OS_EXC_MF_DACCVIOL 8
/**
* @ingroup los_exc
* Cortex-M exception types: Memory management status register access violation.
*/
#define OS_EXC_MF_IACCVIOL 9
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage indicating that the divisor is zero during the division operation.
*/
#define OS_EXC_UF_DIVBYZERO 10
/**
* @ingroup los_exc
* Cortex-M exception types: Usage error, error caused by unaligned access.
*/
#define OS_EXC_UF_UNALIGNED 11
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage attempting to execute coprocessor related instruction.
*/
#define OS_EXC_UF_NOCP 12
/**
* @ingroup los_exc
* Cortex-M exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
*/
#define OS_EXC_UF_INVPC 13
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage, attempting to cut to ARM state.
*/
#define OS_EXC_UF_INVSTATE 14
/**
* @ingroup los_exc
* Cortex-M exception types: Incorrect usage. Executed instruction whose code is undefined.
*/
#define OS_EXC_UF_UNDEFINSTR 15
/**
* @ingroup los_exc
* Cortex-M exception types: NMI
*/
#define OS_EXC_CAUSE_NMI 16
/**
* @ingroup los_exc
* Cortex-M exception types: hard fault
*/
#define OS_EXC_CAUSE_HARDFAULT 17
/**
* @ingroup los_exc
* Cortex-M exception types: The task handler exits.
*/
#define OS_EXC_CAUSE_TASK_EXIT 18
/**
* @ingroup los_exc
* Cortex-M exception types: A fatal error.
*/
#define OS_EXC_CAUSE_FATAL_ERR 19
/**
* @ingroup los_exc
* Cortex-M exception types: Hard Fault caused by a debug event.
*/
#define OS_EXC_CAUSE_DEBUGEVT 20
/**
* @ingroup los_exc
* Cortex-M exception types: A hard fault that occurs when a quantity is oriented.
*/
#define OS_EXC_CAUSE_VECTBL 21
/**
* @ingroup los_exc
* Exception information structure
*
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;
/**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
extern UINT8 g_uwExcTbl[32];
extern ExcInfo g_excInfo;
#define MAX_INT_INFO_SIZE (8 + 0x164)
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_EXC_H */

View File

@@ -1,7 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021 Nuclei Limited. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -27,15 +26,15 @@
* 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
*
* Description: Provide a task example.
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _TASKSAMPLE_H
#define _TASKSAMPLE_H
#ifndef _LOS_ARCH_TIMER_H
#define _LOS_ARCH_TIMER_H
#include "los_config.h"
#include "los_compiler.h"
#include "los_timer.h"
#ifdef __cplusplus
#if __cplusplus
@@ -43,12 +42,11 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
VOID RunTaskSample(VOID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _TASKSAMPLE_H */
#endif /* _LOS_ARCH_TIMER_H */

View File

@@ -0,0 +1,158 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_context.h"
#include "securec.h"
#include "los_arch_context.h"
#include "los_arch_interrupt.h"
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_debug.h"
/* ****************************************************************************
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
HalHwiInit();
}
/* ****************************************************************************
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
(VOID)LOS_IntLock();
while (1) {
}
}
/* ****************************************************************************
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
topStack --- Top of task's stack
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
context->S16 = 0xAA000010;
context->S17 = 0xAA000011;
context->S18 = 0xAA000012;
context->S19 = 0xAA000013;
context->S20 = 0xAA000014;
context->S21 = 0xAA000015;
context->S22 = 0xAA000016;
context->S23 = 0xAA000017;
context->S24 = 0xAA000018;
context->S25 = 0xAA000019;
context->S26 = 0xAA00001A;
context->S27 = 0xAA00001B;
context->S28 = 0xAA00001C;
context->S29 = 0xAA00001D;
context->S30 = 0xAA00001E;
context->S31 = 0xAA00001F;
context->S0 = 0xAA000000;
context->S1 = 0xAA000001;
context->S2 = 0xAA000002;
context->S3 = 0xAA000003;
context->S4 = 0xAA000004;
context->S5 = 0xAA000005;
context->S6 = 0xAA000006;
context->S7 = 0xAA000007;
context->S8 = 0xAA000008;
context->S9 = 0xAA000009;
context->S10 = 0xAA00000A;
context->S11 = 0xAA00000B;
context->S12 = 0xAA00000C;
context->S13 = 0xAA00000D;
context->S14 = 0xAA00000E;
context->S15 = 0xAA00000F;
context->FPSCR = 0x00000000;
context->NO_NAME = 0xAA000011;
#endif
context->uwR4 = 0x04040404L;
context->uwR5 = 0x05050505L;
context->uwR6 = 0x06060606L;
context->uwR7 = 0x07070707L;
context->uwR8 = 0x08080808L;
context->uwR9 = 0x09090909L;
context->uwR10 = 0x10101010L;
context->uwR11 = 0x11111111L;
context->uwPriMask = 0;
context->uwR0 = taskID;
context->uwR1 = 0x01010101L;
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
{
UNUSED(stackTop);
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
context->uwR0 = param;
context->uwPC = sigHandler;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();
HalStartToRun();
return LOS_OK; /* never return */
}

View File

@@ -0,0 +1,175 @@
;
; Copyright (c) 2013-2019 Huawei Technologies 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,
; 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.
;
PRESERVE8
EXPORT ArchIntLock
EXPORT ArchIntUnLock
EXPORT ArchIntRestore
EXPORT HalStartToRun
EXPORT ArchTaskSchedule
EXPORT HalPendSV
IMPORT OsSchedTaskSwitch
IMPORT OsSignalTaskContextRestore
IMPORT g_losTask
OS_FPU_CPACR EQU 0xE000ED88
OS_FPU_CPACR_ENABLE EQU 0x00F00000
OS_NVIC_INT_CTRL EQU 0xE000ED04
OS_NVIC_SYSPRI2 EQU 0xE000ED20
OS_NVIC_PENDSV_PRI EQU 0xF0F00000
OS_NVIC_PENDSVSET EQU 0x10000000
OS_TASK_STATUS_RUNNING EQU 0x0010
SECTION .text:CODE(2)
THUMB
REQUIRE8
MACRO SIGNAL_CONTEXT_RESTORE
PUSH {R12, LR}
BLX OsSignalTaskContextRestore
POP {R12, LR}
CMP R0, #0
MOV R1, R0
BNE SignalContextRestore
ENDM
HalStartToRun
LDR R4, =OS_NVIC_SYSPRI2
LDR R5, =OS_NVIC_PENDSV_PRI
STR R5, [R4]
MOV R0, #2
MSR CONTROL, R0
LDR R1, =g_losTask
LDR R0, [R1, #4]
LDR R12, [R0]
LDR.W R1, =OS_FPU_CPACR
LDR R1, [R1]
AND R1, R1, #OS_FPU_CPACR_ENABLE
CMP R1, #OS_FPU_CPACR_ENABLE
BNE __DisabledFPU
ADD R12, R12, #100
LDMFD R12!, {R0-R7}
ADD R12, R12, #72
MSR PSP, R12
VPUSH S0;
VPOP S0;
MOV LR, R5
CPSIE I
BX R6
__DisabledFPU
ADD R12, R12, #36
LDMFD R12!, {R0-R7}
MSR PSP, R12
MOV LR, R5
CPSIE I
BX R6
ArchIntLock
MRS R0, PRIMASK
CPSID I
BX LR
ArchIntUnLock
MRS R0, PRIMASK
CPSIE I
BX LR
ArchIntRestore
MSR PRIMASK, R0
BX LR
ArchTaskSchedule
LDR R0, =OS_NVIC_INT_CTRL
LDR R1, =OS_NVIC_PENDSVSET
STR R1, [R0]
DSB
ISB
BX LR
HalPendSV
MRS R12, PRIMASK
CPSID I
HalTaskSwitch
PUSH {R12, LR}
BLX OsSchedTaskSwitch
POP {R12, LR}
CMP R0, #0
MOV R0, LR
BNE TaskContextSwitch
MSR PRIMASK, R12
BX LR
TaskContextSwitch
MOV LR, R0
MRS R0, PSP
STMFD R0!, {R4-R12}
LDR.W R3, =OS_FPU_CPACR
LDR R3, [R3]
AND R3, R3, #OS_FPU_CPACR_ENABLE
CMP R3, #OS_FPU_CPACR_ENABLE
BNE __DisabledFPU1
VSTMDB R0!, {D8-D15}
__DisabledFPU1
LDR R5, =g_losTask
LDR R6, [R5]
STR R0, [R6]
LDR R0, [R5, #4]
STR R0, [R5]
LDR R1, [R0]
SignalContextRestore
LDR.W R3, =OS_FPU_CPACR
LDR R3, [R3]
AND R3, R3, #OS_FPU_CPACR_ENABLE
CMP R3, #OS_FPU_CPACR_ENABLE
BNE __DisabledFPU2
VLDMIA R1!, {D8-D15}
__DisabledFPU2
LDMFD R1!, {R4-R12}
MSR PSP, R1
MSR PRIMASK, R12
BX LR
END

View File

@@ -0,0 +1,285 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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.
*/
PRESERVE8
SECTION .text:CODE(2)
THUMB
EXPORT HalExcNMI
EXPORT HalExcHardFault
EXPORT HalExcMemFault
EXPORT HalExcBusFault
EXPORT HalExcUsageFault
EXPORT HalSVCHandler
IMPORT HalExcHandleEntry
IMPORT g_uwExcTbl
IMPORT g_taskScheduled
OS_FLG_BGD_ACTIVE EQU 0x0002
OS_EXC_CAUSE_NMI EQU 16
OS_EXC_CAUSE_HARDFAULT EQU 17
HF_DEBUGEVT EQU 20
HF_VECTBL EQU 21
FLAG_ADDR_VALID EQU 0x10000
FLAG_HWI_ACTIVE EQU 0x20000
FLAG_NO_FLOAT EQU 0x10000000
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Register
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Register
OS_NVIC_BFAR EQU 0xE000ED38
OS_NVIC_MMAR EQU 0xE000ED34
OS_NVIC_ACT_BASE EQU 0xE000E300
OS_NVIC_SHCSRS EQU 0xE000ED24
OS_NVIC_SHCSR_MASK EQU 0xC00
HalExcNMI
MOV R0, #OS_EXC_CAUSE_NMI
MOV R1, #0
B osExcDispatch
HalExcHardFault
MOV R0, #OS_EXC_CAUSE_HARDFAULT
LDR R2, =OS_NVIC_HFSR
LDR R2, [R2]
MOV R1, #HF_DEBUGEVT
ORR R0, R0, R1, LSL #0x8
TST R2, #0x80000000
BNE osExcDispatch ; DEBUGEVT
AND R0, R0 , #0x000000FF
MOV R1, #HF_VECTBL
ORR R0, R0, R1, LSL #0x8
TST R2, #0x00000002
BNE osExcDispatch ; VECTBL
;if not DEBUGEVT and VECTBL then is FORCED
AND R0, R0, #0x000000FF
LDR R2, =OS_NVIC_FSR
LDR R2, [R2]
TST R2, #0x8000 ; BFARVALID
BNE _HFBusFault ; BusFault
TST R2, #0x80 ; MMARVALID
BNE _HFMemFault ; MemFault
MOV R12,#0
B osHFExcCommonBMU
_HFBusFault
LDR R1, =OS_NVIC_BFAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
B osHFExcCommonBMU
_HFMemFault
LDR R1, =OS_NVIC_MMAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
osHFExcCommonBMU
CLZ R2, R2
LDR R3, =g_uwExcTbl
ADD R3, R3, R2
LDRB R2, [R3]
ORR R0, R0, R2, LSL #0x8
ORR R0, R0 ,R12
B osExcDispatch
HalSVCHandler
TST LR, #0x4
ITE EQ
MRSEQ R0, MSP
MRSNE R0, PSP
LDR R1, [R0,#24]
LDRB R0, [R1,#-2]
MOV R1, #0
B osExcDispatch
HalExcBusFault
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
TST R0, #0x8000 ; BFARVALID
BEQ _ExcBusNoADDR
LDR R1, =OS_NVIC_BFAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
AND R0, R0, #0x1F00
B osExcCommonBMU
_ExcBusNoADDR
MOV R12,#0
B osExcCommonBMU
HalExcMemFault
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
TST R0, #0x80 ; MMARVALID
BEQ _ExcMemNoADDR
LDR R1, =OS_NVIC_MMAR
LDR R1, [R1]
MOV R12, #FLAG_ADDR_VALID
AND R0, R0, #0x1B
B osExcCommonBMU
_ExcMemNoADDR
MOV R12,#0
B osExcCommonBMU
HalExcUsageFault
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
MOV R1, #0x030F
LSL R1, R1, #16
AND R0, R0, R1
MOV R12, #0
osExcCommonBMU
CLZ R0, R0
LDR R3, =g_uwExcTbl
ADD R3, R3, R0
LDRB R0, [R3]
ORR R0, R0, R12
; R0 -- EXCCAUSE(bit 16 is 1 if EXCADDR valid), R1 -- EXCADDR
osExcDispatch
LDR R2, =OS_NVIC_ACT_BASE
MOV R12, #8 ; R12 is hwi check loop counter
_hwiActiveCheck
LDR R3, [R2] ; R3 store active hwi register when exc
CMP R3, #0
BEQ _hwiActiveCheckNext
; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3
CLZ R2, R2
AND R12, R12, #1
ADD R2, R2, R12, LSL #5 ; calculate R2 (hwi number) as uwPid
_ExcInMSP
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}
MRS R12, PRIMASK ; store message-->exc: disable int?
PUSH {R4-R12} ; store message-->exc: {R4-R12}
VPUSH {D8-D15}
B _handleEntry
_NoFloatInMsp
ADD R3, R13, #32
PUSH {R3} ; save IRQ SP ; store message-->exc: MSP(R13)
MRS R12, PRIMASK ; store message-->exc: disable int?
PUSH {R4-R12} ; store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
_hwiActiveCheckNext
ADD R2, R2, #4 ; next NVIC ACT ADDR
SUBS R12, R12, #1
BNE _hwiActiveCheck
;/*NMI interrupt excption*/
LDR R2, =OS_NVIC_SHCSRS
LDRH R2,[R2]
LDR R3,=OS_NVIC_SHCSR_MASK
AND R2, R2,R3
CMP R2,#0
BNE _ExcInMSP
; exc occurred in Task or Init or exc
; reserved for register info from task stack
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp
; exc occurred in Task
MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #104
PUSH {R12} ; save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
VPUSH {D8-D15}
; copy auto saved task register
LDMFD R3!, {R4-R11} ; R4-R11 store PSP reg(auto push when exc in task)
VLDMIA R3!, {D8-D15}
VSTMDB R2!, {D8-D15}
STMFD R2!, {R4-R11}
B _handleEntry
_NoFloatInPsp
MOV R2, R13 ;no auto push floating registers
SUB R13, #32 ; add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #32
PUSH {R12} ; save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
LDMFD R3, {R4-R11} ; R4-R11 store PSP reg(auto push when exc in task)
STMFD R2!, {R4-R11}
ORR R0, R0, #FLAG_NO_FLOAT
_handleEntry
MOV R3, R13 ; R13:the 4th param
CPSID I
CPSID F
B HalExcHandleEntry
NOP
END

View File

@@ -0,0 +1,654 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies 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,
* 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_interrupt.h"
#include "securec.h"
#include <stdarg.h>
#include "los_arch_interrupt.h"
#include "los_context.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_task.h"
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
VOID *pParm;
} HWI_HANDLER_FUNC;
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
}
}
#else
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
{
if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
}
}
#endif
WEAK VOID SysTick_Handler(VOID)
{
return;
}
/* ****************************************************************************
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
/* ****************************************************************************
Function : HalHwiDefaultHandler
Description : default handler of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
/* ****************************************************************************
Function : HalInterrupt
Description : Hardware interrupt entry function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
{
UINT32 hwiIndex;
UINT32 intSave;
#if (LOSCFG_KERNEL_RUNSTOP == 1)
SCB->SCR &= (UINT32) ~((UINT32)SCB_SCR_SLEEPDEEP_Msk);
#endif
intSave = LOS_IntLock();
g_intCount++;
LOS_IntRestore(intSave);
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
if (g_hwiHandlerForm[hwiIndex] != 0) {
g_hwiHandlerForm[hwiIndex]();
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
g_intCount--;
LOS_IntRestore(intSave);
}
/* ****************************************************************************
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINTPTR intSave;
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return OS_ERRNO_HWI_ALREADY_CREATED;
}
if (hwiPrio > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
intSave = LOS_IntLock();
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
LOS_IntRestore(intSave);
return LOS_OK;
}
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
#define MEMFAULT (1 << 16)
#define DIV0FAULT (1 << 4)
#define HARDFAULT_IRQN (-13)
ExcInfo g_excInfo = {0};
UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
0, 0, 0, 0, OS_EXC_UF_NOCP, OS_EXC_UF_INVPC, OS_EXC_UF_INVSTATE, OS_EXC_UF_UNDEFINSTR,
0, 0, 0, OS_EXC_BF_STKERR, OS_EXC_BF_UNSTKERR, OS_EXC_BF_IMPRECISERR, OS_EXC_BF_PRECISERR, OS_EXC_BF_IBUSERR,
0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
};
#if (LOSCFG_KERNEL_PRINTF != 0)
STATIC VOID OsExcNvicDump(VOID)
{
#define OS_NR_NVIC_EXC_DUMP_TYPES 7
UINT32 *base = NULL;
UINT32 len, i, j;
UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_TYPES] = {
OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE, OS_NVIC_INT_ACT_BASE,
OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL
};
UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_TYPES] = {
OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, OS_NVIC_INT_ACT_SIZE,
OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE,
OS_NVIC_INT_CTRL_SIZE
};
CHAR strRgEnable[] = "enable";
CHAR strRgPending[] = "pending";
CHAR strRgActive[] = "active";
CHAR strRgPriority[] = "priority";
CHAR strRgException[] = "exception";
CHAR strRgShcsr[] = "shcsr";
CHAR strRgIntCtrl[] = "control";
CHAR *strRgs[] = {
strRgEnable, strRgPending, strRgActive, strRgPriority,
strRgException, strRgShcsr, strRgIntCtrl
};
PRINTK("\r\nOS exception NVIC dump:\n");
for (i = 0; i < OS_NR_NVIC_EXC_DUMP_TYPES; i++) {
base = (UINT32 *)rgNvicBases[i];
len = rgNvicLens[i];
PRINTK("interrupt %s register, base address: %p, size: 0x%x\n", strRgs[i], base, len);
len = (len >> 2); /* 2: Gets the next register offset */
for (j = 0; j < len; j++) {
PRINTK("0x%x ", *(base + j));
if ((j != 0) && ((j % 16) == 0)) { /* 16: print wrap line */
PRINTK("\n");
}
}
PRINTK("\n");
}
}
STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
{
PRINTK("Current task info:\n");
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
} else if (excInfo->phase == OS_EXC_IN_HWI) {
PRINTK("Exception occur in interrupt phase!\n");
} else {
PRINTK("Exception occur in system init phase!\n");
}
}
STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
{
PRINTK("Exception reg dump:\n");
PRINTK("PC = 0x%x\n", excInfo->context->uwPC);
PRINTK("LR = 0x%x\n", excInfo->context->uwLR);
PRINTK("SP = 0x%x\n", excInfo->context->uwSP);
PRINTK("R0 = 0x%x\n", excInfo->context->uwR0);
PRINTK("R1 = 0x%x\n", excInfo->context->uwR1);
PRINTK("R2 = 0x%x\n", excInfo->context->uwR2);
PRINTK("R3 = 0x%x\n", excInfo->context->uwR3);
PRINTK("R4 = 0x%x\n", excInfo->context->uwR4);
PRINTK("R5 = 0x%x\n", excInfo->context->uwR5);
PRINTK("R6 = 0x%x\n", excInfo->context->uwR6);
PRINTK("R7 = 0x%x\n", excInfo->context->uwR7);
PRINTK("R8 = 0x%x\n", excInfo->context->uwR8);
PRINTK("R9 = 0x%x\n", excInfo->context->uwR9);
PRINTK("R10 = 0x%x\n", excInfo->context->uwR10);
PRINTK("R11 = 0x%x\n", excInfo->context->uwR11);
PRINTK("R12 = 0x%x\n", excInfo->context->uwR12);
PRINTK("PriMask = 0x%x\n", excInfo->context->uwPriMask);
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
UINT32 index;
OsBackTraceHookCall(LR, LOSCFG_BACKTRACE_DEPTH, 0, excInfo->context->uwSP);
PRINTK("----- backtrace start -----\n");
for (index = 0; index < LOSCFG_BACKTRACE_DEPTH; index++) {
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
PRINTK("\r\nmemory pools check:\n");
#if (LOSCFG_PLATFORM_EXC == 1)
MemInfoCB memExcInfo[OS_SYS_MEM_NUM];
UINT32 errCnt;
UINT32 i;
(VOID)memset_s(memExcInfo, sizeof(memExcInfo), 0, sizeof(memExcInfo));
errCnt = OsMemExcInfoGet(OS_SYS_MEM_NUM, memExcInfo);
if (errCnt < OS_SYS_MEM_NUM) {
errCnt += OsMemboxExcInfoGet(OS_SYS_MEM_NUM - errCnt, memExcInfo + errCnt);
}
if (errCnt == 0) {
PRINTK("all memory pool check passed!\n");
return;
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
if (ret == LOS_OK) {
PRINTK("system heap memcheck over, all passed!\n");
}
PRINTK("memory pool check end!\n");
}
#endif
STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
{
#if (LOSCFG_KERNEL_PRINTF != 0)
PRINTK("*************Exception Information**************\n");
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
#endif
}
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
{
UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; /* 16: Get Exception Type */
g_intCount++;
g_excInfo.nestCnt++;
g_excInfo.type = excType & OS_NULL_SHORT;
if (tmpFlag & OS_EXC_FLAG_FAULTADDR_VALID) {
g_excInfo.faultAddr = faultAddr;
} else {
g_excInfo.faultAddr = OS_EXC_IMPRECISE_ACCESS_ADDR;
}
if (g_losTask.runTask != NULL) {
if (tmpFlag & OS_EXC_FLAG_IN_HWI) {
g_excInfo.phase = OS_EXC_IN_HWI;
g_excInfo.thrdPid = pid;
} else {
g_excInfo.phase = OS_EXC_IN_TASK;
g_excInfo.thrdPid = g_losTask.runTask->taskID;
}
} else {
g_excInfo.phase = OS_EXC_IN_INIT;
g_excInfo.thrdPid = OS_NULL_INT;
}
if (excType & OS_EXC_FLAG_NO_FLOAT) {
g_excInfo.context = (EXC_CONTEXT_S *)((CHAR *)excBufAddr - LOS_OFF_SET_OF(EXC_CONTEXT_S, uwR4));
} else {
g_excInfo.context = excBufAddr;
}
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
ArchSysExit();
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
#endif
#if (__CORTEX_M >= 0x03U) /* only for Cortex-M3 and above */
NVIC_SetPriorityGrouping(OS_NVIC_AIRCR_PRIGROUP);
#endif
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
return;
}

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