Compare commits

...

170 Commits

Author SHA1 Message Date
openharmony_ci
557a71c1c3 !1020 jffs2.patch 文件适配LTS补丁升级
Merge pull request !1020 from 闻飞/master
2022-10-08 11:28:25 +00:00
wenfei
569aecb6ea jffs2.patch update
Signed-off-by: wenfei <wenfei9@huawei.com>
2022-09-30 11:23:29 +08:00
openharmony_ci
c488817b32 !1008 修复内核告警信息
Merge pull request !1008 from zhangdengyu/fix_preferused
2022-09-26 12:52:00 +00:00
openharmony_ci
43d47a27e3 !1011 fix: 修复shell_lk.c告警清零带来的逻辑修改
Merge pull request !1011 from 夏不白/module_fix
2022-09-26 11:22:57 +00:00
xiacong
a83f916298 <fix>
恢复告警清零带来的逻辑改变

Signed-off-by: xiacong <xiacong4@huawei.com>
Change-Id: I8d34d2b9c43ea54e5474cbddcde0048658cbb891
Signed-off-by: xiacong <xiacong4@huawei.com>
2022-09-26 17:29:08 +08:00
zhangdengyu
8dbfd3846e fix: 修复告警
Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-09-26 17:08:56 +08:00
openharmony_ci
f34762c105 !1001 修复函数返回错误等问题
Merge pull request !1001 from zhangdengyu/fix_tsacn
2022-09-25 06:42:18 +00:00
zhangdengyu
043e84dfcb fix:修复函数返回错误等问题
Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-09-25 10:09:29 +08:00
openharmony_ci
453c376198 !997 Fix : 内核告警清理
Merge pull request !997 from yinjiaming/fix
2022-09-22 11:33:00 +00:00
yinjiaming
204d7a4abb fix: 内核告警清理
【背景】
内核中经扫描有可以修改的告警之处

【修改方案】
优化了代码的格式

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

re #I5SHM2

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I89be86a8317637f9eb54257131712b5b79f1e454
2022-09-22 16:53:11 +08:00
openharmony_ci
f2861a84bf !987 Fix : 内核告警清理
Merge pull request !987 from yinjiaming/fix
2022-09-21 04:42:42 +00:00
yinjiaming
96b2d557ac fix: 内核告警修复
【背景】
经代码扫描工具检测,内核代码中存在
可以修复的告警

【修改方案】
1.将单语句的if, while等加上括号
2.将C语言风格的类型转换变为C++风格

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I7d4a04a8904abb3c33e843049bf15f4386d3efd8
2022-09-21 11:38:51 +08:00
openharmony_ci
ffa11535ca !991 【OpenHarmony开源贡献者计划2022】fix warning: expression result unused
Merge pull request !991 from xiwen1225/void
2022-09-19 03:19:16 +00:00
openharmony_ci
b581207045 !992 【OpenHarmony开源贡献者计划2022】fix warning for signal_test_016.cpp
Merge pull request !992 from queuechen/warn
2022-09-19 02:44:00 +00:00
ookami78
5105249ecf fix warning for signal_test_016.cpp
Signed-off-by: ookami78 <ookami78@mymailcr.com>
2022-09-18 14:21:46 +08:00
cunwen
a61e2cf16e fix warning: expression result unused
Signed-off-by: cunwen <cunwen181168@liuxiuhai.cn>
2022-09-18 11:29:44 +08:00
openharmony_ci
39e25c5220 !989 Fix : 修复测试用例返回值问题
Merge pull request !989 from yinjiaming/dev
2022-09-13 12:38:03 +00:00
yinjiaming
5541965365 fix: 修复测试用例中函数返回值的问题
【背景】
测试用例中有函数的返回值不正确

【修改方案】
将返回值为VOID *的函数的返回值改为
retrun NULL

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

re #I5O3LH

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I6d3ce9efbe9afe14b1e9dd12538b80e69928fd71
2022-09-09 15:28:22 +08:00
openharmony_ci
edd2223083 !983 【OpenHarmony开源贡献者计划2022】删除未使用的变量 count
Merge pull request !983 from leijiawei/master
2022-09-06 06:20:52 +00:00
openharmony_ci
22392965b5 !947 Fix : 版权头时间更新
Merge pull request !947 from yinjiaming/dev
2022-09-06 02:55:30 +00:00
yinjiaming
d906bb91ea fix: 版权头时间更新问题
【背景】
一些代码文件经过修改后需要更新版权头

【修改方案】
更新了需要更新的版权头时间

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

re #I5LG22

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I7963bf6ce5746707bad688dd4c634ae9d72b3c04
2022-09-05 16:03:30 +08:00
leijiawei
51f6a20723 fix warning:unused variable 'count' & add return value
Signed-off-by: leijiawei <18691361562@163.com>
2022-08-31 15:28:27 +08:00
leibanli
325ea29df3 fix warning:unused variable 'count'
Signed-off-by: leijiawei <18691361562@163.com>
2022-08-31 15:01:32 +08:00
leibanli
c2f9f6705f 【openHarmony开源贡献者计划2022】18691361562@163.com
Signed-off-by: leibanli <18691361562@163.com>
2022-08-30 21:53:58 +08:00
openharmony_ci
71e51d8813 !971 非安全函数告警清理
Merge pull request !971 from xuxinyu/function_s
2022-08-26 04:45:29 +00:00
xuxinyu
e0b4fcb23d test: replace unsecure function with secure function
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ie120ffa529798f0f087ddfcd34f5d9c5802b6766
2022-08-25 23:08:58 +08:00
openharmony_ci
7d62d3d62b !979 style: shell脚本中不同函数使用不同变量
Merge pull request !979 from Hongjin Li/dev
2022-08-25 03:32:45 +00:00
Hongjin Li
69f3bf3a2a style: using different variable in different functions
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I814dcccefcd6248ea32cae94bfde567f3077c7cd
2022-08-25 10:16:45 +08:00
openharmony_ci
2590e34346 !969 编译构建规范优化
Merge pull request !969 from Hongjin Li/dev
2022-08-23 12:55:42 +00:00
Hongjin Li
660b314f90 style: string format in python
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: Ie84a97ca5e0250991aa774b737eb7787e27d80af
2022-08-23 20:22:13 +08:00
openharmony_ci
44ec199465 !951 【OpenHarmony开源贡献者计划2022】fix moudule to module
Merge pull request !951 from bingge88/module
2022-08-12 02:16:38 +00:00
openharmony_ci
7437408f65 !950 OpenHarmony开源贡献者计划2022】fix: change szie to size
Merge pull request !950 from Dream_Liu/master
2022-08-12 02:15:42 +00:00
binge889
1134332a58 fix moudule to module
Signed-off-by: binge889 <binge889@liuxiuhai.cn>
2022-08-11 23:31:52 +08:00
Dream_Liu
8099f6578d fix:change szie to size
Signed-off-by: Dream_Liu <lxm201x@163.com>
2022-08-11 23:14:20 +08:00
openharmony_ci
ba23a26f95 !928 Fix : 内核告警清理
Merge pull request !928 from yinjiaming/fix
2022-08-09 08:37:34 +00:00
yinjiaming
2dc24da826 fix: 内核告警清理
【背景】
内核代码经代码扫描工具发现存在一些关于代码格式的告警,
现经修改解除掉告警.

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

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

re #I5H6F5

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ie46b5b3238fd88c25f99542b8ccd138b956c6458
2022-08-08 13:09:54 +00:00
openharmony_ci
6302c5f767 !938 修复用例告警
Merge pull request !938 from xuxinyu/master
2022-07-29 03:46:59 +00:00
xuxinyu
f0d5959576 fix: 修复用例告警问题
re #I5I21P

Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Iedab5b6fddafc2042c7fd23fbcd82061629f87d8
2022-07-26 11:07:02 +08:00
openharmony_ci
65790b67d5 !937 拼写错误修正
Merge pull request !937 from yinjiaming/dev
2022-07-25 11:06:35 +00:00
openharmony_ci
9eff5cff1d !934 refactor: sysroot部件化
Merge pull request !934 from Zhaotianyu/20220716sysroot_lite
2022-07-22 08:57:25 +00:00
yinjiaming
99ea8d4ed2 fix: 拼写错误修正
【背景】
代码中存在拼写错误

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

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

re #I5IA7P

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Idd5d7fc9705e5ec661596aa6533402e8d4a8a117
2022-07-21 11:05:11 +00:00
arvinzzz
1568c317bb refactor: sysroot部件化
close: #I5HF8S

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I727b10c3b419fc71e228f5ad92abc107e756bbac
2022-07-19 12:32:32 +08:00
openharmony_ci
5e70129199 !917 【OpenHarmony开源贡献者计划2022】fix warning: unused variable
Merge pull request !917 from rtos_ming/unused
2022-07-04 01:24:28 +00:00
zhumingxian
089376994a fix warning: unused variable
Signed-off-by: zhumingxian <zhumingxian@ohos.com.cn>
2022-06-30 20:49:50 +08:00
openharmony_ci
12adfd5832 !915 【OpenHarmony开源贡献者计划2022】Fixed typos.
Merge pull request !915 from Mr_YX/master
2022-06-30 06:11:01 +00:00
openharmony_ci
c46c5a640d !905 「OpenHarmony贡献者计划2022」update signal_test_020.cpp
Merge pull request !905 from Mr_YX/master
2022-06-30 06:09:18 +00:00
mr-yx
c812b0c27b fixed typos
Signed-off-by: mr-yx <496043997@qq.com>
2022-06-28 23:48:24 +08:00
openharmony_ci
51528ec39c !906 【OpenHarmony开源贡献者计划2022】Optimized conversion instructions.
Merge pull request !906 from Mr_YX/master
2022-06-27 09:31:08 +00:00
openharmony_ci
beb03bfc81 !903 【OpenHarmony开源贡献者计划2022】fix typos for net
Merge pull request !903 from c01dface/master
2022-06-23 14:54:42 +00:00
openharmony_ci
bbbd96784e !904 修复liteos_a仓库中存在的一些拼写错误
Merge pull request !904 from Hongjin Li/dev
2022-06-23 04:15:03 +00:00
lihongjin
1c0de289ec style: Misspelling
Signed-off-by: lihongjin <lihongjin1@huawei.com>
Change-Id: I13163f2e4d1e4b6e6c6bedaf9d4e705544df926b
2022-06-23 09:45:46 +08:00
openharmony_ci
a3d757c8e1 !898 【轻量级 PR】:「OpenHarmony开源贡献者计划2022」update testsuites/unittest/libc/util/smoke/util_test_005.cpp.
Merge pull request !898 from Mr_YX/N/A
2022-06-23 01:02:42 +00:00
openharmony_ci
6fede4eb92 !892 【OpenHarmony开源贡献者计划2022】更新readme中的目录结构
Merge pull request !892 from wanggang/master
2022-06-23 00:43:57 +00:00
Mr_YX
7be302633f Signed-off-by: mr-yx <496043997@qq.com> 2022-06-20 18:08:19 +00:00
Mr_YX
0164461b33 Signed-off-by: mr-yx <496043997@qq.com> 2022-06-20 15:16:02 +00:00
Neil Chen
9bb4be5e13 fix typos for net
Signed-off-by: Neil Chen <jingsi.chen@petalmail.com>
2022-06-19 14:10:19 +08:00
openharmony_ci
4acf1e9f8d !896 feat: normalize drivers framework component and repos
Merge pull request !896 from yuanbo/master
2022-06-17 06:39:48 +00:00
openharmony_ci
870221452d !900 【轻量级 PR】:remove tzdriver Kconfig
Merge pull request !900 from WoolenSky/N/A
2022-06-17 03:16:48 +00:00
WoolenSky
30c3fb086e remove tzdriver Kconfig
Signed-off-by: YuanHao<yuanhao34@huawei.com>
2022-06-16 11:59:28 +00:00
Mr_YX
9b1e0a186b update testsuites/unittest/libc/util/smoke/util_test_005.cpp.
Signed-off-by: mr-yx <496043997@qq.com>
2022-06-15 14:05:19 +00:00
yuanbo
00dbf1e5d5 feat: normalize drivers framework component and repos
Signed-off-by: yuanbo <yuanbo@huawei.com>
2022-06-15 20:02:05 +08:00
openharmony_ci
16fdbdf650 !885 【OpenHarmony开源贡献者计划2022】代码打印中sucess修改为success
Merge pull request !885 from lingxin_2019/master
2022-06-14 01:57:54 +00:00
openharmony_ci
bee3d97163 !890 fix:修复llvm编译告警
Merge pull request !890 from Zhaotianyu/0601llvm_apt
2022-06-13 02:20:53 +00:00
wanggang
9fb176b827 update readme
Signed-off-by: wanggang <wanggang@kaihongdigi.com>
2022-06-10 10:11:17 +08:00
openharmony_ci
398f4a6ada !891 fix : 修复测试用例中部分测试内容硬编码的问题
Merge pull request !891 from yinjiaming/master
2022-06-09 12:42:07 +00:00
yinjiaming
19553f73e1 fix: 修复测试用例中部分测试内容硬编码的问题
【背景】
A核测试用例中有一些敏感字符串需要修改

【修改方案】
将敏感的字符串改为随机生成

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

re #I5ALBS

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib9b023ace6be1d58248c993f7b9919a96afbea96
2022-06-09 02:28:05 +00:00
arvinzzz
de24efadfa fix: llvm10.0->12.0
close: I5AM0I

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I02ae045208411c6dac1234372b706ce0dbec5cef
2022-06-07 15:35:33 +08:00
openharmony_ci
0057fb0dd5 !886 修复文档链接失效问题
Merge pull request !886 from xuxinyu/master
2022-05-30 08:50:35 +00:00
x_xiny
bcf7e8ee02 修复文档链接失效问题
re #I59PF7

Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Idc498604fbaadd8a00db4a5690de094883b280c4
2022-05-30 15:43:46 +08:00
lingxin_2019
0b9cac2cd3 Signed-off-by: 贺婷婷 <596256905@qq.com> 2022-05-26 08:09:56 +00:00
lingxin_2019
9958f647f5 Signed-off-by: 贺婷婷 <596256905@qq.com> 2022-05-26 12:24:46 +08:00
openharmony_ci
fa6b2d352c !880 【OpenHarmony开源贡献者计划2022】readme表达规范性和OAT英文表达规范性
Merge pull request !880 from king_he/master
2022-05-17 07:09:56 +00:00
openharmony_ci
7f57e11ef9 !881 修改jffs2引用路径
Merge pull request !881 from xuxinyu/master
2022-05-11 07:02:30 +00:00
x_xiny
1097d41a40 修改jffs2引用路径
Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Id4ab149ff33747f1957b3a6843a1d8e43447e00e
2022-05-11 11:27:11 +08:00
openharmony_ci
90d6ff9a6f !871 fix: newlib for liteos_a and clip for liteos_a_mini
Merge pull request !871 from Harylee/qemu
2022-05-05 08:41:34 +00:00
king_he
eebe85fe31 update README_zh.md.
Signed-off-by: king_he <6384784@qq.com>
2022-04-30 03:41:16 +00:00
king_he
b126f1cb5f update README_zh.md.
Signed-off-by: king_he <6384784@qq.com>
2022-04-30 03:35:27 +00:00
king_he
639160f517 update OAT.xml.
Signed-off-by: king_he <6384784@qq.com>
2022-04-30 03:26:01 +00:00
Haryslee
7fef6ac8d9 fix: newlib for liteos_a and clip for liteos_a_mini
close #I53VW6

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: I591b4ffaeb220311b63bd95f19400e0b9fde3c45
2022-04-29 14:12:29 +08:00
openharmony_ci
2f44d18618 !877 LiteOS-A内核jffs2文件系统停止使用third_party下的Linux_Kernel
Merge pull request !877 from Far/master
2022-04-29 03:32:22 +00:00
Far
fbc81cd821 fix: LiteOS-A内核jffs2文件系统停止使用third_party下的Linux_Kernel
Close #I5564N
Signed-off-by: Far <yesiyuan2@huawei.com>
2022-04-29 10:46:39 +08:00
openharmony_ci
a6e17fea9b !875 LiteIpc驱动增强:增加版本控制命令、增加handle特殊处理机制。
Merge pull request !875 from 万晓庆/master
2022-04-27 01:45:22 +00:00
openharmony_ci
18f7ab1380 !874 fix:进程退出后还能获取其调度参数的问题
Merge pull request !874 from Zhaotianyu/0426sched_fix
2022-04-26 13:27:49 +00:00
arvinzzz
d205cfa65a fix: 进程退出后获取其调度参数有问题
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I0e98fef07e4919a5fbb051899ecb45a224225f91
2022-04-26 18:35:19 +08:00
万晓庆
11b35fe795 LiteIpc驱动增强:增加版本控制命令、增加handle特殊处理机制。
Signed-off-by: 万晓庆 <wanxiaoqing@huawei.com>
2022-04-26 17:40:17 +08:00
openharmony_ci
b086195e97 !869 chore:精简冗余语句
Merge pull request !869 from Zhaotianyu/0326libc_opt
2022-04-11 02:53:22 +00:00
openharmony_ci
b90531e366 !869 chore:精简冗余语句
Merge pull request !869 from Zhaotianyu/0326libc_opt
2022-04-11 02:53:21 +00:00
arvinzzz
a1a6286500 feature: 高频函数优化
精简冗余语句

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: If7716d6ce6b751b3525c41fe3c95ff608ef64136
2022-04-08 17:14:23 +08:00
openharmony_ci
e1027b5902 !866 fix: 修复前后台进程支持
Merge pull request !866 from zhushengle/shell_
2022-04-07 11:19:32 +00:00
openharmony_ci
b9a445ca44 !866 fix: 修复前后台进程支持
Merge pull request !866 from zhushengle/shell_
2022-04-07 11:19:32 +00:00
zhushengle
338044cd9c fix: 修复前后台进程支持
1.优化shell机制,删除无用的线程
2.修复前后台进程支持

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I8bb13e53f290989455260dd5fb3f604ddebc9c8b
2022-04-06 16:47:49 +08:00
openharmony_ci
18a2fc8e8d !769 fix: 修复hm_liteipc.c的double unlock错误
Merge pull request !769 from niejianglei/master
2022-04-06 03:14:21 +00:00
openharmony_ci
fa0e803ac9 !865 add stm32mp157 development board
Merge pull request !865 from Laowang-BearPi/master
2022-04-01 06:38:31 +00:00
Laowang-BearPi
4f641cc145 删除GN中特殊构建命令
Signed-off-by: Laowang-BearPi <wangcheng@holdiot.com>
2022-03-31 23:08:50 +08:00
Laowang-BearPi
9063a45d5a 修改部分板级配置
Signed-off-by: Laowang-BearPi <wangcheng@holdiot.com>
2022-03-31 22:12:44 +08:00
Laowang-BearPi
4b4e1264f5 add stm32mp157 development board
Signed-off-by: Laowang-BearPi <wangcheng@holdiot.com>
2022-03-30 18:46:02 +08:00
openharmony_ci
3f5307e7bb !855 feat: 支持调度框架
Merge pull request !855 from zhushengle/sched_frame
2022-03-30 09:27:43 +00:00
zhushengle
eddcb840d3 feat: 支持调度框架
Close #I4Z3BL

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I5f32d1001ffabc0f725ce65b51ed9b3791e97f2b
2022-03-30 15:54:47 +08:00
openharmony_ci
a0e205eb0a !864 update readme
Merge pull request !864 from LeonChan/master
2022-03-30 03:44:30 +00:00
LeonChan
707028dfe1 update README
Signed-off-by: leonchan5 <chenwei26@huawei.com>
2022-03-29 07:15:46 +00:00
openharmony_ci
49d72afc8e !810 fix:优化修改epoll系统调用接口
Merge pull request !810 from Kiita/220224_epoll
2022-03-28 08:41:06 +00:00
zhangyan
c11ff67869 fix:优化修改epoll_create系统调用接口和epoll_create实现方式
re #I4STTF
Signed-off-by: Kiita <zhanyan@huawei.com>
Change-Id: I4d5dcfbe6937659489a3f688d188706398e25ec0
2022-03-28 04:13:54 +00:00
zhangyan
b6a49e7c89 fix:优化修改epoll_create系统调用接口和epoll_create实现方式
re #I4STTF
Signed-off-by: Kiita <zhanyan@huawei.com>
Change-Id: I06a8bb79376ca3799fa45732bc612c977e0a7ac9
2022-03-28 04:10:11 +00:00
lnlan
e847c8b468 fix:优化修改epoll_create系统调用接口和epoll_create实现方式
re #I4STTF
Signed-off-by: Kiita <zhanyan@huawei.com>
Change-Id: Ifec720eb5dd7aef8283875048d23b6a3d66b5436
2022-03-28 04:07:59 +00:00
openharmony_ci
faeeaf294c !862 fix: 修复魔法键无法显示进程信息的问题
Merge pull request !862 from zhushengle/magickey
2022-03-26 06:52:05 +00:00
zhushengle
b2caf46b4e fix: 修复魔法键无法显示进程信息的问题
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I9787fb3420da73cf289c434995fd2371e3fe5117
2022-03-26 11:54:39 +08:00
openharmony_ci
ccbc55df60 !861 feat: 优化调度debug功能
Merge pull request !861 from zhushengle/sched_stat
2022-03-26 02:19:22 +00:00
zhushengle
7f4294af00 feat: 优化调度debug功能
1.删除废弃功能
2.优化调度debug功能
3.删除sched_sq目录

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: If2e60fb334f4c3a3f6008d724d7619cdcb3baf51
2022-03-26 09:58:54 +08:00
openharmony_ci
4a63bacc47 !860 fix:修复readme链接指向问题
Merge pull request !860 from xuxinyu/master
2022-03-24 13:10:28 +00:00
x_xiny
ee6f3f0d79 fix:修复readme链接指向问题
Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Ieb18e3e525c9222aea8605875bb6c141420ae13f
2022-03-24 21:01:55 +08:00
openharmony_ci
e05300cdf0 !858 fix:修复readme链接指向问题
Merge pull request !858 from xuxinyu/master
2022-03-24 12:37:53 +00:00
openharmony_ci
b8951e2cd9 !858 fix:修复readme链接指向问题
Merge pull request !858 from xuxinyu/master
2022-03-24 12:37:53 +00:00
x_xiny
e3ce27536c fix:修复readme链接指向问题
Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: Iac679135e78e895f0bb6fb2fd12df017db3534c9
2022-03-24 20:23:34 +08:00
openharmony_ci
a6c5309a5f !856 fix: 修复类型不匹配问题
Merge pull request !856 from zhushengle/type
2022-03-24 03:59:05 +00:00
zhushengle
65d5526c70 fix: 修复类型不匹配问题
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I31e16c9716de1223db7e4de916af3e010ca5f4e4
2022-03-24 11:24:34 +08:00
openharmony_ci
33c4e194b8 !851 增加队列支持变长读操作
Merge pull request !851 from chenliming_kh/master
2022-03-24 01:51:29 +00:00
openharmony_ci
1b11caa45c !853 检视问题修复
Merge pull request !853 from wangchen/0322_up
2022-03-22 13:46:47 +00:00
wangchen
6ba17fc862 fix: kora工具检视问题修复
【背景】kora工具检视问题修复

【修改方案】
1,对部分代码问题进行整改

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

Signed-off-by: wangchen <wangchen64@huawei.com>
Change-Id: Iafc58b7c71e5d139e11a0ae9d98ca5a57fc6549f
2022-03-22 13:24:07 +00:00
openharmony_ci
f61ecd7669 !849 fix: 删除无效用例
Merge pull request !849 from zhushengle/de
2022-03-22 11:14:27 +00:00
chenliming
ec3c8be6ee chenliming@kaihongdigi.com: 队列支持变长读操作
Signed-off-by: chenliming <chenliming@kaihongdigi.com>
2022-03-22 18:36:24 +08:00
zhushengle
3cd28f32ca fix: 删除无效用例
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I8d932d850705f2ef9d54a53403fef2a44e77a2fc
2022-03-22 18:24:45 +08:00
openharmony_ci
4b6a6e806f !846 fix: 编码规范修复
Merge pull request !846 from zhushengle/xxx
2022-03-21 13:40:48 +00:00
zhushengle
216c124854 fix: 编码规范修复
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Idddb6f081546d880560d075395079d95e4112599
2022-03-21 20:47:46 +08:00
openharmony_ci
e26d969ca8 !751 OsFutexWait接口当absTime为0时,返回值不正确,导致用户态c库处理不当,触发当前线程卡死
Merge pull request !751 from zhangfanfan2/other
2022-03-21 04:03:26 +00:00
openharmony_ci
45f66359cd !841 fix:3.1代码检视问题修改
Merge pull request !841 from xuxinyu/master
2022-03-19 12:50:31 +00:00
x_xiny
5b87a530f5 fix:3.1代码检视
Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: I0e0b59cdc22b292ccf0a790010c037d43793a934
2022-03-19 20:22:59 +08:00
openharmony_ci
5280a45434 !840 fix: 修复內源检视问题
Merge pull request !840 from zhushengle/xxx
2022-03-19 10:37:45 +00:00
zhushengle
f7a8630584 fix: 修复內源检视问题
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I3e4e26d55dedc1eb079911eaee59a8bddf4e8eee
2022-03-19 17:50:04 +08:00
openharmony_ci
cb67dd5498 !834 feat: swtmr机制与调度分离,调度只针对通用线程,不针对特殊功能
Merge pull request !834 from zhushengle/swtmr
2022-03-19 07:59:45 +00:00
zhushengle
6d8cef40c8 feat: swtmr机制与调度分离,调度只针对通用线程,不针对特殊功能
背景:
原调度机制与软件定时器实现混合,调度时间链表存在两个链表,
任务切换时需要遍历两个链表才可以获取到最终的tick响应时间。
软件定时作为一个独立的功能,不应该和调度强耦合,而且软件定时
器作为一个任务,某个软件定时器的响应时间应该是软件定时器任务的
响应时间,不应该直接做为tick中断的响应时间。

方案描述:
1.将软件定时器从调度分离,作为一个独立的机制,从调度角度看其就是一个任务
2.软件定时器从调度分离之后,其timelist遍历从tick中断移动至软件定时器任务中
3.优化软件定时器的均衡调度

优势:
1.将软件定时器与调度完全分离,使得调度功能单一化,便于后续其它调度算法的引入
2.优化tick中断,减小tick中断耗时
3.优化通过写队列唤醒软件定时器任务去执行软件定时器钩子为插队列,减少软件定时
器机制本身的耗时,提升软件定时器的实时性
4.优化软件定时器均衡调度,使得软件定时器均匀分布于多核,提升软件定时器的实时性

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I07c01f134e69c1d9b7061ddf5a231df1ee99b68e
2022-03-19 11:23:36 +08:00
openharmony_ci
41b80ad20a !838 fix: 内源检视问题修复
Merge pull request !838 from Zhaotianyu/0318codex_fix_1
2022-03-18 08:42:36 +00:00
arvinzzz
47fac7158e fix: 内源检视问题修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I7c0b8f4026d8fbd4b0d985d4ce82187e56f1d6ec
2022-03-18 16:06:23 +08:00
openharmony_ci
6c0e1b1f04 !836 内核内源代码检视问题修改
Merge pull request !836 from wangchen/0317_lfx_a
2022-03-18 07:21:54 +00:00
wangchen
b06520ac7c fix: 内核内源代码检视问题修改
【背景】内源代码检视问题

【修改方案】
1,按检视意见,进行拼写等问题的修改

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

Signed-off-by: wangchen <wangchen64@huawei.com>
2022-03-17 12:33:01 +00:00
openharmony_ci
e4cad073a9 !835 fix: 修复任务部分接口防护
Merge pull request !835 from zhushengle/task
2022-03-16 12:22:41 +00:00
zhushengle
b151fa6b65 fix: 修复任务部分接口防护
1.LosTaskDelete接口未对锁调度做检查
2.LOS_SetTaskScheduler未校验任务有效性
3.LOS_TaskJoin未对系统任务做校验

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I2c0a83ed5825706f3fa2609574e9e440a0d8eb1f
2022-03-16 19:51:18 +08:00
openharmony_ci
40329e182c !832 fix: 修复部分内核态测试用例
Merge pull request !832 from zhushengle/test
2022-03-16 09:45:59 +00:00
zhushengle
0f38ecb863 fix: 修复部分内核态测试用例
1.修复删除任务后调度不及时的问题
2.修复部分内核态测试用例

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I4cb29f6a7dce96bfdad68e0d89a004b5f5e33036
2022-03-16 17:16:55 +08:00
openharmony_ci
3f43438017 !831 fix:修复拼写错误
Merge pull request !831 from xuxinyu/master
2022-03-14 14:43:36 +00:00
x_xiny
bc70db58a7 fix:修复拼写错误
Signed-off-by: x_xiny <1301913191@qq.com>
Change-Id: I1cc4897e5d37dd98696221f0cc70220cef45e7d4
2022-03-14 22:22:56 +08:00
openharmony_ci
ac9399d2b7 !830 C库gn修改
Merge pull request !830 from Zhaotianyu/0314libc_opt
2022-03-14 14:13:07 +00:00
arvinzzz
89850d0715 feature: libc opt
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I6efb8c61179b29c0415ec6df060d8a4c7ede88ab
2022-03-14 19:57:39 +08:00
openharmony_ci
86be540829 !829 fix:修改拼写错误
Merge pull request !829 from xuxinyu/FixSpellingMisstakes
2022-03-14 10:45:10 +00:00
x_xiny
0f75bf01a6 fix:内源代码检视拼写错误修改
【背景】3.1代码review问题修改

    【修改方案】
     根据检视意见对拼写错误进行修改

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

Change-Id: I9fb982a8ba2052fa4d56e91eec33c96ab4035a90
2022-03-14 17:34:46 +08:00
openharmony_ci
395c0be775 !828 fix: 内源代码检视问题修改
Merge pull request !828 from zhushengle/sample
2022-03-14 08:26:48 +00:00
zhushengle
a40f8383ee fix: 内源代码检视问题修改
1.删除测试用例中的需求单号和问题单号
2.部分格式问题
3.使用非安全函数问题

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I348bd9730f584fd3ebeb6d4245fe4a84c0c90c7d
2022-03-14 15:14:44 +08:00
openharmony_ci
87a7df48b8 !821 fix: 源代码检视问题修复
Merge pull request !821 from xuxinyu/master
2022-03-10 12:13:18 +00:00
openharmony_ci
2df39a7e51 !825 A核内源代码检视问题修改2
Merge pull request !825 from wangchen/0310_a
2022-03-10 12:12:21 +00:00
openharmony_ci
9f8127cc54 !824 fix: 源码检视修复
Merge pull request !824 from yinjiaming/master
2022-03-10 08:19:06 +00:00
wangchen
2f1ed39bc1 fix: 内源代码检视问题
【背景】内源代码检视问题

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

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

re #I4WV56
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-03-10 07:47:56 +00:00
x_xiny
0770e5f972 fix:内源代码检视修改(安全函数)
【背景】3.1代码review问题修改

【修改方案】
 根据检视意见对安全函数,版权等信息进行修改

 re #I4WV56

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

Change-Id: Ia2a6ba828700006f6bfe810714e2cd88fc2ccddc
2022-03-10 14:40:58 +08:00
openharmony_ci
0fb16312dc !823 添加一些启动注释
Merge pull request !823 from Zhaotianyu/0309reset
2022-03-10 04:06:28 +00:00
yinjiaming
9a030d6930 fix: 修复3.1源码检视的问题
【背景】
3.1 代码检视过程中有一些问题需要修复

【修改方案】
修改了失效的文档链接,更改了一些非可执行文件的权限

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: If87ac9a3e17ba679f4712552f5a89cc13349287e
2022-03-09 09:34:31 +00:00
arvinzzz
29dde5d752 refactor: 启动加注释
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I124e24f42b52c7ac1d848cbdeeb2e111d5813d33
2022-03-09 17:28:16 +08:00
openharmony_ci
b797f50596 !813 主干告警清零
Merge pull request !813 from yinjiaming/master
2022-03-09 03:51:33 +00:00
openharmony_ci
913d22bf83 !822 A核内源代码检视问题修改
Merge pull request !822 from wangchen/0308_a
2022-03-09 03:29:42 +00:00
wangchen
3824d1e9e4 【背景】内源代码检视问题
【修改方案】
1,按检视意见,进行资源泄露等问题的修改

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

