Compare commits

..

28 Commits

Author SHA1 Message Date
openharmony_ci
8e22f6584d !736 3.1分支 littlefs mount目录命名不合理
Merge pull request !736 from wangchen/0624_31_name
2022-07-07 08:09:27 +00:00
openharmony_ci
c0c8a7da3a !726 fix: 修复系统时间比RTC时间过快的问题
Merge pull request !726 from zhushengle/tick_3.1
2022-06-25 10:03:17 +00:00
zhushengle
e0fd5c306f fix: 修复系统时间比RTC时间过快的问题
1.标记在时间接口中更新base后在中断中不再更新base
2.优化tick计算

Close #I5DCRB

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I79940335543889dbf746f48607828527fb606763
2022-06-25 09:52:40 +08:00
wangchen
fb35d6d286 fix: 3.1分支 littlefs mount目录命名不合理
【背景】3.1分支 littlefs mount目录命名不合理

【修改方案】
原有的/a过于奇怪, 添加 /littlefs

【影响】
对现有的产品编译不会有影响。
re #I5E1VW
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-06-24 10:40:22 +00:00
openharmony_ci
17d7594e52 !733 挑单 LOSCFG_PLATFORM_HWI_WITH_ARG开启后M核编译失败修改
Merge pull request !733 from wangchen/0623_31_hwi
2022-06-24 08:56:02 +00:00
wangchen
ff2f099deb fix: 挑单 LOSCFG_PLATFORM_HWI_WITH_ARG开启后M核编译失败修改
【背景】LOSCFG_PLATFORM_HWI_WITH_ARG开启后M核编译失败

【修改方案】
对涉及的函数指针进行强制转换

【影响】
对现有的产品编译不会有影响。
re #I4W4GM
Signed-off-by: wangchen <wangchen64@huawei.com>
2022-06-23 12:34:09 +00:00
openharmony_ci
281b21cd5f !720 Fix : 执行内核测试套到线程模块显示非posix线程,无法继续执行
Merge pull request !720 from yinjiaming/fix
2022-06-22 09:00:38 +00:00
yinjiaming
d279b7059d fix: 修复执行内核测试套到线程模块显示非posix线程,无法继续执行的问题
【背景】
执行内核测试套到线程模块显示非posix线程,无法继续执行

【修改方案】
修复线程id判断存在的问题

【影响】
对现有的产品编译不会有影响。

re #I57LXR

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I93acf7abbffd43d7b8ab6f65e33b5b9d3345dbfe
2022-06-18 09:00:14 +00:00
openharmony_ci
17db92dbc9 !707 【3.1-Release】 littlefs接口缺乏锁的保护
Merge pull request !707 from Far/OpenHarmony-3.1-Release
2022-06-13 08:05:04 +00:00
Far
b0f5f377c7 fix: 修复littlefs中lfs相关接口未用锁保护的问题
littlefs适配lfs_api.c中调用littlefs原生接口未用锁保护,修复之

Close #I5BVQ3

Change-Id: I5744dc2e22c8808b9e8ca2517a5b4bc66ae122d6
Signed-off-by: Far <yesiyuan2@huawei.com>
2022-06-13 14:16:32 +08:00
openharmony_ci
6997bcf648 !678 fix: 低功耗tick timer休眠时间计算有误
Merge pull request !678 from zhushengle/cherry-pick-1650532074
2022-04-24 10:23:21 +00:00
zhushengle
b65216740a fixed 8550117 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/660
fix: 低功耗tick timer休眠时间计算有误

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I3dfa2a8ec7562a1182dae74cc706c7a660ae867a
2022-04-21 09:07:55 +00:00
openharmony_ci
2d8e86ede0 !667 解决taskCB未定义以及初始化的问题
Merge pull request !667 from 夏不白/cherry-pick-1648781865
2022-04-11 08:36:50 +00:00
xia-bubai
f750154f44 fixed 67b5791 from https://gitee.com/xia-bubai/kernel_liteos_m/pulls/666
Description: add initialize of taskCB in function ArchTskStackInit
IssueNo:https://gitee.com/openharmony/kernel_liteos_m/issues/I50NRJ
Feature or Bugfix: Bugfix

Signed-off-by: xia-bubai <xiacong4@huawei.com>
2022-04-01 02:57:45 +00:00
openharmony_ci
6b26b1d825 !659 fix: 修复README格式问题
Merge pull request !659 from zhushengle/cherry-pick-1648129430
2022-03-24 13:52:35 +00:00
zhushengle
384bd910f4 fixed 9e0e39f from https://gitee.com/zhushengle/kernel_liteos_m/pulls/658
fix: 修复README格式问题

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I35a67592ceaab7bdaaf3c2bf4122f6a4bc4a66bb
2022-03-24 13:43:51 +00:00
openharmony_ci
f5fe0b0217 !656 fix: 告警修复
Merge pull request !656 from Zhaotianyu/0323codex_fix_b_3.1_release
2022-03-23 09:21:48 +00:00
arvinzzz
7d2fd01c2d fix: 告警修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Iccf2fa30b1c16148c8c3e548fcdceda07dff8ae5
2022-03-23 16:11:13 +08:00
openharmony_ci
8cf05b45ec !654 fix: 告警修复
Merge pull request !654 from Zhaotianyu/cherry-pick-1647957155
2022-03-22 14:09:05 +00:00
arvinzzz
6a53e1f3eb fixed 637de91 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/652
fix: 告警修复

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I4c69ab116920db527b39070038d36e7f0bd4e331
2022-03-22 13:52:36 +00:00
openharmony_ci
c0bc99ca18 !651 fix: 告警修复
Merge pull request !651 from Zhaotianyu/cherry-pick-1647949948
2022-03-22 13:31:24 +00:00
openharmony_ci
fe6f342e8f !649 fix:告警修复
Merge pull request !649 from Zhaotianyu/0322codex_fix_b_3.1_release
2022-03-22 12:33:09 +00:00
arvinzzz
fc3349403c fixed 0e2dded from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/650
fix: 告警修复

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I09d6e86c958838d95297176c235fe1a7ad34c88c
2022-03-22 11:52:28 +00:00
arvinzzz
2d7bf3b7d8 fix: 告警修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I0535818b4c5f39c9ca916d2ff76eaffda900c726
2022-03-22 18:31:16 +08:00
openharmony_ci
7e4681fefb !644 fix: 内源检视问题修复
Merge pull request !644 from Zhaotianyu/0321codex_fix_b_3.1_release
2022-03-21 06:57:53 +00:00
arvinzzz
c24363bc50 fix: 内源检视问题修复
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-03-21 14:37:31 +08:00
openharmony_ci
74def19245 !616 fix: codex及合规修复
Merge pull request !616 from Zhaotianyu/cherry-pick-1646726740
2022-03-10 07:12:39 +00:00
arvinzzz
c4ffb4fb6e fixed f34b94e from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/615
fix: codex等问题修复

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ib2c46be5e117fab5506bb7b5229f31e611195f1b
2022-03-08 08:05:41 +00:00
105 changed files with 3053 additions and 6551 deletions

20
Kconfig
View File

@@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@@ -317,7 +317,7 @@ config CPUP_INCLUDE_IRQ
help
If you wish to include irq usage for cpup.
config KERNEL_DYNLINK
config DYNLINK
bool "Enable Dynamic Link Feature"
default n
depends on KERNEL_EXTKERNEL && ARCH_ARM
@@ -554,13 +554,6 @@ config SHELL_CMD_DEBUG
default n
depends on DEBUG_VERSION && SHELL
config DEBUG_TOOLS
bool "Enable DEBUG TOOLS"
default n
depends on DEBUG_VERSION
help
Answer Y to enable LiteOS debug tools, include stackdump, hwidump, tasktrack.
config USB_DEBUG
bool "Enable USB Debug"
default n
@@ -607,11 +600,11 @@ endmenu
######################## config options os security #######################
menu "Security"
osource "security/Kconfig"
config SECURE_TRUSTZONE
bool "Enable ARM TrustZone"
default n
depends on ARCH_ARM
depends on ARCH_ARM_V8M
config SECURE_HEAP_SIZE
int "TrustZone Heap Size (bytes)"
default 2048
@@ -622,13 +615,6 @@ config SECURE_STACK_DEFAULT_SIZE
depends on SECURE_TRUSTZONE
help
The secure stack must be allocated before the task calls non-secure functions.
config SECURE
bool "Enable Security"
default n
select MPU_ENABLE
config MPU_ENABLE
bool "Enable MPU"
default n
endmenu
menu "Test"

View File

