Compare commits

...

93 Commits

Author SHA1 Message Date
openharmony_ci cc6b4e3b06
!1046 Fix : pthread_cond_timedwait 信号丢失问题修复挑单到3.0-LTS 分支
Merge pull request !1046 from yinjiaming/cherry-pick-1680507888
2023-04-10 09:20:52 +00:00
yinjiaming d13b497b01 fixed 2374c01 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/1043
fix:pthread_cond_timedwait解锁后清理的问题
该函数解锁mutex 后先清理事件,导致等的事件丢失

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I36f8658b1b850734bc029b486fec103f6bd10588
2023-04-03 07:44:51 +00:00
openharmony_ci 887a845874
!724 fix: 修复系统时间比RTC时间过快的问题
Merge pull request !724 from zhushengle/tick_3.0.0
2022-06-25 10:12:26 +00:00
zhushengle 8ee33a771b fix: 修复系统时间比RTC时间过快的问题
1.标记在时间接口中更新base后在中断中不再更新base
2.优化tick计算

Close #I5DCRB

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I525e6e996fd40890b52c1c749ef0bad20c8136d8
2022-06-25 09:45:45 +08:00
openharmony_ci c182540a92
!716 fix:ping命令访问野指针及内存泄漏问题修复
Merge pull request !716 from Zhaotianyu/0617ping_fix
2022-06-18 10:06:29 +00:00
arvinzzz d837ed3e9d fix: ping命令内访问野指针及内存泄漏
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-06-17 16:54:51 +08:00
openharmony_ci a2371f1b27
!706 【3.0-LTS】 littlefs接口缺乏锁的保护
Merge pull request !706 from Far/OpenHarmony-3.0-LTS
2022-06-13 07:53:29 +00:00
Far 8245cd5cd0 fix: 修复littlefs适配层锁的问题
littlefs适配lfs_api.c中调用littlefs原生接口未用锁保护,修复之

Close #I5BVO3

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I18e99d2be27c9de86acd1610b58168d9190203bd
2022-06-13 14:04:44 +08:00
openharmony_ci b9311b9aa0
!696 FatFs升级r0.14a版本同步3.0分支
Merge pull request !696 from wangchen/05_31_up_m
2022-06-02 07:43:02 +00:00
wangchen 8cf75d80fd fix: FatFs升级r0.14a版本同步3.0分支
【背景】FatFs升级r0.14a版本同步3.0分支

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

Change-Id: I571f458a19d04520c86ab0ed63edcabb25d80e5e
2022-05-31 09:00:54 +00:00
openharmony_ci 4491d561c7
!679 内核codex清零
Merge pull request !679 from Kiita/0421_codex
2022-04-25 04:36:10 +00:00
zhangyan 1bf61bb4b0 内核codex告警清零
Signed-off-by: Kiita <zhanyan@huawei.com>
Change-Id: Ie510061dd37e4bafcb208e08311f43ef3119040c
2022-04-24 09:05:50 +00:00
openharmony_ci b62463abc5
!594 处理M核编译告警
Merge pull request !594 from yinjiaming/OpenHarmony-3.0-LTS
2022-02-15 01:21:53 +00:00
yinjiaming 6ffea886d3 fix: 编译告警清零
【背景】

3.0 LTS 告警清零

【修改方案】
添加了安全函数的检查,将不安全的函数改写为安全函数

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

re #I4TM2U

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I4479172e755821916aa6f299607fdceac763d468
2022-02-14 12:41:52 +00:00
openharmony_ci 9de6f57cda
!549 挑单 pthread_create创建的线程未设置detach属性,主动退出后,OsGetAllTskInfo调用后,相关的任务名为乱码
Merge pull request !549 from wangchen/exit_3
2022-01-18 03:54:25 +00:00
openharmony_ci 307ab396a5
!548 挑单 L0 pthread_cond_timedwait接口存在计算溢出
Merge pull request !548 from wangchen/cond_3
2022-01-18 03:53:40 +00:00
wangchen 96b2eaeab6 fix: thread_create创建的线程未设置detach属性,主动退出后,OsGetAllTskInfo调用后,相关的任务名为乱码
【背景】thread_create创建的线程未设置detach属性,主动退出后,OsGetAllTskInfo调用后,相关的任务名为乱码

【修改方案】
修改线程退出流程
【影响】
对现有的产品编译不会有影响。

re #I4R4D3
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-01-17 08:02:20 +00:00
wangchen 58e67dde3b fix: L0 pthread_cond_timedwait接口实现存在的几个问题
【背景】L0 pthread_cond_timedwait接口存在计算溢出

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

re #I4R4A5
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-01-17 07:14:09 +00:00
openharmony_ci f74067b24f
!519 chore: shell体验优化
Merge pull request !519 from huangshan/cherry-pick-1640932575
2022-01-07 03:21:00 +00:00
huangshan 86bc68744d fixed 57cff79 from https://gitee.com/uhamc/kernel_liteos_m/pulls/386
chore: shell完善帮助信息,特殊处理不可见字符

Signed-off-by: huangshan <huangshan9@huawei.com>
Change-Id: I3cbc559c388b5d5a524783c1f55c1e569a44465c
2021-12-31 06:36:18 +00:00
openharmony_ci 39db69b6bf !478 添加bundle.json
Merge pull request !478 from pjscc/OpenHarmony-3.0-LTS
2021-12-31 03:13:18 +00:00
openharmony_ci 87c6e9476d !500 【fix】api_shell.c 宏修改
Merge pull request !500 from pef/lts_sync
2021-12-30 08:20:32 +00:00
openharmony_ci 94537e17ae !507 fix:在非静态初始化条件下pthread_mutex_lock,没有经过init初始化就可以对已销毁的锁进行加锁 挑单到3.0分支
Merge pull request !507 from x_xiny/fix_pthread_mutex_lock
2021-12-29 07:21:32 +00:00
openharmony_ci 9717eafff7 !514 fix the compile warning
Merge pull request !514 from laojr1/OpenHarmony-3.0-LTS
2021-12-29 06:23:04 +00:00
老家荣 0712c2df56 chore: 解决 cmsis_liteos2.c:115:23: warning 编译告警
Signed-off-by: laojr1 <laojr1@midea.com>
2021-12-29 14:11:44 +08:00
pjscc 50b4e91f91 feat: 添加bundle.json作为hpm包管理描述文件
Signed-off-by: pjscc <pangjiashuai@huawei.com>
2021-12-29 10:33:46 +08:00
openharmony_ci 443d9deb9b !483 fix: 修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题
Merge pull request !483 from kenneth/cherry-pick-1640158553
2021-12-29 00:54:26 +00:00
kenneth caa28225a8 fixed d32e25f from https://gitee.com/rtos_yuan/kernel_liteos_m/pulls/362
fix: 修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题

修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题

close #I4EJGR

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-28 09:13:14 +08:00
openharmony_ci fdb12dbe31 !486 fix: 移除los_arch_interrupt.h文件中冗余声明的函数VOID OsExcInit(VOID)
Merge pull request !486 from kenneth/cherry-pick-1640158838
2021-12-28 00:54:46 +00:00
openharmony_ci 8ebfe352f5 !490 fix: gcc编译testsuite编译问题修复
Merge pull request !490 from kenneth/cherry-pick-1640160367
2021-12-28 00:53:56 +00:00
x-xiny 2332f34a79 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-12-27 06:23:22 +00:00
pef 314af71a48 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-12-27 09:55:08 +08:00
openharmony_ci 2ef5ff366e !488 fix: 删除LOS_TRACE 记录SWTMR_START中的无效字段
Merge pull request !488 from Zhaotianyu/cherry-pick-1640159998
2021-12-23 08:46:38 +00:00
openharmony_ci 5acd9b36ff !481 fix:修复Fault异常模块中FPU宏等问题
Merge pull request !481 from kenneth/cherry-pick-1640158227
2021-12-23 07:17:18 +00:00
openharmony_ci 314102c234 !485 fix: los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误
Merge pull request !485 from kenneth/cherry-pick-1640158674
2021-12-23 07:15:36 +00:00
openharmony_ci b31437fe27 !489 fix: 解决los_pm.c:743:19: warning 编译告警
Merge pull request !489 from kenneth/cherry-pick-1640160304
2021-12-23 07:11:28 +00:00
openharmony_ci a2852d8bce !482 fix:hook层LOS_HOOK_TYPE_SEM_PEND的runningTask入参可能为空
Merge pull request !482 from Zhaotianyu/cherry-pick-1640158494
2021-12-22 09:33:02 +00:00
openharmony_ci 0ce46a3989 !484 fix:修复不能开启硬浮点选项的问题
Merge pull request !484 from Zhaotianyu/cherry-pick-1640158615
2021-12-22 09:32:42 +00:00
openharmony_ci b5db6ee2d4 !487 解决gmtime和localtime接口由于g_tm全局变量导致的竞态问题
Merge pull request !487 from JerryH/cherry-pick-1640159938
2021-12-22 08:47:05 +00:00
kenneth f0ed09be65 fixed f7d26b8 from https://gitee.com/rtos_yuan/kernel_liteos_m/pulls/343
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-12-22 08:06:07 +00:00
kenneth 802e01de21 fixed 0c72c8b from https://gitee.com/rtos_yuan/kernel_liteos_m/pulls/340
fix: 解决los_pm.c:743:19: warning 编译告警

修复PRINT_ERR函数格式化参数数目不一致。

close #I4D4L8

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-22 08:05:04 +00:00
LiteOS2021 d95a1523f2 fixed afbc9a5 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/348
fix: 优化trace buffer初始化,删除swtmr 桩中的无效参数
close #I4DPR7

Signed-off-by: LiteOS2021 <dinglu@huawei.com>
2021-12-22 07:59:58 +00:00
JerryH 0a1df72f7e fixed 1454b76 from https://gitee.com/JerryH1011/kernel_liteos_m/pulls/454
fix: 解决gmtime和localtime接口由于g_tm全局变量导致的竞态问题

删除全局变量,接口使用自己的内部静态变量,避免竞态

Close #I4LW3H

Signed-off-by: JerryH <huangjieliang@huawei.com>
Change-Id: I3c74b1897b3909df93d21b9d521af270cc6fc610
2021-12-22 07:59:00 +00:00
kenneth 48484444ce fixed 136952f from https://gitee.com/rtos_yuan/kernel_liteos_m/pulls/342
fix: 移除los_arch_interrupt.h文件中冗余声明的函数VOID OsExcInit(VOID)

VOID OsExcInit(VOID)函数的注释中参数描述错误,并且该函数并没有在C源文件中使用到,需要删除。

close #I4D9OO

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-22 07:40:38 +00:00
kenneth 6240af2522 fixed c51df7a from https://gitee.com/rtos_yuan/kernel_liteos_m/pulls/363
fix: los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误

修复los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误

close #I4EJI4

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-22 07:37:56 +00:00
arvinzzz b1b46451e7 fixed 988fd85 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/300
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-12-22 07:36:56 +00:00
arvinzzz 54936c19bd fixed 3fd22ac from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/324
fix: 修复hook层LOS_HOOK_TYPE_SEM_PEND的runningTask入参可能为空

在校验完semPend之后,就获取好runningTask并且与semPend关联

close: #I4BU4P
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ib56a1a1db8e4471d9e2adb0b7c3d8b17b1f87b8d
2021-12-22 07:34:56 +00:00
kenneth 7a6242549f fixed 2da043c from https://gitee.com/rtos_yuan/kernel_liteos_m/pulls/367
fix:修复Fault异常模块中FPU宏等问题

去掉不必要的宏判断__FPU_PRESENT;参数变量名称 uwPid改为pid,和函数HalExcHandleEntry的参数保持一致

close #I4D575

Signed-off-by: kenneth <zhushangyuan@huawei.com>
2021-12-22 07:30:27 +00:00
openharmony_ci 07ef35ccdf !467 pthread_cond_timedwait接口不规范
Merge pull request !467 from wangchen/posix_cond
2021-12-20 03:53:26 +00:00
wangchen 08e3025ec5 fix: pthread_cond_timedwait接口入参不规范
【背景】pthread_cond_timedwait函数的入参时间应该是绝对时间

【修改方案】
1,修改为相对时间
2,每次等待事件前清理

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

re #I4MVUO
Signed-off-by: wangchen <253227059@qq.com>
2021-12-20 01:39:45 +00:00
openharmony_ci ae2c3c5823 !463 fix: tick中断处理时,无挂起任务时应更新当前运行任务的时间片, 并触发一次调度
Merge pull request !463 from zhushengle/cherry-pick-1639542040
2021-12-17 03:25:22 +00:00
zhushengle d32fea7096 fixed ea12d40 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/456
fix: tick中断处理时,无挂起任务时应更新当前运行任务的时间片, 并触发一次调度

Close #I4LRZG

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I4472fb50c775b832688aa7a555498901a80e2999
2021-12-15 04:20:42 +00:00
openharmony_ci 915e5b9517 !438 fix: 取消cpu进入低功耗前开中断操作,优化注册机制
Merge pull request !438 from zhushengle/cherry-pick-1638271705
2021-12-03 09:26:16 +00:00
zhushengle 6e665e6771 fixed bd39e9e from https://gitee.com/zhushengle/kernel_liteos_m/pulls/435
fix: 取消cpu进入低功耗前开中断操作

    开中断导致低功耗流程非原子,容易造成流程出错。
    提供低功耗默认处理函数,优化注册机制

Close #I4KDP8
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ied8bab691e7725e207b8b3cfb058f851eafe3052
2021-11-30 11:28:25 +00:00
openharmony_ci a338ba8f69 !391 补充内存释放函数和去除多余参数。
Merge pull request !391 from pef/OpenHarmony-3.0-LTS
2021-11-25 08:33:08 +00:00
pef 81d02b4fea 补充内存释放函数和去除多余参数。
【背景】
1.有手动申请内存在return前未释放。
2.PRINTK存在多余参数

【修改方案】
1. 添加free(fullpath),释放内存。
2. 去掉多余参数。

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

Change-Id: Ifa74d5b443e98b03c10a34cca4ce6eaebfb2a120
Signed-off-by: pef <cyd1997@126.com>
2021-11-25 03:21:20 +00:00
openharmony_ci bd607c8922 !388 fix: 修复cortex-m系列系统提供的timer在低频下时间不准的问题
Merge pull request !388 from zhushengle/cherry-pick-1636507317
2021-11-11 02:38:39 +00:00
zhushengle f23481e041 fixed 3e569ba from https://gitee.com/zhushengle/kernel_liteos_m/pulls/385
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-10 01:21:57 +00:00
openharmony_ci 792b131d55 !379 修改inet_addr等宏为函数,外层调用可不包含lwip头文件
Merge pull request !379 from 刘建东/cherry-pick-1635579054
2021-10-30 08:57:44 +00:00
YOUR_NAME 3969fbfac8 fixed b30e913 from https://gitee.com/life-liu/kernel_liteos_m/pulls/377
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 07:30:54 +00:00
openharmony_ci 33e2b5e085 !376 m核优化lwip默认配置
Merge pull request !376 from 刘建东/cherry-pick-1635479803
2021-10-30 03:08:58 +00:00
YOUR_NAME 79099bb28c fixed b2e3849 from https://gitee.com/life-liu/kernel_liteos_m/pulls/375
fix: optimize default configuration

optimize default configuration

close: #I4FSC9

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-10-29 14:46:02 +08:00
openharmony_ci 11e8e895d3 !373 m核ioctl支持SIOCGIFBRDADDR选项
Merge pull request !373 from 刘建东/cherry-pick-1635300312
2021-10-29 02:19:05 +00:00
YOUR_NAME a562b67f90 fixed 33ee492 from https://gitee.com/life-liu/kernel_liteos_m/pulls/360
feat: add option SIOCGIFBRDADDR for ioctl

add option SIOCGIFBRDADDR for ioctl

close: #I4EGNG

Signed-off-by: liujiandong <liujiandong1@huawei.com>
2021-10-27 02:05:13 +00:00
openharmony_ci fafd3b66d4 !365 fix:修复文件系统vfs层未正确判空g_fs的问题
Merge pull request !365 from Far/cherry-pick-1634701427
2021-10-20 04:18:58 +00:00
Far 5e3a29dd97 fix:修复文件系统vfs层未正确判空g_fs的问题
Close #I4ELVA

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Id8cbbd6c65df0411f22af11412f01b57fa8c27d1
2021-10-20 11:50:35 +08:00
openharmony_ci d1d19e088d !352 fix: 调用LOS_TaskDetach操作已退出的joinable的任务时,未正确回收该任务
Merge pull request !352 from zhushengle/cherry-pick-1634283734
2021-10-15 10:38:32 +00:00
zhushengle 2c85b0ec6d fixed 49c93b3 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/351
fix: 调用LOS_TaskDetach操作已退出的joinable的任务时,未正确回收该任务

Close #I4DZL7
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Iac88818317c07807d0636712025f2c75b3b1f766
2021-10-15 07:42:15 +00:00
openharmony_ci 773613af16 !333 fix: OS_TASK_STACK_PROTECT_SIZE undeclared error
Merge pull request !333 from kenneth/mpu-3.0
2021-09-29 03:49:03 +00:00
openharmony_ci 0f0e4dfafd !334 fix: LOS_QueueInfoGet函数统计等待读写任务有误
Merge pull request !334 from kenneth/queue-3.0
2021-09-29 02:57:37 +00:00
kenneth 2a5a515f50 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:30:49 +08:00
kenneth 215a1f6dc0 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 10:18:41 +08:00
openharmony_ci 093af869d5 !329 解决dailycheck告警
Merge pull request !329 from Caoruihong/cherry-pick-1632647820
2021-09-26 10:14:11 +00:00
openharmony_ci ef8d27db07 !329 解决dailycheck告警
Merge pull request !329 from Caoruihong/cherry-pick-1632647820
2021-09-26 10:14:10 +00:00
openharmony_ci b22234dd6a !326 fix: 添加文件版权头等信息
Merge pull request !326 from Harylee/cherry-pick-1632645903
2021-09-26 09:34:41 +00:00
Caoruihong 5169a23adf fixed 4aba2c0 from https://gitee.com/caoruihong/kernel_liteos_m/pulls/327
chore: fix dailycheck issues

master --> HEAD
remove useless @since

Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: Id3452cccdcc823c374f873cf4905015351580d15
2021-09-26 09:17:00 +00:00
Haryslee bc42e348d0 fixed cf4e017 from https://gitee.com/harylee/kernel_liteos_m/pulls/325
fix: 添加文件版权头等信息

close #I4BXBH

Signed-off-by: Haryslee <lihao189@huawei.com>
Change-Id: Id798eec0473a9b8e18b1c8be31f3dd6babb879b0
2021-09-26 08:45:03 +00:00
openharmony_ci 93cc5747a2 !322 feat: 支持posix 和 cmsis join能力
Merge pull request !322 from zhushengle/cherry-pick-1632465410
2021-09-24 08:10:40 +00:00
zhushengle 96b4c460e2 fixed ecfdf7f from https://gitee.com/zhushengle/kernel_liteos_m/pulls/311
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-24 06:36:51 +00:00
openharmony_ci 23f634bde5 !319 fix: 修复pthread_create行为与posix不一致问题
Merge pull request !319 from zhushengle/cherry-pick-1632447173
2021-09-24 06:10:15 +00:00
openharmony_ci aee17ecfa6 !320 cherry-pick PR259: 完善CMSIS-RTOS V2部分接口(osSemaphoreNew,osThreadJoin)
Merge pull request !320 from Caoruihong/cherry-pick-1632450240
2021-09-24 02:26:39 +00:00
Caoruihong 9b160141c4 fixed d478152 from https://gitee.com/caoruihong/kernel_liteos_m/pulls/259
feat(cmsis): support max_count for osSemaphoreNew

Signed-off-by: Caoruihong <crh.cao@huawei.com>
Change-Id: Iacb6cb7771ae32ea1ca645c72fda241e8e85d422
2021-09-24 02:24:01 +00:00
zhushengle 3141961013 fixed 2b1e5a7 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/308
fix: 修复pthread_create行为与posix不一致问题

1.提升posix接口和LOS接口的兼容性
2.支持优先级继承属性

Close #I49W9F
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I4d9df778a559f094dd3062e5e7030e3a03c884ec
2021-09-24 01:32:54 +00:00
openharmony_ci 51a6c21315 !315 fix: risc-v 低功耗下存在功能问题
Merge pull request !315 from zhushengle/cherry-pick-1631945741
2021-09-22 03:55:32 +00:00
zhushengle c5a9ba4abf fixed 9f185b5 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/314
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 06:15:45 +00:00
openharmony_ci 7fa979c67c !313 挑单 shell模块task命令踩内存问题修改
Merge pull request !313 from wangchen/shell_lts
2021-09-17 07:46:26 +00:00
wangchen b5e84d5516 fix: shell模块task命令踩内存问题修改
【背景】定期M核代码消除。

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

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