re #I4WV56
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-03-08 09:45:17 +00:00
openharmony_ci
7941b93d1c !816 fix: codex及合规修复
Merge pull request !816 from Zhaotianyu/0307codex_fix
2022-03-08 08:06:29 +00:00
openharmony_ci
d376efbe46 !815 feat: 优化shell 命令
Merge pull request !815 from zhushengle/shell
2022-03-08 02:14:59 +00:00
arvinzzz
64ddb1ff07 fix:codex及合规问题修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I5a738c243a07325b7cc314956a1658a69e768559
2022-03-07 19:34:50 +08:00
zhushengle
f02d40d25d feat: 优化shell 命令
1.优化task 命令关中断时间较长的问题
  2.优化hwi 命令,可以查看不同核的中断分布情况
  3.丰富hiw 命令,统计每个中断在一定时间内的平均执行时间和最大执行时间
  4.丰富swtmr 命令,在debug模式下支持查看各软件定时器的运行情况, 默认关闭

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I01cfe50c918da51f9de5b460e9eb91a863e1de36
2022-03-07 15:25:38 +08:00
yinjiaming
672bc729a6 fix: 主干告警清理
【背景】
主干告警清理

【修改方案】
在需要的地方添加了强制类型转换

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Id6693137310d8c2e63f4e5489564d7c01c016a18
2022-03-03 12:04:22 +00:00
openharmony_ci
31403e0e45 !808 修复A核文档失效的问题
Merge pull request !808 from yinjiaming/docs-01
2022-02-18 08:06:30 +00:00
yinjiaming
456d255a81 fix: 修复A核文档失效的问题
【背景】
【内核子系统】查看Ubuntu编译环境准备 不存在

【修改方案】
源文档中的链接已经失效,现修改链接指向新的文档
【影响】
对现有的产品编译不会有影响。

re #I4U7TF

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: If566f598fa9d19c5deafbb62990fdc20c9050a58
2022-02-18 07:28:36 +00:00
openharmony_ci
8c44c82723 !807 修复A核测试用例失败的问题
Merge pull request !807 from yinjiaming/sys_test
2022-02-17 12:10:12 +00:00
openharmony_ci
4c024f757e !806 修复A核测试用例失败的问题
Merge pull request !806 from yinjiaming/master
2022-02-17 12:09:28 +00:00
yinjiaming
59329ce7c6 fix: 修复A核测试用例失败的问题
【背景】
【OpenHarmony】【master】L1 liteos测试执行liteos_a_libc_unittest.bin 测试模块,测试套TimeTimerTest 3条用例Fail

【修改方案】
将一个测试用例中创建的无限循环的线程
在测试用例末尾关闭

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

re #I4SQDR

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I390f411502fe1a6a04071e0d7e02d936e3388cd7
2022-02-17 07:34:48 +00:00
yinjiaming
be68dc8bca fix: 修复A核测试用例失败的问题
【背景】
【OpenHarmony】【master】L1 liteos测试执行liteos_a_libc_unittest.bin 测试模块,测试套SysTest 1条用例Fail

【修改方案】
将先前更改locale的地方将locale设置为默认值

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

re #I4SQDP

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I4cd5d5d59aa3ff8ece469ee7a61054f3d4635f45
2022-02-17 07:15:27 +00:00
Jianglei Nie
a0ad1a4333 fix: 修复hm_liteipc.c的double unlock错误
对g_cmsTask的访问应该加锁,但代码中LOS_MuxLock被误用为LOS_MuxUnLock,导致double unlock错误。
可以将865行的LOS_MuxUnlock改为LOS_MuxLock来解决这个问题。

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
2022-01-07 11:28:55 +08:00
zff
f504cc9145 fix: OsFutexWait接口当absTime为0时,返回值不正确,导致用户态c库不当处理,触发当前线程卡死
close: #I4KGO4

Signed-off-by: zff <zhangfanfan2@huawei.com>
Change-Id: I77d73836ec550828fd74ca84a13f83b1050316ac
2021-12-25 10:37:20 +08:00
1815 changed files with 18317 additions and 150899 deletions

View File

@@ -35,6 +35,7 @@ declare_args() {
tee_enable = false
liteos_name = "OHOS_Image"
liteos_skip_make = false
liteos_is_mini = false
}
tee = ""
@@ -75,7 +76,6 @@ generate_notice_file("kernel_notice_file") {
"$LITEOSTHIRDPARTY/musl",
"$LITEOSTHIRDPARTY/zlib",
"$LITEOSTHIRDPARTY/FatFs",
"$LITEOSTHIRDPARTY/Linux_Kernel",
"$LITEOSTHIRDPARTY/lwip",
"$LITEOSTHIRDPARTY/NuttX",
"$LITEOSTHIRDPARTY/mtd-utils",
@@ -129,7 +129,9 @@ config("stdinc_config") {
"-isystem",
std_include,
]
cflags += [ "-nostdinc" ]
if (!defined(LOSCFG_LIBC_NEWLIB)) {
cflags += [ "-nostdinc" ]
}
asmflags = cflags
}
@@ -290,6 +292,7 @@ group("modules") {
"security",
"shell",
"syscall",
"testsuites/kernel:kernel_test",
]
deps += [
@@ -315,13 +318,17 @@ group("kernel") {
}
group("liteos_a") {
deps = [
":apps",
":kernel",
":make",
":tests",
"//prebuilts/lite/sysroot/build:strip",
]
deps = [ ":kernel" ]
if (!liteos_is_mini) {
deps += [
":apps",
":tests",
"//third_party/musl/scripts/build_lite:strip",
]
if (liteos_skip_make == false) {
deps += [ ":make" ]
}
}
}
executable("liteos") {
@@ -337,6 +344,17 @@ executable("liteos") {
"-Wl,--no-eh-frame-hdr",
]
if (defined(LOSCFG_LIBC_NEWLIB)) {
ldflags += [
"-Wl,--wrap=_free_r",
"-Wl,--wrap,_malloc_usable_size_r",
"-Wl,--wrap,_malloc_r",
"-Wl,--wrap,_memalign_r",
"-Wl,--wrap,_realloc_r",
"-Wl,--wrap,_fseeko_r",
]
ldflags -= [ "-nostdlib" ]
}
libgcc = exec_script("//build/lite/run_shell_cmd.py",
[ "$cc -print-libgcc-file-name" ],
"trim string")
@@ -348,7 +366,7 @@ executable("liteos") {
} else {
ldflags +=
[ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
ldflags += [ "-Wl,-nostartfiles" ]
ldflags += [ "-nostartfiles" ]
inputs = [ "tools/build/liteos.ld" ]
}

View File

@@ -189,7 +189,7 @@ config DEBUG_VERSION
It also means you do not want to use debug modules, like shell,telnet,tftp,nfs and
memory check, etc.
If you select this option that means you enable a debug version for LiteOS.
That means you want a opposite behaviour compared to release version.
That means you want an opposite behaviour compared to release version.
config DEBUG_KERNEL
bool "Enable Debug LiteOS Kernel Resource"
@@ -198,7 +198,7 @@ config DEBUG_KERNEL
help
If you select this option that means you enable debugging kernel resource.
It also means you want to get queue, mutex, semaphore, memory debug information.
That means you want a opposite behaviour compared to release version.
That means you want an opposite behaviour compared to release version.
config DEBUG_QUEUE
bool "Enable Queue Debugging"
@@ -265,7 +265,7 @@ config MEM_LEAKCHECK
default n
depends on DEBUG_VERSION && MEM_DEBUG
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

View File

@@ -97,7 +97,7 @@ Targets:
cleanall: clean all build outputs
all: make liteos kernel image and rootfs image (Default target)
$(APPS): build all apps
$(ROOTFS): make a original rootfs image
$(ROOTFS): make an original rootfs image
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
$(LITEOS_TARGET): make liteos kernel image
update_config: update product kernel config (use menuconfig)
@@ -121,7 +121,7 @@ sysroot:
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
ifeq ($(origin SYSROOT_PATH),file)
$(HIDE)mkdir -p $(SYSROOT_PATH)/build && cd $(SYSROOT_PATH)/build && \
ln -snf $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/build/Makefile && \
ln -snf $(LITEOSTOPDIR)/../../third_party/musl/scripts/build_lite/Makefile && \
$(MAKE) TARGETS=liteos_a_user \
ARCH=$(ARCH) \
TARGET=$(LOSCFG_LLVM_TARGET) \

View File

@@ -12,9 +12,10 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
<!--
This is the configuration file template for OpenHarmony OSS Audit Tool. Please copy it to your project root dir and modify it by referring to OpenHarmony/tools_oat/README.
-->
<configuration>
@@ -23,6 +24,7 @@
<policylist>
<policy name="projectPolicy" desc="">
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="copyright" name="Huawei Device Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
</policy>
</policylist>
@@ -37,7 +39,7 @@
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies">
<filefilter name="defaultPolicyFilter" desc="Filters for license header policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->

View File

@@ -62,20 +62,19 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
## Constraints<a name="section119744591305"></a>
- Programming languages: C and C++
- Applicable development boards: Hi3518E V300 and Hi3516D V300
- Hi3518E V300 uses the JFFS2 file system by default, and Hi3516D V300 uses the FAT file system by default.
- Applicable development boards: Hi3516D V300
- Hi3516D V300 uses the FAT file system by default.
## Usage<a name="section741617511812"></a>
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on both development boards.
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on this development board.
### Preparations<a name="section1579912573329"></a>
You need to set up the compilation environment on Linux.
- [Compilation environment on Linux](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-lin.md)
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-setting.md).
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-setting.md).
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup.md)
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md).
### Source Code Acquisition<a name="section11443189655"></a>
@@ -85,9 +84,7 @@ Download and decompress a set of source code on a Linux server to acquire the [
For details about how to develop the first application, see:
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-running.md)
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-running.md)
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)
## Repositories Involved<a name="section1371113476307"></a>
@@ -95,5 +92,5 @@ For details about how to develop the first application, see:
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README.md)
**kernel\_liteos\_a**
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README.md)

View File

