Compare commits

..

71 Commits

Author SHA1 Message Date
openharmony_ci c959698519
!1066 【挑单】time相关系统调用内核栈信息泄露排查
Merge pull request !1066 from zhushengle/cherry-pick-1668148730
2022-11-11 08:12:00 +00:00
zhushengle c2dd72e356 fixed 0b05a46 from https://gitee.com/zhushengle/kernel_liteos_a/pulls/1061
task: time相关系统调用内核栈信息泄露排查

解决方案:
    在涉及从内核拷贝数据到用户态的场景时,先将内核的数据进行清零操作,再填充内核数据
Close #I60M1P

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ia61d4e39b9e190accea477ff5b361e41d0eed2af
2022-11-11 06:38:50 +00:00
openharmony_ci a7080aaa85
!889 FatFs升级r0.14a版本同步3.0分支
Merge pull request !889 from wangchen/05_31_up_a
2022-06-02 07:43:01 +00:00
wangchen 1f7e6fa76f fix: FatFs升级r0.14a版本同步3.0分支
【背景】FatFs升级r0.14a版本同步3.0分支

【修改方案】
将三方库FatFs升级至r0.14a版本
主要修改点为:
适配_mkfs、find_volume接口更新
【影响】
对现有的产品编译不会有影响。
re #I5A7AS
Signed-off-by: wangchen <wangchen64@huawei.com>

Change-Id: I428fcb930fa0ead43ea033d14898fc0a00445933
2022-05-31 08:57:16 +00:00
openharmony_ci efd00c1e0d
!872 内核codex清零
Merge pull request !872 from Kiita/0421_codex
2022-04-25 02:25:39 +00:00
zhangyan ffe7462c7f 内核codex告警清零
Signed-off-by: Kiita <zhanyan@huawei.com>
Change-Id: I6b0bc9ba638f7aa73be754d5c92561fc372de1c6
2022-04-24 03:13:12 +00:00
openharmony_ci 6d7641af53
!812 3.0 LTS 告警清零
Merge pull request !812 from yinjiaming/OpenHarmony-3.0-LTS
2022-03-09 03:54:00 +00:00
yinjiaming 143309945a fix: 3.0 lts 告警清零
【背景】
3.0 lts 告警清零

【修改方案】
添加了强制类型转换

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

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I6faba4fe43ec127ad2a75b7123d0365b9903045b
2022-03-03 09:15:59 +00:00
openharmony_ci 9c1e902b55
!809 3.0 LTS 告警清零
Merge pull request !809 from yinjiaming/OpenHarmony-3.0-LTS
2022-03-02 03:14:43 +00:00
yinjiaming 84011c89a5 fix: 3.0 LTS 告警清零
【背景】
3.0 LTS 经过扫描有一些告警需要清理

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

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

re #I4UZW3

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I1f9cd16293b649ea9f9b3c4d3d02b1bfe95114e2
2022-02-23 11:02:55 +00:00
openharmony_ci 89154a3765
!777 [LTS-3.0]修复toybox mv指令能够移动成功,但提示错误22的BUG
Merge pull request !777 from Far/cherry-pick-1641884328
2022-01-12 02:21:53 +00:00
Far 8e6f3f1bfb fix: 修复futime提示错误22的BUG
调用futime时,系统调用接口函数直接使用了file结构体的f_path字段,该字段在退出前被错误地释放了。
避免该问题需要拷贝一份路径

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Ic0f8e608363da3ed15e252a3f91c46e8397c245e
2022-01-11 16:03:17 +08:00
openharmony_ci d5c8341bb0
!775 【轻量级 PR】:reduce print log if hilog ringbuffer is full
Merge pull request !775 from shenchenkai/N/A
2022-01-11 06:29:33 +00:00
shenchenkai 157fb8b212
reduce print log if hilog ringbuffer is full
Signed-off-by: shenchenkai <shenchenkai@huawei.com>
2022-01-11 04:14:49 +00:00
openharmony_ci 95f7cf16d0
!770 LOS_PaddrToKVaddr函数的实现存在冗余修改
Merge pull request !770 from 闻飞/OpenHarmony-3.0-LTS
2022-01-10 13:19:32 +00:00
wenfei6316 790573d018 fix LOS_PaddrToKVaddr function logical redundancy
Signed-off-by: wenfei6316 <wenfei6316@163.com>
2022-01-07 16:18:14 +08:00
openharmony_ci 246bdd11d8
!760 fix: shell支持exit退出,完善帮助信息,特殊处理不可见字符
Merge pull request !760 from huangshan/cherry-pick-1640932477
2022-01-07 03:20:56 +00:00
huangshan 017d8163ea fixed cc6e112 from https://gitee.com/uhamc/kernel_liteos_a/pulls/702
fix: shell支持exit退出,完善帮助信息,特殊处理不可见字符

Change-Id: Ia6dbff0faed4ec73fcf35691676f1acb2b8df78d
Signed-off-by: huangshan <huangshan9@huawei.com>
2021-12-31 06:34:40 +00:00
openharmony_ci f6d727fed8 !753 fix: implicit declaration of function 'syscall' in apps/shell
Merge pull request !753 from huangshan/673
2021-12-31 06:16:07 +00:00
openharmony_ci a771e39988 !754 fix: 修复Ctrl+C会终止所有进程的问题
Merge pull request !754 from huangshan/cherry-pick-1640571697
2021-12-31 06:16:01 +00:00
openharmony_ci 594f50733e !742 添加bundle.json
Merge pull request !742 from pjscc/OpenHarmony-3.0-LTS
2021-12-31 03:13:18 +00:00
openharmony_ci 10bf30f91f !758 【轻量级 PR】:fix: 修复重复执行内存用例导致系统卡死问题同步
Merge pull request !758 from Harylee/N/A
2021-12-30 08:20:49 +00:00
Harylee 60e77d0ea7
fix: 修复重复执行内存用例导致系统卡死问题同步
Signed-off-by: Haryslee <lihao189@huawei.com>
2021-12-29 11:55:31 +00:00
openharmony_ci 68b477588f !741 [LTS-3.0]修复los_disk_cache_clear有条件编译错误
Merge pull request !741 from Far/cherry-pick-1640053131
2021-12-29 03:43:29 +00:00
pjscc 2f8d12ece1 feat: 添加bundle.json作为hpm包管理描述文件
Signed-off-by: pjscc <pangjiashuai@huawei.com>
2021-12-29 10:41:28 +08:00
huangshan 12d4bc05f4 fixed cdc0877 from https://gitee.com/uhamc/kernel_liteos_a/pulls/693
修复Ctrl+C会终止所有进程的问题

Signed-off-by: huangshan <huangshan9@huawei.com>
Change-Id: I5861569c63fd6c1adf8c702797e4d79eba76211f
2021-12-27 02:21:37 +00:00
uhamc b9d012b026 fix: implicit declaration of function 'syscall' in apps/shell
Change-Id: Id3f56ac53ec5a3c86b04bcb7a4611f2eb77f4b80
Signed-off-by: uhamc <uhamc@foxmail.com>
2021-12-27 10:07:03 +08:00
openharmony_ci b0f642b493 !748 fix: 临终遗言重定向内容缺失task相关信息,对应的shell命令中申请的内存需要cacheline对齐
Merge pull request !748 from zhushengle/OpenHarmony-3.0-LTS
2021-12-25 02:55:52 +00:00
openharmony_ci 6c36623ac7 !746 fix: 修复xts权限用例压测异常问题
Merge pull request !746 from Harylee/cherry-pick-1640220757
2021-12-25 02:10:44 +00:00
zhushengle 9078efccd1 fix: 临终遗言重定向内容缺失task相关信息,对应的shell命令中申请的内存需要cacheline对齐
1.内核打印的地方支持异常时重定向打印信息
2.excinfo 命令中申请的内存64对齐

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I6ccd57b93b4a6e2eeabe5b366e9c0eb262dcad8e
2021-12-24 12:17:41 +08:00
openharmony_ci b7c4acfb78 !745 fix: 非当前进程退出时,销毁liteipc时错误的销毁了当前进程的
Merge pull request !745 from zhushengle/OpenHarmony-3.0-LTS
2021-12-24 03:57:14 +00:00
Haryslee aaa3cc9d7b fixed b0d31cb from https://gitee.com/harylee/kernel_liteos_a/pulls/738
fix: 修复xts权限用例压测异常问题

用例异常时出现Domain fault或者unknown fault,经分析发现是TLB缓存一致性问题,
在缺页异常入口,对上述两种异常类型做异常地址TLB缓存清理即可。

close #I3ZJ1D

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: Ib84e3e87047fcac392b83a4cf6cca0d91754e66f
2021-12-23 00:52:37 +00:00
openharmony_ci dc8853bb78 !743 fix: 优化trace buffer初始化,删除swtmr 桩中的无效参数
Merge pull request !743 from Zhaotianyu/cherry-pick-1640160115
2021-12-22 09:30:55 +00:00
zhushengle 892201f67b fix: 非当前进程退出时,销毁liteipc时错误的销毁了当前进程的
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Icf6688cf0d15efd0c6ef278f3fce37bf3849b03a
2021-12-22 17:24:08 +08:00
LiteOS2021 91709a3599 fixed b551270 from https://gitee.com/arvinzzz/kernel_liteos_a/pulls/660
fix: 优化trace buffer初始化,删除swtmr 桩中的无效参数
    close #I4DQ1X
Signed-off-by: LiteOS2021 <dinglu@huawei.com>

Change-Id: I79b416720f5327749a5884a65a5e61db07f2a17c
2021-12-22 08:02:09 +00:00
Far 332ba8fd65 fixed 63e71fe from https://gitee.com/yesiyuanjim/kernel_liteos_a/pulls/731
fix: 修复LOSCFG_FS_FAT_CACHE宏关闭后编译失败的BUG

1. 在必要处增加宏开关关闭部分代码的编译;
2. 由于驱动是一个独立的内核线程,在一些场景下文件系统会将用户态地址透传给驱动,这会导致内核崩溃。
因此在需要透传用户态地址时增加了一个内核buffer作为中转。

Close #I3T3N0

Signed-off-by: Far <yesiyuan2@huawei.com>
2021-12-21 02:18:52 +00:00
openharmony_ci d9752abcb4 !736 支持产品定制化hilog内核缓存大小
Merge pull request !736 from shenchenkai/OpenHarmony-3.0-LTS
2021-12-18 06:53:05 +00:00
shenchenkai 12cc392f46 Description:[feature] support customized hilog ring buffer size
Change-Id: I5d23deaada5939bbb6fb57505f72c2348bd6afe9
Signed-off-by: shenchenkai <shenchenkai@huawei.com>
2021-12-17 15:56:15 +08:00
openharmony_ci 62aa4aa0b1 !725 Codex警告清零
Merge pull request !725 from yinjiaming/yjm-kernel-fs-20211203
2021-12-03 07:08:29 +00:00
yinjiaming 929a282bad 【背景】
codex 告警清零
【修改方案】
修改和添加了procfs的默认文件模式的宏定义,对进行位操作运算的有符号数进行强制类型转换

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

re #I4KVS7

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
2021-12-03 01:41:48 +00:00
openharmony_ci 8bb15bf8e7 !720 当hilog/hievent驱动缓存出问题时,进行恢复处理
Merge pull request !720 from shenchenkai/cherry-pick-1637986052
2021-11-29 03:55:39 +00:00
openharmony_ci aec7840626 !718 [LTS-3.0]修复jffs2适配层错误释放锁的BUG
Merge pull request !718 from Far/cherry-pick-1637906208
2021-11-27 07:48:22 +00:00
shenchenkai e43e252e14 fixed c121d0e from https://gitee.com/shenchenkai/kernel_liteos_a/pulls/670
Description:[fix] clean hilog/hievent ring buffer after memory verification failed

Change-Id: I9310fe807ec95721be78deb60ed9728ef9b56e48
Signed-off-by: shenchenkai <shenchenkai@huawei.com>
2021-11-27 04:07:32 +00:00
Far ba4ed5a599 fixed 011a55f from https://gitee.com/yesiyuanjim/kernel_liteos_a/pulls/712
fix: 修复jffs2适配层错误释放锁的BUG

修复重复释放jffs2全局锁的BUG

Close #I4FH9M

Signed-off-by: Far <yesiyuan2@huawei.com>
2021-11-26 05:56:54 +00:00
openharmony_ci 55bdf174b8 !700 修改blackbox生成的文件和文件夹权限
Merge pull request !700 from mgceshuang/cherry-pick-1636013017
2021-11-08 02:26:54 +00:00
openharmony_ci c8c3034709 !688 PR665 misc09用例修改挑单到3.0LTS
Merge pull request !688 from pef/OpenHarmony-3.0-LTS
2021-11-04 11:45:23 +00:00
YOUR_NAME f32154f9cb fixed f360b21 from https://gitee.com/mgce/kernel_liteos_a/pulls/698
add blackbox to 2.3

Signed-off-by: YOUR_NAME <mashuang9@huawei.com>
2021-11-04 08:03:37 +00:00
openharmony_ci 60d3f6d5da !689 PR666 关于sys用例修复挑单到3.0TLS
Merge pull request !689 from pef/OpenHarmony-3.0-LTS_sys_test
2021-11-04 02:08:43 +00:00
openharmony_ci 44279b256a !694 PR676 关于ppoll修改挑单到3.0TLS
Merge pull request !694 from pef/OpenHarmony-3.0-1102
2021-11-04 02:08:40 +00:00
lnlan 951d233676 修复ppoll接口"[ERR]OsMemFree check error!"报错
【背景】
1.内核中释放用户空间指针报错:"[ERR]OsMemFree check error!"
2.现有ppoll实现存在问题
3.相关用例需要整理
【修改方案】
1.去掉释放用户空间指针操作
2.更正逻辑错误
3.更正掩码设置与恢复不起作用
4.修复补充现有用例
【影响】
对现有的产品编译不会有影响。

re #I47YWZ

Change-Id: Ib2f60986e9cafb2ea5ef1097ab8552cbb1ede5b4
Signed-off-by: lnlan <lanleinan@163.com>
2021-11-02 11:41:07 +00:00
pef ca70dc4dd1 修复ppoll接口"[ERR]OsMemFree check error!"报错
【背景】
内核中释放用户空间指针报错:"[ERR]OsMemFree check error!"

【修改方案】
修改SysPpoll函数。

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

re #I47YWZ

Change-Id: Id7f86036870d4f32be8fc438b9aad85cdda59546
Signed-off-by: pef <cyd1997@126.com>
2021-11-02 11:40:55 +00:00
teamol a693cd4198 fix: fix ppoll
1.modifications:
modified:   syscall/fs_syscall.c
2.modify 2 testcases:
IO/full/IO_test_ppoll_001.cpp
IO/full/IO_test_ppoll_002.cpp
3.influence:
none

Signed-off-by: pef <cyd1997@126.com>
Change-Id: I85fc091098a6dfef1a4694a3bbc489640ee6dda2
2021-11-02 11:40:25 +00:00
lnlan f249db759d fix(test): 修复sys部分用例因依赖passwd、group文件而失败
【背景】
1.sys部分用例因依赖passwd、group文件而失败

【修改方案】
1.用例执行前检查是否存在这些配置文件,不存在就跳过该用例

re#I48IUC

Change-Id: I787ce4b200f2a7546e57290b7dd073127caa07bb
Signed-off-by: lnlan <lanleinan@163.com>
2021-11-01 01:27:22 +00:00
lnlan 6f0c5d10e2 fix(test): misc09用例因依赖hosts文件而失败
【背景】
1.etc/hosts文件不存在,misc09依赖hosts文件而失败

【修改方案】
1.用例执行前检查是否存在这些配置文件,不存在就跳过该用例

re#I48IZ0

Change-Id: I193cb03770932c1f681cd726ceb383816aa2257a

Signed-off-by: lnlan <lanleinan@163.com>
Change-Id: I3fb7ca1ed5f8cc79a56cd1872f3b303ab325a7a9
2021-11-01 01:21:34 +00:00
openharmony_ci ca8909b8e3 !677 a核ioctl支持SIOCGIFBRDADDR选项
Merge pull request !677 from 刘建东/cherry-pick-1635300058
2021-10-27 08:47:35 +00:00
openharmony_ci 431c9e9d61 !678 signal内存泄露修复挑单到3.0tls
Merge pull request !678 from lnlan/tlsSignalFixed
2021-10-27 06:30:54 +00:00
lnlan d71db99932 fix: 修复PR520缺陷
【背景】
https://gitee.com/openharmony/kernel_liteos_a/pulls/520
上面修改,信号处理时才会释放申请的内存,当信号被屏蔽,且一直发送该信号时,
内存占用会不断变大
【修改方案】
1.
信号发送时已经有该信号的siginfo在链表中时,不再重新申请,重复使用之前的siginfo.

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

re#I4DEG5

Signed-off-by: lanleinan <lanleinan@163.com>

Change-Id: I74b3b7ff0b9efb0179313af9a0c8d1e12d1db5bb
2021-10-27 03:52:39 +00:00
YOUR_NAME 6b54224726 fixed 4ecc473 from https://gitee.com/life-liu/kernel_liteos_a/pulls/659
feat: add option SIOCGIFBRDADDR for ioctl

add option SIOCGIFBRDADDR for ioctl

close: #I4DNRF

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-10-27 02:01:00 +00:00
openharmony_ci 9ac04e886a !653 fix: 进程在退出前回收vmspace中的所有Region
Merge pull request !653 from zhushengle/cherry-pick-1633924550
2021-10-14 02:59:28 +00:00
zhushengle 06b0396945 fixed 298ccea from https://gitee.com/zhushengle/kernel_liteos_a/pulls/631
fix: 进程退出前自己回收vmspace中的所有region

背景:
父进程fork一个子进程,调用waitpid等待子进程结束。
子进程dlopen一个文件a.so,并退出。当守护进程正在
1核回收子进程资源时,父进程在0核运行从waitpid返
回后,同时remove a.so概率失败。

Close #I4CKQC

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ie7940e7c931ced10ee357cf9aa7c64355effed49
2021-10-11 03:55:51 +00:00
openharmony_ci bb3590a448 !648 pagecache优化需求回合到LTS 3.0分支
Merge pull request !648 from LeonChan/pg3
2021-10-08 07:38:41 +00:00
Leon Chan 027fa6136a feat: page cache backed by vnode instead of filep
1, change the owner of page to vnode
2, save the file path in vnode

close: #I4AGBR
Signed-off-by: Leon Chan <chenwei26@huawei.com>
Change-Id: I04f93e344c7231d1731746456babc419a6139e52
Signed-off-by: Leon Chan <chenwei26@huawei.com>
2021-09-30 16:21:03 +08:00
openharmony_ci 532f96d746 !647 将menuconfig 与 update_config功能做成一样
Merge pull request !647 from Caoruihong/cherry-pick-1632974889
2021-09-30 07:19:10 +00:00
Caoruihong d2bc8f2f1b fixed 3dd952b from https://gitee.com/caoruihong/kernel_liteos_a/pulls/646
chore(make): make menuconfig same as update_config

Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: I5c4a1a0601865c1c7d6ae40b829abdb53f13ccd3
2021-09-30 04:08:10 +00:00
Guangyao Ma e5c7549bc2 fix: dyload open close failed
本次提交修复内核加载器,异常情况分支的一个bug:mksh通过exec命令(mksh内置命令
,正常情况下,该命令成功执行会复用mksh进程空间,拉起新的指定进程)。但是如果
进程没有成功加载的情况下,内核加载器的异常分支会错误释放mksh的fd句柄。最终导致
下次拉起其他进程时(fork + exec方式),新的进程会继承fd,映射了早就释放的sysfd
,此时的sysfd可能已经被复用,issue场景下这个sysfd被加载过程中打开的libc.so占用
,exec时会释放procfd->sysfd(错误的映射关系),最终新进程libc.so被关闭。
导致内核崩溃。

close #I452Z7

Signed-off-by: Guangyao Ma <guangyao.ma@outlook.com>
Change-Id: Ifca809f88b5ffcfb879dc5520d1f6adf5cf92bcd
2021-09-30 10:56:11 +08:00
openharmony_ci 832001a6af !645 去除mtd对hisilicon驱动的依赖
Merge pull request !645 from SimonLi/OpenHarmony-3.0-LTS
2021-09-30 02:43:38 +00:00
SimonLi 7d7188c737 fix(mtd): 去除mtd对hisilicon驱动的依赖
【背景】
1. liteos-a内核drivers/mtd/multi_partition/用到了device/hisilicon下的驱动函数实
现,这样导致三方芯片适配时,会依赖hisilicon的驱动。
2. HDF的mtd驱动提供了这几个函数的实现,但是未暴露头文件出来。

【修改方案】
1. 修改BUILD.gn去除/device/hisilicon的依赖。
2. 修改mtd_partition.c,将hisilicon的头文件改为hdf的头文件依赖。

【遗留问题】
liteos-a内核与HDF mtd驱动的分界线还不明确,导致依赖关系不清楚

close: #I49FKL

Signed-off-by: SimonLi <likailong@huawei.com>
2021-09-29 20:51:11 +08:00
openharmony_ci 88a0caae24 !632 fix: 共享内存问题修复
Merge pull request !632 from Harylee/cherry-pick-1632710893
2021-09-27 06:54:52 +00:00
openharmony_ci 99824916dd !630 master分支关于sigwait的修改挑单到TLS
Merge pull request !630 from lnlan/to_LTS
2021-09-27 02:53:36 +00:00
Haryslee 42fdaffe76 fixed 9fdb80f from https://gitee.com/harylee/kernel_liteos_a/pulls/628
fix: 共享内存问题修复

Signed-off-by: Haryslee <lihao189@huawei.com>
背景:父进程移除共享内存并标记SHM_SEG_REMOVE,当子进程资源回收时在
ShmFindSeg接口中判断该共享内存具有SHM_SEG_REMOVE时返回空,但是此时
seg->ds.shm_nattch不为0,不应返回空。
方案:ShmFindSeg接口中增加seg->ds.shm_nattch为0的判断。

close #I47X2Z

Change-Id: I8735cd11ac237b17fa745c50313da0fd0649bb9f
2021-09-27 02:48:14 +00:00
lnlan ed7defbd43 fix: 修复sigwait等待到的信号值与获取的siginfo中的值不一致
【背景】
集成测试发送两个不同的信号,sigwait第二次等到的仍是第一个信号
经定位,信号在kill时会将相关的siginfo信息拷贝到taskcb的unbinfo中,sigwait
处理时从unbinfo拷贝给用户。若此信号发送时处于屏蔽状态,再有其他信号发送会覆盖
掉unbinfo,此时sigwait等待这个信号获取到的info已经被覆盖
【修改方案】
1. 每个任务添加一个siginfo缓存链表,在处理信号前夕从缓存链表取出info到unbinfo中

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

re #I3M12H

Signed-off-by: lanleinan <lanleinan@163.com>

Change-Id: If4b064c18773f8eca7419c665977260167b09810
2021-09-26 09:57:32 +00:00
2704 changed files with 158337 additions and 69902 deletions

View File

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

222
BUILD.gn
View File

