Compare commits

...

384 Commits

Author SHA1 Message Date
openharmony_ci
d4d59cf08f !603 cpup和测试套解耦,使用cpup相关宏来管理相关内容。
Merge pull request !603 from LiteOS/master
2022-02-22 07:04:53 +00:00
LiteOS2021
692651fe40 fix(testsuites): cpup和测试套解耦
cpup和测试套解耦,使用相关宏来管理cpup相关内容。

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

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

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

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

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

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

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-02-18 17:30:29 +08:00
openharmony_ci
6efd469a4f !601 fix: 修复pthread 编译告警
Merge pull request !601 from zhushengle/pthread
2022-02-17 03:36:42 +00:00
zhushengle
cc57f81ab8 fix: 修复pthread 编译告警
Close #I4U16U
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I67ba2469f2a4697bcb6da9f342bd8d18835cc874
2022-02-17 10:06:15 +08:00
openharmony_ci
5dbac3ab4c !599 fix: posix线程和LOS_TaskCreate任务不兼容,补齐接口防护,防止访问野指针
Merge pull request !599 from zhushengle/pthread
2022-02-16 11:15:25 +00:00
zhushengle
60805e1a7c fix: posix线程和LOS_TaskCreate任务不兼容,补齐接口防护,防止访问野指针
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I03040e86a5ac618d3ede671c497a0ae88a3717ae
2022-02-16 14:47:35 +08:00
openharmony_ci
7cf08722a0 !597 修复未使用的参数和类型比较编译报错问题
Merge pull request !597 from 方烨/develop
2022-02-16 06:42:11 +00:00
fangye
21b46e82f3 fix: 修复未使用的参数和类型比较编译报错问题
Signed-off-by: fangye <fangye@talkweb.com.cn>
Change-Id: I64f9e0cd20b62f877f353340b81922ddd45fbf7c
2022-02-15 18:53:30 +08:00
openharmony_ci
35971d660e !591 littlefs最大打开文件个数修改为可通过menuconfig配置
Merge pull request !591 from 方烨/master
2022-02-15 06:55:09 +00:00
openharmony_ci
289ad2c57d !591 littlefs最大打开文件个数修改为可通过menuconfig配置
Merge pull request !591 from 方烨/master
2022-02-15 06:55:09 +00:00
openharmony_ci
e20444cda6 !591 littlefs最大打开文件个数修改为可通过menuconfig配置
Merge pull request !591 from 方烨/master
2022-02-15 06:55:08 +00:00
openharmony_ci
b9830c61f5 !592 【liteos_m】kernel接口融合修改
Merge pull request !592 from LiteOS/master
2022-02-15 06:30:43 +00:00
LiteOS2021
cee9714a90 fix: kernel接口融合,添加/修改kernel函数
kernel接口融合,添加/修改kernel函数

BREAKING CHANGE:
新增接口:
LOS_TaskResRecycle
LOS_CurrNanosec
LOS_MDelay
接口修改:
LOS_QueueCreate:第一个入参添加const修饰并增加一种异常情况处理
los_memory.c中 OS_ERROR 修改为LOS_NOK,重定义LOS_NOK为(UINT32)-1。
接口位置转移:
LOS_UDelay 由los_task.h/.c 转移到los_tick.h/.c 
宏修改:
LOS_ERRNO_MUX_PEND_INTERR 改名为 LOS_ERRNO_MUX_IN_INTERR
增加宏:

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-02-15 09:47:58 +08:00
openharmony_ci
ffd228cd8d !595 fix: los_interrupt.c存在未使用的参数编译出错
Merge pull request !595 from kenneth/compile_error
2022-02-14 13:16:38 +00:00
kenneth
5af4c2e213 fix: los_interrupt.c存在未使用的参数编译出错
修复los_interrupt.c存在未使用的参数编译出错

close #I4SJPZ

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2022-02-14 20:14:40 +08:00
openharmony_ci
b423d9f7bb !589 feat: 同步调度部分优化至liteos_m
Merge pull request !589 from zhushengle/sched_timer
2022-02-13 04:17:46 +00:00
zhushengle
fb11ab181e feat: 同步调度部分优化至liteos_m
1.tick timer与调度进一步剥离
2.性能敏感函数内敛化

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I00c27216e286dd7ca9c02db3e2377707d628a786
2022-02-12 14:52:36 +08:00
openharmony_ci
c811efbf37 !590 feat: cortex-m55支持psplimit
Merge pull request !590 from Harylee/m55
2022-02-11 07:26:26 +00:00
fangye
9bc9f3aa53 feat: littlefs最大打开文件个数修改为可通过menuconfig配置
Signed-off-by: fangye <fangye@talkweb.com.cn>
Change-Id: Iba141821200b6044d89ec50b7ddb1047490f5229
2022-02-11 14:52:42 +08:00
Haryslee
db7d641c22 feat: cortex-m55支持psplimit
cortex-m55增加栈溢出检测特性

close #I4T7R3

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: Ie24adbb672c47404b56aa5bfc9f22e0f7f947540
2022-02-11 11:35:38 +08:00
openharmony_ci
a68323683d !587 fix: cortex-m55栈优化
Merge pull request !587 from Harylee/m55
2022-02-10 13:37:30 +00:00
Haryslee
59e9c6ed73 fix: cortex-m55栈优化
利用EXC_RETURN可判断出上下文是否使用FPU寄存器,进而确定是否对FPU寄存器进行压栈操作

close #I4SQIQ

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: Ib8b3a8b359486b3b7851278365860be1bfed65f2
2022-02-10 21:17:27 +08:00
openharmony_ci
d1d412255c !570 fix:shell 命令 ctrl +c 打印使用多余的参数
Merge pull request !570 from 拓维信息候鹏飞/master
2022-02-10 12:16:07 +00:00
openharmony_ci
b534083056 !569 shell命令行输入增加回退支持
Merge pull request !569 from 方烨/master
2022-02-10 11:56:34 +00:00
openharmony_ci
968c00f049 !588 【liteos_m】posix接口融合,接口规范兼容性修改
Merge pull request !588 from LiteOS/master
2022-02-10 11:43:16 +00:00
openharmony_ci
df0ed8d219 !588 【liteos_m】posix接口融合,接口规范兼容性修改
Merge pull request !588 from LiteOS/master
2022-02-10 11:43:15 +00:00
LiteOS2021
4b607fd074 fix(posix接口融合): posix接口融合,接口规范兼容性修改
posix接口融合,接口规范兼容性修改

BREAKING CHANGE:
接口修改:
calloc
pthread_mutex_init
mq_unlink
pthread_join
pthread_exit
pthread_attr_init
pthread_attr_destroy
pthread_condattr_destroy
pthread_cond_timedwait
pthread_mutexattr_init
pthread_mutexattr_settype
pthread_mutex_destroy
pthread_mutex_timedlock
pthread_mutex_trylockk
pthread_mutex_unlock
sem_getvalue
sem_timedwait
pthread_cond_timedwait
nanosleep
timer_create
timer_settime
timer_gettime
testStdlibStrtoull005
testStdlibStrtol011
testStdlibStrtoul007
testPthread004

新增接口:
CheckForCancel
pthread_setcancelstate
pthread_setcanceltype
pthread_once
pthread_setschedprio
pthread_attr_setstack
pthread_attr_getstack
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_condattr_getclock
pthread_mutexattr_gettype
CheckMutexAttr
OsMuxPreCheck
sem_trywait
MuxPendForPosix
MuxPostForPosix
增加overrun功能

接口变化:
mq_getsetattr 改为内部接口MqGetSetAttr
GetTickTimeFromNow->OsGetTickTimeFromNow

接口位置转移:
pthread_equal接口由newlib下转移到kal/posix/src/pthread.c中

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-02-10 16:41:12 +08:00
openharmony_ci
1013f24209 !583 posix兼容回退
Merge pull request !583 from LiteOS/master
2022-01-30 23:49:31 +00:00
LiteOS2021
207efc15b8 fix(posix): posix兼容回退
posix兼容回退

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-01-30 23:09:20 +08:00
openharmony_ci
f2e55bd6a3 !576 支持cortex-m55
Merge pull request !576 from Harylee/m55
2022-01-30 13:21:28 +00:00
openharmony_ci
607152c434 !566 【liteos_m】posix接口融合,接口规范兼容性修改
Merge pull request !566 from LiteOS/master
2022-01-30 02:27:56 +00:00
LiteOS
39558ae1a3 Merge branch 'master' of gitee.com:openharmony/kernel_liteos_m into master
Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-01-29 19:30:28 +08:00
openharmony_ci
eae638be6c !575 【liteos_m】posix单元测试融合
Merge pull request !575 from LiteOS/master
2022-01-29 11:11:00 +00:00
LiteOS2021
e0b12758da fix(posix): posix接口融合,接口规范兼容性修改
posix接口融合,接口规范兼容性修改

BREAKING CHANGE:
接口修改:
calloc
pthread_mutex_init
mq_unlink
pthread_join
pthread_exit
pthread_attr_init
pthread_attr_destroy
pthread_condattr_destroy
pthread_cond_timedwait
pthread_mutexattr_init
pthread_mutexattr_settype
pthread_mutex_destroy
pthread_mutex_timedlock
pthread_mutex_trylockk
pthread_mutex_unlock
sem_getvalue

新增接口:
CheckForCancel
pthread_setcancelstate
pthread_setcanceltype
pthread_once
pthread_setschedprio
pthread_attr_setstack
pthread_attr_getstack
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_condattr_getclock
pthread_mutexattr_gettype
CheckMutexAttr
OsMuxPreCheck
sem_trywait

接口变化:
mq_getsetattr 改为内部接口OsMqGetSetAttr

接口位置转移:
pthread_equal接口由newlib下转移到kal/posix/src/pthread.c中

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-01-29 16:57:49 +08:00
Haryslee
6e1780546c feat: 支持cortex-m55
基于qemu支持cortex-m55处理器,包括MVE功能使能。

close #I4Q9OQ

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: I571702ac8e8f52769afdf600b48451f1f1806a88
2022-01-28 15:40:37 +08:00
LiteOS2021
ad6f249d1e fix(posix unittest): posix unittest 融合
posix unittest 融合

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2022-01-26 14:50:44 +08:00
openharmony_ci
907dfc63f3 !572 kernel部件化编译构建(liteos_m仓库修改)
Merge pull request !572 from Hongjin Li/lihongjin/br_dev
2022-01-24 13:27:49 +00:00
openharmony_ci
5a2c176651 !571 支持select.h的FD_SETSIZE宏配置
Merge pull request !571 from SimonLi/master
2022-01-24 12:48:31 +00:00
likailong
05642f05ae feat: 支持select.h的FD_SETSIZE宏配置
1. FD_SETSIZE由普通文件+网络文件的文件句柄个数之和决定。
2. 以前vfs_config.h引入fatfs.h和lfs_api.h又会引入其他头文件,
导致变异问题。因此需要将配置宏拆分出来放到fatfs_conf.h和
lfs_conf.h 头文件中。
3. lwipopts.h会提供网络的句柄个数,依赖FD_SETSIZE,而select.h会提供FD_SETSIZE,
依赖网络句柄个数,因此会形成相互依赖的情况,需要通过顺序来解决。
4. 网络中新增ntohl的定义。

close: #I4RYK4

Signed-off-by: likailong <likailong@huawei.com>
2022-01-24 17:24:26 +08:00
Hongjin Li
300e83214d chore: kernel部件化编译构建
liteos_m部件只包括两个子部件:kernel和build_kernel_image

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I0c96f103641d2bba52b093a014dd07b75c6d28e1
2022-01-24 16:24:23 +08:00
houpengfei
8b586fb2bf 删除不必要的参数
Signed-off-by: houpengfei <houpengfei@talkweb.com.cn>
2022-01-24 09:07:36 +08:00
fangye
d986648e9c shell命令行增加回退支持
Signed-off-by: fangye <fangye@talkweb.com.cn>
2022-01-23 21:11:43 +08:00
openharmony_ci
e133ce6865 !513 CMSIS接口融合修改
Merge pull request !513 from LiteOS/master
2022-01-22 04:53:32 +00:00
openharmony_ci
168fde70d4 !513 CMSIS接口融合修改
Merge pull request !513 from LiteOS/master
2022-01-22 04:53:32 +00:00
openharmony_ci
fede33b32a !568 liteos-m kernel 部件标准化
Merge pull request !568 from Hongjin Li/lihongjin/br_dev
2022-01-22 03:45:24 +00:00
LiteOS
3eba6cb2af add cmsis change
Signed-off-by: LiteOS <dinglu@huawei.com>
Signed-off-by: ou-yangkan <519689417@qq.com>
2022-01-22 09:28:55 +08:00
openharmony_ci
d8e7a477f3 !567 fix: pr模板补充说明
Merge pull request !567 from Harylee/mmu
2022-01-22 00:54:59 +00:00
openharmony_ci
2d1b6f1cc0 !567 fix: pr模板补充说明
Merge pull request !567 from Harylee/mmu
2022-01-22 00:54:59 +00:00
openharmony_ci
30ff05c6a5 !567 fix: pr模板补充说明
Merge pull request !567 from Harylee/mmu
2022-01-22 00:54:59 +00:00
openharmony_ci
295681f08f !563 newlib支持signal接口
Merge pull request !563 from JerryH/newlib
2022-01-21 09:45:12 +00:00
openharmony_ci
161e631dcd !555 feat:内核提供Interrupt框架,支持多架构多平台通用化
Merge pull request !555 from 王树林/master
2022-01-21 09:29:43 +00:00
Haryslee
7b86f69cc0 fix: pr模板补充说明
Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: I97159bd21d3d8768a8a9c59a895368d90442a304
2022-01-21 17:10:14 +08:00
openharmony_ci
8a034a6202 !565 修改kernel原子测试套中不规范的命名
Merge pull request !565 from ouyk/master
2022-01-21 08:58:05 +00:00
ou-yangkan
e8538d041a feat: 内核提供Interrupt框架,支持多架构多平台通用化
BREAKING CHANGE:
    新增接口:
    LOS_HwiTrigger ArchIntTrigger
    LOS_HwiEnable ArchIntEnable
    LOS_HwiDisable ArchIntDisable
    LOS_HwiClear ArchIntClear
    LOS_HwiSetPriority ArchIntSetPriority

https://gitee.com/openharmony/kernel_liteos_m/issues/I4RDNJ
Signed-off-by: wang-shulin93 <15173259956@163.com>
2022-01-21 16:40:45 +08:00
ou-yangkan
5b1380ebfd 修改kernel原子测试套中不规范的命名
Signed-off-by: ou-yangkan <519689417@qq.com>
2022-01-21 09:43:47 +08:00
JerryH
017adac7a4 feature: Newlib support signal.
修改signal适配支持Newlic

close #I4RD3H

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I59f59856a275f5a4f802a1ea7d08e9405a2fb6aa
2022-01-20 18:50:17 +08:00
openharmony_ci
1b78e6ae78 !541 fix: 补充newlib库对curl的支持
Merge pull request !541 from Kiita/220115_curl
2022-01-20 09:41:31 +00:00
openharmony_ci
911043ed4b !541 fix: 补充newlib库对curl的支持
Merge pull request !541 from Kiita/220115_curl
2022-01-20 09:41:31 +00:00
openharmony_ci
a641899cd9 !562 修复esp32编译缺少result定义问题
Merge pull request !562 from ouyk/master
2022-01-20 09:11:51 +00:00
ou-yangkan
08921dc7a0 修复esp32编译报错问题
Signed-off-by: ou-yangkan <519689417@qq.com>
2022-01-20 16:42:29 +08:00
openharmony_ci
1edfa86bc9 !552 支持signal
Merge pull request !552 from JerryH/signal
2022-01-20 06:15:24 +00:00
openharmony_ci
f4add1711a !557 修复esp32编译告警导致编译失败问题
Merge pull request !557 from ouyk/master
2022-01-20 05:54:31 +00:00
JerryH
8d7468b44c feature: Support kernel signal and POSIX API.
内核支持信号功能,支持注册、屏蔽、等待及触发等操作。

close #I4R72Q

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I26fb11a03d1899c6f7e665f0798824c578d592a6
2022-01-20 11:17:40 +08:00
openharmony_ci
93e1edf81e !559 fix: 针对pr是否同步至release分支,增加原因说明规则
Merge pull request !559 from Harylee/mmu
2022-01-20 00:47:27 +00:00
ou-yangkan
af0db5562b 修复kernel_liteos_m的pr526后esp32编译告警导致编译失败问题
Signed-off-by: ou-yangkan <519689417@qq.com>
2022-01-20 00:10:06 +08:00
Kiita
bd04d9f29a fix: 将curl依赖的函数新增至newlib库
re #I4RG71
Signed-off-by: yansira <yansira@hotmail.com>
Change-Id: I9bd13f7232015f1ec0da383f7063936a2745ee71
2022-01-19 18:17:03 +08:00
Hongjin Li
9314b2fe81 chore: liteos-m kernel 部件标准化
1、添加liteos-m kernel的部件描述文件bundle.json
2、依赖三方开源软件的编译脚本修改,取消直接include头文件,改为引用三方开源软件提供的公共配置。

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
Change-Id: I345c105a75c5cd87144c821fae123abf1f53e9f7
2022-01-19 17:44:49 +08:00
openharmony_ci
1f8151649b !556 fix:当前仓代码编译告警的问题
Merge pull request !556 from 拓维信息候鹏飞/master
2022-01-19 08:34:36 +00:00
houpengfei
1e5aeb9eed fix:当前仓代码编译告警的问题
Signed-off-by: houpengfei <houpengfei@talkweb.com.cn>
2022-01-19 16:11:39 +08:00
openharmony_ci
5a535f9f1f !526 处理M核编译告警
Merge pull request !526 from yinjiaming/yjm-kernel-20220105
2022-01-19 02:56:01 +00:00
openharmony_ci
3a978d51b8 !526 处理M核编译告警
Merge pull request !526 from yinjiaming/yjm-kernel-20220105
2022-01-19 02:56:01 +00:00
yinjiaming
194ac5898d fix: 当前仓代码编译告警的问题
【背景】
当前仓代码存在编译告警需要处理

【修改方案】
在测试用例中屏蔽了-Werror选项
在对应的代码处添加了相应函数的声明头文件

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

re #I4N50W

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I7dc1e38105aa3d60f9f991f34f88875cccb48463
2022-01-19 02:27:14 +00:00
Haryslee
1ee543d5d3 fix: 针对pr是否同步至release分支,增加原因说明规则
Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: I01cdf45204c73d2b94d41e5350969d0356604b91
2022-01-18 21:32:17 +08:00
openharmony_ci
a305119a4a !539 fix:修复iar、keil版本原子接口编译报错问题
Merge pull request !539 from 王树林/master
2022-01-18 11:27:09 +00:00
ou-yangkan
a906dfaa99 fix atomic compile error of iar
Signed-off-by: wang-shulin93 <15173259956@163.com>
2022-01-18 18:59:29 +08:00
openharmony_ci
c2d3518c42 !538 支持pipe管道通信机制以及poll多文件描述符检测接口
Merge pull request !538 from JerryH/pipe
2022-01-18 10:29:15 +00:00
openharmony_ci
4a8d3a52ec !553 fix: 队列相关的API实现中,参数的校验不完全,导致程序异常
Merge pull request !553 from Lyb/master
2022-01-18 09:30:03 +00:00
openharmony_ci
2c07ddb2b0 !551 fix:backtrace严重BUG
Merge pull request !551 from 拓维信息候鹏飞/master
2022-01-18 09:01:34 +00:00
JerryH
4890222e7c feature: Support pipe and poll interfaces.
支持pipe管道驱动,支持poll多文件描述符检测接口。

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: Ida1f29709affbc91a26b8518e4a77b8e5469be19
2022-01-18 16:47:35 +08:00
Lyb
eef7c80a72 fix: 队列相关的API实现中,参数的校验不完全,导致程序异常
Signed-off-by: Lyb <1576988680@qq.com>
2022-01-18 16:36:15 +08:00
openharmony_ci
2294ff93d8 !544 OsGetAllTskInfo调用和异常时无任务回调函数地址
Merge pull request !544 from wangchen/tskinfo
2022-01-18 08:33:43 +00:00
openharmony_ci
ca6801dce8 !546 L0 pthread_cond_timedwait接口存在计算溢出
Merge pull request !546 from wangchen/cond
2022-01-18 03:33:25 +00:00
houpengfei
566f46dee2 fix:backtrace严重BUG
Signed-off-by: houpengfei <houpengfei@talkweb.com.cn>
2022-01-17 20:35:04 +08:00
openharmony_ci
10fd031b09 !550 新增newlib的uio的接口支持
Merge pull request !550 from SimonLi/master
2022-01-17 12:14:26 +00:00
SimonLi
25a1eb522d feati(newlib): 新增newlib的uio的接口支持
Signed-off-by: SimonLi <likailong@huawei.com>
2022-01-17 19:16:59 +08:00
openharmony_ci
382872d998 !540 fix: 补充newlib对net的支持
Merge pull request !540 from Zhaotianyu/0113newlib_add
2022-01-17 09:02:37 +00:00
wangchen
2219c32784 fix: L0 pthread_cond_timedwait接口实现存在的几个问题
【背景】L0 pthread_cond_timedwait接口存在计算溢出

【修改方案】
1,新增abstick 相关修改,先判断再转成32位,避免截断
2,LOS_Event相关函数返回值的处理已存在,无需处理
【影响】
对现有的产品编译不会有影响。

re #I4N9P8
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-01-17 07:34:39 +00:00
arvinzzz
93f616b64e fix: 补充net相关头文件
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I32f713800b5451bfd5350c10273f1513366d473a
2022-01-17 11:57:29 +08:00
wangchen
1c605a338a fix: OsGetAllTskInfo调用和异常时无任务回调函数地址
【背景】OsGetAllTskInfo调用和异常时无任务回调函数地址

【修改方案】
1,新增tskinfo内容

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

re #I4MG2T
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-01-15 08:14:53 +00:00
openharmony_ci
570f2785bd !537 补充完善原子接口测试用例及部分原子接口修复
Merge pull request !537 from ouyk/master
2022-01-13 10:44:04 +00:00
ou-yangkan
3900785b8f 补充完善原子接口测试用例及部分原子接口修复
Signed-off-by: ou-yangkan <519689417@qq.com>
2022-01-13 15:22:14 +08:00
openharmony_ci
d50c106304 !536 xtensa架构增加alloc异常入口
Merge pull request !536 from ouyk/master
2022-01-13 03:06:19 +00:00
ou-yangkan
697a0cbdeb xtensa架构增加alloc异常入口
Signed-off-by: ou-yangkan <519689417@qq.com>
2022-01-12 16:12:48 +08:00
openharmony_ci
b9c9936270 !509 libatomic底层实现补充
Merge pull request !509 from wangchen/atomic
2022-01-12 03:00:44 +00:00
openharmony_ci
852114d9d2 !532 kernel测试套适配xtensa及csky架构
Merge pull request !532 from gsshch/master
2022-01-12 01:35:56 +00:00
openharmony_ci
68cd62733f !535 feat: newlib支持pthread_equal
Merge pull request !535 from zhushengle/equal
2022-01-12 01:33:08 +00:00
zhushengle
ce5357eee1 feat: newlib支持pthread_equal
Close #I4QERS
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ife2c6afdd47b4bc0407e07f6f629716d4d0f2d1e
2022-01-11 21:27:57 +08:00
LiteOS2021
dcda9dcfa3 kernel测试套适配xtensa及csky架构
Signed-off-by: gsshch <17326005269@163.com>
2022-01-11 19:58:39 +08:00
openharmony_ci
4a9d1f0c51 !531 fix: 修复liteos-m在iar环境下的编译问题
Merge pull request !531 from zhushengle/iar
2022-01-11 10:46:48 +00:00
zhushengle
4c4784e33d fix: 修复liteos-m在iar环境下的编译问题
1.数据类型转换
2.使用未初始化数据
3.无用的标签
4.pthread 线程退出后name指向野指针

Close #I4Q5Q5
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ib89390d8f61a355788da77651bf9aeee816561bb
2022-01-11 18:01:01 +08:00
openharmony_ci
47c6ef37d7 !527 支持IAR C++ thread_local特性
Merge pull request !527 from JerryH/iar_thread_local
2022-01-10 13:09:23 +00:00
JerryH
b98aa4eacd feature: 支持IAR C++ thread_local特性
在需要IAR的thread_local特性时,在targets_config.h中包含los_iar_tls.h,覆盖los_config.h的默认定义,使能该特性。

close #I4PTVZ

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I92d3f960555f95cb3618dd5e3915824105eb13a4
2022-01-10 20:10:35 +08:00
openharmony_ci
4a120d7533 !528 修复内核gn模板编译依赖的问题
Merge pull request !528 from SimonLi/master
2022-01-08 07:53:08 +00:00
SimonLi
11215e111a build: 修复内核gn编译依赖的问题
背景:
1. //kernel/liteos_m/BUILD.gn通过excutable生成config.gni文件到
out目录下
2. //kernel/liteos_m/liteos.gni定义内核模板,依赖out目录下的config.gni
意味着使用内核模板的模块(例如device/board、device/soc)需要依赖
kernel/liteos_m/BUILD.gn先加载,有这个顺序依赖约束。

解决方案:
将生成config.gni部分移到liteos.gni模块定义处,解决这个约束。

Signed-off-by: SimonLi <likailong@huawei.com>
2022-01-08 14:58:38 +08:00
openharmony_ci
9d5668e52c !497 Clang triple renaming
Merge pull request !497 from maweiye/master
2022-01-07 03:19:29 +00:00
openharmony_ci
9fe091bd42 !525 fix: 修正liteos-m内核README不准确信息
Merge pull request !525 from zhushengle/readme
2022-01-07 02:03:02 +00:00
openharmony_ci
ba1d7e7b90 !517 feat:added assembly atomic interface
Merge pull request !517 from 王树林/master
2022-01-06 13:29:56 +00:00
openharmony_ci
b89759c678 !517 feat:added assembly atomic interface
Merge pull request !517 from 王树林/master
2022-01-06 13:29:56 +00:00
zhushengle
0e067b2393 fix: 修正liteos-m内核README不准确信息
1.修正README不准确信息
2.新增内核编码规范指导

Close #I4PLWP

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Iac96fb0a2e2bc80f82338921287c8ca987e89652
2022-01-06 17:21:10 +08:00
ou-yangkan
1513f50a47 feat: added assembly atomic interface
added 32-bit assembly atomic interface:

BREAKING CHANGE:
Assembly implementation:
    ArchAtomicRead
    ArchAtomicSet
    ArchAtomicAdd
    ArchAtomicSub
    ArchAtomicInc
    ArchAtomicIncRet
    ArchAtomicDec
    ArchAtomicDecRet

https://gitee.com/openharmony/kernel_liteos_m/issues/I4O1UC
Signed-off-by: wang-shulin93 <15173259956@163.com>
2022-01-06 10:37:54 +08:00
openharmony_ci
f3fbeb87db !523 fix: tick timer时钟频率赋值修改为运行时赋值
Merge pull request !523 from zhushengle/tick_timer
2022-01-05 09:06:07 +00:00
zhushengle
ae02afc850 fix: tick timer时钟频率赋值修改为运行时赋值
OS_SYS_CLOCK 宏由产品定义,该宏可能为函数,在编译时赋值无法覆盖该场景

Close #I4PGUR
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I60e3f4fcd8f94b26c23cc88e0622408a24fbebe2
2022-01-05 15:51:11 +08:00
openharmony_ci
3c19b017fc !522 fix: 修复pthread_create相关问题
Merge pull request !522 from zhushengle/pthread
2022-01-04 11:16:07 +00:00
zhushengle
cd949ddae0 fix: 修复pthread_create相关问题
1. 系统调度未起时,调用pthread_create失败
  系统调度未起时,系统无运行任务,获取当前线程失败
2. 先创建任务再给任务赋值name,且未加锁保护,和shell存在静态

Close #I4P78J

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I2570dcf90953ced06400a0a22193cc81719fb546
2022-01-04 15:06:13 +08:00
openharmony_ci
67f8149640 !480 feat: 内核提供tick timer框架,支持多架构多平台通用化
Merge pull request !480 from zhushengle/timer
2022-01-04 01:12:29 +00:00
openharmony_ci
9ebad7d291 !521 fix: 修复newlib缺省PTHREAD_KEYS_MAX 问题
Merge pull request !521 from zhushengle/key
2021-12-31 08:51:16 +00:00
zhushengle
65f04bf093 fix: 修复newlib缺省PTHREAD_KEYS_MAX 问题
Close #I4OX47
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I4c6b07a77dca5eb5b24f462e639ff173f06d5da0
2021-12-31 15:38:18 +08:00
openharmony_ci
1af387098f !520 pm codex告警清零
Merge pull request !520 from zhushengle/codex
2021-12-31 07:22:52 +00:00
zhushengle
96663805ec fix: pm codex告警清零
Close #I4OWPE
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I07f6db919062090b917ce991198f769032365472
2021-12-31 14:55:20 +08:00
zhushengle
f635450d7c feat: 内核提供tick timer框架,支持多架构多平台通用化
背景:
      当前Arch下tick timer的实现依赖于弱函数机制,三方适配时出错及限制较大,且tick
  timer作为内核必须模块,未模块化,当前散落在tick和调度等模块中,且当前存在arch依赖
  内核,内核也依赖arch的情况,为了解决上述问题,将tick timer模块化,通过提供tick
  timer框架实现内核依赖Arch而Arch不依赖内核,并且可以减少对外暴漏的接口,使得三方
  适配时更加明确需要实现的接口。

方案描述:
1.tick timer结构
  在kernel_liteos_m/arch/include/los_timer.h,中定义结构:

  typedef struct {
    UINT32        freq;
    INT32         irqNum;
    UINT32        (*init)(HWI_PROC_FUNC tickHandler);
    UINT64        (*getCycle)(UINT32 *period);
    VOID          (*reload)(UINT64 time);
    VOID          (*lock)(VOID);
    VOID          (*unlock)(VOID);
    HWI_PROC_FUNC tickHandler;
  } ArchTickTimer;
  并声明对外获取tick timer的接口:

  ArchTickTimer *ArchSysTickTimerGet(VOID)
  define LOS_SysTickTimerGet ArchSysTickTimerGet
2.在每个架构下提供默认的tick timer操作:

  STATIC ArchTickTimer g_archTickTimer = {
    .freq = xxx, 必填
    .irqNum = xxx, 必填
    .init = xxx, 必填
    .getCycle = xxx, 必填
    .reload = xxx, 必填
    .lock = xxx, 必填
    .unlock = xxx, 必填
    .tickHandler = NULL, 可选
  }
  并实现:ArchTickTimer *ArchSysTickTimerGet(VOID) 接口
3.内核los_tick.c中提供对外(其它模块)和公共的tick timer初始化操作函数,
  如果用户不想启用系统默认的tick timer,则需要在 "内核初始化之前" 调用接口:
  LOS_TickTimerRegister(const ArchTickTimer *timer, const HWI_PROC_FUNC tickHandler)
  将用户自己的tick timer或中断处理函数 注册进去。
  用户也可以注册自己的中断处理函数(用户不提供,默认使用系统提供的)。

BREAKING CHANGE:
  原来版本中每个架构下提供的tick timer相关操作函数为弱函数:
    WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler);
    WEAK VOID HalSysTickReload(UINT64 nextResponseTime);
    WEAK UINT64 HalGetTickCycle(UINT32 *period);
    WEAK VOID HalTickLock(VOID);
    WEAK VOID HalTickUnlock(VOID);
  用户如果需要启用自己的tick timer需要自己实现相关接口(强属性),在 "内核初始化之前" 通过调用:
  LOS_TickTimerRegister 接口替换系统默认提供的tick timer相关接口。
  无论用户提供的tick timer 还是系统默认提供的,均在内核初始化时启动。

Close #I4N7XV:arch 重构

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I83ad0bdf303904f0e73f808b57b60183619fddcd
2021-12-31 10:50:33 +08:00
openharmony_ci
909a18ec8f !510 feat: 支持posix线程私有数据能力
Merge pull request !510 from zhushengle/pthread_key
2021-12-30 06:34:28 +00:00
openharmony_ci
bd0ae07bcf !511 fix: 公版gcc编译内核,调用calloc崩溃
Merge pull request !511 from Zhaotianyu/1228newlib_calloc
2021-12-30 01:12:29 +00:00
openharmony_ci
ad6bdba415 !460 fix: 中断向量表对齐大小支持可配置
Merge pull request !460 from kenneth/align
2021-12-29 00:55:39 +00:00
zhushengle
a856303b9c feat: 支持posix线程私有数据能力
BREAKING CHANGE:
  int pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
  int pthread_key_delete(pthread_key_t k)
  int pthread_setspecific(pthread_key_t k, const void *x)
  void *pthread_getspecific(pthread_key_t k)

Close #I4ODEB
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I60ce26c20d1e2033922d2d1b01d73fc8938c8019
2021-12-28 19:55:10 +08:00
arvinzzz
8d0ced2069 fix: 修复公版gcc编译内核,调用calloc崩溃
使用内核提供的calloc接口替换工具链的实现

close: #I4OFG6

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ia979f2b613c8bab89b5df3aa4bd340f6cc6fabd7
2021-12-28 16:12:26 +08:00
kenneth
cf9c8387e3 fix: 中断向量表对齐大小支持可配置
根据板端实际设置中断向量表对齐大小,支持可配置。

fix #I4M20E

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-28 09:52:13 +08:00
openharmony_ci
5a7fabe4f8 !498 fix: liteos_kernel_only=true编译内核报错
Merge pull request !498 from kenneth/mk
2021-12-28 00:59:20 +00:00
openharmony_ci
d7fd58b986 !496 fix the compile warning
Merge pull request !496 from laojr1/master
2021-12-28 00:58:24 +00:00
wangchen
2f7f6f0cbb 【背景】使用公版gcc编译m核时,会缺少部分底层函数
【修改方案】
1,补充这部分接口

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

re #I4OAY9
Signed-off-by: wangchen <253227059@qq.com>
2021-12-27 12:55:53 +00:00
openharmony_ci
28d0761b85 !505 解决m核开启ipv6功能的编译的问题
Merge pull request !505 from xieshen9527/master
2021-12-27 06:23:03 +00:00
zhangyang
c7843926b8 refactor: 解决m核开启ipv6功能的编译
close #I4NOIP

Signed-off-by: zhangyang <zhangyang349@huawei.com>
2021-12-27 12:00:30 +08:00
openharmony_ci
900f183260 !504 在arch\csky\v2\gcc\los_exc.S中添加IrqEntry函数实现
Merge pull request !504 from ouyk/master
2021-12-27 03:38:51 +00:00
wcc0
79d42b7976 在arch\csky\v2\gcc\los_exc.S中添加IrqEntry函数实现
Signed-off-by: wcc0 <917033401@qq.com>
2021-12-27 11:10:45 +08:00
openharmony_ci
85a1ce43c6 !493 feat:Synchronizing arch api
Merge pull request !493 from LiteOS/master
2021-12-25 10:42:15 +00:00
LiteOS2021
04bf3a682f feat: synchronizing arch api
命名规范:修改少量Arch接口,命名规范化调整:
1.修改arch/include下接口声明,所有arch对外提供调用函数均以ArchXX命名
2.提取多个架构均有实现的公共函数声明至arch/include对应头文件中以供外部调用,并修改命名格式为ArchXX
3.修改OS_HWI_WITH_ARG为LOSCFG_PLATFORM_HWI_WITH_ARG并移至los_config.h中
4.typedef VOID (*OS_TICK_HANDLER)(VOID);暂时移至arch/include/los_timer.h中
5.实现atomic原子操作相关接口,位于arch/include/los_atomic.h,arm架构部分与汇编指令相关原子操作接口使用ARCH_ARM宏进行控制是否编译

BREAKING CHANGE: 1.修改arch/include下接口,以ArchXX命名函数
2.提取公共函数声明:ArchAtomicXchg32bits、ArchAtomicDecRet、ArchAtomicCmpXchg32bits
3.新增部分原子操作c内联实现

Close #I4N7XV

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2021-12-25 18:36:09 +08:00
kenneth
adc21052b2 fix: liteos_kernel_only=true编译内核报错
修复单独编译内核报错的问题

close #I4O204

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-25 14:10:01 +08:00
maweiye
5a185df69d clang triple renaming
Signed-off-by: maweiye <maweiye@huawei.com>
2021-12-24 16:46:46 +08:00
老家荣
cbcd297a3a chore: 解决 cmsis_liteos2.c:115:23: warning 编译告警
Signed-off-by: laojr1 <laojr1@midea.com>
2021-12-23 17:55:11 +08:00
openharmony_ci
4334b3e18b !473 fix:修复拼写错误
Merge pull request !473 from ouyk/master
2021-12-22 02:46:46 +00:00
openharmony_ci
b998978561 !474 fix: 修复L0_Emulator 门禁高概率失败的问题
Merge pull request !474 from zhushengle/Emulator
2021-12-20 08:18:56 +00:00
zhushengle
7ad2f62a03 fix: 修复L0_Emulator 门禁高概率失败的问题
内存测试用例002中对全局的内存池进行了重复申请释放操作,
释放之后全局的测试内存池为无效的野指针,而该内存已被网络
分配并使用,从而导致出现踩内存的现象。

Close #I4NB0N

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Iffd631fcdaa020afefd108c189850ef3e75d1e4b
2021-12-20 15:34:08 +08:00
ou-yangkan
c082d77f55 fix:Fix spelling errors
Signed-off-by: ou-yangkan <519689417@qq.com>
2021-12-20 09:35:58 +08:00
openharmony_ci
7e9d84362f !442 M核posix接口fs模块用例完善
Merge pull request !442 from wangchen/posix_test
2021-12-19 08:12:27 +00:00
openharmony_ci
b56c6e86d4 !470 fix: 补充newlib对ipv6的支持
Merge pull request !470 from Zhaotianyu/1218newlib_ipv6
2021-12-18 11:58:52 +00:00
arvinzzz
f7400fbcb2 fix: 添加newlib对ipv6的支持
补充业务中需要的ipv6相关宏定义

close: #I4M1DB

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I6835fb0673874ed8efff01c8e4f79c2d64ea0d46
2021-12-18 19:35:10 +08:00
openharmony_ci
e6dd09733d !469 修复posix的Kconfig
Merge pull request !469 from Zhaotianyu/1217Kconfig_fix
2021-12-17 04:05:20 +00:00
arvinzzz
bb04582910 fix: 修复Kconfig信息错误
close: #I4MZ1F

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I9216b28ab5b2a43d77512d529a6a6637998e19ea
2021-12-17 11:35:04 +08:00
openharmony_ci
41a3cb0233 !468 fix:修复异常处理入口条件判断范围错误的问题
Merge pull request !468 from 王树林/master
2021-12-17 03:20:15 +00:00
wcc0
d09d46ff75 fix:fix bug of exception
Signed-off-by: wcc0 <917033401@qq.com>
2021-12-17 09:37:03 +08:00
openharmony_ci
6f7ceb3e72 !464 转移csky架构中断入口由device到kernel中
Merge pull request !464 from ouyk/master
2021-12-16 12:03:15 +00:00
ou-yangkan
ee79364748 转移csky架构中断入口由device到kernel中
Signed-off-by: ou-yangkan <519689417@qq.com>
2021-12-16 19:43:47 +08:00
openharmony_ci
91e5b3054e !466 修改csky和xtensa架构的g_intCount变量使用
Merge pull request !466 from ouyk/modify_g_intCount
2021-12-16 08:01:06 +00:00
ou-yangkan
d6aa3bf44b 修改csky和xtensa架构的g_intCount变量使用
Signed-off-by: ou-yangkan <519689417@qq.com>
2021-12-16 13:50:48 +08:00
openharmony_ci
d03b490d3d !462 OsMuxInit函数中增加对owner成员的初始化
Merge pull request !462 from fangye945a/master
2021-12-15 02:34:24 +00:00
openharmony_ci
939414ea9a !456 fix: tick中断处理时,无挂起任务时应更新当前运行任务的时间片, 并触发一次调度
Merge pull request !456 from zhushengle/tick
2021-12-15 01:57:10 +00:00
fangye
d1f7b8e465 OsMuxInit函数中增加对owner成员的初始化
Signed-off-by: fangye <fangye@talkweb.com.cn>
2021-12-14 22:45:29 +08:00
openharmony_ci
12b66edbe3 !459 解决kernel目录下一些函数入参过剩导致编译错误的问题
Merge pull request !459 from 苏宗耀/master
2021-12-14 02:15:40 +00:00
suzongyao
eff6b5533c fix: 解决kernel目录下一些函数入参过剩导致编译错误的问题
Signed-off-by: suzongyao <suzongyao@talkweb.com.cn>
2021-12-13 17:15:26 -08:00
openharmony_ci
4b43e360a2 !458 解决_SEM_MAGIC宏定义数据类型错误导致的编译问题
Merge pull request !458 from 苏宗耀/master
2021-12-13 10:14:32 +00:00
szy
58ebbf0a71 fix: 解决宏定义_SEM_MAGIC数据类型错误导致的编译问题
Signed-off-by: suzongyao <suzongyao@talkweb.com.cn>
2021-12-13 01:52:13 -08:00
openharmony_ci
3aff6c572f !434 feat: 低内存资源回收low memory killer
Merge pull request !434 from kenneth/lmk1130
2021-12-13 08:56:26 +00:00
kenneth
ab886d848a feat: 低内存资源回收low memory killer
低内存资源回收特性,支持维护可杀低重要任务,当高内存任务申请不到足够内存时,临时释放低重要性的任务来释放内存来满足高内存任务正常运行;
当高内存任务退出运行时,自动恢复被杀的低重要性任务。设计文档归档位置 https://gitee.com/rtos_yuan/lmk/tree/design/

BREAKING CHANGE: 增加低内存资源回收注册相关接口LOS_LmkOpsNodeRegister、LOS_LmkOpsNodeUnregister和内存资源释放和任务恢复接口LOS_LmkTasksKill和LOS_LmkTasksRestore.

close #I4ID0M

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-13 12:07:33 +08:00
zhushengle
ea12d40caf fix: tick中断处理时,无挂起任务时应更新当前运行任务的时间片, 并触发一次调度
Close #I4LRZG

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I4472fb50c775b832688aa7a555498901a80e2999
2021-12-13 11:37:50 +08:00
openharmony_ci
16259a955e !455 清除因g_tm变量没有使用引入的编译告警
Merge pull request !455 from JerryH/warning
2021-12-11 03:18:19 +00:00
JerryH
9689522a8e fix: 清除因g_tm变量没有使用引入的编译告警
close #I4LW3H

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I8f1be047ce5af5e7d50822c22764f9b2f04167d9
2021-12-11 10:38:35 +08:00
openharmony_ci
ff11e86c42 !452 解除net对cmsis的依赖,net属于内核模块,不应该依赖内核对外接口
Merge pull request !452 from SimonLi/master
2021-12-10 06:46:40 +00:00
SimonLi
99826240d9 fix: 解除net对cmsis的依赖,net属于内核模块,不应该依赖内核对外接口
Signed-off-by: SimonLi <likailong@huawei.com>
2021-12-10 10:22:17 +08:00
openharmony_ci
a1b4ebd479 !454 解决gmtime和localtime接口由于g_tm全局变量导致的竞态问题
Merge pull request !454 from JerryH/time
2021-12-10 02:20:33 +00:00
JerryH
1454b76482 fix: 解决gmtime和localtime接口由于g_tm全局变量导致的竞态问题
删除全局变量,接口使用自己的内部静态变量,避免竞态

Close #I4LW3H

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I3c74b1897b3909df93d21b9d521af270cc6fc610
2021-12-10 09:24:30 +08:00
openharmony_ci
48fd327654 !453 fix: FD_SETSIZE compatible newlibc
Merge pull request !453 from besyangjian/master
2021-12-09 14:42:33 +00:00
openharmony_ci
2037e4de37 !451 fix: adapt net
Merge pull request !451 from besyangjian/master
2021-12-09 13:54:03 +00:00
yangjian
82c6d5f174 fix: FD_SETSIZE compatible newlibc
Signed-off-by: yangjian <jianyang@bestechnic.com>
Change-Id: I9d6b708772e63b2dc797d7305801be617fb32e75
2021-12-09 21:53:56 +08:00
yangjian
8594ee469a feat: adapt net
Signed-off-by: yangjian <jianyang@bestechnic.com>
Change-Id: I91d1ef2b5b77be7ec84af939db202a8b06a9b68f
2021-12-09 21:08:04 +08:00
openharmony_ci
4a95944fc5 !446 支持删除已经超时但还在队列中未执行的软件定时器
Merge pull request !446 from JerryH/swtmr
2021-12-09 03:10:36 +00:00
openharmony_ci
555b0a05b8 !444 fix: 调度中将pm相关的部分用LOSCFG_KERNEL_PM包含
Merge pull request !444 from zhushengle/pm
2021-12-09 03:04:30 +00:00
openharmony_ci
c0091d5fda !450 feature: newlib支持lwip
Merge pull request !450 from Zhaotianyu/1208newlib_lwip
2021-12-08 15:09:14 +00:00
arvinzzz
885027dc91 feature: newlib支持lwip
close: #I4LPB2

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I01fcc0ef35e69103562d4c59e52b335a5695dfc7
2021-12-08 22:06:12 +08:00
openharmony_ci
24f970ab34 !449 将内核静态库的complete_static_lib设置为fasle,解决链接灌段缺失问题
Merge pull request !449 from Caoruihong/complete_static_lib_false
2021-12-08 13:43:10 +00:00
Caoruihong
02e6a0a7ea chore(build): set complete_static_lib false for libkernel
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: Ia3da4f963f44babdc802c58c0afbb1adc1f16ee9
2021-12-08 17:53:53 +08:00
JerryH
ecce17ea48 fix: 解决定时器超时但还在队列中无法删除的问题
利用每次创建时,软件定时器timerId都是唯一的(0~0xffffffff循环),在超时写队列时,同时记录软件定时器id,删除的时候更新软件定时器id,那么在处理软件定时器前,
通过队列中记录的id获取软件定时器控制块,如果控制块的id不等于记录的id,那么说明该软件定时器被删除过,将不执行对应回调函数,表现为删除该定时器。

BREAKING CHANGE: SwtmrHandlerItem结构体新增swtmrID字段,用于标识超时队列中软件定时器id

Close #I4LFVD

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I716176f177c4bc07adb348936d5568fbadcbebe7
2021-12-08 15:27:49 +08:00
openharmony_ci
ee754f1f46 !440 优化构建脚本
Merge pull request !440 from Caoruihong/support_gcc
2021-12-08 07:20:43 +00:00
openharmony_ci
ffda523f2d !443 fix:Kconfig中打开littlefs默认关联打开LOSCFG_SUPPORT_LITTLEFS宏
Merge pull request !443 from Zhaotianyu/1206newlib_fix_Kconfig
2021-12-06 13:56:15 +00:00
zhushengle
d7c0059dc4 fix: 调度中将pm相关的部分用LOSCFG_KERNEL_PM包含
Close #I4L00F
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I0dbe0954dcb881c0079677c215aceb099d6d1b94
2021-12-06 19:12:55 +08:00
arvinzzz
b2bcab3a5b fix: Kconfig中打开littlefs选项默认关联打开LOSCFG_SUPPORT_LITTLEFS宏
close: #I4ENQ1

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ib86ba0e35860e225e57c8da9f481de55ba154a40
2021-12-06 18:14:56 +08:00
lnlan
ee380fb9be fix: M核posix接口fs模块用例完善
【背景】M核posix接口fs模块用例无平台进行验证,在qemu上运行时会有报错。

【修改方案】
1,对部分用例进行修改,增加对qeum的适配度

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

re #I4L7BF
Signed-off-by: wangchen <253227059@qq.com>
2021-12-06 09:31:15 +00:00
Caoruihong
84ea5528e2 chore(build): optimize build scripts
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: I672b7e6109563d457d493c08903bb5a1dff118ad
2021-12-05 02:29:49 +08:00
openharmony_ci
cd31fc9a8b !368 【feature】内核支持musl与newlib C库切换
Merge pull request !368 from Zhaotianyu/1020newlib
2021-12-04 14:19:55 +00:00
arvinzzz
753d86014b feature: 支持newlib与musl切换
系统支持newlib,并且可以与musl-C自由切换

1. 新增newlib支持,适配newlib的预留钩子,针对系统能力适配newlib头文件(补充宏定义,结构体定义,posix能力开关),
  采用标准C与自研posix接口声明与结构体定义混合作为C库
2. 梳理kal的依赖关系,kal作为内核对外提供的标准接口,下属包含cmsis、libc、posix。
  cmsis为内核对cmsis接口的支持,libc为内核对三方C库的适配及使用,posix为内核自研提供的posix标准接口。
  若采用musl-C,则kal中选取libc/musl,posix共同作为C库对外支持;
  若采用newlib-C,则kal中选取libc/newlib,部分posix共同作为C库对外支持。
3. fs整理,components/fs下提供基于posix标准的接口改为内部对外接口,供musl以及newlib切换 适配使用

close: #I4ENQ1

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I72eda5ac5499f72c67e800e22b0f39eb288f2b94
2021-12-04 21:43:55 +08:00
openharmony_ci
746acf55e4 !433 fix: 去掉编译选项-fno-short-enums
Merge pull request !433 from kenneth/short_enum
2021-12-03 07:02:45 +00:00
openharmony_ci
1c9703b049 !436 LOS_Panic接口中增加需要增加LOS_BackTrace(),方便定位主动异常位置
Merge pull request !436 from zhangfanfan2/master
2021-12-02 04:05:33 +00:00
openharmony_ci
d3bf180b7f !428 对arch.c文件里面的方法进行防空处理
Merge pull request !428 from xieshen9527/master
2021-12-02 02:19:31 +00:00
openharmony_ci
da135662f3 !437 test: 修正测试用例中固定的资源设定,修改为动态获取
Merge pull request !437 from zhushengle/test
2021-11-30 12:58:16 +00:00
zhushengle
143e8a7df6 test: 修正测试用例中固定的资源设定,修改为动态获取
Close #I4KH68

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I9d23f63cd751a804966a7c6366590897f3858b72
2021-11-30 19:04:12 +08:00
openharmony_ci
d0692abae9 !435 fix: 取消cpu进入低功耗前开中断操作,优化注册机制
Merge pull request !435 from zhushengle/pm
2021-11-30 09:51:35 +00:00
zhangfanfan2
f51d675fee fix: LOS_Panic接口中增加需要增加LOS_BackTrace(),方便定位主动异常位置
close: #I4IGGY

Signed-off-by: zff <zhangfanfan2@huawei.com>
2021-11-30 07:24:29 +00:00
zhushengle
bd39e9e6d6 fix: 取消cpu进入低功耗前开中断操作
开中断导致低功耗流程非原子,容易造成流程出错。
    提供低功耗默认处理函数,优化注册机制

