Compare commits

...

22 Commits

Author SHA1 Message Date
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
31 changed files with 242 additions and 124 deletions

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

View File

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

View File

@ -40,12 +40,13 @@
#include "securec.h"
#include "los_compiler.h"
#include "los_debug.h"
#include "cmsis_os2.h"
#include "los_sched.h"
#include "vfs_files.h"
#include "vfs_operations.h"
#include "vfs_partition.h"
#include "vfs_maps.h"
#include "vfs_mount.h"
#include "los_fs.h"
/* the max name length of different parts should not bigger than 32 */
#define FS_DRIVE_NAME_MAX_LEN 32
@ -73,7 +74,7 @@ static int FsLock(void)
{
int ret = 0;
struct timespec absTimeout = {0};
if (osKernelGetState() != osKernelRunning) {
if (!OsCheckKernelRunning()) {
return ret;
}
ret = clock_gettime(CLOCK_REALTIME, &absTimeout);
@ -88,7 +89,7 @@ static int FsLock(void)
static void FsUnlock(void)
{
if (osKernelGetState() != osKernelRunning) {
if (!OsCheckKernelRunning()) {
return;
}
(void)pthread_mutex_unlock(&g_fatfsMutex);
@ -244,7 +245,7 @@ char * GetLdPath(const char *source)
}
char *volPath = g_volPath[partId];
char *ldPath = (char *)malloc(strlen(volPath) + LDPATH_PAD);
char *ldPath = (char *)LOSCFG_FS_MALLOC_HOOK(strlen(volPath) + LDPATH_PAD);
if (ldPath == NULL) {
return NULL;
}
@ -255,7 +256,7 @@ char * GetLdPath(const char *source)
*ldPath = '/';
ret = strcpy_s(ldPath + 1, strlen(volPath)+1, volPath);
if (ret != EOK) {
free(ldPath);
LOSCFG_FS_FREE_HOOK(ldPath);
return NULL;
}
@ -265,7 +266,7 @@ char * GetLdPath(const char *source)
void PutLdPath(const char *ldPath)
{
if (ldPath != NULL) {
free((void *)ldPath);
LOSCFG_FS_FREE_HOOK((void *)ldPath);
}
}
@ -282,6 +283,12 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
return (int)LOS_NOK;
}
if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags);
FsUnlock();
return ret;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
@ -289,12 +296,7 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
goto ERROUT;
}
if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags);
goto ERROUT;
}
fs = (FATFS *)malloc(sizeof(FATFS));
fs = (FATFS *)LOSCFG_FS_MALLOC_HOOK(sizeof(FATFS));
if (fs == NULL) {
errno = ENOMEM;
ret = (int)LOS_NOK;
@ -315,7 +317,7 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
return (int)LOS_OK;
ERROUT:
free(fs);
LOSCFG_FS_FREE_HOOK(fs);
mp->mData = NULL;
PutLdPath(ldPath);
FsUnlock();
@ -368,7 +370,7 @@ int FatfsUmount(struct MountPoint *mp)
ff_memfree(fatfs->win);
}
free(mp->mData);
LOSCFG_FS_FREE_HOOK(mp->mData);
mp->mData = NULL;
ret = (int)LOS_OK;
@ -423,7 +425,7 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
ff_memfree(fatfs->win);
}
free(mp->mData);
LOSCFG_FS_FREE_HOOK(mp->mData);
mp->mData = NULL;
ret = (int)LOS_OK;
@ -448,7 +450,7 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
fmode = FatFsGetMode(oflag);
fp = (FIL *)malloc(sizeof(FIL));
fp = (FIL *)LOSCFG_FS_MALLOC_HOOK(sizeof(FIL));
if (fp == NULL) {
errno = ENOMEM;
return (int)LOS_NOK;
@ -457,7 +459,7 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
ret = FsLock();
if (ret != 0) {
errno = ret;
free(fp);
LOSCFG_FS_FREE_HOOK(fp);
return (int)LOS_NOK;
}
@ -466,14 +468,14 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = (int)LOS_NOK;
free(fp);
LOSCFG_FS_FREE_HOOK(fp);
goto OUT;
}
res = f_open(fp, path, fmode);
if (res != FR_OK) {
PRINT_ERR("FAT open err 0x%x!\r\n", res);
free(fp);
LOSCFG_FS_FREE_HOOK(fp);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
@ -517,7 +519,7 @@ int FatfsClose(struct File *file)
(void)ff_memfree(fp->buf);
}
#endif
free(file->fData);
LOSCFG_FS_FREE_HOOK(file->fData);
file->fData = NULL;
FsUnlock();
@ -832,7 +834,7 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
goto ERROUT;
}
dp = (DIR *)malloc(sizeof(DIR));
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
if (dp == NULL) {
errno = ENOENT;
goto ERROUT;
@ -866,7 +868,7 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
ERROUT:
if (dp != NULL) {
free(dp);
LOSCFG_FS_FREE_HOOK(dp);
}
FsUnlock();
return (int)LOS_NOK;
@ -938,7 +940,7 @@ int FatfsClosedir(struct Dir *dir)
return (int)LOS_NOK;
}
free(dir->dData);
LOSCFG_FS_FREE_HOOK(dir->dData);
dir->dData = NULL;
FsUnlock();

View File

@ -39,6 +39,7 @@
#include "vfs_maps.h"
#include "vfs_mount.h"
#include "securec.h"
#include "los_fs.h"
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
@ -184,7 +185,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 +211,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 +240,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 +334,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 +343,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;
}
@ -415,7 +422,7 @@ int LfsClosedir(struct Dir *dir)
ret = (int)LOS_NOK;
}
free(dirInfo);
LOSCFG_FS_FREE_HOOK(dirInfo);
dir->dData = NULL;
return ret;
@ -432,7 +439,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 +448,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;
}
@ -569,7 +576,7 @@ int LfsClose(struct File *file)
ret = (int)LOS_NOK;
}
free(file->fData);
LOSCFG_FS_FREE_HOOK(file->fData);
file->fData = NULL;
return ret;
}

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"
@ -52,6 +53,14 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#ifndef LOSCFG_FS_MALLOC_HOOK
#define LOSCFG_FS_MALLOC_HOOK(size) LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, size)
#endif
#ifndef LOSCFG_FS_FREE_HOOK
#define LOSCFG_FS_FREE_HOOK(ptr) LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, ptr)
#endif
int LOS_Open(const char *path, int flags, ...);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buff, size_t bytes);

View File

@ -40,6 +40,7 @@
#include "fcntl.h"
#include "los_mux.h"
#include "los_debug.h"
#include "los_sched.h"
#include "limits.h"
#include "securec.h"
#include "vfs_config.h"
@ -85,7 +86,7 @@ int PollQueryFd(int fd, struct PollTable *table)
#endif
#define FREE_AND_SET_NULL(ptr) do { \
free(ptr); \
LOSCFG_FS_FREE_HOOK(ptr); \
ptr = NULL; \
} while (0)
@ -96,6 +97,9 @@ UINT32 g_fsMutex;
int VfsLock(void)
{
if (!OsCheckKernelRunning()) {
return LOS_OK;
}
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
PRINT_ERR("VfsLock failed!");
return (int)LOS_NOK;
@ -106,6 +110,9 @@ int VfsLock(void)
void VfsUnlock(void)
{
if (!OsCheckKernelRunning()) {
return;
}
(void)LOS_MuxPost(g_fsMutex);
}
@ -136,13 +143,13 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
offset = strlen("///") + 1; // three '/' and one '\0'
size_t tmpLen = strlen(cwd) + strlen(path) + offset;
char *tmpBuf = (char *)malloc(tmpLen);
char *tmpBuf = (char *)LOSCFG_FS_MALLOC_HOOK(tmpLen);
if (tmpBuf == NULL) {
return LOS_OK;
}
if (-1 == sprintf_s(tmpBuf, tmpLen, "/%s/%s/", cwd, path)) {
free(tmpBuf);
LOSCFG_FS_FREE_HOOK(tmpBuf);
return LOS_OK;
}
@ -151,7 +158,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
offset = strlen("/./") - 1;
while ((p = strstr(tmpBuf, "/./")) != NULL) {
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
LOSCFG_FS_FREE_HOOK(tmpBuf);
return LOS_OK;
}
}
@ -159,7 +166,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
/* replace // to / */
while ((p = strstr(tmpBuf, "//")) != NULL) {
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + 1, tmpLen - (p - tmpBuf) - 1)) {
free(tmpBuf);
LOSCFG_FS_FREE_HOOK(tmpBuf);
return LOS_OK;
}
}
@ -172,7 +179,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
--start;
}
if (EOK != memmove_s(start, tmpLen - (start - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
LOSCFG_FS_FREE_HOOK(tmpBuf);
return LOS_OK;
}
}
@ -184,23 +191,24 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
}
if ((!buf) || (bufSize == 0)) {
free(tmpBuf);
LOSCFG_FS_FREE_HOOK(tmpBuf);
return totalLen;
}
if (EOK != memcpy_s(buf, bufSize, tmpBuf, (((totalLen + 1) > bufSize) ? bufSize : (totalLen + 1)))) {
free(tmpBuf);
LOSCFG_FS_FREE_HOOK(tmpBuf);
return LOS_OK;
}
buf[bufSize - 1] = 0;
free(tmpBuf);
LOSCFG_FS_FREE_HOOK(tmpBuf);
return totalLen;
}
#endif
static int VfsOpen(const char *path, int flags)
{
size_t len;
struct File *file = NULL;
int fd = -1;
const char *pathInMp = NULL;
@ -240,13 +248,15 @@ static int VfsOpen(const char *path, int flags)
return fd;
}
file->fullPath = strdup(path);
len = strlen(path) + 1;
file->fullPath = LOSCFG_FS_MALLOC_HOOK(len);
if (file->fullPath == NULL) {
VFS_ERRNO_SET(ENOMEM);
VfsFilePut(file);
VfsUnlock();
return (int)LOS_NOK;
}
(void)strcpy_s((char *)file->fullPath, len, path);
file->fFlags = (UINT32)flags;
file->fOffset = 0;
@ -337,7 +347,7 @@ static int VfsClose(int fd)
}
if (file->fullPath != NULL) {
free((void *)file->fullPath);
LOSCFG_FS_FREE_HOOK((void *)file->fullPath);
}
VfsDetachFile(file);
@ -644,7 +654,7 @@ static DIR *VfsOpendir(const char *path)
return NULL;
}
dir = (struct Dir *)malloc(sizeof(struct Dir));
dir = (struct Dir *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct Dir));
if (dir == NULL) {
VFS_ERRNO_SET(ENOMEM);
return NULL;
@ -652,7 +662,7 @@ static DIR *VfsOpendir(const char *path)
if (VfsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
free(dir);
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
}
@ -660,14 +670,14 @@ static DIR *VfsOpendir(const char *path)
if ((mp == NULL) || (pathInMp == NULL)) {
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
free(dir);
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
}
if (mp->mFs->fsFops->opendir == NULL) {
VFS_ERRNO_SET(ENOTSUP);
VfsUnlock();
free(dir);
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
}
@ -678,7 +688,7 @@ static DIR *VfsOpendir(const char *path)
if (ret == 0) {
mp->mRefs++;
} else {
free(dir);
LOSCFG_FS_FREE_HOOK(dir);
dir = NULL;
}
@ -747,7 +757,7 @@ static int VfsClosedir(DIR *d)
}
VfsUnlock();
free(dir);
LOSCFG_FS_FREE_HOOK(dir);
dir = NULL;
return ret;
}
@ -920,7 +930,7 @@ int LOS_Open(const char *path, int flags, ...)
return (int)LOS_NOK;
}
char *canonicalPath = (char *)malloc(pathLen);
char *canonicalPath = (char *)LOSCFG_FS_MALLOC_HOOK(pathLen);
if (!canonicalPath) {
errno = ENOMEM;
return (int)LOS_NOK;
@ -1235,7 +1245,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
return (ssize_t)LOS_NOK;
}
totalLen = bufLen * sizeof(char);
buf = (char *)malloc(totalLen);
buf = (char *)LOSCFG_FS_MALLOC_HOOK(totalLen);
if (buf == NULL) {
return (ssize_t)LOS_NOK;
}
@ -1252,7 +1262,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
size_t lenToRead = totalLen < bytesToRead ? totalLen : bytesToRead;
ret = memcpy_s(readBuf, bytesToRead, curBuf, lenToRead);
if (ret != EOK) {
free(buf);
LOSCFG_FS_FREE_HOOK(buf);
return (ssize_t)LOS_NOK;
}
if (totalLen < (size_t)bytesToRead) {
@ -1261,7 +1271,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
curBuf += bytesToRead;
totalLen -= bytesToRead;
}
free(buf);
LOSCFG_FS_FREE_HOOK(buf);
return totalBytesRead;
}
@ -1293,7 +1303,7 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
return (ssize_t)LOS_NOK;
}
totalLen = bufLen * sizeof(char);
buf = (char *)malloc(totalLen);
buf = (char *)LOSCFG_FS_MALLOC_HOOK(totalLen);
if (buf == NULL) {
return (ssize_t)LOS_NOK;
}
@ -1306,7 +1316,7 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
}
ret = memcpy_s(curBuf, totalLen, writeBuf, bytesToWrite);
if (ret != EOK) {
free(buf);
LOSCFG_FS_FREE_HOOK(buf);
return (ssize_t)LOS_NOK;
}
curBuf += bytesToWrite;
@ -1314,7 +1324,7 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
}
totalBytesWritten = write(fd, buf, bufLen);
free(buf);
LOSCFG_FS_FREE_HOOK(buf);
return totalBytesWritten;
}

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;
@ -57,22 +58,25 @@ struct FsMap *VfsFsMapGet(const char *fsType)
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt)
{
size_t len;
if ((fsMops == NULL) || (fsFops == NULL)) {
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);
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);
return (int)LOS_NOK;
}
(void)strcpy_s((char *)newfs->fsType, len, fsType);
newfs->fsMops = fsMops;
newfs->fsFops = fsFops;

View File

@ -33,6 +33,8 @@
#include "vfs_config.h"
#include "stdlib.h"
#include "string.h"
#include "errno.h"
#include "securec.h"
#include "vfs_operations.h"
#include "los_compiler.h"
#include "los_debug.h"
@ -122,7 +124,7 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
return bestMp;
}
STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType, unsigned long mountflags)
STATIC struct MountPoint *VfsMountPointInit(const char *target, const char *fsType, unsigned long mountflags)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
@ -140,7 +142,7 @@ STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType,
return NULL;
}
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
mp = (struct MountPoint *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct MountPoint));
if (mp == NULL) {
return NULL;
}
@ -155,10 +157,32 @@ STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType,
return mp;
}
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);
}
int LOS_FsMount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data)
{
size_t len;
int ret;
struct MountPoint *mp = NULL;
@ -169,25 +193,35 @@ int LOS_FsMount(const char *source, const char *target,
(void)VfsLock();
mp = MountPointInit(target, fsType, mountflags);
if (mountflags & MS_REMOUNT) {
ret = VfsRemount(source, target, fsType, mountflags, data);
VfsUnlock();
return ret;
}
mp = VfsMountPointInit(target, fsType, mountflags);
if (mp == NULL) {
VfsUnlock();
return (int)LOS_NOK;
}
if (source != NULL) {
mp->mDev = strdup(source);
len = strlen(source) + 1;
mp->mDev = LOSCFG_FS_MALLOC_HOOK(len);
if (mp->mDev == NULL) {
free(mp);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
return (int)LOS_NOK;
}
(void)strcpy_s((char *)mp->mDev, len, source);
}
mp->mPath = strdup(target);
len = strlen(target) + 1;
mp->mPath = LOSCFG_FS_MALLOC_HOOK(len);
if (mp->mPath == NULL) {
goto errout;
}
(void)strcpy_s((char *)mp->mPath, len, target);
ret = mp->mFs->fsMops->mount(mp, mountflags, data);
if (ret != 0) {
@ -201,9 +235,9 @@ int LOS_FsMount(const char *source, const char *target,
return LOS_OK;
errout:
free((void *)mp->mPath);
free((void *)mp->mDev);
free(mp);
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
return (int)LOS_NOK;
}
@ -238,9 +272,9 @@ 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((void *)mp->mPath);
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
return LOS_OK;
@ -298,9 +332,9 @@ 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((void *)mp->mPath);
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
return LOS_OK;

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;
}
@ -160,8 +165,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

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

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

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