Compare commits

...

32 Commits

Author SHA1 Message Date
openharmony_ci d4d56b2b7c
!1045 Fix : pthread_cond_timedwait 信号丢失问题修复挑单到3.1-Release 分支
Merge pull request !1045 from yinjiaming/cherry-pick-1680507618
2023-04-11 01:58:35 +00:00
yinjiaming 01dae72fe5 fixed 2374c01 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/1043
fix:pthread_cond_timedwait解锁后清理的问题
该函数解锁mutex 后先清理事件,导致等的事件丢失

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I36f8658b1b850734bc029b486fec103f6bd10588
2023-04-03 07:40:22 +00:00
openharmony_ci 93e8dee1ae
!1018 fix:添加MAX_OPEN_DIRS宏,标识最大可打开dir数量
Merge pull request !1018 from zhangdengyu/max_open_dir
2023-01-31 11:28:55 +00:00
zhangdengyu 0988dcde34 fix: 添加LOSCFG_MAX_OPEN_DIRS标识最大可打开dir数量
方案描述:
提供LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。

BREAKING CHANGE:
新增LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。

Close:#I6BVYZ

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2023-01-31 10:46:40 +08:00
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
166 changed files with 568 additions and 495 deletions

View File

@ -369,7 +369,7 @@ config KERNEL_LMK
default n default n
depends on KERNEL_EXTKERNEL depends on KERNEL_EXTKERNEL
help help
Configuration item for low momery killer tailoring. Configuration item for low memory killer tailoring.
If you wish to build LiteOS with support for low memory killer. If you wish to build LiteOS with support for low memory killer.
config KERNEL_LMK_DEBUG config KERNEL_LMK_DEBUG
@ -574,7 +574,7 @@ config MEM_LEAKCHECK
depends on DEBUG_VERSION && MEM_DEBUG depends on DEBUG_VERSION && MEM_DEBUG
select KERNEL_BACKTRACE select KERNEL_BACKTRACE
help help
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node. Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the informations of mem node.
config BASE_MEM_NODE_INTEGRITY_CHECK config BASE_MEM_NODE_INTEGRITY_CHECK
bool "Enable integrity check or not" bool "Enable integrity check or not"
default n default n

View File