@ -29,16 +29,17 @@
import("//build/lite/config/component/lite_component.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
declare_args() {
tee_enable = false
liteos_name = "OHOS_Image"
liteos_container_enable = false
liteos_skip_make = false
liteos_is_mini = false
}
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
tee = ""
if (tee_enable) {
tee = "_tee"
@ -48,27 +49,29 @@ declare_args() {
liteos_config_file = "${ohos_build_type}${tee}.config"
}
liteos_config_file =
rebase_path(liteos_config_file, "", "$product_path/kernel_configs")
liteos_config_file = rebase_path(liteos_config_file, "", "$product_path/kernel_configs")
print("liteos_config_file:", liteos_config_file)
exec_script("//build/lite/run_shell_cmd.py",
[ "env" + " CONFIG_=LOSCFG_" + " KCONFIG_CONFIG_HEADER='y=true'" +
" KCONFIG_CONFIG=$liteos_config_file" +
" DEVICE_PATH=$device_path" + " srctree=" + rebase_path(".") +
" genconfig" + " --header-path $LITEOS_MENUCONFIG_H" +
" --file-list kconfig_files.txt" +
" --env-list kconfig_env.txt" + " --config-out config.gni" ],
"",
[ liteos_config_file ])
[
"env" +
" CONFIG_=LOSCFG_" +
" KCONFIG_CONFIG_HEADER='y=true'" +
" KCONFIG_CONFIG=$liteos_config_file" +
" DEVICE_PATH=$device_path" +
" srctree=" + rebase_path(".") +
" genconfig" +
" --header-path $LITEOS_MENUCONFIG_H" +
" --file-list kconfig_files.txt" +
" --env-list kconfig_env.txt" +
" --config-out config.gni",
], "", [ liteos_config_file ])
import("liteos.gni")
assert(ARCH != "", "ARCH not set!")
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
assert(tee_enable == defined(LOSCFG_TEE_ENABLE), "TEE switch not match!")
assert(ohos_build_compiler == "clang" == defined(LOSCFG_COMPILER_CLANG_LLVM),
"compiler not match!")
generate_notice_file("kernel_notice_file") {
module_name = "kernel"
@ -77,6 +80,7 @@ generate_notice_file("kernel_notice_file") {
"$LITEOSTHIRDPARTY/musl",
"$LITEOSTHIRDPARTY/zlib",
"$LITEOSTHIRDPARTY/FatFs",
"$LITEOSTHIRDPARTY/Linux_Kernel",
"$LITEOSTHIRDPARTY/lwip",
"$LITEOSTHIRDPARTY/NuttX",
"$LITEOSTHIRDPARTY/mtd-utils",
@ -109,7 +113,7 @@ config("arch_config") {
ldflags = cflags
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-mthumb-interwork" ]
cflags += ["-mthumb-interwork"]
}
}
if (defined(LOSCFG_THUMB)) {
@ -123,16 +127,12 @@ config("arch_config") {
}
config("stdinc_config") {
std_include = exec_script("//build/lite/run_shell_cmd.py",
[ "$cc -print-file-name=include" ],
"trim string")
std_include = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-file-name=include" ], "trim string")
cflags = [
"-isystem",
std_include,
]
if (!defined(LOSCFG_LIBC_NEWLIB)) {
cflags += [ "-nostdinc" ]
}
cflags += [ "-nostdinc" ]
asmflags = cflags
}
@ -177,7 +177,7 @@ config("optimize_config") {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-flto=thin" ]
} else {
#cflags += [ "-flto" ]
cflags += [ "-flto" ]
}
}
cflags += [ optimization_cflag ]
@ -199,14 +199,8 @@ config("warn_config") {
"-Wpointer-arith",
"-Wstrict-prototypes",
"-Winvalid-pch",
"-Wno-address-of-packed-member",
]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-Wno-address-of-packed-member" ]
cflags += [
"-Wno-unused-but-set-variable",
"-Wno-strict-prototypes",
]
}
asmflags = cflags
}
@ -217,7 +211,6 @@ config("dialect_config") {
config("misc_config") {
defines = [ "__LITEOS__" ]
defines += [ "__LITEOS_A__" ]
if (!defined(LOSCFG_DEBUG_VERSION)) {
defines += [ "NDEBUG" ]
}
@ -244,28 +237,6 @@ config("misc_config") {
asmflags = cflags
}
config("container_config") {
if (liteos_container_enable) {
cflags = [
"-DLOSCFG_KERNEL_CONTAINER",
"-DLOSCFG_PID_CONTAINER",
"-DLOSCFG_UTS_CONTAINER",
"-DLOSCFG_MNT_CONTAINER",
"-DLOSCFG_CHROOT",
"-DLOSCFG_IPC_CONTAINER",
"-DLOSCFG_TIME_CONTAINER",
"-DLOSCFG_USER_CONTAINER",
"-DLOSCFG_NET_CONTAINER",
"-DLOSCFG_PROC_PROCESS_DIR",
"-DLOSCFG_KERNEL_PLIMITS",
"-DLOSCFG_KERNEL_MEM_PLIMIT",
"-DLOSCFG_KERNEL_IPC_PLIMIT",
"-DLOSCFG_KERNEL_DEV_PLIMIT",
"-DLOSCFG_KERNEL_SCHED_PLIMIT",
]
}
}
config("los_config") {
configs = [
":arch_config",
@ -276,16 +247,65 @@ config("los_config") {
":ssp_config",
":warn_config",
":misc_config",
":container_config",
]
}
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
executable("liteos") {
configs = [] # clear default configs
configs += [ ":arch_config" ]
configs += [ ":public" ]
ldflags = [
"-static",
"-nostdlib",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
"-Wl,--no-eh-frame-hdr",
]
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
libs = [ libgcc ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
inputs = [ "tools/build/liteos_llvm.ld" ]
} else {
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
ldflags += [ "-Wl,-nostartfiles" ]
inputs = [ "tools/build/liteos.ld" ]
}
inputs += [ "$root_out_dir/board.ld" ]
output_dir = target_out_dir
deps = [
"platform:copy_board.ld",
":modules",
]
}
copy("copy_liteos") {
deps = [ ":liteos" ]
sources = [ "$target_out_dir/unstripped/bin/liteos" ]
outputs = [ "$root_out_dir/$liteos_name" ]
}
build_ext_component("build_kernel_image") {
deps = [ ":copy_liteos" ]
exec_path = rebase_path(root_out_dir)
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
command += " && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
}
config("public") {
configs = [
"arch:public",
"platform:public",
"kernel:public",
"compat:public",
"bsd:public",
@ -299,7 +319,7 @@ config("public") {
configs += [
"$HDFTOPDIR:public",
"$DRIVERS_LITEOS_DIR:public",
"//drivers/liteos:public",
]
if (HAVE_DEVICE_SDK) {
@ -317,15 +337,15 @@ group("modules") {
"kernel",
"lib",
"net",
"platform",
"security",
"shell",
"syscall",
"testsuites/kernel:kernel_test",
]
deps += [
"$DRIVERS_LITEOS_DIR",
"$HDFTOPDIR",
HDFTOPDIR,
"//drivers/liteos",
]
if (HAVE_DEVICE_SDK) {
@ -346,87 +366,13 @@ group("kernel") {
}
group("liteos_a") {
deps = [ ":kernel" ]
if (!liteos_is_mini) {
deps += [
":apps",
":tests",
"$THIRDPARTY_MUSL_DIR/scripts/build_lite:strip",
]
if (liteos_skip_make == false) {
deps += [ ":make" ]
}
}
}
executable("liteos") {
configs = [] # clear default configs
configs += [ ":arch_config" ]
configs += [ ":public" ]
ldflags = [
"-static",
"-nostdlib",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
"-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")
libs = [ libgcc ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
ldflags +=
[ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
inputs = [ "tools/build/liteos_llvm.ld" ]
} else {
ldflags +=
[ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
ldflags += [ "-nostartfiles" ]
inputs = [ "tools/build/liteos.ld" ]
}
inputs += [ "$root_out_dir/board.ld" ]
output_dir = target_out_dir
deps = [
":modules",
"platform:copy_board.ld",
":apps",
":kernel",
":tests",
]
}
copy("copy_liteos") {
deps = [ ":liteos" ]
sources = [ "$target_out_dir/unstripped/bin/liteos" ]
outputs = [ "$root_out_dir/$liteos_name" ]
}
build_ext_component("build_kernel_image") {
deps = [ ":copy_liteos" ]
exec_path = rebase_path(root_out_dir)
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
command +=
" && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
}
build_ext_component("make") {
exec_path = rebase_path(".", root_build_dir)
outdir = rebase_path("$target_out_dir/${target_name}_out")

View File

@ -1,338 +0,0 @@
# (2022-03-30)
### Bug Fixes
* **arm-virt:** HW_RANDOM_ENABLE配置支持arm virt平台 ([68f9f49](https://gitee.com/openharmony/kernel_liteos_a/commits/68f9f49c2a62d3271db14ccb896c9f9fc78a60e4))
* A核代码静态告警定期清理 ([9ba725c](https://gitee.com/openharmony/kernel_liteos_a/commits/9ba725c3d486dd28fe9b2489b0f95a65354d7d86)), closes [#I4I0O8](https://gitee.com/openharmony/kernel_liteos_a/issues/I4I0O8)
* change default permission of procfs to 0550 ([a776c04](https://gitee.com/openharmony/kernel_liteos_a/commits/a776c04a3da414f73ef7136a543c029cc6dd75be)), closes [#I4NY49](https://gitee.com/openharmony/kernel_liteos_a/issues/I4NY49)
* change the execFile field in TCB to execVnode ([e4a0662](https://gitee.com/openharmony/kernel_liteos_a/commits/e4a06623ceb49b5bead60d45c0534db88b9c666f)), closes [#I4CLL9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CLL9)
* close file when process interpretor failed ([a375bf5](https://gitee.com/openharmony/kernel_liteos_a/commits/a375bf5668a5e86e082d0e124b538e423023a259)), closes [#I4ATQX](https://gitee.com/openharmony/kernel_liteos_a/issues/I4ATQX)
* codex 清理 ([9ab3e35](https://gitee.com/openharmony/kernel_liteos_a/commits/9ab3e351d38cdae2ec083048a50a253bc2a3b604)), closes [#I4BL3S](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BL3S)
* dyload open close failed ([5e87d8c](https://gitee.com/openharmony/kernel_liteos_a/commits/5e87d8c183471166294e2caa041ab4da8570c6a1)), closes [#I452Z7](https://gitee.com/openharmony/kernel_liteos_a/issues/I452Z7)
* fix ppoll ([a55f68f](https://gitee.com/openharmony/kernel_liteos_a/commits/a55f68f957e9f8ad74bd9e0c1b3d27775e0f8c75))
* fix some function declarations ([63fd8bc](https://gitee.com/openharmony/kernel_liteos_a/commits/63fd8bc39b21fffb6990f74e879eefecafad6c88))
* implicit declaration of function 'syscall' in apps/shell ([bd0c083](https://gitee.com/openharmony/kernel_liteos_a/commits/bd0c0835fc58ed5f941dbbc9adfac74253eeb874))
* LOS_Panic和魔法键功能中的使用PRINTK打印依赖任务调度特殊情况下存在打印不出来的问题 ([53addea](https://gitee.com/openharmony/kernel_liteos_a/commits/53addea304de09e0df457b690403ac652bbcea72)), closes [#I4NOC7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4NOC7)
* los_stat_pri.h中缺少依赖的头文件 ([2cd03c5](https://gitee.com/openharmony/kernel_liteos_a/commits/2cd03c55b7a614c648adc965ebfe494d491fe20f)), closes [#I4KEZ1](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KEZ1)
* los_trace.h接口注释错误修正 ([6d24961](https://gitee.com/openharmony/kernel_liteos_a/commits/6d249618aecc216388f9b1a2b48fe0ac6dd19ff2)), closes [#I4CYPZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CYPZ)
* MMU竞态问题修复 ([748e0d8](https://gitee.com/openharmony/kernel_liteos_a/commits/748e0d8ffb6ee9c8757ed056f575e3abc6c10702)), closes [#I2WARC](https://gitee.com/openharmony/kernel_liteos_a/issues/I2WARC)
* **mtd:** 去除mtd对hisilicon驱动的依赖 ([f7d010d](https://gitee.com/openharmony/kernel_liteos_a/commits/f7d010dfa4cb825096267528e131a9e2735d7505)), closes [#I49FKL](https://gitee.com/openharmony/kernel_liteos_a/issues/I49FKL)
* OsFutexWaitParamCheck函数中absTime为0时直接返回不需要打印 ([3f71be7](https://gitee.com/openharmony/kernel_liteos_a/commits/3f71be75355f11037d9de80cc4d7da0f01905003)), closes [#I4D67E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D67E)
* OsLockDepCheckIn异常处理中存在g_lockdepAvailable锁嵌套调用, ([bf030b6](https://gitee.com/openharmony/kernel_liteos_a/commits/bf030b6bb5843151a5b8b8736246a1376a5fb9d0)), closes [#I457ZZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I457ZZ)
* pr模板补充说明 ([e3cd485](https://gitee.com/openharmony/kernel_liteos_a/commits/e3cd485db528490a16a8932d734faab263b44bc9))
* same file mode for procfs files ([c79bcd0](https://gitee.com/openharmony/kernel_liteos_a/commits/c79bcd028e1be34b45cba000077230fa2ef95e68)), closes [#I4ACTC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4ACTC)
* shell支持exit退出完善帮助信息特殊处理不可见字符 ([cc6e112](https://gitee.com/openharmony/kernel_liteos_a/commits/cc6e11281e63b6bdc9be8e5d3c39f1258eb2ceaa))
* smp初始化中副核冗余的启动框架调用 ([5ce70a5](https://gitee.com/openharmony/kernel_liteos_a/commits/5ce70a50c3733b6ec8cc4b444837e366ec837f69)), closes [#I4F8A5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F8A5)
* solve SIGCHLD ignored in sigsuspend() ([5a80d4e](https://gitee.com/openharmony/kernel_liteos_a/commits/5a80d4e1a34c94204a0bb01443bf25a4fdb12750)), closes [#I47CKK](https://gitee.com/openharmony/kernel_liteos_a/issues/I47CKK)
* syscall review bugfix ([214f44e](https://gitee.com/openharmony/kernel_liteos_a/commits/214f44e935277c29d347c50b553a31ea7df36448)), closes [#149](https://gitee.com/openharmony/kernel_liteos_a/issues/149)
* **test:** misc09用例因依赖hosts文件而失败 ([f2f5c5f](https://gitee.com/openharmony/kernel_liteos_a/commits/f2f5c5fdc3202610de173e7046adab4df5e59142)), closes [#I48IZ0](https://gitee.com/openharmony/kernel_liteos_a/issues/I48IZ0)
* **test:** 修复sys部分用例因依赖passwd、group文件而失败 ([614cdcc](https://gitee.com/openharmony/kernel_liteos_a/commits/614cdccf91bd2d220c4c76418b53400ce714c6cb)), closes [#I48IUC](https://gitee.com/openharmony/kernel_liteos_a/issues/I48IUC)
* 中断中调用PRINTK概率卡死导致系统不能正常响应中断 ([9726ba1](https://gitee.com/openharmony/kernel_liteos_a/commits/9726ba11a79f3d2d1e616e12ef0bb44e4fc5cd20)), closes [#I4C9GC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4C9GC)
* 临终遗言重定向内容缺失task相关信息对应的shell命令中申请的内存需要cacheline对齐 ([48ca854](https://gitee.com/openharmony/kernel_liteos_a/commits/48ca854bf07f8dcda9657f950601043a485a1b33)), closes [#I482S5](https://gitee.com/openharmony/kernel_liteos_a/issues/I482S5)
* 优化liteipc任务状态删除功能重复字段 ([5004ef4](https://gitee.com/openharmony/kernel_liteos_a/commits/5004ef4d87b54fb6d7f748ca8212ae155bcefac5)), closes [#I4FVHK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FVHK)
* 优化trace buffer初始化删除swtmr 桩中的无效参数 ([b551270](https://gitee.com/openharmony/kernel_liteos_a/commits/b551270ef50cb206360e2eee3dd20ace5cecccb7)), closes [#I4DQ1X](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DQ1X)
* 修复 virpart.c 不适配的格式化打印问题 ([de29140](https://gitee.com/openharmony/kernel_liteos_a/commits/de29140edf2567f4847876cb1ed5e0b6857420f3)), closes [#I4PEVP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4PEVP)
* 修复A核文档失效的问题 ([456d255](https://gitee.com/openharmony/kernel_liteos_a/commits/456d255a81c2031be8ebecc2bf897af80c3d3c7a)), closes [#I4U7TF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4U7TF)
* 修复A核测试用例失败的问题 ([59329ce](https://gitee.com/openharmony/kernel_liteos_a/commits/59329ce7c6b6a00084df427748e6283287a773c0)), closes [#I4SQDR](https://gitee.com/openharmony/kernel_liteos_a/issues/I4SQDR)
* 修复A核测试用例失败的问题 ([be68dc8](https://gitee.com/openharmony/kernel_liteos_a/commits/be68dc8bcaf8d965039ae1d792775f00a08adfac)), closes [#I4SQDP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4SQDP)
* 修复dispatch单词拼写错误。 ([9b07aec](https://gitee.com/openharmony/kernel_liteos_a/commits/9b07aece2dfa3494cf35e8b388410341508d6224)), closes [#I4BLE8](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BLE8)
* 修复futime提示错误22的BUG ([f2861dd](https://gitee.com/openharmony/kernel_liteos_a/commits/f2861ddfb424af7b99c278273601ce0fab1f37e6))
* 修复jffs2适配层错误释放锁的BUG ([011a55f](https://gitee.com/openharmony/kernel_liteos_a/commits/011a55ff21d95f969abac60bcff96f4c4d7a326d)), closes [#I4FH9M](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FH9M)
* 修复los_vm_scan.c中内部函数OsInactiveListIsLow冗余代码 ([bc32a1e](https://gitee.com/openharmony/kernel_liteos_a/commits/bc32a1ec0fa5d19c6d2672bcf4a01de5e1be3afb)), closes [#I4HKFF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HKFF)
* 修复LOSCFG_FS_FAT_CACHE宏关闭后编译失败的BUG ([63e71fe](https://gitee.com/openharmony/kernel_liteos_a/commits/63e71feca05a8d46a49822c713258738740f0712)), closes [#I3T3N0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T3N0)
* 修复OsVmPhysFreeListAdd和OsVmPhysFreeListAddUnsafe函数内容重复 ([6827bd2](https://gitee.com/openharmony/kernel_liteos_a/commits/6827bd2a22b78aa05e20d6460412fc7b2d738929)), closes [#I4FL95](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FL95)
* 修复PR520缺陷 ([4033891](https://gitee.com/openharmony/kernel_liteos_a/commits/40338918d9132399ee0494d331930a05b7a13c67)), closes [#I4DEG5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DEG5)
* 修复shcmd.h需要用宏包起来的问题 ([6c4e4b1](https://gitee.com/openharmony/kernel_liteos_a/commits/6c4e4b16abe9c68fea43d40b2d39b4f0ed4bfc9c)), closes [#I4N50W](https://gitee.com/openharmony/kernel_liteos_a/issues/I4N50W)
* 修复xts权限用例压测异常问题 ([b0d31cb](https://gitee.com/openharmony/kernel_liteos_a/commits/b0d31cb43f5a8d1c3da574b2b957e3b0e98b3067)), closes [#I3ZJ1D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZJ1D)
* 修复硬随机不可用时,地址随机化不可用问题 ([665c152](https://gitee.com/openharmony/kernel_liteos_a/commits/665c152c27bb86395ddd0395279255f6cdaf7255)), closes [#I4D4TK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4D4TK)
* 修复进程用例导致门禁概率失败 ([1ed28b4](https://gitee.com/openharmony/kernel_liteos_a/commits/1ed28b4c80cfd222be08b0c2e71e6287e52bb276)), closes [#I4FO0N](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FO0N)
* 修复进程线程不稳定用例 ([f6ac03d](https://gitee.com/openharmony/kernel_liteos_a/commits/f6ac03d3e3c56236adc5734d4c059f1fbcc9e0c1)), closes [#I4F1XL](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F1XL)
* 修复重复执行内存用例导致系统卡死问题 ([6c2b163](https://gitee.com/openharmony/kernel_liteos_a/commits/6c2b163c7d7c696ef89b17a0275f3cddb3d7cefb)), closes [#I4F7PO](https://gitee.com/openharmony/kernel_liteos_a/issues/I4F7PO)
* 修改MMU模块的注释错误 ([1a8e22d](https://gitee.com/openharmony/kernel_liteos_a/commits/1a8e22dcf15944153e013d004fd7bbf24557a8c7)), closes [#I4KMMJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KMMJ)
* 共享内存问题修复 ([9fdb80f](https://gitee.com/openharmony/kernel_liteos_a/commits/9fdb80f85f92d0167a0456455a94fc6f679797ce)), closes [#I47X2Z](https://gitee.com/openharmony/kernel_liteos_a/issues/I47X2Z)
* 内核ERR打印无进程和线程信息不方便问题定位。 ([cb423f8](https://gitee.com/openharmony/kernel_liteos_a/commits/cb423f845462b8cc474c3cba261dadf3943a08ef)), closes [#I4DAKM](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DAKM)
* 内核ERR级别及以上的打印输出当前进程和线程名 ([540b201](https://gitee.com/openharmony/kernel_liteos_a/commits/540b2017c5460e300365d2039a08abd5945cec6b))
* 内源检视测试用例问题修复 ([a6ac759](https://gitee.com/openharmony/kernel_liteos_a/commits/a6ac7597f85043ba6de3a1b395ca676d85c65ea7))
* 删除冗余的头文件 ([8e614bb](https://gitee.com/openharmony/kernel_liteos_a/commits/8e614bb1616b75bc89eee7ad7da49b7a9c285b47)), closes [#I4KN63](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KN63)
* 增加pselect SYSCALL函数及测试用例 ([f601c16](https://gitee.com/openharmony/kernel_liteos_a/commits/f601c16b9e67d531dda51fc18389a53db4360b7b)), closes [#I45SXU](https://gitee.com/openharmony/kernel_liteos_a/issues/I45SXU)
* 增加内核epoll系统调用 ([2251b8a](https://gitee.com/openharmony/kernel_liteos_a/commits/2251b8a2d1f649422dd67f8551b085a7e0c63ec7)), closes [#I4FXPT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FXPT)
* 实现了musl库net模块中的一些函数接口和相应的测试用例 ([3d00a7d](https://gitee.com/openharmony/kernel_liteos_a/commits/3d00a7d23a96f29c138cfc1672825b90b9e0c05e)), closes [#I4JQI1](https://gitee.com/openharmony/third_party_musl/issues/I4JQI1)
* 添加进程线程冒烟用例 ([2be5968](https://gitee.com/openharmony/kernel_liteos_a/commits/2be59680f2fb0801b43522cd38cc387c8ff38766)), closes [#I4EOGA](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EOGA)
* 用户态进程主线程退出时,其他子线程刚好进入异常处理流程会导致系统卡死 ([d955790](https://gitee.com/openharmony/kernel_liteos_a/commits/d955790a44a679421798ec1ac2900b4d75dd75a4)), closes [#I4KGBT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KGBT)
* 编码规范修改 ([d161a0b](https://gitee.com/openharmony/kernel_liteos_a/commits/d161a0b03de046c05fff45a2b625631b4e45a347))
* 编码规范问题修复 ([f60bc94](https://gitee.com/openharmony/kernel_liteos_a/commits/f60bc94cf231bc615ff6603ca0393b8fe33a8c47))
* 编译框架在做编译入口的统一 ([bdb9864](https://gitee.com/openharmony/kernel_liteos_a/commits/bdb9864436a6f128a4c3891bbd63e3c60352689f)), closes [#I4KRQN](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KRQN)
* 解决dmesg -s参数double lock问题 ([e151256](https://gitee.com/openharmony/kernel_liteos_a/commits/e1512566e322eb1fbc8f5d5997f9bfcd022feac7)), closes [#I4HIJK](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HIJK)
* 进程退出前自己回收vmspace中的所有region ([298ccea](https://gitee.com/openharmony/kernel_liteos_a/commits/298ccea3fedaccc651b38973f0455fa1ce12e516)), closes [#I4CKQC](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CKQC)
* 通过g_uart_fputc_en关闭打印后shell进程不能正常启动 ([d21b05c](https://gitee.com/openharmony/kernel_liteos_a/commits/d21b05c0f69877130366ad37b852a0f30c11809d)), closes [#I4CTY2](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CTY2)
* 针对pr是否同步至release分支增加原因说明规则 ([b37a7b7](https://gitee.com/openharmony/kernel_liteos_a/commits/b37a7b79292d93dae6c4914952b5f3bb509e8721))
* 非当前进程销毁时销毁liteipc时错误的销毁了当前进程的liteipc资源 ([0f0e85b](https://gitee.com/openharmony/kernel_liteos_a/commits/0f0e85b7a6bf76d540925fbf661c483c8dba1cba)), closes [#I4FSA7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FSA7)
### Code Refactoring
* los_cir_buf.c中接口整合 ([0d325c5](https://gitee.com/openharmony/kernel_liteos_a/commits/0d325c56a1053043db05d53a6c8083f4d35f116b)), closes [#I4MC13](https://gitee.com/openharmony/kernel_liteos_a/issues/I4MC13)
### Features
* add option SIOCGIFBRDADDR for ioctl ([4ecc473](https://gitee.com/openharmony/kernel_liteos_a/commits/4ecc473843207d259613d26b8ee176d75e7f00fd)), closes [#I4DNRF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4DNRF)
* add sync() to vfs ([f67c4da](https://gitee.com/openharmony/kernel_liteos_a/commits/f67c4dae5141914df2e069dce0196b14780649d8)), closes [#I480HV](https://gitee.com/openharmony/kernel_liteos_a/issues/I480HV)
* **build:** support gcc toolchain ([6e886d4](https://gitee.com/openharmony/kernel_liteos_a/commits/6e886d4233dec3b82a27642f174b920e5f98f6aa))
* L0-L1 支持Perf ([6e0a3f1](https://gitee.com/openharmony/kernel_liteos_a/commits/6e0a3f10bbbfe29d110c050da927684b6d77b961)), closes [#I47I9A](https://gitee.com/openharmony/kernel_liteos_a/issues/I47I9A)
* L0~L1 支持Lms ([e748fdb](https://gitee.com/openharmony/kernel_liteos_a/commits/e748fdbe578a1ddd8eb10b2e207042676231ba26)), closes [#I4HYAV](https://gitee.com/openharmony/kernel_liteos_a/issues/I4HYAV)
* liteipc 静态内存优化 ([5237924](https://gitee.com/openharmony/kernel_liteos_a/commits/52379242c109e0cf442784dbe811ff9d42d5f33a)), closes [#I4G4HP](https://gitee.com/openharmony/kernel_liteos_a/issues/I4G4HP)
* page cache backed by vnode instead of filep ([38a6b80](https://gitee.com/openharmony/kernel_liteos_a/commits/38a6b804e9291d2fdbd189825ebd7d56165ec51c)), closes [#I44TBS](https://gitee.com/openharmony/kernel_liteos_a/issues/I44TBS)
* 提供低功耗默认处理框架 ([212d1bd](https://gitee.com/openharmony/kernel_liteos_a/commits/212d1bd1e806530fe7e7a16ea986cb2c6fb084ed)), closes [#I4KBG9](https://gitee.com/openharmony/kernel_liteos_a/issues/I4KBG9)
* 支持AT_RANDOM以增强用户态栈保护能力 ([06ea037](https://gitee.com/openharmony/kernel_liteos_a/commits/06ea03715f0cfb8728fadd0d9c19a403dc8f6028)), closes [#I4CB8M](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CB8M)
* 支持L1 低功耗框架 ([64e49ab](https://gitee.com/openharmony/kernel_liteos_a/commits/64e49aba7c9c7d2280c5b3f29f04b17b63209855)), closes [#I4JSOT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4JSOT)
* 支持LOS_TaskJoin 和 LOS_TaskDetach ([37bc11f](https://gitee.com/openharmony/kernel_liteos_a/commits/37bc11fa8837a3019a0a56702f401ec1845f6547)), closes [#I4EENF](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EENF)
* 新增解析异常和backtrace信息脚本 ([7019fdf](https://gitee.com/openharmony/kernel_liteos_a/commits/7019fdfcbb33c660e8aa9fd399d5fccbd7e23b49)), closes [#I47EVQ](https://gitee.com/openharmony/kernel_liteos_a/issues/I47EVQ)
* 调度tick响应时间计算优化 ([f47da44](https://gitee.com/openharmony/kernel_liteos_a/commits/f47da44b39be7fa3e9b5031d7b79b9bef1fd4fbc))
* 调度去进程化,优化进程线程依赖关系 ([dc479fb](https://gitee.com/openharmony/kernel_liteos_a/commits/dc479fb7bd9cb8441e4e47d44b42110ea07d76a2))
* 调度相关模块间依赖优化 ([0e3936c](https://gitee.com/openharmony/kernel_liteos_a/commits/0e3936c4f8b8bcfc48d283a6d53413e0fc0619b3)), closes [#I4RPRW](https://gitee.com/openharmony/kernel_liteos_a/issues/I4RPRW)
* 进程cpup占用率结构优化为动态分配 ([f06e090](https://gitee.com/openharmony/kernel_liteos_a/commits/f06e090a1085a654fd726fbc3c3a1c2bc703d663)), closes [#I4GLNT](https://gitee.com/openharmony/kernel_liteos_a/issues/I4GLNT)
* 进程rlimit修改为动态分配,减少静态内存占用 ([cf8446c](https://gitee.com/openharmony/kernel_liteos_a/commits/cf8446c94112ed6993a2e6e71e793d83a72689d5)), closes [#I4EZY5](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EZY5)
### BREAKING CHANGES
* 1. 删除 LOS_CirBufLock()LOS_CirBufUnlock()内核对外接口
2. LOS_CirBufWrite()LOS_CirBufRead()由原先内部不进行上/解锁操作,变为默认已包含上/解锁操作。
* 新增支持API:
LOS_LmsCheckPoolAdd使能检测指定内存池
LOS_LmsCheckPoolDel不检测指定内存池
LOS_LmsAddrProtect为指定内存段上锁不允许访问
LOS_LmsAddrDisableProtect去能指定内存段的访问保护
* 1.新增一系列perf的对外API位于los_perf.h中.
LOS_PerfInit配置采样数据缓冲区
LOS_PerfStart开启Perf采样
LOS_PerfStop停止Perf采样
LOS_PerfConfig配置Perf采样事件
LOS_PerfDataRead读取采样数据
LOS_PerfNotifyHookReg 注册采样数据缓冲区的钩子函数
LOS_PerfFlushHookReg 注册缓冲区刷cache的钩子
2. 用户态新增perf命令
【Usage】:
./perf [start] /[start id] Start perf.
./perf [stop] Stop perf.
./perf [read nBytes] Read nBytes raw data from perf buffer and print out.
./perf [list] List events to be used in -e.
./perf [stat] or [record] <option> <command>
-e, event selector. use './perf list' to list available events.
-p, event period.
-o, perf data output filename.
-t, taskId filter(whiltelist), if not set perf will sample all tasks.
-s, type of data to sample defined in PerfSampleType los_perf.h.
-P, processId filter(whiltelist), if not set perf will sample all processes.
-d, whether to prescaler (once every 64 counts), which only take effect on cpu cycle hardware event.
# (2021-09-30)
### Bug Fixes
* A核代码告警清零 ([698756d](https://gitee.com/openharmony/kernel_liteos_a/commits/698756d1e6dfb11b9f874c02ce6a1496646f2c27)), closes [#I4378T](https://gitee.com/openharmony/kernel_liteos_a/issues/I4378T)
* A核告警消除 ([d16bfd0](https://gitee.com/openharmony/kernel_liteos_a/commits/d16bfd005a6dae78df2df3ad55cf21e0716dfae9)), closes [#I46KF6](https://gitee.com/openharmony/kernel_liteos_a/issues/I46KF6)
* 3518平台, 异常测试进程无法正常退出 ([23937a2](https://gitee.com/openharmony/kernel_liteos_a/commits/23937a239f50d1487e89f3184e4f4b933d6842c6)), closes [#I3V8R5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V8R5)
* add (void) to GetFileMappingList method ([56b8eca](https://gitee.com/openharmony/kernel_liteos_a/commits/56b8ecaf171671c0fe97f1dd1f191bebb7812a51)), closes [#I3XPXY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XPXY)
* add capability and amend smoke testcase ([c9d69e2](https://gitee.com/openharmony/kernel_liteos_a/commits/c9d69e2d1bde57c67068cc36f6a79327d5db5daf))
* add fchdir api ([e828cbd](https://gitee.com/openharmony/kernel_liteos_a/commits/e828cbdeac7d60bfd6ed98c75a9958ee8ec7b672))
* add fchmod api ([2f214bf](https://gitee.com/openharmony/kernel_liteos_a/commits/2f214bf4de6c31875c77e84b1763e96bc5ceb669))
* add fststfs api and unitest ([4c57aa2](https://gitee.com/openharmony/kernel_liteos_a/commits/4c57aa26ad3644ce2429effc8e8fe7fd3c52ebc2))
* add product_path parameter for driver build ([88fe4eb](https://gitee.com/openharmony/kernel_liteos_a/commits/88fe4eb3e1eafa6d1e32c7b96579a07f5a8c6e35)), closes [#I3PQ10](https://gitee.com/openharmony/drivers_adapter/issues/I3PQ10)
* add syscall for ppoll & add 2 testcases ([defedb6](https://gitee.com/openharmony/kernel_liteos_a/commits/defedb6fdf0806da4a39e22408544cdfb405f2ff))
* avoid compile warning ignored ([eca711b](https://gitee.com/openharmony/kernel_liteos_a/commits/eca711bb64a7c806ae34c8483cac73fe22b0104f)), closes [#I3VOAO](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VOAO)
* A核codex修改 ([ec977a1](https://gitee.com/openharmony/kernel_liteos_a/commits/ec977a1c7e9ba4ea6621ceb1d0d10e586148208d)), closes [#I40B1S](https://gitee.com/openharmony/kernel_liteos_a/issues/I40B1S)
* BBOX使用预留物理内存缓存故障日志 ([2ad176e](https://gitee.com/openharmony/kernel_liteos_a/commits/2ad176e587d5ed7106831a25d386a88e26192e2b)), closes [#I41YIZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I41YIZ)
* bootargs解析与rootfs挂载解耦并支持自定义bootargs参数 ([80473f0](https://gitee.com/openharmony/kernel_liteos_a/commits/80473f0975fe6fd4c4eae3a8a473674ad2dd1293)), closes [#I41CL8](https://gitee.com/openharmony/kernel_liteos_a/issues/I41CL8)
* **build:** clang10.0.1支持lto去掉冗余判断 ([73223ae](https://gitee.com/openharmony/kernel_liteos_a/commits/73223ae7e652b7cd9f1e1848c32b2b2573d07b2a))
* **build:** fix rootfsdir.sh target directory not exist ([21bf2b8](https://gitee.com/openharmony/kernel_liteos_a/commits/21bf2b889931787fb18ca7ea238291fd57e76d51)), closes [#I3NHQ0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NHQ0)
* **build:** 去除冗余单板相关的宏配置 ([471de36](https://gitee.com/openharmony/kernel_liteos_a/commits/471de3663ea8b63f7448162edc0293b8723dcefc))
* clang10 lld could not recognized Oz ([87a0006](https://gitee.com/openharmony/kernel_liteos_a/commits/87a0006d5e1976fdf5efe4be383921610eb04ec6))
* clang相关编译选项隔离 ([77dcef4](https://gitee.com/openharmony/kernel_liteos_a/commits/77dcef4bc0c92d0141f7a3be0addd4d5cb533b0b)), closes [#I444AV](https://gitee.com/openharmony/kernel_liteos_a/issues/I444AV)
* codex ([101a55d](https://gitee.com/openharmony/kernel_liteos_a/commits/101a55d1199530d621f809976f0024aa8295cce8))
* codex clean ([b5370af](https://gitee.com/openharmony/kernel_liteos_a/commits/b5370af822c8e81ed2248ac8aa3bb479a0db9dae)), closes [#I3UOFN](https://gitee.com/openharmony/kernel_liteos_a/issues/I3UOFN)
* compile error when fatfs disabled ([fd3f407](https://gitee.com/openharmony/kernel_liteos_a/commits/fd3f4072b5c3dff710013ccdaddf114b0e13f435))
* console compile bug fix ([f8441a0](https://gitee.com/openharmony/kernel_liteos_a/commits/f8441a0cdea301449416b0c0477dc48a05b6ab4e))
* correct spelling ([c66fe03](https://gitee.com/openharmony/kernel_liteos_a/commits/c66fe0313f76ba41992b4864c93cf82934378ad3))
* Correctly handle the return value of LOS_EventRead in QuickstartListen. ([0e0ab81](https://gitee.com/openharmony/kernel_liteos_a/commits/0e0ab81ff9474cffd5e60a8ee741840eac5d737b)), closes [#I3PSLZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PSLZ)
* Ctrl-C move out of LOS_MAGIC_KEY_ENABLE ([40f239a](https://gitee.com/openharmony/kernel_liteos_a/commits/40f239a7d4673dc740c853b1011b5072e48385b7))
* Delete useless 'exc interaction' macros and function declarations. ([d2f2679](https://gitee.com/openharmony/kernel_liteos_a/commits/d2f26790716c9f76589c4a7d6fa5518f9ccd743c)), closes [#I3SDKY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SDKY)
* dereference NULL point bug fix ([deaa564](https://gitee.com/openharmony/kernel_liteos_a/commits/deaa564a66b83c9fe19a37b8a061ec9064ece354))
* do not build toybox temporarily ([044f2c7](https://gitee.com/openharmony/kernel_liteos_a/commits/044f2c7c17c68e10aeccc3af0c222cfc722d194c))
* do not override existing libs ([8118408](https://gitee.com/openharmony/kernel_liteos_a/commits/8118408123e75f7f5a4ab9101e388be6bba0dcda))
* **doc:** 修复README_zh-HK.md的链接错误 ([f1b4c87](https://gitee.com/openharmony/kernel_liteos_a/commits/f1b4c87bc44650348504bc00b3f6f94491c341a0))
* fatfs memory leak ([fbfd71d](https://gitee.com/openharmony/kernel_liteos_a/commits/fbfd71dfe3b5555ef09e542d96a630dfba636daa))
* fix function name OsSchedSetIdleTaskSchedParam ([8f8c038](https://gitee.com/openharmony/kernel_liteos_a/commits/8f8c038b217d5ba2518413bfc1ba857587d47442))
* Fix kernel page fault exception handling causing system exception. ([a89fb57](https://gitee.com/openharmony/kernel_liteos_a/commits/a89fb57f5795236b93fd19ee2d7a059cae1b2b1b)), closes [#I3RAN4](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RAN4)
* fix length typo ([12d98b1](https://gitee.com/openharmony/kernel_liteos_a/commits/12d98b144b70e726d3fd31ddc9d17ed855d0ec1b))
* fix mq function by enable mq_notify api ([4427142](https://gitee.com/openharmony/kernel_liteos_a/commits/4427142d734df8f95f4599093392904abacc5c93))
* Fix quickstart codingstyle ([2e011b6](https://gitee.com/openharmony/kernel_liteos_a/commits/2e011b672f6b96ea7e0db066a07e3f9fb6ba5df3)), closes [#I3OPOM](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OPOM)
* fix stored typo ([d25560f](https://gitee.com/openharmony/kernel_liteos_a/commits/d25560f8ac3216670d198cbbb25891c394e0b3c2))
* fix syscall faccessat,fstatfs,fstatat & add 6 testcases ([aa1cd24](https://gitee.com/openharmony/kernel_liteos_a/commits/aa1cd245a5711e5b53c328b688da5ddc2e783d5f))
* fix the inappropriate errno in FatFs ([af61187](https://gitee.com/openharmony/kernel_liteos_a/commits/af61187587411dca38ff62e720451f08f19c1c82)), closes [#I3O8IF](https://gitee.com/openharmony/kernel_liteos_a/issues/I3O8IF)
* fix typo in quickstart ([3b2ff4b](https://gitee.com/openharmony/kernel_liteos_a/commits/3b2ff4b71fc5ae1dc74180c33fd66f69da0059d1)), closes [#I3M1S8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M1S8)
* Fix wrong judgment in los_trace.c to avoid null pointer access. ([4d863e9](https://gitee.com/openharmony/kernel_liteos_a/commits/4d863e985b6372f7895db57b602b662dba5cadd0)), closes [#I3RT9F](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RT9F)
* Identical condition 'ret<0', second condition is always false. :bug: ([1348809](https://gitee.com/openharmony/kernel_liteos_a/commits/1348809807548dd481286a55a6677a9169fcd705))
* init进程收到子进程退出信号后调用fork重新拉起进程会导致系统卡死 ([35a2f3a](https://gitee.com/openharmony/kernel_liteos_a/commits/35a2f3af33a5dba1e0ba36587efced8fead97223)), closes [#I41HOY](https://gitee.com/openharmony/kernel_liteos_a/issues/I41HOY)
* kernel crashed after rmdir the umounted folder ([ac0d083](https://gitee.com/openharmony/kernel_liteos_a/commits/ac0d083b1c89c4ad3fdaab0347d11f174d0185cb))
* kernel crashed when delete a umounted folder ([f305d1f](https://gitee.com/openharmony/kernel_liteos_a/commits/f305d1f702a770010125a0f4f0152ffefeeec5c4))
* kernel crashed when delete a umounted folder ([c6e9212](https://gitee.com/openharmony/kernel_liteos_a/commits/c6e921241b1cf26bcbfeea44e20f6b596512e259))
* **kernel_test:** 内核mem/shm冒烟用例重复运行失败 ([0676578](https://gitee.com/openharmony/kernel_liteos_a/commits/0676578aae09c101d79e7a276823e849df293e29)), closes [#I3TH4W](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TH4W)
* L1 toybox 命令功能实现 ([2ff44c4](https://gitee.com/openharmony/kernel_liteos_a/commits/2ff44c4938d2e66ce60e9497c505eb6e97efc8c2)), closes [#I41N2A](https://gitee.com/openharmony/third_party_toybox/issues/I41N2A)
* liteipc max data size too small ([4dc421e](https://gitee.com/openharmony/kernel_liteos_a/commits/4dc421e3decdaae60219d533c4a93dbc9334e35f))
* LiteOS_A BBOX Codex整改 ([6a5a032](https://gitee.com/openharmony/kernel_liteos_a/commits/6a5a0326d2b18ffacce5d38fb351530973c2f245)), closes [#I43RQU](https://gitee.com/openharmony/kernel_liteos_a/issues/I43RQU)
* Liteos-a创建的文件夹在Ubuntu中不可见 ([a9fc1e0](https://gitee.com/openharmony/kernel_liteos_a/commits/a9fc1e0e5d3e5eb8a34c568a8d147320a9afebe1)), closes [#I3XMY6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XMY6)
* lookup new vnode may cause parent vnode freeing ([902a11d](https://gitee.com/openharmony/kernel_liteos_a/commits/902a11de9a4b08e799820fb87942cb2171b9e095)), closes [#I3MYP4](https://gitee.com/openharmony/kernel_liteos_a/issues/I3MYP4)
* **mini:** fix compile error in mini liteos_a ([e13cb3b](https://gitee.com/openharmony/kernel_liteos_a/commits/e13cb3bcc4e74d4c49c31d290d686f99a4e81e3f))
* minimal compile ([ac8c2c6](https://gitee.com/openharmony/kernel_liteos_a/commits/ac8c2c6d5b9ede0e46b48212f0b3447605a613c4))
* misspell ([08980ea](https://gitee.com/openharmony/kernel_liteos_a/commits/08980eac3c249ec6a6717d8a04fb0be7716053a1))
* mkdir -p is more robust ([e38f9a9](https://gitee.com/openharmony/kernel_liteos_a/commits/e38f9a98c9d373db8381af707c5996d1fefef64e))
* mksh compile bug fix ([d8263b1](https://gitee.com/openharmony/kernel_liteos_a/commits/d8263b1e91d76706d52df321ef642c1c8297e8e4)), closes [#I3ZMR7](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZMR7)
* modify event API description ([937734b](https://gitee.com/openharmony/kernel_liteos_a/commits/937734b1e9f5fc52e0ac727549bd2e4b4c864e3c))
* move nuttx head file back ([4c8a86e](https://gitee.com/openharmony/kernel_liteos_a/commits/4c8a86ece7cafa8f74441bacc74c7788c0a1b780)), closes [#I4443Q](https://gitee.com/openharmony/kernel_liteos_a/issues/I4443Q)
* nanosleep 接口的rmtp参数被错误清零 ([9458de9](https://gitee.com/openharmony/kernel_liteos_a/commits/9458de9ac664cd75540c8b638b9a6caf82812fc8)), closes [#I41U0R](https://gitee.com/openharmony/kernel_liteos_a/issues/I41U0R)
* no exception information output, when the system is abnormal ([5bf4d1c](https://gitee.com/openharmony/kernel_liteos_a/commits/5bf4d1c7128e6718611bbec23cb4373bcb3bfe55))
* no exception information output, when the system is abnormal ([28aa777](https://gitee.com/openharmony/kernel_liteos_a/commits/28aa777191e7b41e4f1f346ab79f8688edc59c6d))
* no exception information output, when the system is abnormal after holding ([0ed8adf](https://gitee.com/openharmony/kernel_liteos_a/commits/0ed8adfe3ae59672e284331d40ef3b9e0bc8e094))
* Optimiz macro of quickstart cmd ([cb140a4](https://gitee.com/openharmony/kernel_liteos_a/commits/cb140a4442c02dd0b1925cc58deecbf4da36dcea)), closes [#I3OSYT](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OSYT)
* Optimize /dev/quickstart permissions. ([4e24b57](https://gitee.com/openharmony/kernel_liteos_a/commits/4e24b572897c33e1b2723122c0e13d3931096bae)), closes [#I3OYUQ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OYUQ)
* Optimize quickstart node implementation ([4abd2e0](https://gitee.com/openharmony/kernel_liteos_a/commits/4abd2e0247b14718bb21756fb446142140d30a88)), closes [#I3R8O8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3R8O8)
* OsGerCurrSchedTimeCycle 函数存在拼写错误 ([53ced1a](https://gitee.com/openharmony/kernel_liteos_a/commits/53ced1a85edc3d06230225ced3916772f432243f)), closes [#I446CX](https://gitee.com/openharmony/kernel_liteos_a/issues/I446CX)
* OsGetArgsAddr声明所在头文件不正确 ([14bd753](https://gitee.com/openharmony/kernel_liteos_a/commits/14bd753aa8beb49af887c8d0aedaefa446409760)), closes [#I41MWM](https://gitee.com/openharmony/kernel_liteos_a/issues/I41MWM)
* parent point of vnode found by VfsHashGet should be updated ([f32caa5](https://gitee.com/openharmony/kernel_liteos_a/commits/f32caa52c67eca20d58676be4e0439acbb4c5ac3)), closes [#I3NNFA](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NNFA)
* PathCacheFree try to free name field in struct PathCache ([9f47faf](https://gitee.com/openharmony/kernel_liteos_a/commits/9f47faff732609cf2249f104b94ed55f3ef133bb)), closes [#I3NTH9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NTH9)
* PathCacheMemoryDump miscalculate the RAM usage of PathCache ([87da7c7](https://gitee.com/openharmony/kernel_liteos_a/commits/87da7c794c9bc8e311ae5242820fbf8aefd8d558)), closes [#I3OBXY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OBXY)
* Provide a separate configuration macro for boot environment in RAM. ([e28e06b](https://gitee.com/openharmony/kernel_liteos_a/commits/e28e06b08f5b28091153e584cb9d93014a9f2b10))
* Provide a separate configuration macro for boot environment in RAM. ([bc67393](https://gitee.com/openharmony/kernel_liteos_a/commits/bc67393a67f714e0a8165b6103e53699c676341c))
* Provide a separate configuration macro for boot environment in RAM. ([f13b90e](https://gitee.com/openharmony/kernel_liteos_a/commits/f13b90e4308ba3d60683799b9ce62fb3705ac277)), closes [#I3OADR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OADR)
* race condition in liteipc ([7e2aef2](https://gitee.com/openharmony/kernel_liteos_a/commits/7e2aef2480b15f71ee0e089cef4443f578e03dbb)), closes [#I3PW5Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PW5Y)
* rebuild mksh depends on rebuild.sh script ([bef4ab9](https://gitee.com/openharmony/kernel_liteos_a/commits/bef4ab9835dec865898c74337dfb7154718b94aa))
* remove redundant headfile ([73a7777](https://gitee.com/openharmony/kernel_liteos_a/commits/73a777777e1b834192f6bb2c0e8bd03c69765c11)), closes [#I3RTNR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3RTNR)
* Remove redundant invalid codes ([fe05df4](https://gitee.com/openharmony/kernel_liteos_a/commits/fe05df40ae710632adb1bd54fb04ad4a8e0c1429)), closes [#I3R70T](https://gitee.com/openharmony/kernel_liteos_a/issues/I3R70T)
* Show conflicting files for git apply or patch -p command ([35f7957](https://gitee.com/openharmony/kernel_liteos_a/commits/35f79579758644cbcac6005f894be21f34f42b99)), closes [#I3NNUS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NNUS)
* SIOCGIFCONF ioctl malloc size error in kernel ([bfd27e7](https://gitee.com/openharmony/kernel_liteos_a/commits/bfd27e78b259eedbd4c30548e80c9b4d789d26e1)), closes [#I3XEZ3](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XEZ3)
* smp启动代码解耦及内存映射关系解耦 ([3bb3173](https://gitee.com/openharmony/kernel_liteos_a/commits/3bb3173604dc4dea09301f61da402974185dc112)), closes [#I41P8Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I41P8Y)
* some branch in format does not release the vnode mutex properly ([9b2b700](https://gitee.com/openharmony/kernel_liteos_a/commits/9b2b700fa0e3a8edadb38f09c917a3e3f013347f)), closes [#I3OFAY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OFAY)
* Sortlink, the response time to insert the node should be inserted into the back of the existing node. ([1323874](https://gitee.com/openharmony/kernel_liteos_a/commits/1323874389030c55fb053fead12ca1c6654d8851)), closes [#I3PSJ8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3PSJ8)
* statfs can't get f_bfree and f_bavail of a FAT12/FAT16 partition ([9503c4a](https://gitee.com/openharmony/kernel_liteos_a/commits/9503c4a9fc30aaa8ea2031d4fb794436f3c98055)), closes [#I3Q0VS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0VS)
* SysOpenat返回值应该为进程fd而非系统全局fd。 ([3457c0b](https://gitee.com/openharmony/kernel_liteos_a/commits/3457c0b11debb2cf5d4abe325c2510a750654512)), closes [#I3TNAK](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TNAK)
* the total used vnode number not increased after unlink a file under ([4f514a1](https://gitee.com/openharmony/kernel_liteos_a/commits/4f514a16af5a3f3b9c4ea182de774297afb17f66)), closes [#I3TS1Y](https://gitee.com/openharmony/kernel_liteos_a/issues/I3TS1Y)
* tick 动态化计算优化,消除中断执行时间对系统总体时间的影响,保证软件定时器的响应精度。 ([8df3e8c](https://gitee.com/openharmony/kernel_liteos_a/commits/8df3e8c96515a1907455a9bbc61426f43c803c62)), closes [#I43UQJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I43UQJ)
* toybox update ([c3245b3](https://gitee.com/openharmony/kernel_liteos_a/commits/c3245b3ce317eb58c8dad58fdfc7f094b9b9794b))
* toybox命令升级 ([76f45b3](https://gitee.com/openharmony/kernel_liteos_a/commits/76f45b3fb2783d1cab45a6ba08787c29dfa2c948)), closes [#I41N2A](https://gitee.com/openharmony/third_party_toybox/issues/I41N2A)
* update LOS_DL_LIST_IS_END comment ([900269b](https://gitee.com/openharmony/kernel_liteos_a/commits/900269bd4645252d898f6d3b73de01d8548c960c))
* userfs分区的起始地址与大小改为通过bootargs配置 ([2e2b142](https://gitee.com/openharmony/kernel_liteos_a/commits/2e2b14205f4b81c7483ab42d62f144487097e9a4)), closes [#I3XNEY](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XNEY)
* VnodeInUseIter and VnodeFreeAll used to be recursive ([5f6656c](https://gitee.com/openharmony/kernel_liteos_a/commits/5f6656cb36a2ffb0b290aeb53981aba7501e80b2)), closes [#I3NN3U](https://gitee.com/openharmony/kernel_liteos_a/issues/I3NN3U)
* 以g_sysSchedStartTime是否为0判断时间轴是否生效存在极限场景导致调度时间不生效 ([67ac8c4](https://gitee.com/openharmony/kernel_liteos_a/commits/67ac8c4c586adc371ece56700fd42371ca7fc885)), closes [#I45HP5](https://gitee.com/openharmony/kernel_liteos_m/issues/I45HP5)
* 修复FATFS中不同内部接口不支持FAT12/FAT16 FAT表结束标志 ([33f5c70](https://gitee.com/openharmony/kernel_liteos_a/commits/33f5c70e6c8781758d2bfde0f60ca3d6ec7d543f)), closes [#I409R6](https://gitee.com/openharmony/kernel_liteos_a/issues/I409R6)
* 修复kill进程时因liteipc阻塞的进程概率无法退出问题 ([7de43bb](https://gitee.com/openharmony/kernel_liteos_a/commits/7de43bb004a12f926550f0b36ca3c2fa610feb27)), closes [#I3XX7K](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XX7K)
* 修复MagicKey数组越界访问 ([071cd62](https://gitee.com/openharmony/kernel_liteos_a/commits/071cd6268aeaaef702387dacaf4ef1ffbb7618fc)), closes [#I3U4N9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3U4N9)
* 修复mprotect修改地址区间的权限后相应的区间名丢失问题 ([e425187](https://gitee.com/openharmony/kernel_liteos_a/commits/e425187d176a5e09bc5253faefc9cfc8454da0a3)), closes [#I43R40](https://gitee.com/openharmony/kernel_liteos_a/issues/I43R40)
* 修复mq_close关闭后仍然占用文件描述符的问题 ([590c7b4](https://gitee.com/openharmony/kernel_liteos_a/commits/590c7b4e22662781d05ad035a785e985d573ec33)), closes [#I3ZQDA](https://gitee.com/openharmony/kernel_liteos_a/issues/I3ZQDA)
* 修复mqueue问题 ([26ee8b8](https://gitee.com/openharmony/kernel_liteos_a/commits/26ee8b836e346e641de4ecd72284f5d377bca6f8)), closes [#I43P4T](https://gitee.com/openharmony/kernel_liteos_a/issues/I43P4T)
* 修复sigwait等待到的信号值与获取的siginfo中的值不一致 ([ed7defb](https://gitee.com/openharmony/kernel_liteos_a/commits/ed7defbd439c345a07159d40eb04433afd530004)), closes [#I3M12H](https://gitee.com/openharmony/kernel_liteos_a/issues/I3M12H)
* 修复了LOSCFG_FS_FAT_VIRTUAL_PARTITION宏开关错误作用域引起的功能错误 ([acda419](https://gitee.com/openharmony/kernel_liteos_a/commits/acda419a2d773ea890052a16ee66b4872f941fbb)), closes [#I3W1IW](https://gitee.com/openharmony/kernel_liteos_a/issues/I3W1IW)
* 修复了内核的VFAT测试用例 ([a8384b5](https://gitee.com/openharmony/kernel_liteos_a/commits/a8384b5db2274d50a350910d7cfd3fc36b4f4103)), closes [#I3XF3R](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XF3R)
* 修复内核access chmod chown接口 ([56a95b9](https://gitee.com/openharmony/kernel_liteos_a/commits/56a95b9ec903f815f9199ac65ca318e00a83b2ed)), closes [#I3Z5L6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z5L6)
* 修复内核c库的makefile中被优化函数替换的高频函数依然参与了编译的问题 ([6f6dc4f](https://gitee.com/openharmony/kernel_liteos_a/commits/6f6dc4f24c8ab05a6d42da46a9fa41d74a477bd7)), closes [#I3XGM8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XGM8)
* 修复内核堆完整性检查逻辑中访问非法指针导致系统异常问题。 ([30f5ab8](https://gitee.com/openharmony/kernel_liteos_a/commits/30f5ab89b72d45f596b15af82a8e8e01add7977d)), closes [#I3VJZT](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VJZT)
* 修复启动框架debug模式下-Werror=maybe-uninitialized告警以及符号链接不进镜像的隐患 ([4c02415](https://gitee.com/openharmony/kernel_liteos_a/commits/4c024159a9600745863e49ee955308470a5b657b)), closes [#I3T5HR](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T5HR)
* 修复开机概率挂死 ([2e82c36](https://gitee.com/openharmony/kernel_liteos_a/commits/2e82c361f73b2119613c3571c48faae8ec41d4eb)), closes [#I3SWY2](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SWY2)
* 修复文档链接失效问题 ([42a3a6c](https://gitee.com/openharmony/kernel_liteos_a/commits/42a3a6c51bfca4ade8ce94084ea2f8eb1c86a137)), closes [#I45297](https://gitee.com/openharmony/kernel_liteos_a/issues/I45297)
* 修改/proc/mounts显示格式 ([6860246](https://gitee.com/openharmony/kernel_liteos_a/commits/6860246cfaac6f540665e79bbc4c3d54c419b092)), closes [#I3XGCS](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XGCS)
* 修改clock_gettime接口适配posix标准测试用例011输入clk_id错误时返回值ESRCH为EINVAL. ([f8cf6e6](https://gitee.com/openharmony/kernel_liteos_a/commits/f8cf6e6439ee017fe8e0d4ecfc9949c28fa6775f)), closes [#I3OUHI](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OUHI)
* 修改DoNanoSleep 以纳秒为单位 ([6917e08](https://gitee.com/openharmony/kernel_liteos_a/commits/6917e08431689ccbd5a30e9a39b67016ffb64d0a)), closes [#I3Z9DP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z9DP)
* 修改某些平台保存bbox日志失败的问题 ([8f6a1dd](https://gitee.com/openharmony/kernel_liteos_a/commits/8f6a1dd33c59164070e8d2fb5abbd3e76ef8ac8e)), closes [#I41UTP](https://gitee.com/openharmony/kernel_liteos_a/issues/I41UTP)
* 修改默认窗口宽度到400 ([09c491c](https://gitee.com/openharmony/kernel_liteos_a/commits/09c491ca1fd6d3110eafb0d07e45b25bdc3bd5d0)), closes [#I40LQX](https://gitee.com/openharmony/kernel_liteos_a/issues/I40LQX)
* 关闭jffs和fat后rootfs配置也被相应关闭导致nand介质的rootfs不可用。 ([0ea476b](https://gitee.com/openharmony/kernel_liteos_a/commits/0ea476b9741fabd3c255c2770688f587920cf509)), closes [#I3SBYN](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SBYN)
* 内核态在console初始化完成后使用printf无法正常打印 ([44ce696](https://gitee.com/openharmony/kernel_liteos_a/commits/44ce6969048c2e252f3f9d66fa485c77bdab8ae7)), closes [#I3UG00](https://gitee.com/openharmony/kernel_liteos_a/issues/I3UG00)
* 去掉冗余的strip操作 ([7819d15](https://gitee.com/openharmony/kernel_liteos_a/commits/7819d15b3619681ae37a1349a6bec2440c829ae9)), closes [#I43767](https://gitee.com/openharmony/kernel_liteos_a/issues/I43767)
* 合并进程栈两个地址连续的region ([42f374d](https://gitee.com/openharmony/kernel_liteos_a/commits/42f374dd7a353f1c8227e92fa92827c1c7b32424)), closes [#I43QYJ](https://gitee.com/openharmony/kernel_liteos_a/issues/I43QYJ)
* 在内核提示No idle TCB时增加打印当前系统任务信息以方便问题定位。 ([11a9b00](https://gitee.com/openharmony/kernel_liteos_a/commits/11a9b00d43a6dbe9fba9f6eb07d78a9d226c28f8)), closes [#I434UC](https://gitee.com/openharmony/kernel_liteos_a/issues/I434UC)
* 增加表头,内容以制表符分栏。 ([e9ad6b7](https://gitee.com/openharmony/kernel_liteos_a/commits/e9ad6b71c3b1136414672cd21b339ded7a02dfb9)), closes [#I3W2M9](https://gitee.com/openharmony/kernel_liteos_a/issues/I3W2M9)
* 将用户态内存调测解析脚本移至tools目录下 ([85b4cb7](https://gitee.com/openharmony/kernel_liteos_a/commits/85b4cb7a67b717984d3ebf68115c7139cc61d690)), closes [#I42T9A](https://gitee.com/openharmony/kernel_liteos_a/issues/I42T9A)
* 恢复了FATFS设置卷标的功能 ([9515d53](https://gitee.com/openharmony/kernel_liteos_a/commits/9515d53dccc9a6458bfbaf8e15143928f05cb660)), closes [#I3Y5G8](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Y5G8)
* 解决kill进程时无法保证进程的已持有的内核资源合理释放. ([cf89f01](https://gitee.com/openharmony/kernel_liteos_a/commits/cf89f016e93f28f8d72e6f5de08640d08a155908)), closes [#I3S0N0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3S0N0)
* 解决不同环境下计算的rootfs的size偏小导致mcopy造成的disk full错误 ([c54879b](https://gitee.com/openharmony/kernel_liteos_a/commits/c54879b54875abece53b1f64072cfacbd2e1970e)), closes [#I3IA06](https://gitee.com/openharmony/kernel_liteos_a/issues/I3IA06)
* 设置qemu默认userfs大小/修改qemu驱动目录 ([1d952a2](https://gitee.com/openharmony/kernel_liteos_a/commits/1d952a254a6e7ec2f70f7112eb27355cfd01ba4d)), closes [#I3XW96](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XW96)
### Features
* active mksh & toybox ([cacb4f0](https://gitee.com/openharmony/kernel_liteos_a/commits/cacb4f0103ecb2d1b7af54d84957f88d3e9443d2)), closes [#I3VEOG](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VEOG)
* Add /dev/quickstart to support synchronous communication between processes in user mode startup. ([46b63f7](https://gitee.com/openharmony/kernel_liteos_a/commits/46b63f71537789743ed2f3f337c1809ee4900d71)), closes [#I3OHO5](https://gitee.com/openharmony/kernel_liteos_a/issues/I3OHO5)
* add /proc/fd file to dump the pid/fd/path information ([600dded](https://gitee.com/openharmony/kernel_liteos_a/commits/600dded31e80df275ed08c326c0ce3d1857d8dd8)), closes [#I3WB5U](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WB5U)
* add /proc/fs_cache to display cache info ([231cb6b](https://gitee.com/openharmony/kernel_liteos_a/commits/231cb6be27380948bc48136ae2e02c28450f47a8)), closes [#I3WWBD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WWBD)
* add /proc/fs_cache to display cache info ([53c6d96](https://gitee.com/openharmony/kernel_liteos_a/commits/53c6d96c6f97cb006216769f8b73f50fba3bc325)), closes [#I3WESD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WESD)
* add and fix some syscall ([ce849f2](https://gitee.com/openharmony/kernel_liteos_a/commits/ce849f2145e1569517c5244c9ffcaebed53f3a66))
* add blackbox for liteos_a ([a195aac](https://gitee.com/openharmony/kernel_liteos_a/commits/a195aac9fb60b0163f9eebb29084287d226bd14c)), closes [#I406NP](https://gitee.com/openharmony/kernel_liteos_a/issues/I406NP)
* add blackbox for liteos_a ([425975e](https://gitee.com/openharmony/kernel_liteos_a/commits/425975e4811023e31a520979c20ea2562224d9d0))
* add clear cache cmd to /proc/fs_cache ([3d1cf68](https://gitee.com/openharmony/kernel_liteos_a/commits/3d1cf683f37a6f75e9db2ce1f11ec93159b77663)), closes [#I3XLPH](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XLPH)
* add liteos patch ability ([98ca844](https://gitee.com/openharmony/kernel_liteos_a/commits/98ca8441fe75ee1c3318a6a09376fd72f5a51350))
* add support for gn build system ([a8805a6](https://gitee.com/openharmony/kernel_liteos_a/commits/a8805a65aab9109b915364fccf36c8328f636e48))
* add uid/gid for ProcFs ([6780659](https://gitee.com/openharmony/kernel_liteos_a/commits/67806596a3c0df9a54893d8c74ebe9da98d7fb06)), closes [#I3WGVP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3WGVP)
* A核proc文件系统在echo模式下新增write的功能 ([f10dd7c](https://gitee.com/openharmony/kernel_liteos_a/commits/f10dd7c135d37a5fb0d78610d5ece5807d01eb1f)), closes [#I3T6MZ](https://gitee.com/openharmony/kernel_liteos_a/issues/I3T6MZ)
* build OHOS_Image from kernel ([abf4d8f](https://gitee.com/openharmony/kernel_liteos_a/commits/abf4d8fb252631aca9d46211762880a23be2a0b1))
* **build:** make liteos_config_file available as gn argument ([f9a9077](https://gitee.com/openharmony/kernel_liteos_a/commits/f9a907772f506ca7e2d84e96d4d17cffc7dae50f))
* **build:** 使用xts -notest选项时内核用例不参与编译构建和用例编译配置方式调整 ([9bdf716](https://gitee.com/openharmony/kernel_liteos_a/commits/9bdf716407c125c9877b6f49c2133112c18cdabc))
* don't apply module_swith on configs of config ([f3beb4b](https://gitee.com/openharmony/kernel_liteos_a/commits/f3beb4b273c9a76fbfaffe57302f27d2a74cd2ba))
* enable gn build for toybox and mksh ([c54bfa1](https://gitee.com/openharmony/kernel_liteos_a/commits/c54bfa16e3907482c252e9738192df869c63326e))
* fatfs支持符号链接功能 ([e50cf0b](https://gitee.com/openharmony/kernel_liteos_a/commits/e50cf0be6f6d118022b6d79c5177aece574ba150)), closes [#I3V8D1](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V8D1)
* **file system:** add memory-based romfs ([c4595d2](https://gitee.com/openharmony/kernel_liteos_a/commits/c4595d25042b188570d991a815009764c37f3cb3)), closes [#I3S0CP](https://gitee.com/openharmony/kernel_liteos_a/issues/I3S0CP)
* introduce mksh toybox to rootfs ([41c7689](https://gitee.com/openharmony/kernel_liteos_a/commits/41c7689dfa49c52fb15705ce15ef22a278fbf2ef))
* L0-L1 支持Trace ([dc9ec68](https://gitee.com/openharmony/kernel_liteos_a/commits/dc9ec6856fe14aa604f037f55f17a3ba2bafb098)), closes [#I46WA0](https://gitee.com/openharmony/kernel_liteos_a/issues/I46WA0)
* L1支持低功耗投票框架 ([21d8ac8](https://gitee.com/openharmony/kernel_liteos_a/commits/21d8ac8752469f6e0dc2d50d28b75421f665385a)), closes [#I3VS5N](https://gitee.com/openharmony/kernel_liteos_a/issues/I3VS5N)
* **libc:** upgrade optimized-routines to v21.02 ([1ec8d5a](https://gitee.com/openharmony/kernel_liteos_a/commits/1ec8d5a454658e95c4acb821d0878f357f4e82ad))
* **make:** optimize makefiles and remove some unused files ([0e26094](https://gitee.com/openharmony/kernel_liteos_a/commits/0e260949c962158a263d4b0ad45fe9f6843d6e30))
* Open macro for ADC moudule ([c71ec9d](https://gitee.com/openharmony/kernel_liteos_a/commits/c71ec9d7e8574078a9dc2a8463f3141cca3d625a))
* **QEMU_ARM_VIRT_CA7:** 使能FAT文件系统编译选项 ([49856dc](https://gitee.com/openharmony/kernel_liteos_a/commits/49856dc1e0de1c5e92346c83eda641dfb1bb16be))
* support .mkshrc ([51a50c9](https://gitee.com/openharmony/kernel_liteos_a/commits/51a50c95b4cd47b6931523926b728d1c0ff8988b)), closes [#I3Y5KE](https://gitee.com/openharmony/third_party_mksh/issues/I3Y5KE)
* support link/symlink/readlink ([6eddc86](https://gitee.com/openharmony/kernel_liteos_a/commits/6eddc869d349be59860bfd84ff10b7579a9b00a9)), closes [#I3Q0OD](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Q0OD)
* support toybox in qemu ([5618319](https://gitee.com/openharmony/kernel_liteos_a/commits/561831928bb1ad1871b2d60d2bba2d67488cea5f)), closes [#I3V17D](https://gitee.com/openharmony/kernel_liteos_a/issues/I3V17D)
* timer_create支持以SIGEV_THREAD方式创建定时器 ([e5f6bf0](https://gitee.com/openharmony/kernel_liteos_a/commits/e5f6bf05567c2d193f3746caca502199e7b81e92)), closes [#I3SRFI](https://gitee.com/openharmony/kernel_liteos_a/issues/I3SRFI)
* using kconfiglib instead of kconfig ([8784694](https://gitee.com/openharmony/kernel_liteos_a/commits/878469468647a19f704e7ee2af696b0ba8ab775a))
* vfs support sdcard hotplug ([2db80ec](https://gitee.com/openharmony/kernel_liteos_a/commits/2db80ecb389176b53c77807567895470bb180a06)), closes [#I44WH1](https://gitee.com/openharmony/kernel_liteos_a/issues/I44WH1)
* **vfs:** vfs支持FD_CLOEXEC标记 ([27dca4d](https://gitee.com/openharmony/kernel_liteos_a/commits/27dca4d857ef8de6b4bb9302e0dd435be7e3284f)), closes [#I3U81W](https://gitee.com/openharmony/kernel_liteos_a/issues/I3U81W)
* 删除zpfs冗余代码 ([3393479](https://gitee.com/openharmony/kernel_liteos_a/commits/3393479c52f4a9dfe2394bb32beb4b98fca8e171))
* 基于汇编实现内核对用户态内存清零的功能 ([9db3407](https://gitee.com/openharmony/kernel_liteos_a/commits/9db3407589bb0b2d4a5772faac3130032bc0b8a9)), closes [#I3XXT0](https://gitee.com/openharmony/kernel_liteos_a/issues/I3XXT0)
* 增加mount的MS_RDONLY标志的支持 ([8729f6e](https://gitee.com/openharmony/kernel_liteos_a/commits/8729f6ee57ea57bc664d076ff112c8726fedded9)), closes [#I3Z1W6](https://gitee.com/openharmony/kernel_liteos_a/issues/I3Z1W6)
* 支持killpg和waitid ([dc3cc09](https://gitee.com/openharmony/kernel_liteos_a/commits/dc3cc094a75c6da65d87522930afea06106d3933))
* 新增toybox reboot命令 ([e567a10](https://gitee.com/openharmony/kernel_liteos_a/commits/e567a10d021c3e0fe02d6911dbe8687255c67ffa)), closes [#I3YQ7S](https://gitee.com/openharmony/third_party_toybox/issues/I3YQ7S)
* 给开发者提供系统信息导出Hidumper工具。 ([cb17fa5](https://gitee.com/openharmony/kernel_liteos_a/commits/cb17fa50ed28e6e8f59b7d68ede13c759b983311))
* 自研shell命令回补 ([7bc68f4](https://gitee.com/openharmony/kernel_liteos_a/commits/7bc68f454ff5fbf415712c9b8479b8c832f68417)), closes [#I44U0H](https://gitee.com/openharmony/third_party_toybox/issues/I44U0H)
### Performance Improvements
* assign '-1' to uninitialized variable: ret ([e0a27ba](https://gitee.com/openharmony/kernel_liteos_a/commits/e0a27badde20868cf3a5b4a44305b90af00e4f3f))
### Reverts
* Revert "fix: 修改默认窗口宽度到400" ([1878849](https://gitee.com/openharmony/kernel_liteos_a/commits/187884937cd087e39a28c033c41033163d6b4766)), closes [#I42X9V](https://gitee.com/openharmony/kernel_liteos_a/issues/I42X9V)
### BREAKING CHANGES
* 1.新增一系列trace的对外API位于los_trace.h中.
LOS_TRACE_EASY简易插桩
LOS_TRACE标准插桩
LOS_TraceInit配置Trace缓冲区的地址和大小
LOS_TraceStart开启事件记录
LOS_TraceStop停止事件记录
LOS_TraceRecordDump输出Trace缓冲区数据
LOS_TraceRecordGet获取Trace缓冲区的首地址
LOS_TraceReset清除Trace缓冲区中的事件
LOS_TraceEventMaskSet设置事件掩码仅记录某些模块的事件
LOS_TraceHwiFilterHookReg注册过滤特定中断号事件的钩子函数
* **vfs:** 执行exec类函数后进程拥有的文件描述符情况发生变化修改前默认关闭所有的进程文件描述符012重新打开修改后除非文件描述符拥有FD_CLOEXEC标记否则该描述符不会被关闭。

78
Kconfig
View File

@ -50,7 +50,7 @@ config COMPILER_CLANG_LLVM
config LLVM_TARGET
string "Clang LLVM target"
depends on COMPILER_CLANG_LLVM
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
default "arm-liteos" if ARCH_ARM_AARCH32
endchoice
@ -94,6 +94,15 @@ source "platform/Kconfig"
######################### config options of cpu arch ################
source "arch/Kconfig"
######################### config options of rootfs #####################
source "kernel/common/rootfs/Kconfig"
######################### config options of patchfs #####################
source "kernel/common/patchfs/Kconfig"
######################### config options of blackbox #####################
source "kernel/common/blackbox/Kconfig"
######################### config options of hidumper #####################
source "kernel/common/hidumper/Kconfig"
config QUICK_START
bool "Enable QUICK_START"
default n
@ -114,7 +123,36 @@ endmenu
######################## config options of filesystem ##################
menu "FileSystem"
source "fs/Kconfig"
source "fs/vfs/Kconfig"
source "fs/fat/Kconfig"
source "fs/ramfs/Kconfig"
source "fs/romfs/Kconfig"
source "fs/nfs/Kconfig"
source "fs/proc/Kconfig"
source "fs/jffs2/Kconfig"
source "fs/zpfs/Kconfig"
config ENABLE_READ_BUFFER
bool "Enable read buffer Option"
default n
depends on FS_VFS
help
Answer Y to add enable read buffer Option.
config MAX_VNODE_SIZE
int "Vnode max number"
range 0 512
default 512
depends on FS_VFS
help
vnode number, range from 0 to 512.
config MAX_PATH_CACHE_SIZE
int "PathCache max number"
range 0 1024
default 512
depends on FS_VFS
help
pathCache number, range from 0 to 1024.
endmenu
######################## config options of net ############################
@ -189,7 +227,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 an opposite behaviour compared to release version.
That means you want a opposite behaviour compared to release version.
config DEBUG_KERNEL
bool "Enable Debug LiteOS Kernel Resource"
@ -198,7 +236,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 an opposite behaviour compared to release version.
That means you want a opposite behaviour compared to release version.
config DEBUG_QUEUE
bool "Enable Queue Debugging"
@ -235,12 +273,7 @@ config SCHED_DEBUG
depends on DEBUG_VERSION
help
If you wish to build LiteOS with support for sched debug.
config SCHED_EDF_DEBUG
bool "Enable sched EDF debug Feature"
default n
depends on SCHED_DEBUG
help
If you wish to build LiteOS with support for sched debug.
config USER_INIT_DEBUG
bool "Enable user init Debug"
default n
@ -270,7 +303,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 information 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 infomations of mem node.
config BASE_MEM_NODE_INTEGRITY_CHECK
bool "Enable integrity check or not"
default n
@ -291,10 +324,29 @@ endmenu
######################## config options os drivers ########################
menu "Driver"
source "drivers/Kconfig"
config DRIVERS
bool "Enable Driver"
default y
help
Answer Y to enable LiteOS support driver.
source "bsd/dev/usb/Kconfig"
source "../../drivers/adapter/khdf/liteos/Kconfig"
# Device driver Kconfig import
source "$(DEVICE_PATH)/drivers/Kconfig"
source "drivers/char/mem/Kconfig"
source "drivers/char/quickstart/Kconfig"
source "drivers/char/random/Kconfig"
source "drivers/char/video/Kconfig"
source "drivers/char/trace/Kconfig"
source "../../drivers/liteos/tzdriver/Kconfig"
source "../../drivers/liteos/hievent/Kconfig"
endmenu
######################## config options os security #######################
menu "Security"
source "security/Kconfig"
endmenu

View File

@ -61,6 +61,12 @@ endif
KCONFIG_CONFIG ?= $(CONFIG)
SYSROOT_PATH ?= $(OUT)/sysroot
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
# export los_config.mk related environment variables
export LITEOS_MENUCONFIG_H
export LITEOS_CONFIG_FILE
# export subdir Makefile related environment variables
export SYSROOT_PATH
@ -82,6 +88,9 @@ endif
ifeq ($(LOSCFG_STORAGE_SPINAND), y)
FSTYPE = yaffs2
endif
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
FSTYPE = jffs2
endif
ROOTFS_DIR = $(OUT)/rootfs
ROOTFS_ZIP = $(OUT)/rootfs.zip
@ -94,7 +103,7 @@ Targets:
cleanall: clean all build outputs
all: make liteos kernel image and rootfs image (Default target)
$(APPS): build all apps
$(ROOTFS): make an original rootfs image
$(ROOTFS): make a 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)
@ -116,18 +125,21 @@ help:
sysroot:
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
ifeq ($(origin SYSROOT_PATH),file)
$(HIDE)mkdir -p $(SYSROOT_PATH)/build && cd $(SYSROOT_PATH)/build && \
ln -snf $(LITEOSTOPDIR)/../../third_party/musl/scripts/build_lite/Makefile && \
ln -snf $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/build/Makefile && \
$(MAKE) TARGETS=liteos_a_user \
ARCH=$(ARCH) \
TARGET=$(LOSCFG_LLVM_TARGET) \
ARCH_CFLAGS="$(LITEOS_CORE_COPTS) -w" \
TOPDIR="$(LITEOSTOPDIR)/../.." \
SYSROOTDIR="$(SYSROOT_PATH)" \
$(if $(LOSCFG_COMPILER_CLANG_LLVM),CLANG="$(LITEOS_COMPILER_PATH)clang",GCC="$(CC)") \
CLANG="$(LITEOS_COMPILER_PATH)clang" \
BUILD_ALL_MULTILIB=false \
BUILD_DEBUG=$(if $(patsubst y,,$(or $(RELEASE:1=y),n)),true,false)
endif
endif
$(filter-out menuconfig,$(KCONFIG_CMDS)):
$(HIDE)$@ $(args)

10
OAT.xml
View File

@ -12,10 +12,9 @@
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 by referring 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 refer to OpenHarmony/tools_oat/README.
-->
<configuration>
@ -24,7 +23,6 @@
<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>
@ -39,7 +37,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 license header policies">
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense 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"/-->
@ -65,8 +63,6 @@
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<filteritem type="filepath" name="figures/architecture-of-the-openharmony-liteos-cortex-a-kernel.png" desc="architecture-of-the-openharmony-liteos-cortex-a-kernel"/>
<filteritem type="filepath" name="figures/OpenHarmony-LiteOS-A内核架构图.png" desc="LiteOS-A内核架构图"/>
<!--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

@ -4,10 +4,10 @@
- [Directory Structure](#section161941989596)
- [Constraints](#section119744591305)
- [Usage](#section741617511812)
- [Preparations](#section1579912573329)
- [Source Code Acquisition](#section11443189655)
- [Compilation and Building](#section2081013992812)
- [Contribution](#section1371123476304)
- [Preparations](#section1579912573329)
- [Source Code Acquisition](#section11443189655)
- [Compilation and Building](#section2081013992812)
- [Repositories Involved](#section1371113476307)
## Introduction<a name="section11660541593"></a>
@ -62,38 +62,32 @@ 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: Hi3516D V300
- Hi3516D V300 uses the FAT file system by default.
- 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.
## Usage<a name="section741617511812"></a>
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-appendix-hi3516.md). You can develop and run your applications based on this development board.
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.
### Preparations<a name="section1579912573329"></a>
You need to set up the compilation environment on Ubuntu.
You need to set up the compilation environment on Linux.
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/Readme-EN.md)
- [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).
### Source Code Acquisition<a name="section11443189655"></a>
Download and decompress a set of source code on a Ubuntu server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
Download and decompress a set of source code on a Linux server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
### Compilation and Building<a name="section2081013992812"></a>
For details about how to develop the first application, see: [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)
For details about how to develop the first application, see:
For compilation, please refer to the [compilation instructions](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-pkg-3516-build.md).
- [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)
## Contribution<a name="section1371123476304"></a>
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution-guide.md)
[Commit message spec](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
[C&C++ Secure Coding Guide](https://gitee.com/openharmony/docs/blob/master/en/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
[LiteOS-A Kernel Coding Style Guide](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
- [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)
## Repositories Involved<a name="section1371113476307"></a>
@ -101,5 +95,5 @@ For compilation, please refer to the [compilation instructions](https://gitee.co
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README.md)
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README.md)
**kernel\_liteos\_a**

View File

@ -4,10 +4,10 @@
- [目錄](#section161941989596)
- [約束](#section119744591305)
- [使用說明](#section741617511812)
- [準備](#section1579912573329)
- [獲取源碼](#section11443189655)
- [編譯構建](#section2081013992812)
- [貢獻](#section1371123476304)
- [準備](#section1579912573329)
- [獲取源碼](#section11443189655)
- [編譯構建](#section2081013992812)
- [相關倉](#section1371113476307)
## 簡介<a name="section11660541593"></a>
@ -54,6 +54,7 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
│ ├── hw # 時鐘與中斷相關邏輯代碼
│ ├── include # 對外暴露頭文件存放目錄
│ └── uart # 串口相關邏輯代碼
├── platform # 支持不同的芯片平台代碼如Hi3516DV300等
├── security # 安全特性相關的代碼包括進程權限管理和虛擬id映射管理
├── syscall # 系統調用
└── tools # 構建工具及相關配置和代碼
@ -62,38 +63,32 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
## 約束<a name="section119744591305"></a>
- 開發語言C/C++
- 適用於Hi3516DV300單板
- Hi3516DV300默認使用FAT文件系統。
- 適用於Hi3518EV300、Hi3516DV300單板
- Hi3518EV300默認使用jffs2文件系統Hi3516DV300默認使用FAT文件系統。
## 使用說明<a name="section741617511812"></a>
OpenHarmony LiteOS-A內核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md)單板,開發者可基於此單板開發運行自己的應用程序。
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))單板,開發者可基於兩種單板開發運行自己的應用程序。
### 準備<a name="section1579912573329"></a>
開發者需要在Ubuntu上搭建編譯環境:
開發者需要在Linux上搭建編譯環境:
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md);
- [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)
- Hi3516DV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 獲取源碼<a name="section11443189655"></a>
Ubuntu服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
Linux服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
### 編譯構建<a name="section2081013992812"></a>
開發者開發第一個應用程序可參考:[helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)。
開發者開發第一個應用程序可參考:
編譯可以參考:[編譯指導](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md)
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
## 貢獻<a name="section1371123476304"></a>
[如何貢獻](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
[Commit message規範](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
[OpenHarmony C&C++ 安全編程指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
[LiteOS-A 內核編碼規範指南](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
- [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>
@ -101,4 +96,4 @@ OpenHarmony LiteOS-A內核支持[Hi3516DV300](https://gitee.com/openharmony/docs
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README_zh-HK.md)
**kernel\_liteos\_a**

View File

@ -4,10 +4,10 @@
- [目录](#section161941989596)
- [约束](#section119744591305)
- [使用说明](#section741617511812)
- [准备](#section1579912573329)
- [获取源码](#section11443189655)
- [编译构建](#section2081013992812)
- [贡献](#section1371123476304)
- [准备](#section1579912573329)
- [获取源码](#section11443189655)
- [编译构建](#section2081013992812)
- [相关仓](#section1371113476307)
## 简介<a name="section11660541593"></a>
@ -33,7 +33,6 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
│ ├── quickstart # 系统快速启动接口目录
│ ├── random # 随机数设备驱动
│ └── video # framebuffer驱动框架
├── figures # 内核架构图
├── fs # 文件系统模块主要来源于NuttX开源项目
│ ├── fat # fat文件系统
│ ├── jffs2 # jffs2文件系统
@ -54,50 +53,41 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
│ ├── hw # 时钟与中断相关逻辑代码
│ ├── include # 对外暴露头文件存放目录
│ └── uart # 串口相关逻辑代码
├── platform # 支持不同的芯片平台代码如Hi3516DV300等
├── security # 安全特性相关的代码包括进程权限管理和虚拟id映射管理
├── shell # 接收用户输入的命令,内核去执行
├── syscall # 系统调用
├── testsuilts # 测试套件
└── tools # 构建工具及相关配置和代码
```
## 约束<a name="section119744591305"></a>
- 开发语言C/C++
- 适用于Hi3516DV300单板
- Hi3516DV300默认使用FAT文件系统。
- 适用于Hi3518EV300、Hi3516DV300单板
- Hi3518EV300默认使用jffs2文件系统Hi3516DV300默认使用FAT文件系统。
## 使用说明<a name="section741617511812"></a>
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md)单板。开发者可基于此单板开发运行自己的应用程序。
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))单板,开发者可基于两种单板开发运行自己的应用程序。
### 准备<a name="section1579912573329"></a>
开发者需要在Ubuntu上搭建编译环境:
开发者需要在Linux上搭建编译环境:
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md);
- [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)
- Hi3516DV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 获取源码<a name="section11443189655"></a>
Ubuntu服务器源码获取方式参考: [源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
Linux服务器上下载并解压一套源代码源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
### 编译构建<a name="section2081013992812"></a>
如果这是您的首次应用程序开发,可参考:[helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)。
开发者开发第一个应用程序可参考:
编译可以参考:[编译指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md)
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
测试参考:[单元测试](testsuites/unittest/tools/README.md)
## 贡献<a name="section1371123476304"></a>
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
[Commit message规范](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
[OpenHarmony C&C++ 安全编程指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
[LiteOS-A 内核编码规范指南](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
- [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>
@ -105,5 +95,5 @@ OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README_zh.md)
**kernel\_liteos\_a**

View File

@ -34,8 +34,8 @@ group("apps") {
if (defined(LOSCFG_SHELL)) {
deps += [
"mksh",
"shell",
"mksh",
"toybox",
]
}
@ -51,12 +51,4 @@ group("apps") {
if (defined(LOSCFG_DRIVERS_TRACE)) {
deps += [ "trace" ]
}
if (defined(LOSCFG_DRIVERS_PERF)) {
deps += [ "perf" ]
}
if (defined(LOSCFG_KERNEL_LMS)) {
deps += [ "lms:sample_usr_lms" ]
}
}

View File

@ -34,7 +34,14 @@ export APPSTOPDIR
include $(APPSTOPDIR)/config.mk
all clean:
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir $@ || exit 1; done
all:
ifneq ($(APP_SUBDIRS), )
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
endif
clean:
ifneq ($(APP_SUBDIRS), )
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done
endif
.PHONY: all clean

View File

@ -27,6 +27,88 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
override TARGET = $(OUT)/bin/$(APP_NAME)
OBJOUT := $(BUILD)$(dir $(subst $(LITEOSTOPDIR),,$(shell pwd)))$(APP_NAME)
include $(MODULE)
APP := $(OUT)/bin/$(APP_NAME)
# create a separate list of objects per source type
LOCAL_CSRCS := $(filter %.c,$(LOCAL_SRCS))
LOCAL_CPPSRCS := $(filter %.cpp,$(LOCAL_SRCS))
LOCAL_ASMSRCS := $(filter %.S,$(LOCAL_SRCS))
LOCAL_ASMSRCS2 := $(filter %.s,$(LOCAL_SRCS))
LOCAL_CCSRCS := $(filter %.cc,$(LOCAL_SRCS))
LOCAL_COBJS := $(patsubst %.c,$(OBJOUT)/%.o,$(LOCAL_CSRCS))
LOCAL_CPPOBJS := $(patsubst %.cpp,$(OBJOUT)/%.o,$(LOCAL_CPPSRCS))
LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS))
LOCAL_ASMOBJS2 := $(patsubst %.s,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS2))
LOCAL_CCOBJS := $(patsubst %.cc,$(OBJOUT)/%.o,$(LOCAL_CCSRCS))
LOCAL_OBJS := $(LOCAL_COBJS) $(LOCAL_CPPOBJS) $(LOCAL_ASMOBJS) $(LOCAL_ASMOBJS2) $(LOCAL_CCOBJS)
LOCAL_CGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CHS))
LOCAL_CPPGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CPPHS))
all : $(APP)
define ECHO =
ifeq ($$(HIDE),@)
_$(1) := $($(1))
$(1) = echo " $(1)" $$(patsubst $$(OUT)/%,%,$$@) && $$(_$(1))
endif
endef
$(foreach cmd,CC GPP AS,$(eval $(call ECHO,$(cmd))))
LOCAL_FLAGS += -MD -MP
-include $(LOCAL_OBJS:%.o=%.d)
$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@
$(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_ASMOBJS2): $(OBJOUT)/%.o: %.s
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(AS) $(ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
$(LOCAL_CCOBJS): $(OBJOUT)/%.o: %.cc
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
$(LOCAL_CGCH): %.h.gch : %.h
$(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) $> $^
$(LOCAL_CPPGCH): %.h.gch : %.h
$(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -x c++-header $> $^
LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH)
$(LOCAL_OBJS): $(LOCAL_GCH)
$(APP): $(LOCAL_OBJS)
$(HIDE)$(OBJ_MKDIR)
$(HIDE)$(GPP) $(LDFLAGS) -o $@ $^
clean:
$(HIDE)$(RM) $(APP) $(OBJOUT) $(LOCAL_GCH) *.bak *~
.PHONY: all clean
# clear some variables we set here
LOCAL_CSRCS :=
LOCAL_CPPSRCS :=
LOCAL_ASMSRCS :=
LOCAL_COBJS :=
LOCAL_CPPOBJS :=
LOCAL_ASMOBJS :=
LOCAL_ASMOBJS2 :=
# LOCAL_OBJS is passed back
#LOCAL_OBJS :=

View File

@ -30,7 +30,7 @@
include $(LITEOSTOPDIR)/config.mk
# common flags config
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700 $(LITEOS_GCOV_OPTS)
ASFLAGS :=
CFLAGS := $(LITEOS_COPTS) $(BASE_OPTS) -fPIE
@ -58,10 +58,6 @@ APP_SUBDIRS += mksh
APP_SUBDIRS += toybox
endif
ifeq ($(LOSCFG_KERNEL_LMS), y)
APP_SUBDIRS += lms
endif
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
APP_SUBDIRS += init
endif
@ -74,6 +70,11 @@ ifeq ($(LOSCFG_DRIVERS_TRACE), y)
APP_SUBDIRS += trace
endif
ifeq ($(LOSCFG_DRIVERS_PERF), y)
APP_SUBDIRS += perf
endif
# clear all local variables
LOCAL_FLAGS :=
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_ASFLAGS :=
LOCAL_SRCS :=
LOCAL_CHS :=
LOCAL_CPPHS :=

View File

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

View File

@ -1,77 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/component/lite_component.gni")
lite_component("LMS-Sample") {
features = [ ":sample_usr_lms" ]
}
executable("sample_usr_lms") {
output_name = "sample_usr_lms"
sources = [ "src/sample_usr_lms.c" ]
include_dirs = []
defines = []
if (ohos_build_compiler == "gcc") {
cflags_c = [
"-O0",
"-fsanitize=kernel-address",
"-funwind-tables",
"-fasynchronous-unwind-tables",
]
} else {
cflags_c = [
"-O0",
"-fsanitize=kernel-address",
"-mllvm",
"-asan-instrumentation-with-call-threshold=0",
"-mllvm",
"-asan-stack=0",
"-mllvm",
"-asan-globals=0",
"-funwind-tables",
"-fasynchronous-unwind-tables",
]
}
ldflags = [
"-rdynamic",
"-lunwind",
"-lusrlms",
"-Wl,--wrap=realloc",
"-Wl,--wrap=calloc",
"-Wl,--wrap=malloc",
"-Wl,--wrap=free",
"-Wl,--wrap=valloc",
"-Wl,--wrap=aligned_alloc",
"-Wl,--wrap=memset",
"-Wl,--wrap=memcpy",
"-Wl,--wrap=memmove",
"-Wl,--wrap=strcpy",
"-Wl,--wrap=strcat",
]
deps = [ "$LITEOSTOPDIR/kernel/extended/lms/usr:usrlmslib" ]
}

View File

@ -1,250 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static void BufWriteTest(void *buf, int start, int end)
{
for (int i = start; i <= end; i++) {
((char *)buf)[i] = 'a';
}
}
static void BufReadTest(void *buf, int start, int end)
{
char tmp;
for (int i = start; i <= end; i++) {
tmp = ((char *)buf)[i];
}
}
static void LmsMallocTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsMallocTest Start --------\n");
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");
}
static void LmsReallocTest(void)
{
#define TEST_SIZE 64
#define TEST_SIZE_MIN 32
printf("\n-------- LmsReallocTest Start --------\n");
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); /* 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(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(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);
printf("\n-------- LmsAlignedAllocTest End --------\n");
}
static void LmsMemsetTest(void)
{
#define TEST_SIZE 32
printf("\n-------- LmsMemsetTest Start --------\n");
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(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(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(TEST_SIZE);
if (buf == NULL) {
return;
}
char *testStr = "bbbbbbbbbbbbbbbbb";
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");
}
static void LmsStrcatTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsStrcatTest Start --------\n");
char *buf = (char *)malloc(TEST_SIZE);
if (buf == NULL) {
return;
}
buf[0] = 'a';
buf[1] = 'b';
buf[2] = 0;
char *testStr = "cccccccccccccc";
printf("[LmsStrcatTest] strcat overflow error should be triggered, src string:%s dest string:%s"
"total buf size:%d\n",
testStr, buf, strlen(testStr) + strlen(buf) + 1);
strcat(buf, testStr);
free(buf);
printf("\n-------- LmsStrcatTest End --------\n");
}
static void LmsFreeTest(void)
{
#define TEST_SIZE 16
printf("\n-------- LmsFreeTest Start --------\n");
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 range[1,1]\n");
BufReadTest(buf, 1, 1);
printf("[LmsFreeTest] double free error should be triggered\n");
free(buf);
printf("\n-------- LmsFreeTest End --------\n");
}
int main(int argc, char * const *argv)
{
(void)argc;
(void)argv;
printf("\n############### Lms Test start ###############\n");
char *tmp = (char *)malloc(5000); /* 5000: test mem size */
if (tmp == NULL) {
return -1;
}
LmsMallocTest();
LmsReallocTest();
LmsCallocTest();
LmsVallocTest();
LmsAlignedAllocTest();
LmsMemsetTest();
LmsMemcpyTest();
LmsMemmoveTest();
LmsStrcpyTest();
LmsStrcatTest();
LmsFreeTest();
free(tmp);
printf("\n############### Lms Test End ###############\n");
return 0;
}

View File

@ -29,20 +29,19 @@
import("//build/lite/config/component/lite_component.gni")
import("//kernel/liteos_a/liteos.gni")
import("$THIRDPARTY_MKSH_DIR/mksh.gni")
group("mksh") {
deps = [ ":build_mksh" ]
}
copy("copy_mksh_src") {
sources = MKSH_SRC_DIR
sources = [ "$LITEOSTHIRDPARTY/mksh" ]
outputs = [ "$target_out_dir/mksh_build" ]
}
build_ext_component("build_mksh") {
deps = [ ":copy_mksh_src" ]
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
deps += [ "//prebuilts/lite/sysroot" ]
exec_path = rebase_path("$target_out_dir/mksh_build")
cflags = [

View File

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

View File

@ -1,62 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include $(APPSTOPDIR)/config.mk
APP_NAME := $(notdir $(shell pwd))
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
LOCAL_SRCS = $(wildcard src/*.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
LOCAL_INCLUDE := \
-I include \
-I $(SECUREC_DIR)/include
LOCAL_FLAGS += $(LOCAL_INCLUDE)
ifeq ($(LOSCFG_PERF_HW_PMU), y)
CFLAGS += -DLOSCFG_PERF_HW_PMU
endif
ifeq ($(LOSCFG_PERF_TIMED_PMU), y)
CFLAGS += -DLOSCFG_PERF_TIMED_PMU
endif
ifeq ($(LOSCFG_PERF_SW_PMU), y)
CFLAGS += -DLOSCFG_PERF_SW_PMU
endif
ifeq ($(LOSCFG_FS_VFS), y)
CFLAGS += -DLOSCFG_FS_VFS
endif
CFLAGS += -DLOSCFG_PERF_BUFFER_SIZE=$(LOSCFG_PERF_BUFFER_SIZE)
include $(APP)

View File

@ -1,163 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PERF_H
#define _PERF_H
#include <stdlib.h>
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define PERF_MAX_EVENT 7
#define PERF_MAX_FILTER_TSKS 32
#ifdef PERF_DEBUG
#define printf_debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define printf_debug(fmt, ...)
#endif
/*
* Perf types
*/
enum PerfEventType {
PERF_EVENT_TYPE_HW, /* boards common hw events */
PERF_EVENT_TYPE_TIMED, /* hrtimer timed events */
PERF_EVENT_TYPE_SW, /* software trace events */
PERF_EVENT_TYPE_RAW, /* boards special hw events, see enum PmuEventType in corresponding arch headfile */
PERF_EVENT_TYPE_MAX
};
/*
* Common hardware pmu events
*/
enum PmuHwId {
PERF_COUNT_HW_CPU_CYCLES = 0, /* cpu cycle event */
PERF_COUNT_HW_INSTRUCTIONS, /* instruction event */
PERF_COUNT_HW_DCACHE_REFERENCES, /* dcache access event */
PERF_COUNT_HW_DCACHE_MISSES, /* dcache miss event */
PERF_COUNT_HW_ICACHE_REFERENCES, /* icache access event */
PERF_COUNT_HW_ICACHE_MISSES, /* icache miss event */
PERF_COUNT_HW_BRANCH_INSTRUCTIONS, /* software change of pc event */
PERF_COUNT_HW_BRANCH_MISSES, /* branch miss event */
PERF_COUNT_HW_MAX,
};
/*
* Common hrtimer timed events
*/
enum PmuTimedId {
PERF_COUNT_CPU_CLOCK = 0, /* hrtimer timed event */
};
/*
* Common software pmu events
*/
enum PmuSwId {
PERF_COUNT_SW_TASK_SWITCH = 1, /* task switch event */
PERF_COUNT_SW_IRQ_RESPONSE, /* irq response event */
PERF_COUNT_SW_MEM_ALLOC, /* memory alloc event */
PERF_COUNT_SW_MUX_PEND, /* mutex pend event */
PERF_COUNT_SW_MAX,
};
/*
* perf sample data types
* Config it through PerfConfigAttr->sampleType.
*/
enum PerfSampleType {
PERF_RECORD_CPU = 1U << 0, /* record current cpuid */
PERF_RECORD_TID = 1U << 1, /* record current task id */
PERF_RECORD_TYPE = 1U << 2, /* record event type */
PERF_RECORD_PERIOD = 1U << 3, /* record event period */
PERF_RECORD_TIMESTAMP = 1U << 4, /* record timestamp */
PERF_RECORD_IP = 1U << 5, /* record instruction pointer */
PERF_RECORD_CALLCHAIN = 1U << 6, /* record backtrace */
PERF_RECORD_PID = 1U << 7, /* record current process id */
};
/*
* perf configuration sub event information
*
* This structure is used to config specific events attributes.
*/
typedef struct {
unsigned int type; /* enum PerfEventType */
struct {
unsigned int eventId; /* the specific event corresponds to the PerfEventType */
unsigned int period; /* event period, for every "period"th occurrence of the event a
sample will be recorded */
} events[PERF_MAX_EVENT]; /* perf event list */
unsigned int eventsNr; /* total perf event number */
size_t predivided; /* whether to prescaler (once every 64 counts),
which only take effect on cpu cycle hardware event */
} PerfEventConfig;
/*
* perf configuration main information
*
* This structure is used to set perf sampling attributes, including events, tasks and other information.
*/
typedef struct {
PerfEventConfig eventsCfg; /* perf event config */
unsigned int taskIds[PERF_MAX_FILTER_TSKS]; /* perf task filter list (allowlist) */
unsigned int taskIdsNr; /* task numbers of task filter allowlist,
if set 0 perf will sample all tasks */
unsigned int processIds[PERF_MAX_FILTER_TSKS]; /* perf process filter list (allowlist) */
unsigned int processIdsNr; /* process numbers of process filter allowlist,
if set 0 perf will sample all processes */
unsigned int sampleType; /* type of data to sample defined in PerfSampleType */
size_t needSample; /* whether to sample data */
} PerfConfigAttr;
void PerfUsage(void);
void PerfDumpAttr(PerfConfigAttr *attr);
int PerfConfig(int fd, PerfConfigAttr *attr);
void PerfStart(int fd, size_t sectionId);
void PerfStop(int fd);
ssize_t PerfRead(int fd, char *buf, size_t size);
void PerfPrintBuffer(const char *buf, ssize_t num);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif /* _PERF_H */

View File

@ -1,182 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include "option.h"
#include "perf_list.h"
static int ParseOption(char **argv, int *index, PerfOption *opts)
{
int ret = 0;
const char *str = NULL;
while ((opts->name != NULL) && (*opts->name != 0)) {
if (strcmp(argv[*index], opts->name) == 0) {
switch (opts->type) {
case OPTION_TYPE_UINT:
*opts->value = strtoul(argv[++(*index)], NULL, 0);
break;
case OPTION_TYPE_STRING:
*opts->str = argv[++(*index)];
break;
case OPTION_TYPE_CALLBACK:
str = argv[++(*index)];
if ((*opts->cb)(str) != 0) {
printf("parse error\n");
ret = -1;
}
break;
default:
printf("invalid option\n");
ret = -1;
break;
}
return ret;
}
opts++;
}
return -1;
}
int ParseOptions(int argc, char **argv, PerfOption *opts, SubCmd *cmd)
{
int i;
int index = 0;
while ((index < argc) && (argv[index] != NULL) && (*argv[index] == '-')) {
if (ParseOption(argv, &index, opts) != 0) {
return -1;
}
index++;
}
if ((index < argc) && (argv[index] != NULL)) {
cmd->path = argv[index];
cmd->params[0] = argv[index];
index++;
} else {
printf("no subcmd to execute\n");
return -1;
}
for (i = 1; (index < argc) && (i < CMD_MAX_PARAMS); index++, i++) {
cmd->params[i] = argv[index];
}
printf_debug("subcmd = %s\n", cmd->path);
for (int j = 0; j < i; j++) {
printf_debug("paras[%d]:%s\n", j, cmd->params[j]);
}
return 0;
}
int ParseIds(const char *argv, int *arr, unsigned int *len)
{
int res, ret;
unsigned int index = 0;
char *sp = NULL;
char *this = NULL;
char *list = strdup(argv);
if (list == NULL) {
printf("no memory for ParseIds\n");
return -1;
}
sp = strtok_r(list, ",", &this);
while (sp) {
res = strtoul(sp, NULL, 0);
if (res < 0) {
ret = -1;
goto EXIT;
}
arr[index++] = res;
sp = strtok_r(NULL, ",", &this);
}
*len = index;
ret = 0;
EXIT:
free(list);
return ret;
}
static inline const PerfEvent *StrToEvent(const char *str)
{
const PerfEvent *evt = &g_events[0];
for (; evt->event != -1; evt++) {
if (strcmp(str, evt->name) == 0) {
return evt;
}
}
return NULL;
}
int ParseEvents(const char *argv, PerfEventConfig *eventsCfg, unsigned int *len)
{
int ret;
unsigned int index = 0;
const PerfEvent *event = NULL;
char *sp = NULL;
char *this = NULL;
char *list = strdup(argv);
if (list == NULL) {
printf("no memory for ParseEvents\n");
return -1;
}
sp = strtok_r(list, ",", &this);
while (sp) {
event = StrToEvent(sp);
if (event == NULL) {
ret = -1;
goto EXIT;
}
if (index == 0) {
eventsCfg->type = event->type;
} else if (eventsCfg->type != event->type) {
printf("events type must be same\n");
ret = -1;
goto EXIT;
}
eventsCfg->events[index].eventId = event->event;
sp = strtok_r(NULL, ",", &this);
index++;
}
*len = index;
ret = 0;
EXIT:
free(list);
return ret;
}

View File

@ -1,136 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include "perf.h"
#define PERF_IOC_MAGIC 'T'
#define PERF_START _IO(PERF_IOC_MAGIC, 1)
#define PERF_STOP _IO(PERF_IOC_MAGIC, 2)
void PerfUsage(void)
{
printf("\nUsage: ./perf start [id]. Start perf.\n");
printf("\nUsage: ./perf stop. Stop perf.\n");
printf("\nUsage: ./perf read <nBytes>. Read nBytes raw data from perf buffer and print out.\n");
printf("\nUsage: ./perf list. List events to be used in -e.\n");
printf("\nUsage: ./perf stat/record [option] <command>. \n"
"-e, event selector. use './perf list' to list available events.\n"
"-p, event period.\n"
"-o, perf data output filename.\n"
"-t, taskId filter(allowlist), if not set perf will sample all tasks.\n"
"-s, type of data to sample defined in PerfSampleType los_perf.h.\n"
"-P, processId filter(allowlist), if not set perf will sample all processes.\n"
"-d, whether to prescaler (once every 64 counts),"
"which only take effect on cpu cycle hardware event.\n"
);
}
static void PerfSetPeriod(PerfConfigAttr *attr)
{
int i;
for (i = 1; i < attr->eventsCfg.eventsNr; i++) {
attr->eventsCfg.events[i].period = attr->eventsCfg.events[0].period;
}
}
void PerfPrintBuffer(const char *buf, ssize_t num)
{
#define BYTES_PER_LINE 4
ssize_t i;
for (i = 0; i < num; i++) {
printf(" %02x", (unsigned char)buf[i]);
if (((i + 1) % BYTES_PER_LINE) == 0) {
printf("\n");
}
}
printf("\n");
}
void PerfDumpAttr(PerfConfigAttr *attr)
{
int i;
printf_debug("attr->type: %d\n", attr->eventsCfg.type);
for (i = 0; i < attr->eventsCfg.eventsNr; i++) {
printf_debug("attr->events[%d]: %d, 0x%x\n", i, attr->eventsCfg.events[i].eventId,
attr->eventsCfg.events[i].period);
}
printf_debug("attr->predivided: %d\n", attr->eventsCfg.predivided);
printf_debug("attr->sampleType: 0x%x\n", attr->sampleType);
for (i = 0; i < attr->taskIdsNr; i++) {
printf_debug("attr->taskIds[%d]: %d\n", i, attr->taskIds[i]);
}
for (i = 0; i < attr->processIdsNr; i++) {
printf_debug("attr->processIds[%d]: %d\n", i, attr->processIds[i]);
}
printf_debug("attr->needSample: %d\n", attr->needSample);
}
void PerfStart(int fd, size_t sectionId)
{
(void)ioctl(fd, PERF_START, sectionId);
}
void PerfStop(int fd)
{
(void)ioctl(fd, PERF_STOP, NULL);
}
int PerfConfig(int fd, PerfConfigAttr *attr)
{
if (attr == NULL) {
return -1;
}
PerfSetPeriod(attr);
PerfDumpAttr(attr);
return write(fd, attr, sizeof(PerfConfigAttr));
}
ssize_t PerfRead(int fd, char *buf, size_t size)
{
ssize_t len;
if (buf == NULL) {
printf("Read buffer is null.\n");
return 0;
}
len = read(fd, buf, size);
return len;
}

View File

@ -1,129 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include "perf.h"
#include "perf_list.h"
static const char *g_eventTypeStr[] = {
"[Hardware event]",
"[Timed event]",
"[Software event]",
};
const PerfEvent g_events[] = {
#ifdef LOSCFG_PERF_HW_PMU
{
.name = "cycles",
.event = PERF_COUNT_HW_CPU_CYCLES,
.type = PERF_EVENT_TYPE_HW,
},
{
.name = "instruction",
.event = PERF_COUNT_HW_INSTRUCTIONS,
.type = PERF_EVENT_TYPE_HW,
},
{
.name = "dcache",
.event = PERF_COUNT_HW_DCACHE_REFERENCES,
.type = PERF_EVENT_TYPE_HW,
},
{
.name = "dcache-miss",
.event = PERF_COUNT_HW_DCACHE_MISSES,
.type = PERF_EVENT_TYPE_HW,
},
{
.name = "icache",
.event = PERF_COUNT_HW_ICACHE_REFERENCES,
.type = PERF_EVENT_TYPE_HW,
},
{
.name = "icache-miss",
.event = PERF_COUNT_HW_ICACHE_MISSES,
.type = PERF_EVENT_TYPE_HW,
},
{
.name = "branch",
.event = PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
.type = PERF_EVENT_TYPE_HW,
},
{
.name = "branch-miss",
.event = PERF_COUNT_HW_BRANCH_MISSES,
.type = PERF_EVENT_TYPE_HW,
},
#endif
#ifdef LOSCFG_PERF_TIMED_PMU
{
.name = "clock",
.event = PERF_COUNT_CPU_CLOCK,
.type = PERF_EVENT_TYPE_TIMED,
},
#endif
#ifdef LOSCFG_PERF_SW_PMU
{
.name = "task-switch",
.event = PERF_COUNT_SW_TASK_SWITCH,
.type = PERF_EVENT_TYPE_SW,
},
{
.name = "irq-in",
.event = PERF_COUNT_SW_IRQ_RESPONSE,
.type = PERF_EVENT_TYPE_SW,
},
{
.name = "mem-alloc",
.event = PERF_COUNT_SW_MEM_ALLOC,
.type = PERF_EVENT_TYPE_SW,
},
{
.name = "mux-pend",
.event = PERF_COUNT_SW_MUX_PEND,
.type = PERF_EVENT_TYPE_SW,
},
#endif
{
.name = "",
.event = -1,
.type = PERF_EVENT_TYPE_MAX,
}
};
void PerfList(void)
{
const PerfEvent *evt = &g_events[0];
printf("\n");
for (; evt->event != -1; evt++) {
printf("\t %-25s%30s\n", evt->name, g_eventTypeStr[evt->type]);
}
printf("\n");
}

View File

@ -1,203 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <unistd.h>
#include <sys/wait.h>
#include <securec.h>
#ifdef LOSCFG_FS_VFS
#include <fcntl.h>
#include <errno.h>
#endif
#include "perf.h"
#include "option.h"
#include "perf_record.h"
#define PERF_FILE_MODE 0644
static PerfConfigAttr g_recordAttr;
static const char *g_savePath = "/storage/data/perf.data";
static inline int GetEvents(const char *argv)
{
return ParseEvents(argv, &g_recordAttr.eventsCfg, &g_recordAttr.eventsCfg.eventsNr);
}
static inline int GetTids(const char *argv)
{
return ParseIds(argv, (int *)g_recordAttr.taskIds, &g_recordAttr.taskIdsNr);
}
static inline int GetPids(const char *argv)
{
return ParseIds(argv, (int *)g_recordAttr.processIds, &g_recordAttr.processIdsNr);
}
static PerfOption g_recordOpts[] = {
OPTION_CALLBACK("-e", GetEvents),
OPTION_CALLBACK("-t", GetTids),
OPTION_CALLBACK("-P", GetPids),
OPTION_STRING("-o", &g_savePath),
OPTION_UINT("-p", &g_recordAttr.eventsCfg.events[0].period),
OPTION_UINT("-s", &g_recordAttr.sampleType),
OPTION_UINT("-d", &g_recordAttr.eventsCfg.predivided),
};
static int PerfRecordAttrInit(void)
{
PerfConfigAttr attr = {
.eventsCfg = {
#ifdef LOSCFG_PERF_HW_PMU
.type = PERF_EVENT_TYPE_HW,
.events = {
[0] = {PERF_COUNT_HW_CPU_CYCLES, 0xFFFF},
},
#elif defined LOSCFG_PERF_TIMED_PMU
.type = PERF_EVENT_TYPE_TIMED,
.events = {
[0] = {PERF_COUNT_CPU_CLOCK, 100},
},
#elif defined LOSCFG_PERF_SW_PMU
.type = PERF_EVENT_TYPE_SW,
.events = {
[0] = {PERF_COUNT_SW_TASK_SWITCH, 1},
},
#endif
.eventsNr = 1, /* 1 event */
.predivided = 0,
},
.taskIds = {0},
.taskIdsNr = 0,
.processIds = {0},
.processIdsNr = 0,
.needSample = 1,
.sampleType = PERF_RECORD_IP | PERF_RECORD_CALLCHAIN,
};
return memcpy_s(&g_recordAttr, sizeof(PerfConfigAttr), &attr, sizeof(PerfConfigAttr)) != EOK ? -1 : 0;
}
ssize_t PerfWriteFile(const char *filePath, const char *buf, ssize_t bufSize)
{
#ifdef LOSCFG_FS_VFS
int fd = -1;
ssize_t totalToWrite = bufSize;
ssize_t totalWrite = 0;
if (filePath == NULL || buf == NULL || bufSize == 0) {
return -1;
}
fd = open(filePath, O_CREAT | O_RDWR | O_TRUNC, PERF_FILE_MODE);
if (fd < 0) {
printf("create file [%s] failed, fd: %d, %s!\n", filePath, fd, strerror(errno));
return -1;
}
while (totalToWrite > 0) {
ssize_t writeThisTime = write(fd, buf, totalToWrite);
if (writeThisTime < 0) {
printf("failed to write file [%s], %s!\n", filePath, strerror(errno));
(void)close(fd);
return -1;
}
buf += writeThisTime;
totalToWrite -= writeThisTime;
totalWrite += writeThisTime;
}
(void)fsync(fd);
(void)close(fd);
return (totalWrite == bufSize) ? 0 : -1;
#else
(void)filePath;
PerfPrintBuffer(buf, bufSize);
return 0;
#endif
}
void PerfRecord(int fd, int argc, char **argv)
{
int ret;
int child;
char *buf;
ssize_t len;
SubCmd cmd = {0};
if (argc < 3) { /* perf record argc is at least 3 */
return;
}
ret = PerfRecordAttrInit();
if (ret != 0) {
printf("perf record attr init failed\n");
return;
}
ret = ParseOptions(argc - 2, &argv[2], g_recordOpts, &cmd); /* parse option and cmd begin at index 2 */
if (ret != 0) {
printf("parse error\n");
return;
}
ret = PerfConfig(fd, &g_recordAttr);
if (ret != 0) {
printf("perf config failed\n");
return;
}
PerfStart(fd, 0);
child = fork();
if (child < 0) {
printf("fork error\n");
PerfStop(fd);
return;
} else if (child == 0) {
(void)execve(cmd.path, cmd.params, NULL);
exit(0);
}
waitpid(child, 0, 0);
PerfStop(fd);
buf = (char *)malloc(LOSCFG_PERF_BUFFER_SIZE);
if (buf == NULL) {
printf("no memory for read perf 0x%x\n", LOSCFG_PERF_BUFFER_SIZE);
return;
}
len = PerfRead(fd, buf, LOSCFG_PERF_BUFFER_SIZE);
ret = PerfWriteFile(g_savePath, buf, len);
if (ret == 0) {
printf("save perf data success at %s\n", g_savePath);
} else {
printf("save perf data failed at %s\n", g_savePath);
}
free(buf);
}

View File

@ -1,149 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <unistd.h>
#include <securec.h>
#include <sys/wait.h>
#include "perf.h"
#include "option.h"
#include "perf_stat.h"
static PerfConfigAttr g_statAttr;
static inline int GetEvents(const char *argv)
{
return ParseEvents(argv, &g_statAttr.eventsCfg, &g_statAttr.eventsCfg.eventsNr);
}
static inline int GetTids(const char *argv)
{
return ParseIds(argv, (int *)g_statAttr.taskIds, &g_statAttr.taskIdsNr);
}
static inline int GetPids(const char *argv)
{
return ParseIds(argv, (int *)g_statAttr.processIds, &g_statAttr.processIdsNr);
}
static PerfOption g_statOpts[] = {
OPTION_CALLBACK("-e", GetEvents),
OPTION_CALLBACK("-t", GetTids),
OPTION_CALLBACK("-P", GetPids),
OPTION_UINT("-p", &g_statAttr.eventsCfg.events[0].period),
OPTION_UINT("-s", &g_statAttr.sampleType),
OPTION_UINT("-d", &g_statAttr.eventsCfg.predivided),
};
static int PerfStatAttrInit(void)
{
PerfConfigAttr attr = {
.eventsCfg = {
#ifdef LOSCFG_PERF_HW_PMU
.type = PERF_EVENT_TYPE_HW,
.events = {
[0] = {PERF_COUNT_HW_CPU_CYCLES, 0xFFFF},
[1] = {PERF_COUNT_HW_INSTRUCTIONS, 0xFFFFFF00},
[2] = {PERF_COUNT_HW_ICACHE_REFERENCES, 0xFFFF},
[3] = {PERF_COUNT_HW_DCACHE_REFERENCES, 0xFFFF},
},
.eventsNr = 4, /* 4 events */
#elif defined LOSCFG_PERF_TIMED_PMU
.type = PERF_EVENT_TYPE_TIMED,
.events = {
[0] = {PERF_COUNT_CPU_CLOCK, 100},
},
.eventsNr = 1, /* 1 event */
#elif defined LOSCFG_PERF_SW_PMU
.type = PERF_EVENT_TYPE_SW,
.events = {
[0] = {PERF_COUNT_SW_TASK_SWITCH, 1},
[1] = {PERF_COUNT_SW_IRQ_RESPONSE, 1},
[2] = {PERF_COUNT_SW_MEM_ALLOC, 1},
[3] = {PERF_COUNT_SW_MUX_PEND, 1},
},
.eventsNr = 4, /* 4 events */
#endif
.predivided = 0,
},
.taskIds = {0},
.taskIdsNr = 0,
.processIds = {0},
.processIdsNr = 0,
.needSample = 0,
.sampleType = 0,
};
return memcpy_s(&g_statAttr, sizeof(PerfConfigAttr), &attr, sizeof(PerfConfigAttr)) != EOK ? -1 : 0;
}
void PerfStat(int fd, int argc, char **argv)
{
int ret;
int child;
SubCmd cmd = {0};
if (argc < 3) { /* perf stat argc is at least 3 */
return;
}
ret = PerfStatAttrInit();
if (ret != 0) {
printf("perf stat attr init failed\n");
return;
}
ret = ParseOptions(argc - 2, &argv[2], g_statOpts, &cmd); /* parse option and cmd begin at index 2 */
if (ret != 0) {
printf("parse error\n");
return;
}
ret = PerfConfig(fd, &g_statAttr);
if (ret != 0) {
printf("perf config failed\n");
return;
}
PerfStart(fd, 0);
child = fork();
if (child < 0) {
printf("fork error\n");
goto EXIT;
} else if (child == 0) {
(void)execve(cmd.path, cmd.params, NULL);
exit(0);
}
(void)waitpid(child, 0, 0);
EXIT:
PerfStop(fd);
}

View File

@ -46,7 +46,7 @@ int Chdir(const char *tgtDir)
ret = chdir(tgtDir);
if (ret == 0) {
ret = OsShellSetWorkingDirectory(tgtDir, strlen(tgtDir) + 1); /* 1: the length of '\0' */
ret = OsShellSetWorkingDirtectory(tgtDir, strlen(tgtDir) + 1); /* 1: the length of '\0' */
}
return ret;

View File

@ -53,7 +53,7 @@ typedef struct {
} CmdKeyLink;
#define NEED_NEW_LINE(timesPrint, lineCap) ((timesPrint) % (lineCap) == 0)
#define SCREEN_IS_FULL(timesPrint, lineCap) ((timesPrint) >= ((lineCap) * DEFAULT_SCREEN_HEIGHT))
#define SCREEN_IS_FULL(timesPrint, lineCap) ((timesPrint) >= ((lineCap) * DEFAULT_SCREEN_HEIGNT))
extern unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr);
extern unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size);
@ -62,7 +62,7 @@ extern void OsShellCmdPush(const char *string, CmdKeyLink *cmdKeyLink);
extern void OsShellHistoryShow(unsigned int value, ShellCB *shellCB);
extern unsigned int OsShellKeyInit(ShellCB *shellCB);
extern void OsShellKeyDeInit(CmdKeyLink *cmdKeyLink);
extern int OsShellSetWorkingDirectory(const char *dir, size_t len);
extern int OsShellSetWorkingDirtectory(const char *dir, size_t len);
#ifdef __cplusplus
#if __cplusplus

View File

@ -54,7 +54,7 @@ extern "C" {
#define CMD_HISTORY_LEN 10
#define CMD_MAX_PATH 256
#define DEFAULT_SCREEN_WIDTH 80
#define DEFAULT_SCREEN_HEIGHT 24
#define DEFAULT_SCREEN_HEIGNT 24
#define SWITCH_QUOTES_STATUS(qu) do { \
if ((qu) == TRUE) { \
@ -67,6 +67,7 @@ extern "C" {
#define QUOTES_STATUS_CLOSE(qu) ((qu) == FALSE)
#define QUOTES_STATUS_OPEN(qu) ((qu) == TRUE)
typedef size_t bool;
typedef struct {
unsigned int consoleID;

View File

@ -32,7 +32,9 @@
#ifndef _SHELL_PRI_H
#define _SHELL_PRI_H
#include "shell.h"
#include "sys/types.h"
#include "bits/alltypes.h"
#include "shcmd.h"
#ifdef __cplusplus
#if __cplusplus
@ -40,7 +42,7 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
extern void ShellEntry(ShellCB *shellCB);
extern void *ShellEntry(void *argv);
extern void *ShellTask(void *argv);
#ifdef __cplusplus

View File

@ -32,6 +32,9 @@
#ifndef _SHERR_H
#define _SHERR_H
#include "sys/types.h"
#include "bits/alltypes.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {

View File

@ -32,7 +32,6 @@
#ifndef _SHMSG_H
#define _SHMSG_H
#include "shell_list.h"
#include "shell.h"
#ifdef __cplusplus
@ -47,7 +46,7 @@ extern "C" {
#define SHELL_EXEC_COMMAND "exec"
#define SHELL_EXEC_COMMAND_BYTES 4
#define CMD_EXEC_COMMAND SHELL_EXEC_COMMAND" "
#define CMD_EXEC_COMMAND_BYTES (SHELL_EXEC_COMMAND_BYTES + 1)
#define CMD_EXEC_COMMAND_BYTES (SHELL_EXEC_COMMAND_BYTES+1)
#define CMD_EXIT_COMMAND "exit"
#define CMD_EXIT_COMMAND_BYTES 4
#define CMD_EXIT_CODE_BASE_DEC 10
@ -60,9 +59,10 @@ extern "C" {
#define COLOR_L_RED "\e[1;31m"
#define SHELL_PROMPT COLOR_L_RED"OHOS # "COLOR_NONE
typedef void (* OutputFunc)(const char *fmt, ...);
typedef void (*OutputFunc)(const char *fmt, ...);
extern int ShellTaskInit(ShellCB *shellCB);
extern void ChildExec(const char *cmdName, char *const paramArray[], bool foreground);
extern int ShellEntryInit(ShellCB *shellCB);
extern void ChildExec(const char *cmdName, char *const paramArray[]);
extern void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB);
extern int ShellNotify(ShellCB *shellCB);

View File

@ -42,7 +42,7 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
extern char *OsShellGetWorkingDirectory(void);
extern char *OsShellGetWorkingDirtectory(void);
extern unsigned int OsShellInit(void);
extern int OsShellDeinit(ShellCB *shellCB);
extern ShellCB *OsGetShellCb(void);

View File

@ -31,25 +31,22 @@
#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;
ShellCB *OsGetShellCb(void)
ShellCB *OsGetShellCb()
{
return g_shellCB;
}
static void ShellDeinit(ShellCB *shellCB)
void ShellDeinit(ShellCB *shellCB)
{
(void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex);
@ -65,23 +62,32 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
ret = ShellTaskInit(shellCB);
if (ret != SH_OK) {
return ret;
goto OUT;
}
shellCB->shellEntryHandle = pthread_self();
return 0;
ret = ShellEntryInit(shellCB);
if (ret != SH_OK) {
goto OUT;
}
(void)pthread_join(shellCB->shellTaskHandle, NULL);
(void)pthread_join(shellCB->shellEntryHandle, NULL);
OUT:
ShellDeinit(shellCB);
return ret;
}
static int DoShellExec(char **argv)
@ -92,7 +98,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, FALSE);
ChildExec(argv[1], argv + 1);
}
for (i = 0; argv[i]; i++) {
len += strlen(argv[i]);
@ -102,39 +108,24 @@ static int DoShellExec(char **argv)
if (!cmdLine) {
return ret;
}
errno_t ret1 = memset_s(cmdLine, len, 0, len);
if (ret1 != EOK) {
free(cmdLine);
return ret1;
memset_s(cmdLine, len, 0, len);
for(j = 0; j < i; j++) {
strcat_s(cmdLine, len, argv[j]);
strcat_s(cmdLine, len, " ");
}
for (j = 0; j < i; j++) {
(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 */
cmdLine[len - 2] = '\0';
ret = syscall(__NR_shellexec, argv[0], cmdLine);
free(cmdLine);
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;
@ -144,7 +135,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) {
return SH_NOK;
goto ERR_OUT1;
}
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) {
@ -170,14 +161,7 @@ int main(int argc, char **argv)
sem_init(&shellCB->shellSem, 0, 0);
g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) {
ShellDeinit(shellCB);
g_shellCB = NULL;
return ret;
}
ShellEntry(shellCB);
return OsShellCreateTask(shellCB);
ERR_OUT3:
(void)pthread_mutex_destroy(&shellCB->historyMutex);

View File

@ -36,6 +36,7 @@
#include "dirent.h"
#include "securec.h"
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
#define CTRL_C 0x03 /* 0x03: ctrl+c ASCII */
@ -90,12 +91,12 @@ static int OsStrSeparateTabStrGet(const char **tabStr, CmdParsed *parsed, unsign
return SH_OK;
}
char *OsShellGetWorkingDirectory(void)
char *OsShellGetWorkingDirtectory()
{
return OsGetShellCb()->shellWorkingDirectory;
}
int OsShellSetWorkingDirectory(const char *dir, size_t len)
int OsShellSetWorkingDirtectory(const char *dir, size_t len)
{
if (dir == NULL) {
return SH_NOK;
@ -114,7 +115,7 @@ static int OsStrSeparate(const char *tabStr, char *strPath, char *nameLooking, u
char *strEnd = NULL;
char *cutPos = NULL;
CmdParsed parsed = {0};
char *shellWorkingDirectory = OsShellGetWorkingDirectory();
char *shellWorkingDirectory = OsShellGetWorkingDirtectory();
int ret;
ret = OsStrSeparateTabStrGet(&tabStr, &parsed, tabStrLen);
@ -222,7 +223,7 @@ static int OsPrintMatchList(unsigned int count, const char *strPath, const char
return (int)SH_ERROR;
}
if (count > (lineCap * DEFAULT_SCREEN_HEIGHT)) {
if (count > (lineCap * DEFAULT_SCREEN_HEIGNT)) {
ret = OsSurePrintAll(count);
if (ret != 1) {
return ret;
@ -374,10 +375,10 @@ static int OsTabMatchFile(char *cmdKey, unsigned int *len)
}
/*
* Description: Pass in the string and clear useless space ,which include:
* Description: Pass in the string and clear useless space ,which inlcude:
* 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 character
* 2) Clear all space before first vaild charatctor
* 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
@ -406,17 +407,17 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
/* Backup the 'output' start address */
outputBak = output;
/* Scan each character in 'cmdKey',and squeeze the overmuch space and ignore invalid character */
/* Scan each charactor in 'cmdKey',and squeeze the overmuch space and ignore invaild charactor */
for (; *cmdKey != '\0'; cmdKey++) {
/* Detected a Double Quotes, switch the matching status */
if (*(cmdKey) == '\"') {
SWITCH_QUOTES_STATUS(quotes);
}
/* Ignore the current character in following situation */
/* Ignore the current charactor in following situation */
/* 1) Quotes matching status is FALSE (which said that the space is not been marked by double 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 */
/* 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) Invaild charactor, such as single quotes */
if ((*cmdKey == ' ') && ((*(cmdKey + 1) == ' ') || (*(cmdKey + 1) == '\0')) && QUOTES_STATUS_CLOSE(quotes)) {
continue;
}
@ -430,7 +431,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 character in buffer */
/* Clear the space which is located at the first charactor in buffer */
if (*output == ' ') {
output++;
len--;
@ -584,6 +585,7 @@ 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

@ -133,7 +133,7 @@ int ShellNotify(ShellCB *shellCB)
}
enum {
STAT_NORMAL_KEY,
STAT_NOMAL_KEY,
STAT_ESC_KEY,
STAT_MULTI_KEY
};
@ -152,23 +152,23 @@ static int ShellCmdLineCheckUDRL(const char ch, ShellCB *shellCB)
} else if (ch == 0x41) { /* up */
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
OsShellHistoryShow(CMD_KEY_UP, shellCB);
shellCB->shellKeyType = STAT_NORMAL_KEY;
shellCB->shellKeyType = STAT_NOMAL_KEY;
return ret;
}
} else if (ch == 0x42) { /* down */
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
shellCB->shellKeyType = STAT_NORMAL_KEY;
shellCB->shellKeyType = STAT_NOMAL_KEY;
OsShellHistoryShow(CMD_KEY_DOWN, shellCB);
return ret;
}
} else if (ch == 0x43) { /* right */
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
shellCB->shellKeyType = STAT_NORMAL_KEY;
shellCB->shellKeyType = STAT_NOMAL_KEY;
return ret;
}
} else if (ch == 0x44) { /* left */
if (shellCB->shellKeyType == STAT_MULTI_KEY) {
shellCB->shellKeyType = STAT_NORMAL_KEY;
shellCB->shellKeyType = STAT_NOMAL_KEY;
return ret;
}
}
@ -265,7 +265,7 @@ void ParseNormalChar(char ch, OutputFunc outputFunc, ShellCB *shellCB)
outputFunc("%c", ch);
}
shellCB->shellKeyType = STAT_NORMAL_KEY;
shellCB->shellKeyType = STAT_NOMAL_KEY;
}
void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB)
@ -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 character itself */
/* Ignore the double quote charactor itself */
tmpStr++;
continue;
}
/* If detected a space which the quotes matching status is false */
/* which said has detected the first space for separator, finish this scan operation */
/* which said has detected the first space for seperator, 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[], bool foreground)
void ChildExec(const char *cmdName, char *const paramArray[])
{
int ret;
pid_t gid;
@ -364,15 +364,11 @@ void ChildExec(const char *cmdName, char *const paramArray[], bool foreground)
gid = getpgrp();
if (gid < 0) {
printf("get group id failed, pgrpid %d, errno %d\n", gid, errno);
exit(1);
}
if (!foreground) {
ret = tcsetpgrp(STDIN_FILENO, gid);
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
exit(1);
}
ret = tcsetpgrp(STDIN_FILENO, gid);
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
}
ret = execve(cmdName, paramArray, NULL);
@ -395,7 +391,7 @@ int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
return -1;
}
if (cmdParsed->paramCnt == 1) {
char *p = NULL;
char *p;
ret = strtol(cmdParsed->paramArray[0], &p, CMD_EXIT_CODE_BASE_DEC);
if (*p != '\0') {
printf("exit: bad number: %s\n", cmdParsed->paramArray[0]);
@ -406,30 +402,20 @@ int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
exit(ret);
}
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, CmdParsed *cmdParsed)
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, const 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("Failed to fork from shell\n");
printf("Faild to fork from shell\n");
return;
} else if (forkPid == 0) {
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray, foreground);
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray);
} else {
if (!foreground) {
(void)waitpid(forkPid, 0, 0);
}
waitpid(forkPid, 0, 0);
ret = tcsetpgrp(STDIN_FILENO, getpid());
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
@ -473,7 +459,7 @@ static void ParseAndExecCmdline(CmdParsed *cmdParsed, const char *cmdline, unsig
DoCmdExec(cmdName, cmdlineOrigin, len, cmdParsed);
if (getcwd(shellWorkingDirectory, PATH_MAX) != NULL) {
(void)OsShellSetWorkingDirectory(shellWorkingDirectory, (PATH_MAX + 1));
(void)OsShellSetWorkingDirtectory(shellWorkingDirectory, (PATH_MAX + 1));
}
OUT:
@ -515,7 +501,7 @@ unsigned int PreHandleCmdline(const char *input, char **output, unsigned int *ou
*output = shiftStr;
*outputlen = shiftLen;
/* Check and parse "./", located at the first two characters of the cmd */
/* Check and parse "./", located at the first two charaters of the cmd */
if ((shiftLen > removeLen) && (shiftStr[0] == '.') && (shiftStr[1] == '/')) {
execLen = strlen(execCmd);
newLen = execLen + shiftLen - removeLen; /* i.e., newLen - execLen == shiftLen - removeLen */
@ -579,10 +565,20 @@ 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) {
char *buf = GetCmdline(shellCB);
/* recycle zombine child process */
RecycleZombieChild();
buf = GetCmdline(shellCB);
if (buf == NULL) {
break;
}
@ -656,19 +652,25 @@ static int ShellKernelReg(unsigned int shellHandle)
return ioctl(STDIN_FILENO, CONSOLE_CONTROL_REG_USERTASK, shellHandle);
}
void ShellEntry(ShellCB *shellCB)
void *ShellEntry(void *argv)
{
char ch;
int ret;
int n;
pid_t tid = syscall(__NR_gettid);
ShellCB *shellCB = (ShellCB *)argv;
if (shellCB == NULL) {
return;
return NULL;
}
(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");
@ -681,5 +683,32 @@ void ShellEntry(ShellCB *shellCB)
ShellCmdLineParse(ch, (OutputFunc)printf, shellCB);
}
}
return;
return NULL;
}
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, /* acknowledgment */
TFTPC_OP_ACK, /* acknowledgement */
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 parameters passed to TFTP interfaces are invalid\n",
"Input paramters 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 length greater than 256\n",
"File name lenght 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 length) or greater than 512bytes\n",
"Error when the received packet is less than 4bytes(error lenght) 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 function failed at TFTP client while setting the socket to non-block\n",
"IOCTL fucntion 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 occurred */
return TFTPC_TIMEOUT_ERROR; /* Select timeout occured */
}
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 acknowledgment for write request (put operation)
received packet is acknowledgement 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
}
}
/* INTERFACE to get a file using filename
/* INTEFACE 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 occurred */
/* If select timeout occured */
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 initialize the buffer */
/* First time intialize 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 initialize the buffer */
/* First time intialize 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 occurred */
/* If select timeout occured */
if (ulError == TFTPC_TIMEOUT_ERROR) {
ulTotalTime++;
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
@ -1419,7 +1419,7 @@ err_handler:
}
#ifdef TFTP_TO_RAWMEM
/* INTERFACE to get a file using filename
/* INTEFACE to get a file using filename
ulHostAddr - IP address of Host
szSrcFileName - Source file
szDestMemAddr - The target memory address in the client
@ -1437,8 +1437,10 @@ 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;
@ -1524,7 +1526,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 occurred */
/* If select timeout occured */
if (ulErrCode == TFTPC_TIMEOUT_ERROR) {
ulTotalTime++;
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
@ -1555,7 +1557,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

@ -29,14 +29,13 @@
import("//build/lite/config/component/lite_component.gni")
import("//kernel/liteos_a/liteos.gni")
import("$THIRDPARTY_TOYBOX_DIR/toybox.gni")
group("toybox") {
deps = [ ":build_toybox" ]
}
copy("copy_toybox_src") {
sources = TOYBOX_SRC_DIR
sources = [ "$LITEOSTHIRDPARTY/toybox" ]
outputs = [ "$target_out_dir/toybox_build" ]
}
@ -47,11 +46,8 @@ copy("copy_toybox_config") {
}
build_ext_component("build_toybox") {
deps = [
":copy_toybox_config",
":copy_toybox_src",
]
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
deps = [ ":copy_toybox_src", ":copy_toybox_config" ]
deps += [ "//prebuilts/lite/sysroot" ]
exec_path = rebase_path("$target_out_dir/toybox_build")
cflags = [

View File

@ -31,4 +31,4 @@ import("//kernel/liteos_a/liteos.gni")
executable("trace") {
sources = [ "src/trace.c" ]
}
}

View File

@ -70,10 +70,6 @@ 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");
@ -92,13 +88,11 @@ static void TraceWrite(int fd, int argc, char **argv)
{
int i;
UsrEventInfo info = {0};
info.eventType = strtoul(argv[2], NULL, 0); /* 2, argv number */
info.identity = strtoul(argv[3], NULL, 0); /* 3, argv number */
/* 4, argc -4 means user argv that does not contain argv[0]~argv[3] */
info.eventType = strtoul(argv[2], NULL, 0);
info.identity = strtoul(argv[3], NULL, 0);
int paramNum = (argc - 4) > TRACE_USR_MAX_PARAMS ? TRACE_USR_MAX_PARAMS : (argc - 4);
for (i = 0; i < paramNum; i++) {
/* 4, argc -4 means user argv that does not contain argv[0]~argv[3] */
info.params[i] = strtoul(argv[4 + i], NULL, 0);
}
(void)write(fd, &info, sizeof(UsrEventInfo));
@ -114,22 +108,22 @@ int main(int argc, char **argv)
if (argc == 1) {
TraceUsage();
} else if (argc == 2 && strcmp(argv[1], "start") == 0) { /* 2, argv num, no special meaning */
} else if (argc == 2 && strcmp(argv[1], "start") == 0) {
ioctl(fd, TRACE_START, NULL);
} else if (argc == 2 && strcmp(argv[1], "stop") == 0) { /* 2, argv num, no special meaning */
} else if (argc == 2 && strcmp(argv[1], "stop") == 0) {
ioctl(fd, TRACE_STOP, NULL);
} else if (argc == 2 && strcmp(argv[1], "reset") == 0) { /* 2, argv num, no special meaning */
} else if (argc == 2 && strcmp(argv[1], "reset") == 0) {
ioctl(fd, TRACE_RESET, NULL);
} else if (argc == 3 && strcmp(argv[1], "mask") == 0) { /* 3, argv num, no special meaning */
} else if (argc == 3 && strcmp(argv[1], "mask") == 0) {
size_t mask = strtoul(argv[2], NULL, 0);
ioctl(fd, TRACE_SET_MASK, mask);
} else if (argc == 3 && strcmp(argv[1], "dump") == 0) { /* 3, argv num, no special meaning */
} else if (argc == 3 && strcmp(argv[1], "dump") == 0) {
size_t flag = strtoul(argv[2], NULL, 0);
ioctl(fd, TRACE_DUMP, flag);
} else if (argc == 3 && strcmp(argv[1], "read") == 0) { /* 3, argv num, no special meaning */
} else if (argc == 3 && strcmp(argv[1], "read") == 0) {
size_t size = strtoul(argv[2], NULL, 0);
TraceRead(fd, size);
} else if (argc >= 4 && strcmp(argv[1], "write") == 0) { /* 4, argv num, no special meaning */
} else if (argc >= 4 && strcmp(argv[1], "write") == 0) {
TraceWrite(fd, argc, argv);
} else {
printf("Unsupported trace command.\n");

View File

@ -74,3 +74,12 @@ ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
# expose FPU info to assembly code
ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y)
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_DISABLE
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D16), y)
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D16
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y)
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32
endif

View File

@ -46,10 +46,10 @@ kernel_module(module_name) {
"src/los_hw_runstop.S",
"src/los_hw_tick.c",
"src/los_hwi.c",
"src/smp.c",
"src/strncpy_from_user.c",
"src/strnlen_user.c",
"src/user_copy.c",
"src/smp.c",
]
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
@ -64,10 +64,6 @@ kernel_module(module_name) {
include_dirs = [ "src/include" ]
if (defined(LOSCFG_PERF_HW_PMU)) {
sources += [ "src/pmu/armv7_pmu.c" ]
}
if (defined(LOSCFG_GDB)) {
configs += [ ":as_objs_libc_flags" ]
}
@ -86,11 +82,9 @@ config("as_objs_libc_flags") {
defines = [ "__ASSEMBLY__" ]
# linux style macros
if (defined(LOSCFG_ARCH_ARM_V7A) || defined(LOSCFG_ARCH_ARM_V7R) ||
defined(LOSCFG_ARCH_ARM_V7M)) {
if (defined(LOSCFG_ARCH_ARM_V7A) || defined(LOSCFG_ARCH_ARM_V7R) || defined(LOSCFG_ARCH_ARM_V7M)) {
defines += [ "__LINUX_ARM_ARCH__=7" ]
} else if (defined(LOSCFG_ARCH_ARM_V8A) || defined(LOSCFG_ARCH_ARM_V8R) ||
defined(LOSCFG_ARCH_ARM_V8M)) {
} else if (defined(LOSCFG_ARCH_ARM_V8A) || defined(LOSCFG_ARCH_ARM_V8R) || defined(LOSCFG_ARCH_ARM_V8M)) {
defines += [ "__LINUX_ARM_ARCH__=8" ]
}
}

View File

@ -32,6 +32,11 @@ include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := $(LOSCFG_ARCH_CPU)
LOCAL_SRCS := $(wildcard src/*.c) $(wildcard src/*.S)
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/base/include \
-I $(LITEOSTOPDIR)/kernel/extended/include \
-I $(LITEOSTOPDIR)/kernel/extended/dynload/include \
-I $(LITEOSTOPDIR)/arch/arm/arm/include \
ifeq ($(LOSCFG_ARCH_ARM_VER), "armv7-a")
LOCAL_SRCS += $(wildcard src/armv7a/*.S)
@ -43,11 +48,7 @@ else
LOCAL_SRCS += src/startup/reset_vector_up.S
endif
ifeq ($(LOSCFG_PERF_HW_PMU), y)
LOCAL_SRCS += src/pmu/armv7_pmu.c
endif
LOCAL_FLAGS := $(LOCAL_INCLUDE)
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
AS_OBJS_LIBC_FLAGS = -D__ASSEMBLY__
# linux style macros

View File

@ -46,7 +46,7 @@ extern VOID HalClockInit(VOID);
extern UINT64 HalClockGetCycles(VOID);
extern VOID HalDelayUs(UINT32 usecs);
extern UINT32 HalClockGetTickTimerCycles(VOID);
extern UINT64 HalClockTickTimerReload(UINT64 cycles);
extern VOID HalClockTickTimerReload(UINT64 cycles);
extern UINT32 HrtimersInit(VOID);
extern VOID HrtimerClockIrqClear(VOID);

View File

@ -38,10 +38,7 @@
#define __LOS_ARCH_MMU_H__
#include "los_typedef.h"
#include "los_vm_phys.h"
#ifndef LOSCFG_PAGE_TABLE_FINE_LOCK
#include "los_spinlock.h"
#endif
#include "los_mux.h"
#ifdef __cplusplus
#if __cplusplus
@ -50,9 +47,7 @@ extern "C" {
#endif /* __cplusplus */
typedef struct ArchMmu {
#ifndef LOSCFG_PAGE_TABLE_FINE_LOCK
SPIN_LOCK_S lock; /**< arch mmu page table entry modification spin lock */
#endif
LosMux mtx; /**< arch mmu page table entry modification mutex lock */
VADDR_T *virtTtb; /**< translation table base virtual addr */
PADDR_T physTtb; /**< translation table base phys addr */
UINT32 asid; /**< TLB asid */
@ -76,5 +71,5 @@ VADDR_T *OsGFirstTableGet(VOID);
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* __LOS_ARCH_MMU_H__ */
#endif /* __LOS_VM_PAGE_H__ */

View File

@ -246,7 +246,7 @@ STATIC INLINE INT32 LOS_AtomicIncRet(Atomic *v)
* @brief Atomic auto-decrement.
*
* @par Description:
* This API is used to implement the atomic auto-decrement.
* This API is used to implementating 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 implement the atomic auto-decrement and return the result of auto-decrement.
* This API is used to implementating 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 implement the atomic64 auto-decrement.
* This API is used to implementating 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 implement the atomic64 auto-decrement and return the result of auto-decrement.
* This API is used to implementating the atomic64 auto-decrement and return the result of auto-decrement.
* @attention
* <ul>
* <li>The pointer v must not be NULL.</li>

View File

@ -69,11 +69,6 @@ STATIC INLINE VOID OsClearPte1(PTE_T *pte1Ptr)
OsSavePte1(pte1Ptr, 0);
}
STATIC INLINE PADDR_T OsGetPte1Paddr(PADDR_T PhysTtb, vaddr_t va)
{
return (PhysTtb + (OsGetPte1Index(va) * sizeof(PADDR_T)));
}
STATIC INLINE PTE_T *OsGetPte1Ptr(PTE_T *pte1BasePtr, vaddr_t va)
{
return (pte1BasePtr + OsGetPte1Index(va));

View File

@ -31,6 +31,7 @@
#include "los_hw_pri.h"
#include "los_tick_pri.h"
#include "los_sched_pri.h"
#include "los_sys_pri.h"
#include "gic_common.h"
@ -138,6 +139,11 @@ LITE_OS_SEC_TEXT_INIT VOID HalClockInit(VOID)
LITE_OS_SEC_TEXT_INIT VOID HalClockStart(VOID)
{
UINT32 ret = OsSchedSetTickTimerType(64); /* 64 bit tick timer */
if (ret != LOS_OK) {
return;
}
HalIrqUnmask(OS_TICK_INT_NUM);
/* triggle the first tick */
@ -169,7 +175,7 @@ UINT32 HalClockGetTickTimerCycles(VOID)
return (UINT32)((cval > cycles) ? (cval - cycles) : 0);
}
UINT64 HalClockTickTimerReload(UINT64 cycles)
VOID HalClockTickTimerReload(UINT64 cycles)
{
HalIrqMask(OS_TICK_INT_NUM);
HalIrqClear(OS_TICK_INT_NUM);
@ -179,5 +185,4 @@ UINT64 HalClockTickTimerReload(UINT64 cycles)
TimerCtlWrite(1);
HalIrqUnmask(OS_TICK_INT_NUM);
return cycles;
}

View File

@ -1,108 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _ARMV7_PMU_PRI_H
#define _ARMV7_PMU_PRI_H
#include "los_typedef.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* counters overflow flag status reg */
#define ARMV7_FLAG_MASK 0xffffffff /* Mask for writable bits */
#define ARMV7_OVERFLOWED_MASK ARMV7_FLAG_MASK /* Mask for pmu overflowed */
/* pmnc config reg */
#define ARMV7_PMNC_E (1U << 0) /* Enable all counters */
#define ARMV7_PMNC_P (1U << 1) /* Reset all counters */
#define ARMV7_PMNC_C (1U << 2) /* Cycle counter reset */
#define ARMV7_PMNC_D (1U << 3) /* CCNT counts every 64th cpu cycle */
#define ARMV7_PMNC_X (1U << 4) /* Export to ETM */
#define ARMV7_PMNC_DP (1U << 5) /* Disable CCNT if non-invasive debug */
#define ARMV7_PMNC_MASK 0x3f /* Mask for writable bits */
/* pmxevtyper event selection reg */
#define ARMV7_EVTYPE_MASK 0xc80000ff /* Mask for writable bits */
/* armv7 counters index */
#define ARMV7_IDX_COUNTER0 1
#define ARMV7_IDX_CYCLE_COUNTER 0
#define ARMV7_IDX_MAX_COUNTER 9
#define ARMV7_MAX_COUNTERS 32
#define ARMV7_IDX_COUNTER_LAST (ARMV7_IDX_CYCLE_COUNTER + ARMV7_MAX_COUNTERS - 1)
#define ARMV7_COUNTER_MASK (ARMV7_MAX_COUNTERS - 1)
/* armv7 event counter index mapping */
#define ARMV7_CNT2BIT(x) (1UL << (x))
#define ARMV7_IDX2CNT(x) (((x) - ARMV7_IDX_COUNTER0) & ARMV7_COUNTER_MASK)
enum PmuEventType {
ARMV7_PERF_HW_CYCLES = 0xFF, /* cycles */
ARMV7_PERF_HW_INSTRUCTIONS = 0x08, /* instructions */
ARMV7_PERF_HW_DCACHES = 0x04, /* dcache */
ARMV7_PERF_HW_DCACHE_MISSES = 0x03, /* dcache-misses */
ARMV7_PERF_HW_ICACHES = 0x14, /* icache */
ARMV7_PERF_HW_ICACHE_MISSES = 0x01, /* icache-misses */
ARMV7_PERF_HW_BRANCHES = 0x0C, /* software change of pc */
ARMV7_PERF_HW_BRANCE_MISSES = 0x10, /* branch-misses */
ARMV7_PERF_HW_PRED_BRANCH = 0x12, /* predictable branches */
ARMV7_PERF_HW_NUM_CYC_IRQ = 0x50, /* number of cycles Irqs are interrupted */
ARMV7_PERF_HW_EXC_TAKEN = 0x09, /* exception_taken */
ARMV7_PERF_HW_DATA_READ = 0x06, /* data read */
ARMV7_PERF_HW_DATA_WRITE = 0x07, /* data write */
ARMV7_PERF_HW_STREX_PASSED = 0x80, /* strex passed */
ARMV7_PERF_HW_STREX_FAILED = 0x81, /* strex failed */
ARMV7_PERF_HW_LP_IN_TCM = 0x82, /* literal pool in TCM region */
ARMV7_PERF_HW_DMB_STALL = 0x90, /* DMB stall */
ARMV7_PERF_HW_ITCM_ACCESS = 0x91, /* ITCM access */
ARMV7_PERF_HW_DTCM_ACCESS = 0x92, /* DTCM access */
ARMV7_PERF_HW_DATA_EVICTION = 0x93, /* data eviction */
ARMV7_PERF_HW_SCU = 0x94, /* SCU coherency operation */
ARMV7_PERF_HW_INSCACHE_DEP_DW = 0x95, /* instruction cache dependent stall */
ARMV7_PERF_HW_DATA_CACHE_DEP_STALL = 0x96, /* data cache dependent stall */
ARMV7_PERF_HW_NOCACHE_NO_PER_DEP_STALL = 0x97, /* non-cacheable no peripheral dependent stall */
ARMV7_PERF_HW_NOCACHE_PER_DEP_STALL = 0x98, /* non-Cacheable peripheral dependent stall */
ARMV7_PERF_HW_DATA_CACHE_HP_DEP_STALL = 0x99, /* data cache high priority dependent stall */
ARMV7_PERF_HW_AXI_FAST_PERIPHERAL = 0x9A, /* Accesses_to_AXI_fast_peripheral_port(reads_and_writes) */
};
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _ARMV7_PMU_PRI_H */

View File

@ -44,24 +44,10 @@ extern "C" {
#define OS_SYSTEM_EXC_CURR_CPU 1
#define OS_SYSTEM_EXC_OTHER_CPU 2
#define REGION_PATH_MAX 32
typedef struct {
#ifdef LOSCFG_KERNEL_VM
UINTPTR ip;
UINT32 len; /* f_path length */
CHAR f_path[REGION_PATH_MAX];
#else
UINTPTR ip;
#endif
} IpInfo;
extern UINT32 OsGetSystemStatus(VOID);
extern VOID BackTraceSub(UINTPTR regFP);
extern VOID OsExcInit(VOID);
extern BOOL OsSystemExcIsReset(VOID);
extern UINT32 BackTraceGet(UINTPTR regFP, IpInfo *callChain, UINT32 maxDepth);
extern BOOL OsGetUsrIpInfo(UINTPTR ip, IpInfo *info);
#ifdef __cplusplus
#if __cplusplus

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -102,7 +102,7 @@ typedef struct {
* Return : pointer to the task context
*/
extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfStask, UINT32 parentStackSize);
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize);
extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);

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(UINT16 cpuid, UINT32 index);
extern UINT32 OsGetHwiFormCnt(UINT16 cpuid, UINT32 index);
extern VOID OsIncHwiFormCnt(UINT32 index);
extern UINT32 OsGetHwiFormCnt(UINT32 index);
extern CHAR *OsGetHwiFormName(UINT32 index);
extern VOID OsInterrupt(UINT32 intNum);
extern VOID OsSyscallHandleInit(VOID);

View File

@ -39,21 +39,14 @@
#include "los_pte_ops.h"
#include "los_tlb_v6.h"
#include "los_printf.h"
#include "los_vm_phys.h"
#include "los_vm_common.h"
#include "los_vm_map.h"
#include "los_vm_boot.h"
#include "los_mmu_descriptor_v6.h"
#include "los_process_pri.h"
#ifdef LOSCFG_KERNEL_MMU
typedef struct {
LosArchMmu *archMmu;
VADDR_T *vaddr;
PADDR_T *paddr;
UINT32 *flags;
} MmuMapInfo;
#define TRY_MAX_TIMES 10
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
@ -68,75 +61,6 @@ extern CHAR __mmu_ttlb_begin; /* defined in .ld script */
UINT8 *g_mmuJumpPageTable = (UINT8 *)&__mmu_ttlb_begin; /* temp page table, this is only used when system power up */
#endif
STATIC SPIN_LOCK_S *OsGetPteLock(LosArchMmu *archMmu, PADDR_T paddr, UINT32 *intSave)
{
SPIN_LOCK_S *lock = NULL;
#ifdef LOSCFG_PAGE_TABLE_FINE_LOCK
LosVmPage *vmPage = NULL;
vmPage = OsVmPaddrToPage(paddr);
if (vmPage == NULL) {
return NULL;
}
lock = &vmPage->lock;
#else
lock = &archMmu->lock;
#endif
LOS_SpinLockSave(lock, intSave);
return lock;
}
STATIC SPIN_LOCK_S *OsGetPte1Lock(LosArchMmu *archMmu, PADDR_T paddr, UINT32 *intSave)
{
return OsGetPteLock(archMmu, paddr, intSave);
}
STATIC INLINE VOID OsUnlockPte1(SPIN_LOCK_S *lock, UINT32 intSave)
{
if (lock == NULL) {
return;
}
LOS_SpinUnlockRestore(lock, intSave);
}
STATIC SPIN_LOCK_S *OsGetPte1LockTmp(LosArchMmu *archMmu, PADDR_T paddr, UINT32 *intSave)
{
SPIN_LOCK_S *spinLock = NULL;
#ifdef LOSCFG_PAGE_TABLE_FINE_LOCK
spinLock = OsGetPteLock(archMmu, paddr, intSave);
#else
(VOID)archMmu;
(VOID)paddr;
(VOID)intSave;
#endif
return spinLock;
}
STATIC INLINE VOID OsUnlockPte1Tmp(SPIN_LOCK_S *lock, UINT32 intSave)
{
#ifdef LOSCFG_PAGE_TABLE_FINE_LOCK
if (lock == NULL) {
return;
}
LOS_SpinUnlockRestore(lock, intSave);
#else
(VOID)lock;
(VOID)intSave;
#endif
}
STATIC INLINE SPIN_LOCK_S *OsGetPte2Lock(LosArchMmu *archMmu, PTE_T pte1, UINT32 *intSave)
{
PADDR_T pa = MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(pte1);
return OsGetPteLock(archMmu, pa, intSave);
}
STATIC INLINE VOID OsUnlockPte2(SPIN_LOCK_S *lock, UINT32 intSave)
{
return OsUnlockPte1(lock, intSave);
}
STATIC INLINE PTE_T *OsGetPte2BasePtr(PTE_T pte1)
{
PADDR_T pa = MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(pte1);
@ -248,30 +172,20 @@ STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Pa
#endif
}
STATIC VOID OsTryUnmapL1PTE(LosArchMmu *archMmu, PTE_T *l1Entry, vaddr_t vaddr, UINT32 scanIndex, UINT32 scanCount)
STATIC VOID OsTryUnmapL1PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 scanIndex, UINT32 scanCount)
{
/*
* Check if all pages related to this l1 entry are deallocated.
* We only need to check pages that we did not clear above starting
* from scanIndex and wrapped around SECTION.
* from page_idx and wrapped around SECTION.
*/
UINT32 l1Index;
PTE_T l1Entry;
PTE_T *pte2BasePtr = NULL;
SPIN_LOCK_S *pte1Lock = NULL;
SPIN_LOCK_S *pte2Lock = NULL;
UINT32 pte1IntSave;
UINT32 pte2IntSave;
PTE_T pte1Val;
PADDR_T pte1Paddr;
pte1Paddr = OsGetPte1Paddr(archMmu->physTtb, vaddr);
pte2Lock = OsGetPte2Lock(archMmu, *l1Entry, &pte2IntSave);
if (pte2Lock == NULL) {
return;
}
pte2BasePtr = OsGetPte2BasePtr(*l1Entry);
pte2BasePtr = OsGetPte2BasePtr(OsGetPte1(archMmu->virtTtb, vaddr));
if (pte2BasePtr == NULL) {
OsUnlockPte2(pte2Lock, pte2IntSave);
VM_ERR("pte2 base ptr is NULL");
return;
}
@ -286,27 +200,15 @@ STATIC VOID OsTryUnmapL1PTE(LosArchMmu *archMmu, PTE_T *l1Entry, vaddr_t vaddr,
}
if (!scanCount) {
/*
* The pte1 of kprocess is placed in kernel image when compiled. So the pte1Lock will be null.
* There is no situation to simultaneous access the pte1 of kprocess.
*/
pte1Lock = OsGetPte1LockTmp(archMmu, pte1Paddr, &pte1IntSave);
if (!OsIsPte1PageTable(*l1Entry)) {
OsUnlockPte1Tmp(pte1Lock, pte1IntSave);
OsUnlockPte2(pte2Lock, pte2IntSave);
return;
}
pte1Val = *l1Entry;
/* we can kill l1 entry */
OsClearPte1(l1Entry);
l1Index = OsGetPte1Index(vaddr);
l1Entry = archMmu->virtTtb[l1Index];
/* we can kill l1 entry */
OsClearPte1(&archMmu->virtTtb[l1Index]);
OsArmInvalidateTlbMvaNoBarrier(l1Index << MMU_DESCRIPTOR_L1_SMALL_SHIFT);
/* try to free l2 page itself */
OsPutL2Table(archMmu, l1Index, MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(pte1Val));
OsUnlockPte1Tmp(pte1Lock, pte1IntSave);
OsPutL2Table(archMmu, l1Index, MMU_DESCRIPTOR_L1_PAGE_TABLE_ADDR(l1Entry));
}
OsUnlockPte2(pte2Lock, pte2IntSave);
}
STATIC UINT32 OsCvtSecCacheFlagsToMMUFlags(UINT32 flags)
@ -438,54 +340,34 @@ STATIC VOID OsCvtSecAttsToFlags(PTE_T l1Entry, UINT32 *flags)
}
}
STATIC UINT32 OsUnmapL2PTE(LosArchMmu *archMmu, PTE_T *pte1, vaddr_t vaddr, UINT32 *count)
STATIC UINT32 OsUnmapL2PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 *count)
{
UINT32 unmapCount;
UINT32 pte2Index;
UINT32 intSave;
PTE_T *pte2BasePtr = NULL;
SPIN_LOCK_S *lock = NULL;
pte2BasePtr = OsGetPte2BasePtr(OsGetPte1((PTE_T *)archMmu->virtTtb, vaddr));
if (pte2BasePtr == NULL) {
LOS_Panic("%s %d, pte2 base ptr is NULL\n", __FUNCTION__, __LINE__);
}
pte2Index = OsGetPte2Index(vaddr);
unmapCount = MIN2(MMU_DESCRIPTOR_L2_NUMBERS_PER_L1 - pte2Index, *count);
lock = OsGetPte2Lock(archMmu, *pte1, &intSave);
if (lock == NULL) {
return unmapCount;
}
pte2BasePtr = OsGetPte2BasePtr(*pte1);
if (pte2BasePtr == NULL) {
OsUnlockPte2(lock, intSave);
return unmapCount;
}
/* unmap page run */
OsClearPte2Continuous(&pte2BasePtr[pte2Index], unmapCount);
/* invalidate tlb */
OsArmInvalidateTlbMvaRangeNoBarrier(vaddr, unmapCount);
OsUnlockPte2(lock, intSave);
*count -= unmapCount;
return unmapCount;
}
STATIC UINT32 OsUnmapSection(LosArchMmu *archMmu, PTE_T *l1Entry, vaddr_t *vaddr, UINT32 *count)
STATIC UINT32 OsUnmapSection(LosArchMmu *archMmu, vaddr_t *vaddr, UINT32 *count)
{
UINT32 intSave;
PADDR_T pte1Paddr;
SPIN_LOCK_S *lock = NULL;
pte1Paddr = OsGetPte1Paddr(archMmu->physTtb, *vaddr);
lock = OsGetPte1Lock(archMmu, pte1Paddr, &intSave);
if (!OsIsPte1Section(*l1Entry)) {
OsUnlockPte1(lock, intSave);
return 0;
}
OsClearPte1(OsGetPte1Ptr((PTE_T *)archMmu->virtTtb, *vaddr));
OsArmInvalidateTlbMvaNoBarrier(*vaddr);
OsUnlockPte1(lock, intSave);
*vaddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
*count -= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
@ -502,9 +384,12 @@ BOOL OsArchMmuInit(LosArchMmu *archMmu, VADDR_T *virtTtb)
}
#endif
#ifndef LOSCFG_PAGE_TABLE_FINE_LOCK
LOS_SpinInit(&archMmu->lock);
#endif
status_t retval = LOS_MuxInit(&archMmu->mtx, NULL);
if (retval != LOS_OK) {
VM_ERR("Create mutex for arch mmu failed, status: %d", retval);
return FALSE;
}
LOS_ListInit(&archMmu->ptList);
archMmu->virtTtb = virtTtb;
archMmu->physTtb = (VADDR_T)(UINTPTR)virtTtb - KERNEL_ASPACE_BASE + SYS_MEM_BASE;
@ -553,55 +438,45 @@ STATUS_T LOS_ArchMmuQuery(const LosArchMmu *archMmu, VADDR_T vaddr, PADDR_T *pad
STATUS_T LOS_ArchMmuUnmap(LosArchMmu *archMmu, VADDR_T vaddr, size_t count)
{
PTE_T *l1Entry = NULL;
PTE_T l1Entry;
INT32 unmapped = 0;
UINT32 unmapCount = 0;
INT32 tryTime = TRY_MAX_TIMES;
while (count > 0) {
l1Entry = OsGetPte1Ptr(archMmu->virtTtb, vaddr);
if (OsIsPte1Invalid(*l1Entry)) {
l1Entry = OsGetPte1(archMmu->virtTtb, vaddr);
if (OsIsPte1Invalid(l1Entry)) {
unmapCount = OsUnmapL1Invalid(&vaddr, &count);
} else if (OsIsPte1Section(*l1Entry)) {
} else if (OsIsPte1Section(l1Entry)) {
if (MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(vaddr) && count >= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1) {
unmapCount = OsUnmapSection(archMmu, l1Entry, &vaddr, &count);
unmapCount = OsUnmapSection(archMmu, &vaddr, &count);
} else {
LOS_Panic("%s %d, unimplemented\n", __FUNCTION__, __LINE__);
}
} else if (OsIsPte1PageTable(*l1Entry)) {
unmapCount = OsUnmapL2PTE(archMmu, l1Entry, vaddr, &count);
OsTryUnmapL1PTE(archMmu, l1Entry, vaddr, OsGetPte2Index(vaddr) + unmapCount,
MMU_DESCRIPTOR_L2_NUMBERS_PER_L1);
} else if (OsIsPte1PageTable(l1Entry)) {
unmapCount = OsUnmapL2PTE(archMmu, vaddr, &count);
OsTryUnmapL1PTE(archMmu, vaddr, OsGetPte2Index(vaddr) + unmapCount,
MMU_DESCRIPTOR_L2_NUMBERS_PER_L1 - unmapCount);
vaddr += unmapCount << MMU_DESCRIPTOR_L2_SMALL_SHIFT;
} else {
LOS_Panic("%s %d, unimplemented\n", __FUNCTION__, __LINE__);
}
tryTime = (unmapCount == 0) ? (tryTime - 1) : tryTime;
if (tryTime == 0) {
return LOS_ERRNO_VM_FAULT;
}
unmapped += unmapCount;
}
OsArmInvalidateTlbBarrier();
return unmapped;
}
STATIC UINT32 OsMapSection(MmuMapInfo *mmuMapInfo, UINT32 *count)
STATIC UINT32 OsMapSection(const LosArchMmu *archMmu, UINT32 flags, VADDR_T *vaddr,
PADDR_T *paddr, UINT32 *count)
{
UINT32 mmuFlags = 0;
UINT32 intSave;
PADDR_T pte1Paddr;
SPIN_LOCK_S *lock = NULL;
mmuFlags |= OsCvtSecFlagsToAttrs(*mmuMapInfo->flags);
pte1Paddr = OsGetPte1Paddr(mmuMapInfo->archMmu->physTtb, *mmuMapInfo->vaddr);
lock = OsGetPte1Lock(mmuMapInfo->archMmu, pte1Paddr, &intSave);
OsSavePte1(OsGetPte1Ptr(mmuMapInfo->archMmu->virtTtb, *mmuMapInfo->vaddr),
OsTruncPte1(*mmuMapInfo->paddr) | mmuFlags | MMU_DESCRIPTOR_L1_TYPE_SECTION);
OsUnlockPte1(lock, intSave);
mmuFlags |= OsCvtSecFlagsToAttrs(flags);
OsSavePte1(OsGetPte1Ptr(archMmu->virtTtb, *vaddr),
OsTruncPte1(*paddr) | mmuFlags | MMU_DESCRIPTOR_L1_TYPE_SECTION);
*count -= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
*mmuMapInfo->vaddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
*mmuMapInfo->paddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
*vaddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
*paddr += MMU_DESCRIPTOR_L1_SMALL_SIZE;
return MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
}
@ -642,10 +517,27 @@ STATIC STATUS_T OsGetL2Table(LosArchMmu *archMmu, UINT32 l1Index, paddr_t *ppa)
(VOID)memset_s(kvaddr, MMU_DESCRIPTOR_L2_SMALL_SIZE, 0, MMU_DESCRIPTOR_L2_SMALL_SIZE);
/* get physical address */
*ppa = OsKVaddrToPaddr((VADDR_T)kvaddr) + l2Offset;
*ppa = LOS_PaddrQuery(kvaddr) + l2Offset;
return LOS_OK;
}
STATIC VOID OsMapL1PTE(LosArchMmu *archMmu, PTE_T *pte1Ptr, vaddr_t vaddr, UINT32 flags)
{
paddr_t pte2Base = 0;
if (OsGetL2Table(archMmu, OsGetPte1Index(vaddr), &pte2Base) != LOS_OK) {
LOS_Panic("%s %d, failed to allocate pagetable\n", __FUNCTION__, __LINE__);
}
*pte1Ptr = pte2Base | MMU_DESCRIPTOR_L1_TYPE_PAGE_TABLE;
if (flags & VM_MAP_REGION_FLAG_NS) {
*pte1Ptr |= MMU_DESCRIPTOR_L1_PAGETABLE_NON_SECURE;
}
*pte1Ptr &= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_MASK;
*pte1Ptr |= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT; // use client AP
OsSavePte1(OsGetPte1Ptr(archMmu->virtTtb, vaddr), *pte1Ptr);
}
STATIC UINT32 OsCvtPte2CacheFlagsToMMUFlags(UINT32 flags)
{
UINT32 mmuFlags = 0;
@ -726,93 +618,32 @@ STATIC UINT32 OsCvtPte2FlagsToAttrs(UINT32 flags)
return mmuFlags;
}
STATIC UINT32 OsMapL1PTE(MmuMapInfo *mmuMapInfo, PTE_T *l1Entry, UINT32 *count)
{
PADDR_T pte2Base = 0;
PADDR_T pte1Paddr;
SPIN_LOCK_S *pte1Lock = NULL;
SPIN_LOCK_S *pte2Lock = NULL;
PTE_T *pte2BasePtr = NULL;
UINT32 saveCounts, archFlags, pte1IntSave, pte2IntSave;
pte1Paddr = OsGetPte1Paddr(mmuMapInfo->archMmu->physTtb, *mmuMapInfo->vaddr);
pte1Lock = OsGetPte1Lock(mmuMapInfo->archMmu, pte1Paddr, &pte1IntSave);
if (!OsIsPte1Invalid(*l1Entry)) {
OsUnlockPte1(pte1Lock, pte1IntSave);
return 0;
}
if (OsGetL2Table(mmuMapInfo->archMmu, OsGetPte1Index(*mmuMapInfo->vaddr), &pte2Base) != LOS_OK) {
LOS_Panic("%s %d, failed to allocate pagetable\n", __FUNCTION__, __LINE__);
}
*l1Entry = pte2Base | MMU_DESCRIPTOR_L1_TYPE_PAGE_TABLE;
if (*mmuMapInfo->flags & VM_MAP_REGION_FLAG_NS) {
*l1Entry |= MMU_DESCRIPTOR_L1_PAGETABLE_NON_SECURE;
}
*l1Entry &= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_MASK;
*l1Entry |= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT; // use client AP
OsSavePte1(OsGetPte1Ptr(mmuMapInfo->archMmu->virtTtb, *mmuMapInfo->vaddr), *l1Entry);
OsUnlockPte1(pte1Lock, pte1IntSave);
pte2Lock = OsGetPte2Lock(mmuMapInfo->archMmu, *l1Entry, &pte2IntSave);
if (pte2Lock == NULL) {
LOS_Panic("pte2 should not be null!\n");
}
pte2BasePtr = (PTE_T *)LOS_PaddrToKVaddr(pte2Base);
/* compute the arch flags for L2 4K pages */
archFlags = OsCvtPte2FlagsToAttrs(*mmuMapInfo->flags);
saveCounts = OsSavePte2Continuous(pte2BasePtr, OsGetPte2Index(*mmuMapInfo->vaddr), *mmuMapInfo->paddr | archFlags,
*count);
OsUnlockPte2(pte2Lock, pte2IntSave);
*mmuMapInfo->paddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
*mmuMapInfo->vaddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
*count -= saveCounts;
return saveCounts;
}
STATIC UINT32 OsMapL2PageContinous(MmuMapInfo *mmuMapInfo, PTE_T *pte1, UINT32 *count)
STATIC UINT32 OsMapL2PageContinous(PTE_T pte1, UINT32 flags, VADDR_T *vaddr, PADDR_T *paddr, UINT32 *count)
{
PTE_T *pte2BasePtr = NULL;
UINT32 archFlags;
UINT32 saveCounts;
UINT32 intSave;
SPIN_LOCK_S *lock = NULL;
lock = OsGetPte2Lock(mmuMapInfo->archMmu, *pte1, &intSave);
if (lock == NULL) {
return 0;
}
pte2BasePtr = OsGetPte2BasePtr(*pte1);
pte2BasePtr = OsGetPte2BasePtr(pte1);
if (pte2BasePtr == NULL) {
OsUnlockPte2(lock, intSave);
return 0;
LOS_Panic("%s %d, pte1 %#x error\n", __FUNCTION__, __LINE__, pte1);
}
/* compute the arch flags for L2 4K pages */
archFlags = OsCvtPte2FlagsToAttrs(*mmuMapInfo->flags);
saveCounts = OsSavePte2Continuous(pte2BasePtr, OsGetPte2Index(*mmuMapInfo->vaddr), *mmuMapInfo->paddr | archFlags,
*count);
OsUnlockPte2(lock, intSave);
*mmuMapInfo->paddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
*mmuMapInfo->vaddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
archFlags = OsCvtPte2FlagsToAttrs(flags);
saveCounts = OsSavePte2Continuous(pte2BasePtr, OsGetPte2Index(*vaddr), *paddr | archFlags, *count);
*paddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
*vaddr += (saveCounts << MMU_DESCRIPTOR_L2_SMALL_SHIFT);
*count -= saveCounts;
return saveCounts;
}
status_t LOS_ArchMmuMap(LosArchMmu *archMmu, VADDR_T vaddr, PADDR_T paddr, size_t count, UINT32 flags)
{
PTE_T *l1Entry = NULL;
PTE_T l1Entry;
UINT32 saveCounts = 0;
INT32 mapped = 0;
INT32 tryTime = TRY_MAX_TIMES;
INT32 checkRst;
MmuMapInfo mmuMapInfo = {
.archMmu = archMmu,
.vaddr = &vaddr,
.paddr = &paddr,
.flags = &flags,
};
checkRst = OsMapParamCheck(flags, vaddr, paddr);
if (checkRst < 0) {
@ -821,27 +652,24 @@ status_t LOS_ArchMmuMap(LosArchMmu *archMmu, VADDR_T vaddr, PADDR_T paddr, size_
/* see what kind of mapping we can use */
while (count > 0) {
if (MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(*mmuMapInfo.vaddr) &&
MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(*mmuMapInfo.paddr) &&
if (MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(vaddr) &&
MMU_DESCRIPTOR_IS_L1_SIZE_ALIGNED(paddr) &&
count >= MMU_DESCRIPTOR_L2_NUMBERS_PER_L1) {
/* compute the arch flags for L1 sections cache, r ,w ,x, domain and type */
saveCounts = OsMapSection(&mmuMapInfo, &count);
saveCounts = OsMapSection(archMmu, flags, &vaddr, &paddr, &count);
} else {
/* have to use a L2 mapping, we only allocate 4KB for L1, support 0 ~ 1GB */
l1Entry = OsGetPte1Ptr(archMmu->virtTtb, *mmuMapInfo.vaddr);
if (OsIsPte1Invalid(*l1Entry)) {
saveCounts = OsMapL1PTE(&mmuMapInfo, l1Entry, &count);
} else if (OsIsPte1PageTable(*l1Entry)) {
saveCounts = OsMapL2PageContinous(&mmuMapInfo, l1Entry, &count);
l1Entry = OsGetPte1(archMmu->virtTtb, vaddr);
if (OsIsPte1Invalid(l1Entry)) {
OsMapL1PTE(archMmu, &l1Entry, vaddr, flags);
saveCounts = OsMapL2PageContinous(l1Entry, flags, &vaddr, &paddr, &count);
} else if (OsIsPte1PageTable(l1Entry)) {
saveCounts = OsMapL2PageContinous(l1Entry, flags, &vaddr, &paddr, &count);
} else {
LOS_Panic("%s %d, unimplemented tt_entry %x\n", __FUNCTION__, __LINE__, l1Entry);
}
}
mapped += saveCounts;
tryTime = (saveCounts == 0) ? (tryTime - 1) : tryTime;
if (tryTime == 0) {
return LOS_ERRNO_VM_TIMED_OUT;
}
}
return mapped;
@ -888,7 +716,7 @@ STATUS_T LOS_ArchMmuMove(LosArchMmu *archMmu, VADDR_T oldVaddr, VADDR_T newVaddr
PADDR_T paddr = 0;
if ((archMmu == NULL) || (oldVaddr == 0) || (newVaddr == 0) || (count == 0)) {
VM_ERR("invalid args: archMmu %p, oldVaddr %p, newVaddr %p, count %d",
VM_ERR("invalid args: archMmu %p, oldVaddr %p, newVddr %p, count %d",
archMmu, oldVaddr, newVaddr, count);
return LOS_NOK;
}
@ -965,6 +793,7 @@ STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
OsArmWriteTlbiasidis(archMmu->asid);
OsFreeAsid(archMmu->asid);
#endif
(VOID)LOS_MuxDestroy(&archMmu->mtx);
return LOS_OK;
}
@ -1033,7 +862,7 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
LosVmSpace *kSpace = LOS_GetKVmSpace();
status_t status;
UINT32 length;
INT32 i;
int i;
LosArchMmuInitMapping *kernelMap = NULL;
UINT32 kmallocLength;
UINT32 flags;
@ -1137,3 +966,4 @@ VOID OsInitMappingStartUp(VOID)
}
#endif

View File

@ -147,14 +147,6 @@ OsIrqHandler:
/* disable irq, switch to svc mode */
CPSID i, #0x13
#ifdef LOSCFG_KERNEL_PERF
PUSH {R0-R3, R12, LR}
MOV R0, LR
MOV R1, FP
BL OsPerfSetIrqRegs
POP {R0-R3, R12, LR}
#endif
STMFD SP!, {R0-R3, R12, LR}
STMFD SP, {R13, R14}^
SUB SP, SP, #(4 * 4)

View File

@ -33,7 +33,6 @@
#include "los_memory_pri.h"
#include "los_printf_pri.h"
#include "los_task_pri.h"
#include "los_percpu_pri.h"
#include "los_hw_pri.h"
#ifdef LOSCFG_SAVE_EXCINFO
#include "los_excinfo_pri.h"
@ -59,7 +58,6 @@
#include "los_bitmap.h"
#include "los_process_pri.h"
#include "los_exc_pri.h"
#include "los_sched_pri.h"
#ifdef LOSCFG_FS_VFS
#include "console.h"
#endif
@ -74,7 +72,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,7 +86,6 @@ 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
@ -113,11 +110,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;
@ -194,7 +191,7 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
return LOS_ERRNO_VM_NOT_FOUND;
}
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
BOOL irqEnable = !(LOS_SpinHeld(&g_taskSpin) && OsSchedIsLock());
BOOL irqEnable = !(LOS_SpinHeld(&g_taskSpin) && (OsPercpuGet()->taskLockCnt != 0));
if (irqEnable) {
ArchIrqEnable();
} else {
@ -248,7 +245,7 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
STATIC VOID OsExcType(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr)
{
/* undefined exception handling or software interrupt */
/* undefinited exception handling or software interrupt */
if ((excType == OS_EXCEPT_UNDEF_INSTR) || (excType == OS_EXCEPT_SWI)) {
if ((excBufAddr->regCPSR & INSTR_SET_MASK) == 0) { /* work status: ARM */
excBufAddr->PC = excBufAddr->PC - ARM_INSTR_LEN;
@ -458,7 +455,7 @@ STATIC VOID OsDumpExcVaddrRegion(LosVmSpace *space, LosVmMapRegion *region)
mmuFlag = FALSE;
}
PrintExcInfo(" 0x%08x 0x%08x 0x%08x\n",
startVaddr, LOS_PaddrToKVaddr(startPaddr), (UINT32)pageCount << PAGE_SHIFT);
startVaddr, (UINTPTR)LOS_PaddrToKVaddr(startPaddr), (UINT32)pageCount << PAGE_SHIFT);
pageCount = 0;
startPaddr = 0;
}
@ -483,7 +480,7 @@ STATIC VOID OsDumpProcessUsedMemRegion(LosProcessCB *runProcess, LosVmSpace *run
RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNodeTemp, pstRbNodeNext)
}
STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFlags)
STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFalgs)
{
LosProcessCB *runProcess = NULL;
LosVmSpace *runspace = NULL;
@ -504,7 +501,7 @@ STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFlags)
return;
}
OsDumpProcessUsedMemRegion(runProcess, runspace, vmmFlags);
OsDumpProcessUsedMemRegion(runProcess, runspace, vmmFalgs);
return;
}
#endif
@ -517,22 +514,13 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
return;
}
for (excReg = &(excBufAddr->R0); count < COM_REGS; excReg++, count++) {
for (excReg = &(excBufAddr->R0); count <= DUMPREGS; excReg++, count++) {
if (IS_VALID_ADDR(*excReg)) {
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
PrintExcInfo("\ndump mem around R%u:0x%x", 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)));
@ -541,15 +529,15 @@ 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);
OsPercpuGet()->excFlag = CPU_RUNNING;
#endif
OsSchedLockSet(0);
OsPercpuGet()->taskLockCnt = 0;
}
STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
@ -566,16 +554,17 @@ 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
runProcess->processStatus &= ~OS_PROCESS_FLAG_EXIT;
#ifdef LOSCFG_KERNEL_SMP
#ifdef LOSCFG_FS_VFS
@ -592,14 +581,14 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
#endif
OsProcessExitCodeSignalSet(runProcess, SIGUSR2);
/* An exception was raised by a task during the exit process of
/* An exception was raised by a task that is not the current main thread during the exit process of
* the current process.
*/
if (runProcess->processStatus & OS_PROCESS_FLAG_EXIT) {
if ((runProcess->processStatus & OS_PROCESS_FLAG_EXIT) && (runProcess->threadGroupID != runTask->taskID)) {
SCHEDULER_UNLOCK(intSave);
/* Exception handling All operations should be kept prior to that operation */
OsExcRestore();
OsRunningTaskToExit(runTask, OS_PRO_EXIT_OK);
OsTaskToExit(runTask, OS_PRO_EXIT_OK);
} else {
SCHEDULER_UNLOCK(intSave);
@ -655,7 +644,6 @@ 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;
@ -666,7 +654,6 @@ 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++) {
@ -704,66 +691,20 @@ FOUND:
return found;
}
BOOL OsGetUsrIpInfo(UINTPTR ip, IpInfo *info)
{
if (info == NULL) {
return FALSE;
}
#ifdef LOSCFG_KERNEL_VM
BOOL ret = FALSE;
const CHAR *name = NULL;
LosVmMapRegion *region = NULL;
LosProcessCB *runProcess = OsCurrProcessGet();
if (LOS_IsUserAddress((VADDR_T)ip) == FALSE) {
info->ip = ip;
name = "kernel";
ret = FALSE;
goto END;
}
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)ip);
if (region == NULL) {
info->ip = ip;
name = "invalid";
ret = FALSE;
goto END;
}
info->ip = ip - OsGetTextRegionBase(region, runProcess);
name = OsGetRegionNameOrFilePath(region);
ret = TRUE;
if (strcmp(name, "/lib/libc.so") != 0) {
PRINT_ERR("ip = 0x%x, %s\n", info->ip, name);
}
END:
info->len = strlen(name);
if (strncpy_s(info->f_path, REGION_PATH_MAX, name, REGION_PATH_MAX - 1) != EOK) {
info->f_path[0] = '\0';
info->len = 0;
PRINT_ERR("copy f_path failed, %s\n", name);
}
return ret;
#else
info->ip = ip;
return FALSE;
#endif
}
UINT32 BackTraceGet(UINTPTR regFP, IpInfo *callChain, UINT32 maxDepth)
VOID BackTraceSub(UINTPTR regFP)
{
UINTPTR tmpFP, backLR;
UINTPTR stackStart, stackEnd;
UINTPTR backFP = regFP;
UINT32 count = 0;
BOOL ret;
VADDR_T kvaddr;
#ifdef LOSCFG_KERNEL_VM
LosProcessCB *runProcess = OsCurrProcessGet();
#endif
if (FindSuitableStack(regFP, &stackStart, &stackEnd, &kvaddr) == FALSE) {
if (callChain == NULL) {
PrintExcInfo("traceback error fp = 0x%x\n", regFP);
}
return 0;
PrintExcInfo("traceback error fp = 0x%x\n", regFP);
return;
}
/*
@ -775,9 +716,7 @@ UINT32 BackTraceGet(UINTPTR regFP, IpInfo *callChain, UINT32 maxDepth)
tmpFP = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidFP(tmpFP, stackStart, stackEnd, NULL) == TRUE) {
backFP = tmpFP;
if (callChain == NULL) {
PrintExcInfo("traceback fp fixed, trace using fp = 0x%x\n", backFP);
}
PrintExcInfo("traceback fp fixed, trace using fp = 0x%x\n", backFP);
}
while (IsValidFP(backFP, stackStart, stackEnd, &kvaddr) == TRUE) {
@ -785,49 +724,38 @@ UINT32 BackTraceGet(UINTPTR regFP, IpInfo *callChain, UINT32 maxDepth)
#ifdef LOSCFG_COMPILER_CLANG_LLVM
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidFP(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
if (callChain == NULL) {
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
}
return 0;
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
return;
}
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
#else
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidFP(tmpFP - POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
if (callChain == NULL) {
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
}
return 0;
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
return;
}
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
#endif
IpInfo info = {0};
ret = OsGetUsrIpInfo((VADDR_T)backLR, &info);
if (callChain == NULL) {
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x ", count, backLR, backFP);
if (ret) {
#ifdef LOSCFG_KERNEL_VM
PrintExcInfo("lr in %s --> 0x%x\n", info.f_path, info.ip);
#else
PrintExcInfo("\n");
LosVmMapRegion *region = NULL;
if (LOS_IsUserAddress((VADDR_T)backLR) == TRUE) {
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)backLR);
}
if (region != NULL) {
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x lr in %s --> 0x%x\n", count, backLR, backFP,
OsGetRegionNameOrFilePath(region),
backLR - OsGetTextRegionBase(region, runProcess));
region = NULL;
} else
#endif
} else {
PrintExcInfo("\n");
}
} else {
(VOID)memcpy_s(&callChain[count], sizeof(IpInfo), &info, sizeof(IpInfo));
{
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x\n", count, backLR, backFP);
}
count++;
if ((count == maxDepth) || (backFP == tmpFP)) {
if ((count == OS_MAX_BACKTRACE) || (backFP == tmpFP)) {
break;
}
}
return count;
}
VOID BackTraceSub(UINTPTR regFP)
{
(VOID)BackTraceGet(regFP, NULL, OS_MAX_BACKTRACE);
}
VOID BackTrace(UINT32 regFP)
@ -884,7 +812,7 @@ VOID OsCallStackInfo(VOID)
PrintExcInfo("runTask->stackPointer = 0x%x\n"
"runTask->topOfStack = 0x%x\n"
"text_start:0x%x,text_end:0x%x\n",
stackPointer, runTask->topOfStack, &__text_start, &__text_end);
(UINTPTR)stackPointer, runTask->topOfStack, &__text_start, &__text_end);
while ((stackPointer > (UINT32 *)runTask->topOfStack) && (count < OS_MAX_BACKTRACE)) {
if ((*stackPointer > (UINTPTR)(&__text_start)) &&
@ -991,14 +919,36 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
#define EXC_WAIT_INTER 50U
#define EXC_WAIT_TIME 2000U
STATIC VOID WaitAllCpuStop(UINT32 cpuid)
STATIC VOID OsAllCpuStatusOutput(VOID)
{
UINT32 i;
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
switch (g_percpu[i].excFlag) {
case CPU_RUNNING:
PrintExcInfo("cpu%u is running.\n", i);
break;
case CPU_HALT:
PrintExcInfo("cpu%u is halted.\n", i);
break;
case CPU_EXC:
PrintExcInfo("cpu%u is in exc.\n", i);
break;
default:
break;
}
}
PrintExcInfo("The current handling the exception is cpu%u !\n", ArchCurrCpuid());
}
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) && (g_percpu[i].excFlag != CPU_HALT)) {
LOS_Mdelay(EXC_WAIT_INTER);
time += EXC_WAIT_INTER;
break;
@ -1012,19 +962,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);
@ -1033,25 +983,25 @@ STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuid)
STATIC VOID OsCheckAllCpuStatus(VOID)
{
UINT32 currCpuid = ArchCurrCpuid();
UINT32 currCpuID = ArchCurrCpuid();
UINT32 ret, target;
OsCpuStatusSet(CPU_EXC);
OsPercpuGet()->excFlag = CPU_EXC;
LOCKDEP_CLEAR_LOCKS();
LOS_SpinLock(&g_excSerializerSpin);
/* Only the current CPU anomaly */
if (g_currHandleExcCpuid == INVALID_CPUID) {
g_currHandleExcCpuid = currCpuid;
/* Only the current nuclear anomaly */
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
*/
@ -1063,12 +1013,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);
@ -1078,7 +1028,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
}
@ -1089,7 +1039,7 @@ STATIC VOID OsCheckCpuStatus(VOID)
#ifdef LOSCFG_KERNEL_SMP
OsCheckAllCpuStatus();
#else
g_currHandleExcCpuid = ArchCurrCpuid();
g_currHandleExcCpuID = ArchCurrCpuid();
#endif
}
@ -1144,15 +1094,15 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
STATIC VOID OsSysStateSave(UINT32 *intCount, UINT32 *lockCount)
{
*intCount = g_intCount[ArchCurrCpuid()];
*lockCount = OsSchedLockCountGet();
*lockCount = OsPercpuGet()->taskLockCnt;
g_intCount[ArchCurrCpuid()] = 0;
OsSchedLockSet(0);
OsPercpuGet()->taskLockCnt = 0;
}
STATIC VOID OsSysStateRestore(UINT32 intCount, UINT32 lockCount)
{
g_intCount[ArchCurrCpuid()] = intCount;
OsSchedLockSet(lockCount);
OsPercpuGet()->taskLockCnt = lockCount;
}
#endif
@ -1169,7 +1119,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
#endif
/* Task scheduling is not allowed during exception handling */
OsSchedLock();
OsPercpuGet()->taskLockCnt++;
g_curNestCount[ArchCurrCpuid()]++;
@ -1230,10 +1180,10 @@ __attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
OsVprintf(fmt, ap, EXC_OUTPUT);
UartVprintf(fmt, ap);
va_end(ap);
__asm__ __volatile__("swi 0");
while (1) {}
while (1);
}
/* stack protector */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -103,7 +103,7 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)taskContext;
}
VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfStack, UINT32 parentStackSize)
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
{
LosTaskCB *task = OsCurrTaskGet();
sig_cb *sigcb = &task->sig;
@ -117,10 +117,6 @@ VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfSta
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
((TaskContext *)childStack)->R0 = 0;
if (sp != 0) {
((TaskContext *)childStack)->USP = TRUNCATE(sp, LOSCFG_STACK_POINT_ALIGN_SIZE);
((TaskContext *)childStack)->ULR = 0;
}
}
LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)

View File

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

View File

@ -1,373 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "armv7_pmu_pri.h"
#include "perf_pmu_pri.h"
#include "los_hw_cpu.h"
#include "asm/platform.h"
OS_PMU_INTS(LOSCFG_KERNEL_CORE_NUM, g_pmuIrqNr);
STATIC HwPmu g_armv7Pmu;
STATIC INLINE UINT32 Armv7PmncRead(VOID)
{
UINT32 value = 0;
__asm__ volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(value));
return value;
}
STATIC INLINE VOID Armv7PmncWrite(UINT32 value)
{
value &= ARMV7_PMNC_MASK;
__asm__ volatile("mcr p15, 0, %0, c9, c12, 0" : : "r"(value));
ISB;
}
STATIC INLINE UINT32 Armv7PmuOverflowed(UINT32 pmnc)
{
return pmnc & ARMV7_OVERFLOWED_MASK;
}
STATIC INLINE UINT32 Armv7PmuCntOverflowed(UINT32 pmnc, UINT32 index)
{
return pmnc & ARMV7_CNT2BIT(ARMV7_IDX2CNT(index));
}
STATIC INLINE UINT32 Armv7CntValid(UINT32 index)
{
return index <= ARMV7_IDX_COUNTER_LAST;
}
STATIC INLINE VOID Armv7PmuSelCnt(UINT32 index)
{
UINT32 counter = ARMV7_IDX2CNT(index);
__asm__ volatile("mcr p15, 0, %0, c9, c12, 5" : : "r" (counter));
ISB;
}
STATIC INLINE VOID Armv7PmuSetCntPeriod(UINT32 index, UINT32 period)
{
if (!Armv7CntValid(index)) {
PRINT_ERR("CPU writing wrong counter %u\n", index);
} else if (index == ARMV7_IDX_CYCLE_COUNTER) {
__asm__ volatile("mcr p15, 0, %0, c9, c13, 0" : : "r" (period));
} else {
Armv7PmuSelCnt(index);
__asm__ volatile("mcr p15, 0, %0, c9, c13, 2" : : "r" (period));
}
}
STATIC INLINE VOID Armv7BindEvt2Cnt(UINT32 index, UINT32 value)
{
PRINT_DEBUG("bind event: %u to counter: %u\n", value, index);
Armv7PmuSelCnt(index);
value &= ARMV7_EVTYPE_MASK;
__asm__ volatile("mcr p15, 0, %0, c9, c13, 1" : : "r" (value));
}
STATIC INLINE VOID Armv7EnableCnt(UINT32 index)
{
UINT32 counter = ARMV7_IDX2CNT(index);
PRINT_DEBUG("index : %u, counter: %u\n", index, counter);
__asm__ volatile("mcr p15, 0, %0, c9, c12, 1" : : "r" (ARMV7_CNT2BIT(counter)));
}
STATIC INLINE VOID Armv7DisableCnt(UINT32 index)
{
UINT32 counter = ARMV7_IDX2CNT(index);
PRINT_DEBUG("index : %u, counter: %u\n", index, counter);
__asm__ volatile("mcr p15, 0, %0, c9, c12, 2" : : "r" (ARMV7_CNT2BIT(counter)));
}
STATIC INLINE VOID Armv7EnableCntInterrupt(UINT32 index)
{
UINT32 counter = ARMV7_IDX2CNT(index);
__asm__ volatile("mcr p15, 0, %0, c9, c14, 1" : : "r" (ARMV7_CNT2BIT(counter)));
ISB;
}
STATIC INLINE VOID Armv7DisableCntInterrupt(UINT32 index)
{
UINT32 counter = ARMV7_IDX2CNT(index);
__asm__ volatile("mcr p15, 0, %0, c9, c14, 2" : : "r" (ARMV7_CNT2BIT(counter)));
/* Clear the overflow flag in case an interrupt is pending. */
__asm__ volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (ARMV7_CNT2BIT(counter)));
ISB;
}
STATIC INLINE UINT32 Armv7PmuGetOverflowStatus(VOID)
{
UINT32 value;
__asm__ volatile("mrc p15, 0, %0, c9, c12, 3" : "=r" (value));
value &= ARMV7_FLAG_MASK;
__asm__ volatile("mcr p15, 0, %0, c9, c12, 3" : : "r" (value));
return value;
}
STATIC VOID Armv7EnableEvent(Event *event)
{
UINT32 cnt = event->counter;
if (!Armv7CntValid(cnt)) {
PRINT_ERR("CPU enabling wrong PMNC counter IRQ enable %u\n", cnt);
return;
}
if (event->period == 0) {
PRINT_INFO("event period value not valid, counter: %u\n", cnt);
return;
}
/*
* Enable counter and interrupt, and set the counter to count
* the event that we're interested in.
*/
UINT32 intSave = LOS_IntLock();
Armv7DisableCnt(cnt);
/*
* Set event (if destined for PMNx counters)
* We only need to set the event for the cycle counter if we
* have the ability to perform event filtering.
*/
if (cnt != ARMV7_IDX_CYCLE_COUNTER) {
Armv7BindEvt2Cnt(cnt, event->eventId);
}
/* Enable interrupt for this counter */
Armv7EnableCntInterrupt(cnt);
Armv7EnableCnt(cnt);
LOS_IntRestore(intSave);
PRINT_DEBUG("enabled event: %u cnt: %u\n", event->eventId, cnt);
}
STATIC VOID Armv7DisableEvent(Event *event)
{
UINT32 cnt = event->counter;
if (!Armv7CntValid(cnt)) {
PRINT_ERR("CPU enabling wrong PMNC counter IRQ enable %u\n", cnt);
return;
}
UINT32 intSave = LOS_IntLock();
Armv7DisableCnt(cnt);
Armv7DisableCntInterrupt(cnt);
LOS_IntRestore(intSave);
}
STATIC VOID Armv7StartAllCnt(VOID)
{
PRINT_DEBUG("starting pmu...\n");
/* Enable all counters */
UINT32 reg = Armv7PmncRead() | ARMV7_PMNC_E;
if (g_armv7Pmu.cntDivided) {
reg |= ARMV7_PMNC_D;
} else {
reg &= ~ARMV7_PMNC_D;
}
Armv7PmncWrite(reg);
HalIrqUnmask(g_pmuIrqNr[ArchCurrCpuid()]);
}
STATIC VOID Armv7StopAllCnt(VOID)
{
PRINT_DEBUG("stopping pmu...\n");
/* Disable all counters */
Armv7PmncWrite(Armv7PmncRead() & ~ARMV7_PMNC_E);
HalIrqMask(g_pmuIrqNr[ArchCurrCpuid()]);
}
STATIC VOID Armv7ResetAllCnt(VOID)
{
UINT32 index;
/* The counter and interrupt enable registers are unknown at reset. */
for (index = ARMV7_IDX_CYCLE_COUNTER; index < ARMV7_IDX_MAX_COUNTER; index++) {
Armv7DisableCnt(index);
Armv7DisableCntInterrupt(index);
}
/* Initialize & Reset PMNC: C and P bits and D bits */
UINT32 reg = ARMV7_PMNC_P | ARMV7_PMNC_C | (g_armv7Pmu.cntDivided ? ARMV7_PMNC_D : 0);
Armv7PmncWrite(reg);
}
STATIC VOID Armv7SetEventPeriod(Event *event)
{
if (event->period != 0) {
PRINT_INFO("counter: %u, period: 0x%x\n", event->counter, event->period);
Armv7PmuSetCntPeriod(event->counter, PERIOD_CALC(event->period));
}
}
STATIC UINTPTR Armv7ReadEventCnt(Event *event)
{
UINT32 value = 0;
UINT32 index = event->counter;
if (!Armv7CntValid(index)) {
PRINT_ERR("CPU reading wrong counter %u\n", index);
} else if (index == ARMV7_IDX_CYCLE_COUNTER) {
__asm__ volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (value));
} else {
Armv7PmuSelCnt(index);
__asm__ volatile("mrc p15, 0, %0, c9, c13, 2" : "=r" (value));
}
if (value < PERIOD_CALC(event->period)) {
if (Armv7PmuCntOverflowed(Armv7PmuGetOverflowStatus(), event->counter)) {
value += event->period;
}
} else {
value -= PERIOD_CALC(event->period);
}
return value;
}
STATIC const UINT32 g_armv7Map[] = {
[PERF_COUNT_HW_CPU_CYCLES] = ARMV7_PERF_HW_CYCLES,
[PERF_COUNT_HW_INSTRUCTIONS] = ARMV7_PERF_HW_INSTRUCTIONS,
[PERF_COUNT_HW_DCACHE_REFERENCES] = ARMV7_PERF_HW_DCACHES,
[PERF_COUNT_HW_DCACHE_MISSES] = ARMV7_PERF_HW_DCACHE_MISSES,
[PERF_COUNT_HW_ICACHE_REFERENCES] = ARMV7_PERF_HW_ICACHES,
[PERF_COUNT_HW_ICACHE_MISSES] = ARMV7_PERF_HW_ICACHE_MISSES,
[PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = ARMV7_PERF_HW_BRANCHES,
[PERF_COUNT_HW_BRANCH_MISSES] = ARMV7_PERF_HW_BRANCE_MISSES,
};
UINT32 Armv7PmuMapEvent(UINT32 eventType, BOOL reverse)
{
if (!reverse) { /* Common event to armv7 real event */
if (eventType < ARRAY_SIZE(g_armv7Map)) {
return g_armv7Map[eventType];
}
return eventType;
} else { /* Armv7 real event to common event */
UINT32 i;
for (i = 0; i < ARRAY_SIZE(g_armv7Map); i++) {
if (g_armv7Map[i] == eventType) {
return i;
}
}
return PERF_HW_INVALID_EVENT_TYPE;
}
}
STATIC VOID Armv7PmuIrqHandler(VOID)
{
UINT32 index;
PerfRegs regs;
PerfEvent *events = &(g_armv7Pmu.pmu.events);
UINT32 eventNum = events->nr;
/* Get and reset the IRQ flags */
UINT32 pmnc = Armv7PmuGetOverflowStatus();
if (!Armv7PmuOverflowed(pmnc)) {
return;
}
(VOID)memset_s(&regs, sizeof(PerfRegs), 0, sizeof(PerfRegs));
OsPerfFetchIrqRegs(&regs);
Armv7StopAllCnt();
for (index = 0; index < eventNum; index++) {
Event *event = &(events->per[index]);
/*
* We have a single interrupt for all counters. Check that
* each counter has overflowed before we process it.
*/
if (!Armv7PmuCntOverflowed(pmnc, event->counter) || (event->period == 0)) {
continue;
}
Armv7PmuSetCntPeriod(event->counter, PERIOD_CALC(event->period));
OsPerfUpdateEventCount(event, event->period);
OsPerfHandleOverFlow(event, &regs);
}
Armv7StartAllCnt();
}
UINT32 OsGetPmuMaxCounter(VOID)
{
return ARMV7_IDX_MAX_COUNTER;
}
UINT32 OsGetPmuCycleCounter(VOID)
{
return ARMV7_IDX_CYCLE_COUNTER;
}
UINT32 OsGetPmuCounter0(VOID)
{
return ARMV7_IDX_COUNTER0;
}
STATIC HwPmu g_armv7Pmu = {
.canDivided = TRUE,
.enable = Armv7EnableEvent,
.disable = Armv7DisableEvent,
.start = Armv7StartAllCnt,
.stop = Armv7StopAllCnt,
.clear = Armv7ResetAllCnt,
.setPeriod = Armv7SetEventPeriod,
.readCnt = Armv7ReadEventCnt,
.mapEvent = Armv7PmuMapEvent,
};
UINT32 OsHwPmuInit(VOID)
{
UINT32 ret;
UINT32 index;
for (index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) {
ret = LOS_HwiCreate(g_pmuIrqNr[index], 0, 0, Armv7PmuIrqHandler, 0);
if (ret != LOS_OK) {
PRINT_ERR("pmu %u irq handler register failed\n", g_pmuIrqNr[index]);
return ret;
}
#ifdef LOSCFG_KERNEL_SMP
HalIrqSetAffinity(g_pmuIrqNr[index], CPUID_TO_AFFI_MASK(index));
#endif
}
ret = OsPerfHwInit(&g_armv7Pmu);
return ret;
}

View File

@ -35,6 +35,7 @@
#include "los_hw.h"
#include "los_atomic.h"
#include "los_arch_mmu.h"
#include "los_init_pri.h"
#include "gic_common.h"
#include "los_task_pri.h"
@ -54,7 +55,7 @@ VOID HalArchCpuOn(UINT32 cpuNum, ArchCpuStartFunc func, struct SmpOps *ops, VOID
{
struct OsCpuInit *cpuInit = &g_cpuInit[cpuNum - 1];
UINTPTR startEntry = (UINTPTR)&reset_vector - KERNEL_VMM_BASE + SYS_MEM_BASE;
INT32 ret;
INT32 ret = 0;
cpuInit->cpuStart = func;
cpuInit->arg = arg;
@ -93,6 +94,7 @@ VOID HalSecondaryCpuStart(VOID)
/* store each core's hwid */
CPU_MAP_SET(cpuid, OsHwIDGet());
HalIrqInitPercpu();
OsInitCall(LOS_INIT_LEVEL_ARCH);
cpuInit->cpuStart(cpuInit->arg);

View File

@ -121,9 +121,8 @@ 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) /* i cache */
bic r0, #(1 << 2) /* d cache */
bic r0, #(1 << 0) /* mmu */
bic r0, #(1<<12)
bic r0, #(1<<2 | 1<<0)
mcr p15, 0, r0, c1, c0, 0
/* enable fpu+neon */
@ -276,18 +275,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, Auxiliary Control Register */
mrc p15, 0, r12, c1, c0, 1 /* ACTLR, Auxlliary 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, Auxiliary Control Register */
mcr p15, 0, r12, c1, c0, 1 /* ACTLR, Auxlliary Control Register */
dsb
mrc p15, 0, r12, c1, c0, 0
bic r12, #(1 << 29 | 1 << 28) /* Disable TRE/AFE */
orr r12, #(1 << 0) /* mmu enable */
bic r12, #(1 << 29 | 1 << 28)
orr r12, #(1 << 0)
bic r12, #(1 << 1)
orr r12, #(1 << 2) /* D cache enable */
orr r12, #(1 << 12) /* I cache enable */
orr r12, #(1 << 2)
orr r12, #(1 << 12)
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,9 +101,8 @@ __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) /* i cache */
bic r0, #(1 << 2) /* d cache */
bic r0, #(1 << 0) /* mmu */
bic r0, #(1<<12)
bic r0, #(1<<2 | 1<<0)
mcr p15, 0, r0, c1, c0, 0
/* enable fpu+neon */
@ -270,11 +269,11 @@ mmu_setup:
isb
mrc p15, 0, r12, c1, c0, 0
bic r12, #(1 << 29 | 1 << 28) /* Disable TRE/AFE */
orr r12, #(1 << 0) /* mmu enable */
bic r12, #(1 << 29 | 1 << 28)
orr r12, #(1 << 0)
bic r12, #(1 << 1)
orr r12, #(1 << 2) /* D cache enable */
orr r12, #(1 << 12) /* I cache enable */
orr r12, #(1 << 2)
orr r12, #(1 << 12)
mcr p15, 0, r12, c1, c0, 0 /* Set SCTLR with r12: Turn on the MMU, I/D cache Disable TRE/AFE */
isb

View File

@ -31,10 +31,18 @@ include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := $(notdir $(shell pwd))
# LOCAL_SRCS := $(wildcard *.c)
ifeq ($(LOSCFG_ARCH_GIC_V2), y)
LOCAL_SRCS := gic_v2.c
else ifeq ($(LOSCFG_ARCH_GIC_V3), y)
LOCAL_SRCS := gic_v3.c
endif
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/base/include \
-I $(LITEOSTOPDIR)/arch/arm/include \
-I $(LITEOSTOPDIR)/arch/arm/arm/src/include \
LOCAL_FLAGS := $(LOCAL_INCLUDE)
include $(MODULE)

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) | /* 24, 16: Register bit offset */
UINT32 val = ((filter & 0x3) << 24) | ((cpuMask & 0xFF) << 16) |
(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; /* 4: Interrupt bit width */
UINT32 offset = vector / 4;
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); /* 32: Interrupt bit width */
GIC_REG_32(GICD_ICENABLER(vector / 32)) = 1U << (vector % 32);
}
VOID HalIrqUnmask(UINT32 vector)
@ -89,7 +89,7 @@ VOID HalIrqUnmask(UINT32 vector)
return;
}
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = 1U << (vector % 32); /* 5, 32: Register bit offset */
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = 1U << (vector % 32);
}
VOID HalIrqPending(UINT32 vector)
@ -98,7 +98,7 @@ VOID HalIrqPending(UINT32 vector)
return;
}
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32); /* 5, 32: Register bit offset */
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32);
}
VOID HalIrqClear(UINT32 vector)
@ -119,24 +119,24 @@ VOID HalIrqInit(VOID)
{
UINT32 i;
/* 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 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 CPU 0 */
for (i = 32; i < OS_HWI_MAX_NUM; i += 4) { /* 32: Start interrupt number, 4: Interrupt bit width */
/* set externel interrupts to CPU 0 */
for (i = 32; i < OS_HWI_MAX_NUM; i += 4) {
GIC_REG_32(GICD_ITARGETSR(i / 4)) = 0x01010101;
}
/* set priority on all interrupts */
for (i = 0; i < OS_HWI_MAX_NUM; i += 4) { /* 4: Interrupt bit width */
for (i = 0; i < OS_HWI_MAX_NUM; i += 4) {
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) { /* 32: Interrupt bit width */
GIC_REG_32(GICD_ICENABLER(i / 32)) = ~0; /* 32: Interrupt bit width */
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) {
GIC_REG_32(GICD_ICENABLER(i / 32)) = ~0;
}
HalIrqInitPercpu();
@ -149,9 +149,6 @@ VOID HalIrqInit(VOID)
(VOID)LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
(VOID)LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
(VOID)LOS_HwiCreate(LOS_MP_IPI_HALT, 0xa0, 0, OsMpHaltHandler, 0);
#ifdef LOSCFG_KERNEL_SMP_CALL
(VOID)LOS_HwiCreate(LOS_MP_IPI_FUNC_CALL, 0xa0, 0, OsMpFuncCallHandler, 0);
#endif
#endif
}
@ -172,7 +169,7 @@ VOID HalIrqHandler(VOID)
OsInterrupt(vector);
/* use original iar to do the EOI */
/* use orignal iar to do the EOI */
GIC_REG_32(GICC_EOIR) = iar;
}

View File

@ -42,9 +42,9 @@ STATIC UINT32 g_curIrqNum = 0;
STATIC INLINE UINT64 MpidrToAffinity(UINT64 mpidr)
{
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 */
return ((MPIDR_AFF_LEVEL(mpidr, 3) << 32) |
(MPIDR_AFF_LEVEL(mpidr, 2) << 16) |
(MPIDR_AFF_LEVEL(mpidr, 1) << 8) |
(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) | /* 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 */
val = ((MPIDR_AFF_LEVEL(cluster, 3) << 48) |
(MPIDR_AFF_LEVEL(cluster, 2) << 32) |
(MPIDR_AFF_LEVEL(cluster, 1) << 16) |
(irq << 24) | tList);
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; /* 32: Interrupt bit width */
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0;
#else
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0xffffffff; /* 32: Interrupt bit width */
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0xffffffff;
#endif
}
@ -248,13 +248,13 @@ UINT32 HalCurIrqGet(VOID)
VOID HalIrqMask(UINT32 vector)
{
INT32 i;
const UINT32 mask = 1U << (vector % 32); /* 32: Interrupt bit width */
const UINT32 mask = 1U << (vector % 32);
if ((vector > OS_USER_HWI_MAX) || (vector < OS_USER_HWI_MIN)) {
return;
}
if (vector < 32) { /* 32: Interrupt bit width */
if (vector < 32) {
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); /* 32: Interrupt bit width */
const UINT32 mask = 1U << (vector % 32);
if ((vector > OS_USER_HWI_MAX) || (vector < OS_USER_HWI_MIN)) {
return;
}
if (vector < 32) { /* 32: Interrupt bit width */
if (vector < 32) {
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; /* 5: Register bit offset */
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = mask;
GicWaitForRwp(GICD_CTLR);
}
}
@ -291,7 +291,7 @@ VOID HalIrqPending(UINT32 vector)
return;
}
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32); /* 5: Register bit offset, 32: Interrupt bit width */
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32);
}
VOID HalIrqClear(UINT32 vector)
@ -362,30 +362,30 @@ VOID HalIrqInit(VOID)
GicWaitForRwp(GICD_CTLR);
ISB;
/* 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 */
/* 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;
}
/* config distributer, mask and clear all spis, set group x */
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 */
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;
GicdSetGroup(i);
}
/* set spi priority as default */
for (i = 32; i < OS_HWI_MAX_NUM; i++) { /* 32: Start interrupt number */
for (i = 32; i < OS_HWI_MAX_NUM; i++) {
GicdSetPmr(i, MIN_INTERRUPT_PRIORITY);
}
GicWaitForRwp(GICD_CTLR);
/* disable all interrupts. */
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 */
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) {
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff;
}
/* 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++) { /* 32: Start interrupt number */
for (i = 32; i < OS_HWI_MAX_NUM; i++) {
GIC_REG_64(GICD_IROUTER(i)) = affinity;
}
@ -401,12 +401,9 @@ VOID HalIrqInit(VOID)
#ifdef LOSCFG_KERNEL_SMP
/* register inter-processor interrupt */
(VOID)LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
(VOID)LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
(VOID)LOS_HwiCreate(LOS_MP_IPI_HALT, 0xa0, 0, OsMpScheduleHandler, 0);
#ifdef LOSCFG_KERNEL_SMP_CALL
(VOID)LOS_HwiCreate(LOS_MP_IPI_FUNC_CALL, 0xa0, 0, OsMpFuncCallHandler, 0);
#endif
LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
LOS_HwiCreate(LOS_MP_IPI_HALT, 0xa0, 0, OsMpScheduleHandler, 0);
#endif
}

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 Registers */
#define GICD_IROUTER(n) (GICD_OFFSET + 0x6000 + (n) * 8) /* Interrupt Rounter Registers */
#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 */
#endif
#define GIC_REG_8(reg) (*(volatile UINT8 *)((UINTPTR)(GIC_BASE_ADDR + (reg))))

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

View File

@ -41,6 +41,14 @@ LOCAL_SRCS += $(wildcard crypto/rijndael/*.c) \
$(wildcard crypto/sha2/*.c) \
$(wildcard dev/random/*.c) \
$(wildcard libkern/*.c)
endif
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/base/include \
-I $(LITEOSTOPDIR)/bsd \
-I $(LITEOSTOPDIR)/bsd/kern \
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE)

View File

@ -37,4 +37,10 @@ ifneq ($(LOSCFG_HRTIMER_ENABLE), y)
LOCAL_SRCS := $(filter-out src/linux_hrtimer.c, $(LOCAL_SRCS))
endif
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/base/include \
-I $(LITEOSTOPDIR)/bsd/compat/linuxkpi/include
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE)

View File

@ -137,13 +137,14 @@ kernel_module(module_name) {
]
}
configs += [ "$HDFTOPDIR:hdf_config" ]
configs += [
"$HDFTOPDIR:hdf_config"
]
public_configs = [ ":public" ]
}
config("public") {
defines = [ "USB_DEBUG_VAR=5" ]
include_dirs = [ "." ]
include_dirs += [ "$LITEOSTHIRDPARTY/FreeBSD/sys/dev/evdev" ]
}

View File

@ -28,7 +28,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include $(LITEOSTOPDIR)/config.mk
include $(LITEOSTOPDIR)/../../drivers/hdf_core/adapter/khdf/liteos/lite.mk
include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/lite.mk
MODULE_NAME := usb_base
@ -122,17 +122,19 @@ LOCAL_SRCS += $(STORAGE_SRC)/umass.c
endif
ifeq ($(LOSCFG_DRIVERS_USB_HID_CLASS)_$(LOSCFG_DRIVERS_HDF_INPUT), y_y)
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 \
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 \
-I$(LITEOSTOPDIR)/../../third_party/FreeBSD/sys/dev/evdev
LOCAL_SRCS += $(INPUT_SRC)/uhid.c \
$(CORE_SRC)/usb_hid.c
endif
LOCAL_FLAGS += $(LITEOS_GCOV_OPTS)
include $(HDF_DRIVER)

View File

@ -1,7 +1,7 @@
{
"name": "@ohos/liteos_a",
"version": "3.1.0",
"description": "liteos-a kernel",
"name": "@ohos/kernel_liteos_a",
"version": "",
"description": "liteos-a内核",
"homePage": "https://gitee.com/openharmony",
"license": "BSD 3-clause",
"repository": "https://gitee.com/openharmony/kernel_liteos_a",
@ -19,44 +19,41 @@
],
"envs": [],
"dirs": [],
"author": {},
"contributors": [],
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "kernel/liteos_a"
},
"component": {
"name": "liteos_a",
"subsystem": "kernel",
"name": "liteos-a",
"subsystem": "liteos_a",
"syscap": [
"SystemCapability.Kernel.liteos-a"
],
"features": [],
"adapted_system_type": [
"adated_system_type": [
"small"
],
"rom": "1.5MB",
"ram": "2MB",
"rom": "",
"ram": "",
"deps": {
"components": [
],
"third_party": [
"bounds_checking_function",
"toybox",
"NuttX",
"FatFs",
"mksh",
"musl",
"mbedtls",
"FreeBSD",
"zlib",
"lwip",
"optimized-routines",
"googletest"
]
"components": [],
"third_party": []
},
"build": {
"sub_component": [
"//kernel/liteos_a:liteos_a"
],
"sub_component": [],
"inner_kits": [],
"test": []
}
}
}
}

View File

@ -33,8 +33,10 @@ MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard src/*.c)
LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/compat/posix/src
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/compat/posix/src \
-I $(LITEOSTOPDIR)/kernel/base/include \
LOCAL_FLAGS := $(LOCAL_INCLUDE)
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -71,13 +71,9 @@ extern "C" {
/* CONSTANTS */
#define MQ_USE_MAGIC 0x89abcdef
/* not support prio */
/* not suppurt prio */
#define MQ_PRIO_MAX 1
#ifndef MAX_MQ_FD
#define MAX_MQ_FD CONFIG_NQUEUE_DESCRIPTORS
#endif
typedef union send_receive_t {
unsigned oth : 3;
unsigned grp : 6;
@ -301,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 operation times out.</li>
* <li><b>ETIMEDOUT</b>: The operaton times out.</li>
* </ul>
*
* @par Dependency:
@ -428,7 +424,6 @@ extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
extern void MqueueRefer(int sysFd);
extern int OsMqNotify(mqd_t personal, const struct sigevent *sigev);
extern VOID OsMqueueCBDestroy(struct mqarray *queueTable);
#ifdef __cplusplus
#if __cplusplus

View File

@ -86,7 +86,6 @@ STATIC INLINE VOID OsTick2TimeSpec(struct timespec *tp, UINT32 tick)
}
int OsTimerCreate(clockid_t, struct ksigevent *__restrict, timer_t *__restrict);
void OsAdjTime(void);
#ifdef __cplusplus
#if __cplusplus

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

@ -53,27 +53,21 @@
int uname(struct utsname *name)
{
INT32 ret;
const char *cpuInfo = NULL;
if (name == NULL) {
return -EFAULT;
}
#ifdef LOSCFG_UTS_CONTAINER
struct utsname *currentUtsName = OsGetCurrUtsName();
if (currentUtsName == NULL) {
return -EFAULT;
}
(VOID)memcpy_s(name, sizeof(struct utsname), currentUtsName, sizeof(struct utsname));
#else
(VOID)strcpy_s(name->sysname, sizeof(name->sysname), KERNEL_NAME);
(VOID)strcpy_s(name->nodename, sizeof(name->nodename), KERNEL_NODE_NAME);
INT32 ret = sprintf_s(name->version, sizeof(name->version), "%s %u.%u.%u.%u %s %s",
KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, __DATE__, __TIME__);
(VOID)strcpy_s(name->nodename, sizeof(name->nodename), "hisilicon");
ret = sprintf_s(name->version, sizeof(name->version), "%s %u.%u.%u.%u %s %s",
KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, __DATE__, __TIME__);
if (ret < 0) {
return -EIO;
}
const char *cpuInfo = LOS_CpuInfo();
cpuInfo = LOS_CpuInfo();
(VOID)strcpy_s(name->machine, sizeof(name->machine), cpuInfo);
ret = sprintf_s(name->release, sizeof(name->release), "%u.%u.%u.%u",
KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE);
@ -82,7 +76,6 @@ int uname(struct utsname *name)
}
name->domainname[0] = '\0';
#endif
return 0;
}
@ -161,9 +154,7 @@ pid_t getpid(void)
int getrlimit(int resource, struct rlimit *rlim)
{
unsigned int intSave;
LosProcessCB *pcb = OsCurrProcessGet();
struct rlimit *resourceLimit = pcb->resourceLimit;
switch (resource) {
case RLIMIT_NOFILE:
@ -172,18 +163,8 @@ int getrlimit(int resource, struct rlimit *rlim)
default:
return -EINVAL;
}
if (resourceLimit == NULL) {
rlim->rlim_cur = 0;
rlim->rlim_max = 0;
return 0;
}
SCHEDULER_LOCK(intSave);
rlim->rlim_cur = resourceLimit[resource].rlim_cur;
rlim->rlim_max = resourceLimit[resource].rlim_max;
SCHEDULER_UNLOCK(intSave);
rlim->rlim_cur = pcb->pl_rlimit[resource].rlim_cur;
rlim->rlim_max = pcb->pl_rlimit[resource].rlim_max;
return 0;
}
@ -194,8 +175,6 @@ int getrlimit(int resource, struct rlimit *rlim)
#endif
int setrlimit(int resource, const struct rlimit *rlim)
{
unsigned int intSave;
struct rlimit *resourceLimit = NULL;
LosProcessCB *pcb = OsCurrProcessGet();
if (rlim->rlim_cur > rlim->rlim_max) {
@ -215,23 +194,8 @@ int setrlimit(int resource, const struct rlimit *rlim)
default:
return -EINVAL;
}
pcb->pl_rlimit[resource].rlim_cur = rlim->rlim_cur;
pcb->pl_rlimit[resource].rlim_max = rlim->rlim_max;
if (pcb->resourceLimit == NULL) {
resourceLimit = LOS_MemAlloc((VOID *)m_aucSysMem0, RLIM_NLIMITS * sizeof(struct rlimit));
if (resourceLimit == NULL) {
return -EINVAL;
}
}
SCHEDULER_LOCK(intSave);
if (pcb->resourceLimit == NULL) {
pcb->resourceLimit = resourceLimit;
resourceLimit = NULL;
}
pcb->resourceLimit[resource].rlim_cur = rlim->rlim_cur;
pcb->resourceLimit[resource].rlim_max = rlim->rlim_max;
SCHEDULER_UNLOCK(intSave);
(VOID)LOS_MemFree((VOID *)m_aucSysMem0, resourceLimit);
return 0;
}
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -44,19 +44,16 @@
#define FNONBLOCK O_NONBLOCK
#ifndef LOSCFG_IPC_CONTAINER
#ifndef MAX_MQ_FD
#define MAX_MQ_FD CONFIG_NQUEUE_DESCRIPTORS
#endif
/* GLOBALS */
STATIC fd_set g_queueFdSet;
STATIC struct mqarray g_queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT];
STATIC pthread_mutex_t g_mqueueMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
STATIC struct mqpersonal *g_mqPrivBuf[MAX_MQ_FD];
#define IPC_QUEUE_FD_SET g_queueFdSet
#define IPC_QUEUE_TABLE g_queueTable
#define IPC_QUEUE_MUTEX g_mqueueMutex
#define IPC_QUEUE_MQ_PRIV_BUF g_mqPrivBuf
#endif
/* LOCAL FUNCTIONS */
STATIC INLINE INT32 MqNameCheck(const CHAR *mqName)
{
@ -99,12 +96,12 @@ STATIC INLINE struct mqarray *GetMqueueCBByName(const CHAR *name)
UINT32 mylen = strlen(name);
for (index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
if ((IPC_QUEUE_TABLE[index].mq_name == NULL) || (strlen(IPC_QUEUE_TABLE[index].mq_name) != mylen)) {
if ((g_queueTable[index].mq_name == NULL) || (strlen(g_queueTable[index].mq_name) != mylen)) {
continue;
}
if (strncmp(name, (const CHAR *)(IPC_QUEUE_TABLE[index].mq_name), mylen) == 0) {
return &(IPC_QUEUE_TABLE[index]);
if (strncmp(name, (const CHAR *)(g_queueTable[index].mq_name), mylen) == 0) {
return &(g_queueTable[index]);
}
}
return NULL;
@ -113,9 +110,7 @@ STATIC INLINE struct mqarray *GetMqueueCBByName(const CHAR *name)
STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
{
UINT32 ret;
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
OsIPCLimitMqFree();
#endif
if (mqueueCB->mq_name != NULL) {
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
mqueueCB->mq_name = NULL;
@ -165,36 +160,18 @@ STATIC int SaveMqueueName(const CHAR *mqName, struct mqarray *mqueueCB)
return LOS_OK;
}
STATIC VOID MqueueCBInit(struct mqarray *mqueueCB, const struct mq_attr *attr, INT32 openFlag, UINT32 mode)
{
mqueueCB->unlinkflag = FALSE;
mqueueCB->unlink_ref = 0;
mqueueCB->mq_personal->mq_status = MQ_USE_MAGIC;
mqueueCB->mq_personal->mq_next = NULL;
mqueueCB->mq_personal->mq_posixdes = mqueueCB;
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
mqueueCB->mq_personal->mq_mode = mode;
mqueueCB->mq_personal->mq_refcount = 0;
mqueueCB->mq_notify.pid = 0;
}
STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR *mqName, INT32 openFlag, UINT32 mode)
{
struct mqarray *mqueueCB = NULL;
UINT32 mqueueID;
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
if (OsIPCLimitMqAlloc() != LOS_OK) {
return (struct mqpersonal *)-1;
}
#endif
UINT32 err = LOS_QueueCreate(NULL, attr->mq_maxmsg, &mqueueID, 0, attr->mq_msgsize);
if (map_errno(err) != ENOERR) {
goto ERROUT;
}
if (IPC_QUEUE_TABLE[GET_QUEUE_INDEX(mqueueID)].mqcb == NULL) {
mqueueCB = &(IPC_QUEUE_TABLE[GET_QUEUE_INDEX(mqueueID)]);
if (g_queueTable[GET_QUEUE_INDEX(mqueueID)].mqcb == NULL) {
mqueueCB = &(g_queueTable[GET_QUEUE_INDEX(mqueueID)]);
mqueueCB->mq_id = mqueueID;
}
@ -221,7 +198,15 @@ STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR
goto ERROUT;
}
MqueueCBInit(mqueueCB, attr, openFlag, mode);
mqueueCB->unlinkflag = FALSE;
mqueueCB->unlink_ref = 0;
mqueueCB->mq_personal->mq_status = MQ_USE_MAGIC;
mqueueCB->mq_personal->mq_next = NULL;
mqueueCB->mq_personal->mq_posixdes = mqueueCB;
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
mqueueCB->mq_personal->mq_mode = mode;
mqueueCB->mq_personal->mq_refcount = 0;
mqueueCB->mq_notify.pid = 0;
return mqueueCB->mq_personal;
ERROUT:
@ -230,9 +215,6 @@ ERROUT:
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
mqueueCB->mq_name = NULL;
}
#ifdef LOSCFG_KERNEL_IPC_PLIMIT
OsIPCLimitMqFree();
#endif
return (struct mqpersonal *)-1;
}
@ -270,7 +252,6 @@ STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
{
struct mqarray *mqueueCB = NULL;
struct mqpersonal *tmp = NULL;
INT32 ret;
mqueueCB = privateMqPersonal->mq_posixdes;
if (mqueueCB == NULL || mqueueCB->mq_personal == NULL) {
@ -278,12 +259,6 @@ STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
return LOS_NOK;
}
if ((mqueueCB->unlinkflag == TRUE) && (privateMqPersonal->mq_next == NULL)) {
ret = DoMqueueDelete(mqueueCB);
if (ret < 0) {
return ret;
}
}
/* find the personal and remove */
if (mqueueCB->mq_personal == privateMqPersonal) {
mqueueCB->mq_personal = privateMqPersonal->mq_next;
@ -305,6 +280,9 @@ STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
/* free the personal */
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
if ((mqueueCB->unlinkflag == TRUE) && (mqueueCB->mq_personal == NULL)) {
return DoMqueueDelete(mqueueCB);
}
return LOS_OK;
}
@ -319,7 +297,7 @@ STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
errno = EBADF;
return NULL;
}
return IPC_QUEUE_MQ_PRIV_BUF[id];
return g_mqPrivBuf[id];
}
/**
@ -333,13 +311,13 @@ STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
{
INT32 i;
fd_set *fdset = &IPC_QUEUE_FD_SET;
fd_set *fdset = &g_queueFdSet;
for (i = 0; i < maxfdp; i++) {
/* sysFd: used bit setting, and get the index of swtmrID buffer */
if (fdset && !(FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
FD_SET(i + MQUEUE_FD_OFFSET, fdset);
if (!IPC_QUEUE_MQ_PRIV_BUF[i]) {
IPC_QUEUE_MQ_PRIV_BUF[i] = privateMqPersonal;
if (!g_mqPrivBuf[i]) {
g_mqPrivBuf[i] = privateMqPersonal;
return i + MQUEUE_FD_OFFSET;
}
}
@ -350,10 +328,10 @@ STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
STATIC VOID MqFreeSysFd(mqd_t personal)
{
INT32 sysFd = (INT32)personal;
fd_set *fdset = &IPC_QUEUE_FD_SET;
fd_set *fdset = &g_queueFdSet;
if (fdset && FD_ISSET(sysFd, fdset)) {
FD_CLR(sysFd, fdset);
IPC_QUEUE_MQ_PRIV_BUF[sysFd - MQUEUE_FD_OFFSET] = NULL;
g_mqPrivBuf[sysFd - MQUEUE_FD_OFFSET] = NULL;
}
}
@ -363,7 +341,7 @@ void MqueueRefer(int sysFd)
struct mqarray *mqueueCB = NULL;
struct mqpersonal *privateMqPersonal = NULL;
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_lock(&g_mqueueMutex);
/* Get the personal sysFd and reset personal fd -1 */
privateMqPersonal = MqGetPrivDataBuff((mqd_t)sysFd);
if (privateMqPersonal == NULL) {
@ -376,7 +354,7 @@ void MqueueRefer(int sysFd)
privateMqPersonal->mq_refcount++;
OUT_UNLOCK:
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return;
}
@ -520,7 +498,7 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
return (mqd_t)-1;
}
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_lock(&g_mqueueMutex);
mqueueCB = GetMqueueCBByName(mqName);
if ((UINT32)openFlag & (UINT32)O_CREAT) {
if (mqueueCB != NULL) {
@ -565,7 +543,7 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
mqFd = (mqd_t)sysFd;
}
OUT:
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return mqFd;
}
@ -574,7 +552,7 @@ int mq_close(mqd_t personal)
INT32 ret = -1;
struct mqpersonal *privateMqPersonal = NULL;
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_lock(&g_mqueueMutex);
/* Get the personal sysFd and reset personal fd -1 */
privateMqPersonal = MqGetPrivDataBuff(personal);
@ -599,7 +577,7 @@ int mq_close(mqd_t personal)
MqFreeSysFd(personal);
OUT_UNLOCK:
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return ret;
}
@ -608,22 +586,20 @@ int OsMqGetAttr(mqd_t personal, struct mq_attr *mqAttr)
struct mqarray *mqueueCB = NULL;
struct mqpersonal *privateMqPersonal = NULL;
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
privateMqPersonal = MqGetPrivDataBuff(personal);
if (privateMqPersonal == NULL) {
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
return -1;
}
if (mqAttr == NULL) {
errno = EINVAL;
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
return -1;
}
(VOID)pthread_mutex_lock(&g_mqueueMutex);
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
errno = EBADF;
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return -1;
}
@ -632,7 +608,7 @@ int OsMqGetAttr(mqd_t personal, struct mq_attr *mqAttr)
mqAttr->mq_msgsize = mqueueCB->mqcb->queueSize - sizeof(UINT32);
mqAttr->mq_curmsgs = mqueueCB->mqcb->readWriteableCnt[OS_QUEUE_READ];
mqAttr->mq_flags = privateMqPersonal->mq_flags;
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return 0;
}
@ -640,22 +616,20 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
{
struct mqpersonal *privateMqPersonal = NULL;
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
privateMqPersonal = MqGetPrivDataBuff(personal);
if (privateMqPersonal == NULL) {
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
return -1;
}
if (mqSetAttr == NULL) {
errno = EINVAL;
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
return -1;
}
(VOID)pthread_mutex_lock(&g_mqueueMutex);
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
errno = EBADF;
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return -1;
}
@ -667,7 +641,7 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
if (((UINT32)mqSetAttr->mq_flags & (UINT32)FNONBLOCK) == (UINT32)FNONBLOCK) {
privateMqPersonal->mq_flags = (INT32)((UINT32)privateMqPersonal->mq_flags | (UINT32)FNONBLOCK);
}
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return 0;
}
@ -688,7 +662,7 @@ int mq_unlink(const char *mqName)
return -1;
}
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_lock(&g_mqueueMutex);
mqueueCB = GetMqueueCBByName(mqName);
if (mqueueCB == NULL) {
errno = ENOENT;
@ -701,11 +675,11 @@ int mq_unlink(const char *mqName)
ret = DoMqueueDelete(mqueueCB);
}
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return ret;
ERROUT_UNLOCK:
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return -1;
}
@ -793,7 +767,7 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
OS_MQ_GOTO_ERROUT_IF(!MqParamCheck(personal, msg, msgLen), errno);
OS_MQ_GOTO_ERROUT_IF(msgPrio > (MQ_PRIO_MAX - 1), EINVAL);
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_lock(&g_mqueueMutex);
privateMqPersonal = MqGetPrivDataBuff(personal);
OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
@ -807,7 +781,7 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
OS_MQ_GOTO_ERROUT_UNLOCK_IF(ConvertTimeout(privateMqPersonal->mq_flags, absTimeout, &absTicks) == -1, errno);
mqueueID = mqueueCB->mq_id;
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
if (LOS_ListEmpty(&mqueueCB->mqcb->readWriteList[OS_QUEUE_READ])) {
MqSendNotify(mqueueCB);
@ -819,7 +793,7 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
}
return 0;
ERROUT_UNLOCK:
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
ERROUT:
return -1;
}
@ -841,7 +815,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
*msgPrio = 0;
}
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_lock(&g_mqueueMutex);
privateMqPersonal = MqGetPrivDataBuff(personal);
if (privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC) {
errno = EBADF;
@ -865,7 +839,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
receiveLen = msgLen;
mqueueID = mqueueCB->mq_id;
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
err = LOS_QueueReadCopy(mqueueID, (VOID *)msg, &receiveLen, (UINT32)absTicks);
if (map_errno(err) == ENOERR) {
@ -875,7 +849,7 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
}
ERROUT_UNLOCK:
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
ERROUT:
return -1;
}
@ -924,7 +898,7 @@ int OsMqNotify(mqd_t personal, const struct sigevent *sigev)
goto ERROUT;
}
(VOID)pthread_mutex_lock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_lock(&g_mqueueMutex);
privateMqPersonal = MqGetPrivDataBuff(personal);
if (privateMqPersonal == NULL) {
goto OUT_UNLOCK;
@ -962,26 +936,11 @@ int OsMqNotify(mqd_t personal, const struct sigevent *sigev)
mqnotify->pid = LOS_GetCurrProcessID();
}
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return 0;
OUT_UNLOCK:
(VOID)pthread_mutex_unlock(&IPC_QUEUE_MUTEX);
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
ERROUT:
return -1;
}
VOID OsMqueueCBDestroy(struct mqarray *queueTable)
{
if (queueTable == NULL) {
return;
}
for (UINT32 index = 0; index < LOSCFG_BASE_IPC_QUEUE_LIMIT; index++) {
struct mqarray *mqueueCB = &(queueTable[index]);
if (mqueueCB->mq_name == NULL) {
continue;
}
(VOID)DoMqueueClose(mqueueCB->mq_personal);
}
}
#endif

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -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 = LOS_TaskPriGet(OsCurrTaskGet()->taskID);
outAttr->schedparam.sched_priority = ((LosTaskCB *)(OsCurrTaskGet()))->priority;
} else {
outAttr->schedpolicy = self->attr.schedpolicy;
outAttr->schedparam = self->attr.schedparam;
@ -231,7 +231,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
SetPthreadAttr(self, attr, &userAttr);
(VOID)snprintf_s(name, sizeof(name), sizeof(name) - 1, "pth%02d", pthreadNumber);
(VOID)snprintf_s(name, sizeof(name), sizeof(name) - 1, "pth%02u", pthreadNumber);
pthreadNumber++;
taskInitParam.pcName = name;
@ -240,15 +240,15 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
taskInitParam.usTaskPrio = (UINT16)userAttr.schedparam.sched_priority;
taskInitParam.uwStackSize = userAttr.stacksize;
if (OsProcessIsUserMode(OsCurrProcessGet())) {
taskInitParam.processID = (UINTPTR)OsGetKernelInitProcess();
taskInitParam.processID = OsGetKernelInitProcessID();
} else {
taskInitParam.processID = (UINTPTR)OsCurrProcessGet();
taskInitParam.processID = OsCurrProcessGet()->processID;
}
if (userAttr.detachstate == PTHREAD_CREATE_DETACHED) {
taskInitParam.uwResved = LOS_TASK_STATUS_DETACHED;
} else {
/* Set the pthread default joinable */
taskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
taskInitParam.uwResved = 0;
}
PthreadReap();

View File

@ -47,7 +47,7 @@ void srand(unsigned s)
int rand(void)
{
return random();
return random();
}
void _exit(int status)

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -71,7 +71,7 @@
#ifdef LOSCFG_AARCH64
/*
* This two structures originally didn't exit,
* This two structures originally did't exit,
* they added by liteos to support 64bit interfaces on 32bit platform,
* in 64bit platform, timeval64 define to timeval which is platform adaptive.
*/
@ -117,7 +117,7 @@ STATIC INLINE BOOL ValidTimerID(UINT16 swtmrID)
}
/* check owner of this timer */
if (OS_SWT_FROM_SID(swtmrID)->uwOwnerPid != (UINTPTR)OsCurrProcessGet()) {
if (OS_SWT_FROM_SID(swtmrID)->uwOwnerPid != LOS_GetCurrProcessID()) {
return FALSE;
}
@ -387,16 +387,9 @@ 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);
@ -478,13 +471,14 @@ 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;
}
LosTaskCB *task = OsGetTaskCB(tid);
if (OsCurrTaskGet()->processCB != task->processCB) {
if (OsCurrTaskGet()->processID != task->processID) {
return -EINVAL;
}
@ -515,11 +509,7 @@ static int ProcessGetCputime(clockid_t clockID, struct timespec *ats)
}
SCHEDULER_LOCK(intSave);
if (spcb->processCpup == NULL) {
SCHEDULER_UNLOCK(intSave);
return -EINVAL;
}
runtime = spcb->processCpup->allTime;
runtime = spcb->processCpup.allTime;
SCHEDULER_UNLOCK(intSave);
ats->tv_sec = runtime / OS_SYS_NS_PER_SECOND;
@ -599,22 +589,13 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
switch (clockID) {
case CLOCK_MONOTONIC_RAW:
#ifdef LOSCFG_TIME_CONTAINER
tmp = OsTimeSpecAdd(hwTime, CLOCK_MONOTONIC_TIME_BASE);
tp->tv_sec = tmp.tv_sec;
tp->tv_nsec = tmp.tv_nsec;
#else
tp->tv_sec = hwTime.tv_sec;
tp->tv_nsec = hwTime.tv_nsec;
#endif
break;
case CLOCK_MONOTONIC:
LOS_SpinLockSave(&g_timeSpin, &intSave);
tmp = OsTimeSpecAdd(hwTime, g_accDeltaFromAdj);
LOS_SpinUnlockRestore(&g_timeSpin, intSave);
#ifdef LOSCFG_TIME_CONTAINER
tmp = OsTimeSpecAdd(tmp, CLOCK_MONOTONIC_TIME_BASE);
#endif
tp->tv_sec = tmp.tv_sec;
tp->tv_nsec = tmp.tv_nsec;
break;
@ -648,7 +629,7 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
return 0;
ERROUT:
ERROUT:
TIME_RETURN(EINVAL);
}
@ -662,7 +643,7 @@ int clock_getres(clockid_t clockID, struct timespec *tp)
case CLOCK_MONOTONIC_RAW:
case CLOCK_MONOTONIC:
case CLOCK_REALTIME:
/* the accessible rtc resolution */
/* the accessable rtc resolution */
tp->tv_nsec = OS_SYS_NS_PER_US; /* the precision of clock_gettime is 1us */
tp->tv_sec = 0;
break;
@ -733,7 +714,6 @@ typedef struct {
static VOID SwtmrProc(UINTPTR tmrArg)
{
#ifdef LOSCFG_KERNEL_VM
INT32 sig, ret;
UINT32 intSave;
pid_t pid;
@ -757,7 +737,7 @@ static VOID SwtmrProc(UINTPTR tmrArg)
/* Make sure that the para is valid */
OS_GOTO_EXIT_IF(OS_TID_CHECK_INVALID(arg->tid), EINVAL);
stcb = OsGetTaskCB(arg->tid);
ret = OsUserProcessOperatePermissionsCheck(stcb, stcb->processCB);
ret = OsUserProcessOperatePermissionsCheck(stcb, stcb->processID);
OS_GOTO_EXIT_IF(ret != LOS_OK, -ret);
/* Dispatch the signal to thread, bypassing normal task group thread
@ -776,48 +756,10 @@ static VOID SwtmrProc(UINTPTR tmrArg)
}
return;
EXIT:
PRINT_ERR("Dispatch signals failed!, ret: %d\r\n", ret);
#endif
PRINT_ERR("Dsipatch signals failed!, ret: %d\r\n", ret);
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;
@ -877,7 +819,6 @@ int timer_delete(timer_t timerID)
{
UINT16 swtmrID = (UINT16)(UINTPTR)timerID;
VOID *arg = NULL;
UINTPTR swtmrProc;
#ifdef LOSCFG_SECURITY_VID
swtmrID = GetRidByVid(swtmrID);
@ -887,11 +828,10 @@ 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 ((swtmrProc == (UINTPTR)SwtmrProc) && (arg != NULL)) {
if (arg != NULL) {
free(arg);
}
@ -1035,11 +975,7 @@ 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);
}
@ -1096,7 +1032,8 @@ clock_t times(struct tms *buf)
int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue)
{
UINT32 intSave;
LosProcessCB *processCB = OsCurrProcessGet();
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
timer_t timerID = 0;
struct itimerspec spec;
struct itimerspec ospec;
@ -1149,7 +1086,8 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
int getitimer(int which, struct itimerval *value)
{
LosProcessCB *processCB = OsCurrProcessGet();
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
struct itimerspec spec = {};
int ret = LOS_OK;

View File

@ -38,7 +38,7 @@ LITEOS_CXXOPTS := $(LITEOS_CXXOPTS_BASE)
LITEOS_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_EXTKERNEL_INCLUDE) \
$(LITEOS_COMPAT_INCLUDE) $(LITEOS_FS_INCLUDE) \
$(LITEOS_NET_INCLUDE) $(LITEOS_LIB_INCLUDE) \
$(LITEOS_DRIVERS_INCLUDE) $(LITEOS_TOOLS_DEBUG_INCLUDE) \
$(LITEOS_DRIVERS_INCLUDE) $(LOSCFG_TOOLS_DEBUG_INCLUDE) \
$(LITEOS_PLATFORM_INCLUDE) $(LITEOS_DFX_INCLUDE) \
$(LITEOS_SECURITY_INCLUDE)
LITEOS_LIBDEP := $(LITEOS_BASELIB)
@ -52,17 +52,10 @@ LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \
$(LITEOS_LD_SCRIPT)
# clear all local variables
LOCAL_FLAGS =
LOCAL_CFLAGS =
LOCAL_CPPFLAGS =
LOCAL_ASFLAGS =
LOCAL_SRCS =
LOCAL_CHS =
LOCAL_CPPHS =
# basic build flags
CFLAGS := $(LITEOS_CFLAGS)
CXXFLAGS := $(LITEOS_CXXFLAGS)
ASFLAGS := $(LITEOS_ASFLAGS)
LDFLAGS := $(LITEOS_LDFLAGS)
ARFLAGS := rc
LOCAL_FLAGS :=
LOCAL_CFLAGS :=
LOCAL_CPPFLAGS :=
LOCAL_ASFLAGS :=
LOCAL_SRCS :=
LOCAL_CHS :=
LOCAL_CPPHS :=

View File

@ -29,10 +29,28 @@
import("//kernel/liteos_a/liteos.gni")
module_group("drivers") {
modules = [
"block",
"char",
"mtd",
group("drivers") {
deps = [
"block/disk",
"char/bch",
"char/mem",
"char/quickstart",
"char/random",
"char/trace",
"char/video",
"mtd/multi_partition",
]
}
config("public") {
configs = [
"block/disk:public",
"char/bch:public",
"char/mem:public",
"char/quickstart:public",
"char/random:public",
"char/video:public",
"char/trace:public",
"mtd/multi_partition:public",
]
}

View File

@ -1,20 +0,0 @@
config DRIVERS
bool "Enable Driver"
default y
help
Answer Y to enable LiteOS support driver.
source "bsd/dev/usb/Kconfig"
source "../../drivers/hdf_core/adapter/khdf/liteos/Kconfig"
# Device driver Kconfig import
source "$(DEVICE_PATH)/drivers/Kconfig"
source "drivers/char/mem/Kconfig"
source "drivers/char/quickstart/Kconfig"
source "drivers/char/random/Kconfig"
source "drivers/char/video/Kconfig"
source "drivers/char/trace/Kconfig"
source "drivers/char/perf/Kconfig"
source "../../drivers/liteos/hievent/Kconfig"

View File

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

View File

@ -33,4 +33,8 @@ MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard src/*.c)
LOCAL_INCLUDE := \
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE)

View File

@ -45,6 +45,8 @@
#include "bcache.h"
#endif
#include "pthread.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
@ -163,7 +165,7 @@ extern "C" {
#define DISK_ATA_GET_MODEL 21 /* Get model name */
#define DISK_ATA_GET_SN 22 /* Get serial number */
#ifndef LOSCFG_FS_FAT_CACHE
#ifdef LOSCFG_FS_FAT_CACHE
#define DISK_DIRECT_BUFFER_SIZE 4 /* los_disk direct io buffer when bcache is off */
#endif
@ -251,7 +253,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 structure.
* @param bops [IN] Type #const struct block_operations * block driver control sturcture.
* @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.
@ -710,7 +712,7 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName);
* @brief get the INUSED disk id.
*
* @par Description:
* Get the corresponding INUSED disk id by diskName.
* Get the correponding 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-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* 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 parameter disk_name is NULL");
PRINT_ERR("The paramter 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 parameter diskName is NULL");
PRINT_ERR("The paramter 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 information. */
/* Fill disk_divide_info structure to set partition's infomation. */
(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 information. */
/* Read the disk_divide_info structure to get partition's infomation. */
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));
@ -1063,7 +1063,7 @@ INT32 los_part_read(INT32 pt, VOID *buf, UINT64 sector, UINT32 count, BOOL useRe
}
if (count > part->sector_count) {
PRINT_ERR("los_part_read failed, invalid count, count = %u\n", count);
PRINT_ERR("los_part_read failed, invaild count, count = %u\n", count);
goto ERROR_HANDLE;
}
@ -1072,7 +1072,7 @@ INT32 los_part_read(INT32 pt, VOID *buf, UINT64 sector, UINT32 count, BOOL useRe
if ((disk->sector_count - part->sector_start) > sector) {
sector += part->sector_start;
} else {
PRINT_ERR("los_part_read failed, invalid sector, sector = %llu\n", sector);
PRINT_ERR("los_part_read failed, invaild sector, sector = %llu\n", sector);
goto ERROR_HANDLE;
}
}
@ -1119,7 +1119,7 @@ INT32 los_part_write(INT32 pt, const VOID *buf, UINT64 sector, UINT32 count)
}
if (count > part->sector_count) {
PRINT_ERR("los_part_write failed, invalid count, count = %u\n", count);
PRINT_ERR("los_part_write failed, invaild count, count = %u\n", count);
goto ERROR_HANDLE;
}
@ -1128,7 +1128,7 @@ INT32 los_part_write(INT32 pt, const VOID *buf, UINT64 sector, UINT32 count)
if ((disk->sector_count - part->sector_start) > sector) {
sector += part->sector_start;
} else {
PRINT_ERR("los_part_write failed, invalid sector, sector = %llu\n", sector);
PRINT_ERR("los_part_write failed, invaild sector, sector = %llu\n", sector);
goto ERROR_HANDLE;
}
}
@ -1465,7 +1465,7 @@ INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops,
ret = VnodeLookup(diskName, &blkDriver, 0);
if (ret < 0) {
VnodeDrop();
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret);
ret = ENOENT;
goto DISK_FIND_ERROR;
}
struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops;

View File

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

View File

@ -28,12 +28,21 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
import("$THIRDPARTY_NUTTX_DIR/NuttX.gni")
module_switch = defined(LOSCFG_FS_VFS_BLOCK_DEVICE)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = NUTTX_DRIVERS_BCH_SRC_FILES
sources = [
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_driver.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_register.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_unregister.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_cache.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_read.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_sem.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_setup.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_teardown.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_write.c",
]
public_configs = [ ":public" ]
}

View File

@ -34,8 +34,9 @@ MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard $(LITEOSTHIRDPARTY)/NuttX/drivers/bch/*.c)
LOCAL_INCLUDE := \
-I $(LITEOSTHIRDPARTY)/NuttX/drivers/bch
-I $(LITEOSTHIRDPARTY)/NuttX/drivers/bch \
-I $(LITEOSTOPDIR)/fs/include \
LOCAL_FLAGS := $(LOCAL_INCLUDE)
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE)

View File

@ -61,7 +61,7 @@ static ssize_t MemMap(struct file *filep, LosVmMapRegion *region)
VADDR_T vaddr = region->range.base;
LosVmSpace *space = LOS_SpaceGet(vaddr);
if (((paddr + size) >= SYS_MEM_BASE) && (paddr < SYS_MEM_END)) {
if ((paddr >= SYS_MEM_BASE) && (paddr < SYS_MEM_END)) {
return -EINVAL;
}
@ -97,5 +97,5 @@ static const struct file_operations_vfs g_memDevOps = {
int DevMemRegister(void)
{
return register_driver("/dev/mem", &g_memDevOps, 0644, 0); /* 0644: file mode */
return register_driver("/dev/mem", &g_memDevOps, 0666, 0); /* 0666: file mode */
}

View File

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

View File

@ -1,6 +0,0 @@
config DRIVERS_PERF
bool "Enable PERF DRIVER"
default y
depends on DRIVERS && FS_VFS && KERNEL_PERF
help
Answer Y to enable LiteOS support perf in userspace.

View File

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

View File

@ -1,153 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "fcntl.h"
#include "user_copy.h"
#include "sys/ioctl.h"
#include "fs/driver.h"
#include "los_dev_perf.h"
#include "los_perf.h"
#include "los_init.h"
#define PERF_DRIVER "/dev/perf"
#define PERF_DRIVER_MODE 0666
/* perf ioctl */
#define PERF_IOC_MAGIC 'T'
#define PERF_START _IO(PERF_IOC_MAGIC, 1)
#define PERF_STOP _IO(PERF_IOC_MAGIC, 2)
static int PerfOpen(struct file *filep)
{
(void)filep;
return 0;
}
static int PerfClose(struct file *filep)
{
(void)filep;
return 0;
}
static ssize_t PerfRead(struct file *filep, char *buffer, size_t buflen)
{
/* perf record buffer read */
(void)filep;
int ret;
int realLen;
char *records = LOS_MemAlloc(m_aucSysMem0, buflen);
if (records == NULL) {
return -ENOMEM;
}
realLen = LOS_PerfDataRead(records, buflen); /* get sample data */
if (realLen == 0) {
PRINT_ERR("Perf read failed, check whether perf is configured to sample mode.\n");
ret = -EINVAL;
goto EXIT;
}
ret = LOS_CopyFromKernel((void *)buffer, buflen, (void *)records, realLen);
if (ret != 0) {
ret = -EINVAL;
goto EXIT;
}
ret = realLen;
EXIT:
LOS_MemFree(m_aucSysMem0, records);
return ret;
}
static ssize_t PerfConfig(struct file *filep, const char *buffer, size_t buflen)
{
(void)filep;
int ret;
PerfConfigAttr attr = {0};
int attrlen = sizeof(PerfConfigAttr);
if (buflen != attrlen) {
PRINT_ERR("PerfConfigAttr is %d bytes not %d\n", attrlen, buflen);
return -EINVAL;
}
ret = LOS_CopyToKernel(&attr, attrlen, buffer, buflen);
if (ret != 0) {
return -EINVAL;
}
ret = LOS_PerfConfig(&attr);
if (ret != LOS_OK) {
PRINT_ERR("perf config error %u\n", ret);
return -EINVAL;
}
return 0;
}
static int PerfIoctl(struct file *filep, int cmd, unsigned long arg)
{
(void)filep;
switch (cmd) {
case PERF_START:
LOS_PerfStart((UINT32)arg);
break;
case PERF_STOP:
LOS_PerfStop();
break;
default:
PRINT_ERR("Unknown perf ioctl cmd:%d\n", cmd);
return -EINVAL;
}
return 0;
}
static const struct file_operations_vfs g_perfDevOps = {
PerfOpen, /* open */
PerfClose, /* close */
PerfRead, /* read */
PerfConfig, /* write */
NULL, /* seek */
PerfIoctl, /* ioctl */
NULL, /* mmap */
#ifndef CONFIG_DISABLE_POLL
NULL, /* poll */
#endif
NULL, /* unlink */
};
int DevPerfRegister(void)
{
return register_driver(PERF_DRIVER, &g_perfDevOps, PERF_DRIVER_MODE, 0); /* 0666: file mode */
}
LOS_MODULE_INIT(DevPerfRegister, LOS_INIT_LEVEL_KMOD_EXTENDED);

View File

@ -112,7 +112,7 @@ static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
return QuickstartNotify(arg);
}
if (LOS_GetCurrProcessID() != OS_USER_ROOT_PROCESS_ID) {
if (OsGetUserInitProcessID() != LOS_GetCurrProcessID()) {
PRINT_ERR("Permission denios!\n");
return -EACCES;
}

View File

@ -5,7 +5,7 @@ config DRIVERS_RANDOM
help
Answer Y to support random.
config HW_RANDOM_ENABLE
depends on DRIVERS_RANDOM && (PLATFORM_HI3518EV300 || PLATFORM_HI3516CV300 || PLATFORM_HI3516DV300 || PLATFORM_HI3556V200 || PLATFORM_QEMU_ARM_VIRT_CA7)
depends on DRIVERS_RANDOM && (PLATFORM_HI3518EV300 || PLATFORM_HI3516CV300 || PLATFORM_HI3516DV300 || PLATFORM_HI3556V200)
bool "Select hw random"
default y
help

View File

@ -37,4 +37,9 @@ ifdef LOSCFG_HW_RANDOM_ENABLE
LOCAL_SRCS += $(wildcard src/random_hw.c)
endif
LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/drivers/char/random/include \
-I $(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH)/include
LOCAL_FLAGS := $(LOCAL_INCLUDE)
include $(MODULE)

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