re #II4AIAQ
Signed-off-by: wangchen <253227059@qq.com>
2021-09-17 14:35:27 +08:00
openharmony_ci c277e8d543 !309 feat: 低功耗支持冻结线程等需求
Merge pull request !309 from zhushengle/cherry-pick-1631622669
2021-09-15 00:58:09 +00:00
zhushengle 230a2f348f fixed 9b5739a from https://gitee.com/zhushengle/kernel_liteos_m/pulls/298
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 12:31:10 +00:00
openharmony_ci 92e3844061 !303 fix: 修复pm编译告警导致内核编译失败
Merge pull request !303 from zhushengle/cherry-pick-1631346536
2021-09-11 08:52:28 +00:00
zhushengle 088a6d5bbd fixed 18b0524 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/301
fix: 修复pm编译告警导致内核编译失败

Close #I49MIN
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I6b448790b170bf5980d16698ecfff27bda6c3600
2021-09-11 07:48:56 +00:00
openharmony_ci d4d6489fb9 !297 fix: 优化低功耗流程
Merge pull request !297 from zhushengle/cherry-pick-1631173853
2021-09-09 09:00:36 +00:00
zhushengle c1b2b15a87 fixed c6600d9 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/281
fix: 优化低功耗流程

1.normal和其它模式分离,流程分层化,使得结构较为清晰
2.tick timer处理实现优化为注册对应机制则默认支持,不注册则不执行,简化使用逻辑
3.添加 pm测试用例
Close #I46VXK

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I7810ce0ca12dce96972399adf88e8319bb487905
2021-09-09 07:50:56 +00:00
169 changed files with 3968 additions and 1183 deletions

View File

@ -29,9 +29,17 @@
import("config.gni")
LITEOS_LOS_CONFIG_H = rebase_path("$LITEOSTOPDIR/kernel/include/los_config.h")
config("los_config") {
cflags = [ "-Werror" ]
asmflags = [
"-DCLZ=CLZ",
"-imacros",
"$LITEOS_LOS_CONFIG_H",
]
include_dirs = [
"//kernel/liteos_m/kernel/include",
"//kernel/liteos_m/kernel/arch/include",

View File

@ -71,7 +71,7 @@ After the compilation is successful, the executable file **NUCLEO-F767.hex** i
## 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.md)
**kernel\_liteos\_m**

View File

@ -52,11 +52,11 @@ OpenHarmony LiteOS-M内核的编译构建系统是一个基于gn和ninja的组
### 搭建系统基础环境
在搭建各个开发板环境前需要完成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的编译环境和开发环境详细介绍请参考官方站点[Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/HEAD/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源码
开发者需要在Linux服务器上通过Git克隆获取OpenHarmony最新源码详细的源码获取方式请见[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。获取OpenHarmony完整仓代码后假设克隆目录为`~/openHarmony`。
开发者需要在Linux服务器上通过Git克隆获取OpenHarmony最新源码详细的源码获取方式请见[源码获取](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/get-code/sourcecode-acquire.md)。获取OpenHarmony完整仓代码后假设克隆目录为`~/openHarmony`。
### 获取示例工程源码
@ -78,7 +78,7 @@ 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)。
关于示例代码目录的说明,可以参考资料站点[板级目录规范](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/porting/transplant-chip-board-overview.md)。如果需要自行移植开发板,请参考[板级系统移植](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/porting/transplant-chip-board.md)。
### 编译运行
@ -121,7 +121,7 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供可以
## 相关仓<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**

59
bundle.json Normal file
View File

@ -0,0 +1,59 @@
{
"name": "@ohos/kernel_liteos_m",
"version": "",
"description": "liteos-m内核",
"homePage": "https://gitee.com/openharmony",
"license": "BSD 3-clause",
"repository": "https://gitee.com/openharmony/kernel_liteos_m",
"domain": "os",
"language": "",
"publishAs": "code-segment",
"private": false,
"scripts": {},
"tags": [
"kernel"
],
"keywords": [
"kernel",
"liteos-m"
],
"envs": [],
"dirs": [],
"author": {
"name": "",
"email": "",
"url": ""
},
"contributors": [
{
"name": "",
"email": "",
"url": ""
}
],
"segment": {
"destPath": "kernel/liteos_m"
},
"component": {
"name": "liteos-m",
"subsystem": "liteos_m",
"syscap": [
"SystemCapability.Kernel.liteos-m"
],
"features": [],
"adapted_system_type": [
"mini"
],
"rom": "",
"ram": "",
"deps": {
"components": [],
"third_party": []
},
"build": {
"sub_component": [],
"inner_kits": [],
"test": []
}
}
}

View File

@ -151,7 +151,7 @@ STATIC INLINE UINT32 OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd, UINT
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
*stackEnd = (UINTPTR)taskCB->topOfStack + taskCB->stackSize;
if ((*stackStart < (UINTPTR)taskCB->topOfStack) || (*stackStart >= *stackEnd)) {
PRINT_ERR("psp stack [0x%x, 0x%x], cur sp(0x%x) is overflow, cur task id is %d!\n",
PRINT_ERR("psp stack [0x%x, 0x%x], cur sp(0x%x) is overflow, cur task id is %u!\n",
taskCB->topOfStack, *stackEnd, *stackStart, taskID);
return LOS_NOK;
}
@ -413,7 +413,7 @@ VOID LOS_BackTrace(VOID)
if (LR[index] == 0) {
break;
}
PRINTK("traceback %d -- lr = 0x%x\r\n", index, LR[index]);
PRINTK("traceback %u -- lr = 0x%x\r\n", index, LR[index]);
}
PRINTK("----- traceback end -----\r\n");
}

View File

@ -31,7 +31,6 @@
#include "los_cppsupport.h"
typedef VOID (*InitFunc)(VOID);
INT32 LOS_CppSystemInit(UINTPTR initArrayStart, UINTPTR initArrayEnd)
@ -39,12 +38,10 @@ INT32 LOS_CppSystemInit(UINTPTR initArrayStart, UINTPTR initArrayEnd)
UINTPTR *start;
InitFunc initFunc = NULL;
for (start = (UINTPTR *)initArrayStart; start < (UINTPTR *)initArrayEnd; start++){
for (start = (UINTPTR *)initArrayStart; start < (UINTPTR *)initArrayEnd; start++) {
initFunc = (InitFunc)(*start);
initFunc();
}
return 0;
}

View File

@ -481,7 +481,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E
PRINTK("\nSysCpuUsage in <1s: ");
}
ret = LOS_HistorySysCpuUsage(mode);
PRINTK("%d.%d", ret / LOS_CPUP_PRECISION_MULT, ret % LOS_CPUP_PRECISION_MULT);
PRINTK("%u.%u", ret / LOS_CPUP_PRECISION_MULT, ret % LOS_CPUP_PRECISION_MULT);
break;
case TASK_CPU_USAGE:
@ -495,11 +495,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E
return OS_ERROR;
}
if (mode == CPUP_IN_10S) {
PRINTK("\nCPUusage of taskID %d in 10s: ", taskID);
PRINTK("\nCPUusage of taskID %u in 10s: ", taskID);
} else if (mode == CPUP_IN_1S) {
PRINTK("\nCPUusage of taskID %d in 1s: ", taskID);
PRINTK("\nCPUusage of taskID %u in 1s: ", taskID);
} else {
PRINTK("\nCPUusage of taskID %d in <1s: ", taskID);
PRINTK("\nCPUusage of taskID %u in <1s: ", taskID);
}
ret = LOS_HistoryTaskCpuUsage(taskID, mode);
PRINTK("%u.%u", ret / LOS_CPUP_PRECISION_MULT, ret % LOS_CPUP_PRECISION_MULT);

View File

@ -1432,6 +1432,7 @@ int fatfs_format(const char *dev, int sectors, int option)
INT32 index;
FRESULT res;
INT32 ret;
MKFS_PARM opt = {0};
if (dev == NULL) {
errno = EFAULT;
@ -1458,7 +1459,9 @@ int fatfs_format(const char *dev, int sectors, int option)
goto OUT;
}
res = f_mkfs(dev, option, sectors, g_workBuffer, FF_MAX_SS);
opt.n_sect = sectors;
opt.fmt = (BYTE)option;
res = f_mkfs(dev, &opt, g_workBuffer, FF_MAX_SS);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = FS_FAILURE;

View File

@ -347,14 +347,14 @@ ssize_t read(int fd, void *buf, size_t nbyte)
return recv(fd, buf, nbyte, 0);
}
#endif
if (g_fs->fsFops == NULL || g_fs->fsFops->Read == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Read == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Read(fd, buf, nbyte);
}

View File

@ -32,6 +32,8 @@
#define _GNU_SOURCE 1
#include "lfs_api.h"
#include "los_config.h"
#include "los_mux.h"
#include "los_debug.h"
#include "securec.h"
lfs_t g_lfs;
@ -40,29 +42,41 @@ FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0};
static LittleFsHandleStruct g_handle[LITTLE_FS_MAX_OPEN_FILES] = {0};
struct dirent g_nameValue;
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a", "/b", "/c"};
#define LFS_MUTEX_UNINIT (-1)
static UINT32 g_lfsMutex = LFS_MUTEX_UNINIT;
static int LfsLock(void)
{
if (LOS_MuxPend(g_lfsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
PRINT_ERR("LfsLock failed!");
return LOS_NOK;
}
return LOS_OK;
}
static void LfsUnlock(void)
{
(void)LOS_MuxPost(g_lfsMutex);
}
LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) {
if (g_handle[i].useFlag == 0) {
*fd = i;
g_handle[i].useFlag = 1;
g_handle[i].pathName = strdup(fileName);
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_handle[i]);
}
}
pthread_mutex_unlock(&g_FslocalMutex);
*fd = INVALID_FD;
return NULL;
}
static void LfsFreeFd(int fd)
{
pthread_mutex_lock(&g_FslocalMutex);
g_handle[fd].useFlag = 0;
if (g_handle[fd].pathName != NULL) {
free((void *)g_handle[fd].pathName);
@ -72,21 +86,17 @@ static void LfsFreeFd(int fd)
if (g_handle[fd].lfsHandle != NULL) {
g_handle[fd].lfsHandle = NULL;
}
pthread_mutex_unlock(&g_FslocalMutex);
}
BOOL CheckFileIsOpen(const char *fileName)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LITTLE_FS_MAX_OPEN_FILES; i++) {
if (g_handle[i].useFlag == 1) {
if (strcmp(g_handle[i].pathName, fileName) == 0) {
pthread_mutex_unlock(&g_FslocalMutex);
return TRUE;
}
}
}
pthread_mutex_unlock(&g_FslocalMutex);
return FALSE;
}
@ -103,22 +113,18 @@ static BOOL LfsFdIsValid(int fd)
FileDirInfo *GetFreeDir(const char *dirName)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) {
if (g_lfsDir[i].useFlag == 0) {
g_lfsDir[i].useFlag = 1;
g_lfsDir[i].dirName = strdup(dirName);
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_lfsDir[i]);
}
}
pthread_mutex_unlock(&g_FslocalMutex);
return NULL;
}
void FreeDirInfo(const char *dirName)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) {
if (g_lfsDir[i].useFlag == 1 && strcmp(g_lfsDir[i].dirName, dirName) == 0) {
g_lfsDir[i].useFlag = 0;
@ -126,24 +132,19 @@ void FreeDirInfo(const char *dirName)
free(g_lfsDir[i].dirName);
g_lfsDir[i].dirName = NULL;
}
pthread_mutex_unlock(&g_FslocalMutex);
}
}
pthread_mutex_unlock(&g_FslocalMutex);
}
BOOL CheckDirIsOpen(const char *dirName)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) {
if (g_lfsDir[i].useFlag == 1) {
if (strcmp(g_lfsDir[i].dirName, dirName) == 0) {
pthread_mutex_unlock(&g_FslocalMutex);
return TRUE;
}
}
}
pthread_mutex_unlock(&g_FslocalMutex);
return FALSE;
}
@ -165,35 +166,29 @@ BOOL CheckPathIsMounted(const char *pathName, struct FileOpInfo **fileOpInfo)
char tmpName[LITTLEFS_MAX_LFN_LEN] = {0};
int len = GetFirstLevelPathLen(pathName);
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 1) {
(void)strncpy_s(tmpName, LITTLEFS_MAX_LFN_LEN, pathName, len);
if (strcmp(tmpName, g_fsOp[i].dirName) == 0) {
*fileOpInfo = &(g_fsOp[i]);
pthread_mutex_unlock(&g_FslocalMutex);
return TRUE;
}
}
}
pthread_mutex_unlock(&g_FslocalMutex);
return FALSE;
}
struct FileOpInfo *AllocMountRes(const char* target, const struct FileOps *fileOps)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 0 && strcmp(target, g_littlefsMntName[i]) == 0) {
g_fsOp[i].useFlag = 1;
g_fsOp[i].fsVops = fileOps;
g_fsOp[i].dirName = strdup(target);
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_fsOp[i]);
}
}
pthread_mutex_unlock(&g_FslocalMutex);
return NULL;
}
@ -203,26 +198,21 @@ int SetDefaultMountPath(int pathNameIndex, const char* target)
return VFS_ERROR;
}
pthread_mutex_lock(&g_FslocalMutex);
g_littlefsMntName[pathNameIndex] = strdup(target);
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_OK;
}
struct FileOpInfo *GetMountRes(const char *target, int *mountIndex)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 1) {
if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) {
*mountIndex = i;
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_fsOp[i]);
}
}
}
pthread_mutex_unlock(&g_FslocalMutex);
return NULL;
}
@ -232,33 +222,28 @@ int FreeMountResByIndex(int mountIndex)
return VFS_ERROR;
}
pthread_mutex_lock(&g_FslocalMutex);
if (g_fsOp[mountIndex].useFlag == 1 && g_fsOp[mountIndex].dirName != NULL) {
g_fsOp[mountIndex].useFlag = 0;
free(g_fsOp[mountIndex].dirName);
g_fsOp[mountIndex].dirName = NULL;
}
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_OK;
}
int FreeMountRes(const char *target)
{
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 1) {
if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) {
g_fsOp[i].useFlag = 0;
free(g_fsOp[i].dirName);
g_fsOp[i].dirName = NULL;
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_OK;
}
}
}
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_ERROR;
}
@ -330,6 +315,18 @@ int LfsMount(const char *source, const char *target, const char *fileSystemType,
int ret;
struct FileOpInfo *fileOpInfo = NULL;
if (g_lfsMutex == LFS_MUTEX_UNINIT) {
if (LOS_MuxCreate(&g_lfsMutex) != LOS_OK) {
errno = EBUSY;
return VFS_ERROR;
}
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (target == NULL || fileSystemType == NULL || data == NULL) {
errno = EFAULT;
ret = VFS_ERROR;
@ -370,6 +367,7 @@ int LfsMount(const char *source, const char *target, const char *fileSystemType,
}
errout:
LfsUnlock();
return ret;
}
@ -384,9 +382,15 @@ int LfsUmount(const char *target)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
fileOpInfo = GetMountRes(target, &mountIndex);
if (fileOpInfo == NULL) {
errno = ENOENT;
LfsUnlock();
return VFS_ERROR;
}
@ -397,6 +401,7 @@ int LfsUmount(const char *target)
}
(void)FreeMountResByIndex(mountIndex);
LfsUnlock();
return ret;
}
@ -410,8 +415,14 @@ int LfsUnlink(const char *fileName)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(fileName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT;
LfsUnlock();
return VFS_ERROR;
}
@ -421,6 +432,7 @@ int LfsUnlink(const char *fileName)
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -434,8 +446,14 @@ int LfsMkdir(const char *dirName, mode_t mode)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT;
LfsUnlock();
return VFS_ERROR;
}
@ -445,6 +463,7 @@ int LfsMkdir(const char *dirName, mode_t mode)
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -459,8 +478,14 @@ int LfsRmdir(const char *dirName)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT;
LfsUnlock();
return VFS_ERROR;
}
@ -470,6 +495,7 @@ int LfsRmdir(const char *dirName)
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -480,9 +506,14 @@ DIR *LfsOpendir(const char *dirName)
if (dirName == NULL) {
errno = EFAULT;
goto errout;
return NULL;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return NULL;
}
if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT;
goto errout;
@ -509,9 +540,11 @@ DIR *LfsOpendir(const char *dirName)
dirInfo->lfsHandle = &(fileOpInfo->lfsInfo);
LfsUnlock();
return (DIR *)dirInfo;
errout:
LfsUnlock();
return NULL;
}
@ -527,9 +560,13 @@ struct dirent *LfsReaddir(DIR *dir)
return NULL;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return NULL;
}
ret = lfs_dir_read(dirInfo->lfsHandle, (lfs_dir_t *)(&(dirInfo->dir)), &lfsInfo);
if (ret == TRUE) {
pthread_mutex_lock(&g_FslocalMutex);
(void)strncpy_s(g_nameValue.d_name, sizeof(g_nameValue.d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
if (lfsInfo.type == LFS_TYPE_DIR) {
g_nameValue.d_type = DT_DIR;
@ -538,8 +575,7 @@ struct dirent *LfsReaddir(DIR *dir)
}
g_nameValue.d_reclen = lfsInfo.size;
pthread_mutex_unlock(&g_FslocalMutex);
LfsUnlock();
return &g_nameValue;
}
@ -547,6 +583,7 @@ struct dirent *LfsReaddir(DIR *dir)
errno = LittlefsErrno(ret);
}
LfsUnlock();
return NULL;
}
@ -560,6 +597,11 @@ int LfsClosedir(DIR *dir)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
ret = lfs_dir_close(dirInfo->lfsHandle, (lfs_dir_t *)(&(dirInfo->dir)));
FreeDirInfo(dirInfo->dirName);
@ -569,6 +611,7 @@ int LfsClosedir(DIR *dir)
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -581,9 +624,14 @@ int LfsOpen(const char *pathName, int openFlag, int mode)
if (pathName == NULL) {
errno = EFAULT;
goto errout;
return INVALID_FD;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(pathName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT;
goto errout;
@ -609,9 +657,11 @@ int LfsOpen(const char *pathName, int openFlag, int mode)
}
g_handle[fd].lfsHandle = &(fileOpInfo->lfsInfo);
LfsUnlock();
return fd;
errout:
LfsUnlock();
return INVALID_FD;
}
@ -624,8 +674,14 @@ int LfsRead(int fd, void *buf, unsigned int len)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF;
LfsUnlock();
return VFS_ERROR;
}
@ -634,6 +690,7 @@ int LfsRead(int fd, void *buf, unsigned int len)
errno = LittlefsErrno(ret);
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -646,8 +703,14 @@ int LfsWrite(int fd, const void *buf, unsigned int len)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF;
LfsUnlock();
return VFS_ERROR;
}
@ -656,6 +719,7 @@ int LfsWrite(int fd, const void *buf, unsigned int len)
errno = LittlefsErrno(ret);
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -663,8 +727,14 @@ off_t LfsSeek(int fd, off_t offset, int whence)
{
off_t ret;
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF;
LfsUnlock();
return VFS_ERROR;
}
@ -674,6 +744,7 @@ off_t LfsSeek(int fd, off_t offset, int whence)
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -681,14 +752,18 @@ int LfsClose(int fd)
{
int ret;
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF;
LfsUnlock();
return VFS_ERROR;
}
pthread_mutex_lock(&g_FslocalMutex);
ret = lfs_file_close(g_handle[fd].lfsHandle, &(g_handle[fd].file));
pthread_mutex_unlock(&g_FslocalMutex);
LfsFreeFd(fd);
@ -696,7 +771,7 @@ int LfsClose(int fd)
errno = LittlefsErrno(ret);
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -710,8 +785,14 @@ int LfsRename(const char *oldName, const char *newName)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(oldName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT;
LfsUnlock();
return VFS_ERROR;
}
@ -721,6 +802,7 @@ int LfsRename(const char *oldName, const char *newName)
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -735,8 +817,14 @@ int LfsStat(const char *path, struct stat *buf)
return VFS_ERROR;
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(path, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT;
LfsUnlock();
return VFS_ERROR;
}
@ -752,7 +840,7 @@ int LfsStat(const char *path, struct stat *buf)
errno = LittlefsErrno(ret);
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}
@ -760,8 +848,14 @@ int LfsFsync(int fd)
{
int ret;
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF;
LfsUnlock();
return VFS_ERROR;
}
@ -770,5 +864,6 @@ int LfsFsync(int fd)
errno = LittlefsErrno(ret);
ret = VFS_ERROR;
}
LfsUnlock();
return ret;
}

View File

@ -42,7 +42,6 @@
#include "lfs.h"
#include "lfs_util.h"
#include "memory.h"
#include "pthread.h"
#define INVALID_FD (-1)

View File