@@ -39,8 +39,7 @@ module_group("arch") {
"$board_cpu" == "cortex-m4" || "$board_cpu" == "cortex-m7" ||
"$board_cpu" == "cortex-m33" || "$board_cpu" == "cortex-m55") {
modules += [ "arm" ]
} else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802" ||
"$board_cpu" == "ck804ef") {
} else if ("$board_cpu" == "ck802" || "$board_cpu" == "e802") {
modules += [ "csky" ]
} else if ("$board_cpu" == "") {
if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") {

View File

@@ -16,16 +16,12 @@ config ARCH_ARM_AARCH32
config ARCH_ARM_V7M
bool
config ARCH_ARM_V8M
bool
config ARCH_ARM_V5TE
bool
config ARCH_ARM_VER
string
default "armv7-m" if ARCH_ARM_V7M
default "armv8-m" if ARCH_ARM_V8M
default "armv5te" if ARCH_ARM_V5TE
#
@@ -88,20 +84,23 @@ config ARCH_CORTEX_M7
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_CORTEX_M33
bool
select ARCH_ARM_V8M
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_CORTEX_M55
bool
select ARCH_ARM_V8M
select ARCH_ARM_V7M
select ARCH_ARM_AARCH32
select ARCH_FPU_VFP_V4
select ARCH_FPU_VFP_D32
select ARCH_FPU_VFP_NEON
config ARCH_ARM9
bool

View File

@@ -39,9 +39,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#include "los_reg.h"
#define OS_INT_IRQ_ENABLE (1U << 0)
@@ -64,30 +61,6 @@ ExcInfo g_excInfo = {0};
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -231,9 +204,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -247,16 +217,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -306,12 +268,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
#else
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask(hwiNum);
LOS_IntRestore(intSave);

View File

@@ -39,9 +39,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
@@ -57,30 +54,6 @@ LITE_OS_SEC_VEC
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -264,9 +237,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -280,16 +250,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -344,14 +306,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -622,19 +576,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -39,9 +39,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
@@ -53,30 +50,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -255,9 +228,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -271,16 +241,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -335,14 +297,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -618,14 +572,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -39,9 +39,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
@@ -52,30 +49,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -255,9 +228,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -271,16 +241,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -335,14 +297,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -618,14 +572,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -40,9 +40,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
@@ -56,30 +53,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -266,9 +239,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -282,16 +252,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -346,14 +308,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -623,19 +577,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -40,9 +40,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0;
@@ -56,30 +53,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -266,9 +239,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -282,16 +252,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -346,14 +308,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -623,19 +577,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -121,29 +121,6 @@ typedef struct TagTskContext {
*/
extern VOID HalStartToRun(VOID);
#if (LOSCFG_SECURE == 1)
/**
* @ingroup los_config
* @brief: User Task Stack Initialize.
*
* @par Description:
* This API is used to init a user task stack.
*
* @attention:
* <ul><li>None.</li></ul>
*
* @param: context [IN] Task context.
* @param: taskEntry [IN] Task entry function address.
* @param: stack [IN] Task stack address.
*
* @retval None.
*
* @par Dependency: <ul><li>los_config.h: the header file that contains the API declaration.</li></ul>
* @see None.
*/
extern VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -148,15 +148,6 @@ VOID *ArchSignalContextInit(VOID *stackPointer, VOID *stackTop, UINTPTR sigHandl
return (VOID *)context;
}
#if (LOSCFG_SECURE == 1)
VOID HalUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
{
context->uwR0 = stack;
context->uwPC = (UINT32)taskEntry;
context->uwxPSR = 0x01000000L; /* Thumb flag, always set 1 */
}
#endif
LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
{
(VOID)LOS_IntLock();

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -40,12 +40,6 @@
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
.equ OS_NVIC_PENDSVSET, 0x10000000
.equ OS_TASK_STATUS_RUNNING, 0x0010
.equ OS_CONTROL_FPCA_ENABLE, 0x4
.equ OS_CONTROL_KERNEL_MODE, 0x2
#if (LOSCFG_SECURE == 1)
.equ OS_CONTROL_USER_MODE, 0x3
.equ OS_TASK_FLAG_USER_TASK, 0x0200
#endif
.section .text
.thumb
@@ -69,7 +63,7 @@ HalStartToRun:
ldr r5, =OS_NVIC_PENDSV_PRI
str r5, [r4]
mov r0, #OS_CONTROL_KERNEL_MODE
mov r0, #2
msr CONTROL, r0
ldr r1, =g_losTask
@@ -147,7 +141,7 @@ ArchTaskSchedule:
bx lr
dsb
isb
.fnend
.fnend
.type HalPendSV, %function
.global HalPendSV
@@ -200,14 +194,6 @@ SignalContextRestore:
vldmia r1!, {d8-d15}
__DisabledFPU2:
#if (LOSCFG_SECURE == 1)
ldrh r7, [r0, #4]
tst r7, #OS_TASK_FLAG_USER_TASK
ite eq
moveq r3, #OS_CONTROL_KERNEL_MODE
movne r3, #OS_CONTROL_USER_MODE
msr CONTROL, r3
#endif
ldmfd r1!, {r4-r12}
msr psp, r1

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -57,15 +57,15 @@
.equ FLAG_ADDR_VALID, 0x10000
.equ FLAG_HWI_ACTIVE, 0x20000
.equ FLAG_NO_FLOAT, 0x10000000
.equ FLAG_NO_FLOAT, 0x10000000
.equ OS_NVIC_FSR, 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
.equ OS_NVIC_HFSR, 0xE000ED2C //HardFault State Register
.equ OS_NVIC_BFAR, 0xE000ED38
.equ OS_NVIC_MMAR, 0xE000ED34
.equ OS_NVIC_ACT_BASE, 0xE000E300
.equ OS_NVIC_SHCSRS, 0xE000ED24
.equ OS_NVIC_SHCSR_MASK, 0xC00
.equ OS_NVIC_FSR , 0xE000ED28 //include BusFault/MemFault/UsageFault State Register
.equ OS_NVIC_HFSR , 0xE000ED2C //HardFault State Register
.equ OS_NVIC_BFAR , 0xE000ED38
.equ OS_NVIC_MMAR , 0xE000ED34
.equ OS_NVIC_ACT_BASE , 0xE000E300
.equ OS_NVIC_SHCSRS , 0xE000ED24
.equ OS_NVIC_SHCSR_MASK , 0xC00
.type HalExcNMI, %function
.global HalExcNMI
@@ -155,25 +155,10 @@ HalExcSvcCall:
.cantunwind
TST LR, #0x4
ITE EQ
MRSEQ R1, MSP
BNE _svcCallFromPsp
B _svcCall
_svcCallFromPsp:
#ifdef LOSCFG_SECURE
PUSH {R0-R12, LR}
MOV R0, SP
CPSIE I
BL OsSyscallHandle
CPSID I
MRS R12, PSP
STM R12, {R0-R1}
POP {R0-R12, LR}
BX LR
#endif
MRS R1, PSP
_svcCall:
LDR R0, [R1,#24]
LDRB R0, [R0,#-2]
MRSEQ R0, MSP
MRSNE R0, PSP
LDR R1, [R0,#24]
LDRB R0, [R1,#-2]
MOV R1, #0
B osExcDispatch
.fnend
@@ -299,7 +284,7 @@ _ExcInMSP:
PUSH {R4-R12} // store message-->exc: {R4-R12}
VPUSH {D8-D15} // FPU
B _handleEntry
.fnend
.fnend
.type _NoFloatInMsp, %function
.global _NoFloatInMsp
@@ -313,7 +298,7 @@ _NoFloatInMsp:
PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
.fnend
.type _hwiActiveCheckNext, %function
.global _hwiActiveCheckNext
@@ -362,7 +347,7 @@ _hwiActiveCheckNext:
VSTMDB R2!, {D8-D15} // FPU
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
.fnend
.type _NoFloatInPsp, %function
.global _NoFloatInPsp
@@ -382,7 +367,7 @@ _NoFloatInPsp:
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
STMFD R2!, {R4-R11}
ORR R0, R0, #FLAG_NO_FLOAT
.fnend
.fnend
.type _handleEntry, %function
.global _handleEntry
@@ -395,4 +380,4 @@ _handleEntry:
B HalExcHandleEntry
NOP
.fnend
.fnend

View File

@@ -39,9 +39,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
@@ -51,30 +48,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -258,9 +231,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -274,16 +244,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -338,14 +300,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -626,19 +580,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -40,9 +40,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
@@ -58,30 +55,6 @@ LITE_OS_SEC_VEC
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -266,9 +239,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -282,16 +252,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -346,14 +308,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -624,19 +578,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -38,9 +38,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
#define DEF_HANDLER_START_INDEX 2
UINT32 g_intCount = 0;
@@ -52,30 +49,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -259,9 +232,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -275,16 +245,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -339,14 +301,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -626,14 +580,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -137,7 +137,7 @@ ArchTaskSchedule:
dsb
isb
bx lr
.fnend
.fnend
.type HalPendSV, %function
.global HalPendSV
@@ -178,7 +178,7 @@ TaskContextSwitch:
str r0, [r5]
ldr r1, [r0]
SignalContextRestore:
SignalContextRestore:
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
vldmia r1!, {d8-d15}

View File

@@ -29,9 +29,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
.syntax unified
.arch armv7e-m
.thumb
.syntax unified
.arch armv7e-m
.thumb
.fpu fpv5-d16
.section .text
@@ -284,7 +284,7 @@ _ExcInMSP:
PUSH {R4-R12} // store message-->exc: {R4-R12}
VPUSH {D8-D15}
B _handleEntry
.fnend
.fnend
.type _NoFloatInMsp, %function
.global _NoFloatInMsp
@@ -298,7 +298,7 @@ _NoFloatInMsp:
PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
.fnend
.type _hwiActiveCheckNext, %function
.global _hwiActiveCheckNext
@@ -347,7 +347,7 @@ _hwiActiveCheckNext:
VSTMDB R2!, {D8-D15}
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
.fnend
.type _NoFloatInPsp, %function
.global _NoFloatInPsp
@@ -367,7 +367,7 @@ _NoFloatInPsp:
LDMFD R3, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
STMFD R2!, {R4-R11}
ORR R0, R0, #FLAG_NO_FLOAT
.fnend
.fnend
.type _handleEntry, %function
.global _handleEntry
@@ -380,5 +380,5 @@ _handleEntry:
B HalExcHandleEntry
NOP
.fnend
.fnend

View File

@@ -39,9 +39,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
@@ -51,30 +48,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC __attribute__((aligned(LOSCFG_ARCH_HWI_VECTOR_ALIGN))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -253,9 +226,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -269,16 +239,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -333,14 +295,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -611,19 +565,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -40,9 +40,6 @@
#include "los_sched.h"
#include "los_memory.h"
#include "los_membox.h"
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_cpup.h"
#endif
UINT32 g_intCount = 0;
@@ -54,30 +51,6 @@ UINT32 g_intCount = 0;
*/
STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (LOSCFG_DEBUG_TOOLS == 1)
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
UINT32 OsGetHwiFormCnt(UINT32 index)
{
return g_hwiFormCnt[index];
}
CHAR *OsGetHwiFormName(UINT32 index)
{
return g_hwiFormName[index];
}
BOOL OsGetHwiCreated(UINT32 index)
{
if (g_hwiForm[index] != (HWI_PROC_FUNC)HalHwiDefaultHandler) {
return TRUE;
}
return FALSE;
}
#endif
#if (LOSCFG_PLATFORM_HWI_WITH_ARG == 1)
typedef struct {
@@ -262,9 +235,6 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HwiNumGet();
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqStart(hwiIndex);
#endif
HalPreInterruptHandler(hwiIndex);
@@ -278,16 +248,8 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
}
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
++g_hwiFormCnt[hwiIndex];
#endif
HalAftInterruptHandler(hwiIndex);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
OsCpupIrqEnd(hwiIndex);
#endif
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, hwiIndex);
intSave = LOS_IntLock();
@@ -342,14 +304,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchHwiCreate(HWI_HANDLE_T hwiNum,
(VOID)irqParam;
OsSetVector(hwiNum, hwiHandler);
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
if ((irqParam != NULL) && (irqParam->pName != NULL)) {
g_hwiFormName[hwiNum + OS_SYS_VECTOR_CNT] = (CHAR *)irqParam->pName;
}
g_hwiFormCnt[hwiNum + OS_SYS_VECTOR_CNT] = 0;
#endif
HwiUnmask((IRQn_Type)hwiNum);
HwiSetPriority((IRQn_Type)hwiNum, hwiPrio);
@@ -620,19 +574,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
g_hwiForm[1] = (HWI_PROC_FUNC)Reset_Handler; /* [1] reset */
for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@@ -59,33 +59,13 @@ typedef struct TagTskContext {
UINT32 R12;
UINT32 R13;
UINT32 R15;
#ifdef CPU_CK804
UINT32 R16;
UINT32 R17;
UINT32 R18;
UINT32 R19;
UINT32 R20;
UINT32 R21;
UINT32 R22;
UINT32 R23;
UINT32 R24;
UINT32 R25;
UINT32 R26;
UINT32 R27;
UINT32 R28;
UINT32 R29;
UINT32 R30;
UINT32 R31;
#endif
UINT32 EPSR;
UINT32 EPC;
} TaskContext;
VOID HalStartToRun(VOID);
VOID HalTaskContextSwitch(VOID);
#ifndef CPU_CK804
VOID HalIrqEndCheckNeedSched(VOID);
#endif
#ifdef __cplusplus
#if __cplusplus

View File

@@ -82,7 +82,7 @@ typedef VOID (**HWI_VECTOR_FUNC)(VOID);
* @ingroup los_arch_interrupt
* Count of interrupts.
*/
extern volatile UINT32 g_intCount;
extern UINT32 g_intCount;
/* *
* @ingroup los_arch_interrupt

View File

@@ -38,9 +38,7 @@
#include "los_interrupt.h"
#include "los_debug.h"
#ifndef CPU_CK804
STATIC UINT32 g_sysNeedSched = FALSE;
#endif
/* ****************************************************************************
Function : ArchInit
@@ -95,29 +93,8 @@ LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VO
context->R11 = 0x11111111L;
context->R12 = 0x12121212L;
context->R13 = 0x13131313L;
#ifdef CPU_CK804
context->R15 = (UINT32)ArchSysExit;
context->R16 = 0x16161616L;
context->R17 = 0x17171717L;
context->R18 = 0x18181818L;
context->R19 = 0x19191919L;
context->R20 = 0x20202020L;
context->R21 = 0x21212121L;
context->R22 = 0x22222222L;
context->R23 = 0x23232323L;
context->R24 = 0x24242424L;
context->R25 = 0x25252525L;
context->R26 = 0x26262626L;
context->R27 = 0x27272727L;
context->R28 = 0x28282828L;
context->R29 = 0x29292929L;
context->R30 = 0x30303030L;
context->R31 = 0x31313131L;
context->EPSR = 0x80000340L;
#else
context->R15 = (UINT32)ArchSysExit;
context->EPSR = 0xe0000144L;
#endif
context->EPC = (UINT32)OsTaskEntry;
return (VOID *)context;
}
@@ -130,7 +107,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 ArchStartSchedule(VOID)
return LOS_OK; /* never return */
}
#ifndef CPU_CK804
VOID HalIrqEndCheckNeedSched(VOID)
{
if (g_sysNeedSched && g_taskScheduled && LOS_CHECK_SCHEDULE) {
@@ -156,10 +132,3 @@ VOID ArchTaskSchedule(VOID)
LOS_IntRestore(intSave);
return;
}
#else
VOID ArchTaskSchedule(VOID)
{
HalTaskContextSwitch();
}
#endif

View File

@@ -32,89 +32,6 @@
#define OS_TASK_STATUS_RUNNING 0x0010
#define VIC_TSPDR 0XE000EC08
#ifdef CPU_CK804
.section .text
.align 2
.type HalStartToRun, %function
.global HalStartToRun
HalStartToRun:
lrw r1, g_losTask
lrw r2, g_losTask + 4
ldw r0, (r2)
st.w r0, (r1)
st.w r0, (r2)
ldw sp, (r0)
ldw r0, (sp, 128)
mtcr r0, epc
ldw r0, (sp, 124)
mtcr r0, epsr
ldw r15, (sp, 56)
ldm r0-r13, (sp)
addi sp, 60
ldm r16-r31, (sp)
addi sp, 72
rte
.align 2
.type HalTaskContextSwitch, %function
.global HalTaskContextSwitch
HalTaskContextSwitch:
lrw r0, VIC_TSPDR
bgeni r1, 0
stw r1, (r0)
nop
nop
nop
rts
.align 2
.type tspend_handler, %function
.global tspend_handler
tspend_handler:
subi sp, 132
stm r0-r13, (sp)
stw r15, (sp, 56)
addi r0, sp, 60
stm r16-r31, (r0)
mfcr r1, epsr
stw r1, (sp, 124)
mfcr r1, epc
stw r1, (sp, 128)
jbsr OsSchedTaskSwitch
bez r0, ret_con
lrw r2, g_losTask
ldw r0, (r2)
stw sp, (r0)
lrw r3, g_losTask + 4
ldw r0, (r3)
stw r0, (r2)
ldw sp, (r0)
ret_con:
ldw r0, (sp, 128)
mtcr r0, epc
ldw r0, (sp, 124)
mtcr r0, epsr
ldw r15, (sp, 56)
ldm r0-r13, (sp)
addi sp, 60
ldm r16-r31, (sp)
addi sp, 72
rte
#else
.section .text
.align 2
.type HalStartToRun, %function
@@ -170,4 +87,3 @@ HalTaskContextSwitch:
rte
#endif

View File

@@ -32,57 +32,6 @@
.import HalExcHandleEntry
.extern g_trapStackBase
#ifdef CPU_CK804
.section .text
.align 2
.global HandleEntry
HandleEntry:
mov r10, sp
lrw r14, g_trapStackBase
stm r0-r15, (sp)
stw r10, (sp, 56)
addi r0, sp, 64
stm r16-r31, (r0)
mfcr r0, epsr
stw r0, (sp, 128)
mfcr r0, epc
stw r0, (sp, 132)
mov r0, sp
mfcr r1, epc
mov sp, r10
lrw r2, HalExcHandleEntry
jmp r2
.section .text
.align 2
.global IrqEntry
IrqEntry:
psrset ee
subi sp, 136
stm r0-r15, (sp)
addi r0, sp, 64
stm r16-r31, (r0)
mfcr r0, epsr
stw r0, (sp, 128)
mfcr r0, epc
stw r0, (sp, 132)
jbsr HalInterrupt
ldw r0, (sp, 132)
mtcr r0, epc
ldw r0, (sp, 128)
bseti r0, r0, 6
mtcr r0, epsr
ldm r0-r15, (sp)
addi sp, 64
ldm r16-r31, (sp)
addi sp, 72
rte
#else
.section .text
.align 2
.global HandleEntry
@@ -126,4 +75,3 @@ IrqEntry:
ldm r0-r15, (sp)
addi sp, 72
rte
#endif

View File

@@ -52,12 +52,13 @@
#define MASK_8_BITS 0xFF
#define MASK_32_BITS 0xFFFFFFFF
#define BYTES_OF_128_INT 4
#define TIM_INT_NUM 1
#define OS_USER_HWI_MIN 0
#define OS_USER_HWI_MAX (LOSCFG_PLATFORM_HWI_LIMIT - 1)
#define HWI_ALIGNSIZE 0x400
UINT32 volatile g_intCount = 0;
UINT32 g_intCount = 0;
CHAR g_trapStackBase[OS_TRAP_STACK_SIZE];
VIC_TYPE *VIC_REG = (VIC_TYPE *)VIC_REG_BASE;
@@ -333,9 +334,7 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
intSave = LOS_IntLock();
g_intCount--;
#ifndef CPU_CK804
HalIrqEndCheckNeedSched();
#endif
LOS_IntRestore(intSave);
}
@@ -587,10 +586,6 @@ WEAK VOID __stack_chk_fail(VOID)
__builtin_return_address(0));
}
WEAK void HalHwiHandleReInit(UINT32 hwiFormAddr)
{
}
/* ****************************************************************************
Function : HalHwiInit
Description : initialization of the hardware interrupt
@@ -609,7 +604,6 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
for (i = OS_SYS_VECTOR_CNT; i < (LOSCFG_PLATFORM_HWI_LIMIT + OS_SYS_VECTOR_CNT); i++) {
g_hwiForm[i] = (HWI_PROC_FUNC)IrqEntry;
}
HalHwiHandleReInit((UINT32)&g_hwiForm);
HalSetVbr((UINT32)&g_hwiForm);
for (int i = 0; i < BYTES_OF_128_INT; i++) {

View File

@@ -50,11 +50,7 @@ typedef struct {
#define CORETIM_SOURCE (1UL << 2)
#define CORETIM_MODE (1UL << 16)
#ifdef CPU_CK804
#define TIM_INT_NUM 25
#else
#define TIM_INT_NUM 1
#endif
STATIC UINT32 SysTickStart(HWI_PROC_FUNC handler);
STATIC UINT64 SysTickReload(UINT64 nextResponseTime);

View File

@@ -41,52 +41,6 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#if defined(__ICCARM__) || defined(__CC_ARM)
STATIC INLINE UINTPTR ArchSpGet(VOID)
{
UINTPTR sp;
__asm("mov %0, sp" : "=r" (sp));
return sp;
}
STATIC INLINE UINTPTR ArchPspGet(VOID)
{
UINTPTR psp;
__asm("mrs %0, psp" : "=r" (psp));
return psp;
}
STATIC INLINE UINTPTR ArchMspGet(VOID)
{
UINTPTR msp;
__asm("mrs %0, msp" : "=r" (msp));
return msp;
}
#elif defined(__CLANG_ARM) || defined(__GNUC__)
STATIC INLINE UINTPTR ArchSpGet(VOID)
{
UINTPTR sp;
__asm volatile("mov %0, sp" : "=r" (sp));
return sp;
}
STATIC INLINE UINTPTR ArchPspGet(VOID)
{
UINTPTR psp;
__asm volatile("mrs %0, psp" : "=r" (psp));
return psp;
}
STATIC INLINE UINTPTR ArchMspGet(VOID)
{
UINTPTR msp;
__asm volatile("mrs %0, msp" : "=r" (msp));
return msp;
}
#else
/* Other platforms to be improved */
#endif
VOID ArchInit(VOID);
#ifdef __cplusplus

View File

@@ -214,12 +214,6 @@ STATIC INLINE HwiControllerOps *ArchIntOpsGet(VOID)
return &g_archHwiOps;
}
#if (LOSCFG_DEBUG_TOOLS == 1)
extern UINT32 OsGetHwiFormCnt(UINT32 index);
extern CHAR *OsGetHwiFormName(UINT32 index);
extern BOOL OsGetHwiCreated(UINT32 index);
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -48,9 +48,7 @@
│ ├── lms --- Lite memory sanitizer functions
│ ├── net --- Networking functions
│ ├── power --- Power management
│ ├── security --- Security isolation
│ ├── shell --- Shell function
│ ├── signal --- Signal support
│ ├── fs --- File systems
│ └── trace --- Trace tool
├── drivers --- driver Kconfig
@@ -73,13 +71,14 @@
│   │   └── los_tick.h --- Tick
│   └── src
├── targets
│   └── riscv_nuclei_demo_soc_gcc
── GCC --- Compilation config
│ │ ├── OS_CONFIG --- Board config
│ │ ├── SoC --- SOC codes
│ │ ── Src --- Application codes
   └── riscv_nuclei_gd32vf103_soc_gcc
│   └── riscv_sifive_fe310_gcc
│   └── targets
   ── riscv_nuclei_demo_soc_gcc
│ ├── GCC --- Compilation config
│ ├── OS_CONFIG --- Board config
── SoC --- SOC codes
│ └── Src --- Application codes
│   └── riscv_nuclei_gd32vf103_soc_gcc
│   └── riscv_sifive_fe310_gcc
├── testsuites --- Kernel testsuites
├── tools --- Kernel tools
└── utils
@@ -94,5 +93,6 @@
├── los_hook.h
├── los_list.h --- Doubly linked list
└── los_reg.h --- Register macros
└── src
```

View File

@@ -48,9 +48,7 @@
│ ├── lms --- Lite memory sanitizer 机制
│ ├── net --- Network功能
│ ├── power --- 低功耗管理
│ ├── security --- 安全隔离
│ ├── shell --- shell功能
│ ├── signal --- signal支持
│ └── trace --- trace 工具
├── drivers --- 驱动框架Kconfig
├── kal --- 内核抽象层提供内核对外接口当前支持CMSIS接口和部分POSIX接口
@@ -72,13 +70,14 @@
│   │   └── los_tick.h --- Tick时钟
   └── src
├── targets
└── riscv_nuclei_demo_soc_gcc
── GCC --- 编译相关
│ │ ├── OS_CONFIG --- 开发板配置功能开关和配置参数
│ │ ├── SoC --- SOC相关代码
│ │ ── Src --- Application相关代码
└── riscv_nuclei_gd32vf103_soc_gcc
│ └── riscv_sifive_fe310_gcc
   └── targets
   ── riscv_nuclei_demo_soc_gcc
│ ├── GCC --- 编译相关
│ ├── OS_CONFIG --- 开发板配置功能开关和配置参数
── SoC --- SOC相关代码
│ └── Src --- Application相关代码
   └── riscv_nuclei_gd32vf103_soc_gcc
│   └── riscv_sifive_fe310_gcc
├── testsuites --- 内核测试用例
├── tools --- 内核工具
└── utils
@@ -93,5 +92,6 @@
├── los_hook.h
├── los_list.h --- 双向链表
└── los_reg.h --- 寄存器读写宏定义
└── src
```

View File

@@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@@ -34,7 +34,6 @@ group("components") {
"backtrace",
"cppsupport",
"cpup",
"debugtools",
"dynlink",
"exchook",
"fs",
@@ -42,7 +41,6 @@ group("components") {
"lms",
"net",
"power",
"security",
"shell",
"signal",
"trace",
@@ -59,12 +57,10 @@ config("public") {
"fs:public",
"net:public",
"power:public",
"security:public",
"shell:public",
"trace:public",
"lmk:public",
"lms:public",
"signal:public",
"debugtools:public",
]
}

View File

@@ -32,7 +32,6 @@
#include "los_backtrace.h"
#include "los_task.h"
#include "los_debug.h"
#include "los_arch.h"
#if (LOSCFG_BACKTRACE_TYPE == 4)
#include "los_arch_regs.h"
#endif
@@ -61,6 +60,52 @@ WEAK BOOL OsStackDataIsCodeAddr(UINTPTR value)
#define OS_BLX_INX_MASK 0xFF00
#define OS_BLX_INX 0x4700
#if defined(__ICCARM__) || defined(__CC_ARM)
STATIC INLINE UINTPTR HalSpGet(VOID)
{
UINTPTR sp;
__asm("mov %0, sp" : "=r" (sp));
return sp;
}
STATIC INLINE UINTPTR HalPspGet(VOID)
{
UINTPTR psp;
__asm("mrs %0, psp" : "=r" (psp));
return psp;
}
STATIC INLINE UINTPTR HalMspGet(VOID)
{
UINTPTR msp;
__asm("mrs %0, msp" : "=r" (msp));
return msp;
}
#elif defined(__CLANG_ARM) || defined(__GNUC__)
STATIC INLINE UINTPTR HalSpGet(VOID)
{
UINTPTR sp;
__asm volatile("mov %0, sp" : "=r" (sp));
return sp;
}
STATIC INLINE UINTPTR HalPspGet(VOID)
{
UINTPTR psp;
__asm volatile("mrs %0, psp" : "=r" (psp));
return psp;
}
STATIC INLINE UINTPTR HalMspGet(VOID)
{
UINTPTR msp;
__asm volatile("mrs %0, msp" : "=r" (msp));
return msp;
}
#else
#error Unknown compiler.
#endif
STATIC INLINE BOOL OsInsIsBlOrBlx(UINTPTR addr)
{
UINT16 ins1 = *((UINT16 *)addr);
@@ -93,8 +138,8 @@ STATIC INLINE UINT32 OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd, UINT
}
}
} else {
if (ArchSpGet() != ArchPspGet()) {
*stackStart = ArchMspGet();
if (HalSpGet() != HalPspGet()) {
*stackStart = HalMspGet();
*stackEnd = CSTACK_END_ADDR;
if ((*stackStart < CSTACK_START_ADDR) || (*stackStart >= CSTACK_END_ADDR)) {
PRINT_ERR("msp stack [0x%x, 0x%x], cur sp(0x%x) is overflow!\n",
@@ -103,7 +148,7 @@ STATIC INLINE UINT32 OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd, UINT
}
PRINTK("msp, start = %x, end = %x\n", *stackStart, *stackEnd);
} else {
*stackStart = ArchPspGet();
*stackStart = HalPspGet();
UINT32 taskID = LOS_CurTaskIDGet();
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
*stackEnd = (UINTPTR)taskCB->topOfStack + taskCB->stackSize;

View File

@@ -35,15 +35,8 @@
#include "los_debug.h"
#include "los_tick.h"
#if (LOSCFG_BASE_CORE_SWTMR == 1)
#include "los_swtmr.h"
#endif
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
#include "los_arch_interrupt.h"
#endif
#if (LOSCFG_BASE_CORE_CPUP == 1)
/**
* @ingroup los_cpup
* CPU usage-type macro: used for tasks.
@@ -61,63 +54,8 @@
LITE_OS_SEC_BSS UINT16 g_cpupInitFlg = 0;
LITE_OS_SEC_BSS OsCpupCB *g_cpup = NULL;
LITE_OS_SEC_BSS UINT64 g_lastRecordTime;
LITE_OS_SEC_BSS UINT16 g_hisPos; /* current Sampling point of historyTime */
LITE_OS_SEC_BSS UINT16 g_hisPos; /* <current Sampling point of historyTime */
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
LITE_OS_SEC_BSS UINT16 g_irqCpupInitFlg = 0;
LITE_OS_SEC_BSS UINT16 g_irqHisPos = 0; /* current Sampling point of historyTime */
LITE_OS_SEC_BSS UINT64 g_irqLastRecordTime;
LITE_OS_SEC_BSS OsIrqCpupCB *g_irqCpup = NULL;
LITE_OS_SEC_BSS STATIC UINT64 g_cpuHistoryTime[OS_CPUP_HISTORY_RECORD_NUM];
#define OS_CPUP_USED 0x1U
#if (LOSCFG_BASE_CORE_SWTMR == 1)
LITE_OS_SEC_TEXT_INIT VOID OsCpupGuard(VOID)
{
UINT16 prevPos;
UINT32 loop;
UINT32 intSave;
intSave = LOS_IntLock();
prevPos = g_irqHisPos;
if (g_irqHisPos == OS_CPUP_HISTORY_RECORD_NUM - 1) {
g_irqHisPos = 0;
} else {
g_irqHisPos++;
}
g_cpuHistoryTime[prevPos] = 0;
for (loop = 0; loop < LOSCFG_PLATFORM_HWI_LIMIT; loop++) {
if (g_irqCpup[loop].status != OS_CPUP_USED) {
continue;
}
g_irqCpup[loop].historyTime[prevPos] = g_irqCpup[loop].allTime;
g_cpuHistoryTime[prevPos] += g_irqCpup[loop].allTime;
}
LOS_IntRestore(intSave);
return;
}
LITE_OS_SEC_TEXT_INIT UINT32 OsCpupGuardCreator(VOID)
{
UINT32 cpupSwtmrID;
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
(VOID)LOS_SwtmrCreate(LOSCFG_BASE_CORE_TICK_PER_SECOND, LOS_SWTMR_MODE_PERIOD,
(SWTMR_PROC_FUNC)OsCpupGuard, &cpupSwtmrID, 0,
OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE);
#else
(VOID)LOS_SwtmrCreate(LOSCFG_BASE_CORE_TICK_PER_SECOND, LOS_SWTMR_MODE_PERIOD,
(SWTMR_PROC_FUNC)OsCpupGuard, &cpupSwtmrID, 0);
#endif
(VOID)LOS_SwtmrStart(cpupSwtmrID);
return LOS_OK;
}
#endif
#endif
/*****************************************************************************
Function : OsCpupInit
Description: initialization of CPUP
@@ -139,21 +77,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit()
(VOID)memset_s(g_cpup, size, 0, size);
g_cpupInitFlg = 1;
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
size = LOSCFG_PLATFORM_HWI_LIMIT * sizeof(OsIrqCpupCB);
g_irqCpup = (OsIrqCpupCB *)LOS_MemAlloc(m_aucSysMem0, size);
if (g_irqCpup == NULL) {
return LOS_ERRNO_CPUP_NO_MEMORY;
}
(VOID)memset_s(g_irqCpup, size, 0, size);
#if (LOSCFG_BASE_CORE_SWTMR == 1)
(VOID)OsCpupGuardCreator();
g_irqCpupInitFlg = 1;
#endif
#endif
return LOS_OK;
}
@@ -590,146 +513,4 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E
return LOS_OK;
}
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum)
{
if (g_irqCpupInitFlg == 0) {
return;
}
g_irqCpup[intNum].startTime = LOS_SysCycleGet();
return;
}
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
{
UINT64 cpuCycle;
UINT64 usedTime;
if (g_irqCpupInitFlg == 0) {
return;
}
if (g_irqCpup[intNum].startTime == 0) {
return;
}
cpuCycle = LOS_SysCycleGet();
if (cpuCycle < g_irqCpup[intNum].startTime) {
cpuCycle += g_cyclesPerTick;
}
g_irqCpup[intNum].cpupID = intNum;
g_irqCpup[intNum].status = OS_CPUP_USED;
usedTime = cpuCycle - g_irqCpup[intNum].startTime;
if (g_irqCpup[intNum].count <= 1000) { /* 1000, Take 1000 samples */
g_irqCpup[intNum].allTime += usedTime;
g_irqCpup[intNum].count++;
} else {
g_irqCpup[intNum].allTime = 0;
g_irqCpup[intNum].count = 0;
}
g_irqCpup[intNum].startTime = 0;
if (usedTime > g_irqCpup[intNum].timeMax) {
g_irqCpup[intNum].timeMax = usedTime;
}
return;
}
LITE_OS_SEC_TEXT_MINOR OsIrqCpupCB *OsGetIrqCpupArrayBase(VOID)
{
return g_irqCpup;
}
LITE_OS_SEC_TEXT_MINOR STATIC VOID OsGetIrqPositions(UINT16 mode, UINT16* curPosAddr, UINT16* prePosAddr)
{
UINT16 curPos;
UINT16 prePos = 0;
curPos = g_irqHisPos;
if (mode == CPUP_IN_1S) {
curPos = OsGetPrePos(curPos);
prePos = OsGetPrePos(curPos);
} else if (mode == CPUP_LESS_THAN_1S) {
curPos = OsGetPrePos(curPos);
}
*curPosAddr = curPos;
*prePosAddr = prePos;
}
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllTime(VOID)
{
INT32 i;
UINT64 cpuCycleAll = 0;
for (i = 0; i < OS_CPUP_HISTORY_RECORD_NUM; i++) {
cpuCycleAll += g_cpuHistoryTime[i];
}
return cpuCycleAll;
}
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllHisTime(UINT32 num)
{
INT32 i;
UINT64 historyTime = 0;
for (i = 0; i < OS_CPUP_HISTORY_RECORD_NUM; i++) {
historyTime += g_irqCpup[num].historyTime[i];
}
return historyTime;
}
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cpupInfo)
{
UINT16 loopNum;
UINT16 curPos;
UINT16 prePos = 0;
UINT32 intSave;
UINT64 cpuCycleAll;
UINT64 cpuCycleCurIrq;
if (g_irqCpupInitFlg == 0) {
return LOS_ERRNO_CPUP_NO_INIT;
}
if (cpupInfo == NULL) {
return LOS_ERRNO_CPUP_TASK_PTR_NULL;
}
intSave = LOS_IntLock();
OsGetIrqPositions(mode, &curPos, &prePos);
if (mode == CPUP_IN_10S) {
cpuCycleAll = OsGetIrqAllTime();
} else {
cpuCycleAll = g_cpuHistoryTime[curPos] - g_cpuHistoryTime[prePos];
}
for (loopNum = 0; loopNum < LOSCFG_PLATFORM_HWI_LIMIT; loopNum++) {
if (g_irqCpup[loopNum].status != OS_CPUP_USED) {
continue;
}
cpupInfo[loopNum].usStatus = g_irqCpup[loopNum].status;
if (mode == CPUP_IN_10S) {
cpuCycleCurIrq = OsGetIrqAllHisTime(loopNum);
} else {
cpuCycleCurIrq = g_irqCpup[loopNum].historyTime[curPos] - g_irqCpup[loopNum].historyTime[prePos];
}
if (cpuCycleAll != 0) {
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurIrq) / cpuCycleAll);
}
}
LOS_IntRestore(intSave);
return LOS_OK;
}
#endif
#endif /* LOSCFG_BASE_CORE_CPUP */

View File

@@ -139,18 +139,6 @@ typedef struct {
extern OsCpupCB *g_cpup;
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
typedef struct {
UINT32 cpupID; /**< Irq ID */
UINT16 status; /**< Irq status */
UINT64 allTime; /**< Total running time */
UINT64 startTime; /**< Time before a task is invoked */
UINT64 timeMax; /**< Irq samples count */
UINT64 count; /**< Irq samples count */
UINT64 historyTime[OS_CPUP_HISTORY_RECORD_NUM]; /**< Historical running time */
} OsIrqCpupCB;
#endif
/**
* @ingroup los_cpup
* @brief Initialization cpup.
@@ -369,13 +357,6 @@ extern UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16 mode);
*/
extern UINT32 LOS_CpupUsageMonitor(CPUP_TYPE_E type, CPUP_MODE_E mode, UINT32 taskID);
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1)
extern VOID OsCpupIrqStart(UINT32 intNum);
extern VOID OsCpupIrqEnd(UINT32 intNum);
extern OsIrqCpupCB *OsGetIrqCpupArrayBase(VOID);
extern UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cpupInfo);
#endif
#ifdef __cplusplus
#if __cplusplus
}

View File

@@ -1,43 +0,0 @@
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_switch = defined(LOSCFG_DEBUG_TOOLS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"los_hwidump.c",
"los_stackdump.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]
}
config("public") {
include_dirs = [ "." ]
}

View File

@@ -1,60 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_DEBUGTOOLS_H
#define _LOS_DEBUGTOOLS_H
#include "los_config.h"
#include "los_task.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define PRINT_PER_ROW 4
/* Shell Callback */
extern UINT32 OsShellCmdStackDump(INT32 argc, const CHAR **argv);
extern UINT32 OsShellCmdHwiDump(INT32 argc, const CHAR **argv);
/* other module Callback */
/* External Interface */
extern VOID LOS_TaskStackDump(UINT32 taskID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif

View File

@@ -1,149 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_debugtools.h"
#include "securec.h"
#include "los_debug.h"
#include "los_memory.h"
#include "los_arch.h"
#include "los_interrupt.h"
#include "los_arch_interrupt.h"
#if (LOSCFG_DEBUG_TOOLS == 1)
#if (LOSCFG_CPUP_INCLUDE_IRQ == 1) && (LOSCFG_BASE_CORE_SWTMR == 1)
#include "los_cpup.h"
#define IRQ_CPUP_INFO_SIZE (sizeof(CPUP_INFO_S) * LOSCFG_PLATFORM_HWI_LIMIT)
#define IRQ_CPUP_ALL_INFO_SIZE (IRQ_CPUP_INFO_SIZE + IRQ_CPUP_INFO_SIZE)
#define IRQ_DATA_SIZE sizeof(OsIrqCpupCB)
#define CPUP_PRECISION_MULT LOS_CPUP_PRECISION_MULT
STATIC VOID ShellCmdHwiInfoShow(OsIrqCpupCB *irqData, CPUP_INFO_S *hwiCpup1s,
CPUP_INFO_S *hwiCpup10s)
{
UINT32 i;
UINT32 intSave;
UINT32 count;
UINT64 cycles = 0;
UINT64 timeMax = 0;
CHAR *irqName = NULL;
OsIrqCpupCB *irqDataBase = OsGetIrqCpupArrayBase();
if (irqDataBase == NULL) {
PRINT_ERR("get hwi info error\n");
return;
}
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue;
}
intSave = LOS_IntLock();
(VOID)memcpy_s(irqData, IRQ_DATA_SIZE, &irqDataBase[i], IRQ_DATA_SIZE);
LOS_IntRestore(intSave);
if (irqData->status == 0) {
continue;
}
count = OsGetHwiFormCnt(i);
if (count != 0) {
if (irqData->count != 0) {
cycles = (irqData->allTime * OS_NS_PER_CYCLE) / (irqData->count * OS_SYS_NS_PER_US);
}
timeMax = (irqData->timeMax * OS_NS_PER_CYCLE) / OS_SYS_NS_PER_US;
}
irqName = OsGetHwiFormName(i);
PRINTK(" %10u:%11u%11llu%10llu%9u.%-2u%9u.%-2u %-12s\n", i - OS_SYS_VECTOR_CNT, count, cycles, timeMax,
hwiCpup1s[i].uwUsage / CPUP_PRECISION_MULT, hwiCpup1s[i].uwUsage % CPUP_PRECISION_MULT,
hwiCpup10s[i].uwUsage / CPUP_PRECISION_MULT, hwiCpup10s[i].uwUsage % CPUP_PRECISION_MULT,
(irqName != NULL) ? irqName : NULL);
}
}
STATIC VOID HwiInfoDump(VOID)
{
UINT32 size;
size = IRQ_CPUP_ALL_INFO_SIZE + IRQ_DATA_SIZE;
CHAR *irqCpup = LOS_MemAlloc(m_aucSysMem0, size);
if (irqCpup == NULL) {
return;
}
CPUP_INFO_S *hwiCpup10s = (CPUP_INFO_S *)(irqCpup);
CPUP_INFO_S *hwiCpup1s = (CPUP_INFO_S *)(hwiCpup10s + IRQ_CPUP_INFO_SIZE);
OsIrqCpupCB *irqData = (OsIrqCpupCB *)(irqCpup + IRQ_CPUP_ALL_INFO_SIZE);
(VOID)LOS_GetAllIrqCpuUsage(CPUP_IN_1S, hwiCpup1s);
(VOID)LOS_GetAllIrqCpuUsage(CPUP_IN_10S, hwiCpup10s);
PRINTK(" InterruptNo Count ATime(us) MTime(us) CPUUSE1s CPUUSE10s Name\n");
ShellCmdHwiInfoShow(irqData, hwiCpup1s, hwiCpup10s);
(VOID)LOS_MemFree(m_aucSysMem0, irqCpup);
return;
}
#else
STATIC VOID HwiInfoDump(VOID)
{
INT32 i;
PRINTK(" InterruptNo Count Name\n");
for (i = 0; i < LOSCFG_PLATFORM_HWI_LIMIT; i++) {
if ((OsGetHwiCreated(i) != TRUE) || (OsGetHwiFormCnt(i) == 0)) {
continue;
}
if (OsGetHwiFormName(i) != NULL) {
PRINTK(" %8d:%10d %-s\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i), OsGetHwiFormName(i));
} else {
PRINTK(" %8d:%10d\n", i - OS_SYS_VECTOR_CNT, OsGetHwiFormCnt(i));
}
}
return;
}
#endif
UINT32 OsShellCmdHwiDump(INT32 argc, const CHAR **argv)
{
(VOID)argv;
if (argc > 1) {
PRINT_ERR("\nUsage:hwi\n");
return LOS_NOK;
}
HwiInfoDump();
return LOS_OK;
}
#endif /* LOSCFG_STACK_DUMP == 1 */

View File

@@ -1,155 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_debugtools.h"
#include "securec.h"
#include "los_debug.h"
#include "los_memory.h"
#include "los_arch.h"
#if (LOSCFG_DEBUG_TOOLS == 1)
typedef struct {
UINT32 waterLine;
UINT32 taskSPTop;
UINT32 taskSPLimit;
UINTPTR taskSP;
} DumpInfo;
STATIC VOID ShowFormat(UINTPTR *buf, DumpInfo *info)
{
INT32 i;
UINT32 len = info->waterLine / sizeof(UINTPTR);
UINTPTR addr = (info->taskSPLimit - info->waterLine);
for (i = 0; i < len; i++) {
if ((i % PRINT_PER_ROW) == 0) {
PRINTK("\r\n 0x%08x: ", addr);
}
if (addr == info->taskSP) {
PRINTK(" *%08x", buf[i]);
} else {
PRINTK(" %08x", buf[i]);
}
addr += sizeof(UINTPTR);
}
PRINTK("\r\n");
}
STATIC INT32 DumpTaskInfo(UINT32 taskID, UINTPTR *buf, DumpInfo *info)
{
errno_t ret;
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
if (taskID == LOS_CurTaskIDGet()) {
info->taskSP = ArchSpGet();
} else {
info->taskSP = (UINTPTR)taskCB->stackPointer;
}
info->taskSPTop = taskCB->topOfStack;
info->taskSPLimit = taskCB->topOfStack + taskCB->stackSize;
if ((info->taskSP > info->taskSPLimit) || (info->taskSP < info->taskSPTop)) {
return LOS_NOK;
}
ret = memcpy_s(buf, info->waterLine, (const VOID *)(info->taskSPLimit - info->waterLine), info->waterLine);
if (ret != EOK) {
return LOS_NOK;
}
return LOS_OK;
}
VOID LOS_TaskStackDump(UINT32 taskID)
{
UINTPTR *buf = NULL;
DumpInfo info;
UINT32 intSave;
INT32 ret;
if (taskID > g_taskMaxNum) {
PRINT_ERR("error taskID %u\r\n", taskID);
return;
}
if (OS_INT_ACTIVE) {
PRINT_ERR("called during an interrupt.\r\n");
return;
}
intSave = LOS_IntLock();
info.waterLine = OsGetTaskWaterLine(taskID);
if (info.waterLine == OS_NULL_INT) {
LOS_IntRestore(intSave);
return;
}
buf = (UINTPTR *)LOS_MemAlloc(OS_SYS_MEM_ADDR, info.waterLine);
if (buf == NULL) {
LOS_IntRestore(intSave);
PRINT_ERR("alloc failed for dump\n");
return;
}
(VOID)memset_s(buf, info.waterLine, 0, info.waterLine);
ret = DumpTaskInfo(taskID, buf, &info);
if (ret != LOS_OK) {
LOS_IntRestore(intSave);
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, buf);
PRINT_ERR("SP 0x%x may error or memcpy_s failed, stack space from 0x%x to 0x%x\r\n", \
info.taskSP, info.taskSPTop, info.taskSPLimit);
return;
}
LOS_IntRestore(intSave);
PRINTK("Task %u, SP 0x%x, WaterLine 0x%x", taskID, info.taskSP, info.waterLine);
ShowFormat(buf, &info);
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, buf);
return;
}
UINT32 OsShellCmdStackDump(INT32 argc, const CHAR **argv)
{
UINT32 taskID;
if (argc != 1) {
PRINT_ERR("\nUsage: stack taskID\n");
return LOS_NOK;
}
taskID = (UINT32)atoi(argv[0]);
LOS_TaskStackDump(taskID);
return LOS_OK;
}
#endif /* LOSCFG_STACK_DUMP == 1 */

