Compare commits

...

61 Commits

Author SHA1 Message Date
openharmony_ci 970bb5c0f4
!1042 Fixed compilation problems with niobe407 and neptune100
Merge pull request !1042 from 张亚雷/cherry-pick-1679913248
2023-04-13 02:10:40 +00:00
mrzhang 53fdba6bb7 fixed 67ee38e from https://gitee.com/ya-lei-zhang1/kernel_liteos_m/pulls/977
fix: Fixed compilation problems with niobe407 and neptune100

Signed-off-by: mrzhang <zhangyalei8@h-partners.com>
2023-03-27 10:34:08 +00:00
openharmony_ci 4176459693
!1014 Fix : OsLs内存问题修复挑单到monthly_20221018
Merge pull request !1014 from yinjiaming/cherry-pick-1673836500
2023-01-17 09:30:24 +00:00
openharmony_ci 44e7c46e5b
!1013 Fix : statfs函数问题修复挑单到monthly_20221018
Merge pull request !1013 from yinjiaming/cherry-pick-1673836173
2023-01-17 08:57:17 +00:00
yinjiaming cd8237fb5e fixed 9a4e967 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/1009
fix:修复OsLs函数内存泄漏问题
当d = NULL时,path没有释放,现释放path所指向的内存

close #I6A07U

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Iee9fd8d2171c6fdcf353a48e7af385bbd1660520
2023-01-16 02:35:00 +00:00
yinjiaming a9cdef1cd4 fixed 2f2a0b7 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/1006
fix:修复statfs函数内部判断错误

修复函数调用的是statfs却用stat!=NULL来判断,当文件系统是little_fs时导致死机的问题。

close #I69BXB

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib9784c017f4260433c3f12e352470108ea83ec19
2023-01-16 02:29:37 +00:00
openharmony_ci 47103b943a
!1011 告警清理
Merge pull request !1011 from 乔克叔叔/cherry-pick-1673590318
2023-01-13 06:57:20 +00:00
liuwenxin b4e2c8a8e2 fixed 705bfbd from https://gitee.com/wenxin-liu_admin/kernel_liteos_m/pulls/1010
fix:release告警清理

release分支告警清理

close:#I6AD15

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-01-13 06:11:59 +00:00
openharmony_ci 5e5acfd04f
!1003 【同步到monthly_20221018分支】mutex trace中ArchLRGet等接口改变实现方式
Merge pull request !1003 from zhangdengyu/cherry-pick-1673256956
2023-01-10 12:10:29 +00:00
zhangdengyu 0b4895cca6 fixed 84d1c20 from https://gitee.com/zhangdengyu/kernel_liteos_m/pulls/1000
fix:mutex trace中ArchLRGet接口改变实现方式

方案描述:
将ArchLRGet接口的实现方式由内联函数修改为宏,
防止产品添加--no_inline等编译选项导致函数无法在调用点展开,
造成由于函数调用过程中函数栈帧的变化带来的LR寄存器中存储的值的变化。

Close #I69D9N

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: If417bc2ec9febf064c63da198faf4ac000d70c52
2023-01-10 14:33:02 +08:00
openharmony_ci 3d7e94ea57
!984 修复codecheck告警同步至monthly_20221018
Merge pull request !984 from 夏不白/cherry-pick-1672373774
2023-01-03 03:08:21 +00:00
xiacong 911e736dab fixed 07091c5 from https://gitee.com/xia-bubai/kernel_liteos_m/pulls/983
fix:修复codecheck告警
1、修复空格、空行使用错误告警;
2、将超过10行的inline函数去除内联符号

fix #I685E3

Signed-off-by: xiacong <xiacong4@huawei.com>
2022-12-30 04:16:14 +00:00
openharmony_ci f109218089
!981 【回合monthly1018】fix: mktime获取的时间缺少时区信息
Merge pull request !981 from Zhaotianyu/cherry-pick-1672302591
2022-12-29 12:48:05 +00:00
arvinzzz bd4d9ffb58 fixed 2a4282f from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/979
fix: The tm struct obtained by mktime lacks timezone information

BREAKING CHANGE:
The tm struct obtained by mktime lacks timezone information
变更API:
time_t mktime(struct tm *tmptr)
原先mktime从入参中获取时区信息进行计算,变更后tm结构体和返回值time_t的计算使用系统g_timezone时区环境变量。

Close I67UIA

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I766cffbff3c1a25bb33cbd245225ee117909af3a
2022-12-29 08:29:51 +00:00
openharmony_ci 015c79a5a9
!976 【monthly_20221018】VfsMpFind接口优化
Merge pull request !976 from Far/monthly_20221018
2022-12-26 02:04:03 +00:00
Far 46bad48e12 fix: VfsMpFind optimize
1. provide VfsMpFind which doesn't support mounting recursively;
2. provide a macro to set whether supporting recursive-mount or not.
3. adding path length checking

BREAKING CHANGE:
new config option:
LOSCFG_FS_SUPPORT_MOUNT_TARGET_RECURSIVE

fix #I677ZT
Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I92a752fe2bcdd2b036630b5e4e8d7df1562629e0
2022-12-24 10:45:01 +08:00
openharmony_ci 18ffbf44ee
!975 【回合monthly1018】fix: misc_config中defines未初始化导致编译失败
Merge pull request !975 from Zhaotianyu/cherry-pick-1671695812
2022-12-23 09:04:20 +00:00
arvinzzz 690e15682b fixed b817c49 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/974
fix: 修复misc_config中defines未初始化的错误

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I4eecfc1af2b0cdc39922a8ce299eb8ab6b7c6e8c
2022-12-22 07:56:53 +00:00
openharmony_ci 84d34eafe1
!967 【monthly_20221018】修复文件系统不合理的锁操作
Merge pull request !967 from Far/monthly_20221018_lock
2022-12-22 06:33:10 +00:00
Far 819833072f fix: 修复文件系统不合理的锁操作
1. 移除了fatfs和littlefs中冗余的加锁操作。
2. 增加了配置选项FS_LOCK_TIMEOUT(宏LOSCFG_FS_LOCK_TIMEOUT),提供文件
   系统锁超时判定能力。
3. 新增对外接口LOS_FsLock()和LOS_FsUnlock()接口,提供HAL层与文件系统的
   互斥操作。

BREAKING CHANGE:
修复文件系统不合理的锁操作
新增API:
los_fs.h:
int LOS_FsLock(void)
int LOS_FsUnlock(void)
新增配置项:
LOSCFG_FS_LOCK_TIMEOUT(menuconfig FS_LOCK_TIMEOUT)

fix #I66A1M

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I2d7b67a209049162cd69f8ef3611ab0431df4d4a
2022-12-22 10:40:30 +08:00
openharmony_ci 8541f81c1e
!970 【回合monthly_1018】open接口内存泄漏优化
Merge pull request !970 from wangchen/1217_1018
2022-12-19 07:02:08 +00:00
openharmony_ci bddda6dcf7
!964 【monthly_20221018】修复文件系统close中的不合理操作
Merge pull request !964 from Far/monthly_20221018
2022-12-19 03:05:37 +00:00
wangchen 2bc508bdd3 fix: 回合1018 open接口内存泄漏修复
方案描述:
1, 修改路径正确时打开失败可能的异常

fix #I66KHK
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-12-17 08:23:19 +00:00
Far 77e204ab62 fix: 修复close接口中无法正常关闭文件的问题
1. close未考虑保留描述符0、1和2,导致fd合法性判断出现错误,这会导致
上限附近的fd不能被正常的关闭
2. 释放file结构体时未在锁的保护中进行,可能存在问题

fix #I66F6I

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I084c7e0e9cfc51a123ebad07d0c94f47e544baa6
2022-12-17 16:06:02 +08:00
arvinzzz 852181749d refactor: vfs opt
1. vfs重构优化,统一fs模块的对外接口,减少不必要的冗余调用,由fs组件直接提供posix对外接口
  2. vfs与libc关系整理
  3. fs接口实现规范化

BREAKING CHANGE:
删除API:
int LOS_Open(const char *path, int flags, ...);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
ssize_t LOS_Write(int fd, const void *buff, size_t bytes);
off_t LOS_Lseek(int fd, off_t off, int whence);
int LOS_Stat(const char *path, struct stat *stat);
int LOS_Statfs(const char *path, struct statfs *buf);
int LOS_Unlink(const char *path);
int LOS_Rename(const char *oldpath, const char *newpath);
int LOS_Fsync(int fd);
DIR *LOS_Opendir(const char *path);
struct dirent *LOS_Readdir(DIR *dir);
int LOS_Closedir(DIR *dir);
int LOS_Mkdir(const char *path, mode_t mode);
int LOS_Rmdir(const char *path);
int LOS_Lstat(const char *path, struct stat *buffer);
int LOS_Fstat(int fd, struct stat *buf);
int LOS_Fcntl(int fd, int cmd, ...);
int LOS_Ioctl(int fd, int req, ...);
ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off);
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off);
int LOS_Isatty(int fd);
int LOS_Access(const char *path, int amode);
int LOS_Ftruncate(int fd, off_t length);
int LOS_FsUmount(const char *target);
int LOS_FsUmount2(const char *target, int flag);
int LOS_FsMount(const char *source, const char *target,
                const char *fsType, unsigned long mountflags,
                const void *data);
int OsFcntl(int fd, int cmd, va_list ap);
int OsIoctl(int fd, int req, va_list ap);

Close #I66F6I

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-12-16 10:26:19 +08:00
openharmony_ci eb08c1744d
!961 【同步到monthly_20221018分支】feat:支持mutex trace
Merge pull request !961 from zhangdengyu/monthly_20221018
2022-12-09 00:56:50 +00:00
openharmony_ci 2a68a0e6d4
!956 【挑单】优化CPUP计算方式, 解耦系统调频
Merge pull request !956 from zhushengle/cherry-pick-1670312099
2022-12-08 14:49:17 +00:00
zhangdengyu 2eb0da90fe feat: 同步:新增mutex trace
方案描述:
1. 新增mutex trace

Close: I5ZMML

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-12-08 16:38:04 +08:00
openharmony_ci da29e90bca
!959 fix: monthly_20221018 对外提供CONFIG_NFILE_DESCRIPTORS宏表示最大可打开fd数量
Merge pull request !959 from Hongjin Li/cherry-pick-1670397258
2022-12-07 07:49:48 +00:00
openharmony_ci 20cd0e4fde
!951 合入monthly_20221018:添加LOSCFG_MAX_OPEN_DIRS标识最大可打开dir数量
Merge pull request !951 from Hongjin Li/monthly_20221018
2022-12-07 07:31:58 +00:00
Hongjin Li 0c39af1d9b fixed a3ce436 from https://gitee.com/hongjin-li/kernel_liteos_m/pulls/934
fix: 提供CONFIG_NFILE_DESCRIPTORS宏标识最大可打开fd数量