@ -44,6 +44,8 @@ static_library("lwip") {
sources = LWIP_PORTING_FILES + LWIPNOAPPSFILES
sources -= [ "$LWIPDIR/api/sockets.c" ]
configs += [ ":lwip_depends" ]
deps = [ "//kernel/liteos_m/kal/posix" ]

View File

@ -105,6 +105,5 @@ extern void LwipLogPrintf(const char *fmt, ...);
#define init_waitqueue_head(...)
#define poll_check_waiters(...)
#define IOCTL_CMD_CASE_HANDLER()
#endif /* _LWIP_PORTING_CC_H_ */

View File

@ -6,15 +6,15 @@
* 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.
* 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.
* 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.
* 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,
@ -29,18 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**********************************************************************************
* Notice of Export Control Law
===============================================
* Huawei LiteOS may be subject to applicable export control laws and regulations, which
* might include those applicable to Huawei LiteOS of U.S. and the country in which you
* are located.
* Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance
* with such applicable export control laws and regulations.
***********************************************************************************/
#ifndef LWIP_API_SHELL_H
#define LWIP_API_SHELL_H

View File

@ -43,9 +43,6 @@
(ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr))
/* directly map this to the lwip internal functions */
#define inet_addr(cp) ipaddr_addr(cp)
#define inet_aton(cp, addr) ip4addr_aton(cp, (ip4_addr_t*)addr)
#define inet_ntoa(addr) ip4addr_ntoa((const ip4_addr_t*)&(addr))
#define inet_ntoa_r(addr, buf, buflen) ip4addr_ntoa_r((const ip4_addr_t*)&(addr), buf, buflen)
#endif /* LWIP_IPV4 */
#if LWIP_IPV6

View File

@ -134,7 +134,7 @@
#define LWIP_NETIF_LOOPBACK 1
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
#define LWIP_RAW 1
#define LWIP_SOCKET_OFFSET FAT_MAX_OPEN_FILES
#define LWIP_SOCKET_OFFSET 0
#define LWIP_SO_RCVBUF 1
#define LWIP_SO_RCVTIMEO 1
#define LWIP_SO_SNDTIMEO 1
@ -220,75 +220,11 @@
#undef LWIP_NETIF_PROMISC
#define LWIP_NETIF_PROMISC 0
#undef LWIP_ICMP
#define LWIP_ICMP 0
#undef LWIP_DHCP
#define LWIP_DHCP 1
#undef LWIP_IGMP
#define LWIP_IGMP 0
#define MEMP_MEM_MALLOC 1
#undef LWIP_IPV6
#define LWIP_IPV6 0
#undef LWIP_IPV6_DHCP6
#define LWIP_IPV6_DHCP6 0
#undef TCP_SND_BUF
#define TCP_SND_BUF (65535 / 3)
#undef TCP_WND
#define TCP_WND ((TCP_SND_BUF * 2) / 3)
#undef TCP_SND_QUEUELEN
#define TCP_SND_QUEUELEN (2 * (TCP_SND_BUF / TCP_MSS))
#undef MEMP_NUM_NETDB
#define MEMP_NUM_NETDB 1
#undef MEMP_NUM_ARP_QUEUE
#define MEMP_NUM_ARP_QUEUE 4
#undef MEMP_NUM_NETBUF
#define MEMP_NUM_NETBUF 32
#undef MEMP_NUM_NETCONN
#define MEMP_NUM_NETCONN 32
#undef MEMP_NUM_PBUF
#define MEMP_NUM_PBUF 0
#undef PBUF_POOL_SIZE
#define PBUF_POOL_SIZE 0
#undef MEMP_NUM_RAW_PCB
#define MEMP_NUM_RAW_PCB 8
#undef MEMP_NUM_REASSDATA
#define MEMP_NUM_REASSDATA 12
#undef MEMP_NUM_TCPIP_MSG_API
#define MEMP_NUM_TCPIP_MSG_API 32
#undef MEMP_NUM_TCPIP_MSG_INPKT
#define MEMP_NUM_TCPIP_MSG_INPKT 32
#undef MEMP_NUM_TCP_PCB
#define MEMP_NUM_TCP_PCB 8
#undef MEMP_NUM_TCP_PCB_LISTEN
#define MEMP_NUM_TCP_PCB_LISTEN 4
#undef MEMP_NUM_TCP_SEG
#define MEMP_NUM_TCP_SEG 64
#undef MEMP_NUM_UDP_PCB
#define MEMP_NUM_UDP_PCB 4
#undef TCPIP_THREAD_STACKSIZE
#define TCPIP_THREAD_STACKSIZE 0x1000
#undef LWIP_SOCKET_SELECT
#define LWIP_SOCKET_SELECT 1

View File

@ -41,7 +41,6 @@
#include <limits.h>
#include <fcntl.h>
#include_next <lwip/sockets.h>
#include <fatfs.h>
#ifdef __cplusplus
extern "C" {

View File

@ -6,15 +6,15 @@
* 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.
* 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.
* 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.
* 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,
@ -29,18 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**********************************************************************************
* Notice of Export Control Law
===============================================
* Huawei LiteOS may be subject to applicable export control laws and regulations, which
* might include those applicable to Huawei LiteOS of U.S. and the country in which you
* are located.
* Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance
* with such applicable export control laws and regulations.
***********************************************************************************/
#define LWIP_STATIC static
#define DHCP_STATE_OFF 0
#define LWIP_EXT_POLL_SUPPORT 1
@ -345,7 +333,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
int ret = 0;
u32_t intrvl;
char *data_buf = NULL;
BOOL timeout_flag = false;
BOOL timeout_flag = FALSE;
char buf[50];
u32_t destip = parg[0];
@ -410,14 +398,14 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
do {
pfd.events = POLLIN;
pfd.revents = 0;
timeout_flag = false;
timeout_flag = FALSE;
ret = poll(&pfd, 1, LWIP_SHELL_CMD_PING_TIMEOUT);
if (ret < 0) {
perror("Ping: poll\n");
goto FAILURE;
} else if (ret == 0) {
/* first type timeout event */
timeout_flag = true;
timeout_flag = TRUE;
break;
}
@ -457,7 +445,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
} while (timout_ms >= 0);
/* all timeout events are true timeout */
if ((timout_ms < 0) || (timeout_flag == true)) {
if ((timout_ms < 0) || (timeout_flag == TRUE)) {
failed_cnt++;
i++;
PRINTK("\nPing: destination unreachable ...");
@ -600,7 +588,6 @@ u32_t OsShellPing(int argc, const char **argv)
stPingTask.uwArg = (UINTPTR)parg;
ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask);
if (ret != LOS_OK) {
free(parg);
PRINTK("ping_task create failed 0x%08x.\n", ret);
count = LWIP_SHELL_CMD_PING_RETRY_TIMES;
} else {
@ -616,6 +603,8 @@ u32_t OsShellPing(int argc, const char **argv)
PRINTK("Ping cmd failed due some errors\n");
}
free(parg);
return LOS_OK;
ping_error:
lwip_ping_usage();

View File

@ -29,8 +29,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "lwip/sockets.h"
#include "lwip/priv/tcpip_priv.h"
#include "lwip/priv/sockets_priv.h"
#include <lwip/sockets.h>
#if !LWIP_COMPAT_SOCKETS
#if LWIP_SOCKET
@ -160,6 +161,27 @@ int inet_pton(int af, const char *src, void *dst)
return lwip_inet_pton(af, src, dst);
}
#ifndef LWIP_INET_ADDR_FUNC
in_addr_t inet_addr(const char *cp)
{
return ipaddr_addr(cp);
}
#endif
#ifndef LWIP_INET_NTOA_FUNC
char *inet_ntoa(struct in_addr addr)
{
return ip4addr_ntoa((const ip4_addr_t*)&(addr));
}
#endif
#ifndef LWIP_INET_ATON_FUNC
int inet_aton(const char *cp, struct in_addr *addr)
{
return ip4addr_aton(cp, (ip4_addr_t*)addr);
}
#endif
int ioctlsocket(int s, long cmd, void *argp)
{
return lwip_ioctl(s, cmd, argp);
@ -185,4 +207,81 @@ unsigned int if_nametoindex(const char *ifname)
}
#endif
#endif /* !LWIP_COMPAT_SOCKETS */
#endif /* !LWIP_COMPAT_SOCKETS */
#define IOCTL_CMD_CASE_HANDLER() do { \
err_t err; \
struct lwip_ioctl_apimsg msg; \
msg.sock = sock; \
msg.cmd = cmd; \
msg.argp = argp; \
\
err = tcpip_api_call(lwip_do_ioctl_impl, &msg.call); \
if (err != ENOSYS) { \
sock_set_errno(sock, err); \
done_socket(sock); \
return -(err != ERR_OK); \
} \
} while (0)
struct lwip_ioctl_apimsg {
struct tcpip_api_call_data call;
struct lwip_sock *sock;
long cmd;
void *argp;
};
static err_t lwip_do_ioctl_impl(struct tcpip_api_call_data *call);
#include "../api/sockets.c"
static u8_t lwip_ioctl_internal_SIOCGIFBRDADDR(struct ifreq *ifr)
{
struct netif *netif = NULL;
struct sockaddr_in *sock_in = NULL;
/* get netif subnet broadcast addr */
netif = netif_find(ifr->ifr_name);
if (netif == NULL) {
return ENODEV;
}
if (ip4_addr_isany_val(*(ip_2_ip4(&netif->netmask)))) {
return ENXIO;
}
sock_in = (struct sockaddr_in *)&ifr->ifr_addr;
sock_in->sin_family = AF_INET;
sock_in->sin_addr.s_addr = (ip_2_ip4(&((netif)->ip_addr))->addr | ~(ip_2_ip4(&netif->netmask)->addr));
return 0;
}
static u8_t lwip_ioctl_impl(const struct lwip_sock *sock, long cmd, void *argp)
{
u8_t err = 0;
struct ifreq *ifr = (struct ifreq *)argp;
bool is_ipv6 = 0;
/* allow it only on IPv6 sockets... */
is_ipv6 = NETCONNTYPE_ISIPV6((unsigned int)(sock->conn->type));
switch ((u32_t)cmd) {
case SIOCGIFBRDADDR:
if (is_ipv6 != 0) {
err = EINVAL;
} else {
err = lwip_ioctl_internal_SIOCGIFBRDADDR(ifr);
}
break;
default:
err = ENOSYS;
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(UNIMPL: 0x%lx)\n", cmd));
break;
}
return err;
}
static err_t lwip_do_ioctl_impl(struct tcpip_api_call_data *call)
{
struct lwip_ioctl_apimsg *msg = (struct lwip_ioctl_apimsg *)(void *)call;
return lwip_ioctl_impl(msg->sock, msg->cmd, msg->argp);
}

View File

@ -34,20 +34,22 @@
#include "los_sched.h"
#include "los_timer.h"
#include "los_memory.h"
#include "los_swtmr.h"
#if (LOSCFG_KERNEL_PM == 1)
#define OS_PM_NODE_FREE 0x80000000U
#define OS_PM_LOCK_MAX 0xFFFFU
#define OS_PM_SYS_EARLY 1
#define OS_PM_SYS_DEVICE_EARLY 2
typedef UINT32 (*Suspend)(VOID);
typedef UINT32 (*Suspend)(UINT32 mode);
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
typedef struct {
CHAR *name;
UINT32 count;
UINT32 swtmrID;
LOS_DL_LIST list;
} OsPmLockCB;
#endif
typedef struct {
LOS_SysSleepEnum pmMode;
@ -60,72 +62,92 @@ typedef struct {
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
UINT64 enterSleepTime;
#endif
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
LOS_DL_LIST lockList;
#endif
} LosPmCB;
#define PM_EVENT_LOCK_MASK 0xF
#define PM_EVENT_LOCK_RELEASE 0x1
STATIC EVENT_CB_S g_pmEvent;
STATIC LosPmCB g_pmCB;
STATIC LosPmSysctrl *g_sysctrl = NULL;
STATIC LosPmSysctrl g_sysctrl;
STATIC UINT64 g_pmSleepTime;
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
STATIC VOID OsPmSysctrlInit(VOID)
{
UINT32 intSave;
UINT64 currTime, sleepTime, realSleepTime;
LosPmTickTimer *tickTimer = pm->tickTimer;
intSave = LOS_IntLock();
/* Restore the main CPU frequency */
sleepTime = tickTimer->timerCycleGet();
tickTimer->timerStop();
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, OS_SYS_CLOCK);
currTime = pm->enterSleepTime + realSleepTime;
pm->enterSleepTime = 0;
OsSchedTimerBaseReset(currTime);
OsSchedUpdateExpireTime(currTime, FALSE);
tickTimer->tickUnlock();
LOS_IntRestore(intSave);
return;
/* Default handler functions, which are implemented by the product */
g_sysctrl.early = NULL;
g_sysctrl.late = NULL;
g_sysctrl.normalSuspend = HalEnterSleep;
g_sysctrl.normalResume = NULL;
g_sysctrl.lightSuspend = HalEnterSleep;
g_sysctrl.lightResume = NULL;
g_sysctrl.deepSuspend = HalEnterSleep;
g_sysctrl.deepResume = NULL;
g_sysctrl.shutdownSuspend = NULL;
g_sysctrl.shutdownResume = NULL;
}
STATIC VOID OsPmTickTimerStop(LosPmCB *pm)
STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
{
UINT64 sleepCycle;
UINT64 realSleepTime = g_pmSleepTime;
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
UINT64 currTime, sleepTime, realSleepTime;
#endif
LosPmTickTimer *tickTimer = pm->tickTimer;
if (realSleepTime == 0) {
if ((tickTimer == NULL) || (tickTimer->tickUnlock == NULL)) {
return;
}
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, OS_SYS_CLOCK);
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
if (tickTimer->timerStop != NULL) {
/* Restore the main CPU frequency */
sleepTime = tickTimer->timerCycleGet();
tickTimer->timerStop();
/* The main CPU reduces the frequency */
pm->enterSleepTime = OsGetCurrSysTimeCycle();
tickTimer->tickLock();
tickTimer->timerStart(sleepCycle);
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, OS_SYS_CLOCK);
currTime = pm->enterSleepTime + realSleepTime;
pm->enterSleepTime = 0;
OsSchedTimerBaseReset(currTime);
}
#endif
tickTimer->tickUnlock();
return;
}
STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
{
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
UINT64 sleepCycle;
UINT64 realSleepTime = g_pmSleepTime;
#endif
LosPmTickTimer *tickTimer = pm->tickTimer;
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL)) {
return FALSE;
}
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
if (tickTimer->timerStart != NULL) {
if (realSleepTime == 0) {
return FALSE;
}
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, OS_SYS_CLOCK);
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
/* The main CPU reduces the frequency */
pm->enterSleepTime = OsGetCurrSysTimeCycle();
tickTimer->tickLock();
tickTimer->timerStart(sleepCycle);
return TRUE;
}
#endif
STATIC VOID OsPmTickTimerResume(LosPmCB *pm)
{
if ((pm->sysMode == LOS_SYS_DEEP_SLEEP) && (pm->tickTimer->tickUnlock != NULL)) {
pm->tickTimer->tickUnlock();
} else {
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
/* Sys tick timer is restored from low power mode */
if (pm->enterSleepTime != 0) {
OsPmTickTimerStart(pm);
}
#endif
}
tickTimer->tickLock();
return TRUE;
}
STATIC VOID OsPmCpuResume(LosPmCB *pm)
@ -139,126 +161,137 @@ STATIC VOID OsPmCpuResume(LosPmCB *pm)
}
}
STATIC Suspend OsPmCpuSuspend(LosPmCB *pm)
STATIC VOID OsPmCpuSuspend(LosPmCB *pm)
{
Suspend sysSuspend = NULL;
/* cpu enter low power mode */
LOS_ASSERT(pm->sysctrl != NULL);
if (pm->sysMode == LOS_SYS_NORMAL_SLEEP) {
sysSuspend = pm->sysctrl->normalSuspend;
pm->sysctrl->normalSuspend();
} else if (pm->sysMode == LOS_SYS_LIGHT_SLEEP) {
sysSuspend = pm->sysctrl->lightSuspend;
pm->sysctrl->lightSuspend();
} else if (pm->sysMode == LOS_SYS_DEEP_SLEEP) {
sysSuspend = pm->sysctrl->deepSuspend;
pm->sysctrl->deepSuspend();
} else {
sysSuspend = pm->sysctrl->shutdownSuspend;
pm->sysctrl->shutdownSuspend();
}
LOS_ASSERT(sysSuspend != NULL);
return sysSuspend;
}
STATIC VOID OsPmTickTimerSuspend(LosPmCB *pm)
STATIC VOID OsPmResumePrepare(LosPmCB *pm, UINT32 mode, UINT32 prepare)
{
if (((pm->sysMode == LOS_SYS_DEEP_SLEEP) || (pm->sysMode == LOS_SYS_SHUTDOWN)) &&
(pm->tickTimer->tickLock != NULL)) {
pm->tickTimer->tickLock();
} else {
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
/* Sys tick timer enter low power mode */
if (pm->tickTimer == NULL) {
return;
}
if ((prepare == 0) && (pm->device->resume != NULL)) {
pm->device->resume(mode);
}
if ((pm->tickTimer->timerStart != NULL) &&
(pm->tickTimer->timerStop != NULL) &&
(pm->tickTimer->timerCycleGet == NULL) &&
(pm->tickTimer->freq != 0)) {
OsPmTickTimerStop(pm);
}
#endif
if (((prepare == 0) || (prepare == OS_PM_SYS_DEVICE_EARLY)) && (pm->sysctrl->late != NULL)) {
pm->sysctrl->late(mode);
}
}
STATIC VOID OsPmEnter(BOOL isIdle)
STATIC UINT32 OsPmSuspendPrepare(Suspend sysSuspendEarly, Suspend deviceSuspend, UINT32 mode, UINT32 *prepare)
{
UINT32 ret;
if (sysSuspendEarly != NULL) {
ret = sysSuspendEarly(mode);
if (ret != LOS_OK) {
*prepare = OS_PM_SYS_EARLY;
return ret;
}
}
if (deviceSuspend != NULL) {
ret = deviceSuspend(mode);
if (ret != LOS_OK) {
*prepare = OS_PM_SYS_DEVICE_EARLY;
return ret;
}
}
return LOS_OK;
}
STATIC UINT32 OsPmSuspendCheck(LosPmCB *pm, Suspend *sysSuspendEarly, Suspend *deviceSuspend, LOS_SysSleepEnum *mode)
{
UINT32 intSave;
Suspend sysSuspend = NULL;
LosPmCB *pm = &g_pmCB;
BOOL isTaskLock = FALSE;
intSave = LOS_IntLock();
pm->sysMode = pm->pmMode;
if (isIdle) {
if ((pm->sysMode != LOS_SYS_NORMAL_SLEEP) && (pm->sysMode != LOS_SYS_LIGHT_SLEEP)) {
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
}
} else {
if ((pm->sysMode != LOS_SYS_DEEP_SLEEP) && (pm->sysMode != LOS_SYS_SHUTDOWN)) {
LOS_IntRestore(intSave);
return;
}
}
if ((pm->sysMode == LOS_SYS_NORMAL_SLEEP) || (pm->sysMode == LOS_SYS_LIGHT_SLEEP)) {
if (pm->lock > 0) {
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
}
} else if (pm->lock > 0) {
if (pm->lock > 0) {
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
LOS_IntRestore(intSave);
return;
return LOS_NOK;
}
if (pm->sysMode != LOS_SYS_NORMAL_SLEEP) {
pm->isWake = FALSE;
LOS_TaskLock();
isTaskLock = TRUE;
ret = pm->device->suspend((UINT32)pm->sysMode);
if (ret != LOS_OK) {
goto EXIT;
}
}
OsPmTickTimerSuspend(pm);
sysSuspend = OsPmCpuSuspend(pm);
pm->isWake = FALSE;
*mode = pm->sysMode;
*sysSuspendEarly = pm->sysctrl->early;
*deviceSuspend = pm->device->suspend;
LOS_IntRestore(intSave);
return LOS_OK;
}
if (!isTaskLock || (isTaskLock && !pm->isWake)) {
(VOID)sysSuspend();
STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
{
UINT32 ret, intSave;
Suspend sysSuspendEarly, deviceSuspend;
LOS_SysSleepEnum mode;
UINT32 prepare = 0;
BOOL tickTimerStop = FALSE;
UINT64 currTime;
ret = OsPmSuspendCheck(pm, &sysSuspendEarly, &deviceSuspend, &mode);
if (ret != LOS_OK) {
return ret;
}
ret = OsPmSuspendPrepare(sysSuspendEarly, deviceSuspend, (UINT32)mode, &prepare);
if (ret != LOS_OK) {
intSave = LOS_IntLock();
LOS_TaskLock();
goto EXIT;
}
intSave = LOS_IntLock();
LOS_TaskLock();
if (pm->isWake || (pm->lock > 0)) {
goto EXIT;
}
tickTimerStop = OsPmTickTimerStop(pm);
if (!tickTimerStop) {
currTime = OsGetCurrSchedTimeCycle();
OsSchedResetSchedResponseTime(0);
OsSchedUpdateExpireTime(currTime, TRUE);
}
OsPmCpuSuspend(pm);
OsPmCpuResume(pm);
OsPmTickTimerResume(pm);
if (pm->sysMode != LOS_SYS_NORMAL_SLEEP) {
pm->device->resume((UINT32)pm->sysMode);
}
if (pm->pmMode == LOS_SYS_DEEP_SLEEP) {
pm->pmMode = LOS_SYS_NORMAL_SLEEP;
}
OsPmTickTimerStart(pm);
EXIT:
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
OsPmResumePrepare(pm, (UINT32)mode, prepare);
LOS_IntRestore(intSave);
if (isTaskLock) {
LOS_TaskUnlock();
}
return;
LOS_TaskUnlock();
return ret;
}
STATIC VOID OsPmTask(VOID)
STATIC VOID OsPmNormalSleep(VOID)
{
OsPmEnter(FALSE);
UINT32 intSave;
LosPmCB *pm = &g_pmCB;
intSave = LOS_IntLock();
OsPmCpuSuspend(pm);
OsPmCpuResume(pm);
LOS_IntRestore(intSave);
}
STATIC UINT32 OsPmDeviceRegister(LosPmCB *pm, LosPmDevice *device)
@ -280,27 +313,60 @@ STATIC UINT32 OsPmTickTimerRegister(LosPmCB *pm, LosPmTickTimer *tickTimer)
{
UINT32 intSave;
intSave = LOS_IntLock();
if ((tickTimer->tickLock == NULL) || (tickTimer->tickUnlock == NULL)) {
return LOS_ERRNO_PM_INVALID_PARAM;
}
if (((tickTimer->timerStart == NULL) && (tickTimer->timerStop == NULL) &&
(tickTimer->timerCycleGet == NULL) && (tickTimer->freq == 0)) ||
((tickTimer->timerStart != NULL) && (tickTimer->timerStop != NULL) &&
(tickTimer->timerCycleGet != NULL) && (tickTimer->freq != 0))) {
intSave = LOS_IntLock();
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
pm->enterSleepTime = 0;
pm->enterSleepTime = 0;
#endif
pm->tickTimer = tickTimer;
LOS_IntRestore(intSave);
return LOS_OK;
pm->tickTimer = tickTimer;
LOS_IntRestore(intSave);
return LOS_OK;
}
return LOS_ERRNO_PM_INVALID_PARAM;
}
STATIC UINT32 OsPmSysctrlRegister(LosPmCB *pm, LosPmSysctrl *sysctrl)
{
UINT32 intSave;
if (sysctrl->normalSuspend == NULL) {
return LOS_ERRNO_PM_INVALID_PARAM;
UINT32 intSave = LOS_IntLock();
if (sysctrl->early != NULL) {
pm->sysctrl->early = sysctrl->early;
}
if (sysctrl->late != NULL) {
pm->sysctrl->late = sysctrl->late;
}
if (sysctrl->normalSuspend != NULL) {
pm->sysctrl->normalSuspend = sysctrl->normalSuspend;
}
if (sysctrl->normalResume != NULL) {
pm->sysctrl->normalResume = sysctrl->normalResume;
}
if (sysctrl->lightSuspend != NULL) {
pm->sysctrl->lightSuspend = sysctrl->lightSuspend;
}
if (sysctrl->lightResume != NULL) {
pm->sysctrl->lightResume = sysctrl->lightResume;
}
if (sysctrl->deepSuspend != NULL) {
pm->sysctrl->deepSuspend = sysctrl->deepSuspend;
}
if (sysctrl->deepResume != NULL) {
pm->sysctrl->deepResume = sysctrl->deepResume;
}
if (sysctrl->shutdownSuspend != NULL) {
pm->sysctrl->shutdownSuspend = sysctrl->shutdownSuspend;
}
if (sysctrl->shutdownResume != NULL) {
pm->sysctrl->shutdownResume = sysctrl->shutdownResume;
}
intSave = LOS_IntLock();
pm->sysctrl = sysctrl;
LOS_IntRestore(intSave);
return LOS_OK;
}
@ -362,27 +428,13 @@ STATIC UINT32 OsPmTickTimerUnregister(LosPmCB *pm, LosPmTickTimer *tickTimer)
STATIC UINT32 OsPmSysctrlUnregister(LosPmCB *pm, LosPmSysctrl *sysctrl)
{
UINT32 intSave;
VOID *freeNode = NULL;
intSave = LOS_IntLock();
if (pm->sysctrl == sysctrl) {
if (pm->sysctrl == g_sysctrl) {
freeNode = (VOID *)pm->sysctrl;
g_sysctrl = NULL;
}
pm->sysctrl = NULL;
LOS_IntRestore(intSave);
if (freeNode != NULL) {
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, freeNode);
}
return LOS_OK;
}
(VOID)sysctrl;
UINT32 intSave = LOS_IntLock();
OsPmSysctrlInit();
pm->pmMode = LOS_SYS_NORMAL_SLEEP;
LOS_IntRestore(intSave);
return LOS_ERRNO_PM_INVALID_NODE;
return LOS_OK;
}
UINT32 LOS_PmUnregister(LOS_PmNodeType type, VOID *node)
@ -433,11 +485,8 @@ LOS_SysSleepEnum LOS_PmModeGet(VOID)
UINT32 LOS_PmModeSet(LOS_SysSleepEnum mode)
{
UINT32 intSave;
UINT32 taskID;
UINT32 ret;
LosPmCB *pm = &g_pmCB;
INT32 sleepMode = (INT32)mode;
TSK_INIT_PARAM_S taskInitParam = { 0 };
if ((sleepMode < 0) || (sleepMode > LOS_SYS_SHUTDOWN)) {
return LOS_ERRNO_PM_INVALID_MODE;
@ -464,29 +513,9 @@ UINT32 LOS_PmModeSet(LOS_SysSleepEnum mode)
return LOS_ERRNO_PM_HANDLER_NULL;
}
if ((mode == LOS_SYS_DEEP_SLEEP) || (mode == LOS_SYS_SHUTDOWN)) {
if ((pm->tickTimer == NULL) ||
(pm->tickTimer->tickLock == NULL) ||
(pm->tickTimer->tickUnlock == NULL)) {
LOS_IntRestore(intSave);
return LOS_ERRNO_PM_TICK_TIMER_NULL;
}
}
pm->pmMode = mode;
LOS_IntRestore(intSave);
if ((mode == LOS_SYS_DEEP_SLEEP) || (mode == LOS_SYS_SHUTDOWN)) {
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsPmTask;
taskInitParam.uwStackSize = LOSCFG_KERNEL_PM_TASK_STACKSIZE;
taskInitParam.pcName = "pm";
taskInitParam.usTaskPrio = LOSCFG_KERNEL_PM_TASK_PTIORITY;
ret = LOS_TaskCreate(&taskID, &taskInitParam);
if (ret != LOS_OK) {
return ret;
}
}
return LOS_OK;
}
@ -513,24 +542,17 @@ VOID LOS_PmLockInfoShow(VOID)
}
#endif
UINT32 LOS_PmLockRequest(const CHAR *name)
UINT32 OsPmLockRequest(const CHAR *name, UINT32 swtmrID)
{
UINT32 intSave;
UINT32 ret = LOS_ERRNO_PM_NOT_LOCK;
LosPmCB *pm = &g_pmCB;
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
OsPmLockCB *listNode = NULL;
OsPmLockCB *lock = NULL;
LOS_DL_LIST *head = &pm->lockList;
LOS_DL_LIST *list = head->pstNext;
if (name == NULL) {
return LOS_ERRNO_PM_INVALID_PARAM;
}
#endif
intSave = LOS_IntLock();
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
while (list != head) {
listNode = LOS_DL_LIST_ENTRY(list, OsPmLockCB, list);
if (strcmp(name, listNode->name) == 0) {
@ -549,11 +571,17 @@ UINT32 LOS_PmLockRequest(const CHAR *name)
}
lock->name = (CHAR *)name;
lock->count = 1;
lock->swtmrID = swtmrID;
LOS_ListTailInsert(head, &lock->list);
} else if (lock->count < OS_PM_LOCK_MAX) {
lock->count++;
}
#endif
if ((lock->swtmrID != OS_INVALID) && (lock->count > 1)) {
lock->count--;
LOS_IntRestore(intSave);
return LOS_ERRNO_PM_ALREADY_LOCK;
}
if (pm->lock < OS_PM_LOCK_MAX) {
pm->lock++;
@ -564,25 +592,34 @@ UINT32 LOS_PmLockRequest(const CHAR *name)
return ret;
}
UINT32 LOS_PmLockRequest(const CHAR *name)
{
if (name == NULL) {
return LOS_ERRNO_PM_INVALID_PARAM;
}
return OsPmLockRequest(name, OS_INVALID);
}
UINT32 LOS_PmLockRelease(const CHAR *name)
{
UINT32 intSave;
UINT32 ret = LOS_ERRNO_PM_NOT_LOCK;
LosPmCB *pm = &g_pmCB;
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
OsPmLockCB *lock = NULL;
OsPmLockCB *listNode = NULL;
LOS_DL_LIST *head = &pm->lockList;
LOS_DL_LIST *list = head->pstNext;
VOID *lockFree = NULL;
OsPmLockCB *lockFree = NULL;
BOOL isRelease = FALSE;
UINT32 mode;
if (name == NULL) {
return LOS_ERRNO_PM_INVALID_PARAM;
}
#endif
intSave = LOS_IntLock();
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
mode = (UINT32)pm->pmMode;
while (list != head) {
listNode = LOS_DL_LIST_ENTRY(list, OsPmLockCB, list);
if (strcmp(name, listNode->name) == 0) {
@ -603,25 +640,141 @@ UINT32 LOS_PmLockRelease(const CHAR *name)
lockFree = lock;
}
}
#endif
if (pm->lock > 0) {
pm->lock--;
if (pm->lock == 0) {
isRelease = TRUE;
}
ret = LOS_OK;
}
LOS_IntRestore(intSave);
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, lockFree);
#endif
if (lockFree != NULL) {
(VOID)LOS_SwtmrDelete(lockFree->swtmrID);
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, lockFree);
}
if (isRelease && (mode > LOS_SYS_NORMAL_SLEEP)) {
(VOID)LOS_EventWrite(&g_pmEvent, PM_EVENT_LOCK_RELEASE);
}
return ret;
}
VOID OsPmFreezeTaskUnsafe(UINT32 taskID)
{
UINT64 responseTime;
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
OsDeleteSortLink(&taskCB->sortList, OS_SORT_LINK_TASK);
SET_SORTLIST_VALUE(&taskCB->sortList, responseTime);
taskCB->taskStatus |= OS_TASK_FALG_FREEZE;
return;
}
VOID OsPmUnfreezeTaskUnsafe(UINT32 taskID)
{
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
UINT64 currTime, responseTime;
UINT32 remainTick;
taskCB->taskStatus &= ~OS_TASK_FALG_FREEZE;
currTime = OsGetCurrSchedTimeCycle();
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
if (responseTime > currTime) {
remainTick = ((responseTime - currTime) + OS_CYCLE_PER_TICK - 1) / OS_CYCLE_PER_TICK;
OsAdd2SortLink(&taskCB->sortList, currTime, remainTick, OS_SORT_LINK_TASK);
return;
}
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
if (taskCB->taskStatus & OS_TASK_STATUS_PEND) {
LOS_ListDelete(&taskCB->pendList);
}
taskCB->taskStatus &= ~(OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_PEND);
return;
}
STATIC VOID OsPmSwtmrHandler(UINT32 arg)
{
const CHAR *name = (const CHAR *)arg;
UINT32 ret = LOS_PmLockRelease(name);
if (ret != LOS_OK) {
PRINT_ERR("Pm delay lock %s release faled! : 0x%x\n", name, ret);
}
}
UINT32 LOS_PmTimeLockRequest(const CHAR *name, UINT64 millisecond)
{
UINT32 ticks;
UINT32 swtmrID;
UINT32 ret;
if ((name == NULL) || !millisecond) {
return LOS_ERRNO_PM_INVALID_PARAM;
}
ticks = (UINT32)((millisecond + OS_MS_PER_TICK - 1) / OS_MS_PER_TICK);
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
ret = LOS_SwtmrCreate(ticks, LOS_SWTMR_MODE_ONCE, OsPmSwtmrHandler, &swtmrID, (UINT32)(UINTPTR)name,
OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE);
#else
ret = LOS_SwtmrCreate(ticks, LOS_SWTMR_MODE_ONCE, OsPmSwtmrHandler, &swtmrID, (UINT32)(UINTPTR)name);
#endif
if (ret != LOS_OK) {
return ret;
}
ret = OsPmLockRequest(name, swtmrID);
if (ret != LOS_OK) {
(VOID)LOS_SwtmrDelete(swtmrID);
return ret;
}
ret = LOS_SwtmrStart(swtmrID);
if (ret != LOS_OK) {
(VOID)LOS_PmLockRelease(name);
}
return ret;
}
UINT32 LOS_PmReadLock(VOID)
{
UINT32 ret = LOS_EventRead(&g_pmEvent, PM_EVENT_LOCK_MASK, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
if (ret > PM_EVENT_LOCK_MASK) {
PRINT_ERR("%s event read failed! ERROR: 0x%x\n", __FUNCTION__, ret);
}
return LOS_OK;
}
UINT32 LOS_PmSuspend(UINT32 wakeCount)
{
(VOID)wakeCount;
return OsPmSuspendSleep(&g_pmCB);
}
STATIC VOID OsPmSleepTimeSet(UINT64 sleepTime)
{
g_pmSleepTime = sleepTime;
}
BOOL OsIsPmMode(VOID)
{
LosPmCB *pm = &g_pmCB;
UINT32 intSave = LOS_IntLock();
if ((pm->sysMode != LOS_SYS_NORMAL_SLEEP) && (pm->lock == 0)) {
LOS_IntRestore(intSave);
return TRUE;
}
LOS_IntRestore(intSave);
return FALSE;
}
UINT32 OsPmInit(VOID)
{
UINT32 ret;
@ -630,34 +783,21 @@ UINT32 OsPmInit(VOID)
(VOID)memset_s(pm, sizeof(LosPmCB), 0, sizeof(LosPmCB));
pm->pmMode = LOS_SYS_NORMAL_SLEEP;
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
LOS_ListInit(&pm->lockList);
#endif
(VOID)LOS_EventInit(&g_pmEvent);
ret = OsSchedRealSleepTimeSet(OsPmSleepTimeSet);
if (ret != LOS_OK) {
return ret;
}
ret = OsPmEnterHandlerSet(OsPmEnter);
ret = OsPmEnterHandlerSet(OsPmNormalSleep);
if (ret != LOS_OK) {
return ret;
}
g_sysctrl = (LosPmSysctrl *)LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, sizeof(LosPmSysctrl));
if (g_sysctrl == NULL) {
return LOS_NOK;
}
(VOID)memset_s(g_sysctrl, sizeof(LosPmSysctrl), 0, sizeof(LosPmSysctrl));
g_sysctrl->normalSuspend = HalEnterSleep;
ret = LOS_PmRegister(LOS_PM_TYPE_SYSCTRL, (VOID *)g_sysctrl);
if (ret != LOS_OK) {
(VOID)LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, g_sysctrl);
g_sysctrl = NULL;
}
OsPmSysctrlInit();
pm->sysctrl = &g_sysctrl;
return ret;
}
#endif

View File

@ -118,6 +118,15 @@
*/
#define LOS_ERRNO_PM_DEVICE_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_PM, 0x09)
/**
* @ingroup los_pm
* Pm error code: The delay lock has already been activated.
*
* Value: 0x0200200a
*
*/
#define LOS_ERRNO_PM_ALREADY_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_PM, 0x0a)
typedef enum {
LOS_SYS_NORMAL_SLEEP = 0,
LOS_SYS_LIGHT_SLEEP,
@ -132,8 +141,8 @@ typedef enum {
} LOS_PmNodeType;
typedef struct {
UINT32 (*suspend)(UINT32 mode);
VOID (*resume)(UINT32 mode);
UINT32 (*suspend)(UINT32 mode); /* The device enters low power consumption, Unlocked task scheduling. */
VOID (*resume)(UINT32 mode); /* The device exits from low power consumption, Unlocked task scheduling. */
} LosPmDevice;
typedef struct {
@ -146,13 +155,47 @@ typedef struct {
} LosPmTickTimer;
typedef struct {
/* Preparations before the CPU enters low power consumption.
* All modes except normal mode are invoked.
* Unlocked task scheduling.
*/
UINT32 (*early)(UINT32 mode);
/* The system performs low-power recovery.
* All modes except normal mode are invoked.
* Unlocked task scheduling.
*/
VOID (*late)(UINT32 mode);
/* The system enters the Normal sleep mode.
* In normal mode, the value cannot be NULL.
*/
UINT32 (*normalSuspend)(VOID);
/* The system recovers from normal sleep.
* The value can be NULL.
*/
VOID (*normalResume)(VOID);
/* The system enters the light sleep mode.
* In light sleep mode, the value cannot be NULL.
*/
UINT32 (*lightSuspend)(VOID);
/* The system recovers from light sleep.
* The value can be NULL.
*/
VOID (*lightResume)(VOID);
/* The system enters the deep sleep mode.
* In deep sleep mode, the value cannot be NULL.
*/
UINT32 (*deepSuspend)(VOID);
/* The system recovers from deep sleep.
* The value can be NULL.
*/
VOID (*deepResume)(VOID);
/* The system enters the shutdown mode.
* In shutdown mode, the value cannot be NULL.
*/
UINT32 (*shutdownSuspend)(VOID);
/* The system recovers from shutdown.
* In shutdown mode, the value cannot be NULL.
*/
VOID (*shutdownResume)(VOID);
} LosPmSysctrl;
@ -174,6 +217,60 @@ typedef struct {
*/
UINT32 OsPmInit(VOID);
/**
* @ingroup los_pm
* @brief Whether the low power consumption condition is met.
*
* @par Description:
* This API is used to check whether low power consumption is met.
*
* @attention None.
*
* @param None.
*
* @retval TRUE or FALSE.
* @par Dependency:
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
* @see
*/
BOOL OsIsPmMode(VOID);
/**
* @ingroup los_pm
* @brief Freeze delay tasks, internal interfaces between modules.
*
* @par Description:
* This API is used to freeze delay tasks.
*
* @attention None.
*
* @param taskID [IN] task ID.
*
* @retval None.
* @par Dependency:
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
* @see OsPmUnfreezeTaskUnsafe
*/
VOID OsPmFreezeTaskUnsafe(UINT32 taskID);
/**
* @ingroup los_pm
* @brief Unfreeze delayed tasks, internal interface between modules.
*
* @par Description:
* This API is used to unfreeze delayed tasks.
*
* @attention None.
*
* @param taskID [IN] task ID.
*
* @retval None.
* @par Dependency:
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
* @see OsPmFreezeTaskUnsafe
*/
VOID OsPmUnfreezeTaskUnsafe(UINT32 taskID);
/**
* @ingroup los_pm
* @brief Register a power management node.
@ -285,6 +382,27 @@ UINT32 LOS_PmModeSet(LOS_SysSleepEnum mode);
*/
UINT32 LOS_PmLockRequest(const CHAR *name);
/**
* @ingroup los_pm
* @brief Request to obtain the lock in current mode, so that the system will not enter
* this mode when it enters the idle task next time. After the specified interval, the
* lock is automatically released.
*
* @par Description:
* This API is used to obtain the delay lock in current mode.
*
* @attention None.
*
* @param name [IN] Who requests the lock.
* @param millisecond [IN] Specifies the time to automatically release the lock.
*
* @retval error code, LOS_OK means success.
* @par Dependency:
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
* @see LOS_PmLockRelease
*/
UINT32 LOS_PmTimeLockRequest(const CHAR *name, UINT64 millisecond);
/**
* @ingroup los_pm
* @brief Release the lock in current mode so that the next time the system enters
@ -304,7 +422,42 @@ UINT32 LOS_PmLockRequest(const CHAR *name);
*/
UINT32 LOS_PmLockRelease(const CHAR *name);
#if (LOSCFG_KERNEL_PM_DEBUG == 1)
/**
* @ingroup los_pm
* @brief Gets the current PM lock status.
*
* @par Description:
* This API is used to Get the current PM lock status.
*
* @attention None.
*
* @param NA.
*
* @retval Number of awakening sources of the device.
* @par Dependency:
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
* @see
*/
UINT32 LOS_PmReadLock(VOID);
/**
* @ingroup los_pm
* @brief The system enters the low-power flow.
*
* @par Description:
* This API is used to enter the system into a low-power process.
*
* @attention None.
*
* @param wakeCount [IN] Number of wake sources.
*
* @retval error code, LOS_OK means success.
* @par Dependency:
* <ul><li>los_pm.h: the header file that contains the API declaration.</li></ul>
* @see
*/
UINT32 LOS_PmSuspend(UINT32 wakeCount);
/**
* @ingroup los_pm
* @brief Output the locking information of the pm lock.
@ -323,4 +476,3 @@ UINT32 LOS_PmLockRelease(const CHAR *name);
*/
VOID LOS_PmLockInfoShow(VOID);
#endif
#endif

View File

@ -42,6 +42,8 @@
EVENT_CB_S g_shellInputEvent;
#define SHELL_CMD_MAX_SIZE 64
#define VISIABLE_CHAR(ch) ((ch) > 0x1F && (ch) < 0x7F)
UINT32 ShellMsgTypeGet(CmdParsed *cmdParsed, const CHAR *cmdType)
{
CmdItemNode *curCmdItem = (CmdItemNode *)NULL;
@ -136,6 +138,9 @@ UINT32 PreHandleCmdline(const CHAR *input, CHAR **output, UINT32 *outputlen)
UINT32 ret;
const CHAR *cmdBuf = input;
UINT32 cmdBufLen = strlen(cmdBuf);
if ((cmdBufLen + 1) > SHELL_CMD_MAX_SIZE) {
return SH_NOK;
}
CHAR *shiftStr = (CHAR *)malloc(cmdBufLen + 1);
if (shiftStr == NULL) {
@ -232,9 +237,17 @@ VOID ShellTaskEntry(VOID)
CHAR buf[SHELL_CMD_MAX_SIZE] = {0};
CHAR *ptr = buf;
PRINTK("OHOS # ");
while(1) {
while (1) {
(VOID)LOS_EventRead(&g_shellInputEvent, 0x1, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, LOS_WAIT_FOREVER);
while((*ptr = (UINT8)UartGetc()) != 0 && *ptr != 13) {
while ((*ptr = (UINT8)UartGetc()) != 0 && *ptr != 13) {
if (*ptr == '\x03') { /* ctrl + c */
PRINTK("^C\n\rOHOS # ", *ptr);
ptr = buf;
break;
}
if (!VISIABLE_CHAR(*ptr)) {
break;
}
PRINTK("%c", *ptr);
if ((ptr - buf) == (sizeof(buf) - 1)) {
break;
@ -243,14 +256,13 @@ VOID ShellTaskEntry(VOID)
}
if (ptr != buf) {
if (*ptr == 13 || ((ptr - buf) == (sizeof(buf) - 1))) {
PRINTK("%c", *ptr);
*ptr = '\0';
ptr = buf;
PRINTK("\n\r", buf);
PRINTK("\n\r");
ExecCmdline(buf);
PRINTK("OHOS # ");
}
} else {
} else if (*ptr == 13) {
PRINTK("\n\rOHOS # ");
}
}

View File

@ -31,6 +31,10 @@
#include "shcmd.h"
#define DEFAULT_SCREEN_WIDTH 80
#define MAX_CMD_KEY_WIDTH 8
#define CMD_ITEM_PER_LINE (DEFAULT_SCREEN_WIDTH / (MAX_CMD_KEY_WIDTH + 1))
INT32 OsShellCmdHelp(INT32 argc, const CHAR **argv)
{
UINT32 loop = 0;
@ -45,10 +49,10 @@ INT32 OsShellCmdHelp(INT32 argc, const CHAR **argv)
PRINTK("*******************shell commands:*************************\n");
LOS_DL_LIST_FOR_EACH_ENTRY(curCmdItem, &(cmdInfo->cmdList.list), CmdItemNode, list) {
if ((loop & (8 - 1)) == 0) { /* 8 - 1:just align print */
if ((loop % CMD_ITEM_PER_LINE) == 0) { /* just align print */
PRINTK("\n");
}
PRINTK("%-12s ", curCmdItem->cmd->cmdKey);
PRINTK("%-8s ", curCmdItem->cmd->cmdKey);
loop++;
}

View File

@ -39,27 +39,6 @@
#define OS_INVALID_SEM_ID 0xFFFFFFFF
#define OS_ALL_TASK_MASK 0xFFFFFFFF
LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellCmdConvertTskStatus(UINT16 taskStatus)
{
if (taskStatus & OS_TASK_STATUS_RUNNING) {
return (UINT8 *)"Running";
} else if (taskStatus & OS_TASK_STATUS_READY) {
return (UINT8 *)"Ready";
} else {
if (taskStatus & OS_TASK_STATUS_DELAY) {
return (UINT8 *)"Delay";
} else if (taskStatus & OS_TASK_STATUS_PEND_TIME) {
return (UINT8 *)"PendTime";
} else if (taskStatus & OS_TASK_STATUS_PEND) {
return (UINT8 *)"Pend";
} else if (taskStatus & OS_TASK_STATUS_SUSPEND) {
return (UINT8 *)"Suspend";
}
}
return (UINT8 *)"Invalid";
}
LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdTskInfoTitle(VOID)
{
PRINTK("Name TaskEntryAddr TID ");
@ -95,7 +74,6 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdTskInfoData(const LosTaskCB *allTas
{
const LosTaskCB *taskCB = NULL;
UINT32 loop;
UINT32 semId;
#if (LOSCFG_TASK_MEM_USED == 1)
UINT32 arraySize = sizeof(UINT32) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1);
@ -105,7 +83,7 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdTskInfoData(const LosTaskCB *allTas
return;
}
(VOID)memset_s(getUsedSizeArray, arraySize, 0, arraySize);
OsTaskMemUsed(m_aucSysMem0, getUsedSizeArray, arraySize);
OsTaskMemUsed(m_aucSysMem0, getUsedSizeArray, (LOSCFG_BASE_CORE_TSK_LIMIT + 1));
#endif
for (loop = 0; loop < g_taskMaxNum; ++loop) {
@ -114,17 +92,15 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsShellCmdTskInfoData(const LosTaskCB *allTas
continue;
}
semId = OsGetSemID(taskCB);
PRINTK("%-23s%-20p0x%-5x", taskCB->taskName, taskCB->taskEntry, taskCB->taskID);
#if (LOSCFG_TASK_MEM_USED == 1)
PRINTK("%-11u%-13s0x%-11x 0x%-11x 0x%-8x 0x%-10x ", taskCB->priority,
OsShellCmdConvertTskStatus(taskCB->taskStatus), getUsedSizeArray[loop], taskCB->stackSize,
taskCB->stackPointer, taskCB->topOfStack, semId);
OsConvertTskStatus(taskCB->taskStatus), getUsedSizeArray[loop], taskCB->stackSize,
taskCB->stackPointer, taskCB->topOfStack);
#else
PRINTK("%-11u%-13s0x%-11x 0x%-8x 0x%-10x ", taskCB->priority,
OsShellCmdConvertTskStatus(taskCB->taskStatus), taskCB->stackSize,
taskCB->stackPointer, taskCB->topOfStack, semId);
OsConvertTskStatus(taskCB->taskStatus), taskCB->stackSize,
taskCB->stackPointer, taskCB->topOfStack);
#endif
PRINTK("\n");
}

View File

@ -276,6 +276,7 @@ int OsShellCmdCat(int argc, const char **argv)
if (fd == -1) {
ret = -1;
free(fullpath);
return ret;
}
@ -522,7 +523,10 @@ static int OsShellCmdDoRmdir(const char *pathname)
char *fullpath = NULL;
int ret;
(void)memset_s(&statInfo, sizeof(statInfo), 0, sizeof(struct stat));
ret = memset_s(&statInfo, sizeof(struct stat), 0, sizeof(struct stat));
if (ret != 0) {
return -1;
}
if (stat(pathname, &statInfo) != 0) {
return -1;
}

View File

@ -218,7 +218,7 @@ STATIC VOID LOS_TraceSwtmrExpired(const SWTMR_CTRL_S *swtmr)
STATIC VOID LOS_TraceSwtmrStart(const SWTMR_CTRL_S *swtmr)
{
LOS_TRACE(SWTMR_START, swtmr->usTimerID, swtmr->ucMode, swtmr->uwCount, swtmr->uwInterval, 0);
LOS_TRACE(SWTMR_START, swtmr->usTimerID, swtmr->ucMode, swtmr->uwInterval);
}
STATIC VOID LOS_TraceSwtmrStop(const SWTMR_CTRL_S *swtmr)

View File

@ -240,7 +240,7 @@ STATIC UINT32 OsCreateTraceAgentTask(VOID)
}
#endif
UINT32 LOS_TraceInit(VOID *buf, UINT32 size)
UINT32 OsTraceInit(VOID)
{
UINT32 intSave;
UINT32 ret;
@ -267,10 +267,15 @@ UINT32 LOS_TraceInit(VOID *buf, UINT32 size)
}
#endif
ret = OsTraceBufInit(buf, size);
#if (LOSCFG_RECORDER_MODE_OFFLINE == 1)
ret = OsTraceBufInit(LOSCFG_TRACE_BUFFER_SIZE);
if (ret != LOS_OK) {
goto LOS_RELEASE;
#if (LOSCFG_TRACE_CONTROL_AGENT == 1)
(VOID)LOS_TaskDelete(g_traceTaskId);
#endif
goto LOS_ERREND;
}
#endif
OsTraceHookInstall();
OsTraceCnvInit();
@ -286,10 +291,6 @@ UINT32 LOS_TraceInit(VOID *buf, UINT32 size)
#endif
TRACE_UNLOCK(intSave);
return LOS_OK;
LOS_RELEASE:
#if (LOSCFG_TRACE_CONTROL_AGENT == 1)
LOS_TaskDelete(g_traceTaskId);
#endif
LOS_ERREND:
TRACE_UNLOCK(intSave);
return ret;

View File

@ -287,7 +287,6 @@ typedef struct {
*
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @since Huawei LiteOS V200R005C00
*/
typedef BOOL (*TRACE_HWI_FILTER_HOOK)(UINT32 hwiNum);
@ -321,7 +320,7 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
#define TASK_RESUME_PARAMS(taskId, taskStatus, prio) taskId, taskStatus, prio
#define TASK_SIGNAL_PARAMS(taskId, signal, schedFlag) // taskId, signal, schedFlag
#define SWTMR_START_PARAMS(swtmrId, mode, overrun, interval, expiry) swtmrId, mode, overrun, interval, expiry
#define SWTMR_START_PARAMS(swtmrId, mode, interval) swtmrId, mode, interval
#define SWTMR_DELETE_PARAMS(swtmrId) swtmrId
#define SWTMR_EXPIRED_PARAMS(swtmrId) swtmrId
#define SWTMR_STOP_PARAMS(swtmrId) swtmrId
@ -391,7 +390,6 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
*
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @since Huawei LiteOS V200R005C00
*/
#define LOS_TRACE(TYPE, IDENTITY, ...) \
do { \
@ -423,7 +421,6 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
*
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @since Huawei LiteOS V200R005C00
*/
#define LOS_TRACE_EASY(TYPE, IDENTITY, ...) \
do { \
@ -437,34 +434,6 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
#define LOS_TRACE_EASY(...)
#endif
/**
* @ingroup los_trace
* @brief Intialize the trace when the system startup.
*
* @par Description:
* This API is used to intilize the trace for system level.
* @attention
* <ul>
* <li>This API can be called only after the memory is initialized. Otherwise, the Trace Init will be fail.</li>
* </ul>
*
* @param buf [IN] Type #VOID *. The ptr is trace buffer address, if ptr is NULL, system will malloc a new one in
* trace offline mode.
* @param size [IN] Type #UINT32. The trace buffer's size.
*
* @retval #LOS_ERRNO_TRACE_ERROR_STATUS 0x02001400: The trace status is not TRACE_UNINIT.
* @retval #LOS_ERRNO_TRACE_NO_MEMORY 0x02001401: The memory is not enough for initilize.
* @retval #LOS_ERRNO_TRACE_BUF_TOO_SMALL 0x02001402: Trace buf size not enough.
* @retval #LOS_ERRNO_TSK_TCB_UNAVAILABLE 0x02000211: No free task control block is available.
* @retval #LOS_ERRNO_TSK_MP_SYNC_RESOURCE 0x02000225: Mp sync resource create failed
* @retval #LOS_OK 0x00000000: The intialization is successful.
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceInit
* @since Huawei LiteOS V200R005C00
*/
extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
/**
* @ingroup los_trace
* @brief Start trace.
@ -483,7 +452,6 @@ extern UINT32 LOS_TraceInit(VOID *buf, UINT32 size);
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceStart
* @since Huawei LiteOS V200R005C00
*/
extern UINT32 LOS_TraceStart(VOID);
@ -504,7 +472,6 @@ extern UINT32 LOS_TraceStart(VOID);
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceStop
* @since Huawei LiteOS V200R005C00
*/
extern VOID LOS_TraceStop(VOID);
@ -525,7 +492,6 @@ extern VOID LOS_TraceStop(VOID);
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceReset
* @since Huawei LiteOS V200R005C00
*/
extern VOID LOS_TraceReset(VOID);
@ -549,7 +515,6 @@ extern VOID LOS_TraceReset(VOID);
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceEventMaskSet
* @since Huawei LiteOS V200R005C00
*/
extern VOID LOS_TraceEventMaskSet(UINT32 mask);
@ -572,7 +537,6 @@ extern VOID LOS_TraceEventMaskSet(UINT32 mask);
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceRecordDump
* @since Huawei LiteOS V200R005C00
*/
extern VOID LOS_TraceRecordDump(BOOL toClient);
@ -595,7 +559,6 @@ extern VOID LOS_TraceRecordDump(BOOL toClient);
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceRecordGet
* @since Huawei LiteOS V200R005C00
*/
extern OfflineHead *LOS_TraceRecordGet(VOID);
@ -616,7 +579,6 @@ extern OfflineHead *LOS_TraceRecordGet(VOID);
* @par Dependency:
* <ul><li>los_trace.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceHwiFilterHookReg
* @since Huawei LiteOS V200R005C00
*/
extern VOID LOS_TraceHwiFilterHookReg(TRACE_HWI_FILTER_HOOK hook);
#ifdef __cplusplus

View File

@ -119,10 +119,10 @@ typedef struct {
OfflineHead *head;
} TraceOfflineHeaderInfo;
extern UINT32 OsTraceInit(VOID);
extern UINT32 OsTraceGetMaskTid(UINT32 taskId);
extern VOID OsTraceSetObj(ObjData *obj, const LosTaskCB *tcb);
extern VOID OsTraceWriteOrSendEvent(const TraceEventFrame *frame);
extern UINT32 OsTraceBufInit(VOID *buf, UINT32 size);
extern VOID OsTraceObjAdd(UINT32 eventType, UINT32 taskId);
extern BOOL OsTraceIsEnable(VOID);
extern OfflineHead *OsTraceRecordGet(VOID);
@ -145,6 +145,7 @@ extern VOID OsTraceSendNotify(UINT32 type, UINT32 value);
#define OsTraceReset()
#define OsTraceRecordDump(toClient)
#else
extern UINT32 OsTraceBufInit(UINT32 size);
extern VOID OsTraceReset(VOID);
extern VOID OsTraceRecordDump(BOOL toClient);
#define OsTraceNotifyStart()

View File

@ -85,7 +85,6 @@ typedef struct {
* @par Dependency:
* <ul><li>trace_tlv.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TraceDataEncode
* @since Huawei LiteOS V200R005C00
*/
extern UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *dest, INT32 destLen);

View File

@ -49,21 +49,19 @@ UINT32 OsTraceGetMaskTid(UINT32 tid)
return tid | ((tid < LOSCFG_BASE_CORE_TSK_LIMIT) ? g_tidMask[tid] << BITS_NUM_FOR_TASK_ID : 0); /* tid < 65535 */
}
UINT32 OsTraceBufInit(VOID *buf, UINT32 size)
UINT32 OsTraceBufInit(UINT32 size)
{
UINT32 headSize;
VOID *buf = NULL;
headSize = sizeof(OfflineHead) + sizeof(ObjData) * LOSCFG_TRACE_OBJ_MAX_NUM;
if (size <= headSize) {
TRACE_ERROR("trace buf size not enough than 0x%x\n", headSize);
return LOS_ERRNO_TRACE_BUF_TOO_SMALL;
}
buf = LOS_MemAlloc(m_aucSysMem0, size);
if (buf == NULL) {
buf = LOS_MemAlloc(m_aucSysMem0, size);
if (buf == NULL) {
return LOS_ERRNO_TRACE_NO_MEMORY;
}
return LOS_ERRNO_TRACE_NO_MEMORY;
}
(VOID)memset_s(buf, size, 0, size);

View File

@ -44,13 +44,6 @@ UINT32 OsTraceGetMaskTid(UINT32 taskId)
return taskId;
}
UINT32 OsTraceBufInit(VOID *buf, UINT32 size)
{
(VOID)buf;
(VOID)size;
return LOS_OK;
}
VOID OsTraceSendHead(VOID)
{
TraceBaseHeaderInfo head = {

View File

@ -112,7 +112,7 @@ osStatus_t osKernelGetInfo(osVersion_t *version, char *id_buf, uint32_t id_size)
}
uwRet = memcpy_s(id_buf, id_size, KERNEL_ID, id_size);
if (uwRet != EOK) {
PRINT_ERR("%s[%d] memcpy failed, error type = %u\n", __FUNCTION__, __LINE__, uwRet);
PRINT_ERR("%s[%d] memcpy failed, error type = %lu\n", __FUNCTION__, __LINE__, uwRet);
return osError;
}
}
@ -299,7 +299,9 @@ osThreadId_t osThreadNew(osThreadFunc_t func, void *argument, const osThreadAttr
stTskInitParam.uwStackSize = attr ? attr->stack_size : LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
stTskInitParam.pcName = (CHAR *)(attr ? attr->name : "[NULL]");
stTskInitParam.usTaskPrio = usPriority;
if (attr->attr_bits == osThreadJoinable) {
stTskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
}
uwRet = LOS_TaskCreate(&uwTid, &stTskInitParam);
if (LOS_OK != uwRet) {
@ -576,6 +578,46 @@ osStatus_t osThreadResume(osThreadId_t thread_id)
}
osStatus_t osThreadDetach(osThreadId_t thread_id)
{
UINT32 ret;
LosTaskCB *taskCB = (LosTaskCB *)thread_id;
if (thread_id == NULL) {
return osErrorParameter;
}
ret = LOS_TaskDetach(taskCB->taskID);
if (ret == LOS_ERRNO_TSK_NOT_ALLOW_IN_INT) {
return osErrorISR;
} else if (ret != LOS_OK) {
return osErrorResource;
}
return osOK;
}
osStatus_t osThreadJoin(osThreadId_t thread_id)
{
UINT32 ret;
LosTaskCB *taskCB = (LosTaskCB *)thread_id;
if (thread_id == NULL) {
return osErrorParameter;
}
ret = LOS_TaskJoin(taskCB->taskID, NULL);
if (ret == LOS_ERRNO_TSK_NOT_ALLOW_IN_INT) {
return osErrorISR;
} else if (ret != LOS_OK) {
return osErrorResource;
}
return osOK;
}
osStatus_t osThreadTerminate(osThreadId_t thread_id)
{
UINT32 uwRet;
@ -1087,8 +1129,9 @@ osStatus_t osMutexDelete(osMutexId_t mutex_id)
osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr)
{
UINT32 uwRet;
UINT32 uwRet = LOS_NOK;
UINT32 uwSemId;
UINT32 intSave;
UNUSED(attr);
@ -1096,14 +1139,16 @@ osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const
return (osSemaphoreId_t)NULL;
}
if (1 == max_count) {
uwRet = LOS_BinarySemCreate((UINT16)initial_count, &uwSemId);
} else {
if (max_count > 0 && max_count <= OS_SEM_COUNTING_MAX_COUNT) {
uwRet = LOS_SemCreate((UINT16)initial_count, &uwSemId);
}
if (uwRet == LOS_OK) {
return (osSemaphoreId_t)(GET_SEM(uwSemId));
osSemaphoreId_t semaphore_id = (osSemaphoreId_t)(GET_SEM(uwSemId));
intSave = LOS_IntLock();
((LosSemCB *)semaphore_id)->maxSemCount = max_count;
LOS_IntRestore(intSave);
return semaphore_id;
} else {
return (osSemaphoreId_t)NULL;
}

View File

@ -34,56 +34,65 @@
#include <stdlib.h>
#include <unistd.h>
#include <securec.h>
#include <limits.h>
#include "los_config.h"
#include "los_task.h"
#define PTHREAD_DEFAULT_NAME "pthread"
#define PTHREAD_DEFAULT_NAME_LEN 8
#define PTHREAD_NAMELEN 16
typedef struct {
void *(*startRoutine)(void *);
void *param;
char name[PTHREAD_NAMELEN];
}PthreadData;
} PthreadData;
static void *PthreadEntry(UINT32 param)
{
PthreadData *pthreadData = (PthreadData *)(UINTPTR)param;
void *(*startRoutine)(void *) = pthreadData->startRoutine;
void *ret = startRoutine(pthreadData->param);
free(pthreadData);
pthread_exit(ret);
return ret;
}
static inline int IsPthread(pthread_t thread)
{
return ((UINT32)thread <= LOSCFG_BASE_CORE_TSK_LIMIT) &&
(OS_TCB_FROM_TID((UINT32)thread)->taskEntry == PthreadEntry);
return ((UINT32)thread <= LOSCFG_BASE_CORE_TSK_LIMIT);
}
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*startRoutine)(void *), void *arg)
static int PthreadCreateAttrInit(const pthread_attr_t *attr, void *(*startRoutine)(void *), void *arg,
TSK_INIT_PARAM_S *taskInitParam)
{
TSK_INIT_PARAM_S taskInitParam = {0};
const pthread_attr_t *threadAttr = attr;
struct sched_param schedParam = { 0 };
PthreadData *pthreadData = NULL;
UINT32 taskID;
if ((thread == NULL) || (startRoutine == NULL)) {
return EINVAL;
INT32 policy = 0;
pthread_attr_t attrTmp;
INT32 ret;
errno_t error;
if (!attr) {
(VOID)pthread_attr_init(&attrTmp);
threadAttr = &attrTmp;
}
taskInitParam.usTaskPrio = LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO;
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
if (attr) {
if (attr->detachstate == PTHREAD_CREATE_DETACHED) {
return ENOTSUP;
if (threadAttr->stackaddr_set != 0) {
return ENOTSUP;
}
if (threadAttr->stacksize < PTHREAD_STACK_MIN) {
return EINVAL;
}
taskInitParam->uwStackSize = threadAttr->stacksize;
if (threadAttr->inheritsched == PTHREAD_EXPLICIT_SCHED) {
taskInitParam->usTaskPrio = (UINT16)threadAttr->schedparam.sched_priority;
} else {
ret = pthread_getschedparam(pthread_self(), &policy, &schedParam);
if (ret != 0) {
return ret;
}
if (attr->stackaddr_set) {
return ENOTSUP;
}
if (attr->stacksize_set) {
taskInitParam.uwStackSize = attr->stacksize;
}
taskInitParam.usTaskPrio = (UINT16)attr->schedparam.sched_priority;
taskInitParam->usTaskPrio = (UINT16)schedParam.sched_priority;
}
pthreadData = (PthreadData *)malloc(sizeof(PthreadData));
@ -91,19 +100,42 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
return ENOMEM;
}
pthreadData->startRoutine = startRoutine;
pthreadData->param = arg;
taskInitParam.pcName = pthreadData->name;
taskInitParam.pfnTaskEntry = PthreadEntry;
taskInitParam.uwArg = (UINT32)(UINTPTR)pthreadData;
if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) {
error = memcpy_s(pthreadData->name, PTHREAD_NAMELEN, PTHREAD_DEFAULT_NAME, PTHREAD_DEFAULT_NAME_LEN);
if (error != EOK) {
free(pthreadData);
return error;
}
pthreadData->startRoutine = startRoutine;
pthreadData->param = arg;
taskInitParam->pcName = pthreadData->name;
taskInitParam->pfnTaskEntry = PthreadEntry;
taskInitParam->uwArg = (UINT32)(UINTPTR)pthreadData;
if (threadAttr->detachstate != PTHREAD_CREATE_DETACHED) {
taskInitParam->uwResved = LOS_TASK_ATTR_JOINABLE;
}
return 0;
}
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*startRoutine)(void *), void *arg)
{
TSK_INIT_PARAM_S taskInitParam = { 0 };
UINT32 taskID;
UINT32 ret;
if ((thread == NULL) || (startRoutine == NULL)) {
return EINVAL;
}
/* set pthread default name */
(void)sprintf_s(taskInitParam.pcName, PTHREAD_NAMELEN, "pthread%u", taskID);
ret = PthreadCreateAttrInit(attr, startRoutine, arg, &taskInitParam);
if (ret != 0) {
return ret;
}
if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) {
free((VOID *)(UINTPTR)taskInitParam.uwArg);
return EINVAL;
}
(void)LOS_TaskResume(taskID);
@ -164,55 +196,74 @@ int pthread_cancel(pthread_t thread)
int pthread_join(pthread_t thread, void **retval)
{
UINT32 taskStatus;
if (!IsPthread(thread)) {
UINTPTR result;
UINT32 ret = LOS_TaskJoin((UINT32)thread, &result);
if (ret == LOS_ERRNO_TSK_NOT_JOIN_SELF) {
return EDEADLK;
} else if (ret != LOS_OK) {
return EINVAL;
}
if (retval) {
/* retrieve thread exit code is not supported currently */
return ENOTSUP;
if (retval != NULL) {
*retval = (VOID *)result;
}
if (thread == pthread_self()) {
return EDEADLK;
}
while (LOS_TaskStatusGet((UINT32)thread, &taskStatus) == LOS_OK) {
(void)LOS_TaskDelay(10); /* 10: Waiting for the end of thread execution. */
}
return 0;
}
int pthread_detach(pthread_t thread)
{
if (!IsPthread(thread)) {
UINT32 ret = LOS_TaskDetach((UINT32)thread);
if (ret == LOS_ERRNO_TSK_NOT_JOIN) {
return ESRCH;
} else if (ret != LOS_OK) {
return EINVAL;
}
return ENOSYS;
return 0;
}
void pthread_exit(void *retVal)
{
(void)retVal;
UINT32 intSave;
LosTaskCB *tcb = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
free((PthreadData *)(UINTPTR)tcb->arg);
(void)LOS_TaskDelete(LOS_CurTaskIDGet());
tcb->joinRetval = (UINTPTR)retVal;
PthreadData *pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
intSave = LOS_IntLock();
tcb->taskName = PTHREAD_DEFAULT_NAME;
LOS_IntRestore(intSave);
free(pthreadData);
(void)LOS_TaskDelete(tcb->taskID);
}
int pthread_setname_np(pthread_t thread, const char *name)
{
UINT32 intSave;
LosTaskCB *taskCB = NULL;
char *taskName = LOS_TaskNameGet((UINT32)thread);
if (taskName == NULL || !IsPthread(thread)) {
return EINVAL;
}
if (strnlen(name, PTHREAD_NAMELEN) >= PTHREAD_NAMELEN) {
return ERANGE;
}
(void)strcpy_s(taskName, PTHREAD_NAMELEN, name);
taskCB = OS_TCB_FROM_TID((UINT32)thread);
intSave = LOS_IntLock();
if (taskCB->taskStatus & OS_TASK_STATUS_EXIT) {
LOS_IntRestore(intSave);
return EINVAL;
}
if (taskCB->taskEntry == PthreadEntry) {
(void)strcpy_s(taskName, PTHREAD_NAMELEN, name);
} else {
LOS_IntRestore(intSave);
return EINVAL;
}
LOS_IntRestore(intSave);
return 0;
}

View File

@ -202,18 +202,22 @@ STATIC INT32 ProcessReturnVal(pthread_cond_t *cond, INT32 val)
}
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec *absTime)
const struct timespec *ts)
{
UINT32 absTicks;
INT32 ret;
UINT64 absTicks;
const UINT32 nsPerTick = OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND;
struct timespec tp;
UINT64 nseconds;
UINT64 currTime;
if ((cond == NULL) || (mutex == NULL) || (absTime == NULL)) {
if ((cond == NULL) || (mutex == NULL) || (ts == NULL)) {
return EINVAL;
}
if (CondInitCheck(cond)) {
ret = pthread_cond_init(cond, NULL);
if (ret != ENOERR) {
if (ret != 0) {
return ret;
}
}
@ -222,22 +226,28 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
cond->count++;
(VOID)pthread_mutex_unlock(cond->mutex);
if ((absTime->tv_sec == 0) && (absTime->tv_nsec == 0)) {
return ETIMEDOUT;
}
if (!ValidTimeSpec(absTime)) {
if (!ValidTimeSpec(ts)) {
return EINVAL;
}
absTicks = OsTimeSpec2Tick(absTime);
if (pthread_mutex_unlock(mutex) != ENOERR) {
clock_gettime(CLOCK_REALTIME, &tp);
currTime = (UINT64)tp.tv_sec * OS_SYS_NS_PER_SECOND + tp.tv_nsec;
nseconds = (UINT64)ts->tv_sec * OS_SYS_NS_PER_SECOND + ts->tv_nsec;
if (currTime >= nseconds) {
return ETIMEDOUT;
}
absTicks = ((nseconds - currTime) + nsPerTick - 1) / nsPerTick + 1;
if (absTicks >= UINT32_MAX) {
return EINVAL;
}
if (pthread_mutex_unlock(mutex) != 0) {
PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);
}
ret = (INT32)LOS_EventRead(&(cond->event), 0x0f, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, absTicks);
ret = (INT32)LOS_EventRead(&(cond->event), 0x0f, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, (UINT32)absTicks);
if (pthread_mutex_lock(mutex) != ENOERR) {
if (pthread_mutex_lock(mutex) != 0) {
PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);
}

View File

@ -93,6 +93,7 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex)
return MapError(ret);
}
mutex->handle = _MUX_INVALID_HANDLE;
mutex->magic = 0;
return 0;
}

View File

@ -63,9 +63,6 @@ STATIC const UINT8 g_montbl[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
*/
long timezone = -8 * 60 * 60; // defaults to CST: 8 hours east of the Prime Meridian
/* internal shared struct tm object for localtime and gmtime */
static struct tm g_tm;
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
UINT64 nseconds;
@ -508,7 +505,8 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result)
struct tm *gmtime(const time_t *timer)
{
return gmtime_r(timer, &g_tm);
static struct tm tm;
return gmtime_r(timer, &tm);
}
struct tm *localtime_r(const time_t *timep, struct tm *result)
@ -526,7 +524,8 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
struct tm *localtime(const time_t *timer)
{
return localtime_r(timer, &g_tm);
static struct tm tm;
return localtime_r(timer, &tm);
}
static time_t ConvertUtc2Secs(struct tm *tm)

View File

@ -49,7 +49,7 @@
#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_INT_DISABLE(num) (*((volatile UINT32 *)OS_INT_ENABLE_ADDR) &= ~(1U << (num)))
#define OS_INSTR_SET_MASK 0x01000020U
#define OS_ARM_INSTR_LEN 4
@ -123,7 +123,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 HalIntNumGet(VOID)
UINT32 status;
READ_UINT32(status, OS_INT_STATUS_ADDR);
return (31 - CLZ(status));
return (31 - CLZ(status)); /* 31 bit map of int */
}
inline UINT32 HalIsIntActive(VOID)
@ -140,8 +140,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -272,8 +271,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -284,7 +283,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = 0x%x\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -328,7 +327,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -354,15 +353,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);

View File

@ -521,25 +521,6 @@ 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);

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

@ -133,8 +133,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -273,6 +272,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};
@ -331,8 +331,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -343,7 +343,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -389,7 +389,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -415,15 +415,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -520,8 +520,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

@ -85,10 +85,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

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
@ -341,10 +338,7 @@ _hwiActiveCheckNext:
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

View File

@ -123,8 +123,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -263,6 +262,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};
@ -321,8 +321,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -333,7 +333,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -379,7 +379,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -405,15 +405,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -510,8 +510,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

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

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
@ -325,10 +322,7 @@ _hwiActiveCheckNext:
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

View File

@ -123,8 +123,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -263,6 +262,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};
@ -321,8 +321,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -333,7 +333,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -379,7 +379,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -405,15 +405,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -488,7 +488,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
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 = 2; index < OS_VECTOR_CNT; index++) { /* 2 Default hw handler stack start from index 2 */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
@ -510,8 +510,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

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

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
@ -341,10 +338,7 @@ _hwiActiveCheckNext:
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

View File

@ -123,8 +123,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -263,6 +262,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};
@ -321,8 +321,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -333,7 +333,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -379,7 +379,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -405,15 +405,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -488,7 +488,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
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 = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
@ -510,8 +510,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

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

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

@ -130,8 +130,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -330,8 +329,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -342,7 +341,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -388,7 +387,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -414,15 +413,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

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

@ -130,8 +130,7 @@ 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:%d\n", __FUNCTION__, HalIntNumGet());
while (1) {}
}
@ -330,8 +329,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -342,7 +341,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -388,7 +387,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -414,15 +413,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

View File

@ -267,7 +267,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,7 +275,7 @@ _hwiActiveCheck:
_ExcInMSP:
.fnstart
.cantunwind
CMP LR, #0XFFFFFFED
CMP LR, #0xFFFFFFE9
BNE _NoFloatInMsp
ADD R3, R13, #104
PUSH {R3}

View File

@ -133,8 +133,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -273,6 +272,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};
@ -331,8 +331,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -343,7 +343,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -389,7 +389,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -415,15 +415,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -530,8 +530,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

@ -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);

View File

@ -85,10 +85,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

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

@ -134,8 +134,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -276,6 +275,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};
@ -334,8 +334,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -346,7 +346,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -392,7 +392,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -418,15 +418,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -523,8 +523,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