Close #I4KDP8
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ied8bab691e7725e207b8b3cfb058f851eafe3052
2021-11-30 10:47:04 +08:00
openharmony_ci
d0d51b4a29 !393 feat: 支持Lms轻量级地址消毒
Merge pull request !393 from LiteOS/lms
2021-11-29 14:22:21 +00:00
kenneth
b542aab09d fix: 去掉编译选项-fno-short-enums
编译选项-fno-short-enums是liteos-m支持kconfig(https://gitee.com/openharmony/kernel_liteos_m/pulls/371)时从Liteos-a核引入的编译选项。添加该编译选项后会输出警告信息,
需要去掉该编译选项。

fix #I4JY32

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-11-29 19:07:10 +08:00
openharmony_ci
6a3f7d85f2 !432 fix: 修正部分编码风格问题
Merge pull request !432 from zhushengle/code
2021-11-29 06:52:07 +00:00
openharmony_ci
f460976604 !431 修改测试代码里的敏感词
Merge pull request !431 from LeonChan/master
2021-11-29 06:46:27 +00:00
zhushengle
91903a3716 fix: 修正部分编码风格问题
Close #I4K8M7

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: If34d5c632cbb06f639434d8c35fb226a0253f4a7
Signed-off-by: zhushengle <zhushengle@huawei.com>
2021-11-29 14:22:39 +08:00
Leon Chan
8e2248c062 fix: change the sensitive words
close: #I4K7LL

Signed-off-by: Leon Chan <chenwei26@huawei.com>
2021-11-29 11:45:13 +08:00
LiteOS2021
7b838e8a7b feat: 支持Lms
1.【需求描述】:
   支持内核态堆内存非法访问检测,包括:越界访问、double free、释放后使用;支持libc常用高频函数内存检测;支持安全函数内存检测;读写检测可配可裁剪。
2.【方案描述】:
   (1).影子内存映射与标记
   (2).编译器使能-fsanitize=kernel-address 自动插桩检测点
   (3).实时校验影子内存的合法性;
   (4).错误访问打印回溯栈

BREAKING CHANGE: 新增支持API:

LOS_LmsCheckPoolAdd使能检测指定内存池
LOS_LmsCheckPoolDel不检测指定内存池
LOS_LmsAddrProtect为指定内存段上锁,不允许访问
LOS_LmsAddrDisableProtect去能指定内存段的访问保护

Close #I4HYBG

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
Change-Id: Ia356a003088b9df37df667ea8ba91c80f5a41967
2021-11-27 11:31:12 +08:00
openharmony_ci
2ad9dc0eac !426 feat: 调度、任务及pm解耦
Merge pull request !426 from zhushengle/pm
2021-11-27 02:08:29 +00:00
openharmony_ci
9af519b3f0 !429 kernel/liteos_m/OAT.xml文件中路径错误
Merge pull request !429 from Hongjin Li/local_hongjin-li
2021-11-26 10:19:04 +00:00
Hongjin Li
4b4a1ad943 修复OAT.xml文件中路径错误。
Change-Id: I432c5241b67139a958874f6705173e4f6bce16de
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2021-11-26 17:37:55 +08:00
openharmony_ci
2cf3b19563 !427 refactor: 将安全函数库的编译由三方移至内核进行控制
Merge pull request !427 from Zhaotianyu/1125libsec
2021-11-26 06:46:01 +00:00
zhangyang
690b8f3627 refactor: 对arch.c文件中方法里面参数进行防空处理
close #I4JV90

Signed-off-by: zhangyang <zhangyang349@huawei.com>
2021-11-26 11:11:10 +08:00
arvinzzz
e45bcc9d4f refactor: 将安全函数库的编译行为由三方移至内核进行控制
close: #I4JUKM

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I201507aae937a01f49eafcf5909c07eae4a60123
2021-11-26 11:07:37 +08:00
zhushengle
cc8a794229 feat: 调度、任务及pm解耦
pm中冻结线程的操作,融合至OsSchedSuspend和OsSchedResume,
使得调度模块提供对应完整的方法给任务模块,做到之间的相互解耦,
方便其它调度算法的融入。

Close #I4JTN6
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ifde7077166a2fe67e7246fa68f777844640d67db
2021-11-25 16:54:02 +08:00
openharmony_ci
119e2d328a !392 补充内存释放函数。
Merge pull request !392 from pef/master
2021-11-25 08:32:36 +00:00
openharmony_ci
e47bbdaa1b !411 make //kernel/liteos_m:kernel avaliable to all targets
Merge pull request !411 from yaoxiaoyu_903c/master
2021-11-25 05:06:02 +00:00
openharmony_ci
d8e512cd7b !422 【轻量级 PR】:[fix] fix target build error
Merge pull request !422 from bh6bao/N/A
2021-11-25 02:45:17 +00:00
openharmony_ci
b3ae1a9002 !423 fix: 修复arch目录调整影响到的target目录下的文件
Merge pull request !423 from kenneth/rename_arch_dir
2021-11-25 02:44:48 +00:00
yaoxiaoyu
9b4386380c make //kernel/lite_m:kernel available for all targets
Signed-off-by: yaoxiaoyu <yaoxiaoyu1@huawei.com>
Change-Id: Ibec8b49c6ece051301fd4d298c7a3b9b20d53409
2021-11-24 15:30:08 +08:00
kenneth
d5725b2264 fix: 修复arch目录调整影响到的target目录下的文件
将arch目录从kernel中移到根目录下 影响target目录下面的readme、makefile文件。

close #I4JM7Z

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-11-24 15:10:22 +08:00
bh6bao
7920eb38fc [fix] fix target build error
Signed-off-by: bh6bao <904710733@qq.com>

Fix compile error caused by arch directory change
2021-11-24 06:13:44 +00:00
openharmony_ci
25d1d68db5 !401 fix: ReadMe中无对动态加载模块待加载的共享库的限制说明。
Merge pull request !401 from Harylee/readme
2021-11-24 05:57:05 +00:00
openharmony_ci
57a8e03e89 !407 fix issues I4J4TK cat can not work well on big file
Merge pull request !407 from 冷钦街/cat_big2
2021-11-24 05:56:08 +00:00
openharmony_ci
a1e97964c6 !415 fix(shell):cp命令执行时 通配出多个源文件时错误提示不正确
Merge pull request !415 from 冷钦街/cp_hit
2021-11-24 05:55:43 +00:00
openharmony_ci
431fcd2443 !412 fix: 在头文件中补充LOSCFG_MEM_FREE_BY_TASKID函数的声明
Merge pull request !412 from kenneth/freeTask
2021-11-24 05:55:13 +00:00
openharmony_ci
36712dcbb6 !421 修改lwip_porting.gni路径为全量路径,方便产品适配
Merge pull request !421 from 刘建东/master
2021-11-24 05:54:18 +00:00
openharmony_ci
ed02106eef !416 【轻量级 PR】:修复一处资源泄漏
Merge pull request !416 from Caoruihong/N/A
2021-11-24 05:53:25 +00:00
YOUR_NAME
321cb9d193 refactor: use all path of lwip_porting.gni for other product
use all path of lwip_porting.gni for other product

close: #I4JKX9

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-11-24 11:53:41 +08:00
openharmony_ci
8310aba4ea !410 宏_BSD_SOURCE放在头文件中定义,其他模块使用lwip头文件时,可不用单独再定义
Merge pull request !410 from 刘建东/master
2021-11-24 01:41:39 +00:00
openharmony_ci
ed64fb1b2f !409 littlefs新增FileOps->Fstat接口
Merge pull request !409 from Hongjin Li/liteos_m_add_fstats_to_littlefs
2021-11-24 01:38:39 +00:00
Caoruihong
b73898a022 修复一处资源泄漏
Signed-off-by: Caoruihong <crh.cao@huawei.com>
2021-11-23 07:15:06 +00:00
lengqinjie
8675abcec9 fix(shell):cp命令执行时 通配出多个源文件时错误提示不正确
close #I4JETR
Signed-off-by: lengqinjie <15390014138@163.com>
2021-11-23 14:09:12 +08:00
openharmony_ci
05a487dcf6 !408 refactor(shell):减少命令行参数的解析次数到1次(原来为2次)
Merge pull request !408 from 冷钦街/reduce
2021-11-22 21:10:48 +00:00
kenneth
ad18026a59 fix: 在头文件中补充LOSCFG_MEM_FREE_BY_TASKID函数的声明
LOSCFG_MEM_FREE_BY_TASKID函数在头文件kernel\include\los_memory.h中没有声明,使用会有警告,补充声明该函数。

close #I4JBOV

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-11-22 20:40:32 +08:00
YOUR_NAME
57208d6e14 refactor: define _BSD_SOURCE in cc.h instead of gn file
define _BSD_SOURCE in cc.h instead of gn file

close: #I4J8OT

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-11-22 15:27:00 +08:00
Hongjin Li
36b7577c5e liteos_m文件系统中,components/fs/littlefs/lfs_api.c中新增注册.Fstat = LfsFstat接口。
Change-Id: Ic56364d1df71b369abfa5be617fc63b77a65b27b
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2021-11-22 11:45:52 +08:00
lengqinjie
078bd0c4b1 refactor(shell):减少命令行参数的解析次数到1次(原来为2次)
通过调整获取命令类型的代码位置,达到减少解析次数的目的
经过分析,本修订无明确的副作用。

Signed-off-by: lengqinjie <15390014138@163.com>
2021-11-22 09:32:17 +08:00
lengqinjie
d518bad0dc fix(shell): cat针对大文件无法工作
close #I4J4TK

Signed-off-by: lengqinjie <15390014138@163.com>
2021-11-22 09:07:58 +08:00
openharmony_ci
4e0bf74f4a !403 Board 和 SoC分离,编译适配
Merge pull request !403 from SimonLi/master
2021-11-21 02:17:37 +00:00
SimonLi
3f1c04dd57 feat: Board 和 SoC分离,编译适配
1. BUILD.gn 根据device_path中是否包含board,来判别 SoC 和 Board 分离特性是否打开,
根据特性开关兼容以前老的Build.gn编译方式

2. Makefile 中新增BOARD_COMPANY环境变量传给Kconfig,确定选择哪一个 Board

3. Kconfig 兼容老的形式,新增 device 路径下 Kconfig.liteos_m.xxxx 表示为 liteos_m
适配 Kconfig 功能,不会影响其他内核适配。主要是同个device 路径下,会有多个不同的
内核进行适配Kconfig。

Signed-off-by: SimonLi <likailong@huawei.com>
Change-Id: Iaa2ffc6e56ab9127bb13dbbb934414f63dfbcdc2
2021-11-20 08:17:52 +08:00
openharmony_ci
b7de7f6085 !398 清理YES/NO宏
Merge pull request !398 from Caoruihong/remove_yesno
2021-11-18 09:32:42 +00:00
openharmony_ci
dd90483e39 !394 m核ioctl增加选项支持
Merge pull request !394 from 刘建东/master
2021-11-18 06:28:09 +00:00
openharmony_ci
b537f8733d !397 将arch目录从kernel中移到根目录下
Merge pull request !397 from Caoruihong/move_arch
2021-11-18 03:38:10 +00:00
Haryslee
f86b97180f fix: ReadMe中无对动态加载模块待加载的共享库的限制说明。
背景:动态加载模块需要确保待加载共享库的安全性,由用户保证。

close #I4ICK8

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: I6390ab3059ce6d134669c62a14f913e5b09b291d
2021-11-17 10:22:23 +08:00
Caoruihong
5196818d47 chore: replace YES/NO macros to 1/0
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: I80f8b23cac10bc714dea921ed1fd43b687ce3748
2021-11-16 01:21:00 +08:00
Caoruihong
201da62e1f chore: move kernel/arch to arch
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: I0f0b6f5cff967c47acf58be133a12a0fd98f4643
2021-11-16 00:45:24 +08:00
openharmony_ci
c9f2c110c6 !396 fix:在非静态初始化条件下pthread_mutex_lock,没有经过init初始化就可以对已销毁的锁进行加锁
Merge pull request !396 from x_xiny/master
2021-11-15 11:10:09 +00:00
openharmony_ci
afc362db23 !390 清理"bits/xxx.h"类头文件包含
Merge pull request !390 from Caoruihong/clean_bits
2021-11-15 09:35:10 +00:00
x-xiny
9c8377fcc6 fix:在非静态初始化条件下pthread_mutex_lock,没有经过init初始化就可以对已销毁的锁进行加锁
【背景】
 在非静态初始化条件下pthread_mutex_lock,没有经过init初始化就可以对已销毁的锁进行加锁

【修改方案】
 在pthread_mutex_destroy中将mutex的magic标记字段清除

 re #I4I7OA

 Signed-off-by: x-xiny <1301913191@qq.com>

Change-Id: I5d4cceff852e20e659a7cd06acf27cc6f381962c
2021-11-15 06:47:03 +00:00
YOUR_NAME
5e8ac4b888 feat: add option for ioctl
add option for ioctl

close: #I4I3W5

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-11-15 14:34:58 +08:00
openharmony_ci
09d972c9af !395 增加module_group模板,先注释掉arch_config
Merge pull request !395 from Caoruihong/build
2021-11-13 12:46:06 +00:00
Caoruihong
e5636f7aca feat(build): add module_group and comment out arch_cflags
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: I83a248d313ec64a5bca6eb860fb84385aac446a0
2021-11-13 19:59:04 +08:00
openharmony_ci
f12e710c3c !381 #I4FDAU已完成翻译,请验收
Merge pull request !381 from Annie_wang/master
2021-11-12 01:00:29 +00:00
pef
0ceb7426c8 补充内存释放函数。
【背景】
有手动申请内存在return前未释放。

【修改方案】
1. 添加free(fullpath),释放内存。

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

Change-Id: I9168bd78e9137fc764292a5faa6bc7e732f82e66
Signed-off-by: pef <cyd1997@126.com>
2021-11-11 09:58:47 +00:00
openharmony_ci
942c614995 !371 支持Kconfig配置
Merge pull request !371 from Caoruihong/kconfig
2021-11-11 06:04:28 +00:00
Caoruihong
931df01e2e chore: clean "bits/xx.h" includes
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: Ia4db457ec704121aa5f0daac17ecee6da8395d63
2021-11-11 11:57:07 +08:00
openharmony_ci
1553e3ed88 !386 chore: shell体验优化
Merge pull request !386 from huangshan/chore
2021-11-10 08:49:51 +00:00
openharmony_ci
3e507d8cec !387 清理kernel/arch/arm/cortex-m33/gcc下无用的代码
Merge pull request !387 from Caoruihong/clean_unused
2021-11-10 02:07:59 +00:00
Caoruihong
4546ff92f7 chore: clean unused files
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: I1ebc5d066a854f502c9f5e31b7acab8d8cdb69b1
2021-11-09 22:06:44 +08:00
huangshan
57cff794ae chore: shell完善帮助信息,特殊处理不可见字符
Signed-off-by: huangshan <huangshan9@huawei.com>
Change-Id: I3cbc559c388b5d5a524783c1f55c1e569a44465c
2021-11-09 20:42:18 +08:00
openharmony_ci
72928ca12e !385 fix: 修复cortex-m系列系统提供的timer在低频下时间不准的问题
Merge pull request !385 from zhushengle/timer
2021-11-09 08:57:07 +00:00
openharmony_ci
4422285b24 !383 lwip可通过宏单独提供read,write等接口操作socket,可以不依赖文件系统
Merge pull request !383 from 刘建东/master
2021-11-08 08:08:11 +00:00
zhushengle
3e569bac58 fix: 修复cortex-m系列系统提供的timer在低频下时间不准的问题
触发场景:
    cpu主频比较高,timer频率较低时,当SysTick->VAL == 0时,
触发tick中断,在中断中系统将当前周期累加到基准时间里,在中
断结束更新tick响应时间时,会更新系统基准时间(为了让时间更
加准确)此时由于SysTick->VAL任然等于0,接口HalGetTickCycle
返回的仍然是当前周期,导致该周期被累加了两次。

解决方案:
    接口HalGetTickCycle在SysTick->VAL == 0时返回0.
因为SysTick->VAL == 0时,必然会触发tick中断,周期
的累加是由中断处理的,此时只需要返回0即可。

Close #I4HBGR
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Iba6e8799b0ae851fc94aa23867b2360a4245994d
2021-11-08 14:49:52 +08:00
YOUR_NAME
d044eda3c3 feat: provide read write for socket by #define
provide read write for socket by #define

close: #I4H8TL

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-11-08 11:20:01 +08:00
openharmony_ci
c488edd707 !370 修正编译告警称解引用void指针
Merge pull request !370 from Caoruihong/void_ptr
2021-11-05 13:45:54 +00:00
Caoruihong
7e673430dc feat(build): support Kconfig
Kconfig usages are the same with liteos_a

Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: I9aacbb69da88d5427cced89d1a49cb1041afa998
2021-11-05 12:18:04 +08:00
Annie_wang
9f2765cfa8 update README.md.
Signed-off-by: Annie_wang <annie.wangli@huawei.com>
2021-11-05 03:43:45 +00:00
Annie_wang
cfc5a0a1ba update README.md.
Signed-off-by: Annie_wang <annie.wangli@huawei.com>
2021-11-04 07:34:32 +00:00
Annie_wang
03941ee363 update README.md.
Signed-off-by: Annie_wang <annie.wangli@huawei.com>
2021-11-04 07:31:35 +00:00
Annie_wang
14fe10a3ff update README.md.
Signed-off-by: Annie_wang <annie.wangli@huawei.com>
2021-11-04 07:28:05 +00:00
Annie_wang
55a68dcd2d update README.md.
Signed-off-by: Annie_wang <annie.wangli@huawei.com>
2021-11-04 07:21:18 +00:00
annie_wangli
2b5f52236a update docs
Signed-off-by: annie_wangli <annie.wangli@huawei.com>
2021-11-04 15:09:56 +08:00
openharmony_ci
f3631fa266 !357 修复 shell 模块存在大量的编译告警及 codeCheck
Merge pull request !357 from pef/codecheck-1018
2021-11-02 13:30:50 +00:00
openharmony_ci
5568d3ac89 !359 fix:修复shcmd.h需要用宏包起来的问题
Merge pull request !359 from yinjiaming/2021-10-18
2021-11-02 02:34:35 +00:00
openharmony_ci
c5b7a7315b !378 feat: 支持pthread_mutex属性相关接口
Merge pull request !378 from zhushengle/mutex
2021-11-01 02:20:25 +00:00
zhushengle
d2be4d7a46 feat: 支持pthread_mutex属性相关接口
接口列表:
pthread_mutexattr_init
pthread_mutexattr_settype
pthread_mutexattr_destroy

Close #I4G4RQ

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I7aea47e375ffe961a3dcbf39da6b84561e3d0a8f
2021-10-30 15:25:56 +08:00
openharmony_ci
f8cad5301b !377 修改inet_addr等宏为函数,外层调用可不包含lwip头文件
Merge pull request !377 from 刘建东/master
2021-10-30 07:25:42 +00:00
YOUR_NAME
b30e9139d5 fix: switch inet_addr to a function
switch inet_addr to a function

close: #I4G4I4

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-10-30 14:46:29 +08:00
openharmony_ci
3bd6076697 !375 优化lwip默认配置
Merge pull request !375 from 刘建东/master
2021-10-29 02:18:35 +00:00
YOUR_NAME
b2e3849bfb fix: optimize default configuration
optimize default configuration

close: #I4FSC9

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-10-28 17:40:59 +08:00
openharmony_ci
454c234512 !354 m4核在任务中异常时backtrace使用的是MSP所在的栈,而不是PSP所在的栈
Merge pull request !354 from zhangfanfan2/exc
2021-10-27 13:51:47 +00:00
zff
3e8aea224e fix: m4核在任务中异常时backtrace使用的是MSP所在的栈,而不是PSP所在的栈
m4核开启浮点运算时,异常处理流程未将浮点压栈,导致异常上下文信息错位,
进而导致backtrace时使用的SP值错误,从而出现backtrace时使用的栈信息不对。

close: #I4D7GE

Signed-off-by: zff <zhangfanfan2@huawei.com>
Change-Id: If7d5198d1f808de4f1cd9c2bc5c6f68185a4ffac
2021-10-27 11:18:57 +08:00
openharmony_ci
844c5952ed !356 系统pend类接口未对软件定时器任务进行限制,容易引发软件定时器任务非正常挂起,出现响应不及时的问题。
Merge pull request !356 from zhangfanfan2/swtmr
2021-10-26 11:19:31 +00:00
openharmony_ci
3fefeba1f0 !362 fix: 修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题
Merge pull request !362 from kenneth/unaligned
2021-10-26 06:11:22 +00:00
openharmony_ci
28bf057ded !367 fix:修复Fault异常模块中FPU宏等问题
Merge pull request !367 from kenneth/fpu_simple
2021-10-26 06:10:25 +00:00
openharmony_ci
d4c0390218 !372 fix: 修复readme中文档链接错误
Merge pull request !372 from kenneth/docs
2021-10-26 06:09:47 +00:00
kenneth
8ee70a0f8f fix: 修复readme中文档链接错误
gitee docs文档链接更新同步修改

close #I4FD5G

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-26 10:11:15 +08:00
Caoruihong
29126a98fe fix: fix compile warning saying dereference void * pointer
Signed-off-by: Caoruihong <crh.cao@huawei.com>
2021-10-22 22:39:36 +08:00
openharmony_ci
1d5c6ee961 !369 修正testsuits目录拼写错误
Merge pull request !369 from Caoruihong/testsuites
2021-10-22 07:36:07 +00:00
Caoruihong
9c69e6039e chore: fix typo: testsuits --> testsuites
keep testsuites the same directory name as in liteos_a

Signed-off-by: Caoruihong <crh.cao@huawei.com>
2021-10-21 21:39:32 +08:00
openharmony_ci
93c1eb54a0 !366 feat: 支持pthread_condattr_setclock
Merge pull request !366 from zhushengle/cond
2021-10-21 09:52:58 +00:00
zhushengle
68dad2ccc9 feat: 支持pthread_condattr_setclock
Close #I4ETLN
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I0b3ddbb0d99000c67f9b41944ab0ab4878094a8b
2021-10-21 11:42:23 +08:00
openharmony_ci
aed479813d !360 m核ioctl支持SIOCGIFBRDADDR选项
Merge pull request !360 from 刘建东/master
2021-10-21 01:51:11 +00:00
kenneth
2da043ce16 fix:修复Fault异常模块中FPU宏等问题
去掉不必要的宏判断__FPU_PRESENT;参数变量名称 uwPid改为pid,和函数HalExcHandleEntry的参数保持一致

close #I4D575

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-20 16:49:43 +08:00
openharmony_ci
fe68a93ded !355 修复qemu和csky编译使用问题
Merge pull request !355 from LiteOS/master
2021-10-20 08:13:47 +00:00
pef
e0d8b5328f fix: 修复shell 模块存在大量的编译告警及codeCheck。
【背景】
代码中存在规范问题和编译告警。
如:error: unused variable 'taskID2' [-Werror=unused-variable]
应该去掉不用的变量。

【修改方案】
1. 修改变量类型宏的使用。
2. 根据告警信息修复问题代码。

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

re #I48V2J

Change-Id: I7f364fcf974d2a439639f35ba428e04f7de7338a
Signed-off-by: pef <cyd1997@126.com>
2021-10-20 07:50:23 +00:00
openharmony_ci
f886283b3b !364 fix:修复文件系统vfs层未正确判空g_fs的问题
Merge pull request !364 from Far/master
2021-10-20 03:41:43 +00:00
Far
269b330989 fix:修复文件系统vfs层未正确判空g_fs的问题
Close #I4ELJN

Signed-off-by: Far <yesiyuan2@huawei.com>
2021-10-20 11:14:51 +08:00
openharmony_ci
f11095cf28 !363 fix: los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误
Merge pull request !363 from kenneth/_ExcInMsp
2021-10-20 01:10:48 +00:00
kenneth
c51df7a94c fix: los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误
修复los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误

close #I4EJI4

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-19 20:01:50 +08:00
kenneth
d32e25f3ae fix: 修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题
修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题

close #I4EJGR

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-19 19:45:24 +08:00
YOUR_NAME
33ee492953 feat: add option SIOCGIFBRDADDR for ioctl
add option SIOCGIFBRDADDR for ioctl

close: #I4EGNG

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-10-19 17:10:09 +08:00
openharmony_ci
d8a6a4bdb9 !347 去掉没有使用的入参consoleid。
Merge pull request !347 from pef/tocommit2
2021-10-19 01:53:57 +00:00
openharmony_ci
4bc6a14914 !346 【fix】api_shell.c 宏修改
Merge pull request !346 from pef/tocommit
2021-10-19 01:52:10 +00:00
yinjiaming
a7a8a62bcb fix: 修复shcmd.h需要用宏包起来的问题
【背景】
api_shell.c中使用了头文件shcmd.h,没有用宏包起来
[ERR] :#include<shcmd.h>:45

【修改方案】
删去包含的头文件shcmd.h,代码中没有用到该头文件中的内容
为能够顺利编译过,添加了头文件<sys/time.h>

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

re #I45FU2

Change-Id: I1727515883adcca1e9aaa25fc46ef1fee11fa1a9
Signed-off-by: yinjiaming <yinjiaming@huawei.com>
2021-10-18 09:23:23 +00:00
zff
c886629e27 fix:系统pend类接口未对软件定时器任务进行限制,容易引发软件定时器任务非正常挂起,
出现响应不及时的问题

close: #I44CI9

Signed-off-by: zff <zhangfanfan2@huawei.com>
Change-Id: I6aa612f3c34eef274eaa0c98efed0a3c4736de6e
2021-10-18 16:35:51 +08:00
LiteOS2021
f2f8a865f0 修复qemu和csky编译使用问题
Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2021-10-18 13:34:48 +08:00
openharmony_ci
28bdb690ba !344 内核ERR打印,无进程和线程信息,不方便问题定位
Merge pull request !344 from zhangfanfan2/master
2021-10-18 03:03:30 +00:00
openharmony_ci
80263488e9 !345 【fix】los_trace.h注释修正
Merge pull request !345 from Zhaotianyu/1012trace_fix
2021-10-15 07:42:20 +00:00
openharmony_ci
c68b67a4e3 !351 fix: 调用LOS_TaskDetach操作已退出的joinable的任务时,未正确回收该任务
Merge pull request !351 from zhushengle/detach
2021-10-15 07:40:54 +00:00
zhushengle
49c93b37c5 fix: 调用LOS_TaskDetach操作已退出的joinable的任务时,未正确回收该任务
Close #I4DZL7
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Iac88818317c07807d0636712025f2c75b3b1f766
2021-10-15 10:56:02 +08:00
openharmony_ci
c313c189b5 !348 fix: 删除LOS_TRACE 记录SWTMR_START中的无效字段
Merge pull request !348 from LiteOS/trace
2021-10-14 09:06:25 +00:00
LiteOS2021
afbc9a593b fix: 优化trace buffer初始化,删除swtmr 桩中的无效参数
close #I4DPR7

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2021-10-14 09:48:49 +08:00
pef
a62795304d fix: 去掉没有使用的入参consoleid。
【背景】
https://gitee.com/openharmony/kernel_liteos_m/blob/master/components/shell/src/base/show.c
L49 consoleid 函数中没有使用,应该改为VOID。

【修改方案】
1. 将consoleid改为VOID。

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

re #I43CVE

Change-Id: Ieac29d16ec06c4fa45652c7106b63f6dd8397ebf
Signed-off-by: pef <cyd1997@126.com>
2021-10-13 08:09:17 +00:00
pef
9819eb5676 fix: 将未定义小写"true","false"改为"TRUE","FALSE"。
【背景】
    api_shell.c文件使用小写的true和false 却没有定义
    [OHOS ERROR] ../../../kernel/liteos_m/components/net/lwip-2.1/porting/src/api_shell.c:342:25: error: 'false' undeclared (first use in this function)
    [OHOS ERROR]      BOOL timeout_flag = false;
    编译报错。
    【修改方案】
    1. 将未定义的 true,false改为已定义的宏TRUE,FALSE。

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

    re #I43D20

Change-Id: If66adab35f2315d0caca2a487960be887567126b
Signed-off-by: pef <cyd1997@126.com>
2021-10-12 10:59:18 +00:00
arvinzzz
693468e527 fix: los_trace.h接口注释错误修正
1. LOS_TraceStop接口的功能描述应该是stop

close: #I4CYPZ

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I09da24e9a57abde288ccd3f558ba9e65ca1092e3
2021-10-12 10:35:14 +08:00
zff
232fec27ac fix: 内核ERR打印,线程信息,不方便问题定位。
close: #I4DAKM

Signed-off-by: zff <zhangfanfan2@huawei.com>
Change-Id: I10a61d87fa516dcccd5ce0ebca18680a20e2f452
2021-10-11 17:27:13 +08:00
openharmony_ci
badf1e9557 !341 fix: csky等新增模块的HalTickStart函数定义和实现不一致
Merge pull request !341 from kenneth/HalTickStart
2021-10-11 09:19:08 +00:00
openharmony_ci
68a3f9e6dd !342 fix: 移除los_arch_interrupt.h文件中冗余声明的函数VOID OsExcInit(VOID)
Merge pull request !342 from kenneth/OsExcInit
2021-10-11 09:18:26 +00:00
openharmony_ci
6c1587bf03 !343 fix: gcc编译testsuite编译问题修复
Merge pull request !343 from kenneth/testsuite
2021-10-11 09:17:47 +00:00
kenneth
f7d26b8e12 fix: gcc编译testsuite编译问题修复
修复It_los_mem.h中没有定义LOS_DLNK_NODE_HEAD_SIZE、MIN_DLNK_POOL_SIZE,编译告警等问题。

close #I4DAOU

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-11 14:30:51 +08:00
kenneth
136952f193 fix: 移除los_arch_interrupt.h文件中冗余声明的函数VOID OsExcInit(VOID)
VOID OsExcInit(VOID)函数的注释中参数描述错误,并且该函数并没有在C源文件中使用到,需要删除。

close #I4D9OO

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-11 10:36:26 +08:00
openharmony_ci
fe06d0cbb9 !335 适配xtensa和csky qemu版本
Merge pull request !335 from LiteOS/master
2021-10-11 02:01:24 +00:00
kenneth
07ab6a5b77 fix: csky等新增模块的HalTickStart函数定义和实现不一致
修复HalTickStart函数定义和实现中的参数类型保持一致

close #I4D1HY

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-09 17:37:08 +08:00
openharmony_ci
adaefc6133 !337 fix: 删除C文件中无用的__cplusplus
Merge pull request !337 from kenneth/cplusplus
2021-10-09 09:06:00 +00:00
openharmony_ci
9dbcb43b51 !338 fix: c-sky等芯片架构的BUILD.gn优化
Merge pull request !338 from kenneth/BUILD.gn
2021-10-09 09:05:04 +00:00
openharmony_ci
9bcc9f5706 !340 fix: 解决los_pm.c:743:19: warning 编译告警
Merge pull request !340 from kenneth/pm
2021-10-09 09:04:36 +00:00
kenneth
0c72c8bf94 fix: 解决los_pm.c:743:19: warning 编译告警
修复PRINT_ERR函数格式化参数数目不一致。

close #I4D4L8

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-09 15:56:27 +08:00
kenneth
7fe3aaddf5 fix: 删除C文件中无用的__cplusplus
新增的c-sky等模块一些c文件中的依旧保留了无用的__cplusplus需要删除;修复注释中的部分不规范内容修改,缩进,空行,错别字等。

close #I4D0YK

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-09 09:21:45 +08:00
kenneth
3311d73406 fix: c-sky等芯片架构的BUILD.gn优化
新增加的c-sky等模块的BUILD.gn实现和其他芯片架构不一致,已优化为一致

close #I4D129

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-10-09 09:07:40 +08:00
LiteOS2021
a7765e2a83 适配xtensa和csky qemu版本,并修复一些已知问题
Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2021-10-09 08:58:13 +08:00
openharmony_ci
892d6981e7 !336 fix: 删除OsMemboxExcInfoGetSub内存调测方法中多余的赋值语句
Merge pull request !336 from kenneth/membox
2021-10-08 02:39:05 +00:00
openharmony_ci
3eb4679f13 !324 【fix】hook层LOS_HOOK_TYPE_SEM_PEND的runningTask入参可能为空
Merge pull request !324 from Zhaotianyu/0926hook_fix
2021-10-08 01:06:22 +00:00
kenneth
94db0fe7a3 fix: 删除OsMemboxExcInfoGetSub内存调测方法中多余的赋值语句。
OsMemboxExcInfoGetSub内存调测方法中存在对memExcInfo->size多次赋值,size含义不清晰,删除多余的赋值语句。

close #I4CFNX

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-09-29 14:51:14 +08:00
openharmony_ci
6134dcd428 !332 fix: LOS_QueueInfoGet函数统计等待读写任务有误
Merge pull request !332 from kenneth/queue
2021-09-29 02:51:19 +00:00
openharmony_ci
91bd0c2e2b !331 fix: OS_TASK_STACK_PROTECT_SIZE undeclared error
Merge pull request !331 from kenneth/mpu
2021-09-29 02:50:25 +00:00
openharmony_ci
3b20e902c4 !323 fix: 修复risc-v异常时,异常信息混乱且backtrace无法输出的问题
Merge pull request !323 from zhushengle/backtrace
2021-09-29 00:15:31 +00:00
zhushengle
0fb49d4422 fix: 修复risc-v异常时,异常信息混乱且backtrace无法输出的问题
1.修复risc-v backtrace无法输出的问题
异常时未将fp传入,且backtrace校验不足,容易导致再次异常
2.优化task 输出信息格式
3.shell中task命令代码重复
4.OSBackTraceInit 拼写有误

Close #I4BPHX:riscv32_virt 异常时无法输出backtrace信息

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I141d5e7808fc967d846f425422f5dcf2ac01d1d1
2021-09-28 11:39:42 +08:00
kenneth
56e234b300 fix: fix OS_TASK_STACK_PROTECT_SIZE undeclared error
当开启LOSCFG_EXC_HARDWARE_STACK_PROTECTION宏时,增加定义OS_TASK_STACK_PROTECT_SIZE宏

close #I4C5RW

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-09-28 10:27:52 +08:00
openharmony_ci
8dfcf71288 !330 feat: 添加L0测试门禁
Merge pull request !330 from zhushengle/test
2021-09-28 02:18:08 +00:00
kenneth
a0b6f98e20 fix: LOS_QueueInfoGet函数统计等待读写任务有误
LOS_QueueInfoGet使用32位无符号数组来记录阻塞队列的任务,每个数组元素的每个bit位对应一个任务编号。
比如第一个数组元素的32个bit位对应任务编号0-31,第二个数组元素的32个bit位对应任务编号32-63....计算任务对应的数组的bit位数时使用
掩码OS_WAIT_TASK_ARRAY_ELEMENT_MASK的值应该为31,不应该依赖任务最大数目。

close #I4C6P2

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-09-28 09:40:23 +08:00
zhushengle
5c168fc3e0 fix: 添加L0 测试门禁
Close #I4C5R4
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I2900175e2507027d61e8fb47277a940250bea8b5
2021-09-27 20:09:36 +08:00
arvinzzz
3fd22ac2b0 fix: 修复hook层LOS_HOOK_TYPE_SEM_PEND的runningTask入参可能为空
在校验完semPend之后,就获取好runningTask并且与semPend关联

close: #I4BU4P
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ib56a1a1db8e4471d9e2adb0b7c3d8b17b1f87b8d
2021-09-27 09:48:02 +08:00
openharmony_ci
3c6f422162 !318 去除backtrace冗余代码
Merge pull request !318 from LiteOS/master
2021-09-26 12:03:00 +00:00
openharmony_ci
1d414d18eb !325 fix: 添加文件版权头等信息
Merge pull request !325 from Harylee/shm
2021-09-26 09:34:20 +00:00
openharmony_ci
56fa29a319 !327 解决dailycheck告警
Merge pull request !327 from Caoruihong/update_url
2021-09-26 09:30:52 +00:00
Caoruihong
4aba2c06b5 chore: fix dailycheck issues
master --> HEAD
remove useless @since

Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: Id3452cccdcc823c374f873cf4905015351580d15
2021-09-26 17:13:13 +08:00
Haryslee
cf4e017970 fix: 添加文件版权头等信息
close #I4BXBH

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: Id798eec0473a9b8e18b1c8be31f3dd6babb879b0
2021-09-26 16:30:17 +08:00
LiteOS2021
db1f9c797c 去除backtrace冗余代码
Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2021-09-26 15:41:26 +08:00
openharmony_ci
87ecfac438 !321 feat: backtrace for arm9
Merge pull request !321 from Harylee/shm
2021-09-24 09:11:12 +00:00
Haryslee
03de7f3745 feat: backtrace for arm9
arm9架构支持栈回溯功能

close #I4BMLG

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: Iba30a6853391c4cad3ed59ddfc05ef2530a4de89
2021-09-24 16:56:58 +08:00
openharmony_ci
af8a6d5047 !259 完善CMSIS-RTOS V2部分接口(osSemaphoreNew,osThreadJoin)
Merge pull request !259 from Caoruihong/cmsis
2021-09-24 02:24:11 +00:00
openharmony_ci
8be34cb78e !293 三方库FatFs升级至r0.14a版本
Merge pull request !293 from Far/fatfs_update
2021-09-24 00:53:41 +00:00
openharmony_ci
4061deaae8 !311 feat: 支持posix 和 cmsis join能力
Merge pull request !311 from zhushengle/join
2021-09-24 00:30:44 +00:00
zhushengle
ecfdf7ff9b feat: 支持posix 和 cmsis join能力
支持API:
  LOS_TaskJoin
  LOS_TaskDeatch
  pthread_join
  pthread_deatch
  osThreadJoin
  osThreadDetach
Close #I44V26

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ib61e69c280eef2e4b3b79d9bba7bbd5a300c7fe4
2021-09-23 18:54:14 +08:00
Caoruihong
d478152762 feat(cmsis): support max_count for osSemaphoreNew
Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: Iacb6cb7771ae32ea1ca645c72fda241e8e85d422
2021-09-23 16:32:21 +08:00
openharmony_ci
565649c1c1 !316 fix: 测试用例任务栈的宏定义重复定义,导致在osTest.h中修改不生效
Merge pull request !316 from zhushengle/test
2021-09-23 01:30:55 +00:00
Far
92ea355756 feat: 适配三方库FatFs升级至r0.14a版本
适配了f_mkfs接口的修改

Signed-off-by: Far <yesiyuan2@huawei.com>
2021-09-22 15:02:40 +08:00
zhushengle
ce6cf6879f fix: 测试用例任务栈的宏定义重复定义,导致在osTest.h中修改不生效
Close #I4BA5F

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I0960eb70664bf188b9f8b2a76689a85c3c2dd4ce
2021-09-22 11:40:43 +08:00
openharmony_ci
25441ec1b5 !314 fix: risc-v 低功耗下存在功能问题
Merge pull request !314 from zhushengle/list
2021-09-18 06:14:40 +00:00
zhushengle
9f185b5b52 fix: pm模块解冻线程时存在删除空链表且时间片频繁唤醒系统
1.如果冻结线程状态为delay,则此时pendlist为NULL,解冻时不需要delete
2.低功耗时关闭时间片,减少时间片频繁唤醒系统
3.risc-v 中64位相加存在溢出
Close #I4AKUS

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Icb9e8f7df8488635f9660d3932b06fa6f57e6133
2021-09-18 11:42:08 +08:00
openharmony_ci
03bbc750ce !305 fix: 修复OsQueueMailFree提早释放内存的问题
Merge pull request !305 from hpline/master
2021-09-17 09:33:45 +00:00
openharmony_ci
89fea841c0 !310 shell模块task命令踩内存问题修改
Merge pull request !310 from wangchen/m_task
2021-09-17 03:55:35 +00:00
openharmony_ci
f1ac6bf160 !312 fix:修复测试用例导致系统异常及中断用例失败问题
Merge pull request !312 from zhushengle/test
2021-09-17 00:58:44 +00:00
zhushengle
9ca65adf32 fix:修复测试用例导致系统异常及中断用例失败问题
1.系统异常
  任务栈过小,导致踩内存
2.中断测试用例失败
  shell占用了测试用例的中断号,导致创建中断失败
Close #I4AENS

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I35512a5634aed328561c760ba6fcce4ec944aa2e
2021-09-16 20:53:33 +08:00
wangchen
6ffd55dcd0 fix: shell模块task命令踩内存问题修改
【背景】task命令获取内存时传入的参数过大,可能引起踩内存问题。

【修改方案】
1,对task命令中获取内存信息时的入参进行调整,避免引起内存问题

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

re #I4A70V
Signed-off-by: wangchen <253227059@qq.com>
2021-09-16 15:56:38 +08:00
lurix
902efbcea9 chore: update the comment.
Signed-off-by: lurix <lurix@foxmail.com>
2021-09-15 12:57:40 +00:00
openharmony_ci
4700ba6973 !308 fix: 修复pthread_create行为与posix不一致问题
Merge pull request !308 from zhushengle/pthread
2021-09-15 08:07:55 +00:00
zhushengle
2b1e5a7a13 fix: 修复pthread_create行为与posix不一致问题
1.提升posix接口和LOS接口的兼容性
2.支持优先级继承属性

Close #I49W9F
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I4d9df778a559f094dd3062e5e7030e3a03c884ec
2021-09-15 14:21:01 +08:00
openharmony_ci
2c525c0fd9 !298 feat: 低功耗支持冻结线程等需求
Merge pull request !298 from zhushengle/suspend
2021-09-14 12:29:10 +00:00
zhushengle
9b5739ab11 feat: 低功耗支持冻结线程等需求
1.支持低功耗时冻结线程
2.支持延时锁
3.低功耗与idle分离
4.支持对接电源管组件的低功耗接口
LOS_PmReadLock --- 常阻塞,低功耗线程阻塞于该接口,当系统无任何模块持锁时会唤醒低功耗线程, 触发低功耗流程
LOS_PmSuspend --- 进入低功耗流程
Close #I49FJF

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I009255cfa1852b109dd8bfaf9c779e976660d621
2021-09-14 19:55:26 +08:00
lurix
9c3a6901f1 chore: 解决代码风格导致的编译报错
Signed-off-by: lurix <lurix@foxmail.com>
2021-09-14 02:04:02 +00:00
lurix
ec88d16289 fix: 修复OsQueueMailFree提早释放内存的问题
Signed-off-by: lurix <lurix@foxmail.com>
2021-09-13 10:04:25 +00:00
openharmony_ci
c77c178ec1 !301 fix: 修复pm编译告警导致内核编译失败
Merge pull request !301 from zhushengle/error
2021-09-11 07:51:37 +00:00
zhushengle
18b052458e fix: 修复pm编译告警导致内核编译失败
Close #I49MIN
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I6b448790b170bf5980d16698ecfff27bda6c3600
2021-09-11 15:27:21 +08:00
openharmony_ci
eebd5f16d3 !300 修复不能开启硬浮点选项的问题
Merge pull request !300 from Zhaotianyu/0910fix_fpu_hard
2021-09-10 23:07:44 +00:00
arvinzzz
988fd85fae fix: 支持硬浮点编译
1. 通过本工程的gn编译时,需要在device目录下,单板的关于内核的config.gn中指定-mfloat-abi的等级,并在单板相关代码的编译选项中保持-mfloat-abi一致
2. 通过本工程的Makefile编译时,需要在kernel/liteos_m/targets/下添加单板相关的代码配置,在Makefile中设置-mfloat-abi即可
3. 通过IDE编译本工程时,需要在IDE的汇编文件相关编译选项中加入 -imacros $(LITEOSTOPDIR)/kernel/include/los_config.h,保证浮点等级在汇编文件中生效

close: #I48KJP
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ibf9b750b922be2530de349981d55e40b5919933f
2021-09-10 17:30:46 +08:00
openharmony_ci
3c0d17fc63 !281 fix: 优化低功耗流程
Merge pull request !281 from zhushengle/pm_optimize
2021-09-09 06:55:55 +00:00
zhushengle
c6600d9ddd fix: 优化低功耗流程
1.normal和其它模式分离,流程分层化,使得结构较为清晰
2.tick timer处理实现优化为注册对应机制则默认支持,不注册则不执行,简化使用逻辑
3.添加 pm测试用例
Close #I46VXK

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I7810ce0ca12dce96972399adf88e8319bb487905
2021-09-09 11:46:23 +08:00
openharmony_ci
0715126021 !289 add xtensa and csky arch support
Merge pull request !289 from LiteOS/master
2021-09-08 06:55:10 +00:00
openharmony_ci
fd8ca3f5dc !289 add xtensa and csky arch support
Merge pull request !289 from LiteOS/master
2021-09-08 06:55:10 +00:00
lanche1024
8bcab9ab7a add csky arch support
Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2021-09-07 17:11:10 +08:00
1246 changed files with 40296 additions and 10218 deletions

View File

@@ -1,6 +1,6 @@
### 相关的Issue
### 原因(目的、解决的问题等)
@@ -8,5 +8,14 @@
### 测试用例(新增、改动、可能影响的功能)
### 是否需要同步至release3.0LTS ... )分支?
必须选择一项在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
- [ ] 是,需要同步的分支:
- [ ]
理由:

5
.gitignore vendored
View File

@@ -14,3 +14,8 @@ targets/cortex-m7_nucleo_f767zi_gcc/build
*.o
*.d
*.su
# Menuconfig temp files
/config.h
/.config
/.config.old

316
BUILD.gn
View File

@@ -27,59 +27,283 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("config.gni")
import("//build/lite/config/component/lite_component.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
declare_args() {
liteos_name = "OHOS_Image"
liteos_kernel_only = false
}
import("liteos.gni")
liteos_arch_cflags = []
if (defined(LOSCFG_ARCH_ARM)) {
mcpu = LOSCFG_ARCH_CPU
if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) {
mcpu += "+nofp"
}
liteos_arch_cflags += [ "-mcpu=$mcpu" ]
if (defined(LOSCFG_ARCH_ARM_AARCH32) && defined(LOSCFG_ARCH_FPU)) {
liteos_arch_cflags += [ "-mfpu=$LOSCFG_ARCH_FPU" ]
}
}
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
if (ohos_build_compiler == "clang") {
cc += " --target=$target_triple"
}
config("arch_config") {
cflags = liteos_arch_cflags
asmflags = cflags
ldflags = cflags
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-mthumb-interwork" ]
}
}
if (defined(LOSCFG_THUMB)) {
cflags += [ "-mthumb" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-mimplicit-it=thumb" ]
} else {
cflags += [ "-Wa,-mimplicit-it=thumb" ]
}
}
}
config("stdinc_config") {
std_include = exec_script("//build/lite/run_shell_cmd.py",
[ "$cc -print-file-name=include" ],
"trim string")
cflags = [
"-isystem",
std_include,
]
cflags += [ "-nostdinc" ]
asmflags = cflags
if (defined(LOSCFG_LIBC_NEWLIB)) {
cflags -= [ "-nostdinc" ]
}
}
config("ssp_config") {
cflags = []
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
cflags += [ "-fstack-protector-all" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
cflags += [ "-fstack-protector-strong" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
cflags += [
"-fstack-protector",
"--param",
"ssp-buffer-size=4",
]
} else {
cflags += [ "-fno-stack-protector" ]
}
asmflags = cflags
}
config("optimize_config") {
cflags = []
if (defined(LOSCFG_COMPILE_DEBUG)) {
cflags += [
"-g",
"-gdwarf-2",
]
optimization_cflag = "-O0"
}
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
optimization_cflag = "-O2"
}
if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
optimization_cflag = "-Oz"
} else {
optimization_cflag = "-Os"
}
}
if (defined(LOSCFG_COMPILE_LTO)) {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-flto=thin" ]
} else {
#cflags += [ "-flto" ]
}
}
cflags += [ optimization_cflag ]
asmflags = cflags
}
config("kconfig_config") {
cflags = [
"-imacros",
"$LITEOS_MENUCONFIG_H",
]
asmflags = cflags
cflags_cc = cflags
}
config("warn_config") {
cflags = [
"-Wall",
"-Werror",
"-Wpointer-arith",
"-Wstrict-prototypes",
"-Winvalid-pch",
"-Wno-address-of-packed-member",
]
asmflags = cflags
}
config("dialect_config") {
cflags_c = [ "-std=c99" ]
cflags_cc = [ "-std=c++11" ]
}
config("misc_config") {
defines = [ "__LITEOS__" ]
defines += [ "__LITEOS_M__" ]
if (!defined(LOSCFG_DEBUG_VERSION)) {
defines += [ "NDEBUG" ]
}
cflags = [
"-fno-pic",
"-fno-builtin",
"-fms-extensions",
"-fno-strict-aliasing",
"-fno-common",
"-fsigned-char",
"-ffunction-sections",
"-fdata-sections",
"-fno-exceptions",
"-fno-omit-frame-pointer",
]
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-fno-aggressive-loop-optimizations" ]
}
asmflags = cflags
asmflags += [ "-DCLZ=CLZ" ]
}
config("los_config") {
cflags = [ "-Werror" ]
configs = [
#":arch_config",
":kconfig_config",
include_dirs = [
"//kernel/liteos_m/kernel/include",
"//kernel/liteos_m/kernel/arch/include",
"//kernel/liteos_m/utils",
"//third_party/bounds_checking_function/include",
":stdinc_config",
":dialect_config",
":optimize_config",
":ssp_config",
#":warn_config",
":misc_config",
]
}
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
# board and soc decoupling feature, device_path should contains board
BOARD_SOC_FEATURE = device_path != string_replace(device_path, "/board/", "")
config("public") {
configs = [
"arch:public",
"kernel:public",
"kal:public",
"components:public",
"utils:public",
]
if (BOARD_SOC_FEATURE) {
configs += [ "//device/board/$device_company:public" ]
configs += [ "//device/soc/$LOSCFG_SOC_COMPANY:public" ]
} else {
if (HAVE_DEVICE_SDK) {
configs += [ "$device_path:public" ]
}
}
}
group("modules") {
deps = [
"arch",
"components",
"kal",
"kernel",
"testsuites",
"utils",
HDFTOPDIR,
]
if (BOARD_SOC_FEATURE) {
deps += [ "//device/board/$device_company" ]
deps += [ "//device/soc/$LOSCFG_SOC_COMPANY" ]
} else {
if (HAVE_DEVICE_SDK) {
deps += [ device_path ]
}
}
}
# when HAVE_DEVICE_SDK is not reached, gn raises an error. so we just use it as
# not needed
not_needed([ "HAVE_DEVICE_SDK" ])
static_library("libkernel") {
deps = [ ":modules" ]
complete_static_lib = false
}
group("kernel") {
deps = [
"kernel:kernel",
"utils:utils",
"//third_party/bounds_checking_function:libsec_static",
deps = [ ":libkernel" ]
}
group("liteos_m") {
}
executable("liteos") {
configs += [
":public",
":los_config",
]
if (enable_ohos_kernel_liteos_m_cppsupport) {
deps += [ "components/cppsupport:cppsupport" ]
}
if (enable_ohos_kernel_liteos_m_cpup) {
deps += [ "components/cpup:cpup" ]
}
if (enable_ohos_kernel_liteos_m_exchook) {
deps += [ "components/exchook:exchook" ]
}
if (enable_ohos_kernel_liteos_m_backtrace) {
deps += [ "components/backtrace:backtrace" ]
}
if (enable_ohos_kernel_liteos_m_fs) {
deps += [ "components/fs:fs" ]
}
if (enable_ohos_kernel_liteos_m_pm) {
deps += [ "components/power:pm" ]
}
if (enable_ohos_kernel_liteos_m_trace) {
deps += [ "components/trace:trace" ]
}
if (enable_ohos_kernel_liteos_m_kal) {
deps += [ "kal:kal" ]
}
if (enable_ohos_kernel_liteos_m_shell) {
deps += [ "components/shell:shell" ]
}
if (enable_ohos_kernel_liteos_m_test) {
deps += [ "testsuits:test" ]
}
if (enable_ohos_kernel_liteos_m_lwip) {
deps += [ ohos_kernel_liteos_m_lwip_path ]
}
if (enable_ohos_kernel_liteos_m_dynlink) {
deps += [ "components/dynlink:dynlink" ]
ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
]
output_dir = target_out_dir
if (liteos_kernel_only) {
deps = [ ":kernel" ]
} else {
deps = [ "//build/lite:ohos" ]
}
}
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'"
}

667
Kconfig Normal file
View File

@@ -0,0 +1,667 @@
# 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.
mainmenu "Huawei LiteOS Configuration"
menu "Compiler"
choice
prompt "Compiler type"
default COMPILER_GCC
help
Choose compiler type.
config COMPILER_GCC
bool "GCC"
config CROSS_COMPILE
string "GCC cross-compile toolchain prefix"
depends on COMPILER_GCC
default "arm-none-eabi-" if ARCH_ARM_AARCH32
config COMPILER_CLANG_LLVM
bool "Clang"
config LLVM_TARGET
string "Clang LLVM target"
depends on COMPILER_CLANG_LLVM
default "arm-liteos-ohos" if ARCH_ARM_AARCH32
endchoice
config COMPILE_DEBUG
bool "Enable debug options"
default n
help
Answer Y to add -g option in compile command.
config COMPILE_OPTIMIZE
bool "Enable code optimization options"
default y
help
Answer Y to add optimization options for efficient code.
The final binary size will be smaller and execute faster.
But the debugging experience may be worst somehow.
config COMPILE_OPTIMIZE_SIZE
bool "Enable code size optimization options" if COMPILE_OPTIMIZE
default y
help
Answer Y to add optimization options for small code size.
The final binary size will be smaller.
But the compile time may be a bit longer.
config COMPILE_LTO
bool "Enable link time optimization (LTO)" if COMPILE_OPTIMIZE_SIZE
default y
help
Answer Y to add lto options for more smaller code size.
The final binary size will be smaller.
But the compile time may be much longer.
endmenu
menu "Platform"
######################### config options of bsp #####################
config PLATFORM
string
default "virt" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
config PRODUCT_NAME
string
default "arm_virt" if PRODUCT_QEMU_ARM
default "arm_mps2_an386" if PRODUCT_QEMU_ARM_MPS2_AN386
default "arm_mps3_an547" if PRODUCT_QEMU_ARM_MPS3_AN547
default "riscv32_virt" if PRODUCT_QEMU_RISCV32_VIRT
default "csky_smartl_e802" if PRODUCT_QEMU_CSKY_SMARTL_E802
default "xtensa_esp32" if PRODUCT_QEMU_XTENSA_ESP32
config DEVICE_COMPANY
string
default "qemu" if PLATFORM_QEMU_ARM_VIRT_CM7 || PLATFORM_QEMU_ARM_VIRT_CM4 || PLATFORM_QEMU_ARM_VIRT_CM55 || PRODUCT_QEMU_RISCV32_VIRT || PLATFORM_QEMU_CSKY_SMARTL || PLATFORM_QEMU_XTENSA_ESP32
choice
prompt "Chip"
default PLATFORM_QEMU_ARM_VIRT_CM7
help
Qemu ARM Virt variants (based on different CPU types):
- qemu_arm_virt_cm7
- qemu_arm_virt_cm4
- qemu_riscv32_virt
- qemu_csky_smartl
- qemu_xtensa_esp32
config PLATFORM_QEMU_ARM_VIRT_CM7
bool "qemu_arm_virt_cm7"
select ARCH_CORTEX_M7
help
QEMU ARM Virtual Platform using Cortex-M7 CPU.
config PLATFORM_QEMU_ARM_VIRT_CM4
bool "qemu_arm_virt_cm4"
select ARCH_CORTEX_M4
help
QEMU ARM Virtual Platform using Cortex-M4 CPU.
config PLATFORM_QEMU_ARM_VIRT_CM55
bool "qemu_arm_virt_cm55"
select ARCH_CORTEX_M55
help
QEMU ARM Virtual Platform using Cortex-M55 CPU.
config PLATFORM_QEMU_RISCV32_VIRT
bool "qemu_riscv32_virt"
select ARCH_RISCV32
help
QEMU RISCV Virtual Platform using riscv32 CPU.
config PLATFORM_QEMU_CSKY_SMARTL
bool "qemu_csky_smartl"
select ARCH_CSKY
help
QEMU SmartL Virtual Platform using csky CPU.
config PLATFORM_QEMU_XTENSA_ESP32
bool "qemu_xtensa_esp32"
select ARCH_XTENSA
help
QEMU ESP32 Virtual Platform using xtensa CPU.
endchoice
choice
prompt "Product"
help
Select your target board.
config PRODUCT_QEMU_ARM
bool "arm_virt" if PLATFORM_QEMU_ARM_VIRT_CM7
config PRODUCT_QEMU_ARM_MPS2_AN386
bool "arm_mps2_an386" if PLATFORM_QEMU_ARM_VIRT_CM4
config PRODUCT_QEMU_ARM_MPS3_AN547
bool "arm_mps3_an547" if PLATFORM_QEMU_ARM_VIRT_CM55
config PRODUCT_QEMU_RISCV32_VIRT
bool "riscv32_virt" if PLATFORM_QEMU_RISCV32_VIRT
config PRODUCT_QEMU_CSKY_SMARTL_E802
bool "csky_smartl_e802" if PLATFORM_QEMU_CSKY_SMARTL
config PRODUCT_QEMU_XTENSA_ESP32
bool "xtensa_esp32" if PLATFORM_QEMU_XTENSA_ESP32
endchoice
######################### config options of cpu arch ################
source "arch/Kconfig"
# Device Kconfig import
osource "$(DEVICE_PATH)/Kconfig"
config SOC_COMPANY
string "SoC company name to locate soc build path"
help
This option specifies the SoC company name, used to locate the build path for soc. This option is set by the
SoC's Kconfig file, and should be exactly the same with SoC company path, and the user should generally avoid
modifying it via the menu configuration.
orsource "../../device/board/*/Kconfig.liteos_m.shields"
orsource "../../device/board/$(BOARD_COMPANY)/Kconfig.liteos_m.defconfig.boards"
choice
prompt "Board Selection"
orsource "../../device/board/$(BOARD_COMPANY)/Kconfig.liteos_m.boards"
endchoice
orsource "../../device/soc/*/Kconfig.liteos_m.defconfig"
choice
prompt "SoC Series Selection"
orsource "../../device/soc/*/Kconfig.liteos_m.series"
endchoice
orsource "../../device/soc/*/Kconfig.liteos_m.soc"
config QUICK_START
bool "Enable QUICK_START"
default n
depends on DRIVERS && FS_VFS
help
Answer Y to enable LiteOS support quick start.
endmenu
######################### config options of kernel #####################
menu "Kernel"
######################### config options of extended #####################
config KERNEL_EXTKERNEL
bool "Enable Extend Kernel"
default y
help
This option will enable extend Kernel of LiteOS. Extend kernel include
cppsupport, cpup, etc. You can select one or some
of them.
config KERNEL_BACKTRACE
bool "Enable Backtrace"
default n
depends on KERNEL_EXTKERNEL
help
If you wish to build LiteOS with support for backtrace.
choice
prompt "Select Backtrace Type"
depends on KERNEL_BACKTRACE
config BACKTRACE_TYPE_1
bool "1: Call stack analysis for cortex-m series by scanning the stack"
depends on ARCH_ARM && !ARCH_ARM9
config BACKTRACE_TYPE_2
bool "2: Call stack analysis for risc-v by using frame pointer"
depends on ARCH_RISCV
config BACKTRACE_TYPE_3
bool "3: Call stack analysis for risc-v by scanning the stack"
depends on ARCH_RISCV
config BACKTRACE_TYPE_4
bool "4: Call stack analysis for xtensa by scanning the stack"
depends on ARCH_XTENSA
config BACKTRACE_TYPE_5
bool "5: Call stack analysis for c-sky by scanning the stack"
depends on ARCH_CSKY
config BACKTRACE_TYPE_6
bool "6: Call stack analysis for arm9 by scanning the stack"
depends on ARCH_ARM9
endchoice
config BACKTRACE_TYPE
int
default 0 if ! KERNEL_BACKTRACE
default 1 if BACKTRACE_TYPE_1
default 2 if BACKTRACE_TYPE_2
default 3 if BACKTRACE_TYPE_3
default 4 if BACKTRACE_TYPE_4
default 5 if BACKTRACE_TYPE_5
default 6 if BACKTRACE_TYPE_6
config BACKTRACE_DEPTH
int "Backtrace depth"
default 15
depends on KERNEL_BACKTRACE
config KERNEL_CPPSUPPORT
bool "Enable C++ Support"
default n
depends on KERNEL_EXTKERNEL
help
If you wish to build LiteOS with support for C++.
rsource "components/signal/Kconfig"
config BASE_CORE_CPUP
bool
default n
config KERNEL_CPUP
bool "Enable Cpup"
default n
depends on KERNEL_EXTKERNEL
select BASE_CORE_CPUP
help
If you wish to build LiteOS with support for cpup.
config CPUP_INCLUDE_IRQ
bool "Enable Cpup include irq"
default y
depends on KERNEL_CPUP
help
If you wish to include irq usage for cpup.
config DYNLINK
bool "Enable Dynamic Link Feature"
default n
depends on KERNEL_EXTKERNEL && ARCH_ARM
help
If you wish to build LiteOS with support for dynamic link.
config KERNEL_PM
bool "Enable Power Management"
default n
depends on KERNEL_EXTKERNEL
help
Configuration item for low power frame tailoring.
If you wish to build LiteOS with support for power management.
config KERNEL_PM_TASK_PTIORITY
int "Power Management Task Priority"
default 1
range 1 31
depends on KERNEL_PM
help
Configuration item for priority of low-power task.
config KERNEL_PM_TASK_STACKSIZE
int "Power Management Task Stack Size"
default 1024
depends on KERNEL_PM
help
Configuration item for stack size of low-power task.
config KERNEL_PM_DEBUG
bool "Power Management Debug"
default n
depends on KERNEL_PM
help
Configuration item for low power frame debug tailoring.
config DEBUG_HOOK
bool
default n
config PLATFORM_EXC
bool "Enable Hook Feature"
default n
depends on KERNEL_EXTKERNEL
select DEBUG_HOOK
config KERNEL_LMK
bool "Enable Low Memory Killer"
default n
depends on KERNEL_EXTKERNEL
help
Configuration item for low momery killer tailoring.
If you wish to build LiteOS with support for low memory killer.
config KERNEL_LMK_DEBUG
bool "Low Memory Killer Debug"
default n
depends on KERNEL_LMK
help
Configuration item forlow memory killer debug tailoring.
######################### config options of trace #########################
source "components/trace/Kconfig"
######################### config options of lms #########################
source "components/lms/Kconfig"
endmenu
######################### config options of lib ########################
menu "Lib"
config LIB_LIBC
bool "Enable Libc"
default y
help
Answer Y to enable libc for full code.
endmenu
######################### config options of compatibility ##############
menu "Compat"
rsource "kal/Kconfig"
endmenu
######################## config options of filesystem ##################
menu "FileSystem"
rsource "components/fs/Kconfig"
endmenu
######################## config options of net ############################
menu "Net"
config NET_LWIP
bool "Enable Lwip"
default n
select NET_LWIP_SACK
help
Answer Y to enable LiteOS support lwip.
config NET_LWIP_SACK
bool
default n
endmenu
######################## config options of debug ########################
menu "Debug"
config GDB
bool "Enable gdb functions"
default n
help
Answer Y to enable gdb functions.
config PLATFORM_ADAPT
bool "Enable Os_adapt"
default y
help
Answer Y to add os_adapt.c to LiteOS.
config ENABLE_OOM_LOOP_TASK
bool "Enable Oom loop task"
default n
depends on KERNEL_VM
help
Answer Y to enable oom loop kthread to check system out of memory.
config DO_ALIGN
bool "Enable do align for hi3518e"
default y
depends on PLATFORM_HI3518EV200
help
Answer Y to enable do align for hi3518e.
config ENABLE_MAGICKEY
bool "Enable MAGIC KEY"
default y
help
Answer Y to enable LiteOS Magic key.
ctrl + r : Magic key check switch;
ctrl + z : Show all magic op key;
ctrl + t : Show task information;
ctrl + p : System panic;
ctrl + e : Check system memory pool.
config THUMB
bool "Enable Thumb"
default n
depends on ARCH_ARM
help
Answer Y to build thumb version. This will make LiteOS smaller.
config PLATFORM_DVFS
bool "Enable Dvfs"
default n
depends on COMPAT_LINUXKPI
help
Answer Y to enable LiteOS support dynamic voltage and frequency scaling feature for
low power consumption.
config SAVE_EXCINFO
bool "Enable Saving Exception Information"
default n
help
Answer Y to enable LiteOS support saving exception information to storage medium.
config DEBUG_VERSION
bool "Enable a Debug Version"
default y
help
If you do not select this option that means you enable a release version for LiteOS.
It also means you do not want to use debug modules, like shell,telnet,tftp,nfs and
memory check, etc.
If you select this option that means you enable a debug version for LiteOS.
That means you want a opposite behaviour compared to release version.
config DEBUG_KERNEL
bool "Enable Debug LiteOS Kernel Resource"
default n
depends on DEBUG_VERSION
help
If you select this option that means you enable debugging kernel resource.
It also means you want to get queue, mutex, semaphore, memory debug information.
That means you want a opposite behaviour compared to release version.
config DEBUG_QUEUE
bool "Enable Queue Debugging"
default n
depends on DEBUG_KERNEL
help
Answer Y to enable debug queue.
config DEBUG_DEADLOCK
bool "Enable Mutex Deadlock Debugging"
default n
depends on DEBUG_KERNEL
help
Answer Y to enable debug mutex deadlock.
config DEBUG_SEMAPHORE
bool "Enable Semaphore Debugging"
default n
depends on DEBUG_KERNEL
help
Answer Y to enable debug semaphore.
source "components/shell/Kconfig"
config NET_LWIP_SACK_TFTP
bool "Enable Tftp"
default y
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
help
Answer Y to enable LiteOS support tftp cmd and tftp tool.
osource "net/telnet/Kconfig"
config SCHED_DEBUG
bool "Enable sched debug Feature"
default n
depends on DEBUG_VERSION
help
If you wish to build LiteOS with support for sched debug.
config USER_INIT_DEBUG
bool "Enable user init Debug"
default n
depends on DEBUG_VERSION
config SHELL_CMD_DEBUG
bool "Enable shell cmd Debug"
default n
depends on DEBUG_VERSION && SHELL
config USB_DEBUG
bool "Enable USB Debug"
default n
depends on SHELL && DRIVERS_USB && DEBUG_VERSION
help
Answer Y to enable LiteOS support usb debug.
use shell command to open the specified debug level print.
config MEM_DEBUG
bool "Enable MEM Debug"
default n
depends on DEBUG_VERSION
help
Answer Y to enable LiteOS support mem debug.
config MEM_LEAKCHECK
bool "Enable Function call stack of Mem operation recorded"
default n
depends on DEBUG_VERSION && MEM_DEBUG
select KERNEL_BACKTRACE
help
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
config BASE_MEM_NODE_INTEGRITY_CHECK
bool "Enable integrity check or not"
default n
depends on DEBUG_VERSION && MEM_DEBUG
config MEM_WATERLINE
bool "Enable memory pool waterline or not"
default n
depends on DEBUG_VERSION && MEM_DEBUG
config VM_OVERLAP_CHECK
bool "Enable VM overlap check or not"
default n
depends on DEBUG_VERSION && MEM_DEBUG
help
Answer Y to enable vm overlap check.
endmenu
######################## config options os drivers ########################
menu "Driver"
source "drivers/Kconfig"
endmenu
######################## config options os security #######################
menu "Security"
osource "security/Kconfig"
config SECURE_TRUSTZONE
bool "Enable ARM TrustZone"
default n
depends on ARCH_ARM
config SECURE_HEAP_SIZE
int "TrustZone Heap Size (bytes)"
default 2048
depends on SECURE_TRUSTZONE
config SECURE_STACK_DEFAULT_SIZE
int "TrustZone Stack Size (bytes)"
default 512
depends on SECURE_TRUSTZONE
help
The secure stack must be allocated before the task calls non-secure functions.
endmenu
menu "Test"
config TEST
bool
default n
config KERNEL_TEST
bool "Enable Kernel Test"
default n
select TEST
config KERNEL_TEST_FULL
bool "Full Kernel Test"
default n
depends on KERNEL_TEST
endmenu
menu "Stack Smashing Protector (SSP) Compiler Feature"
choice
prompt "Enable stack buffer overflow detection"
default CC_STACKPROTECTOR_STRONG
---help---
This option turns on the -fstack-protector GCC feature. This
feature puts, at the beginning of functions, a canary value on
the stack just before the return address, and validates
the value just before actually returning. Stack based buffer
overflows (that need to overwrite this return address) now also
overwrite the canary, which gets detected and the attack is then
neutralized via a kernel panic.
This feature requires gcc version 4.2 or above, or a distribution
gcc with the feature backported. Older versions are automatically
detected and for those versions, this configuration option is
ignored. (and a warning is printed during bootup)
config CC_NO_STACKPROTECTOR
bool "-fno-stack-protector"
config CC_STACKPROTECTOR
bool "-fstack-protector"
config CC_STACKPROTECTOR_STRONG
bool "-fstack-protector-strong"
config CC_STACKPROTECTOR_ALL
bool "-fstack-protector-all"
endchoice
endmenu

122
Makefile Normal file
View File

@@ -0,0 +1,122 @@
# 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.
LITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
export LITEOSTOPDIR
LITEOS_TARGET = liteos
HIDE := @
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
ohos_kernel ?= liteos_m
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
ifneq ($(ohos_kernel),liteos_m)
$(error The selected product ($(ohos_product)) is not a liteos_m kernel type product)
endif
ifeq ($(PRODUCT_PATH),)
PRODUCT_PATH:=$(ohos_product_path)
endif
ifeq ($(DEVICE_PATH),)
DEVICE_PATH:=$(ohos_device_path)
endif
ifeq ($(BOARD_COMPANY),)
BOARD_COMPANY:=$(ohos_device_company)
endif
ifeq ($(TEE:1=y),y)
tee = _tee
endif
ifeq ($(RELEASE:1=y),y)
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/release$(tee).config
else
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
endif
KCONFIG_CONFIG ?= $(CONFIG)
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 BOARD_COMPANY
export DEVICE_PATH
export PRODUCT_PATH
# export kconfig related environment variables
export CONFIG_=LOSCFG_
export srctree=$(LITEOSTOPDIR)
-include $(LITEOS_CONFIG_FILE)
define HELP =
Usage: make [TARGET]... [PARAMETER=VALUE]...
Targets:
help: display this help and exit
clean: clean compiled objects
cleanall: clean all build outputs
all: do build (Default target)
update_config: update product kernel config (use menuconfig)
xxconfig: invoke xxconfig command of kconfiglib (xxconfig is one of $(KCONFIG_CMDS))
Parameters:
TEE: boolean value(1 or y for true), enable tee
RELEASE: boolean value(1 or y for true), build release version
CONFIG: kernel config file to be use
args: arguments for xxconfig command
endef
export HELP
all:
$(HIDE)hb build -f --gn-args "liteos_kernel_only=true liteos_name=\"$(LITEOS_TARGET)\""
help:
$(HIDE)echo "$$HELP"
$(filter-out menuconfig,$(KCONFIG_CMDS)):
$(HIDE)$@ $(args)
$(LITEOS_CONFIG_FILE): $(KCONFIG_CONFIG)
$(HIDE)env KCONFIG_CONFIG=$< genconfig --config-out $@ --header-path $(LITEOS_MENUCONFIG_H)
update_config menuconfig:
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig $(args) && savedefconfig --out "$(CONFIG)"
clean:
$(HIDE)hb clean
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
cleanall: clean
$(HIDE)echo "clean all done"
.PHONY: all clean cleanall help update_config $(KCONFIG_CMDS) $(KCONFIG_CONFIG)

View File

@@ -29,11 +29,11 @@
</policylist>
<filefilterlist>
<filefilter name="defaultFilter" desc="文件属于FreeBSD仓库软连接本仓库屏蔽告警在FreeBSD仓库进行处理">
<filteritem type="filepath" name="kernel/arch/risc-v/nuclei/gcc/nmsis/Library/.*" desc="文件属于三方芯片的二进制代码,属于社区贡献,不用提供额外的说明"/>
<filteritem type="filepath" name="arch/risc-v/nuclei/gcc/nmsis/Library/.*" desc="文件属于三方芯片的二进制代码,属于社区贡献,不用提供额外的说明"/>
<filteritem type="filepath" name="targets/riscv_nuclei_demo_soc_gcc/.*" desc="文件属于nuclei三方芯片的源代码文件头说明跟随liteos_m/LICENSE不用额外说明"/>
<filteritem type="filepath" name="targets/riscv_nuclei_gd32vf103_soc_gcc/.*" desc="文件属于nuclei三方芯片的源代码文件头说明跟随liteos_m/LICENSE不用额外说明"/>
<filteritem type="filepath" name="NOTICE" desc="NOTICE文件"/>
<filteritem type="filepath" name="kernel/arch/risc-v/nuclei" desc="该文件的license为apache 2.0符合"/>
<filteritem type="filepath" name="arch/risc-v/nuclei" desc="该文件的license为apache 2.0符合"/>
</filefilter>
<filefilter name="defaultFilter" desc="Files not to check">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->

117
README.md
View File

@@ -1,77 +1,134 @@
# LiteOS Cortex-M<a name="EN-US_TOPIC_0000001096757661"></a>
# LiteOS-M Kernel<a name="EN-US_TOPIC_0000001096757661"></a>
- [Introduction](#section11660541593)
- [Directory Structure](#section161941989596)
- [Constraints](#section119744591305)
- [Usage](#section3732185231214)
- [Contribution](#section1371123476307)
- [Repositories Involved](#section1371113476307)
## Introduction<a name="section11660541593"></a>
The OpenHarmony LiteOS Cortex-M is the kernel designed for the lightweight operating system \(OS\) for the Internet of Things \(IoT\) field. It features small size, low power consumption, and high performance. In addition, it has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory, and is divided into the hardware-related and hardware-irrelevant layers. The hardware-related layers provide unified hardware abstraction layer \(HAL\) interfaces to improve hardware adaptability. The combination and classification of different compilation toolchains and chip architectures meet the requirements of the Artificial Intelligence of Things \(AIoT\) field for rich hardware and compilation toolchains. [Figure1](#fig0865152210223) shows the architecture of the OpenHarmony LiteOS Cortex-M kernel.
OpenHarmony LiteOS-M is a lightweight operating system kernel designed for the Internet of Things (IoT) field. It features small footprint, low power consumption, and high performance. It has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory. The LiteOS-M kernel is divided into the hardware layer and hardware-irrelevant layers. The hardware layer provides a unified hardware abstraction layer (HAL) interface for easier hardware adaptation. A range of compilation toolchains can be used with different chip architectures to meet the expansion of diversified hardware and compilation toolchains in the Artificial Intelligence of Things (AIoT) field.
**Figure1** shows the architecture of the LiteOS-M kernel.
**Figure 1** Architecture of OpenHarmony the LiteOS Cortex-M kernel<a name="fig0865152210223"></a>
![](figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png "architecture-of-openharmony-the-liteos-cortex-m-kernel")
**Figure 1** Architecture of the OpenHarmony LiteOS-M kernel<a name="fig0865152210223"></a>
![](figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png "OpenHarmony-LiteOS-M Kernel Architecture")
## Directory Structure<a name="section161941989596"></a>
The directory structure is listed as below, for the detailed directories, please refer to [arch_spec.md](arch_spec.md).
The directory structure is as follows. For more details, see [arch_spec.md](arch_spec.md).
```
/kernel/liteos_m
├── arch # Code of the kernel instruction architecture layer
│ ├── arm # Code of the ARM32 architecture
│ │ ├── arm9 # Code of the ARM9 architecture
│ │ ├── cortex-m3 # Code of the cortex-m3 architecture
│ │ ├── cortex-m33 # Code of the cortex-m33 architecture
│ │ ├── cortex-m4 # Code of the cortex-m4 architecture
│ │ ├── cortex-m7 # Code of the cortex-m7 architecture
│ │ └── include # Arm architecture public header file directory
│ ├── csky # Code of the csky architecture
│ │ └── v2 # Code of the csky v2 architecture
│ ├── include # APIs exposed externally
│ ├── risc-v # Code of the risc-v architecture
│ │ ├── nuclei # Code of the nuclei system technology risc-v architecture
│ │ └── riscv32 # Code of the risc-v architecture
│ └── xtensa # Code of the xtensa architecture
│ └── lx6 # Code of the lx6 xtensa architecture
├── components # Optional components
│ ├── backtrace # Backtrace support
│ ├── cppsupport # C++ support
│ ├── cpup # CPU possession (CPUP)
│ ├── dynlink # Dynamic loader & linker
│ ├── exchook # Exception hook
│ ├── fs # File system
── net # Network support
│ ├── cpup # CPU percent (CPUP)
│ ├── dynlink # Dynamic loading and linking
│ ├── exchook # Exception hooks
│ ├── fs # File systems
── lmk # Low memory killer functions
│ ├── lms # Lite memory sanitizer functions
│ ├── net # Networking functions
│ ├── power # Power management
│ ├── shell # Shell function
│ ├── fs # File systems
│ └── trace # Trace tool
├── drivers # driver Kconfig
├── kal # Kernel abstraction layer
│ ├── cmsis # CMSIS-compliant API support
│ ├── cmsis # CMSIS API support
│ └── posix # POSIX API support
├── kernel # Minimum function set support
│ ├── arch # Code of the kernel instruction architecture layer
│ │ ├── arm # Code of the ARM32 architecture
│ │ └── include # APIs exposed externally
├── kernel # Minimum kernel function set
│ ├── include # APIs exposed externally
│ └── src # Source code of the minimum function set of the kernel
│ └── src # Source code of the minimum kernel function set
├── targets # Board-level projects
├── utils # Common code
├── testsuites # Kernel testsuites
├── tools # Kernel tools
├── utils # Common directory
```
## Constraints<a name="section119744591305"></a>
Programming languages: C and C++
OpenHarmony LiteOS-M supports only C and C++.
Currently applicable architectures: Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V
Applicable architecture: See the directory structure for the arch layer.
As for dynamic loading module, the shared library to be loaded needs signature verification or source restriction to ensure security.
## Usage<a name="section3732185231214"></a>
LiteOS Cortex-M provides projects for three chip architectures, which are located in the **targets** directory. The methods of compiling and using these projects are as follows:
The OpenHarmony LiteOS-M kernel build system is a modular build system based on Generate Ninja (GN) and Ninja. It supports module-based configuration, tailoring, and assembling, and helps you build custom products. This document describes how to build a LiteOS-M project based on GN and Ninja. For details about the methods such as GCC+gn, IAR, and Keil MDK, visit the community websites.
### Setting Up the Environment
Before setting up the environment for a development board, you must set up the basic system environment for OpenHarmony first. The basic system environment includes the OpenHarmony build environment and development environment. For details, see [Setting Up Development Environment](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/quick-start/quickstart-lite-env-setup.md).
### Obtaining the OpenHarmony Source Code
For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained.
### Example projects that are already supported
Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`, For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu)
Bestechnic: `bes2600`, For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic)
### Community Porting Project Links
The LiteOS-M kernel porting projects for specific development boards are provided by community developers. The following provides the links to these projects. If you have porting projects for more development boards, you can provide your links to share your projects.
- Cortex-M3:
The **kernel/liteos\_m/targets/cortex-m3\_stm32f103\_simulator\_keil** directory is the Keil project directory created based on the STM32F103 chip architecture. You can download and install Keil development tools from the Internet. To compile the Cortex-M3 project, go to the **cortex-m3\_stm32f103\_simulator\_keil/project** directory and double-click the **los\_demo.uvproj** file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
- STM32F103 https://gitee.com/rtos_lover/stm32f103_simulator_keil
This repository provides the Keil project code for building the OpenHarmony LiteOS-M kernel based on the STM32F103 chip architecture. This code supports build in Keil MDK mode.
- Cortex-M4:
The **kernel/liteos\_m/targets/cortex-m4\_stm32f429ig\_fire-challenger\_iar** directory is the IAR project directory created based on the STM32F429IG chip architecture. You can download and install IAR development tools from the Internet. To compile the Cortex-M4 project, go to the **cortex-m4\_stm32f429ig\_fire-challenger\_iar/project** directory and double-click the **los\_demo.eww** file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
- STM32F429IGTb https://gitee.com/harylee/stm32f429ig_firechallenger
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the STM32F429IGTb development board. The code supports build in Ninja, GCC, and IAR modes.
- Cortex-M7:
The **kernel/liteos\_m/targets/cortex-m7\_nucleo\_f767zi\_gcc** directory is the Makefile project directory created based on the STM32F767ZI chip architecture. The compilation commands are as follows:
- Nucleo-F767ZI https://gitee.com/harylee/nucleo_f767zi
```
cd kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc
make clean; make
```
This repository provides the project code for porting the OpenHarmony LiteOS-M kernel to support the Nucleo-F767ZI development board. The code supports build in Ninja, GCC, and IAR modes.
After the compilation is successful, the executable file **NUCLEO-F767.hex** is generated in the **cortex-m7\_nucleo\_f767zi\_gcc/build** directory. Burn the file to the corresponding board using STM32 ST-LINK Utility.
## Contribution<a name="section1371123476307"></a>
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution.md)
[Commit message spec](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)
[Liteos-M kernel coding style guide](https://gitee.com/openharmony/kernel_liteos_m/wikis/OpenHarmony%E8%BD%BB%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83)
How to contribute a chip based on Liteos-M kernel:
[ Board-Level Directory Specifications](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/porting/porting-chip-board-overview.md)
[Mini System SoC Porting Guide](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/porting/porting-minichip.md)
## Repositories Involved<a name="section1371113476307"></a>
[Kernel subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/kernel.md)
[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md)
**kernel\_liteos\_m**

View File

@@ -4,6 +4,7 @@
- [目录](#section161941989596)
- [约束](#section119744591305)
- [使用说明](#section3732185231214)
- [贡献](#section1371123476307)
- [相关仓](#section1371113476307)
## 简介<a name="section11660541593"></a>
@@ -19,24 +20,45 @@ OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系
```
/kernel/liteos_m
├── arch # 内核指令架构层目录
│ ├── arm # arm 架构代码
│ │ ├── arm9 # arm9 架构代码
│ │ ├── cortex-m3 # cortex-m3架构代码
│ │ ├── cortex-m33 # cortex-m33架构代码
│ │ ├── cortex-m4 # cortex-m4架构代码
│ │ ├── cortex-m7 # cortex-m7架构代码
│ │ └── include # arm架构公共头文件目录
│ ├── csky # csky架构代码
│ │ └── v2 # csky v2架构代码
│ ├── include # 架构层对外接口存放目录
│ ├── risc-v # risc-v 架构
│ │ ├── nuclei # 芯来科技risc-v架构代码
│ │ └── riscv32 # risc-v官方通用架构代码
│ └── xtensa # xtensa 架构代码
│ └── lx6 # xtensa lx6架构代码
├── components # 可选组件
│ ├── backtrace # 回溯栈支持
│ ├── backtrace # 回溯功能
│ ├── cppsupport # C++支持
│ ├── cpup # CPUP功能
│ ├── dynlink # 动态加载与链接
│ ├── exchook # 异常钩子
│ ├── fs # 文件系统
── net # Network功能
── lmk # Low memory killer 机制
│ ├── lms # Lite memory sanitizer 机制
│ ├── net # Network功能
│ ├── power # 低功耗管理
│ ├── shell # shell功能
│ └── trace # trace 工具
├── drivers # 驱动框架Kconfig
├── kal # 内核抽象层
│ ├── cmsis # cmsis标准接口支持
│ └── posix # posix标准接口支持
├── kernel # 内核最小功能集支持
│ ├── arch # 内核指令架构层代码
│ │ ├── arm # arm32架构的代码
│ │ └── include # 对外接口存放目录
│ ├── include # 对外接口存放目录
│ └── src # 内核最小功能集源码
├── targets # 板级工程目录
├── testsuites # 内核测试用例
├── tools # 内核工具
├── utils # 通用公共目录
```
@@ -44,58 +66,28 @@ OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系
开发语言C/C++
适用架构:当前只适用于cortex-m3、cortex-m4、cortex-m7、risc-v芯片架构
适用架构:详见目录结构arch层
动态加载模块:待加载的共享库需要验签或者限制来源,确保安全性。
## 使用说明<a name="section3732185231214"></a>
OpenHarmony LiteOS-M内核的编译构建系统是一个基于gn和ninja的组件化构建系统支持按组件配置、裁剪和拼装按需构建出定制化的产品。本文主要介绍如何基于gn和ninja编译LiteOS-M工程GCC+Makefile、IAR、Keil MDK等编译方式可以参考社区爱好者贡献的站点。
OpenHarmony
LiteOS-M内核的编译构建系统是一个基于gn和ninja的组件化构建系统支持按组件配置、裁剪和拼装按需构建出定制化的产品。本文主要介绍如何基于gn和ninja编译LiteOS-M工程GCC+gn、IAR、Keil MDK等编译方式可以参考社区爱好者贡献的站点。
### 搭建系统基础环境
在搭建各个开发板环境前需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境详细介绍请参考官方站点[Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md)。开发者需要根据环境搭建文档完成下述软件的安装Python3.7+、gn、ninja、hb。对于LiteOS-M内核还需要安装Make构建工具和[ARM GCC编译工具链](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
在搭建各个开发板环境前需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境详细介绍请参考官方站点[开发环境准备](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md)。开发者需要根据环境搭建文档完成环境搭建
### 获取OpenHarmony源码
开发者需要在Linux服务器上通过Git克隆获取OpenHarmony最新源码详细的源码获取方式,请见[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。获取OpenHarmony完整仓代码后假设克隆目录为`~/openHarmony`
详细的源码获取方式,请见[源码获取](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/get-code/sourcecode-acquire.md)。获取OpenHarmony完整仓代码后假设克隆目录为`~/openHarmony`
### 获取示例工程源码
### 已支持的示例工程
以开发板Nucleo-F767Zi为例演示如何编译运行`OpenHarmony LiteOS-M`内核工程。在本地目录,执行下述命令克隆示例代码。
Qemu模拟器: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`, 编译运行详见: [Qemu指导](https://gitee.com/openharmony/device_qemu)
```
git clone https://gitee.com/harylee/nucleo_f767zi.git
```
假设克隆到的代码目录为`~/nucleo_f767zi`。 执行如下命令把代码目录的`device``vendor`目录复制到`openHarmony`工程的相应目录。
```
mkdir ~/openHarmony/device/st
cp -r ~/nucleo_f767zi/device/st/nucleo_f767zi ~/openHarmony/device/st/nucleo_f767zi
chmod +x ~/openHarmony/device/st/nucleo_f767zi/build.sh
cp -r ~/nucleo_f767zi/vendor/st ~/openHarmony/vendor/st
```
关于示例代码目录的说明,可以参考资料站点[板级目录规范](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/transplant-chip-board-overview.md)。如果需要自行移植开发板,请参考[板级系统移植](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/transplant-chip-board.md)。
### 编译运行
编译运行前,交叉编译工具链`bin`目录配置到`PATH`环境变量中或者配置`device/st/nucleo_f767zi/liteos_m/config.gni`文件中`board_toolchain_path`配置项为交叉编译工具链`bin`目录。
`OpenHarmony`根目录,执行`hb set`设置产品路径,选择`nucleo_f767zi`产品,然后执行`hb build`开启编译。如下:
```
user@dev:~/OpenHarmony$ hb set
[OHOS INFO] Input code path: # 直接按回车然后选择nucleo_f767zi产品即可
OHOS Which product do you need? nucleo_f767zi@st
user@dev:~/OpenHarmony$ hb build
```
最终的镜像生成在`~/openHarmony/out/nucleo_f767zi/`目录中,通过`STM32 ST-LINK Utility`软件将镜像文件下载至单板查看运行效果。
恒玄科技: `bes2600`, 编译运行详见: [恒玄开发指导](https://gitee.com/openharmony/device_soc_bestechnic)
### 社区移植工程链接
@@ -119,9 +111,25 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供可以
该仓包含OpenHarmony LiteOS-M内核移植支持`Nucleo-F767ZI`开发板的工程代码支持Ninja、GCC、IAR等方式进行编译。
## 贡献<a name="section1371123476307"></a>
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
[Commit message规范](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)
[Liteos-M 内核编码规范](https://gitee.com/openharmony/kernel_liteos_m/wikis/OpenHarmony%E8%BD%BB%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83)
如何基于Liteos-M内核贡献一款芯片:
[板级目录规范](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/porting/porting-chip-board-overview.md)
[轻量系统芯片移植指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/porting-minichip.md)
[轻量系统芯片移植案例](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/porting/porting-minichip-cases.md)
## 相关仓<a name="section1371113476307"></a>
[内核子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
[内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
**kernel\_liteos\_m**

52
arch/BUILD.gn Normal file
View File

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

53
arch/Kconfig Normal file
View File

@@ -0,0 +1,53 @@
config ARCH_ARM
bool
rsource "arm/Kconfig"
config ARCH_CSKY
bool
config ARCH_RISCV
bool
config ARCH_RISCV32
bool
select ARCH_RISCV
config ARCH_XTENSA
bool
comment "Extra Configurations"
config ARCH_FPU_DISABLE
bool "Disable Floating Pointer Unit"
default n
help
This option will bypass floating procedure in system.
config ARCH_SECURE_MONITOR_MODE
bool "Run On Secure Monitor Mode"
default n
depends on ARCH_ARM_AARCH64
help
This option will make the system run on EL3.
config ARCH_INTERRUPT_PREEMPTION
bool "Enable Interrupt Preemption"
default n
depends on ARCH_ARM_AARCH64
help
This option will support high priority interrupt preemption.
config IRQ_USE_STANDALONE_STACK
bool "Use Interrupt Stack"
default y
depends on ARCH_ARM_AARCH64 || ARCH_ARM_AARCH32
help
This option will support using standalone interrupt stack.
config ARCH_UNALIGNED_EXC
bool "Enable Unaligned Exception"
default y
depends on ARCH_ARM
help
This option will enable unaligned exception.

39
arch/arm/BUILD.gn Normal file
View File

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

117
arch/arm/Kconfig Normal file
View File

@@ -0,0 +1,117 @@
# ARM Architecture
#
# ARM has 32-bit(Aarch32) and 64-bit(Aarch64) implementations
#
config ARCH_ARM_AARCH32
bool
select ARCH_ARM
help
32-bit ARM architecture implementations, Except the M-profile.
It is not limited to ARMv7-A but also ARMv7-R, ARMv8-A 32-bit and etc.
#
# Architecture Versions
#
config ARCH_ARM_V7M
bool
config ARCH_ARM_V5TE
bool
config ARCH_ARM_VER
string
default "armv7-m" if ARCH_ARM_V7M
default "armv5te" if ARCH_ARM_V5TE
#
# VFP Hardware
#
config ARCH_FPU_VFP_V3
bool
help
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
VFPv3U is a variant of VFPv3 that supports the trapping of floating-point exceptions to support code.
config ARCH_FPU_VFP_V4
bool
help
An optional extension to the Arm, Thumb, and ThumbEE instruction sets in the ARMv7-A and ARMv7-R profiles.
VFPv4U is a variant of VFPv4 that supports the trapping of floating-point exceptions to support code.
VFPv4 and VFPv4U add both the Half-precision Extension and the fused multiply-add instructions to the features of VFPv3.
config ARCH_FPU_VFP_D16
bool
depends on ARCH_ARM_AARCH32
help
VPU implemented with 16 doubleword registers (16 x 64-bit).
config ARCH_FPU_VFP_D32
bool
depends on ARCH_ARM_AARCH32
help
VPU implemented with 32 doubleword registers (32 x 64-bit).
config ARCH_FPU_VFP_NEON
bool
help
Advanced SIMD extension (NEON) support.
config ARCH_FPU
string
default "vfpv3" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D32
default "vfpv3-d16" if ARCH_FPU_VFP_V3 && ARCH_FPU_VFP_D16
default "neon-vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32 && ARCH_FPU_VFP_NEON
default "vfpv4" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D32
default "vfpv4-d16" if ARCH_FPU_VFP_V4 && ARCH_FPU_VFP_D16
#
# Supported Processor Cores
#
config ARCH_CORTEX_M3
bool
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
config ARCH_CORTEX_M4
bool
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
config ARCH_CORTEX_M7
bool
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_CORTEX_M33
bool
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_CORTEX_M55
bool
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_ARM9
bool
select ARCH_ARM_V5TE
select ARCH_ARM_AARCH32
config ARCH_CPU
string
default "cortex-m3" if ARCH_CORTEX_M3
default "cortex-m4" if ARCH_CORTEX_M4
default "cortex-m7" if ARCH_CORTEX_M7
default "cortex-m33" if ARCH_CORTEX_M33
default "cortex-m55" if ARCH_CORTEX_M55
default "arm9" if ARCH_ARM9

View File

@@ -27,9 +27,10 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/config.gni")
import("//kernel/liteos_m/liteos.gni")
static_library("arch") {
module_name = "arch"
kernel_module(module_name) {
sources = [
"los_context.c",
"los_dispatch.S",
@@ -38,6 +39,9 @@ static_library("arch") {
"los_timer.c",
"reset_vector.S",
]
configs += [ "$LITEOSTOPDIR:los_config" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@@ -0,0 +1,233 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
return *v;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicXchg32bits(Atomic *v, INT32 val)
{
INT32 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(Atomic *v, INT32 val, INT32 oldVal)
{
INT32 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -97,7 +97,8 @@ extern UINT32 g_intCount;
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a arm9 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -147,7 +148,8 @@ extern UINT32 g_intCount;
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a arm9 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -157,7 +159,8 @@ extern UINT32 g_intCount;
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
@@ -171,7 +174,7 @@ extern UINT32 g_intCount;
*/
#define OS_ERRNO_HWI_FASTMODE_ALREADY_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x07)
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Set interrupt vector table.
@@ -204,25 +207,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Get an interrupt number.
*
* @par Description:
* This API is used to get the current interrupt number.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval: Interrupt Indexes number.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern UINT32 HalIntNumGet(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
@@ -282,7 +266,7 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
VOID HalHwiInit();
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
@@ -322,15 +306,18 @@ VOID HalHwiInit();
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 19 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;

View File

@@ -34,7 +34,7 @@
#include "los_config.h"
#include "los_compiler.h"
#include "los_context.h"
#include "los_timer.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,8 +42,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
UINT32 HalTickStart(OS_TICK_HANDLER handler);
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -36,35 +36,28 @@
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_arch_timer.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalArchInit
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
UINT32 ret;
HalHwiInit();
ret = HalTickStart(OsTickHandler);
if (ret != LOS_OK) {
PRINT_ERR("Tick start failed!\n");
}
}
/* ****************************************************************************
Function : HalSysExit
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
while (1) {
@@ -72,7 +65,7 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
}
/* ****************************************************************************
Function : HalTskStackInit
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
@@ -80,20 +73,9 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = NULL;
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
errno_t result;
/* initialize the task stack, write magic num to stack top */
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
if (result != EOK) {
PRINT_ERR("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
}
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
context->r0 = taskID;
context->r1 = 0x01010101L;
@@ -109,7 +91,7 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
context->r11 = 0x11111111L;
context->r12 = 0x12121212L;
context->sp = (UINTPTR)topStack + stackSize;
context->lr = (UINTPTR)HalSysExit;
context->lr = (UINTPTR)ArchSysExit;
if ((UINTPTR)taskCB->taskEntry & 0x01) {
context->pc = (UINTPTR)OsTaskEntryThumb;
@@ -122,7 +104,7 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(VOID)
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();
@@ -131,7 +113,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(VOID)
return LOS_OK; /* never return */
}
LITE_OS_SEC_TEXT_INIT VOID HalTaskSchedule(VOID)
LITE_OS_SEC_TEXT_INIT VOID ArchTaskSchedule(VOID)
{
__asm__ __volatile__("swi 0");
}

View File

@@ -48,9 +48,6 @@
#define OS_INT_ENABLE_ADDR (OS_INT_REG_BASE)
#define OS_INT_STATUS_ADDR (OS_INT_REG_BASE + 12)
#define OS_INT_ENABLE(num) (*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (num)))
#define OS_INT_DISABLE(num) (*((volatile UINT32 *)OS_INT_ENABLE_ADDR ) &= ~(1U << (num)))
#define OS_INSTR_SET_MASK 0x01000020U
#define OS_ARM_INSTR_LEN 4
#define OS_THUMB_INSTR_LEN 2
@@ -64,7 +61,7 @@ ExcInfo g_excInfo = {0};
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
@@ -112,21 +109,50 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
/* ****************************************************************************
Function : HalIntNumGet
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
STATIC UINT32 HwiNumGet(VOID)
{
UINT32 status;
READ_UINT32(status, OS_INT_STATUS_ADDR);
return (31 - CLZ(status));
}
inline UINT32 HalIsIntActive(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) |= (1U << (hwiNum));
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
*((volatile UINT32 *)OS_INT_ENABLE_ADDR) &= ~(1U << (hwiNum));
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.getCurIrqNum = HwiNumGet,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
@@ -140,18 +166,19 @@ inline UINT32 HalIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HalIntNumGet();
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
@@ -175,13 +202,13 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
OsSchedUpdateSleepTime();
#endif
hwiIndex = HalIntNumGet();
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
@@ -201,25 +228,26 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
/* ****************************************************************************
Function : HalHwiCreate
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -232,33 +260,40 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
intSave = LOS_IntLock();
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
OsSetVector(hwiNum, handler);
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
OS_INT_ENABLE(hwiNum);
HwiUnmask(hwiNum);
LOS_IntRestore(intSave);
return LOS_OK;
}
/* ****************************************************************************
Function : HalHwiDelete
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
OS_INT_DISABLE(hwiNum);
HwiMask(hwiNum);
intSave = LOS_IntLock();
g_hwiForm[hwiNum + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
@@ -316,6 +351,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
PRINTK("xPSR = 0x%x\n", excInfo->context->spsr);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
@@ -332,6 +368,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
@@ -381,7 +418,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcMemPoolCheckInfo();
#endif
@@ -414,7 +453,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
HalSysExit();
ArchSysExit();
}
/* ****************************************************************************
@@ -431,7 +470,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
UINT32 val;
for (val = OS_SYS_VECTOR_CNT; val < OS_VECTOR_CNT; val++) {
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
g_hwiForm[val].pfnHook = HalHwiDefaultHandler;
g_hwiForm[val].uwParam = 0;
#else
@@ -447,7 +486,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
return;
}
UINT32 HalIntLock(VOID)
UINT32 ArchIntLock(VOID)
{
UINT32 ret;
UINT32 temp;
@@ -461,12 +500,12 @@ UINT32 HalIntLock(VOID)
return ret;
}
VOID HalIntRestore(UINT32 intSave)
VOID ArchIntRestore(UINT32 intSave)
{
__asm__ __volatile__("MSR CPSR_c, %0" : : "r"(intSave));
}
UINT32 HalIntUnLock(VOID)
UINT32 ArchIntUnLock(VOID)
{
UINT32 intSave;

View File

@@ -29,8 +29,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_timer.h"
#include "los_config.h"
#include "los_sched.h"
#include "los_arch_context.h"
#include "los_arch_interrupt.h"
#include "los_reg.h"
@@ -51,18 +51,32 @@
#define OS_TIMER_READ_CTL_ADDR (OS_TIMER_REG_BASE + 16)
#define OS_TIMER_READ_VAL_ADDR (OS_TIMER_REG_BASE + 20)
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = OS_TIMER_IRQ_NUM,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 intSave = LOS_IntLock();
UINT32 value;
ArchTickTimer *tick = &g_archTickTimer;
tick->freq = OS_SYS_CLOCK;
READ_UINT32(value, OS_TIMER_CLK_PWD_ADDR);
value &= ~(OS_TIMER_32K_CLK_BIT);
WRITE_UINT32(value, OS_TIMER_CLK_PWD_ADDR);
@@ -77,13 +91,13 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
value |= OS_TIMER_ENABLE; // Enable timer.
WRITE_UINT32(value, OS_TIMER_CTL_REG_ADDR);
(VOID)HalHwiCreate(OS_TIMER_IRQ_NUM, 0, 0, (HWI_PROC_FUNC)handler, 0);
(VOID)ArchHwiCreate(OS_TIMER_IRQ_NUM, 0, 0, (HWI_PROC_FUNC)handler, 0);
LOS_IntRestore(intSave);
return LOS_OK;
}
STATIC VOID HalClockIrqClear(VOID)
STATIC VOID SysTickClockIrqClear(VOID)
{
UINT32 mask = OS_TIMER_INT_MASK << OS_TIMER_INT_POS;
UINT32 status;
@@ -94,15 +108,20 @@ STATIC VOID HalClockIrqClear(VOID)
} while (status & mask);
}
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
HalTickLock();
WRITE_UINT32(nextResponseTime, OS_TIMER_PERIOD_REG_ADDR);
HalClockIrqClear();
HalTickUnlock();
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTickLock();
WRITE_UINT32((UINT32)nextResponseTime, OS_TIMER_PERIOD_REG_ADDR);
SysTickClockIrqClear();
SysTickUnlock();
return nextResponseTime;
}
WEAK UINT64 HalGetTickCycle(UINT32 *period)
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 val;
@@ -118,7 +137,7 @@ WEAK UINT64 HalGetTickCycle(UINT32 *period)
return (UINT64)val;
}
WEAK VOID HalTickLock(VOID)
STATIC VOID SysTickLock(VOID)
{
UINT32 value;
@@ -129,7 +148,7 @@ WEAK VOID HalTickLock(VOID)
WRITE_UINT32(value, OS_TIMER_CTL_REG_ADDR);
}
WEAK VOID HalTickUnlock(VOID)
STATIC VOID SysTickUnlock(VOID)
{
UINT32 value;
@@ -140,7 +159,12 @@ WEAK VOID HalTickUnlock(VOID)
WRITE_UINT32(value, OS_TIMER_CTL_REG_ADDR);
}
UINT32 HalEnterSleep(VOID)
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
dsb();
wfi();

View File

@@ -0,0 +1,152 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M3 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M3 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
@@ -309,7 +312,7 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Get an interrupt number.
*
* @par Description:
* This API is used to get the current interrupt number.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval: Interrupt Indexes number.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern UINT32 HalIntNumGet(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
@@ -375,8 +359,7 @@ extern UINT32 HalIntNumGet(VOID);
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li
></ul>
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
@@ -521,33 +504,13 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
/**
* @ingroup los_arch_interrupt
* @brief: Exception initialization.
*
* @par Description:
* This API is used to configure the exception function vector table.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
VOID OsExcInit(VOID);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalExcSvcCall(VOID);
VOID HalHwiInit();
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
@@ -681,19 +644,22 @@ VOID HalHwiInit();
* @ingroup los_exc
* Exception information structure
*
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
* Description: Exception information saved when an exception is triggered on the Cortex-M3 platform.
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;

View File

@@ -34,7 +34,7 @@
#include "los_config.h"
#include "los_compiler.h"
#include "los_context.h"
#include "los_timer.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,8 +42,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
UINT32 HalTickStart(OS_TICK_HANDLER handler);
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -0,0 +1,98 @@
;
; Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without modification,
; are permitted provided that the following conditions are met:
;
; 1. Redistributions of source code must retain the above copyright notice, this list of
; conditions and the following disclaimer.
;
; 2. Redistributions in binary form must reproduce the above copyright notice, this list
; of conditions and the following disclaimer in the documentation and/or other materials
; provided with the distribution.
;
; 3. Neither the name of the copyright holder nor the names of its contributors may be used
; to endorse or promote products derived from this software without specific prior written
; permission.
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;
EXPORT ArchAtomicRead
EXPORT ArchAtomicSet
EXPORT ArchAtomicAdd
EXPORT ArchAtomicSub
EXPORT ArchAtomicXchg32bits
EXPORT ArchAtomicCmpXchg32bits
PRESERVE8
AREA |.text|, CODE, READONLY
THUMB
EXPORT ArchAtomicRead
EXPORT ArchAtomicSet
EXPORT ArchAtomicAdd
EXPORT ArchAtomicSub
EXPORT ArchAtomicXchg32bits
EXPORT ArchAtomicCmpXchg32bits
PRESERVE8
AREA |.text|, CODE, READONLY
THUMB
ArchAtomicRead
ldrex r1, [r0]
mov r0, r1
bx lr
ArchAtomicSet
ldrex r2, [r0]
strex r3, r1, [r0]
teq r3, #0
bne ArchAtomicSet
bx lr
ArchAtomicAdd
ldrex r2, [r0]
add r2, r2, r1
strex r3, r2, [r0]
teq r3, #0
bne ArchAtomicAdd
mov r0, r2
bx lr
ArchAtomicSub
ldrex r2, [r0]
sub r2, r2, r1
strex r3, r2, [r0]
teq r3, #0
bne ArchAtomicSub
mov r0, r2
bx lr
ArchAtomicXchg32bits
ldrex r2, [r0]
strex r3, r1, [r0]
teq r3, #0
bne ArchAtomicXchg32bits
mov r0, r2
ArchAtomicCmpXchg32bits
ldrex r3, [r0]
cmp r3, r2
bne end
strex r4, r1, [r0]
teq r4, #0
bne ArchAtomicCmpXchg32bits
end

View File

@@ -37,35 +37,28 @@
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_arch_timer.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalArchInit
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
UINT32 ret;
HalHwiInit();
ret = HalTickStart(OsTickHandler);
if (ret != LOS_OK) {
PRINT_ERR("Tick start failed!\n");
}
}
/* ****************************************************************************
Function : HalSysExit
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
while (1) {
@@ -73,27 +66,17 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
}
/* ****************************************************************************
Function : HalTskStackInit
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
topStack --- Top of task's stack
topStack --- Top of task's stack
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = NULL;
errno_t result;
/* initialize the task stack, write magic num to stack top */
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
if (result != EOK) {
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
}
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
@@ -147,14 +130,14 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(VOID)
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();

View File

@@ -31,11 +31,11 @@
PRESERVE8
EXPORT HalIntLock
EXPORT HalIntUnLock
EXPORT HalIntRestore
EXPORT ArchIntLock
EXPORT ArchIntUnLock
EXPORT ArchIntRestore
EXPORT HalStartToRun
EXPORT HalTaskSchedule
EXPORT ArchTaskSchedule
EXPORT HalPendSV
IMPORT OsSchedTaskSwitch
IMPORT g_losTask
@@ -77,21 +77,21 @@ HalStartToRun
BX R6
HalIntLock
ArchIntLock
MRS R0, PRIMASK
CPSID I
BX LR
HalIntUnLock
ArchIntUnLock
MRS R0, PRIMASK
CPSIE I
BX LR
HalIntRestore
ArchIntRestore
MSR PRIMASK, R0
BX LR
HalTaskSchedule
ArchTaskSchedule
LDR R0, =OS_NVIC_INT_CTRL
LDR R1, =OS_NVIC_PENDSVSET
STR R1, [R0]

View File

@@ -195,10 +195,10 @@ _hwiActiveCheck
RBIT R2, R3
CLZ R2, R2
AND R12, R12, #1
ADD R2, R2, R12, LSL #5 ; calculate R2 (hwi number) as uwPid
ADD R2, R2, R12, LSL #5 ; calculate R2 (hwi number) as pid
_ExcInMSP
CMP LR, #0XFFFFFFED
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}

View File

@@ -47,16 +47,16 @@ UINT32 g_intCount = 0;
#ifdef __ICCARM__
#pragma location = ".data.vector"
#elif defined(__CC_ARM) || defined(__GNUC__)
#pragma data_alignment=0x100
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
LITE_OS_SEC_VEC
#endif
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
@@ -65,7 +65,7 @@ typedef struct {
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
@@ -108,18 +108,86 @@ WEAK VOID SysTick_Handler(VOID)
}
/* ****************************************************************************
Function : HalIntNumGet
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
inline UINT32 HalIsIntActive(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
@@ -133,18 +201,19 @@ inline UINT32 HalIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HalIntNumGet();
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
@@ -168,13 +237,13 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
g_intCount++;
LOS_IntRestore(intSave);
hwiIndex = HalIntNumGet();
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
@@ -194,25 +263,26 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
/* ****************************************************************************
Function : HalHwiCreate
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -229,13 +299,18 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
intSave = LOS_IntLock();
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
OsSetVector(hwiNum, handler);
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
NVIC_EnableIRQ((IRQn_Type)hwiNum);
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
@@ -243,21 +318,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
/* ****************************************************************************
Function : HalHwiDelete
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
HwiMask((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
@@ -273,6 +350,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
#define BUSFAULT (1 << 17)
#define MEMFAULT (1 << 16)
#define DIV0FAULT (1 << 4)
#define UNALIGNFAULT (1 << 3)
#define HARDFAULT_IRQN (-13)
ExcInfo g_excInfo = {0};
@@ -377,6 +455,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
@@ -393,6 +472,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
@@ -442,7 +522,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
@@ -482,7 +564,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
HalSysExit();
ArchSysExit();
}
/* ****************************************************************************
@@ -492,7 +574,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
@@ -520,8 +602,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
#else
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT);
#endif
return;
}

View File

@@ -34,38 +34,41 @@
#include "ARMCM3.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_context.h"
#include "los_sched.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = SysTick_IRQn,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 ret;
ArchTickTimer *tick = &g_archTickTimer;
if ((OS_SYS_CLOCK == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK)) {
return LOS_ERRNO_TICK_CFG_INVALID;
}
tick->freq = OS_SYS_CLOCK;
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(tick->irqNum, handler, NULL);
#else
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
OsSetVector(tick->irqNum, handler);
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
ret = SysTick_Config(LOSCFG_BASE_CORE_TICK_RESPONSE_MAX);
if (ret == 1) {
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
@@ -74,36 +77,50 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
return LOS_OK;
}
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime;
}
WEAK UINT64 HalGetTickCycle(UINT32 *period)
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle;
UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL;
if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave);
return (UINT64)hwCycle;
}
WEAK VOID HalTickLock(VOID)
STATIC VOID SysTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
WEAK VOID HalTickUnlock(VOID)
STATIC VOID SysTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
UINT32 HalEnterSleep(VOID)
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
__DSB();
__WFI();

View File

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

View File

@@ -27,9 +27,10 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/config.gni")
import("//kernel/liteos_m/liteos.gni")
static_library("arch") {
module_name = "arch"
kernel_module(module_name) {
sources = [
"los_context.c",
"los_dispatch.S",
@@ -37,6 +38,9 @@ static_library("arch") {
"los_interrupt.c",
"los_timer.c",
]
configs += [ "$LITEOSTOPDIR:los_config" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@@ -0,0 +1,296 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
INT32 val;
__asm__ __volatile__("ldrex %0, [%1]\n"
: "=&r"(val)
: "r"(v)
: "cc");
return val;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 status;
do {
__asm__ __volatile__("ldrex %0, [%1]\n"
"strex %0, %2, [%1]\n"
: "=&r"(status)
: "r"(v), "r"(setVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"add %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(addVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"sub %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(subVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable
* and return the previous value of the atomic variable.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The exchange value.
*
* @retval #INT32 The previous value of the atomic variable
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, [%3]\n"
"strex %1, %4, [%3]"
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
: "r"(v), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal;
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable with compare.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The new value.
* @param oldVal [IN] The old value.
*
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, %2\n"
"mov %1, #0\n"
"cmp %0, %3\n"
"bne 1f\n"
"strex %1, %4, %2\n"
"1:"
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
: "r"(oldVal), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
@@ -309,7 +312,7 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Get an interrupt number.
*
* @par Description:
* This API is used to get the current interrupt number.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval: Interrupt Indexes number.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern UINT32 HalIntNumGet(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
@@ -375,8 +359,7 @@ extern UINT32 HalIntNumGet(VOID);
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li
></ul>
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
@@ -521,33 +504,13 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
/**
* @ingroup los_arch_interrupt
* @brief: Exception initialization.
*
* @par Description:
* This API is used to configure the exception function vector table.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
VOID OsExcInit(VOID);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalSVCHandler(VOID);
VOID HalHwiInit();
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
@@ -681,19 +644,22 @@ VOID HalHwiInit();
* @ingroup los_exc
* Exception information structure
*
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;

View File

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

View File

@@ -36,35 +36,28 @@
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_arch_timer.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalArchInit
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
UINT32 ret;
HalHwiInit();
ret = HalTickStart(OsTickHandler);
if (ret != LOS_OK) {
PRINT_ERR("Tick start failed!\n");
}
}
/* ****************************************************************************
Function : HalSysExit
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
while (1) {
@@ -72,27 +65,17 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
}
/* ****************************************************************************
Function : HalTskStackInit
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
topStack --- Top of task's stack
topStack --- Top of task's stack
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = NULL;
errno_t result;
/* initialize the task stack, write magic num to stack top */
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
if (result != EOK) {
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
}
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
@@ -146,14 +129,29 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(VOID)
#if (LOSCFG_KERNEL_SIGNAL == 1)
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
{
UNUSED(stackTop);
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
context->uwR0 = param;
context->uwPC = sigHandler;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
return (VOID *)context;
}
#endif
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();

View File

@@ -47,6 +47,15 @@
.section .text
.thumb
.macro SIGNAL_CONTEXT_RESTORE
push {r12, lr}
blx OsSignalTaskContextRestore
pop {r12, lr}
cmp r0, #0
mov r1, r0
bne SignalContextRestore
.endm
.type HalStartToRun, %function
.global HalStartToRun
HalStartToRun:
@@ -90,13 +99,11 @@ __DisabledFPU:
MOV lr, r5
cpsie I
BX r6
.fnend
.type HalIntLock, %function
.global HalIntLock
HalIntLock:
.type ArchIntLock, %function
.global ArchIntLock
ArchIntLock:
.fnstart
.cantunwind
@@ -105,9 +112,9 @@ HalIntLock:
BX LR
.fnend
.type HalIntUnLock, %function
.global HalIntUnLock
HalIntUnLock:
.type ArchIntUnLock, %function
.global ArchIntUnLock
ArchIntUnLock:
.fnstart
.cantunwind
@@ -116,9 +123,9 @@ HalIntUnLock:
BX LR
.fnend
.type HalIntRestore, %function
.global HalIntRestore
HalIntRestore:
.type ArchIntRestore, %function
.global ArchIntRestore
ArchIntRestore:
.fnstart
.cantunwind
@@ -126,9 +133,9 @@ HalIntRestore:
BX LR
.fnend
.type HalTaskSchedule, %function
.global HalTaskSchedule
HalTaskSchedule:
.type ArchTaskSchedule, %function
.global ArchTaskSchedule
ArchTaskSchedule:
.fnstart
.cantunwind
@@ -140,9 +147,6 @@ HalTaskSchedule:
bx lr
.fnend
.type HalPendSV, %function
.global HalPendSV
HalPendSV:
@@ -153,6 +157,8 @@ HalPendSV:
cpsid I
HalTaskSwitch:
SIGNAL_CONTEXT_RESTORE
push {r12, lr}
blx OsSchedTaskSwitch
pop {r12, lr}
@@ -182,9 +188,11 @@ __DisabledFPU1:
ldr r0, [r5, #4]
str r0, [r5]
ldr r1, [r0]
SignalContextRestore:
ldr.w r3, =OS_FPU_CPACR
ldr r3, [r3]
and r3, r3, #OS_FPU_CPACR_ENABLE
cmp r3, #OS_FPU_CPACR_ENABLE
bne __DisabledFPU2
@@ -193,9 +201,7 @@ __DisabledFPU1:
__DisabledFPU2:
ldmfd r1!, {r4-r12}
msr psp, r1
msr PRIMASK, r12
bx lr
.fnend

View File

@@ -268,7 +268,7 @@ _hwiActiveCheck:
RBIT R2, R3
CLZ R2, R2
AND R12, R12, #1
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as uwPid
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as pid
.fnend
.type _ExcInMSP, %function
@@ -276,16 +276,13 @@ _hwiActiveCheck:
_ExcInMSP:
.fnstart
.cantunwind
CMP LR, #0XFFFFFFED
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
VPUSH {D8-D15}
#endif
B _handleEntry
.fnend
@@ -324,7 +321,7 @@ _hwiActiveCheckNext:
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch
@@ -337,14 +334,11 @@ _hwiActiveCheckNext:
MRS R3, PSP
ADD R12, R3, #104
PUSH {R12} // save task SP
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
VPUSH {D8-D15}
#endif
// copy auto saved task register
@@ -360,12 +354,12 @@ _hwiActiveCheckNext:
_NoFloatInPsp:
.fnstart
.cantunwind
MOV R2, R13 //no auto push floating registers
MOV R2, R13 // no auto push floating registers
SUB R13, #32 // add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #32
PUSH {R12} // save task SP
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}

View File

@@ -40,6 +40,7 @@
#include "los_memory.h"
#include "los_membox.h"
#define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
@@ -47,11 +48,11 @@ UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
@@ -60,7 +61,7 @@ typedef struct {
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
@@ -98,18 +99,86 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
#endif
/* ****************************************************************************
Function : HalIntNumGet
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
inline UINT32 HalIsIntActive(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
@@ -123,18 +192,19 @@ inline UINT32 HalIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HalIntNumGet();
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
@@ -158,13 +228,13 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
g_intCount++;
LOS_IntRestore(intSave);
hwiIndex = HalIntNumGet();
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
@@ -184,25 +254,26 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
/* ****************************************************************************
Function : HalHwiCreate
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -219,13 +290,18 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
intSave = LOS_IntLock();
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
OsSetVector(hwiNum, handler);
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
NVIC_EnableIRQ((IRQn_Type)hwiNum);
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
@@ -233,21 +309,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
/* ****************************************************************************
Function : HalHwiDelete
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
HwiMask((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
@@ -263,6 +341,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
#define BUSFAULT (1 << 17)
#define MEMFAULT (1 << 16)
#define DIV0FAULT (1 << 4)
#define UNALIGNFAULT (1 << 3)
#define HARDFAULT_IRQN (-13)
ExcInfo g_excInfo = {0};
@@ -367,6 +446,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
@@ -383,6 +463,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
@@ -432,7 +513,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
@@ -472,7 +555,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
HalSysExit();
ArchSysExit();
}
/* ****************************************************************************
@@ -482,13 +565,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = 0; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) {
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
@@ -510,8 +593,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
#else
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT);
#endif
return;
}

View File

@@ -33,38 +33,41 @@
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_context.h"
#include "los_sched.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = SysTick_IRQn,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 ret;
ArchTickTimer *tick = &g_archTickTimer;
if ((OS_SYS_CLOCK == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK)) {
return LOS_ERRNO_TICK_CFG_INVALID;
}
tick->freq = OS_SYS_CLOCK;
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(tick->irqNum, handler, NULL);
#else
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
OsSetVector(tick->irqNum, handler);
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
ret = SysTick_Config(LOSCFG_BASE_CORE_TICK_RESPONSE_MAX);
if (ret == 1) {
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
@@ -73,36 +76,49 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
return LOS_OK;
}
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime;
}
WEAK UINT64 HalGetTickCycle(UINT32 *period)
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle;
UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL;
if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave);
return (UINT64)hwCycle;
}
WEAK VOID HalTickLock(VOID)
STATIC VOID SysTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
WEAK VOID HalTickUnlock(VOID)
STATIC VOID SysTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
UINT32 HalEnterSleep(VOID)
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
__DSB();
__WFI();

View File

@@ -27,9 +27,10 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/config.gni")
import("//kernel/liteos_m/liteos.gni")
static_library("arch") {
module_name = "arch"
kernel_module(module_name) {
sources = [
"non_secure/los_context.c",
"non_secure/los_dispatch.S",
@@ -38,11 +39,14 @@ static_library("arch") {
"non_secure/los_timer.c",
"non_secure/los_trustzone.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
include_dirs = [
"./non_secure",
"./secure",
"non_secure",
"secure",
]
configs += [ "$LITEOSTOPDIR:los_config" ]
}
config("public") {
include_dirs = [ "non_secure" ]
}

View File

@@ -0,0 +1,296 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
INT32 val;
__asm__ __volatile__("ldrex %0, [%1]\n"
: "=&r"(val)
: "r"(v)
: "cc");
return val;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 status;
do {
__asm__ __volatile__("ldrex %0, [%1]\n"
"strex %0, %2, [%1]\n"
: "=&r"(status)
: "r"(v), "r"(setVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"add %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(addVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"sub %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(subVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable
* and return the previous value of the atomic variable.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The exchange value.
*
* @retval #INT32 The previous value of the atomic variable
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, [%3]\n"
"strex %1, %4, [%3]"
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
: "r"(v), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal;
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable with compare.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The new value.
* @param oldVal [IN] The old value.
*
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, %2\n"
"mov %1, #0\n"
"cmp %0, %3\n"
"bne 1f\n"
"strex %1, %4, %2\n"
"1:"
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
: "r"(oldVal), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -43,7 +43,7 @@ extern "C" {
typedef struct TagTskContext {
UINT32 secureContext;
UINT32 stackLmit;
UINT32 stackLimit;
UINT32 excReturn;
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))

View File

@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
@@ -309,7 +312,7 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Get an interrupt number.
*
* @par Description:
* This API is used to get the current interrupt number.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval: Interrupt Indexes number.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern UINT32 HalIntNumGet(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
@@ -375,8 +359,7 @@ extern UINT32 HalIntNumGet(VOID);
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li
></ul>
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
@@ -521,33 +504,13 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
/**
* @ingroup los_arch_interrupt
* @brief: Exception initialization.
*
* @par Description:
* This API is used to configure the exception function vector table.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
VOID OsExcInit(VOID);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalSVCHandler(VOID);
VOID HalHwiInit();
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
@@ -681,19 +644,22 @@ VOID HalHwiInit();
* @ingroup los_exc
* Exception information structure
*
* Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
* Description: Exception information saved when an exception is triggered on the Cortex-M33 platform.
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;

View File

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

View File

@@ -36,35 +36,28 @@
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_arch_timer.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalArchInit
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
UINT32 ret;
HalHwiInit();
ret = HalTickStart(OsTickHandler);
if (ret != LOS_OK) {
PRINT_ERR("Tick start failed!\n");
}
}
/* ****************************************************************************
Function : HalSysExit
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
while (1) {
@@ -72,27 +65,17 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
}
/* ****************************************************************************
Function : HalTskStackInit
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
topStack --- Top of task's stack
topStack --- Top of task's stack
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = NULL;
errno_t result;
/* initialize the task stack, write magic num to stack top */
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
if (result != EOK) {
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
}
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
@@ -133,7 +116,7 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
#endif
context->secureContext = 0UL;
context->stackLmit = (UINT32)topStack;
context->stackLimit = (UINT32)topStack;
context->excReturn = 0xFFFFFFBC;
context->uwR4 = 0x04040404L;
@@ -150,14 +133,28 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(VOID)
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
{
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
context->uwR0 = param;
context->uwPC = sigHandler;
context->stackLimit = (UINT32)stackTop;
context->excReturn = 0xFFFFFFBC;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();

View File

@@ -45,6 +45,15 @@
.section .text
.thumb
.macro SIGNAL_CONTEXT_RESTORE
PUSH {R12, LR}
BLX OsSignalTaskContextRestore
POP {R12, LR}
CMP R0, #0
MOV R1, R0
BNE SignalContextRestore
.endm
.type HalStartFirstTask, %function
.global HalStartFirstTask
HalStartFirstTask:
@@ -76,9 +85,9 @@ __DisabledFPU1:
CPSIE I
BX R3
.type HalIntLock, %function
.global HalIntLock
HalIntLock:
.type ArchIntLock, %function
.global ArchIntLock
ArchIntLock:
.fnstart
.cantunwind
@@ -87,9 +96,9 @@ HalIntLock:
BX LR
.fnend
.type HalIntUnLock, %function
.global HalIntUnLock
HalIntUnLock:
.type ArchIntUnLock, %function
.global ArchIntUnLock
ArchIntUnLock:
.fnstart
.cantunwind
@@ -98,9 +107,9 @@ HalIntUnLock:
BX LR
.fnend
.type HalIntRestore, %function
.global HalIntRestore
HalIntRestore:
.type ArchIntRestore, %function
.global ArchIntRestore
ArchIntRestore:
.fnstart
.cantunwind
@@ -108,9 +117,9 @@ HalIntRestore:
BX LR
.fnend
.type HalTaskSchedule, %function
.global HalTaskSchedule
HalTaskSchedule:
.type ArchTaskSchedule, %function
.global ArchTaskSchedule
ArchTaskSchedule:
.fnstart
.cantunwind
@@ -132,6 +141,8 @@ HalPendSV:
cpsid I
HalTaskSwitch:
SIGNAL_CONTEXT_RESTORE
push {r12, lr}
blx OsSchedTaskSwitch
pop {r12, lr}
@@ -175,8 +186,9 @@ __DisabledFPU2:
LDR R0, [R5, #4]
STR R0, [R5]
LDR R1, [R0]
SignalContextRestore:
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
MSR PSPLIM, R2
MOV LR, R3
@@ -205,7 +217,7 @@ __DisabledFPU3:
.fnend
.type HalSVCStartSchedule, %function
.global HalSVCStartSchedule
.global HalSVCStartSchedule
HalSVCStartSchedule:
.fnstart
.cantunwind
@@ -219,7 +231,7 @@ HalSVCStartSchedule:
.fnend
.type HalSVCSecureContextAlloc, %function
.global HalSVCSecureContextAlloc
.global HalSVCSecureContextAlloc
HalSVCSecureContextAlloc:
.fnstart
.cantunwind
@@ -228,7 +240,7 @@ HalSVCSecureContextAlloc:
.fnend
.type HalSVCSecureContextFree, %function
.global HalSVCSecureContextFree
.global HalSVCSecureContextFree
HalSVCSecureContextFree:
.fnstart
.cantunwind
@@ -237,7 +249,7 @@ HalSVCSecureContextFree:
.fnend
.type HalSVCHandler, %function
.global HalSVCHandler
.global HalSVCHandler
HalSVCHandler:
.fnstart
.cantunwind

View File

@@ -252,7 +252,7 @@ _hwiActiveCheck:
RBIT R2, R3
CLZ R2, R2
AND R12, R12, #1
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as uwPid
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as pid
.fnend
.type _ExcInMSP, %function
@@ -260,16 +260,13 @@ _hwiActiveCheck:
_ExcInMSP:
.fnstart
.cantunwind
CMP LR, #0XFFFFFFED
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
VPUSH {D8-D15}
#endif
B _handleEntry
.fnend
@@ -308,7 +305,7 @@ _hwiActiveCheckNext:
LDR R2, =g_taskScheduled
LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE
TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch
@@ -321,14 +318,11 @@ _hwiActiveCheckNext:
MRS R3, PSP
ADD R12, R3, #104
PUSH {R12} // save task SP
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
VPUSH {D8-D15}
#endif
// copy auto saved task register
@@ -344,12 +338,12 @@ _hwiActiveCheckNext:
_NoFloatInPsp:
.fnstart
.cantunwind
MOV R2, R13 //no auto push floating registers
MOV R2, R13 // no auto push floating registers
SUB R13, #32 // add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #32
PUSH {R12} // save task SP
PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}

View File

@@ -40,6 +40,7 @@
#include "los_memory.h"
#include "los_membox.h"
#define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
@@ -47,11 +48,11 @@ UINT32 g_intCount = 0;
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
@@ -60,7 +61,7 @@ typedef struct {
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
@@ -98,18 +99,86 @@ VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
#endif
/* ****************************************************************************
Function : HalIntNumGet
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
inline UINT32 HalIsIntActive(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
@@ -123,18 +192,19 @@ inline UINT32 HalIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HalIntNumGet();
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
@@ -158,13 +228,13 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
g_intCount++;
LOS_IntRestore(intSave);
hwiIndex = HalIntNumGet();
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
@@ -184,25 +254,26 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
/* ****************************************************************************
Function : HalHwiCreate
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -219,13 +290,18 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
intSave = LOS_IntLock();
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
OsSetVector(hwiNum, handler);
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
NVIC_EnableIRQ((IRQn_Type)hwiNum);
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
@@ -233,14 +309,16 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
/* ****************************************************************************
Function : HalHwiDelete
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -263,6 +341,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
#define BUSFAULT (1 << 17)
#define MEMFAULT (1 << 16)
#define DIV0FAULT (1 << 4)
#define UNALIGNFAULT (1 << 3)
#define HARDFAULT_IRQN (-13)
ExcInfo g_excInfo = {0};
@@ -367,6 +446,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
@@ -383,6 +463,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
@@ -432,7 +513,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
@@ -472,7 +555,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
HalSysExit();
ArchSysExit();
}
/* ****************************************************************************
@@ -482,13 +565,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = 0; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) {
for (index = DEF_HANDLER_START_INDEX; index < OS_VECTOR_CNT; index++) {
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
@@ -510,8 +593,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
#else
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT);
#endif
return;
}

View File

@@ -33,38 +33,40 @@
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_context.h"
#include "los_sched.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = SysTick_IRQn,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 ret;
ArchTickTimer *tick = &g_archTickTimer;
if ((OS_SYS_CLOCK == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK)) {
return LOS_ERRNO_TICK_CFG_INVALID;
}
tick->freq = OS_SYS_CLOCK;
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(tick->irqNum, handler, NULL);
#else
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
OsSetVector(tick->irqNum, handler);
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
ret = SysTick_Config(g_cyclesPerTick);
if (ret == 1) {
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
@@ -73,36 +75,49 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
return LOS_OK;
}
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime;
}
WEAK UINT64 HalGetTickCycle(UINT32 *period)
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle;
UINT32 hwCycle = 0
UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL;
if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave);
return (UINT64)hwCycle;
}
WEAK VOID HalTickLock(VOID)
STATIC VOID SysTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
WEAK VOID HalTickUnlock(VOID)
STATIC VOID SysTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
UINT32 HalEnterSleep(VOID)
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
__DSB();
__WFI();

View File

@@ -0,0 +1,296 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
INT32 val;
asm volatile("ldrex %0, [%1]\n"
: "=&r"(val)
: "r"(v)
: "cc");
return val;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 status;
do {
asm volatile("ldrex %0, [%1]\n"
"strex %0, %2, [%1]\n"
: "=&r"(status)
: "r"(v), "r"(setVal)
: "cc");
} while (status != 0);
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 status;
do {
asm volatile("ldrex %1, [%2]\n"
"add %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(addVal)
: "cc");
} while (status != 0);
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 status;
do {
asm volatile("ldrex %1, [%2]\n"
"sub %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(subVal)
: "cc");
} while (status != 0);
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable
* and return the previous value of the atomic variable.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The exchange value.
*
* @retval #INT32 The previous value of the atomic variable
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
asm volatile("ldrex %0, [%2]\n"
"strex %1, %3, [%2]"
: "=&r"(prevVal), "=&r"(status)
: "r"(v), "r"(val)
: "cc");
} while (status != 0);
return prevVal;
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable with compare.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The new value.
* @param oldVal [IN] The old value.
*
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
asm volatile("ldrex %0, [%2]\n"
"mov %1, #0\n"
"cmp %0, %3\n"
"bne 1f\n"
"strex %1, %4, [%2]\n"
"1:"
: "=&r"(prevVal), "=&r"(status)
: "r"(v), "r"(oldVal), "r"(val)
: "cc");
} while (status != 0);
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
@@ -309,7 +312,7 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Set interrupt vector table.
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_hwi
* @brief: Get an interrupt number.
*
* @par Description:
* This API is used to get the current interrupt number.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval: Interrupt Indexes number.
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern UINT32 HalIntNumGet(VOID);
/* *
* @ingroup los_hwi
* @brief: Default vector handling function.
@@ -521,33 +505,13 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
/**
* @ingroup los_hwi
* @brief: Exception initialization.
*
* @par Description:
* This API is used to configure the exception function vector table.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
VOID OsExcInit(VOID);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalSVCHandler(VOID);
VOID HalHwiInit();
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
@@ -685,15 +649,18 @@ VOID HalHwiInit();
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;

View File

@@ -34,7 +34,7 @@
#include "los_config.h"
#include "los_compiler.h"
#include "los_context.h"
#include "los_timer.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,8 +42,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
UINT32 HalTickStart(OS_TICK_HANDLER handler);
#ifdef __cplusplus
#if __cplusplus
}
@@ -51,3 +49,4 @@ UINT32 HalTickStart(OS_TICK_HANDLER handler);
#endif /* __cplusplus */
#endif /* _LOS_ARCH_TIMER_H */

View File

@@ -36,35 +36,28 @@
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_arch_timer.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalArchInit
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
UINT32 ret;
HalHwiInit();
ret = HalTickStart(OsTickHandler);
if (ret != LOS_OK) {
PRINT_ERR("Tick start failed!\n");
}
}
/* ****************************************************************************
Function : HalSysExit
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
while (1) {
@@ -72,7 +65,7 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
}
/* ****************************************************************************
Function : HalTskStackInit
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
@@ -80,19 +73,9 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = NULL;
errno_t result;
/* initialize the task stack, write magic num to stack top */
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
if (result != EOK) {
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
}
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
@@ -146,14 +129,27 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(VOID)
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
{
UNUSED(stackTop);
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
context->uwR0 = param;
context->uwPC = sigHandler;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();

View File

@@ -31,13 +31,14 @@
PRESERVE8
EXPORT HalIntLock
EXPORT HalIntUnLock
EXPORT HalIntRestore
EXPORT ArchIntLock
EXPORT ArchIntUnLock
EXPORT ArchIntRestore
EXPORT HalStartToRun
EXPORT HalTaskSchedule
EXPORT ArchTaskSchedule
EXPORT HalPendSV
IMPORT OsSchedTaskSwitch
IMPORT OsSignalTaskContextRestore
IMPORT g_losTask
OS_FPU_CPACR EQU 0xE000ED88
@@ -52,6 +53,15 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
THUMB
REQUIRE8
MACRO SIGNAL_CONTEXT_RESTORE
PUSH {R12, LR}
BLX OsSignalTaskContextRestore
POP {R12, LR}
CMP R0, #0
MOV R1, R0
BNE SignalContextRestore
ENDM
HalStartToRun
LDR R4, =OS_NVIC_SYSPRI2
LDR R5, =OS_NVIC_PENDSV_PRI
@@ -90,21 +100,21 @@ __DisabledFPU
BX R6
HalIntLock
ArchIntLock
MRS R0, PRIMASK
CPSID I
BX LR
HalIntUnLock
ArchIntUnLock
MRS R0, PRIMASK
CPSIE I
BX LR
HalIntRestore
ArchIntRestore
MSR PRIMASK, R0
BX LR
HalTaskSchedule
ArchTaskSchedule
LDR R0, =OS_NVIC_INT_CTRL
LDR R1, =OS_NVIC_PENDSVSET
STR R1, [R0]
@@ -145,8 +155,11 @@ __DisabledFPU1
LDR R0, [R5, #4]
STR R0, [R5]
LDR R1, [R0]
SignalContextRestore
LDR.W R3, =OS_FPU_CPACR
LDR R3, [R3]
AND R3, R3, #OS_FPU_CPACR_ENABLE
CMP R3, #OS_FPU_CPACR_ENABLE
BNE __DisabledFPU2

View File

@@ -198,7 +198,7 @@ _hwiActiveCheck
ADD R2, R2, R12, LSL #5 ; calculate R2 (hwi number) as uwPid
_ExcInMSP
CMP LR, #0XFFFFFFED
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}

View File

@@ -46,14 +46,14 @@ UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment=0x100
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
@@ -105,18 +105,86 @@ WEAK VOID SysTick_Handler(VOID)
}
/* ****************************************************************************
Function : HalIntNumGet
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
inline UINT32 HalIsIntActive(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
@@ -130,18 +198,19 @@ inline UINT32 HalIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HalIntNumGet();
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
@@ -167,13 +236,13 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
hwiIndex = HalIntNumGet();
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
@@ -193,25 +262,26 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
/* ****************************************************************************
Function : HalHwiCreate
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINTPTR intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -228,13 +298,18 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
intSave = LOS_IntLock();
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
OsSetVector(hwiNum, handler);
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
NVIC_EnableIRQ((IRQn_Type)hwiNum);
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
@@ -242,14 +317,16 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
/* ****************************************************************************
Function : HalHwiDelete
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -376,6 +453,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
@@ -392,6 +470,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
@@ -441,7 +520,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
@@ -481,7 +562,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
HalSysExit();
ArchSysExit();
}
/* ****************************************************************************
@@ -491,7 +572,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;

View File

@@ -33,38 +33,41 @@
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_context.h"
#include "los_sched.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = SysTick_IRQn,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 ret;
ArchTickTimer *tick = &g_archTickTimer;
if ((OS_SYS_CLOCK == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK)) {
return LOS_ERRNO_TICK_CFG_INVALID;
}
tick->freq = OS_SYS_CLOCK;
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(tick->irqNum, handler, NULL);
#else
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
OsSetVector(tick->irqNum, handler);
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
ret = SysTick_Config(LOSCFG_BASE_CORE_TICK_RESPONSE_MAX);
if (ret == 1) {
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
@@ -73,40 +76,51 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
return LOS_OK;
}
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime;
}
WEAK UINT64 HalGetTickCycle(UINT32 *period)
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle;
UINT32 hwCycle = 0;
UINTPTR intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL;
if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave);
return (UINT64)hwCycle;
}
WEAK VOID HalTickLock(VOID)
STATIC VOID SysTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
WEAK VOID HalTickUnlock(VOID)
STATIC VOID SysTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
UINT32 HalEnterSleep(VOID)
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
__DSB();
__WFI();
__ISB();
return LOS_OK;
}

View File

@@ -0,0 +1,296 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
INT32 val;
asm volatile("ldrex %0, [%1]\n"
: "=&r"(val)
: "r"(v)
: "cc");
return val;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 status;
do {
asm volatile("ldrex %0, [%1]\n"
"strex %0, %2, [%1]\n"
: "=&r"(status)
: "r"(v), "r"(setVal)
: "cc");
} while (status != 0);
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 status;
do {
asm volatile("ldrex %1, [%2]\n"
"add %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(addVal)
: "cc");
} while (status != 0);
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 status;
do {
asm volatile("ldrex %1, [%2]\n"
"sub %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(subVal)
: "cc");
} while (status != 0);
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable
* and return the previous value of the atomic variable.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The exchange value.
*
* @retval #INT32 The previous value of the atomic variable
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
asm volatile("ldrex %0, [%2]\n"
"strex %1, %3, [%2]"
: "=&r"(prevVal), "=&r"(status)
: "r"(v), "r"(val)
: "cc");
} while (status != 0);
return prevVal;
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable with compare.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The new value.
* @param oldVal [IN] The old value.
*
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
asm volatile("ldrex %0, [%2]\n"
"mov %1, #0\n"
"cmp %0, %3\n"
"bne 1f\n"
"strex %1, %4, [%2]\n"
"1:"
: "=&r"(prevVal), "=&r"(status)
: "r"(v), "r"(oldVal), "r"(val)
: "cc");
} while (status != 0);
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M33 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M33 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
@@ -309,7 +312,7 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_hwi
* Set interrupt vector table.
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_hwi
* @brief: Get an interrupt number.
*
* @par Description:
* This API is used to get the current interrupt number.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval: Interrupt Indexes number.
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern UINT32 HalIntNumGet(VOID);
/* *
* @ingroup los_hwi
* @brief: Default vector handling function.
@@ -521,33 +505,13 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
/**
* @ingroup los_hwi
* @brief: Exception initialization.
*
* @par Description:
* This API is used to configure the exception function vector table.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
VOID OsExcInit(VOID);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalSVCHandler(VOID);
VOID HalHwiInit();
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
@@ -685,15 +649,18 @@ VOID HalHwiInit();
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;

View File

@@ -34,7 +34,7 @@
#include "los_config.h"
#include "los_compiler.h"
#include "los_context.h"
#include "los_timer.h"
#ifdef __cplusplus
#if __cplusplus
@@ -42,8 +42,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
UINT32 HalTickStart(OS_TICK_HANDLER handler);
#ifdef __cplusplus
#if __cplusplus
}
@@ -51,3 +49,4 @@ UINT32 HalTickStart(OS_TICK_HANDLER handler);
#endif /* __cplusplus */
#endif /* _LOS_ARCH_TIMER_H */

View File

@@ -36,35 +36,28 @@
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
#include "los_arch_timer.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalArchInit
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalArchInit(VOID)
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
UINT32 ret;
HalHwiInit();
ret = HalTickStart(OsTickHandler);
if (ret != LOS_OK) {
PRINT_ERR("Tick start failed!\n");
}
}
/* ****************************************************************************
Function : HalSysExit
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
while (1) {
@@ -72,7 +65,7 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
}
/* ****************************************************************************
Function : HalTskStackInit
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
@@ -80,19 +73,9 @@ LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = NULL;
errno_t result;
/* initialize the task stack, write magic num to stack top */
result = memset_s(topStack, stackSize, (INT32)(OS_TASK_STACK_INIT & 0xFF), stackSize);
if (result != EOK) {
printf("memset_s is failed:%s[%d]\r\n", __FUNCTION__, __LINE__);
}
*((UINT32 *)(topStack)) = OS_TASK_MAGIC_WORD;
context = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
@@ -150,14 +133,28 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)HalSysExit;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(VOID)
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
{
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
context->uwR0 = param;
context->uwPC = sigHandler;
context->stackLimit = (UINT32)stackTop;
context->excReturn = 0xFFFFFFBC;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();

View File

@@ -31,17 +31,17 @@
PRESERVE8
EXPORT HalIntLock
EXPORT HalIntUnLock
EXPORT HalIntRestore
EXPORT HalTaskSchedule
EXPORT ArchIntLock
EXPORT ArchIntUnLock
EXPORT ArchIntRestore
EXPORT ArchTaskSchedule
EXPORT HalPendSV
EXPORT HalSVCHandler
EXPORT HalStartFirstTask
EXPORT HalSVCStartSchedule
EXPORT HalSVCSecureContextAlloc
EXPORT HalSVCSecureContextFree
IMPORT OsSignalTaskContextRestore
IMPORT OsSchedTaskSwitch
IMPORT g_losTask
@@ -62,6 +62,15 @@ OS_TASK_STATUS_RUNNING EQU 0x0010
THUMB
REQUIRE8
MACRO SIGNAL_CONTEXT_RESTORE
PUSH {R12, LR}
BLX OsSignalTaskContextRestore
POP {R12, LR}
CMP R0, #0
MOV R1, R0
BNE SignalContextRestore
ENDM
HalStartFirstTask
MOV R0, #2
MSR CONTROL, R0
@@ -91,21 +100,21 @@ __DisabledFPU1
CPSIE I
BX R3
HalIntLock
ArchIntLock
MRS R0, PRIMASK
CPSID I
BX LR
HalIntUnLock
ArchIntUnLock
MRS R0, PRIMASK
CPSIE I
BX LR
HalIntRestore
ArchIntRestore
MSR PRIMASK, R0
BX LR
HalTaskSchedule
ArchTaskSchedule
LDR R0, =OS_NVIC_INT_CTRL
LDR R1, =OS_NVIC_PENDSVSET
STR R1, [R0]
@@ -118,6 +127,8 @@ HalPendSV
CPSID I
HalTaskSwitch
SIGNAL_CONTEXT_RESTORE
PUSH {R12, LR}
BLX OsSchedTaskSwitch
POP {R12, LR}
@@ -161,8 +172,9 @@ __DisabledFPU2
LDR R0, [R5, #4]
STR R0, [R5]
LDR R1, [R0]
SignalContextRestore
LDMIA R1!, {R0, R2-R3} /* Restore secureContext, PSPLIM and LR from the current task stack. */
MSR PSPLIM, R2
MOV LR, R3

View File

@@ -184,10 +184,10 @@ _hwiActiveCheck
RBIT R2, R3
CLZ R2, R2
AND R12, R12, #1
ADD R2, R2, R12, LSL #5 ; calculate R2 (hwi number) as uwPid
ADD R2, R2, R12, LSL #5 ; calculate R2 (hwi number) as pid
_ExcInMSP
CMP LR, #0XFFFFFFED
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}

View File

@@ -46,14 +46,14 @@ UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment=0x100
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
@@ -105,18 +105,86 @@ WEAK VOID SysTick_Handler(VOID)
}
/* ****************************************************************************
Function : HalIntNumGet
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
inline UINT32 HalIsIntActive(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
@@ -130,18 +198,19 @@ inline UINT32 HalIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HalIntNumGet();
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
@@ -167,13 +236,13 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
LOS_IntRestore(intSave);
hwiIndex = HalIntNumGet();
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
@@ -193,25 +262,26 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
/* ****************************************************************************
Function : HalHwiCreate
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINTPTR intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -228,13 +298,18 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
intSave = LOS_IntLock();
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
OsSetVector(hwiNum, handler);
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
NVIC_EnableIRQ((IRQn_Type)hwiNum);
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
@@ -242,14 +317,16 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
/* ****************************************************************************
Function : HalHwiDelete
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
@@ -376,6 +453,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
@@ -392,6 +470,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
@@ -441,7 +520,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
@@ -481,7 +562,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
HalSysExit();
ArchSysExit();
}
/* ****************************************************************************
@@ -491,7 +572,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;

View File

@@ -33,38 +33,41 @@
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_context.h"
#include "los_sched.h"
#include "los_debug.h"
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = SysTick_IRQn,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 ret;
ArchTickTimer *tick = &g_archTickTimer;
if ((OS_SYS_CLOCK == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND == 0) ||
(LOSCFG_BASE_CORE_TICK_PER_SECOND > OS_SYS_CLOCK)) {
return LOS_ERRNO_TICK_CFG_INVALID;
}
tick->freq = OS_SYS_CLOCK;
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler, NULL);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(tick->irqNum, handler, NULL);
#else
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
OsSetVector(tick->irqNum, handler);
#endif
#endif
g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
ret = SysTick_Config(LOSCFG_BASE_CORE_TICK_RESPONSE_MAX);
if (ret == 1) {
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
@@ -73,39 +76,53 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
return LOS_OK;
}
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime;
}
WEAK UINT64 HalGetTickCycle(UINT32 *period)
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle;
UINT32 hwCycle = 0;
UINTPTR intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;
hwCycle = *period - SysTick->VAL;
if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave);
return (UINT64)hwCycle;
}
WEAK VOID HalTickLock(VOID)
STATIC VOID SysTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
WEAK VOID HalTickUnlock(VOID)
STATIC VOID SysTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
UINT32 HalEnterSleep(VOID)
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
__DSB();
__WFI();
__ISB();
return LOS_OK;
}

View File

@@ -27,9 +27,10 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/config.gni")
import("//kernel/liteos_m/liteos.gni")
static_library("arch") {
module_name = "arch"
kernel_module(module_name) {
sources = [
"los_context.c",
"los_dispatch.S",
@@ -38,6 +39,9 @@ static_library("arch") {
"los_mpu.c",
"los_timer.c",
]
configs += [ "$LITEOSTOPDIR:los_config" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@@ -0,0 +1,296 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_ARCH_ATOMIC_H
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
STATIC INLINE INT32 ArchAtomicRead(const Atomic *v)
{
INT32 val;
__asm__ __volatile__("ldrex %0, [%1]\n"
: "=&r"(val)
: "r"(v)
: "cc");
return val;
}
STATIC INLINE VOID ArchAtomicSet(Atomic *v, INT32 setVal)
{
UINT32 status;
do {
__asm__ __volatile__("ldrex %0, [%1]\n"
"strex %0, %2, [%1]\n"
: "=&r"(status)
: "r"(v), "r"(setVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
}
STATIC INLINE INT32 ArchAtomicAdd(Atomic *v, INT32 addVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"add %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(addVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE INT32 ArchAtomicSub(Atomic *v, INT32 subVal)
{
INT32 val;
UINT32 status;
do {
__asm__ __volatile__("ldrex %1, [%2]\n"
"sub %1, %1, %3\n"
"strex %0, %1, [%2]"
: "=&r"(status), "=&r"(val)
: "r"(v), "r"(subVal)
: "cc");
} while (__builtin_expect(status != 0, 0));
return val;
}
STATIC INLINE VOID ArchAtomicInc(Atomic *v)
{
(VOID)ArchAtomicAdd(v, 1);
}
STATIC INLINE VOID ArchAtomicDec(Atomic *v)
{
(VOID)ArchAtomicSub(v, 1);
}
STATIC INLINE INT32 ArchAtomicIncRet(Atomic *v)
{
return ArchAtomicAdd(v, 1);
}
STATIC INLINE INT32 ArchAtomicDecRet(Atomic *v)
{
return ArchAtomicSub(v, 1);
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable
* and return the previous value of the atomic variable.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The exchange value.
*
* @retval #INT32 The previous value of the atomic variable
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE INT32 ArchAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, [%3]\n"
"strex %1, %4, [%3]"
: "=&r"(prevVal), "=&r"(status), "+m"(*v)
: "r"(v), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal;
}
/**
* @ingroup los_arch_atomic
* @brief Atomic exchange for 32-bit variable with compare.
*
* @par Description:
* This API is used to implement the atomic exchange for 32-bit variable, if the value of variable is equal to oldVal.
* @attention
* <ul>The pointer v must not be NULL.</ul>
*
* @param v [IN] The variable pointer.
* @param val [IN] The new value.
* @param oldVal [IN] The old value.
*
* @retval TRUE The previous value of the atomic variable is not equal to oldVal.
* @retval FALSE The previous value of the atomic variable is equal to oldVal.
* @par Dependency:
* <ul><li>los_arch_atomic.h: the header file that contains the API declaration.</li></ul>
* @see
*/
STATIC INLINE BOOL ArchAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
INT32 prevVal = 0;
UINT32 status = 0;
do {
__asm__ __volatile__("ldrex %0, %2\n"
"mov %1, #0\n"
"cmp %0, %3\n"
"bne 1f\n"
"strex %1, %4, %2\n"
"1:"
: "=&r"(prevVal), "=&r"(status), "+Q"(*v)
: "r"(oldVal), "r"(val)
: "cc");
} while (__builtin_expect(status != 0, 0));
return prevVal != oldVal;
}
STATIC INLINE INT64 ArchAtomic64Read(const Atomic64 *v)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Set(Atomic64 *v, INT64 setVal)
{
UINT32 intSave;
intSave = LOS_IntLock();
*v = setVal;
LOS_IntRestore(intSave);
}
STATIC INLINE INT64 ArchAtomic64Add(Atomic64 *v, INT64 addVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v += addVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE INT64 ArchAtomic64Sub(Atomic64 *v, INT64 subVal)
{
INT64 val;
UINT32 intSave;
intSave = LOS_IntLock();
*v -= subVal;
val = *v;
LOS_IntRestore(intSave);
return val;
}
STATIC INLINE VOID ArchAtomic64Inc(Atomic64 *v)
{
(VOID)ArchAtomic64Add(v, 1);
}
STATIC INLINE INT64 ArchAtomic64IncRet(Atomic64 *v)
{
return ArchAtomic64Add(v, 1);
}
STATIC INLINE VOID ArchAtomic64Dec(Atomic64 *v)
{
(VOID)ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomic64DecRet(Atomic64 *v)
{
return ArchAtomic64Sub(v, 1);
}
STATIC INLINE INT64 ArchAtomicXchg64bits(Atomic64 *v, INT64 val)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
*v = val;
LOS_IntRestore(intSave);
return prevVal;
}
STATIC INLINE BOOL ArchAtomicCmpXchg64bits(Atomic64 *v, INT64 val, INT64 oldVal)
{
INT64 prevVal;
UINT32 intSave;
intSave = LOS_IntLock();
prevVal = *v;
if (prevVal == oldVal) {
*v = val;
}
LOS_IntRestore(intSave);
return prevVal != oldVal;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_ARCH_ATOMIC_H */

View File

@@ -109,7 +109,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000900
*
* Solution: Ensure that the interrupt number is valid. The value range of the interrupt number applicable for a Cortex-A7 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
* Solution: Ensure that the interrupt number is valid.
* The value range of the interrupt number applicable for a Cortex-M4 platform is [OS_USER_HWI_MIN,OS_USER_HWI_MAX].
*/
#define OS_ERRNO_HWI_NUM_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x00)
@@ -159,7 +160,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000905
*
* Solution: Ensure that the interrupt priority is valid. The value range of the interrupt priority applicable for a Cortex-A7 platform is [0,15].
* Solution: Ensure that the interrupt priority is valid.
* The value range of the interrupt priority applicable for a Cortex-M4 platform is [0,15].
*/
#define OS_ERRNO_HWI_PRIO_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x05)
@@ -169,7 +171,8 @@ extern UINT32 _BootVectors[];
*
* Value: 0x02000906
*
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or OS_HWI_MODE_FAST of which the value can be 0 or 1.
* Solution: The interrupt creation mode can be only set to OS_HWI_MODE_COMM or
* OS_HWI_MODE_FAST of which the value can be 0 or 1.
*/
#define OS_ERRNO_HWI_MODE_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_HWI, 0x06)
@@ -309,7 +312,7 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
/* *
* @ingroup los_arch_interrupt
* Set interrupt vector table.
@@ -342,25 +345,6 @@ extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
*/
extern VOID HalInterrupt(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Get an interrupt number.
*
* @par Description:
* This API is used to get the current interrupt number.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: None.
*
* @retval: Interrupt Indexes number.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern UINT32 HalIntNumGet(VOID);
/* *
* @ingroup los_arch_interrupt
* @brief: Default vector handling function.
@@ -375,8 +359,7 @@ extern UINT32 HalIntNumGet(VOID);
*
* @retval:None.
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li
></ul>
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalHwiDefaultHandler(VOID);
@@ -521,33 +504,13 @@ typedef struct TagExcContext {
typedef VOID (*EXC_PROC_FUNC)(UINT32, EXC_CONTEXT_S *);
VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr);
/**
* @ingroup los_arch_interrupt
* @brief: Exception initialization.
*
* @par Description:
* This API is used to configure the exception function vector table.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
* <ul><li>los_arch_interrupt.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
VOID OsExcInit(VOID);
VOID HalExcNMI(VOID);
VOID HalExcHardFault(VOID);
VOID HalExcMemFault(VOID);
VOID HalExcBusFault(VOID);
VOID HalExcUsageFault(VOID);
VOID HalExcSvcCall(VOID);
VOID HalHwiInit();
VOID HalHwiInit(VOID);
/**
* @ingroup los_exc
@@ -685,15 +648,18 @@ VOID HalHwiInit();
*
*/
typedef struct TagExcInfo {
/**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
/**< Exception occurrence phase: 0 means that an exception occurs in initialization,
* 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
/**< Exception type. When exceptions occur, check the numbers 1 - 21 listed above */
UINT16 type;
/**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
/**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
/**< An exception occurs in an interrupt, indicating the interrupt number.
* An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
/**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
/**< Number of nested exceptions. Currently only registered hook functions are supported
* when an exception is entered for the first time */
UINT16 nestCnt;
/**< reserve */
UINT16 reserved;

View File

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

View File

@@ -0,0 +1,158 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_context.h"
#include "securec.h"
#include "los_arch_context.h"
#include "los_arch_interrupt.h"
#include "los_task.h"
#include "los_sched.h"
#include "los_interrupt.h"
/* ****************************************************************************
Function : ArchInit
Description : arch init function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
{
HalHwiInit();
}
/* ****************************************************************************
Function : ArchSysExit
Description : Task exit function
Input : None
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
{
LOS_IntLock();
while (1) {
}
}
/* ****************************************************************************
Function : ArchTskStackInit
Description : Task stack initialization function
Input : taskID --- TaskID
stackSize --- Total size of the stack
topStack --- Top of task's stack
Output : None
Return : Context pointer
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
context->S16 = 0xAA000010;
context->S17 = 0xAA000011;
context->S18 = 0xAA000012;
context->S19 = 0xAA000013;
context->S20 = 0xAA000014;
context->S21 = 0xAA000015;
context->S22 = 0xAA000016;
context->S23 = 0xAA000017;
context->S24 = 0xAA000018;
context->S25 = 0xAA000019;
context->S26 = 0xAA00001A;
context->S27 = 0xAA00001B;
context->S28 = 0xAA00001C;
context->S29 = 0xAA00001D;
context->S30 = 0xAA00001E;
context->S31 = 0xAA00001F;
context->S0 = 0xAA000000;
context->S1 = 0xAA000001;
context->S2 = 0xAA000002;
context->S3 = 0xAA000003;
context->S4 = 0xAA000004;
context->S5 = 0xAA000005;
context->S6 = 0xAA000006;
context->S7 = 0xAA000007;
context->S8 = 0xAA000008;
context->S9 = 0xAA000009;
context->S10 = 0xAA00000A;
context->S11 = 0xAA00000B;
context->S12 = 0xAA00000C;
context->S13 = 0xAA00000D;
context->S14 = 0xAA00000E;
context->S15 = 0xAA00000F;
context->FPSCR = 0x00000000;
context->NO_NAME = 0xAA000011;
#endif
context->uwR4 = 0x04040404L;
context->uwR5 = 0x05050505L;
context->uwR6 = 0x06060606L;
context->uwR7 = 0x07070707L;
context->uwR8 = 0x08080808L;
context->uwR9 = 0x09090909L;
context->uwR10 = 0x10101010L;
context->uwR11 = 0x11111111L;
context->uwPriMask = 0;
context->uwR0 = taskID;
context->uwR1 = 0x01010101L;
context->uwR2 = 0x02020202L;
context->uwR3 = 0x03030303L;
context->uwR12 = 0x12121212L;
context->uwLR = (UINT32)(UINTPTR)ArchSysExit;
context->uwPC = (UINT32)(UINTPTR)OsTaskEntry;
context->uwxPSR = 0x01000000L;
return (VOID *)context;
}
VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandler, UINT32 param)
{
UNUSED(stackTop);
TaskContext *context = (TaskContext *)((UINTPTR)stackPointer - sizeof(TaskContext));
(VOID)memset_s((VOID *)context, sizeof(TaskContext), 0, sizeof(TaskContext));
context->uwR0 = param;
context->uwPC = sigHandler;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
return (VOID *)context;
}
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();
OsSchedStart();
HalStartToRun();
return LOS_OK; /* never return */
}

View File

@@ -30,7 +30,7 @@
*/
.syntax unified
.arch armv7e-m
.fpu fpv5-d16
.fpu fpv4-sp-d16
.thumb
.equ OS_FPU_CPACR, 0xE000ED88
@@ -44,6 +44,15 @@
.section .text
.thumb
.macro SIGNAL_CONTEXT_RESTORE
push {r12, lr}
blx OsSignalTaskContextRestore
pop {r12, lr}
cmp r0, #0
mov r1, r0
bne SignalContextRestore
.endm
.type HalStartToRun, %function
.global HalStartToRun
HalStartToRun:
@@ -88,10 +97,9 @@ __DisabledFPU:
.fnend
.type HalIntLock, %function
.global HalIntLock
HalIntLock:
.type ArchIntLock, %function
.global ArchIntLock
ArchIntLock:
.fnstart
.cantunwind
@@ -100,9 +108,9 @@ HalIntLock:
BX LR
.fnend
.type HalIntUnLock, %function
.global HalIntUnLock
HalIntUnLock:
.type ArchIntUnLock, %function
.global ArchIntUnLock
ArchIntUnLock:
.fnstart
.cantunwind
@@ -111,9 +119,9 @@ HalIntUnLock:
BX LR
.fnend
.type HalIntRestore, %function
.global HalIntRestore
HalIntRestore:
.type ArchIntRestore, %function
.global ArchIntRestore
ArchIntRestore:
.fnstart
.cantunwind
@@ -121,9 +129,9 @@ HalIntRestore:
BX LR
.fnend
.type HalTaskSchedule, %function
.global HalTaskSchedule
HalTaskSchedule:
.type ArchTaskSchedule, %function
.global ArchTaskSchedule
ArchTaskSchedule:
.fnstart
.cantunwind
@@ -135,9 +143,6 @@ HalTaskSchedule:
isb
.fnend
.type HalPendSV, %function
.global HalPendSV
HalPendSV:
@@ -148,6 +153,8 @@ HalPendSV:
cpsid I
HalTaskSwitch:
SIGNAL_CONTEXT_RESTORE
push {r12, lr}
blx OsSchedTaskSwitch
pop {r12, lr}
@@ -176,8 +183,11 @@ __DisabledFPU1:
ldr r0, [r5, #4]
str r0, [r5]
ldr r1, [r0]
SignalContextRestore:
ldr.w r3, =OS_FPU_CPACR
ldr r3, [r3]
and r3, r3, #OS_FPU_CPACR_ENABLE
cmp r3, #OS_FPU_CPACR_ENABLE
bne __DisabledFPU2

View File

@@ -29,9 +29,10 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
.syntax unified
.arch armv7e-m
.thumb
.syntax unified
.arch armv7e-m
.fpu fpv4-sp-d16
.thumb
.section .text
@@ -267,7 +268,7 @@ _hwiActiveCheck:
RBIT R2, R3
CLZ R2, R2
AND R12, R12, #1
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as uwPid
ADD R2, R2, R12, LSL #5 // calculate R2 (hwi number) as pid
.fnend
.type _ExcInMSP, %function
@@ -275,13 +276,13 @@ _hwiActiveCheck:
_ExcInMSP:
.fnstart
.cantunwind
CMP LR, #0XFFFFFFED
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
#VPUSH {D8-D15} // FPU
VPUSH {D8-D15} // FPU
B _handleEntry
.fnend
@@ -337,12 +338,13 @@ _hwiActiveCheckNext:
MRS R12, PRIMASK
PUSH {R4-R12}
VPUSH {D8-D15} // FPU
// copy auto saved task register
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
#VLDMIA R3!, {D8-D15} // FPU
#VSTMDB R2!, {D8-D15} // FPU
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
VLDMIA R3!, {D8-D15} // FPU
VSTMDB R2!, {D8-D15} // FPU
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
@@ -352,7 +354,7 @@ _hwiActiveCheckNext:
_NoFloatInPsp:
.fnstart
.cantunwind
MOV R2, R13 //no auto push floating registers
MOV R2, R13 // no auto push floating registers
SUB R13, #32 // add 8 Bytes reg(for STMFD)
MRS R3, PSP

View File

@@ -44,19 +44,14 @@
UINT32 g_intCount = 0;
/*lint -restore*/
#ifdef __ICCARM__
#pragma location = ".data.vector"
#pragma data_alignment=0x100
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
#endif
/* *
* @ingroup los_hwi
* hardware interrupt form mapping handling function array.
* Hardware interrupt form mapping handling function array.
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
HWI_PROC_FUNC pfnHandler;
@@ -65,7 +60,7 @@ typedef struct {
/* *
* @ingroup los_hwi
* hardware interrupt handler form mapping handling function array.
* Hardware interrupt handler form mapping handling function array.
*/
STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
@@ -108,18 +103,86 @@ WEAK VOID SysTick_Handler(VOID)
}
/* ****************************************************************************
Function : HalIntNumGet
Function : HwiNumGet
Description : Get an interrupt number
Input : None
Output : None
Return : Interrupt Indexes number
**************************************************************************** */
LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
STATIC UINT32 HwiNumGet(VOID)
{
return __get_IPSR();
}
inline UINT32 HalIsIntActive(VOID)
STATIC UINT32 HwiUnmask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_EnableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiMask(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiSetPriority(HWI_HANDLE_T hwiNum, UINT8 priority)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
if (priority > OS_HWI_PRIO_LOWEST) {
return OS_ERRNO_HWI_PRIO_INVALID;
}
NVIC_SetPriority((IRQn_Type)hwiNum, priority);
return LOS_OK;
}
STATIC UINT32 HwiPending(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_SetPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
STATIC UINT32 HwiClear(HWI_HANDLE_T hwiNum)
{
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_ClearPendingIRQ((IRQn_Type)hwiNum);
return LOS_OK;
}
HwiControllerOps g_archHwiOps = {
.enableIrq = HwiUnmask,
.disableIrq = HwiMask,
.setIrqPriority = HwiSetPriority,
.getCurIrqNum = HwiNumGet,
.triggerIrq = HwiPending,
.clearIrq = HwiClear,
};
inline UINT32 ArchIsIntActive(VOID)
{
return (g_intCount > 0);
}
@@ -133,18 +196,19 @@ inline UINT32 HalIsIntActive(VOID)
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{
UINT32 irqNum = HalIntNumGet();
PRINT_ERR("%s irqnum:%d\n", __FUNCTION__, irqNum);
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
while (1) {}
}
WEAK VOID HalPreInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
WEAK VOID HalAftInterruptHandler(UINT32 arg)
{
(VOID)arg;
return;
}
@@ -168,13 +232,13 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
g_intCount++;
LOS_IntRestore(intSave);
hwiIndex = HalIntNumGet();
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
@@ -194,25 +258,26 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
/* ****************************************************************************
Function : HalHwiCreate
Function : ArchHwiCreate
Description : create hardware interrupt
Input : hwiNum --- hwi num to create
hwiPrio --- priority of the hwi
mode --- unused
handler --- hwi handler
arg --- param of the hwi handler
hwiMode --- unused
hwiHandler --- hwi handler
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T mode,
HWI_PROC_FUNC handler,
HWI_ARG_T arg)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
HWI_PRIOR_T hwiPrio,
HWI_MODE_T hwiMode,
HWI_PROC_FUNC hwiHandler,
HwiIrqParam *irqParam)
{
(VOID)hwiMode;
UINT32 intSave;
if (handler == NULL) {
if (hwiHandler == NULL) {
return OS_ERRNO_HWI_PROC_FUNC_NULL;
}
@@ -229,13 +294,18 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
intSave = LOS_IntLock();
#if (OS_HWI_WITH_ARG == 1)
OsSetVector(hwiNum, handler, arg);
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
if (irqParam != NULL) {
OsSetVector(hwiNum, hwiHandler, irqParam->pDevId);
} else {
OsSetVector(hwiNum, hwiHandler, NULL);
}
#else
OsSetVector(hwiNum, handler);
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
NVIC_EnableIRQ((IRQn_Type)hwiNum);
NVIC_SetPriority((IRQn_Type)hwiNum, hwiPrio);
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
LOS_IntRestore(intSave);
@@ -243,21 +313,23 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
}
/* ****************************************************************************
Function : HalHwiDelete
Function : ArchHwiDelete
Description : Delete hardware interrupt
Input : hwiNum --- hwi num to delete
irqParam --- param of the hwi handler
Output : None
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam)
{
(VOID)irqParam;
UINT32 intSave;
if (hwiNum >= OS_HWI_MAX_NUM) {
return OS_ERRNO_HWI_NUM_INVALID;
}
NVIC_DisableIRQ((IRQn_Type)hwiNum);
HwiMask((IRQn_Type)hwiNum);
intSave = LOS_IntLock();
@@ -273,6 +345,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
#define BUSFAULT (1 << 17)
#define MEMFAULT (1 << 16)
#define DIV0FAULT (1 << 4)
#define UNALIGNFAULT (1 << 3)
#define HARDFAULT_IRQN (-13)
ExcInfo g_excInfo = {0};
@@ -377,6 +450,7 @@ STATIC VOID OsExcRegInfo(const ExcInfo *excInfo)
PRINTK("xPSR = 0x%x\n", excInfo->context->uwxPSR);
}
#if (LOSCFG_KERNEL_BACKTRACE == 1)
STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
{
UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
@@ -393,6 +467,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
}
PRINTK("----- backtrace end -----\n");
}
#endif
STATIC VOID OsExcMemPoolCheckInfo(VOID)
{
@@ -442,7 +517,9 @@ STATIC VOID OsExcInfoDisplay(const ExcInfo *excInfo)
OsExcTypeInfo(excInfo);
OsExcCurTaskInfo(excInfo);
OsExcRegInfo(excInfo);
#if (LOSCFG_KERNEL_BACKTRACE == 1)
OsExcBackTraceInfo(excInfo);
#endif
OsGetAllTskInfo();
OsExcNvicDump();
OsExcMemPoolCheckInfo();
@@ -482,7 +559,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
OsDoExcHook(EXC_INTERRUPT);
OsExcInfoDisplay(&g_excInfo);
HalSysExit();
ArchSysExit();
}
/* stack protector */
@@ -502,7 +579,7 @@ WEAK VOID __stack_chk_fail(VOID)
Output : None
Return : None
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
{
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
@@ -530,8 +607,13 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
/* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
#ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);
#else
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT);
#endif
return;
}

View File

@@ -49,22 +49,22 @@ typedef enum {
MPU_AP_RO_USER_RO = 0x6, /* Privileged:Read-only Unprivileged:Read-only */
} MpuApConfig;
VOID HalMpuEnable(UINT32 defaultRegionEnable)
VOID ArchMpuEnable(UINT32 defaultRegionEnable)
{
UINT32 intSave = HalIntLock();
UINT32 intSave = ArchIntLock();
MPU->CTRL = (MPU_CTRL_ENABLE_Msk | ((defaultRegionEnable << MPU_CTRL_PRIVDEFENA_Pos) & MPU_CTRL_PRIVDEFENA_Msk));
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
__DSB();
__ISB();
HalIntRestore(intSave);
ArchIntRestore(intSave);
}
VOID HalMpuDisable(VOID)
VOID ArchMpuDisable(VOID)
{
UINT32 intSave = HalIntLock();
UINT32 intSave = ArchIntLock();
MPU->CTRL = 0;
__DSB();
__ISB();
HalIntRestore(intSave);
ArchIntRestore(intSave);
}
STATIC VOID HalMpuRASRAddMemAttr(MPU_CFG_PARA *para, UINT32 *RASR)
@@ -97,7 +97,7 @@ STATIC UINT32 HalMpuEncodeSize(UINT64 size)
if (size > SIZE_4G_BYTE) {
return 0;
}
if ((size & 0x1F) != 0) { /* size sould aligned to 32 byte at least. */
if ((size & 0x1F) != 0) { /* size should aligned to 32 byte at least. */
return 0;
}
size = (size >> 2);
@@ -147,7 +147,7 @@ STATIC UINT32 HalMpuGetRASR(UINT32 encodeSize, MPU_CFG_PARA *para)
return RASR;
}
UINT32 HalMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
UINT32 ArchMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
{
UINT32 RASR;
UINT32 RBAR;
@@ -175,9 +175,9 @@ UINT32 HalMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
}
RBAR = para->baseAddr & MPU_RBAR_ADDR_Msk;
RASR = HalMpuGetRASR(encodeSize, para);
intSave = HalIntLock();
intSave = ArchIntLock();
if (g_regionNumBeUsed[regionId]) {
HalIntRestore(intSave);
ArchIntRestore(intSave);
return LOS_NOK;
}
MPU->RNR = RNR;
@@ -186,11 +186,11 @@ UINT32 HalMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
__DSB();
__ISB();
g_regionNumBeUsed[regionId] = 1; /* Set mpu region used flag */
HalIntRestore(intSave);
ArchIntRestore(intSave);
return LOS_OK;
}
UINT32 HalMpuDisableRegion(UINT32 regionId)
UINT32 ArchMpuDisableRegion(UINT32 regionId)
{
volatile UINT32 type;
UINT32 intSave;
@@ -199,9 +199,9 @@ UINT32 HalMpuDisableRegion(UINT32 regionId)
return LOS_NOK;
}
intSave = HalIntLock();
intSave = ArchIntLock();
if (!g_regionNumBeUsed[regionId]) {
HalIntRestore(intSave);
ArchIntRestore(intSave);
return LOS_NOK;
}
@@ -213,20 +213,20 @@ UINT32 HalMpuDisableRegion(UINT32 regionId)
__ISB();
}
g_regionNumBeUsed[regionId] = 0; /* clear mpu region used flag */
HalIntRestore(intSave);
ArchIntRestore(intSave);
return LOS_OK;
}
INT32 HalMpuUnusedRegionGet(VOID)
INT32 ArchMpuUnusedRegionGet(VOID)
{
INT32 id;
UINT32 intSave = HalIntLock();
UINT32 intSave = ArchIntLock();
for (id = 0; id < MPU_MAX_REGION_NUM; id++) {
if (!g_regionNumBeUsed[id]) {
break;
}
}
HalIntRestore(intSave);
ArchIntRestore(intSave);
if (id == MPU_MAX_REGION_NUM) {
return -1;

View File

@@ -0,0 +1,128 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_timer.h"
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
#include "los_debug.h"
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);
STATIC UINT64 SysTickCycleGet(UINT32 *period);
STATIC VOID SysTickLock(VOID);
STATIC VOID SysTickUnlock(VOID);
STATIC ArchTickTimer g_archTickTimer = {
.freq = 0,
.irqNum = SysTick_IRQn,
.periodMax = LOSCFG_BASE_CORE_TICK_RESPONSE_MAX,
.init = SysTickStart,
.getCycle = SysTickCycleGet,
.reload = SysTickReload,
.lock = SysTickLock,
.unlock = SysTickUnlock,
.tickHandler = NULL,
};
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler)
{
UINT32 ret;
ArchTickTimer *tick = &g_archTickTimer;
tick->freq = OS_SYS_CLOCK;
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
OsSetVector(tick->irqNum, handler, NULL);
#else
OsSetVector(tick->irqNum, handler);
#endif
#endif
ret = SysTick_Config(LOSCFG_BASE_CORE_TICK_RESPONSE_MAX);
if (ret == 1) {
return LOS_ERRNO_TICK_PER_SEC_TOO_SMALL;
}
return LOS_OK;
}
STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
{
if (nextResponseTime > g_archTickTimer.periodMax) {
nextResponseTime = g_archTickTimer.periodMax;
}
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->LOAD = (UINT32)(nextResponseTime - 1UL); /* set reload register */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
NVIC_ClearPendingIRQ(SysTick_IRQn);
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
return nextResponseTime;
}
STATIC UINT64 SysTickCycleGet(UINT32 *period)
{
UINT32 hwCycle = 0;
UINT32 intSave = LOS_IntLock();
UINT32 val = SysTick->VAL;
*period = SysTick->LOAD;
if (val != 0) {
hwCycle = *period - val;
}
LOS_IntRestore(intSave);
return (UINT64)hwCycle;
}
STATIC VOID SysTickLock(VOID)
{
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
STATIC VOID SysTickUnlock(VOID)
{
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
ArchTickTimer *ArchSysTickTimerGet(VOID)
{
return &g_archTickTimer;
}
UINT32 ArchEnterSleep(VOID)
{
__DSB();
__WFI();
__ISB();
return LOS_OK;
}

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