@ -85,11 +85,11 @@ Before setting up the environment for a development board, you must set up the b
For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained. For details about how to obtain the source code, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/HEAD/en/device-dev/get-code/sourcecode-acquire.md). This document assumes that the clone directory is `~/openHarmony` after the complete OpenHarmony repository code is obtained.
### Example projects that are already supported ### Example projects
Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`, For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu) Qemu simulator: `arm_mps2_an386、esp32、riscv32_virt、SmartL_E802`. For details about how to compile and run, see [qemu guide](https://gitee.com/openharmony/device_qemu).
Bestechnic: `bes2600`, For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic) Bestechnic: `bes2600`. For details about how to compile and run, see [Bestechnic developer guide](https://gitee.com/openharmony/device_soc_bestechnic).
### Community Porting Project Links ### Community Porting Project Links
@ -131,4 +131,4 @@ How to contribute a chip based on Liteos-M kernel:
[Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md) [Kernel Subsystem](https://gitee.com/openharmony/docs/blob/HEAD/en/readme/kernel-subsystem.md)
**kernel\_liteos\_m** [kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README.md)

View File

@ -131,5 +131,5 @@ LiteOS-M内核移植的具体开发板的工程由社区开发者提供可以
[内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md) [内核子系统](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
**kernel\_liteos\_m** [kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m/blob/master/README_zh.md)

View File

@ -76,6 +76,7 @@ LITE_OS_SEC_TEXT_MINOR VOID ArchSysExit(VOID)
LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack) LITE_OS_SEC_TEXT_INIT VOID *ArchTskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack)
{ {
TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext)); TaskContext *context = (TaskContext *)((UINTPTR)topStack + stackSize - sizeof(TaskContext));
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
context->r0 = taskID; context->r0 = taskID;
context->r1 = 0x01010101L; context->r1 = 0x01010101L;

View File

@ -163,7 +163,6 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None Output : None
Return : None Return : None
**************************************************************************** */ **************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID) LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{ {
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet()); PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());

0
arch/arm/cortex-m3/keil/los_atomic.S Executable file → Normal file
View File

View File

@ -190,7 +190,7 @@ _hwiActiveCheck
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
; exc occured in IRQ ; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -228,19 +228,19 @@ _hwiActiveCheckNext
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
; exc occured in Task or Init or exc ; exc occurred in Task or Init or exc
; reserved for register info from task stack ; reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
; exc occured in Task ; exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD) SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@ -40,14 +40,12 @@
#include "los_memory.h" #include "los_memory.h"
#include "los_membox.h" #include "los_membox.h"
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
#ifdef __ICCARM__ #ifdef __ICCARM__
#pragma location = ".data.vector" #pragma location = ".data.vector"
#elif defined(__CC_ARM) || defined(__GNUC__) #elif defined(__CC_ARM) || defined(__GNUC__)
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN #pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
LITE_OS_SEC_VEC LITE_OS_SEC_VEC
#endif #endif
/* * /* *
@ -198,7 +196,6 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None Output : None
Return : None Return : None
**************************************************************************** */ **************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID) LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{ {
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet()); PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
@ -579,19 +576,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ 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 */ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@ -602,7 +599,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */ /* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */ /* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC #ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT); *(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

0
arch/arm/cortex-m33/gcc/NTZ/los_arch_atomic.h Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/NTZ/los_arch_context.h Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/NTZ/los_arch_interrupt.h Executable file → Normal file
View File

8
arch/arm/cortex-m33/gcc/NTZ/los_exc.S Executable file → Normal file
View File

@ -263,7 +263,7 @@ _hwiActiveCheck:
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
// exc occured in IRQ // exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -316,19 +316,19 @@ _hwiActiveCheckNext:
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
// exc occured in Task or Init or exc // exc occurred in Task or Init or exc
// reserved for register info from task stack // reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
// exc occured in Task // exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD) SUB R13, #96 // add 8 Bytes reg(for STMFD)

21
arch/arm/cortex-m33/gcc/NTZ/los_interrupt.c Executable file → Normal file
View File

@ -41,10 +41,8 @@
#include "los_membox.h" #include "los_membox.h"
#define DEF_HANDLER_START_INDEX 2 #define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
@ -189,7 +187,6 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None Output : None
Return : None Return : None
**************************************************************************** */ **************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID) LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{ {
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet()); PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
@ -575,14 +572,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@ -593,7 +590,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */ /* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */ /* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC #ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT); *(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

0
arch/arm/cortex-m33/gcc/NTZ/los_timer.c Executable file → Normal file
View File

View File

View File

View File

8
arch/arm/cortex-m33/gcc/TZ/non_secure/los_exc.S Executable file → Normal file
View File

@ -247,7 +247,7 @@ _hwiActiveCheck:
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
// exc occured in IRQ // exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -300,19 +300,19 @@ _hwiActiveCheckNext:
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
// exc occured in Task or Init or exc // exc occurred in Task or Init or exc
// reserved for register info from task stack // reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
// exc occured in Task // exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD) SUB R13, #96 // add 8 Bytes reg(for STMFD)

21
arch/arm/cortex-m33/gcc/TZ/non_secure/los_interrupt.c Executable file → Normal file
View File

@ -41,11 +41,8 @@
#include "los_membox.h" #include "los_membox.h"
#define DEF_HANDLER_START_INDEX 2 #define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* Hardware interrupt form mapping handling function array. * Hardware interrupt form mapping handling function array.
@ -575,14 +572,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@ -593,7 +590,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */ /* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */ /* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC #ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT); *(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

0
arch/arm/cortex-m33/gcc/TZ/non_secure/los_timer.c Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/non_secure/los_trustzone.c Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/non_secure/los_trustzone.h Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.c Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_context.h Executable file → Normal file
View File

View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_heap.c Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_heap.h Executable file → Normal file
View File

0
arch/arm/cortex-m33/gcc/TZ/secure/los_secure_macros.h Executable file → Normal file
View File

View File

@ -56,8 +56,8 @@ FLAG_ADDR_VALID EQU 0x10000
FLAG_HWI_ACTIVE EQU 0x20000 FLAG_HWI_ACTIVE EQU 0x20000
FLAG_NO_FLOAT EQU 0x10000000 FLAG_NO_FLOAT EQU 0x10000000
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Regeister OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Register
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Regeister OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Register
OS_NVIC_BFAR EQU 0xE000ED38 OS_NVIC_BFAR EQU 0xE000ED38
OS_NVIC_MMAR EQU 0xE000ED34 OS_NVIC_MMAR EQU 0xE000ED34
OS_NVIC_ACT_BASE EQU 0xE000E300 OS_NVIC_ACT_BASE EQU 0xE000E300
@ -190,7 +190,7 @@ _hwiActiveCheck
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
; exc occured in IRQ ; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -228,19 +228,19 @@ _hwiActiveCheckNext
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
; exc occured in Task or Init or exc ; exc occurred in Task or Init or exc
; reserved for register info from task stack ; reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
; exc occured in Task ; exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD) SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@ -46,7 +46,7 @@ UINT32 g_intCount = 0;
/*lint -restore*/ /*lint -restore*/
#pragma location = ".data.vector" #pragma location = ".data.vector"
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN #pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* hardware interrupt form mapping handling function array. * hardware interrupt form mapping handling function array.
@ -577,19 +577,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ 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 */ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@ -55,8 +55,8 @@ FLAG_ADDR_VALID EQU 0x10000
FLAG_HWI_ACTIVE EQU 0x20000 FLAG_HWI_ACTIVE EQU 0x20000
FLAG_NO_FLOAT EQU 0x10000000 FLAG_NO_FLOAT EQU 0x10000000
OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Regeister OS_NVIC_FSR EQU 0xE000ED28 ;include BusFault/MemFault/UsageFault State Register
OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Regeister OS_NVIC_HFSR EQU 0xE000ED2C ;HardFault State Register
OS_NVIC_BFAR EQU 0xE000ED38 OS_NVIC_BFAR EQU 0xE000ED38
OS_NVIC_MMAR EQU 0xE000ED34 OS_NVIC_MMAR EQU 0xE000ED34
OS_NVIC_ACT_BASE EQU 0xE000E300 OS_NVIC_ACT_BASE EQU 0xE000E300
@ -179,7 +179,7 @@ _hwiActiveCheck
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
; exc occured in IRQ ; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -217,19 +217,19 @@ _hwiActiveCheckNext
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
; exc occured in Task or Init or exc ; exc occurred in Task or Init or exc
; reserved for register info from task stack ; reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
; exc occured in Task ; exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD) SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@ -46,7 +46,7 @@ UINT32 g_intCount = 0;
/*lint -restore*/ /*lint -restore*/
#pragma location = ".data.vector" #pragma location = ".data.vector"
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN #pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* hardware interrupt form mapping handling function array. * hardware interrupt form mapping handling function array.
@ -577,19 +577,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ 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 */ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

View File

@ -34,7 +34,7 @@
#include "los_config.h" #include "los_config.h"
#include "los_list.h" #include "los_list.h"
#pragma data_alignment=0x4 #pragma data_alignment = 0x4
STATIC UINT8 g_secureHeap[LOSCFG_SECURE_HEAP_SIZE] = {0}; STATIC UINT8 g_secureHeap[LOSCFG_SECURE_HEAP_SIZE] = {0};
STATIC LOS_DL_LIST g_secureHeapFreeList = {NULL, NULL}; STATIC LOS_DL_LIST g_secureHeapFreeList = {NULL, NULL};

View File

@ -263,7 +263,7 @@ _hwiActiveCheck:
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
// exc occured in IRQ // exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -316,19 +316,19 @@ _hwiActiveCheckNext:
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
// exc occured in Task or Init or exc // exc occurred in Task or Init or exc
// reserved for register info from task stack // reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
// exc occured in Task // exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD) SUB R13, #96 // add 8 Bytes reg(for STMFD)

View File

@ -40,11 +40,8 @@
#include "los_memory.h" #include "los_memory.h"
#include "los_membox.h" #include "los_membox.h"
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* Hardware interrupt form mapping handling function array. * Hardware interrupt form mapping handling function array.
@ -193,7 +190,6 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None Output : None
Return : None Return : None
**************************************************************************** */ **************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID) LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{ {
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet()); PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
@ -584,19 +580,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ 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 */ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@ -607,7 +603,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */ /* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */ /* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC #ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT); *(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

View File

@ -190,7 +190,7 @@ _hwiActiveCheck
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
; exc occured in IRQ ; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -228,19 +228,19 @@ _hwiActiveCheckNext
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
; exc occured in Task or Init or exc ; exc occurred in Task or Init or exc
; reserved for register info from task stack ; reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
; exc occured in Task ; exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD) SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@ -41,13 +41,11 @@
#include "los_memory.h" #include "los_memory.h"
#include "los_membox.h" #include "los_membox.h"
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
#ifdef __ICCARM__ #ifdef __ICCARM__
#pragma location = ".data.vector" #pragma location = ".data.vector"
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN #pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
#elif defined(__CC_ARM) || defined(__GNUC__) #elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC LITE_OS_SEC_VEC
#endif #endif
@ -580,19 +578,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ 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 */ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@ -603,7 +601,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */ /* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */ /* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC #ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT); *(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

0
arch/arm/cortex-m55/gcc/BUILD.gn Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/BUILD.gn Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_arch_atomic.h Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_arch_context.h Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_arch_interrupt.h Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_arch_timer.h Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_context.c Executable file → Normal file
View File

0
arch/arm/cortex-m55/gcc/NTZ/los_dispatch.S Executable file → Normal file
View File

8
arch/arm/cortex-m55/gcc/NTZ/los_exc.S Executable file → Normal file
View File

@ -260,7 +260,7 @@ _hwiActiveCheck:
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
// exc occured in IRQ // exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -313,19 +313,19 @@ _hwiActiveCheckNext:
AND R2, R2, R3 AND R2, R2, R3
CMP R2, #0 CMP R2, #0
BNE _ExcInMSP BNE _ExcInMSP
// exc occured in Task or Init or exc // exc occurred in Task or Init or exc
// reserved for register info from task stack // reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
// exc occured in Task // exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD) SUB R13, #96 // add 8 Bytes reg(for STMFD)

19
arch/arm/cortex-m55/gcc/NTZ/los_interrupt.c Executable file → Normal file
View File

@ -40,10 +40,8 @@
#include "los_membox.h" #include "los_membox.h"
#define DEF_HANDLER_START_INDEX 2 #define DEF_HANDLER_START_INDEX 2
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
@ -193,7 +191,6 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None Output : None
Return : None Return : None
**************************************************************************** */ **************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID) LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{ {
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet()); PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
@ -583,14 +580,14 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalSVCHandler; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalSVCHandler;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = OsTickHandler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)OsTickHandler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;

0
arch/arm/cortex-m55/gcc/NTZ/los_timer.c Executable file → Normal file
View File

View File

@ -263,7 +263,7 @@ _hwiActiveCheck:
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
// exc occured in IRQ // exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -316,19 +316,19 @@ _hwiActiveCheckNext:
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
// exc occured in Task or Init or exc // exc occurred in Task or Init or exc
// reserved for register info from task stack // reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 // OS_FLG_BGD_ACTIVE TST R2, #1 // OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP // if exc occured in Init then branch BEQ _ExcInMSP // if exc occurred in Init then branch
CMP LR, #0xFFFFFFED //auto push floating registers CMP LR, #0xFFFFFFED //auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
// exc occured in Task // exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 // add 8 Bytes reg(for STMFD) SUB R13, #96 // add 8 Bytes reg(for STMFD)

View File

@ -40,11 +40,8 @@
#include "los_memory.h" #include "los_memory.h"
#include "los_membox.h" #include "los_membox.h"
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* Hardware interrupt form mapping handling function array. * Hardware interrupt form mapping handling function array.
@ -188,7 +185,6 @@ inline UINT32 ArchIsIntActive(VOID)
Output : None Output : None
Return : None Return : None
**************************************************************************** */ **************************************************************************** */
/*lint -e529*/
LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID) LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
{ {
PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet()); PRINT_ERR("%s irqnum:%u\n", __FUNCTION__, HwiNumGet());
@ -569,19 +565,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ 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 */ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@ -592,7 +588,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */ /* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */ /* Enable DIV 0 and unaligned exception */
#ifdef LOSCFG_ARCH_UNALIGNED_EXC #ifdef LOSCFG_ARCH_UNALIGNED_EXC
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT); *(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

View File

@ -190,7 +190,7 @@ _hwiActiveCheck
CMP R3, #0 CMP R3, #0
BEQ _hwiActiveCheckNext BEQ _hwiActiveCheckNext
; exc occured in IRQ ; exc occurred in IRQ
ORR R0, R0, #FLAG_HWI_ACTIVE ORR R0, R0, #FLAG_HWI_ACTIVE
RBIT R2, R3 RBIT R2, R3
CLZ R2, R2 CLZ R2, R2
@ -228,19 +228,19 @@ _hwiActiveCheckNext
AND R2, R2,R3 AND R2, R2,R3
CMP R2,#0 CMP R2,#0
BNE _ExcInMSP BNE _ExcInMSP
; exc occured in Task or Init or exc ; exc occurred in Task or Init or exc
; reserved for register info from task stack ; reserved for register info from task stack
LDR R2, =g_taskScheduled LDR R2, =g_taskScheduled
LDR R2, [R2] LDR R2, [R2]
TST R2, #1 ; OS_FLG_BGD_ACTIVE TST R2, #1 ; OS_FLG_BGD_ACTIVE
BEQ _ExcInMSP ; if exc occured in Init then branch BEQ _ExcInMSP ; if exc occurred in Init then branch
CMP LR, #0xFFFFFFED ;auto push floating registers CMP LR, #0xFFFFFFED ;auto push floating registers
BNE _NoFloatInPsp BNE _NoFloatInPsp
; exc occured in Task ; exc occurred in Task
MOV R2, R13 MOV R2, R13
SUB R13, #96 ; add 8 Bytes reg(for STMFD) SUB R13, #96 ; add 8 Bytes reg(for STMFD)

View File

@ -41,12 +41,10 @@
#include "los_memory.h" #include "los_memory.h"
#include "los_membox.h" #include "los_membox.h"
/*lint -save -e40 -e522 -e533*/
UINT32 g_intCount = 0; UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector" #pragma location = ".data.vector"
#pragma data_alignment=LOSCFG_ARCH_HWI_VECTOR_ALIGN #pragma data_alignment = LOSCFG_ARCH_HWI_VECTOR_ALIGN
/* * /* *
* @ingroup los_hwi * @ingroup los_hwi
* Hardware interrupt form mapping handling function array. * Hardware interrupt form mapping handling function array.
@ -576,19 +574,19 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
#if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1) #if (LOSCFG_USE_SYSTEM_DEFINED_INTERRUPT == 1)
UINT32 index; UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */ 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 */ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler; g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
} }
/* Exception handler register */ /* Exception handler register */
g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = HalExcNMI; g_hwiForm[NonMaskableInt_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcNMI;
g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = HalExcHardFault; g_hwiForm[HARDFAULT_IRQN + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcHardFault;
g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = HalExcMemFault; g_hwiForm[MemoryManagement_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcMemFault;
g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcBusFault; g_hwiForm[BusFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcBusFault;
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault; g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall; g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV; g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalPendSV;
g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler; g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)SysTick_Handler;
/* Interrupt vector table location */ /* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm; SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@ -599,7 +597,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
/* Enable USGFAULT, BUSFAULT, MEMFAULT */ /* Enable USGFAULT, BUSFAULT, MEMFAULT */
*(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT); *(volatile UINT32 *)OS_NVIC_SHCSR |= (USGFAULT | BUSFAULT | MEMFAULT);
/* Enable DIV 0 and unaligned exception */ /* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT); *(volatile UINT32 *)OS_NVIC_CCR |= (DIV0FAULT | UNALIGNFAULT);

0
arch/csky/v2/gcc/BUILD.gn Executable file → Normal file
View File

0
arch/include/los_atomic.h Executable file → Normal file
View File

View File

@ -179,7 +179,6 @@ exc_entry:
csrr a0, mcause csrr a0, mcause
mv a1, sp mv a1, sp
/* /*
* TODO: Call the exception handler function
* By default, the function template is provided in * By default, the function template is provided in
* system_Device.c, you can adjust it as you want * system_Device.c, you can adjust it as you want
*/ */

View File

@ -105,7 +105,7 @@
* Based on the types of the four 8-bit arithmetic operations, the SIMD 8-bit add/subtract instructions * Based on the types of the four 8-bit arithmetic operations, the SIMD 8-bit add/subtract instructions
* can be classified into 2 main categories: Addition (four 8-bit addition), and Subtraction (four 8-bit * can be classified into 2 main categories: Addition (four 8-bit addition), and Subtraction (four 8-bit
* subtraction). * subtraction).
* Based on the way of how an overflow condition is handled for singed or unsigned operation, the * Based on the way of how an overflow condition is handled for signed or unsigned operation, the
* SIMD 8-bit add/subtract instructions can be classified into 5 groups: Wrap-around (dropping * SIMD 8-bit add/subtract instructions can be classified into 5 groups: Wrap-around (dropping
* overflow), Signed Halving (keeping overflow by dropping 1 LSB bit), Unsigned Halving, Signed * overflow), Signed Halving (keeping overflow by dropping 1 LSB bit), Unsigned Halving, Signed
* Saturation (clipping overflow), and Unsigned Saturation. * Saturation (clipping overflow), and Unsigned Saturation.

View File

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

View File

@ -332,7 +332,7 @@ VOID HalExcEntry(const LosExcContext *excBufAddr)
ExcInfoDisplay(excBufAddr); ExcInfoDisplay(excBufAddr);
if (LOS_TaskIsRunning()) { if (LOS_TaskIsRunning()) {
PRINTK("----------------All Task infomation ------------\n"); PRINTK("----------------All Task information ------------\n");
OsGetAllTskInfo(); OsGetAllTskInfo();
} }

View File

@ -52,8 +52,8 @@ extern "C" {
#define CODE_SECTION_NAME ".text" #define CODE_SECTION_NAME ".text"
/* The default C stack section name is CSTACK */ /* The default C stack section name is CSTACK */
#define CSTACK_SECTION_NAME "CSTACK" #define CSTACK_SECTION_NAME "CSTACK"
#pragma section=CODE_SECTION_NAME #pragma section = CODE_SECTION_NAME
#pragma section=CSTACK_SECTION_NAME #pragma section = CSTACK_SECTION_NAME
/* Default only one code section. In fact, there may be more than one. /* Default only one code section. In fact, there may be more than one.
You can define more than one and redefine the OsStackDataIsCodeAddr function You can define more than one and redefine the OsStackDataIsCodeAddr function

View File

@ -82,7 +82,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit()
/***************************************************************************** /*****************************************************************************
Function : OsTskCycleStart Function : OsTskCycleStart
Description: start task to get cycles count in current task begining Description: start task to get cycles count in current task beginning
Input : None Input : None
Return : None Return : None
*****************************************************************************/ *****************************************************************************/

21
components/dynlink/los_dynlink.c Executable file → Normal file
View File

@ -73,8 +73,8 @@ const SymInfo symTableEnd __attribute__((section(".table.end"))) = {
.name = "end", .name = "end",
.addr = 0 .addr = 0
}; };
#pragma section=".TABLE.START" #pragma section = ".TABLE.START"
#pragma section=".table.end" #pragma section = ".table.end"
#elif defined(__CLANG_ARM) || defined(__GNUC__) #elif defined(__CLANG_ARM) || defined(__GNUC__)
/** /**
* Place instructions below in rodata segment of .ld linker file: * Place instructions below in rodata segment of .ld linker file:
@ -796,13 +796,13 @@ VOID *LOS_SoLoad(const CHAR *fileName, VOID *pool)
return dso; return dso;
ERR2: ERR2:
LOS_MemFree(dso->pool, (VOID *)dso->loadBase); (VOID)LOS_MemFree(dso->pool, (VOID *)dso->loadBase);
ERR1: ERR1:
close(dso->fd); close(dso->fd);
(VOID)LOS_MuxPost(g_dynlinkMux); (VOID)LOS_MuxPost(g_dynlinkMux);
LOS_MemFree(OS_SYS_MEM_ADDR, dso->dlInfo->elfPhdr); (VOID)LOS_MemFree(OS_SYS_MEM_ADDR, dso->dlInfo->elfPhdr);
LOS_MemFree(OS_SYS_MEM_ADDR, dso->dlInfo); (VOID)LOS_MemFree(OS_SYS_MEM_ADDR, dso->dlInfo);
LOS_MemFree(OS_SYS_MEM_ADDR, dso); (VOID)LOS_MemFree(OS_SYS_MEM_ADDR, dso);
return NULL; return NULL;
} }
@ -902,9 +902,12 @@ INT32 LOS_SoUnload(VOID *handle)
LOS_ListDelete(&dso->dsoNode); LOS_ListDelete(&dso->dsoNode);
(VOID)LOS_MuxPost(g_dynlinkMux); (VOID)LOS_MuxPost(g_dynlinkMux);
LOS_MemFree(dso->pool, (VOID *)dso->loadBase); (VOID)LOS_MemFree(dso->pool, (VOID *)dso->loadBase);
LOS_MemFree(OS_SYS_MEM_ADDR, dso->dlInfo); if (dso->dlInfo != NULL) {
LOS_MemFree(OS_SYS_MEM_ADDR, dso); (VOID)LOS_MemFree(OS_SYS_MEM_ADDR, dso->dlInfo->elfPhdr);
}
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, dso->dlInfo);
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, dso);
return LOS_OK; return LOS_OK;
ERR: ERR:

2
components/dynlink/los_dynlink.h Executable file → Normal file
View File

@ -169,7 +169,7 @@ VOID *LOS_SoLoad(const CHAR *fileName, VOID *pool);
VOID *LOS_FindSym(VOID *handle, const CHAR *name); VOID *LOS_FindSym(VOID *handle, const CHAR *name);
/* /*
* @brief Decrement the reference count on the loaded shared library refered to by handle. * @brief Decrement the reference count on the loaded shared library referred to by handle.
* If the reference count drops to zero, then the library is unloaded. * If the reference count drops to zero, then the library is unloaded.
* *
* This function validates that the handle is valid. * This function validates that the handle is valid.

View File

@ -55,7 +55,7 @@ STATIC ExcInfoArray g_excArray[OS_EXC_TYPE_MAX];
STATIC UINT32 OsExcSaveIntStatus(UINT32 type, VOID *arg) STATIC UINT32 OsExcSaveIntStatus(UINT32 type, VOID *arg)
{ {
UINT32 ret; errno_t ret;
UINTPTR excContentEnd = (UINTPTR)MAX_INT_INFO_SIZE + (UINTPTR)g_excContent; UINTPTR excContentEnd = (UINTPTR)MAX_INT_INFO_SIZE + (UINTPTR)g_excContent;
(VOID)arg; (VOID)arg;
@ -92,6 +92,9 @@ STATIC UINT32 OsExcSaveIntStatus(UINT32 type, VOID *arg)
/* save IRQ Priority reg group */ /* save IRQ Priority reg group */
ret = memcpy_s(g_excContent, excContentEnd - (UINTPTR)g_excContent, ret = memcpy_s(g_excContent, excContentEnd - (UINTPTR)g_excContent,
(const VOID *)OS_NVIC_PRI_BASE, OS_NVIC_INT_PRI_SIZE); (const VOID *)OS_NVIC_PRI_BASE, OS_NVIC_INT_PRI_SIZE);
if (ret != EOK) {
return LOS_NOK;
}
g_excContent = (UINT8 *)g_excContent + OS_NVIC_INT_PRI_SIZE; g_excContent = (UINT8 *)g_excContent + OS_NVIC_INT_PRI_SIZE;
/* save Exception Priority reg group */ /* save Exception Priority reg group */
@ -294,5 +297,3 @@ VOID OsExcMsgDumpInit(VOID)
(VOID)LOS_RegExcHook(EXC_INTERRUPT, (ExcHookFn)OsExcMsgDump); (VOID)LOS_RegExcHook(EXC_INTERRUPT, (ExcHookFn)OsExcMsgDump);
} }
#endif #endif

View File

@ -32,6 +32,8 @@
#define _GNU_SOURCE 1 #define _GNU_SOURCE 1
#include "lfs_api.h" #include "lfs_api.h"
#include "los_config.h" #include "los_config.h"
#include "los_mux.h"
#include "los_debug.h"
#include "securec.h" #include "securec.h"
lfs_t g_lfs; lfs_t g_lfs;
@ -40,29 +42,41 @@ FileDirInfo g_lfsDir[LFS_MAX_OPEN_DIRS] = {0};
struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0}; struct FileOpInfo g_fsOp[LOSCFG_LFS_MAX_MOUNT_SIZE] = {0};
static LittleFsHandleStruct g_handle[LOSCFG_LFS_MAX_OPEN_FILES] = {0}; static LittleFsHandleStruct g_handle[LOSCFG_LFS_MAX_OPEN_FILES] = {0};
struct dirent g_nameValue; struct dirent g_nameValue;
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER; static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a", "/littlefs"};
static const char *g_littlefsMntName[LOSCFG_LFS_MAX_MOUNT_SIZE] = {"/a"}; #define LFS_MUTEX_UNINIT (-1)
static UINT32 g_lfsMutex = LFS_MUTEX_UNINIT;
static int LfsLock(void)
{
if (LOS_MuxPend(g_lfsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
PRINT_ERR("LfsLock failed!");
return LOS_NOK;
}
return LOS_OK;
}
static void LfsUnlock(void)
{
(void)LOS_MuxPost(g_lfsMutex);
}
LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd) LittleFsHandleStruct *LfsAllocFd(const char *fileName, int *fd)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) { for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) {
if (g_handle[i].useFlag == 0) { if (g_handle[i].useFlag == 0) {
*fd = i; *fd = i;
g_handle[i].useFlag = 1; g_handle[i].useFlag = 1;
g_handle[i].pathName = strdup(fileName); g_handle[i].pathName = strdup(fileName);
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_handle[i]); return &(g_handle[i]);
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
*fd = INVALID_FD; *fd = INVALID_FD;
return NULL; return NULL;
} }
static void LfsFreeFd(int fd) static void LfsFreeFd(int fd)
{ {
pthread_mutex_lock(&g_FslocalMutex);
g_handle[fd].useFlag = 0; g_handle[fd].useFlag = 0;
if (g_handle[fd].pathName != NULL) { if (g_handle[fd].pathName != NULL) {
free((void *)g_handle[fd].pathName); free((void *)g_handle[fd].pathName);
@ -72,21 +86,17 @@ static void LfsFreeFd(int fd)
if (g_handle[fd].lfsHandle != NULL) { if (g_handle[fd].lfsHandle != NULL) {
g_handle[fd].lfsHandle = NULL; g_handle[fd].lfsHandle = NULL;
} }
pthread_mutex_unlock(&g_FslocalMutex);
} }
BOOL CheckFileIsOpen(const char *fileName) BOOL CheckFileIsOpen(const char *fileName)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) { for (int i = 0; i < LOSCFG_LFS_MAX_OPEN_FILES; i++) {
if (g_handle[i].useFlag == 1) { if (g_handle[i].useFlag == 1) {
if (strcmp(g_handle[i].pathName, fileName) == 0) { if (strcmp(g_handle[i].pathName, fileName) == 0) {
pthread_mutex_unlock(&g_FslocalMutex);
return TRUE; return TRUE;
} }
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
return FALSE; return FALSE;
} }
@ -103,22 +113,18 @@ static BOOL LfsFdIsValid(int fd)
FileDirInfo *GetFreeDir(const char *dirName) FileDirInfo *GetFreeDir(const char *dirName)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) { for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) {
if (g_lfsDir[i].useFlag == 0) { if (g_lfsDir[i].useFlag == 0) {
g_lfsDir[i].useFlag = 1; g_lfsDir[i].useFlag = 1;
g_lfsDir[i].dirName = strdup(dirName); g_lfsDir[i].dirName = strdup(dirName);
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_lfsDir[i]); return &(g_lfsDir[i]);
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
return NULL; return NULL;
} }
void FreeDirInfo(const char *dirName) void FreeDirInfo(const char *dirName)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) { for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) {
if (g_lfsDir[i].useFlag == 1 && strcmp(g_lfsDir[i].dirName, dirName) == 0) { if (g_lfsDir[i].useFlag == 1 && strcmp(g_lfsDir[i].dirName, dirName) == 0) {
g_lfsDir[i].useFlag = 0; g_lfsDir[i].useFlag = 0;
@ -126,24 +132,19 @@ void FreeDirInfo(const char *dirName)
free(g_lfsDir[i].dirName); free(g_lfsDir[i].dirName);
g_lfsDir[i].dirName = NULL; g_lfsDir[i].dirName = NULL;
} }
pthread_mutex_unlock(&g_FslocalMutex);
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
} }
BOOL CheckDirIsOpen(const char *dirName) BOOL CheckDirIsOpen(const char *dirName)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) { for (int i = 0; i < LFS_MAX_OPEN_DIRS; i++) {
if (g_lfsDir[i].useFlag == 1) { if (g_lfsDir[i].useFlag == 1) {
if (strcmp(g_lfsDir[i].dirName, dirName) == 0) { if (strcmp(g_lfsDir[i].dirName, dirName) == 0) {
pthread_mutex_unlock(&g_FslocalMutex);
return TRUE; return TRUE;
} }
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
return FALSE; return FALSE;
} }
@ -165,35 +166,29 @@ BOOL CheckPathIsMounted(const char *pathName, struct FileOpInfo **fileOpInfo)
char tmpName[LITTLEFS_MAX_LFN_LEN] = {0}; char tmpName[LITTLEFS_MAX_LFN_LEN] = {0};
int len = GetFirstLevelPathLen(pathName); int len = GetFirstLevelPathLen(pathName);
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) { for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 1) { if (g_fsOp[i].useFlag == 1) {
(void)strncpy_s(tmpName, LITTLEFS_MAX_LFN_LEN, pathName, len); (void)strncpy_s(tmpName, LITTLEFS_MAX_LFN_LEN, pathName, len);
if (strcmp(tmpName, g_fsOp[i].dirName) == 0) { if (strcmp(tmpName, g_fsOp[i].dirName) == 0) {
*fileOpInfo = &(g_fsOp[i]); *fileOpInfo = &(g_fsOp[i]);
pthread_mutex_unlock(&g_FslocalMutex);
return TRUE; return TRUE;
} }
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
return FALSE; return FALSE;
} }
struct FileOpInfo *AllocMountRes(const char* target, const struct FileOps *fileOps) struct FileOpInfo *AllocMountRes(const char* target, const struct FileOps *fileOps)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) { for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 0 && strcmp(target, g_littlefsMntName[i]) == 0) { if (g_fsOp[i].useFlag == 0 && strcmp(target, g_littlefsMntName[i]) == 0) {
g_fsOp[i].useFlag = 1; g_fsOp[i].useFlag = 1;
g_fsOp[i].fsVops = fileOps; g_fsOp[i].fsVops = fileOps;
g_fsOp[i].dirName = strdup(target); g_fsOp[i].dirName = strdup(target);
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_fsOp[i]); return &(g_fsOp[i]);
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
return NULL; return NULL;
} }
@ -203,26 +198,21 @@ int SetDefaultMountPath(int pathNameIndex, const char* target)
return VFS_ERROR; return VFS_ERROR;
} }
pthread_mutex_lock(&g_FslocalMutex);
g_littlefsMntName[pathNameIndex] = strdup(target); g_littlefsMntName[pathNameIndex] = strdup(target);
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_OK; return VFS_OK;
} }
struct FileOpInfo *GetMountRes(const char *target, int *mountIndex) struct FileOpInfo *GetMountRes(const char *target, int *mountIndex)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) { for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 1) { if (g_fsOp[i].useFlag == 1) {
if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) { if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) {
*mountIndex = i; *mountIndex = i;
pthread_mutex_unlock(&g_FslocalMutex);
return &(g_fsOp[i]); return &(g_fsOp[i]);
} }
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
return NULL; return NULL;
} }
@ -232,33 +222,28 @@ int FreeMountResByIndex(int mountIndex)
return VFS_ERROR; return VFS_ERROR;
} }
pthread_mutex_lock(&g_FslocalMutex);
if (g_fsOp[mountIndex].useFlag == 1 && g_fsOp[mountIndex].dirName != NULL) { if (g_fsOp[mountIndex].useFlag == 1 && g_fsOp[mountIndex].dirName != NULL) {
g_fsOp[mountIndex].useFlag = 0; g_fsOp[mountIndex].useFlag = 0;
free(g_fsOp[mountIndex].dirName); free(g_fsOp[mountIndex].dirName);
g_fsOp[mountIndex].dirName = NULL; g_fsOp[mountIndex].dirName = NULL;
} }
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_OK; return VFS_OK;
} }
int FreeMountRes(const char *target) int FreeMountRes(const char *target)
{ {
pthread_mutex_lock(&g_FslocalMutex);
for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) { for (int i = 0; i < LOSCFG_LFS_MAX_MOUNT_SIZE; i++) {
if (g_fsOp[i].useFlag == 1) { if (g_fsOp[i].useFlag == 1) {
if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) { if (g_fsOp[i].dirName && strcmp(target, g_fsOp[i].dirName) == 0) {
g_fsOp[i].useFlag = 0; g_fsOp[i].useFlag = 0;
free(g_fsOp[i].dirName); free(g_fsOp[i].dirName);
g_fsOp[i].dirName = NULL; g_fsOp[i].dirName = NULL;
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_OK; return VFS_OK;
} }
} }
} }
pthread_mutex_unlock(&g_FslocalMutex);
return VFS_ERROR; return VFS_ERROR;
} }
@ -335,20 +320,30 @@ int LfsMount(const char *source, const char *target, const char *fileSystemType,
if (target == NULL || fileSystemType == NULL || data == NULL) { if (target == NULL || fileSystemType == NULL || data == NULL) {
errno = EFAULT; errno = EFAULT;
ret = VFS_ERROR; return VFS_ERROR;
goto errout;
} }
if (strcmp(fileSystemType, "littlefs") != 0) { if (strcmp(fileSystemType, "littlefs") != 0) {
errno = ENODEV; errno = ENODEV;
ret = VFS_ERROR; return VFS_ERROR;
goto errout;
} }
if (g_lfsMutex == LFS_MUTEX_UNINIT) {
if (LOS_MuxCreate(&g_lfsMutex) != LOS_OK) {
errno = EBUSY;
return VFS_ERROR;
}
}
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(target, &fileOpInfo)) { if (CheckPathIsMounted(target, &fileOpInfo)) {
errno = EBUSY; errno = EBUSY;
ret = VFS_ERROR; ret = VFS_ERROR;
goto errout; goto ERROUT;
} }
// select free mount resource // select free mount resource
@ -356,7 +351,7 @@ int LfsMount(const char *source, const char *target, const char *fileSystemType,
if (fileOpInfo == NULL) { if (fileOpInfo == NULL) {
errno = ENODEV; errno = ENODEV;
ret = VFS_ERROR; ret = VFS_ERROR;
goto errout; goto ERROUT;
} }
ret = lfs_mount(&(fileOpInfo->lfsInfo), (struct lfs_config*)data); ret = lfs_mount(&(fileOpInfo->lfsInfo), (struct lfs_config*)data);
@ -372,7 +367,8 @@ int LfsMount(const char *source, const char *target, const char *fileSystemType,
ret = VFS_ERROR; ret = VFS_ERROR;
} }
errout: ERROUT:
LfsUnlock();
return ret; return ret;
} }
@ -387,9 +383,15 @@ int LfsUmount(const char *target)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
fileOpInfo = GetMountRes(target, &mountIndex); fileOpInfo = GetMountRes(target, &mountIndex);
if (fileOpInfo == NULL) { if (fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -400,6 +402,7 @@ int LfsUmount(const char *target)
} }
(void)FreeMountResByIndex(mountIndex); (void)FreeMountResByIndex(mountIndex);
LfsUnlock();
return ret; return ret;
} }
@ -413,8 +416,14 @@ int LfsUnlink(const char *fileName)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(fileName, &fileOpInfo) == FALSE || fileOpInfo == NULL) { if (CheckPathIsMounted(fileName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -424,6 +433,7 @@ int LfsUnlink(const char *fileName)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -437,8 +447,14 @@ int LfsMkdir(const char *dirName, mode_t mode)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) { if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -448,6 +464,7 @@ int LfsMkdir(const char *dirName, mode_t mode)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -462,8 +479,14 @@ int LfsRmdir(const char *dirName)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) { if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -473,6 +496,7 @@ int LfsRmdir(const char *dirName)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -483,23 +507,28 @@ DIR *LfsOpendir(const char *dirName)
if (dirName == NULL) { if (dirName == NULL) {
errno = EFAULT; errno = EFAULT;
goto errout; return NULL;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return NULL;
}
if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) { if (CheckPathIsMounted(dirName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
goto errout; goto ERROUT;
} }
if (CheckDirIsOpen(dirName)) { if (CheckDirIsOpen(dirName)) {
errno = EBUSY; errno = EBUSY;
goto errout; goto ERROUT;
} }
FileDirInfo *dirInfo = GetFreeDir(dirName); FileDirInfo *dirInfo = GetFreeDir(dirName);
if (dirInfo == NULL) { if (dirInfo == NULL) {
errno = ENFILE; errno = ENFILE;
goto errout; goto ERROUT;
} }
ret = lfs_dir_open(&(fileOpInfo->lfsInfo), (lfs_dir_t *)(&(dirInfo->dir)), dirName); ret = lfs_dir_open(&(fileOpInfo->lfsInfo), (lfs_dir_t *)(&(dirInfo->dir)), dirName);
@ -507,14 +536,16 @@ DIR *LfsOpendir(const char *dirName)
if (ret != 0) { if (ret != 0) {
FreeDirInfo(dirName); FreeDirInfo(dirName);
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
goto errout; goto ERROUT;
} }
dirInfo->lfsHandle = &(fileOpInfo->lfsInfo); dirInfo->lfsHandle = &(fileOpInfo->lfsInfo);
LfsUnlock();
return (DIR *)dirInfo; return (DIR *)dirInfo;
errout: ERROUT:
LfsUnlock();
return NULL; return NULL;
} }
@ -530,9 +561,13 @@ struct dirent *LfsReaddir(DIR *dir)
return NULL; return NULL;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return NULL;
}
ret = lfs_dir_read(dirInfo->lfsHandle, (lfs_dir_t *)(&(dirInfo->dir)), &lfsInfo); ret = lfs_dir_read(dirInfo->lfsHandle, (lfs_dir_t *)(&(dirInfo->dir)), &lfsInfo);
if (ret == TRUE) { if (ret == TRUE) {
pthread_mutex_lock(&g_FslocalMutex);
(void)strncpy_s(g_nameValue.d_name, sizeof(g_nameValue.d_name), lfsInfo.name, strlen(lfsInfo.name) + 1); (void)strncpy_s(g_nameValue.d_name, sizeof(g_nameValue.d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
if (lfsInfo.type == LFS_TYPE_DIR) { if (lfsInfo.type == LFS_TYPE_DIR) {
g_nameValue.d_type = DT_DIR; g_nameValue.d_type = DT_DIR;
@ -541,8 +576,8 @@ struct dirent *LfsReaddir(DIR *dir)
} }
g_nameValue.d_reclen = lfsInfo.size; g_nameValue.d_reclen = lfsInfo.size;
pthread_mutex_unlock(&g_FslocalMutex);
LfsUnlock();
return &g_nameValue; return &g_nameValue;
} }
@ -550,6 +585,7 @@ struct dirent *LfsReaddir(DIR *dir)
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
} }
LfsUnlock();
return NULL; return NULL;
} }
@ -563,6 +599,11 @@ int LfsClosedir(DIR *dir)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
ret = lfs_dir_close(dirInfo->lfsHandle, (lfs_dir_t *)(&(dirInfo->dir))); ret = lfs_dir_close(dirInfo->lfsHandle, (lfs_dir_t *)(&(dirInfo->dir)));
FreeDirInfo(dirInfo->dirName); FreeDirInfo(dirInfo->dirName);
@ -572,6 +613,7 @@ int LfsClosedir(DIR *dir)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -584,23 +626,28 @@ int LfsOpen(const char *pathName, int openFlag, ...)
if (pathName == NULL) { if (pathName == NULL) {
errno = EFAULT; errno = EFAULT;
goto errout; return INVALID_FD;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(pathName, &fileOpInfo) == FALSE || fileOpInfo == NULL) { if (CheckPathIsMounted(pathName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
goto errout; goto ERROUT;
} }
// if file is already open, return invalid fd // if file is already open, return invalid fd
if (CheckFileIsOpen(pathName)) { if (CheckFileIsOpen(pathName)) {
errno = EBUSY; errno = EBUSY;
goto errout; goto ERROUT;
} }
LittleFsHandleStruct *fsHandle = LfsAllocFd(pathName, &fd); LittleFsHandleStruct *fsHandle = LfsAllocFd(pathName, &fd);
if (fd == INVALID_FD) { if (fd == INVALID_FD) {
errno = ENFILE; errno = ENFILE;
goto errout; goto ERROUT;
} }
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag); int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
@ -608,13 +655,15 @@ int LfsOpen(const char *pathName, int openFlag, ...)
if (err != 0) { if (err != 0) {
LfsFreeFd(fd); LfsFreeFd(fd);
errno = LittlefsErrno(err); errno = LittlefsErrno(err);
goto errout; goto ERROUT;
} }
g_handle[fd].lfsHandle = &(fileOpInfo->lfsInfo); g_handle[fd].lfsHandle = &(fileOpInfo->lfsInfo);
LfsUnlock();
return fd; return fd;
errout: ERROUT:
LfsUnlock();
return INVALID_FD; return INVALID_FD;
} }
@ -627,8 +676,14 @@ int LfsRead(int fd, void *buf, unsigned int len)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -637,6 +692,7 @@ int LfsRead(int fd, void *buf, unsigned int len)
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -649,8 +705,14 @@ int LfsWrite(int fd, const void *buf, unsigned int len)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -659,6 +721,7 @@ int LfsWrite(int fd, const void *buf, unsigned int len)
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -666,8 +729,14 @@ off_t LfsSeek(int fd, off_t offset, int whence)
{ {
off_t ret; off_t ret;
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -677,6 +746,7 @@ off_t LfsSeek(int fd, off_t offset, int whence)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -684,14 +754,18 @@ int LfsClose(int fd)
{ {
int ret; int ret;
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
pthread_mutex_lock(&g_FslocalMutex);
ret = lfs_file_close(g_handle[fd].lfsHandle, &(g_handle[fd].file)); ret = lfs_file_close(g_handle[fd].lfsHandle, &(g_handle[fd].file));
pthread_mutex_unlock(&g_FslocalMutex);
LfsFreeFd(fd); LfsFreeFd(fd);
@ -700,6 +774,7 @@ int LfsClose(int fd)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -713,8 +788,14 @@ int LfsRename(const char *oldName, const char *newName)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(oldName, &fileOpInfo) == FALSE || fileOpInfo == NULL) { if (CheckPathIsMounted(oldName, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -724,6 +805,7 @@ int LfsRename(const char *oldName, const char *newName)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -738,8 +820,14 @@ int LfsStat(const char *path, struct stat *buf)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (CheckPathIsMounted(path, &fileOpInfo) == FALSE || fileOpInfo == NULL) { if (CheckPathIsMounted(path, &fileOpInfo) == FALSE || fileOpInfo == NULL) {
errno = ENOENT; errno = ENOENT;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -756,6 +844,7 @@ int LfsStat(const char *path, struct stat *buf)
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -763,8 +852,14 @@ int LfsFsync(int fd)
{ {
int ret; int ret;
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -773,6 +868,7 @@ int LfsFsync(int fd)
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -786,8 +882,14 @@ int LfsFstat(int fd, struct stat *buf)
return FS_FAILURE; return FS_FAILURE;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -803,6 +905,7 @@ int LfsFstat(int fd, struct stat *buf)
errno = LittlefsErrno(ret); errno = LittlefsErrno(ret);
ret = VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -816,20 +919,28 @@ int LfsPread(int fd, void *buf, size_t nbyte, off_t offset)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
savepos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), 0, SEEK_CUR); savepos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), 0, SEEK_CUR);
if (savepos == (off_t)-1) { if (savepos == (off_t)-1) {
errno = LittlefsErrno(savepos); errno = LittlefsErrno(savepos);
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, SEEK_SET); pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, SEEK_SET);
if (pos == (off_t)-1) { if (pos == (off_t)-1) {
errno = LittlefsErrno(pos); errno = LittlefsErrno(pos);
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -842,9 +953,10 @@ int LfsPread(int fd, void *buf, size_t nbyte, off_t offset)
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), savepos, SEEK_SET); pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) { if ((pos == (off_t)-1) && (ret >= 0)) {
errno = LittlefsErrno(pos); errno = LittlefsErrno(pos);
return VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }
@ -858,20 +970,28 @@ int LfsPwrite(int fd, const void *buf, size_t nbyte, off_t offset)
return VFS_ERROR; return VFS_ERROR;
} }
if (LfsLock() != LOS_OK) {
errno = EAGAIN;
return VFS_ERROR;
}
if (LfsFdIsValid(fd) == FALSE) { if (LfsFdIsValid(fd) == FALSE) {
errno = EBADF; errno = EBADF;
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
savepos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), 0, SEEK_CUR); savepos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), 0, SEEK_CUR);
if (savepos == (off_t)-1) { if (savepos == (off_t)-1) {
errno = LittlefsErrno(savepos); errno = LittlefsErrno(savepos);
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, SEEK_SET); pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, SEEK_SET);
if (pos == (off_t)-1) { if (pos == (off_t)-1) {
errno = LittlefsErrno(pos); errno = LittlefsErrno(pos);
LfsUnlock();
return VFS_ERROR; return VFS_ERROR;
} }
@ -884,8 +1004,9 @@ int LfsPwrite(int fd, const void *buf, size_t nbyte, off_t offset)
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), savepos, SEEK_SET); pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) { if ((pos == (off_t)-1) && (ret >= 0)) {
errno = LittlefsErrno(pos); errno = LittlefsErrno(pos);
return VFS_ERROR; ret = VFS_ERROR;
} }
LfsUnlock();
return ret; return ret;
} }

View File

@ -42,7 +42,6 @@
#include "lfs_conf.h" #include "lfs_conf.h"
#include "lfs_util.h" #include "lfs_util.h"
#include "memory.h" #include "memory.h"
#include "pthread.h"
#define INVALID_FD (-1) #define INVALID_FD (-1)

View File

@ -269,6 +269,10 @@ int LOS_Open(const char *path, int oflag, ...)
} }
size_t pathLen = strlen(path) + 1; size_t pathLen = strlen(path) + 1;
if ((unsigned)pathLen > PATH_MAX) {
errno = EINVAL;
return FS_FAILURE;
}
char *canonicalPath = (char *)malloc(pathLen); char *canonicalPath = (char *)malloc(pathLen);
if (!canonicalPath) { if (!canonicalPath) {
errno = ENOMEM; errno = ENOMEM;

View File

@ -138,4 +138,9 @@
#define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR #define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR
/* max number of open directories */
#ifndef LOSCFG_MAX_OPEN_DIRS
#define LOSCFG_MAX_OPEN_DIRS 10
#endif
#endif #endif

View File

@ -54,7 +54,7 @@ void __DLIB_TLS_MEMORY *__iar_dlib_perthread_access(void _DLIB_TLS_MEMORY *symbp
} }
#else /* IAR version 8 or above. */ #else /* IAR version 8 or above. */
#pragma section="__iar_tls$$DATA" #pragma section = "__iar_tls$$DATA"
void *__aeabi_read_tp(void) void *__aeabi_read_tp(void)
{ {
if (!LOS_TaskIsRunning()) { if (!LOS_TaskIsRunning()) {
@ -211,4 +211,4 @@ void __iar_file_Mtxunlock(__iar_Rmtx *m)
if (LOS_TaskIsRunning()) { if (LOS_TaskIsRunning()) {
(void)LOS_MuxPost(muxInfo->muxID); (void)LOS_MuxPost(muxInfo->muxID);
} }
} }

View File

@ -128,7 +128,7 @@ typedef struct {
* @param lmkNode [IN] The LosLmkOpsNode node to be registered. * @param lmkNode [IN] The LosLmkOpsNode node to be registered.
* *
* @retval LOS_OK The LosLmkOpsNode node is registered successfully. * @retval LOS_OK The LosLmkOpsNode node is registered successfully.
* @retval LOS_ERRNO_LMK_INVALID_PARAMETER The paramter is invalid. * @retval LOS_ERRNO_LMK_INVALID_PARAMETER The parameter is invalid.
* @retval LOS_ERRNO_LMK_ALREADY_REGISTERED The LosLmkOpsNode node already registered. * @retval LOS_ERRNO_LMK_ALREADY_REGISTERED The LosLmkOpsNode node already registered.
* @par Dependency: * @par Dependency:
* <ul><li>los_lmk.h: the header file that contains the API declaration.</li></ul> * <ul><li>los_lmk.h: the header file that contains the API declaration.</li></ul>

0
components/lms/lms_libc.c Executable file → Normal file
View File

5
components/lms/los_lms.c Executable file → Normal file
View File

@ -182,11 +182,12 @@ VOID LOS_LmsCheckPoolDel(const VOID *pool)
LmsMemListNode *delNode = OsLmsGetPoolNode(pool); LmsMemListNode *delNode = OsLmsGetPoolNode(pool);
if (delNode == NULL) { if (delNode == NULL) {
PRINT_ERR("[LMS]pool %p is not on lms checklist !\n", pool); PRINT_ERR("[LMS]pool %p is not on lms checklist !\n", pool);
goto Release; goto REALEASE;
} }
delNode->used = LMS_POOL_UNUSED; delNode->used = LMS_POOL_UNUSED;
LOS_ListDelete(&(delNode->node)); LOS_ListDelete(&(delNode->node));
Release:
REALEASE:
LMS_UNLOCK(intSave); LMS_UNLOCK(intSave);
} }

0
components/lms/los_lms.h Executable file → Normal file
View File

0
components/lms/los_lms_pri.h Executable file → Normal file
View File

View File

@ -124,7 +124,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
u16_t *a16 = (u16_t *)addr->addr; u16_t *a16 = (u16_t *)addr->addr;
int squash_pos = ipv6_blocks; int squash_pos = ipv6_blocks;
int i; int i;
const char *sc = cp; const unsigned char *sc = (const unsigned char *)cp;
const char *ss = cp-1; const char *ss = cp-1;
for (; ; sc++) { for (; ; sc++) {

View File

@ -217,19 +217,11 @@ void lwip_ifconfig_show_internal(void *arg)
sys_sem_signal(&ifconfig_cmd->cb_completed); sys_sem_signal(&ifconfig_cmd->cb_completed);
} }
/*lint -e838 -e438*/
u32_t lwip_ifconfig(int argc, const char **argv) u32_t lwip_ifconfig(int argc, const char **argv)
{ {
static struct ifconfig_option ifconfig_cmd; static struct ifconfig_option ifconfig_cmd;
err_t ret; err_t ret;
#if LWIP_STATS
u32_t stat_err_cnt;
u32_t stat_drop_cnt;
u32_t stat_rx_or_tx_cnt;
u32_t stat_rx_or_tx_bytes;
#endif
(void)memset_s(&ifconfig_cmd, sizeof(ifconfig_cmd), 0, sizeof(ifconfig_cmd)); (void)memset_s(&ifconfig_cmd, sizeof(ifconfig_cmd), 0, sizeof(ifconfig_cmd));
if (sys_sem_new(&ifconfig_cmd.cb_completed, 0) != ERR_OK) { if (sys_sem_new(&ifconfig_cmd.cb_completed, 0) != ERR_OK) {
PRINTK("%s: sys_sem_new fail\n", __FUNCTION__); PRINTK("%s: sys_sem_new fail\n", __FUNCTION__);
@ -252,7 +244,6 @@ u32_t lwip_ifconfig(int argc, const char **argv)
return 0; return 0;
} }
/*lint +e838 +e438*/
#if LWIP_DNS #if LWIP_DNS
#ifndef LWIP_TESTBED #ifndef LWIP_TESTBED
@ -278,7 +269,7 @@ struct hostent *gethostnameinfo(const char *host, char *tmphstbuf, size_t hstbuf
LWIP_STATIC unsigned int get_hostip(const char *hname) LWIP_STATIC unsigned int get_hostip(const char *hname)
{ {
unsigned int ip = 0; unsigned int ip = 0;
int ret; errno_t ret;
const size_t hstbuflen = 1024; const size_t hstbuflen = 1024;
char *tmphstbuf = NULL; char *tmphstbuf = NULL;
@ -291,8 +282,8 @@ LWIP_STATIC unsigned int get_hostip(const char *hname)
free(tmphstbuf); free(tmphstbuf);
return 0; return 0;
} }
ret = memcpy_s(&ip, sizeof(ip), pent->h_addr, 4); ret = memcpy_s(&ip, sizeof(ip), pent->h_addr, sizeof(pent->h_addr));
if (ret != 0) { if (ret != EOK) {
free(tmphstbuf); free(tmphstbuf);
return 0; return 0;
} }
@ -419,7 +410,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
/* Accessing ip header and icmp header */ /* Accessing ip header and icmp header */
iphdr_resp = pbuf_resp->payload; iphdr_resp = pbuf_resp->payload;
ip_hlen = (IPH_HL(iphdr_resp) << 2); ip_hlen = (IPH_HL(iphdr_resp) << 2); /* 2: offset */
if (pbuf_header(pbuf_resp, -ip_hlen)) { if (pbuf_header(pbuf_resp, -ip_hlen)) {
/* this failure will never happen, but failure handle is written just to be in safe side */ /* this failure will never happen, but failure handle is written just to be in safe side */
PRINTK("Ping : memory management failure\n"); PRINTK("Ping : memory management failure\n");
@ -437,7 +428,8 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
((ICMPH_TYPE(iecho_resp) == ICMP_ECHO) && (iphdr_resp->src.addr == to.sin_addr.s_addr))) { ((ICMPH_TYPE(iecho_resp) == ICMP_ECHO) && (iphdr_resp->src.addr == to.sin_addr.s_addr))) {
/* second type timeout event */ /* second type timeout event */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &end); (void)clock_gettime(CLOCK_MONOTONIC_RAW, &end);
timout_ms = ((end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000); timout_ms = ((end.tv_sec - start.tv_sec) * OS_SYS_MS_PER_SECOND + \
(end.tv_nsec - start.tv_nsec) / OS_SYS_NS_PER_MS);
timout_ms = LWIP_SHELL_CMD_PING_TIMEOUT - timout_ms; timout_ms = LWIP_SHELL_CMD_PING_TIMEOUT - timout_ms;
} else { } else {
timout_ms = 0; timout_ms = 0;
@ -454,7 +446,8 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
} }
/* capture the end time to calculate round trip time */ /* capture the end time to calculate round trip time */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &end); (void)clock_gettime(CLOCK_MONOTONIC_RAW, &end);
rtt = ((end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000); rtt = ((end.tv_sec - start.tv_sec) * OS_SYS_MS_PER_SECOND + \
(end.tv_nsec - start.tv_nsec) / OS_SYS_NS_PER_MS);
if (iphdr_resp->src.addr == to.sin_addr.s_addr) { if (iphdr_resp->src.addr == to.sin_addr.s_addr) {
switch (ICMPH_TYPE(iecho_resp)) { switch (ICMPH_TYPE(iecho_resp)) {
@ -470,12 +463,12 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
/* delay 1s for every successful ping */ /* delay 1s for every successful ping */
intrvl = interval; intrvl = interval;
do { do {
if (intrvl < 1000) { if (intrvl < 1000) { /* 1000: 1000ms = 1s */
sys_msleep(intrvl); sys_msleep(intrvl);
break; break;
} }
intrvl -= 1000; intrvl -= 1000; /* 1000: 1000ms = 1s */
sys_msleep(1000); sys_msleep(1000); /* 1000: 1000ms = 1s */
if (ping_kill == 1) if (ping_kill == 1)
break; break;
} while (intrvl > 0); } while (intrvl > 0);
@ -497,7 +490,7 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
PRINTK("\nPing: parameter problem ..."); PRINTK("\nPing: parameter problem ...");
break; break;
default: default:
PRINTK("\nPing: unknow error ..."); PRINTK("\nPing: unknown error ...");
break; break;
} }
i++; i++;
@ -527,7 +520,7 @@ static void ping_cmd(u32_t *parg)
if (ret < 0) { if (ret < 0) {
PRINTK("Ping cmd failed due to some errors\n"); PRINTK("Ping cmd failed due to some errors\n");
} }
free(parg);
ping_taskid = -1; ping_taskid = -1;
} }
@ -565,7 +558,7 @@ u32_t OsShellPing(int argc, const char **argv)
return LOS_NOK; return LOS_NOK;
} }
parg = (u32_t *)malloc(4 * sizeof(int)); parg = (u32_t *)malloc(4 * sizeof(int)); /* 4: number of args */
if (parg == NULL) { if (parg == NULL) {
return LOS_NOK; return LOS_NOK;
} }
@ -584,12 +577,11 @@ u32_t OsShellPing(int argc, const char **argv)
stPingTask.pfnTaskEntry = (TSK_ENTRY_FUNC)ping_cmd; stPingTask.pfnTaskEntry = (TSK_ENTRY_FUNC)ping_cmd;
stPingTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; stPingTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
stPingTask.pcName = "ping_task"; stPingTask.pcName = "ping_task";
stPingTask.usTaskPrio = 8; /* higher than shell */ stPingTask.usTaskPrio = 8; /* 8: higher than shell */
stPingTask.uwResved = LOS_TASK_STATUS_DETACHED; stPingTask.uwResved = LOS_TASK_STATUS_DETACHED;
stPingTask.uwArg = (UINTPTR)parg; stPingTask.uwArg = (UINTPTR)parg;
ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask); ret = LOS_TaskCreate((UINT32 *)(&ping_taskid), &stPingTask);
if (ret != LOS_OK) { if (ret != LOS_OK) {
free(parg);
PRINTK("ping_task create failed 0x%08x.\n", ret); PRINTK("ping_task create failed 0x%08x.\n", ret);
count = LWIP_SHELL_CMD_PING_RETRY_TIMES; count = LWIP_SHELL_CMD_PING_RETRY_TIMES;
} else { } else {
@ -605,6 +597,8 @@ u32_t OsShellPing(int argc, const char **argv)
PRINTK("Ping cmd failed due some errors\n"); PRINTK("Ping cmd failed due some errors\n");
} }
free(parg);
return LOS_OK; return LOS_OK;
ping_error: ping_error:
lwip_ping_usage(); lwip_ping_usage();

View File

@ -34,8 +34,6 @@
#include <lwip/snmp.h> #include <lwip/snmp.h>
#include <lwip/etharp.h> #include <lwip/etharp.h>
#include <lwip/sockets.h> #include <lwip/sockets.h>
#include <lwip/snmp.h>
#include <lwip/etharp.h>
#include <lwip/ethip6.h> #include <lwip/ethip6.h>
#define LWIP_NETIF_HOSTNAME_DEFAULT "default" #define LWIP_NETIF_HOSTNAME_DEFAULT "default"

View File

@ -33,11 +33,9 @@
#include <lwip/sys.h> #include <lwip/sys.h>
#include <lwip/debug.h> #include <lwip/debug.h>
#include <los_task.h> #include <los_task.h>
#include <los_tick.h>
#include <los_queue.h> #include <los_queue.h>
#include <los_sem.h> #include <los_sem.h>
#include <los_mux.h> #include <los_mux.h>
#include <los_tick.h>
#include <los_config.h> #include <los_config.h>
#ifndef LOSCFG_KERNEL_SMP #ifndef LOSCFG_KERNEL_SMP
@ -151,7 +149,7 @@ err_t sys_mbox_new(sys_mbox_t *mbox, int size)
} }
CHAR qName[] = "lwIP"; CHAR qName[] = "lwIP";
UINT32 ret = LOS_QueueCreate(qName, (UINT16)size, mbox, 0, sizeof(void *)); UINT32 ret = LOS_QueueCreate(qName, (UINT16)size, (UINT32 *)mbox, 0, sizeof(void *));
switch (ret) { switch (ret) {
case LOS_OK: case LOS_OK:
return ERR_OK; return ERR_OK;
@ -202,6 +200,8 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg) err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg)
{ {
(void)mbox;
(void)msg;
return ERR_ARG; return ERR_ARG;
} }
@ -292,7 +292,7 @@ err_t sys_sem_new(sys_sem_t *sem, u8_t count)
return ERR_ARG; return ERR_ARG;
} }
UINT32 ret = LOS_SemCreate(count, sem); UINT32 ret = LOS_SemCreate(count, (UINT32 *)(sem));
if (ret != LOS_OK) { if (ret != LOS_OK) {
return ERR_ARG; return ERR_ARG;
} }
@ -367,7 +367,7 @@ err_t sys_mutex_new(sys_mutex_t *mutex)
return ERR_ARG; return ERR_ARG;
} }
UINT32 ret = LOS_MuxCreate(mutex); UINT32 ret = LOS_MuxCreate((UINT32 *)mutex);
if (ret != LOS_OK) { if (ret != LOS_OK) {
return ERR_ARG; return ERR_ARG;
} }

View File

@ -217,7 +217,6 @@ static void ParsePackageIpUdp(struct netif *netif, struct pbuf *btBuf)
ICUNIT_ASSERT_EQUAL(dataLen, strlen(MSG), 4); ICUNIT_ASSERT_EQUAL(dataLen, strlen(MSG), 4);
LogPrintln("================================="); LogPrintln("=================================");
// 回应udp报文
ReplayUdpTask(); ReplayUdpTask();
} }
@ -229,7 +228,6 @@ static void ParsePackageEthernet(struct netif *netif, struct pbuf *p)
ethhdr = (struct eth_hdr *)p->payload; ethhdr = (struct eth_hdr *)p->payload;
u16_t type = ethhdr->type; u16_t type = ethhdr->type;
LogPrintln("ParsePackageEthernet type is %d", type);
switch (type) { switch (type) {
#if LWIP_IPV4 && LWIP_ARP #if LWIP_IPV4 && LWIP_ARP
/* IP packet? */ /* IP packet? */
@ -322,7 +320,6 @@ static void UdpTestNetifTask(void *p)
struct ifreq nif; struct ifreq nif;
int ret; int ret;
// 注册网卡
btProxyNf = CreateBtNetIf(); btProxyNf = CreateBtNetIf();
/* socket creation */ /* socket creation */
@ -335,7 +332,6 @@ static void UdpTestNetifTask(void *p)
ret = bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr)); ret = bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
LWIP_ASSERT("socket invalid param.", ret == 0); LWIP_ASSERT("socket invalid param.", ret == 0);
/* 指定网卡接口 */
char *inface = NETIF_NAME_BT; char *inface = NETIF_NAME_BT;
(void)strcpy_s(nif.ifr_name, sizeof(nif.ifr_name), inface); (void)strcpy_s(nif.ifr_name, sizeof(nif.ifr_name), inface);
if (setsockopt(sfd, SOL_SOCKET, SO_BINDTODEVICE, (char *)&nif, sizeof(nif)) < 0) { if (setsockopt(sfd, SOL_SOCKET, SO_BINDTODEVICE, (char *)&nif, sizeof(nif)) < 0) {
@ -393,7 +389,6 @@ static void ArpPackageProc(struct netif *netif, struct pbuf *p)
return; return;
} }
// 回应arp报文
ReplayArpTask(); ReplayArpTask();
} }
@ -446,4 +441,4 @@ static void ReplayArpTask()
ret = sys_thread_new("replay_arp", ReplayArp, NULL, ret = sys_thread_new("replay_arp", ReplayArp, NULL,
STACK_TEST_SIZE, TCPIP_THREAD_PRIO); STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23); ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
} }

View File

@ -101,7 +101,7 @@ STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
} }
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0) #if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
if (tickTimer->timerStop != NULL) { if ((tickTimer->timerStop != NULL) && (pm->enterSleepTime != 0)) {
/* Restore the main CPU frequency */ /* Restore the main CPU frequency */
sleepTime = tickTimer->timerCycleGet(); sleepTime = tickTimer->timerCycleGet();
tickTimer->timerStop(); tickTimer->timerStop();
@ -123,8 +123,9 @@ STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
STATIC BOOL OsPmTickTimerStop(LosPmCB *pm) STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
{ {
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0) #if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
UINT64 sleepCycle; UINT64 sleepCycle, realSleepTime;
UINT64 realSleepTime = OsSchedGetNextExpireTime(OsGetCurrSchedTimeCycle()); UINT64 currTime = OsGetCurrSchedTimeCycle();
UINT64 expireTime = OsSchedGetNextExpireTime(currTime);
#endif #endif
LosPmTickTimer *tickTimer = pm->tickTimer; LosPmTickTimer *tickTimer = pm->tickTimer;
@ -134,10 +135,9 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0) #if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
if (tickTimer->timerStart != NULL) { if (tickTimer->timerStart != NULL) {
if (realSleepTime == 0) { LOS_ASSERT(expireTime > currTime);
return FALSE;
}
realSleepTime = expireTime - currTime;
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock); sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq); sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);

View File

@ -115,7 +115,7 @@ typedef enum {
/* /*
* Hook for user-defined debug function * Hook for user-defined debug function
* Unify differnt module's func for registration * Unify different module's func for registration
*/ */
typedef UINT32 (*CmdCallBackFunc)(UINT32 argc, const CHAR **argv); typedef UINT32 (*CmdCallBackFunc)(UINT32 argc, const CHAR **argv);

View File

@ -54,7 +54,7 @@ STATIC INLINE VOID SetErrno(INT32 errcode)
STATIC INLINE VOID SetErr(INT32 errcode, const CHAR *errMessage) STATIC INLINE VOID SetErr(INT32 errcode, const CHAR *errMessage)
{ {
SetErrno(errcode); SetErrno(errcode);
PRINTK(errMessage); PRINTK("%s", errMessage);
} }
#ifdef __cplusplus #ifdef __cplusplus

7
components/shell/src/base/shcmd.c Executable file → Normal file
View File

@ -69,10 +69,10 @@ CmdModInfo *OsCmdInfoGet(VOID)
} }
/* /*
* Description: Pass in the string and clear useless space ,which inlcude: * Description: Pass in the string and clear useless space ,which include:
* 1) The overmatch space which is not be marked by Quote's area * 1) The overmatch space which is not be marked by Quote's area
* Squeeze the overmatch space into one space * Squeeze the overmatch space into one space
* 2) Clear all space before first vaild charatctor * 2) Clear all space before first vaild character
* Input: cmdKey : Pass in the buff string, which is ready to be operated * Input: cmdKey : Pass in the buff string, which is ready to be operated
* cmdOut : Pass out the buffer string ,which has already been operated * cmdOut : Pass out the buffer string ,which has already been operated
* size : cmdKey length * size : cmdKey length
@ -98,6 +98,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsCmdKeyShift(const CHAR *cmdKey, CHAR *cmdOut, UI
PRINTK("malloc failure in %s[%d]", __FUNCTION__, __LINE__); PRINTK("malloc failure in %s[%d]", __FUNCTION__, __LINE__);
return (UINT32)OS_ERROR; return (UINT32)OS_ERROR;
} }
(VOID)memset_s(output, len + 1, 0, len + 1);
/* Backup the 'output' start address */ /* Backup the 'output' start address */
outputBak = output; outputBak = output;
/* Scan each charactor in 'cmdKey',and squeeze the overmuch space and ignore invaild charactor */ /* Scan each charactor in 'cmdKey',and squeeze the overmuch space and ignore invaild charactor */
@ -110,7 +111,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsCmdKeyShift(const CHAR *cmdKey, CHAR *cmdOut, UI
/* 1) Quotes matching status is FALSE (which said that the space is not been marked by double quotes) */ /* 1) Quotes matching status is FALSE (which said that the space is not been marked by double quotes) */
/* 2) Current charactor is a space */ /* 2) Current charactor is a space */
/* 3) Next charactor is a space too, or the string is been seeked to the end already(\0) */ /* 3) Next charactor is a space too, or the string is been seeked to the end already(\0) */
/* 4) Invaild charactor, such as single quotes */ /* 4) Invalid charactor, such as single quotes */
if ((*cmdKey == ' ') && ((*(cmdKey + 1) == ' ') || (*(cmdKey + 1) == '\0')) && QUOTES_STATUS_CLOSE(quotes)) { if ((*cmdKey == ' ') && ((*(cmdKey + 1) == ' ') || (*(cmdKey + 1) == '\0')) && QUOTES_STATUS_CLOSE(quotes)) {
continue; continue;
} }

0
components/shell/src/base/shcmdparse.c Executable file → Normal file
View File

View File

@ -96,7 +96,7 @@ CHAR *GetCmdName(const CHAR *cmdline, UINT32 len)
continue; continue;
} }
/* If detected a space which the quotes matching status is false */ /* If detected a space which the quotes matching status is false */
/* which said has detected the first space for seperator, finish this scan operation */ /* which said has detected the first space for separator, finish this scan operation */
if ((*tmpStr == ' ') && (QUOTES_STATUS_CLOSE(quotes))) { if ((*tmpStr == ' ') && (QUOTES_STATUS_CLOSE(quotes))) {
break; break;
} }

0
components/shell/src/base/show.c Executable file → Normal file
View File

0
components/shell/src/cmds/date_shell.c Executable file → Normal file
View File

4
components/shell/src/cmds/fullpath.c Executable file → Normal file
View File

@ -203,14 +203,14 @@ STATIC CHAR *VfsNormalizeFullpath(const CHAR *directory, const CHAR *filename, C
CHAR *fullpath = NULL; CHAR *fullpath = NULL;
if (filename[0] != '/') { if (filename[0] != '/') {
/* not a absolute path */ /* not an absolute path */
fullpath = VfsNotAbsolutePath(directory, filename, pathname, namelen); fullpath = VfsNotAbsolutePath(directory, filename, pathname, namelen);
if (fullpath == NULL) { if (fullpath == NULL) {
return (CHAR *)NULL; return (CHAR *)NULL;
} }
} else { } else {
/* it's a absolute path, use it directly */ /* it's an absolute path, use it directly */
fullpath = strdup(filename); /* copy string */ fullpath = strdup(filename); /* copy string */
if (fullpath == NULL) { if (fullpath == NULL) {

0
components/shell/src/cmds/mempt_shellcmd.c Executable file → Normal file
View File

0
components/shell/src/cmds/shell_shellcmd.c Executable file → Normal file
View File

0
components/shell/src/cmds/task_shellcmd.c Executable file → Normal file
View File

3
components/shell/src/cmds/vfs_shellcmd.c Executable file → Normal file
View File

@ -130,7 +130,7 @@ STATIC CHAR *OsLsGetFullpath(const CHAR *path, struct dirent *pdirent)
goto exit_with_nomem; goto exit_with_nomem;
} }
ret = snprintf_s(fullpath, pathLen, pathLen, "%s/%s", path, pdirent->d_name); ret = snprintf_s(fullpath, pathLen, pathLen - 1, "%s/%s", path, pdirent->d_name);
if (ret < 0) { if (ret < 0) {
free(fullpath); free(fullpath);
return NULL; return NULL;
@ -209,6 +209,7 @@ VOID OsLs(const CHAR *pathname)
} }
} while (pdirent != NULL); } while (pdirent != NULL);
free(path);
(VOID)closedir(d); (VOID)closedir(d);
} }
} }

View File

@ -106,7 +106,7 @@ STATIC VOID OsTraceSetFrame(TraceEventFrame *frame, UINT32 eventType, UINTPTR id
#if (LOSCFG_TRACE_FRAME_CORE_MSG == 1) #if (LOSCFG_TRACE_FRAME_CORE_MSG == 1)
frame->core.cpuId = ArchCurrCpuid(); frame->core.cpuId = ArchCurrCpuid();
frame->core.hwiActive = OS_INT_ACTIVE ? TRUE : FALSE; frame->core.hwiActive = OS_INT_ACTIVE ? TRUE : FALSE;
frame->core.taskLockCnt = MIN(OsPercpuGet()->taskLockCnt, 0xF); /* taskLockCnt is 4 bits, max vaule = 0xF */ frame->core.taskLockCnt = MIN(OsPercpuGet()->taskLockCnt, 0xF); /* taskLockCnt is 4 bits, max value = 0xF */
frame->core.paramCount = paramCount; frame->core.paramCount = paramCount;
#endif #endif

View File

@ -223,7 +223,7 @@ typedef struct {
/** /**
* @ingroup los_trace * @ingroup los_trace
* struct to store the event infomation * struct to store the event information
*/ */
typedef struct { typedef struct {
UINT32 eventType; /**< event type */ UINT32 eventType; /**< event type */
@ -304,9 +304,9 @@ extern TRACE_EVENT_HOOK g_traceEventHook;
* <li>The first param is treat as key, keep at least this param if you want trace this event.</li> * <li>The first param is treat as key, keep at least this param if you want trace this event.</li>
* <li>All parameters were treated as UINTPTR.</li> * <li>All parameters were treated as UINTPTR.</li>
* </ul> * </ul>
* eg. Trace a event as: * eg. Trace an event as:
* #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId, taskStatus, oldPrio, newPrio
* eg. Not Trace a event as: * eg. Not Trace an event as:
* #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio)
* eg. Trace only you need parmas as: * eg. Trace only you need parmas as:
* #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId * #define TASK_PRIOSET_PARAMS(taskId, taskStatus, oldPrio, newPrio) taskId

View File

@ -96,7 +96,7 @@ typedef struct {
/** /**
* @ingroup los_trace * @ingroup los_trace
* struct to store the event infomation * struct to store the event information
*/ */
typedef struct { typedef struct {
UINT32 cmd; /* trace start or stop cmd */ UINT32 cmd; /* trace start or stop cmd */

View File

@ -134,7 +134,7 @@ VOID OsTraceDataSend(UINT8 type, UINT16 len, UINT8 *data)
UINT32 intSave; UINT32 intSave;
UINT8 outBuf[LOSCFG_TRACE_TLV_BUF_SIZE] = {0}; UINT8 outBuf[LOSCFG_TRACE_TLV_BUF_SIZE] = {0};
if ((type > TRACE_MSG_MAX) || (len > LOSCFG_TRACE_TLV_BUF_SIZE)) { if ((type >= TRACE_MSG_MAX) || (len > LOSCFG_TRACE_TLV_BUF_SIZE)) {
return; return;
} }

View File

@ -186,7 +186,7 @@ STATIC VOID OsTraceInfoEventData(VOID)
UINT32 taskLockCnt = frame->core.taskLockCnt; UINT32 taskLockCnt = frame->core.taskLockCnt;
#if (LOSCFG_KERNEL_SMP == 1) #if (LOSCFG_KERNEL_SMP == 1)
/* /*
* For smp systems, TRACE_LOCK will requst taskLock, and this counter * For smp systems, TRACE_LOCK will request taskLock, and this counter
* will increase by 1 in that case. * will increase by 1 in that case.
*/ */
taskLockCnt -= 1; taskLockCnt -= 1;

View File

@ -1634,7 +1634,7 @@ uint32_t osMemoryPoolGetSpace(osMemoryPoolId_t mp_id)
if ((mp->status & MEM_POOL_VALID) != MEM_POOL_VALID) { if ((mp->status & MEM_POOL_VALID) != MEM_POOL_VALID) {
space = 0; space = 0;
} else { } else {
space = mp->poolInfo.uwBlkCnt - mp->poolInfo.uwBlkCnt; space = mp->poolInfo.uwBlkNum - mp->poolInfo.uwBlkCnt;
} }
LOS_IntRestore(intSave); LOS_IntRestore(intSave);

View File

@ -1,6 +1,3 @@
#ifndef _ADAPT_SYS_PRCTL_H
#define _ADAPT_SYS_PRCTL_H
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
* *
@ -31,6 +28,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef _ADAPT_SYS_PRCTL_H
#define _ADAPT_SYS_PRCTL_H
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved. * Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@ -37,7 +37,7 @@
int _isatty(int file) int _isatty(int file)
{ {
return file <= 2; return (int)(file <= 2); // 2: stderr
} }
int _kill(int i, int j) int _kill(int i, int j)
@ -52,7 +52,7 @@ int _getpid(void)
void _exit(int status) void _exit(int status)
{ {
write(1, "exit\n", 5); write(1, "exit\n", 5); // 1: stdout; 5: string length
(VOID)pthread_exit(&status); (VOID)pthread_exit(&status);
while (1) { while (1) {
} }

View File

@ -174,7 +174,7 @@ STATIC size_t PipeRingbufferRead(struct PipeDev *dev, VOID *buf, size_t len)
} }
} }
nbytes = (nbytes > len) ? len : nbytes; nbytes = (nbytes > len) ? len : nbytes;
(VOID)memcpy_s((char *)buf, len, dev->ringBuffer + dev->readIndex, nbytes); (VOID)memcpy_s(buf, len, dev->ringBuffer + dev->readIndex, nbytes);
dev->readIndex += nbytes; dev->readIndex += nbytes;
if (dev->readIndex >= dev->bufferSize) { if (dev->readIndex >= dev->bufferSize) {
dev->readIndex = 0; dev->readIndex = 0;
@ -184,7 +184,7 @@ STATIC size_t PipeRingbufferRead(struct PipeDev *dev, VOID *buf, size_t len)
return nbytes; return nbytes;
} }
STATIC size_t PipeRingbufferWrite(struct PipeDev *dev, VOID *buf, size_t len) STATIC size_t PipeRingbufferWrite(struct PipeDev *dev, const VOID *buf, size_t len)
{ {
size_t nbytes; size_t nbytes;
@ -220,7 +220,6 @@ STATIC INT32 PipeDevRegister(CHAR *devName, UINT32 len)
return -ENODEV; return -ENODEV;
} }
struct PipeDev *devTemp = NULL;
struct PipeDev *dev = LOS_MemAlloc(OS_SYS_MEM_ADDR, sizeof(struct PipeDev)); struct PipeDev *dev = LOS_MemAlloc(OS_SYS_MEM_ADDR, sizeof(struct PipeDev));
if (dev == NULL) { if (dev == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
@ -230,7 +229,7 @@ STATIC INT32 PipeDevRegister(CHAR *devName, UINT32 len)
(VOID)snprintf_s(dev->devName, PIPE_DEV_NAME_MAX, PIPE_DEV_NAME_MAX - 1, "%s%d", PIPE_DEV_PATH, num); (VOID)snprintf_s(dev->devName, PIPE_DEV_NAME_MAX, PIPE_DEV_NAME_MAX - 1, "%s%d", PIPE_DEV_PATH, num);
(VOID)memcpy_s(devName, len, dev->devName, strlen(dev->devName)); (VOID)memcpy_s(devName, len, dev->devName, strlen(dev->devName));
devTemp = PipeDevFind(dev->devName); struct PipeDev *devTemp = PipeDevFind(dev->devName);
if (devTemp != NULL) { if (devTemp != NULL) {
ret = -EEXIST; ret = -EEXIST;
goto ERROR; goto ERROR;
@ -389,22 +388,15 @@ INT32 PipeOpen(const CHAR *path, INT32 openFlag, INT32 minFd)
dev->ringBuffer = LOS_MemAlloc(OS_SYS_MEM_ADDR, PIPE_DEV_BUF_SIZE); dev->ringBuffer = LOS_MemAlloc(OS_SYS_MEM_ADDR, PIPE_DEV_BUF_SIZE);
if (dev->ringBuffer == NULL) { if (dev->ringBuffer == NULL) {
PIPE_DEV_UNLOCK(dev->mutex); PIPE_DEV_UNLOCK(dev->mutex);
PipeDevFdFree(fd);
errno = ENOMEM; errno = ENOMEM;
goto ERROR; return -1;
} }
dev->bufferSize = PIPE_DEV_BUF_SIZE; dev->bufferSize = PIPE_DEV_BUF_SIZE;
} }
PIPE_DEV_UNLOCK(dev->mutex); PIPE_DEV_UNLOCK(dev->mutex);
return (fd + minFd); return (fd + minFd);
ERROR:
if (dev->ringBuffer != NULL) {
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, dev->ringBuffer);
dev->ringBuffer = NULL;
}
PipeDevFdFree(fd);
return -1;
} }
STATIC INLINE struct PipeFdDev *PipeFdDevGet(INT32 fd) STATIC INLINE struct PipeFdDev *PipeFdDevGet(INT32 fd)
@ -448,9 +440,7 @@ INT32 PipeClose(INT32 fd)
PIPE_DEV_LOCK(dev->mutex); PIPE_DEV_LOCK(dev->mutex);
if (openFlag == O_RDONLY) { if (openFlag == O_RDONLY) {
dev->readerCnt--; dev->readerCnt--;
} } else if (openFlag == O_WRONLY) {
if (openFlag == O_WRONLY) {
dev->writerCnt--; dev->writerCnt--;
} }
@ -676,8 +666,19 @@ int pipe(int filedes[2])
return -1; return -1;
} }
struct PipeDev *dev = PipeDevFind(devName);
filedes[0] = open(devName, O_RDONLY); filedes[0] = open(devName, O_RDONLY);
if (filedes[0] < 0) {
(VOID)PipeDevUnregister(dev);
return -1;
}
filedes[1] = open(devName, O_WRONLY); filedes[1] = open(devName, O_WRONLY);
if (filedes[1] < 0) {
(VOID)PipeDevUnregister(dev);
(VOID)close(filedes[0]);
return -1;
}
return 0; return 0;
} }

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