@ -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);

View File

@ -85,10 +85,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -35,6 +35,7 @@ static_library("arch") {
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_mpu.c",
"los_timer.c",
]

View File

@ -521,25 +521,6 @@ 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);

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

View File

@ -123,8 +123,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -263,6 +262,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};
@ -321,8 +321,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -333,7 +333,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -379,7 +379,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -405,15 +405,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -510,8 +510,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

@ -0,0 +1,237 @@
/*
* 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_mpu.h"
#include "los_config.h"
#include "los_context.h"
#if (LOSCFG_MPU_ENABLE == 1)
#define SIZE_4G_BYTE 0x100000000
#define MPU_MAX_REGION_NUM 8
STATIC UINT8 g_regionNumBeUsed[MPU_MAX_REGION_NUM] = {0};
typedef enum {
MPU_AP_FORBID_USER_FORBID = 0x0, /* Privileged:No access Unprivileged:No access */
MPU_AP_RW_USER_FORBID = 0x1, /* Privileged:Read/Write Unprivileged:No access */
MPU_AP_RW_USER_RO = 0x2, /* Privileged:Read/Write Unprivileged:Read-only */
MPU_AP_RW_USER_RW = 0x3, /* Privileged:Read/Write Unprivileged:Read/Write */
MPU_AP_NA_USER_NA = 0x4, /* Privileged:UNPREDICTABLE Unprivileged:UNPREDICTABLE */
MPU_AP_RO_USER_FORBID = 0x5, /* Privileged:Read-only Unprivileged:No access */
MPU_AP_RO_USER_RO = 0x6, /* Privileged:Read-only Unprivileged:Read-only */
} MpuApConfig;
VOID HalMpuEnable(UINT32 defaultRegionEnable)
{
UINT32 intSave = HalIntLock();
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);
}
VOID HalMpuDisable(VOID)
{
UINT32 intSave = HalIntLock();
MPU->CTRL = 0;
__DSB();
__ISB();
HalIntRestore(intSave);
}
STATIC VOID HalMpuRASRAddMemAttr(MPU_CFG_PARA *para, UINT32 *RASR)
{
BOOL cachable = 0;
BOOL buffable = 0;
switch (para->memType) {
case MPU_MEM_ON_CHIP_ROM:
case MPU_MEM_ON_CHIP_RAM:
cachable = 1;
buffable = 0;
break;
case MPU_MEM_XIP_PSRAM:
cachable = 1;
buffable = 1;
break;
case MPU_MEM_XIP_NOR_FLASH:
cachable = 0;
buffable = 1;
break;
default:
break;
}
(*RASR) |= ((cachable << MPU_RASR_C_Pos) | (buffable << MPU_RASR_B_Pos));
}
STATIC UINT32 HalMpuEncodeSize(UINT64 size)
{
UINT32 encodeSize = 0;
if (size > SIZE_4G_BYTE) {
return 0;
}
if ((size & 0x1F) != 0) { /* size should aligned to 32 byte at least. */
return 0;
}
size = (size >> 2);
while (size != 0) {
if (((size & 1) != 0) && ((size & 0xFFFFFFFE) != 0)) { /* size != 2^x (5 <= x <= 32) 128B - 4GB */
return 0;
}
size = (size >> 1);
encodeSize++;
}
return encodeSize;
}
STATIC UINT32 HalMpuEncodeAP(MpuAccessPermission permission)
{
UINT32 ap;
switch (permission) {
case MPU_RW_BY_PRIVILEGED_ONLY:
ap = MPU_AP_RW_USER_FORBID;
break;
case MPU_RW_ANY:
ap = MPU_AP_RW_USER_RW;
break;
case MPU_RO_BY_PRIVILEGED_ONLY:
ap = MPU_AP_RO_USER_FORBID;
break;
case MPU_RO_ANY:
ap = MPU_AP_RO_USER_RO;
break;
default:
ap = MPU_AP_RW_USER_RW;
break;
}
return ap;
}
STATIC UINT32 HalMpuGetRASR(UINT32 encodeSize, MPU_CFG_PARA *para)
{
UINT32 RASR;
UINT32 ap;
ap = HalMpuEncodeAP(para->permission);
RASR = MPU_RASR_ENABLE_Msk;
RASR |= ((encodeSize << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk);
RASR |= ((ap << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | ((para->executable << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) |
((para->shareability << MPU_RASR_S_Pos) & MPU_RASR_S_Msk);
HalMpuRASRAddMemAttr(para, &RASR);
return RASR;
}
UINT32 HalMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
{
UINT32 RASR;
UINT32 RBAR;
UINT32 RNR;
UINT32 encodeSize;
UINT32 intSave;
UINT64 size;
if ((regionId >= MPU_MAX_REGION_NUM) || (para == NULL)) {
return LOS_NOK;
}
if ((MPU_TYPE_DREGION_Msk & MPU->TYPE) == 0) {
return LOS_NOK;
}
RNR = regionId;
encodeSize = HalMpuEncodeSize(para->size);
if (encodeSize == 0) {
return LOS_NOK;
}
size = para->size - 1; /* size aligned after encode check */
if ((para->baseAddr & size) != 0) { /* base addr should aligned to region size */
return LOS_NOK;
}
RBAR = para->baseAddr & MPU_RBAR_ADDR_Msk;
RASR = HalMpuGetRASR(encodeSize, para);
intSave = HalIntLock();
if (g_regionNumBeUsed[regionId]) {
HalIntRestore(intSave);
return LOS_NOK;
}
MPU->RNR = RNR;
MPU->RBAR = RBAR;
MPU->RASR = RASR;
__DSB();
__ISB();
g_regionNumBeUsed[regionId] = 1; /* Set mpu region used flag */
HalIntRestore(intSave);
return LOS_OK;
}
UINT32 HalMpuDisableRegion(UINT32 regionId)
{
volatile UINT32 type;
UINT32 intSave;
if (regionId >= MPU_MAX_REGION_NUM) {
return LOS_NOK;
}
intSave = HalIntLock();
if (!g_regionNumBeUsed[regionId]) {
HalIntRestore(intSave);
return LOS_NOK;
}
type = MPU->TYPE;
if ((MPU_TYPE_DREGION_Msk & type) != 0) {
MPU->RNR = regionId;
MPU->RASR = 0;
__DSB();
__ISB();
}
g_regionNumBeUsed[regionId] = 0; /* clear mpu region used flag */
HalIntRestore(intSave);
return LOS_OK;
}
INT32 HalMpuUnusedRegionGet(VOID)
{
INT32 id;
UINT32 intSave = HalIntLock();
for (id = 0; id < MPU_MAX_REGION_NUM; id++) {
if (!g_regionNumBeUsed[id]) {
break;
}
}
HalIntRestore(intSave);
if (id == MPU_MAX_REGION_NUM) {
return -1;
} else {
return id;
}
}
#endif

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -521,25 +521,6 @@ 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);

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

@ -130,8 +130,7 @@ 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__, HalIntNumGet());
while (1) {}
}
@ -272,6 +271,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};
@ -330,8 +330,8 @@ STATIC VOID OsExcTypeInfo(const ExcInfo *excInfo)
{
CHAR *phaseStr[] = {"exc in init", "exc in task", "exc in hwi"};
PRINTK("Type = %d\n", excInfo->type);
PRINTK("ThrdPid = %d\n", excInfo->thrdPid);
PRINTK("Type = %u\n", excInfo->type);
PRINTK("ThrdPid = %u\n", excInfo->thrdPid);
PRINTK("Phase = %s\n", phaseStr[excInfo->phase]);
PRINTK("FaultAddr = 0x%x\n", excInfo->faultAddr);
}
@ -342,7 +342,7 @@ STATIC VOID OsExcCurTaskInfo(const ExcInfo *excInfo)
if (excInfo->phase == OS_EXC_IN_TASK) {
LosTaskCB *taskCB = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
PRINTK("Task name = %s\n", taskCB->taskName);
PRINTK("Task ID = %d\n", taskCB->taskID);
PRINTK("Task ID = %u\n", taskCB->taskID);
PRINTK("Task SP = %p\n", taskCB->stackPointer);
PRINTK("Task ST = 0x%x\n", taskCB->topOfStack);
PRINTK("Task SS = 0x%x\n", taskCB->stackSize);
@ -388,7 +388,7 @@ STATIC VOID OsExcBackTraceInfo(const ExcInfo *excInfo)
if (LR[index] == 0) {
break;
}
PRINTK("backtrace %d -- lr = 0x%x\n", index, LR[index]);
PRINTK("backtrace %u -- lr = 0x%x\n", index, LR[index]);
}
PRINTK("----- backtrace end -----\n");
}
@ -414,15 +414,15 @@ STATIC VOID OsExcMemPoolCheckInfo(VOID)
}
for (i = 0; i < errCnt; i++) {
PRINTK("pool num = %d\n", i);
PRINTK("pool num = %u\n", i);
PRINTK("pool type = %d\n", memExcInfo[i].type);
PRINTK("pool addr = 0x%x\n", memExcInfo[i].startAddr);
PRINTK("pool size = 0x%x\n", memExcInfo[i].size);
PRINTK("pool free = 0x%x\n", memExcInfo[i].free);
PRINTK("pool blkNum = %d\n", memExcInfo[i].blockSize);
PRINTK("pool blkNum = %u\n", memExcInfo[i].blockSize);
PRINTK("pool error node addr = 0x%x\n", memExcInfo[i].errorAddr);
PRINTK("pool error node len = 0x%x\n", memExcInfo[i].errorLen);
PRINTK("pool error node owner = %d\n", memExcInfo[i].errorOwner);
PRINTK("pool error node owner = %u\n", memExcInfo[i].errorOwner);
}
#endif
UINT32 ret = LOS_MemIntegrityCheck(LOSCFG_SYS_HEAP_ADDR);
@ -491,7 +491,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;
@ -519,8 +519,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