提供CONFIG_NFILE_DESCRIPTORS宏,标识最大可打开fd数量。
提供FAT_MAX_OPEN_FILES宏,标识FAT文件系统中最大可打开fd数量。

如果只有FAT文件系统,那么CONFIG_NFILE_DESCRIPTORS等于FAT_MAX_OPEN_FILES。
如果有多个文件系统,比如fat+little+yaffs,那么CONFIG_NFILE_DESCRIPTORS应该定义为多个文件系统可打开fd数量之和。

BREAKING CHANGE:

对外提供的CONFIG_NFILE_DESCRIPTORS宏,用来标识最大可打开fd数量。

开发者可以在target_config.h中自定义CONFIG_NFILE_DESCRIPTORS和FAT_MAX_OPEN_FILES宏。

Close #I62WDU

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-12-07 07:14:18 +00:00
openharmony_ci 9cac5041f2
!954 【monthly_20221018】对内核模块暴露OsMemNodeHead/OsMemPoolHead等结构体
Merge pull request !954 from Far/monthly_20221018
2022-12-06 13:57:37 +00:00
openharmony_ci 02ad24988b
!936 feat: 挑单 fs增加注册接口 到1030
Merge pull request !936 from wangchen/1124_1030
2022-12-06 09:17:09 +00:00
openharmony_ci 9e4b228f3b
!946 挑单 vfs 分区逻辑修改 到 monthly_20221018
Merge pull request !946 from wangchen/1129_x_partit
2022-12-06 09:03:20 +00:00
zhushengle 2fad9065c8 fixed 974182d from https://gitee.com/zhushengle/kernel_liteos_m/pulls/955
feat: 优化CPUP计算方式, 解耦系统调频

Close #I5R9XG

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I07cb388732b1190943374802f792d32bd666c06e
2022-12-06 07:35:00 +00:00
Far c23f36940d feat: 对内核模块暴露OsMemNodeHead/OsMemPoolHead
对内核其他模块暴露OsMemNodeHead/OsMemPoolHead等结构体,
以便于对堆内存管理的调测及管理。

fix #I64OVX

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I603188722beaf67ba65e26ed93168617485e770a
2022-12-05 17:10:58 +08:00
wangchen 83198b9a6c feat: 挑单 fs增加注册接口 到1030
方案描述:
增加注册机制, 并增加重复注册判断

BREAKING CHANGE:
挑单 fs增加注册接口 到1030
新增API:
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
                   const struct FileOps *fsFops, const struct FsManagement *fsMgt);

fix #I62WMS
Signed-off-by: wangchen <wangchen240@huawei.com>
https://gitee.com/openharmony/kernel_liteos_m/issues/I62WMS
2022-12-01 02:49:05 +00:00
Hongjin Li ee66077ec6 fix: 添加LOSCFG_MAX_OPEN_DIRS标识最大可打开dir数量
提供LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。新增g_dirNum静态变量,标识已打开的dir数量。
在opendir成功时g_dirNum++,在closedir成功时g_dirNum--。

BREAKING CHANGE:
新增LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。

Close #I641DZ

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-12-01 10:03:51 +08:00
wangchen bbbf0b857c fix: 挑单 vfs 分区逻辑修改 到 1018
方案描述:
1,删除fat分区时调用的adddevice的动作

fix #I63QXK
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-29 09:06:04 +00:00
openharmony_ci af5fcc0e6c
!942 【monthly_20221018】文件系统提供动态内存分配器钩子
Merge pull request !942 from Far/monthly_20221018
2022-11-29 03:53:36 +00:00
Far e004ca9783 feat: 文件系统提供动态内存分配器钩子
增加LOS_FS_MALLOC/LOS_FS_FREE宏以提供用户配置动态内存分配器的能力。
用户只需要在components/fs/vfs/los_fs.h中修改对应的函数即可。

BREAKING CHANGE:
文件系统提供动态内存分配器钩子
新增宏:
LOS_FS_MALLOC
LOS_FS_FREE

fix #I63IZ8

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Ia18cbf907709dbfaa1bbc4e779537ec8e659a0ec
2022-11-28 20:01:36 +08:00
openharmony_ci 257364f873
!931 Fix : 内核告警清理挑单
Merge pull request !931 from yinjiaming/cherry-pick-1669172283
2022-11-23 11:07:51 +00:00
yinjiaming 86ee9aff2e fixed a4087a6 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/930
Fix: 内核告警清理
消除了多余的空格

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ibe90fcf8c46ef9a60c0a8f4dbba07d399e139b8c
2022-11-23 02:58:04 +00:00
openharmony_ci e709718fdc
!926 告警清理
Merge pull request !926 from 乔克叔叔/cherry-pick-1669000234
2022-11-23 01:46:38 +00:00
openharmony_ci 34fcef1bf1
!924 告警清理
Merge pull request !924 from 乔克叔叔/cherry-pick-1668998063
2022-11-21 14:06:09 +00:00
liuwenxin f5833a19ce fixed 2806c4a from https://gitee.com/wenxin-liu_admin/kernel_liteos_m/pulls/892
Fix:m核告警清理

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-21 16:43:48 +08:00
liuwenxin 5b65d5d0f3 fixed fa6f0c3 from https://gitee.com/wenxin-liu_admin/kernel_liteos_m/pulls/917
fix:告警清理

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-21 02:34:24 +00:00
openharmony_ci 1a525b1f0f
!920 告警清理 合入monthly_20221018
Merge pull request !920 from Hongjin Li/cherry-pick-1668687992
2022-11-19 07:08:11 +00:00
openharmony_ci 780227205d
!923 挑单 其他分区已mount时会引起格式化失败至monthly_20221018
Merge pull request !923 from wangchen/1118_1030_m
2022-11-18 10:21:09 +00:00
wangchen 171ffc4f4b fix: 挑单 其他分区已mount时会引起格式化失败至monthly_20221018
【背景】其他分区已mount时会引起格式化失败至monthly_20221018

【修改方案】
1, 格式化时判断方式修改为路径

【影响】
对现有的产品编译不会有影响。
re #I61W0J
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-18 06:58:29 +00:00
Hongjin Li 87e957c6a6 fixed 2dc3998 from https://gitee.com/hongjin-li/kernel_liteos_m/pulls/919
fix: add space after comma

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-11-17 12:26:32 +00:00
openharmony_ci 03a72de3ed
!914 【monthly_20221018】修复mount接口对MS_REMOUNT的支持
Merge pull request !914 from Far/cherry-pick-1668503371
2022-11-17 04:56:30 +00:00
Far ed3ad6e65f fixed 64d15df from https://gitee.com/yesiyuanjim/kernel_liteos_m/pulls/909
fix: fix the MS_REMOUNT support

The mount interface can't deal with MS_REMOUNT flag now, fix it.

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Id0960c8d92ce767b8d8ef98b3ba2e1d1ab7db15d
2022-11-15 09:09:32 +00:00
openharmony_ci 48b116bebb
!883 【回合monthly1018】feat: 提供死机场景下dump文件能力
Merge pull request !883 from Zhaotianyu/cherry-pick-1667647264
2022-11-14 02:23:37 +00:00
openharmony_ci d4cbd3b563
!888 cortex-m4支持iar编译器的gn适配
Merge pull request !888 from yiweiniunan/cherry-pick-1667812780
2022-11-07 11:15:42 +00:00
yiweiniunan 787eaac712 fixed 62cd8fe from https://gitee.com/yiweiniunan/kernel_liteos_m/pulls/886
cortex-m4支持iar编译器的gn适配

Signed-off-by: yiweiniunan <michael.likai@huawei.com>
2022-11-07 09:19:40 +00:00
openharmony_ci de6e3829b2
!872 挑单 解决部分平台ping失败
Merge pull request !872 from wangchen/1103_net
2022-11-07 01:37:53 +00:00
arvinzzz 9c0ea618df fixed 4742015 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/881
feat: 提供死机场景下dump文件的能力

死机场景下,vfs层锁会放开,提供dump文件的能力

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Id8c9e63fbf011dbc6690b9b4557bd3370353bf21
2022-11-05 11:21:05 +00:00
openharmony_ci 6fdbdf18cb
!876 挑单-pm idle控制选项添加到menuconfig中至monthly_20221018
Merge pull request !876 from zhushengle/cherry-pick-1667528978
2022-11-04 09:38:11 +00:00
zhushengle 9454dd8bda fixed 98d20e9 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/874
feat: pm idle添加到menuconfig中

Close #I5ZD5L
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ibdedff3043a0902aa3cd9539497ef97fb6a1ce6c
2022-11-04 02:29:38 +00:00
wangchen 291cb06744 fix: 挑单 解决部分平台ping失败
【背景】挑单 解决部分平台ping失败

【修改方案】
挑单 解决部分平台ping失败

【影响】
对现有的产品编译不会有影响。
re #I5Z9TP
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-03 07:18:47 +00:00
55 changed files with 1258 additions and 1896 deletions

View File