View File

@@ -36,3 +36,39 @@ config FS_FAT
help
Answer Y to enable LiteOS support fat filesystem.
config FS_FAT_CACHE
bool "Enable FAT Cache"
default y
depends on FS_FAT
help
Answer Y to enable LiteOS fat filesystem support cache.
config FS_FAT_CACHE_SYNC_THREAD
bool "Enable FAT Cache Sync Thread"
default n
depends on FS_FAT_CACHE
help
Answer Y to enable LiteOS fat filesystem support cache sync thread.
config FS_FAT_CHINESE
bool "Enable Chinese"
default y
depends on FS_FAT
help
Answer Y to enable LiteOS fat filesystem support Chinese.
config FS_FAT_VIRTUAL_PARTITION
bool "Enabel Virtual Partition"
default n
depends on FS_FAT
config FS_FAT_VOLUMES
int
depends on FS_FAT
default 32 if PLATFORM_HI3731
default 16
config FS_FAT_DISK
bool "Enable partinfo for storage device"
depends on FS_FAT
default y

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,14 @@
#ifndef _FATFS_H
#define _FATFS_H
#include "ff.h"
#include "dirent.h"
#include "fatfs_conf.h"
#include "fcntl.h"
#include "fs_config.h"
#include "sys/mount.h"
#include "sys/stat.h"
#include "sys/statfs.h"
#include "unistd.h"
#ifdef __cplusplus
#if __cplusplus
@@ -40,7 +47,58 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
void FatFsInit(void);
int fatfs_mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
int fatfs_umount(const char *target);
int fatfs_umount2(const char *target, int flag);
int fatfs_open(const char *path, int oflag, ...);
int fatfs_close(int fd);
ssize_t fatfs_read(int fd, void *buf, size_t nbyte);
ssize_t fatfs_write(int fd, const void *buf, size_t nbyte);
off_t fatfs_lseek(int fd, off_t offset, int whence);
int fatfs_unlink(const char *path);
int fatfs_fstat(int fd, struct stat *buf);
int fatfs_stat(const char *path, struct stat *buf);
int fatfs_fsync(int fd);
int fatfs_mkdir(const char *path, mode_t mode);
DIR *fatfs_opendir(const char *dirName);
struct dirent *fatfs_readdir(DIR *dir);
int fatfs_closedir(DIR *dir);
int fatfs_rmdir(const char *path);
int fatfs_rename(const char *oldName, const char *newName);
int fatfs_statfs(const char *path, struct statfs *buf);
int fatfs_ftruncate(int fd, off_t length);
ssize_t fatfs_pread(int fd, void *buf, size_t nbyte, off_t offset);
ssize_t fatfs_pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
/**
* @brief divide a physical drive (SD card, U disk, and MMC card), this function is OHOS-specific
* @param pdrv physical drive number.
* @param partTbl list of partition size to create on the drive.
* -- item is <= 100: specifies the partition size in percentage of the entire drive space.
* -- item is > 100: specifies number of sectors.
* @return fdisk result
* @retval -1 fdisk error
* @retval 0 fdisk successful
*/
int fatfs_fdisk(int pdrv, const unsigned int *partTbl);
/**
* @brief format FAT device (SD card, U disk, and MMC card), this function is OHOS-specific
* @param dev device name.
* @param sectors sectors per cluster, can be 0 OR power of 2. The sector size for standard FAT volumes is 512 bytes.
* -- sector number is 0 OR >128: automatically choose the appropriate cluster size.
* -- sector number is 1 ~ 128: cluster size = sectors per cluster * 512B.
* @param option file system type.
* -- FMT_FAT
* -- FMT_FAT32
* -- FMT_ANY
* @return format result
* @retval -1 format error
* @retval 0 format successful
*/
int fatfs_format(const char *dev, int sectors, int option);
#ifdef __cplusplus
#if __cplusplus

View File

@@ -34,7 +34,7 @@ module_switch = defined(LOSCFG_FS_LITTLEFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
configs += [ "$LITEOSTOPDIR:warn_config" ]
sources = LITTLEFS_SRC_FILES_FOR_KERNEL_MODULE + [ "lfs_adapter.c" ]
sources = LITTLEFS_SRC_FILES_FOR_KERNEL_MODULE + [ "lfs_api.c" ]
}
config("public") {

View File

@@ -1,596 +0,0 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE 1
#include "lfs_adapter.h"
#include "los_config.h"
#include "vfs_files.h"
#include "vfs_operations.h"
#include "vfs_partition.h"
#include "vfs_maps.h"
#include "vfs_mount.h"
#include "securec.h"
struct dirent g_nameValue;
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
static int ConvertFlagToLfsOpenFlag (int oflags)
{
int lfsOpenFlag = 0;
if (oflags & O_CREAT) {
lfsOpenFlag |= LFS_O_CREAT;
}
if (oflags & O_EXCL) {
lfsOpenFlag |= LFS_O_EXCL;
}
if (oflags & O_TRUNC) {
lfsOpenFlag |= LFS_O_TRUNC;
}
if (oflags & O_APPEND) {
lfsOpenFlag |= LFS_O_APPEND;
}
if (oflags & O_RDWR) {
lfsOpenFlag |= LFS_O_RDWR;
}
if (oflags & O_WRONLY) {
lfsOpenFlag |= LFS_O_WRONLY;
}
if (oflags == O_RDONLY) {
lfsOpenFlag |= LFS_O_RDONLY;
}
return lfsOpenFlag;
}
static int LittlefsErrno(int result)
{
return (result < 0) ? -result : result;
}
int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
{
int ret;
lfs_t *mountHdl = NULL;
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
errno = EFAULT;
ret = LOS_NOK;
goto errout;
}
mountHdl = (lfs_t *)malloc(sizeof(lfs_t));
if (mountHdl == NULL) {
errno = ENODEV;
ret = LOS_NOK;
goto errout;
}
(void)memset_s(mountHdl, sizeof(lfs_t), 0, sizeof(lfs_t));
mp->mData = (void *)mountHdl;
ret = lfs_mount((lfs_t *)mp->mData, (struct lfs_config *)data);
if (ret != 0) {
ret = lfs_format((lfs_t *)mp->mData, (struct lfs_config*)data);
if (ret == 0) {
ret = lfs_mount((lfs_t *)mp->mData, (struct lfs_config*)data);
}
}
if (ret != 0) {
free(mountHdl);
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
errout:
return ret;
}
int LfsUmount(struct MountPoint *mp)
{
int ret;
if (mp == NULL) {
errno = EFAULT;
return LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
}
ret = lfs_unmount((lfs_t *)mp->mData);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
free(mp->mData);
mp->mData = NULL;
return ret;
}
int LfsUnlink(struct MountPoint *mp, const char *fileName)
{
int ret;
if ((mp == NULL) || (fileName == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
}
ret = lfs_remove((lfs_t *)mp->mData, fileName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
int LfsMkdir(struct MountPoint *mp, const char *dirName)
{
int ret;
if ((dirName == NULL) || (mp == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
}
lfs_t *lfs = (lfs_t *)mp->mData;
ret = lfs_mkdir(lfs, dirName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
int LfsRmdir(struct MountPoint *mp, const char *dirName)
{
int ret;
lfs_t *lfs = NULL;
if (mp == NULL) {
errno = EFAULT;
return LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
}
lfs = (lfs_t *)mp->mData;
if (dirName == NULL) {
errno = EFAULT;
return LOS_NOK;
}
ret = lfs_remove(lfs, dirName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
int LfsOpendir(struct Dir *dir, const char *dirName)
{
int ret;
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) {
errno = EFAULT;
return 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;
}
(void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t));
ret = lfs_dir_open(lfs, dirInfo, dirName);
if (ret != 0) {
free(dirInfo);
errno = LittlefsErrno(ret);
goto errout;
}
dir->dData = dirInfo;
dir->dOffset = 0;
return LOS_OK;
errout:
return LOS_NOK;
}
int LfsReaddir(struct Dir *dir, struct dirent *dent)
{
int ret;
struct lfs_info lfsInfo;
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL) ||
(dent == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
if (dir->dData == NULL) {
errno = EBADF;
return LOS_NOK;
}
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
lfs_dir_t *dirInfo = (lfs_dir_t *)dir->dData;
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
if (ret == TRUE) {
pthread_mutex_lock(&g_FslocalMutex);
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
if (lfsInfo.type == LFS_TYPE_DIR) {
dent->d_type = DT_DIR;
} else if (lfsInfo.type == LFS_TYPE_REG) {
dent->d_type = DT_REG;
}
dent->d_reclen = lfsInfo.size;
pthread_mutex_unlock(&g_FslocalMutex);
return LOS_OK;
}
if (ret != 0) {
errno = LittlefsErrno(ret);
}
return LOS_NOK;
}
int LfsClosedir(struct Dir *dir)
{
int ret;
if ((dir == NULL) || (dir->dMp == NULL) || (dir->dMp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
if (dir->dData == NULL) {
errno = EBADF;
return LOS_NOK;
}
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
lfs_dir_t *dirInfo = (lfs_dir_t *)dir->dData;
ret = lfs_dir_close(lfs, dirInfo);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
free(dirInfo);
dir->dData = NULL;
return ret;
}
int LfsOpen(struct File *file, const char *pathName, int openFlag)
{
int ret;
lfs_file_t *lfsHandle = NULL;
if ((pathName == NULL) || (file == NULL) || (file->fMp == NULL) ||
(file->fMp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
lfsHandle = (lfs_file_t *)malloc(sizeof(lfs_file_t));
if (lfsHandle == NULL) {
errno = ENOMEM;
return LOS_NOK;
}
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
ret = lfs_file_open((lfs_t *)file->fMp->mData, lfsHandle, pathName, lfsOpenFlag);
if (ret != 0) {
free(lfsHandle);
errno = LittlefsErrno(ret);
goto errout;
}
file->fData = (void *)lfsHandle;
return ret;
errout:
return INVALID_FD;
}
int LfsRead(struct File *file, char *buf, size_t len)
{
int ret;
struct MountPoint *mp = NULL;
lfs_file_t *lfsHandle = NULL;
if (buf == NULL) {
errno = EFAULT;
return LOS_NOK;
}
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
ret = lfs_file_read((lfs_t *)mp->mData, lfsHandle, buf, len);
if (ret < 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
int LfsWrite(struct File *file, const char *buf, size_t len)
{
int ret;
struct MountPoint *mp = NULL;
lfs_file_t *lfsHandle = NULL;
if (buf == NULL) {
errno = EFAULT;
return LOS_NOK;
}
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
ret = lfs_file_write((lfs_t *)mp->mData, lfsHandle, buf, len);
if (ret < 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
off_t LfsSeek(struct File *file, off_t offset, int whence)
{
off_t ret;
struct MountPoint *mp = NULL;
lfs_file_t *lfsHandle = NULL;
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
ret = (off_t)lfs_file_seek((lfs_t *)mp->mData, lfsHandle, offset, whence);
if (ret < 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
int LfsClose(struct File *file)
{
INT32 ret;
struct MountPoint *mp = NULL;
lfs_file_t *lfsHandle = NULL;
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
}
lfsHandle = (lfs_file_t *)file->fData;
mp = file->fMp;
if ((mp == NULL) || (mp->mData == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
pthread_mutex_lock(&g_FslocalMutex);
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
pthread_mutex_unlock(&g_FslocalMutex);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
free(file->fData);
file->fData = NULL;
return ret;
}
int LfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
{
int ret;
if ((mp == NULL) || (oldName == NULL) || (newName == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
}
ret = lfs_rename((lfs_t *)mp->mData, oldName, newName);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
int LfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
{
int ret;
struct lfs_info info;
if ((mp == NULL) || (path == NULL) || (buf == NULL)) {
errno = EFAULT;
return LOS_NOK;
}
if (mp->mData == NULL) {
errno = ENOENT;
return LOS_NOK;
}
ret = lfs_stat((lfs_t *)mp->mData, path, &info);
if (ret == 0) {
buf->st_size = info.size;
if (info.type == LFS_TYPE_REG) {
buf->st_mode = S_IFREG;
} else {
buf->st_mode = S_IFDIR;
}
} else {
errno = LittlefsErrno(ret);
ret = LOS_NOK;
}
return ret;
}
int LfsSync(struct File *file)
{
int ret;
struct MountPoint *mp = NULL;
if ((file == NULL) || (file->fData == NULL)) {
errno = EBADF;
return LOS_NOK;
}
if ((file->fMp == NULL) || (file->fMp->mData == NULL)) {
errno = EFAULT;
return 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;
}
return ret;
}
static struct MountOps g_lfsMnt = {
.mount = LfsMount,
.umount = LfsUmount,
.umount2 = NULL,
.statfs = NULL,
};
static struct FileOps g_lfsFops = {
.open = LfsOpen,
.close = LfsClose,
.read = LfsRead,
.write = LfsWrite,
.lseek = LfsSeek,
.stat = LfsStat,
.truncate = NULL,
.unlink = LfsUnlink,
.rename = LfsRename,
.ioctl = NULL, /* not support */
.sync = LfsSync,
.rmdir = LfsRmdir,
.opendir = LfsOpendir,
.readdir = LfsReaddir,
.closedir = LfsClosedir,
.mkdir = LfsMkdir,
};
static struct FsManagement g_lfsMgt = {
.fdisk = NULL,
.format = NULL,
};
void LfsInit(void)
{
(void)OsFsRegister("littlefs", &g_lfsMnt, &g_lfsFops, &g_lfsMgt);
}

File diff suppressed because it is too large Load Diff

View File

@@ -29,22 +29,75 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LFS_ADAPTER_H_
#define _LFS_ADAPTER_H_
#ifndef _LFS_API_H_
#define _LFS_API_H_
#include "fcntl.h"
#include "sys/stat.h"
#include "dirent.h"
#include "errno.h"
#include "vfs_operations.h"
#include "fs_operations.h"
#include "lfs.h"
#include "lfs_conf.h"
#include "lfs_util.h"
#include "memory.h"
#include "pthread.h"
#define INVALID_FD (-1)
void LfsInit(void);
#endif /* _LFS_ADAPTER_H_ */
#ifndef VFS_ERROR
#define VFS_ERROR (-1)
#endif
#ifndef VFS_OK
#define VFS_OK 0
#endif
typedef struct {
uint8_t useFlag;
const char *pathName;
lfs_t *lfsHandle;
lfs_file_t file;
} LittleFsHandleStruct;
struct FileOpInfo {
uint8_t useFlag;
const struct FileOps *fsVops;
char *dirName;
lfs_t lfsInfo;
};
typedef struct {
uint8_t useFlag;
char *dirName;
lfs_t *lfsHandle;
lfs_dir_t dir;
} FileDirInfo;
LittleFsHandleStruct *GetFreeFd(int *fd);
int LfsMount(const char *source, const char *target, const char *fileSystemType, unsigned long mountflags,
const void *data);
int LfsUmount(const char *target);
int LfsUnlink(const char *fileName);
int LfsMkdir(const char *dirName, mode_t mode);
int LfsRmdir(const char *dirName);
DIR *LfsOpendir(const char *dirName);
struct dirent *LfsReaddir(DIR *dir);
int LfsClosedir(DIR *dir);
int LfsOpen(const char *pathName, int openFlag, ...);
int LfsRead(int fd, void *buf, unsigned int len);
int LfsWrite(int fd, const void *buf, unsigned int len);
off_t LfsSeek(int fd, off_t offset, int whence);
int LfsClose(int fd);
int LfsRename(const char *oldName, const char *newName);
int LfsStat(const char *path, struct stat *buf);
int LfsFsync(int fd);
int LfsFstat(int fd, struct stat *buf);
int SetDefaultMountPath(int pathNameIndex, const char* target);
int LfsPread(int fd, void *buf, size_t nbyte, off_t offset);
int LfsPwrite(int fd, const void *buf, size_t nbyte, off_t offset);
#endif /* _LFS_API_H_ */

View File

@@ -1,4 +1,5 @@
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@@ -31,26 +32,7 @@ import("//kernel/liteos_m/liteos.gni")
module_switch = defined(LOSCFG_FS_VFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"vfs_files.c",
"vfs_fs.c",
"vfs_init.c",
"vfs_maps.c",
"vfs_mount.c",
"vfs_partition.c",
]
include_dirs = [
"//kernel/liteos_m/kernel/arch/include",
"//kernel/liteos_m/kernel/include",
"//kernel/liteos_m/utils",
"../",
".",
]
deps = [ "//kernel/liteos_m/kal" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
cflags = [ "-Wno-parentheses" ]
sources = [ "los_fs.c" ]
}
config("public") {

View File

@@ -1,5 +1,5 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
@@ -30,6 +30,5 @@
config FS_VFS
bool "Enable FS VFS"
default y
help
Answer Y to enable LiteOS support VFS.

View File

@@ -0,0 +1,82 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FS_OPERATIONS_H_
#define _FS_OPERATIONS_H_
#include "fcntl.h"
#include "dirent.h"
#include "unistd.h"
#include "sys/mount.h"
#include "sys/stat.h"
#include "sys/statfs.h"
#define FS_SUCCESS 0
#define FS_FAILURE (-1)
#define MAX_FILESYSTEM_LEN 2
struct MountOps {
int (*Mount)(const char *source, const char *target, const char *filesystemtype, unsigned long mountflags,
const void *data);
int (*Umount)(const char* target);
int (*Umount2)(const char* target, int flag);
int (*Statfs)(const char *path, struct statfs *buf);
};
struct FsMap {
const char *fileSystemtype;
const struct MountOps *fsMops;
const struct FileOps *fsFops;
};
struct FileOps {
int (*Open)(const char *path, int openFlag, ...);
int (*Close)(int fd);
int (*Unlink)(const char *fileName);
int (*Rmdir)(const char *dirName);
int (*Mkdir)(const char *dirName, mode_t mode);
struct dirent *(*Readdir)(DIR *dir);
DIR *(*Opendir)(const char *dirName);
int (*Closedir)(DIR *dir);
int (*Read)(int fd, void *buf, size_t len);
int (*Write)(int fd, const void *buf, size_t len);
off_t (*Seek)(int fd, off_t offset, int whence);
int (*Getattr)(const char *path, struct stat *buf);
int (*Rename)(const char *oldName, const char *newName);
int (*Fsync)(int fd);
int (*Fstat)(int fd, struct stat *buf);
int (*Stat)(const char *path, struct stat *buf);
int (*Ftruncate)(int fd, off_t length);
int (*Pread)(int fd, void *buf, size_t nbyte, off_t offset);
int (*Pwrite)(int fd, const void *buf, size_t nbyte, off_t offset);
};
#endif /* _FS_OPERATIONS_H_ */

653
components/fs/vfs/los_fs.c Normal file
View File

@@ -0,0 +1,653 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_fs.h"
#include "los_config.h"
#include "fs_operations.h"
#if (LOSCFG_SUPPORT_FATFS == 1)
#include "fatfs.h"
#endif
#include "dirent.h"
#include "errno.h"
#include "fcntl.h"
#include "securec.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "sys/mount.h"
#include "sys/statfs.h"
#include "sys/stat.h"
#include "unistd.h"
#ifdef LOSCFG_NET_LWIP_SACK
#define _BSD_SOURCE
#include "lwip/sockets.h"
#endif
#include "vfs_config.h"
#ifdef LOSCFG_RANDOM_DEV
#include "hks_client.h"
#define RANDOM_DEV_FD CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS
#define RANDOM_DEV_PATH "/dev/random"
#endif
#if (LOSCFG_POSIX_PIPE_API == 1)
#include "pipe_impl.h"
#ifdef LOSCFG_RANDOM_DEV
#define PIPE_DEV_FD (RANDOM_DEV_FD + 1)
#else
#define PIPE_DEV_FD (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)
#endif
int PollQueryFd(int fd, struct PollTable *table)
{
if (fd >= PIPE_DEV_FD) {
return PipePoll(fd, table);
}
return -ENODEV;
}
#endif
#define FREE_AND_SET_NULL(ptr) do { \
free(ptr); \
ptr = NULL; \
} while (0)
#ifdef LOSCFG_RANDOM_DEV
/**
* @brief Get canonical form of a given path based on cwd(Current working directory).
*
* @param cwd Indicates the current working directory.
* @param path Indicates the path to be canonicalization.
* @param buf Indicates the pointer to the buffer where the result will be return.
* @param bufSize Indicates the size of the buffer.
* @return Returns the length of the canonical path.
*
* @attention if path is an absolute path, cwd is ignored. if cwd if not specified, it is assumed to be root('/').
* if the buffer is not big enough the result will be truncated, but the return value will always be the
* length of the canonical path.
*/
static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, size_t bufSize)
{
size_t offset;
if (!path) {
path = "";
}
if (!cwd || path[0] == '/') {
cwd = "";
}
offset = strlen("///") + 1; // three '/' and one '\0'
size_t tmpLen = strlen(cwd) + strlen(path) + offset;
char *tmpBuf = (char *)malloc(tmpLen);
if (tmpBuf == NULL) {
return FS_SUCCESS;
}
if (-1 == sprintf_s(tmpBuf, tmpLen, "/%s/%s/", cwd, path)) {
free(tmpBuf);
return FS_SUCCESS;
}
char *p;
/* replace /./ to / */
offset = strlen("/./") - 1;
while ((p = strstr(tmpBuf, "/./")) != NULL) {
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
return FS_SUCCESS;
}
}
/* replace // to / */
while ((p = strstr(tmpBuf, "//")) != NULL) {
if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + 1, tmpLen - (p - tmpBuf) - 1)) {
free(tmpBuf);
return FS_SUCCESS;
}
}
/* handle /../ (e.g., replace /aa/bb/../ to /aa/) */
offset = strlen("/../") - 1;
while ((p = strstr(tmpBuf, "/../")) != NULL) {
char *start = p;
while (start > tmpBuf && *(start - 1) != '/') {
--start;
}
if (EOK != memmove_s(start, tmpLen - (start - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
return FS_SUCCESS;
}
}
size_t totalLen = strlen(tmpBuf);
/* strip the last / */
if (totalLen > 1 && tmpBuf[totalLen - 1] == '/') {
tmpBuf[--totalLen] = 0;
}
if (!buf || bufSize == 0) {
free(tmpBuf);
return totalLen;
}
if (EOK != memcpy_s(buf, bufSize, tmpBuf, (((totalLen + 1) > bufSize) ? bufSize : (totalLen + 1)))) {
free(tmpBuf);
return FS_SUCCESS;
}
buf[bufSize - 1] = 0;
free(tmpBuf);
return totalLen;
}
#endif
static struct FsMap g_fsmap[MAX_FILESYSTEM_LEN] = {0};
static struct FsMap *g_fs = NULL;
static void InitMountInfo(void)
{
#if (LOSCFG_SUPPORT_FATFS == 1)
extern struct MountOps g_fatfsMnt;
extern struct FileOps g_fatfsFops;
g_fsmap[0].fileSystemtype = strdup("fat");
g_fsmap[0].fsMops = &g_fatfsMnt;
g_fsmap[0].fsFops = &g_fatfsFops;
#endif
#if (LOSCFG_SUPPORT_LITTLEFS == 1)
extern struct MountOps g_lfsMnt;
extern struct FileOps g_lfsFops;
g_fsmap[1].fileSystemtype = strdup("littlefs");
g_fsmap[1].fsMops = &g_lfsMnt;
g_fsmap[1].fsFops = &g_lfsFops;
#endif
}
static struct FsMap *MountFindfs(const char *fileSystemtype)
{
struct FsMap *m = NULL;
for (int i = 0; i < MAX_FILESYSTEM_LEN; i++) {
m = &(g_fsmap[i]);
if (m->fileSystemtype && strcmp(fileSystemtype, m->fileSystemtype) == 0) {
return m;
}
}
return NULL;
}
int LOS_FsMount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data)
{
static int initFlag = 0;
if (initFlag == 0) {
InitMountInfo();
initFlag = 1;
}
g_fs = MountFindfs(filesystemtype);
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Mount == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Mount(source, target, filesystemtype, mountflags, data);
}
int LOS_FsUmount(const char *target)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Umount == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Umount(target);
}
int LOS_FsUmount2(const char *target, int flag)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Umount2 == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Umount2(target, flag);
}
int LOS_Open(const char *path, int oflag, ...)
{
#ifdef LOSCFG_RANDOM_DEV
unsigned flags = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY;
if ((unsigned)oflag & ~flags) {
errno = EINVAL;
return FS_FAILURE;
}
size_t pathLen = strlen(path) + 1;
if ((unsigned)pathLen > PATH_MAX) {
errno = EINVAL;
return FS_FAILURE;
}
char *canonicalPath = (char *)malloc(pathLen);
if (!canonicalPath) {
errno = ENOMEM;
return FS_FAILURE;
}
if (GetCanonicalPath(NULL, path, canonicalPath, pathLen) == 0) {
FREE_AND_SET_NULL(canonicalPath);
errno = ENOMEM;
return FS_FAILURE;
}
if (strcmp(canonicalPath, RANDOM_DEV_PATH) == 0) {
FREE_AND_SET_NULL(canonicalPath);
if ((O_ACCMODE & (unsigned)oflag) != O_RDONLY) {
errno = EPERM;
return FS_FAILURE;
}
if ((unsigned)oflag & O_DIRECTORY) {
errno = ENOTDIR;
return FS_FAILURE;
}
return RANDOM_DEV_FD;
}
if (strcmp(canonicalPath, "/") == 0 || strcmp(canonicalPath, "/dev") == 0) {
FREE_AND_SET_NULL(canonicalPath);
if ((unsigned)oflag & O_DIRECTORY) {
errno = EPERM;
return FS_FAILURE;
}
errno = EISDIR;
return FS_FAILURE;
}
FREE_AND_SET_NULL(canonicalPath);
#endif
#if (LOSCFG_POSIX_PIPE_API == 1)
if ((path != NULL) && !strncmp(path, PIPE_DEV_PATH, strlen(PIPE_DEV_PATH))) {
return PipeOpen(path, oflag, PIPE_DEV_FD);
}
#endif
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Open == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Open(path, oflag);
}
int LOS_Close(int fd)
{
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
return FS_SUCCESS;
}
#endif
#ifdef LOSCFG_NET_LWIP_SACK
if (fd >= CONFIG_NFILE_DESCRIPTORS && fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) {
return closesocket(fd);
}
#endif
#if (LOSCFG_POSIX_PIPE_API == 1)
if (fd >= PIPE_DEV_FD) {
return PipeClose(fd);
}
#endif
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Close == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Close(fd);
}
ssize_t LOS_Read(int fd, void *buf, size_t nbyte)
{
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
if (nbyte == 0) {
return FS_SUCCESS;
}
if (buf == NULL) {
errno = EINVAL;
return FS_FAILURE;
}
if (nbyte > 1024) { /* 1024, max random_size */
nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */
}
struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte};
if (hks_generate_random(&key) != 0) {
errno = EIO;
return FS_FAILURE;
}
return (ssize_t)nbyte;
}
#endif
#ifdef LOSCFG_NET_LWIP_SACK
if (fd >= CONFIG_NFILE_DESCRIPTORS && fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) {
return recv(fd, buf, nbyte, 0);
}
#endif
#if (LOSCFG_POSIX_PIPE_API == 1)
if (fd >= PIPE_DEV_FD) {
return PipeRead(fd, buf, nbyte);
}
#endif
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Read == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Read(fd, buf, nbyte);
}
ssize_t LOS_Write(int fd, const void *buf, size_t nbyte)
{
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
errno = EBADF; /* "/dev/random" is readonly */
return FS_FAILURE;
}
#endif
#ifdef LOSCFG_NET_LWIP_SACK
if (fd >= CONFIG_NFILE_DESCRIPTORS && fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) {
return send(fd, buf, nbyte, 0);
}
#endif
#if (LOSCFG_POSIX_PIPE_API == 1)
if (fd >= PIPE_DEV_FD) {
return PipeWrite(fd, buf, nbyte);
}
#endif
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Write == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Write(fd, buf, nbyte);
}
off_t LOS_Lseek(int fd, off_t offset, int whence)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Seek == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Seek(fd, offset, whence);
}
int LOS_Unlink(const char *path)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Unlink == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Unlink(path);
}
int LOS_Fstat(int fd, struct stat *buf)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Fstat == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Fstat(fd, buf);
}
int LOS_Stat(const char *path, struct stat *buf)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Getattr == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Getattr(path, buf);
}
int LOS_Fsync(int fd)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Fsync == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Fsync(fd);
}
int LOS_Mkdir(const char *path, mode_t mode)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Mkdir == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Mkdir(path, mode);
}
DIR *LOS_Opendir(const char *dirName)
{
if (g_fs == NULL) {
errno = ENODEV;
return NULL;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Opendir == NULL) {
errno = ENOSYS;
return NULL;
}
return g_fs->fsFops->Opendir(dirName);
}
struct dirent *LOS_Readdir(DIR *dir)
{
if (g_fs == NULL) {
errno = ENODEV;
return NULL;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Readdir == NULL) {
errno = ENOSYS;
return NULL;
}
return g_fs->fsFops->Readdir(dir);
}
int LOS_Closedir(DIR *dir)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Closedir == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Closedir(dir);
}
int LOS_Rmdir(const char *path)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Rmdir == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Rmdir(path);
}
int LOS_Rename(const char *oldName, const char *newName)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Rename == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Rename(oldName, newName);
}
int LOS_Statfs(const char *path, struct statfs *buf)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsMops == NULL || g_fs->fsMops->Statfs == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsMops->Statfs(path, buf);
}
int LOS_Ftruncate(int fd, off_t length)
{
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Ftruncate == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Ftruncate(fd, length);
}
ssize_t LOS_Pread(int fd, void *buf, size_t nbyte, off_t offset)
{
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
if (nbyte == 0) {
return FS_SUCCESS;
}
if (buf == NULL) {
errno = EINVAL;
return FS_FAILURE;
}
if (nbyte > 1024) { /* 1024, max random_size */
nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */
}
struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte};
if (hks_generate_random(&key) != 0) {
errno = EIO;
return FS_FAILURE;
}
return (ssize_t)nbyte;
}
#endif
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Pread == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Pread(fd, buf, nbyte, offset);
}
ssize_t LOS_Pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
{
#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
errno = EBADF; /* "/dev/random" is readonly */
return FS_FAILURE;
}
#endif
if (g_fs == NULL) {
errno = ENODEV;
return FS_FAILURE;
}
if (g_fs->fsFops == NULL || g_fs->fsFops->Pwrite == NULL) {
errno = ENOSYS;
return FS_FAILURE;
}
return g_fs->fsFops->Pwrite(fd, buf, nbyte, offset);
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -30,19 +30,18 @@
*/
/**
* @defgroup los_fs fs
* @defgroup los_vfs fs
* @ingroup kernel
*/
#ifndef _LOS_FS_H_
#define _LOS_FS_H_
#ifndef _LOS_VFS_H_
#define _LOS_VFS_H_
#include "los_config.h"
#include "dirent.h"
#include "sys/mount.h"
#include "sys/statfs.h"
#include "sys/stat.h"
#include "sys/uio.h"
#include "unistd.h"
#ifdef __cplusplus
@@ -51,72 +50,51 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
int LOS_Open(const char *path, int flags, ...);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
ssize_t LOS_Write(int fd, const void *buff, size_t bytes);
off_t LOS_Lseek(int fd, off_t off, int whence);
int LOS_Stat(const char *path, struct stat *stat);
int LOS_Statfs(const char *path, struct statfs *buf);
int LOS_Unlink(const char *path);
int LOS_Rename(const char *oldpath, const char *newpath);
int LOS_Fsync(int fd);
DIR *LOS_Opendir(const char *path);
struct dirent *LOS_Readdir(DIR *dir);
int LOS_Closedir(DIR *dir);
int LOS_Mkdir(const char *path, mode_t mode);
int LOS_Rmdir(const char *path);
int LOS_Lstat(const char *path, struct stat *buffer);
int LOS_Fstat(int fd, struct stat *buf);
int LOS_Fcntl(int fd, int cmd, ...);
int LOS_Ioctl(int fd, int req, ...);
ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off);
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off);
int LOS_Isatty(int fd);
int LOS_Access(const char *path, int amode);
int LOS_Ftruncate(int fd, off_t length);
int LOS_FsUmount(const char *target);
int LOS_FsUmount2(const char *target, int flag);
int LOS_FsMount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data);
/*
* @brief Divide the device into partitions.
*
* @param dev Device name, which customized by caller, it is recommended to
* name it as: "emmc0", "emmc1", "flash0", etc. The name is combined with
* "device_type" + "device_id", and the last character is device_id.
* device_id >= 0 && device_id <= 9.
* @param fsType Filesystem type.
* @param lengthArray List of partition size. For example:
* [0x10000000, 0x2000000], 256M and 512M partitions will be created and
* left all will not allocated.
* @param partNum Length of 'lengthArray'.
*
* @return Return LOS_NOK if error. Return LOS_OK if success.
* Partition naming rules:
* In the current vfs, after successfully calling the 'fdisk' hook,
* "partNum" partitions will be created.
* The partition naming rules is:
* 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_Open(const char *path, int oflag, ...);
/*
* @brief Format a partition.
*
* @param partName PartitionName, following the rule of fdisk hook.
* @param data For FatFs, the data indicates a pointer to a byte which
* specifies combination of FAT type flags, FM_FAT, FM_FAT32, FM_EXFAT and
* bitwise-or of these three, FM_ANY.
*
* @return Return LOS_NOK if error. Return LOS_OK if success.
*/
int LOS_PartitionFormat(const char *partName, char *fsType, void *data);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buf, size_t nbyte);
ssize_t LOS_Write(int fd, const void *buf, size_t nbyte);
off_t LOS_Lseek(int fd, off_t offset, int whence);
int LOS_Unlink(const char *path);
int LOS_Fstat(int fd, struct stat *buf);
int LOS_Stat(const char *path, struct stat *buf);
int LOS_Fsync(int fd);
int LOS_Mkdir(const char *path, mode_t mode);
DIR *LOS_Opendir(const char *dirName);
struct dirent *LOS_Readdir(DIR *dir);
int LOS_Closedir(DIR *dir);
int LOS_Rmdir(const char *path);
int LOS_Rename(const char *oldName, const char *newName);
int LOS_Statfs(const char *path, struct statfs *buf);
int LOS_Ftruncate(int fd, off_t length);
int LOS_FsUmount2(const char *target, int flag);
int LOS_FsUmount(const char *target);
int LOS_FsMount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
ssize_t LOS_Pread(int fd, void *buf, size_t nbyte, off_t offset);
ssize_t LOS_Pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
#ifdef __cplusplus
#if __cplusplus
@@ -124,4 +102,4 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_FS_H_ */
#endif /* _LOS_FS_H_ */

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -32,8 +32,54 @@
#ifndef _VFS_CONFIG_H_
#define _VFS_CONFIG_H_
#define PATH_MAX 256
#define CONFIG_DISABLE_MQUEUE // disable posix mqueue inode configure
/* file system configur */
#define CONFIG_FS_WRITABLE // enable file system can be written
#define CONFIG_FS_READABLE // enable file system can be read
#define CONFIG_DEBUG_FS // enable vfs debug function
/* fatfs cache configur */
/* config block size for fat file system, only can be 0,32,64,128,256,512,1024 */
#define CONFIG_FS_FAT_SECTOR_PER_BLOCK 64
/* config block num for fat file system */
#define CONFIG_FS_FAT_READ_NUMS 7
#define CONFIG_FS_FAT_BLOCK_NUMS 28
#ifdef LOSCFG_FS_FAT_CACHE_SYNC_THREAD
/* config the priority of sync task */
#define CONFIG_FS_FAT_SYNC_THREAD_PRIO 10
/* config dirty ratio of bcache for fat file system */
#define CONFIG_FS_FAT_DIRTY_RATIO 60
/* config time interval of sync thread for fat file system, in milliseconds */
#define CONFIG_FS_FAT_SYNC_INTERVAL 5000
#endif
#define CONFIG_FS_FLASH_BLOCK_NUM 1
#define CONFIG_FS_MAX_LNK_CNT 40
/* nfs configure */
#define CONFIG_NFS_MACHINE_NAME "IPC" // nfs device name is IPC
#define CONFIG_NFS_MACHINE_NAME_SIZE 3 // size of nfs machine name
/* file descriptors configure */
#define CONFIG_NFILE_STREAMS 1 // enable file stream
#define CONFIG_STDIO_BUFFER_SIZE 0
#define CONFIG_NUNGET_CHARS 0
#define MIN_START_FD 3 // 0,1,2 are used for stdin,stdout,stderr respectively
/* net configure */
@@ -41,8 +87,12 @@
#ifdef LOSCFG_NET_LWIP_SACK // enable socket and net function
#include "lwip/lwipopts.h"
#define CONFIG_NSOCKET_DESCRIPTORS LWIP_CONFIG_NUM_SOCKETS // max numbers of socket descriptor
#define CONFIG_NET_SENDFILE 1 // enable sendfile function
#define CONFIG_NET_TCP 1 // enable sendfile and send function
#else
#define CONFIG_NSOCKET_DESCRIPTORS 0
#define CONFIG_NET_SENDFILE 0 // disable sendfile function
#define CONFIG_NET_TCP 0 // disable sendfile and send function
#endif
/* max numbers of other descriptors except socket descriptors */

View File

@@ -1,98 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vfs_files.h"
#include "errno.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "los_config.h"
#include "vfs_config.h"
#include "vfs_mount.h"
#include "vfs_operations.h"
static struct File g_files[NR_OPEN_DEFAULT];
int FileToFd(struct File *file)
{
if (file == NULL) {
return LOS_NOK;
}
return file - g_files + MIN_START_FD;
}
struct File *FdToFile(int fd)
{
if ((fd < MIN_START_FD) || (fd >= CONFIG_NFILE_DESCRIPTORS)) {
return NULL;
}
return &g_files[fd - MIN_START_FD];
}
struct File *VfsFileGet(void)
{
int i;
/* protected by g_fsMutex */
for (i = 0; i < NR_OPEN_DEFAULT; i++) {
if (g_files[i].fStatus == FILE_STATUS_NOT_USED) {
g_files[i].fStatus = FILE_STATUS_INITING;
return &g_files[i];
}
}
return NULL;
}
struct File *VfsFileGetSpec(int fd)
{
if ((fd < MIN_START_FD) || (fd >= CONFIG_NFILE_DESCRIPTORS)) {
return NULL;
}
if (g_files[fd - MIN_START_FD].fStatus == FILE_STATUS_NOT_USED) {
g_files[fd - MIN_START_FD].fStatus = FILE_STATUS_INITING;
return &g_files[fd - MIN_START_FD];
}
return NULL;
}
void VfsFilePut(struct File *file)
{
if (file == NULL) {
return;
}
file->fFlags = 0;
file->fFops = NULL;
file->fData = NULL;
file->fMp = NULL;
file->fOffset = 0;
file->fOwner = -1;
file->fullPath = NULL;
file->fStatus = FILE_STATUS_NOT_USED;
}

View File

@@ -1,104 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VFS_FILES_H_
#define _VFS_FILES_H_
#include "dirent.h"
#include "sys/stat.h"
#include "unistd.h"
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define FILE_STATUS_NOT_USED 0
#define FILE_STATUS_INITING 1
#define FILE_STATUS_READY 2
#define FILE_STATUS_CLOSING 3
struct FileOps;
struct File;
struct Dir;
struct MountPoint;
struct FileOps {
int (*open)(struct File *, const char *, int);
int (*close)(struct File *);
ssize_t (*read)(struct File *, char *, size_t);
ssize_t (*write)(struct File *, const char *, size_t);
off_t (*lseek)(struct File *, off_t, int);
int (*stat)(struct MountPoint *, const char *, struct stat *);
int (*truncate)(struct File *, off_t);
int (*unlink)(struct MountPoint *, const char *);
int (*rename)(struct MountPoint *, const char *, const char *);
int (*ioctl)(struct File *, int, unsigned long);
int (*sync)(struct File *);
int (*opendir)(struct Dir *, const char *);
int (*readdir)(struct Dir *, struct dirent *);
int (*closedir)(struct Dir *);
int (*mkdir)(struct MountPoint *, const char *);
int (*rmdir)(struct MountPoint *, const char *);
};
struct File {
const struct FileOps *fFops;
UINT32 fFlags;
UINT32 fStatus;
off_t fOffset;
INT32 fOwner;
struct MountPoint *fMp;
void *fData; /* file system opreations handle, fatfs FIL, etc. */
const char *fullPath;
};
struct Dir {
struct MountPoint *dMp;
struct dirent dDent;
off_t dOffset;
void *dData;
};
int FileToFd(struct File *file);
struct File *FdToFile(int fd);
struct File *VfsFileGet(void);
struct File *VfsFileGetSpec(int fd);
void VfsFilePut(struct File *file);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _VFS_FILES_H_ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,54 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "stdlib.h"
#include "vfs_operations.h"
#if (LOSCFG_SUPPORT_LITTLEFS == 1)
#include "lfs_adapter.h"
#endif
#if (LOSCFG_SUPPORT_FATFS == 1)
#include "fatfs.h"
#endif
#include "los_compiler.h"
#include "los_mux.h"
int OsVfsInit(void)
{
if (LOS_MuxCreate(&g_fsMutex) != LOS_OK) {
return LOS_NOK;
}
#if (LOSCFG_SUPPORT_FATFS == 1)
FatFsInit();
#endif
#if (LOSCFG_SUPPORT_LITTLEFS == 1)
LfsInit();
#endif
return LOS_OK;
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vfs_maps.h"
#include "vfs_operations.h"
#include <stdlib.h>
#include "securec.h"
#include "los_debug.h"
#include "los_compiler.h"
struct FsMap *g_fsMap = NULL;
struct FsMap *VfsFsMapGet(const char *fsType)
{
struct FsMap *curr = g_fsMap;
(void)VfsLock();
while (curr != NULL) {
if ((curr->fsType != NULL) && (fsType != NULL) &&
(strcmp(curr->fsType, fsType) == 0)) {
(void)VfsUnlock();
return curr;
}
curr = curr->next;
}
VfsUnlock();
return NULL;
}
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt)
{
if ((fsMops == NULL) || (fsFops == NULL)) {
return 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;
}
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
newfs->fsType = strdup(fsType);
if (newfs->fsType == NULL) {
free(newfs);
return LOS_NOK;
}
newfs->fsMops = fsMops;
newfs->fsFops = fsFops;
newfs->fsMgt = fsMgt;
newfs->fsRefs = 0;
(void)VfsLock();
newfs->next = g_fsMap;
g_fsMap = newfs;
VfsUnlock();
return LOS_OK;
}

View File

@@ -1,69 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VFS_MAPS_H_
#define _VFS_MAPS_H_
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
struct MountOps;
struct FsManagement {
int (*fdisk)(const char *dev, int *lengthArray, int partNum);
int (*format)(const char *partName, void *data);
};
struct FsMap {
const char *fsType;
const struct MountOps *fsMops;
const struct FileOps *fsFops;
const struct FsManagement *fsMgt;
UINT32 fsRefs;
struct FsMap *next;
};
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
struct FileOps *fsFops, struct FsManagement *fsMgt);
struct FsMap *VfsFsMapGet(const char *fsType);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _VFS_MAPS_H_ */

View File

@@ -1,294 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vfs_mount.h"
#include "vfs_files.h"
#include "vfs_maps.h"
#include "vfs_config.h"
#include "stdlib.h"
#include "string.h"
#include "vfs_operations.h"
#include "los_compiler.h"
#include "los_debug.h"
#include "los_fs.h"
#include "los_mux.h"
struct MountPoint *g_mountPoints = NULL;
static void MpDeleteFromList(struct MountPoint *mp)
{
struct MountPoint *prev = NULL;
/* delete mp from mount list */
if (g_mountPoints == mp) {
g_mountPoints = mp->mNext;
} else {
for (prev = g_mountPoints; prev != NULL; prev = prev->mNext) {
if (prev->mNext != mp) {
continue;
}
prev->mNext = mp->mNext;
break;
}
}
}
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
{
struct MountPoint *mp = g_mountPoints;
struct MountPoint *bestMp = NULL;
int bestMatches = 0;
if (path == NULL) {
return NULL;
}
if (pathInMp != NULL) {
*pathInMp = NULL;
}
while ((mp != NULL) && (mp->mPath != NULL)) {
const char *mPath = mp->mPath;
const char *iPath = path;
const char *t = NULL;
int matches = 0;
do {
while ((*mPath == '/') && (*(mPath + 1) != '/')) {
mPath++;
}
while ((*iPath == '/') && (*(iPath + 1) != '/')) {
iPath++;
}
t = strchr(mPath, '/');
if (t == NULL) {
t = strchr(mPath, '\0');
}
if ((t == mPath) || (t == NULL)) {
break;
}
if (strncmp(mPath, iPath, (size_t)(t - mPath)) != 0) {
goto next; /* this mount point do not match, check next */
}
iPath += (t - mPath);
if ((*iPath != '\0') && (*iPath != '/')) {
goto next;
}
matches += (t - mPath);
mPath += (t - mPath);
} while (*mPath != '\0');
if (matches > bestMatches) {
bestMatches = matches;
bestMp = mp;
while ((*iPath == '/') && (*(iPath + 1) != '/')) {
iPath++;
}
if (pathInMp != NULL) {
*pathInMp = path;
}
}
next:
mp = mp->mNext;
}
return bestMp;
}
int LOS_FsMount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data)
{
int ret;
struct MountPoint *mp = NULL;
const char *pathInMp = 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;
}
/* Find fsMap coresponding to the fsType */
struct FsMap *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) {
goto errout;
}
mp->mFs = mFs;
mp->mDev = NULL;
if (source != NULL) {
mp->mDev = strdup(source);
if (mp->mDev == NULL) {
goto errout;
}
}
mp->mPath = strdup(target);
if (mp->mPath == NULL) {
goto errout;
}
ret = mp->mFs->fsMops->mount(mp, mountflags, data);
if (ret != 0) {
/* errno is set */
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;
errout:
free((void *)mp->mPath);
free((void *)mp->mDev);
free(mp);
VfsUnlock();
return LOS_NOK;
}
int LOS_FsUmount(const char *target)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
(void)VfsLock();
if (target == NULL) {
goto errout;
}
mp = VfsMpFind(target, &pathInMp);
if ((mp == NULL) || (mp->mRefs != 0)) {
goto errout;
}
if ((mp->mFs == NULL) || (mp->mFs->fsMops == NULL) ||
(mp->mFs->fsMops->umount == NULL)) {
goto errout;
}
ret = mp->mFs->fsMops->umount(mp);
if (ret != 0) {
/* errno is set */
goto errout;
}
/* delete mp from mount list */
MpDeleteFromList(mp);
mp->mFs->fsRefs--;
free((void *)mp->mPath);
free((void *)mp->mDev);
free(mp);
VfsUnlock();
return LOS_OK;
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
return LOS_NOK;
}
static void CloseFdsInMp(struct MountPoint *mp)
{
for (int fd = 0; fd < NR_OPEN_DEFAULT; fd++) {
struct File *f = FdToFile(fd);
if (f == NULL) {
continue;
}
if ((f->fMp == mp) &&
(f->fFops != NULL) &&
(f->fFops->close != NULL)) {
(void)f->fFops->close(f);
}
}
}
int LOS_FsUmount2(const char *target, int flag)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = LOS_NOK;
(void)VfsLock();
if (target == NULL) {
goto errout;
}
mp = VfsMpFind(target, &pathInMp);
if ((mp == NULL) || (mp->mRefs != 0) ||
(mp->mFs == NULL) || (mp->mFs->fsMops == NULL) ||
(mp->mFs->fsMops->umount2 == NULL)) {
goto errout;
}
/* Close all files under the mount point */
if ((UINT32)flag & MNT_FORCE) {
CloseFdsInMp(mp);
}
ret = mp->mFs->fsMops->umount2(mp, flag);
if (ret != 0) {
/* errno is set */
goto errout;
}
/* delete mp from mount list */
MpDeleteFromList(mp);
mp->mFs->fsRefs--;
free((void *)mp->mPath);
free((void *)mp->mDev);
free(mp);
VfsUnlock();
return LOS_OK;
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
return LOS_NOK;
}

View File

@@ -1,76 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VFS_MOUNT_H_
#define _VFS_MOUNT_H_
#include "sys/statfs.h"
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
struct FsMap;
struct MountPoint;
struct MountOps {
int (*mount)(struct MountPoint *mp, unsigned long mountflags,
const void *data);
int (*umount)(struct MountPoint *mp);
int (*umount2)(struct MountPoint *mp, int flag);
int (*statfs)(const char *path, struct statfs *buf);
};
struct MountPoint {
struct FsMap *mFs; /* file system info */
struct MountPoint *mNext; /* point to next mount point */
const char *mPath; /* target path, /system, /usr, etc. */
const char *mDev; /* device, "emmc0p0", "emmc0p1", etc. */
UINT32 mRefs; /* reference to mount point */
void *mData; /* specific file system handle */
BOOL mWriteEnable; /* writable flag */
};
extern struct MountPoint *g_mountPoints;
#define LOS_MP_FOR_EACH_ENTRY(prev) \
for (prev = g_mountPoints; prev != NULL; prev = prev->mNext)
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _VFS_MOUNT_H_ */

View File

@@ -1,64 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VFS_OPERATIONS_H_
#define _VFS_OPERATIONS_H_
#include "errno.h"
#include "fcntl.h"
#include "dirent.h"
#include "stdint.h"
#include "unistd.h"
#include "sys/mount.h"
#include "sys/stat.h"
#include "sys/statfs.h"
#include "los_compiler.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define VFS_ERRNO_SET(err) (errno = (err))
extern UINT32 g_fsMutex;
int OsVfsInit(void);
int VfsLock(void);
void VfsUnlock(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _VFS_OPERATIONS_H_ */

View File

@@ -1,104 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "vfs_partition.h"
#include "vfs_operations.h"
#include "los_fs.h"
#include "los_list.h"
#include "vfs_maps.h"
#include "vfs_mount.h"
#include "securec.h"
#include "stdlib.h"
#include "string.h"
int GetPartIdByPartName(const char *partName)
{
if (partName == NULL) {
return LOS_NOK;
}
/* the character next to p is the partId */
char *p = strrchr(partName, 'p');
if (p + 1 != NULL) {
return atoi(p + 1);
}
return LOS_NOK;
}
int GetDevIdByDevName(const char *dev)
{
if (dev == NULL) {
return LOS_NOK;
}
/* last character is the deviceId */
char *p = (char *)dev + strlen(dev) - 1;
if (p != NULL) {
return atoi(p);
}
return LOS_NOK;
}
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
int partnum)
{
int ret = LOS_NOK;
struct FsMap *fMap = VfsFsMapGet(fsType);
if ((fMap != NULL) && (fMap->fsMgt != NULL) &&
(fMap->fsMgt->fdisk != NULL)) {
ret = fMap->fsMgt->fdisk(dev, lengthArray, partnum);
}
return ret;
}
int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
{
int ret = LOS_NOK;
/* check if the device is mounted by iterate the mp list
format is not allowed when the device has been mounted. */
struct MountPoint *iter = NULL;
LOS_MP_FOR_EACH_ENTRY(iter) {
if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) &&
strcmp(iter->mFs->fsType, fsType) == 0) {
errno = EBUSY;
return LOS_NOK;
}
}
struct FsMap *fMap = VfsFsMapGet(fsType);
if ((fMap != NULL) && (fMap->fsMgt != NULL) &&
(fMap->fsMgt->format != NULL)) {
ret = fMap->fsMgt->format(partName, data);
}
return ret;
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _VFS_PARTITION_H_
#define _VFS_PARTITION_H_
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#define MAX_PARTITION_NUM 4
int GetPartIdByPartName(const char *partName);
int GetDevIdByDevName(const char *dev);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _VFS_PARTITION_H_ */

View File

@@ -178,11 +178,6 @@
#define NO_SYS 0
#define TCP_QUEUE_OOSEQ LWIP_TCP
#if defined LWIP_STATS_DISPLAY && !LWIP_STATS
#undef LWIP_STATS_DISPLAY
#define LWIP_STATS_DISPLAY 0
#endif
// Change some options for lwIP 2.1.2
#undef TCP_MAXRTX
#define TCP_MAXRTX 12

View File

@@ -1,38 +0,0 @@
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
module_group(module_name) {
modules = [
"box",
"syscall",
"userlib",
]
}

View File

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

View File

@@ -1,119 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_box.h"
#include "los_task.h"
#include "los_context.h"
#include "los_arch_context.h"
#include "los_debug.h"
static UserTaskCB g_UserTaskCBArray[LOSCFG_BASE_CORE_TSK_LIMIT] = { 0 };
static LosBoxCB g_boxCB[1];
VOID OsUserTaskInit(UINT32 taskID, UINTPTR entry, UINTPTR userArea, UINTPTR userSp)
{
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
taskCB->taskStatus |= OS_TASK_FLAG_USER_TASK;
HalUserTaskStackInit(taskCB->stackPointer, entry, userSp);
g_UserTaskCBArray[taskID].userArea = userArea;
g_UserTaskCBArray[taskID].userSp = userSp;
g_UserTaskCBArray[taskID].boxID = g_UserTaskCBArray[g_losTask.runTask->taskID].boxID;
}
VOID OsUserTaskDelete(UINT32 taskID)
{
(VOID)memset_s(&g_UserTaskCBArray[taskID], sizeof(UserTaskCB), 0, sizeof(UserTaskCB));
}
UserTaskCB *OsGetUserTaskCB(UINT32 taskID)
{
return &g_UserTaskCBArray[taskID];
}
static UINT32 BoxInit(VOID)
{
UINT32 count = sizeof(g_boxCB) / sizeof(LosBoxCB);
for (UINT32 i = 0; i < count; i++) {
LosBoxCB *box = &g_boxCB[i];
box->boxStackAddr = box->boxStartAddr + box->boxSize - box->boxStackSize;
}
return LOS_OK;
}
VOID OsBoxStart(VOID)
{
UINT32 ret, taskID;
UINT32 count = sizeof(g_boxCB) / sizeof(LosBoxCB);
TSK_INIT_PARAM_S taskInitParam = { 0 };
for (UINT32 i = 0; i < count; i++) {
LosBoxCB *box = &g_boxCB[i];
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)box->boxStartAddr;
taskInitParam.uwStackSize = 0x1000;
taskInitParam.pcName = "BoxMainTask";
taskInitParam.usTaskPrio = LOSCFG_BOX_PRIO;
taskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
ret = LOS_TaskCreateOnly(&taskID, &taskInitParam);
if (ret != LOS_OK) {
PRINT_ERR("Create box %u main task failed, Error 0x%x\n", i, ret);
return;
}
OsUserTaskInit(taskID, (UINTPTR)_ulibc_start, 0, box->boxStackAddr + box->boxStackSize);
g_UserTaskCBArray[taskID].boxID = i;
ret = LOS_TaskResume(taskID);
if (ret != LOS_OK) {
PRINT_ERR("Box(%u) resume task %u failed, Error 0x%x\n", i, taskID, ret);
return;
}
}
}
UINT32 LOS_BoxStart(VOID)
{
UINT32 ret, taskID;
TSK_INIT_PARAM_S taskInitParam = { 0 };
ret = BoxInit();
if (ret != LOS_OK) {
PRINT_ERR("Box init failed! Error 0x%x\n", ret);
return ret;
}
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsBoxStart;
taskInitParam.uwStackSize = 0x1000;
taskInitParam.pcName = "BoxStart";
taskInitParam.usTaskPrio = LOSCFG_BOX_START_PRIO;
taskInitParam.uwResved = 0;
return LOS_TaskCreate(&taskID, &taskInitParam);
}

View File

@@ -1,72 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_BOX_H
#define _LOS_BOX_H
#include "los_compiler.h"
#define LOSCFG_BOX_START_PRIO 5
#define LOSCFG_BOX_PRIO 10
/*
* -------------------- boxStartAddr(main)
* | .text |
* | -----------------
* | .data |
* | ----------------- boxHeapAddr
* | .heap |
* | ----------------- boxStackAddr
* | boxStackSize |
* --------------------
*/
typedef struct {
UINTPTR boxStartAddr;
UINTPTR boxSize;
UINTPTR boxHeapAddr;
UINTPTR boxHeapSize;
UINTPTR boxStackAddr; /* box main task stack addr */
UINTPTR boxStackSize;
} LosBoxCB;
typedef struct {
unsigned long userArea;
unsigned long userSp;
unsigned int boxID;
} UserTaskCB;
VOID OsUserTaskInit(UINT32 taskID, UINTPTR entry, UINTPTR userArea, UINTPTR userSp);
VOID OsUserTaskDelete(UINT32 taskID);
UserTaskCB *OsGetUserTaskCB(UINT32 taskID);
UINT32 LOS_BoxStart(VOID);
extern INT32 _ulibc_start(UINTPTR main);
#endif

View File

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

View File

@@ -1,115 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define GNU_SOURCE
#include "los_syscall.h"
#include "los_context.h"
#include "los_task.h"
#include "los_debug.h"
#include "unistd.h"
#include "errno.h"
#define SYS_CALL_NUM_LIMIT (__NR_syscallend + 1)
#define SYS_CALL_NUM_REG_OFFSET 7
#define NARG_BITS 4
#define NARG_MASK 0x0F
#define NARG_PER_BYTE 2
typedef UINT32 (*SyscallFun1)(UINT32);
typedef UINT32 (*SyscallFun2)(UINT32, UINT32);
typedef UINT32 (*SyscallFun3)(UINT32, UINT32, UINT32);
typedef UINT32 (*SyscallFun4)(UINT32, UINT32, UINT32, UINT32);
typedef UINT32 (*SyscallFun5)(UINT32, UINT32, UINT32, UINT32, UINT32);
typedef UINT32 (*SyscallFun7)(UINT32, UINT32, UINT32, UINT32, UINT32, UINT32, UINT32);
static UINTPTR g_syscallHandle[SYS_CALL_NUM_LIMIT] = {0};
static UINT8 g_syscallNArgs[(SYS_CALL_NUM_LIMIT + 1) / NARG_PER_BYTE] = {0};
void OsSyscallHandleInit(void)
{
#define SYSCALL_HAND_DEF(id, fun, rType, nArg) \
if ((id) < SYS_CALL_NUM_LIMIT) { \
g_syscallHandle[(id)] = (UINTPTR)(fun); \
g_syscallNArgs[(id) / NARG_PER_BYTE] |= ((id) & 1) ? (nArg) << NARG_BITS : (nArg); \
} \
#include "syscall_lookup.h"
#undef SYSCALL_HAND_DEF
}
/* The SYSCALL ID is in R7 on entry. Parameters follow in R0..R6 */
VOID OsSyscallHandle(UINT32 *args)
{
UINT32 ret;
UINT8 nArgs;
UINTPTR handle;
UINT32 svcNum = (UINT32)args[SYS_CALL_NUM_REG_OFFSET];
if (svcNum >= SYS_CALL_NUM_LIMIT) {
PRINT_ERR("Syscall ID: error %d !!!\n", svcNum);
return;
}
handle = g_syscallHandle[svcNum];
nArgs = g_syscallNArgs[svcNum / NARG_PER_BYTE]; /* 4bit per nargs */
nArgs = (svcNum & 1) ? (nArgs >> NARG_BITS) : (nArgs & NARG_MASK);
if ((handle == 0) || (nArgs > ARG_NUM_7)) {
PRINT_ERR("Unsupported syscall ID: %d nArgs: %d\n", svcNum, nArgs);
args[ARG_NUM_0] = -ENOSYS;
return;
}
switch (nArgs) {
case ARG_NUM_0:
case ARG_NUM_1:
ret = (*(SyscallFun1)handle)(args[ARG_NUM_0]);
break;
case ARG_NUM_2:
ret = (*(SyscallFun2)handle)(args[ARG_NUM_0], args[ARG_NUM_1]);
break;
case ARG_NUM_3:
ret = (*(SyscallFun3)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2]);
break;
case ARG_NUM_4:
ret = (*(SyscallFun4)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2], args[ARG_NUM_3]);
break;
case ARG_NUM_5:
ret = (*(SyscallFun5)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2], args[ARG_NUM_3], \
args[ARG_NUM_4]);
break;
default:
ret = (*(SyscallFun7)handle)(args[ARG_NUM_0], args[ARG_NUM_1], args[ARG_NUM_2], args[ARG_NUM_3], \
args[ARG_NUM_4], args[ARG_NUM_5], args[ARG_NUM_6]);
}
args[ARG_NUM_0] = ret;
return;
}

View File

@@ -1,50 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _LOS_SYSCALL_H
#define _LOS_SYSCALL_H
#include "los_arch_context.h"
#include "los_task.h"
#include "syscall.h"
void OsSyscallHandleInit(void);
void OsSyscallHandle(UINT32 *regs);
/* pthread */
int SysUserTaskCreate(unsigned long entry, unsigned long userArea, unsigned long userSp, BOOL joinable);
int SysSchedSetScheduler(unsigned int tid, int policy, int priority);
int *SysSchedGetArea(unsigned int tid);
int SysSetThreadArea(const char *area);
char *SysGetThreadArea(void);
int SysFutex(const unsigned int *uAddr, unsigned int flags, int val,
unsigned int absTime, const unsigned int *newUserAddr);
#endif /* _LOS_SYSCALL_H */

View File

@@ -1,126 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_task.h"
#include "securec.h"
#include "los_config.h"
#include "los_debug.h"
#include "los_hook.h"
#include "los_interrupt.h"
#include "los_memory.h"
#include "los_mpu.h"
#include "los_sched.h"
#include "los_mux.h"
#include "los_sem.h"
#include "los_timer.h"
#include "los_arch_context.h"
#include "los_box.h"
#include "los_syscall.h"
int SysUserTaskCreate(unsigned long entry, unsigned long userArea, unsigned long userSp, BOOL joinable)
{
UINT32 ret, taskID;
TSK_INIT_PARAM_S taskInitParam = { 0 };
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
taskInitParam.uwStackSize = 0x1000;
taskInitParam.pcName = "UserTask";
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
taskInitParam.stackAddr = userSp;
if (joinable) {
taskInitParam.uwResved |= LOS_TASK_ATTR_JOINABLE;
}
ret = LOS_TaskCreateOnly(&taskID, &taskInitParam);
if (ret != LOS_OK) {
return -EINVAL;
}
OsUserTaskInit(taskID, entry, userArea, userSp);
return taskID;
}
int SysSchedSetScheduler(unsigned int tid, int policy, int priority)
{
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
return EINVAL;
}
if (policy != 0) {
return EINVAL;
}
if ((priority <= 0) || (priority > OS_TASK_PRIORITY_LOWEST)) {
return EINVAL;
}
UINT32 ret = LOS_TaskPriSet((UINT32)tid, (UINT16)priority);
if (ret != LOS_OK) {
return EINVAL;
}
return 0;
}
int *SysSchedGetArea(unsigned int tid)
{
unsigned int intSave;
int *area = NULL;
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
return NULL;
}
intSave = LOS_IntLock();
area = (int *)OsGetUserTaskCB(tid)->userArea;
LOS_IntRestore(intSave);
return area;
}
int SysSetThreadArea(const char *area)
{
unsigned int intSave;
intSave = LOS_IntLock();
LosTaskCB *runTask = g_losTask.runTask;
OsGetUserTaskCB(runTask->taskID)->userArea = (unsigned long)(uintptr_t)area;
LOS_IntRestore(intSave);
return 0;
}
char *SysGetThreadArea(void)
{
unsigned int intSave;
char *area = NULL;
intSave = LOS_IntLock();
LosTaskCB *runTask = g_losTask.runTask;
area = (char *)OsGetUserTaskCB(runTask->taskID)->userArea;
LOS_IntRestore(intSave);
return area;
}

View File

@@ -1,270 +0,0 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* SYSCALL_HAND_DEF must be defined before including this file. */
/* SYSCALL_HAND_DEF(id, fun, rtype, narg); note if we have 64bit arg, narg should be ARG_NUM_7 */
// #ifdef LOSCFG_FS_VFS
// SYSCALL_HAND_DEF(__NR_read, SysRead, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_write, SysWrite, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_open, SysOpen, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_close, SysClose, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_creat, SysCreat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_link, SysLink, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_readlink, SysReadlink, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_symlink, SysSymlink, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_unlink, SysUnlink, int, ARG_NUM_1)
// #ifdef LOSCFG_KERNEL_DYNLOAD
// SYSCALL_HAND_DEF(__NR_execve, SysExecve, int, ARG_NUM_3)
// #endif
// SYSCALL_HAND_DEF(__NR_sysinfo, SysInfo, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_fchdir, SysFchdir, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_chdir, SysChdir, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_utimensat, SysUtimensat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_fchmodat, SysFchmodat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_fchmod, SysFchmod, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_utimensat, SysUtimensat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_chmod, SysChmod, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_lseek, SysLseek, off_t, ARG_NUM_7) /* current only support 32bit max 4G file */
// SYSCALL_HAND_DEF(__NR_mount, SysMount, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_umount, SysUmount, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_access, SysAccess, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_faccessat, SysFaccessat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_sync, SysSync, void, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_rename, SysRename, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_mkdir, SysMkdir, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_rmdir, SysRmdir, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_dup, SysDup, int, ARG_NUM_1)
// #ifdef LOSCFG_KERNEL_PIPE
// SYSCALL_HAND_DEF(__NR_pipe, SysPipe, int, ARG_NUM_1)
// #endif
// SYSCALL_HAND_DEF(__NR_umount2, SysUmount2, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_ioctl, SysIoctl, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_fcntl, SysFcntl, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_dup2, SysDup2, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_truncate, SysTruncate, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_ftruncate, SysFtruncate, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_statfs, SysStatfs, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstatfs, SysFstatfs, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstatfs64, SysFstatfs64, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_stat, SysStat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_lstat, SysLstat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstat, SysFstat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstatat64, SysFstatat64, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_fsync, SysFsync, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR__llseek, SysLseek64, off64_t, ARG_NUM_5) /* current only support 32bit max 4G file */
// SYSCALL_HAND_DEF(__NR__newselect, SysSelect, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_pselect6, SysPselect6, int, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_readv, SysReadv, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_writev, SysWritev, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_poll, SysPoll, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_ppoll, SysPpoll, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_prctl, SysPrctl, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_pread64, SysPread64, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_pwrite64, SysPwrite64, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_epoll_create, SysEpollCreate, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_epoll_create1, SysEpollCreate1, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_epoll_ctl, SysEpollCtl, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_epoll_wait, SysEpollWait, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_epoll_pwait, SysEpollPwait, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_getcwd, SysGetcwd, char *, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_sendfile, SysSendFile, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_truncate64, SysTruncate64, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_ftruncate64, SysFtruncate64, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_stat64, SysStat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_lstat64, SysLstat, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fstat64, SysFstat64, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_fcntl64, SysFcntl64, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sendfile64, SysSendFile, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_preadv, SysPreadv, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_pwritev, SysPwritev, ssize_t, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_fallocate, SysFallocate64, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_getdents64, SysGetdents64, int, ARG_NUM_3)
// #ifdef LOSCFG_FS_FAT
// SYSCALL_HAND_DEF(__NR_format, SysFormat, int, ARG_NUM_3)
// #endif
// SYSCALL_HAND_DEF(__NR_linkat, SysLinkat, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_symlinkat, SysSymlinkat, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_readlinkat, SysReadlinkat, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_unlinkat, SysUnlinkat, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_renameat, SysRenameat, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_openat, SysOpenat, int, ARG_NUM_7)
// SYSCALL_HAND_DEF(__NR_mkdirat, SysMkdirat, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_statfs64, SysStatfs64, int, ARG_NUM_3)
// #ifdef LOSCFG_DEBUG_VERSION
// SYSCALL_HAND_DEF(__NR_dumpmemory, LOS_DumpMemRegion, void, ARG_NUM_1)
// #endif
// #ifdef LOSCFG_KERNEL_PIPE
// SYSCALL_HAND_DEF(__NR_mkfifo, SysMkFifo, int, ARG_NUM_2)
// #endif
// SYSCALL_HAND_DEF(__NR_mqclose, SysMqClose, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_realpath, SysRealpath, char *, ARG_NUM_2)
// #ifdef LOSCFG_SHELL
// SYSCALL_HAND_DEF(__NR_shellexec, SysShellExec, UINT32, ARG_NUM_2)
// #endif
// #endif
// SYSCALL_HAND_DEF(__NR_exit, SysThreadExit, void, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_fork, SysFork, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_vfork, SysVfork, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getpid, SysGetPID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_pause, SysPause, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_kill, SysKill, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_reboot, SysReboot, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_times, SysTimes, clock_t, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_brk, SysBrk, void *, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_setgid, SysSetGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_getgid, SysGetGroupID, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_setpgid, SysSetProcessGroupID, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_getppid, SysGetPPID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getpgrp, SysGetProcessGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_munmap, SysMunmap, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_getpriority, SysGetProcessPriority, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setpriority, SysSetProcessPriority, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setitimer, SysSetiTimer, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getitimer, SysGetiTimer, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_wait4, SysWait, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_waitid, SysWaitid, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_uname, SysUname, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_mprotect, SysMprotect, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getpgid, SysGetProcessGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_setparam, SysSchedSetParam, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_getparam, SysSchedGetParam, int, ARG_NUM_2)
SYSCALL_HAND_DEF(__NR_sched_setscheduler, SysSchedSetScheduler, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_getscheduler, SysSchedGetScheduler, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_sched_yield, SysSchedYield, void, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_get_priority_max, SysSchedGetPriorityMax, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_get_priority_min, SysSchedGetPriorityMin, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_sched_setaffinity, SysSchedSetAffinity, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_getaffinity, SysSchedGetAffinity, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_sched_rr_get_interval, SysSchedRRGetInterval, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_nanosleep, SysNanoSleep, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_mremap, SysMremap, void *, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_umask, SysUmask, mode_t, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_rt_sigaction, SysSigAction, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_rt_sigprocmask, SysSigprocMask, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_rt_sigpending, SysSigPending, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_rt_sigtimedwait, SysSigTimedWait, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_rt_sigsuspend, SysSigSuspend, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_fchownat, SysFchownat, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_fchown32, SysFchown, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_chown, SysChown, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_chown32, SysChown, int, ARG_NUM_3)
// #ifdef LOSCFG_SECURITY_CAPABILITY
// SYSCALL_HAND_DEF(__NR_ohoscapget, SysCapGet, UINT32, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_ohoscapset, SysCapSet, UINT32, ARG_NUM_1)
// #endif
// SYSCALL_HAND_DEF(__NR_mmap2, SysMmap, void*, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_getuid32, SysGetUserID, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getgid32, SysGetGroupID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_geteuid32, SysGetEffUserID, int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getegid32, SysGetEffGID, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_getresuid32, SysGetRealEffSaveUserID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getresgid32, SysGetRealEffSaveGroupID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setresuid32, SysSetRealEffSaveUserID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setresgid32, SysSetRealEffSaveGroupID, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_setreuid32, SysSetRealEffUserID, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setregid32, SysSetRealEffGroupID, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setgroups32, SysSetGroups, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_getgroups32, SysGetGroups, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setuid32, SysSetUserID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_setgid32, SysSetGroupID, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_gettid, SysGetTid, unsigned int, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_tkill, SysPthreadKill, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_futex, SysFutex, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_exit_group, SysUserExitGroup, void, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_set_thread_area, SysSetThreadArea, int, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_get_thread_area, SysGetThreadArea, char *, ARG_NUM_0)
// SYSCALL_HAND_DEF(__NR_timer_create, SysTimerCreate, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_timer_settime32, SysTimerSettime, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_timer_gettime32, SysTimerGettime, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_timer_getoverrun, SysTimerGetoverrun, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_timer_delete, SysTimerDelete, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_clock_settime32, SysClockSettime, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_clock_gettime32, SysClockGettime, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_clock_getres_time32, SysClockGetres, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_clock_nanosleep_time32, SysClockNanoSleep, int, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_mq_open, SysMqOpen, mqd_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_mq_unlink, SysMqUnlink, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_mq_timedsend, SysMqTimedSend, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_mq_timedreceive, SysMqTimedReceive, ssize_t, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_mq_notify, SysMqNotify, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_mq_getsetattr, SysMqGetSetAttr, int, ARG_NUM_3)
// #ifdef LOSCFG_NET_LWIP_SACK
// SYSCALL_HAND_DEF(__NR_socket, SysSocket, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_bind, SysBind, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_connect, SysConnect, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_listen, SysListen, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_accept, SysAccept, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getsockname, SysGetSockName, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_getpeername, SysGetPeerName, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_send, SysSend, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_sendto, SysSendTo, ssize_t, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_recv, SysRecv, ssize_t, ARG_NUM_4)
// SYSCALL_HAND_DEF(__NR_recvfrom, SysRecvFrom, ssize_t, ARG_NUM_6)
// SYSCALL_HAND_DEF(__NR_shutdown, SysShutdown, int, ARG_NUM_2)
// SYSCALL_HAND_DEF(__NR_setsockopt, SysSetSockOpt, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_getsockopt, SysGetSockOpt, int, ARG_NUM_5)
// SYSCALL_HAND_DEF(__NR_sendmsg, SysSendMsg, ssize_t, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_recvmsg, SysRecvMsg, ssize_t, ARG_NUM_3)
// #endif
// #ifdef LOSCFG_KERNEL_SHM
// SYSCALL_HAND_DEF(__NR_shmat, SysShmAt, void *, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_shmdt, SysShmDt, int, ARG_NUM_1)
// SYSCALL_HAND_DEF(__NR_shmget, SysShmGet, int, ARG_NUM_3)
// SYSCALL_HAND_DEF(__NR_shmctl, SysShmCtl, int, ARG_NUM_3)
// #endif
// SYSCALL_HAND_DEF(__NR_statx, SysStatx, int, ARG_NUM_5)
// /* LiteOS customized syscalls, not compatible with ARM EABI */
// 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_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)
// SYSCALL_HAND_DEF(__NR_setrlimit, SysSetrlimit, int, ARG_NUM_2)

View File

@@ -1,37 +0,0 @@
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/liteos.gni")
module_switch = defined(LOSCFG_SECURE)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = []
deps = [ "//third_party/musl/porting/liteos_m/user" ]
}

View File

@@ -42,13 +42,11 @@ kernel_module(module_name) {
"src/cmds/mempt_shellcmd.c",
"src/cmds/shell_shellcmd.c",
"src/cmds/task_shellcmd.c",
"src/cmds/vfs_shellcmd.c",
]
if (defined(LOSCFG_NET_LWIP_SACK)) {
defines = [ "LWIP_SHELLCMD_ENABLE" ]
}
if (defined(LOSCFG_FS_VFS)) {
sources += [ "src/cmds/vfs_shellcmd.c" ]
}
}
config("public") {

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -39,10 +39,6 @@
#include "los_mux.h"
#include "los_memory.h"
#if (LOSCFG_DEBUG_TOOLS == 1)
#include "los_debugtools.h"
#endif
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
STATIC CmdModInfo cmdInfo;
@@ -55,7 +51,6 @@ CmdItem g_shellcmdAll[] = {
{CMD_TYPE_EX, "ifconfig", XARGS, (CmdCallBackFunc)lwip_ifconfig},
{CMD_TYPE_EX, "ping", XARGS, (CmdCallBackFunc)OsShellPing},
#endif
#if (LOSCFG_FS_VFS == 1)
{CMD_TYPE_EX, "touch", XARGS, (CmdCallBackFunc)OsShellCmdTouch},
{CMD_TYPE_EX, "ls", XARGS, (CmdCallBackFunc)OsShellCmdLs},
{CMD_TYPE_EX, "pwd", XARGS, (CmdCallBackFunc)OsShellCmdPwd},
@@ -65,11 +60,6 @@ CmdItem g_shellcmdAll[] = {
{CMD_TYPE_EX, "rmdir", XARGS, (CmdCallBackFunc)OsShellCmdRmdir},
{CMD_TYPE_EX, "mkdir", XARGS, (CmdCallBackFunc)OsShellCmdMkdir},
{CMD_TYPE_EX, "cp", XARGS, (CmdCallBackFunc)OsShellCmdCp},
#endif
#if (LOSCFG_DEBUG_TOOLS == 1)
{CMD_TYPE_EX, "stack", 1, (CmdCallBackFunc)OsShellCmdStackDump},
{CMD_TYPE_EX, "hwi", 1, (CmdCallBackFunc)OsShellCmdHwiDump},
#endif
{CMD_TYPE_EX, "help", 0, (CmdCallBackFunc)OsShellCmdHelp},
};
@@ -203,7 +193,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCmdAscendingInsert(CmdItemNode *cmd)
}
for (cmdItem = LOS_DL_LIST_ENTRY((&cmdInfo.cmdList.list)->pstPrev, CmdItemNode, list);
&cmdItem->list != &(cmdInfo.cmdList.list);) {
&cmdItem->list != &(cmdInfo.cmdList.list); ) {
cmdNext = LOS_DL_LIST_ENTRY(cmdItem->list.pstPrev, CmdItemNode, list);
if (&cmdNext->list != &(cmdInfo.cmdList.list)) {
if ((strncmp(cmdItem->cmd->cmdKey, cmd->cmd->cmdKey, strlen(cmd->cmd->cmdKey)) >= 0) &&

View File

@@ -33,12 +33,13 @@ import("//third_party/musl/porting/liteos_m/kernel/musl.gni")
module_switch = defined(LOSCFG_LIBC_MUSL)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"fs.c",
"malloc.c",
]
sources = [ "malloc.c" ]
configs += [ "$LITEOSTOPDIR:warn_config" ]
if (defined(LOSCFG_LIBC_MUSL_FS)) {
sources += [ "fs.c" ]
}
deps = [ "//third_party/musl/porting/liteos_m/kernel" ]
}

View File

@@ -30,6 +30,7 @@
*/
#include "los_config.h"
#include "los_fs.h"
#include "stdarg.h"
#include "dirent.h"
#include "sys/mount.h"
@@ -37,16 +38,9 @@
#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)
const char *filesystemtype, unsigned long mountflags,
const void *data)
{
return LOS_FsMount(source, target, filesystemtype, mountflags, data);
}
@@ -160,119 +154,3 @@ ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
{
return LOS_Pwrite(fd, buf, nbyte, offset);
}
#else /* #ifdef LOSCFG_FS_VFS */
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data)
{
return -1;
}
int umount(const char *target)
{
return -1;
}
int umount2(const char *target, int flag)
{
return -1;
}
int open(const char *path, int oflag, ...)
{
return -1;
}
int close(int fd)
{
return -1;
}
ssize_t read(int fd, void *buf, size_t nbyte)
{
return -1;
}
ssize_t write(int fd, const void *buf, size_t nbyte)
{
return -1;
}
off_t lseek(int fd, off_t offset, int whence)
{
return -1;
}
int unlink(const char *path)
{
return -1;
}
int fstat(int fd, struct stat *buf)
{
return -1;
}
int stat(const char *path, struct stat *buf)
{
return -1;
}
int fsync(int fd)
{
return -1;
}
int mkdir(const char *path, mode_t mode)
{
return -1;
}
DIR *opendir(const char *dirName)
{
return NULL;
}
struct dirent *readdir(DIR *dir)
{
return NULL;
}
int closedir(DIR *dir)
{
return -1;
}
int rmdir(const char *path)
{
return -1;
}
int rename(const char *oldName, const char *newName)
{
return -1;
}
int statfs(const char *path, struct statfs *buf)
{
return -1;
}
int ftruncate(int fd, off_t length)
{
return -1;
}
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
{
return -1;
}
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
{
return -1;
}
#endif

View File

@@ -35,10 +35,4 @@
#define O_NDELAY _FNDELAY
#ifdef __riscv
#ifndef O_CLOEXEC
#define O_CLOEXEC 02000000
#endif
#endif /* __riscv */
#endif /* !_ADAPT_SYS_FCNTL_H */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* 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:

View File

@@ -33,7 +33,6 @@
#include <sys/features.h>
#include <sys/types.h>
#include <sys/uio.h>
#ifdef __cplusplus
extern "C" {
@@ -42,6 +41,11 @@ extern "C" {
typedef unsigned socklen_t;
typedef unsigned short sa_family_t;
struct iovec {
void *iov_base;
size_t iov_len;
};
struct msghdr {
void *msg_name;
socklen_t msg_namelen;

View File

@@ -40,11 +40,6 @@ extern "C" {
#define UIO_MAXIOV 1024
struct iovec {
void *iov_base;
size_t iov_len;
};
ssize_t readv(int, const struct iovec *, int);
ssize_t writev(int, const struct iovec *, int);

View File

@@ -37,38 +37,4 @@
#include_next <time.h>
#ifdef __riscv
#ifndef CLOCK_MONOTONIC_RAW
#define CLOCK_MONOTONIC_RAW 12
#endif
#ifndef CLOCK_REALTIME_COARSE
#define CLOCK_REALTIME_COARSE 5
#endif
#ifndef CLOCK_MONOTONIC_COARSE
#define CLOCK_MONOTONIC_COARSE 6
#endif
#ifndef CLOCK_BOOTTIME
#define CLOCK_BOOTTIME 7
#endif
#ifndef CLOCK_REALTIME_ALARM
#define CLOCK_REALTIME_ALARM 8
#endif
#ifndef CLOCK_BOOTTIME_ALARM
#define CLOCK_BOOTTIME_ALARM 9
#endif
#ifndef CLOCK_SGI_CYCLE
#define CLOCK_SGI_CYCLE 10
#endif
#ifndef CLOCK_TAI
#define CLOCK_TAI 11
#endif
#endif /* __riscv */
#endif /* !_ADAPT_TIME_H */

View File

@@ -29,16 +29,11 @@
*/
#include "los_config.h"
#include "los_fs.h"
#include "stdio.h"
#include "stdarg.h"
#include <sys/ioctl.h>
#ifdef LOSCFG_LIBC_NEWLIB_FS
#include "los_fs.h"
#else
#include "sys/stat.h"
#endif
#ifdef LOSCFG_LIBC_NEWLIB_FS
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
@@ -149,12 +144,7 @@ int ftruncate(int fd, off_t length)
int ioctl(int fd, int req, ...)
{
va_list ap;
va_start(ap, req);
int ret;
ret = LOS_Ioctl(fd, req, ap);
va_end(ap);
return ret;
return -1;
}
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)

View File

@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <poll.h>
#include "securec.h"
#include "los_fs.h"
#include "los_list.h"
#include "los_mux.h"
#include "los_sem.h"

View File

@@ -89,8 +89,6 @@ BOOL OsSchedTaskSwitch(VOID);
LosTaskCB *OsGetTopTask(VOID);
VOID OsSchedTimeConvertFreq(UINT32 oldFreq);
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
{
return LOS_SysCycleGet();

View File

@@ -56,10 +56,7 @@ typedef struct {
} SortLinkAttribute;
extern SortLinkAttribute g_taskSortLink;
#if (LOSCFG_BASE_CORE_SWTMR == 1)
extern SortLinkAttribute g_swtmrSortLink;
#endif
#define OS_SORT_LINK_INVALID_TIME ((UINT64)-1)
#define SET_SORTLIST_VALUE(sortList, value) (((SortLinkList *)(sortList))->responseTime = (value))
@@ -81,9 +78,9 @@ STATIC INLINE VOID OsDeleteNodeSortLink(SortLinkList *sortList)
SET_SORTLIST_VALUE(sortList, OS_SORT_LINK_INVALID_TIME);
}
STATIC INLINE UINT64 GetSortLinkNextExpireTime(SortLinkAttribute *sortHead, UINT64 startTime, UINT32 tickPrecision)
STATIC INLINE UINT64 GetSortLinkNextExpireTime(SortLinkAttribute *sortHeader, UINT64 startTime, UINT32 tickPrecision)
{
LOS_DL_LIST *head = &sortHead->sortLink;
LOS_DL_LIST *head = &sortHeader->sortLink;
LOS_DL_LIST *list = head->pstNext;
if (LOS_ListEmpty(head)) {
@@ -101,22 +98,16 @@ STATIC INLINE UINT64 GetSortLinkNextExpireTime(SortLinkAttribute *sortHead, UINT
STATIC INLINE UINT64 OsGetNextExpireTime(UINT64 startTime, UINT32 tickPrecision)
{
UINT64 taskExpireTime = GetSortLinkNextExpireTime(&g_taskSortLink, startTime, tickPrecision);
#if (LOSCFG_BASE_CORE_SWTMR == 1)
UINT64 swtmrExpireTime = GetSortLinkNextExpireTime(&g_swtmrSortLink, startTime, tickPrecision);
#else
UINT64 swtmrExpireTime = taskExpireTime;
#endif
return (taskExpireTime < swtmrExpireTime) ? taskExpireTime : swtmrExpireTime;
}
SortLinkAttribute *OsGetSortLinkAttribute(SortLinkType type);
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHead);
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHeader);
VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, SortLinkType type);
VOID OsDeleteSortLink(SortLinkList *node);
UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList);
UINT64 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHead);
VOID OsSortLinkResponseTimeConvertFreq(UINT32 oldFreq);
UINT64 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader);
#ifdef __cplusplus
#if __cplusplus

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -1277,16 +1277,6 @@ extern UINT32 LOS_TaskDetach(UINT32 taskID);
*/
#define OS_TASK_STATUS_EXIT 0x0100
#if (LOSCFG_SECURE == 1)
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
*
* This task is a user mode task.
*/
#define OS_TASK_FLAG_USER_TASK 0x0200
#endif
/**
* @ingroup los_task
* Flag that indicates the task or task control block status.
@@ -1503,11 +1493,6 @@ typedef struct {
LOSCFG_TASK_STRUCT_EXTENSION /**< Task extension field */
} LosTaskCB;
STATIC INLINE BOOL OsTaskIsExit(const LosTaskCB *taskCB)
{
return ((taskCB->taskStatus & OS_TASK_STATUS_EXIT) != 0);
}
typedef struct {
LosTaskCB *runTask;
LosTaskCB *newTask;
@@ -1584,9 +1569,7 @@ extern UINT32 g_idleTaskID;
* Software timer task ID.
*
*/
#if (LOSCFG_BASE_CORE_SWTMR == 1)
extern UINT32 g_swtmrTaskID;
#endif
/**
* @ingroup los_task

View File

@@ -157,6 +157,10 @@ extern UINT32 g_sysClock;
#define OS_SYS_NS_TO_CYCLE(time, freq) (((time) / OS_SYS_NS_PER_SECOND) * (freq) + \
((time) % OS_SYS_NS_PER_SECOND) * (freq) / OS_SYS_NS_PER_SECOND)
#define OS_SYS_TICK_TO_CYCLE(ticks) (((UINT64)(ticks) * g_sysClock) / LOSCFG_BASE_CORE_TICK_PER_SECOND)
#define OS_SYS_CYCLE_TO_TICK(cycle) ((((UINT64)(cycle)) * LOSCFG_BASE_CORE_TICK_PER_SECOND) / g_sysClock)
/**
* @ingroup los_tick
* System time basic function error code: Null pointer.
@@ -261,58 +265,6 @@ UINT32 OsTickTimerInit(VOID);
VOID OsTickSysTimerStartTimeSet(UINT64 currTime);
STATIC INLINE UINT64 OsTimeConvertFreq(UINT64 time, UINT32 oldFreq, UINT32 newFreq)
{
if (oldFreq >= newFreq) {
return (time / (oldFreq / newFreq));
}
return (time * (newFreq / oldFreq));
}
/**
* @ingroup los_tick
* @brief Adjust the system tick timer clock frequency function hooks.
*
* @par Description:
* This API is used to adjust the system tick timer clock frequency.
* @attention
* <ul>
* <li>None</li>
* </ul>
*
* @param param [IN] Function parameters.
*
* @retval 0: Adjust the system tick timer clock frequency failed.
* @retval more than zero: Adjust after the system tick timer clock frequency.
* @par Dependency:
* <ul><li>los_tick.h: the header file that contains the API declaration.</li></ul>
* @see None
*/
typedef UINT32 (*SYS_TICK_FREQ_ADJUST_FUNC)(UINTPTR param);
/**
* @ingroup los_tick
* @brief Adjust the system tick timer clock frequency.
*
* @par Description:
* This API is used to adjust the system tick timer clock frequency.
* @attention
* <ul>
* <li>This function needs to be invoked only when the clock frequency of the system tick timer adjust as a result of
* changing the CPU frequency.</li>
* </ul>
*
* @param handler [IN] Adjust the system tick timer clock frequency function hooks.
* @param param [IN] Function parameters.
*
* @retval LOS_OK or Error code.
* @par Dependency:
* <ul><li>los_tick.h: the header file that contains the API declaration.</li></ul>
* @see None
*/
extern UINT32 LOS_SysTickClockFreqAdjust(const SYS_TICK_FREQ_ADJUST_FUNC handler, UINTPTR param);
/**
* @ingroup los_tick
* @brief Obtain the number of Ticks.

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -82,15 +82,6 @@
#include "los_signal.h"
#endif
#if (LOSCFG_SECURE == 1)
#include "los_syscall.h"
#include "los_box.h"
#endif
#if (LOSCFG_FS_VFS == 1)
#include "vfs_operations.h"
#endif
/*****************************************************************************
Function : LOS_Reboot
Description : system exception, die in here, wait for watchdog.
@@ -181,6 +172,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
OsTaskMonInit();
#endif
#if (LOSCFG_BASE_CORE_CPUP == 1)
ret = OsCpupInit();
if (ret != LOS_OK) {
PRINT_ERR("OsCpupInit error\n");
return ret;
}
#endif
#if (LOSCFG_BASE_IPC_SEM == 1)
ret = OsSemInit();
if (ret != LOS_OK) {
@@ -211,22 +210,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
#if (LOSCFG_BASE_CORE_CPUP == 1)
ret = OsCpupInit();
if (ret != LOS_OK) {
PRINT_ERR("OsCpupInit error\n");
return ret;
}
#endif
#if (LOSCFG_FS_VFS == 1)
ret = OsVfsInit();
if (ret != LOS_OK) {
PRINT_ERR("OsVfsInit error\n");
return ret;
}
#endif
ret = OsIdleTaskCreate();
if (ret != LOS_OK) {
return ret;
@@ -279,11 +262,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
#if (LOSCFG_SECURE == 1)
OsSyscallHandleInit();
LOS_BoxStart();
#endif
return LOS_OK;
}

View File

@@ -245,7 +245,6 @@ static INLINE VOID OsQueueBufferOperate(LosQueueCB *queueCB, UINT32 operateType,
} else {
if (OS_QUEUE_IS_READ(operateType)) {
msgDataSize = *((UINT32 *)(UINTPTR)((queueNode + queueCB->queueSize) - sizeof(UINT32)));
msgDataSize = (*bufferSize < msgDataSize) ? *bufferSize : msgDataSize;
rc = memcpy_s((VOID *)bufferAddr, *bufferSize, (VOID *)queueNode, msgDataSize);
if (rc != EOK) {
PRINT_ERR("%s[%d] memcpy failed, error type = %u\n", __FUNCTION__, __LINE__, rc);
@@ -270,7 +269,9 @@ static INLINE UINT32 OsQueueOperateParamCheck(const LosQueueCB *queueCB, UINT32
return LOS_ERRNO_QUEUE_NOT_CREATE;
}
if (OS_QUEUE_IS_WRITE(operateType) && (*bufferSize > (queueCB->queueSize - sizeof(UINT32)))) {
if (OS_QUEUE_IS_READ(operateType) && (*bufferSize < (queueCB->queueSize - sizeof(UINT32)))) {
return LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL;
} else if (OS_QUEUE_IS_WRITE(operateType) && (*bufferSize > (queueCB->queueSize - sizeof(UINT32)))) {
return LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG;
}

View File

@@ -47,7 +47,10 @@ extern "C" {
#define OS_PRIORITY_QUEUE_NUM 32
#define PRIQUEUE_PRIOR0_BIT 0x80000000U
#define OS_SCHED_TIME_SLICES ((LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT * OS_SYS_NS_PER_US) / OS_NS_PER_CYCLE)
#define OS_TIME_SLICE_MIN (INT32)((50 * OS_SYS_NS_PER_US) / OS_NS_PER_CYCLE) /* 50us */
#define OS_TICK_RESPONSE_TIME_MAX LOSCFG_BASE_CORE_TICK_RESPONSE_MAX
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
#if (LOSCFG_BASE_CORE_TICK_RESPONSE_MAX == 0)
#error "Must specify the maximum value that tick timer counter supports!"
#endif
@@ -64,11 +67,6 @@ STATIC UINT32 g_schedResponseID = 0;
STATIC UINT16 g_tickIntLock = 0;
STATIC UINT64 g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
STATIC INT32 g_schedTimeSlice;
STATIC INT32 g_schedTimeSliceMin;
STATIC UINT32 g_schedTickMinPeriod;
STATIC UINT32 g_tickResponsePrecision;
VOID OsSchedResetSchedResponseTime(UINT64 responseTime)
{
if (responseTime <= g_schedResponseTime) {
@@ -93,15 +91,15 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT32 responseID, UINT64 taskEndTim
BOOL isTimeSlice = FALSE;
UINT64 currTime = OsGetCurrSchedTimeCycle();
UINT64 nextExpireTime = OsGetNextExpireTime(currTime, g_tickResponsePrecision);
UINT64 nextExpireTime = OsGetNextExpireTime(currTime, OS_TICK_RESPONSE_PRECISION);
/* The response time of the task time slice is aligned to the next response time in the delay queue */
if ((nextExpireTime > taskEndTime) && ((nextExpireTime - taskEndTime) > g_schedTickMinPeriod)) {
if ((nextExpireTime > taskEndTime) && ((nextExpireTime - taskEndTime) > OS_SCHED_MINI_PERIOD)) {
nextExpireTime = taskEndTime;
isTimeSlice = TRUE;
}
if ((g_schedResponseTime <= nextExpireTime) ||
((g_schedResponseTime - nextExpireTime) < g_tickResponsePrecision)) {
((g_schedResponseTime - nextExpireTime) < OS_TICK_RESPONSE_PRECISION)) {
return;
}
@@ -113,8 +111,8 @@ STATIC INLINE VOID OsSchedSetNextExpireTime(UINT32 responseID, UINT64 taskEndTim
}
nextResponseTime = nextExpireTime - currTime;
if (nextResponseTime < g_tickResponsePrecision) {
nextResponseTime = g_tickResponsePrecision;
if (nextResponseTime < OS_TICK_RESPONSE_PRECISION) {
nextResponseTime = OS_TICK_RESPONSE_PRECISION;
}
g_schedResponseTime = currTime + OsTickTimerReload(nextResponseTime);
}
@@ -133,10 +131,10 @@ VOID OsSchedUpdateExpireTime(VOID)
isPmMode = OsIsPmMode();
#endif
if ((runTask->taskID != g_idleTaskID) && !isPmMode) {
INT32 timeSlice = (runTask->timeSlice <= g_schedTimeSliceMin) ? g_schedTimeSlice : runTask->timeSlice;
INT32 timeSlice = (runTask->timeSlice <= OS_TIME_SLICE_MIN) ? (INT32)OS_SCHED_TIME_SLICES : runTask->timeSlice;
endTime = runTask->startTime + timeSlice;
} else {
endTime = OS_SCHED_MAX_RESPONSE_TIME - g_tickResponsePrecision;
endTime = OS_SCHED_MAX_RESPONSE_TIME - OS_TICK_RESPONSE_PRECISION;
}
OsSchedSetNextExpireTime(runTask->taskID, endTime);
}
@@ -229,10 +227,10 @@ VOID OsSchedTaskEnQueue(LosTaskCB *taskCB)
LOS_ASSERT(!(taskCB->taskStatus & OS_TASK_STATUS_READY));
if (taskCB->taskID != g_idleTaskID) {
if (taskCB->timeSlice > g_schedTimeSliceMin) {
if (taskCB->timeSlice > OS_TIME_SLICE_MIN) {
OsSchedPriQueueEnHead(&taskCB->pendList, taskCB->priority);
} else {
taskCB->timeSlice = g_schedTimeSlice;
taskCB->timeSlice = OS_SCHED_TIME_SLICES;
OsSchedPriQueueEnTail(&taskCB->pendList, taskCB->priority);
}
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTOREADYSTATE, taskCB);
@@ -268,7 +266,6 @@ VOID OsSchedTaskExit(LosTaskCB *taskCB)
OsDeleteSortLink(&taskCB->sortList);
taskCB->taskStatus &= ~(OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME);
}
taskCB->taskStatus |= OS_TASK_STATUS_EXIT;
}
VOID OsSchedYield(VOID)
@@ -420,44 +417,7 @@ UINT32 OsTaskNextSwitchTimeGet(VOID)
UINT64 OsSchedGetNextExpireTime(UINT64 startTime)
{
return OsGetNextExpireTime(startTime, g_tickResponsePrecision);
}
STATIC VOID TaskSchedTimeConvertFreq(UINT32 oldFreq)
{
for (UINT32 loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
LosTaskCB *taskCB = (((LosTaskCB *)g_taskCBArray) + loopNum);
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
continue;
}
if (taskCB->timeSlice > 0) {
taskCB->timeSlice = (INT32)OsTimeConvertFreq((UINT64)taskCB->timeSlice, oldFreq, g_sysClock);
} else {
taskCB->timeSlice = 0;
}
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
taskCB->startTime = OsTimeConvertFreq(taskCB->startTime, oldFreq, g_sysClock);
}
}
}
STATIC VOID SchedTimeBaseInit(VOID)
{
g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
g_schedTickMinPeriod = g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI;
g_tickResponsePrecision = (g_schedTickMinPeriod * 75) / 100; /* 75 / 100: minimum accuracy */
g_schedTimeSlice = (INT32)(((UINT64)g_sysClock * LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT) / OS_SYS_US_PER_SECOND);
g_schedTimeSliceMin = (INT32)(((UINT64)g_sysClock * 50) / OS_SYS_US_PER_SECOND); /* Minimum time slice 50 us */
}
VOID OsSchedTimeConvertFreq(UINT32 oldFreq)
{
SchedTimeBaseInit();
TaskSchedTimeConvertFreq(oldFreq);
OsSortLinkResponseTimeConvertFreq(oldFreq);
OsSchedUpdateExpireTime();
return OsGetNextExpireTime(startTime, OS_TICK_RESPONSE_PRECISION);
}
UINT32 OsSchedInit(VOID)
@@ -474,7 +434,7 @@ UINT32 OsSchedInit(VOID)
}
OsSortLinkInit(g_taskSortLinkList);
SchedTimeBaseInit();
g_schedResponseTime = OS_SCHED_MAX_RESPONSE_TIME;
return LOS_OK;
}
@@ -509,9 +469,7 @@ VOID OsSchedStart(VOID)
OsTickSysTimerStartTimeSet(newTask->startTime);
#if (LOSCFG_BASE_CORE_SWTMR == 1)
OsSwtmrResponseTimeReset(newTask->startTime);
#endif
/* Initialize the schedule timeline and enable scheduling */
g_taskScheduled = TRUE;
@@ -554,7 +512,7 @@ BOOL OsSchedTaskSwitch(VOID)
if (newTask->taskID != g_idleTaskID) {
endTime = newTask->startTime + newTask->timeSlice;
} else {
endTime = OS_SCHED_MAX_RESPONSE_TIME - g_tickResponsePrecision;
endTime = OS_SCHED_MAX_RESPONSE_TIME - OS_TICK_RESPONSE_PRECISION;
}
if (g_schedResponseID == runTask->taskID) {

View File

@@ -40,20 +40,17 @@ extern "C" {
#endif /* __cplusplus */
SortLinkAttribute g_taskSortLink;
#if (LOSCFG_BASE_CORE_SWTMR == 1)
SortLinkAttribute g_swtmrSortLink;
#endif
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHead)
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHeader)
{
LOS_ListInit(&sortLinkHead->sortLink);
LOS_ListInit(&sortLinkHeader->sortLink);
return LOS_OK;
}
STATIC INLINE VOID OsAddNode2SortLink(SortLinkAttribute *sortLinkHead, SortLinkList *sortList)
STATIC INLINE VOID OsAddNode2SortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortList)
{
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHead->sortLink;
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHeader->sortLink;
if (LOS_ListEmpty(head)) {
LOS_ListAdd(head, &sortList->sortLinkNode);
@@ -84,21 +81,19 @@ STATIC INLINE VOID OsAddNode2SortLink(SortLinkAttribute *sortLinkHead, SortLinkL
VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, SortLinkType type)
{
UINT32 intSave;
SortLinkAttribute *sortLinkHead = NULL;
SortLinkAttribute *sortLinkHeader = NULL;
if (type == OS_SORT_LINK_TASK) {
sortLinkHead = &g_taskSortLink;
#if (LOSCFG_BASE_CORE_SWTMR == 1)
sortLinkHeader = &g_taskSortLink;
} else if (type == OS_SORT_LINK_SWTMR) {
sortLinkHead = &g_swtmrSortLink;
#endif
sortLinkHeader = &g_swtmrSortLink;
} else {
LOS_Panic("Sort link type error : %u\n", type);
}
intSave = LOS_IntLock();
SET_SORTLIST_VALUE(node, startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK);
OsAddNode2SortLink(sortLinkHead, node);
SET_SORTLIST_VALUE(node, startTime + OS_SYS_TICK_TO_CYCLE(waitTicks));
OsAddNode2SortLink(sortLinkHeader, node);
LOS_IntRestore(intSave);
}
@@ -114,41 +109,12 @@ VOID OsDeleteSortLink(SortLinkList *node)
LOS_IntRestore(intSave);
}
STATIC INLINE VOID SortLinkNodeTimeUpdate(SortLinkAttribute *sortLinkHead, UINT32 oldFreq)
{
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHead->sortLink;
if (LOS_ListEmpty(head)) {
return;
}
LOS_DL_LIST *nextNode = head->pstNext;
do {
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(nextNode, SortLinkList, sortLinkNode);
listSorted->responseTime = OsTimeConvertFreq(listSorted->responseTime, oldFreq, g_sysClock);
nextNode = nextNode->pstNext;
} while (nextNode != head);
}
VOID OsSortLinkResponseTimeConvertFreq(UINT32 oldFreq)
{
SortLinkAttribute *taskHead = &g_taskSortLink;
SortLinkNodeTimeUpdate(taskHead, oldFreq);
#if (LOSCFG_BASE_CORE_SWTMR == 1)
SortLinkAttribute *swtmrHead = &g_swtmrSortLink;
SortLinkNodeTimeUpdate(swtmrHead, oldFreq);
#endif
}
SortLinkAttribute *OsGetSortLinkAttribute(SortLinkType type)
{
if (type == OS_SORT_LINK_TASK) {
return &g_taskSortLink;
#if (LOSCFG_BASE_CORE_SWTMR == 1)
} else if (type == OS_SORT_LINK_SWTMR) {
return &g_swtmrSortLink;
#endif
}
PRINT_ERR("Invalid sort link type!\n");
@@ -164,9 +130,9 @@ UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *target
return (targetSortList->responseTime - currTime);
}
UINT64 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHead)
UINT64 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader)
{
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHead->sortLink;
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHeader->sortLink;
if (LOS_ListEmpty(head)) {
return 0;

View File

@@ -141,8 +141,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrTaskCreate(VOID)
STATIC UINT64 OsSwtmrCalcStartTime(UINT64 currTime, SWTMR_CTRL_S *swtmr, const SWTMR_CTRL_S *alignSwtmr)
{
UINT64 usedTime, startTime;
UINT64 alignEnd = (UINT64)alignSwtmr->uwInterval * OS_CYCLE_PER_TICK;
UINT64 swtmrTime = (UINT64)swtmr->uwInterval * OS_CYCLE_PER_TICK;
UINT64 alignEnd = OS_SYS_TICK_TO_CYCLE(alignSwtmr->uwInterval);
UINT64 swtmrTime = OS_SYS_TICK_TO_CYCLE(swtmr->uwInterval);
UINT64 remainTime = OsSortLinkGetRemainTime(currTime, &alignSwtmr->stSortList);
if (remainTime == 0) {
startTime = GET_SORTLIST_VALUE(&alignSwtmr->stSortList);
@@ -357,7 +357,7 @@ LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
UINT32 intSave = LOS_IntLock();
UINT64 time = OsSortLinkGetNextExpireTime(g_swtmrSortLinkList);
LOS_IntRestore(intSave);
time = time / OS_CYCLE_PER_TICK;
time = OS_SYS_CYCLE_TO_TICK(time);
if (time > OS_NULL_INT) {
time = OS_NULL_INT;
}
@@ -367,7 +367,7 @@ LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
LITE_OS_SEC_TEXT UINT32 OsSwtmrTimeGet(const SWTMR_CTRL_S *swtmr)
{
UINT64 time = OsSortLinkGetTargetExpireTime(OsGetCurrSchedTimeCycle(), &swtmr->stSortList);
time = time / OS_CYCLE_PER_TICK;
time = OS_SYS_CYCLE_TO_TICK(time);
if (time > OS_NULL_INT) {
time = OS_NULL_INT;
}

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -102,11 +102,7 @@ LITE_OS_SEC_BSS LosTask g_losTask;
LITE_OS_SEC_BSS UINT16 g_losTaskLock;
LITE_OS_SEC_BSS UINT32 g_taskMaxNum;
LITE_OS_SEC_BSS UINT32 g_idleTaskID;
#if (LOSCFG_BASE_CORE_SWTMR == 1)
LITE_OS_SEC_BSS UINT32 g_swtmrTaskID;
#endif
LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_losFreeTask;
LITE_OS_SEC_DATA_INIT LOS_DL_LIST g_taskRecycleList;
LITE_OS_SEC_BSS BOOL g_taskScheduled = FALSE;
@@ -122,10 +118,8 @@ STATIC_INLINE UINT32 OsCheckTaskIDValid(UINT32 taskID)
UINT32 ret = LOS_OK;
if (taskID == g_idleTaskID) {
ret = LOS_ERRNO_TSK_OPERATE_IDLE;
#if (LOSCFG_BASE_CORE_SWTMR == 1)
} else if (taskID == g_swtmrTaskID) {
ret = LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED;
#endif
} else if (OS_TSK_GET_INDEX(taskID) >= g_taskMaxNum) {
ret = LOS_ERRNO_TSK_ID_INVALID;
}
@@ -152,7 +146,7 @@ STATIC VOID OsRecycleTaskResources(LosTaskCB *taskCB, UINTPTR *stackPtr)
taskCB->topOfStack = (UINT32)NULL;
taskCB->taskStatus &= ~OS_TASK_FLAG_STACK_FREE;
}
if (!(taskCB->taskStatus & OS_TASK_FLAG_JOINABLE)) {
if (!(taskCB->taskStatus & OS_TASK_STATUS_EXIT)) {
OsInsertTCBToFreeList(taskCB);
}
}
@@ -937,6 +931,7 @@ STATIC VOID OsTaskJoinPostUnsafe(LosTaskCB *taskCB)
resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(taskCB->joinList)));
OsSchedTaskWake(resumedTask);
}
taskCB->taskStatus |= OS_TASK_STATUS_EXIT;
}
}
@@ -1008,7 +1003,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval)
}
intSave = LOS_IntLock();
taskCB->taskStatus &= ~OS_TASK_FLAG_JOINABLE;
taskCB->taskStatus &= ~OS_TASK_STATUS_EXIT;
OsRecycleTaskResources(taskCB, &stackPtr);
LOS_IntRestore(intSave);
(VOID)LOS_MemFree(OS_TASK_STACK_ADDR, (VOID *)stackPtr);
@@ -1106,8 +1101,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
}
OsHookCall(LOS_HOOK_TYPE_TASK_DELETE, taskCB);
OsTaskJoinPostUnsafe(taskCB);
OsSchedTaskExit(taskCB);
OsTaskJoinPostUnsafe(taskCB);
LOS_EventDestroy(&(taskCB->event));
taskCB->event.uwEventID = OS_NULL_INT;
@@ -1127,7 +1122,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
LOSCFG_TASK_DELETE_EXTENSION_HOOK(taskCB);
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
if (!(taskCB->taskStatus & OS_TASK_FLAG_JOINABLE)) {
if (!(taskCB->taskStatus & OS_TASK_STATUS_EXIT)) {
taskCB->taskStatus |= OS_TASK_STATUS_UNUSED;
OsRunningTaskDelete(taskID, taskCB);
}
@@ -1218,11 +1213,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskPriSet(UINT32 taskID, UINT16 taskPrio)
return LOS_ERRNO_TSK_OPERATE_IDLE;
}
#if (LOSCFG_BASE_CORE_SWTMR == 1)
if (taskID == g_swtmrTaskID) {
return LOS_ERRNO_TSK_OPERATE_SWTMR;
}
#endif
if (OS_CHECK_TSK_PID_NOIDLE(taskID)) {
return LOS_ERRNO_TSK_ID_INVALID;

View File

@@ -48,14 +48,17 @@ LITE_OS_SEC_BSS STATIC UINT64 g_tickTimerStartTime;
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
STATIC UINT64 g_tickTimerBase;
STATIC UINT64 g_oldTickTimerBase;
STATIC BOOL g_tickTimerBaseUpdate = FALSE;
LITE_OS_SEC_TEXT STATIC VOID OsUpdateSysTimeBase(VOID)
{
UINT32 period = 0;
(VOID)g_sysTickTimer->getCycle(&period);
g_tickTimerBase += period;
if (g_tickTimerBaseUpdate == FALSE) {
(VOID)g_sysTickTimer->getCycle(&period);
g_tickTimerBase += period;
}
g_tickTimerBaseUpdate = FALSE;
}
LITE_OS_SEC_TEXT VOID OsTickTimerBaseReset(UINT64 currTime)
@@ -88,19 +91,21 @@ LITE_OS_SEC_TEXT UINT64 LOS_SysCycleGet(VOID)
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 1)
return g_sysTickTimer->getCycle(NULL);
#else
STATIC UINT64 oldSchedTime = 0;
UINT32 period = 0;
UINT32 intSave = LOS_IntLock();
UINT64 time = g_sysTickTimer->getCycle(&period);
UINT64 schedTime = g_tickTimerBase + time;
if (schedTime < g_oldTickTimerBase) {
if (schedTime < oldSchedTime) {
/* Turn the timer count */
g_tickTimerBase += period;
schedTime = g_tickTimerBase + time;
g_tickTimerBaseUpdate = TRUE;
}
LOS_ASSERT(schedTime >= g_oldTickTimerBase);
LOS_ASSERT(schedTime >= oldSchedTime);
g_oldTickTimerBase = schedTime;
oldSchedTime = schedTime;
LOS_IntRestore(intSave);
return schedTime;
#endif
@@ -230,47 +235,6 @@ LITE_OS_SEC_TEXT UINT32 LOS_TickTimerRegister(const ArchTickTimer *timer, const
return LOS_OK;
}
UINT32 LOS_SysTickClockFreqAdjust(const SYS_TICK_FREQ_ADJUST_FUNC handler, UINTPTR param)
{
UINT32 intSave;
UINT32 freq;
UINT32 oldFreq = g_sysClock;
if (handler == NULL) {
return LOS_ERRNO_SYS_HOOK_IS_NULL;
}
intSave = LOS_IntLock();
g_sysTickTimer->lock();
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
UINT64 currTimeCycle = LOS_SysCycleGet();
#endif
freq = handler(param);
if ((freq == 0) || (freq == g_sysClock)) {
g_sysTickTimer->unlock();
LOS_IntRestore(intSave);
return LOS_ERRNO_SYS_CLOCK_INVALID;
}
g_sysTickTimer->reload(LOSCFG_BASE_CORE_TICK_RESPONSE_MAX);
g_sysTickTimer->unlock();
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
g_tickTimerBase = OsTimeConvertFreq(currTimeCycle, oldFreq, freq);
g_oldTickTimerBase = OsTimeConvertFreq(g_oldTickTimerBase, oldFreq, freq);
g_tickTimerStartTime = OsTimeConvertFreq(g_tickTimerStartTime, oldFreq, freq);
#endif
g_sysTickTimer->freq = freq;
g_sysClock = g_sysTickTimer->freq;
g_cyclesPerTick = g_sysTickTimer->freq / LOSCFG_BASE_CORE_TICK_PER_SECOND;
OsSchedTimeConvertFreq(oldFreq);
LOS_IntRestore(intSave);
return LOS_OK;
}
LITE_OS_SEC_TEXT_MINOR VOID OsTickSysTimerStartTimeSet(UINT64 currTime)
{
g_tickTimerStartTime = currTime;
@@ -285,7 +249,7 @@ Return : current tick
*****************************************************************************/
LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID)
{
return (LOS_SysCycleGet() - g_tickTimerStartTime) / g_cyclesPerTick;
return OS_SYS_CYCLE_TO_TICK(LOS_SysCycleGet() - g_tickTimerStartTime);
}
/*****************************************************************************

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -2288,7 +2288,7 @@ UINT32 OsMemSystemInit(VOID)
#endif
ret = LOS_MemInit(m_aucSysMem0, LOSCFG_SYS_HEAP_SIZE);
PRINT_INFO("LiteOS heap memory address:%p, size:0x%lx\n", m_aucSysMem0, (unsigned long int)LOSCFG_SYS_HEAP_SIZE);
PRINT_INFO("LiteOS heap memory address:%p, size:0x%lx\n", m_aucSysMem0, LOSCFG_SYS_HEAP_SIZE);
return ret;
}

View File

@@ -48,7 +48,7 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL, ret, EXIT);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);

View File

@@ -47,7 +47,7 @@ static UINT32 Testcase(VOID)
// 6, Set a value less than QUEUE_BASE_MSGSIZE, for test erro code LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL
ret = LOS_QueueRead(g_testQueueID01, &buff2, 6, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL, ret, EXIT);
ret = LOS_QueueDelete(g_testQueueID01);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);

View File

@@ -45,6 +45,9 @@ static UINT32 Testcase(VOID)
ret = LOS_QueueWrite(g_testQueueID01, buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueRead(g_testQueueID01, &buff2, 7, 0); // 7, for boundary value test
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_READ_SIZE_TOO_SMALL, ret, EXIT);
ret = LOS_QueueRead(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
// 6, to verify the correct value

Some files were not shown because too many files have changed in this diff Show More