@ -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);

View File

@ -84,10 +84,13 @@ WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
WEAK UINT64 HalGetTickCycle(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;
}

View File

@ -338,8 +338,12 @@ __STATIC_FORCEINLINE q31_t riscv_nn_requantize(const q31_t val, const q31_t mult
__STATIC_FORCEINLINE q31_t riscv_nn_read_q15x2_ia(const q15_t **in_q15)
{
q31_t val;
int ret;
memcpy(&val, *in_q15, 4);
ret = memcpy_s(&val, sizeof(q31_t), *in_q15, 4); // 4: data offset
if (ret != 0) {
return 0;
}
*in_q15 += 2;
return (val);
@ -353,7 +357,10 @@ __STATIC_FORCEINLINE q31_t riscv_nn_read_q15x2_ia(const q15_t **in_q15)
__STATIC_FORCEINLINE q31_t riscv_nn_read_q7x4_ia(const q7_t **in_q7)
{
q31_t val;
memcpy(&val, *in_q7, 4);
int ret = memcpy_s(&val, sizeof(q31_t), *in_q7, 4); // 4: data offset
if (ret != 0) {
return 0;
}
*in_q7 += 4;
return (val);

View File

@ -52,12 +52,17 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler)
WEAK VOID HalSysTickReload(UINT64 nextResponseTime)
{
UINT64 timeMax = (UINT64)LOSCFG_BASE_CORE_TICK_RESPONSE_MAX - 1;
UINT64 timer;
UINT32 timerL, timerH;
READ_UINT32(timerL, MTIMER);
READ_UINT32(timerH, MTIMER + MTIMER_HI_OFFSET);
timer = OS_COMBINED_64(timerH, timerL);
timer += nextResponseTime;
if ((timeMax - nextResponseTime) > timer) {
timer += nextResponseTime;
} else {
timer = timeMax;
}
HalIrqDisable(RISCV_MACH_TIMER_IRQ);
WRITE_UINT32(0xffffffff, MTIMERCMP + MTIMER_HI_OFFSET);

View File

@ -781,6 +781,10 @@ extern UINT8 *m_aucSysMem0;
#define LOSCFG_MPU_ENABLE 0
#endif
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1) && (LOSCFG_MPU_ENABLE == 0)
#error "if hardware stack protection is enabled, then MPU should be supported and enabled"
#endif
/*=============================================================================
shell module configuration
=============================================================================*/

View File

@ -469,7 +469,7 @@ extern UINT32 LOS_MemIntegrityCheck(const VOID *pool);
extern VOID LOS_MemUnlockEnable(VOID *pool);
extern UINT32 OsMemSystemInit(VOID);
extern VOID OsTaskMemUsed(VOID *pool, UINT32 *outArray, UINT32 arraySize);
extern VOID OsTaskMemUsed(VOID *pool, UINT32 *tskMemInfoBuf, UINT32 tskMemInfoCnt);
#ifdef __cplusplus
#if __cplusplus

View File

@ -341,7 +341,7 @@ extern "C" {
*/
#define OS_WAIT_TASK_ARRAY_LEN ((LOSCFG_BASE_CORE_TSK_LIMIT >> 5) + 1)
#define OS_WAIT_TASK_ID_TO_ARRAY_IDX(taskID) (taskID >> 5)
#define OS_WAIT_TASK_ARRAY_ELEMENT_MASK ((1 << OS_WAIT_TASK_ARRAY_LEN) - 1)
#define OS_WAIT_TASK_ARRAY_ELEMENT_MASK (31)
/**
* @ingroup los_queue

View File

@ -369,8 +369,66 @@ extern "C" {
*/
#define LOS_ERRNO_TSK_OPERATE_SWTMR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x22)
/**
* @ingroup los_task
* Task error code: Task timeout.
*
* Value: 0x02000223
*
* Solution: Check whether the waiting time and timeout are reasonable.
*/
#define LOS_ERRNO_TSK_TIMEOUT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x23)
/**
* @ingroup los_task
* Task error code: This task cannot wait for other tasks to finish.
*
* Value: 0x02000224
*
* Solution: Check the task properties and whether it is waiting for other tasks to finish.
*/
#define LOS_ERRNO_TSK_NOT_JOIN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24)
/**
* @ingroup los_task
* Task error code: Tasks can't join himself.
*
* Value: 0x02000225
*
* Solution: Check whether the task ID is the current running task.
*/
#define LOS_ERRNO_TSK_NOT_JOIN_SELF LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25)
/**
* @ingroup los_task
* Task error code: This task operation is not allowed to be performed in an interrupt.
*
* Value: 0x02000226
*
* Solution: Check whether the interface is used in interrupts.
*/
#define LOS_ERRNO_TSK_NOT_ALLOW_IN_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26)
/**
* @ingroup los_task
* Task error code: An exited task cannot be deleted.
*
* Value: 0x02000227
*
* Solution: Check whether a Joinable task exists. If so, call LOS_TaskJoin to reclaim resources.
*/
#define LOS_ERRNO_TSK_ALREADY_EXIT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x27)
/**
* @ingroup los_task
* Task error code: Locked scheduling does not allow tasks to be blocked.
*
* Value: 0x02000228
*
* Solution: Check for faulty lock scheduling logic.
*/
#define LOS_ERRNO_TSK_SCHED_LOCKED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x28)
/**
* @ingroup los_task
* Define the type of the task entry function.
@ -393,17 +451,21 @@ typedef struct tagTskInitParam {
UINT32 uwResved; /**< Reserved */
} TSK_INIT_PARAM_S;
/**
* @ingroup los_task
* Task detach attribute.
*/
#define LOS_TASK_ATTR_JOINABLE 0x80000000
/**
* @ingroup los_task
* Task name length
*
*/
#define LOS_TASK_NAMELEN 32
/**
* @ingroup los_task
* Task information structure.
*
*/
typedef struct tagTskInfo {
CHAR acName[LOS_TASK_NAMELEN]; /**< Task entrance function */
@ -1088,6 +1150,45 @@ extern CHAR* LOS_TaskNameGet(UINT32 taskID);
*/
extern VOID LOS_UDelay(UINT64 microseconds);
/* *
* @ingroup los_task
* @brief: cpu delay.
*
* @par Description:
* This API is used to wait for the subtask to finish and reclaim the resource.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param taskID [IN] task ID.
* @param retval [IN] Value returned when the task is complete.
*
* @retval: None.
* @par Dependency:
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TaskDetach.
*/
extern UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval);
/* *
* @ingroup los_task
* @brief: Modify the task attributes to detach.
*
* @par Description:
* This API is used to modify the attribute of the specified task to detach.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param taskID [IN] task ID.
*
* @retval: None.
* @par Dependency:
* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
* @see LOS_TaskJoin.
*/
extern UINT32 LOS_TaskDetach(UINT32 taskID);
/**
* @ingroup los_task
* Null task ID
@ -1177,11 +1278,28 @@ extern VOID LOS_UDelay(UINT64 microseconds);
/**
* @ingroup los_task
* Flag that indicates the task is in userspace.
* Flag that indicates the task or task control block status.
*
* The task is a user task.
* The task exits and waits for the parent thread to reclaim the resource.
*/
#define OS_TASK_STATUS_USERSPACE 0x8000
#define OS_TASK_STATUS_EXIT 0x0100
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
*
* The delayed operation of this task is frozen.
*/
#define OS_TASK_FALG_FREEZE 0x4000
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
*
* Task join properties, The parent thread needs to reclaim
* the resource after the task ends.
*/
#define OS_TASK_FLAG_JOINABLE 0x8000
/**
* @ingroup los_task
@ -1346,6 +1464,8 @@ typedef struct {
CHAR *taskName; /**< Task name */
LOS_DL_LIST pendList;
LOS_DL_LIST timerList;
LOS_DL_LIST joinList;
UINTPTR joinRetval; /**< Return value of the end of the task, If the task does not exit by itself, the ID of the task that killed the task is recorded. */
EVENT_CB_S event;
UINT32 eventMask; /**< Event mask */
UINT32 eventMode; /**< Event mode */
@ -1622,7 +1742,7 @@ extern UINT32 OsGetAllTskInfo(VOID);
extern VOID *OsTskUserStackInit(VOID* stackPtr, VOID* userSP, UINT32 userStackSize);
extern UINT32 OsPmEnterHandlerSet(VOID (*func)(BOOL));
extern UINT32 OsPmEnterHandlerSet(VOID (*func)(VOID));
#ifdef __cplusplus
#if __cplusplus

View File

@ -130,6 +130,10 @@ extern UINT64 LOS_SysCycleGet(VOID);
#define OS_SYS_NS_TO_CYCLE(time, freq) (((time) / OS_SYS_NS_PER_SECOND) * (freq) + \
(time % OS_SYS_NS_PER_SECOND) * (freq) / OS_SYS_NS_PER_SECOND)
#define OS_SYS_TICK_TO_CYCLE(ticks) (((UINT64)(ticks) * g_sysClock) / LOSCFG_BASE_CORE_TICK_PER_SECOND)
#define OS_SYS_CYCLE_TO_TICK(cycle) ((((UINT64)(cycle)) * LOSCFG_BASE_CORE_TICK_PER_SECOND) / g_sysClock)
/**
* @ingroup los_tick
* System time basic function error code: Null pointer.

View File

@ -127,7 +127,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
OsRegister();
ret = OsMemSystemInit();
if (ret != LOS_OK) {
PRINT_ERR("OsMemSystemInit error %d\n", ret);
PRINT_ERR("OsMemSystemInit error %u\n", ret);
return ret;
}
@ -187,9 +187,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#if (LOSCFG_KERNEL_TRACE == 1)
ret = LOS_TraceInit(NULL, LOSCFG_TRACE_BUFFER_SIZE);
ret = OsTraceInit(LOSCFG_TRACE_BUFFER_SIZE);
if (ret != LOS_OK) {
PRINT_ERR("LOS_TraceInit error\n");
PRINT_ERR("OsTraceInit error\n");
return ret;
}
#endif
@ -203,11 +203,11 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
#endif
#if (LOSCFG_TEST == 1)
//ret = los_TestInit();
//if (ret != LOS_OK) {
// PRINT_ERR("los_TestInit error\n");
// return ret;
//}
ret = los_TestInit();
if (ret != LOS_OK) {
PRINT_ERR("los_TestInit error\n");
return ret;
}
#endif
#if (LOSCFG_PLATFORM_EXC == 1)

View File

@ -243,7 +243,7 @@ static INLINE VOID OsQueueBufferOperate(LosQueueCB *queueCB, UINT32 operateType,
msgDataSize = *((UINT32 *)(UINTPTR)((queueNode + queueCB->queueSize) - sizeof(UINT32)));
rc = memcpy_s((VOID *)bufferAddr, *bufferSize, (VOID *)queueNode, msgDataSize);
if (rc != EOK) {
PRINT_ERR("%s[%d] memcpy failed, error type = %u\n", __FUNCTION__, __LINE__, rc);
PRINT_ERR("%s[%d] memcpy failed, error type = %d\n", __FUNCTION__, __LINE__, rc);
return;
}
@ -252,7 +252,7 @@ static INLINE VOID OsQueueBufferOperate(LosQueueCB *queueCB, UINT32 operateType,
*((UINT32 *)(UINTPTR)((queueNode + queueCB->queueSize) - sizeof(UINT32))) = *bufferSize;
rc = memcpy_s((VOID *)queueNode, queueCB->queueSize, (VOID *)bufferAddr, *bufferSize);
if (rc != EOK) {
PRINT_ERR("%s[%d] memcpy failed, error type = %u\n", __FUNCTION__, __LINE__, rc);
PRINT_ERR("%s[%d] memcpy failed, error type = %d\n", __FUNCTION__, __LINE__, rc);
return;
}
}

View File

@ -34,6 +34,9 @@
#include "los_tick.h"
#include "los_debug.h"
#include "los_hook.h"
#if (LOSCFG_KERNEL_PM == 1)
#include "los_pm.h"
#endif
#ifdef __cplusplus
#if __cplusplus
@ -50,6 +53,9 @@ extern "C" {
#error "Must specify the maximum value that tick timer counter supports!"
#endif
#define OS_TASK_BLOCKED_STATUS (OS_TASK_STATUS_PEND | OS_TASK_STATUS_SUSPEND | \
OS_TASK_STATUS_EXIT | OS_TASK_STATUS_UNUSED)
STATIC SchedScan g_swtmrScan = NULL;
STATIC SortLinkAttribute *g_taskSortLinkList = NULL;
STATIC LOS_DL_LIST g_priQueueList[OS_PRIORITY_QUEUE_NUM];
@ -86,13 +92,17 @@ VOID OsSchedResetSchedResponseTime(UINT64 responseTime)
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
STATIC UINT64 g_schedTimerBase;
STATIC BOOL g_tickTimerBaseUpdate = FALSE;
VOID OsSchedUpdateSchedTimeBase(VOID)
{
UINT32 period = 0;
(VOID)HalGetTickCycle(&period);
g_schedTimerBase += period;
if (g_tickTimerBaseUpdate == FALSE) {
(VOID)HalGetTickCycle(&period);
g_schedTimerBase += period;
}
g_tickTimerBaseUpdate = FALSE;
}
VOID OsSchedTimerBaseReset(UINT64 currTime)
@ -118,6 +128,7 @@ UINT64 OsGetCurrSysTimeCycle(VOID)
/* Turn the timer count */
g_schedTimerBase += period;
schedTime = g_schedTimerBase + time;
g_tickTimerBaseUpdate = TRUE;
}
LOS_ASSERT(schedTime >= oldSchedTime);
@ -139,22 +150,11 @@ STATIC INLINE VOID OsTimeSliceUpdate(LosTaskCB *taskCB, UINT64 currTime)
taskCB->startTime = currTime;
}
STATIC INLINE VOID OsSchedTickReload(UINT64 nextResponseTime, UINT32 responseID, BOOL isTimeSlice, BOOL timeUpdate)
STATIC INLINE VOID OsSchedTickReload(UINT64 currTime, UINT64 nextResponseTime, UINT32 responseID,
BOOL isTimeSlice, BOOL timeUpdate)
{
UINT64 currTime, nextExpireTime;
UINT32 usedTime;
currTime = OsGetCurrSchedTimeCycle();
if (g_tickStartTime != 0) {
usedTime = currTime - g_tickStartTime;
g_tickStartTime = 0;
} else {
usedTime = 0;
}
if ((nextResponseTime > usedTime) && ((nextResponseTime - usedTime) > OS_TICK_RESPONSE_PRECISION)) {
nextResponseTime -= usedTime;
} else {
UINT64 nextExpireTime;
if (nextResponseTime < OS_TICK_RESPONSE_PRECISION) {
nextResponseTime = OS_TICK_RESPONSE_PRECISION;
}
@ -184,8 +184,10 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID,
UINT64 nextExpireTime;
UINT64 nextResponseTime = 0;
BOOL isTimeSlice = FALSE;
(VOID)startTime;
nextExpireTime = OsGetNextExpireTime(startTime);
UINT64 currTime = OsGetCurrSchedTimeCycle();
nextExpireTime = OsGetNextExpireTime(currTime);
/* The response time of the task time slice is aligned to the next response time in the delay queue */
if ((nextExpireTime > taskEndTime) && ((nextExpireTime - taskEndTime) > OS_SCHED_MINI_PERIOD)) {
nextExpireTime = taskEndTime;
@ -194,7 +196,7 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID,
if ((g_schedResponseTime > nextExpireTime) &&
((g_schedResponseTime - nextExpireTime) >= OS_TICK_RESPONSE_PRECISION)) {
nextResponseTime = nextExpireTime - startTime;
nextResponseTime = nextExpireTime - currTime;
if (nextResponseTime > OS_TICK_RESPONSE_TIME_MAX) {
if (SchedRealSleepTimeSet != NULL) {
SchedRealSleepTimeSet(nextResponseTime);
@ -211,11 +213,12 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT64 startTime, UINT32 responseID,
return;
}
OsSchedTickReload(nextResponseTime, responseID, isTimeSlice, timeUpdate);
OsSchedTickReload(currTime, nextResponseTime, responseID, isTimeSlice, timeUpdate);
}
VOID OsSchedUpdateExpireTime(UINT64 startTime, BOOL timeUpdate)
{
BOOL isPmMode = FALSE;
UINT64 endTime;
LosTaskCB *runTask = g_losTask.runTask;
@ -223,7 +226,10 @@ VOID OsSchedUpdateExpireTime(UINT64 startTime, BOOL timeUpdate)
return;
}
if (runTask->taskID != g_idleTaskID) {
#if (LOSCFG_KERNEL_PM == 1)
isPmMode = OsIsPmMode();
#endif
if ((runTask->taskID != g_idleTaskID) && !isPmMode) {
INT32 timeSlice = (runTask->timeSlice <= OS_TIME_SLICE_MIN) ? OS_SCHED_TIME_SLICES : runTask->timeSlice;
endTime = startTime + timeSlice;
} else {
@ -415,7 +421,7 @@ BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 priority)
}
taskCB->priority = priority;
OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority);
OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority);
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
return TRUE;
}
@ -511,7 +517,7 @@ BOOL OsSchedTaskSwitch(VOID)
if (runTask->taskStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY)) {
OsAdd2SortLink(&runTask->sortList, runTask->startTime, runTask->waitTimes, OS_SORT_LINK_TASK);
} else if (!(runTask->taskStatus & (OS_TASK_STATUS_PEND | OS_TASK_STATUS_SUSPEND | OS_TASK_STATUS_UNUSED))) {
} else if (!(runTask->taskStatus & OS_TASK_BLOCKED_STATUS)) {
OsSchedTaskEnQueue(runTask);
}
@ -568,8 +574,6 @@ UINT64 LOS_SchedTickTimeoutNsGet(VOID)
VOID LOS_SchedTickHandler(VOID)
{
BOOL needSched = FALSE;
if (!g_taskScheduled) {
return;
}
@ -579,19 +583,21 @@ VOID LOS_SchedTickHandler(VOID)
if (g_schedResponseID == OS_INVALID) {
g_tickIntLock++;
if (g_swtmrScan != NULL) {
needSched = g_swtmrScan();
(VOID)g_swtmrScan();
}
needSched |= OsSchedScanTimerList();
(VOID)OsSchedScanTimerList();
g_tickIntLock--;
}
OsTimeSliceUpdate(g_losTask.runTask, g_tickStartTime);
g_losTask.runTask->startTime = OsGetCurrSchedTimeCycle();
g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
if (needSched && LOS_CHECK_SCHEDULE) {
if (LOS_CHECK_SCHEDULE) {
HalTaskSchedule();
} else {
OsTimeSliceUpdate(g_losTask.runTask, g_tickStartTime);
OsSchedUpdateExpireTime(g_tickStartTime, TRUE);
OsSchedUpdateExpireTime(g_losTask.runTask->startTime, TRUE);
}
LOS_IntRestore(intSave);

View File

@ -232,6 +232,8 @@ LITE_OS_SEC_TEXT UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout)
goto ERROR_SEM_PEND;
}
runningTask = (LosTaskCB *)g_losTask.runTask;
if (semPended->semCount > 0) {
semPended->semCount--;
LOS_IntRestore(intSave);
@ -244,7 +246,6 @@ LITE_OS_SEC_TEXT UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout)
goto ERROR_SEM_PEND;
}
runningTask = (LosTaskCB *)g_losTask.runTask;
runningTask->taskSem = (VOID *)semPended;
OsSchedTaskWait(&semPended->semList, timeout);
LOS_IntRestore(intSave);