@ -91,8 +91,9 @@ config("dialect_config") {
}
config("misc_config") {
defines = []
if (!defined(LOSCFG_COMPILER_ICCARM)) {
defines = [ "__LITEOS__" ]
defines += [ "__LITEOS__" ]
defines += [ "__LITEOS_M__" ]
}
if (!defined(LOSCFG_DEBUG_VERSION)) {

18
Kconfig
View File

@ -335,6 +335,14 @@ config KERNEL_PM
Configuration item for low power frame tailoring.
If you wish to build LiteOS with support for power management.
config KERNEL_PM_IDLE
bool "Enable Power Management Idle"
default n
depends on KERNEL_PM
help
Configuration item for low power frame tailoring.
If you wish to build LiteOS with support for power management idle.
config KERNEL_PM_TASK_PTIORITY
int "Power Management Task Priority"
default 1
@ -513,6 +521,14 @@ config DEBUG_QUEUE
help
Answer Y to enable debug queue.
config MUTEX_CREATE_TRACE
bool "Enable Mutex Trace Debugging"
default n
depends on ARCH_ARM
depends on DEBUG_KERNEL
help
Answer Y to enable debug mutex trace.
config DEBUG_DEADLOCK
bool "Enable Mutex Deadlock Debugging"
default n
@ -601,7 +617,7 @@ config VM_OVERLAP_CHECK
depends on DEBUG_VERSION && MEM_DEBUG
help
Answer Y to enable vm overlap check.
config TASK_MEM_USED
bool "Enable show task mem used or not"
default n

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -27,13 +27,21 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if LIBC_MUSL
import("//kernel/liteos_m/liteos.gni")
config LIBC_MUSL_FS
bool "Enable POSIX file system API support"
default y
depends on FS_VFS
help
This enables POSIX style file system related APIs.
module_name = "arch"
kernel_module(module_name) {
sources = [
"los_context.c",
"los_dispatch.S",
"los_exc.S",
"los_interrupt.c",
"los_mpu.c",
"los_timer.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
endif # LIBC_MUSL
config("public") {
include_dirs = [ "." ]
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -62,6 +62,14 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
__asm("mrs %0, msp" : "=r" (msp));
return msp;
}
#define ARCH_LR_GET() \
({ \
UINTPTR lr; \
__asm("mov %0, lr" : "=r" (lr)); \
(lr); \
})
#define ArchLRGet ARCH_LR_GET
#elif defined(__CLANG_ARM) || defined(__GNUC__)
STATIC INLINE UINTPTR ArchSpGet(VOID)
{
@ -83,6 +91,14 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
__asm volatile("mrs %0, msp" : "=r" (msp));
return msp;
}
#define ARCH_LR_GET() \
({ \
UINTPTR lr; \
__asm volatile("mov %0, lr" : "=r" (lr)); \
(lr); \
})
#define ArchLRGet ARCH_LR_GET
#else
/* Other platforms to be improved */
#endif

View File

@ -58,6 +58,9 @@
#define OS_CPUP_RECORD_PERIOD (g_sysClock)
#define OS_SYS_CYCLE_TO_US(cycle) ((cycle) / (g_sysClock)) * OS_SYS_US_PER_SECOND + \
((cycle) % (g_sysClock) * OS_SYS_US_PER_SECOND / (g_sysClock))
LITE_OS_SEC_BSS UINT16 g_cpupInitFlg = 0;
LITE_OS_SEC_BSS OsCpupCB *g_cpup = NULL;
LITE_OS_SEC_BSS UINT64 g_lastRecordTime;
@ -167,6 +170,15 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit()
return LOS_OK;
}
/* The calculation time unit is changed to us to decouple the influence of
* system frequency modulation on CPUP
*/
STATIC UINT64 CpupTimeUsGet(VOID)
{
UINT64 time = LOS_SysCycleGet();
return OS_SYS_CYCLE_TO_US(time);
}
/*****************************************************************************
Function : OsTskCycleStart
Description: start task to get cycles count in current task beginning
@ -183,10 +195,11 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleStart(VOID)
taskID = g_losTask.newTask->taskID;
g_cpup[taskID].cpupID = taskID;
g_cpup[taskID].startTime = LOS_SysCycleGet();
g_cpup[taskID].startTime = CpupTimeUsGet();
return;
}
/*****************************************************************************
Function : OsTskCycleEnd
Description: quit task and get cycle count
@ -196,7 +209,7 @@ Return : None
LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID)
{
UINT32 taskID;
UINT64 cpuCycle;
UINT64 cpuTime;
if (g_cpupInitFlg == 0) {
return;
@ -208,16 +221,17 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID)
return;
}
cpuCycle = LOS_SysCycleGet();
if (cpuCycle < g_cpup[taskID].startTime) {
cpuCycle += g_cyclesPerTick;
cpuTime = CpupTimeUsGet();
if (cpuTime < g_cpup[taskID].startTime) {
cpuTime += OS_US_PER_TICK;
}
g_cpup[taskID].allTime += (cpuCycle - g_cpup[taskID].startTime);
g_cpup[taskID].allTime += (cpuTime - g_cpup[taskID].startTime);
g_cpup[taskID].startTime = 0;
return;
}
/*****************************************************************************
Function : OsTskCycleEndStart
Description: start task to get cycles count in current task ending
@ -227,7 +241,7 @@ Return : None
LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
{
UINT32 taskID;
UINT64 cpuCycle;
UINT64 cpuTime;
UINT16 loopNum;
if (g_cpupInitFlg == 0) {
@ -235,23 +249,23 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
}
taskID = g_losTask.runTask->taskID;
cpuCycle = LOS_SysCycleGet();
cpuTime = CpupTimeUsGet();
if (g_cpup[taskID].startTime != 0) {
if (cpuCycle < g_cpup[taskID].startTime) {
cpuCycle += g_cyclesPerTick;
if (cpuTime < g_cpup[taskID].startTime) {
cpuTime += OS_US_PER_TICK;
}
g_cpup[taskID].allTime += (cpuCycle - g_cpup[taskID].startTime);
g_cpup[taskID].allTime += (cpuTime - g_cpup[taskID].startTime);
g_cpup[taskID].startTime = 0;
}
taskID = g_losTask.newTask->taskID;
g_cpup[taskID].cpupID = taskID;
g_cpup[taskID].startTime = cpuCycle;
g_cpup[taskID].startTime = cpuTime;
if ((cpuCycle - g_lastRecordTime) > OS_CPUP_RECORD_PERIOD) {
g_lastRecordTime = cpuCycle;
if ((cpuTime - g_lastRecordTime) > OS_CPUP_RECORD_PERIOD) {
g_lastRecordTime = cpuTime;
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
g_cpup[loopNum].historyTime[g_hisPos] = g_cpup[loopNum].allTime;
@ -267,12 +281,12 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
return;
}
LITE_OS_SEC_TEXT_MINOR static inline UINT16 OsGetPrePos(UINT16 curPos)
LITE_OS_SEC_TEXT_MINOR STATIC INLINE UINT16 OsGetPrePos(UINT16 curPos)
{
return (curPos == 0) ? (OS_CPUP_HISTORY_RECORD_NUM - 1) : (curPos - 1);
}
LITE_OS_SEC_TEXT_MINOR static VOID OsGetPositions(UINT16 mode, UINT16* curPosAddr, UINT16* prePosAddr)
LITE_OS_SEC_TEXT_MINOR STATIC VOID OsGetPositions(UINT16 mode, UINT16* curPosAddr, UINT16* prePosAddr)
{
UINT16 curPos;
UINT16 prePos = 0;
@ -298,7 +312,7 @@ Return : cpupRet:current CPU usage
*****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysCpuUsage(VOID)
{
UINT64 cpuCycleAll = 0;
UINT64 cpuTimeAll = 0;
UINT32 cpupRet = 0;
UINT16 loopNum;
UINT32 intSave;
@ -312,12 +326,12 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysCpuUsage(VOID)
OsTskCycleEnd();
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
cpuCycleAll += g_cpup[loopNum].allTime;
cpuTimeAll += g_cpup[loopNum].allTime;
}
if (cpuCycleAll) {
if (cpuTimeAll) {
cpupRet = LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION *
g_cpup[g_idleTaskID].allTime) / cpuCycleAll);
g_cpup[g_idleTaskID].allTime) / cpuTimeAll);
}
OsTskCycleStart();
@ -334,7 +348,7 @@ Return : cpupRet:CPU usage history
*****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
{
UINT64 cpuCycleAll = 0;
UINT64 cpuTimeAll = 0;
UINT64 idleCycleAll = 0;
UINT32 cpupRet = 0;
UINT16 loopNum;
@ -354,9 +368,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
if (mode == CPUP_IN_1S) {
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else {
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
}
}
@ -367,8 +381,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
idleCycleAll += g_cpup[g_idleTaskID].allTime - g_cpup[g_idleTaskID].historyTime[curPos];
}
if (cpuCycleAll) {
cpupRet = (LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * idleCycleAll) / cpuCycleAll));
if (cpuTimeAll) {
cpupRet = (LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * idleCycleAll) / cpuTimeAll));
}
OsTskCycleStart();
@ -385,7 +399,7 @@ Return : cpupRet:CPU usage of certain task
*****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuUsage(UINT32 taskID)
{
UINT64 cpuCycleAll = 0;
UINT64 cpuTimeAll = 0;
UINT16 loopNum;
UINT32 intSave;
UINT32 cpupRet = 0;
@ -410,11 +424,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuUsage(UINT32 taskID)
if ((g_cpup[loopNum].status & OS_TASK_STATUS_UNUSED) || (g_cpup[loopNum].status == 0)) {
continue;
}
cpuCycleAll += g_cpup[loopNum].allTime;
cpuTimeAll += g_cpup[loopNum].allTime;
}
if (cpuCycleAll) {
cpupRet = (UINT32)((LOS_CPUP_PRECISION * g_cpup[taskID].allTime) / cpuCycleAll);
if (cpuTimeAll) {
cpupRet = (UINT32)((LOS_CPUP_PRECISION * g_cpup[taskID].allTime) / cpuTimeAll);
}
OsTskCycleStart();
@ -432,8 +446,8 @@ Return : cpupRet:CPU usage history of task
*****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode)
{
UINT64 cpuCycleAll = 0;
UINT64 cpuCycleCurTsk = 0;
UINT64 cpuTimeAll = 0;
UINT64 cpuTimeCurTsk = 0;
UINT16 loopNum, curPos;
UINT16 prePos = 0;
UINT32 intSave;
@ -463,19 +477,19 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode
}
if (mode == CPUP_IN_1S) {
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else {
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
}
}
if (mode == CPUP_IN_1S) {
cpuCycleCurTsk += g_cpup[taskID].historyTime[curPos] - g_cpup[taskID].historyTime[prePos];
cpuTimeCurTsk += g_cpup[taskID].historyTime[curPos] - g_cpup[taskID].historyTime[prePos];
} else {
cpuCycleCurTsk += g_cpup[taskID].allTime - g_cpup[taskID].historyTime[curPos];
cpuTimeCurTsk += g_cpup[taskID].allTime - g_cpup[taskID].historyTime[curPos];
}
if (cpuCycleAll) {
cpupRet = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTsk) / cpuCycleAll);
if (cpuTimeAll) {
cpupRet = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurTsk) / cpuTimeAll);
}
OsTskCycleStart();
@ -490,8 +504,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
UINT16 curPos;
UINT16 prePos = 0;
UINT32 intSave;
UINT64 cpuCycleAll = 0;
UINT64 cpuCycleCurTsk = 0;
UINT64 cpuTimeAll = 0;
UINT64 cpuTimeCurTsk = 0;
if (g_cpupInitFlg == 0) {
return LOS_ERRNO_CPUP_NO_INIT;
@ -513,9 +527,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
}
if (mode == CPUP_IN_1S) {
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else {
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
}
}
@ -526,16 +540,16 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
}
if (mode == CPUP_IN_1S) {
cpuCycleCurTsk += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
cpuTimeCurTsk += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
} else {
cpuCycleCurTsk += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
cpuTimeCurTsk += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
}
cpupInfo[loopNum].usStatus = g_cpup[loopNum].status;
if (cpuCycleAll) {
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTsk) / cpuCycleAll);
if (cpuTimeAll) {
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurTsk) / cpuTimeAll);
}
cpuCycleCurTsk = 0;
cpuTimeCurTsk = 0;
}
OsTskCycleStart();
@ -606,13 +620,13 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum)
return;
}
g_irqCpup[intNum].startTime = LOS_SysCycleGet();
g_irqCpup[intNum].startTime = CpupTimeUsGet();
return;
}
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
{
UINT64 cpuCycle;
UINT64 cpuTime;
UINT64 usedTime;
if (g_irqCpupInitFlg == 0) {
@ -623,14 +637,14 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
return;
}
cpuCycle = LOS_SysCycleGet();
if (cpuCycle < g_irqCpup[intNum].startTime) {
cpuCycle += g_cyclesPerTick;
cpuTime = CpupTimeUsGet();
if (cpuTime < g_irqCpup[intNum].startTime) {
cpuTime += OS_US_PER_TICK;
}
g_irqCpup[intNum].cpupID = intNum;
g_irqCpup[intNum].status = OS_CPUP_USED;
usedTime = cpuCycle - g_irqCpup[intNum].startTime;
usedTime = cpuTime - g_irqCpup[intNum].startTime;
if (g_irqCpup[intNum].count <= 1000) { /* 1000, Take 1000 samples */
g_irqCpup[intNum].allTime += usedTime;
@ -672,12 +686,12 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsGetIrqPositions(UINT16 mode, UINT16* curPos
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllTime(VOID)
{
INT32 i;
UINT64 cpuCycleAll = 0;
UINT64 cpuTimeAll = 0;
for (i = 0; i < OS_CPUP_HISTORY_RECORD_NUM; i++) {
cpuCycleAll += g_cpuHistoryTime[i];
cpuTimeAll += g_cpuHistoryTime[i];
}
return cpuCycleAll;
return cpuTimeAll;
}
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllHisTime(UINT32 num)
@ -697,8 +711,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
UINT16 curPos;
UINT16 prePos = 0;
UINT32 intSave;
UINT64 cpuCycleAll;
UINT64 cpuCycleCurIrq;
UINT64 cpuTimeAll;
UINT64 cpuTimeCurIrq;
if (g_irqCpupInitFlg == 0) {
return LOS_ERRNO_CPUP_NO_INIT;
@ -712,9 +726,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
OsGetIrqPositions(mode, &curPos, &prePos);
if (mode == CPUP_IN_10S) {
cpuCycleAll = OsGetIrqAllTime();
cpuTimeAll = OsGetIrqAllTime();
} else {
cpuCycleAll = g_cpuHistoryTime[curPos] - g_cpuHistoryTime[prePos];
cpuTimeAll = g_cpuHistoryTime[curPos] - g_cpuHistoryTime[prePos];
}
for (loopNum = 0; loopNum < LOSCFG_PLATFORM_HWI_LIMIT; loopNum++) {
@ -725,13 +739,13 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
cpupInfo[loopNum].usStatus = g_irqCpup[loopNum].status;
if (mode == CPUP_IN_10S) {
cpuCycleCurIrq = OsGetIrqAllHisTime(loopNum);
cpuTimeCurIrq = OsGetIrqAllHisTime(loopNum);
} else {
cpuCycleCurIrq = g_irqCpup[loopNum].historyTime[curPos] - g_irqCpup[loopNum].historyTime[prePos];
cpuTimeCurIrq = g_irqCpup[loopNum].historyTime[curPos] - g_irqCpup[loopNum].historyTime[prePos];
}
if (cpuCycleAll != 0) {
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurIrq) / cpuCycleAll);
if (cpuTimeAll != 0) {
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurIrq) / cpuTimeAll);
}
}

View File

@ -32,7 +32,6 @@ config FS_FAT
default n
depends on FS_VFS
select SUPPORT_FATFS
select KAL_CMSIS
help
Answer Y to enable LiteOS support fat filesystem.

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,7 @@
#include "vfs_maps.h"
#include "vfs_mount.h"
#include "securec.h"
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
#include "los_fs.h"
static struct PartitionCfg g_partitionCfg;
static struct DeviceDesc *g_lfsDevice = NULL;
@ -184,7 +183,13 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
goto errout;
}
mountHdl = (lfs_t *)malloc(sizeof(lfs_t) + sizeof(struct lfs_config));
if (mountflags & MS_REMOUNT) {
errno = ENOSYS;
ret = (int)LOS_NOK;
goto errout;
}
mountHdl = (lfs_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_t) + sizeof(struct lfs_config));
if (mountHdl == NULL) {
errno = ENODEV;
ret = (int)LOS_NOK;
@ -204,7 +209,7 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
}
}
if (ret != 0) {
free(mountHdl);
LOSCFG_FS_FREE_HOOK(mountHdl);
errno = LittlefsErrno(ret);
ret = (int)LOS_NOK;
}
@ -233,7 +238,7 @@ int LfsUmount(struct MountPoint *mp)
ret = (int)LOS_NOK;
}
free(mp->mData);
LOSCFG_FS_FREE_HOOK(mp->mData);
mp->mData = NULL;
return ret;
}
@ -327,7 +332,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
}
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
lfs_dir_t *dirInfo = (lfs_dir_t *)malloc(sizeof(lfs_dir_t));
lfs_dir_t *dirInfo = (lfs_dir_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_dir_t));
if (dirInfo == NULL) {
errno = ENOMEM;
return (int)LOS_NOK;
@ -336,7 +341,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
(void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t));
ret = lfs_dir_open(lfs, dirInfo, dirName);
if (ret != 0) {
free(dirInfo);
LOSCFG_FS_FREE_HOOK(dirInfo);
errno = LittlefsErrno(ret);
goto errout;
}
@ -371,7 +376,6 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
if (ret == TRUE) {
pthread_mutex_lock(&g_fsLocalMutex);
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
if (lfsInfo.type == LFS_TYPE_DIR) {
dent->d_type = DT_DIR;
@ -380,7 +384,6 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
}
dent->d_reclen = lfsInfo.size;
pthread_mutex_unlock(&g_fsLocalMutex);
return LOS_OK;
}
@ -415,7 +418,7 @@ int LfsClosedir(struct Dir *dir)
ret = (int)LOS_NOK;
}
free(dirInfo);
LOSCFG_FS_FREE_HOOK(dirInfo);
dir->dData = NULL;
return ret;
@ -432,7 +435,7 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
return (int)LOS_NOK;
}
lfsHandle = (lfs_file_t *)malloc(sizeof(lfs_file_t));
lfsHandle = (lfs_file_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_file_t));
if (lfsHandle == NULL) {
errno = ENOMEM;
return (int)LOS_NOK;
@ -441,7 +444,7 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
ret = lfs_file_open((lfs_t *)file->fMp->mData, lfsHandle, pathName, lfsOpenFlag);
if (ret != 0) {
free(lfsHandle);
LOSCFG_FS_FREE_HOOK(lfsHandle);
errno = LittlefsErrno(ret);
goto errout;
}
@ -560,16 +563,13 @@ int LfsClose(struct File *file)
return (int)LOS_NOK;
}
pthread_mutex_lock(&g_fsLocalMutex);
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
pthread_mutex_unlock(&g_fsLocalMutex);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = (int)LOS_NOK;
}
free(file->fData);
LOSCFG_FS_FREE_HOOK(file->fData);
file->fData = NULL;
return ret;
}

View File

@ -30,6 +30,23 @@
config FS_VFS
bool "Enable FS VFS"
default y
select POSIX_FS_API
help
Answer Y to enable LiteOS support VFS.
if FS_VFS
config FS_LOCK_TIMEOUT
int "Filesystem global lock timeout value in tick. -1 for waiting forever"
default -1
help
The timeout value of getting filesystem lock in tick. -1 for waiting forever
config FS_SUPPORT_MOUNT_TARGET_RECURSIVE
bool "Mount target can be recursive"
default n
depends on FS_VFS
help
Answer Y to enable LiteOS support VFS mount recursively. For example, "/system/bin".
endif

View File

@ -38,6 +38,7 @@
#define _LOS_FS_H_
#include "los_config.h"
#include "los_memory.h"
#include "dirent.h"
#include "sys/mount.h"
#include "sys/statfs.h"
@ -45,6 +46,7 @@
#include "sys/uio.h"
#include "unistd.h"
#include <stdarg.h>
#include "vfs_maps.h"
#ifdef __cplusplus
#if __cplusplus
@ -52,40 +54,13 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
int LOS_Open(const char *path, int flags, ...);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
ssize_t LOS_Write(int fd, const void *buff, size_t bytes);
off_t LOS_Lseek(int fd, off_t off, int whence);
int LOS_Stat(const char *path, struct stat *stat);
int LOS_Statfs(const char *path, struct statfs *buf);
int LOS_Unlink(const char *path);
int LOS_Rename(const char *oldpath, const char *newpath);
int LOS_Fsync(int fd);
DIR *LOS_Opendir(const char *path);
struct dirent *LOS_Readdir(DIR *dir);
int LOS_Closedir(DIR *dir);
int LOS_Mkdir(const char *path, mode_t mode);
int LOS_Rmdir(const char *path);
int LOS_Lstat(const char *path, struct stat *buffer);
int LOS_Fstat(int fd, struct stat *buf);
int LOS_Fcntl(int fd, int cmd, ...);
int LOS_Ioctl(int fd, int req, ...);
ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off);
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off);
int LOS_Isatty(int fd);
int LOS_Access(const char *path, int amode);
int LOS_Ftruncate(int fd, off_t length);
int LOS_FsUmount(const char *target);
int LOS_FsUmount2(const char *target, int flag);
int LOS_FsMount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data);
#ifndef LOSCFG_FS_MALLOC_HOOK
#define LOSCFG_FS_MALLOC_HOOK(size) LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, size)
#endif
int OsFcntl(int fd, int cmd, va_list ap);
int OsIoctl(int fd, int req, va_list ap);
#ifndef LOSCFG_FS_FREE_HOOK
#define LOSCFG_FS_FREE_HOOK(ptr) LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, ptr)
#endif
struct PartitionCfg {
/* partition low-level read func */
@ -143,6 +118,39 @@ int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int
*/
int LOS_PartitionFormat(const char *partName, char *fsType, void *data);
/*
* @brief new file system callbacks register.
* These callback functions are the adaptation layer implemented by the developer,
* used to interconnect the vfs with the new file system.
*
* LOS_FsRegister must be called after kernel initialization is complete.
*
* @param fsType file system type, don't register the same type fs more than once.
* @param fsMops mount operation of the fs.
* @param fsFops file operation of the fs.
* @param fsMgt management operation of the fs.
*
* @return Return LOS_OK if success.
* Return LOS_NOK if error.
* errno EINVAL: input errors, such as null pointers.
* errno ENOMEM: memory may malloc failed.
*
*/
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
/*
* @brief Lock the whole filesystem to forbid filesystem access.
*
* @return Return LOS_NOK if error. Return LOS_OK if seccess.
*/
int LOS_FsLock(void);
/*
* @brief Unlock the whole filesystem to allow filesystem access.
*/
void LOS_FsUnlock(void);
#ifdef __cplusplus
#if __cplusplus
extern "C" {

View File

@ -49,21 +49,17 @@
#ifdef LOSCFG_FS_FAT
#include "fatfs_conf.h"
#define __FAT_NFILE FAT_MAX_OPEN_FILES
#else
#define __FAT_NFILE 0
#endif
#ifdef LOSCFG_FS_LITTLEFS
#include "lfs_conf.h"
#define __LFS_NFILE LOSCFG_LFS_MAX_OPEN_FILES
#else
#define __LFS_NFILE 0
#endif
#define CONFIG_NFILE_DESCRIPTORS (__FAT_NFILE + __LFS_NFILE)
#ifndef CONFIG_NFILE_DESCRIPTORS
#define CONFIG_NFILE_DESCRIPTORS 256
#endif
#define NR_OPEN_DEFAULT CONFIG_NFILE_DESCRIPTORS
#define NR_OPEN_DEFAULT (CONFIG_NFILE_DESCRIPTORS - MIN_START_FD)
/* time configure */
@ -88,4 +84,9 @@
#define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR
/* max number of open directories */
#ifndef LOSCFG_MAX_OPEN_DIRS
#define LOSCFG_MAX_OPEN_DIRS 10
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@
#include "securec.h"
#include "los_debug.h"
#include "los_compiler.h"
#include "los_fs.h"
struct FsMap *g_fsMap = NULL;
@ -40,49 +41,67 @@ struct FsMap *VfsFsMapGet(const char *fsType)
{
struct FsMap *curr = g_fsMap;
(void)VfsLock();
(void)LOS_FsLock();
while (curr != NULL) {
if ((curr->fsType != NULL) && (fsType != NULL) &&
(strcmp(curr->fsType, fsType) == 0)) {
(void)VfsUnlock();
LOS_FsUnlock();
return curr;
}
curr = curr->next;
}
VfsUnlock();
LOS_FsUnlock();
return NULL;
}
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt)
int OsFsRegister(const char *fsType, const struct MountOps *fsMops,
const struct FileOps *fsFops, const struct FsManagement *fsMgt)
{
size_t len;
if ((fsMops == NULL) || (fsFops == NULL)) {
VFS_ERRNO_SET(EINVAL);
return (int)LOS_NOK;
}
struct FsMap *newfs = (struct FsMap *)malloc(sizeof(struct FsMap));
struct FsMap *newfs = (struct FsMap *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct FsMap));
if (newfs == NULL) {
PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType);
VFS_ERRNO_SET(ENOMEM);
return (int)LOS_NOK;
}
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
newfs->fsType = strdup(fsType);
len = strlen(fsType) + 1;
newfs->fsType = LOSCFG_FS_MALLOC_HOOK(len);
if (newfs->fsType == NULL) {
free(newfs);
LOSCFG_FS_FREE_HOOK(newfs);
VFS_ERRNO_SET(ENOMEM);
return (int)LOS_NOK;
}
(void)strcpy_s((char *)newfs->fsType, len, fsType);
newfs->fsMops = fsMops;
newfs->fsFops = fsFops;
newfs->fsMgt = fsMgt;
newfs->fsRefs = 0;
(void)VfsLock();
(void)LOS_FsLock();
newfs->next = g_fsMap;
g_fsMap = newfs;
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
}
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
const struct FileOps *fsFops, const struct FsManagement *fsMgt)
{
if (VfsFsMapGet(fsType) != NULL) {
PRINT_ERR("fsType has been registered or fsType error\n");
VFS_ERRNO_SET(EINVAL);
return (int)LOS_NOK;
}
return OsFsRegister(fsType, fsMops, fsFops, fsMgt);
}