@@ -54,7 +54,6 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
│ ├── hw # 時鐘與中斷相關邏輯代碼
│ ├── include # 對外暴露頭文件存放目錄
│ └── uart # 串口相關邏輯代碼
├── platform # 支持不同的芯片平台代碼如Hi3516DV300等
├── security # 安全特性相關的代碼包括進程權限管理和虛擬id映射管理
├── syscall # 系統調用
└── tools # 構建工具及相關配置和代碼
@@ -63,19 +62,18 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
## 約束<a name="section119744591305"></a>
- 開發語言C/C++
- 適用於Hi3518EV300、Hi3516DV300單板
- Hi3518EV300默認使用jffs2文件系統Hi3516DV300默認使用FAT文件系統。
- 適用於Hi3516DV300單板
- Hi3516DV300默認使用FAT文件系統。
## 使用說明<a name="section741617511812"></a>
OpenHarmony LiteOS-A內核支持Hi3518EV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md)、Hi3516DV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
OpenHarmony LiteOS-A內核支持Hi3516DV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md))單板,開發者可基於單板開發運行自己的應用程序。
### 準備<a name="section1579912573329"></a>
開發者需要在Linux上搭建編譯環境
- [Ubuntu編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
- Hi3518EV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md)
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
- Hi3516DV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 獲取源碼<a name="section11443189655"></a>
@@ -86,8 +84,6 @@ OpenHarmony LiteOS-A內核支持Hi3518EV300[介紹](https://gitee.com/openhar
開發者開發第一個應用程序可參考:
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
## 相關倉<a name="section1371113476307"></a>
@@ -96,4 +92,4 @@ OpenHarmony LiteOS-A內核支持Hi3518EV300[介紹](https://gitee.com/openhar
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
**kernel\_liteos\_a**
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README_zh-HK.md)

View File

@@ -33,6 +33,7 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
│ ├── quickstart # 系统快速启动接口目录
│ ├── random # 随机数设备驱动
│ └── video # framebuffer驱动框架
├── figures # 内核架构图
├── fs # 文件系统模块主要来源于NuttX开源项目
│ ├── fat # fat文件系统
│ ├── jffs2 # jffs2文件系统
@@ -53,28 +54,28 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
│ ├── hw # 时钟与中断相关逻辑代码
│ ├── include # 对外暴露头文件存放目录
│ └── uart # 串口相关逻辑代码
├── platform # 支持不同的芯片平台代码如Hi3516DV300等
├── security # 安全特性相关的代码包括进程权限管理和虚拟id映射管理
├── shell # 接收用户输入的命令,内核去执行
├── syscall # 系统调用
├── testsuilts # 测试套件
└── tools # 构建工具及相关配置和代码
```
## 约束<a name="section119744591305"></a>
- 开发语言C/C++
- 适用于Hi3518EV300、Hi3516DV300单板
- Hi3518EV300默认使用jffs2文件系统Hi3516DV300默认使用FAT文件系统。
- 适用于Hi3516DV300单板
- Hi3516DV300默认使用FAT文件系统。
## 使用说明<a name="section741617511812"></a>
OpenHarmony LiteOS-A内核支持Hi3518EV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md)、Hi3516DV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md)单板开发者可基于两种单板开发运行自己的应用程序。
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)单板开发者可基于单板开发运行自己的应用程序。
### 准备<a name="section1579912573329"></a>
开发者需要在Linux上搭建编译环境
- [Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
- Hi3518EV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md)
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
- Hi3516DV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 获取源码<a name="section11443189655"></a>
@@ -83,9 +84,7 @@ OpenHarmony LiteOS-A内核支持Hi3518EV300[介绍](https://gitee.com/openhar
### 编译构建<a name="section2081013992812"></a>
开发者开发第一个应用程序可参考:
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
如果这是您的首次应用程序开发,可参考:
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
@@ -95,5 +94,5 @@ OpenHarmony LiteOS-A内核支持Hi3518EV300[介绍](https://gitee.com/openhar
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
**kernel\_liteos\_a**
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README_zh.md)

View File

@@ -48,6 +48,7 @@
#endif
int main(int argc, char * const *argv)
{
(void)argv;
int ret;
pid_t gid;
const char *shellPath = "/bin/mksh";

147
apps/lms/src/sample_usr_lms.c Executable file → Normal file
View File

@@ -50,14 +50,16 @@ static void BufReadTest(void *buf, int start, int end)
static void LmsMallocTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsMallocTest Start --------\n");
char *buf = (char *)malloc(16);
printf("[LmsMallocTest] malloc addr:%p size:%d\n", buf, 16);
printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1,16]\n");
BufReadTest(buf, -1, 16);
printf("[LmsMallocTest] write overflow error should be triggered, write range[0,16]\n");
BufWriteTest(buf, 0, 16);
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
BufReadTest(buf, -1, TEST_SIZE);
printf("[LmsMallocTest] write overflow error should be triggered, write range[0, TEST_SIZE]\n");
BufWriteTest(buf, 0, TEST_SIZE);
free(buf);
printf("\n-------- LmsMallocTest End --------\n");
@@ -65,46 +67,61 @@ static void LmsMallocTest(void)
static void LmsReallocTest(void)
{
#define TEST_SIZE 64
#define TEST_SIZE_MIN 32
printf("\n-------- LmsReallocTest Start --------\n");
char *buf = (char *)malloc(64);
printf("[LmsReallocTest] malloc addr:%p size:%d\n", buf, 64);
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,64]\n");
BufReadTest(buf, -1, 64);
buf = (char *)realloc(buf, 32);
printf("[LmsReallocTest] realloc addr:%p size:%d\n", buf, 32);
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,32]\n");
BufReadTest(buf, -1, 32);
free(buf);
char *buf = (char *)malloc(TEST_SIZE);
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
BufReadTest(buf, -1, TEST_SIZE);
char *buf1 = (char *)realloc(buf, TEST_SIZE_MIN);
if (buf1 == NULL) {
free(buf);
return;
}
buf = NULL;
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE_MIN]\n");
BufReadTest(buf1, -1, TEST_SIZE_MIN);
free(buf1);
printf("\n-------- LmsReallocTest End --------\n");
}
static void LmsCallocTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsCallocTest Start --------\n");
char *buf = (char *)calloc(4, 4);
printf("[LmsCallocTest] calloc addr:%p size:%d\n", buf, 16);
printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1,16]\n");
BufReadTest(buf, -1, 16);
char *buf = (char *)calloc(4, 4); /* 4: test size */
if (buf == NULL) {
return;
}
printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
BufReadTest(buf, -1, TEST_SIZE);
free(buf);
printf("\n-------- LmsCallocTest End --------\n");
}
static void LmsVallocTest(void)
{
#define TEST_SIZE 4096
printf("\n-------- LmsVallocTest Start --------\n");
char *buf = (char *)valloc(4096);
printf("[LmsVallocTest] valloc addr:%p size:%d\n", buf, 4096);
printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1,4096]\n");
BufReadTest(buf, -1, 4096);
char *buf = (char *)valloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
BufReadTest(buf, -1, TEST_SIZE);
free(buf);
printf("\n-------- LmsVallocTest End --------\n");
}
static void LmsAlignedAllocTest(void)
{
#define TEST_ALIGN_SIZE 64
#define TEST_SIZE 128
printf("\n-------- LmsAlignedAllocTest Start --------\n");
char *buf = (char *)aligned_alloc(64, 128);
printf("[LmsAlignedAllocTest] aligned_alloc boundsize:%d addr:%p size:%d\n", 64, buf, 128);
char *buf = (char *)aligned_alloc(TEST_ALIGN_SIZE, TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsAlignedAllocTest] read overflow & underflow error should be triggered, read range[-1,128]\n");
BufReadTest(buf, -1, 128);
free(buf);
@@ -113,46 +130,58 @@ static void LmsAlignedAllocTest(void)
static void LmsMemsetTest(void)
{
#define TEST_SIZE 32
printf("\n-------- LmsMemsetTest Start --------\n");
char *buf = (char *)malloc(32);
printf("[LmsMemsetTest] malloc addr:%p size:%d\n", buf, 32);
printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", 33);
memset(buf, 0, 33);
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", TEST_SIZE + 1);
memset(buf, 0, TEST_SIZE + 1);
free(buf);
printf("\n-------- LmsMemsetTest End --------\n");
}
static void LmsMemcpyTest(void)
{
#define TEST_SIZE 20
printf("\n-------- LmsMemcpyTest Start --------\n");
char *buf = (char *)malloc(20);
printf("[LmsMemcpyTest] malloc addr:%p size:%d\n", buf, 20);
char localBuf[32] = {0};
printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", 21);
memcpy(buf, localBuf, 21);
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
char localBuf[32] = {0}; /* 32: test size */
printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", TEST_SIZE + 1);
memcpy(buf, localBuf, TEST_SIZE + 1);
free(buf);
printf("\n-------- LmsMemcpyTest End --------\n");
}
static void LmsMemmoveTest(void)
{
#define TEST_SIZE 20
printf("\n-------- LmsMemmoveTest Start --------\n");
char *buf = (char *)malloc(20);
printf("[LmsMemmoveTest] malloc addr:%p size:%d\n", buf, 20);
printf("[LmsMemmoveTest] memmove overflow error should be triggered, dest addr:%p src addr:%p size:%d\n", buf + 12,
buf, 10);
memmove(buf + 12, buf, 10);
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsMemmoveTest] memmove overflow error should be triggered\n");
memmove(buf + 12, buf, 10); /* 12 and 10: test size */
free(buf);
printf("\n-------- LmsMemmoveTest End --------\n");
}
static void LmsStrcpyTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsStrcpyTest Start --------\n");
char *buf = (char *)malloc(16);
printf("[LmsStrcpyTest] malloc addr:%p size:%d\n", buf, 16);
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
char *testStr = "bbbbbbbbbbbbbbbbb";
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n",
(int)strlen(testStr) + 1);
strcpy(buf, testStr);
free(buf);
printf("\n-------- LmsStrcpyTest End --------\n");
@@ -160,9 +189,12 @@ static void LmsStrcpyTest(void)
static void LmsStrcatTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsStrcatTest Start --------\n");
char *buf = (char *)malloc(16);
printf("[LmsStrcatTest] malloc addr:%p size:%d\n", buf, 16);
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
buf[0] = 'a';
buf[1] = 'b';
buf[2] = 0;
@@ -177,22 +209,30 @@ static void LmsStrcatTest(void)
static void LmsFreeTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsFreeTest Start --------\n");
char *buf = (char *)malloc(16);
printf("[LmsFreeTest] malloc addr:%p size:%d\n", buf, 16);
printf("[LmsFreeTest] free addr:%p\n", buf, 16);
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
printf("[LmsFreeTest] free size:%d\n", TEST_SIZE);
free(buf);
printf("[LmsFreeTest] Use after free error should be triggered, read addr:%p range[1,1]\n", buf);
printf("[LmsFreeTest] Use after free error should be triggered, read range[1,1]\n");
BufReadTest(buf, 1, 1);
printf("[LmsFreeTest] double free error should be triggered, free addr:%p\n", buf);
printf("[LmsFreeTest] double free error should be triggered\n");
free(buf);
printf("\n-------- LmsFreeTest End --------\n");
}
int main(int argc, char * const * argv)
int main(int argc, char * const *argv)
{
(void)argc;
(void)argv;
printf("\n############### Lms Test start ###############\n");
char *tmp = (char *)malloc(5000);
char *tmp = (char *)malloc(5000); /* 5000: test mem size */
if (tmp == NULL) {
return;
}
LmsMallocTest();
LmsReallocTest();
LmsCallocTest();
@@ -204,5 +244,6 @@ int main(int argc, char * const * argv)
LmsStrcpyTest();
LmsStrcatTest();
LmsFreeTest();
free(tmp);
printf("\n############### Lms Test End ###############\n");
}
}

View File

@@ -42,7 +42,7 @@ copy("copy_mksh_src") {
build_ext_component("build_mksh") {
deps = [ ":copy_mksh_src" ]
deps += [ "//prebuilts/lite/sysroot" ]
deps += [ "//third_party/musl:sysroot_lite" ]
exec_path = rebase_path("$target_out_dir/mksh_build")
cflags = [

View File

@@ -62,10 +62,17 @@ int main(int argc, char **argv)
PerfStop(fd);
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "read") == 0) {
size_t size = strtoul(argv[THREE_ARGS - 1], NULL, 0);
if (size == 0) {
goto EXIT:
}
char *buf = (char *)malloc(size);
int len = PerfRead(fd, buf, size);
PerfPrintBuffer(buf, len);
free(buf);
if (buf != NULL) {
int len = PerfRead(fd, buf, size);
PerfPrintBuffer(buf, len);
free(buf);
buf = NULL;
}
} else if ((argc == TWO_ARGS) && strcmp(argv[1], "list") == 0) {
PerfList();
} else if ((argc >= THREE_ARGS) && strcmp(argv[1], "stat") == 0) {
@@ -77,6 +84,7 @@ int main(int argc, char **argv)
PerfUsage();
}
EXIT:
close(fd);
return 0;
}

View File

@@ -113,7 +113,6 @@ ssize_t PerfWriteFile(const char *filePath, const char *buf, ssize_t bufSize)
ssize_t totalWrite = 0;
if (filePath == NULL || buf == NULL || bufSize == 0) {
printf("filePath: %p, buf: %p, bufSize: %u!\n", filePath, buf, bufSize);
return -1;
}

View File

@@ -32,13 +32,15 @@
#ifndef _SHELL_PRI_H
#define _SHELL_PRI_H
#include "shell.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
extern void *ShellEntry(void *argv);
extern void ShellEntry(ShellCB *shellCB);
extern void *ShellTask(void *argv);
#ifdef __cplusplus

View File

@@ -32,6 +32,7 @@
#ifndef _SHMSG_H
#define _SHMSG_H
#include "shell_list.h"
#include "shell.h"
#ifdef __cplusplus
@@ -61,8 +62,7 @@ extern "C" {
typedef void (* OutputFunc)(const char *fmt, ...);
extern int ShellTaskInit(ShellCB *shellCB);
extern int ShellEntryInit(ShellCB *shellCB);
extern void ChildExec(const char *cmdName, char *const paramArray[]);
extern void ChildExec(const char *cmdName, char *const paramArray[], bool foreground);
extern void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB);
extern int ShellNotify(ShellCB *shellCB);

View File

@@ -31,13 +31,16 @@
#define _GNU_SOURCE
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include "show.h"
#include "shmsg.h"
#include "shcmd.h"
#include "shell_pri.h"
#include "semaphore.h"
#include "securec.h"
#include "unistd.h"
#include <sys/syscall.h>
ShellCB *g_shellCB = NULL;
@@ -77,13 +80,8 @@ static int OsShellCreateTask(ShellCB *shellCB)
goto OUT;
}
ret = ShellEntryInit(shellCB);
if (ret != SH_OK) {
goto OUT;
}
(void)pthread_join(shellCB->shellTaskHandle, NULL);
(void)pthread_join(shellCB->shellEntryHandle, NULL);
shellCB->shellEntryHandle = pthread_self();
return 0;
OUT:
ShellDeinit(shellCB);
@@ -98,7 +96,7 @@ static int DoShellExec(char **argv)
char *cmdLine = NULL;
if (strncmp(argv[0], SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
ChildExec(argv[1], argv + 1);
ChildExec(argv[1], argv + 1, FALSE);
}
for (i = 0; argv[i]; i++) {
len += strlen(argv[i]);
@@ -108,11 +106,15 @@ static int DoShellExec(char **argv)
if (!cmdLine) {
return ret;
}
memset_s(cmdLine, len, 0, len);
errno_t ret1 = memset_s(cmdLine, len, 0, len);
if (ret1 != EOK) {
free(cmdLine);
return ret1;
}
for (j = 0; j < i; j++) {
strcat_s(cmdLine, len, argv[j]);
strcat_s(cmdLine, len, " ");
(void)strcat_s(cmdLine, len, argv[j]);
(void)strcat_s(cmdLine, len, " ");
}
cmdLine[len - 2] = '\0'; /* 2, (len - 2) is the end of cmdline buf */
@@ -121,11 +123,22 @@ static int DoShellExec(char **argv)
return ret;
}
static void ShellSigChildHook(int sig)
{
(void)sig;
while (waitpid(-1, NULL, WNOHANG) > 0) {
continue;
}
}
int main(int argc, char **argv)
{
int ret = SH_NOK;
ShellCB *shellCB = NULL;
(void)signal(SIGCHLD, ShellSigChildHook);
if (argc > 1) {
ret = DoShellExec(argv + 1);
return ret;
@@ -161,7 +174,12 @@ int main(int argc, char **argv)
sem_init(&shellCB->shellSem, 0, 0);
g_shellCB = shellCB;
return OsShellCreateTask(shellCB);
ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) {
goto ERR_OUT3;
}
ShellEntry(shellCB);
ERR_OUT3:
(void)pthread_mutex_destroy(&shellCB->historyMutex);

View File

@@ -36,7 +36,6 @@
#include "dirent.h"
#include "securec.h"
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
#define CTRL_C 0x03 /* 0x03: ctrl+c ASCII */
@@ -378,7 +377,7 @@ static int OsTabMatchFile(char *cmdKey, unsigned int *len)
* Description: Pass in the string and clear useless space ,which include:
* 1) The overmatch space which is not be marked by Quote's area
* Squeeze the overmatch space into one space
* 2) Clear all space before first valid charatctor
* 2) Clear all space before first valid character
* Input: cmdKey : Pass in the buff string, which is ready to be operated
* cmdOut : Pass out the buffer string ,which has already been operated
* size : cmdKey length
@@ -407,17 +406,17 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
/* Backup the 'output' start address */
outputBak = output;
/* Scan each charactor in 'cmdKey',and squeeze the overmuch space and ignore invalid charactor */
/* Scan each character in 'cmdKey',and squeeze the overmuch space and ignore invalid character */
for (; *cmdKey != '\0'; cmdKey++) {
/* Detected a Double Quotes, switch the matching status */
if (*(cmdKey) == '\"') {
SWITCH_QUOTES_STATUS(quotes);
}
/* Ignore the current charactor in following situation */
/* Ignore the current character in following situation */
/* 1) Quotes matching status is FALSE (which said that the space is not been marked by double quotes) */
/* 2) Current charactor is a space */
/* 3) Next charactor is a space too, or the string is been seeked to the end already(\0) */
/* 4) Invalid charactor, such as single quotes */
/* 2) Current character is a space */
/* 3) Next character is a space too, or the string is been seeked to the end already(\0) */
/* 4) Invalid character, such as single quotes */
if ((*cmdKey == ' ') && ((*(cmdKey + 1) == ' ') || (*(cmdKey + 1) == '\0')) && QUOTES_STATUS_CLOSE(quotes)) {
continue;
}
@@ -431,7 +430,7 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
/* Restore the 'output' start address */
output = outputBak;
len = strlen(output);
/* Clear the space which is located at the first charactor in buffer */
/* Clear the space which is located at the first character in buffer */
if (*output == ' ') {
output++;
len--;
@@ -585,7 +584,6 @@ END:
unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr)
{
/* TODO: complete the usrspace command */
unsigned int ret = SH_OK;
if (cmdParsed && cmdStr) {
ret = SH_NOK;

View File

@@ -334,12 +334,12 @@ char *GetCmdName(const char *cmdline, unsigned int len)
/* If reach a double quotes, switch the quotes matching status */
if (*tmpStr == '\"') {
SWITCH_QUOTES_STATUS(quotes);
/* Ignore the double quote charactor itself */
/* Ignore the double quote character itself */
tmpStr++;
continue;
}
/* If detected a space which the quotes matching status is false */
/* which said has detected the first space for seperator, finish this scan operation */
/* which said has detected the first space for separator, finish this scan operation */
if ((*tmpStr == ' ') && (QUOTES_STATUS_CLOSE(quotes))) {
break;
}
@@ -351,7 +351,7 @@ char *GetCmdName(const char *cmdline, unsigned int len)
return cmdName;
}
void ChildExec(const char *cmdName, char *const paramArray[])
void ChildExec(const char *cmdName, char *const paramArray[], bool foreground)
{
int ret;
pid_t gid;
@@ -367,10 +367,12 @@ void ChildExec(const char *cmdName, char *const paramArray[])
exit(1);
}
ret = tcsetpgrp(STDIN_FILENO, gid);
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
exit(1);
if (!foreground) {
ret = tcsetpgrp(STDIN_FILENO, gid);
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
exit(1);
}
}
ret = execve(cmdName, paramArray, NULL);
@@ -404,20 +406,30 @@ int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
exit(ret);
}
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, const CmdParsed *cmdParsed)
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, CmdParsed *cmdParsed)
{
bool foreground = FALSE;
int ret;
pid_t forkPid;
if (strncmp(cmdline, CMD_EXEC_COMMAND, CMD_EXEC_COMMAND_BYTES) == 0) {
if ((cmdParsed->paramCnt > 1) && (strcmp(cmdParsed->paramArray[cmdParsed->paramCnt - 1], "&") == 0)) {
free(cmdParsed->paramArray[cmdParsed->paramCnt - 1]);
cmdParsed->paramArray[cmdParsed->paramCnt - 1] = NULL;
cmdParsed->paramCnt--;
foreground = TRUE;
}
forkPid = fork();
if (forkPid < 0) {
printf("Faild to fork from shell\n");
printf("Failed to fork from shell\n");
return;
} else if (forkPid == 0) {
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray);
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray, foreground);
} else {
waitpid(forkPid, 0, 0);
if (!foreground) {
(void)waitpid(forkPid, 0, 0);
}
ret = tcsetpgrp(STDIN_FILENO, getpid());
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
@@ -503,7 +515,7 @@ unsigned int PreHandleCmdline(const char *input, char **output, unsigned int *ou
*output = shiftStr;
*outputlen = shiftLen;
/* Check and parse "./", located at the first two charaters of the cmd */
/* Check and parse "./", located at the first two characters of the cmd */
if ((shiftLen > removeLen) && (shiftStr[0] == '.') && (shiftStr[1] == '/')) {
execLen = strlen(execCmd);
newLen = execLen + shiftLen - removeLen; /* i.e., newLen - execLen == shiftLen - removeLen */
@@ -567,20 +579,10 @@ static void ExecCmdline(const char *cmdline)
free(output);
}
void RecycleZombieChild(void)
{
while (waitpid(-1, NULL, WNOHANG) > 0) {
continue;
}
}
static void ShellCmdProcess(ShellCB *shellCB)
{
char *buf = NULL;
while (1) {
/* recycle zombine child process */
RecycleZombieChild();
buf = GetCmdline(shellCB);
char *buf = GetCmdline(shellCB);
if (buf == NULL) {
break;
}
@@ -654,25 +656,19 @@ static int ShellKernelReg(unsigned int shellHandle)
return ioctl(STDIN_FILENO, CONSOLE_CONTROL_REG_USERTASK, shellHandle);
}
void *ShellEntry(void *argv)
void ShellEntry(ShellCB *shellCB)
{
char ch;
int ret;
int n;
pid_t tid = syscall(__NR_gettid);
ShellCB *shellCB = (ShellCB *)argv;
if (shellCB == NULL) {
return NULL;
return;
}
(void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
ret = prctl(PR_SET_NAME, "ShellEntry");
if (ret != SH_OK) {
return NULL;
}
ret = ShellKernelReg((int)tid);
if (ret != 0) {
printf("another shell is already running!\n");
@@ -685,32 +681,5 @@ void *ShellEntry(void *argv)
ShellCmdLineParse(ch, (OutputFunc)printf, shellCB);
}
}
return NULL;
return;
}
int ShellEntryInit(ShellCB *shellCB)
{
int ret;
size_t stackSize = SHELL_ENTRY_STACKSIZE;
void *arg = NULL;
pthread_attr_t attr;
if (shellCB == NULL) {
return SH_NOK;
}
ret = pthread_attr_init(&attr);
if (ret != SH_OK) {
return SH_NOK;
}
pthread_attr_setstacksize(&attr, stackSize);
arg = (void *)shellCB;
ret = pthread_create(&shellCB->shellEntryHandle, &attr, &ShellEntry, arg);
if (ret != SH_OK) {
return SH_NOK;
}
return ret;
}

View File

@@ -42,7 +42,7 @@ extern "C" {
#define TFTP_NULL_UINT32 ((u32_t)0xffffffffUL)
#define TFTP_NULL_INT32 -1
#define TFTP_NULL_INT32 (-1)
/** @cond liteos
* @defgroup TFTP_Interfaces
@@ -114,7 +114,7 @@ typedef enum tagTFTPC_OpCode {
TFTPC_OP_RRQ = 1, /* read request */
TFTPC_OP_WRQ, /* write request */
TFTPC_OP_DATA, /* data packet */
TFTPC_OP_ACK, /* acknowledgement */
TFTPC_OP_ACK, /* acknowledgment */
TFTPC_OP_ERROR, /* error code */
TFTPC_OP_OPT /* option code */
} TFTPC_OPCODE_E;

View File

@@ -50,11 +50,11 @@ static char *TftpError[] = {
"Error while sending data to the peer\n",
"Requested file is not found\n",
"This is the error sent by the server when hostname cannot be resolved\n",
"Input paramters passed to TFTP interfaces are invalid\n",
"Input parameters passed to TFTP interfaces are invalid\n",
"Error detected in TFTP packet or the error received from the TFTP server\n",
"Error during packet synhronization while sending or unexpected packet is received\n",
"File size limit crossed, Max block can be 0xFFFF, each block containing 512 bytes\n",
"File name lenght greater than 256\n",
"File name length greater than 256\n",
"Hostname IP is not valid\n",
"TFTP server returned file access error\n",
"TFTP server returned error signifying that the DISK is full to write\n",
@@ -66,11 +66,11 @@ static char *TftpError[] = {
"File create error\n",
"File write error\n",
"Max time expired while waiting for file to be recived\n",
"Error when the received packet is less than 4bytes(error lenght) or greater than 512bytes\n",
"Error when the received packet is less than 4bytes(error length) or greater than 512bytes\n",
"Returned by TFTP server for protocol user error\n",
"The destination file path length greater than 256\n",
"Returned by TFTP server for undefined transfer ID\n",
"IOCTL fucntion failed at TFTP client while setting the socket to non-block\n",
"IOCTL function failed at TFTP client while setting the socket to non-block\n",
};
#ifndef ARRAY_SIZE

View File

@@ -189,7 +189,7 @@ u32_t lwip_tftp_recv_from_server(s32_t iSockNum, u32_t *pulSize, TFTPC_PACKET_S
if (iRet == -1) {
return TFTPC_SELECT_ERROR;
} else if (iRet == 0) {
return TFTPC_TIMEOUT_ERROR; /* Select timeout occured */
return TFTPC_TIMEOUT_ERROR; /* Select timeout occurred */
}
if (!FD_ISSET(iSockNum, &stReadfds)) {
@@ -218,7 +218,7 @@ u32_t lwip_tftp_recv_from_server(s32_t iSockNum, u32_t *pulSize, TFTPC_PACKET_S
usOpcode = ntohs(pstRecvBuf->usOpcode);
/* if this packet is ERROR packet */
if (usOpcode == TFTPC_OP_ERROR) {
ulError = ntohs (pstRecvBuf->u.stTFTP_Err.usErrNum);
ulError = ntohs(pstRecvBuf->u.stTFTP_Err.usErrNum);
/*If the error is according to RFC,then convert to lwip error codes.
Constant values are used in the cases as these error codes are as per
@@ -268,7 +268,7 @@ u32_t lwip_tftp_recv_from_server(s32_t iSockNum, u32_t *pulSize, TFTPC_PACKET_S
*pulSize = (u32_t)iRet;
/* If received packet is first block of data(for get operation) or if
received packet is acknowledgement for write request (put operation)
received packet is acknowledgment for write request (put operation)
store the received port number */
if (((usOpcode == TFTPC_OP_DATA) &&
(ntohs(pstRecvBuf->u.stTFTP_Data.usBlknum) == 1)) ||
@@ -500,7 +500,7 @@ static void lwip_tftp_send_error(s32_t iSockNum, u32_t ulError, const char *szEr
}
}
/* INTEFACE to get a file using filename
/* INTERFACE to get a file using filename
ulHostAddr - IP address of Host
szSrcFileName - Source file
szDestDirPath - Destination file path
@@ -687,7 +687,7 @@ u32_t lwip_tftp_get_file_by_filename(u32_t ulHostAddr,
ulErrCode = lwip_tftp_recv_from_server(iSockNum, &ulRecvSize, pstRecvBuf,
&ulIgnorePkt, &stServerAddr, pstSendBuf);
/* If select timeout occured */
/* If select timeout occurred */
if (ulErrCode == TFTPC_TIMEOUT_ERROR) {
ulTotalTime++;
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
@@ -727,7 +727,7 @@ u32_t lwip_tftp_get_file_by_filename(u32_t ulHostAddr,
}
/* if this packet is unkonwn or incorrect packet */
if (ntohs (pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
if (ntohs(pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
/* Send error packet to server */
lwip_tftp_send_error(iSockNum,
TFTPC_PROTOCOL_PROTO_ERROR,
@@ -982,7 +982,7 @@ u32_t lwip_tftp_put_file_by_filename(u32_t ulHostAddr, u16_t usTftpServPort, u8_
return TFTPC_MEMALLOC_ERROR;
}
/* First time intialize the buffer */
/* First time initialize the buffer */
(void)memset_s((void *)pstSendBuf, sizeof(TFTPC_PACKET_S), 0, sizeof(TFTPC_PACKET_S));
/* The destination path can only be one of the following:
@@ -1221,7 +1221,7 @@ u32_t lwip_tftp_inner_put_file(s32_t iSockNum,
return TFTPC_MEMALLOC_ERROR;
}
/* First time intialize the buffer */
/* First time initialize the buffer */
(void)memset_s((void *)pstRecvBuf, sizeof(TFTPC_PACKET_S), 0, sizeof(TFTPC_PACKET_S));
/* Initialize from address to the server address at first */
@@ -1235,7 +1235,7 @@ u32_t lwip_tftp_inner_put_file(s32_t iSockNum,
ulError = lwip_tftp_recv_from_server(iSockNum, &ulPktSize,
pstRecvBuf, &ulIgnorePkt,
pstServerAddr, pstSendBuf);
/* If select timeout occured */
/* If select timeout occurred */
if (ulError == TFTPC_TIMEOUT_ERROR) {
ulTotalTime++;
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
@@ -1419,7 +1419,7 @@ err_handler:
}
#ifdef TFTP_TO_RAWMEM
/* INTEFACE to get a file using filename
/* INTERFACE to get a file using filename
ulHostAddr - IP address of Host
szSrcFileName - Source file
szDestMemAddr - The target memory address in the client
@@ -1437,10 +1437,8 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
{
s32_t iSockNum = TFTP_NULL_INT32;
u32_t ulSrcStrLen;
u32_t lDestStrLen;
u32_t ulSize;
u32_t ulRecvSize = TFTP_NULL_UINT32;
s32_t iErrCode;
u32_t ulErrCode;
u16_t usReadReq;
u16_t usTempServPort;
@@ -1526,7 +1524,7 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
ulErrCode = lwip_tftp_recv_from_server(iSockNum, &ulRecvSize, pstRecvBuf, &ulIgnorePkt,
&stServerAddr, pstSendBuf);
/* If select timeout occured */
/* If select timeout occurred */
if (ulErrCode == TFTPC_TIMEOUT_ERROR) {
ulTotalTime++;
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
@@ -1557,7 +1555,7 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
}
/* if this packet is unkonwn or incorrect packet */
if (ntohs (pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
if (ntohs(pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
/* Send error packet to server */
lwip_tftp_send_error(iSockNum,
TFTPC_PROTOCOL_PROTO_ERROR,

View File

@@ -51,7 +51,7 @@ build_ext_component("build_toybox") {
":copy_toybox_config",
":copy_toybox_src",
]
deps += [ "//prebuilts/lite/sysroot" ]
deps += [ "//third_party/musl:sysroot_lite" ]
exec_path = rebase_path("$target_out_dir/toybox_build")
cflags = [

View File

@@ -70,6 +70,10 @@ static void TraceRead(int fd, size_t size)
{
ssize_t i;
ssize_t len;
if (size == 0) {
return;
}
char *buffer = (char *)malloc(size);
if (buffer == NULL) {
printf("Read buffer malloc failed.\n");

View File

@@ -246,7 +246,7 @@ STATIC INLINE INT32 LOS_AtomicIncRet(Atomic *v)
* @brief Atomic auto-decrement.
*
* @par Description:
* This API is used to implementating the atomic auto-decrement.
* This API is used to implement the atomic auto-decrement.
* @attention
* <ul>
* <li>The pointer v must not be NULL.</li>
@@ -280,7 +280,7 @@ STATIC INLINE VOID LOS_AtomicDec(Atomic *v)
* @brief Atomic auto-decrement.
*
* @par Description:
* This API is used to implementating the atomic auto-decrement and return the result of auto-decrement.
* This API is used to implement the atomic auto-decrement and return the result of auto-decrement.
* @attention
* <ul>
* <li>The pointer v must not be NULL.</li>
@@ -531,7 +531,7 @@ STATIC INLINE INT64 LOS_Atomic64IncRet(Atomic64 *v)
* @brief Atomic64 auto-decrement.
*
* @par Description:
* This API is used to implementating the atomic64 auto-decrement.
* This API is used to implement the atomic64 auto-decrement.
* @attention
* <ul>
* <li>The pointer v must not be NULL.</li>
@@ -566,7 +566,7 @@ STATIC INLINE VOID LOS_Atomic64Dec(Atomic64 *v)
* @brief Atomic64 auto-decrement.
*
* @par Description:
* This API is used to implementating the atomic64 auto-decrement and return the result of auto-decrement.
* This API is used to implement the atomic64 auto-decrement and return the result of auto-decrement.
* @attention
* <ul>
* <li>The pointer v must not be NULL.</li>

View File

@@ -55,8 +55,8 @@ extern "C" {
#define HWI_IS_REGISTED(num) ((&g_hwiForm[num])->pstNext != NULL)
#endif
extern VOID OsHwiInit(VOID);
extern VOID OsIncHwiFormCnt(UINT32 index);
extern UINT32 OsGetHwiFormCnt(UINT32 index);
extern VOID OsIncHwiFormCnt(UINT16 cpuid, UINT32 index);
extern UINT32 OsGetHwiFormCnt(UINT16 cpuid, UINT32 index);
extern CHAR *OsGetHwiFormName(UINT32 index);
extern VOID OsInterrupt(UINT32 intNum);
extern VOID OsSyscallHandleInit(VOID);

View File

@@ -74,7 +74,7 @@
STATIC UINTPTR g_minAddr;
STATIC UINTPTR g_maxAddr;
STATIC UINT32 g_currHandleExcCpuID = INVALID_CPUID;
STATIC UINT32 g_currHandleExcCpuid = INVALID_CPUID;
VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr);
UINT32 g_curNestCount[LOSCFG_KERNEL_CORE_NUM] = { 0 };
BOOL g_excFromUserMode[LOSCFG_KERNEL_CORE_NUM];
@@ -88,6 +88,7 @@ STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
#define OS_MAX_BACKTRACE 15U
#define DUMPSIZE 128U
#define DUMPREGS 12U
#define COM_REGS 4U
#define INSTR_SET_MASK 0x01000020U
#define THUMB_INSTR_LEN 2U
#define ARM_INSTR_LEN 4U
@@ -112,11 +113,11 @@ STATIC const StackInfo g_excStack[] = {
UINT32 OsGetSystemStatus(VOID)
{
UINT32 flag;
UINT32 cpuID = g_currHandleExcCpuID;
UINT32 cpuid = g_currHandleExcCpuid;
if (cpuID == INVALID_CPUID) {
if (cpuid == INVALID_CPUID) {
flag = OS_SYSTEM_NORMAL;
} else if (cpuID == ArchCurrCpuid()) {
} else if (cpuid == ArchCurrCpuid()) {
flag = OS_SYSTEM_EXC_CURR_CPU;
} else {
flag = OS_SYSTEM_EXC_OTHER_CPU;
@@ -516,13 +517,22 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
return;
}
for (excReg = &(excBufAddr->R0); count <= DUMPREGS; excReg++, count++) {
for (excReg = &(excBufAddr->R0); count < COM_REGS; excReg++, count++) {
if (IS_VALID_ADDR(*excReg)) {
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
OsDumpMemByte(DUMPSIZE, ((*excReg) - (DUMPSIZE >> 1)));
}
}
for (excReg = &(excBufAddr->R4); count < DUMPREGS; excReg++, count++) {
if (IS_VALID_ADDR(*excReg)) {
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
OsDumpMemByte(DUMPSIZE, ((*excReg) - (DUMPSIZE >> 1)));
}
}
if (IS_VALID_ADDR(excBufAddr->R12)) {
PrintExcInfo("\ndump mem around R12:%p", excBufAddr->R12);
OsDumpMemByte(DUMPSIZE, (excBufAddr->R12 - (DUMPSIZE >> 1)));
}
if (IS_VALID_ADDR(excBufAddr->SP)) {
PrintExcInfo("\ndump mem around SP:%p", excBufAddr->SP);
OsDumpMemByte(DUMPSIZE, (excBufAddr->SP - (DUMPSIZE >> 1)));
@@ -531,11 +541,11 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
STATIC VOID OsExcRestore(VOID)
{
UINT32 currCpuID = ArchCurrCpuid();
UINT32 currCpuid = ArchCurrCpuid();
g_excFromUserMode[currCpuID] = FALSE;
g_intCount[currCpuID] = 0;
g_curNestCount[currCpuID] = 0;
g_excFromUserMode[currCpuid] = FALSE;
g_intCount[currCpuid] = 0;
g_curNestCount[currCpuid] = 0;
#ifdef LOSCFG_KERNEL_SMP
OsCpuStatusSet(CPU_RUNNING);
#endif
@@ -556,15 +566,15 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
#ifdef LOSCFG_KERNEL_SMP
LOS_SpinLock(&g_excSerializerSpin);
if (g_nextExcWaitCpu != INVALID_CPUID) {
g_currHandleExcCpuID = g_nextExcWaitCpu;
g_currHandleExcCpuid = g_nextExcWaitCpu;
g_nextExcWaitCpu = INVALID_CPUID;
} else {
g_currHandleExcCpuID = INVALID_CPUID;
g_currHandleExcCpuid = INVALID_CPUID;
}
g_currHandleExcPID = OS_INVALID_VALUE;
LOS_SpinUnlock(&g_excSerializerSpin);
#else
g_currHandleExcCpuID = INVALID_CPUID;
g_currHandleExcCpuid = INVALID_CPUID;
#endif
#ifdef LOSCFG_KERNEL_SMP
@@ -645,6 +655,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
const StackInfo *stack = NULL;
vaddr_t kvaddr;
#ifdef LOSCFG_KERNEL_VM
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
taskCB = OsCurrTaskGet();
stackStart = taskCB->userMapBase;
@@ -655,6 +666,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
}
return found;
}
#endif
/* Search in the task stacks */
for (index = 0; index < g_taskMaxNum; index++) {
@@ -979,14 +991,14 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
#define EXC_WAIT_INTER 50U
#define EXC_WAIT_TIME 2000U
STATIC VOID WaitAllCpuStop(UINT32 cpuID)
STATIC VOID WaitAllCpuStop(UINT32 cpuid)
{
UINT32 i;
UINT32 time = 0;
while (time < EXC_WAIT_TIME) {
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
if ((i != cpuID) && !OsCpuStatusIsHalt(i)) {
if ((i != cpuid) && !OsCpuStatusIsHalt(i)) {
LOS_Mdelay(EXC_WAIT_INTER);
time += EXC_WAIT_INTER;
break;
@@ -1000,19 +1012,19 @@ STATIC VOID WaitAllCpuStop(UINT32 cpuID)
return;
}
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuid)
{
while (1) {
LOS_SpinLock(&g_excSerializerSpin);
if ((g_currHandleExcCpuID == INVALID_CPUID) || (g_currHandleExcCpuID == currCpuID)) {
g_currHandleExcCpuID = currCpuID;
if ((g_currHandleExcCpuid == INVALID_CPUID) || (g_currHandleExcCpuid == currCpuid)) {
g_currHandleExcCpuid = currCpuid;
g_currHandleExcPID = OsCurrProcessGet()->processID;
LOS_SpinUnlock(&g_excSerializerSpin);
break;
}
if (g_nextExcWaitCpu == INVALID_CPUID) {
g_nextExcWaitCpu = currCpuID;
g_nextExcWaitCpu = currCpuid;
}
LOS_SpinUnlock(&g_excSerializerSpin);
LOS_Mdelay(EXC_WAIT_INTER);
@@ -1021,7 +1033,7 @@ STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
STATIC VOID OsCheckAllCpuStatus(VOID)
{
UINT32 currCpuID = ArchCurrCpuid();
UINT32 currCpuid = ArchCurrCpuid();
UINT32 ret, target;
OsCpuStatusSet(CPU_EXC);
@@ -1029,17 +1041,17 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
LOS_SpinLock(&g_excSerializerSpin);
/* Only the current CPU anomaly */
if (g_currHandleExcCpuID == INVALID_CPUID) {
g_currHandleExcCpuID = currCpuID;
if (g_currHandleExcCpuid == INVALID_CPUID) {
g_currHandleExcCpuid = currCpuid;
g_currHandleExcPID = OsCurrProcessGet()->processID;
LOS_SpinUnlock(&g_excSerializerSpin);
#ifndef LOSCFG_SAVE_EXCINFO
if (g_excFromUserMode[currCpuID] == FALSE) {
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
if (g_excFromUserMode[currCpuid] == FALSE) {
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuid));
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
}
#endif
} else if (g_excFromUserMode[currCpuID] == TRUE) {
} else if (g_excFromUserMode[currCpuid] == TRUE) {
/* Both cores raise exceptions, and the current core is a user-mode exception.
* Both cores are abnormal and come from the same process
*/
@@ -1051,12 +1063,12 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
}
LOS_SpinUnlock(&g_excSerializerSpin);
OsWaitOtherCoresHandleExcEnd(currCpuID);
OsWaitOtherCoresHandleExcEnd(currCpuid);
} else {
if ((g_currHandleExcCpuID < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuID] == TRUE)) {
g_currHandleExcCpuID = currCpuID;
if ((g_currHandleExcCpuid < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuid] == TRUE)) {
g_currHandleExcCpuid = currCpuid;
LOS_SpinUnlock(&g_excSerializerSpin);
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuid));
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
} else {
LOS_SpinUnlock(&g_excSerializerSpin);
@@ -1066,7 +1078,7 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
#ifndef LOSCFG_SAVE_EXCINFO
/* use halt ipi to stop other active cores */
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
WaitAllCpuStop(currCpuID);
WaitAllCpuStop(currCpuid);
}
#endif
}
@@ -1077,7 +1089,7 @@ STATIC VOID OsCheckCpuStatus(VOID)
#ifdef LOSCFG_KERNEL_SMP
OsCheckAllCpuStatus();
#else
g_currHandleExcCpuID = ArchCurrCpuid();
g_currHandleExcCpuid = ArchCurrCpuid();
#endif
}

View File

@@ -46,16 +46,11 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
size_t g_intCount[LOSCFG_KERNEL_CORE_NUM] = {0};
HwiHandleForm g_hwiForm[OS_HWI_MAX_NUM];
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC UINT32 g_hwiFormCnt[LOSCFG_KERNEL_CORE_NUM][OS_HWI_MAX_NUM] = {0};
VOID OsIncHwiFormCnt(UINT32 index)
UINT32 OsGetHwiFormCnt(UINT16 cpuid, UINT32 index)
{
g_hwiFormCnt[index]++;
}
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
return g_hwiFormCnt[cpuid][index];
}
CHAR *OsGetHwiFormName(UINT32 index)
@@ -74,16 +69,17 @@ VOID OsInterrupt(UINT32 intNum)
{
HwiHandleForm *hwiForm = NULL;
UINT32 *intCnt = NULL;
UINT16 cpuid = ArchCurrCpuid();
/* Must keep the operation at the beginning of the interface */
intCnt = &g_intCount[ArchCurrCpuid()];
intCnt = &g_intCount[cpuid];
*intCnt = *intCnt + 1;
OsSchedIrqStartTime();
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqStart();
OsCpupIrqStart(cpuid);
#endif
OsSchedIrqStartTime();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum);
hwiForm = (&g_hwiForm[intNum]);
#ifndef LOSCFG_NO_SHARED_IRQ
@@ -105,14 +101,14 @@ VOID OsInterrupt(UINT32 intNum)
#ifndef LOSCFG_NO_SHARED_IRQ
}
#endif
++g_hwiFormCnt[intNum];
++g_hwiFormCnt[cpuid][intNum];
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum);
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqEnd(intNum);
#endif
OsSchedIrqUpdateUsedTime();
OsSchedIrqUsedTimeUpdate();
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqEnd(cpuid, intNum);
#endif
/* Must keep the operation at the end of the interface */
*intCnt = *intCnt - 1;
}

View File

@@ -121,8 +121,9 @@ reset_vector:
mcr p15, 0, r0, c13, c0, 4
/* do some early cpu setup: i/d cache disable, mmu disabled */
mrc p15, 0, r0, c1, c0, 0
bic r0, #(1<<12)
bic r0, #(1<<2 | 1<<0)
bic r0, #(1 << 12) /* i cache */
bic r0, #(1 << 2) /* d cache */
bic r0, #(1 << 0) /* mmu */
mcr p15, 0, r0, c1, c0, 0
/* enable fpu+neon */
@@ -275,18 +276,18 @@ mmu_setup:
mov r12, #0x7 /* 0b0111 */
mcr p15, 0, r12, c3, c0, 0 /* Set DACR with 0b0111, client and manager domian */
isb
mrc p15, 0, r12, c1, c0, 1 /* ACTLR, Auxlliary Control Register */
mrc p15, 0, r12, c1, c0, 1 /* ACTLR, Auxiliary Control Register */
orr r12, r12, #(1 << 6) /* SMP, Enables coherent requests to the processor. */
orr r12, r12, #(1 << 2) /* Enable D-side prefetch */
orr r12, r12, #(1 << 11) /* Global BP Enable bit */
mcr p15, 0, r12, c1, c0, 1 /* ACTLR, Auxlliary Control Register */
mcr p15, 0, r12, c1, c0, 1 /* ACTLR, Auxiliary Control Register */
dsb
mrc p15, 0, r12, c1, c0, 0
bic r12, #(1 << 29 | 1 << 28)
orr r12, #(1 << 0)
bic r12, #(1 << 29 | 1 << 28) /* Disable TRE/AFE */
orr r12, #(1 << 0) /* mmu enable */
bic r12, #(1 << 1)
orr r12, #(1 << 2)
orr r12, #(1 << 12)
orr r12, #(1 << 2) /* D cache enable */
orr r12, #(1 << 12) /* I cache enable */
mcr p15, 0, r12, c1, c0, 0 /* Set SCTLR with r12: Turn on the MMU, I/D cache Disable TRE/AFE */
isb
ldr pc, =1f /* Convert to VA */

View File

@@ -101,8 +101,9 @@ __exception_handlers:
reset_vector:
/* do some early cpu setup: i/d cache disable, mmu disabled */
mrc p15, 0, r0, c1, c0, 0
bic r0, #(1<<12)
bic r0, #(1<<2 | 1<<0)
bic r0, #(1 << 12) /* i cache */
bic r0, #(1 << 2) /* d cache */
bic r0, #(1 << 0) /* mmu */
mcr p15, 0, r0, c1, c0, 0
/* enable fpu+neon */
@@ -269,11 +270,11 @@ mmu_setup:
isb
mrc p15, 0, r12, c1, c0, 0
bic r12, #(1 << 29 | 1 << 28)
orr r12, #(1 << 0)
bic r12, #(1 << 29 | 1 << 28) /* Disable TRE/AFE */
orr r12, #(1 << 0) /* mmu enable */
bic r12, #(1 << 1)
orr r12, #(1 << 2)
orr r12, #(1 << 12)
orr r12, #(1 << 2) /* D cache enable */
orr r12, #(1 << 12) /* I cache enable */
mcr p15, 0, r12, c1, c0, 0 /* Set SCTLR with r12: Turn on the MMU, I/D cache Disable TRE/AFE */
isb

View File

@@ -46,7 +46,7 @@ INT32 LOS_StrncpyFromUser(CHAR *dst, const CHAR *src, INT32 count)
}
maxCount = (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)src, (size_t)count)) ? \
count : (USER_ASPACE_TOP_MAX - (UINTPTR)src);
count : (INT32)(USER_ASPACE_TOP_MAX - (UINTPTR)src);
for (i = 0; i < maxCount; ++i) {
if (LOS_GetUser(&character, src + offset) != LOS_OK) {

View File

@@ -49,7 +49,7 @@ STATIC UINT32 g_curIrqNum = 0;
*/
STATIC VOID GicWriteSgi(UINT32 vector, UINT32 cpuMask, UINT32 filter)
{
UINT32 val = ((filter & 0x3) << 24) | ((cpuMask & 0xFF) << 16) |
UINT32 val = ((filter & 0x3) << 24) | ((cpuMask & 0xFF) << 16) | /* 24, 16: Register bit offset */
(vector & 0xF);
GIC_REG_32(GICD_SGIR) = val;
@@ -62,7 +62,7 @@ VOID HalIrqSendIpi(UINT32 target, UINT32 ipi)
VOID HalIrqSetAffinity(UINT32 vector, UINT32 cpuMask)
{
UINT32 offset = vector / 4;
UINT32 offset = vector / 4; /* 4: Interrupt bit width */
UINT32 index = vector & 0x3;
GIC_REG_8(GICD_ITARGETSR(offset) + index) = cpuMask;
@@ -80,7 +80,7 @@ VOID HalIrqMask(UINT32 vector)
return;
}
GIC_REG_32(GICD_ICENABLER(vector / 32)) = 1U << (vector % 32);
GIC_REG_32(GICD_ICENABLER(vector / 32)) = 1U << (vector % 32); /* 32: Interrupt bit width */
}
VOID HalIrqUnmask(UINT32 vector)
@@ -89,7 +89,7 @@ VOID HalIrqUnmask(UINT32 vector)
return;
}
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = 1U << (vector % 32);
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = 1U << (vector % 32); /* 5, 32: Register bit offset */
}
VOID HalIrqPending(UINT32 vector)
@@ -98,7 +98,7 @@ VOID HalIrqPending(UINT32 vector)
return;
}
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32);
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32); /* 5, 32: Register bit offset */
}
VOID HalIrqClear(UINT32 vector)
@@ -119,24 +119,24 @@ VOID HalIrqInit(VOID)
{
UINT32 i;
/* set externel interrupts to be level triggered, active low. */
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) {
GIC_REG_32(GICD_ICFGR(i / 16)) = 0;
/* set external interrupts to be level triggered, active low. */
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) { /* 32: Start interrupt number, 16: Interrupt bit width */
GIC_REG_32(GICD_ICFGR(i / 16)) = 0; /* 16: Register bit offset */
}
/* set externel interrupts to CPU 0 */
for (i = 32; i < OS_HWI_MAX_NUM; i += 4) {
/* set external interrupts to CPU 0 */
for (i = 32; i < OS_HWI_MAX_NUM; i += 4) { /* 32: Start interrupt number, 4: Interrupt bit width */
GIC_REG_32(GICD_ITARGETSR(i / 4)) = 0x01010101;
}
/* set priority on all interrupts */
for (i = 0; i < OS_HWI_MAX_NUM; i += 4) {
for (i = 0; i < OS_HWI_MAX_NUM; i += 4) { /* 4: Interrupt bit width */
GIC_REG_32(GICD_IPRIORITYR(i / 4)) = GICD_INT_DEF_PRI_X4;
}
/* disable all interrupts. */
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) {
GIC_REG_32(GICD_ICENABLER(i / 32)) = ~0;
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) { /* 32: Interrupt bit width */
GIC_REG_32(GICD_ICENABLER(i / 32)) = ~0; /* 32: Interrupt bit width */
}
HalIrqInitPercpu();

View File

@@ -42,9 +42,9 @@ STATIC UINT32 g_curIrqNum = 0;
STATIC INLINE UINT64 MpidrToAffinity(UINT64 mpidr)
{
return ((MPIDR_AFF_LEVEL(mpidr, 3) << 32) |
(MPIDR_AFF_LEVEL(mpidr, 2) << 16) |
(MPIDR_AFF_LEVEL(mpidr, 1) << 8) |
return ((MPIDR_AFF_LEVEL(mpidr, 3) << 32) | /* 3: Serial number, 32: Register bit offset */
(MPIDR_AFF_LEVEL(mpidr, 2) << 16) | /* 2: Serial number, 16: Register bit offset */
(MPIDR_AFF_LEVEL(mpidr, 1) << 8) | /* 1: Serial number, 8: Register bit offset */
(MPIDR_AFF_LEVEL(mpidr, 0)));
}
@@ -106,10 +106,10 @@ STATIC VOID GicSgi(UINT32 irq, UINT32 cpuMask)
tList = GicTargetList(&cpu, cpuMask, cluster);
/* Generates a Group 1 interrupt for the current security state */
val = ((MPIDR_AFF_LEVEL(cluster, 3) << 48) |
(MPIDR_AFF_LEVEL(cluster, 2) << 32) |
(MPIDR_AFF_LEVEL(cluster, 1) << 16) |
(irq << 24) | tList);
val = ((MPIDR_AFF_LEVEL(cluster, 3) << 48) | /* 3: Serial number, 48: Register bit offset */
(MPIDR_AFF_LEVEL(cluster, 2) << 32) | /* 2: Serial number, 32: Register bit offset */
(MPIDR_AFF_LEVEL(cluster, 1) << 16) | /* 1: Serial number, 16: Register bit offset */
(irq << 24) | tList); /* 24: Register bit offset */
GiccSetSgi1r(val);
}
@@ -150,9 +150,9 @@ STATIC INLINE VOID GicdSetGroup(UINT32 irq)
{
/* configure spi as group 0 on secure mode and group 1 on unsecure mode */
#ifdef LOSCFG_ARCH_SECURE_MONITOR_MODE
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0;
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0; /* 32: Interrupt bit width */
#else
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0xffffffff;
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0xffffffff; /* 32: Interrupt bit width */
#endif
}
@@ -248,13 +248,13 @@ UINT32 HalCurIrqGet(VOID)
VOID HalIrqMask(UINT32 vector)
{
INT32 i;
const UINT32 mask = 1U << (vector % 32);
const UINT32 mask = 1U << (vector % 32); /* 32: Interrupt bit width */
if ((vector > OS_USER_HWI_MAX) || (vector < OS_USER_HWI_MIN)) {
return;
}
if (vector < 32) {
if (vector < 32) { /* 32: Interrupt bit width */
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
GIC_REG_32(GICR_ICENABLER0(i)) = mask;
GicWaitForRwp(GICR_CTLR(i));
@@ -268,19 +268,19 @@ VOID HalIrqMask(UINT32 vector)
VOID HalIrqUnmask(UINT32 vector)
{
INT32 i;
const UINT32 mask = 1U << (vector % 32);
const UINT32 mask = 1U << (vector % 32); /* 32: Interrupt bit width */
if ((vector > OS_USER_HWI_MAX) || (vector < OS_USER_HWI_MIN)) {
return;
}
if (vector < 32) {
if (vector < 32) { /* 32: Interrupt bit width */
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
GIC_REG_32(GICR_ISENABLER0(i)) = mask;
GicWaitForRwp(GICR_CTLR(i));
}
} else {
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = mask;
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = mask; /* 5: Register bit offset */
GicWaitForRwp(GICD_CTLR);
}
}
@@ -291,7 +291,7 @@ VOID HalIrqPending(UINT32 vector)
return;
}
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32);
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32); /* 5: Register bit offset, 32: Interrupt bit width */
}
VOID HalIrqClear(UINT32 vector)
@@ -362,30 +362,30 @@ VOID HalIrqInit(VOID)
GicWaitForRwp(GICD_CTLR);
ISB;
/* set externel interrupts to be level triggered, active low. */
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) {
/* set external interrupts to be level triggered, active low. */
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) { /* 32: Start interrupt number, 16: Interrupt bit width */
GIC_REG_32(GICD_ICFGR(i / 16)) = 0;
}
/* config distributer, mask and clear all spis, set group x */
for (i = 32; i < OS_HWI_MAX_NUM; i += 32) {
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff;
GIC_REG_32(GICD_ICPENDR(i / 32)) = 0xffffffff;
GIC_REG_32(GICD_IGRPMODR(i / 32)) = 0;
for (i = 32; i < OS_HWI_MAX_NUM; i += 32) { /* 32: Start interrupt number, 32: Interrupt bit width */
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff; /* 32: Interrupt bit width */
GIC_REG_32(GICD_ICPENDR(i / 32)) = 0xffffffff; /* 32: Interrupt bit width */
GIC_REG_32(GICD_IGRPMODR(i / 32)) = 0; /* 32: Interrupt bit width */
GicdSetGroup(i);
}
/* set spi priority as default */
for (i = 32; i < OS_HWI_MAX_NUM; i++) {
for (i = 32; i < OS_HWI_MAX_NUM; i++) { /* 32: Start interrupt number */
GicdSetPmr(i, MIN_INTERRUPT_PRIORITY);
}
GicWaitForRwp(GICD_CTLR);
/* disable all interrupts. */
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) {
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff;
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) { /* 32: Interrupt bit width */
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff; /* 32: Interrupt bit width */
}
/* enable distributor with ARE, group 1 enabled */
@@ -393,7 +393,7 @@ VOID HalIrqInit(VOID)
/* set spi to boot cpu only. ARE must be enabled */
affinity = MpidrToAffinity(AARCH64_SYSREG_READ(mpidr_el1));
for (i = 32; i < OS_HWI_MAX_NUM; i++) {
for (i = 32; i < OS_HWI_MAX_NUM; i++) { /* 32: Start interrupt number */
GIC_REG_64(GICD_IROUTER(i)) = affinity;
}

View File

@@ -77,8 +77,8 @@ enum {
#define GICD_PIDR2V3 (GICD_OFFSET + 0xffe8)
#ifdef LOSCFG_ARCH_GIC_V3
#define GICD_IGRPMODR(n) (GICD_OFFSET + 0x0d00 + (n) * 4) /* Interrupt Group Mode Reisters */
#define GICD_IROUTER(n) (GICD_OFFSET + 0x6000 + (n) * 8) /* Interrupt Rounter Reisters */
#define GICD_IGRPMODR(n) (GICD_OFFSET + 0x0d00 + (n) * 4) /* Interrupt Group Mode Registers */
#define GICD_IROUTER(n) (GICD_OFFSET + 0x6000 + (n) * 8) /* Interrupt Rounter Registers */
#endif
#define GIC_REG_8(reg) (*(volatile UINT8 *)((UINTPTR)(GIC_BASE_ADDR + (reg))))

0
arch/arm/include/gic_v3.h Executable file → Normal file
View File

View File

@@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include $(LITEOSTOPDIR)/config.mk
include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/lite.mk
include $(LITEOSTOPDIR)/../../drivers/hdf_core/adapter/khdf/liteos/lite.mk
MODULE_NAME := usb_base
@@ -122,13 +122,13 @@ LOCAL_SRCS += $(STORAGE_SRC)/umass.c
endif
ifeq ($(LOSCFG_DRIVERS_USB_HID_CLASS)_$(LOSCFG_DRIVERS_HDF_INPUT), y_y)
LOCAL_FLAGS += -I$(LITEOSTOPDIR)/../../drivers/framework/model/input/driver \
-I$(LITEOSTOPDIR)/../../drivers/framework/include/core \
-I$(LITEOSTOPDIR)/../../drivers/framework/core/common/include/host \
-I$(LITEOSTOPDIR)/../../drivers/framework/utils \
-I$(LITEOSTOPDIR)/../../drivers/framework/osal \
-I$(LITEOSTOPDIR)/../../drivers/framework/ability/sbuf/include \
-I$(LITEOSTOPDIR)/../../drivers/framework/include/osal \
LOCAL_FLAGS += -I$(LITEOSTOPDIR)/../../drivers/hdf_core/framework/model/input/driver \
-I$(LITEOSTOPDIR)/../../drivers/hdf_core/framework/include/core \
-I$(LITEOSTOPDIR)/../../drivers/hdf_core/framework/core/common/include/host \
-I$(LITEOSTOPDIR)/../../drivers/hdf_core/framework/utils \
-I$(LITEOSTOPDIR)/../../drivers/hdf_core/framework/osal \
-I$(LITEOSTOPDIR)/../../drivers/hdf_core/framework/ability/sbuf/include \
-I$(LITEOSTOPDIR)/../../drivers/hdf_core/framework/include/osal \
-I$(LITEOSTOPDIR)/../../third_party/FreeBSD/sys/dev/evdev
LOCAL_SRCS += $(INPUT_SRC)/uhid.c \

View File

@@ -43,7 +43,6 @@
"bounds_checking_function",
"toybox",
"NuttX",
"Linux_Kernel",
"FatFs",
"mksh",
"musl",
@@ -63,4 +62,4 @@
"test": []
}
}
}
}

View File

@@ -71,7 +71,7 @@ extern "C" {
/* CONSTANTS */
#define MQ_USE_MAGIC 0x89abcdef
/* not suppurt prio */
/* not support prio */
#define MQ_PRIO_MAX 1
typedef union send_receive_t {
@@ -297,7 +297,7 @@ extern int mq_send(mqd_t personal, const char *msg, size_t msgLen, unsigned int
* <li><b>EAGAIN</b>: The message queue is empty.</li>
* <li><b>EINVAL</b>: invalid parameter.</li>
* <li><b>EMSGSIZE</b>: The message to be received is too long.</li>
* <li><b>ETIMEDOUT</b>: The operaton times out.</li>
* <li><b>ETIMEDOUT</b>: The operation times out.</li>
* </ul>
*
* @par Dependency:

View File

@@ -40,7 +40,7 @@
*/
void *calloc(size_t nitems, size_t size)
{ /*lint !e578*/
{
size_t real_size;
void *ptr = NULL;
@@ -78,7 +78,7 @@ void free(void *ptr)
*/
void *malloc(size_t size)
{ /*lint !e31 !e10*/
{
if (size == 0) {
return NULL;
}
@@ -87,7 +87,7 @@ void *malloc(size_t size)
}
void *zalloc(size_t size)
{ /*lint !e10*/
{
void *ptr = NULL;
if (size == 0) {
@@ -142,4 +142,4 @@ void *realloc(void *ptr, size_t size)
}
return LOS_KernelRealloc(ptr, (UINT32) size);
}
}

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:
@@ -158,7 +158,7 @@ STATIC VOID SetPthreadAttr(const _pthread_data *self, const pthread_attr_t *attr
}
if (outAttr->inheritsched == PTHREAD_INHERIT_SCHED) {
if (self->task == NULL) {
outAttr->schedparam.sched_priority = ((LosTaskCB *)(OsCurrTaskGet()))->priority;
outAttr->schedparam.sched_priority = LOS_TaskPriGet(OsCurrTaskGet()->taskID);
} else {
outAttr->schedpolicy = self->attr.schedpolicy;
outAttr->schedparam = self->attr.schedparam;

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:
@@ -71,7 +71,7 @@
#ifdef LOSCFG_AARCH64
/*
* This two structures originally did't exit,
* This two structures originally didn't exit,
* they added by liteos to support 64bit interfaces on 32bit platform,
* in 64bit platform, timeval64 define to timeval which is platform adaptive.
*/
@@ -387,9 +387,16 @@ int gettimeofday64(struct timeval64 *tv, struct timezone *tz)
}
#endif
#ifdef LOSCFG_LIBC_NEWLIB
int gettimeofday(struct timeval *tv, void *_tz)
#else
int gettimeofday(struct timeval *tv, struct timezone *tz)
#endif
{
struct timeval64 stTimeVal64 = {0};
#ifdef LOSCFG_LIBC_NEWLIB
struct timezone *tz = (struct timezone *)_tz;
#endif
if (tv == NULL) {
TIME_RETURN(EINVAL);
@@ -471,7 +478,6 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
uint64_t runtime;
UINT32 intSave;
UINT32 tid = GetTidFromClockID(clockID);
if (OS_TID_CHECK_INVALID(tid)) {
return -EINVAL;
}
@@ -647,7 +653,7 @@ int clock_getres(clockid_t clockID, struct timespec *tp)
case CLOCK_MONOTONIC_RAW:
case CLOCK_MONOTONIC:
case CLOCK_REALTIME:
/* the accessable rtc resolution */
/* the accessible rtc resolution */
tp->tv_nsec = OS_SYS_NS_PER_US; /* the precision of clock_gettime is 1us */
tp->tv_sec = 0;
break;
@@ -718,6 +724,7 @@ typedef struct {
static VOID SwtmrProc(UINTPTR tmrArg)
{
#ifdef LOSCFG_KERNEL_VM
INT32 sig, ret;
UINT32 intSave;
pid_t pid;
@@ -761,9 +768,47 @@ static VOID SwtmrProc(UINTPTR tmrArg)
return;
EXIT:
PRINT_ERR("Dispatch signals failed!, ret: %d\r\n", ret);
#endif
return;
}
int timer_create(clockid_t clockID, struct sigevent *restrict evp, timer_t *restrict timerID)
{
UINT32 ret;
UINT16 swtmrID;
#ifdef LOSCFG_SECURITY_VID
UINT16 vid;
#endif
if (!timerID || (clockID != CLOCK_REALTIME) || !evp) {
errno = EINVAL;
return -1;
}
if ((evp->sigev_notify != SIGEV_THREAD) || evp->sigev_notify_attributes) {
errno = ENOTSUP;
return -1;
}
ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)evp->sigev_notify_function,
&swtmrID, (UINTPTR)evp->sigev_value.sival_ptr);
if (ret != LOS_OK) {
errno = (ret == LOS_ERRNO_SWTMR_MAXSIZE) ? EAGAIN : EINVAL;
return -1;
}
#ifdef LOSCFG_SECURITY_VID
vid = AddNodeByRid(swtmrID);
if (vid == MAX_INVALID_TIMER_VID) {
(VOID)LOS_SwtmrDelete(swtmrID);
return -1;
}
swtmrID = vid;
#endif
*timerID = (timer_t)(UINTPTR)swtmrID;
return 0;
}
int OsTimerCreate(clockid_t clockID, struct ksigevent *evp, timer_t *timerID)
{
UINT32 ret;
@@ -823,6 +868,7 @@ int timer_delete(timer_t timerID)
{
UINT16 swtmrID = (UINT16)(UINTPTR)timerID;
VOID *arg = NULL;
UINTPTR swtmrProc;
#ifdef LOSCFG_SECURITY_VID
swtmrID = GetRidByVid(swtmrID);
@@ -832,10 +878,11 @@ int timer_delete(timer_t timerID)
}
arg = (VOID *)OS_SWT_FROM_SID(swtmrID)->uwArg;
swtmrProc = (UINTPTR)OS_SWT_FROM_SID(swtmrID)->pfnHandler;
if (LOS_SwtmrDelete(swtmrID)) {
goto ERROUT;
}
if (arg != NULL) {
if ((swtmrProc == (UINTPTR)SwtmrProc) && (arg != NULL)) {
free(arg);
}
@@ -979,7 +1026,11 @@ STATIC INT32 DoNanoSleep(UINT64 nanoseconds)
return -1;
}
#ifdef LOSCFG_LIBC_NEWLIB
int usleep(unsigned long useconds)
#else
int usleep(unsigned useconds)
#endif
{
return DoNanoSleep((UINT64)useconds * OS_SYS_NS_PER_US);
}

View File

@@ -5,7 +5,7 @@ config DRIVERS
Answer Y to enable LiteOS support driver.
source "bsd/dev/usb/Kconfig"
source "../../drivers/adapter/khdf/liteos/Kconfig"
source "../../drivers/hdf_core/adapter/khdf/liteos/Kconfig"
# Device driver Kconfig import
source "$(DEVICE_PATH)/drivers/Kconfig"
@@ -17,5 +17,4 @@ source "drivers/char/video/Kconfig"
source "drivers/char/trace/Kconfig"
source "drivers/char/perf/Kconfig"
source "../../drivers/liteos/tzdriver/Kconfig"
source "../../drivers/liteos/hievent/Kconfig"

View File

@@ -45,8 +45,6 @@
#include "bcache.h"
#endif
#include "pthread.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
@@ -165,7 +163,7 @@ extern "C" {
#define DISK_ATA_GET_MODEL 21 /* Get model name */
#define DISK_ATA_GET_SN 22 /* Get serial number */
#ifdef LOSCFG_FS_FAT_CACHE
#ifndef LOSCFG_FS_FAT_CACHE
#define DISK_DIRECT_BUFFER_SIZE 4 /* los_disk direct io buffer when bcache is off */
#endif
@@ -253,7 +251,7 @@ struct disk_divide_info {
* </ul>
*
* @param diskName [IN] Type #const CHAR * disk driver name.
* @param bops [IN] Type #const struct block_operations * block driver control sturcture.
* @param bops [IN] Type #const struct block_operations * block driver control structure.
* @param priv [IN] Type #VOID * private data of vnode.
* @param diskID [IN] Type #INT32 disk id number, less than SYS_MAX_DISK.
* @param info [IN] Type #VOID * disk driver partition information.
@@ -712,7 +710,7 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName);
* @brief get the INUSED disk id.
*
* @par Description:
* Get the correponding INUSED disk id by diskName.
* Get the corresponding INUSED disk id by diskName.
*
* @attention
* <ul>

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:
@@ -42,7 +42,7 @@
#ifdef __cplusplus
#if __cplusplus
extern "C"{
extern "C" {
#endif
#endif /* __cplusplus */

View File

@@ -107,7 +107,7 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName)
size_t nameLen;
if (diskName == NULL) {
PRINT_ERR("The paramter disk_name is NULL");
PRINT_ERR("The parameter disk_name is NULL");
return VFS_ERROR;
}
@@ -163,7 +163,7 @@ INT32 los_get_diskid_byname(const CHAR *diskName)
size_t diskNameLen;
if (diskName == NULL) {
PRINT_ERR("The paramter diskName is NULL");
PRINT_ERR("The parameter diskName is NULL");
return VFS_ERROR;
}
@@ -756,7 +756,7 @@ INT32 DiskPartitionRegister(los_disk *disk)
los_part *part = NULL;
struct disk_divide_info parInfo;
/* Fill disk_divide_info structure to set partition's infomation. */
/* Fill disk_divide_info structure to set partition's information. */
(VOID)memset_s(parInfo.part, sizeof(parInfo.part), 0, sizeof(parInfo.part));
partSize = sizeof(parInfo.part) / sizeof(parInfo.part[0]);
@@ -788,7 +788,7 @@ INT32 DiskPartitionRegister(los_disk *disk)
}
for (i = 0; i < partSize; i++) {
/* Read the disk_divide_info structure to get partition's infomation. */
/* Read the disk_divide_info structure to get partition's information. */
if ((parInfo.part[i].type != 0) && (parInfo.part[i].type != EXTENDED_PAR) &&
(parInfo.part[i].type != EXTENDED_8G)) {
part = get_part(DiskAddPart(disk, parInfo.part[i].sector_start, parInfo.part[i].sector_count, TRUE));

View File

@@ -41,7 +41,7 @@ void RandomOperationsInit(const RandomOperations *r)
if (r != NULL) {
(void)memcpy_s(&g_randomOp, sizeof(RandomOperations), r, sizeof(RandomOperations));
} else {
PRINT_ERR("param is invalid\n", __FUNCTION__, __LINE__);
PRINT_ERR("%s %d param is invalid\n", __FUNCTION__, __LINE__);
}
return;
}

View File

@@ -103,7 +103,7 @@ static ssize_t TraceWrite(struct file *filep, const char *buffer, size_t buflen)
if (info == NULL) {
return -ENOMEM;
}
memset_s(info, infoLen, 0, infoLen);
(void)memset_s(info, infoLen, 0, infoLen);
ret = LOS_CopyToKernel(info, infoLen, buffer, buflen);
if (ret != 0) {

View File

@@ -289,7 +289,7 @@ static INT32 BlockDriverRegisterOperate(mtd_partition *newNode,
if (ret) {
free(newNode->blockdriver_name);
newNode->blockdriver_name = NULL;
PRINT_ERR("register blkdev partion error\n");
PRINT_ERR("register blkdev partition error\n");
return ret;
}
} else {
@@ -322,7 +322,7 @@ static INT32 CharDriverRegisterOperate(mtd_partition *newNode,
ret = register_driver(newNode->chardriver_name, param->char_ops, RWE_RW_RW, newNode);
if (ret) {
PRINT_ERR("register chardev partion error\n");
PRINT_ERR("register chardev partition error\n");
free(newNode->chardriver_name);
newNode->chardriver_name = NULL;
return ret;
@@ -340,7 +340,7 @@ static INT32 BlockDriverUnregister(mtd_partition *node)
if (node->blockdriver_name != NULL) {
ret = unregister_blockdriver(node->blockdriver_name);
if (ret == -EBUSY) {
PRINT_ERR("unregister blkdev partion error:%d\n", ret);
PRINT_ERR("unregister blkdev partition error:%d\n", ret);
return ret;
}
free(node->blockdriver_name);
@@ -356,7 +356,7 @@ static INT32 CharDriverUnregister(mtd_partition *node)
if (node->chardriver_name != NULL) {
ret = unregister_driver(node->chardriver_name);
if (ret == -EBUSY) {
PRINT_ERR("unregister chardev partion error:%d\n", ret);
PRINT_ERR("unregister chardev partition error:%d\n", ret);
return ret;
}
free(node->chardriver_name);

View File

@@ -4,7 +4,7 @@ source "fs/ramfs/Kconfig"
source "fs/romfs/Kconfig"
source "fs/nfs/Kconfig"
source "fs/proc/Kconfig"
source "fs/jffs2/Kconfig"
#source "fs/jffs2/Kconfig"
source "fs/rootfs/Kconfig"
source "fs/patchfs/Kconfig"
source "fs/zpfs/Kconfig"
source "fs/zpfs/Kconfig"

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:
@@ -343,7 +343,8 @@ static FRESULT init_cluster(DIR_FILE *pdfp, DIR *dp_new, FATFS *fs, int type, co
return FR_OK;
}
static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp, BYTE type, const char *target)
static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp,
BYTE type, const char *target)
{
struct Vnode *vp = NULL;
FATFS *fs = (FATFS *)parent->originMount->data;
@@ -1408,7 +1409,7 @@ DWORD fattime_format(time_t time)
ftime |= ((DWORD)((st.tm_year > YEAR_OFFSET) ? (st.tm_year - YEAR_OFFSET) : 0)) << FTIME_YEAR_OFFSET;
ftime <<= FTIME_DATE_OFFSET;
ftime = (DWORD)st.tm_sec / SEC_MULTIPLIER;
ftime |= (DWORD)st.tm_sec / SEC_MULTIPLIER;
ftime |= ((DWORD)st.tm_min) << FTIME_MIN_OFFSET;
ftime |= ((DWORD)st.tm_hour) << FTIME_HR_OFFSET;
@@ -1861,7 +1862,7 @@ static FRESULT fatfs_setlabel(los_part *part)
return result;
}
int fatfs_mkfs (struct Vnode *device, int sectors, int option)
int fatfs_mkfs(struct Vnode *device, int sectors, int option)
{
BYTE *work_buff = NULL;
los_part *part = NULL;
@@ -2166,7 +2167,7 @@ int fatfs_symlink(struct Vnode *parentVnode, struct Vnode **newVnode, const char
ssize_t fatfs_readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
{
int ret;
FRESULT res = FR_OK;
FRESULT res;
DWORD clust;
QWORD sect;
DIR_FILE *dfp = (DIR_FILE *)(vnode->data);

View File

@@ -64,7 +64,7 @@ extern "C" {
#define MBR_PRIMARY_PART_NUM 4
#define JUMP_CODE "\xEB\xFE\x90"
/* Partiton type */
/* Partition type */
#define FAT12 0x01 /* FAT12 as primary partition in first physical 32MB */
#define FAT16 0x04 /* FAT16 with less than 65536 sectors(32MB) */
#define EXTENDED_PARTITION_CHS 0x05
@@ -137,7 +137,7 @@ int fatfs_readdir(struct Vnode *vnode, struct fs_dirent_s *idir);
int fatfs_rewinddir(struct Vnode *vnode, struct fs_dirent_s *dir);
int fatfs_closedir(struct Vnode *vnode, struct fs_dirent_s *dir);
int fatfs_rename(struct Vnode *oldvnode, struct Vnode *newparent, const char *oldname, const char *newname);
int fatfs_mkfs (struct Vnode *device, int sectors, int option);
int fatfs_mkfs(struct Vnode *device, int sectors, int option);
int fatfs_mkdir(struct Vnode *parent, const char *name, mode_t mode, struct Vnode **vpp);
int fatfs_rmdir(struct Vnode *parent, struct Vnode *vp, const char *name);
int fatfs_unlink(struct Vnode *parent, struct Vnode *vp, const char *name);

View File

@@ -179,7 +179,7 @@ static INT FatfsDisablePart(void *handle)
* Scan the FAT inside the boundary of CHILD FATFS limit, and update the free cluster and last cluster
* for all CHILD FATFS.
* Acceptable Return Value:
* - FR_OK : Successfully scaned the FAT and update field.
* - FR_OK : Successfully scanned the FAT and update field.
* Others Return Value:
* - FR_INVAILD_FATFS : The FATFS object has error or the info in it has been occuried
* - FR_DENIED : The virtual partition feature has been shut down by switcher

View File

@@ -319,7 +319,7 @@ FRESULT f_regvirfs(FATFS *fs)
/* Set the CHILD object field */
for (i = 0; i < fs->vir_amount; i++) {
pfs = ff_memalloc(sizeof(FATFS)); /* Allocate a memeory for current child FATFS object */
pfs = ff_memalloc(sizeof(FATFS)); /* Allocate a memory for current child FATFS object */
if (pfs == NULL) { /* If allocate failed, must call 'f_unregvirfs' to free the previous FATFS object memory */
goto ERROUT;
}
@@ -373,7 +373,7 @@ static FRESULT FatfsCheckScanFatParam(FATFS *fs)
* Scan the FAT inside the boundary of CHILD FATFS limit, and update the free cluster and last cluster
*
* Acceptable Return Value:
* - FR_OK : Successfully scaned the FAT and update field.
* - FR_OK : Successfully scanned the FAT and update field.
*
* Others Return Value:
* - FR_INVAILD_FATFS : The FATFS object has error or the info in it has been occuried
@@ -500,7 +500,7 @@ static void FatfsSetChildClst(BYTE *work, FATFS *fs, WORD i)
* - FR_OK : The external SD configure is complete, all info has been set to the
* each CHILD FATFS
* - FR_NOT_MATCHED : The virtual partition's configure does not matched as current setting
* - FR_MODIFIED : The virtual partition's configure has been destoried partly or completely
* - FR_MODIFIED : The virtual partition's configure has been destroyed partly or completely
* - FR_NOVIRPART : The external SD has not been apllied as virtual partition yet
*
* Others Return Value:
@@ -581,11 +581,11 @@ FRESULT f_checkvirpart(FATFS *fs, const TCHAR *path, BYTE vol)
labelTmp = (DWORD *)label;
*labelTmp = tmp;
tmp = ld_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 4);
*((DWORD * )(label + 4)) = tmp;
*((DWORD *)(label + 4)) = tmp;
tmp = ld_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 8);
*((DWORD * )(label + 8)) = tmp;
*((DWORD *)(label + 8)) = tmp;
tmp = ld_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 12);
*((DWORD * )(label + 12)) = tmp;
*((DWORD *)(label + 12)) = tmp;
if (f_checkname(label) != FR_OK) {
(void)f_unregvirfs(fs);
@@ -721,11 +721,11 @@ FRESULT f_makevirpart(FATFS *fs, const TCHAR *path, BYTE vol)
labelTmp = (DWORD *)label;
tmp = *labelTmp;
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 0, tmp);
tmp = *((DWORD * )(label + 4));
tmp = *((DWORD *)(label + 4));
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 4, tmp);
tmp = *((DWORD * )(label + 8));
tmp = *((DWORD *)(label + 8));
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 8, tmp);
tmp = *((DWORD * )(label + 12));
tmp = *((DWORD *)(label + 12));
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 12, tmp);
virpartper += g_fatVirPart.virtualinfo.virpartpercent[i];

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:
@@ -98,7 +98,7 @@ extern char *rindex(const char *s, int c);
* @ingroup fs
*
* @par Description:
* The set_label() function shall set the value of a global varible,
* The set_label() function shall set the value of a global variable,
* the value will be used to set the label of SD card in format().
*
* @param name [IN] label to set, the length must be less than 12
@@ -244,8 +244,9 @@ extern int chattr(const char *pathname, struct IATTR *attr);
*
* @retval #0 On success.
* @retval #-1 On failure with errno set.
* @retval CONTINE_NUTTX_FCNTL doesn't support some cmds in VfsFcntl, needs to continue going through Nuttx vfs operation.</li>
*
* @retval CONTINE_NUTTX_FCNTL doesn't support some cmds in VfsFcntl, needs to continue going through
* Nuttx vfs operation.</li>
*
* @par Dependency:
* <ul><li>fs.h</li></ul>
* @see None

View File

@@ -49,7 +49,7 @@ struct Mount {
LIST_HEAD vnodeList; /* list of vnodes */
int vnodeSize; /* size of vnode list */
LIST_HEAD activeVnodeList; /* list of active vnodes */
int activeVnodeSize; /* szie of active vnodes list */
int activeVnodeSize; /* size of active vnodes list */
void *data; /* private data */
uint32_t hashseed; /* Random seed for vfshash */
unsigned long mountFlags; /* Flags for mount */

View File

@@ -28,23 +28,89 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
import("//third_party/Linux_Kernel/Linux_Kernel.gni")
module_switch = defined(LOSCFG_FS_JFFS)
module_name = get_path_info(rebase_path("."), "name")
linux_path = rebase_path("//kernel/linux/linux-5.10")
out_path = rebase_path(target_out_dir)
kernel_module(module_name) {
patch_path = rebase_path(".")
cmd = "if [ -d ${out_path}/jffs2_build ]; then rm -r ${out_path}/jffs2_build; fi && mkdir -p ${out_path}/jffs2_build/fs"
cmd += " && cp ${linux_path}/fs/jffs2 ${out_path}/jffs2_build/fs/. -r"
cmd += " && pushd ${out_path}/jffs2_build/"
cmd += " && patch -p1 < ${patch_path}/jffs2.patch && popd"
exec_script("//build/lite/run_shell_cmd.py", [ cmd ])
sources = [
"src/jffs2_hash.c",
"src/vfs_jffs2.c",
]
sources += LINUX_KERNEL_FS_JFFS2_SRC_FILES
sources += [
"${out_path}/jffs2_build/fs/jffs2/background.c",
"${out_path}/jffs2_build/fs/jffs2/build.c",
"${out_path}/jffs2_build/fs/jffs2/compr.c",
"${out_path}/jffs2_build/fs/jffs2/compr_rtime.c",
"${out_path}/jffs2_build/fs/jffs2/compr_rubin.c",
"${out_path}/jffs2_build/fs/jffs2/compr_zlib.c",
"${out_path}/jffs2_build/fs/jffs2/debug.c",
"${out_path}/jffs2_build/fs/jffs2/dir.c",
"${out_path}/jffs2_build/fs/jffs2/erase.c",
"${out_path}/jffs2_build/fs/jffs2/file.c",
"${out_path}/jffs2_build/fs/jffs2/fs.c",
"${out_path}/jffs2_build/fs/jffs2/gc.c",
"${out_path}/jffs2_build/fs/jffs2/malloc.c",
"${out_path}/jffs2_build/fs/jffs2/nodelist.c",
"${out_path}/jffs2_build/fs/jffs2/nodemgmt.c",
"${out_path}/jffs2_build/fs/jffs2/read.c",
"${out_path}/jffs2_build/fs/jffs2/readinode.c",
"${out_path}/jffs2_build/fs/jffs2/scan.c",
"${out_path}/jffs2_build/fs/jffs2/summary.c",
"${out_path}/jffs2_build/fs/jffs2/super.c",
"${out_path}/jffs2_build/fs/jffs2/write.c",
"${out_path}/jffs2_build/fs/jffs2/writev.c",
]
include_dirs = LINUX_KERNEL_FS_JFFS2_INCLUDE_DIRS
include_dirs = [
"${out_path}/jffs2_build/fs",
"${out_path}/jffs2_build/fs/jffs2",
]
public_configs = [ ":public" ]
deps = [ ":cp_jffs2_src" ]
}
config("public") {
include_dirs = [ "include" ]
}
action("cp_jffs2_src") {
script = "//build/lite/run_shell_cmd.py"
outputs = [
"${target_out_dir}/jffs2_build/fs/jffs2/background.c",
"${target_out_dir}/jffs2_build/fs/jffs2/build.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr_rtime.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr_rubin.c",
"${target_out_dir}/jffs2_build/fs/jffs2/compr_zlib.c",
"${target_out_dir}/jffs2_build/fs/jffs2/debug.c",
"${target_out_dir}/jffs2_build/fs/jffs2/dir.c",
"${target_out_dir}/jffs2_build/fs/jffs2/erase.c",
"${target_out_dir}/jffs2_build/fs/jffs2/file.c",
"${target_out_dir}/jffs2_build/fs/jffs2/fs.c",
"${target_out_dir}/jffs2_build/fs/jffs2/gc.c",
"${target_out_dir}/jffs2_build/fs/jffs2/malloc.c",
"${target_out_dir}/jffs2_build/fs/jffs2/nodelist.c",
"${target_out_dir}/jffs2_build/fs/jffs2/nodemgmt.c",
"${target_out_dir}/jffs2_build/fs/jffs2/read.c",
"${target_out_dir}/jffs2_build/fs/jffs2/readinode.c",
"${target_out_dir}/jffs2_build/fs/jffs2/scan.c",
"${target_out_dir}/jffs2_build/fs/jffs2/summary.c",
"${target_out_dir}/jffs2_build/fs/jffs2/super.c",
"${target_out_dir}/jffs2_build/fs/jffs2/write.c",
"${target_out_dir}/jffs2_build/fs/jffs2/writev.c",
]
}

View File

@@ -31,13 +31,51 @@ include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard src/*.c) \
$(wildcard $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2/*.c)
LINUX_PATH := $(LITEOSTOPDIR)/../linux/linux-5.10
LOCAL_PATH := $(shell pwd)
TEMP_SRC_PATH := $(OUT)/jffs2_build
LOCAL_SRCS := \
$(TEMP_SRC_PATH)/fs/jffs2/background.c \
$(TEMP_SRC_PATH)/fs/jffs2/build.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr_rtime.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr_rubin.c \
$(TEMP_SRC_PATH)/fs/jffs2/compr_zlib.c \
$(TEMP_SRC_PATH)/fs/jffs2/debug.c \
$(TEMP_SRC_PATH)/fs/jffs2/dir.c \
$(TEMP_SRC_PATH)/fs/jffs2/erase.c \
$(TEMP_SRC_PATH)/fs/jffs2/file.c \
$(TEMP_SRC_PATH)/fs/jffs2/fs.c \
$(TEMP_SRC_PATH)/fs/jffs2/gc.c \
$(TEMP_SRC_PATH)/fs/jffs2/malloc.c \
$(TEMP_SRC_PATH)/fs/jffs2/nodelist.c \
$(TEMP_SRC_PATH)/fs/jffs2/nodemgmt.c \
$(TEMP_SRC_PATH)/fs/jffs2/read.c \
$(TEMP_SRC_PATH)/fs/jffs2/readinode.c \
$(TEMP_SRC_PATH)/fs/jffs2/scan.c \
$(TEMP_SRC_PATH)/fs/jffs2/summary.c \
$(TEMP_SRC_PATH)/fs/jffs2/super.c \
$(TEMP_SRC_PATH)/fs/jffs2/write.c \
$(TEMP_SRC_PATH)/fs/jffs2/writev.c \
$(LOCAL_PATH)/src/jffs2_hash.c \
$(LOCAL_PATH)/src/vfs_jffs2.c \
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/fs/jffs2/include \
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2 \
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs
-I $(TEMP_SRC_PATH)/fs/jffs2 \
-I $(TEMP_SRC_PATH)/fs
LOCAL_FLAGS := $(LOCAL_INCLUDE)
.PHONY: patch patch_clean
$(LOCAL_SRCS): patch
patch: patch_clean
cp $(LINUX_PATH)/fs/jffs2 $(TEMP_SRC_PATH)/fs/. -r
cd $(TEMP_SRC_PATH) && patch -p1 < $(LOCAL_PATH)/jffs2.patch
patch_clean:
$(HIDE) $(RM) -rf $(TEMP_SRC_PATH)
include $(MODULE)

9936
fs/jffs2/jffs2.patch Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021-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:
@@ -682,7 +682,6 @@ int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, const ch
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
ret = jffs2_rmdir(parentInode, targetInode, (const unsigned char *)path);
if (ret == 0) {
(void)jffs2_iput(targetInode);
}
@@ -809,7 +808,6 @@ int VfsJffs2Unlink(struct Vnode *parentVnode, struct Vnode *targetVnode, const c
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
ret = jffs2_unlink(parentInode, targetInode, (const unsigned char *)path);
if (ret == 0) {
(void)jffs2_iput(targetInode);
}

View File

@@ -55,14 +55,15 @@ INT32 OsMountPatchFs(VOID)
}
partInfo.fsType = strdup(FS_TYPE);
if (partInfo.fsType == NULL) {
return LOS_NOK;
ret = LOS_NOK;
goto EXIT;
}
partInfo.startAddr = PATCHFS_FLASH_ADDR;
partInfo.partSize = PATCHFS_FLASH_SIZE;
#else
ret = GetPartitionInfo(&partInfo);
if (ret != LOS_OK) {
return ret;
goto EXIT;
}
partInfo.startAddr = (partInfo.startAddr >= 0) ? partInfo.startAddr : PATCHFS_FLASH_ADDR;
partInfo.partSize = (partInfo.partSize >= 0) ? partInfo.partSize : PATCHFS_FLASH_SIZE;
@@ -71,7 +72,7 @@ INT32 OsMountPatchFs(VOID)
ret = LOS_NOK;
partInfo.devName = strdup(PATCH_FLASH_DEV_NAME);
if (partInfo.devName == NULL) {
return LOS_NOK;
goto EXIT;
}
const CHAR *devName = GetDevNameOfPartition(&partInfo);
if (devName != NULL) {
@@ -92,9 +93,13 @@ INT32 OsMountPatchFs(VOID)
ResetDevNameofPartition(&partInfo);
}
EXIT:
free(partInfo.devName);
partInfo.devName = NULL;
free(partInfo.storageType);
partInfo.storageType = NULL;
free(partInfo.fsType);
partInfo.fsType = NULL;
return ret;
}

View File

@@ -60,7 +60,7 @@ typedef unsigned short fmode_t;
#define FMODE_64BITHASH ((fmode_t)0x400)
/* 32bit hashes as llseek() offset (for directories) */
#define FMODE_32BITHASH ((fmode_t)0x200)
/* File is opened using open(.., 3, ..) and is writeable only for ioctls
/* File is opened using open(.., 3, ..) and is writable only for ioctls
* (specialy hack for floppy.c)
*/
#define FMODE_WRITE_IOCTL ((fmode_t)0x100)
@@ -137,7 +137,7 @@ struct ProcData {
#define S_IALLUGO (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO)
/**
* Interface for modules using proc below internal proc moudule;
* Interface for modules using proc below internal proc module;
*/
/**
* @ingroup procfs

View File

@@ -135,7 +135,7 @@ void ProcFdInit(void)
{
struct ProcDirEntry *pde = CreateProcEntry("fd", 0, NULL);
if (pde == NULL) {
PRINT_ERR("creat /proc/fd error.\n");
PRINT_ERR("create /proc/fd error.\n");
return;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021-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:
@@ -154,7 +154,8 @@ static int FsCacheInfoFill(struct SeqBuf *buf, void *arg)
VnodeHold();
LosBufPrintf(buf, "\n=================================================================\n");
LosBufPrintf(buf, "VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode\n");
LosBufPrintf(buf,
"VnodeAddr ParentAddr DataAddr VnodeOps Hash Ref Type Gid Uid Mode\n");
vnodeVirtual = VnodeListProcess(buf, GetVnodeVirtualList());
vnodeFree = VnodeListProcess(buf, GetVnodeFreeList());
vnodeActive = VnodeListProcess(buf, GetVnodeActiveList());

View File

@@ -91,7 +91,7 @@ void ProcMountsInit(void)
{
struct ProcDirEntry *pde = CreateProcEntry("mounts", 0, NULL);
if (pde == NULL) {
PRINT_ERR("creat mounts error!\n");
PRINT_ERR("create mounts error!\n");
return;
}

View File

@@ -78,7 +78,7 @@ void ProcUptimeInit(void)
{
struct ProcDirEntry *pde = CreateProcEntry("uptime", 0, NULL);
if (pde == NULL) {
PRINT_ERR("creat /proc/uptime error!\n");
PRINT_ERR("create /proc/uptime error!\n");
return;
}

View File

@@ -62,8 +62,9 @@ static struct ProcDirEntry g_procRootDirEntry = {
int ProcMatch(unsigned int len, const char *name, struct ProcDirEntry *pn)
{
if (len != pn->nameLen)
if (len != pn->nameLen) {
return 0;
}
return !strncmp(name, pn->name, len);
}
@@ -87,7 +88,7 @@ static struct ProcDirEntry *ProcFindNode(struct ProcDirEntry *parent, const char
}
/*
* descrition: find the file's handle
* description: find the file's handle
* path: the file of fullpath
* return: the file of handle
* add by ll
@@ -387,8 +388,9 @@ static void FreeProcEntry(struct ProcDirEntry *entry)
void ProcFreeEntry(struct ProcDirEntry *pn)
{
if (atomic_dec_and_test(&pn->count))
if (atomic_dec_and_test(&pn->count)) {
FreeProcEntry(pn);
}
}
static void RemoveProcEntryTravalsal(struct ProcDirEntry *pn)
@@ -519,7 +521,7 @@ int ProcOpen(struct ProcFile *procFile)
static int ProcRead(struct ProcDirEntry *pde, char *buf, size_t len)
{
if (pde == NULL || pde == NULL || pde->pf == NULL) {
if (pde == NULL || pde->pf == NULL) {
return PROC_ERROR;
}
struct ProcFile *procFile = pde->pf;

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:
@@ -62,8 +62,8 @@ int OsShellCmdWriteProc(int argc, char **argv)
if (argc == WRITEPROC_ARGC) {
value = argv[0];
path = argv[2];
len = strlen(value) + 1; /* +1:add the \0 */
path = argv[2]; // 2: index of path
len = strlen(value) + 1; /* + 1:add the \0 */
if (strncmp(argv[1], ">>", strlen(">>")) == 0) {
if ((realpath(path, realPath) == NULL) || (strncmp(realPath, rootProcDir, strlen(rootProcDir)) != 0)) {
PRINT_ERR("No such file or directory\n");

View File

@@ -29,10 +29,9 @@ endchoice
config BOOTENV_ADDR
int "Address of boot command line (KB)"
depends on PLATFORM_ROOTFS && (STORAGE_SPINOR || STORAGE_SPINAND || STORAGE_EMMC)
range 0 1024
default 512
help
Boot command line addr, range from 0 to 1MB.
Boot command line addr.
config BOOTENV_RAM
bool "Read bootenv from RAM"

View File

@@ -214,7 +214,7 @@ UINT64 LOS_SizeStrToNum(CHAR *value)
UINT64 num = 0;
/* If the string is a hexadecimal value */
if (sscanf_s(value, "0x%x", &num) > 0) {
if (sscanf_s(value, "0x%llx", &num) > 0) {
value += strlen("0x");
if (strspn(value, "0123456789abcdefABCDEF") < strlen(value)) {
goto ERROUT;
@@ -247,4 +247,4 @@ UINT64 LOS_SizeStrToNum(CHAR *value)
ERROUT:
PRINT_ERR("Invalid value string \"%s\"!\n", value);
return num;
}
}

View File

@@ -327,7 +327,7 @@ STATIC INT32 CheckValidation(UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr,
if ((rootAddr & (alignSize - 1)) || (rootSize & (alignSize - 1)) ||
(userAddr & (alignSize - 1)) || (userSize & (alignSize - 1))) {
PRINT_ERR("The address or size value should be 0x%x aligned!\n", alignSize);
PRINT_ERR("The address or size value should be 0x%llx aligned!\n", alignSize);
return LOS_NOK;
}
@@ -371,4 +371,4 @@ INT32 OsMountRootfs()
}
return LOS_OK;
}
}

View File

@@ -351,7 +351,7 @@ static INT32 BcacheSyncBlock(OsBcache *bc, OsBcacheBlock *block)
UINT32 len, start, end;
if (block->modified == TRUE) {
D(("bcache writting block = %llu\n", block->num));
D(("bcache writing block = %llu\n", block->num));
ret = FindFlagPos(block->flag, bc->sectorPerBlock >> UNINT_LOG2_SHIFT, &start, &end);
if (ret == ENOERR) {
@@ -581,8 +581,8 @@ static OsBcacheBlock *AllocNewBlock(OsBcache *bc, BOOL read, UINT64 num)
DelBlock(bc, prefer);
}
if (prefer->used) {
MergeSyncBlocks(bc, prefer);
if (prefer->used) { /* do not combine with next check */
MergeSyncBlocks(bc, prefer); /* prefer->used may be changed here */
}
if (prefer->used) {
@@ -932,7 +932,7 @@ INT32 BlockCacheWrite(OsBcache *bc, const UINT8 *buf, UINT32 *len, UINT64 sector
bc->modifiedBlock++;
}
if ((pos == 0) && (currentSize == bc->blockSize)) {
memset_s(block->flag, sizeof(block->flag), 0xFF, sizeof(block->flag));
(void)memset_s(block->flag, sizeof(block->flag), 0xFF, sizeof(block->flag));
block->allDirty = TRUE;
} else {
BcacheSetFlag(bc, block, (UINT32)pos, currentSize);

27
fs/vfs/epoll/fs_epoll.c Executable file → Normal file
View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021-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:
@@ -164,23 +164,23 @@ static VOID DoEpollClose(struct epoll_head *epHead)
}
/**
* epoll_create,
* epoll_create unsupported api
*
* epoll_create is implemented by calling epoll_create1, it's parameter 'size' is useless.
*
* epoll_create1,
* The simple version of epoll does not use red-black trees,
* so when fd is normal value (greater than 0),
* actually allocated epoll can manage num of EPOLL_DEFAULT_SIZE
*
* @param size: not actually used
* @param flags: not actually used
* @return epoll fd
*/
int epoll_create(int size)
int epoll_create1(int flags)
{
(void)flags;
int fd = -1;
if (size <= 0) {
set_errno(EINVAL);
return fd;
}
struct epoll_head *epHead = (struct epoll_head *)malloc(sizeof(struct epoll_head));
if (epHead == NULL) {
set_errno(ENOMEM);
@@ -242,6 +242,11 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
return ret;
}
if (ev == NULL) {
set_errno(EINVAL);
return -1;
}
switch (op) {
case EPOLL_CTL_ADD:
ret = CheckFdExist(epHead, fd);
@@ -299,12 +304,12 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout
int pollSize;
epHead = EpollGetDataBuff(epfd);
if (epHead== NULL) {
if (epHead == NULL) {
set_errno(EBADF);
return -1;
}
if (maxevents <= 0) {
if ((maxevents <= 0) || (evs == NULL)) {
set_errno(EINVAL);
return -1;
}

View File

@@ -138,7 +138,7 @@ typedef struct tagOsBcache {
* <li>The block number is automatically adjusted if position is greater than block size.</li>
* </ul>
*
* @retval #0 read succeded
* @retval #0 read succeeded
* @retval #INT32 read failed
*
* @par Dependency:
@@ -168,7 +168,7 @@ INT32 BlockCacheRead(OsBcache *bc,
* <li>The block number is automatically adjusted if position is greater than block size.</li>
* </ul>
*
* @retval #0 write succeded
* @retval #0 write succeeded
* @retval #INT32 write failed
*
* @par Dependency:
@@ -193,7 +193,7 @@ INT32 BlockCacheWrite(OsBcache *bc,
* <li>None.</li>
* </ul>
*
* @retval #0 sync succeded
* @retval #0 sync succeeded
* @retval #INT32 sync failed
*
* @par Dependency:
@@ -219,7 +219,7 @@ INT32 BlockCacheSync(OsBcache *bc);
* <li>None.</li>
* </ul>
*
* @retval #OsBcache * init succeded
* @retval #OsBcache * init succeeded
* @retval #NULL init failed
*
* @par Dependency:

2
fs/vfs/include/epoll.h Executable file → Normal file
View File

@@ -72,7 +72,7 @@ struct epoll_event {
epoll_data_t data;
};
int epoll_create(int size);
int epoll_create1(int flags);
int epoll_close(int epfd);
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev);
int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout);

View File

@@ -160,7 +160,7 @@ typedef int VfsHashCmp(struct Vnode *vnode, void *arg);
int VnodesInit(void);
int VnodeDevInit(void);
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **vnode);
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode);
int VnodeFree(struct Vnode *vnode);
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
int VnodeLookupFullpath(const char *fullpath, struct Vnode **vnode, uint32_t flags);

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:
@@ -225,7 +225,6 @@ static char *vfs_normalize_fullpath(const char *directory, const char *filename,
/* it's a absolute path, use it directly */
fullpath = strdup(filename); /* copy string */
if (fullpath == NULL) {
*pathname = NULL;
set_errno(ENOMEM);
@@ -258,11 +257,10 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
}
#ifdef VFS_USING_WORKDIR
if (directory == NULL)
{
if (directory == NULL) {
spin_lock_irqsave(&curr->files->workdir_lock, lock_flags);
directory = curr->files->workdir;
}
}
#else
if ((directory == NULL) && (filename[0] != '/')) {
PRINT_ERR("NO_WORKING_DIR\n");
@@ -275,20 +273,18 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
if ((filename[0] != '/') && (strlen(directory) + namelen + 2 > TEMP_PATH_MAX)) {
#ifdef VFS_USING_WORKDIR
if (dir_flags == TRUE)
{
if (dir_flags == TRUE) {
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
}
}
#endif
return -ENAMETOOLONG;
}
fullpath = vfs_normalize_fullpath(directory, filename, pathname, namelen);
#ifdef VFS_USING_WORKDIR
if (dir_flags == TRUE)
{
if (dir_flags == TRUE) {
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
}
}
#endif
if (fullpath == NULL) {
return -get_errno();
@@ -308,7 +304,7 @@ int vfs_normalize_path(const char *directory, const char *filename, char **pathn
int vfs_normalize_pathat(int dirfd, const char *filename, char **pathname)
{
/* Get path by dirfd*/
/* Get path by dirfd */
char *relativeoldpath = NULL;
char *fullpath = NULL;
int ret = 0;

View File

@@ -133,7 +133,7 @@ int fallocate64(int fd, int mode, off64_t offset, off64_t len)
return VFS_ERROR;
}
if (filep->f_oflags & O_DIRECTORY) {
if ((unsigned int)filep->f_oflags & O_DIRECTORY) {
set_errno(EBADF);
return VFS_ERROR;
}

View File

@@ -35,115 +35,174 @@
#include "path_cache.h"
/* vnode operations returns EIO */
static int ErrorVopCreate (struct Vnode *parent, const char *name, int mode, struct Vnode **vnode)
static int ErrorVopCreate(struct Vnode *parent, const char *name, int mode, struct Vnode **vnode)
{
(void)parent;
(void)name;
(void)mode;
(void)vnode;
return -EIO;
}
static int ErrorVopLookup (struct Vnode *parent, const char *name, int len, struct Vnode **vnode)
static int ErrorVopLookup(struct Vnode *parent, const char *name, int len, struct Vnode **vnode)
{
(void)parent;
(void)name;
(void)len;
(void)vnode;
return -EIO;
}
static int ErrorVopOpen (struct Vnode *vnode, int fd, int mode, int flags)
static int ErrorVopOpen(struct Vnode *vnode, int fd, int mode, int flags)
{
(void)vnode;
(void)fd;
(void)mode;
(void)flags;
return -EIO;
}
static int ErrorVopClose (struct Vnode *vnode)
static int ErrorVopClose(struct Vnode *vnode)
{
(void)vnode;
/* already closed at force umount, do nothing here */
return OK;
}
static int ErrorVopReclaim (struct Vnode *vnode)
static int ErrorVopReclaim(struct Vnode *vnode)
{
(void)vnode;
return -EIO;
}
static int ErrorVopUnlink (struct Vnode *parent, struct Vnode *vnode, const char *fileName)
static int ErrorVopUnlink(struct Vnode *parent, struct Vnode *vnode, const char *fileName)
{
(void)parent;
(void)vnode;
(void)fileName;
return -EIO;
}
static int ErrorVopRmdir (struct Vnode *parent, struct Vnode *vnode, const char *dirName)
static int ErrorVopRmdir(struct Vnode *parent, struct Vnode *vnode, const char *dirName)
{
(void)parent;
(void)vnode;
(void)dirName;
return -EIO;
}
static int ErrorVopMkdir (struct Vnode *parent, const char *dirName, mode_t mode, struct Vnode **vnode)
static int ErrorVopMkdir(struct Vnode *parent, const char *dirName, mode_t mode, struct Vnode **vnode)
{
(void)parent;
(void)dirName;
(void)mode;
(void)vnode;
return -EIO;
}
static int ErrorVopReaddir (struct Vnode *vnode, struct fs_dirent_s *dir)
static int ErrorVopReaddir(struct Vnode *vnode, struct fs_dirent_s *dir)
{
(void)vnode;
(void)dir;
return -EIO;
}
static int ErrorVopOpendir (struct Vnode *vnode, struct fs_dirent_s *dir)
static int ErrorVopOpendir(struct Vnode *vnode, struct fs_dirent_s *dir)
{
(void)vnode;
(void)dir;
return -EIO;
}
static int ErrorVopRewinddir (struct Vnode *vnode, struct fs_dirent_s *dir)
static int ErrorVopRewinddir(struct Vnode *vnode, struct fs_dirent_s *dir)
{
(void)vnode;
(void)dir;
return -EIO;
}
static int ErrorVopClosedir (struct Vnode *vnode, struct fs_dirent_s *dir)
static int ErrorVopClosedir(struct Vnode *vnode, struct fs_dirent_s *dir)
{
(void)vnode;
(void)dir;
/* already closed at force umount, do nothing here */
return OK;
}
static int ErrorVopGetattr (struct Vnode *vnode, struct stat *st)
static int ErrorVopGetattr(struct Vnode *vnode, struct stat *st)
{
(void)vnode;
(void)st;
return -EIO;
}
static int ErrorVopSetattr (struct Vnode *vnode, struct stat *st)
static int ErrorVopSetattr(struct Vnode *vnode, struct stat *st)
{
(void)vnode;
(void)st;
return -EIO;
}
static int ErrorVopChattr (struct Vnode *vnode, struct IATTR *attr)
static int ErrorVopChattr(struct Vnode *vnode, struct IATTR *attr)
{
(void)vnode;
(void)attr;
return -EIO;
}
static int ErrorVopRename (struct Vnode *src, struct Vnode *dstParent, const char *srcName, const char *dstName)
static int ErrorVopRename(struct Vnode *src, struct Vnode *dstParent, const char *srcName, const char *dstName)
{
(void)src;
(void)dstParent;
(void)srcName;
(void)dstName;
return -EIO;
}
static int ErrorVopTruncate (struct Vnode *vnode, off_t len)
static int ErrorVopTruncate(struct Vnode *vnode, off_t len)
{
(void)vnode;
(void)len;
return -EIO;
}
static int ErrorVopTruncate64 (struct Vnode *vnode, off64_t len)
static int ErrorVopTruncate64(struct Vnode *vnode, off64_t len)
{
(void)vnode;
(void)len;
return -EIO;
}
static int ErrorVopFscheck (struct Vnode *vnode, struct fs_dirent_s *dir)
static int ErrorVopFscheck(struct Vnode *vnode, struct fs_dirent_s *dir)
{
(void)vnode;
(void)dir;
return -EIO;
}
static int ErrorVopLink (struct Vnode *src, struct Vnode *dstParent, struct Vnode **dst, const char *dstName)
static int ErrorVopLink(struct Vnode *src, struct Vnode *dstParent, struct Vnode **dst, const char *dstName)
{
(void)src;
(void)dstParent;
(void)dst;
(void)dstName;
return -EIO;
}
static int ErrorVopSymlink (struct Vnode *parentVnode, struct Vnode **newVnode, const char *path, const char *target)
static int ErrorVopSymlink(struct Vnode *parentVnode, struct Vnode **newVnode, const char *path, const char *target)
{
(void)parentVnode;
(void)newVnode;
(void)path;
(void)target;
return -EIO;
}
static ssize_t ErrorVopReadlink (struct Vnode *vnode, char *buffer, size_t bufLen)
static ssize_t ErrorVopReadlink(struct Vnode *vnode, char *buffer, size_t bufLen)
{
(void)vnode;
(void)buffer;
(void)bufLen;
return -EIO;
}
@@ -173,74 +232,107 @@ static struct VnodeOps g_errorVnodeOps = {
};
/* file operations returns EIO */
static int ErrorFopOpen (struct file *filep)
static int ErrorFopOpen(struct file *filep)
{
(void)filep;
return -EIO;
}
static int ErrorFopClose (struct file *filep)
static int ErrorFopClose(struct file *filep)
{
(void)filep;
/* already closed at force umount, do nothing here */
return OK;
}
static ssize_t ErrorFopRead (struct file *filep, char *buffer, size_t buflen)
static ssize_t ErrorFopRead(struct file *filep, char *buffer, size_t buflen)
{
(void)filep;
(void)buffer;
(void)buflen;
return -EIO;
}
static ssize_t ErrorFopWrite (struct file *filep, const char *buffer, size_t buflen)
static ssize_t ErrorFopWrite(struct file *filep, const char *buffer, size_t buflen)
{
(void)filep;
(void)buffer;
(void)buflen;
return -EIO;
}
static off_t ErrorFopSeek (struct file *filep, off_t offset, int whence)
static off_t ErrorFopSeek(struct file *filep, off_t offset, int whence)
{
(void)filep;
(void)offset;
(void)whence;
return -EIO;
}
static int ErrorFopIoctl (struct file *filep, int cmd, unsigned long arg)
static int ErrorFopIoctl(struct file *filep, int cmd, unsigned long arg)
{
(void)filep;
(void)cmd;
(void)arg;
return -EIO;
}
static int ErrorFopMmap (struct file* filep, struct VmMapRegion *region)
static int ErrorFopMmap(struct file* filep, struct VmMapRegion *region)
{
(void)filep;
(void)region;
return -EIO;
}
static int ErrorFopPoll (struct file *filep, poll_table *fds)
static int ErrorFopPoll(struct file *filep, poll_table *fds)
{
(void)filep;
(void)fds;
return -EIO;
}
static int ErrorFopStat (struct file *filep, struct stat* st)
static int ErrorFopStat(struct file *filep, struct stat* st)
{
(void)filep;
(void)st;
return -EIO;
}
static int ErrorFopFallocate (struct file* filep, int mode, off_t offset, off_t len)
static int ErrorFopFallocate(struct file* filep, int mode, off_t offset, off_t len)
{
(void)filep;
(void)mode;
(void)offset;
(void)len;
return -EIO;
}
static int ErrorFopFallocate64 (struct file *filep, int mode, off64_t offset, off64_t len)
static int ErrorFopFallocate64(struct file *filep, int mode, off64_t offset, off64_t len)
{
(void)filep;
(void)mode;
(void)offset;
(void)len;
return -EIO;
}
static int ErrorFopFsync (struct file *filep)
static int ErrorFopFsync(struct file *filep)
{
(void)filep;
return -EIO;
}
static ssize_t ErrorFopReadpage (struct file *filep, char *buffer, size_t buflen)
static ssize_t ErrorFopReadpage(struct file *filep, char *buffer, size_t buflen)
{
(void)filep;
(void)buffer;
(void)buflen;
return -EIO;
}
static int ErrorFopUnlink (struct Vnode *vnode)
static int ErrorFopUnlink(struct Vnode *vnode)
{
(void)vnode;
return -EIO;
}

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:
@@ -132,19 +132,19 @@ int VfsPermissionCheck(uint fuid, uint fgid, uint fileMode, int accMode)
#ifdef VFS_USING_WORKDIR
static int SetWorkDir(const char *dir, size_t len)
{
errno_t ret;
uint lock_flags;
LosProcessCB *curr = OsCurrProcessGet();
errno_t ret;
uint lock_flags;
LosProcessCB *curr = OsCurrProcessGet();
spin_lock_irqsave(&curr->files->workdir_lock, lock_flags);
ret = strncpy_s(curr->files->workdir, PATH_MAX, dir, len);
curr->files->workdir[PATH_MAX - 1] = '\0';
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
if (ret != EOK) {
return -1;
}
spin_lock_irqsave(&curr->files->workdir_lock, lock_flags);
ret = strncpy_s(curr->files->workdir, PATH_MAX, dir, len);
curr->files->workdir[PATH_MAX - 1] = '\0';
spin_unlock_irqrestore(&curr->files->workdir_lock, lock_flags);
if (ret != EOK) {
return -1;
}
return 0;
return 0;
}
#endif
@@ -155,7 +155,6 @@ int chdir(const char *path)
char *fullpath_bak = NULL;
struct stat statBuff;
if (!path) {
set_errno(EFAULT);
return -1;
@@ -637,7 +636,7 @@ void ls(const char *pathname)
if (statInfo.st_mode & S_IFDIR) { /* list all directory and file */
ret = LsDir((pathname == NULL) ? path : pathname);
} else { /* show the file infomation */
} else { /* show the file information */
ret = LsFile(path);
}
if (ret < 0) {

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,7 +57,6 @@ int utime(const char *path, const struct utimbuf *ptimes)
/* Sanity checks */
if (path == NULL) {
ret = -EINVAL;
goto errout;

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2021-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:
@@ -198,7 +198,7 @@ int VnodeFree(struct Vnode *vnode)
g_totalVnodeSize--;
} else {
/* for normal vnode, reclaim it to g_VnodeFreeList */
memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
(void)memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
LOS_ListAdd(&g_vnodeFreeList, &vnode->actFreeEntry);
g_freeVnodeSize++;
}
@@ -239,7 +239,7 @@ BOOL VnodeInUseIter(const struct Mount *mount)
return FALSE;
}
int VnodeHold()
int VnodeHold(void)
{
int ret = LOS_MuxLock(&g_vnodeMux, LOS_WAIT_FOREVER);
if (ret != LOS_OK) {
@@ -248,7 +248,7 @@ int VnodeHold()
return ret;
}
int VnodeDrop()
int VnodeDrop(void)
{
int ret = LOS_MuxUnlock(&g_vnodeMux);
if (ret != LOS_OK) {
@@ -380,6 +380,11 @@ int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struc
if (orgVnode != NULL) {
startVnode = orgVnode;
normalizedPath = strdup(path);
if (normalizedPath == NULL) {
PRINT_ERR("[VFS]lookup failed, strdup err\n");
ret = -EINVAL;
goto OUT_FREE_PATH;
}
} else {
ret = PreProcess(path, &startVnode, &normalizedPath);
if (ret != LOS_OK) {
@@ -578,7 +583,7 @@ int VnodeCreate(struct Vnode *parent, const char *name, int mode, struct Vnode *
return 0;
}
int VnodeDevInit()
int VnodeDevInit(void)
{
struct Vnode *devNode = NULL;
struct Mount *devMount = NULL;
@@ -611,7 +616,7 @@ int VnodeGetattr(struct Vnode *vnode, struct stat *buf)
return LOS_OK;
}
struct Vnode *VnodeGetRoot()
struct Vnode *VnodeGetRoot(void)
{
return g_rootVnode;
}
@@ -692,7 +697,7 @@ LIST_HEAD* GetVnodeActiveList()
return &g_vnodeActiveList;
}
int VnodeClearCache()
int VnodeClearCache(void)
{
struct Vnode *item = NULL;
struct Vnode *nextItem = NULL;

View File

@@ -67,6 +67,12 @@ config PAGE_TABLE_FINE_LOCK
help
This option will enable fine lock for page table.
config ENABLE_KERNEL_TEST
bool "Enable kernel test"
default n
help
This option will enable kernel test.
######################### config options of extended #####################
source "kernel/extended/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:
@@ -65,10 +65,12 @@ kernel_module(module_name) {
"mp/los_mp.c",
"mp/los_percpu.c",
"mp/los_spinlock.c",
"mp/los_stat.c",
"om/los_err.c",
"sched/sched_sq/los_sched.c",
"sched/sched_sq/los_sortlink.c",
"sched/los_idle.c",
"sched/los_priority.c",
"sched/los_sched.c",
"sched/los_sortlink.c",
"sched/los_statistics.c",
"vm/los_vm_boot.c",
"vm/los_vm_dump.c",
"vm/los_vm_fault.c",
@@ -88,8 +90,13 @@ kernel_module(module_name) {
}
public_configs = [ ":public" ]
configs += [ ":private" ]
}
config("public") {
include_dirs = [ "include" ]
}
config("private") {
cflags = [ "-Wno-frame-address" ]
}

View File

@@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include $(LITEOSTOPDIR)/config.mk
include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/lite.mk
include $(LITEOSTOPDIR)/../../drivers/hdf_core/adapter/khdf/liteos/lite.mk
MODULE_NAME := $(notdir $(shell pwd))
@@ -37,9 +37,9 @@ LOCAL_SRCS := $(wildcard ipc/*.c) $(wildcard core/*.c) $(wildcard mem/membox/*.
$(wildcard misc/*.c)\
$(wildcard mem/tlsf/*.c) \
$(wildcard mp/*.c) \
$(wildcard sched/sched_sq/*.c) \
$(wildcard sched/*.c) \
$(wildcard vm/*.c)
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK)
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) -Wno-frame-address
include $(MODULE)

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:
@@ -87,7 +87,7 @@ VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB)
OsTaskInsertToRecycleList(taskCB);
}
UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB)
UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB, SchedParam *param)
{
UINT32 intSave;
UINT16 numCount;
@@ -100,12 +100,14 @@ UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB)
if (OsProcessIsUserMode(processCB)) {
taskCB->taskStatus |= OS_TASK_FLAG_USER_MODE;
if (processCB->threadNumber > 0) {
taskCB->basePrio = OS_TCB_FROM_TID(processCB->threadGroupID)->basePrio;
LosTaskCB *task = OS_TCB_FROM_TID(processCB->threadGroupID);
task->ops->schedParamGet(task, param);
} else {
taskCB->basePrio = OS_USER_PROCESS_PRIORITY_HIGHEST;
OsSchedProcessDefaultSchedParamGet(param->policy, param);
}
} else {
taskCB->basePrio = OsCurrTaskGet()->basePrio;
LosTaskCB *runTask = OsCurrTaskGet();
runTask->ops->schedParamGet(runTask, param);
}
#ifdef LOSCFG_KERNEL_VM
@@ -176,7 +178,7 @@ STATIC ProcessGroup *OsFindProcessGroup(UINT32 gid)
}
}
PRINT_INFO("%s is find group : %u failed!\n", __FUNCTION__, gid);
PRINT_INFO("%s failed! group id = %u\n", __FUNCTION__, gid);
return NULL;
}
@@ -283,7 +285,7 @@ STATIC LosProcessCB *OsFindExitChildProcess(const LosProcessCB *processCB, INT32
VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID)
{
taskCB->waitID = wakePID;
OsSchedTaskWake(taskCB);
taskCB->ops->wake(taskCB);
#ifdef LOSCFG_KERNEL_SMP
LOS_MpSchedule(OS_MP_CPU_ALL);
#endif
@@ -897,7 +899,7 @@ STATIC INLINE INT32 OsProcessSchedlerParamCheck(INT32 which, INT32 pid, UINT16 p
}
#ifdef LOSCFG_SECURITY_CAPABILITY
STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, UINT16 prio)
STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, const SchedParam *param, UINT16 prio)
{
LosProcessCB *runProcess = OsCurrProcessGet();
@@ -907,7 +909,7 @@ STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, UINT16 prio)
}
/* user mode process can reduce the priority of itself */
if ((runProcess->processID == processCB->processID) && (prio > OsCurrTaskGet()->basePrio)) {
if ((runProcess->processID == processCB->processID) && (prio > param->basePrio)) {
return TRUE;
}
@@ -921,31 +923,33 @@ STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, UINT16 prio)
LITE_OS_SEC_TEXT INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio, UINT16 policy)
{
LosProcessCB *processCB = NULL;
BOOL needSched = FALSE;
SchedParam param = { 0 };
UINT32 intSave;
INT32 ret;
ret = OsProcessSchedlerParamCheck(which, pid, prio, policy);
INT32 ret = OsProcessSchedlerParamCheck(which, pid, prio, policy);
if (ret != LOS_OK) {
return -ret;
}
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
SCHEDULER_LOCK(intSave);
processCB = OS_PCB_FROM_PID(pid);
if (OsProcessIsInactive(processCB)) {
ret = LOS_ESRCH;
goto EXIT;
}
#ifdef LOSCFG_SECURITY_CAPABILITY
if (!OsProcessCapPermitCheck(processCB, prio)) {
if (!OsProcessCapPermitCheck(processCB, &param, prio)) {
ret = LOS_EPERM;
goto EXIT;
}
#endif
needSched = OsSchedModifyProcessSchedParam(pid, policy, prio);
LosTaskCB *taskCB = OS_TCB_FROM_TID(processCB->threadGroupID);
taskCB->ops->schedParamGet(taskCB, &param);
param.basePrio = prio;
BOOL needSched = taskCB->ops->schedParamModify(taskCB, &param);
SCHEDULER_UNLOCK(intSave);
LOS_MpSchedule(OS_MP_CPU_ALL);
@@ -991,8 +995,8 @@ LITE_OS_SEC_TEXT INT32 LOS_SetProcessPriority(INT32 pid, UINT16 prio)
LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
{
INT32 prio;
UINT32 intSave;
SchedParam param = { 0 };
(VOID)which;
if (OS_PID_CHECK_INVALID(pid)) {
@@ -1006,15 +1010,15 @@ LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
SCHEDULER_LOCK(intSave);
if (OsProcessIsUnused(processCB)) {
prio = -LOS_ESRCH;
goto OUT;
SCHEDULER_UNLOCK(intSave);
return -LOS_ESRCH;
}
prio = (INT32)OS_TCB_FROM_TID(processCB->threadGroupID)->basePrio;
LosTaskCB *taskCB = OS_TCB_FROM_TID(processCB->threadGroupID);
taskCB->ops->schedParamGet(taskCB, &param);
OUT:
SCHEDULER_UNLOCK(intSave);
return prio;
return param.basePrio;
}
LITE_OS_SEC_TEXT INT32 LOS_GetProcessPriority(INT32 pid)
@@ -1050,8 +1054,7 @@ STATIC VOID OsWaitInsertWaitListInOrder(LosTaskCB *runTask, LosProcessCB *proces
/* if runTask->waitFlag == OS_PROCESS_WAIT_PRO,
* this node is inserted directly into the header of the waitList
*/
(VOID)OsSchedTaskWait(list->pstNext, LOS_WAIT_FOREVER, TRUE);
(VOID)runTask->ops->wait(runTask, list->pstNext, LOS_WAIT_FOREVER);
return;
}
@@ -1202,13 +1205,10 @@ STATIC INT32 OsWait(INT32 pid, USER INT32 *status, USER siginfo_t *info, UINT32
UINT32 ret;
UINT32 intSave;
LosProcessCB *childCB = NULL;
LosProcessCB *processCB = NULL;
LosTaskCB *runTask = NULL;
LosProcessCB *processCB = OsCurrProcessGet();
LosTaskCB *runTask = OsCurrTaskGet();
SCHEDULER_LOCK(intSave);
processCB = OsCurrProcessGet();
runTask = OsCurrTaskGet();
ret = OsWaitChildProcessCheck(processCB, pid, &childCB);
if (ret != LOS_OK) {
pid = -ret;
@@ -1725,47 +1725,37 @@ STATIC UINT32 OsCopyUser(LosProcessCB *childCB, LosProcessCB *parentCB)
return LOS_OK;
}
STATIC VOID OsInitCopyTaskParam(LosProcessCB *childProcessCB, const CHAR *name, UINTPTR entry, UINT32 size,
TSK_INIT_PARAM_S *childPara)
{
LosTaskCB *mainThread = NULL;
UINT32 intSave;
SCHEDULER_LOCK(intSave);
mainThread = OsCurrTaskGet();
if (OsProcessIsUserMode(childProcessCB)) {
childPara->pfnTaskEntry = mainThread->taskEntry;
childPara->uwStackSize = mainThread->stackSize;
childPara->userParam.userArea = mainThread->userArea;
childPara->userParam.userMapBase = mainThread->userMapBase;
childPara->userParam.userMapSize = mainThread->userMapSize;
} else {
childPara->pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
childPara->uwStackSize = size;
}
childPara->pcName = (CHAR *)name;
childPara->policy = mainThread->policy;
childPara->usTaskPrio = mainThread->priority;
childPara->processID = childProcessCB->processID;
if (mainThread->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
childPara->uwResved = LOS_TASK_ATTR_JOINABLE;
}
SCHEDULER_UNLOCK(intSave);
}
STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR *name, UINTPTR entry, UINT32 size)
{
LosTaskCB *runTask = OsCurrTaskGet();
TSK_INIT_PARAM_S childPara = { 0 };
UINT32 ret;
UINT32 intSave;
UINT32 taskID;
TSK_INIT_PARAM_S taskParam = { 0 };
UINT32 ret, taskID, intSave;
SchedParam param = { 0 };
OsInitCopyTaskParam(childProcessCB, name, entry, size, &childPara);
SCHEDULER_LOCK(intSave);
if (OsProcessIsUserMode(childProcessCB)) {
taskParam.pfnTaskEntry = runTask->taskEntry;
taskParam.uwStackSize = runTask->stackSize;
taskParam.userParam.userArea = runTask->userArea;
taskParam.userParam.userMapBase = runTask->userMapBase;
taskParam.userParam.userMapSize = runTask->userMapSize;
} else {
taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
taskParam.uwStackSize = size;
}
if (runTask->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
taskParam.uwResved = LOS_TASK_ATTR_JOINABLE;
}
ret = LOS_TaskCreateOnly(&taskID, &childPara);
runTask->ops->schedParamGet(runTask, &param);
SCHEDULER_UNLOCK(intSave);
taskParam.pcName = (CHAR *)name;
taskParam.policy = param.policy;
taskParam.usTaskPrio = param.priority;
taskParam.processID = childProcessCB->processID;
ret = LOS_TaskCreateOnly(&taskID, &taskParam);
if (ret != LOS_OK) {
if (ret == LOS_ERRNO_TSK_TCB_UNAVAILABLE) {
return LOS_EAGAIN;
@@ -1775,7 +1765,7 @@ STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR
LosTaskCB *childTaskCB = OS_TCB_FROM_TID(taskID);
childTaskCB->taskStatus = runTask->taskStatus;
childTaskCB->basePrio = runTask->basePrio;
childTaskCB->ops->schedParamModify(childTaskCB, &param);
if (childTaskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
childTaskCB->taskStatus &= ~OS_TASK_STATUS_RUNNING;
} else {
@@ -1882,6 +1872,7 @@ STATIC UINT32 OsChildSetProcessGroupAndSched(LosProcessCB *child, LosProcessCB *
UINT32 ret;
ProcessGroup *group = NULL;
LosTaskCB *taskCB = OS_TCB_FROM_TID(child->threadGroupID);
SCHEDULER_LOCK(intSave);
if (run->group->groupID == OS_USER_PRIVILEGE_PROCESS_GROUP) {
ret = OsSetProcessGroupIDUnsafe(child->processID, child->processID, &group);
@@ -1892,7 +1883,7 @@ STATIC UINT32 OsChildSetProcessGroupAndSched(LosProcessCB *child, LosProcessCB *
}
child->processStatus &= ~OS_PROCESS_STATUS_INIT;
OsSchedTaskEnQueue(OS_TCB_FROM_TID(child->threadGroupID));
taskCB->ops->enqueue(OsSchedRunqueue(), taskCB);
SCHEDULER_UNLOCK(intSave);
(VOID)LOS_MemFree(m_aucSysMem1, group);
@@ -2002,6 +1993,8 @@ LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status)
{
UINT32 intSave;
(void)status;
/* The exit of a kernel - state process must be kernel - state and all threads must actively exit */
LosProcessCB *processCB = OsCurrProcessGet();
SCHEDULER_LOCK(intSave);

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:
@@ -43,6 +43,9 @@
#error "swtmr maxnum cannot be zero"
#endif /* LOSCFG_BASE_CORE_SWTMR_LIMIT <= 0 */
STATIC INLINE VOID SwtmrDelete(SWTMR_CTRL_S *swtmr);
STATIC INLINE UINT64 SwtmrToStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid);
LITE_OS_SEC_BSS SWTMR_CTRL_S *g_swtmrCBArray = NULL; /* First address in Timer memory space */
LITE_OS_SEC_BSS UINT8 *g_swtmrHandlerPool = NULL; /* Pool of Swtmr Handler */
LITE_OS_SEC_BSS LOS_DL_LIST g_swtmrFreeList; /* Free list of Software Timer */
@@ -52,22 +55,232 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_swtmrSpin);
#define SWTMR_LOCK(state) LOS_SpinLockSave(&g_swtmrSpin, &(state))
#define SWTMR_UNLOCK(state) LOS_SpinUnlockRestore(&g_swtmrSpin, (state))
typedef struct {
SortLinkAttribute swtmrSortLink;
LosTaskCB *swtmrTask; /* software timer task id */
LOS_DL_LIST swtmrHandlerQueue; /* software timer timeout queue id */
} SwtmrRunqueue;
STATIC SwtmrRunqueue g_swtmrRunqueue[LOSCFG_KERNEL_CORE_NUM];
#ifdef LOSCFG_SWTMR_DEBUG
#define OS_SWTMR_PERIOD_TO_CYCLE(period) (((UINT64)(period) * OS_NS_PER_TICK) / OS_NS_PER_CYCLE)
STATIC SwtmrDebugData *g_swtmrDebugData = NULL;
BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID)
{
if (swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) {
return FALSE;
}
return g_swtmrDebugData[swtmrID].swtmrUsed;
}
UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode)
{
UINT32 intSave;
errno_t ret;
if ((swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) || (data == NULL) ||
(mode == NULL) || (len < sizeof(SwtmrDebugData))) {
return LOS_NOK;
}
SWTMR_CTRL_S *swtmr = &g_swtmrCBArray[swtmrID];
SWTMR_LOCK(intSave);
ret = memcpy_s(data, len, &g_swtmrDebugData[swtmrID], sizeof(SwtmrDebugData));
*mode = swtmr->ucMode;
SWTMR_UNLOCK(intSave);
if (ret != EOK) {
return LOS_NOK;
}
return LOS_OK;
}
#endif
STATIC VOID SwtmrDebugDataInit(VOID)
{
#ifdef LOSCFG_SWTMR_DEBUG
UINT32 size = sizeof(SwtmrDebugData) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
g_swtmrDebugData = (SwtmrDebugData *)LOS_MemAlloc(m_aucSysMem1, size);
if (g_swtmrDebugData == NULL) {
PRINT_ERR("SwtmrDebugDataInit malloc failed!\n");
return;
}
(VOID)memset_s(g_swtmrDebugData, size, 0, size);
#endif
}
STATIC INLINE VOID SwtmrDebugDataUpdate(SWTMR_CTRL_S *swtmr, UINT32 ticks, UINT32 times)
{
#ifdef LOSCFG_SWTMR_DEBUG
SwtmrDebugData *data = &g_swtmrDebugData[swtmr->usTimerID];
if (data->period != ticks) {
(VOID)memset_s(&data->base, sizeof(SwtmrDebugBase), 0, sizeof(SwtmrDebugBase));
data->period = ticks;
}
data->base.startTime = swtmr->startTime;
data->base.times += times;
#endif
}
STATIC INLINE VOID SwtmrDebugDataStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid)
{
#ifdef LOSCFG_SWTMR_DEBUG
SwtmrDebugData *data = &g_swtmrDebugData[swtmr->usTimerID];
data->swtmrUsed = TRUE;
data->handler = swtmr->pfnHandler;
data->cpuid = cpuid;
#endif
}
STATIC INLINE VOID SwtmrDebugWaitTimeCalculate(UINT32 swtmrID, SwtmrHandlerItemPtr swtmrHandler)
{
#ifdef LOSCFG_SWTMR_DEBUG
SwtmrDebugBase *data = &g_swtmrDebugData[swtmrID].base;
swtmrHandler->swtmrID = swtmrID;
UINT64 currTime = OsGetCurrSchedTimeCycle();
UINT64 waitTime = currTime - data->startTime;
data->waitTime += waitTime;
if (waitTime > data->waitTimeMax) {
data->waitTimeMax = waitTime;
}
data->readyStartTime = currTime;
data->waitCount++;
#endif
}
STATIC INLINE VOID SwtmrDebugDataClear(UINT32 swtmrID)
{
#ifdef LOSCFG_SWTMR_DEBUG
(VOID)memset_s(&g_swtmrDebugData[swtmrID], sizeof(SwtmrDebugData), 0, sizeof(SwtmrDebugData));
#endif
}
STATIC INLINE VOID SwtmrHandler(SwtmrHandlerItemPtr swtmrHandle)
{
#ifdef LOSCFG_SWTMR_DEBUG
UINT32 intSave;
SwtmrDebugBase *data = &g_swtmrDebugData[swtmrHandle->swtmrID].base;
UINT64 startTime = OsGetCurrSchedTimeCycle();
#endif
swtmrHandle->handler(swtmrHandle->arg);
#ifdef LOSCFG_SWTMR_DEBUG
UINT64 runTime = OsGetCurrSchedTimeCycle() - startTime;
SWTMR_LOCK(intSave);
data->runTime += runTime;
if (runTime > data->runTimeMax) {
data->runTimeMax = runTime;
}
runTime = startTime - data->readyStartTime;
data->readyTime += runTime;
if (runTime > data->readyTimeMax) {
data->readyTimeMax = runTime;
}
data->runCount++;
SWTMR_UNLOCK(intSave);
#endif
}
STATIC INLINE VOID SwtmrWake(SwtmrRunqueue *srq, UINT64 startTime, SortLinkList *sortList)
{
UINT32 intSave;
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
SwtmrHandlerItemPtr swtmrHandler = (SwtmrHandlerItemPtr)LOS_MemboxAlloc(g_swtmrHandlerPool);
LOS_ASSERT(swtmrHandler != NULL);
OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
SWTMR_LOCK(intSave);
swtmrHandler->handler = swtmr->pfnHandler;
swtmrHandler->arg = swtmr->uwArg;
LOS_ListTailInsert(&srq->swtmrHandlerQueue, &swtmrHandler->node);
SwtmrDebugWaitTimeCalculate(swtmr->usTimerID, swtmrHandler);
if (swtmr->ucMode == LOS_SWTMR_MODE_ONCE) {
SwtmrDelete(swtmr);
if (swtmr->usTimerID < (OS_SWTMR_MAX_TIMERID - LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
swtmr->usTimerID += LOSCFG_BASE_CORE_SWTMR_LIMIT;
} else {
swtmr->usTimerID %= LOSCFG_BASE_CORE_SWTMR_LIMIT;
}
} else if (swtmr->ucMode == LOS_SWTMR_MODE_NO_SELFDELETE) {
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
} else {
swtmr->uwOverrun++;
swtmr->startTime = startTime;
(VOID)SwtmrToStart(swtmr, ArchCurrCpuid());
}
SWTMR_UNLOCK(intSave);
}
STATIC INLINE VOID ScanSwtmrTimeList(SwtmrRunqueue *srq)
{
UINT32 intSave;
SortLinkAttribute *swtmrSortLink = &srq->swtmrSortLink;
LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
/*
* it needs to be carefully coped with, since the swtmr is in specific sortlink
* while other cores still has the chance to process it, like stop the timer.
*/
LOS_SpinLockSave(&swtmrSortLink->spinLock, &intSave);
if (LOS_ListEmpty(listObject)) {
LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
return;
}
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
UINT64 currTime = OsGetCurrSchedTimeCycle();
while (sortList->responseTime <= currTime) {
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
UINT64 startTime = GET_SORTLIST_VALUE(sortList);
OsDeleteNodeSortLink(swtmrSortLink, sortList);
LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
SwtmrWake(srq, startTime, sortList);
LOS_SpinLockSave(&swtmrSortLink->spinLock, &intSave);
if (LOS_ListEmpty(listObject)) {
break;
}
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
}
LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
return;
}
STATIC VOID SwtmrTask(VOID)
{
SwtmrHandlerItemPtr swtmrHandlePtr = NULL;
SwtmrHandlerItem swtmrHandle;
UINT32 ret, swtmrHandlerQueue;
UINT32 intSave;
UINT64 waitTime;
swtmrHandlerQueue = OsSchedSwtmrHandlerQueueGet();
SwtmrRunqueue *srq = &g_swtmrRunqueue[ArchCurrCpuid()];
LOS_DL_LIST *head = &srq->swtmrHandlerQueue;
for (;;) {
ret = LOS_QueueRead(swtmrHandlerQueue, &swtmrHandlePtr, sizeof(CHAR *), LOS_WAIT_FOREVER);
if ((ret == LOS_OK) && (swtmrHandlePtr != NULL)) {
swtmrHandle.handler = swtmrHandlePtr->handler;
swtmrHandle.arg = swtmrHandlePtr->arg;
waitTime = OsSortLinkGetNextExpireTime(OsGetCurrSchedTimeCycle(), &srq->swtmrSortLink);
if (waitTime != 0) {
SCHEDULER_LOCK(intSave);
srq->swtmrTask->ops->delay(srq->swtmrTask, waitTime);
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTODELAYEDLIST, srq->swtmrTask);
SCHEDULER_UNLOCK(intSave);
}
ScanSwtmrTimeList(srq);
while (!LOS_ListEmpty(head)) {
SwtmrHandlerItemPtr swtmrHandlePtr = LOS_DL_LIST_ENTRY(LOS_DL_LIST_FIRST(head), SwtmrHandlerItem, node);
LOS_ListDelete(&swtmrHandlePtr->node);
(VOID)memcpy_s(&swtmrHandle, sizeof(SwtmrHandlerItem), swtmrHandlePtr, sizeof(SwtmrHandlerItem));
(VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandlePtr);
if (swtmrHandle.handler != NULL) {
swtmrHandle.handler(swtmrHandle.arg);
}
SwtmrHandler(&swtmrHandle);
}
}
}
@@ -94,6 +307,11 @@ STATIC UINT32 SwtmrTaskCreate(UINT16 cpuid, UINT32 *swtmrTaskID)
return ret;
}
UINT32 OsSwtmrTaskIDGetByCpuid(UINT16 cpuid)
{
return g_swtmrRunqueue[cpuid].swtmrTask->taskID;
}
BOOL OsIsSwtmrTask(const LosTaskCB *taskCB)
{
if (taskCB->taskEntry == (TSK_ENTRY_FUNC)SwtmrTask) {
@@ -111,51 +329,58 @@ LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle(UINT32 processID)
}
}
LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
STATIC UINT32 SwtmrBaseInit(VOID)
{
UINT32 size;
UINT16 index;
UINT32 ret;
SWTMR_CTRL_S *swtmr = NULL;
UINT32 swtmrHandlePoolSize;
UINT32 cpuid = ArchCurrCpuid();
UINT32 swtmrTaskID, swtmrHandlerQueue;
if (cpuid == 0) {
size = sizeof(SWTMR_CTRL_S) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
swtmr = (SWTMR_CTRL_S *)LOS_MemAlloc(m_aucSysMem0, size); /* system resident resource */
if (swtmr == NULL) {
ret = LOS_ERRNO_SWTMR_NO_MEMORY;
goto ERROR;
}
(VOID)memset_s(swtmr, size, 0, size);
g_swtmrCBArray = swtmr;
LOS_ListInit(&g_swtmrFreeList);
for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
swtmr->usTimerID = index;
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
}
swtmrHandlePoolSize = LOS_MEMBOX_SIZE(sizeof(SwtmrHandlerItem), OS_SWTMR_HANDLE_QUEUE_SIZE);
g_swtmrHandlerPool = (UINT8 *)LOS_MemAlloc(m_aucSysMem1, swtmrHandlePoolSize); /* system resident resource */
if (g_swtmrHandlerPool == NULL) {
ret = LOS_ERRNO_SWTMR_NO_MEMORY;
goto ERROR;
}
ret = LOS_MemboxInit(g_swtmrHandlerPool, swtmrHandlePoolSize, sizeof(SwtmrHandlerItem));
if (ret != LOS_OK) {
ret = LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM;
goto ERROR;
}
UINT32 size = sizeof(SWTMR_CTRL_S) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
SWTMR_CTRL_S *swtmr = (SWTMR_CTRL_S *)LOS_MemAlloc(m_aucSysMem0, size); /* system resident resource */
if (swtmr == NULL) {
return LOS_ERRNO_SWTMR_NO_MEMORY;
}
ret = LOS_QueueCreate(NULL, OS_SWTMR_HANDLE_QUEUE_SIZE, &swtmrHandlerQueue, 0, sizeof(CHAR *));
(VOID)memset_s(swtmr, size, 0, size);
g_swtmrCBArray = swtmr;
LOS_ListInit(&g_swtmrFreeList);
for (UINT16 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
swtmr->usTimerID = index;
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
}
size = LOS_MEMBOX_SIZE(sizeof(SwtmrHandlerItem), OS_SWTMR_HANDLE_QUEUE_SIZE);
g_swtmrHandlerPool = (UINT8 *)LOS_MemAlloc(m_aucSysMem1, size); /* system resident resource */
if (g_swtmrHandlerPool == NULL) {
return LOS_ERRNO_SWTMR_NO_MEMORY;
}
ret = LOS_MemboxInit(g_swtmrHandlerPool, size, sizeof(SwtmrHandlerItem));
if (ret != LOS_OK) {
ret = LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED;
goto ERROR;
return LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM;
}
for (UINT16 index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) {
SwtmrRunqueue *srq = &g_swtmrRunqueue[index];
/* The linked list of all cores must be initialized at core 0 startup for load balancing */
OsSortLinkInit(&srq->swtmrSortLink);
LOS_ListInit(&srq->swtmrHandlerQueue);
srq->swtmrTask = NULL;
}
SwtmrDebugDataInit();
return LOS_OK;
}
LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
{
UINT32 ret;
UINT32 cpuid = ArchCurrCpuid();
UINT32 swtmrTaskID;
if (cpuid == 0) {
ret = SwtmrBaseInit();
if (ret != LOS_OK) {
goto ERROR;
}
}
ret = SwtmrTaskCreate(cpuid, &swtmrTaskID);
@@ -164,21 +389,88 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
goto ERROR;
}
OsSchedRunQueSwtmrInit(swtmrTaskID, swtmrHandlerQueue);
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
srq->swtmrTask = OsGetTaskCB(swtmrTaskID);
return LOS_OK;
ERROR:
PRINT_ERR("OsSwtmrInit error! ret = %u\n", ret);
(VOID)LOS_MemFree(m_aucSysMem0, g_swtmrCBArray);
g_swtmrCBArray = NULL;
(VOID)LOS_MemFree(m_aucSysMem1, g_swtmrHandlerPool);
g_swtmrHandlerPool = NULL;
return ret;
}
/*
* Description: Start Software Timer
* Input : swtmr --- Need to start software timer
*/
LITE_OS_SEC_TEXT VOID OsSwtmrStart(SWTMR_CTRL_S *swtmr)
#ifdef LOSCFG_KERNEL_SMP
STATIC INLINE VOID FindIdleSwtmrRunqueue(UINT16 *idleCpuid)
{
SwtmrRunqueue *idleRq = &g_swtmrRunqueue[0];
UINT32 nodeNum = OsGetSortLinkNodeNum(&idleRq->swtmrSortLink);
UINT16 cpuid = 1;
do {
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
UINT32 temp = OsGetSortLinkNodeNum(&srq->swtmrSortLink);
if (nodeNum > temp) {
*idleCpuid = cpuid;
nodeNum = temp;
}
cpuid++;
} while (cpuid < LOSCFG_KERNEL_CORE_NUM);
}
#endif
STATIC INLINE VOID AddSwtmr2TimeList(SortLinkList *node, UINT64 responseTime, UINT16 cpuid)
{
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
OsAdd2SortLink(&srq->swtmrSortLink, node, responseTime, cpuid);
}
STATIC INLINE VOID DeSwtmrFromTimeList(SortLinkList *node)
{
#ifdef LOSCFG_KERNEL_SMP
UINT16 cpuid = OsGetSortLinkNodeCpuid(node);
#else
UINT16 cpuid = 0;
#endif
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
OsDeleteFromSortLink(&srq->swtmrSortLink, node);
return;
}
STATIC VOID SwtmrAdjustCheck(UINT16 cpuid, UINT64 responseTime)
{
UINT32 ret;
UINT32 intSave;
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
SCHEDULER_LOCK(intSave);
if ((srq->swtmrTask == NULL) || !OsTaskIsBlocked(srq->swtmrTask)) {
SCHEDULER_UNLOCK(intSave);
return;
}
if (responseTime >= GET_SORTLIST_VALUE(&srq->swtmrTask->sortList)) {
SCHEDULER_UNLOCK(intSave);
return;
}
ret = OsSchedTimeoutQueueAdjust(srq->swtmrTask, responseTime);
SCHEDULER_UNLOCK(intSave);
if (ret != LOS_OK) {
return;
}
if (cpuid == ArchCurrCpuid()) {
OsSchedExpireTimeUpdate();
} else {
LOS_MpSchedule(CPUID_TO_AFFI_MASK(cpuid));
}
}
STATIC UINT64 SwtmrToStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid)
{
UINT32 ticks;
UINT32 times = 0;
if ((swtmr->uwOverrun == 0) && ((swtmr->ucMode == LOS_SWTMR_MODE_ONCE) ||
(swtmr->ucMode == LOS_SWTMR_MODE_OPP) ||
@@ -189,75 +481,122 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStart(SWTMR_CTRL_S *swtmr)
}
swtmr->ucState = OS_SWTMR_STATUS_TICKING;
OsSchedAddSwtmr2TimeList(&swtmr->stSortList, swtmr->startTime, ticks);
OsSchedUpdateExpireTime();
return;
UINT64 period = (UINT64)ticks * OS_CYCLE_PER_TICK;
UINT64 responseTime = swtmr->startTime + period;
UINT64 currTime = OsGetCurrSchedTimeCycle();
if (responseTime < currTime) {
times = (UINT32)((currTime - swtmr->startTime) / period);
swtmr->startTime += times * period;
responseTime = swtmr->startTime + period;
PRINT_WARN("Swtmr already timeout! SwtmrID: %u\n", swtmr->usTimerID);
}
AddSwtmr2TimeList(&swtmr->stSortList, responseTime, cpuid);
SwtmrDebugDataUpdate(swtmr, ticks, times);
return responseTime;
}
/*
* Description: Start Software Timer
* Input : swtmr --- Need to start software timer
*/
STATIC INLINE VOID SwtmrStart(SWTMR_CTRL_S *swtmr)
{
UINT64 responseTime;
UINT16 idleCpu = 0;
#ifdef LOSCFG_KERNEL_SMP
FindIdleSwtmrRunqueue(&idleCpu);
#endif
swtmr->startTime = OsGetCurrSchedTimeCycle();
responseTime = SwtmrToStart(swtmr, idleCpu);
SwtmrDebugDataStart(swtmr, idleCpu);
SwtmrAdjustCheck(idleCpu, responseTime);
}
/*
* Description: Delete Software Timer
* Input : swtmr --- Need to delete software timer, When using, Ensure that it can't be NULL.
*/
STATIC INLINE VOID OsSwtmrDelete(SWTMR_CTRL_S *swtmr)
STATIC INLINE VOID SwtmrDelete(SWTMR_CTRL_S *swtmr)
{
/* insert to free list */
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
swtmr->ucState = OS_SWTMR_STATUS_UNUSED;
swtmr->uwOwnerPid = 0;
SwtmrDebugDataClear(swtmr->usTimerID);
}
VOID OsSwtmrWake(SchedRunQue *rq, UINT64 startTime, SortLinkList *sortList)
{
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
LOS_SpinLock(&g_swtmrSpin);
SwtmrHandlerItemPtr swtmrHandler = (SwtmrHandlerItemPtr)LOS_MemboxAlloc(g_swtmrHandlerPool);
if (swtmrHandler != NULL) {
swtmrHandler->handler = swtmr->pfnHandler;
swtmrHandler->arg = swtmr->uwArg;
if (LOS_QueueWrite(rq->swtmrHandlerQueue, swtmrHandler, sizeof(CHAR *), LOS_NO_WAIT)) {
(VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandler);
}
}
if (swtmr->ucMode == LOS_SWTMR_MODE_ONCE) {
OsSwtmrDelete(swtmr);
if (swtmr->usTimerID < (OS_SWTMR_MAX_TIMERID - LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
swtmr->usTimerID += LOSCFG_BASE_CORE_SWTMR_LIMIT;
} else {
swtmr->usTimerID %= LOSCFG_BASE_CORE_SWTMR_LIMIT;
}
} else if (swtmr->ucMode == LOS_SWTMR_MODE_NO_SELFDELETE) {
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
} else {
swtmr->uwOverrun++;
swtmr->startTime = startTime;
OsSwtmrStart(swtmr);
}
LOS_SpinUnlock(&g_swtmrSpin);
}
VOID OsSwtmrRestart(UINT64 startTime, SortLinkList *sortList)
STATIC INLINE VOID SwtmrRestart(UINT64 startTime, SortLinkList *sortList, UINT16 cpuid)
{
UINT32 intSave;
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
SWTMR_LOCK(intSave);
swtmr->startTime = startTime;
OsSwtmrStart(swtmr);
(VOID)SwtmrToStart(swtmr, cpuid);
SWTMR_UNLOCK(intSave);
}
VOID OsSwtmrResponseTimeReset(UINT64 startTime)
{
UINT16 cpuid = ArchCurrCpuid();
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[cpuid].swtmrSortLink;
LOS_DL_LIST *listHead = &swtmrSortLink->sortLink;
LOS_DL_LIST *listNext = listHead->pstNext;
LOS_SpinLock(&swtmrSortLink->spinLock);
while (listNext != listHead) {
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listNext, SortLinkList, sortLinkNode);
OsDeleteNodeSortLink(swtmrSortLink, sortList);
LOS_SpinUnlock(&swtmrSortLink->spinLock);
SwtmrRestart(startTime, sortList, cpuid);
LOS_SpinLock(&swtmrSortLink->spinLock);
listNext = listNext->pstNext;
}
LOS_SpinUnlock(&swtmrSortLink->spinLock);
}
STATIC INLINE BOOL SwtmrRunqueueFind(SortLinkAttribute *swtmrSortLink, SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
{
LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
LOS_DL_LIST *list = listObject->pstNext;
LOS_SpinLock(&swtmrSortLink->spinLock);
while (list != listObject) {
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
if (checkFunc((UINTPTR)listSorted, arg)) {
LOS_SpinUnlock(&swtmrSortLink->spinLock);
return TRUE;
}
list = list->pstNext;
}
LOS_SpinUnlock(&swtmrSortLink->spinLock);
return FALSE;
}
STATIC BOOL SwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
{
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[ArchCurrCpuid()].swtmrSortLink;
if (SwtmrRunqueueFind(swtmrSortLink, checkFunc, arg)) {
return TRUE;
}
}
return FALSE;
}
BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
{
UINT32 intSave;
SWTMR_LOCK(intSave);
BOOL find = OsSchedSwtmrTimeListFind(checkFunc, arg);
BOOL find = SwtmrTimeListFind(checkFunc, arg);
SWTMR_UNLOCK(intSave);
return find;
}
@@ -269,7 +608,8 @@ BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
{
UINT64 currTime = OsGetCurrSchedTimeCycle();
UINT64 time = (OsSortLinkGetNextExpireTime(currTime, &OsSchedRunQue()->swtmrSortLink) / OS_CYCLE_PER_TICK);
SwtmrRunqueue *srq = &g_swtmrRunqueue[ArchCurrCpuid()];
UINT64 time = (OsSortLinkGetNextExpireTime(currTime, &srq->swtmrSortLink) / OS_CYCLE_PER_TICK);
if (time > OS_INVALID_VALUE) {
time = OS_INVALID_VALUE;
}
@@ -278,21 +618,19 @@ LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
/*
* Description: Stop of Software Timer interface
* Input : swtmr --- the software timer contrl handler
* Input : swtmr --- the software timer control handler
*/
LITE_OS_SEC_TEXT STATIC VOID OsSwtmrStop(SWTMR_CTRL_S *swtmr)
STATIC VOID SwtmrStop(SWTMR_CTRL_S *swtmr)
{
OsSchedDeSwtmrFromTimeList(&swtmr->stSortList);
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
swtmr->uwOverrun = 0;
OsSchedUpdateExpireTime();
DeSwtmrFromTimeList(&swtmr->stSortList);
}
/*
* Description: Get next software timer expiretime
* Input : swtmr --- the software timer contrl handler
* Input : swtmr --- the software timer control handler
*/
LITE_OS_SEC_TEXT STATIC UINT32 OsSwtmrTimeGet(const SWTMR_CTRL_S *swtmr)
{
@@ -385,11 +723,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID)
* then start the swtmr again.
*/
case OS_SWTMR_STATUS_TICKING:
OsSwtmrStop(swtmr);
SwtmrStop(swtmr);
/* fall-through */
case OS_SWTMR_STATUS_CREATED:
swtmr->startTime = OsGetCurrSchedTimeCycle();
OsSwtmrStart(swtmr);
SwtmrStart(swtmr);
break;
default:
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;
@@ -429,7 +766,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStop(UINT16 swtmrID)
ret = LOS_ERRNO_SWTMR_NOT_STARTED;
break;
case OS_SWTMR_STATUS_TICKING:
OsSwtmrStop(swtmr);
SwtmrStop(swtmr);
break;
default:
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;
@@ -507,10 +844,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrID)
ret = LOS_ERRNO_SWTMR_NOT_CREATED;
break;
case OS_SWTMR_STATUS_TICKING:
OsSwtmrStop(swtmr);
SwtmrStop(swtmr);
/* fall-through */
case OS_SWTMR_STATUS_CREATED:
OsSwtmrDelete(swtmr);
SwtmrDelete(swtmr);
break;
default:
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;

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:
@@ -90,19 +90,23 @@ VOID OsSetMainTask()
{
UINT32 i;
CHAR *name = "osMain";
SchedParam schedParam = { 0 };
schedParam.policy = LOS_SCHED_RR;
schedParam.basePrio = OS_PROCESS_PRIORITY_HIGHEST;
schedParam.priority = OS_TASK_PRIORITY_LOWEST;
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
g_mainTask[i].taskStatus = OS_TASK_STATUS_UNUSED;
g_mainTask[i].taskID = LOSCFG_BASE_CORE_TSK_LIMIT;
g_mainTask[i].processID = OS_KERNEL_PROCESS_GROUP;
g_mainTask[i].basePrio = OS_TASK_PRIORITY_HIGHEST;
g_mainTask[i].priority = OS_TASK_PRIORITY_LOWEST;
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
g_mainTask[i].lockDep.lockDepth = 0;
g_mainTask[i].lockDep.waitLock = NULL;
#endif
(VOID)strncpy_s(g_mainTask[i].taskName, OS_TCB_NAME_LEN, name, OS_TCB_NAME_LEN - 1);
LOS_ListInit(&g_mainTask[i].lockList);
(VOID)OsSchedParamInit(&g_mainTask[i], schedParam.policy, &schedParam, NULL);
}
}
@@ -120,13 +124,11 @@ VOID OsTaskInsertToRecycleList(LosTaskCB *taskCB)
LITE_OS_SEC_TEXT_INIT VOID OsTaskJoinPostUnsafe(LosTaskCB *taskCB)
{
LosTaskCB *resumedTask = NULL;
if (taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
if (!LOS_ListEmpty(&taskCB->joinList)) {
resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(taskCB->joinList)));
LosTaskCB *resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(taskCB->joinList)));
OsTaskWakeClearPendMask(resumedTask);
OsSchedTaskWake(resumedTask);
resumedTask->ops->wake(resumedTask);
}
}
taskCB->taskStatus |= OS_TASK_STATUS_EXIT;
@@ -144,7 +146,8 @@ LITE_OS_SEC_TEXT UINT32 OsTaskJoinPendUnsafe(LosTaskCB *taskCB)
if ((taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) && LOS_ListEmpty(&taskCB->joinList)) {
OsTaskWaitSetPendMask(OS_TASK_WAIT_JOIN, taskCB->taskID, LOS_WAIT_FOREVER);
return OsSchedTaskWait(&taskCB->joinList, LOS_WAIT_FOREVER, TRUE);
LosTaskCB *runTask = OsCurrTaskGet();
return runTask->ops->wait(runTask, &taskCB->joinList, LOS_WAIT_FOREVER);
}
return LOS_EINVAL;
@@ -203,7 +206,7 @@ EXIT:
UINT32 OsGetIdleTaskId(VOID)
{
return OsSchedGetRunQueIdle();
return OsSchedRunqueueIdleGet();
}
LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
@@ -216,18 +219,21 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsIdleTask;
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE;
taskInitParam.pcName = "Idle";
taskInitParam.policy = LOS_SCHED_IDLE;
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
taskInitParam.processID = OsGetIdleProcessID();
#ifdef LOSCFG_KERNEL_SMP
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
#endif
ret = LOS_TaskCreateOnly(&idleTaskID, &taskInitParam);
if (ret != LOS_OK) {
return ret;
}
LosTaskCB *idleTask = OS_TCB_FROM_TID(idleTaskID);
idleTask->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
OsSchedRunQueIdleInit(idleTaskID);
OsSchedSetIdleTaskSchedParam(idleTask);
OsSchedRunqueueIdleInit(idleTaskID);
return ret;
return LOS_TaskResume(idleTaskID);
}
/*
@@ -277,9 +283,9 @@ STATIC INLINE UINT32 OsTaskSyncWait(const LosTaskCB *taskCB)
/*
* gc soft timer works every OS_MP_GC_PERIOD period, to prevent this timer
* triggered right at the timeout has reached, we set the timeout as double
* of the gc peroid.
* of the gc period.
*/
if (LOS_SemPend(taskCB->syncSignal, OS_MP_GC_PERIOD * 2) != LOS_OK) {
if (LOS_SemPend(taskCB->syncSignal, OS_MP_GC_PERIOD * 2) != LOS_OK) { /* 2: Wait 200 ms */
ret = LOS_ERRNO_TSK_MP_SYNC_FAILED;
}
@@ -369,12 +375,11 @@ STATIC VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
{
LosTaskCB *taskCB = NULL;
UINT32 intSave;
SCHEDULER_LOCK(intSave);
while (!LOS_ListEmpty(&g_taskRecycleList)) {
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecycleList));
LosTaskCB *taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecycleList));
LOS_ListDelete(&taskCB->pendList);
SCHEDULER_UNLOCK(intSave);
@@ -391,8 +396,6 @@ LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
*/
LITE_OS_SEC_TEXT_INIT VOID OsTaskEntry(UINT32 taskID)
{
LosTaskCB *taskCB = NULL;
LOS_ASSERT(!OS_TID_CHECK_INVALID(taskID));
/*
@@ -403,7 +406,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsTaskEntry(UINT32 taskID)
LOS_SpinUnlock(&g_taskSpin);
(VOID)LOS_IntUnLock();
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
taskCB->joinRetval = taskCB->taskEntry(taskCB->args[0], taskCB->args[1],
taskCB->args[2], taskCB->args[3]); /* 2 & 3: just for args array index */
if (!(taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN)) {
@@ -463,10 +466,8 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskStackAlloc(VOID **topStack, UINT32 stack
*topStack = (VOID *)LOS_MemAllocAlign(pool, stackSize, LOSCFG_STACK_POINT_ALIGN_SIZE);
}
LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskCBInitBase(LosTaskCB *taskCB,
const VOID *stackPtr,
const VOID *topStack,
const TSK_INIT_PARAM_S *initParam)
STATIC VOID TaskCBBaseInit(LosTaskCB *taskCB, const VOID *stackPtr, const VOID *topStack,
const TSK_INIT_PARAM_S *initParam)
{
taskCB->stackPointer = (VOID *)stackPtr;
taskCB->args[0] = initParam->auwArgs[0]; /* 0~3: just for args array index */
@@ -475,7 +476,6 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskCBInitBase(LosTaskCB *taskCB,
taskCB->args[3] = initParam->auwArgs[3];
taskCB->topOfStack = (UINTPTR)topStack;
taskCB->stackSize = initParam->uwStackSize;
taskCB->priority = initParam->usTaskPrio;
taskCB->taskEntry = initParam->pfnTaskEntry;
taskCB->signal = SIGNAL_NONE;
@@ -484,7 +484,6 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskCBInitBase(LosTaskCB *taskCB,
taskCB->cpuAffiMask = (initParam->usCpuAffiMask) ?
initParam->usCpuAffiMask : LOSCFG_KERNEL_CPU_MASK;
#endif
taskCB->policy = (initParam->policy == LOS_SCHED_FIFO) ? LOS_SCHED_FIFO : LOS_SCHED_RR;
taskCB->taskStatus = OS_TASK_STATUS_INIT;
if (initParam->uwResved & LOS_TASK_ATTR_JOINABLE) {
taskCB->taskStatus |= OS_TASK_FLAG_PTHREAD_JOIN;
@@ -500,10 +499,13 @@ STATIC UINT32 OsTaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam,
{
UINT32 ret;
UINT32 numCount;
SchedParam schedParam = { 0 };
UINT16 policy = (initParam->policy == LOS_SCHED_NORMAL) ? LOS_SCHED_RR : initParam->policy;
OsTaskCBInitBase(taskCB, stackPtr, topStack, initParam);
TaskCBBaseInit(taskCB, stackPtr, topStack, initParam);
numCount = OsProcessAddNewTask(initParam->processID, taskCB);
schedParam.policy = policy;
numCount = OsProcessAddNewTask(initParam->processID, taskCB, &schedParam);
#ifdef LOSCFG_KERNEL_VM
taskCB->futex.index = OS_INVALID_VALUE;
if (taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) {
@@ -514,6 +516,11 @@ STATIC UINT32 OsTaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam,
}
#endif
ret = OsSchedParamInit(taskCB, policy, &schedParam, initParam);
if (ret != LOS_OK) {
return ret;
}
if (initParam->pcName != NULL) {
ret = (UINT32)OsSetTaskName(taskCB, initParam->pcName, FALSE);
if (ret == LOS_OK) {
@@ -530,7 +537,6 @@ STATIC UINT32 OsTaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam,
LITE_OS_SEC_TEXT LosTaskCB *OsGetFreeTaskCB(VOID)
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
SCHEDULER_LOCK(intSave);
if (LOS_ListEmpty(&g_losFreeTask)) {
@@ -539,7 +545,7 @@ LITE_OS_SEC_TEXT LosTaskCB *OsGetFreeTaskCB(VOID)
return NULL;
}
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_losFreeTask));
LosTaskCB *taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_losFreeTask));
LOS_ListDelete(LOS_DL_LIST_FIRST(&g_losFreeTask));
SCHEDULER_UNLOCK(intSave);
@@ -550,8 +556,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
{
UINT32 intSave, errRet;
VOID *topStack = NULL;
VOID *stackPtr = NULL;
LosTaskCB *taskCB = NULL;
VOID *pool = NULL;
errRet = OsTaskCreateParamCheck(taskID, initParam, &pool);
@@ -559,7 +563,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
return errRet;
}
taskCB = OsGetFreeTaskCB();
LosTaskCB *taskCB = OsGetFreeTaskCB();
if (taskCB == NULL) {
errRet = LOS_ERRNO_TSK_TCB_UNAVAILABLE;
goto LOS_ERREND;
@@ -576,7 +580,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
goto LOS_ERREND_REWIND_SYNC;
}
stackPtr = OsTaskStackInit(taskCB->taskID, initParam->uwStackSize, topStack, TRUE);
VOID *stackPtr = OsTaskStackInit(taskCB->taskID, initParam->uwStackSize, topStack, TRUE);
errRet = OsTaskCBInit(taskCB, initParam, stackPtr, topStack);
if (errRet != LOS_OK) {
goto LOS_ERREND_TCB_INIT;
@@ -630,7 +634,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *in
LosTaskCB *taskCB = OS_TCB_FROM_TID(*taskID);
SCHEDULER_LOCK(intSave);
OsSchedTaskEnQueue(taskCB);
taskCB->ops->enqueue(OsSchedRunqueue(), taskCB);
SCHEDULER_UNLOCK(intSave);
/* in case created task not running on this core,
@@ -647,13 +651,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
{
UINT32 intSave;
UINT32 errRet;
LosTaskCB *taskCB = NULL;
BOOL needSched = FALSE;
if (OS_TID_CHECK_INVALID(taskID)) {
return LOS_ERRNO_TSK_ID_INVALID;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
/* clear pending signal */
@@ -667,7 +671,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
OS_GOTO_ERREND();
}
BOOL needSched = OsSchedResume(taskCB);
errRet = taskCB->ops->resume(taskCB, &needSched);
SCHEDULER_UNLOCK(intSave);
LOS_MpSchedule(OS_MP_CPU_ALL);
@@ -675,7 +679,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
LOS_Schedule();
}
return LOS_OK;
return errRet;
LOS_ERREND:
SCHEDULER_UNLOCK(intSave);
@@ -723,9 +727,7 @@ LITE_OS_SEC_TEXT_INIT STATIC BOOL OsTaskSuspendCheckOnRun(LosTaskCB *taskCB, UIN
LITE_OS_SEC_TEXT STATIC UINT32 OsTaskSuspend(LosTaskCB *taskCB)
{
UINT32 errRet;
UINT16 tempStatus;
tempStatus = taskCB->taskStatus;
UINT16 tempStatus = taskCB->taskStatus;
if (tempStatus & OS_TASK_STATUS_UNUSED) {
return LOS_ERRNO_TSK_NOT_CREATED;
}
@@ -739,21 +741,19 @@ LITE_OS_SEC_TEXT STATIC UINT32 OsTaskSuspend(LosTaskCB *taskCB)
return errRet;
}
OsSchedSuspend(taskCB);
return LOS_OK;
return taskCB->ops->suspend(taskCB);
}
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskSuspend(UINT32 taskID)
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
UINT32 errRet;
if (OS_TID_CHECK_INVALID(taskID)) {
return LOS_ERRNO_TSK_ID_INVALID;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
if (taskCB->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
}
@@ -842,11 +842,11 @@ LITE_OS_SEC_TEXT VOID OsInactiveTaskDelete(LosTaskCB *taskCB)
OsTaskReleaseHoldLock(taskCB);
OsSchedTaskExit(taskCB);
taskCB->ops->exit(taskCB);
if (taskStatus & OS_TASK_STATUS_PENDING) {
LosMux *mux = (LosMux *)taskCB->taskMux;
if (LOS_MuxIsValid(mux) == TRUE) {
OsMuxBitmapRestore(mux, taskCB, (LosTaskCB *)mux->owner);
OsMuxBitmapRestore(mux, NULL, taskCB);
}
}
@@ -872,6 +872,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
if (taskCB == OsCurrTaskGet()) {
if (!OsPreemptable()) {
return LOS_ERRNO_TSK_DELETE_LOCKED;
}
OsRunningTaskToExit(taskCB, OS_PRO_EXIT_OK);
return LOS_NOK;
}
@@ -900,20 +904,22 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
LOS_ERREND:
SCHEDULER_UNLOCK(intSave);
if (ret == LOS_OK) {
LOS_Schedule();
}
return ret;
}
LITE_OS_SEC_TEXT UINT32 LOS_TaskDelay(UINT32 tick)
{
UINT32 intSave;
LosTaskCB *runTask = NULL;
if (OS_INT_ACTIVE) {
PRINT_ERR("In interrupt not allow delay task!\n");
return LOS_ERRNO_TSK_DELAY_IN_INT;
}
runTask = OsCurrTaskGet();
LosTaskCB *runTask = OsCurrTaskGet();
if (runTask->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
OsBackTrace();
return LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
@@ -928,39 +934,37 @@ LITE_OS_SEC_TEXT UINT32 LOS_TaskDelay(UINT32 tick)
}
SCHEDULER_LOCK(intSave);
OsSchedDelay(runTask, tick);
UINT32 ret = runTask->ops->delay(runTask, OS_SCHED_TICK_TO_CYCLE(tick));
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTODELAYEDLIST, runTask);
SCHEDULER_UNLOCK(intSave);
return LOS_OK;
return ret;
}
LITE_OS_SEC_TEXT_MINOR UINT16 LOS_TaskPriGet(UINT32 taskID)
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
UINT16 priority;
SchedParam param = { 0 };
if (OS_TID_CHECK_INVALID(taskID)) {
return (UINT16)OS_INVALID;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
SCHEDULER_UNLOCK(intSave);
return (UINT16)OS_INVALID;
}
priority = taskCB->priority;
taskCB->ops->schedParamGet(taskCB, &param);
SCHEDULER_UNLOCK(intSave);
return priority;
return param.priority;
}
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskPriSet(UINT32 taskID, UINT16 taskPrio)
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
SchedParam param = { 0 };
if (taskPrio > OS_TASK_PRIORITY_LOWEST) {
return LOS_ERRNO_TSK_PRIOR_ERROR;
@@ -970,7 +974,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskPriSet(UINT32 taskID, UINT16 taskPrio)
return LOS_ERRNO_TSK_ID_INVALID;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
if (taskCB->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
}
@@ -981,11 +985,15 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskPriSet(UINT32 taskID, UINT16 taskPrio)
return LOS_ERRNO_TSK_NOT_CREATED;
}
BOOL isReady = OsSchedModifyTaskSchedParam(taskCB, taskCB->policy, taskPrio);
taskCB->ops->schedParamGet(taskCB, &param);
param.priority = taskPrio;
BOOL needSched = taskCB->ops->schedParamModify(taskCB, &param);
SCHEDULER_UNLOCK(intSave);
LOS_MpSchedule(OS_MP_CPU_ALL);
if (isReady && OS_SCHEDULER_ACTIVE) {
if (needSched && OS_SCHEDULER_ACTIVE) {
LOS_Schedule();
}
return LOS_OK;
@@ -1015,7 +1023,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskYield(VOID)
SCHEDULER_LOCK(intSave);
/* reset timeslice of yielded task */
OsSchedYield();
runTask->ops->yield(runTask);
SCHEDULER_UNLOCK(intSave);
return LOS_OK;
}
@@ -1045,7 +1053,7 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_TaskUnlock(VOID)
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInfo)
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
SchedParam param = { 0 };
if (taskInfo == NULL) {
return LOS_ERRNO_TSK_PTR_NULL;
@@ -1055,7 +1063,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInf
return LOS_ERRNO_TSK_ID_INVALID;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
SCHEDULER_UNLOCK(intSave);
@@ -1068,8 +1076,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInf
taskInfo->uwSP = ArchSPGet();
}
taskCB->ops->schedParamGet(taskCB, &param);
taskInfo->usTaskStatus = taskCB->taskStatus;
taskInfo->usTaskPrio = taskCB->priority;
taskInfo->usTaskPrio = param.priority;
taskInfo->uwStackSize = taskCB->stackSize;
taskInfo->uwTopOfStack = taskCB->topOfStack;
taskInfo->uwEventMask = taskCB->eventMask;
@@ -1113,7 +1122,6 @@ LITE_OS_SEC_TEXT BOOL OsTaskCpuAffiSetUnsafe(UINT32 taskID, UINT16 newCpuAffiMas
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuAffiSet(UINT32 taskID, UINT16 cpuAffiMask)
{
LosTaskCB *taskCB = NULL;
BOOL needSched = FALSE;
UINT32 intSave;
UINT16 currCpuMask;
@@ -1126,7 +1134,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuAffiSet(UINT32 taskID, UINT16 cpuAffiMa
return LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
SCHEDULER_UNLOCK(intSave);
@@ -1147,7 +1155,6 @@ LITE_OS_SEC_TEXT_MINOR UINT16 LOS_TaskCpuAffiGet(UINT32 taskID)
{
#ifdef LOSCFG_KERNEL_SMP
#define INVALID_CPU_AFFI_MASK 0
LosTaskCB *taskCB = NULL;
UINT16 cpuAffiMask;
UINT32 intSave;
@@ -1155,7 +1162,7 @@ LITE_OS_SEC_TEXT_MINOR UINT16 LOS_TaskCpuAffiGet(UINT32 taskID)
return INVALID_CPU_AFFI_MASK;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
SCHEDULER_UNLOCK(intSave);
@@ -1208,7 +1215,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTaskProcSignal(VOID)
} else if (runTask->signal & SIGNAL_AFFI) {
runTask->signal &= ~SIGNAL_AFFI;
/* pri-queue has updated, notify the target cpu */
/* priority queue has updated, notify the target cpu */
LOS_MpSchedule((UINT32)runTask->cpuAffiMask);
#endif
}
@@ -1257,19 +1264,19 @@ EXIT:
return err;
}
UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB)
INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB)
{
return OsUserProcessOperatePermissionsCheck(taskCB, OsCurrProcessGet()->processID);
}
UINT32 OsUserProcessOperatePermissionsCheck(LosTaskCB *taskCB, UINT32 processID)
INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINT32 processID)
{
if (taskCB == NULL) {
return LOS_EINVAL;
}
if (processID == OS_INVALID_VALUE) {
return OS_INVALID_VALUE;
return LOS_EINVAL;
}
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
@@ -1347,21 +1354,22 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S
LITE_OS_SEC_TEXT INT32 LOS_GetTaskScheduler(INT32 taskID)
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
INT32 policy;
SchedParam param = { 0 };
if (OS_TID_CHECK_INVALID(taskID)) {
return -LOS_EINVAL;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
policy = -LOS_EINVAL;
OS_GOTO_ERREND();
}
policy = taskCB->policy;
taskCB->ops->schedParamGet(taskCB, &param);
policy = (INT32)param.policy;
LOS_ERREND:
SCHEDULER_UNLOCK(intSave);
@@ -1370,8 +1378,8 @@ LOS_ERREND:
LITE_OS_SEC_TEXT INT32 LOS_SetTaskScheduler(INT32 taskID, UINT16 policy, UINT16 priority)
{
SchedParam param = { 0 };
UINT32 intSave;
BOOL needSched = FALSE;
if (OS_TID_CHECK_INVALID(taskID)) {
return LOS_ESRCH;
@@ -1385,8 +1393,21 @@ LITE_OS_SEC_TEXT INT32 LOS_SetTaskScheduler(INT32 taskID, UINT16 policy, UINT16
return LOS_EINVAL;
}
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
if (taskCB->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_EPERM;
}
SCHEDULER_LOCK(intSave);
needSched = OsSchedModifyTaskSchedParam(OS_TCB_FROM_TID(taskID), policy, priority);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
SCHEDULER_UNLOCK(intSave);
return LOS_EINVAL;
}
taskCB->ops->schedParamGet(taskCB, &param);
param.policy = policy;
param.priority = priority;
BOOL needSched = taskCB->ops->schedParamModify(taskCB, &param);
SCHEDULER_UNLOCK(intSave);
LOS_MpSchedule(OS_MP_CPU_ALL);
@@ -1411,9 +1432,15 @@ STATIC UINT32 OsTaskJoinCheck(UINT32 taskID)
return LOS_EINVAL;
}
if (taskID == OsCurrTaskGet()->taskID) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
if (taskCB->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
return LOS_EPERM;
}
if (taskCB == OsCurrTaskGet()) {
return LOS_EDEADLK;
}
return LOS_OK;
}
@@ -1421,7 +1448,6 @@ UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval)
{
UINT32 intSave;
LosTaskCB *runTask = OsCurrTaskGet();
LosTaskCB *taskCB = NULL;
UINT32 errRet;
errRet = OsTaskJoinCheck(taskID);
@@ -1429,7 +1455,7 @@ UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval)
return errRet;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
SCHEDULER_UNLOCK(intSave);
@@ -1462,7 +1488,6 @@ UINT32 LOS_TaskDetach(UINT32 taskID)
{
UINT32 intSave;
LosTaskCB *runTask = OsCurrTaskGet();
LosTaskCB *taskCB = NULL;
UINT32 errRet;
if (OS_TID_CHECK_INVALID(taskID)) {
@@ -1473,7 +1498,7 @@ UINT32 LOS_TaskDetach(UINT32 taskID)
return LOS_EINTR;
}
taskCB = OS_TCB_FROM_TID(taskID);
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
SCHEDULER_LOCK(intSave);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
SCHEDULER_UNLOCK(intSave);

View File

@@ -54,7 +54,7 @@ extern BOOL OsMemIsHeapNode(const VOID *ptr);
extern UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[]);
/* memory expand size at least 1/8 of pool size if we can */
#define MEM_EXPAND_SIZE(poolSize) (poolSize >> 3)
#define MEM_EXPAND_SIZE(poolSize) ((poolSize) >> 3)
#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:
@@ -43,7 +43,7 @@ extern "C" {
#define OS_MUX_MAGIC 0xEBCFDEA0
extern VOID OsMuxBitmapRestore(const LosMux *mutex, const LosTaskCB *taskCB, LosTaskCB *owner);
extern VOID OsMuxBitmapRestore(const LosMux *mutex, const LOS_DL_LIST *list, const LosTaskCB *runTask);
extern UINT32 OsMuxLockUnsafe(LosMux *mutex, UINT32 timeout);
extern UINT32 OsMuxTrylockUnsafe(LosMux *mutex, UINT32 timeout);
extern UINT32 OsMuxUnlockUnsafe(LosTaskCB *taskCB, LosMux *mutex, BOOL *needSched);

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:
@@ -295,11 +295,6 @@ STATIC INLINE BOOL OsProcessIsUserMode(const LosProcessCB *processCB)
return (processCB->processMode == OS_USER_MODE);
}
#define LOS_SCHED_NORMAL 0U
#define LOS_SCHED_FIFO 1U
#define LOS_SCHED_RR 2U
#define LOS_SCHED_IDLE 3U
#define LOS_PRIO_PROCESS 0U
#define LOS_PRIO_PGRP 1U
#define LOS_PRIO_USER 2U
@@ -488,7 +483,7 @@ extern UINTPTR OsGetSigHandler(VOID);
extern VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID);
extern INT32 OsSendSignalToProcessGroup(INT32 pid, siginfo_t *info, INT32 permission);
extern INT32 OsSendSignalToAllProcess(siginfo_t *info, INT32 permission);
extern UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB);
extern UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB, SchedParam *param);
extern VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB);
extern VOID OsProcessThreadGroupDestroy(VOID);

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-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:
@@ -41,7 +41,7 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define OS_RWLOCK_MAGIC 0xBEFDCAU
#define OS_RWLOCK_MAGIC 0xEFDCAU
enum RwlockMode {
RWLOCK_NONE_MODE,

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:
@@ -37,10 +37,13 @@
#include "los_hwi.h"
#include "hal_timer.h"
#ifdef LOSCFG_SCHED_DEBUG
#include "los_stat_pri.h"
#include "los_statistics_pri.h"
#endif
#include "los_stackinfo_pri.h"
#include "los_futex_pri.h"
#ifdef LOSCFG_KERNEL_PM
#include "los_pm_pri.h"
#endif
#include "los_signal.h"
#ifdef LOSCFG_KERNEL_CPUP
#include "los_cpup_pri.h"
@@ -48,6 +51,7 @@
#ifdef LOSCFG_KERNEL_LITEIPC
#include "hm_liteipc.h"
#endif
#include "los_mp.h"
#ifdef __cplusplus
#if __cplusplus
@@ -55,14 +59,17 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define OS_SCHED_MINI_PERIOD (OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
#define OS_SCHED_MAX_RESPONSE_TIME (UINT64)(((UINT64)-1) - 1U)
#define OS_SCHED_MINI_PERIOD (OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
#define OS_SCHED_MAX_RESPONSE_TIME OS_SORT_LINK_INVALID_TIME
#define OS_SCHED_TICK_TO_CYCLE(ticks) ((UINT64)ticks * OS_CYCLE_PER_TICK)
#define AFFI_MASK_TO_CPUID(mask) ((UINT16)((mask) - 1))
extern UINT32 g_taskScheduled;
#define OS_SCHEDULER_ACTIVE (g_taskScheduled & (1U << ArchCurrCpuid()))
#define OS_SCHEDULER_ALL_ACTIVE (g_taskScheduled == LOSCFG_KERNEL_CPU_MASK)
typedef struct TagTaskCB LosTaskCB;
typedef BOOL (*SCHED_TL_FIND_FUNC)(UINTPTR, UINTPTR);
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
@@ -76,53 +83,65 @@ typedef enum {
INT_PEND_TICK = 0x2, /* pending tick */
} SchedFlag;
#define OS_PRIORITY_QUEUE_NUM 32
typedef struct {
SortLinkAttribute taskSortLink; /* task sort link */
SortLinkAttribute swtmrSortLink; /* swtmr sort link */
UINT64 responseTime; /* Response time for current CPU tick interrupts */
UINT32 responseID; /* The response ID of the current CPU tick interrupt */
UINT32 idleTaskID; /* idle task id */
UINT32 taskLockCnt; /* task lock flag */
UINT32 swtmrTaskID; /* software timer task id */
UINT32 swtmrHandlerQueue; /* software timer timeout queue id */
UINT32 schedFlag; /* pending scheduler flag */
} SchedRunQue;
LOS_DL_LIST priQueList[OS_PRIORITY_QUEUE_NUM];
UINT32 readyTasks[OS_PRIORITY_QUEUE_NUM];
UINT32 queueBitmap;
} HPFQueue;
extern SchedRunQue g_schedRunQue[LOSCFG_KERNEL_CORE_NUM];
typedef struct {
HPFQueue queueList[OS_PRIORITY_QUEUE_NUM];
UINT32 queueBitmap;
} HPFRunqueue;
STATIC INLINE SchedRunQue *OsSchedRunQue(VOID)
typedef struct {
SortLinkAttribute timeoutQueue; /* task timeout queue */
HPFRunqueue *hpfRunqueue;
UINT64 responseTime; /* Response time for current CPU tick interrupts */
UINT32 responseID; /* The response ID of the current CPU tick interrupt */
UINT32 idleTaskID; /* idle task id */
UINT32 taskLockCnt; /* task lock flag */
UINT32 schedFlag; /* pending scheduler flag */
} SchedRunqueue;
extern SchedRunqueue g_schedRunqueue[LOSCFG_KERNEL_CORE_NUM];
VOID OsSchedExpireTimeUpdate(VOID);
STATIC INLINE SchedRunqueue *OsSchedRunqueue(VOID)
{
return &g_schedRunQue[ArchCurrCpuid()];
return &g_schedRunqueue[ArchCurrCpuid()];
}
STATIC INLINE SchedRunQue *OsSchedRunQueByID(UINT16 id)
STATIC INLINE SchedRunqueue *OsSchedRunqueueByID(UINT16 id)
{
return &g_schedRunQue[id];
return &g_schedRunqueue[id];
}
STATIC INLINE UINT32 OsSchedLockCountGet(VOID)
{
return OsSchedRunQue()->taskLockCnt;
return OsSchedRunqueue()->taskLockCnt;
}
STATIC INLINE VOID OsSchedLockSet(UINT32 count)
{
OsSchedRunQue()->taskLockCnt = count;
OsSchedRunqueue()->taskLockCnt = count;
}
STATIC INLINE VOID OsSchedLock(VOID)
{
OsSchedRunQue()->taskLockCnt++;
OsSchedRunqueue()->taskLockCnt++;
}
STATIC INLINE VOID OsSchedUnlock(VOID)
{
OsSchedRunQue()->taskLockCnt--;
OsSchedRunqueue()->taskLockCnt--;
}
STATIC INLINE BOOL OsSchedUnlockResch(VOID)
{
SchedRunQue *rq = OsSchedRunQue();
SchedRunqueue *rq = OsSchedRunqueue();
if (rq->taskLockCnt > 0) {
rq->taskLockCnt--;
if ((rq->taskLockCnt == 0) && (rq->schedFlag & INT_PEND_RESCH) && OS_SCHEDULER_ACTIVE) {
@@ -135,130 +154,106 @@ STATIC INLINE BOOL OsSchedUnlockResch(VOID)
STATIC INLINE BOOL OsSchedIsLock(VOID)
{
return (OsSchedRunQue()->taskLockCnt != 0);
return (OsSchedRunqueue()->taskLockCnt != 0);
}
/* Check if preemptable with counter flag */
/* Check if preemptible with counter flag */
STATIC INLINE BOOL OsPreemptable(VOID)
{
SchedRunQue *rq = OsSchedRunQue();
SchedRunqueue *rq = OsSchedRunqueue();
/*
* Unlike OsPreemptableInSched, the int may be not disabled when OsPreemptable
* is called, needs mannually disable interrupt, to prevent current task from
* being migrated to another core, and get the wrong preeptable status.
* is called, needs manually disable interrupt, to prevent current task from
* being migrated to another core, and get the wrong preemptable status.
*/
UINT32 intSave = LOS_IntLock();
BOOL preemptable = (rq->taskLockCnt == 0);
if (!preemptable) {
BOOL preemptible = (rq->taskLockCnt == 0);
if (!preemptible) {
/* Set schedule flag if preemption is disabled */
rq->schedFlag |= INT_PEND_RESCH;
}
LOS_IntRestore(intSave);
return preemptable;
return preemptible;
}
STATIC INLINE BOOL OsPreemptableInSched(VOID)
{
BOOL preemptable = FALSE;
SchedRunQue *rq = OsSchedRunQue();
BOOL preemptible = FALSE;
SchedRunqueue *rq = OsSchedRunqueue();
#ifdef LOSCFG_KERNEL_SMP
/*
* For smp systems, schedule must hold the task spinlock, and this counter
* will increase by 1 in that case.
*/
preemptable = (rq->taskLockCnt == 1);
preemptible = (rq->taskLockCnt == 1);
#else
preemptable = (rq->taskLockCnt == 0);
preemptible = (rq->taskLockCnt == 0);
#endif
if (!preemptable) {
if (!preemptible) {
/* Set schedule flag if preemption is disabled */
rq->schedFlag |= INT_PEND_RESCH;
}
return preemptable;
return preemptible;
}
STATIC INLINE UINT32 OsSchedGetRunQueIdle(VOID)
STATIC INLINE UINT32 OsSchedRunqueueIdleGet(VOID)
{
return OsSchedRunQue()->idleTaskID;
return OsSchedRunqueue()->idleTaskID;
}
STATIC INLINE VOID OsSchedRunQuePendingSet(VOID)
STATIC INLINE VOID OsSchedRunqueuePendingSet(VOID)
{
OsSchedRunQue()->schedFlag |= INT_PEND_RESCH;
OsSchedRunqueue()->schedFlag |= INT_PEND_RESCH;
}
#ifdef LOSCFG_KERNEL_SMP
STATIC INLINE VOID FindIdleRunQue(UINT16 *idleCpuID)
{
SchedRunQue *idleRq = OsSchedRunQueByID(0);
UINT32 nodeNum = OsGetSortLinkNodeNum(&idleRq->taskSortLink) + OsGetSortLinkNodeNum(&idleRq->swtmrSortLink);
UINT16 cpuID = 1;
do {
SchedRunQue *rq = OsSchedRunQueByID(cpuID);
UINT32 temp = OsGetSortLinkNodeNum(&rq->taskSortLink) + OsGetSortLinkNodeNum(&rq->swtmrSortLink);
if (nodeNum > temp) {
*idleCpuID = cpuID;
nodeNum = temp;
}
cpuID++;
} while (cpuID < LOSCFG_KERNEL_CORE_NUM);
}
#endif
#define LOS_SCHED_NORMAL 0U
#define LOS_SCHED_FIFO 1U
#define LOS_SCHED_RR 2U
#define LOS_SCHED_IDLE 3U
STATIC INLINE VOID OsSchedAddTask2TimeList(SortLinkList *node, UINT64 startTime, UINT32 waitTicks)
{
UINT16 idleCpu = 0;
#ifdef LOSCFG_KERNEL_SMP
FindIdleRunQue(&idleCpu);
#endif
SchedRunQue *rq = OsSchedRunQueByID(idleCpu);
UINT64 responseTime = startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK;
OsAdd2SortLink(&rq->taskSortLink, node, responseTime, idleCpu);
}
typedef struct {
UINT16 policy;
UINT16 basePrio;
UINT16 priority;
UINT32 timeSlice;
} SchedParam;
STATIC INLINE UINT32 OsSchedSwtmrHandlerQueueGet(VOID)
{
return OsSchedRunQue()->swtmrHandlerQueue;
}
typedef struct {
UINT16 policy; /* This field must be present for all scheduling policies and must be the first in the structure */
UINT16 basePrio;
UINT16 priority;
UINT32 initTimeSlice;
UINT32 priBitmap; /**< Bitmap for recording the change of task priority, the priority can not be greater than 31 */
} SchedHPF;
STATIC INLINE VOID OsSchedDeTaskFromTimeList(SortLinkList *node)
{
#ifdef LOSCFG_KERNEL_SMP
SchedRunQue *rq = OsSchedRunQueByID(node->cpuid);
#else
SchedRunQue *rq = OsSchedRunQueByID(0);
#endif
OsDeleteFromSortLink(&rq->taskSortLink, node);
}
typedef struct {
union {
SchedHPF hpf;
} Policy;
} SchedPolicy;
STATIC INLINE VOID OsSchedAddSwtmr2TimeList(SortLinkList *node, UINT64 startTime, UINT32 waitTicks)
{
UINT16 idleCpu = 0;
#ifdef LOSCFG_KERNEL_SMP
FindIdleRunQue(&idleCpu);
#endif
SchedRunQue *rq = OsSchedRunQueByID(idleCpu);
UINT64 responseTime = startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK;
OsAdd2SortLink(&rq->swtmrSortLink, node, responseTime, idleCpu);
}
STATIC INLINE VOID OsSchedDeSwtmrFromTimeList(SortLinkList *node)
{
#ifdef LOSCFG_KERNEL_SMP
SchedRunQue *rq = OsSchedRunQueByID(node->cpuid);
#else
SchedRunQue *rq = OsSchedRunQueByID(0);
#endif
OsDeleteFromSortLink(&rq->swtmrSortLink, node);
}
VOID OsSchedRunQueIdleInit(UINT32 idleTaskID);
VOID OsSchedRunQueSwtmrInit(UINT32 swtmrTaskID, UINT32 swtmrQueue);
VOID OsSchedRunQueInit(VOID);
BOOL OsSchedSwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
typedef struct {
VOID (*dequeue)(SchedRunqueue *rq, LosTaskCB *taskCB);
VOID (*enqueue)(SchedRunqueue *rq, LosTaskCB *taskCB);
VOID (*start)(SchedRunqueue *rq, LosTaskCB *taskCB);
VOID (*exit)(LosTaskCB *taskCB);
UINT32 (*wait)(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 timeout);
VOID (*wake)(LosTaskCB *taskCB);
BOOL (*schedParamModify)(LosTaskCB *taskCB, const SchedParam *param);
UINT32 (*schedParamGet)(const LosTaskCB *taskCB, SchedParam *param);
UINT32 (*delay)(LosTaskCB *taskCB, UINT64 waitTime);
VOID (*yield)(LosTaskCB *taskCB);
UINT32 (*suspend)(LosTaskCB *taskCB);
UINT32 (*resume)(LosTaskCB *taskCB, BOOL *needSched);
UINT64 (*deadlineGet)(const LosTaskCB *taskCB);
VOID (*timeSliceUpdate)(SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 currTime);
INT32 (*schedParamCompare)(const SchedPolicy *sp1, const SchedPolicy *sp2);
VOID (*priorityInheritance)(LosTaskCB *owner, const SchedParam *param);
VOID (*priorityRestore)(LosTaskCB *owner, const LOS_DL_LIST *list, const SchedParam *param);
} SchedOps;
/**
* @ingroup los_sched
@@ -348,23 +343,31 @@ BOOL OsSchedSwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
*/
#define OS_TASK_STATUS_EXIT 0x0100U
#define OS_TASK_STATUS_BLOCKED (OS_TASK_STATUS_INIT | OS_TASK_STATUS_PENDING | \
OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME)
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
*
* The delayed operation of this task is frozen.
*/
#define OS_TASK_STATUS_FROZEN 0x0200U
#define OS_TCB_NAME_LEN 32
typedef struct {
typedef struct TagTaskCB {
VOID *stackPointer; /**< Task stack pointer */
UINT16 taskStatus; /**< Task status */
/* The scheduling */
UINT16 basePrio;
UINT16 priority; /**< Task priority */
UINT16 policy;
UINT64 startTime; /**< The start time of each phase of task */
UINT64 waitTime; /**< Task delay time, tick number */
UINT64 irqStartTime; /**< Interrupt start time */
UINT32 irqUsedTime; /**< Interrupt consumption time */
UINT32 initTimeSlice; /**< Task init time slice */
INT32 timeSlice; /**< Task remaining time slice */
UINT32 waitTimes; /**< Task delay time, tick number */
SortLinkList sortList; /**< Task sortlink node */
const SchedOps *ops;
SchedPolicy sp;
UINT32 stackSize; /**< Task stack size */
UINTPTR topOfStack; /**< Task stack top */
@@ -379,8 +382,6 @@ typedef struct {
LOS_DL_LIST threadList; /**< thread list */
UINT32 eventMask; /**< Event mask */
UINT32 eventMode; /**< Event mode */
UINT32 priBitMap; /**< BitMap for recording the change of task priority,
the priority can not be greater than 31 */
#ifdef LOSCFG_KERNEL_CPUP
OsCpupBase taskCpup; /**< task cpu usage */
#endif
@@ -468,7 +469,7 @@ STATIC INLINE VOID OsCurrUserTaskSet(UINTPTR thread)
ArchCurrUserTaskSet(thread);
}
STATIC INLINE VOID OsSchedIrqUpdateUsedTime(VOID)
STATIC INLINE VOID OsSchedIrqUsedTimeUpdate(VOID)
{
LosTaskCB *runTask = OsCurrTaskGet();
runTask->irqUsedTime = OsGetCurrSchedTimeCycle() - runTask->irqStartTime;
@@ -480,6 +481,123 @@ STATIC INLINE VOID OsSchedIrqStartTime(VOID)
runTask->irqStartTime = OsGetCurrSchedTimeCycle();
}
#ifdef LOSCFG_KERNEL_SMP
STATIC INLINE VOID IdleRunqueueFind(UINT16 *idleCpuid)
{
SchedRunqueue *idleRq = OsSchedRunqueueByID(0);
UINT32 nodeNum = OsGetSortLinkNodeNum(&idleRq->timeoutQueue);
UINT16 cpuid = 1;
do {
SchedRunqueue *rq = OsSchedRunqueueByID(cpuid);
UINT32 temp = OsGetSortLinkNodeNum(&rq->timeoutQueue);
if (nodeNum > temp) {
*idleCpuid = cpuid;
nodeNum = temp;
}
cpuid++;
} while (cpuid < LOSCFG_KERNEL_CORE_NUM);
}
#endif
STATIC INLINE VOID OsSchedTimeoutQueueAdd(LosTaskCB *taskCB, UINT64 responseTime)
{
#ifdef LOSCFG_KERNEL_SMP
UINT16 cpuid = AFFI_MASK_TO_CPUID(taskCB->cpuAffiMask);
if (cpuid >= LOSCFG_KERNEL_CORE_NUM) {
cpuid = 0;
IdleRunqueueFind(&cpuid);
}
#else
UINT16 cpuid = 0;
#endif
SchedRunqueue *rq = OsSchedRunqueueByID(cpuid);
OsAdd2SortLink(&rq->timeoutQueue, &taskCB->sortList, responseTime, cpuid);
#ifdef LOSCFG_KERNEL_SMP
if ((cpuid != ArchCurrCpuid()) && (responseTime < rq->responseTime)) {
rq->schedFlag |= INT_PEND_TICK;
LOS_MpSchedule(CPUID_TO_AFFI_MASK(cpuid));
}
#endif
}
STATIC INLINE VOID OsSchedTimeoutQueueDelete(LosTaskCB *taskCB)
{
SortLinkList *node = &taskCB->sortList;
#ifdef LOSCFG_KERNEL_SMP
SchedRunqueue *rq = OsSchedRunqueueByID(node->cpuid);
#else
SchedRunqueue *rq = OsSchedRunqueueByID(0);
#endif
UINT64 oldResponseTime = GET_SORTLIST_VALUE(node);
OsDeleteFromSortLink(&rq->timeoutQueue, node);
if (oldResponseTime <= rq->responseTime) {
rq->responseTime = OS_SCHED_MAX_RESPONSE_TIME;
}
}
STATIC INLINE UINT32 OsSchedTimeoutQueueAdjust(LosTaskCB *taskCB, UINT64 responseTime)
{
UINT32 ret;
SortLinkList *node = &taskCB->sortList;
#ifdef LOSCFG_KERNEL_SMP
UINT16 cpuid = node->cpuid;
#else
UINT16 cpuid = 0;
#endif
SchedRunqueue *rq = OsSchedRunqueueByID(cpuid);
ret = OsSortLinkAdjustNodeResponseTime(&rq->timeoutQueue, node, responseTime);
if (ret == LOS_OK) {
rq->schedFlag |= INT_PEND_TICK;
}
return ret;
}
STATIC INLINE VOID SchedTaskFreeze(LosTaskCB *taskCB)
{
UINT64 responseTime;
#ifdef LOSCFG_KERNEL_PM
if (!OsIsPmMode()) {
return;
}
#endif
if (!(taskCB->taskStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY))) {
return;
}
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
OsSchedTimeoutQueueDelete(taskCB);
SET_SORTLIST_VALUE(&taskCB->sortList, responseTime);
taskCB->taskStatus |= OS_TASK_STATUS_FROZEN;
return;
}
STATIC INLINE VOID SchedTaskUnfreeze(LosTaskCB *taskCB)
{
UINT64 currTime, responseTime;
if (!(taskCB->taskStatus & OS_TASK_STATUS_FROZEN)) {
return;
}
taskCB->taskStatus &= ~OS_TASK_STATUS_FROZEN;
currTime = OsGetCurrSchedTimeCycle();
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
if (responseTime > currTime) {
OsSchedTimeoutQueueAdd(taskCB, responseTime);
return;
}
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
if (taskCB->taskStatus & OS_TASK_STATUS_PENDING) {
LOS_ListDelete(&taskCB->pendList);
}
taskCB->taskStatus &= ~OS_TASK_STATUS_BLOCKED;
return;
}
/*
* Schedule flag, one bit represents one core.
* This flag is used to prevent kernel scheduling before OSStartToRun.
@@ -492,25 +610,59 @@ STATIC INLINE VOID OsSchedIrqStartTime(VOID)
g_taskScheduled &= ~(1U << (cpuid)); \
} while (0);
VOID OsSchedSetIdleTaskSchedParam(LosTaskCB *idleTask);
VOID OsSchedResetSchedResponseTime(UINT64 responseTime);
VOID OsSchedUpdateExpireTime(VOID);
STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
{
LosTaskCB *newTask = NULL;
UINT32 baseBitmap = rq->queueBitmap;
#ifdef LOSCFG_KERNEL_SMP
UINT32 cpuid = ArchCurrCpuid();
#endif
while (baseBitmap) {
UINT32 basePrio = CLZ(baseBitmap);
HPFQueue *queueList = &rq->queueList[basePrio];
UINT32 bitmap = queueList->queueBitmap;
while (bitmap) {
UINT32 priority = CLZ(bitmap);
LOS_DL_LIST_FOR_EACH_ENTRY(newTask, &queueList->priQueList[priority], LosTaskCB, pendList) {
#ifdef LOSCFG_KERNEL_SMP
if (newTask->cpuAffiMask & (1U << cpuid)) {
#endif
return newTask;
#ifdef LOSCFG_KERNEL_SMP
}
#endif
}
bitmap &= ~(1U << (OS_PRIORITY_QUEUE_NUM - priority - 1));
}
baseBitmap &= ~(1U << (OS_PRIORITY_QUEUE_NUM - basePrio - 1));
}
return NULL;
}
VOID HPFSchedPolicyInit(SchedRunqueue *rq);
VOID HPFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
VOID HPFProcessDefaultSchedParamGet(SchedParam *param);
VOID IdleTaskSchedParamInit(LosTaskCB *taskCB);
INT32 OsSchedParamCompare(const LosTaskCB *task1, const LosTaskCB *task2);
VOID OsSchedPriorityInheritance(LosTaskCB *owner, const SchedParam *param);
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param);
VOID OsSchedResponseTimeReset(UINT64 responseTime);
VOID OsSchedToUserReleaseLock(VOID);
VOID OsSchedTaskDeQueue(LosTaskCB *taskCB);
VOID OsSchedTaskEnQueue(LosTaskCB *taskCB);
UINT32 OsSchedTaskWait(LOS_DL_LIST *list, UINT32 timeout, BOOL needSched);
VOID OsSchedTaskWake(LosTaskCB *resumedTask);
BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 policy, UINT16 priority);
BOOL OsSchedModifyProcessSchedParam(UINT32 pid, UINT16 policy, UINT16 priority);
VOID OsSchedSuspend(LosTaskCB *taskCB);
BOOL OsSchedResume(LosTaskCB *taskCB);
VOID OsSchedDelay(LosTaskCB *runTask, UINT32 tick);
VOID OsSchedYield(VOID);
VOID OsSchedTaskExit(LosTaskCB *taskCB);
VOID OsSchedTick(VOID);
UINT32 OsSchedInit(VOID);
VOID OsSchedStart(VOID);
VOID OsSchedRunqueueIdleInit(UINT32 idleTaskID);
VOID OsSchedRunqueueInit(VOID);
/*
* This function simply picks the next task and switches to it.
* Current task needs to already be in the right state or the right
@@ -525,14 +677,6 @@ VOID OsSchedIrqEndCheckNeedSched(VOID);
*/
LOS_DL_LIST *OsSchedLockPendFindPos(const LosTaskCB *runTask, LOS_DL_LIST *lockList);
#ifdef LOSCFG_SCHED_TICK_DEBUG
VOID OsSchedDebugRecordData(VOID);
#endif
UINT32 OsShellShowTickRespo(VOID);
UINT32 OsShellShowSchedParam(VOID);
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -61,11 +61,11 @@ STATIC INLINE VOID OsSemDbgTimeUpdateHook(UINT32 semID)
return;
}
/* Update the SEM_DEBUG_CB of the semaphore when created or deleted */
extern VOID OsSemDbgUpdate(UINT32 semID, TSK_ENTRY_FUNC creater, UINT16 count);
STATIC INLINE VOID OsSemDbgUpdateHook(UINT32 semID, TSK_ENTRY_FUNC creater, UINT16 count)
extern VOID OsSemDbgUpdate(UINT32 semID, TSK_ENTRY_FUNC creator, UINT16 count);
STATIC INLINE VOID OsSemDbgUpdateHook(UINT32 semID, TSK_ENTRY_FUNC creator, UINT16 count)
{
#ifdef LOSCFG_DEBUG_SEMAPHORE
OsSemDbgUpdate(semID, creater, count);
OsSemDbgUpdate(semID, creator, count);
#endif
return;
}

View File

@@ -72,28 +72,42 @@ STATIC INLINE UINT64 OsGetSortLinkNextExpireTime(SortLinkAttribute *sortHeader,
LOS_DL_LIST *head = &sortHeader->sortLink;
LOS_DL_LIST *list = head->pstNext;
LOS_SpinLock(&sortHeader->spinLock);
if (LOS_ListEmpty(head)) {
LOS_SpinUnlock(&sortHeader->spinLock);
return OS_SORT_LINK_INVALID_TIME - tickPrecision;
}
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
if (listSorted->responseTime <= (startTime + tickPrecision)) {
LOS_SpinUnlock(&sortHeader->spinLock);
return startTime + tickPrecision;
}
LOS_SpinUnlock(&sortHeader->spinLock);
return listSorted->responseTime;
}
STATIC INLINE UINT32 OsGetSortLinkNodeNum(SortLinkAttribute *head)
STATIC INLINE UINT32 OsGetSortLinkNodeNum(const SortLinkAttribute *head)
{
return head->nodeNum;
}
STATIC INLINE UINT16 OsGetSortLinkNodeCpuid(const SortLinkList *node)
{
#ifdef LOSCFG_KERNEL_SMP
return node->cpuid;
#else
return 0;
#endif
}
VOID OsSortLinkInit(SortLinkAttribute *sortLinkHeader);
VOID OsAdd2SortLink(SortLinkAttribute *head, SortLinkList *node, UINT64 responseTime, UINT16 idleCpu);
VOID OsDeleteFromSortLink(SortLinkAttribute *head, SortLinkList *node);
UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList);
UINT64 OsSortLinkGetNextExpireTime(UINT64 currTime, const SortLinkAttribute *sortLinkHeader);
UINT32 OsSortLinkAdjustNodeResponseTime(SortLinkAttribute *head, SortLinkList *node, UINT64 responseTime);
#ifdef __cplusplus
#if __cplusplus

View File

@@ -48,7 +48,7 @@ typedef struct {
} StackInfo;
#define OS_INVALID_WATERLINE 0xFFFFFFFF
#define OS_STACK_MAGIC_CHECK(topstack) (*(UINTPTR *)(topstack) == OS_STACK_MAGIC_WORD) /* 1:magic valid 0:unvalid */
#define OS_STACK_MAGIC_CHECK(topstack) (*(UINTPTR *)(topstack) == OS_STACK_MAGIC_WORD) /* 1:magic valid 0:invalid */
extern VOID OsExcStackInfo(VOID);
extern VOID OsExcStackInfoReg(const StackInfo *stackInfo, UINT32 stackNum);
@@ -81,4 +81,4 @@ extern UINT32 OsStackWaterLineGet(const UINTPTR *stackBottom, const UINTPTR *sta
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_STACK_INFO_PRI_H */
#endif /* _LOS_STACK_INFO_PRI_H */

View File

@@ -40,11 +40,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
typedef struct {
UINT64 runtime;
UINT32 contexSwitch;
} SchedPercpu;
typedef struct {
UINT64 allRuntime;
UINT64 runTime;
@@ -56,9 +51,17 @@ typedef struct {
UINT64 pendCount;
UINT64 waitSchedTime; /* task status is ready to running times */
UINT64 waitSchedCount;
SchedPercpu schedPercpu[LOSCFG_KERNEL_CORE_NUM];
} SchedStat;
#ifdef LOSCFG_SCHED_DEBUG
#ifdef LOSCFG_SCHED_TICK_DEBUG
VOID OsSchedDebugRecordData(VOID);
UINT32 OsShellShowTickResponse(VOID);
UINT32 OsShellShowSchedStatistics(VOID);
UINT32 OsSchedDebugInit(VOID);
#endif
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -66,6 +66,10 @@ typedef struct {
SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout */
UINTPTR arg; /**< Parameter passed in when the callback function
that handles software timer timeout is called */
LOS_DL_LIST node;
#ifdef LOSCFG_SWTMR_DEBUG
UINT32 swtmrID;
#endif
} SwtmrHandlerItem;
/**
@@ -100,13 +104,42 @@ extern SWTMR_CTRL_S *g_swtmrCBArray;
* @see LOS_SwtmrStop
*/
extern UINT32 OsSwtmrGetNextTimeout(VOID);
extern BOOL OsIsSwtmrTask(const LosTaskCB *taskCB);
extern VOID OsSwtmrRestart(UINT64 startTime, SortLinkList *sortList);
extern VOID OsSwtmrWake(SchedRunQue *rq, UINT64 currTime, SortLinkList *sortList);
extern VOID OsSwtmrResponseTimeReset(UINT64 startTime);
extern UINT32 OsSwtmrInit(VOID);
extern VOID OsSwtmrRecycle(UINT32 processID);
extern BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
extern SPIN_LOCK_S g_swtmrSpin;
extern UINT32 OsSwtmrTaskIDGetByCpuid(UINT16 cpuid);
#ifdef LOSCFG_SWTMR_DEBUG
typedef struct {
UINT64 startTime;
UINT64 waitTimeMax;
UINT64 waitTime;
UINT64 waitCount;
UINT64 readyStartTime;
UINT64 readyTime;
UINT64 readyTimeMax;
UINT64 runTime;
UINT64 runTimeMax;
UINT64 runCount;
UINT32 times;
} SwtmrDebugBase;
typedef struct {
SwtmrDebugBase base;
SWTMR_PROC_FUNC handler;
UINT32 period;
UINT32 cpuid;
BOOL swtmrUsed;
} SwtmrDebugData;
extern BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID);
extern UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode);
#endif
#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:
@@ -43,9 +43,9 @@ extern "C" {
/**
* @ingroup los_task
* Define task siginal types.
* Define task signal types.
*
* Task siginal types.
* Task signal types.
*/
#define SIGNAL_NONE 0U
#define SIGNAL_KILL (1U << 0)
@@ -73,7 +73,7 @@ extern SPIN_LOCK_S g_taskSpin;
*
* The task control block is unused.
*/
#define OS_TASK_STATUS_UNUSED 0x0200U
#define OS_TASK_STATUS_UNUSED 0x0400U
/**
* @ingroup los_task
@@ -81,7 +81,7 @@ extern SPIN_LOCK_S g_taskSpin;
*
* The task is joinable.
*/
#define OS_TASK_FLAG_PTHREAD_JOIN 0x0400U
#define OS_TASK_FLAG_PTHREAD_JOIN 0x0800U
/**
* @ingroup los_task
@@ -89,7 +89,7 @@ extern SPIN_LOCK_S g_taskSpin;
*
* The task is user mode task.
*/
#define OS_TASK_FLAG_USER_MODE 0x0800U
#define OS_TASK_FLAG_USER_MODE 0x1000U
/**
* @ingroup los_task
@@ -97,7 +97,7 @@ extern SPIN_LOCK_S g_taskSpin;
*
* The task is system-level task, like idle, swtmr and etc.
*/
#define OS_TASK_FLAG_SYSTEM_TASK 0x1000U
#define OS_TASK_FLAG_SYSTEM_TASK 0x2000U
/**
* @ingroup los_task
@@ -105,7 +105,7 @@ extern SPIN_LOCK_S g_taskSpin;
*
* The task is no-delete system task, like resourceTask.
*/
#define OS_TASK_FLAG_NO_DELETE 0x2000U
#define OS_TASK_FLAG_NO_DELETE 0x4000U
/**
* @ingroup los_task
@@ -113,15 +113,7 @@ extern SPIN_LOCK_S g_taskSpin;
*
* Kills the thread during process exit.
*/
#define OS_TASK_FLAG_EXIT_KILL 0x4000U
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
*
* The delayed operation of this task is frozen.
*/
#define OS_TASK_FLAG_FREEZE 0x8000U
#define OS_TASK_FLAG_EXIT_KILL 0x8000U
/**
* @ingroup los_task
@@ -323,8 +315,8 @@ extern UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S *initParam);
extern INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL setPName);
extern VOID OsTaskCBRecycleToFree(VOID);
extern VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status);
extern UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB);
extern UINT32 OsUserProcessOperatePermissionsCheck(LosTaskCB *taskCB, UINT32 processID);
extern INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB);
extern INT32 OsUserProcessOperatePermissionsCheck(const LosTaskCB *taskCB, UINT32 processID);
extern INT32 OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info);
extern VOID OsWriteResourceEvent(UINT32 events);
extern VOID OsWriteResourceEventUnsafe(UINT32 events);

View File

@@ -59,9 +59,9 @@ extern "C" {
const CHAR *OsGetRegionNameOrFilePath(LosVmMapRegion *region);
INT32 OsRegionOverlapCheckUnlock(LosVmSpace *space, LosVmMapRegion *region);
UINT32 OsShellCmdProcessVmUsage(LosVmSpace *space);
VOID OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
VOID OsKProcessPmUsage(LosVmSpace *kAspace, UINT32 *actualPm);
UINT32 OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
UINT32 OsKProcessPmUsage(LosVmSpace *kAspace, UINT32 *actualPm);
VOID OsDumpAspace(LosVmSpace *space);
UINT32 OsCountRegionPages(LosVmSpace *space, LosVmMapRegion *region, UINT32 *pssPages);
UINT32 OsCountAspacePages(LosVmSpace *space);

View File

@@ -50,7 +50,7 @@ extern "C" {
#define min(x, y) ((x) < (y) ? (x) : (y))
#endif
#define VM_PAGE_TO_PHYS(page) (page->physAddr)
#define VM_PAGE_TO_PHYS(page) ((page)->physAddr)
#define VM_ORDER_TO_PAGES(order) (1 << (order))
#define VM_ORDER_TO_PHYS(order) (1 << (PAGE_SHIFT + (order)))
#define VM_PHYS_TO_ORDER(phys) (min(LOS_LowBitGet((phys) >> PAGE_SHIFT), VM_LIST_ORDER_MAX - 1))

View File

@@ -86,18 +86,18 @@ extern "C" {
#define PERIPH_UNCACHED_SIZE U32_C(PERIPH_PMM_SIZE)
#endif
#define IO_DEVICE_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_DEVICE_BASE)
#define IO_CACHED_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_CACHED_BASE)
#define IO_UNCACHED_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_UNCACHED_BASE)
#define IO_DEVICE_ADDR(paddr) ((paddr) - PERIPH_PMM_BASE + PERIPH_DEVICE_BASE)
#define IO_CACHED_ADDR(paddr) ((paddr) - PERIPH_PMM_BASE + PERIPH_CACHED_BASE)
#define IO_UNCACHED_ADDR(paddr) ((paddr) - PERIPH_PMM_BASE + PERIPH_UNCACHED_BASE)
#define MEM_CACHED_ADDR(paddr) (paddr - DDR_MEM_ADDR + KERNEL_VMM_BASE)
#define MEM_UNCACHED_ADDR(paddr) (paddr - DDR_MEM_ADDR + UNCACHED_VMM_BASE)
#define MEM_CACHED_ADDR(paddr) ((paddr) - DDR_MEM_ADDR + KERNEL_VMM_BASE)
#define MEM_UNCACHED_ADDR(paddr) ((paddr) - DDR_MEM_ADDR + UNCACHED_VMM_BASE)
#define VMM_TO_UNCACHED_ADDR(vaddr) (vaddr - KERNEL_VMM_BASE + UNCACHED_VMM_BASE)
#define UNCACHED_TO_VMM_ADDR(vaddr) (vaddr - UNCACHED_VMM_BASE + KERNEL_VMM_BASE)
#define VMM_TO_UNCACHED_ADDR(vaddr) ((vaddr) - KERNEL_VMM_BASE + UNCACHED_VMM_BASE)
#define UNCACHED_TO_VMM_ADDR(vaddr) ((vaddr) - UNCACHED_VMM_BASE + KERNEL_VMM_BASE)
#define VMM_TO_DMA_ADDR(vaddr) (vaddr - KERNEL_VMM_BASE + SYS_MEM_BASE)
#define DMA_TO_VMM_ADDR(vaddr) (vaddr - SYS_MEM_BASE + KERNEL_VMM_BASE)
#define VMM_TO_DMA_ADDR(vaddr) ((vaddr) - KERNEL_VMM_BASE + SYS_MEM_BASE)
#define DMA_TO_VMM_ADDR(vaddr) ((vaddr) - SYS_MEM_BASE + KERNEL_VMM_BASE)
#if (PERIPH_UNCACHED_BASE >= (0xFFFFFFFFU - PERIPH_UNCACHED_SIZE))
#error "Kernel virtual memory space has overflowed!"

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