Compare commits

...

16 Commits

Author SHA1 Message Date
openharmony_ci 366365fbf9
!803 低功耗增加idle选项
Merge pull request !803 from zhushengle/cherry-pick-1661260031
2022-08-23 13:57:24 +00:00
zhushengle 9f8c031324 fixed 9add4b4 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/795
feat: 低功耗增加idle选项

Close #I5N9J2

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I066ff415709145e585f1eb94e70263361d3d71af
2022-08-23 13:07:11 +00:00
openharmony_ci a0f66a0d21
!797 【回合3.2Beta2】feature:允许device_path指向vendor
Merge pull request !797 from Zhaotianyu/cherry-pick-1660982811
2022-08-22 01:49:07 +00:00
arvinzzz 7437d84d8a fixed d4db5a5 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/796
feature: BUILD.gn中device_path允许指向vendor
close: #I5N9NC

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: If6a05871a0c78a92d6370b73528674e411642e20
2022-08-20 08:06:52 +00:00
openharmony_ci 6b809620c4
!793 【回合】fix: iccarm fatfs编译问题修复 回合 3.2Beta2
Merge pull request !793 from Zhaotianyu/cherry-pick-1660816794
2022-08-18 13:47:15 +00:00
arvinzzz dbfa3a345d fixed 99640e9 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/792
fix: fatfs iccarm编译修复
close: #I5MZ62

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ie3882e443406d5055ff58c780cd376ddd6054bbf
2022-08-18 09:59:55 +00:00
openharmony_ci 07c5e942d0
!788 fix: iccarm编译修复
Merge pull request !788 from Zhaotianyu/cherry-pick-1660717353
2022-08-17 12:54:08 +00:00
arvinzzz ec15ef95c9 fixed d0c50a4 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/766
fix: iccarm编译修复
close: #I5JXMJ

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3fbaf459ad4807a44396f319a4d53d3cc1e7700c
2022-08-17 06:22:34 +00:00
openharmony_ci d2b40f293d
!762 挑单 M核time支持RTC接口回合3.2Beta2
Merge pull request !762 from wangchen/0727_m
2022-07-27 07:39:09 +00:00
openharmony_ci b95196e954
!761 refactor: Kconfig解耦
Merge pull request !761 from Zhaotianyu/cherry-pick-1658890842
2022-07-27 07:38:03 +00:00
openharmony_ci 61191eb629
!760 fix: 修复iccarm编译问题
Merge pull request !760 from Zhaotianyu/cherry-pick-1658890154
2022-07-27 07:37:28 +00:00
openharmony_ci d47ec89be7
!759 refactor:编译框架对不同工具链的解耦优化 回合 3.2Beta
Merge pull request !759 from Zhaotianyu/cherry-pick-1658889939
2022-07-27 07:36:28 +00:00
wangchen 96a8074bb1 fix: 回合, M核time模块支持调用RTC接口
【背景】主线代码回合3.2分支

【修改方案】
主线代码回合3.2分支

【影响】
对现有的产品编译不会有影响。
re #I5J3UR
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-07-27 03:29:25 +00:00
arvinzzz 91650c04a6 fixed 732a346 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/758
refactor: Kconfig选项解耦
close: #I5I7LX

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ieaf3bc6bf0c345a7d7945abb9133bd40fbe9d5b8
2022-07-27 03:00:42 +00:00
i-wangliangliang dc4cc3fb26 fixed 62eb96d from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/745
iccarm工具链编译适配

Signed-off-by: i-wangliangliang <willfox@126.com>
Change-Id: I9360dc232c35ec4db7a9bee08f3c288e22941e39
2022-07-27 02:49:14 +00:00
arvinzzz 64f43fabd3 fixed 009d250 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/751
refactor: 编译框架对不同工具链的解耦优化
close: #I5GQ9A

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I3e371a67bdab75c53e769e08c1c54ec83c741a69
2022-07-27 02:45:39 +00:00
47 changed files with 642 additions and 372 deletions

View File

