Compare commits
28 Commits
master
...
OpenHarmon
Author | SHA1 | Date |
---|---|---|
|
ff96b1499d | |
|
e4bf00a5e8 | |
|
43c6a8056b | |
|
bbb1c73322 | |
|
cbf91caf0d | |
|
64da4a5fbc | |
|
49950a52d1 | |
|
77b1f175fc | |
|
d14a45a1c5 | |
|
860fa611ee | |
|
b59f3d871d | |
|
d264a032fc | |
|
110b201e69 | |
|
d5bc445a4e | |
|
00f7b6ac63 | |
|
2f6ae64adc | |
|
07f7213885 | |
|
c83efabbeb | |
|
02aaa768dc | |
|
b8f8715040 | |
|
a967903ae8 | |
|
af8c69507e | |
|
c9c8d68f5f | |
|
3dec8a92df | |
|
06631fce7d | |
|
6d3a950a21 | |
|
798fbd0212 | |
|
1a66fa3daf |
18
Kconfig
18
Kconfig
|
@ -335,6 +335,14 @@ config KERNEL_PM
|
||||||
Configuration item for low power frame tailoring.
|
Configuration item for low power frame tailoring.
|
||||||
If you wish to build LiteOS with support for power management.
|
If you wish to build LiteOS with support for power management.
|
||||||
|
|
||||||
|
config KERNEL_PM_IDLE
|
||||||
|
bool "Enable Power Management Idle"
|
||||||
|
default n
|
||||||
|
depends on KERNEL_PM
|
||||||
|
help
|
||||||
|
Configuration item for low power frame tailoring.
|
||||||
|
If you wish to build LiteOS with support for power management idle.
|
||||||
|
|
||||||
config KERNEL_PM_TASK_PTIORITY
|
config KERNEL_PM_TASK_PTIORITY
|
||||||
int "Power Management Task Priority"
|
int "Power Management Task Priority"
|
||||||
default 1
|
default 1
|
||||||
|
@ -513,6 +521,14 @@ config DEBUG_QUEUE
|
||||||
help
|
help
|
||||||
Answer Y to enable debug queue.
|
Answer Y to enable debug queue.
|
||||||
|
|
||||||
|
config MUTEX_CREATE_TRACE
|
||||||
|
bool "Enable Mutex Trace Debugging"
|
||||||
|
default n
|
||||||
|
depends on ARCH_ARM
|
||||||
|
depends on DEBUG_KERNEL
|
||||||
|
help
|
||||||
|
Answer Y to enable debug mutex trace.
|
||||||
|
|
||||||
config DEBUG_DEADLOCK
|
config DEBUG_DEADLOCK
|
||||||
bool "Enable Mutex Deadlock Debugging"
|
bool "Enable Mutex Deadlock Debugging"
|
||||||
default n
|
default n
|
||||||
|
@ -601,7 +617,7 @@ config VM_OVERLAP_CHECK
|
||||||
depends on DEBUG_VERSION && MEM_DEBUG
|
depends on DEBUG_VERSION && MEM_DEBUG
|
||||||
help
|
help
|
||||||
Answer Y to enable vm overlap check.
|
Answer Y to enable vm overlap check.
|
||||||
|
|
||||||
config TASK_MEM_USED
|
config TASK_MEM_USED
|
||||||
bool "Enable show task mem used or not"
|
bool "Enable show task mem used or not"
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
# provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
# to endorse or promote products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
import("//kernel/liteos_m/liteos.gni")
|
||||||
|
|
||||||
|
module_name = "arch"
|
||||||
|
kernel_module(module_name) {
|
||||||
|
sources = [
|
||||||
|
"los_context.c",
|
||||||
|
"los_dispatch.S",
|
||||||
|
"los_exc.S",
|
||||||
|
"los_interrupt.c",
|
||||||
|
"los_mpu.c",
|
||||||
|
"los_timer.c",
|
||||||
|
]
|
||||||
|
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "." ]
|
||||||
|
}
|
|
@ -62,6 +62,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
|
||||||
__asm("mrs %0, msp" : "=r" (msp));
|
__asm("mrs %0, msp" : "=r" (msp));
|
||||||
return msp;
|
return msp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC INLINE UINTPTR ArchLRGet(VOID)
|
||||||
|
{
|
||||||
|
UINTPTR lr;
|
||||||
|
__asm("mov %0, lr" : "=r" (lr));
|
||||||
|
return lr;
|
||||||
|
}
|
||||||
#elif defined(__CLANG_ARM) || defined(__GNUC__)
|
#elif defined(__CLANG_ARM) || defined(__GNUC__)
|
||||||
STATIC INLINE UINTPTR ArchSpGet(VOID)
|
STATIC INLINE UINTPTR ArchSpGet(VOID)
|
||||||
{
|
{
|
||||||
|
@ -83,6 +90,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
|
||||||
__asm volatile("mrs %0, msp" : "=r" (msp));
|
__asm volatile("mrs %0, msp" : "=r" (msp));
|
||||||
return msp;
|
return msp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC INLINE UINTPTR ArchLRGet(VOID)
|
||||||
|
{
|
||||||
|
UINTPTR lr;
|
||||||
|
__asm volatile("mov %0, lr" : "=r" (lr));
|
||||||
|
return lr;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Other platforms to be improved */
|
/* Other platforms to be improved */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,12 +40,13 @@
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
#include "cmsis_os2.h"
|
#include "los_sched.h"
|
||||||
#include "vfs_files.h"
|
#include "vfs_files.h"
|
||||||
#include "vfs_operations.h"
|
#include "vfs_operations.h"
|
||||||
#include "vfs_partition.h"
|
#include "vfs_partition.h"
|
||||||
#include "vfs_maps.h"
|
#include "vfs_maps.h"
|
||||||
#include "vfs_mount.h"
|
#include "vfs_mount.h"
|
||||||
|
#include "los_fs.h"
|
||||||
|
|
||||||
/* the max name length of different parts should not bigger than 32 */
|
/* the max name length of different parts should not bigger than 32 */
|
||||||
#define FS_DRIVE_NAME_MAX_LEN 32
|
#define FS_DRIVE_NAME_MAX_LEN 32
|
||||||
|
@ -73,7 +74,7 @@ static int FsLock(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct timespec absTimeout = {0};
|
struct timespec absTimeout = {0};
|
||||||
if (osKernelGetState() != osKernelRunning) {
|
if (!OsCheckKernelRunning()) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = clock_gettime(CLOCK_REALTIME, &absTimeout);
|
ret = clock_gettime(CLOCK_REALTIME, &absTimeout);
|
||||||
|
@ -88,7 +89,7 @@ static int FsLock(void)
|
||||||
|
|
||||||
static void FsUnlock(void)
|
static void FsUnlock(void)
|
||||||
{
|
{
|
||||||
if (osKernelGetState() != osKernelRunning) {
|
if (!OsCheckKernelRunning()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(void)pthread_mutex_unlock(&g_fatfsMutex);
|
(void)pthread_mutex_unlock(&g_fatfsMutex);
|
||||||
|
@ -244,7 +245,7 @@ char * GetLdPath(const char *source)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *volPath = g_volPath[partId];
|
char *volPath = g_volPath[partId];
|
||||||
char *ldPath = (char *)malloc(strlen(volPath) + LDPATH_PAD);
|
char *ldPath = (char *)LOSCFG_FS_MALLOC_HOOK(strlen(volPath) + LDPATH_PAD);
|
||||||
if (ldPath == NULL) {
|
if (ldPath == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +256,7 @@ char * GetLdPath(const char *source)
|
||||||
*ldPath = '/';
|
*ldPath = '/';
|
||||||
ret = strcpy_s(ldPath + 1, strlen(volPath)+1, volPath);
|
ret = strcpy_s(ldPath + 1, strlen(volPath)+1, volPath);
|
||||||
if (ret != EOK) {
|
if (ret != EOK) {
|
||||||
free(ldPath);
|
LOSCFG_FS_FREE_HOOK(ldPath);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +266,7 @@ char * GetLdPath(const char *source)
|
||||||
void PutLdPath(const char *ldPath)
|
void PutLdPath(const char *ldPath)
|
||||||
{
|
{
|
||||||
if (ldPath != NULL) {
|
if (ldPath != NULL) {
|
||||||
free((void *)ldPath);
|
LOSCFG_FS_FREE_HOOK((void *)ldPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,6 +283,12 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mountflags & MS_REMOUNT) {
|
||||||
|
ret = Remount(mp, mountflags);
|
||||||
|
FsUnlock();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
char *ldPath = GetLdPath(mp->mDev);
|
char *ldPath = GetLdPath(mp->mDev);
|
||||||
if (ldPath == NULL) {
|
if (ldPath == NULL) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
|
@ -289,12 +296,7 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
|
||||||
goto ERROUT;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mountflags & MS_REMOUNT) {
|
fs = (FATFS *)LOSCFG_FS_MALLOC_HOOK(sizeof(FATFS));
|
||||||
ret = Remount(mp, mountflags);
|
|
||||||
goto ERROUT;
|
|
||||||
}
|
|
||||||
|
|
||||||
fs = (FATFS *)malloc(sizeof(FATFS));
|
|
||||||
if (fs == NULL) {
|
if (fs == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
@ -315,7 +317,7 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
|
||||||
return (int)LOS_OK;
|
return (int)LOS_OK;
|
||||||
|
|
||||||
ERROUT:
|
ERROUT:
|
||||||
free(fs);
|
LOSCFG_FS_FREE_HOOK(fs);
|
||||||
mp->mData = NULL;
|
mp->mData = NULL;
|
||||||
PutLdPath(ldPath);
|
PutLdPath(ldPath);
|
||||||
FsUnlock();
|
FsUnlock();
|
||||||
|
@ -368,7 +370,7 @@ int FatfsUmount(struct MountPoint *mp)
|
||||||
ff_memfree(fatfs->win);
|
ff_memfree(fatfs->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(mp->mData);
|
LOSCFG_FS_FREE_HOOK(mp->mData);
|
||||||
mp->mData = NULL;
|
mp->mData = NULL;
|
||||||
|
|
||||||
ret = (int)LOS_OK;
|
ret = (int)LOS_OK;
|
||||||
|
@ -423,7 +425,7 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
|
||||||
ff_memfree(fatfs->win);
|
ff_memfree(fatfs->win);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(mp->mData);
|
LOSCFG_FS_FREE_HOOK(mp->mData);
|
||||||
mp->mData = NULL;
|
mp->mData = NULL;
|
||||||
|
|
||||||
ret = (int)LOS_OK;
|
ret = (int)LOS_OK;
|
||||||
|
@ -448,7 +450,7 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
|
||||||
|
|
||||||
fmode = FatFsGetMode(oflag);
|
fmode = FatFsGetMode(oflag);
|
||||||
|
|
||||||
fp = (FIL *)malloc(sizeof(FIL));
|
fp = (FIL *)LOSCFG_FS_MALLOC_HOOK(sizeof(FIL));
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
|
@ -457,7 +459,7 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
|
||||||
ret = FsLock();
|
ret = FsLock();
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
errno = ret;
|
errno = ret;
|
||||||
free(fp);
|
LOSCFG_FS_FREE_HOOK(fp);
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,14 +468,14 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
|
||||||
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
|
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
free(fp);
|
LOSCFG_FS_FREE_HOOK(fp);
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = f_open(fp, path, fmode);
|
res = f_open(fp, path, fmode);
|
||||||
if (res != FR_OK) {
|
if (res != FR_OK) {
|
||||||
PRINT_ERR("FAT open err 0x%x!\r\n", res);
|
PRINT_ERR("FAT open err 0x%x!\r\n", res);
|
||||||
free(fp);
|
LOSCFG_FS_FREE_HOOK(fp);
|
||||||
errno = FatfsErrno(res);
|
errno = FatfsErrno(res);
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
|
@ -517,7 +519,7 @@ int FatfsClose(struct File *file)
|
||||||
(void)ff_memfree(fp->buf);
|
(void)ff_memfree(fp->buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
free(file->fData);
|
LOSCFG_FS_FREE_HOOK(file->fData);
|
||||||
file->fData = NULL;
|
file->fData = NULL;
|
||||||
FsUnlock();
|
FsUnlock();
|
||||||
|
|
||||||
|
@ -832,7 +834,7 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
|
||||||
goto ERROUT;
|
goto ERROUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
dp = (DIR *)malloc(sizeof(DIR));
|
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
|
||||||
if (dp == NULL) {
|
if (dp == NULL) {
|
||||||
errno = ENOENT;
|
errno = ENOENT;
|
||||||
goto ERROUT;
|
goto ERROUT;
|
||||||
|
@ -866,7 +868,7 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
|
||||||
|
|
||||||
ERROUT:
|
ERROUT:
|
||||||
if (dp != NULL) {
|
if (dp != NULL) {
|
||||||
free(dp);
|
LOSCFG_FS_FREE_HOOK(dp);
|
||||||
}
|
}
|
||||||
FsUnlock();
|
FsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
|
@ -938,7 +940,7 @@ int FatfsClosedir(struct Dir *dir)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(dir->dData);
|
LOSCFG_FS_FREE_HOOK(dir->dData);
|
||||||
dir->dData = NULL;
|
dir->dData = NULL;
|
||||||
FsUnlock();
|
FsUnlock();
|
||||||
|
|
||||||
|
|
|
@ -39,11 +39,11 @@
|
||||||
#include "vfs_maps.h"
|
#include "vfs_maps.h"
|
||||||
#include "vfs_mount.h"
|
#include "vfs_mount.h"
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
|
#include "los_fs.h"
|
||||||
|
|
||||||
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 PartitionCfg g_partitionCfg;
|
||||||
static struct lfs_config g_lfsCfg;
|
|
||||||
static struct DeviceDesc *g_lfsDevice = NULL;
|
static struct DeviceDesc *g_lfsDevice = NULL;
|
||||||
|
|
||||||
static uint32_t LfsGetStartAddr(int partition)
|
static uint32_t LfsGetStartAddr(int partition)
|
||||||
|
@ -177,6 +177,7 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
lfs_t *mountHdl = NULL;
|
lfs_t *mountHdl = NULL;
|
||||||
|
struct lfs_config *cfg = NULL;
|
||||||
|
|
||||||
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
|
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
|
@ -184,26 +185,33 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
mountHdl = (lfs_t *)malloc(sizeof(lfs_t));
|
if (mountflags & MS_REMOUNT) {
|
||||||
|
errno = ENOSYS;
|
||||||
|
ret = (int)LOS_NOK;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
|
mountHdl = (lfs_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||||
if (mountHdl == NULL) {
|
if (mountHdl == NULL) {
|
||||||
errno = ENODEV;
|
errno = ENODEV;
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
goto errout;
|
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;
|
mp->mData = (void *)mountHdl;
|
||||||
|
cfg = (void *)((UINTPTR)mountHdl + sizeof(lfs_t));
|
||||||
|
|
||||||
LfsConfigAdapter((struct PartitionCfg *)data, &g_lfsCfg);
|
LfsConfigAdapter((struct PartitionCfg *)data, cfg);
|
||||||
|
|
||||||
ret = lfs_mount((lfs_t *)mp->mData, &g_lfsCfg);
|
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
ret = lfs_format((lfs_t *)mp->mData, &g_lfsCfg);
|
ret = lfs_format((lfs_t *)mp->mData, cfg);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = lfs_mount((lfs_t *)mp->mData, &g_lfsCfg);
|
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
free(mountHdl);
|
LOSCFG_FS_FREE_HOOK(mountHdl);
|
||||||
errno = LittlefsErrno(ret);
|
errno = LittlefsErrno(ret);
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +240,7 @@ int LfsUmount(struct MountPoint *mp)
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(mp->mData);
|
LOSCFG_FS_FREE_HOOK(mp->mData);
|
||||||
mp->mData = NULL;
|
mp->mData = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +334,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
|
||||||
}
|
}
|
||||||
|
|
||||||
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
|
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
|
||||||
lfs_dir_t *dirInfo = (lfs_dir_t *)malloc(sizeof(lfs_dir_t));
|
lfs_dir_t *dirInfo = (lfs_dir_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_dir_t));
|
||||||
if (dirInfo == NULL) {
|
if (dirInfo == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
|
@ -335,7 +343,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
|
||||||
(void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t));
|
(void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t));
|
||||||
ret = lfs_dir_open(lfs, dirInfo, dirName);
|
ret = lfs_dir_open(lfs, dirInfo, dirName);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
free(dirInfo);
|
LOSCFG_FS_FREE_HOOK(dirInfo);
|
||||||
errno = LittlefsErrno(ret);
|
errno = LittlefsErrno(ret);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +422,7 @@ int LfsClosedir(struct Dir *dir)
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(dirInfo);
|
LOSCFG_FS_FREE_HOOK(dirInfo);
|
||||||
dir->dData = NULL;
|
dir->dData = NULL;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -431,7 +439,7 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
lfsHandle = (lfs_file_t *)malloc(sizeof(lfs_file_t));
|
lfsHandle = (lfs_file_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_file_t));
|
||||||
if (lfsHandle == NULL) {
|
if (lfsHandle == NULL) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
|
@ -440,7 +448,7 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
|
||||||
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
|
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
|
||||||
ret = lfs_file_open((lfs_t *)file->fMp->mData, lfsHandle, pathName, lfsOpenFlag);
|
ret = lfs_file_open((lfs_t *)file->fMp->mData, lfsHandle, pathName, lfsOpenFlag);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
free(lfsHandle);
|
LOSCFG_FS_FREE_HOOK(lfsHandle);
|
||||||
errno = LittlefsErrno(ret);
|
errno = LittlefsErrno(ret);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
@ -568,7 +576,7 @@ int LfsClose(struct File *file)
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(file->fData);
|
LOSCFG_FS_FREE_HOOK(file->fData);
|
||||||
file->fData = NULL;
|
file->fData = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -655,12 +663,13 @@ int LfsFormat(const char *partName, void *privData)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
lfs_t lfs = {0};
|
lfs_t lfs = {0};
|
||||||
|
struct lfs_config cfg = {0};
|
||||||
|
|
||||||
(void)partName;
|
(void)partName;
|
||||||
|
|
||||||
LfsConfigAdapter((struct PartitionCfg *)privData, &g_lfsCfg);
|
LfsConfigAdapter((struct PartitionCfg *)privData, &cfg);
|
||||||
|
|
||||||
ret = lfs_format(&lfs, &g_lfsCfg);
|
ret = lfs_format(&lfs, &cfg);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
errno = LittlefsErrno(ret);
|
errno = LittlefsErrno(ret);
|
||||||
ret = (int)LOS_NOK;
|
ret = (int)LOS_NOK;
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#define _LOS_FS_H_
|
#define _LOS_FS_H_
|
||||||
|
|
||||||
#include "los_config.h"
|
#include "los_config.h"
|
||||||
|
#include "los_memory.h"
|
||||||
#include "dirent.h"
|
#include "dirent.h"
|
||||||
#include "sys/mount.h"
|
#include "sys/mount.h"
|
||||||
#include "sys/statfs.h"
|
#include "sys/statfs.h"
|
||||||
|
@ -52,6 +53,14 @@ extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#ifndef LOSCFG_FS_MALLOC_HOOK
|
||||||
|
#define LOSCFG_FS_MALLOC_HOOK(size) LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, size)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef LOSCFG_FS_FREE_HOOK
|
||||||
|
#define LOSCFG_FS_FREE_HOOK(ptr) LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, ptr)
|
||||||
|
#endif
|
||||||
|
|
||||||
int LOS_Open(const char *path, int flags, ...);
|
int LOS_Open(const char *path, int flags, ...);
|
||||||
int LOS_Close(int fd);
|
int LOS_Close(int fd);
|
||||||
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
|
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
|
||||||
|
|
|
@ -88,4 +88,9 @@
|
||||||
|
|
||||||
#define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR
|
#define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR
|
||||||
|
|
||||||
|
/* max number of open directories */
|
||||||
|
#ifndef LOSCFG_MAX_OPEN_DIRS
|
||||||
|
#define LOSCFG_MAX_OPEN_DIRS 10
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "fcntl.h"
|
#include "fcntl.h"
|
||||||
#include "los_mux.h"
|
#include "los_mux.h"
|
||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
#include "los_sched.h"
|
||||||
#include "limits.h"
|
#include "limits.h"
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "vfs_config.h"
|
#include "vfs_config.h"
|
||||||
|
@ -85,7 +86,7 @@ int PollQueryFd(int fd, struct PollTable *table)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FREE_AND_SET_NULL(ptr) do { \
|
#define FREE_AND_SET_NULL(ptr) do { \
|
||||||
free(ptr); \
|
LOSCFG_FS_FREE_HOOK(ptr); \
|
||||||
ptr = NULL; \
|
ptr = NULL; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
@ -93,9 +94,13 @@ int PollQueryFd(int fd, struct PollTable *table)
|
||||||
#define IOV_MAX_CNT 4
|
#define IOV_MAX_CNT 4
|
||||||
|
|
||||||
UINT32 g_fsMutex;
|
UINT32 g_fsMutex;
|
||||||
|
static UINT32 g_dirNum = 0;
|
||||||
|
|
||||||
int VfsLock(void)
|
int VfsLock(void)
|
||||||
{
|
{
|
||||||
|
if (!OsCheckKernelRunning()) {
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
|
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
|
||||||
PRINT_ERR("VfsLock failed!");
|
PRINT_ERR("VfsLock failed!");
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
|
@ -106,6 +111,9 @@ int VfsLock(void)
|
||||||
|
|
||||||
void VfsUnlock(void)
|
void VfsUnlock(void)
|
||||||
{
|
{
|
||||||
|
if (!OsCheckKernelRunning()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
(void)LOS_MuxPost(g_fsMutex);
|
(void)LOS_MuxPost(g_fsMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,13 +144,13 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
|
||||||
|
|
||||||
offset = strlen("///") + 1; // three '/' and one '\0'
|
offset = strlen("///") + 1; // three '/' and one '\0'
|
||||||
size_t tmpLen = strlen(cwd) + strlen(path) + offset;
|
size_t tmpLen = strlen(cwd) + strlen(path) + offset;
|
||||||
char *tmpBuf = (char *)malloc(tmpLen);
|
char *tmpBuf = (char *)LOSCFG_FS_MALLOC_HOOK(tmpLen);
|
||||||
if (tmpBuf == NULL) {
|
if (tmpBuf == NULL) {
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-1 == sprintf_s(tmpBuf, tmpLen, "/%s/%s/", cwd, path)) {
|
if (-1 == sprintf_s(tmpBuf, tmpLen, "/%s/%s/", cwd, path)) {
|
||||||
free(tmpBuf);
|
LOSCFG_FS_FREE_HOOK(tmpBuf);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +159,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
|
||||||
offset = strlen("/./") - 1;
|
offset = strlen("/./") - 1;
|
||||||
while ((p = strstr(tmpBuf, "/./")) != NULL) {
|
while ((p = strstr(tmpBuf, "/./")) != NULL) {
|
||||||
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
|
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
|
||||||
free(tmpBuf);
|
LOSCFG_FS_FREE_HOOK(tmpBuf);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +167,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
|
||||||
/* replace // to / */
|
/* replace // to / */
|
||||||
while ((p = strstr(tmpBuf, "//")) != NULL) {
|
while ((p = strstr(tmpBuf, "//")) != NULL) {
|
||||||
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + 1, tmpLen - (p - tmpBuf) - 1)) {
|
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + 1, tmpLen - (p - tmpBuf) - 1)) {
|
||||||
free(tmpBuf);
|
LOSCFG_FS_FREE_HOOK(tmpBuf);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +180,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
|
||||||
--start;
|
--start;
|
||||||
}
|
}
|
||||||
if (EOK != memmove_s(start, tmpLen - (start - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
|
if (EOK != memmove_s(start, tmpLen - (start - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
|
||||||
free(tmpBuf);
|
LOSCFG_FS_FREE_HOOK(tmpBuf);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,23 +192,24 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!buf) || (bufSize == 0)) {
|
if ((!buf) || (bufSize == 0)) {
|
||||||
free(tmpBuf);
|
LOSCFG_FS_FREE_HOOK(tmpBuf);
|
||||||
return totalLen;
|
return totalLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EOK != memcpy_s(buf, bufSize, tmpBuf, (((totalLen + 1) > bufSize) ? bufSize : (totalLen + 1)))) {
|
if (EOK != memcpy_s(buf, bufSize, tmpBuf, (((totalLen + 1) > bufSize) ? bufSize : (totalLen + 1)))) {
|
||||||
free(tmpBuf);
|
LOSCFG_FS_FREE_HOOK(tmpBuf);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[bufSize - 1] = 0;
|
buf[bufSize - 1] = 0;
|
||||||
free(tmpBuf);
|
LOSCFG_FS_FREE_HOOK(tmpBuf);
|
||||||
return totalLen;
|
return totalLen;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int VfsOpen(const char *path, int flags)
|
static int VfsOpen(const char *path, int flags)
|
||||||
{
|
{
|
||||||
|
size_t len;
|
||||||
struct File *file = NULL;
|
struct File *file = NULL;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
const char *pathInMp = NULL;
|
const char *pathInMp = NULL;
|
||||||
|
@ -240,13 +249,15 @@ static int VfsOpen(const char *path, int flags)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->fullPath = strdup(path);
|
len = strlen(path) + 1;
|
||||||
|
file->fullPath = LOSCFG_FS_MALLOC_HOOK(len);
|
||||||
if (file->fullPath == NULL) {
|
if (file->fullPath == NULL) {
|
||||||
VFS_ERRNO_SET(ENOMEM);
|
VFS_ERRNO_SET(ENOMEM);
|
||||||
VfsFilePut(file);
|
VfsFilePut(file);
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
(void)strcpy_s((char *)file->fullPath, len, path);
|
||||||
|
|
||||||
file->fFlags = (UINT32)flags;
|
file->fFlags = (UINT32)flags;
|
||||||
file->fOffset = 0;
|
file->fOffset = 0;
|
||||||
|
@ -337,7 +348,7 @@ static int VfsClose(int fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->fullPath != NULL) {
|
if (file->fullPath != NULL) {
|
||||||
free((void *)file->fullPath);
|
LOSCFG_FS_FREE_HOOK((void *)file->fullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
VfsDetachFile(file);
|
VfsDetachFile(file);
|
||||||
|
@ -644,7 +655,7 @@ static DIR *VfsOpendir(const char *path)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dir = (struct Dir *)malloc(sizeof(struct Dir));
|
dir = (struct Dir *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct Dir));
|
||||||
if (dir == NULL) {
|
if (dir == NULL) {
|
||||||
VFS_ERRNO_SET(ENOMEM);
|
VFS_ERRNO_SET(ENOMEM);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -652,7 +663,14 @@ static DIR *VfsOpendir(const char *path)
|
||||||
|
|
||||||
if (VfsLock() != LOS_OK) {
|
if (VfsLock() != LOS_OK) {
|
||||||
VFS_ERRNO_SET(EAGAIN);
|
VFS_ERRNO_SET(EAGAIN);
|
||||||
free(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_dirNum >= LOSCFG_MAX_OPEN_DIRS) {
|
||||||
|
VFS_ERRNO_SET(ENFILE);
|
||||||
|
VfsUnlock();
|
||||||
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,14 +678,14 @@ static DIR *VfsOpendir(const char *path)
|
||||||
if ((mp == NULL) || (pathInMp == NULL)) {
|
if ((mp == NULL) || (pathInMp == NULL)) {
|
||||||
VFS_ERRNO_SET(ENOENT);
|
VFS_ERRNO_SET(ENOENT);
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
free(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mp->mFs->fsFops->opendir == NULL) {
|
if (mp->mFs->fsFops->opendir == NULL) {
|
||||||
VFS_ERRNO_SET(ENOTSUP);
|
VFS_ERRNO_SET(ENOTSUP);
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
free(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,8 +695,9 @@ static DIR *VfsOpendir(const char *path)
|
||||||
ret = (UINT32)mp->mFs->fsFops->opendir(dir, pathInMp);
|
ret = (UINT32)mp->mFs->fsFops->opendir(dir, pathInMp);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
mp->mRefs++;
|
mp->mRefs++;
|
||||||
|
g_dirNum++;
|
||||||
} else {
|
} else {
|
||||||
free(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
dir = NULL;
|
dir = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,12 +761,13 @@ static int VfsClosedir(DIR *d)
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
mp->mRefs--;
|
mp->mRefs--;
|
||||||
|
g_dirNum--;
|
||||||
} else {
|
} else {
|
||||||
VFS_ERRNO_SET(EBADF);
|
VFS_ERRNO_SET(EBADF);
|
||||||
}
|
}
|
||||||
|
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
free(dir);
|
LOSCFG_FS_FREE_HOOK(dir);
|
||||||
dir = NULL;
|
dir = NULL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -920,7 +940,7 @@ int LOS_Open(const char *path, int flags, ...)
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *canonicalPath = (char *)malloc(pathLen);
|
char *canonicalPath = (char *)LOSCFG_FS_MALLOC_HOOK(pathLen);
|
||||||
if (!canonicalPath) {
|
if (!canonicalPath) {
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
|
@ -1235,7 +1255,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
totalLen = bufLen * sizeof(char);
|
totalLen = bufLen * sizeof(char);
|
||||||
buf = (char *)malloc(totalLen);
|
buf = (char *)LOSCFG_FS_MALLOC_HOOK(totalLen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
@ -1252,7 +1272,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
|
||||||
size_t lenToRead = totalLen < bytesToRead ? totalLen : bytesToRead;
|
size_t lenToRead = totalLen < bytesToRead ? totalLen : bytesToRead;
|
||||||
ret = memcpy_s(readBuf, bytesToRead, curBuf, lenToRead);
|
ret = memcpy_s(readBuf, bytesToRead, curBuf, lenToRead);
|
||||||
if (ret != EOK) {
|
if (ret != EOK) {
|
||||||
free(buf);
|
LOSCFG_FS_FREE_HOOK(buf);
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
if (totalLen < (size_t)bytesToRead) {
|
if (totalLen < (size_t)bytesToRead) {
|
||||||
|
@ -1261,7 +1281,7 @@ ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt)
|
||||||
curBuf += bytesToRead;
|
curBuf += bytesToRead;
|
||||||
totalLen -= bytesToRead;
|
totalLen -= bytesToRead;
|
||||||
}
|
}
|
||||||
free(buf);
|
LOSCFG_FS_FREE_HOOK(buf);
|
||||||
return totalBytesRead;
|
return totalBytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,7 +1313,7 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
totalLen = bufLen * sizeof(char);
|
totalLen = bufLen * sizeof(char);
|
||||||
buf = (char *)malloc(totalLen);
|
buf = (char *)LOSCFG_FS_MALLOC_HOOK(totalLen);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
@ -1306,7 +1326,7 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
|
||||||
}
|
}
|
||||||
ret = memcpy_s(curBuf, totalLen, writeBuf, bytesToWrite);
|
ret = memcpy_s(curBuf, totalLen, writeBuf, bytesToWrite);
|
||||||
if (ret != EOK) {
|
if (ret != EOK) {
|
||||||
free(buf);
|
LOSCFG_FS_FREE_HOOK(buf);
|
||||||
return (ssize_t)LOS_NOK;
|
return (ssize_t)LOS_NOK;
|
||||||
}
|
}
|
||||||
curBuf += bytesToWrite;
|
curBuf += bytesToWrite;
|
||||||
|
@ -1314,7 +1334,7 @@ ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
totalBytesWritten = write(fd, buf, bufLen);
|
totalBytesWritten = write(fd, buf, bufLen);
|
||||||
free(buf);
|
LOSCFG_FS_FREE_HOOK(buf);
|
||||||
|
|
||||||
return totalBytesWritten;
|
return totalBytesWritten;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
|
#include "los_fs.h"
|
||||||
|
|
||||||
struct FsMap *g_fsMap = NULL;
|
struct FsMap *g_fsMap = NULL;
|
||||||
|
|
||||||
|
@ -57,22 +58,25 @@ struct FsMap *VfsFsMapGet(const char *fsType)
|
||||||
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
|
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
|
||||||
struct FileOps *fsFops, struct FsManagement *fsMgt)
|
struct FileOps *fsFops, struct FsManagement *fsMgt)
|
||||||
{
|
{
|
||||||
|
size_t len;
|
||||||
if ((fsMops == NULL) || (fsFops == NULL)) {
|
if ((fsMops == NULL) || (fsFops == NULL)) {
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FsMap *newfs = (struct FsMap *)malloc(sizeof(struct FsMap));
|
struct FsMap *newfs = (struct FsMap *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct FsMap));
|
||||||
if (newfs == NULL) {
|
if (newfs == NULL) {
|
||||||
PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType);
|
PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType);
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
|
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
|
||||||
|
|
||||||
newfs->fsType = strdup(fsType);
|
len = strlen(fsType) + 1;
|
||||||
|
newfs->fsType = LOSCFG_FS_MALLOC_HOOK(len);
|
||||||
if (newfs->fsType == NULL) {
|
if (newfs->fsType == NULL) {
|
||||||
free(newfs);
|
LOSCFG_FS_FREE_HOOK(newfs);
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
(void)strcpy_s((char *)newfs->fsType, len, fsType);
|
||||||
|
|
||||||
newfs->fsMops = fsMops;
|
newfs->fsMops = fsMops;
|
||||||
newfs->fsFops = fsFops;
|
newfs->fsFops = fsFops;
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "vfs_config.h"
|
#include "vfs_config.h"
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
#include "errno.h"
|
||||||
|
#include "securec.h"
|
||||||
#include "vfs_operations.h"
|
#include "vfs_operations.h"
|
||||||
#include "los_compiler.h"
|
#include "los_compiler.h"
|
||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
@ -122,14 +124,67 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
|
||||||
return bestMp;
|
return bestMp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC struct MountPoint *VfsMountPointInit(const char *target, const char *fsType, unsigned long mountflags)
|
||||||
|
{
|
||||||
|
struct MountPoint *mp = NULL;
|
||||||
|
const char *pathInMp = NULL;
|
||||||
|
struct FsMap *mFs = NULL;
|
||||||
|
|
||||||
|
/* find mp by target, to see if it was mounted */
|
||||||
|
mp = VfsMpFind(target, &pathInMp);
|
||||||
|
if (mp != NULL && pathInMp != NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find fsMap coresponding to the fsType */
|
||||||
|
mFs = VfsFsMapGet(fsType);
|
||||||
|
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mp = (struct MountPoint *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct MountPoint));
|
||||||
|
if (mp == NULL) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC int VfsRemount(const char *source ,const char *target,
|
||||||
|
const char *fsType, unsigned long mountflags,
|
||||||
|
const void *data)
|
||||||
|
{
|
||||||
|
(VOID)source;
|
||||||
|
(VOID)fsType;
|
||||||
|
struct MountPoint *mp;
|
||||||
|
|
||||||
|
mp = VfsMpFind(target, NULL);
|
||||||
|
if (mp == NULL) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return (int)LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOS_ASSERT(mp->mFs != NULL);
|
||||||
|
LOS_ASSERT(mp->mFs->fsMops != NULL);
|
||||||
|
LOS_ASSERT(mp->mFs->fsMops->mount != NULL);
|
||||||
|
|
||||||
|
return mp->mFs->fsMops->mount(mp, mountflags, data);
|
||||||
|
}
|
||||||
|
|
||||||
int LOS_FsMount(const char *source, const char *target,
|
int LOS_FsMount(const char *source, const char *target,
|
||||||
const char *fsType, unsigned long mountflags,
|
const char *fsType, unsigned long mountflags,
|
||||||
const void *data)
|
const void *data)
|
||||||
{
|
{
|
||||||
|
size_t len;
|
||||||
int ret;
|
int ret;
|
||||||
struct MountPoint *mp = NULL;
|
struct MountPoint *mp = NULL;
|
||||||
struct FsMap *mFs = NULL;
|
|
||||||
const char *pathInMp = NULL;
|
|
||||||
|
|
||||||
/* target must begin with '/', for example /system, /data, etc. */
|
/* target must begin with '/', for example /system, /data, etc. */
|
||||||
if ((target == NULL) || (target[0] != '/')) {
|
if ((target == NULL) || (target[0] != '/')) {
|
||||||
|
@ -137,36 +192,36 @@ int LOS_FsMount(const char *source, const char *target,
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)VfsLock();
|
(void)VfsLock();
|
||||||
/* find mp by target, to see if it was mounted */
|
|
||||||
mp = VfsMpFind(target, &pathInMp);
|
if (mountflags & MS_REMOUNT) {
|
||||||
if (mp != NULL && pathInMp != NULL) {
|
ret = VfsRemount(source, target, fsType, mountflags, data);
|
||||||
goto errout;
|
VfsUnlock();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find fsMap coresponding to the fsType */
|
mp = VfsMountPointInit(target, fsType, mountflags);
|
||||||
mFs = VfsFsMapGet(fsType);
|
|
||||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
|
||||||
goto errout;
|
|
||||||
}
|
|
||||||
|
|
||||||
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
|
|
||||||
if (mp == NULL) {
|
if (mp == NULL) {
|
||||||
goto errout;
|
VfsUnlock();
|
||||||
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp->mFs = mFs;
|
|
||||||
mp->mDev = NULL;
|
|
||||||
if (source != NULL) {
|
if (source != NULL) {
|
||||||
mp->mDev = strdup(source);
|
len = strlen(source) + 1;
|
||||||
|
mp->mDev = LOSCFG_FS_MALLOC_HOOK(len);
|
||||||
if (mp->mDev == NULL) {
|
if (mp->mDev == NULL) {
|
||||||
goto errout;
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
|
VfsUnlock();
|
||||||
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
(void)strcpy_s((char *)mp->mDev, len, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp->mPath = strdup(target);
|
len = strlen(target) + 1;
|
||||||
|
mp->mPath = LOSCFG_FS_MALLOC_HOOK(len);
|
||||||
if (mp->mPath == NULL) {
|
if (mp->mPath == NULL) {
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
(void)strcpy_s((char *)mp->mPath, len, target);
|
||||||
|
|
||||||
ret = mp->mFs->fsMops->mount(mp, mountflags, data);
|
ret = mp->mFs->fsMops->mount(mp, mountflags, data);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -174,18 +229,15 @@ int LOS_FsMount(const char *source, const char *target,
|
||||||
PRINT_ERR("mount failed, target %s.\n", target);
|
PRINT_ERR("mount failed, target %s.\n", target);
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
mp->mRefs = 0;
|
|
||||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
|
||||||
mp->mFs->fsRefs++;
|
|
||||||
mp->mNext = g_mountPoints;
|
|
||||||
g_mountPoints = mp;
|
g_mountPoints = mp;
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
||||||
errout:
|
errout:
|
||||||
free((void *)mp->mPath);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
|
||||||
free((void *)mp->mDev);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
||||||
free(mp);
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
@ -220,9 +272,9 @@ int LOS_FsUmount(const char *target)
|
||||||
/* delete mp from mount list */
|
/* delete mp from mount list */
|
||||||
MpDeleteFromList(mp);
|
MpDeleteFromList(mp);
|
||||||
mp->mFs->fsRefs--;
|
mp->mFs->fsRefs--;
|
||||||
free((void *)mp->mPath);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
|
||||||
free((void *)mp->mDev);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
||||||
free(mp);
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
|
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
@ -280,9 +332,9 @@ int LOS_FsUmount2(const char *target, int flag)
|
||||||
/* delete mp from mount list */
|
/* delete mp from mount list */
|
||||||
MpDeleteFromList(mp);
|
MpDeleteFromList(mp);
|
||||||
mp->mFs->fsRefs--;
|
mp->mFs->fsRefs--;
|
||||||
free((void *)mp->mPath);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
|
||||||
free((void *)mp->mDev);
|
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
|
||||||
free(mp);
|
LOSCFG_FS_FREE_HOOK(mp);
|
||||||
|
|
||||||
VfsUnlock();
|
VfsUnlock();
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
|
@ -77,6 +77,7 @@ struct DeviceDesc *getDeviceList(VOID)
|
||||||
static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
||||||
int partNum)
|
int partNum)
|
||||||
{
|
{
|
||||||
|
size_t len;
|
||||||
struct DeviceDesc *prev = NULL;
|
struct DeviceDesc *prev = NULL;
|
||||||
for (prev = g_deviceList; prev != NULL; prev = prev->dNext) {
|
for (prev = g_deviceList; prev != NULL; prev = prev->dNext) {
|
||||||
if (strcmp(prev->dDev, dev) == 0) {
|
if (strcmp(prev->dDev, dev) == 0) {
|
||||||
|
@ -90,21 +91,25 @@ static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = (struct DeviceDesc *)malloc(sizeof(struct DeviceDesc));
|
prev = (struct DeviceDesc *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct DeviceDesc));
|
||||||
if (prev == NULL) {
|
if (prev == NULL) {
|
||||||
errno = -ENOMEM;
|
errno = -ENOMEM;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
prev->dDev = strdup(dev);
|
len = strlen(dev) + 1;
|
||||||
prev->dFsType = strdup(fsType);
|
prev->dDev = LOSCFG_FS_MALLOC_HOOK(len);
|
||||||
prev->dAddrArray = (int *)malloc(partNum * sizeof(int));
|
len = strlen(fsType) + 1;
|
||||||
|
prev->dFsType = LOSCFG_FS_MALLOC_HOOK(len);
|
||||||
|
prev->dAddrArray = (int *)LOSCFG_FS_MALLOC_HOOK(partNum * sizeof(int));
|
||||||
if (prev->dDev == NULL || prev->dFsType == NULL || prev->dAddrArray == NULL) {
|
if (prev->dDev == NULL || prev->dFsType == NULL || prev->dAddrArray == NULL) {
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
(void)strcpy_s((char *)prev->dDev, len, dev);
|
||||||
|
(void)strcpy_s((char *)prev->dFsType, len, fsType);
|
||||||
(void)memcpy_s(prev->dAddrArray, partNum * sizeof(int), addrArray, partNum * sizeof(int));
|
(void)memcpy_s(prev->dAddrArray, partNum * sizeof(int), addrArray, partNum * sizeof(int));
|
||||||
|
|
||||||
if (lengthArray != NULL) {
|
if (lengthArray != NULL) {
|
||||||
prev->dLengthArray = (int *)malloc(partNum * sizeof(int));
|
prev->dLengthArray = (int *)LOSCFG_FS_MALLOC_HOOK(partNum * sizeof(int));
|
||||||
if (prev->dLengthArray == NULL) {
|
if (prev->dLengthArray == NULL) {
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
@ -117,19 +122,19 @@ static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
errout:
|
errout:
|
||||||
if (prev->dDev != NULL) {
|
if (prev->dDev != NULL) {
|
||||||
free((void *)prev->dDev);
|
LOSCFG_FS_FREE_HOOK((void *)prev->dDev);
|
||||||
}
|
}
|
||||||
if (prev->dFsType != NULL) {
|
if (prev->dFsType != NULL) {
|
||||||
free((void *)prev->dFsType);
|
LOSCFG_FS_FREE_HOOK((void *)prev->dFsType);
|
||||||
}
|
}
|
||||||
if (prev->dAddrArray != NULL) {
|
if (prev->dAddrArray != NULL) {
|
||||||
free((void *)prev->dAddrArray);
|
LOSCFG_FS_FREE_HOOK((void *)prev->dAddrArray);
|
||||||
}
|
}
|
||||||
if (prev->dLengthArray != NULL) {
|
if (prev->dLengthArray != NULL) {
|
||||||
free((void *)prev->dLengthArray);
|
LOSCFG_FS_FREE_HOOK((void *)prev->dLengthArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(prev);
|
LOSCFG_FS_FREE_HOOK(prev);
|
||||||
errno = -ENOMEM;
|
errno = -ENOMEM;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
@ -160,8 +165,7 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
|
||||||
format is not allowed when the device has been mounted. */
|
format is not allowed when the device has been mounted. */
|
||||||
struct MountPoint *iter = NULL;
|
struct MountPoint *iter = NULL;
|
||||||
LOS_MP_FOR_EACH_ENTRY(iter) {
|
LOS_MP_FOR_EACH_ENTRY(iter) {
|
||||||
if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) &&
|
if ((iter->mPath != NULL) && (strcmp(iter->mPath, partName) == 0)) {
|
||||||
strcmp(iter->mFs->fsType, fsType) == 0) {
|
|
||||||
errno = EBUSY;
|
errno = EBUSY;
|
||||||
return (int)LOS_NOK;
|
return (int)LOS_NOK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,4 +240,7 @@
|
||||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define LWIP_SOCKET_IOCTL 0
|
||||||
|
#define LWIP_SOCKET_FCNTL 0
|
||||||
|
|
||||||
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
||||||
|
|
|
@ -211,6 +211,7 @@ int close(int fd)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_SOCKET_IOCTL
|
||||||
#ifdef LWIP_SOCKET_IOCTL_FUNC
|
#ifdef LWIP_SOCKET_IOCTL_FUNC
|
||||||
int ioctl(int fd, int req, ...)
|
int ioctl(int fd, int req, ...)
|
||||||
{
|
{
|
||||||
|
@ -222,7 +223,9 @@ int ioctl(int fd, int req, ...)
|
||||||
return lwip_ioctl(fd, (long)req, (void *)arg);
|
return lwip_ioctl(fd, (long)req, (void *)arg);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_SOCKET_FCNTL
|
||||||
#ifdef LWIP_SOCKET_FCNTL_FUNC
|
#ifdef LWIP_SOCKET_FCNTL_FUNC
|
||||||
int fcntl(int fd, int cmd, ...)
|
int fcntl(int fd, int cmd, ...)
|
||||||
{
|
{
|
||||||
|
@ -234,6 +237,7 @@ int fcntl(int fd, int cmd, ...)
|
||||||
return lwip_fcntl(fd, cmd, val);
|
return lwip_fcntl(fd, cmd, val);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LWIP_SOCKET_SELECT
|
#if LWIP_SOCKET_SELECT
|
||||||
#ifdef LWIP_SOCKET_SELECT_FUNC
|
#ifdef LWIP_SOCKET_SELECT_FUNC
|
||||||
|
|
|
@ -130,7 +130,7 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
||||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||||
|
|
||||||
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL) ||
|
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL) ||
|
||||||
(pm->pmMode == LOS_SYS_NORMAL_SLEEP)) {
|
(pm->sysMode == LOS_SYS_NORMAL_SLEEP)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +264,7 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||||
|
|
||||||
if (pm->sysctrl->suspendCheck != NULL) {
|
if (pm->sysctrl->suspendCheck != NULL) {
|
||||||
pm->sysctrl->suspendCheck(mode);
|
pm->sysctrl->suspendCheck(mode);
|
||||||
|
pm->sysMode = pm->pmMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
tickTimerStop = OsPmTickTimerStop(pm);
|
tickTimerStop = OsPmTickTimerStop(pm);
|
||||||
|
|
|
@ -42,6 +42,9 @@
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
#include "los_timer.h"
|
#include "los_timer.h"
|
||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
#include "los_arch.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "securec.h"
|
#include "securec.h"
|
||||||
|
@ -1002,6 +1005,10 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
UINT32 muxId;
|
UINT32 muxId;
|
||||||
|
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
UINTPTR regLR = ArchLRGet();
|
||||||
|
#endif
|
||||||
|
|
||||||
UNUSED(attr);
|
UNUSED(attr);
|
||||||
|
|
||||||
if (OS_INT_ACTIVE) {
|
if (OS_INT_ACTIVE) {
|
||||||
|
@ -1010,6 +1017,9 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
|
||||||
|
|
||||||
ret = LOS_MuxCreate(&muxId);
|
ret = LOS_MuxCreate(&muxId);
|
||||||
if (ret == LOS_OK) {
|
if (ret == LOS_OK) {
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
OsSetMutexCreateInfo(GET_MUX(muxId), regLR);
|
||||||
|
#endif
|
||||||
return (osMutexId_t)(GET_MUX(muxId));
|
return (osMutexId_t)(GET_MUX(muxId));
|
||||||
} else {
|
} else {
|
||||||
return (osMutexId_t)NULL;
|
return (osMutexId_t)NULL;
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#include "los_debug.h"
|
#include "los_debug.h"
|
||||||
#include "los_hook.h"
|
#include "los_hook.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
#include "los_arch.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MUTEXATTR_TYPE_MASK 0x0FU
|
#define MUTEXATTR_TYPE_MASK 0x0FU
|
||||||
#define OS_SYS_NS_PER_MSECOND 1000000
|
#define OS_SYS_NS_PER_MSECOND 1000000
|
||||||
|
@ -130,6 +133,10 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||||
UINT32 muxHandle;
|
UINT32 muxHandle;
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
|
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
UINTPTR regLR = ArchLRGet();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (mutex == NULL) {
|
if (mutex == NULL) {
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -148,6 +155,9 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||||
mutex->stAttr = useAttr;
|
mutex->stAttr = useAttr;
|
||||||
mutex->magic = _MUX_MAGIC;
|
mutex->magic = _MUX_MAGIC;
|
||||||
mutex->handle = muxHandle;
|
mutex->handle = muxHandle;
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -324,6 +334,10 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||||
struct timespec curTime = {0};
|
struct timespec curTime = {0};
|
||||||
LosMuxCB *muxPended = NULL;
|
LosMuxCB *muxPended = NULL;
|
||||||
|
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
UINTPTR regLR = ArchLRGet();
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return (INT32)ret;
|
return (INT32)ret;
|
||||||
|
@ -337,6 +351,9 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||||
if (ret != LOS_OK) {
|
if (ret != LOS_OK) {
|
||||||
return MapError(ret);
|
return MapError(ret);
|
||||||
}
|
}
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
muxPended = GET_MUX(mutex->handle);
|
muxPended = GET_MUX(mutex->handle);
|
||||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||||
|
@ -364,6 +381,11 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
LosMuxCB *muxPended = NULL;
|
LosMuxCB *muxPended = NULL;
|
||||||
|
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
UINTPTR regLR = ArchLRGet();
|
||||||
|
#endif
|
||||||
|
|
||||||
LosTaskCB *runTask = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
LosTaskCB *runTask = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||||
|
|
||||||
ret = MuxPreCheck(mutex, runTask);
|
ret = MuxPreCheck(mutex, runTask);
|
||||||
|
@ -376,6 +398,9 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||||
if (ret != LOS_OK) {
|
if (ret != LOS_OK) {
|
||||||
return MapError(ret);
|
return MapError(ret);
|
||||||
}
|
}
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
muxPended = GET_MUX(mutex->handle);
|
muxPended = GET_MUX(mutex->handle);
|
||||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||||
|
@ -394,6 +419,10 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
LosMuxCB *muxPended = NULL;
|
LosMuxCB *muxPended = NULL;
|
||||||
|
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
UINTPTR regLR = ArchLRGet();
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
return (INT32)ret;
|
return (INT32)ret;
|
||||||
|
@ -404,6 +433,9 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||||
if (ret != LOS_OK) {
|
if (ret != LOS_OK) {
|
||||||
return MapError(ret);
|
return MapError(ret);
|
||||||
}
|
}
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
muxPended = GET_MUX(mutex->handle);
|
muxPended = GET_MUX(mutex->handle);
|
||||||
if ((mutex->stAttr.type != PTHREAD_MUTEX_RECURSIVE) && (muxPended->muxCount != 0)) {
|
if ((mutex->stAttr.type != PTHREAD_MUTEX_RECURSIVE) && (muxPended->muxCount != 0)) {
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
#include "los_task.h"
|
#include "los_task.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -302,6 +301,9 @@ typedef struct {
|
||||||
UINT32 muxID; /**< Handle ID */
|
UINT32 muxID; /**< Handle ID */
|
||||||
LOS_DL_LIST muxList; /**< Mutex linked list */
|
LOS_DL_LIST muxList; /**< Mutex linked list */
|
||||||
LosTaskCB *owner; /**< The current thread that is locking a mutex */
|
LosTaskCB *owner; /**< The current thread that is locking a mutex */
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
UINTPTR createInfo; /**< Return address of the caller */
|
||||||
|
#endif
|
||||||
UINT16 priority; /**< Priority of the thread that is locking a mutex */
|
UINT16 priority; /**< Priority of the thread that is locking a mutex */
|
||||||
} LosMuxCB;
|
} LosMuxCB;
|
||||||
|
|
||||||
|
@ -351,6 +353,13 @@ extern UINT32 OsMuxInit(VOID);
|
||||||
*/
|
*/
|
||||||
#define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosMuxCB, muxList)
|
#define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosMuxCB, muxList)
|
||||||
|
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
STATIC INLINE VOID OsSetMutexCreateInfo(LosMuxCB *mux, UINTPTR val)
|
||||||
|
{
|
||||||
|
mux->createInfo = val;
|
||||||
|
}
|
||||||
|
#endif /* LOSCFG_MUTEX_CREATE_TRACE == 1 */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,11 @@ STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||||
return LOS_SysCycleGet();
|
return LOS_SysCycleGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC INLINE BOOL OsCheckKernelRunning(VOID)
|
||||||
|
{
|
||||||
|
return (g_taskScheduled && LOS_CHECK_SCHEDULE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_sched
|
* @ingroup los_sched
|
||||||
* @brief Get the time, in nanoseconds, remaining before the next tick interrupt response.
|
* @brief Get the time, in nanoseconds, remaining before the next tick interrupt response.
|
||||||
|
|
|
@ -120,21 +120,6 @@ LITE_OS_SEC_TEXT_INIT VOID LOS_Panic(const CHAR *fmt, ...)
|
||||||
ArchSysExit();
|
ArchSysExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
Function : OsRegister
|
|
||||||
Description : Configuring the maximum number of tasks
|
|
||||||
Input : None
|
|
||||||
Output : None
|
|
||||||
Return : None
|
|
||||||
*****************************************************************************/
|
|
||||||
LITE_OS_SEC_TEXT_INIT static VOID OsRegister(VOID)
|
|
||||||
{
|
|
||||||
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID)
|
LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID)
|
||||||
{
|
{
|
||||||
return ArchStartSchedule();
|
return ArchStartSchedule();
|
||||||
|
@ -156,8 +141,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
|
||||||
OsBackTraceInit();
|
OsBackTraceInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OsRegister();
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_LMS
|
#ifdef LOSCFG_KERNEL_LMS
|
||||||
OsLmsInit();
|
OsLmsInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
#include "los_memory.h"
|
#include "los_memory.h"
|
||||||
#include "los_sched.h"
|
#include "los_sched.h"
|
||||||
|
|
||||||
|
|
||||||
#if (LOSCFG_BASE_IPC_MUX == 1)
|
#if (LOSCFG_BASE_IPC_MUX == 1)
|
||||||
|
|
||||||
LITE_OS_SEC_BSS LosMuxCB* g_allMux = NULL;
|
LITE_OS_SEC_BSS LosMuxCB* g_allMux = NULL;
|
||||||
|
@ -71,6 +70,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsMuxInit(VOID)
|
||||||
muxNode->muxID = index;
|
muxNode->muxID = index;
|
||||||
muxNode->owner = (LosTaskCB *)NULL;
|
muxNode->owner = (LosTaskCB *)NULL;
|
||||||
muxNode->muxStat = OS_MUX_UNUSED;
|
muxNode->muxStat = OS_MUX_UNUSED;
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
muxNode->createInfo = 0;
|
||||||
|
#endif
|
||||||
LOS_ListTailInsert(&g_unusedMuxList, &muxNode->muxList);
|
LOS_ListTailInsert(&g_unusedMuxList, &muxNode->muxList);
|
||||||
}
|
}
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
@ -149,7 +151,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_MuxDelete(UINT32 muxHandle)
|
||||||
|
|
||||||
LOS_ListAdd(&g_unusedMuxList, &muxDeleted->muxList);
|
LOS_ListAdd(&g_unusedMuxList, &muxDeleted->muxList);
|
||||||
muxDeleted->muxStat = OS_MUX_UNUSED;
|
muxDeleted->muxStat = OS_MUX_UNUSED;
|
||||||
|
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||||
|
muxDeleted->createInfo = 0;
|
||||||
|
#endif
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
|
||||||
OsHookCall(LOS_HOOK_TYPE_MUX_DELETE, muxDeleted);
|
OsHookCall(LOS_HOOK_TYPE_MUX_DELETE, muxDeleted);
|
||||||
|
@ -320,5 +324,5 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxPost(UINT32 muxHandle)
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
#endif /* (LOSCFG_BASE_IPC_MUX == 1) */
|
|
||||||
|
|
||||||
|
#endif /* (LOSCFG_BASE_IPC_MUX == 1) */
|
||||||
|
|
|
@ -618,7 +618,7 @@ VOID LOS_SchedTickHandler(VOID)
|
||||||
|
|
||||||
VOID LOS_Schedule(VOID)
|
VOID LOS_Schedule(VOID)
|
||||||
{
|
{
|
||||||
if (g_taskScheduled && LOS_CHECK_SCHEDULE) {
|
if (OsCheckKernelRunning()) {
|
||||||
ArchTaskSchedule();
|
ArchTaskSchedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
* @ingroup los_task
|
* @ingroup los_task
|
||||||
* @brief check task id's validation
|
* @brief check task id's validation
|
||||||
*/
|
*/
|
||||||
#define OS_TASK_ID_CHECK(taskID) LOS_ASSERT_COND(OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
|
#define OS_TASK_ID_CHECK(taskID) (OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup los_task
|
* @ingroup los_task
|
||||||
|
@ -409,6 +409,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
|
||||||
UINT32 size;
|
UINT32 size;
|
||||||
UINT32 index;
|
UINT32 index;
|
||||||
|
|
||||||
|
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
|
||||||
size = (g_taskMaxNum + 1) * sizeof(LosTaskCB);
|
size = (g_taskMaxNum + 1) * sizeof(LosTaskCB);
|
||||||
g_taskCBArray = (LosTaskCB *)LOS_MemAlloc(m_aucSysMem0, size);
|
g_taskCBArray = (LosTaskCB *)LOS_MemAlloc(m_aucSysMem0, size);
|
||||||
if (g_taskCBArray == NULL) {
|
if (g_taskCBArray == NULL) {
|
||||||
|
@ -856,7 +857,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
|
||||||
UINT32 retErr = OS_ERROR;
|
UINT32 retErr = OS_ERROR;
|
||||||
BOOL needSched = FALSE;
|
BOOL needSched = FALSE;
|
||||||
|
|
||||||
if (taskID > LOSCFG_BASE_CORE_TSK_LIMIT) {
|
if (!OS_TASK_ID_CHECK(taskID)) {
|
||||||
return LOS_ERRNO_TSK_ID_INVALID;
|
return LOS_ERRNO_TSK_ID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ static UINT32 Testcase(VOID)
|
||||||
LOS_EventInit(&g_pevent);
|
LOS_EventInit(&g_pevent);
|
||||||
|
|
||||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||||
|
|
||||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||||
g_testCount++;
|
g_testCount++;
|
||||||
|
@ -111,7 +111,6 @@ static UINT32 Testcase(VOID)
|
||||||
EXIT1:
|
EXIT1:
|
||||||
LOS_TaskDelete(g_testTaskID02);
|
LOS_TaskDelete(g_testTaskID02);
|
||||||
|
|
||||||
EXIT:
|
|
||||||
LOS_TaskDelete(g_testTaskID01);
|
LOS_TaskDelete(g_testTaskID01);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
|
@ -88,7 +88,7 @@ static UINT32 Testcase(VOID)
|
||||||
LOS_EventInit(&g_pevent);
|
LOS_EventInit(&g_pevent);
|
||||||
|
|
||||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||||
|
|
||||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||||
g_testCount++;
|
g_testCount++;
|
||||||
|
@ -106,7 +106,6 @@ static UINT32 Testcase(VOID)
|
||||||
EXIT1:
|
EXIT1:
|
||||||
LOS_TaskDelete(g_testTaskID02);
|
LOS_TaskDelete(g_testTaskID02);
|
||||||
|
|
||||||
EXIT:
|
|
||||||
LOS_TaskDelete(g_testTaskID01);
|
LOS_TaskDelete(g_testTaskID01);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
|
@ -37,7 +37,7 @@ static VOID TaskF01(VOID)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ItHwiM3B001F001()
|
static VOID ItHwiM3B001F001(VOID)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ static UINT32 g_uwsTick2;
|
||||||
static UINT32 g_uwsTick3;
|
static UINT32 g_uwsTick3;
|
||||||
|
|
||||||
extern VOID LOS_GetCpuTick(UINT32 *puwCntHi, UINT32 *puwCntLo);
|
extern VOID LOS_GetCpuTick(UINT32 *puwCntHi, UINT32 *puwCntLo);
|
||||||
extern VOID ItSuiteLosSwtmr();
|
extern VOID ItSuiteLosSwtmr(VOID);
|
||||||
extern VOID ItLosSwtmr001(VOID);
|
extern VOID ItLosSwtmr001(VOID);
|
||||||
extern VOID ItLosSwtmr002(VOID);
|
extern VOID ItLosSwtmr002(VOID);
|
||||||
extern VOID ItLosSwtmr003(VOID);
|
extern VOID ItLosSwtmr003(VOID);
|
||||||
|
|
|
@ -39,7 +39,7 @@ static VOID Case1(UINT32 arg)
|
||||||
g_testCount++;
|
g_testCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID Case2()
|
static VOID Case2(VOID)
|
||||||
{
|
{
|
||||||
g_testCount++;
|
g_testCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,12 @@ static VOID Case1(UINT32 arg)
|
||||||
g_testCount++;
|
g_testCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID Case2()
|
static VOID Case2(VOID)
|
||||||
{
|
{
|
||||||
g_testCount++;
|
g_testCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID Case3()
|
static VOID Case3(VOID)
|
||||||
{
|
{
|
||||||
g_testCount++;
|
g_testCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
|
|
||||||
static UINT32 g_testCount1 = 0;
|
static UINT32 g_testCount1 = 0;
|
||||||
static VOID Case1()
|
static VOID Case1(VOID)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
static UINT32 g_testCount1 = 0;
|
static UINT32 g_testCount1 = 0;
|
||||||
|
|
||||||
static VOID Case1()
|
static VOID Case1(VOID)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ static VOID Case1(UINT32 arg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID Case2()
|
static VOID Case2(VOID)
|
||||||
{
|
{
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
UINT32 tick;
|
UINT32 tick;
|
||||||
|
|
|
@ -32,9 +32,6 @@
|
||||||
#include "osTest.h"
|
#include "osTest.h"
|
||||||
#include "It_los_task.h"
|
#include "It_los_task.h"
|
||||||
|
|
||||||
static UINT32 g_freeMem1 = 0;
|
|
||||||
static UINT32 g_freeMem2 = 0;
|
|
||||||
|
|
||||||
static UINT32 GetfreeMemSize(void *pool)
|
static UINT32 GetfreeMemSize(void *pool)
|
||||||
{
|
{
|
||||||
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
|
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include <securec.h>
|
#include <securec.h>
|
||||||
#include "osTest.h"
|
#include "osTest.h"
|
||||||
#include "pthread.h"
|
#include "pthread.h"
|
||||||
|
#include "time.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define TASK_PRIO_TEST LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO
|
#define TASK_PRIO_TEST LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO
|
||||||
#define OS_TSK_TEST_STACK_SIZE 0x1000
|
#define OS_TSK_TEST_STACK_SIZE 0x1000
|
||||||
|
@ -688,7 +690,6 @@ static VOID PthreadOnceFunc01(void)
|
||||||
LITE_TEST_CASE(PthreadFuncTestSuite, TestPthread010, Function | MediumTest | Level1)
|
LITE_TEST_CASE(PthreadFuncTestSuite, TestPthread010, Function | MediumTest | Level1)
|
||||||
{
|
{
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_t thread[TEST_THREAD_COUNT];
|
|
||||||
struct sched_param schedParam = { 0 };
|
struct sched_param schedParam = { 0 };
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
UINT32 i = 0;
|
UINT32 i = 0;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "posix_test.h"
|
#include "posix_test.h"
|
||||||
#include "kernel_test.h"
|
#include "kernel_test.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#define RET_TRUE 1
|
#define RET_TRUE 1
|
||||||
#define RET_FALSE 0
|
#define RET_FALSE 0
|
||||||
|
|
|
@ -75,6 +75,8 @@
|
||||||
|
|
||||||
void ItSuitePosix(void);
|
void ItSuitePosix(void);
|
||||||
|
|
||||||
|
extern void ItSuitePosixPthread(void);
|
||||||
|
extern void ItSuitePosixMutex(void);
|
||||||
extern void PosixCtypeFuncTest(void);
|
extern void PosixCtypeFuncTest(void);
|
||||||
extern void PosixIsdigitFuncTest(void);
|
extern void PosixIsdigitFuncTest(void);
|
||||||
extern void PosixIslowerFuncTest(void);
|
extern void PosixIslowerFuncTest(void);
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "los_config.h"
|
#include "los_config.h"
|
||||||
#include "kernel_test.h"
|
#include "kernel_test.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define RET_OK 0
|
#define RET_OK 0
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@
|
||||||
#include "los_config.h"
|
#include "los_config.h"
|
||||||
#include "kernel_test.h"
|
#include "kernel_test.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
#define EQUAL 0
|
#define EQUAL 0
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "kernel_test.h"
|
#include "kernel_test.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "los_tick.h"
|
#include "los_tick.h"
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define RET_OK 0
|
#define RET_OK 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue