Compare commits
99 Commits
OpenHarmon
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e76dd685c2 | ||
|
|
54a5365a25 | ||
|
|
2d1160fdc4 | ||
|
|
f3d606b6dd | ||
|
|
392e4c2cec | ||
|
|
b334658723 | ||
|
|
2b1f2d554e | ||
|
|
2cf290bb7c | ||
|
|
8fc9852e34 | ||
|
|
816d03f5c1 | ||
|
|
61877ec97a | ||
|
|
f94d3ee119 | ||
|
|
784429d0dc | ||
|
|
1a764df92a | ||
|
|
cf50cde1b7 | ||
|
|
bfef7bfb2e | ||
|
|
5bae8b58c6 | ||
|
|
044cf59583 | ||
|
|
0adbafb9c2 | ||
|
|
3398937b1b | ||
|
|
3c010b4717 | ||
|
|
c237ff63fa | ||
|
|
3508110f6d | ||
|
|
ffa868a81c | ||
|
|
7d391c9bbf | ||
|
|
e4a1c18d40 | ||
|
|
83790f4f9b | ||
|
|
6377f98e9e | ||
|
|
b8f8ab5a36 | ||
|
|
a0b776a709 | ||
|
|
f5f18ca669 | ||
|
|
5756d45e84 | ||
|
|
8a25f31aa4 | ||
|
|
f7cc6ff14e | ||
|
|
bf9e0c9e2b | ||
|
|
e9de74a94a | ||
|
|
b38f135242 | ||
|
|
0cb50baa55 | ||
|
|
565049f1eb | ||
|
|
9add4b4b92 | ||
|
|
5992506c75 | ||
|
|
d4db5a5a75 | ||
|
|
fe8b68826a | ||
|
|
99640e9977 | ||
|
|
0dc3c7ae9e | ||
|
|
699bb81fc3 | ||
|
|
f2c4b59773 | ||
|
|
b656553c5c | ||
|
|
7653bd8da1 | ||
|
|
1275ecbc8a | ||
|
|
ebc57397f0 | ||
|
|
cce6365f4f | ||
|
|
04f391d814 | ||
|
|
14e64fc89b | ||
|
|
2ce5ce9397 | ||
|
|
eb40e4a068 | ||
|
|
dc5feb9e19 | ||
|
|
7a61f8d836 | ||
|
|
330760dbb3 | ||
|
|
2739a00c55 | ||
|
|
7f14b060d4 | ||
|
|
8be6e129fc | ||
|
|
f465c15d7a | ||
|
|
0af2577498 | ||
|
|
238ff396b8 | ||
|
|
5917c4b01b | ||
|
|
5c4edb9b1a | ||
|
|
ce176e77e6 | ||
|
|
8ef012bdad | ||
|
|
933efffba7 | ||
|
|
ae692bfbc4 | ||
|
|
ab46b9c836 | ||
|
|
b83d17039e | ||
|
|
08404f3252 | ||
|
|
8b19c3cbe4 | ||
|
|
192a2a6e61 | ||
|
|
2ec2c369e7 | ||
|
|
f2b280bdbd | ||
|
|
c09b3a8774 | ||
|
|
04cded2f0a | ||
|
|
ddfb363675 | ||
|
|
d0c50a4af0 | ||
|
|
6affe19d5a | ||
|
|
a36d5d9058 | ||
|
|
63bf098b0f | ||
|
|
252052f024 | ||
|
|
8c46636052 | ||
|
|
6ff615b9ca | ||
|
|
732a346399 | ||
|
|
2931dc6013 | ||
|
|
df30bc4e0a | ||
|
|
1599669290 | ||
|
|
d8104f6290 | ||
|
|
3a190a1a1b | ||
|
|
e1f986305b | ||
|
|
0c8b7d2a1b | ||
|
|
62eb96dd8d | ||
|
|
009d2503fb | ||
|
|
f7d79148b7 |
39
BUILD.gn
39
BUILD.gn
@@ -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
19
Kconfig
@@ -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 ########################
|
||||
|
||||
@@ -43,7 +43,7 @@ module_group("arch") {
|
||||
"$board_cpu" == "ck804ef") {
|
||||
modules += [ "csky" ]
|
||||
} else if ("$board_cpu" == "") {
|
||||
if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") {
|
||||
if ("$board_arch" != string_replace("$board_arch", "rv32i", "")) {
|
||||
modules += [ "risc-v" ]
|
||||
} else if ("$board" == "esp32") {
|
||||
modules += [ "xtensa" ]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -60,7 +60,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
{
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
UINT32 val = SysTick->VAL;
|
||||
*period = SysTick->LOAD;
|
||||
|
||||
@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -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:
|
||||
@@ -63,5 +63,3 @@ extern VOID HalSecureContextSaveAsm(OsSecureContext *secureContext);
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -58,7 +58,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -61,7 +61,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define _LOS_ARCH_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
#include "los_interrupt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -58,7 +58,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
{
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
UINT32 val = SysTick->VAL;
|
||||
*period = SysTick->LOAD;
|
||||
|
||||
@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#define _LOS_ARCH_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
#include "los_interrupt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#define _LOS_ARCH_ATOMIC_H
|
||||
|
||||
#include "los_compiler.h"
|
||||
#include "los_interrupt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -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:
|
||||
@@ -63,5 +63,3 @@ extern VOID HalSecureContextSaveAsm(OsSecureContext *secureContext);
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -59,7 +59,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -63,7 +63,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
**************************************************************************** */
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||
HalHwiHandleReInit((UINT32)&g_hwiForm);
|
||||
|
||||
HalSetVbr((UINT32)&g_hwiForm);
|
||||
for (int i = 0; i < BYTES_OF_128_INT; i++) {
|
||||
for (i = 0; i < BYTES_OF_128_INT; i++) {
|
||||
VIC_REG->IABR[i] = 0x0;
|
||||
VIC_REG->ICPR[i] = MASK_32_BITS;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
@@ -107,13 +107,16 @@ UINT32 ArchIntUnLock(VOID);
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].</li>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware
|
||||
* interrupt tailoring is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range
|
||||
* applicable for a Cortex-A7 platform is [32,95].</li>
|
||||
* <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li>
|
||||
* <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable
|
||||
* for a Cortex-A7 platform is [32,95].
|
||||
* @param irqParam [IN] Type #HwiIrqParam *. ID of hardware interrupt which will base on
|
||||
* when delete the hardware interrupt.
|
||||
* @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
|
||||
@@ -133,13 +136,16 @@ UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam);
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware interrupt tailoring is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range applicable for a Cortex-A7 platform is [32,95].</li>
|
||||
* <li>The hardware interrupt module is usable only when the configuration item for hardware
|
||||
* interrupt tailoring is enabled.</li>
|
||||
* <li>Hardware interrupt number value range: [OS_USER_HWI_MIN,OS_USER_HWI_MAX]. The value range
|
||||
* applicable for a Cortex-A7 platform is [32,95].</li>
|
||||
* <li>OS_HWI_MAX_NUM specifies the maximum number of interrupts that can be created.</li>
|
||||
* <li>Before executing an interrupt on a platform, refer to the chip manual of the platform.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a Cortex-A7 platform is [32,95].
|
||||
* @param hwiNum [IN] Type#HWI_HANDLE_T: hardware interrupt number. The value range applicable for a
|
||||
* Cortex-A7 platform is [32,95].
|
||||
* @param hwiPrio [IN] Type#HWI_PRIOR_T: hardware interrupt priority. Ignore this parameter temporarily.
|
||||
* @param mode [IN] Type#HWI_MODE_T: hardware interrupt mode. Ignore this parameter temporarily.
|
||||
* @param handler [IN] Type#HWI_PROC_FUNC: interrupt handler used when a hardware interrupt is triggered.
|
||||
@@ -149,7 +155,8 @@ UINT32 ArchHwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irqParam);
|
||||
* @retval #OS_ERRNO_HWI_PROC_FUNC_NULL 0x02000901: Null hardware interrupt handling function.
|
||||
* @retval #OS_ERRNO_HWI_NUM_INVALID 0x02000900: Invalid interrupt number.
|
||||
* @retval #OS_ERRNO_HWI_NO_MEMORY 0x02000903: Insufficient memory for hardware interrupt creation.
|
||||
* @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has already been created.
|
||||
* @retval #OS_ERRNO_HWI_ALREADY_CREATED 0x02000904: The interrupt handler being created has
|
||||
* already been created.
|
||||
* @retval #LOS_OK 0 : The interrupt is successfully created.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_interrupt.h: the header file that contains the API declaration.</li></ul>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "los_config.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_arch_context.h"
|
||||
#include "los_error.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -103,7 +103,7 @@ LITE_OS_SEC_TEXT_INIT VOID ArchInit(VOID)
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
|
||||
{
|
||||
LOS_IntLock();
|
||||
(VOID)LOS_IntLock();
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,6 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID)
|
||||
}
|
||||
|
||||
cpuCycle = LOS_SysCycleGet();
|
||||
|
||||
if (cpuCycle < g_cpup[taskID].startTime) {
|
||||
cpuCycle += g_cyclesPerTick;
|
||||
}
|
||||
@@ -625,7 +624,6 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
|
||||
}
|
||||
|
||||
cpuCycle = LOS_SysCycleGet();
|
||||
|
||||
if (cpuCycle < g_irqCpup[intNum].startTime) {
|
||||
cpuCycle += g_cyclesPerTick;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
@@ -250,7 +250,8 @@ extern UINT32 LOS_SysCpuUsage(VOID);
|
||||
* This API is used to obtain the historical CPU usage.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.</li>
|
||||
* <li>This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails
|
||||
* to be obtained.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param mode [IN] UINT16. Task mode. The parameter value 0 indicates that the CPU usage within 10s will be
|
||||
@@ -273,7 +274,8 @@ extern UINT32 LOS_HistorySysCpuUsage(UINT16 mode);
|
||||
* This API is used to obtain the CPU usage of a task specified by a passed-in task ID.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.</li>
|
||||
* <li>This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails
|
||||
* to be obtained.</li>
|
||||
* <li>The passed-in task ID must be valid and the task specified by the task ID must be created. Otherwise,
|
||||
* the CPU usage fails to be obtained.</li>
|
||||
* </ul>
|
||||
@@ -327,7 +329,8 @@ extern UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode);
|
||||
* This API is used to obtain the CPU usage of all tasks according to maximum number of threads.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails to be obtained.</li>
|
||||
* <li>This API can be called only after the CPU usage is initialized. Otherwise, the CPU usage fails
|
||||
* to be obtained.</li>
|
||||
* <li>The input parameter pointer must not be NULL, Otherwise, the CPU usage fails to be obtained.</li>
|
||||
* </ul>
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2021-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:
|
||||
@@ -41,12 +41,6 @@
|
||||
#include "los_debug.h"
|
||||
#include "los_mux.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if (LOSCFG_DYNLINK == 1)
|
||||
|
||||
#if defined(__ICCARM__) || defined(__CC_ARM)
|
||||
@@ -279,7 +273,7 @@ STATIC DynSharedObj *OsLoadInit(const CHAR *fileName, VOID *pool)
|
||||
goto ERR2;
|
||||
}
|
||||
|
||||
strcpy(dso->buf, fileName);
|
||||
(void)strcpy_s(dso->buf, nameLen + 1, fileName);
|
||||
dso->fileName = dso->buf;
|
||||
dso->ref = 1;
|
||||
dso->pool = (pool ? pool : OS_SYS_MEM_ADDR);
|
||||
@@ -867,7 +861,7 @@ STATIC VOID OsDoFini(DynSharedObj *dso)
|
||||
--func;
|
||||
finiFunc = (INIT_FINI_FUNC)(*func);
|
||||
finiFunc();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (initFiniTab->fini.func != 0) {
|
||||
@@ -929,10 +923,3 @@ INT32 LOS_DynlinkInit(VOID)
|
||||
}
|
||||
|
||||
#endif /* LOSCFG_DYNLINK */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2021-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:
|
||||
@@ -129,8 +129,8 @@ typedef struct {
|
||||
} DynSharedObj;
|
||||
|
||||
typedef struct {
|
||||
CHAR *name;
|
||||
UINTPTR addr;
|
||||
CHAR *name;
|
||||
UINTPTR addr;
|
||||
} SymInfo;
|
||||
|
||||
#define SYM_EXPORT(func) \
|
||||
|
||||
@@ -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:
|
||||
@@ -54,13 +54,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
|
||||
#define MAX_SWITCH_INFO_SIZE (INFO_TYPE_AND_SIZE + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) * OS_TASK_SWITCH_INFO_COUNT)
|
||||
#define MAX_SWITCH_INFO_SIZE (INFO_TYPE_AND_SIZE + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) \
|
||||
* OS_TASK_SWITCH_INFO_COUNT)
|
||||
#else
|
||||
#define MAX_SWITCH_INFO_SIZE (0)
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_MEM_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(MemInfoCB) * OS_SYS_MEM_NUM)
|
||||
#define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE)
|
||||
#define MAX_EXC_MEM_SIZE (INFO_TYPE_AND_SIZE + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE \
|
||||
+ MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE)
|
||||
|
||||
typedef enum {
|
||||
OS_EXC_TYPE_CONTEXT = 0,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
@@ -32,6 +32,7 @@
|
||||
#define _GNU_SOURCE 1
|
||||
#include "lfs_adapter.h"
|
||||
#include "los_config.h"
|
||||
#include "los_fs.h"
|
||||
#include "vfs_files.h"
|
||||
#include "vfs_operations.h"
|
||||
#include "vfs_partition.h"
|
||||
@@ -39,8 +40,75 @@
|
||||
#include "vfs_mount.h"
|
||||
#include "securec.h"
|
||||
|
||||
struct dirent g_nameValue;
|
||||
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct PartitionCfg g_partitionCfg;
|
||||
static struct DeviceDesc *g_lfsDevice = NULL;
|
||||
|
||||
static uint32_t LfsGetStartAddr(int partition)
|
||||
{
|
||||
if (g_lfsDevice == NULL) {
|
||||
struct DeviceDesc *device = NULL;
|
||||
for (device = getDeviceList(); device != NULL; device = device->dNext) {
|
||||
if (strcmp(device->dFsType, "littlefs") == 0) {
|
||||
g_lfsDevice = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((g_lfsDevice == NULL) || (partition >= g_lfsDevice->dPartNum)) {
|
||||
return INVALID_DEVICE_ADDR;
|
||||
}
|
||||
|
||||
return (uint32_t)g_lfsDevice->dAddrArray[partition];
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_read(const struct lfs_config *c, lfs_block_t block,
|
||||
lfs_off_t off, void *dst, lfs_size_t size)
|
||||
{
|
||||
UINT32 addr = c->block_size * block + off;
|
||||
UINT32 startaddr = LfsGetStartAddr((int)c->context);
|
||||
if (startaddr == INVALID_DEVICE_ADDR) {
|
||||
return -1;
|
||||
}
|
||||
addr += startaddr;
|
||||
|
||||
return (g_partitionCfg.readFunc)((int)c->context, &addr, dst, size);
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_write(const struct lfs_config *c, lfs_block_t block,
|
||||
lfs_off_t off, const void *dst, lfs_size_t size)
|
||||
{
|
||||
UINT32 addr = c->block_size * block + off;
|
||||
UINT32 startaddr = LfsGetStartAddr((int)c->context);
|
||||
if (startaddr == INVALID_DEVICE_ADDR) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr += startaddr;
|
||||
|
||||
return (g_partitionCfg.writeFunc)((int)c->context, &addr, dst, size);
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_erase(const struct lfs_config *c, lfs_block_t block)
|
||||
{
|
||||
UINT32 addr = c->block_size * block;
|
||||
UINT32 startaddr = LfsGetStartAddr((int)c->context);
|
||||
if (startaddr == INVALID_DEVICE_ADDR) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr += startaddr;
|
||||
|
||||
return (g_partitionCfg.eraseFunc)((int)c->context, addr, c->block_size);
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_sync(const struct lfs_config *c)
|
||||
{
|
||||
(void)c;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ConvertFlagToLfsOpenFlag (int oflags)
|
||||
{
|
||||
@@ -82,38 +150,63 @@ static int LittlefsErrno(int result)
|
||||
return (result < 0) ? -result : result;
|
||||
}
|
||||
|
||||
void LfsConfigAdapter(struct PartitionCfg *pCfg, struct lfs_config *lfsCfg)
|
||||
{
|
||||
lfsCfg->context = (void *)pCfg->partNo;
|
||||
|
||||
lfsCfg->read_size = pCfg->readSize;
|
||||
lfsCfg->prog_size = pCfg->writeSize;
|
||||
lfsCfg->cache_size = pCfg->cacheSize;
|
||||
lfsCfg->block_cycles = pCfg->blockCycles;
|
||||
lfsCfg->lookahead_size = pCfg->lookaheadSize;
|
||||
lfsCfg->block_size = pCfg->blockSize;
|
||||
lfsCfg->block_count = pCfg->blockCount;
|
||||
|
||||
lfsCfg->read = littlefs_block_read;
|
||||
lfsCfg->prog = littlefs_block_write;
|
||||
lfsCfg->erase = littlefs_block_erase;
|
||||
lfsCfg->sync = littlefs_block_sync;
|
||||
|
||||
g_partitionCfg.readFunc = pCfg->readFunc;
|
||||
g_partitionCfg.writeFunc = pCfg->writeFunc;
|
||||
g_partitionCfg.eraseFunc = pCfg->eraseFunc;
|
||||
}
|
||||
|
||||
int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||
{
|
||||
int ret;
|
||||
lfs_t *mountHdl = NULL;
|
||||
struct lfs_config *cfg = NULL;
|
||||
|
||||
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));
|
||||
mountHdl = (lfs_t *)malloc(sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
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));
|
||||
(void)memset_s(mountHdl, sizeof(lfs_t) + sizeof(struct lfs_config), 0, sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
mp->mData = (void *)mountHdl;
|
||||
cfg = (void *)((UINTPTR)mountHdl + sizeof(lfs_t));
|
||||
|
||||
ret = lfs_mount((lfs_t *)mp->mData, (struct lfs_config *)data);
|
||||
LfsConfigAdapter((struct PartitionCfg *)data, cfg);
|
||||
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
if (ret != 0) {
|
||||
ret = lfs_format((lfs_t *)mp->mData, (struct lfs_config*)data);
|
||||
ret = lfs_format((lfs_t *)mp->mData, cfg);
|
||||
if (ret == 0) {
|
||||
ret = lfs_mount((lfs_t *)mp->mData, (struct lfs_config*)data);
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
free(mountHdl);
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = LOS_NOK;
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
|
||||
errout:
|
||||
@@ -126,18 +219,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 +244,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 +267,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 +280,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 +293,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 +323,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 +347,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 +358,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;
|
||||
@@ -278,7 +371,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||
|
||||
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
|
||||
if (ret == TRUE) {
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
pthread_mutex_lock(&g_fsLocalMutex);
|
||||
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
|
||||
if (lfsInfo.type == LFS_TYPE_DIR) {
|
||||
dent->d_type = DT_DIR;
|
||||
@@ -287,7 +380,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||
}
|
||||
|
||||
dent->d_reclen = lfsInfo.size;
|
||||
pthread_mutex_unlock(&g_FslocalMutex);
|
||||
pthread_mutex_unlock(&g_fsLocalMutex);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
@@ -296,7 +389,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 +398,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 +412,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 +429,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 +461,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 +492,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 +523,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,29 +544,29 @@ 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);
|
||||
pthread_mutex_lock(&g_fsLocalMutex);
|
||||
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
|
||||
pthread_mutex_unlock(&g_FslocalMutex);
|
||||
pthread_mutex_unlock(&g_fsLocalMutex);
|
||||
|
||||
if (ret != 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = LOS_NOK;
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
|
||||
free(file->fData);
|
||||
@@ -487,18 +580,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 +604,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 +622,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 +635,37 @@ 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;
|
||||
}
|
||||
|
||||
int LfsFormat(const char *partName, void *privData)
|
||||
{
|
||||
int ret;
|
||||
lfs_t lfs = {0};
|
||||
struct lfs_config cfg = {0};
|
||||
|
||||
(void)partName;
|
||||
|
||||
LfsConfigAdapter((struct PartitionCfg *)privData, &cfg);
|
||||
|
||||
ret = lfs_format(&lfs, &cfg);
|
||||
if (ret != 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -587,7 +698,7 @@ static struct FileOps g_lfsFops = {
|
||||
|
||||
static struct FsManagement g_lfsMgt = {
|
||||
.fdisk = NULL,
|
||||
.format = NULL,
|
||||
.format = LfsFormat,
|
||||
};
|
||||
|
||||
void LfsInit(void)
|
||||
|
||||
@@ -45,6 +45,6 @@
|
||||
#include "pthread.h"
|
||||
|
||||
#define INVALID_FD (-1)
|
||||
|
||||
#define INVALID_DEVICE_ADDR ((uint32_t)-1)
|
||||
void LfsInit(void);
|
||||
#endif /* _LFS_ADAPTER_H_ */
|
||||
|
||||
@@ -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") {
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "sys/stat.h"
|
||||
#include "sys/uio.h"
|
||||
#include "unistd.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -80,8 +81,31 @@ int LOS_Ftruncate(int fd, off_t length);
|
||||
int LOS_FsUmount(const char *target);
|
||||
int LOS_FsUmount2(const char *target, int flag);
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data);
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data);
|
||||
|
||||
int OsFcntl(int fd, int cmd, va_list ap);
|
||||
int OsIoctl(int fd, int req, va_list ap);
|
||||
|
||||
struct PartitionCfg {
|
||||
/* partition low-level read func */
|
||||
int (*readFunc)(int partition, UINT32 *offset, void *buf, UINT32 size);
|
||||
/* partition low-level write func */
|
||||
int (*writeFunc)(int partition, UINT32 *offset, const void *buf, UINT32 size);
|
||||
/* partition low-level erase func */
|
||||
int (*eraseFunc)(int partition, UINT32 offset, UINT32 size);
|
||||
|
||||
int readSize; /* size of a block read */
|
||||
int writeSize; /* size of a block write */
|
||||
int blockSize; /* size of an erasable block */
|
||||
int blockCount; /* number of partition blocks */
|
||||
int cacheSize; /* size of block caches */
|
||||
|
||||
int partNo; /* partition number */
|
||||
int lookaheadSize; /* lookahead size */
|
||||
int blockCycles; /* block cycles */
|
||||
};
|
||||
|
||||
/*
|
||||
* @brief Divide the device into partitions.
|
||||
*
|
||||
@@ -93,6 +117,7 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
* @param lengthArray List of partition size. For example:
|
||||
* [0x10000000, 0x2000000], 256M and 512M partitions will be created and
|
||||
* left all will not allocated.
|
||||
* @param addrArray List of partition start addr, partition num same as lengthArray
|
||||
* @param partNum Length of 'lengthArray'.
|
||||
*
|
||||
* @return Return LOS_NOK if error. Return LOS_OK if success.
|
||||
@@ -103,8 +128,8 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
* The name is a combination of: 'deviceName'+'p'+'partitionId',
|
||||
* such as "emmc0p0", "emmc0p1", "emmc0p2"...
|
||||
*/
|
||||
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
|
||||
int partnum);
|
||||
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
||||
int partNum);
|
||||
|
||||
/*
|
||||
* @brief Format a partition.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -582,17 +582,13 @@ static int VfsRename(const char *old, const char *new)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int VfsIoctl(int fd, int func, ...)
|
||||
static int VfsIoctl(int fd, int func, va_list ap)
|
||||
{
|
||||
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);
|
||||
va_end(ap);
|
||||
|
||||
file = VfsAttachFileReady(fd);
|
||||
if (file == NULL) {
|
||||
return ret;
|
||||
@@ -612,7 +608,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) {
|
||||
@@ -709,8 +705,6 @@ static struct dirent *VfsReaddir(DIR *d)
|
||||
(dir->dMp->mFs->fsFops->readdir != NULL)) {
|
||||
if (dir->dMp->mFs->fsFops->readdir(dir, &dir->dDent) == 0) {
|
||||
ret = &dir->dDent;
|
||||
} else {
|
||||
VFS_ERRNO_SET(EBADF);
|
||||
}
|
||||
} else {
|
||||
VFS_ERRNO_SET(ENOTSUP);
|
||||
@@ -724,7 +718,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 +756,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 +780,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 +817,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 +826,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 +859,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 +868,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();
|
||||
@@ -908,39 +902,44 @@ static int MapToPosixRet(int ret)
|
||||
/* POSIX interface */
|
||||
int LOS_Open(const char *path, int flags, ...)
|
||||
{
|
||||
if (path == NULL) {
|
||||
errno = EINVAL;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
unsigned flagMask = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY;
|
||||
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,15 +948,15 @@ 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
|
||||
#if (LOSCFG_POSIX_PIPE_API == 1)
|
||||
if ((path != NULL) && !strncmp(path, PIPE_DEV_PATH, strlen(PIPE_DEV_PATH))) {
|
||||
if (!strncmp(path, PIPE_DEV_PATH, strlen(PIPE_DEV_PATH))) {
|
||||
return PipeOpen(path, flags, PIPE_DEV_FD);
|
||||
}
|
||||
#endif
|
||||
@@ -984,7 +983,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 +1024,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 +1037,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 +1053,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,58 +1136,74 @@ 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);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LOS_Fcntl(int fd, int cmd, ...)
|
||||
int OsFcntl(int fd, int cmd, va_list ap)
|
||||
{
|
||||
struct File *filep = NULL;
|
||||
va_list ap;
|
||||
int ret;
|
||||
va_start(ap, cmd);
|
||||
|
||||
if (fd < CONFIG_NFILE_DESCRIPTORS) {
|
||||
filep = VfsAttachFileReady(fd);
|
||||
ret = VfsVfcntl(filep, cmd, ap);
|
||||
VfsDetachFile(filep);
|
||||
} else {
|
||||
#ifndef LOSCFG_NET_LWIP_SACK
|
||||
ret = -EBADF;
|
||||
#ifdef LOSCFG_NET_LWIP_SACK
|
||||
#else
|
||||
int arg = va_arg(ap, int);
|
||||
ret = lwip_fcntl(fd, (long)cmd, arg);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
#endif /* LOSCFG_NET_LWIP_SACK */
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
if (ret < 0) {
|
||||
VFS_ERRNO_SET(-ret);
|
||||
ret = LOS_NOK;
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LOS_Fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int ret;
|
||||
va_start(ap, cmd);
|
||||
ret = OsFcntl(fd, cmd, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int OsIoctl(int fd, int req, va_list ap)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (fd < CONFIG_NFILE_DESCRIPTORS) {
|
||||
ret = VfsIoctl(fd, req, ap);
|
||||
} else {
|
||||
#ifndef LOSCFG_NET_LWIP_SACK
|
||||
ret = -EBADF;
|
||||
#else
|
||||
UINTPTR arg = va_arg(ap, UINTPTR);
|
||||
ret = lwip_ioctl(fd, (long)req, (void *)arg);
|
||||
#endif /* LOSCFG_NET_LWIP_SACK */
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LOS_Ioctl(int fd, int req, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list ap;
|
||||
va_start(ap, req);
|
||||
if (fd < CONFIG_NFILE_DESCRIPTORS) {
|
||||
ret = VfsIoctl(fd, req, ap);
|
||||
} else {
|
||||
ret = -EBADF;
|
||||
#ifdef LOSCFG_NET_LWIP_SACK
|
||||
UINTPTR arg = va_arg(ap, UINTPTR);
|
||||
ret = lwip_ioctl(fd, (long)req, (void *)arg);
|
||||
#endif /* LOSCFG_NET_LWIP_SACK */
|
||||
}
|
||||
|
||||
ret = OsIoctl(fd, req, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
@@ -1207,22 +1222,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 +1253,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 +1279,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 +1307,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 +1333,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 +1360,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 +1394,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 +1404,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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
* 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. *
|
||||
* 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.
|
||||
@@ -54,23 +55,23 @@ struct FsMap *VfsFsMapGet(const char *fsType)
|
||||
}
|
||||
|
||||
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
|
||||
struct FileOps *fsFops, struct FsManagement *fsMgt)
|
||||
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;
|
||||
|
||||
@@ -57,7 +57,7 @@ struct FsMap {
|
||||
};
|
||||
|
||||
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
|
||||
struct FileOps *fsFops, struct FsManagement *fsMgt);
|
||||
struct FileOps *fsFops, struct FsManagement *fsMgt);
|
||||
struct FsMap *VfsFsMapGet(const char *fsType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -122,44 +122,65 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
|
||||
return bestMp;
|
||||
}
|
||||
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data)
|
||||
STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType, unsigned long mountflags)
|
||||
{
|
||||
int ret;
|
||||
struct MountPoint *mp = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
struct FsMap *mFs = NULL;
|
||||
|
||||
/* target must begin with '/', for example /system, /data, etc. */
|
||||
if ((target == NULL) || (target[0] != '/')) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
(void)VfsLock();
|
||||
/* find mp by target, to see if it was mounted */
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if (mp != NULL && pathInMp != NULL) {
|
||||
goto errout;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find fsMap coresponding to the fsType */
|
||||
struct FsMap *mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) ||
|
||||
(mFs->fsMops->mount == NULL)) {
|
||||
goto errout;
|
||||
mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
|
||||
if (mp == NULL) {
|
||||
goto errout;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mp->mFs = mFs;
|
||||
mp->mDev = NULL;
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
mp->mNext = g_mountPoints;
|
||||
|
||||
return mp;
|
||||
}
|
||||
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
int ret;
|
||||
struct MountPoint *mp = NULL;
|
||||
|
||||
/* target must begin with '/', for example /system, /data, etc. */
|
||||
if ((target == NULL) || (target[0] != '/')) {
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
(void)VfsLock();
|
||||
|
||||
mp = MountPointInit(target, fsType, mountflags);
|
||||
if (mp == NULL) {
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
if (source != NULL) {
|
||||
mp->mDev = strdup(source);
|
||||
if (mp->mDev == NULL) {
|
||||
goto errout;
|
||||
free(mp);
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,10 +195,7 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
PRINT_ERR("mount failed, target %s.\n", target);
|
||||
goto errout;
|
||||
}
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
mp->mNext = g_mountPoints;
|
||||
|
||||
g_mountPoints = mp;
|
||||
VfsUnlock();
|
||||
return LOS_OK;
|
||||
@@ -187,14 +205,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 +248,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 +270,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 +308,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;
|
||||
}
|
||||
|
||||
@@ -37,25 +37,27 @@
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
static struct DeviceDesc *g_deviceList = NULL;
|
||||
|
||||
int GetPartIdByPartName(const char *partName)
|
||||
{
|
||||
if (partName == NULL) {
|
||||
return LOS_NOK;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
/* the character next to p is the partId */
|
||||
char *p = strrchr(partName, 'p');
|
||||
if (p + 1 != NULL) {
|
||||
if (p != NULL) {
|
||||
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,25 +66,95 @@ 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)
|
||||
struct DeviceDesc *getDeviceList(VOID)
|
||||
{
|
||||
int ret = LOS_NOK;
|
||||
return g_deviceList;
|
||||
}
|
||||
|
||||
static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
||||
int partNum)
|
||||
{
|
||||
struct DeviceDesc *prev = NULL;
|
||||
for (prev = g_deviceList; prev != NULL; prev = prev->dNext) {
|
||||
if (strcmp(prev->dDev, dev) == 0) {
|
||||
errno = -EEXIST;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
}
|
||||
|
||||
if (addrArray == NULL) {
|
||||
errno = -EFAULT;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
prev = (struct DeviceDesc *)malloc(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));
|
||||
if (prev->dDev == NULL || prev->dFsType == NULL || prev->dAddrArray == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
(void)memcpy_s(prev->dAddrArray, partNum * sizeof(int), addrArray, partNum * sizeof(int));
|
||||
|
||||
if (lengthArray != NULL) {
|
||||
prev->dLengthArray = (int *)malloc(partNum * sizeof(int));
|
||||
if (prev->dLengthArray == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
(void)memcpy_s(prev->dLengthArray, partNum * sizeof(int), lengthArray, partNum * sizeof(int));
|
||||
}
|
||||
|
||||
prev->dNext = g_deviceList;
|
||||
prev->dPartNum = partNum;
|
||||
g_deviceList = prev;
|
||||
return LOS_OK;
|
||||
errout:
|
||||
if (prev->dDev != NULL) {
|
||||
free((void *)prev->dDev);
|
||||
}
|
||||
if (prev->dFsType != NULL) {
|
||||
free((void *)prev->dFsType);
|
||||
}
|
||||
if (prev->dAddrArray != NULL) {
|
||||
free((void *)prev->dAddrArray);
|
||||
}
|
||||
if (prev->dLengthArray != NULL) {
|
||||
free((void *)prev->dLengthArray);
|
||||
}
|
||||
|
||||
free(prev);
|
||||
errno = -ENOMEM;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
|
||||
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
||||
int partNum)
|
||||
{
|
||||
int ret = (int)LOS_NOK;
|
||||
struct FsMap *fMap = VfsFsMapGet(fsType);
|
||||
if ((fMap != NULL) && (fMap->fsMgt != NULL) &&
|
||||
(fMap->fsMgt->fdisk != NULL)) {
|
||||
ret = fMap->fsMgt->fdisk(dev, lengthArray, partnum);
|
||||
ret = fMap->fsMgt->fdisk(dev, lengthArray, partNum);
|
||||
if (ret == (int)LOS_NOK) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = AddDevice(dev, fsType, lengthArray, addrArray, partNum);
|
||||
return ret;
|
||||
}
|
||||
|
||||
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 +163,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,5 +172,6 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
|
||||
(fMap->fsMgt->format != NULL)) {
|
||||
ret = fMap->fsMgt->format(partName, data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#ifndef _VFS_PARTITION_H_
|
||||
#define _VFS_PARTITION_H_
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -41,6 +43,19 @@ extern "C" {
|
||||
|
||||
int GetPartIdByPartName(const char *partName);
|
||||
int GetDevIdByDevName(const char *dev);
|
||||
struct DeviceDesc *getDeviceList(void);
|
||||
|
||||
struct DeviceDesc {
|
||||
struct FsMap *dFs; /* file system info */
|
||||
struct DeviceDesc *dNext; /* point to next mount point */
|
||||
const char *dPath; /* target path, /system, /usr, etc. */
|
||||
const char *dDev; /* device, "emmc0p0", "emmc0p1", etc. */
|
||||
void *dData; /* specific file system handle */
|
||||
const char *dFsType; /* file system type */
|
||||
int *dLengthArray; /* point to device partitions length array */
|
||||
int *dAddrArray; /* point to device partitions address array */
|
||||
int dPartNum; /* number of device partitions */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -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:
|
||||
@@ -191,7 +191,7 @@ VOID LOS_LmkOpsNodeInfoShow(VOID)
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(opsNode, &g_losLmkOps.lmkOpsList, LosLmkOpsNode, node) {
|
||||
PRINTK("Priority: %-4u Free:0x%-8x Restore:0x%-8x\n", opsNode->priority,
|
||||
PRINTK("Priority: %-4u Free:0x%-8x Restore:0x%-8x\n", opsNode->priority,
|
||||
(UINT32)(UINTPTR)opsNode->freeMem, (UINT32)(UINTPTR)opsNode->restoreTask);
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
@@ -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:
|
||||
@@ -199,7 +199,7 @@ UINT32 LOS_LmkTasksRestore(VOID);
|
||||
* @brief Kill the tasks to release the used memory.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to kill the tasks to release the used memory when low memory killer is triggered.
|
||||
* This API is used to kill the tasks to release the used memory when low memory killer is triggered.
|
||||
*
|
||||
* @attention None.
|
||||
*
|
||||
|
||||
@@ -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:
|
||||
@@ -56,7 +56,7 @@ void *memcpy(void *dest, const void *src, size_t len)
|
||||
}
|
||||
|
||||
#undef strcat
|
||||
char *strcat (char *s, const char *append)
|
||||
char *strcat(char *s, const char *append)
|
||||
{
|
||||
if ((s == NULL) || (append == NULL)) {
|
||||
return NULL;
|
||||
|
||||
@@ -182,18 +182,18 @@ VOID LOS_LmsCheckPoolDel(const VOID *pool)
|
||||
LmsMemListNode *delNode = OsLmsGetPoolNode(pool);
|
||||
if (delNode == NULL) {
|
||||
PRINT_ERR("[LMS]pool %p is not on lms checklist !\n", pool);
|
||||
goto REALEASE;
|
||||
goto RELEASE;
|
||||
}
|
||||
delNode->used = LMS_POOL_UNUSED;
|
||||
LOS_ListDelete(&(delNode->node));
|
||||
|
||||
REALEASE:
|
||||
RELEASE:
|
||||
LMS_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
VOID OsLmsInit(VOID)
|
||||
{
|
||||
memset(g_lmsCheckPoolArray, 0, sizeof(g_lmsCheckPoolArray));
|
||||
(VOID)memset(g_lmsCheckPoolArray, 0, sizeof(g_lmsCheckPoolArray));
|
||||
LOS_ListInit(&g_lmsCheckPoolList);
|
||||
static LmsHook hook = {
|
||||
.init = LOS_LmsCheckPoolAdd,
|
||||
@@ -284,7 +284,7 @@ VOID OsLmsSetShadowValue(LmsMemListNode *node, UINTPTR startAddr, UINTPTR endAdd
|
||||
}
|
||||
|
||||
if (shadowEnd + 1 > shadowStart) {
|
||||
memset((VOID *)shadowStart, value & LMS_SHADOW_MASK_U8, shadowEnd + 1 - shadowStart);
|
||||
(VOID)memset((VOID *)shadowStart, value & LMS_SHADOW_MASK_U8, shadowEnd + 1 - shadowStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +339,7 @@ VOID OsLmsLosMallocMark(const VOID *curNodeStart, const VOID *nextNodeStart, UIN
|
||||
}
|
||||
|
||||
OsLmsSetShadowValue(node, curNodeStartAddr, curNodeStartAddr + nodeHeadSize, LMS_SHADOW_REDZONE_U8);
|
||||
OsLmsSetShadowValue(node, curNodeStartAddr + nodeHeadSize, nextNodeStartAddr, LMS_SHADOW_ACCESSABLE_U8);
|
||||
OsLmsSetShadowValue(node, curNodeStartAddr + nodeHeadSize, nextNodeStartAddr, LMS_SHADOW_ACCESSIBLE_U8);
|
||||
OsLmsSetShadowValue(node, nextNodeStartAddr, nextNodeStartAddr + nodeHeadSize, LMS_SHADOW_REDZONE_U8);
|
||||
LMS_UNLOCK(intSave);
|
||||
}
|
||||
@@ -357,7 +357,7 @@ VOID OsLmsCheckValid(UINTPTR checkAddr, BOOL isFreeCheck)
|
||||
|
||||
OsLmsGetShadowValue(node, checkAddr, &shadowValue);
|
||||
LMS_UNLOCK(intSave);
|
||||
if ((shadowValue == LMS_SHADOW_ACCESSABLE) || ((isFreeCheck) && (shadowValue == LMS_SHADOW_PAINT))) {
|
||||
if ((shadowValue == LMS_SHADOW_ACCESSIBLE) || ((isFreeCheck) && (shadowValue == LMS_SHADOW_PAINT))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ VOID OsLmsLosFreeMark(const VOID *curNodeStart, const VOID *nextNodeStart, UINT3
|
||||
UINTPTR nextNodeStartAddr = (UINTPTR)nextNodeStart;
|
||||
|
||||
OsLmsGetShadowValue(node, curNodeStartAddr + nodeHeadSize, &shadowValue);
|
||||
if ((shadowValue != LMS_SHADOW_ACCESSABLE) && (shadowValue != LMS_SHADOW_PAINT)) {
|
||||
if ((shadowValue != LMS_SHADOW_ACCESSIBLE) && (shadowValue != LMS_SHADOW_PAINT)) {
|
||||
LMS_UNLOCK(intSave);
|
||||
OsLmsReportError(curNodeStartAddr + nodeHeadSize, MEM_REGION_SIZE_1, FREE_ERRORMODE);
|
||||
return;
|
||||
@@ -421,7 +421,7 @@ VOID LOS_LmsAddrDisableProtect(UINTPTR addrStart, UINTPTR addrEnd)
|
||||
LMS_LOCK(intSave);
|
||||
LmsMemListNode *node = OsLmsGetPoolNodeFromAddr(addrStart);
|
||||
if (node != NULL) {
|
||||
OsLmsSetShadowValue(node, addrStart, addrEnd, LMS_SHADOW_ACCESSABLE_U8);
|
||||
OsLmsSetShadowValue(node, addrStart, addrEnd, LMS_SHADOW_ACCESSIBLE_U8);
|
||||
}
|
||||
LMS_UNLOCK(intSave);
|
||||
}
|
||||
@@ -440,7 +440,7 @@ STATIC UINT32 OsLmsCheckAddr(UINTPTR addr)
|
||||
LmsMemListNode *node = OsLmsGetPoolNodeFromAddr(addr);
|
||||
if (node == NULL) {
|
||||
LMS_UNLOCK(intSave);
|
||||
return LMS_SHADOW_ACCESSABLE_U8;
|
||||
return LMS_SHADOW_ACCESSIBLE_U8;
|
||||
}
|
||||
|
||||
OsLmsGetShadowValue(node, addr, &shadowValue);
|
||||
@@ -556,7 +556,7 @@ STATIC VOID OsLmsGetErrorInfo(UINTPTR addr, UINT32 size, LmsAddrInfo *info)
|
||||
{
|
||||
LmsMemListNode *node = OsLmsGetPoolNodeFromAddr(addr);
|
||||
OsLmsGetShadowInfo(node, addr, info);
|
||||
if (info->shadowValue != LMS_SHADOW_ACCESSABLE_U8) {
|
||||
if (info->shadowValue != LMS_SHADOW_ACCESSIBLE_U8) {
|
||||
return;
|
||||
} else {
|
||||
OsLmsGetShadowInfo(node, addr + size - 1, info);
|
||||
@@ -572,7 +572,7 @@ STATIC VOID OsLmsPrintErrInfo(LmsAddrInfo *info, UINT32 errMod)
|
||||
case LMS_SHADOW_REDZONE:
|
||||
PRINT_ERR("Heap buffer overflow error detected\n");
|
||||
break;
|
||||
case LMS_SHADOW_ACCESSABLE:
|
||||
case LMS_SHADOW_ACCESSIBLE:
|
||||
PRINT_ERR("No error\n");
|
||||
break;
|
||||
default:
|
||||
@@ -609,7 +609,7 @@ VOID OsLmsReportError(UINTPTR p, UINT32 size, UINT32 errMod)
|
||||
|
||||
LMS_LOCK(intSave);
|
||||
g_checkDepth += 1;
|
||||
memset(&info, 0, sizeof(LmsAddrInfo));
|
||||
(VOID)memset(&info, 0, sizeof(LmsAddrInfo));
|
||||
|
||||
PRINT_ERR("***** Kernel Address Sanitizer Error Detected Start *****\n");
|
||||
|
||||
@@ -628,7 +628,7 @@ VOID OsLmsReportError(UINTPTR p, UINT32 size, UINT32 errMod)
|
||||
#if (LOSCFG_LMS_STORE_CHECK == 1)
|
||||
VOID __asan_store1_noabort(UINTPTR p)
|
||||
{
|
||||
if (OsLmsCheckAddr(p) != LMS_SHADOW_ACCESSABLE_U8) {
|
||||
if (OsLmsCheckAddr(p) != LMS_SHADOW_ACCESSIBLE_U8) {
|
||||
OsLmsReportError(p, MEM_REGION_SIZE_1, STORE_ERRMODE);
|
||||
}
|
||||
}
|
||||
@@ -704,7 +704,7 @@ VOID __asan_storeN_noabort(UINTPTR p, UINT32 size)
|
||||
#if (LOSCFG_LMS_LOAD_CHECK == 1)
|
||||
VOID __asan_load1_noabort(UINTPTR p)
|
||||
{
|
||||
if (OsLmsCheckAddr(p) != LMS_SHADOW_ACCESSABLE_U8) {
|
||||
if (OsLmsCheckAddr(p) != LMS_SHADOW_ACCESSIBLE_U8) {
|
||||
OsLmsReportError(p, MEM_REGION_SIZE_1, LOAD_ERRMODE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ extern "C" {
|
||||
#define LMS_POOL_RESIZE(size) ((size) / (LMS_SHADOW_U8_REFER_BYTES + 1) * LMS_SHADOW_U8_REFER_BYTES)
|
||||
#define LMS_ADDR_ALIGN(p) (((UINTPTR)(p) + sizeof(UINTPTR) - 1) & ~((UINTPTR)(sizeof(UINTPTR) - 1)))
|
||||
|
||||
#define LMS_SHADOW_ACCESSABLE 0x00
|
||||
#define LMS_SHADOW_ACCESSIBLE 0x00
|
||||
#define LMS_SHADOW_AFTERFREE 0x03
|
||||
#define LMS_SHADOW_REDZONE 0x02
|
||||
#define LMS_SHADOW_PAINT 0x01
|
||||
#define LMS_SHADOW_MASK 0x03
|
||||
|
||||
#define LMS_SHADOW_ACCESSABLE_U8 0x00
|
||||
#define LMS_SHADOW_ACCESSIBLE_U8 0x00
|
||||
#define LMS_SHADOW_AFTERFREE_U8 0xFF
|
||||
#define LMS_SHADOW_REDZONE_U8 0xAA
|
||||
#define LMS_SHADOW_MASK_U8 0xFF
|
||||
|
||||
@@ -34,7 +34,7 @@ module_switch = defined(LOSCFG_NET_LWIP_SACK)
|
||||
module_name = "lwip"
|
||||
kernel_module(module_name) {
|
||||
sources = LWIP_PORTING_FILES + LWIPNOAPPSFILES - [ "$LWIPDIR/api/sockets.c" ]
|
||||
include_dirs = [ "//utils/native/lite/include" ]
|
||||
include_dirs = [ "//commonlibrary/utils_lite/include" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
|
||||
@@ -240,4 +240,7 @@
|
||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||
#endif
|
||||
|
||||
#define LWIP_SOCKET_IOCTL 0
|
||||
#define LWIP_SOCKET_FCNTL 0
|
||||
|
||||
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
||||
|
||||
@@ -469,8 +469,9 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
|
||||
}
|
||||
intrvl -= 1000; /* 1000: 1000ms = 1s */
|
||||
sys_msleep(1000); /* 1000: 1000ms = 1s */
|
||||
if (ping_kill == 1)
|
||||
if (ping_kill == 1) {
|
||||
break;
|
||||
}
|
||||
} while (intrvl > 0);
|
||||
succ_cnt++;
|
||||
break;
|
||||
@@ -528,7 +529,7 @@ u32_t OsShellPing(int argc, const char **argv)
|
||||
{
|
||||
int ret;
|
||||
u32_t i = 0;
|
||||
u32_t count = 0;
|
||||
u32_t count;
|
||||
int count_set = 0;
|
||||
u32_t interval = 1000; /* default ping interval */
|
||||
u32_t data_len = 48; /* default data length */
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
#include <stdlib.h>
|
||||
#include "lwip/tcpip.h"
|
||||
#include "ohos_init.h"
|
||||
void TcpIpPortingInit()
|
||||
|
||||
void TcpIpPortingInit(void)
|
||||
{
|
||||
tcpip_init(NULL, NULL);
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ int close(int fd)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_IOCTL
|
||||
#ifdef LWIP_SOCKET_IOCTL_FUNC
|
||||
int ioctl(int fd, int req, ...)
|
||||
{
|
||||
@@ -222,7 +223,9 @@ int ioctl(int fd, int req, ...)
|
||||
return lwip_ioctl(fd, (long)req, (void *)arg);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_FCNTL
|
||||
#ifdef LWIP_SOCKET_FCNTL_FUNC
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
@@ -234,6 +237,7 @@ int fcntl(int fd, int cmd, ...)
|
||||
return lwip_fcntl(fd, cmd, val);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_SELECT
|
||||
#ifdef LWIP_SOCKET_SELECT_FUNC
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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->sysMode == 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,11 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (pm->sysctrl->suspendCheck != NULL) {
|
||||
pm->sysctrl->suspendCheck(mode);
|
||||
pm->sysMode = pm->pmMode;
|
||||
}
|
||||
|
||||
tickTimerStop = OsPmTickTimerStop(pm);
|
||||
if (!tickTimerStop) {
|
||||
OsSchedResetSchedResponseTime(0);
|
||||
@@ -283,6 +290,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 +303,7 @@ STATIC VOID OsPmNormalSleep(VOID)
|
||||
OsPmCpuResume(pm);
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC UINT32 OsPmDeviceRegister(LosPmCB *pm, LosPmDevice *device)
|
||||
@@ -343,6 +354,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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -67,7 +67,7 @@ int SysUserTaskCreate(unsigned long entry, unsigned long userArea, unsigned long
|
||||
|
||||
int SysSchedSetScheduler(unsigned int tid, int policy, int priority)
|
||||
{
|
||||
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
if ((tid == 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ int *SysSchedGetArea(unsigned int tid)
|
||||
unsigned int intSave;
|
||||
int *area = NULL;
|
||||
|
||||
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
if ((tid == 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ SYSCALL_HAND_DEF(__NR_get_thread_area, SysGetThreadArea, char *, ARG_NUM_0)
|
||||
// SYSCALL_HAND_DEF(__NR_pthread_set_detach, SysUserThreadSetDetach, int, ARG_NUM_1)
|
||||
// SYSCALL_HAND_DEF(__NR_pthread_join, SysThreadJoin, int, ARG_NUM_1)
|
||||
// SYSCALL_HAND_DEF(__NR_pthread_deatch, SysUserThreadDetach, int, ARG_NUM_1)
|
||||
SYSCALL_HAND_DEF(__NR_creat_user_thread, SysUserTaskCreate, unsigned int, ARG_NUM_4)
|
||||
SYSCALL_HAND_DEF(__NR_create_user_thread, SysUserTaskCreate, unsigned int, ARG_NUM_4)
|
||||
// SYSCALL_HAND_DEF(__NR_getrusage, SysGetrusage, int, ARG_NUM_2)
|
||||
// SYSCALL_HAND_DEF(__NR_sysconf, SysSysconf, long, ARG_NUM_1)
|
||||
// SYSCALL_HAND_DEF(__NR_ugetrlimit, SysUgetrlimit, int, ARG_NUM_2)
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
#include "los_debugtools.h"
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_KERNEL_TRACE == 1)
|
||||
#include "los_trace_pri.h"
|
||||
#endif
|
||||
|
||||
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
|
||||
|
||||
STATIC CmdModInfo cmdInfo;
|
||||
@@ -75,6 +79,13 @@ CmdItem g_shellcmdAll[] = {
|
||||
{CMD_TYPE_EX, "st", 1, (CmdCallBackFunc)OsShellCmdSchedTrace},
|
||||
#endif
|
||||
{CMD_TYPE_EX, "help", 0, (CmdCallBackFunc)OsShellCmdHelp},
|
||||
#if (LOSCFG_KERNEL_TRACE == 1)
|
||||
{CMD_TYPE_EX, "trace_start", 0, (CmdCallBackFunc)LOS_TraceStart},
|
||||
{CMD_TYPE_EX, "trace_stop", 0, (CmdCallBackFunc)LOS_TraceStop},
|
||||
{CMD_TYPE_EX, "trace_mask", 1, (CmdCallBackFunc)OsShellCmdTraceSetMask},
|
||||
{CMD_TYPE_EX, "trace_reset", 0, (CmdCallBackFunc)LOS_TraceReset},
|
||||
{CMD_TYPE_EX, "trace_dump", 1, (CmdCallBackFunc)OsShellCmdTraceDump},
|
||||
#endif
|
||||
};
|
||||
|
||||
CmdModInfo *OsCmdInfoGet(VOID)
|
||||
|
||||
@@ -82,7 +82,6 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdFree(INT32 argc, const CHAR *argv[])
|
||||
#if (LOSCFG_MEM_WATERLINE == 1)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdWaterLine(INT32 argc, const CHAR *argv[])
|
||||
{
|
||||
UINT32 ret;
|
||||
LOS_MEM_POOL_STATUS poolStatus;
|
||||
|
||||
if (argc > 1) {
|
||||
|
||||
@@ -544,11 +544,6 @@ STATIC INT32 OsShellCmdDoRmdir(const CHAR *pathname)
|
||||
}
|
||||
if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) {
|
||||
size_t fullPathBufSize = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN;
|
||||
if (fullPathBufSize <= 0) {
|
||||
PRINTK("buffer size is invalid!\n");
|
||||
(VOID)closedir(d);
|
||||
return -1;
|
||||
}
|
||||
fullpath = (CHAR *)malloc(fullPathBufSize);
|
||||
if (fullpath == NULL) {
|
||||
PRINTK("malloc failure!\n");
|
||||
@@ -724,7 +719,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) {
|
||||
|
||||
@@ -64,3 +64,11 @@ kernel_module(module_name) {
|
||||
include_dirs += [ "pipeline/serial" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
".",
|
||||
"cnv",
|
||||
"pipeline",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -39,12 +39,6 @@
|
||||
#include "los_swtmr.h"
|
||||
#include "los_hook.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
STATIC VOID LOS_TraceMemInit(VOID *pool, UINT32 size)
|
||||
{
|
||||
LOS_TRACE(MEM_INFO_REQ, pool);
|
||||
@@ -264,9 +258,3 @@ VOID OsTraceCnvInit(VOID)
|
||||
LOS_HookReg(LOS_HOOK_TYPE_SWTMR_START, LOS_TraceSwtmrStart);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_SWTMR_STOP, LOS_TraceSwtmrStop);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -45,12 +45,6 @@
|
||||
#include "shell.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if (LOSCFG_KERNEL_TRACE == 1)
|
||||
LITE_OS_SEC_BSS STATIC UINT32 g_traceEventCount;
|
||||
LITE_OS_SEC_BSS STATIC volatile enum TraceState g_traceState = TRACE_UNINIT;
|
||||
@@ -417,18 +411,6 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTraceDump(INT32 argc, const CHAR **argv)
|
||||
LOS_TraceRecordDump(toClient);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
SHELLCMD_ENTRY(tracestart_shellcmd, CMD_TYPE_EX, "trace_start", 0, (CmdCallBackFunc)LOS_TraceStart);
|
||||
SHELLCMD_ENTRY(tracestop_shellcmd, CMD_TYPE_EX, "trace_stop", 0, (CmdCallBackFunc)LOS_TraceStop);
|
||||
SHELLCMD_ENTRY(tracesetmask_shellcmd, CMD_TYPE_EX, "trace_mask", 1, (CmdCallBackFunc)OsShellCmdTraceSetMask);
|
||||
SHELLCMD_ENTRY(tracereset_shellcmd, CMD_TYPE_EX, "trace_reset", 0, (CmdCallBackFunc)LOS_TraceReset);
|
||||
SHELLCMD_ENTRY(tracedump_shellcmd, CMD_TYPE_EX, "trace_dump", 1, (CmdCallBackFunc)OsShellCmdTraceDump);
|
||||
#endif
|
||||
|
||||
#endif /* LOSCFG_KERNEL_TRACE == 1 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -152,6 +152,11 @@ extern VOID OsTraceRecordDump(BOOL toClient);
|
||||
#define OsTraceNotifyStop()
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_SHELL == 1)
|
||||
extern UINT32 OsShellCmdTraceSetMask(INT32 argc, const CHAR **argv);
|
||||
extern UINT32 OsShellCmdTraceDump(INT32 argc, const CHAR **argv);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -32,12 +32,6 @@
|
||||
#include "trace_pipeline_serial.h"
|
||||
#include "trace_pipeline.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if (LOSCFG_TRACE_CONTROL_AGENT == 1)
|
||||
UINT32 SerialPipelineInit(VOID)
|
||||
{
|
||||
@@ -93,9 +87,3 @@ UINT32 OsTracePipelineInit(VOID)
|
||||
OsTracePipelineReg(&g_serialOps);
|
||||
return g_serialOps.init();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -33,12 +33,6 @@
|
||||
#include "trace_tlv.h"
|
||||
#include "los_trace_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == 1)
|
||||
LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_pipeSpin);
|
||||
#define PIPE_LOCK(state) LOS_SpinLockSave(&g_pipeSpin, &(state))
|
||||
@@ -154,9 +148,3 @@ UINT32 OsTraceDataWait(VOID)
|
||||
{
|
||||
return g_tracePipelineOps->wait();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -32,12 +32,6 @@
|
||||
#include "trace_tlv.h"
|
||||
#include "securec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define CRC_WIDTH 8
|
||||
#define CRC_POLY 0x1021
|
||||
#define CRC_TOPBIT 0x8000
|
||||
@@ -114,9 +108,3 @@ UINT32 OsTraceDataEncode(UINT8 type, const TlvTable *table, UINT8 *src, UINT8 *d
|
||||
head->crc = crc;
|
||||
return len + sizeof(TraceMsgTlvHead);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -31,12 +31,8 @@
|
||||
|
||||
#include "los_trace_pri.h"
|
||||
#include "trace_pipeline.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#include "los_memory.h"
|
||||
#include "securec.h"
|
||||
|
||||
#if (LOSCFG_RECORDER_MODE_OFFLINE == 1)
|
||||
#define BITS_NUM_FOR_TASK_ID 16
|
||||
@@ -257,9 +253,3 @@ OfflineHead *OsTraceRecordGet(VOID)
|
||||
}
|
||||
|
||||
#endif /* LOSCFG_RECORDER_MODE_OFFLINE == 1 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -32,12 +32,6 @@
|
||||
#include "los_trace_pri.h"
|
||||
#include "trace_pipeline.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#if (LOSCFG_RECORDER_MODE_ONLINE == 1)
|
||||
UINT32 OsTraceGetMaskTid(UINT32 taskId)
|
||||
{
|
||||
@@ -105,9 +99,3 @@ OfflineHead *OsTraceRecordGet(VOID)
|
||||
}
|
||||
|
||||
#endif /* LOSCFG_RECORDER_MODE_ONLINE == 1 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
20
config.gni
20
config.gni
@@ -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'"
|
||||
|
||||
@@ -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'"
|
||||
|
||||
@@ -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;
|
||||
@@ -966,21 +978,17 @@ osStatus_t osEventFlagsDelete(osEventFlagsId_t ef_id)
|
||||
{
|
||||
PEVENT_CB_S pstEventCB = (PEVENT_CB_S)ef_id;
|
||||
UINT32 intSave;
|
||||
osStatus_t ret;
|
||||
osStatus_t ret = osOK;
|
||||
if (OS_INT_ACTIVE) {
|
||||
return osErrorISR;
|
||||
}
|
||||
intSave = LOS_IntLock();
|
||||
if (LOS_EventDestroy(pstEventCB) == LOS_OK) {
|
||||
ret = osOK;
|
||||
} else {
|
||||
if (LOS_EventDestroy(pstEventCB) != LOS_OK) {
|
||||
ret = osErrorParameter;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if (LOS_MemFree(m_aucSysMem0, (void *)pstEventCB) == LOS_OK) {
|
||||
ret = osOK;
|
||||
} else {
|
||||
if (LOS_MemFree(m_aucSysMem0, (void *)pstEventCB) != LOS_OK) {
|
||||
ret = osErrorParameter;
|
||||
}
|
||||
|
||||
@@ -1226,14 +1234,40 @@ osMessageQueueId_t osMessageQueueNew(uint32_t msg_count, uint32_t msg_size, cons
|
||||
{
|
||||
UINT32 queueId;
|
||||
UINT32 ret;
|
||||
UNUSED(attr);
|
||||
osMessageQueueId_t handle;
|
||||
const char *queueName = NULL;
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
UINT32 queueSize = 0;
|
||||
UINT8 *staticMem = NULL;
|
||||
#endif
|
||||
|
||||
if ((msg_count == 0) || (msg_size == 0) || OS_INT_ACTIVE) {
|
||||
return (osMessageQueueId_t)NULL;
|
||||
}
|
||||
|
||||
ret = LOS_QueueCreate((char *)NULL, (UINT16)msg_count, &queueId, 0, (UINT16)msg_size);
|
||||
if (attr != NULL) {
|
||||
queueName = attr->name;
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
queueSize = attr->mq_size;
|
||||
staticMem = attr->mq_mem;
|
||||
if (((queueSize == 0) && (staticMem != NULL)) || ((queueSize != 0) && (staticMem == NULL))) {
|
||||
return (osMessageQueueId_t)NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
if (staticMem != NULL) {
|
||||
ret = LOS_QueueCreateStatic((const CHAR *)queueName, (UINT16)msg_count, &queueId, \
|
||||
(UINT8 *)staticMem, 0, (UINT16)queueSize / msg_count);
|
||||
} else {
|
||||
ret = LOS_QueueCreate((const CHAR *)queueName, (UINT16)msg_count, &queueId, 0, (UINT16)msg_size);
|
||||
}
|
||||
#else
|
||||
ret = LOS_QueueCreate((const CHAR *)queueName, (UINT16)msg_count, &queueId, 0, (UINT16)msg_size);
|
||||
#endif
|
||||
|
||||
if (ret == LOS_OK) {
|
||||
handle = (osMessageQueueId_t)(GET_QUEUE_HANDLE(queueId));
|
||||
} else {
|
||||
@@ -1361,8 +1395,13 @@ osStatus_t osMessageQueueDelete(osMessageQueueId_t mq_id)
|
||||
|
||||
const char *osMessageQueueGetName(osMessageQueueId_t mq_id)
|
||||
{
|
||||
UNUSED(mq_id);
|
||||
return NULL;
|
||||
if (mq_id == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LosQueueCB *pstQueue = (LosQueueCB *)mq_id;
|
||||
|
||||
return (const char *)pstQueue->queueName;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -28,22 +28,20 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "los_config.h"
|
||||
#include "stdarg.h"
|
||||
#include "dirent.h"
|
||||
#include "sys/mount.h"
|
||||
#include "sys/statfs.h"
|
||||
#include "sys/stat.h"
|
||||
#include "unistd.h"
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef LOSCFG_LIBC_MUSL_FS
|
||||
#include "los_fs.h"
|
||||
#else
|
||||
#include "sys/stat.h"
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_LIBC_MUSL_FS
|
||||
int mount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data)
|
||||
@@ -161,6 +159,45 @@ ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
return LOS_Pwrite(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
int access(const char *path, int mode)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(path, &st) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if ((st.st_mode & S_IFDIR) || (st.st_mode & S_IFREG)) {
|
||||
return 0;
|
||||
}
|
||||
if ((mode & W_OK) && !(st.st_mode & S_IWRITE)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list vaList;
|
||||
|
||||
va_start(vaList, cmd);
|
||||
ret = OsFcntl(fd, cmd, vaList);
|
||||
va_end(vaList);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ioctl(int fd, int req, ...)
|
||||
{
|
||||
int ret;
|
||||
va_list vaList;
|
||||
|
||||
va_start(vaList, req);
|
||||
ret = OsIoctl(fd, req, vaList);
|
||||
va_end(vaList);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* #ifdef LOSCFG_FS_VFS */
|
||||
|
||||
int mount(const char *source, const char *target,
|
||||
@@ -275,4 +312,18 @@ ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int access(const char *path, int mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ioctl(int fd, int req, ...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2021-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:
|
||||
@@ -175,7 +175,8 @@ int gethostbyname2_r(const char * __restrict name, int af, struct hostent * __re
|
||||
int * __restrict h_errnop);
|
||||
struct hostent *gethostbyname2(const char *name, int af);
|
||||
int gethostbyaddr_r(const void * __restrict addr, __socklen_t len, int type, struct hostent * __restrict result_buf, \
|
||||
char * __restrict buf, size_t buflen, struct hostent ** __restrict result, int * __restrict h_errnop);
|
||||
char * __restrict buf, size_t buflen, struct hostent ** __restrict result, \
|
||||
int * __restrict h_errnop);
|
||||
int getservbyport_r(int port, const char * __restrict proto, struct servent * __restrict result_buf, \
|
||||
char * __restrict buf, size_t buflen, struct servent ** __restrict result);
|
||||
int getservbyname_r(const char *name, const char *proto, struct servent *result_buf, char *buf, size_t buflen, \
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _ADAPT_SYS_STAT_H
|
||||
#define _ADAPT_SYS_STAT_H
|
||||
|
||||
#include <sys/features.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define S_IFMT 0170000
|
||||
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFREG 0100000
|
||||
#define S_IFIFO 0010000
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFSOCK 0140000
|
||||
|
||||
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
|
||||
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
|
||||
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
|
||||
|
||||
#ifndef S_IRUSR
|
||||
#define S_ISUID 04000
|
||||
#define S_ISGID 02000
|
||||
#define S_ISVTX 01000
|
||||
#define S_IRUSR 0400
|
||||
#define S_IWUSR 0200
|
||||
#define S_IXUSR 0100
|
||||
#define S_IRWXU 0700
|
||||
#define S_IRGRP 0040
|
||||
#define S_IWGRP 0020
|
||||
#define S_IXGRP 0010
|
||||
#define S_IRWXG 0070
|
||||
#define S_IROTH 0004
|
||||
#define S_IWOTH 0002
|
||||
#define S_IXOTH 0001
|
||||
#define S_IRWXO 0007
|
||||
#endif
|
||||
|
||||
#define st_atime st_atim.tv_sec
|
||||
#define st_mtime st_mtim.tv_sec
|
||||
#define st_ctime st_ctim.tv_sec
|
||||
|
||||
struct stat {
|
||||
dev_t st_dev;
|
||||
int __st_dev_padding;
|
||||
long __st_ino_truncated;
|
||||
mode_t st_mode;
|
||||
nlink_t st_nlink;
|
||||
uid_t st_uid;
|
||||
gid_t st_gid;
|
||||
dev_t st_rdev;
|
||||
int __st_rdev_padding;
|
||||
off_t st_size;
|
||||
blksize_t st_blksize;
|
||||
blkcnt_t st_blocks;
|
||||
struct {
|
||||
long tv_sec;
|
||||
long tv_nsec;
|
||||
} __st_atim32, __st_mtim32, __st_ctim32;
|
||||
ino_t st_ino;
|
||||
struct timespec st_atim;
|
||||
struct timespec st_mtim;
|
||||
struct timespec st_ctim;
|
||||
};
|
||||
|
||||
int stat(const char *__restrict, struct stat *__restrict);
|
||||
int fstat(int, struct stat *);
|
||||
int mkdir(const char *, mode_t);
|
||||
|
||||
#if defined(_GNU_SOURCE)
|
||||
#define stat64 stat
|
||||
#define fstat64 fstat
|
||||
#define blkcnt64_t blkcnt_t
|
||||
#define fsblkcnt64_t fsblkcnt_t
|
||||
#define fsfilcnt64_t fsfilcnt_t
|
||||
#define ino64_t ino_t
|
||||
#define off64_t off_t
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_ADAPT_SYS_STAT_H */
|
||||
@@ -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
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user