View File

@ -115,7 +115,7 @@ VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, Sort
}
intSave = LOS_IntLock();
SET_SORTLIST_VALUE(node, startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK);
SET_SORTLIST_VALUE(node, startTime + OS_SYS_TICK_TO_CYCLE(waitTicks));
OsAddNode2SortLink(sortLinkHeader, node);
LOS_IntRestore(intSave);
}

View File

@ -88,7 +88,7 @@ LITE_OS_SEC_TEXT VOID OsSwtmrTask(VOID)
tick = LOS_TickCountGet() - tick;
if (tick >= SWTMR_MAX_RUNNING_TICKS) {
PRINT_WARN("timer_handler(%p) cost too many ms(%d)\n",
PRINT_WARN("timer_handler(%p) cost too many ms(%u)\n",
swtmrHandle.handler,
(UINT32)((tick * OS_SYS_MS_PER_SECOND) / LOSCFG_BASE_CORE_TICK_PER_SECOND));
}
@ -123,8 +123,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrTaskCreate(VOID)
STATIC UINT64 OsSwtmrCalcStartTime(UINT64 currTime, SWTMR_CTRL_S *swtmr, const SWTMR_CTRL_S *alignSwtmr)
{
UINT64 usedTime, startTime;
UINT64 alignEnd = (UINT64)alignSwtmr->uwInterval * OS_CYCLE_PER_TICK;
UINT64 swtmrTime = (UINT64)swtmr->uwInterval * OS_CYCLE_PER_TICK;
UINT64 alignEnd = OS_SYS_TICK_TO_CYCLE(alignSwtmr->uwInterval);
UINT64 swtmrTime = OS_SYS_TICK_TO_CYCLE(swtmr->uwInterval);
UINT64 remainTime = OsSortLinkGetRemainTime(currTime, &alignSwtmr->stSortList);
if (remainTime == 0) {
startTime = GET_SORTLIST_VALUE(&alignSwtmr->stSortList);

View File

@ -44,6 +44,9 @@
#if (LOSCFG_BASE_CORE_CPUP == 1)
#include "los_cpup.h"
#endif
#if (LOSCFG_KERNEL_PM == 1)
#include "los_pm.h"
#endif
/**
* @ingroup los_task
@ -91,6 +94,14 @@
*/
#define OS_TASK_STACK_TOP_OFFSET 4
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
/**
* @ingroup los_task
* @brief the size of task stack's protection area
*/
#define OS_TASK_STACK_PROTECT_SIZE 32
#endif
LITE_OS_SEC_BSS LosTaskCB *g_taskCBArray = NULL;
LITE_OS_SEC_BSS LosTask g_losTask;
LITE_OS_SEC_BSS UINT16 g_losTaskLock;
@ -101,7 +112,7 @@ LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_losFreeTask;
LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_taskRecyleList;
LITE_OS_SEC_BSS BOOL g_taskScheduled = FALSE;
STATIC VOID (*PmEnter)(BOOL isIdle) = NULL;
STATIC VOID (*PmEnter)(VOID) = NULL;
#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
TaskSwitchInfo g_taskSwitchInfo;
@ -120,6 +131,22 @@ STATIC_INLINE UINT32 OsCheckTaskIDValid(UINT32 taskID)
return ret;
}
STATIC VOID OsRecycleTaskResources(LosTaskCB *taskCB, UINTPTR *stackPtr)
{
if (!(taskCB->taskStatus & OS_TASK_STATUS_EXIT)) {
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
}
if (taskCB->topOfStack != 0) {
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
*stackPtr = taskCB->topOfStack - OS_TASK_STACK_PROTECT_SIZE;
#else
*stackPtr = taskCB->topOfStack;
#endif
taskCB->topOfStack = (UINT32)NULL;
}
}
STATIC VOID OsRecyleFinishedTask(VOID)
{
LosTaskCB *taskCB = NULL;
@ -130,19 +157,17 @@ STATIC VOID OsRecyleFinishedTask(VOID)
while (!LOS_ListEmpty(&g_taskRecyleList)) {
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecyleList));
LOS_ListDelete(LOS_DL_LIST_FIRST(&g_taskRecyleList));
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
stackPtr = taskCB->topOfStack - OS_TASK_STACK_PROTECT_SIZE;
#else
stackPtr = taskCB->topOfStack;
#endif
stackPtr = 0;
OsRecycleTaskResources(taskCB, &stackPtr);
LOS_IntRestore(intSave);
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
taskCB->topOfStack = (UINT32)NULL;
intSave = LOS_IntLock();
}
LOS_IntRestore(intSave);
}
UINT32 OsPmEnterHandlerSet(VOID (*func)(BOOL))
UINT32 OsPmEnterHandlerSet(VOID (*func)(VOID))
{
if (func == NULL) {
return LOS_NOK;
@ -165,7 +190,7 @@ LITE_OS_SEC_TEXT VOID OsIdleTask(VOID)
OsRecyleFinishedTask();
if (PmEnter != NULL) {
PmEnter(TRUE);
PmEnter();
} else {
(VOID)HalEnterSleep();
}
@ -185,6 +210,10 @@ LITE_OS_SEC_TEXT_MINOR UINT8 *OsConvertTskStatus(UINT16 taskStatus)
return (UINT8 *)"Running";
} else if (taskStatus & OS_TASK_STATUS_READY) {
return (UINT8 *)"Ready";
} else if (taskStatus & OS_TASK_STATUS_EXIT) {
return (UINT8 *)"Exit";
} else if (taskStatus & OS_TASK_STATUS_SUSPEND) {
return (UINT8 *)"Suspend";
} else if (taskStatus & OS_TASK_STATUS_DELAY) {
return (UINT8 *)"Delay";
} else if (taskStatus & OS_TASK_STATUS_PEND) {
@ -192,8 +221,6 @@ LITE_OS_SEC_TEXT_MINOR UINT8 *OsConvertTskStatus(UINT16 taskStatus)
return (UINT8 *)"PendTime";
}
return (UINT8 *)"Pend";
} else if (taskStatus & OS_TASK_STATUS_SUSPEND) {
return (UINT8 *)"Suspend";
}
return (UINT8 *)"Impossible";
@ -316,7 +343,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
continue;
}
PRINTK("%d %d %s 0x%x 0x%x 0x%x 0x%x 0x%x ",
PRINTK("%u %u %s 0x%x 0x%x 0x%x 0x%x 0x%x ",
taskCB->taskID, taskCB->priority, OsConvertTskStatus(taskCB->taskStatus),
taskCB->stackSize, OsGetTaskWaterLine(taskCB->taskID),
(UINT32)(UINTPTR)taskCB->stackPointer, taskCB->topOfStack, taskCB->eventMask);
@ -325,7 +352,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsGetAllTskInfo(VOID)
PRINTK("0x%x ", semID);
#if (LOSCFG_BASE_CORE_CPUP == 1)
PRINTK("%d.%d %d.%d %d.%d ",
PRINTK("%u.%u %u.%u %u.%u ",
cpuLessOneSec[taskCB->taskID].uwUsage / LOS_CPUP_PRECISION_MULT,
cpuLessOneSec[taskCB->taskID].uwUsage % LOS_CPUP_PRECISION_MULT,
cpuTenSec[taskCB->taskID].uwUsage / LOS_CPUP_PRECISION_MULT,
@ -403,7 +430,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
taskInitParam.pcName = "IdleCore000";
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
retVal = LOS_TaskCreateOnly(&g_idleTaskID, &taskInitParam);
if (retVal != LOS_OK) {
return retVal;
}
@ -472,7 +498,7 @@ LITE_OS_SEC_TEXT CHAR *LOS_CurTaskNameGet(VOID)
*****************************************************************************/
LITE_OS_SEC_TEXT STATIC VOID OsHandleRunTaskStackOverflow(VOID)
{
PRINT_ERR("CURRENT task ID: %s:%d stack overflow!\n",
PRINT_ERR("CURRENT task ID: %s:%u stack overflow!\n",
g_losTask.runTask->taskName, g_losTask.runTask->taskID);
OsDoExcHook(EXC_STACKOVERFLOW);
}
@ -488,7 +514,7 @@ LITE_OS_SEC_TEXT STATIC VOID OsHandleNewTaskStackOverflow(VOID)
{
LosTaskCB *tmp = NULL;
PRINT_ERR("HIGHEST task ID: %s:%d SP error!\n",
PRINT_ERR("HIGHEST task ID: %s:%u SP error!\n",
g_losTask.newTask->taskName, g_losTask.newTask->taskID);
PRINT_ERR("HIGHEST task StackPointer: 0x%x TopOfStack: 0x%x\n",
(UINT32)(UINTPTR)(g_losTask.newTask->stackPointer), g_losTask.newTask->topOfStack);
@ -604,11 +630,10 @@ LITE_OS_SEC_TEXT_INIT VOID OsTaskEntry(UINT32 taskID)
UINT32 retVal;
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
(VOID)taskCB->taskEntry(taskCB->arg);
taskCB->joinRetval = (UINTPTR)taskCB->taskEntry(taskCB->arg);
retVal = LOS_TaskDelete(taskCB->taskID);
if (retVal != LOS_OK) {
PRINT_ERR("Delete Task[TID: %d] Failed!\n", taskCB->taskID);
PRINT_ERR("Delete Task[TID: %u] Failed!\n", taskCB->taskID);
}
}
@ -669,6 +694,11 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *
taskCB->stackPointer = HalTskStackInit(taskCB->taskID, taskInitParam->uwStackSize, topOfStack);
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
LOS_EventInit(&(taskCB->event));
if (taskInitParam->uwResved & LOS_TASK_ATTR_JOINABLE) {
taskCB->taskStatus |= OS_TASK_FLAG_JOINABLE;
LOS_ListInit(&taskCB->joinList);
}
return LOS_OK;
}
@ -803,6 +833,12 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
OS_GOTO_ERREND();
}
#if (LOSCFG_KERNEL_PM == 1)
if (tempStatus & OS_TASK_FALG_FREEZE) {
OsPmUnfreezeTaskUnsafe(taskID);
}
#endif
taskCB->taskStatus &= (~OS_TASK_STATUS_SUSPEND);
if (!(taskCB->taskStatus & OS_CHECK_TASK_BLOCK)) {
OsSchedTaskEnQueue(taskCB);
@ -862,6 +898,12 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskSuspend(UINT32 taskID)
OsSchedTaskDeQueue(taskCB);
}
#if (LOSCFG_KERNEL_PM == 1)
if ((tempStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY)) && OsIsPmMode()) {
OsPmFreezeTaskUnsafe(taskID);
}
#endif
taskCB->taskStatus |= OS_TASK_STATUS_SUSPEND;
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTOSUSPENDEDLIST, taskCB);
if (taskID == g_losTask.runTask->taskID) {
@ -878,6 +920,129 @@ LOS_ERREND:
return retErr;
}
STATIC VOID OsTaskJoinPostUnsafe(LosTaskCB *taskCB)
{
LosTaskCB *resumedTask = NULL;
if (taskCB->taskStatus & OS_TASK_FLAG_JOINABLE) {
if (!LOS_ListEmpty(&taskCB->joinList)) {
resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(taskCB->joinList)));
OsSchedTaskWake(resumedTask);
}
taskCB->taskStatus |= OS_TASK_STATUS_EXIT;
}
}
STATIC UINT32 OsTaskJoinPendUnsafe(LosTaskCB *taskCB)
{
if (taskCB->taskStatus & OS_TASK_STATUS_EXIT) {
return LOS_OK;
} else if ((taskCB->taskStatus & OS_TASK_FLAG_JOINABLE) && LOS_ListEmpty(&taskCB->joinList)) {
OsSchedTaskWait(&taskCB->joinList, LOS_WAIT_FOREVER);
return LOS_OK;
}
return LOS_NOK;
}
STATIC UINT32 OsTaskSetDetachUnsafe(LosTaskCB *taskCB)
{
if (taskCB->taskStatus & OS_TASK_FLAG_JOINABLE) {
if (LOS_ListEmpty(&(taskCB->joinList))) {
LOS_ListDelete(&(taskCB->joinList));
taskCB->taskStatus &= ~OS_TASK_FLAG_JOINABLE;
return LOS_OK;
}
/* This error code has a special purpose and is not allowed to appear again on the interface */
return LOS_ERRNO_TSK_NOT_JOIN;
}
return LOS_NOK;
}
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval)
{
LosTaskCB *taskCB = NULL;
UINTPTR stackPtr = 0;
UINT32 intSave;
UINT32 ret;
ret = OsCheckTaskIDValid(taskID);
if (ret != LOS_OK) {
return ret;
}
if (OS_INT_ACTIVE) {
return LOS_ERRNO_TSK_NOT_ALLOW_IN_INT;
}
if (g_losTaskLock != 0) {
return LOS_ERRNO_TSK_SCHED_LOCKED;
}
if (taskID == LOS_CurTaskIDGet()) {
return LOS_ERRNO_TSK_NOT_JOIN_SELF;
}
taskCB = OS_TCB_FROM_TID(taskID);
intSave = LOS_IntLock();
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
LOS_IntRestore(intSave);
return LOS_ERRNO_TSK_NOT_CREATED;
}
ret = OsTaskJoinPendUnsafe(taskCB);
LOS_IntRestore(intSave);
if (ret == LOS_OK) {
LOS_Schedule();
if (retval != NULL) {
*retval = taskCB->joinRetval;
}
intSave = LOS_IntLock();
taskCB->taskStatus &= ~OS_TASK_STATUS_EXIT;
OsRecycleTaskResources(taskCB, &stackPtr);
LOS_IntRestore(intSave);
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
return LOS_OK;
}
return ret;
}
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDetach(UINT32 taskID)
{
UINT32 intSave;
UINT32 ret;
LosTaskCB *taskCB = NULL;
ret = OsCheckTaskIDValid(taskID);
if (ret != LOS_OK) {
return ret;
}
if (OS_INT_ACTIVE) {
return LOS_ERRNO_TSK_NOT_ALLOW_IN_INT;
}
taskCB = OS_TCB_FROM_TID(taskID);
intSave = LOS_IntLock();
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
LOS_IntRestore(intSave);
return LOS_ERRNO_TSK_NOT_CREATED;
}
if (taskCB->taskStatus & OS_TASK_STATUS_EXIT) {
LOS_IntRestore(intSave);
return LOS_TaskJoin(taskID, NULL);
}
ret = OsTaskSetDetachUnsafe(taskCB);
LOS_IntRestore(intSave);
return ret;
}
LITE_OS_SEC_TEXT_INIT STATIC_INLINE VOID OsRunningTaskDelete(UINT32 taskID, LosTaskCB *taskCB)
{
LOS_ListTailInsert(&g_taskRecyleList, &taskCB->pendList);
@ -897,21 +1062,27 @@ LITE_OS_SEC_TEXT_INIT STATIC_INLINE VOID OsRunningTaskDelete(UINT32 taskID, LosT
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
{
UINT32 intSave;
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
UINTPTR stackPtr;
UINTPTR stackPtr = 0;
LosTaskCB *taskCB = NULL;
UINT32 ret = OsCheckTaskIDValid(taskID);
if (ret != LOS_OK) {
return ret;
}
taskCB = OS_TCB_FROM_TID(taskID);
intSave = LOS_IntLock();
if ((taskCB->taskStatus) & OS_TASK_STATUS_UNUSED) {
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
LOS_IntRestore(intSave);
return LOS_ERRNO_TSK_NOT_CREATED;
}
if (taskCB->taskStatus & OS_TASK_STATUS_EXIT) {
LOS_IntRestore(intSave);
return LOS_ERRNO_TSK_ALREADY_EXIT;
}
/* If the task is running and scheduler is locked then you can not delete it */
if (((taskCB->taskStatus) & OS_TASK_STATUS_RUNNING) && (g_losTaskLock != 0)) {
PRINT_INFO("In case of task lock, task deletion is not recommended\n");
@ -920,6 +1091,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
OsHookCall(LOS_HOOK_TYPE_TASK_DELETE, taskCB);
OsSchedTaskExit(taskCB);
OsTaskJoinPostUnsafe(taskCB);
LOS_EventDestroy(&(taskCB->event));
taskCB->event.uwEventID = OS_NULL_INT;
@ -929,24 +1101,19 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
(VOID)memset_s((VOID *)&g_cpup[taskCB->taskID], sizeof(OsCpupCB), 0, sizeof(OsCpupCB));
#endif
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
OsRunningTaskDelete(taskID, taskCB);
if (!(taskCB->taskStatus & OS_TASK_STATUS_EXIT)) {
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
OsRunningTaskDelete(taskID, taskCB);
}
LOS_IntRestore(intSave);
LOS_Schedule();
return LOS_OK;
} else {
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
stackPtr = taskCB->topOfStack - OS_TASK_STACK_PROTECT_SIZE;
#else
stackPtr = taskCB->topOfStack;
#endif
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
taskCB->topOfStack = (UINT32)NULL;
}
taskCB->joinRetval = LOS_CurTaskIDGet();
OsRecycleTaskResources(taskCB, &stackPtr);
LOS_IntRestore(intSave);
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
return LOS_OK;
}

View File

@ -72,7 +72,7 @@ Return : current tick
*****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID)
{
return OsGetCurrSchedTimeCycle() / OS_CYCLE_PER_TICK;
return OS_SYS_CYCLE_TO_TICK(OsGetCurrSchedTimeCycle());
}
/*****************************************************************************

View File

@ -345,23 +345,23 @@ STATIC VOID OsAllMemNodeDoHandle(VOID *pool, VOID (*handle)(struct OsMemNodeHead
STATIC VOID GetTaskMemUsedHandle(struct OsMemNodeHead *curNode, VOID *arg)
{
UINT32 *args = (UINT32 *)arg;
UINT32 *outArray = (UINT32 *)(UINTPTR)*args;
UINT32 arraySize = *(args + 1);
UINT32 *tskMemInfoBuf = (UINT32 *)(UINTPTR)*args;
UINT32 tskMemInfoCnt = *(args + 1);
#ifndef LOSCFG_MEM_MUL_REGIONS
if (OS_MEM_NODE_GET_USED_FLAG(curNode->sizeAndFlag)) {
#else
if (OS_MEM_NODE_GET_USED_FLAG(curNode->sizeAndFlag) && !OS_MEM_IS_GAP_NODE(curNode)) {
#endif
if (curNode->taskID < arraySize) {
outArray[curNode->taskID] += OS_MEM_NODE_GET_SIZE(curNode->sizeAndFlag);
if (curNode->taskID < tskMemInfoCnt) {
tskMemInfoBuf[curNode->taskID] += OS_MEM_NODE_GET_SIZE(curNode->sizeAndFlag);
}
}
return;
}
VOID OsTaskMemUsed(VOID *pool, UINT32 *outArray, UINT32 arraySize)
VOID OsTaskMemUsed(VOID *pool, UINT32 *tskMemInfoBuf, UINT32 tskMemInfoCnt)
{
UINT32 args[2] = {(UINT32)(UINTPTR)outArray, arraySize};
UINT32 args[2] = {(UINT32)(UINTPTR)tskMemInfoBuf, tskMemInfoCnt};
OsAllMemNodeDoHandle(pool, GetTaskMemUsedHandle, (VOID *)args);
return;
}
@ -952,7 +952,7 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
if (((UINTPTR)pool & (OS_MEM_ALIGN_SIZE - 1)) || \
(size & (OS_MEM_ALIGN_SIZE - 1))) {
PRINT_ERR("LiteOS heap memory address or size configured not aligned:address:0x%x,size:0x%x, alignsize:%d\n", \
PRINT_ERR("LiteOS heap memory address or size configured not aligned:address:0x%x,size:0x%x, alignsize:%u\n", \
(UINTPTR)pool, size, OS_MEM_ALIGN_SIZE);
return OS_ERROR;
}
@ -1788,8 +1788,8 @@ STATIC VOID OsMemIntegrityCheckError(struct OsMemPoolHead *pool,
PRINTK("The prev node is free\n");
}
MEM_UNLOCK(pool, intSave);
PRINT_ERR("cur node: 0x%x, pre node: 0x%x, pre node was allocated by task: %d, %s\n",
tmpNode, preNode, taskCB->taskID, taskCB->taskName);
PRINT_ERR("cur node: 0x%x, pre node: 0x%x, pre node was allocated by task: %u, %s\n",
(UINTPTR)tmpNode, (UINTPTR)preNode, taskCB->taskID, taskCB->taskName);
LOS_Panic("Memory integrity check error!\n");
#else
MEM_UNLOCK(pool, intSave);

View File

@ -176,7 +176,7 @@ $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
$(AS) -c $(CFLAGS) $(ASFLAGS) $< -o $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile $(LDSCRIPT)
$(CC) $(OBJECTS) $(LDFLAGS) -o $@

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