View File

@ -56,8 +56,8 @@ struct FsMap {
struct FsMap *next;
};
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt);
int OsFsRegister(const char *fsType, const struct MountOps *fsMops,
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
struct FsMap *VfsFsMapGet(const char *fsType);
#ifdef __cplusplus

View File

@ -33,6 +33,9 @@
#include "vfs_config.h"
#include "stdlib.h"
#include "string.h"
#include "limits.h"
#include "errno.h"
#include "securec.h"
#include "vfs_operations.h"
#include "los_compiler.h"
#include "los_debug.h"
@ -60,14 +63,13 @@ static void MpDeleteFromList(struct MountPoint *mp)
}
}
#if (LOSCFG_FS_SUPPORT_MOUNT_TARGET_RECURSIVE == 1)
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
{
struct MountPoint *mp = g_mountPoints;
struct MountPoint *bestMp = NULL;
int bestMatches = 0;
if (path == NULL) {
return NULL;
}
if (pathInMp != NULL) {
*pathInMp = NULL;
}
@ -119,29 +121,85 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
next:
mp = mp->mNext;
}
return bestMp;
}
#else
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
{
struct MountPoint *mp = g_mountPoints;
const char *iPath = path;
const char *mPath = NULL;
const char *target = NULL;
STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType, unsigned long mountflags)
if (pathInMp != NULL) {
*pathInMp = NULL;
}
while (*iPath == '/') {
++iPath;
}
while ((mp != NULL) && (mp->mPath != NULL)) {
mPath = mp->mPath;
target = iPath;
while (*mPath == '/') {
++mPath;
}
while ((*mPath != '\0') && (*mPath != '/') &&
(*target != '\0') && (*target != '/')) {
if (*mPath != *target) {
break;
}
++mPath;
++target;
}
if (((*mPath == '\0') || (*mPath == '/')) &&
((*target == '\0') || (*target == '/'))) {
if (pathInMp != NULL) {
*pathInMp = path;
}
return mp;
}
mp = mp->mNext;
}
return NULL;
}
#endif
STATIC struct MountPoint *VfsMountPointInit(const char *source, const char *target,
const char *fsType, unsigned long mountflags)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
struct FsMap *mFs = NULL;
size_t ssize = 0;
size_t tsize;
/* find mp by target, to see if it was mounted */
mp = VfsMpFind(target, &pathInMp);
if (mp != NULL && pathInMp != NULL) {
errno = EINVAL;
return NULL;
}
/* Find fsMap coresponding to the fsType */
mFs = VfsFsMapGet(fsType);
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
errno = ENODEV;
return NULL;
}
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
if (source != NULL) {
ssize = strlen(source) + 1;
}
tsize = strlen(target) + 1;
mp = (struct MountPoint *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct MountPoint) + ssize + tsize);
if (mp == NULL) {
errno = ENOMEM;
return NULL;
}
@ -150,45 +208,86 @@ STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType,
mp->mRefs = 0;
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
mp->mFs->fsRefs++;
mp->mNext = g_mountPoints;
if (source != NULL && strcpy_s((char *)mp + sizeof(struct MountPoint), ssize, source) != EOK) {
LOSCFG_FS_FREE_HOOK(mp);
errno = ENOMEM;
return NULL;
}
if (strcpy_s((char *)mp + sizeof(struct MountPoint) + ssize, tsize, target) != EOK) {
LOSCFG_FS_FREE_HOOK(mp);
errno = ENOMEM;
return NULL;
}
mp->mDev = source ? (char *)mp + sizeof(struct MountPoint) : NULL;
mp->mPath = (char *)mp + sizeof(struct MountPoint) + ssize;
return mp;
}
int LOS_FsMount(const char *source, const char *target,
STATIC int VfsRemount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data)
{
(VOID)source;
(VOID)fsType;
struct MountPoint *mp;
mp = VfsMpFind(target, NULL);
if (mp == NULL) {
errno = EINVAL;
return (int)LOS_NOK;
}
LOS_ASSERT(mp->mFs != NULL);
LOS_ASSERT(mp->mFs->fsMops != NULL);
LOS_ASSERT(mp->mFs->fsMops->mount != NULL);
return mp->mFs->fsMops->mount(mp, mountflags, data);
}
STATIC int VfsMountPathCheck(const char *target)
{
/* target must begin with '/', for example /system, /data, etc. */
if ((target == NULL) || (target[0] != '/')) {
errno = EINVAL;
return (int)LOS_NOK;
}
if (strlen(target) >= PATH_MAX) {
errno = ENAMETOOLONG;
return (int)LOS_NOK;
}
return LOS_OK;
}
int mount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data)
{
int ret;
struct MountPoint *mp = NULL;
/* target must begin with '/', for example /system, /data, etc. */
if ((target == NULL) || (target[0] != '/')) {
if (VfsMountPathCheck(target) != LOS_OK) {
return (int)LOS_NOK;
}
(void)VfsLock();
(void)LOS_FsLock();
mp = MountPointInit(target, fsType, mountflags);
if (mountflags & MS_REMOUNT) {
ret = VfsRemount(source, target, fsType, mountflags, data);
LOS_FsUnlock();
return ret;
}
mp = VfsMountPointInit(source, target, fsType, mountflags);
if (mp == NULL) {
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}
if (source != NULL) {
mp->mDev = strdup(source);
if (mp->mDev == NULL) {
free(mp);
VfsUnlock();
return (int)LOS_NOK;
}
}
mp->mPath = strdup(target);
if (mp->mPath == NULL) {
goto errout;
}
ret = mp->mFs->fsMops->mount(mp, mountflags, data);
if (ret != 0) {
/* errno is set */
@ -196,30 +295,28 @@ int LOS_FsMount(const char *source, const char *target,
goto errout;
}
mp->mNext = g_mountPoints;
g_mountPoints = mp;
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
errout:
free((void *)mp->mPath);
free((void *)mp->mDev);
free(mp);
VfsUnlock();
LOSCFG_FS_FREE_HOOK(mp);
LOS_FsUnlock();
return (int)LOS_NOK;
}
int LOS_FsUmount(const char *target)
int umount(const char *target)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = (int)LOS_NOK;
(void)VfsLock();
if (target == NULL) {
(void)LOS_FsLock();
if (VfsMountPathCheck(target) != LOS_OK) {
goto errout;
}
mp = VfsMpFind(target, &pathInMp);
mp = VfsMpFind(target, NULL);
if ((mp == NULL) || (mp->mRefs != 0)) {
goto errout;
}
@ -238,16 +335,14 @@ int LOS_FsUmount(const char *target)
/* delete mp from mount list */
MpDeleteFromList(mp);
mp->mFs->fsRefs--;
free((void *)mp->mPath);
free((void *)mp->mDev);
free(mp);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}
@ -266,18 +361,17 @@ static void CloseFdsInMp(const struct MountPoint *mp)
}
}
int LOS_FsUmount2(const char *target, int flag)
int umount2(const char *target, int flag)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = (int)LOS_NOK;
(void)VfsLock();
if (target == NULL) {
(void)LOS_FsLock();
if (VfsMountPathCheck(target) != LOS_OK) {
goto errout;
}
mp = VfsMpFind(target, &pathInMp);
mp = VfsMpFind(target, NULL);
if ((mp == NULL) || (mp->mRefs != 0) ||
(mp->mFs == NULL) || (mp->mFs->fsMops == NULL) ||
(mp->mFs->fsMops->umount2 == NULL)) {
@ -298,15 +392,13 @@ int LOS_FsUmount2(const char *target, int flag)
/* delete mp from mount list */
MpDeleteFromList(mp);
mp->mFs->fsRefs--;
free((void *)mp->mPath);
free((void *)mp->mDev);
free(mp);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}

View File

@ -52,8 +52,6 @@ extern "C" {
extern UINT32 g_fsMutex;
int OsVfsInit(void);
int VfsLock(void);
void VfsUnlock(void);
#ifdef __cplusplus
#if __cplusplus

View File

@ -77,6 +77,7 @@ struct DeviceDesc *getDeviceList(VOID)
static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
int partNum)
{
size_t len;
struct DeviceDesc *prev = NULL;
for (prev = g_deviceList; prev != NULL; prev = prev->dNext) {
if (strcmp(prev->dDev, dev) == 0) {
@ -90,21 +91,25 @@ static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int
return (int)LOS_NOK;
}
prev = (struct DeviceDesc *)malloc(sizeof(struct DeviceDesc));
prev = (struct DeviceDesc *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct DeviceDesc));
if (prev == NULL) {
errno = -ENOMEM;
return (int)LOS_NOK;
}
prev->dDev = strdup(dev);
prev->dFsType = strdup(fsType);
prev->dAddrArray = (int *)malloc(partNum * sizeof(int));
len = strlen(dev) + 1;
prev->dDev = LOSCFG_FS_MALLOC_HOOK(len);
len = strlen(fsType) + 1;
prev->dFsType = LOSCFG_FS_MALLOC_HOOK(len);
prev->dAddrArray = (int *)LOSCFG_FS_MALLOC_HOOK(partNum * sizeof(int));
if (prev->dDev == NULL || prev->dFsType == NULL || prev->dAddrArray == NULL) {
goto errout;
}
(void)strcpy_s((char *)prev->dDev, len, dev);
(void)strcpy_s((char *)prev->dFsType, len, fsType);
(void)memcpy_s(prev->dAddrArray, partNum * sizeof(int), addrArray, partNum * sizeof(int));
if (lengthArray != NULL) {
prev->dLengthArray = (int *)malloc(partNum * sizeof(int));
prev->dLengthArray = (int *)LOSCFG_FS_MALLOC_HOOK(partNum * sizeof(int));
if (prev->dLengthArray == NULL) {
goto errout;
}
@ -117,19 +122,19 @@ static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int
return LOS_OK;
errout:
if (prev->dDev != NULL) {
free((void *)prev->dDev);
LOSCFG_FS_FREE_HOOK((void *)prev->dDev);
}
if (prev->dFsType != NULL) {
free((void *)prev->dFsType);
LOSCFG_FS_FREE_HOOK((void *)prev->dFsType);
}
if (prev->dAddrArray != NULL) {
free((void *)prev->dAddrArray);
LOSCFG_FS_FREE_HOOK((void *)prev->dAddrArray);
}
if (prev->dLengthArray != NULL) {
free((void *)prev->dLengthArray);
LOSCFG_FS_FREE_HOOK((void *)prev->dLengthArray);
}
free(prev);
LOSCFG_FS_FREE_HOOK(prev);
errno = -ENOMEM;
return (int)LOS_NOK;
}
@ -143,9 +148,7 @@ int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int
if ((fMap != NULL) && (fMap->fsMgt != NULL) &&
(fMap->fsMgt->fdisk != NULL)) {
ret = fMap->fsMgt->fdisk(dev, lengthArray, partNum);
if (ret == (int)LOS_NOK) {
return ret;
}
return ret;
}
ret = AddDevice(dev, fsType, lengthArray, addrArray, partNum);
@ -160,8 +163,7 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
format is not allowed when the device has been mounted. */
struct MountPoint *iter = NULL;
LOS_MP_FOR_EACH_ENTRY(iter) {
if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) &&
strcmp(iter->mFs->fsType, fsType) == 0) {
if ((iter->mPath != NULL) && (strcmp(iter->mPath, partName) == 0)) {
errno = EBUSY;
return (int)LOS_NOK;
}

View File

@ -373,8 +373,9 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
while (!ping_kill && (forever || (i < cnt))) {
iecho->seqno = htons((u16_t)i);
iecho->chksum = 0;
#if (CHECKSUM_GEN_ICMP > 0)
iecho->chksum = inet_chksum((void *)iecho, iecho_len);
#endif
ret = sendto(sfd, iecho, iecho_len, 0, (struct sockaddr *)&to, (socklen_t)sizeof(to));
if (ret < 0) {
perror("Ping: sending ICMP echo request failed\n");

View File

@ -181,6 +181,7 @@ VOID OsLs(const CHAR *pathname)
d = opendir(path);
if (d == NULL) {
PRINT_ERR("No such directory = %s\n", path);
free(path);
} else {
PRINTK("Directory %s:\n", path);
do {

View File

@ -42,6 +42,9 @@
#include "los_task.h"
#include "los_timer.h"
#include "los_debug.h"
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
#include "los_arch.h"
#endif
#include "string.h"
#include "securec.h"
@ -1002,6 +1005,10 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
UINT32 ret;
UINT32 muxId;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
UINTPTR regLR = ArchLRGet();
#endif
UNUSED(attr);
if (OS_INT_ACTIVE) {
@ -1010,6 +1017,9 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
ret = LOS_MuxCreate(&muxId);
if (ret == LOS_OK) {
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
OsSetMutexCreateInfo(GET_MUX(muxId), regLR);
#endif
return (osMutexId_t)(GET_MUX(muxId));
} else {
return (osMutexId_t)NULL;

View File

@ -35,7 +35,6 @@ choice
config LIBC_MUSL
bool "musl libc"
rsource "musl/Kconfig"
config LIBC_NEWLIB
bool "newlibc"

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -33,10 +33,7 @@ import("//third_party/musl/porting/liteos_m/kernel/musl.gni")
module_switch = defined(LOSCFG_LIBC_MUSL)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"fs.c",
"malloc.c",
]
sources = [ "malloc.c" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
deps = [ "//third_party/musl/porting/liteos_m/kernel" ]

View File

@ -1,329 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE
#include "los_config.h"
#include <errno.h>
#include <stdarg.h>
#include <dirent.h>
#include <sys/mount.h>
#include <sys/statfs.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef LOSCFG_LIBC_MUSL_FS
#include "los_fs.h"
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data)
{
return LOS_FsMount(source, target, filesystemtype, mountflags, data);
}
int umount(const char *target)
{
return LOS_FsUmount(target);
}
int umount2(const char *target, int flag)
{
return LOS_FsUmount2(target, flag);
}
int open(const char *path, int oflag, ...)
{
va_list vaList;
va_start(vaList, oflag);
int ret;
ret = LOS_Open(path, oflag, vaList);
va_end(vaList);
return ret;
}
int close(int fd)
{
return LOS_Close(fd);
}
ssize_t read(int fd, void *buf, size_t nbyte)
{
return LOS_Read(fd, buf, nbyte);
}
ssize_t write(int fd, const void *buf, size_t nbyte)
{
return LOS_Write(fd, buf, nbyte);
}
off_t lseek(int fd, off_t offset, int whence)
{
return LOS_Lseek(fd, offset, whence);
}
int unlink(const char *path)
{
return LOS_Unlink(path);
}
int fstat(int fd, struct stat *buf)
{
return LOS_Fstat(fd, buf);
}
int stat(const char *path, struct stat *buf)
{
return LOS_Stat(path, buf);
}
int fsync(int fd)
{
return LOS_Fsync(fd);
}
int mkdir(const char *path, mode_t mode)
{
return LOS_Mkdir(path, mode);
}
DIR *opendir(const char *dirName)
{
return LOS_Opendir(dirName);
}
struct dirent *readdir(DIR *dir)
{
return LOS_Readdir(dir);
}
int closedir(DIR *dir)
{
return LOS_Closedir(dir);
}
int rmdir(const char *path)
{
return LOS_Unlink(path);
}
int rename(const char *oldName, const char *newName)
{
return LOS_Rename(oldName, newName);
}
int statfs(const char *path, struct statfs *buf)
{
return LOS_Statfs(path, buf);
}
int ftruncate(int fd, off_t length)
{
return LOS_Ftruncate(fd, length);
}
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
{
return LOS_Pread(fd, buf, nbyte, offset);
}
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
{
return LOS_Pwrite(fd, buf, nbyte, offset);
}
int access(const char *path, int mode)
{
struct stat st;
if (stat(path, &st) < 0) {
return -1;
}
if ((st.st_mode & S_IFDIR) || (st.st_mode & S_IFREG)) {
return 0;
}
if ((mode & W_OK) && !(st.st_mode & S_IWRITE)) {
return -1;
}
return 0;
}
int fcntl(int fd, int cmd, ...)
{
int ret;
va_list vaList;
va_start(vaList, cmd);
ret = OsFcntl(fd, cmd, vaList);
va_end(vaList);
return ret;
}
int ioctl(int fd, int req, ...)
{
int ret;
va_list vaList;
va_start(vaList, req);
ret = OsIoctl(fd, req, vaList);
va_end(vaList);
return ret;
}
#else /* #ifdef LOSCFG_FS_VFS */
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data)
{
return -1;
}
int umount(const char *target)
{
return -1;
}
int umount2(const char *target, int flag)
{
return -1;
}
int open(const char *path, int oflag, ...)
{
return -1;
}
int close(int fd)
{
return -1;
}
ssize_t read(int fd, void *buf, size_t nbyte)
{
return -1;
}
ssize_t write(int fd, const void *buf, size_t nbyte)
{
return -1;
}
off_t lseek(int fd, off_t offset, int whence)
{
return -1;
}
int unlink(const char *path)
{
return -1;
}
int fstat(int fd, struct stat *buf)
{
return -1;
}
int stat(const char *path, struct stat *buf)
{
return -1;
}
int fsync(int fd)
{
return -1;
}
int mkdir(const char *path, mode_t mode)
{
return -1;
}
DIR *opendir(const char *dirName)
{
return NULL;
}
struct dirent *readdir(DIR *dir)
{
return NULL;
}
int closedir(DIR *dir)
{
return -1;
}
int rmdir(const char *path)
{
return -1;
}
int rename(const char *oldName, const char *newName)
{
return -1;
}
int statfs(const char *path, struct statfs *buf)
{
return -1;
}
int ftruncate(int fd, off_t length)
{
return -1;
}
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
{
return -1;
}
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
{
return -1;
}
int access(const char *path, int mode)
{
return -1;
}
int fcntl(int fd, int cmd, ...)
{
return -1;
}
int ioctl(int fd, int req, ...)
{
return -1;
}
#endif

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -34,7 +34,6 @@
#include "los_config.h"
#include "los_memory.h"
void *calloc(size_t nitems, size_t size)
{
size_t real_size;
@ -107,4 +106,3 @@ void *realloc(void *ptr, size_t size)
return LOS_MemRealloc(OS_SYS_MEM_ADDR, ptr, size);
}

View File

@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@ -33,7 +33,6 @@ module_switch = defined(LOSCFG_LIBC_NEWLIB)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"porting/src/fs.c",
"porting/src/malloc.c",
"porting/src/network/htonl.c",
"porting/src/network/htons.c",
@ -44,7 +43,7 @@ kernel_module(module_name) {
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
if (defined(LOSCFG_LIBC_NEWLIB_FS)) {
if (defined(LOSCFG_FS_VFS)) {
sources +=
[ "//third_party/musl/porting/liteos_m/kernel/src/misc/realpath.c" ]
}

View File

@ -1,271 +0,0 @@
/*
* Copyright (c) 2021-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.
*/
#define _GNU_SOURCE
#include "los_config.h"
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#ifdef LOSCFG_LIBC_NEWLIB_FS
#include "los_fs.h"
#endif
#ifdef LOSCFG_LIBC_NEWLIB_FS
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data)
{
return LOS_FsMount(source, target, filesystemtype, mountflags, data);
}
int umount(const char *target)
{
return LOS_FsUmount(target);
}
int umount2(const char *target, int flag)
{
return LOS_FsUmount2(target, flag);
}
int _open(const char *path, int oflag, ...)
{
va_list vaList;
va_start(vaList, oflag);
int ret;
ret = LOS_Open(path, oflag);
va_end(vaList);
return ret;
}
int _close(int fd)
{
return LOS_Close(fd);
}
ssize_t _read(int fd, void *buf, size_t nbyte)
{
return LOS_Read(fd, buf, nbyte);
}
ssize_t _write(int fd, const void *buf, size_t nbyte)
{
return LOS_Write(fd, buf, nbyte);
}
off_t _lseek(int fd, off_t offset, int whence)
{
return LOS_Lseek(fd, offset, whence);
}
int _unlink(const char *path)
{
return LOS_Unlink(path);
}
int _fstat(int fd, struct stat *buf)
{
return LOS_Fstat(fd, buf);
}
int _stat(const char *path, struct stat *buf)
{
return LOS_Stat(path, buf);
}
int fsync(int fd)
{
return LOS_Fsync(fd);
}
int mkdir(const char *path, mode_t mode)
{
return LOS_Mkdir(path, mode);
}
DIR *opendir(const char *dirName)
{
return LOS_Opendir(dirName);
}
struct dirent *readdir(DIR *dir)
{
return LOS_Readdir(dir);
}
int closedir(DIR *dir)
{
return LOS_Closedir(dir);
}
int rmdir(const char *path)
{
return LOS_Unlink(path);
}
int rename(const char *oldName, const char *newName)
{
return LOS_Rename(oldName, newName);
}
int statfs(const char *path, struct statfs *buf)
{
return LOS_Statfs(path, buf);
}
int ftruncate(int fd, off_t length)
{
return LOS_Ftruncate(fd, length);
}
int fcntl(int fd, int cmd, ...)
{
int ret;
va_list vaList;
va_start(vaList, cmd);
ret = OsFcntl(fd, cmd, vaList);
va_end(vaList);
return ret;
}
int ioctl(int fd, int req, ...)
{
int ret;
va_list vaList;
va_start(vaList, req);
ret = OsIoctl(fd, req, vaList);
va_end(vaList);
return ret;
}
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
{
return LOS_Pread(fd, buf, nbyte, offset);
}
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
{
return LOS_Pwrite(fd, buf, nbyte, offset);
}
int access(const char *path, int mode)
{
struct stat st;
if (stat(path, &st) < 0) {
return -1;
}
if ((st.st_mode & S_IFDIR) || (st.st_mode & S_IFREG)) {
return 0;
}
if ((mode & W_OK) && !(st.st_mode & S_IWRITE)) {
return -1;
}
return 0;
}
int remove(const char *filename)
{
int ret = unlink(filename);
if (ret == -EISDIR) {
ret = rmdir(filename);
}
return ret;
}
#else /* #ifdef LOSCFG_FS_VFS */
int _open(const char *path, int oflag, ...)
{
return -1;
}
int _close(int fd)
{
return -1;
}
ssize_t _read(int fd, void *buf, size_t nbyte)
{
return -1;
}
ssize_t _write(int fd, const void *buf, size_t nbyte)
{
return -1;
}
off_t _lseek(int fd, off_t offset, int whence)
{
return -1;
}
int _unlink(const char *path)
{
return -1;
}
int _fstat(int fd, struct stat *buf)
{
return -1;
}
int _stat(const char *path, struct stat *buf)
{
return -1;
}
int access(const char *path, int mode)
{
return -1;
}
int remove(const char *filename)
{
return -1;
}
int fcntl(int fd, int cmd, ...)
{
return -1;
}
int ioctl(int fd, int req, ...)
{
return -1;
}
#endif

View File

@ -57,4 +57,3 @@ void _exit(int status)
while (1) {
}
}

View File

@ -73,4 +73,11 @@ config POSIX_SIGNAL_API
help
Answer Y to enable LiteOS support POSIX Signal API.
config POSIX_FS_API
bool "Enable POSIX FS API"
default y
depends on FS_VFS
help
Answer Y to enable LiteOS support POSIX FS API.
endif # POSIX_API

View File

@ -38,6 +38,9 @@
#include "los_debug.h"
#include "los_hook.h"
#include "los_sched.h"
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
#include "los_arch.h"
#endif
#define MUTEXATTR_TYPE_MASK 0x0FU
#define OS_SYS_NS_PER_MSECOND 1000000
@ -130,6 +133,10 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
UINT32 muxHandle;
UINT32 ret;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
UINTPTR regLR = ArchLRGet();
#endif
if (mutex == NULL) {
return EINVAL;
}
@ -148,6 +155,9 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
mutex->stAttr = useAttr;
mutex->magic = _MUX_MAGIC;
mutex->handle = muxHandle;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
#endif
return 0;
}
@ -324,6 +334,10 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
struct timespec curTime = {0};
LosMuxCB *muxPended = NULL;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
UINTPTR regLR = ArchLRGet();
#endif
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
if (ret != 0) {
return (INT32)ret;
@ -337,6 +351,9 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
if (ret != LOS_OK) {
return MapError(ret);
}
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
#endif
} else {
muxPended = GET_MUX(mutex->handle);
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
@ -364,6 +381,11 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
{
UINT32 ret;
LosMuxCB *muxPended = NULL;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
UINTPTR regLR = ArchLRGet();
#endif
LosTaskCB *runTask = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
ret = MuxPreCheck(mutex, runTask);
@ -376,6 +398,9 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
if (ret != LOS_OK) {
return MapError(ret);
}
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
#endif
} else {
muxPended = GET_MUX(mutex->handle);
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
@ -394,6 +419,10 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
UINT32 ret;
LosMuxCB *muxPended = NULL;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
UINTPTR regLR = ArchLRGet();
#endif
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
if (ret != 0) {
return (INT32)ret;
@ -404,6 +433,9 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
if (ret != LOS_OK) {
return MapError(ret);
}
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
#endif
} else {
muxPended = GET_MUX(mutex->handle);
if ((mutex->stAttr.type != PTHREAD_MUTEX_RECURSIVE) && (muxPended->muxCount != 0)) {

View File

@ -664,7 +664,7 @@ static time_t ConvertUtc2Secs(struct tm *tm)
seconds += (tm->tm_mday - 1) * SECS_PER_DAY;
seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec;
seconds -= tm->__tm_gmtoff; // sub time zone to get UTC time
seconds += g_timezone;
return seconds;
}
@ -690,7 +690,7 @@ time_t mktime(struct tm *tmptr)
}
timeInSeconds = ConvertUtc2Secs(tmptr);
/* normalize tm_wday and tm_yday */
ConvertSecs2Utc(timeInSeconds, tmptr->__tm_gmtoff, tmptr);
ConvertSecs2Utc(timeInSeconds, -g_timezone, tmptr);
return timeInSeconds;
}

View File

@ -490,6 +490,72 @@ extern UINT32 LOS_MemIntegrityCheck(const VOID *pool);
* </ul>
* @see None.
*/
/* Supposing a Second Level Index: SLI = 3. */
#define OS_MEM_SLI 3
/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
#define OS_MEM_SMALL_BUCKET_COUNT 31
#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
#define OS_MEM_LARGE_BUCKET_COUNT 24
/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
#define OS_MEM_LARGE_START_BUCKET 7
/* The count of free list. */
#define OS_MEM_FREE_LIST_COUNT (OS_MEM_SMALL_BUCKET_COUNT + (OS_MEM_LARGE_BUCKET_COUNT << OS_MEM_SLI))
/* The bitmap is used to indicate whether the free list is empty, 1: not empty, 0: empty. */
#define OS_MEM_BITMAP_WORDS ((OS_MEM_FREE_LIST_COUNT >> 5) + 1)
struct OsMemNodeHead {
#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
UINT32 magic;
#endif
#if (LOSCFG_MEM_LEAKCHECK == 1)
UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
#endif
union {
struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
struct OsMemNodeHead *next; /* The next is used for sentinel node points to the expand node */
} ptr;
#if (LOSCFG_TASK_MEM_USED == 1)
UINT32 taskID;
UINT32 sizeAndFlag;
#elif (LOSCFG_MEM_FREE_BY_TASKID == 1)
UINT32 taskID : 6;
UINT32 sizeAndFlag : 26;
#else
UINT32 sizeAndFlag;
#endif
};
struct OsMemFreeNodeHead {
struct OsMemNodeHead header;
struct OsMemFreeNodeHead *prev;
struct OsMemFreeNodeHead *next;
};
struct OsMemPoolInfo {
VOID *pool;
UINT32 totalSize;
UINT32 attr;
#if (LOSCFG_MEM_WATERLINE == 1)
UINT32 waterLine; /* Maximum usage size in a memory pool */
UINT32 curUsedSize; /* Current usage size in a memory pool */
#endif
#if (LOSCFG_MEM_MUL_REGIONS == 1)
UINT32 totalGapSize;
#endif
};
struct OsMemPoolHead {
struct OsMemPoolInfo info;
UINT32 freeListBitmap[OS_MEM_BITMAP_WORDS];
struct OsMemFreeNodeHead *freeList[OS_MEM_FREE_LIST_COUNT];
#if (LOSCFG_MEM_MUL_POOL == 1)
VOID *nextPool;
#endif
};
extern VOID LOS_MemUnlockEnable(VOID *pool);
extern UINT32 OsMemSystemInit(VOID);

View File

@ -39,7 +39,6 @@
#include "los_task.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
@ -302,6 +301,9 @@ typedef struct {
UINT32 muxID; /**< Handle ID */
LOS_DL_LIST muxList; /**< Mutex linked list */
LosTaskCB *owner; /**< The current thread that is locking a mutex */
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
UINTPTR createInfo; /**< Return address of the caller */
#endif
UINT16 priority; /**< Priority of the thread that is locking a mutex */
} LosMuxCB;
@ -351,6 +353,13 @@ extern UINT32 OsMuxInit(VOID);
*/
#define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosMuxCB, muxList)
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
STATIC INLINE VOID OsSetMutexCreateInfo(LosMuxCB *mux, UINTPTR val)
{
mux->createInfo = val;
}
#endif /* LOSCFG_MUTEX_CREATE_TRACE == 1 */
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -96,6 +96,11 @@ STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
return LOS_SysCycleGet();
}
STATIC INLINE BOOL OsCheckKernelRunning(VOID)
{
return (g_taskScheduled && LOS_CHECK_SCHEDULE);
}
/**
* @ingroup los_sched
* @brief Get the time, in nanoseconds, remaining before the next tick interrupt response.

View File

@ -120,21 +120,6 @@ LITE_OS_SEC_TEXT_INIT VOID LOS_Panic(const CHAR *fmt, ...)
ArchSysExit();
}
/*****************************************************************************
Function : OsRegister
Description : Configuring the maximum number of tasks
Input : None
Output : None
Return : None
*****************************************************************************/
LITE_OS_SEC_TEXT_INIT static VOID OsRegister(VOID)
{
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
return;
}
LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID)
{
return ArchStartSchedule();
@ -156,8 +141,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
OsBackTraceInit();
#endif
OsRegister();
#ifdef LOSCFG_KERNEL_LMS
OsLmsInit();
#endif

View File

@ -37,7 +37,6 @@
#include "los_memory.h"
#include "los_sched.h"
#if (LOSCFG_BASE_IPC_MUX == 1)
LITE_OS_SEC_BSS LosMuxCB* g_allMux = NULL;
@ -71,6 +70,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsMuxInit(VOID)
muxNode->muxID = index;
muxNode->owner = (LosTaskCB *)NULL;
muxNode->muxStat = OS_MUX_UNUSED;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
muxNode->createInfo = 0;
#endif
LOS_ListTailInsert(&g_unusedMuxList, &muxNode->muxList);
}
return LOS_OK;
@ -149,7 +151,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_MuxDelete(UINT32 muxHandle)
LOS_ListAdd(&g_unusedMuxList, &muxDeleted->muxList);
muxDeleted->muxStat = OS_MUX_UNUSED;
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
muxDeleted->createInfo = 0;
#endif
LOS_IntRestore(intSave);
OsHookCall(LOS_HOOK_TYPE_MUX_DELETE, muxDeleted);
@ -320,5 +324,5 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxPost(UINT32 muxHandle)
return LOS_OK;
}
#endif /* (LOSCFG_BASE_IPC_MUX == 1) */
#endif /* (LOSCFG_BASE_IPC_MUX == 1) */

View File

@ -618,7 +618,7 @@ VOID LOS_SchedTickHandler(VOID)
VOID LOS_Schedule(VOID)
{
if (g_taskScheduled && LOS_CHECK_SCHEDULE) {
if (OsCheckKernelRunning()) {
ArchTaskSchedule();
}
}

View File

@ -75,7 +75,7 @@
* @ingroup los_task
* @brief check task id's validation
*/
#define OS_TASK_ID_CHECK(taskID) LOS_ASSERT_COND(OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
#define OS_TASK_ID_CHECK(taskID) (OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
/**
* @ingroup los_task
@ -409,6 +409,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
UINT32 size;
UINT32 index;
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
size = (g_taskMaxNum + 1) * sizeof(LosTaskCB);
g_taskCBArray = (LosTaskCB *)LOS_MemAlloc(m_aucSysMem0, size);
if (g_taskCBArray == NULL) {
@ -856,7 +857,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
UINT32 retErr = OS_ERROR;
BOOL needSched = FALSE;
if (taskID > LOSCFG_BASE_CORE_TSK_LIMIT) {
if (!OS_TASK_ID_CHECK(taskID)) {
return LOS_ERRNO_TSK_ID_INVALID;
}

View File

@ -59,21 +59,6 @@ VOID *g_poolHead = NULL;
/* The following is the macro definition and interface implementation related to the TLSF. */
/* Supposing a Second Level Index: SLI = 3. */
#define OS_MEM_SLI 3
/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
#define OS_MEM_SMALL_BUCKET_COUNT 31
#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
#define OS_MEM_LARGE_BUCKET_COUNT 24
/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
#define OS_MEM_LARGE_START_BUCKET 7
/* The count of free list. */
#define OS_MEM_FREE_LIST_COUNT (OS_MEM_SMALL_BUCKET_COUNT + (OS_MEM_LARGE_BUCKET_COUNT << OS_MEM_SLI))
/* The bitmap is used to indicate whether the free list is empty, 1: not empty, 0: empty. */
#define OS_MEM_BITMAP_WORDS ((OS_MEM_FREE_LIST_COUNT >> 5) + 1)
#define OS_MEM_BITMAP_MASK 0x1FU
/* Used to find the first bit of 1 in bitmap. */
@ -120,60 +105,10 @@ STATIC INLINE UINT32 OsMemSlGet(UINT32 size, UINT32 fl)
#error "When enter here, LOSCFG_BASE_CORE_TSK_LIMIT larger than 63 is not support"
#endif
struct OsMemNodeHead {
#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
UINT32 magic;
#endif
#if (LOSCFG_MEM_LEAKCHECK == 1)
UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
#endif
union {
struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
struct OsMemNodeHead *next; /* The next is used for sentinel node points to the expand node */
} ptr;
#if (LOSCFG_TASK_MEM_USED == 1)
UINT32 taskID;
UINT32 sizeAndFlag;
#elif (LOSCFG_MEM_FREE_BY_TASKID == 1)
UINT32 taskID : 6;
UINT32 sizeAndFlag : 26;
#else
UINT32 sizeAndFlag;
#endif
};
struct OsMemUsedNodeHead {
struct OsMemNodeHead header;
};
struct OsMemFreeNodeHead {
struct OsMemNodeHead header;
struct OsMemFreeNodeHead *prev;
struct OsMemFreeNodeHead *next;
};
struct OsMemPoolInfo {
VOID *pool;
UINT32 totalSize;
UINT32 attr;
#if (LOSCFG_MEM_WATERLINE == 1)
UINT32 waterLine; /* Maximum usage size in a memory pool */
UINT32 curUsedSize; /* Current usage size in a memory pool */
#endif
#if (LOSCFG_MEM_MUL_REGIONS == 1)
UINT32 totalGapSize;
#endif
};
struct OsMemPoolHead {
struct OsMemPoolInfo info;
UINT32 freeListBitmap[OS_MEM_BITMAP_WORDS];
struct OsMemFreeNodeHead *freeList[OS_MEM_FREE_LIST_COUNT];
#if (LOSCFG_MEM_MUL_POOL == 1)
VOID *nextPool;
#endif
};
/* The memory pool support expand. */
#define OS_MEM_POOL_EXPAND_ENABLE 0x01
/* The memory pool support no lock. */

View File

@ -90,7 +90,7 @@ static UINT32 Testcase(VOID)
LOS_EventInit(&g_pevent);
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
g_testCount++;
@ -111,7 +111,6 @@ static UINT32 Testcase(VOID)
EXIT1:
LOS_TaskDelete(g_testTaskID02);
EXIT:
LOS_TaskDelete(g_testTaskID01);
return LOS_OK;

View File

@ -88,7 +88,7 @@ static UINT32 Testcase(VOID)
LOS_EventInit(&g_pevent);
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
g_testCount++;
@ -106,7 +106,6 @@ static UINT32 Testcase(VOID)
EXIT1:
LOS_TaskDelete(g_testTaskID02);
EXIT:
LOS_TaskDelete(g_testTaskID01);
return LOS_OK;

View File

@ -37,7 +37,7 @@ static VOID TaskF01(VOID)
{
}
VOID ItHwiM3B001F001()
static VOID ItHwiM3B001F001(VOID)
{
return;
}

View File

@ -69,7 +69,7 @@ static UINT32 g_uwsTick2;
static UINT32 g_uwsTick3;
extern VOID LOS_GetCpuTick(UINT32 *puwCntHi, UINT32 *puwCntLo);
extern VOID ItSuiteLosSwtmr();
extern VOID ItSuiteLosSwtmr(VOID);
extern VOID ItLosSwtmr001(VOID);
extern VOID ItLosSwtmr002(VOID);
extern VOID ItLosSwtmr003(VOID);

View File

@ -39,7 +39,7 @@ static VOID Case1(UINT32 arg)
g_testCount++;
}
static VOID Case2()
static VOID Case2(VOID)
{
g_testCount++;
}

View File

@ -44,12 +44,12 @@ static VOID Case1(UINT32 arg)
g_testCount++;
}
static VOID Case2()
static VOID Case2(VOID)
{
g_testCount++;
}
static VOID Case3()
static VOID Case3(VOID)
{
g_testCount++;
}

View File

@ -34,7 +34,7 @@
static UINT32 g_testCount1 = 0;
static VOID Case1()
static VOID Case1(VOID)
{
UINT32 ret;

View File

@ -35,7 +35,7 @@
static UINT32 g_testCount1 = 0;
static VOID Case1()
static VOID Case1(VOID)
{
UINT32 ret;

View File

@ -44,7 +44,7 @@ static VOID Case1(UINT32 arg)
return;
}
static VOID Case2()
static VOID Case2(VOID)
{
UINT32 ret;
UINT32 tick;

View File

@ -32,9 +32,6 @@
#include "osTest.h"
#include "It_los_task.h"
static UINT32 g_freeMem1 = 0;
static UINT32 g_freeMem2 = 0;
static UINT32 GetfreeMemSize(void *pool)
{
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);

View File

@ -43,7 +43,7 @@ pthread_t TestPthreadSelf(void)
return tid;
}
VOID ItSuitePosixPthread()
void ItSuitePosixPthread(void)
{
printf("************** begin SAMPLE POSIX pthread test *************\n");
ItPosixPthread001();

View File

@ -32,6 +32,7 @@
#include "osTest.h"
#include "pthread.h"
#include "time.h"
#include <unistd.h>
#undef TASK_PRIO_TEST
#define TASK_PRIO_TEST LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO
@ -690,7 +691,6 @@ static VOID PthreadOnceFunc01(void)
LITE_TEST_CASE(PthreadFuncTestSuite, TestPthread010, Function | MediumTest | Level1)
{
pthread_attr_t attr;
pthread_t thread[TEST_THREAD_COUNT];
struct sched_param schedParam = { 0 };
UINT32 ret;
UINT32 i = 0;

View File

@ -34,6 +34,7 @@
#include "posix_test.h"
#include "kernel_test.h"
#include "log.h"
#include <ctype.h>
#define RET_TRUE 1
#define RET_FALSE 0

View File

@ -77,6 +77,8 @@
void ItSuitePosix(void);
extern void ItSuitePosixPthread(void);
extern void ItSuitePosixMutex(void);
extern void PosixCtypeFuncTest(void);
extern void PosixIsdigitFuncTest(void);
extern void PosixIslowerFuncTest(void);

View File

@ -33,6 +33,8 @@
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
#include <string.h>
#include <stdlib.h>
#define RET_OK 0

View File

@ -34,6 +34,8 @@
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
#include <string.h>
#include <stdlib.h>
#define EQUAL 0

View File

@ -41,6 +41,7 @@
#include "kernel_test.h"
#include "log.h"
#include "los_tick.h"
#include <unistd.h>
#define RET_OK 0