@ -31,11 +31,6 @@ import("//build/lite/config/component/lite_component.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
declare_args() {
liteos_name = "OHOS_Image"
liteos_kernel_only = false
}
import("liteos.gni")
if (defined(LOSCFG_COMPILER_ICCARM)) {
@ -125,8 +120,11 @@ config("los_config") {
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
# board and soc decoupling feature, device_path should contains board
BOARD_SOC_FEATURE = device_path != string_replace(device_path, "/board/", "")
# If device_path points to vendor, use device_path directly,
# otherwise board is decoupled from soc, device_path should contain board
BOARD_SOC_FEATURE =
device_path == string_replace(device_path, "/vendor/", "") &&
device_path != string_replace(device_path, "/board/", "")
config("public") {
configs = [
@ -194,15 +192,7 @@ executable("liteos") {
":los_config",
]
if (defined(LOSCFG_COMPILER_ICCARM)) {
ldflags = [ "--map=$liteos_name.map" ]
} else {
ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
]
}
ldflags = executable_config_ldflags
output_dir = target_out_dir
@ -223,20 +213,5 @@ build_ext_component("build_kernel_image") {
deps = [ ":copy_liteos" ]
exec_path = rebase_path(root_out_dir)
if (defined(LOSCFG_COMPILER_ICCARM)) {
objcopy = "${compile_prefix}ielftool$toolchain_cmd_suffix"
objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
command = "$objcopy --bin --verbose $liteos_name $liteos_name.bin"
command +=
" && sh -c '$objdump --source --all $liteos_name -o $liteos_name.asm'"
} else {
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
command +=
" && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
}
command = toochain_config_command
}

19
Kconfig
View File

@ -357,15 +357,10 @@ config KERNEL_PM_DEBUG
help
Configuration item for low power frame debug tailoring.
config DEBUG_HOOK
bool
default n
config PLATFORM_EXC
bool "Enable Hook Feature"
bool "Enable Platform Exc Hook"
default n
depends on KERNEL_EXTKERNEL
select DEBUG_HOOK
config KERNEL_LMK
bool "Enable Low Memory Killer"
@ -532,14 +527,20 @@ config DEBUG_SEMAPHORE
help
Answer Y to enable debug semaphore.
source "components/shell/Kconfig"
config NET_LWIP_SACK_TFTP
bool "Enable Tftp"
default y
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
help
Answer Y to enable LiteOS support tftp cmd and tftp tool.
osource "net/telnet/Kconfig"
config DEBUG_HOOK
bool "Enable Hook Framework"
default n
depends on DEBUG_VERSION
help
Enable the kernel hook framework to support customized trace information capture.
config SCHED_DEBUG
bool "Enable sched debug Feature"
default n
@ -606,6 +607,8 @@ config TASK_MEM_USED
default n
depends on DEBUG_VERSION && MEM_DEBUG
source "components/shell/Kconfig"
endmenu
######################## config options os drivers ########################

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@ -32,6 +32,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

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:
@ -33,6 +33,7 @@
#define _LOS_ARCH_ATOMIC_H
#include "los_compiler.h"
#include "los_interrupt.h"
#ifdef __cplusplus
#if __cplusplus

View File

@ -71,7 +71,7 @@ PARTITION VolToPart[] = {
static int FsLock(void)
{
INT32 ret = 0;
int ret = 0;
struct timespec absTimeout = {0};
if (osKernelGetState() != osKernelRunning) {
return ret;
@ -110,15 +110,15 @@ static int FsChangeDrive(const char *path)
retErr = strncpy_s(tmpPath + 1, (FS_DRIVE_NAME_MAX_LEN - 1), (char const *)path, pathLen);
if (retErr != EOK) {
return LOS_NOK;
return (int)LOS_NOK;
}
res = f_chdrive(tmpPath);
if (res != FR_OK) {
return LOS_NOK;
return (int)LOS_NOK;
}
return LOS_OK;
return (int)LOS_OK;
}
static int Remount(struct MountPoint *mp, unsigned long mountflags)
@ -128,11 +128,11 @@ static int Remount(struct MountPoint *mp, unsigned long mountflags)
/* remount is not allowed when the device is not mounted. */
if (fatfs->fs_type == 0) {
errno = EINVAL;
return LOS_NOK;
return (int)LOS_NOK;
}
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
return LOS_OK;
return (int)LOS_OK;
}
static unsigned int FatFsGetMode(int oflags)
@ -273,19 +273,19 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
const void *data)
{
FRESULT res;
INT32 ret;
FATFS *fs = NULL;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto ERROUT;
}
@ -297,7 +297,7 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
fs = (FATFS *)malloc(sizeof(FATFS));
if (fs == NULL) {
errno = ENOMEM;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto ERROUT;
}
(void)memset_s(fs, sizeof(FATFS), 0, sizeof(FATFS));
@ -306,13 +306,13 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
res = f_mount((FATFS *)mp->mData, ldPath, 1);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto ERROUT;
}
PutLdPath(ldPath);
FsUnlock();
return LOS_OK;
return (int)LOS_OK;
ERROUT:
free(fs);
@ -324,28 +324,28 @@ ERROUT:
int FatfsUmount(struct MountPoint *mp)
{
int ret;
int volId;
FRESULT res;
INT32 ret;
INT32 volId;
FATFS *fatfs = (FATFS *)mp->mData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
/* The volume is not mounted */
if (fatfs->fs_type == 0) {
errno = EINVAL;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -353,14 +353,14 @@ int FatfsUmount(struct MountPoint *mp)
/* umount is not allowed when a file or directory is opened. */
if (f_checkopenlock(volId) != FR_OK) {
errno = EBUSY;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
res = f_mount((FATFS *)NULL, ldPath, 0);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -371,7 +371,7 @@ int FatfsUmount(struct MountPoint *mp)
free(mp->mData);
mp->mData = NULL;
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
PutLdPath(ldPath);
@ -381,7 +381,7 @@ OUT:
int FatfsUmount2(struct MountPoint *mp, int flag)
{
INT32 ret;
int ret;
UINT32 flags;
FRESULT res;
FATFS *fatfs = (FATFS *)mp->mData;
@ -389,33 +389,33 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
flags = MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW;
if ((UINT32)flag & ~flags) {
errno = EINVAL;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
/* The volume is not mounted */
if (fatfs->fs_type == 0) {
errno = EINVAL;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
res = f_mount((FATFS *)NULL, ldPath, 0);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -426,7 +426,7 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
free(mp->mData);
mp->mData = NULL;
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
PutLdPath(ldPath);
@ -438,12 +438,12 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
{
FRESULT res;
UINT32 fmode;
INT32 ret;
FIL *fp = NULL;
int ret;
if (path == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
fmode = FatFsGetMode(oflag);
@ -451,21 +451,21 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
fp = (FIL *)malloc(sizeof(FIL));
if (fp == NULL) {
errno = ENOMEM;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
free(fp);
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != LOS_OK) {
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
free(fp);
goto OUT;
}
@ -475,7 +475,7 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
PRINT_ERR("FAT open err 0x%x!\r\n", res);
free(fp);
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -489,19 +489,19 @@ OUT:
int FatfsClose(struct File *file)
{
FRESULT res;
INT32 ret;
FIL *fp = (FIL *)file->fData;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
FsUnlock();
errno = ENOENT;
return LOS_NOK;
return (int)LOS_NOK;
}
res = f_close(fp);
@ -509,7 +509,7 @@ int FatfsClose(struct File *file)
PRINT_ERR("FAT close err 0x%x!\r\n", res);
FsUnlock();
errno = FatfsErrno(res);
return LOS_NOK;
return (int)LOS_NOK;
}
#if !FF_FS_TINY
@ -521,37 +521,37 @@ int FatfsClose(struct File *file)
file->fData = NULL;
FsUnlock();
return LOS_OK;
return (int)LOS_OK;
}
ssize_t FatfsRead(struct File *file, char *buf, size_t nbyte)
{
FRESULT res;
INT32 ret;
UINT32 lenRead;
FIL *fp = (FIL *)file->fData;
int ret;
if (buf == NULL) {
errno = EFAULT;
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
if (fp == NULL) {
FsUnlock();
errno = ENOENT;
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
res = f_read(fp, buf, nbyte, &lenRead);
if (res != FR_OK) {
FsUnlock();
errno = FatfsErrno(res);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
FsUnlock();
@ -561,20 +561,20 @@ ssize_t FatfsRead(struct File *file, char *buf, size_t nbyte)
ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
{
FRESULT res;
INT32 ret;
UINT32 lenWrite;
static BOOL overFlow = FALSE;
FIL *fp = (FIL *)file->fData;
int ret;
if (buf == NULL) {
errno = EFAULT;
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
if ((fp ==NULL) || (fp->obj.fs == NULL)) {
@ -598,20 +598,20 @@ ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
ERROUT:
FsUnlock();
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
off_t FatfsLseek(struct File *file, off_t offset, int whence)
{
FRESULT res;
INT32 ret;
off_t pos;
FIL *fp = (FIL *)file->fData;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (off_t)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
@ -642,37 +642,37 @@ off_t FatfsLseek(struct File *file, off_t offset, int whence)
ERROUT:
FsUnlock();
return LOS_NOK;
return (off_t)LOS_NOK;
}
/* Remove the specified FILE */
int FatfsUnlink(struct MountPoint *mp, const char *path)
{
FRESULT res;
INT32 ret;
int ret;
if (path == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = FsChangeDrive(path);
if (ret != LOS_OK) {
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT unlink ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -680,11 +680,11 @@ int FatfsUnlink(struct MountPoint *mp, const char *path)
if (res != FR_OK) {
PRINT_ERR("FAT unlink err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -695,24 +695,24 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
{
FRESULT res;
FILINFO fileInfo = {0};
INT32 ret;
int ret;
if ((path == NULL) || (buf == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != LOS_OK) {
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT stat ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -720,7 +720,7 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
if (res != FR_OK) {
PRINT_ERR("FAT stat err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -738,7 +738,7 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
buf->st_mode |= S_IFDIR;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -748,29 +748,29 @@ OUT:
/* Synchronize all changes to Flash */
int FatfsSync(struct File *file)
{
int ret;
FRESULT res;
INT32 ret;
FIL *fp = (FIL *)file->fData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
res = f_sync(fp);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -780,30 +780,30 @@ OUT:
int FatfsMkdir(struct MountPoint *mp, const char *path)
{
FRESULT res;
INT32 ret;
int ret;
if (path == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = FsChangeDrive(path);
if (ret != LOS_OK) {
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT mkdir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -811,10 +811,10 @@ int FatfsMkdir(struct MountPoint *mp, const char *path)
if (res != FR_OK) {
PRINT_ERR("FAT mkdir err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -824,8 +824,8 @@ OUT:
int FatfsOpendir(struct Dir *dir, const char *dirName)
{
FRESULT res;
INT32 ret;
DIR *dp = NULL;
int ret;
if (dirName == NULL) {
errno = EFAULT;
@ -845,7 +845,7 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
}
ret = FsChangeDrive(dirName);
if (ret != LOS_OK) {
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT opendir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
goto ERROUT;
@ -862,33 +862,33 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
dir->dOffset = 0;
FsUnlock();
return LOS_OK;
return (int)LOS_OK;
ERROUT:
if (dp != NULL) {
free(dp);
}
FsUnlock();
return LOS_NOK;
return (int)LOS_NOK;
}
int FatfsReaddir(struct Dir *dir, struct dirent *dent)
{
FRESULT res;
INT32 ret;
FILINFO fileInfo = {0};
DIR *dp = NULL;
int ret;
if ((dir == NULL) || (dir->dData == NULL)) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
dp = (DIR *)dir->dData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
res = f_readdir(dp, &fileInfo);
@ -897,7 +897,7 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
PRINT_ERR("FAT readdir err 0x%x!\r\n", res);
errno = FatfsErrno(res);
FsUnlock();
return LOS_NOK;
return (int)LOS_NOK;
}
(void)memcpy_s(dent->d_name, sizeof(dent->d_name),
@ -909,25 +909,25 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
}
FsUnlock();
return LOS_OK;
return (int)LOS_OK;
}
int FatfsClosedir(struct Dir *dir)
{
FRESULT res;
INT32 ret;
DIR *dp = NULL;
int ret;
if ((dir == NULL) || (dir->dData == NULL)) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
dp = dir->dData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
res = f_closedir(dp);
@ -935,43 +935,43 @@ int FatfsClosedir(struct Dir *dir)
PRINT_ERR("FAT closedir err 0x%x!\r\n", res);
FsUnlock();
errno = FatfsErrno(res);
return LOS_NOK;
return (int)LOS_NOK;
}
free(dir->dData);
dir->dData = NULL;
FsUnlock();
return LOS_OK;
return (int)LOS_OK;
}
int FatfsRmdir(struct MountPoint *mp, const char *path)
{
FRESULT res;
INT32 ret;
int ret;
if ((path == NULL) || (mp == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = FsChangeDrive(path);
if (ret != LOS_OK) {
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT rmdir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -979,10 +979,10 @@ int FatfsRmdir(struct MountPoint *mp, const char *path)
if (res != FR_OK) {
PRINT_ERR("FAT rmdir err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -992,30 +992,30 @@ OUT:
int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
{
FRESULT res;
INT32 ret;
int ret;
if ((oldName == NULL) || (newName == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = FsChangeDrive(oldName);
if (ret != LOS_OK) {
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT f_getfree ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -1023,10 +1023,10 @@ int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
if (res != FR_OK) {
PRINT_ERR("FAT frename err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -1038,24 +1038,24 @@ int FatfsStatfs(const char *path, struct statfs *buf)
FATFS *fs = NULL;
UINT32 freeClust;
FRESULT res;
INT32 ret;
int ret;
if ((path == NULL) || (buf == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != FR_OK) {
PRINT_ERR("FAT f_getfree ChangeDrive err %d.", ret);
errno = FatfsErrno(FR_INVALID_PARAMETER);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -1063,7 +1063,7 @@ int FatfsStatfs(const char *path, struct statfs *buf)
if (res != FR_OK) {
PRINT_ERR("FAT f_getfree err 0x%x.", res);
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
buf->f_bfree = freeClust;
@ -1076,7 +1076,7 @@ int FatfsStatfs(const char *path, struct statfs *buf)
buf->f_bsize = FF_MIN_SS * fs->csize;
#endif
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -1086,9 +1086,9 @@ OUT:
static int DoTruncate(struct File *file, off_t length, UINT32 count)
{
FRESULT res = FR_OK;
INT32 ret = LOS_OK;
DWORD csz;
FIL *fp = (FIL *)file->fData;
int ret = (int)LOS_OK;
csz = (DWORD)(fp->obj.fs)->csize * SS(fp->obj.fs); /* Cluster size */
if (length > csz * count) {
@ -1096,7 +1096,7 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
res = f_expand(fp, 0, (FSIZE_t)(length), FALLOC_FL_KEEP_SIZE);
#else
errno = ENOSYS;
ret = LOS_NOK;
ret = (int)LOS_NOK;
return ret;
#endif
} else if (length < csz * count) {
@ -1105,7 +1105,7 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
return ret;
}
@ -1118,32 +1118,32 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
int FatfsTruncate(struct File *file, off_t length)
{
FRESULT res;
INT32 ret;
UINT count;
DWORD fclust;
FIL *fp = (FIL *)file->fData;
int ret;
if ((length < 0) || (length > UINT_MAX)) {
errno = EINVAL;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return LOS_NOK;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
res = f_getclustinfo(fp, &fclust, &count);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
@ -1152,7 +1152,7 @@ int FatfsTruncate(struct File *file, off_t length)
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -1163,34 +1163,34 @@ int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
{
int pdrv;
FRESULT res;
INT32 ret;
int ret;
if ((dev == NULL) || (partTbl == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
pdrv = GetDevIdByDevName(dev);
if (pdrv < 0) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
res = f_fdisk(pdrv, (DWORD const *)partTbl, g_workBuffer);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
FsUnlock();
@ -1200,27 +1200,27 @@ OUT:
int FatfsFormat(const char *partName, void *privData)
{
FRESULT res;
INT32 ret;
MKFS_PARM opt = {0};
int option = *(int *)privData;
char *dev = NULL; /* logical driver */
int ret;
if (partName == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
dev = GetLdPath(partName);
if (dev == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
PutLdPath(dev);
return LOS_NOK;
return (int)LOS_NOK;
}
opt.fmt = option;
@ -1229,11 +1229,11 @@ int FatfsFormat(const char *partName, void *privData)
res = f_mkfs(dev, &opt, g_workBuffer, FF_MAX_SS);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto OUT;
}
ret = LOS_OK;
ret = (int)LOS_OK;
OUT:
PutLdPath(dev);

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:
@ -89,14 +89,14 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
errno = EFAULT;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto errout;
}
mountHdl = (lfs_t *)malloc(sizeof(lfs_t));
if (mountHdl == NULL) {
errno = ENODEV;
ret = LOS_NOK;
ret = (int)LOS_NOK;
goto errout;
}
(void)memset_s(mountHdl, sizeof(lfs_t), 0, sizeof(lfs_t));
@ -113,7 +113,7 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
if (ret != 0) {
free(mountHdl);
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
errout:
@ -126,18 +126,18 @@ int LfsUmount(struct MountPoint *mp)
if (mp == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = lfs_unmount((lfs_t *)mp->mData);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
free(mp->mData);
@ -151,18 +151,18 @@ int LfsUnlink(struct MountPoint *mp, const char *fileName)
if ((mp == NULL) || (fileName == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = lfs_remove((lfs_t *)mp->mData, fileName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
@ -174,12 +174,12 @@ int LfsMkdir(struct MountPoint *mp, const char *dirName)
if ((dirName == NULL) || (mp == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
return (int)LOS_NOK;
}
lfs_t *lfs = (lfs_t *)mp->mData;
@ -187,7 +187,7 @@ int LfsMkdir(struct MountPoint *mp, const char *dirName)
ret = lfs_mkdir(lfs, dirName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
@ -200,25 +200,25 @@ int LfsRmdir(struct MountPoint *mp, const char *dirName)
if (mp == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
return (int)LOS_NOK;
}
lfs = (lfs_t *)mp->mData;
if (dirName == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = lfs_remove(lfs, dirName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
@ -230,14 +230,14 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
lfs_dir_t *dirInfo = (lfs_dir_t *)malloc(sizeof(lfs_dir_t));
if (dirInfo == NULL) {
errno = ENOMEM;
return LOS_NOK;
return (int)LOS_NOK;
}
(void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t));
@ -254,7 +254,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
return LOS_OK;
errout:
return LOS_NOK;
return (int)LOS_NOK;
}
int LfsReaddir(struct Dir *dir, struct dirent *dent)
@ -265,12 +265,12 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL) ||
(dent == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (dir->dData == NULL) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
@ -296,7 +296,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
errno = LittlefsErrno(ret);
}
return LOS_NOK;
return (int)LOS_NOK;
}
int LfsClosedir(struct Dir *dir)
@ -305,12 +305,12 @@ int LfsClosedir(struct Dir *dir)
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (dir->dData == NULL) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
@ -319,7 +319,7 @@ int LfsClosedir(struct Dir *dir)
ret = lfs_dir_close(lfs, dirInfo);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
free(dirInfo);
@ -336,13 +336,13 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
if ((pathName == NULL) || (file == NULL) || (file->fMp == NULL) ||
(file->fMp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
lfsHandle = (lfs_file_t *)malloc(sizeof(lfs_file_t));
if (lfsHandle == NULL) {
errno = ENOMEM;
return LOS_NOK;
return (int)LOS_NOK;
}
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
@ -368,25 +368,25 @@ int LfsRead(struct File *file, char *buf, size_t len)
if (buf == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = lfs_file_read((lfs_t *)mp->mData, lfsHandle, buf, len);
if (ret < 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
}
@ -399,25 +399,25 @@ int LfsWrite(struct File *file, const char *buf, size_t len)
if (buf == NULL) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = lfs_file_write((lfs_t *)mp->mData, lfsHandle, buf, len);
if (ret < 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
}
@ -430,20 +430,20 @@ off_t LfsSeek(struct File *file, off_t offset, int whence)
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
return (off_t)LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (off_t)LOS_NOK;
}
ret = (off_t)lfs_file_seek((lfs_t *)mp->mData, lfsHandle, offset, whence);
if (ret < 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (off_t)LOS_NOK;
}
return ret;
@ -451,20 +451,20 @@ off_t LfsSeek(struct File *file, off_t offset, int whence)
int LfsClose(struct File *file)
{
INT32 ret;
int ret;
struct MountPoint *mp = NULL;
lfs_file_t *lfsHandle = NULL;
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
pthread_mutex_lock(&g_FslocalMutex);
@ -473,7 +473,7 @@ int LfsClose(struct File *file)
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
free(file->fData);
@ -487,18 +487,18 @@ int LfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
if ((mp == NULL) || (oldName == NULL) || (newName == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = lfs_rename((lfs_t *)mp->mData, oldName, newName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
@ -511,12 +511,12 @@ int LfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
if ((mp == NULL) || (path == NULL) || (buf == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
return (int)LOS_NOK;
}
ret = lfs_stat((lfs_t *)mp->mData, path, &info);
@ -529,7 +529,7 @@ int LfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
}
} else {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
@ -542,19 +542,19 @@ int LfsSync(struct File *file)
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
return (int)LOS_NOK;
}
if ((file->fMp == NULL) || (file->fMp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
return (int)LOS_NOK;
}
mp = file->fMp;
ret = lfs_file_sync((lfs_t *)mp->mData, (lfs_file_t *)file->fData);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
}

View File

@ -50,7 +50,9 @@ kernel_module(module_name) {
deps = [ "//kernel/liteos_m/kal" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
cflags = [ "-Wno-parentheses" ]
if (!defined(LOSCFG_COMPILER_ICCARM)) {
cflags = [ "-Wno-parentheses" ]
}
}
config("public") {

View File

@ -42,7 +42,7 @@ static struct File g_files[NR_OPEN_DEFAULT];
int FileToFd(struct File *file)
{
if (file == NULL) {
return LOS_NOK;
return (int)LOS_NOK;
}
return file - g_files + MIN_START_FD;
}

View File

@ -98,7 +98,7 @@ int VfsLock(void)
{
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
PRINT_ERR("VfsLock failed!");
return LOS_NOK;
return (int)LOS_NOK;
}
return LOS_OK;
@ -245,7 +245,7 @@ static int VfsOpen(const char *path, int flags)
VFS_ERRNO_SET(ENOMEM);
VfsFilePut(file);
VfsUnlock();
return LOS_NOK;
return (int)LOS_NOK;
}
file->fFlags = (UINT32)flags;
@ -319,7 +319,7 @@ static void VfsDetachFile(const struct File *file)
static int VfsClose(int fd)
{
struct File *file = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
file = VfsAttachFileWithStatus(fd, FILE_STATUS_CLOSING);
if (file == NULL) {
@ -383,7 +383,7 @@ static ssize_t VfsRead(int fd, char *buff, size_t bytes)
static ssize_t VfsWrite(int fd, const void *buff, size_t bytes)
{
struct File *file = NULL;
ssize_t ret = LOS_NOK;
ssize_t ret = (ssize_t)LOS_NOK;
if ((buff == NULL) || (bytes == 0)) {
VFS_ERRNO_SET(EINVAL);
@ -412,7 +412,7 @@ static ssize_t VfsWrite(int fd, const void *buff, size_t bytes)
static off_t VfsLseek(int fd, off_t off, int whence)
{
struct File *file;
off_t ret = LOS_NOK;
off_t ret = (off_t)LOS_NOK;
file = VfsAttachFileReady(fd);
if (file == NULL) {
@ -434,7 +434,7 @@ static int VfsStat(const char *path, struct stat *stat)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
if ((path == NULL) || (stat == NULL)) {
VFS_ERRNO_SET(EINVAL);
@ -467,7 +467,7 @@ static int VfsStatfs(const char *path, struct statfs *buf)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
if ((path == NULL) || (buf == NULL)) {
VFS_ERRNO_SET(EINVAL);
@ -500,7 +500,7 @@ static int VfsUnlink(const char *path)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
if (path == NULL) {
VFS_ERRNO_SET(EINVAL);
@ -532,7 +532,7 @@ static int VfsRename(const char *old, const char *new)
struct MountPoint *mpNew = NULL;
const char *pathInMpOld = NULL;
const char *pathInMpNew = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
if ((old == NULL) || (new == NULL)) {
VFS_ERRNO_SET(EINVAL);
@ -587,7 +587,7 @@ static int VfsIoctl(int fd, int func, ...)
va_list ap;
unsigned long arg;
struct File *file = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
va_start(ap, func);
arg = va_arg(ap, unsigned long);
@ -612,7 +612,7 @@ static int VfsIoctl(int fd, int func, ...)
static int VfsSync(int fd)
{
struct File *file;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
file = VfsAttachFileReady(fd);
if (file == NULL) {
@ -724,7 +724,7 @@ static struct dirent *VfsReaddir(DIR *d)
static int VfsClosedir(DIR *d)
{
struct MountPoint *mp = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
struct Dir *dir = (struct Dir *)d;
if ((dir == NULL) || (dir->dMp == NULL)) {
@ -762,7 +762,7 @@ static int VfsMkdir(const char *path, int mode)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
(void)mode;
if (path == NULL) {
@ -786,7 +786,7 @@ static int VfsMkdir(const char *path, int mode)
ret = mp->mFs->fsFops->mkdir(mp, pathInMp);
} else {
VFS_ERRNO_SET(ENOTSUP);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
VfsUnlock();
@ -823,7 +823,7 @@ static ssize_t VfsPread(int fd, void *buff, size_t bytes, off_t off)
if (buff == NULL) {
VFS_ERRNO_SET(EFAULT);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
if (bytes == 0) {
@ -832,26 +832,26 @@ static ssize_t VfsPread(int fd, void *buff, size_t bytes, off_t off)
if (VfsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
savepos = LOS_Lseek(fd, 0, SEEK_CUR);
if (savepos == (off_t)-1) {
VfsUnlock();
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
pos = LOS_Lseek(fd, off, SEEK_SET);
if (pos == (off_t)-1) {
VfsUnlock();
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
ret = LOS_Read(fd, buff, bytes);
pos = LOS_Lseek(fd, savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) {
VfsUnlock();
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
VfsUnlock();
@ -865,7 +865,7 @@ static ssize_t VfsPwrite(int fd, const void *buff, size_t bytes, off_t off)
if (buff == NULL) {
VFS_ERRNO_SET(EFAULT);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
if (bytes == 0) {
@ -874,26 +874,26 @@ static ssize_t VfsPwrite(int fd, const void *buff, size_t bytes, off_t off)
if (VfsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
savepos = LOS_Lseek(fd, 0, SEEK_CUR);
if (savepos == (off_t)-1) {
VfsUnlock();
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
pos = LOS_Lseek(fd, off, SEEK_SET);
if (pos == (off_t)-1) {
VfsUnlock();
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
ret = LOS_Write(fd, buff, bytes);
pos = LOS_Lseek(fd, savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) {
VfsUnlock();
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
VfsUnlock();
@ -912,35 +912,35 @@ int LOS_Open(const char *path, int flags, ...)
unsigned flagMask = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY;
if ((unsigned)flags & ~flagMask) {
errno = EINVAL;
return LOS_NOK;
return (int)LOS_NOK;
}
size_t pathLen = strlen(path) + 1;
if ((unsigned)pathLen > PATH_MAX) {
errno = EINVAL;
return LOS_NOK;
return (int)LOS_NOK;
}
char *canonicalPath = (char *)malloc(pathLen);
if (!canonicalPath) {
errno = ENOMEM;
return LOS_NOK;
return (int)LOS_NOK;
}
if (GetCanonicalPath(NULL, path, canonicalPath, pathLen) == 0) {
FREE_AND_SET_NULL(canonicalPath);
errno = ENOMEM;
return LOS_NOK;
return (int)LOS_NOK;
}
if (strcmp(canonicalPath, RANDOM_DEV_PATH) == 0) {
FREE_AND_SET_NULL(canonicalPath);
if ((O_ACCMODE & (unsigned)flags) != O_RDONLY) {
errno = EPERM;
return LOS_NOK;
return (int)LOS_NOK;
}
if ((unsigned)flags & O_DIRECTORY) {
errno = ENOTDIR;
return LOS_NOK;
return (int)LOS_NOK;
}
return RANDOM_DEV_FD;
}
@ -949,10 +949,10 @@ int LOS_Open(const char *path, int flags, ...)
FREE_AND_SET_NULL(canonicalPath);
if ((unsigned)flags & O_DIRECTORY) {
errno = EPERM;
return LOS_NOK;
return (int)LOS_NOK;
}
errno = EISDIR;
return LOS_NOK;
return (int)LOS_NOK;
}
FREE_AND_SET_NULL(canonicalPath);
#endif
@ -984,7 +984,7 @@ int LOS_Close(int fd)
}
#endif
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsClose(fd);
}
@ -1025,7 +1025,7 @@ ssize_t LOS_Read(int fd, void *buff, size_t bytes)
}
#endif
ssize_t ret = LOS_NOK;
ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsRead(fd, buff, bytes);
}
@ -1038,7 +1038,7 @@ ssize_t LOS_Write(int fd, const void *buff, size_t bytes)
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
errno = EBADF; /* "/dev/random" is readonly */
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
#endif
#ifdef LOSCFG_NET_LWIP_SACK
@ -1054,7 +1054,7 @@ ssize_t LOS_Write(int fd, const void *buff, size_t bytes)
}
#endif
ssize_t ret = LOS_NOK;
ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsWrite(fd, buff, bytes);
}
@ -1137,7 +1137,7 @@ int LOS_Fstat(int fd, struct stat *buf)
int ret;
filep = VfsAttachFileReady(fd);
if ((filep == NULL) || (filep->fMp == NULL) || filep->fullPath == NULL) {
return LOS_NOK;
return (int)LOS_NOK;
}
ret = stat(filep->fullPath, buf);
VfsDetachFile(filep);
@ -1169,7 +1169,7 @@ int LOS_Fcntl(int fd, int cmd, ...)
if (ret < 0) {
VFS_ERRNO_SET(-ret);
ret = LOS_NOK;
ret = (int)LOS_NOK;
}
return ret;
}
@ -1207,22 +1207,22 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
const struct iovec *iov = (const struct iovec *)iovBuf;
if ((iov == NULL) || (iovcnt <= 0) || (iovcnt > IOV_MAX_CNT)) {
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
for (i = 0; i < iovcnt; ++i) {
if ((SSIZE_MAX - bufLen) < iov[i].iov_len) {
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
bufLen += iov[i].iov_len;
}
if (bufLen == 0) {
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
totalLen = bufLen * sizeof(char);
buf = (char *)malloc(totalLen);
if (buf == NULL) {
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
totalBytesRead = read(fd, buf, bufLen);
@ -1238,7 +1238,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
ret = memcpy_s(readBuf, bytesToRead, curBuf, lenToRead);
if (ret != EOK) {
free(buf);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
if (totalLen < (size_t)bytesToRead) {
break;
@ -1264,23 +1264,23 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
const struct iovec *iov = iovBuf;
if ((iov == NULL) || (iovcnt <= 0) || (iovcnt > IOV_MAX_CNT)) {
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
for (i = 0; i < iovcnt; ++i) {
if ((SSIZE_MAX - bufLen) < iov[i].iov_len) {
VFS_ERRNO_SET(EINVAL);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
bufLen += iov[i].iov_len;
}
if (bufLen == 0) {
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
totalLen = bufLen * sizeof(char);
buf = (char *)malloc(totalLen);
if (buf == NULL) {
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
curBuf = buf;
for (i = 0; i < iovcnt; ++i) {
@ -1292,7 +1292,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);
return LOS_NOK;
return (ssize_t)LOS_NOK;
}
curBuf += bytesToWrite;
totalLen -= bytesToWrite;
@ -1318,26 +1318,26 @@ int LOS_Access(const char *path, int amode)
result = stat(path, &buf);
if (result != 0) {
return LOS_NOK;
return (int)LOS_NOK;
}
mode = buf.st_mode;
if ((unsigned int)amode & R_OK) {
if ((mode & (S_IROTH | S_IRGRP | S_IRUSR)) == 0) {
VFS_ERRNO_SET(EACCES);
return LOS_NOK;
return (int)LOS_NOK;
}
}
if ((unsigned int)amode & W_OK) {
if ((mode & (S_IWOTH | S_IWGRP | S_IWUSR)) == 0) {
VFS_ERRNO_SET(EACCES);
return LOS_NOK;
return (int)LOS_NOK;
}
}
if ((unsigned int)amode & X_OK) {
if ((mode & (S_IXOTH | S_IXGRP | S_IXUSR)) == 0) {
VFS_ERRNO_SET(EACCES);
return LOS_NOK;
return (int)LOS_NOK;
}
}
return 0;
@ -1345,7 +1345,7 @@ int LOS_Access(const char *path, int amode)
int LOS_Ftruncate(int fd, off_t length)
{
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
struct File *file = NULL;
if (length <= 0) {
@ -1379,7 +1379,7 @@ int LOS_Ftruncate(int fd, off_t length)
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off)
{
ssize_t ret = LOS_NOK;
ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsPread(fd, buff, bytes, off);
}
@ -1389,7 +1389,7 @@ 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)
{
ssize_t ret = LOS_NOK;
ssize_t ret = (ssize_t)LOS_NOK;
if (fd >= 0 && fd < CONFIG_NFILE_DESCRIPTORS) {
ret = VfsPwrite(fd, buff, bytes, off);
}

View File

@ -41,7 +41,7 @@
int OsVfsInit(void)
{
if (LOS_MuxCreate(&g_fsMutex) != LOS_OK) {
return LOS_NOK;
return (int)LOS_NOK;
}
#if (LOSCFG_SUPPORT_FATFS == 1)
FatFsInit();

View File

@ -57,20 +57,20 @@ int OsFsRegister(const char *fsType, struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt)
{
if ((fsMops == NULL) || (fsFops == NULL)) {
return LOS_NOK;
return (int)LOS_NOK;
}
struct FsMap *newfs = (struct FsMap *)malloc(sizeof(struct FsMap));
if (newfs == NULL) {
PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType);
return LOS_NOK;
return (int)LOS_NOK;
}
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
newfs->fsType = strdup(fsType);
if (newfs->fsType == NULL) {
free(newfs);
return LOS_NOK;
return (int)LOS_NOK;
}
newfs->fsMops = fsMops;

View File

@ -128,11 +128,12 @@ int LOS_FsMount(const char *source, const char *target,
{
int ret;
struct MountPoint *mp = NULL;
struct FsMap *mFs = NULL;
const char *pathInMp = NULL;
/* target must begin with '/', for example /system, /data, etc. */
if ((target == NULL) || (target[0] != '/')) {
return LOS_NOK;
return (int)LOS_NOK;
}
(void)VfsLock();
@ -143,9 +144,8 @@ int LOS_FsMount(const char *source, const char *target,
}
/* Find fsMap coresponding to the fsType */
struct FsMap *mFs = VfsFsMapGet(fsType);
if ((mFs == NULL) || (mFs->fsMops == NULL) ||
(mFs->fsMops->mount == NULL)) {
mFs = VfsFsMapGet(fsType);
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
goto errout;
}
@ -187,14 +187,14 @@ errout:
free((void *)mp->mDev);
free(mp);
VfsUnlock();
return LOS_NOK;
return (int)LOS_NOK;
}
int LOS_FsUmount(const char *target)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
(void)VfsLock();
if (target == NULL) {
@ -230,7 +230,7 @@ int LOS_FsUmount(const char *target)
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
return LOS_NOK;
return (int)LOS_NOK;
}
static void CloseFdsInMp(struct MountPoint *mp)
@ -252,7 +252,7 @@ int LOS_FsUmount2(const char *target, int flag)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
(void)VfsLock();
if (target == NULL) {
@ -290,5 +290,5 @@ int LOS_FsUmount2(const char *target, int flag)
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
return LOS_NOK;
return (int)LOS_NOK;
}

View File

@ -40,7 +40,7 @@
int GetPartIdByPartName(const char *partName)
{
if (partName == NULL) {
return LOS_NOK;
return (int)LOS_NOK;
}
/* the character next to p is the partId */
@ -49,13 +49,13 @@ int GetPartIdByPartName(const char *partName)
return atoi(p + 1);
}
return LOS_NOK;
return (int)LOS_NOK;
}
int GetDevIdByDevName(const char *dev)
{
if (dev == NULL) {
return LOS_NOK;
return (int)LOS_NOK;
}
/* last character is the deviceId */
@ -64,13 +64,13 @@ int GetDevIdByDevName(const char *dev)
return atoi(p);
}
return LOS_NOK;
return (int)LOS_NOK;
}
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
int partnum)
{
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
struct FsMap *fMap = VfsFsMapGet(fsType);
if ((fMap != NULL) && (fMap->fsMgt != NULL) &&
(fMap->fsMgt->fdisk != NULL)) {
@ -82,7 +82,7 @@ int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
{
int ret = LOS_NOK;
int ret = (int)LOS_NOK;
/* check if the device is mounted by iterate the mp list
format is not allowed when the device has been mounted. */
@ -91,7 +91,7 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) &&
strcmp(iter->mFs->fsType, fsType) == 0) {
errno = EBUSY;
return LOS_NOK;
return (int)LOS_NOK;
}
}

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:
@ -209,7 +209,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeoutMs)
{
if (mbox == NULL) {
LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_mbox_fetch: mbox is null"));
return ERR_ARG;
return (u32_t)ERR_ARG;
}
void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
@ -232,7 +232,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
{
if (mbox == NULL) {
LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_mbox_tryfetch: mbox is null"));
return ERR_ARG;
return (u32_t)ERR_ARG;
}
void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
@ -313,7 +313,7 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeoutMs)
{
if (sem == NULL) {
LWIP_DEBUGF(SYS_DEBUG, ("sys_arch_sem_wait: sem is null"));
return ERR_ARG;
return (u32_t)ERR_ARG;
}
UINT64 tick = ROUND_UP_DIV((UINT64)timeoutMs * LOSCFG_BASE_CORE_TICK_PER_SECOND, OS_SYS_MS_PER_SECOND);

View File

@ -129,7 +129,8 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
#endif
LosPmTickTimer *tickTimer = pm->tickTimer;
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL)) {
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL) ||
(pm->pmMode == LOS_SYS_NORMAL_SLEEP)) {
return FALSE;
}
@ -167,7 +168,6 @@ STATIC VOID OsPmCpuResume(LosPmCB *pm)
STATIC VOID OsPmCpuSuspend(LosPmCB *pm)
{
/* cpu enter low power mode */
LOS_ASSERT(pm->sysctrl != NULL);
if (pm->sysMode == LOS_SYS_NORMAL_SLEEP) {
pm->sysctrl->normalSuspend();
@ -226,6 +226,8 @@ STATIC UINT32 OsPmSuspendCheck(LosPmCB *pm, Suspend *sysSuspendEarly, Suspend *d
return LOS_NOK;
}
LOS_ASSERT(pm->sysctrl != NULL);
pm->isWake = FALSE;
*mode = pm->sysMode;
*sysSuspendEarly = pm->sysctrl->early;
@ -260,6 +262,10 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
goto EXIT;
}
if (pm->sysctrl->suspendCheck != NULL) {
pm->sysctrl->suspendCheck(mode);
}
tickTimerStop = OsPmTickTimerStop(pm);
if (!tickTimerStop) {
OsSchedResetSchedResponseTime(0);
@ -283,6 +289,9 @@ EXIT:
STATIC VOID OsPmNormalSleep(VOID)
{
#if (LOSCFG_KERNEL_PM_IDLE == 1)
(VOID)LOS_PmSuspend(0);
#else
UINT32 intSave;
LosPmCB *pm = &g_pmCB;
@ -293,6 +302,7 @@ STATIC VOID OsPmNormalSleep(VOID)
OsPmCpuResume(pm);
LOS_IntRestore(intSave);
#endif
}
STATIC UINT32 OsPmDeviceRegister(LosPmCB *pm, LosPmDevice *device)
@ -343,6 +353,9 @@ STATIC UINT32 OsPmSysctrlRegister(LosPmCB *pm, LosPmSysctrl *sysctrl)
if (sysctrl->late != NULL) {
pm->sysctrl->late = sysctrl->late;
}
if (sysctrl->suspendCheck != NULL) {
pm->sysctrl->suspendCheck = sysctrl->suspendCheck;
}
if (sysctrl->normalSuspend != NULL) {
pm->sysctrl->normalSuspend = sysctrl->normalSuspend;
}

View File

@ -165,6 +165,8 @@ typedef struct {
* Unlocked task scheduling.
*/
VOID (*late)(UINT32 mode);
/* Final check before low-power consumption. */
VOID (*suspendCheck)(UINT32 mode);
/* The system enters the Normal sleep mode.
* In normal mode, the value cannot be NULL.
*/

View File

@ -724,7 +724,7 @@ STATIC INT32 OsWildcardExtractDirectory(CHAR *fullpath, VOID *dst, wildcard_type
if (d == NULL) {
perror("opendir error");
return VFS_ERROR;
return (INT32)VFS_ERROR;
}
while (1) {

View File

@ -1,7 +1,7 @@
config KERNEL_TRACE
bool "Enable Trace Feature"
default n
depends on DEBUG_HOOK
select DEBUG_HOOK
config TRACE_MSG_EXTEND
bool "Enable Record more extended content"

View File

@ -31,6 +31,9 @@ import("liteos.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
liteos_name = "OHOS_Image"
liteos_kernel_only = false
#
# arch_config
#
@ -188,3 +191,20 @@ if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
}
misc_config_asmflags += misc_config_cflags
misc_config_asmflags += [ "-DCLZ=CLZ" ]
# ldflags for generating executable bin files
executable_config_ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
]
# Commands to generate kernel_image
toochain_config_objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
toochain_config_objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
toochain_config_command =
"$toochain_config_objcopy -O binary $liteos_name $liteos_name.bin"
toochain_config_command += " && sh -c '$toochain_config_objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
toochain_config_command +=
" && sh -c '$toochain_config_objdump -d $liteos_name >$liteos_name.asm'"

View File

@ -31,6 +31,9 @@ import("liteos.gni")
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
liteos_name = "OHOS_Image"
liteos_kernel_only = false
#
# arch_config
#
@ -138,3 +141,14 @@ misc_config_cflags = []
misc_config_asmflags = []
misc_config_asmflags += [ "-DCLZ=CLZ" ]
# ldflags for generating executable bin files
executable_config_ldflags = [ "--map=$liteos_name.map" ]
# Commands to generate kernel_image
toochain_config_objcopy = "${compile_prefix}ielftool$toolchain_cmd_suffix"
toochain_config_objdump = "${compile_prefix}ielfdumparm$toolchain_cmd_suffix"
toochain_config_command =
"$toochain_config_objcopy --bin --verbose $liteos_name $liteos_name.bin"
toochain_config_command += " && sh -c '$toochain_config_objdump --source --all $liteos_name -o $liteos_name.asm'"

View File

@ -631,6 +631,12 @@ void osThreadExit(void)
UNREACHABLE;
}
/* before kernel running osDelay is implemented by HalDelay interface */
WEAK VOID HalDelay(UINT32 ticks)
{
}
osStatus_t osDelay(uint32_t ticks)
{
UINT32 ret;
@ -640,6 +646,12 @@ osStatus_t osDelay(uint32_t ticks)
if (ticks == 0) {
return osErrorParameter;
}
if (osKernelGetState() != osKernelRunning) {
HalDelay(ticks);
return osOK;
}
ret = LOS_TaskDelay(ticks);
if (ret == LOS_OK) {
return osOK;
@ -788,7 +800,7 @@ osStatus_t osTimerStop(osTimerId_t timer_id)
uint32_t osTimerIsRunning(osTimerId_t timer_id)
{
if (OS_INT_ACTIVE) {
return osErrorISR;
return (uint32_t)osErrorISR;
}
if (timer_id == NULL) {
return 0;

View File

@ -31,7 +31,6 @@
#ifndef _ADAPT_TIME_H
#define _ADAPT_TIME_H
#define _timezone timezone
#define __TM_GMTOFF __tm_gmtoff
#define __TM_ZONE __tm_zone

View File

@ -47,7 +47,7 @@ int _gettimeofday(struct timeval *__tp, void *__tzp)
__tp->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
}
if (tz != NULL) {
tz->tz_minuteswest = timezone / SECS_PER_MIN;
tz->tz_minuteswest = _timezone / SECS_PER_MIN;
tz->tz_dsttime = 0;
}
return 0;

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RTC_TIME_HOOK_H
#define _RTC_TIME_HOOK_H
#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/*
* RTC interfaces for improving the accuracy of the time, need implement and
* register by user, implementation method is as follows:
*
* UINT64 RtcGetTickHook(VOID)
* brief: supplement expanded ticks
* input: VOID
* return: UINT64 ticks
*
* INT32 RtcGetTimeHook(UINT64 *usec)
* brief: get RTC time
* output: UINT64 *usec, pointer to get the time, value is counted in microsecond(us)
* return: non-0 if error, 0 if success.
*
* INT32 RtcSetTimeHook(UINT64 msec, UINT64 *usec)
* brief: set RTC time
* input: UINT64 msec, the time to be set counted in millisecond(ms).
* input: UINT64 *usec, the time to be set counted in microsecond(us)
* return: non-0 if error, 0 if success.
*
* INT32 RtcGetTimezoneHook(INT32 *tz)
* brief: get RTC timezone
* output: INT32 *tz, pointer to get the timezone, value is counted in second
* return: non-0 if error, 0 if success.
*
* INT32 RtcSetTimezoneHook(INT32 tz)
* brief: set RTC timezone
* input: INT32 tz, the timezone to be set, value is counted in second
* return: non-0 if error, 0 if success.
*/
struct RtcTimeHook {
UINT64 (*RtcGetTickHook)(VOID);
INT32 (*RtcGetTimeHook)(UINT64 *usec);
INT32 (*RtcSetTimeHook)(UINT64 msec, UINT64 *usec);
INT32 (*RtcGetTimezoneHook)(INT32 *tz);
INT32 (*RtcSetTimezoneHook)(INT32 tz);
};
/*
* @brief let user register a RTC getter hook to improve time accuracy for time-related POSIX methods.
* @param cfg, a structure, member is pointer to function to be registered
* @return VOID.
*/
VOID LOS_RtcHookRegister(struct RtcTimeHook *cfg);
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif

View File

@ -163,14 +163,14 @@ STATIC int SaveMqueueName(const CHAR *mqName, struct mqarray *mqueueCB)
mqueueCB->mq_name = (char *)LOS_MemAlloc(OS_SYS_MEM_ADDR, nameLen + 1);
if (mqueueCB->mq_name == NULL) {
errno = ENOMEM;
return LOS_NOK;
return (int)LOS_NOK;
}
if (strncpy_s(mqueueCB->mq_name, (nameLen + 1), mqName, nameLen) != EOK) {
LOS_MemFree(OS_SYS_MEM_ADDR, mqueueCB->mq_name);
mqueueCB->mq_name = NULL;
errno = EINVAL;
return LOS_NOK;
return (int)LOS_NOK;
}
mqueueCB->mq_name[nameLen] = '\0';
return LOS_OK;

View File

@ -215,6 +215,7 @@ STATIC INT32 PipeDevRegister(CHAR *devName, UINT32 len)
{
INT32 ret;
INT32 num = PipeDevNumAlloc();
struct PipeDev *devTemp = NULL;
if (num < 0) {
return -ENODEV;
}
@ -228,7 +229,7 @@ STATIC INT32 PipeDevRegister(CHAR *devName, UINT32 len)
(VOID)snprintf_s(dev->devName, PIPE_DEV_NAME_MAX, PIPE_DEV_NAME_MAX - 1, "%s%d", PIPE_DEV_PATH, num);
(VOID)memcpy_s(devName, len, dev->devName, strlen(dev->devName));
struct PipeDev *devTemp = PipeDevFind(dev->devName);
devTemp = PipeDevFind(dev->devName);
if (devTemp != NULL) {
ret = -EEXIST;
goto ERROR;

View File

@ -504,6 +504,8 @@ int pthread_detach(pthread_t thread)
void pthread_exit(void *retVal)
{
UINT32 intSave;
LosTaskCB *tcb = NULL;
PthreadData *pthreadData = NULL;
pthread_t thread = pthread_self();
if (!IsPthread(thread)) {
@ -511,9 +513,9 @@ void pthread_exit(void *retVal)
goto EXIT;
}
LosTaskCB *tcb = OS_TCB_FROM_TID((UINT32)thread);
tcb = OS_TCB_FROM_TID((UINT32)thread);
tcb->joinRetval = (UINTPTR)retVal;
PthreadData *pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
pthreadData = (PthreadData *)(UINTPTR)tcb->arg;
if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL) != 0) {
PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);
}

View File

@ -1,6 +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) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -44,6 +43,7 @@
#include "los_context.h"
#include "los_interrupt.h"
#include "sys/times.h"
#include "rtc_time_hook.h"
#define DELAYTIMER_MAX 0x7FFFFFFFF
@ -61,12 +61,38 @@ STATIC const UINT16 g_daysInMonth[2][13] = {
STATIC const UINT8 g_montbl[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
#endif
#ifndef __USE_NEWLIB__
#define g_timezone timezone
#else
#define g_Timezone _timezone
#endif
/*
* Time zone information, stored in seconds,
* negative values indicate the east of UTC,
* positive values indicate the west of UTC.
*/
long timezone = -8 * 60 * 60; // defaults to CST: 8 hours east of the Prime Meridian
long g_timezone = -8 * 60 * 60; // set default to CST(UTC+8)
/*
* store register rtc func
*/
STATIC struct RtcTimeHook g_rtcTimeFunc;
STATIC UINT64 g_rtcTimeBase = 0;
STATIC UINT64 g_systickBase = 0;
VOID LOS_RtcHookRegister(struct RtcTimeHook *cfg)
{
if (cfg == NULL) {
return;
}
g_rtcTimeFunc.RtcGetTickHook = cfg->RtcGetTickHook;
g_rtcTimeFunc.RtcGetTimeHook = cfg->RtcGetTimeHook;
g_rtcTimeFunc.RtcSetTimeHook = cfg->RtcSetTimeHook;
g_rtcTimeFunc.RtcGetTimezoneHook = cfg->RtcGetTimezoneHook;
g_rtcTimeFunc.RtcSetTimezoneHook = cfg->RtcSetTimezoneHook;
}
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
@ -443,6 +469,10 @@ int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct
clock_t clock(void)
{
if (g_rtcTimeFunc.RtcGetTickHook != NULL) {
return g_rtcTimeFunc.RtcGetTickHook();
}
clock_t clk;
struct timespec hwTime;
OsGetHwTime(&hwTime);
@ -453,19 +483,52 @@ clock_t clock(void)
return clk;
}
STATIC UINT64 GetCurrentTime(VOID)
{
UINT64 tickDelta = 0;
UINT64 currentTick;
if (g_rtcTimeFunc.RtcGetTickHook != NULL) {
currentTick = g_rtcTimeFunc.RtcGetTickHook();
if ((g_systickBase != 0) && (currentTick > g_systickBase)) {
tickDelta = currentTick - g_systickBase;
}
}
return g_rtcTimeBase + LOS_Tick2MS((UINT32)tickDelta);
}
time_t time(time_t *timer)
{
struct timespec ts;
UINT64 usec = 0;
time_t sec;
INT32 rtcRet = 0;
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
return (time_t)-1;
}
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
if (rtcRet != 0) {
UINT64 currentTime;
currentTime = GetCurrentTime();
sec = currentTime / OS_SYS_MS_PER_SECOND;
} else {
sec = usec / OS_SYS_US_PER_SECOND;
}
if (timer != NULL) {
*timer = sec;
}
return sec;
} else {
struct timespec ts;
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
return (time_t)-1;
}
if (timer != NULL) {
*timer = ts.tv_sec;
if (timer != NULL) {
*timer = ts.tv_sec;
}
return ts.tv_sec;
}
return ts.tv_sec;
}
#ifndef __USE_NEWLIB__
/*
* Compute the `struct tm' representation of T,
@ -558,7 +621,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
errno = EFAULT;
return NULL;
}
if (!ConvertSecs2Utc(*timep, -timezone, result)) {
if (!ConvertSecs2Utc(*timep, -g_timezone, result)) {
errno = EINVAL;
return NULL;
}
@ -633,18 +696,42 @@ time_t mktime(struct tm *tmptr)
int gettimeofday(struct timeval *tv, void *ptz)
{
struct timespec ts;
struct timezone *tz = (struct timezone *)ptz;
if (tv != NULL) {
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
return -1;
INT32 rtcRet;
UINT64 usec = 0;
UINT64 currentTime;
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
if (rtcRet != 0) {
currentTime = GetCurrentTime();
tv->tv_sec = currentTime / OS_SYS_MS_PER_SECOND;
tv->tv_usec = (currentTime % OS_SYS_MS_PER_SECOND) * OS_SYS_MS_PER_SECOND;
} else {
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
}
} else {
struct timespec ts;
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {
return -1;
}
tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
}
tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
}
if (tz != NULL) {
tz->tz_minuteswest = timezone / SECS_PER_MIN;
INT32 timeZone = 0;
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
g_rtcTimeFunc.RtcGetTimezoneHook(&timeZone);
tz->tz_minuteswest = timezone / SECS_PER_MIN;
} else {
tz->tz_minuteswest = g_timezone / SECS_PER_MIN;
}
tz->tz_dsttime = 0;
}
return 0;
@ -654,34 +741,49 @@ int gettimeofday(struct timeval *tv, void *ptz)
int settimeofday(const struct timeval *tv, const struct timezone *tz)
{
struct timespec ts;
INT32 rtcTimeZone = timezone;
if (tv == NULL) {
errno = EFAULT;
return -1;
}
if (tz != NULL) {
if ((tz->tz_minuteswest >= TIME_ZONE_MIN) &&
(tz->tz_minuteswest <= TIME_ZONE_MAX)) {
rtcTimeZone = tz->tz_minuteswest * SECS_PER_MIN;
} else {
errno = EINVAL;
return -1;
}
}
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
errno = EINVAL;
return -1;
}
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
if (-1 == clock_settime(CLOCK_REALTIME, &ts)) {
return -1;
if (tz != NULL) {
if ((tz->tz_minuteswest >= TIME_ZONE_MIN) &&
(tz->tz_minuteswest <= TIME_ZONE_MAX)) {
g_timezone = tz->tz_minuteswest * SECS_PER_MIN;
} else {
errno = EINVAL;
return -1;
}
if (g_rtcTimeFunc.RtcSetTimezoneHook != NULL) {
g_rtcTimeFunc.RtcSetTimezoneHook(g_timezone);
}
}
timezone = rtcTimeZone;
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
UINT64 usec;
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
if (-1 == g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec)) {
return -1;
}
} else {
ts.tv_sec = tv->tv_sec;
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
if (-1 == clock_settime(CLOCK_REALTIME, &ts)) {
return -1;
}
}
if (g_rtcTimeFunc.RtcGetTickHook != NULL) {
g_systickBase = g_rtcTimeFunc.RtcGetTickHook();
}
return 0;
}
@ -718,4 +820,3 @@ clock_t times(struct tms *tms)
}
return clockTick;
}

View File

@ -655,6 +655,22 @@ extern UINT8 *m_aucSysMem0;
#define LOSCFG_KERNEL_SIGNAL 0
#endif
/**
* @ingroup los_config
* Configuration item to enable kernel power module.
*/
#ifndef LOSCFG_KERNEL_PM
#define LOSCFG_KERNEL_PM 0
#endif
/**
* @ingroup los_config
* Configuration item to enable kernel power module in idle task.
*/
#ifndef LOSCFG_KERNEL_PM_IDLE
#define LOSCFG_KERNEL_PM_IDLE 0
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -1901,14 +1901,12 @@ STATIC VOID OsMemIntegrityCheckError(struct OsMemPoolHead *pool,
if (taskID >= LOSCFG_BASE_CORE_TSK_LIMIT) {
MEM_UNLOCK(pool, intSave);
LOS_Panic("Task ID %u in pre node is invalid!\n", taskID);
return;
}
taskCB = OS_TCB_FROM_TID(taskID);
if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL)) {
MEM_UNLOCK(pool, intSave);
LOS_Panic("\r\nTask ID %u in pre node is not created!\n", taskID);
return;
}
} else {
PRINTK("The prev node is free\n");

View File

@ -34,7 +34,7 @@
/* for IAR Compiler */
#ifdef __ICCARM__
#include"iccarm_builtin.h"
#include "iccarm_builtin.h"
#endif
#ifdef __cplusplus

View File

@ -87,7 +87,7 @@ VOID OsDoExcHook(EXC_TYPE excType)
INT32 OsLogLevelCheck(INT32 level)
{
if (level > PRINT_LEVEL) {
return LOS_NOK;
return (INT32)LOS_NOK;
}
if ((level != LOG_COMMON_LEVEL) && ((level > LOG_EMG_LEVEL) && (level <= LOG_DEBUG_LEVEL))) {