diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md
deleted file mode 100644
index f09d98dd..00000000
--- a/.gitee/ISSUE_TEMPLATE.zh-CN.md
+++ /dev/null
@@ -1,13 +0,0 @@
-### 该问题是怎么引起的?
-
-
-
-### 重现步骤
-
-
-
-### 报错信息
-
-
-
-
diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
deleted file mode 100644
index 33948fdc..00000000
--- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
+++ /dev/null
@@ -1,15 +0,0 @@
-### 相关的Issue
-
-
-### 原因(目的、解决的问题等)
-
-
-### 描述(做了什么,变更了什么)
-
-
-### 测试用例(新增、改动、可能影响的功能)
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
index df3c495f..f31ded30 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,13 @@ test
tags
cscope.*
*.swp
+/**/*_iar/project/
+!los_demo.eww
+!los_demo.ewp
+!los_demo.ewd
+!los_demo.ewt
+!los_demo.dep
+!*.icf
targets/cortex-m7_nucleo_f767zi_gcc/build
*.o
*.d
diff --git a/BUILD.gn b/BUILD.gn
new file mode 100644
index 00000000..35e88fcb
--- /dev/null
+++ b/BUILD.gn
@@ -0,0 +1,63 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+declare_args() {
+ enable_ohos_kernel_liteos_m_cppsupport = true
+ enable_ohos_kernel_liteos_m_cpup = true
+ enable_ohos_kernel_liteos_m_exchook = true
+ enable_ohos_kernel_liteos_m_kal = true
+ enable_ohos_kernel_liteos_m_fs = true
+ enable_ohos_kernel_liteos_m_backtrace = true
+}
+
+group("kernel") {
+ deps = [
+ "components/bounds_checking_function:sec",
+ "kernel:kernel",
+ "utils:utils",
+ ]
+ if (enable_ohos_kernel_liteos_m_cppsupport == true) {
+ deps += [ "components/cppsupport:cppsupport" ]
+ }
+ if (enable_ohos_kernel_liteos_m_cpup == true) {
+ deps += [ "components/cpup:cpup" ]
+ }
+ if (enable_ohos_kernel_liteos_m_exchook == true) {
+ deps += [ "components/exchook:exchook" ]
+ }
+ if (enable_ohos_kernel_liteos_m_backtrace == true) {
+ deps += [ "components/backtrace:backtrace" ]
+ }
+ if (enable_ohos_kernel_liteos_m_fs == true) {
+ deps += [ "components/fs:fs" ]
+ }
+ if (enable_ohos_kernel_liteos_m_kal == true) {
+ deps += [ "kal:kal" ]
+ }
+}
diff --git a/LICENSE b/LICENSE
index 61fa69e3..208b4cd3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,5 @@
-Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
-Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@@ -25,4 +25,4 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 00000000..54e56597
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,8 @@
+1、In kernel/liteos_m/targets/cortex-m4_stm32f429ig_fire-challenger_iar directory, the files including main.c,
+target_config.h, dprintf.c, board/iar_stm32f429ig_fire-challenger.c and board/iar_stm32f429ig_fire-challenger.h,
+are under the terms of the licence: kernel/liteos_m/LICENSE file,
+and other files are under the terms of the licence: kernel/liteos_m/targets/cortex-m4_stm32f429ig_fire-challenger_iar/LICENSE.pdf file.
+
+2、In kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc directory, the files including target_config.h,
+Core/Inc/task_sample.h and Core/Src/task_sample.c, are under the terms of the licence: kernel/liteos_m/LICENSE file,
+and other files are under the terms of the licence: kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc/LICENSE.pdf file.
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..3d3ad085
--- /dev/null
+++ b/README.md
@@ -0,0 +1,77 @@
+# LiteOS Cortex-M
+
+- [Introduction](#section11660541593)
+- [Directory Structure](#section161941989596)
+- [Constraints](#section119744591305)
+- [Usage](#section3732185231214)
+- [Repositories Involved](#section1371113476307)
+
+## Introduction
+
+The OpenHarmony LiteOS Cortex-M is the kernel designed for the lightweight operating system \(OS\) for the Internet of Things \(IoT\) field. It features small size, low power consumption, and high performance. In addition, it has a simple code structure, including the minimum kernel function set, kernel abstraction layer, optional components, and project directory, and is divided into the hardware-related and hardware-irrelevant layers. The hardware-related layers provide unified hardware abstraction layer \(HAL\) interfaces to improve hardware adaptability. The combination and classification of different compilation toolchains and chip architectures meet the requirements of the Artificial Intelligence of Things \(AIoT\) field for rich hardware and compilation toolchains. [Figure1](#fig0865152210223) shows the architecture of the OpenHarmony LiteOS Cortex-M kernel.
+
+**Figure 1** Architecture of OpenHarmony the LiteOS Cortex-M kernel
+
+
+## Directory Structure
+
+```
+/kernel/liteos_m
+├── components # Optional components
+│ ├── cppsupport # C++ support
+│ └── cpup # CPU possession (CPUP)
+├── kal # Kernel abstraction layer
+│ ├── cmsis # CMSIS-compliant API support
+│ └── posix # POSIX API support
+├── kernel # Minimum function set support
+│ ├── arch # Code of the kernel instruction architecture layer
+│ │ ├── arm # Code of the ARM32 architecture
+│ │ └── include # APIs exposed externally
+│ ├── include # APIs exposed externally
+│ └── src # Source code of the minimum function set of the kernel
+├── targets # Board-level projects
+├── utils # Common code
+```
+
+## Constraints
+
+Programming languages: C and C++
+
+Currently applicable architectures: Cortex-M3, Cortex-M4, Cortex-M7, and RISC-V
+
+## Usage
+
+LiteOS Cortex-M provides projects for three chip architectures, which are located in the **targets** directory. The methods of compiling and using these projects are as follows:
+
+- Cortex-M3:
+
+The **kernel/liteos\_m/targets/cortex-m3\_stm32f103\_simulator\_keil** directory is the Keil project directory created based on the STM32F103 chip architecture. You can download and install Keil development tools from the Internet. To compile the Cortex-M3 project, go to the **cortex-m3\_stm32f103\_simulator\_keil/project** directory and double-click the **los\_demo.uvproj** file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
+
+- Cortex-M4:
+
+The **kernel/liteos\_m/targets/cortex-m4\_stm32f429ig\_fire-challenger\_iar** directory is the IAR project directory created based on the STM32F429IG chip architecture. You can download and install IAR development tools from the Internet. To compile the Cortex-M4 project, go to the **cortex-m4\_stm32f429ig\_fire-challenger\_iar/project** directory and double-click the **los\_demo.eww** file to open the desired project. After the compilation is successful, burn the file to the corresponding board using JLINK or STM32 ST-LINK Utility.
+
+- Cortex-M7:
+
+The **kernel/liteos\_m/targets/cortex-m7\_nucleo\_f767zi\_gcc** directory is the Makefile project directory created based on the STM32F767ZI chip architecture. The compilation commands are as follows:
+
+```
+cd kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc
+make clean; make
+```
+
+After the compilation is successful, the executable file **NUCLEO-F767.hex** is generated in the **cortex-m7\_nucleo\_f767zi\_gcc/build** directory. Burn the file to the corresponding board using STM32 ST-LINK Utility.
+
+## Change Log
+
+v1.0.1
+1. removed these KAL apis: `KalThreadGetInfo`,`KalDelayUs`,`KalTimerCreate`,`KalTimerStart`,`KalTimerChange`,`KalTimerStop`,`KalTimerDelete`,`KalTimerIsRunning`,`KalTickToMs`,`KalMsToTick`,`KalGetMemInfo`
+2. add some POSIX apis
+
+v1.0
+1. first release
+
+## Repositories Involved
+
+**[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m)**
+
diff --git a/README_zh.md b/README_zh.md
new file mode 100644
index 00000000..0ec989a5
--- /dev/null
+++ b/README_zh.md
@@ -0,0 +1,77 @@
+# LiteOS-M内核
+
+- [简介](#section11660541593)
+- [目录](#section161941989596)
+- [约束](#section119744591305)
+- [使用说明](#section3732185231214)
+- [相关仓](#section1371113476307)
+
+## 简介
+
+OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系统内核,具有小体积、低功耗、高性能的特点,其代码结构简单,主要包括内核最小功能集、内核抽象层、可选组件以及工程目录等,分为硬件相关层以及硬件无关层,硬件相关层提供统一的HAL(Hardware Abstraction Layer)接口,提升硬件易适配性,不同编译工具链和芯片架构的组合分类,满足AIoT类型丰富的硬件和编译工具链的拓展。其架构图如图1所示:
+
+**图 1** OpenHarmony LiteOS-M核内核架构图
+
+
+## 目录
+
+```
+/kernel/liteos_m
+├── components # 可选组件
+│ ├── cppsupport # C++支持
+│ └── cpup # CPUP功能
+├── kal # 内核抽象层
+│ ├── cmsis # cmsis标准接口支持
+│ └── posix # posix标准接口支持
+├── kernel # 内核最小功能集支持
+│ ├── arch # 内核指令架构层代码
+│ │ ├── arm # arm32架构的代码
+│ │ └── include # 对外接口存放目录
+│ ├── include # 对外接口存放目录
+│ └── src # 内核最小功能集源码
+├── targets # 板级工程目录
+├── utils # 通用公共目录
+```
+
+## 约束
+
+开发语言:C/C++;
+
+适用架构:当前只适用于cortex-m3、cortex-m4、cortex-m7、risc-v芯片架构。
+
+## 使用说明
+
+LiteOS-M内核提供了三种芯片架构的工程位于targets目录。三种架构的工程编译及使用方式如下:
+
+- cortex-m3:
+
+kernel/liteos\_m/targets/cortex-m3\_stm32f103\_simulator\_keil目录是基于STM32F103芯片架构构建的keil工程目录,keil开发工具可通过网络下载并安装。进入cortex-m3\_stm32f103\_simulator\_keil/project目录,双击los\_demo.uvproj文件即可打开相应工程,编译成功后即可通过JLINK或者STM32 ST-LINK Utility烧录至对应单板。
+
+- cortex-m4:
+
+kernel/liteos\_m/targets/cortex-m4\_stm32f429ig\_fire-challenger\_iar目录是基于STM32F429IG芯片架构构建的IAR工程目录,IAR开发工具可通过网络下载并安装。进入cortex-m4\_stm32f429ig\_fire-challenger\_iar/project目录,双击los\_demo.eww文件即可打开相应工程,编译成功后即可通过JLINK或者STM32 ST-LINK Utility烧录至对应单板。
+
+- cortex-m7:
+
+kernel/liteos\_m/targets/cortex-m7\_nucleo\_f767zi\_gcc目录是基于STM32F767ZI芯片架构构建的Makefile工程目录。编译方式如下:
+
+```
+cd kernel/liteos_m/targets/cortex-m7_nucleo_f767zi_gcc
+make clean; make
+```
+
+编译成功后在cortex-m7\_nucleo\_f767zi\_gcc/build目录下生成NUCLEO-F767.hex可执行文件,通过烧录工具STM32 ST-LINK Utility烧录到对应的单板。
+
+## 修改日志
+
+v1.0.1
+1. 删除以下KAL接口: `KalThreadGetInfo`,`KalDelayUs`,`KalTimerCreate`,`KalTimerStart`,`KalTimerChange`,`KalTimerStop`,`KalTimerDelete`,`KalTimerIsRunning`,`KalTickToMs`,`KalMsToTick`,`KalGetMemInfo`
+2. 添加部分POSIX接口
+
+v1.0
+1. 首次发布
+
+## 相关仓
+
+**[kernel\_liteos\_m](https://gitee.com/openharmony/kernel_liteos_m)**
+
diff --git a/components/backtrace/BUILD.gn b/components/backtrace/BUILD.gn
new file mode 100644
index 00000000..c6839eac
--- /dev/null
+++ b/components/backtrace/BUILD.gn
@@ -0,0 +1,40 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("backtrace") {
+ sources = [ "los_backtrace.c" ]
+
+ include_dirs = [
+ "../../kernel/include",
+ "../../kernel/arch/include",
+ "../../utils",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/components/backtrace/los_backtrace.c b/components/backtrace/los_backtrace.c
new file mode 100644
index 00000000..11b86f4c
--- /dev/null
+++ b/components/backtrace/los_backtrace.c
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "los_backtrace.h"
+#include "los_task.h"
+#include "los_debug.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#if (LOSCFG_BACKTRACE_TYPE != 0)
+#if (LOSCFG_BACKTRACE_TYPE == 1)
+#define OS_BACKTRACE_START 2
+/* Thumb instruction, so the pc must be an odd number */
+#define OS_IS_THUMB_INSTRUCTION(pc) ((pc & 0x1) == 1)
+
+/* BL or BLX instruction flag. */
+#define OS_BL_INS_MASK 0xF800
+#define OS_BL_INS_HIGH 0xF800
+#define OS_BL_INS_LOW 0xF000
+#define OS_BLX_INX_MASK 0xFF00
+#define OS_BLX_INX 0x4700
+
+#if defined(__ICCARM__) || defined(__CC_ARM)
+STATIC INLINE UINTPTR HalSpGet(VOID)
+{
+ UINTPTR sp;
+ __asm("mov %0, sp" : "=r" (sp));
+ return sp;
+}
+
+STATIC INLINE UINTPTR HalPspGet(VOID)
+{
+ UINTPTR psp;
+ __asm("mrs %0, psp" : "=r" (psp));
+ return psp;
+}
+
+STATIC INLINE UINTPTR HalMspGet(VOID)
+{
+ UINTPTR msp;
+ __asm("mrs %0, msp" : "=r" (msp));
+ return msp;
+}
+#elif defined(__CLANG_ARM) || defined(__GNUC__)
+STATIC INLINE UINTPTR HalSpGet(VOID)
+{
+ UINTPTR sp;
+ __asm volatile("mov %0, sp" : "=r" (sp));
+ return sp;
+}
+
+STATIC INLINE UINTPTR HalPspGet(VOID)
+{
+ UINTPTR psp;
+ __asm volatile("mrs %0, psp" : "=r" (psp));
+ return psp;
+}
+
+STATIC INLINE UINTPTR HalMspGet(VOID)
+{
+ UINTPTR msp;
+ __asm volatile("mrs %0, msp" : "=r" (msp));
+ return msp;
+}
+#else
+#error Unknown compiler.
+#endif
+
+STATIC INLINE BOOL OsInsIsBlOrBlx(UINTPTR addr)
+{
+ UINT16 ins1 = *((UINT16 *)addr);
+ UINT16 ins2 = *((UINT16 *)(addr + 2)); /* 2: Thumb instruction is two bytes. */
+
+ if (((ins2 & OS_BL_INS_MASK) == OS_BL_INS_HIGH) &&
+ ((ins1 & OS_BL_INS_MASK) == OS_BL_INS_LOW)) {
+ return TRUE;
+ } else if ((ins2 & OS_BLX_INX_MASK) == OS_BLX_INX) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+STATIC INLINE VOID OsStackAddrGet(UINTPTR *stackStart, UINTPTR *stackEnd)
+{
+ if (HalSpGet() != HalPspGet()) {
+ *stackStart = HalMspGet();
+ *stackEnd = CSTACK_END_ADDR;
+ } else {
+ UINT32 taskID = LOS_CurTaskIDGet();
+ LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
+ *stackStart = HalSpGet();
+ *stackEnd = (UINTPTR)taskCB->topOfStack + taskCB->stackSize;
+ }
+}
+
+STATIC INLINE UINTPTR OsAddrIsValid(UINTPTR sp)
+{
+ UINTPTR pc;
+ BOOL ret;
+
+ /* The stack space pointed to by the current SP may store the LR,
+ so need decrease a word to PC. */
+ pc = *((UINTPTR *)sp) - sizeof(UINTPTR);
+
+ if (!OS_IS_THUMB_INSTRUCTION(pc)) {
+ return 0;
+ }
+
+ /* PC in thumb mode is an odd number, fix the PC address by decreasing one byte. */
+ pc = *((UINTPTR *)sp) - 1;
+
+ ret = OsStackDataIsCodeAddr(pc);
+ if (ret == FALSE) {
+ return 0;
+ }
+
+ ret = OsInsIsBlOrBlx(pc - sizeof(UINTPTR));
+ if (ret == FALSE) {
+ return 0;
+ }
+
+ return pc;
+}
+
+VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount)
+{
+ if (LR == NULL) {
+ return;
+ }
+
+ UINTPTR stackStart;
+ UINTPTR stackEnd;
+ UINT32 count = 0;
+ UINT32 index = 0;
+ UINTPTR sp;
+ UINTPTR pc;
+
+ OsStackAddrGet(&stackStart, &stackEnd);
+
+ /* Traverse the stack space and find the LR address. */
+ for (sp = stackStart; sp < stackEnd; sp += sizeof(UINTPTR)) {
+ pc = OsAddrIsValid(sp);
+ if ((pc != 0) && (count < LRSize)) {
+ if (index++ < jumpCount) {
+ continue;
+ }
+ LR[count] = pc;
+ count++;
+ if (count == LRSize) {
+ break;
+ }
+ }
+ }
+
+ if (count < LRSize) {
+ LR[count] = 0;
+ }
+}
+#elif (LOSCFG_BACKTRACE_TYPE == 2)
+STATIC INLINE BOOL OsBackTraceFpCheck(UINT32 value);
+#define OS_BACKTRACE_START 1
+#define OS_RA_OFFSET 4
+#define OS_FP_OFFSET 8
+#define OS_FP_ALIGN(value) (((UINT32)(value) & (UINT32)(LOSCFG_STACK_POINT_ALIGN_SIZE - 1)) == 0)
+#define OS_FP_CHECK(value) (((UINT32)(value) != FP_INIT_VALUE) && OS_FP_ALIGN(value))
+
+STATIC INLINE UINTPTR OsFpGet(VOID)
+{
+ UINTPTR fp = 0;
+ __asm volatile("mv %0, s0" : "=r"(fp));
+ dsb();
+ return fp;
+}
+
+VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount)
+{
+ UINT32 backFp = OsFpGet();
+ UINT32 tmpFp;
+ UINT32 backRa;
+ UINT32 count = 0;
+ UINT32 index = 0;
+
+ if (LR == NULL) {
+ return;
+ }
+
+ while (OS_FP_CHECK(backFp)) {
+ tmpFp = backFp;
+ backRa = *((UINT32 *)(UINTPTR)(tmpFp - OS_RA_OFFSET));
+ backFp = *((UINT32 *)(UINTPTR)(tmpFp - OS_FP_OFFSET));
+ if (index++ < jumpCount) {
+ continue;
+ }
+
+ LR[count] = backRa;
+ count++;
+ if ((count == LRSize) || (backFp == tmpFp) ||
+ (!OsStackDataIsCodeAddr(backRa))) {
+ break;
+ }
+ }
+
+ if (count < LRSize) {
+ LR[count] = 0;
+ }
+}
+#else
+#error Unknown backtrace type.
+#endif
+
+VOID LOS_BackTrace(VOID)
+{
+ UINTPTR LR[BACKTRACE_MAX_DEPTH] = {0};
+ UINT32 index;
+
+ LOS_RecordLR(LR, BACKTRACE_MAX_DEPTH, OS_BACKTRACE_START);
+
+ if (LOS_TaskIsRunning()) {
+ PRINTK("taskName = %s\n", g_losTask.runTask->taskName);
+ PRINTK("taskID = %u\n", g_losTask.runTask->taskID);
+ }
+
+ PRINTK("----- traceback start -----\r\n");
+ for (index = 0; index < BACKTRACE_MAX_DEPTH; index++) {
+ if (LR[index] == 0) {
+ break;
+ }
+ PRINTK("traceback %d -- lr = 0x%x\r\n", index, LR[index]);
+ }
+ PRINTK("----- traceback end -----\r\n");
+}
+
+VOID LOS_BackTraceInit(VOID)
+{
+ OsBackTraceHookSet(LOS_RecordLR);
+}
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
diff --git a/components/backtrace/los_backtrace.h b/components/backtrace/los_backtrace.h
new file mode 100644
index 00000000..1399b091
--- /dev/null
+++ b/components/backtrace/los_backtrace.h
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LOS_BACKTRACE_H
+#define _LOS_BACKTRACE_H
+
+#include "los_config.h"
+#include "los_arch_interrupt.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#define BACKTRACE_MAX_DEPTH LOSCFG_BACKTRACE_DEPTH
+
+#if (LOSCFG_BACKTRACE_TYPE != 0)
+#if (LOSCFG_BACKTRACE_TYPE == 1)
+/* The default name of the code section and CSTACK section are given below,
+ and the user can be adjust it according to the linker script file. */
+#if defined(__ICCARM__)
+/* The default code section name is .text */
+#define CODE_SECTION_NAME ".text"
+/* The default C stack section name is CSTACK */
+#define CSTACK_SECTION_NAME "CSTACK"
+#pragma section=CODE_SECTION_NAME
+#pragma section=CSTACK_SECTION_NAME
+
+/* Default only one code section. In fact, there may be more than one.
+ You can define more than one and modify the OsStackDataIsCodeAddr function
+ to support searching in multiple code sections */
+#define CODE_START_ADDR ((UINTPTR)__section_begin(CODE_SECTION_NAME))
+#define CODE_END_ADDR ((UINTPTR)__section_end(CODE_SECTION_NAME))
+#define CSTACK_START_ADDR ((UINTPTR)__section_begin(CSTACK_SECTION_NAME))
+#define CSTACK_END_ADDR ((UINTPTR)__section_end(CSTACK_SECTION_NAME))
+#elif defined(__CC_ARM) || defined(__CLANG_ARM)
+/* The default code section name is ER_IROM1 */
+#define CODE_SECTION_NAME ER_IROM1
+/* The default C stack section name is STACK */
+#define CSTACK_SECTION_NAME STACK
+
+#define SECTION_START(_name_) _name_##$$Base
+#define SECTION_END(_name_) _name_##$$Limit
+#define CSTACK_SECTION_START(_name_) SECTION_START(_name_)
+#define CSTACK_SECTION_END(_name_) SECTION_END(_name_)
+
+#define IMAGE_SECTION_START(_name_) Image$$##_name_##$$Base
+#define IMAGE_SECTION_END(_name_) Image$$##_name_##$$Limit
+#define CODE_SECTION_START(_name_) IMAGE_SECTION_START(_name_)
+#define CODE_SECTION_END(_name_) IMAGE_SECTION_END(_name_)
+
+extern CHAR *CSTACK_SECTION_START(CSTACK_SECTION_NAME);
+extern CHAR *CSTACK_SECTION_END(CSTACK_SECTION_NAME);
+extern CHAR *CODE_SECTION_START(CODE_SECTION_NAME);
+extern CHAR *CODE_SECTION_END(CODE_SECTION_NAME);
+
+/* Default only one code section. In fact, there may be more than one.
+ You can define more than one and modify the OsStackDataIsCodeAddr function
+ to support searching in multiple code sections */
+#define CODE_START_ADDR ((UINTPTR)&CODE_SECTION_START(CODE_SECTION_NAME))
+#define CODE_END_ADDR ((UINTPTR)&CODE_SECTION_END(CODE_SECTION_NAME))
+#define CSTACK_START_ADDR ((UINTPTR)&CSTACK_SECTION_START(CSTACK_SECTION_NAME))
+#define CSTACK_END_ADDR ((UINTPTR)&CSTACK_SECTION_END(CSTACK_SECTION_NAME))
+#elif defined(__GNUC__)
+/* The defalut code section start address */
+#define CODE_SECTION_START _stext
+/* The defalut code section end address */
+#define CODE_SECTION_END _etext
+/* The default C stack section start address */
+#define CSTACK_SECTION_START _sstack
+/* The default C stack section end address */
+#define CSTACK_SECTION_END _estack
+
+extern CHAR *CODE_SECTION_START;
+extern CHAR *CODE_SECTION_END;
+extern CHAR *CSTACK_SECTION_START;
+extern CHAR *CSTACK_SECTION_END;
+
+/* Default only one code section. In fact, there may be more than one.
+ You can define more than one and modify the OsStackDataIsCodeAddr function
+ to support searching in multiple code sections */
+#define CODE_START_ADDR ((UINTPTR)&CODE_SECTION_START)
+#define CODE_END_ADDR ((UINTPTR)&CODE_SECTION_END)
+#define CSTACK_START_ADDR ((UINTPTR)&CSTACK_SECTION_START)
+#define CSTACK_END_ADDR ((UINTPTR)&CSTACK_SECTION_END)
+#else
+#error Unknown compiler.
+#endif
+#elif (LOSCFG_BACKTRACE_TYPE == 2)
+#if defined(__GNUC__)
+/* The defalut code section start address */
+#define CODE_SECTION_START __text_start
+/* The defalut code section end address */
+#define CODE_SECTION_END __text_end
+
+extern CHAR *CODE_SECTION_START;
+extern CHAR *CODE_SECTION_END;
+
+#define CODE_START_ADDR ((UINTPTR)&CODE_SECTION_START)
+#define CODE_END_ADDR ((UINTPTR)&CODE_SECTION_END)
+#else
+#error Unknown compiler.
+#endif
+#endif
+
+/* This function is used to judge whether the data in the stack is a code section address.
+ The default code section is only one, but there may be more than one. Modify the
+ judgment condition to support multiple code sections. */
+STATIC INLINE BOOL OsStackDataIsCodeAddr(UINTPTR value)
+{
+ if ((value >= CODE_START_ADDR) && (value < CODE_END_ADDR)) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* This function is currently used to register the memory leak check hook,
+ other uses do not need to be called temporarily. */
+VOID LOS_BackTraceInit(VOID);
+
+/* This function is used to print the function call stack. */
+VOID LOS_BackTrace(VOID);
+
+/* This function is used to record the function call stack. */
+VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount);
+#endif
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+#endif
\ No newline at end of file
diff --git a/components/bounds_checking_function/BUILD.gn b/components/bounds_checking_function/BUILD.gn
new file mode 100755
index 00000000..6c03fa4d
--- /dev/null
+++ b/components/bounds_checking_function/BUILD.gn
@@ -0,0 +1,74 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("sec") {
+ include_dirs = [ "//third_party/bounds_checking_function/include" ]
+
+ sources = [
+ "//third_party/bounds_checking_function/src/fscanf_s.c",
+ "//third_party/bounds_checking_function/src/fwscanf_s.c",
+ "//third_party/bounds_checking_function/src/gets_s.c",
+ "//third_party/bounds_checking_function/src/memcpy_s.c",
+ "//third_party/bounds_checking_function/src/memmove_s.c",
+ "//third_party/bounds_checking_function/src/memset_s.c",
+ "//third_party/bounds_checking_function/src/scanf_s.c",
+ "//third_party/bounds_checking_function/src/securecutil.c",
+ "//third_party/bounds_checking_function/src/secureinput_a.c",
+ "//third_party/bounds_checking_function/src/secureinput_w.c",
+ "//third_party/bounds_checking_function/src/secureprintoutput_a.c",
+ "//third_party/bounds_checking_function/src/secureprintoutput_w.c",
+ "//third_party/bounds_checking_function/src/snprintf_s.c",
+ "//third_party/bounds_checking_function/src/sprintf_s.c",
+ "//third_party/bounds_checking_function/src/sscanf_s.c",
+ "//third_party/bounds_checking_function/src/strcat_s.c",
+ "//third_party/bounds_checking_function/src/strcpy_s.c",
+ "//third_party/bounds_checking_function/src/strncat_s.c",
+ "//third_party/bounds_checking_function/src/strncpy_s.c",
+ "//third_party/bounds_checking_function/src/strtok_s.c",
+ "//third_party/bounds_checking_function/src/swprintf_s.c",
+ "//third_party/bounds_checking_function/src/swscanf_s.c",
+ "//third_party/bounds_checking_function/src/vfscanf_s.c",
+ "//third_party/bounds_checking_function/src/vfwscanf_s.c",
+ "//third_party/bounds_checking_function/src/vscanf_s.c",
+ "//third_party/bounds_checking_function/src/vsnprintf_s.c",
+ "//third_party/bounds_checking_function/src/vsprintf_s.c",
+ "//third_party/bounds_checking_function/src/vsscanf_s.c",
+ "//third_party/bounds_checking_function/src/vswprintf_s.c",
+ "//third_party/bounds_checking_function/src/vswscanf_s.c",
+ "//third_party/bounds_checking_function/src/vwscanf_s.c",
+ "//third_party/bounds_checking_function/src/wcscat_s.c",
+ "//third_party/bounds_checking_function/src/wcscpy_s.c",
+ "//third_party/bounds_checking_function/src/wcsncat_s.c",
+ "//third_party/bounds_checking_function/src/wcsncpy_s.c",
+ "//third_party/bounds_checking_function/src/wcstok_s.c",
+ "//third_party/bounds_checking_function/src/wmemcpy_s.c",
+ "//third_party/bounds_checking_function/src/wmemmove_s.c",
+ "//third_party/bounds_checking_function/src/wscanf_s.c",
+ ]
+}
diff --git a/components/cppsupport/BUILD.gn b/components/cppsupport/BUILD.gn
new file mode 100644
index 00000000..d74632fc
--- /dev/null
+++ b/components/cppsupport/BUILD.gn
@@ -0,0 +1,37 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("cppsupport") {
+ sources = [ "los_cppsupport.c" ]
+
+ include_dirs = [
+ "../../utils",
+ "./",
+ ]
+}
diff --git a/components/cppsupport/los_cppsupport.c b/components/cppsupport/los_cppsupport.c
index e0901eb6..dcdbe8bc 100644
--- a/components/cppsupport/los_cppsupport.c
+++ b/components/cppsupport/los_cppsupport.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/components/cppsupport/los_cppsupport.h b/components/cppsupport/los_cppsupport.h
index b1229a7e..6ede711b 100644
--- a/components/cppsupport/los_cppsupport.h
+++ b/components/cppsupport/los_cppsupport.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/components/cpup/BUILD.gn b/components/cpup/BUILD.gn
new file mode 100644
index 00000000..acd1d086
--- /dev/null
+++ b/components/cpup/BUILD.gn
@@ -0,0 +1,40 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("cpup") {
+ sources = [ "los_cpup.c" ]
+
+ include_dirs = [
+ "../../kernel/include",
+ "../../kernel/arch/include",
+ "../../utils",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/components/cpup/los_cpup.c b/components/cpup/los_cpup.c
index e077ebae..4456d592 100755
--- a/components/cpup/los_cpup.c
+++ b/components/cpup/los_cpup.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/components/cpup/los_cpup.h b/components/cpup/los_cpup.h
index 16dc9d84..b73d67dd 100644
--- a/components/cpup/los_cpup.h
+++ b/components/cpup/los_cpup.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/components/exchook/BUILD.gn b/components/exchook/BUILD.gn
new file mode 100644
index 00000000..3550c550
--- /dev/null
+++ b/components/exchook/BUILD.gn
@@ -0,0 +1,42 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("exchook") {
+ sources = [
+ "los_exc_info.c",
+ "los_exchook.c",
+ ]
+ include_dirs = [
+ "../../kernel/arch/include",
+ "../../kernel/include",
+ "../../utils",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/components/exchook/los_exc_info.c b/components/exchook/los_exc_info.c
index 4d74f969..dd412e16 100644
--- a/components/exchook/los_exc_info.c
+++ b/components/exchook/los_exc_info.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/components/exchook/los_exc_info.h b/components/exchook/los_exc_info.h
index dc2f98da..27a6bc92 100644
--- a/components/exchook/los_exc_info.h
+++ b/components/exchook/los_exc_info.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -41,6 +41,7 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
+#if (LOSCFG_PLATFORM_EXC == 1)
#define INFO_TYPE_AND_SIZE 8
#define MAX_SCENE_INFO_SIZE (INFO_TYPE_AND_SIZE + sizeof(ExcInfo) + sizeof(EXC_CONTEXT_S))
@@ -108,6 +109,7 @@ typedef struct {
VOID OsExcMsgDumpInit(VOID);
extern UINT8 g_excMsgArray[MAX_EXC_MEM_SIZE];
+#endif
#ifdef __cplusplus
#if __cplusplus
diff --git a/components/exchook/los_exchook.c b/components/exchook/los_exchook.c
old mode 100644
new mode 100755
index 7583f53c..78f5de87
--- a/components/exchook/los_exchook.c
+++ b/components/exchook/los_exchook.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/components/exchook/los_exchook.h b/components/exchook/los_exchook.h
old mode 100644
new mode 100755
index 8bc5760a..960fa44a
--- a/components/exchook/los_exchook.h
+++ b/components/exchook/los_exchook.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/components/fs/BUILD.gn b/components/fs/BUILD.gn
new file mode 100644
index 00000000..094d2edc
--- /dev/null
+++ b/components/fs/BUILD.gn
@@ -0,0 +1,39 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+declare_args() {
+ enable_ohos_kernel_liteos_m_fatfs = true
+}
+
+group("fs") {
+ deps = []
+ if (enable_ohos_kernel_liteos_m_fatfs == true) {
+ deps += [ "fatfs:fatfs" ]
+ }
+}
diff --git a/components/fs/fatfs/BUILD.gn b/components/fs/fatfs/BUILD.gn
new file mode 100644
index 00000000..ee0075cd
--- /dev/null
+++ b/components/fs/fatfs/BUILD.gn
@@ -0,0 +1,47 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("fatfs") {
+ sources = [
+ "fatfs.c",
+ "fs.c",
+ ]
+
+ include_dirs = [
+ "../../../kernel/arch/include",
+ "../../../kernel/include",
+ "../../../utils",
+ "../../../kal/cmsis",
+ "../../../kal",
+ "../../../kal/posix/include",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ "//third_party/FatFs/source/",
+ ]
+}
diff --git a/components/fs/fatfs/fatfs.c b/components/fs/fatfs/fatfs.c
old mode 100644
new mode 100755
index 4b7d4346..363bc8a9
--- a/components/fs/fatfs/fatfs.c
+++ b/components/fs/fatfs/fatfs.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,21 +29,18 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_compiler.h"
-#include "fcntl.h"
-#include "unistd.h"
-#include "sys/mount.h"
-#include "sys/stat.h"
-#include "sys/statfs.h"
-#include "dirent.h"
-#include "stdio.h"
+#include "ff.h"
+#if FF_USE_EXPAND
+#define _GNU_SOURCE
+#endif
+#include "fatfs.h"
#include "errno.h"
+#include "limits.h"
#include "pthread.h"
#include "time.h"
#include "securec.h"
-#include "ff.h"
+#include "los_compiler.h"
#include "los_debug.h"
-#include "fatfs.h"
#include "cmsis_os.h"
#define FS_SUCCESS 0
@@ -55,10 +52,6 @@
#define FAT_MAX_OPEN_DIRS 8
#endif /* FAT_MAX_OPEN_DIRS */
-#ifndef FAT_MAX_OPEN_FILES
-#define FAT_MAX_OPEN_FILES 50
-#endif /* FAT_MAX_OPEN_FILES */
-
#ifndef FS_LOCK_TIMEMOUT_SEC
#define FS_LOCK_TIMEMOUT_SEC 15
#endif /* FS_LOCK_TIMEMOUT_SEC */
@@ -327,9 +320,9 @@ static int FatfsErrno(int result)
return status;
}
-int mount(const char *source, const char *target,
- const char *filesystemtype, unsigned long mountflags,
- const void *data)
+int fatfs_mount(const char *source, const char *target,
+ const char *filesystemtype, unsigned long mountflags,
+ const void *data)
{
INT32 index;
FRESULT res;
@@ -386,7 +379,7 @@ OUT:
return ret;
}
-int umount(const char *target)
+int fatfs_umount(const char *target)
{
FRESULT res;
INT32 ret;
@@ -482,7 +475,7 @@ static int CloseAll(int index)
return FS_SUCCESS;
}
-int umount2(const char *target, int flag)
+int fatfs_umount2(const char *target, int flag)
{
INT32 index;
INT32 ret;
@@ -546,7 +539,7 @@ OUT:
return ret;
}
-int open(const char *path, int oflag, ...)
+int fatfs_open(const char *path, int oflag, ...)
{
FRESULT res;
UINT32 i;
@@ -626,7 +619,7 @@ OUT:
return ret;
}
-int close(int fd)
+int fatfs_close(int fd)
{
FRESULT res;
INT32 ret;
@@ -667,7 +660,7 @@ int close(int fd)
return FS_SUCCESS;
}
-ssize_t read(int fd, void *buf, size_t nbyte)
+ssize_t fatfs_read(int fd, void *buf, size_t nbyte)
{
FRESULT res;
INT32 ret;
@@ -699,7 +692,7 @@ ssize_t read(int fd, void *buf, size_t nbyte)
return (ssize_t)lenRead;
}
-ssize_t write(int fd, const void *buf, size_t nbyte)
+ssize_t fatfs_write(int fd, const void *buf, size_t nbyte)
{
FRESULT res;
INT32 ret;
@@ -743,7 +736,7 @@ ERROUT:
return FS_FAILURE;
}
-off_t lseek(int fd, off_t offset, int whence)
+off_t fatfs_lseek(int fd, off_t offset, int whence)
{
FRESULT res;
INT32 ret;
@@ -787,7 +780,7 @@ ERROUT:
}
/* Remove the specified FILE */
-int unlink(const char *path)
+int fatfs_unlink(const char *path)
{
FRESULT res;
INT32 ret;
@@ -833,7 +826,7 @@ OUT:
}
/* Return information about a file */
-int fstat(int fd, struct stat *buf)
+int fatfs_fstat(int fd, struct stat *buf)
{
INT32 ret;
@@ -864,7 +857,7 @@ int fstat(int fd, struct stat *buf)
return FS_SUCCESS;
}
-int stat(const char *__restrict path, struct stat *__restrict buf)
+int fatfs_stat(const char *path, struct stat *buf)
{
FRESULT res;
FILINFO fileInfo = {0};
@@ -918,7 +911,7 @@ OUT:
}
/* Synchronize all changes to Flash */
-int fsync(int fd)
+int fatfs_fsync(int fd)
{
FRESULT res;
INT32 ret;
@@ -952,7 +945,7 @@ OUT:
return ret;
}
-int mkdir(const char *path, mode_t mode)
+int fatfs_mkdir(const char *path, mode_t mode)
{
FRESULT res;
INT32 ret;
@@ -996,7 +989,7 @@ OUT:
return ret;
}
-DIR *opendir(const char *dirName)
+DIR *fatfs_opendir(const char *dirName)
{
FRESULT res;
UINT32 openNum = 0;
@@ -1058,7 +1051,7 @@ ERROUT:
return NULL;
}
-struct dirent *readdir(DIR *dir)
+struct dirent *fatfs_readdir(DIR *dir)
{
FRESULT res;
INT32 ret;
@@ -1095,7 +1088,7 @@ struct dirent *readdir(DIR *dir)
return &g_retValue;
}
-int closedir(DIR *dir)
+int fatfs_closedir(DIR *dir)
{
FRESULT res;
INT32 ret;
@@ -1126,7 +1119,7 @@ int closedir(DIR *dir)
return FS_SUCCESS;
}
-int rmdir(const char *path)
+int fatfs_rmdir(const char *path)
{
FRESULT res;
INT32 ret;
@@ -1170,7 +1163,7 @@ OUT:
return ret;
}
-int rename(const char *oldName, const char *newName)
+int fatfs_rename(const char *oldName, const char *newName)
{
FRESULT res;
INT32 ret;
@@ -1214,7 +1207,7 @@ OUT:
return ret;
}
-int statfs(const char *path, struct statfs *buf)
+int fatfs_statfs(const char *path, struct statfs *buf)
{
FATFS *fs = NULL;
UINT32 freeClust;
@@ -1264,6 +1257,85 @@ OUT:
return ret;
}
+static int do_truncate(int fd, off_t length, UINT count)
+{
+ FRESULT res;
+ INT32 ret = FR_OK;
+ DWORD csz;
+
+ csz = (DWORD)(g_handle[fd].fil.obj.fs)->csize * SS(g_handle[fd].fil.obj.fs); /* Cluster size */
+ if (length > csz * count) {
+#if FF_USE_EXPAND
+ res = f_expand(&g_handle[fd].fil, 0, (FSIZE_t)(length), FALLOC_FL_KEEP_SIZE);
+#else
+ errno = ENOSYS;
+ ret = FS_FAILURE;
+ return ret;
+#endif
+ } else if (length < csz * count) {
+ res = f_truncate(&g_handle[fd].fil, (FSIZE_t)length);
+ }
+
+ if (res != FR_OK) {
+ errno = FatfsErrno(res);
+ ret = FS_FAILURE;
+ return ret;
+ }
+
+ g_handle[fd].fil.obj.objsize = length; /* Set file size to length */
+ g_handle[fd].fil.flag |= 0x40; /* Set modified flag */
+
+ return ret;
+}
+
+int fatfs_ftruncate(int fd, off_t length)
+{
+ FRESULT res;
+ INT32 ret;
+ UINT count;
+ DWORD fclust;
+
+ if (!IsValidFd(fd)) {
+ errno = EBADF;
+ return FS_FAILURE;
+ }
+
+ if ((length < 0) || (length > UINT_MAX)) {
+ errno = EINVAL;
+ return FS_FAILURE;
+ }
+
+ ret = FsLock();
+ if (ret != 0) {
+ errno = ret;
+ return FS_FAILURE;
+ }
+
+ if (!FsCheckByID(g_handle[fd].fil.obj.fs->id)) {
+ errno = EACCES;
+ ret = FS_FAILURE;
+ goto OUT;
+ }
+
+ res = f_getclustinfo(&g_handle[fd].fil, &fclust, &count);
+ if (res != FR_OK) {
+ errno = FatfsErrno(res);
+ ret = FS_FAILURE;
+ goto OUT;
+ }
+
+ ret = do_truncate(fd, length, count);
+ if (ret != FR_OK) {
+ goto OUT;
+ }
+
+ ret = FS_SUCCESS;
+
+OUT:
+ FsUnlock();
+ return ret;
+}
+
int fatfs_fdisk(int pdrv, const unsigned int *partTbl)
{
INT32 index;
@@ -1348,4 +1420,4 @@ int fatfs_format(const char *dev, int sectors, int option)
OUT:
FsUnlock();
return ret;
-}
\ No newline at end of file
+}
diff --git a/components/fs/fatfs/fatfs.h b/components/fs/fatfs/fatfs.h
old mode 100644
new mode 100755
index c5c494a9..21ad1e7f
--- a/components/fs/fatfs/fatfs.h
+++ b/components/fs/fatfs/fatfs.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -32,17 +32,51 @@
#ifndef _FATFS_H
#define _FATFS_H
+#include "fcntl.h"
+#include "dirent.h"
+#include "unistd.h"
+#include "sys/mount.h"
+#include "sys/stat.h"
+#include "sys/statfs.h"
+#include "fs_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
+#ifndef FAT_MAX_OPEN_FILES
+#define FAT_MAX_OPEN_FILES 50
+#endif /* FAT_MAX_OPEN_FILES */
+
/* Format options */
#define FMT_FAT 0x01
#define FMT_FAT32 0x02
#define FMT_ANY 0x07
+int fatfs_mount(const char *source, const char *target,
+ const char *filesystemtype, unsigned long mountflags,
+ const void *data);
+int fatfs_umount(const char *target);
+int fatfs_umount2(const char *target, int flag);
+int fatfs_open(const char *path, int oflag, ...);
+int fatfs_close(int fd);
+ssize_t fatfs_read(int fd, void *buf, size_t nbyte);
+ssize_t fatfs_write(int fd, const void *buf, size_t nbyte);
+off_t fatfs_lseek(int fd, off_t offset, int whence);
+int fatfs_unlink(const char *path);
+int fatfs_fstat(int fd, struct stat *buf);
+int fatfs_stat(const char *path, struct stat *buf);
+int fatfs_fsync(int fd);
+int fatfs_mkdir(const char *path, mode_t mode);
+DIR *fatfs_opendir(const char *dirName);
+struct dirent *fatfs_readdir(DIR *dir);
+int fatfs_closedir(DIR *dir);
+int fatfs_rmdir(const char *path);
+int fatfs_rename(const char *oldName, const char *newName);
+int fatfs_statfs(const char *path, struct statfs *buf);
+int fatfs_ftruncate(int fd, off_t length);
+
/**
* @brief divide a physical drive (SD card, U disk, and MMC card), this function is OHOS-specific
* @param pdrv physical drive number.
@@ -77,4 +111,4 @@ int fatfs_format(const char *dev, int sectors, int option);
#endif /* __cplusplus */
#endif /* __cplusplus */
-#endif /* _FATFS_H */
\ No newline at end of file
+#endif /* _FATFS_H */
diff --git a/kal/posix/src/file.c b/components/fs/fatfs/fs.c
old mode 100644
new mode 100755
similarity index 64%
rename from kal/posix/src/file.c
rename to components/fs/fatfs/fs.c
index ff2d99f4..7435e822
--- a/kal/posix/src/file.c
+++ b/components/fs/fatfs/fs.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,14 +29,18 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "hks_client.h"
+#include "fatfs.h"
+#include "dirent.h"
+#include "errno.h"
+#include "fcntl.h"
+#include "securec.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "string.h"
+#include "sys/mount.h"
+#include "sys/statfs.h"
+#include "sys/stat.h"
+#include "unistd.h"
#ifdef LOSCFG_NET_LWIP_SACK
#include "lwip/lwipopts.h"
@@ -44,16 +48,21 @@
#else
#define CONFIG_NSOCKET_DESCRIPTORS 0
#endif
-#define CONFIG_NFILE_DESCRIPTORS 1 /* only for random currently */
-#define RANDOM_DEV_FD CONFIG_NSOCKET_DESCRIPTORS
+#define CONFIG_NFILE_DESCRIPTORS FAT_MAX_OPEN_FILES /* only for random currently */
+
+#ifdef LOSCFG_RANDOM_DEV
+#include "hks_client.h"
+#define RANDOM_DEV_FD CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS
#define RANDOM_DEV_PATH "/dev/random"
+#endif
#define FREE_AND_SET_NULL(ptr) do { \
free(ptr); \
ptr = NULL; \
} while (0)
+#ifdef LOSCFG_RANDOM_DEV
/**
* @brief Get canonical form of a given path based on cwd(Current working directory).
*
@@ -69,6 +78,7 @@
*/
static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, size_t bufSize)
{
+ size_t offset;
if (!path) {
path = "";
}
@@ -77,7 +87,8 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
cwd = "";
}
- size_t tmpLen = strlen(cwd) + strlen(path) + 4; // three '/' and one '\0'
+ offset = strlen("///") + 1; // three '/' and one '\0'
+ size_t tmpLen = strlen(cwd) + strlen(path) + offset;
char *tmpBuf = (char *)malloc(tmpLen);
if (tmpBuf == NULL) {
return 0;
@@ -90,8 +101,9 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
char *p;
/* replace /./ to / */
+ offset = strlen("/./") - 1;
while ((p = strstr(tmpBuf, "/./")) != NULL) {
- if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + 2, tmpLen - (p - tmpBuf) - 2)) {
+ if (EOK != memmove_s(p, tmpLen - (p - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
return 0;
}
@@ -106,18 +118,19 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
}
/* handle /../ (e.g., replace /aa/bb/../ to /aa/) */
+ offset = strlen("/../") - 1;
while ((p = strstr(tmpBuf, "/../")) != NULL) {
char *start = p;
- while (start > tmpBuf && *--start != '/') {
+ while (start > tmpBuf && *(start - 1) != '/') {
+ --start;
}
- if (EOK != memmove_s(start, tmpLen - (start - tmpBuf), p + 3, tmpLen - (p - tmpBuf) - 3)) {
+ if (EOK != memmove_s(start, tmpLen - (start - tmpBuf), p + offset, tmpLen - (p - tmpBuf) - offset)) {
free(tmpBuf);
return 0;
}
}
size_t totalLen = strlen(tmpBuf);
-
/* strip the last / */
if (totalLen > 1 && tmpBuf[totalLen - 1] == '/') {
tmpBuf[--totalLen] = 0;
@@ -128,7 +141,7 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
return totalLen;
}
- if (EOK != memcpy_s(buf, bufSize, tmpBuf, (totalLen + 1 > bufSize) ? bufSize : totalLen + 1)) {
+ if (EOK != memcpy_s(buf, bufSize, tmpBuf, (((totalLen + 1) > bufSize) ? bufSize : (totalLen + 1)))) {
free(tmpBuf);
return 0;
}
@@ -137,25 +150,46 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
free(tmpBuf);
return totalLen;
}
+#endif
-int open(const char *file, int oflag, ...)
+int mount(const char *source, const char *target,
+ const char *filesystemtype, unsigned long mountflags,
+ const void *data)
{
+ return fatfs_mount(source, target, filesystemtype, mountflags, data);
+}
+
+int umount(const char *target)
+{
+ return fatfs_umount(target);
+}
+
+int umount2(const char *target, int flag)
+{
+ return fatfs_umount2(target, flag);
+}
+
+int open(const char *path, int oflag, ...)
+{
+#ifdef LOSCFG_RANDOM_DEV
unsigned flags = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY;
if ((unsigned)oflag & ~flags) {
errno = EINVAL;
return -1;
}
- size_t pathLen = strlen(file) + 1;
+
+ size_t pathLen = strlen(path) + 1;
char *canonicalPath = (char *)malloc(pathLen);
if (!canonicalPath) {
errno = ENOMEM;
return -1;
}
- if (GetCanonicalPath(NULL, file, canonicalPath, pathLen) == 0) {
+ if (GetCanonicalPath(NULL, path, canonicalPath, pathLen) == 0) {
FREE_AND_SET_NULL(canonicalPath);
errno = ENOMEM;
return -1;
}
+
if (strcmp(canonicalPath, RANDOM_DEV_PATH) == 0) {
FREE_AND_SET_NULL(canonicalPath);
if ((O_ACCMODE & (unsigned)oflag) != O_RDONLY) {
@@ -178,64 +212,132 @@ int open(const char *file, int oflag, ...)
return -1;
}
FREE_AND_SET_NULL(canonicalPath);
- errno = ENOENT;
- return -1;
+#endif
+ return fatfs_open(path, oflag);
}
int close(int fd)
{
+#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
return 0;
}
+#endif
#ifdef LOSCFG_NET_LWIP_SACK
if (fd >= CONFIG_NFILE_DESCRIPTORS && fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) {
return closesocket(fd);
}
#endif
- errno = EBADF;
- return -1;
+ return fatfs_close(fd);
}
-ssize_t read(int fd, void *buf, size_t nbytes)
+ssize_t read(int fd, void *buf, size_t nbyte)
{
+#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
- if (nbytes == 0) {
+ if (nbyte == 0) {
return 0;
}
if (buf == NULL) {
errno = EINVAL;
return -1;
}
- if (nbytes > 1024) {
- nbytes = 1024; /* hks_generate_random: random_size must <= 1024 */
+ if (nbyte > 1024) {
+ nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */
}
- struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbytes};
+ struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte};
if (hks_generate_random(&key) != 0) {
errno = EIO;
return -1;
}
- return (ssize_t)nbytes;
- }
-#ifdef LOSCFG_NET_LWIP_SACK
- if (fd >= CONFIG_NFILE_DESCRIPTORS && fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) {
- return recv(fd, buf, nbytes, 0);
+ return (ssize_t)nbyte;
}
#endif
- errno = EBADF;
- return -1;
+#ifdef LOSCFG_NET_LWIP_SACK
+ if (fd >= CONFIG_NFILE_DESCRIPTORS && fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) {
+ return recv(fd, buf, nbyte, 0);
+ }
+#endif
+ return fatfs_read(fd, buf, nbyte);
}
-ssize_t write(int fd, const void *buf, size_t nbytes)
+ssize_t write(int fd, const void *buf, size_t nbyte)
{
+#ifdef LOSCFG_RANDOM_DEV
if (fd == RANDOM_DEV_FD) {
errno = EBADF; /* "/dev/random" is readonly */
return -1;
}
+#endif
#ifdef LOSCFG_NET_LWIP_SACK
if (fd >= CONFIG_NFILE_DESCRIPTORS && fd < (CONFIG_NFILE_DESCRIPTORS + CONFIG_NSOCKET_DESCRIPTORS)) {
- return send(fd, buf, nbytes, 0);
+ return send(fd, buf, nbyte, 0);
}
#endif
- errno = EBADF;
- return -1;
+ return fatfs_write(fd, buf, nbyte);
+}
+
+off_t lseek(int fd, off_t offset, int whence)
+{
+ return fatfs_lseek(fd, offset, whence);
+}
+
+int unlink(const char *path)
+{
+ return fatfs_unlink(path);
+}
+
+int fstat(int fd, struct stat *buf)
+{
+ return fatfs_fstat(fd, buf);
+}
+
+int stat(const char *path, struct stat *buf)
+{
+ return fatfs_stat(path, buf);
+}
+
+int fsync(int fd)
+{
+ return fatfs_fsync(fd);
+}
+
+int mkdir(const char *path, mode_t mode)
+{
+ return fatfs_mkdir(path, mode);
+}
+
+DIR *opendir(const char *dirName)
+{
+ return fatfs_opendir(dirName);
+}
+
+struct dirent *readdir(DIR *dir)
+{
+ return fatfs_readdir(dir);
+}
+
+int closedir(DIR *dir)
+{
+ return fatfs_closedir(dir);
+}
+
+int rmdir(const char *path)
+{
+ return fatfs_rmdir(path);
+}
+
+int rename(const char *oldName, const char *newName)
+{
+ return fatfs_rename(oldName, newName);
+}
+
+int statfs(const char *path, struct statfs *buf)
+{
+ return fatfs_statfs(path, buf);
+}
+
+int ftruncate(int fd, off_t length)
+{
+ return fatfs_ftruncate(fd, length);
}
diff --git a/components/net/lwip-2.1/enhancement/src/fixme.c b/components/net/lwip-2.1/enhancement/src/fixme.c
new file mode 100644
index 00000000..5985736b
--- /dev/null
+++ b/components/net/lwip-2.1/enhancement/src/fixme.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+#include
+#include
+#include
+
+#define NETIFAPI_VAR_REF(name) API_VAR_REF(name)
+#define NETIFAPI_VAR_DECLARE(name) API_VAR_DECLARE(struct netifapi_msg, name)
+#define NETIFAPI_VAR_ALLOC(name) API_VAR_ALLOC(struct netifapi_msg, MEMP_NETIFAPI_MSG, name, ERR_MEM)
+#define NETIFAPI_VAR_FREE(name) API_VAR_FREE(MEMP_NETIFAPI_MSG, name)
+
+static struct netif *netif_find_by_name(const char *name)
+{
+ struct netif *netif = NULL;
+ LWIP_ASSERT_CORE_LOCKED();
+ if (name == NULL) {
+ return NULL;
+ }
+ NETIF_FOREACH(netif) {
+ if (strcmp("lo", name) == 0 && (netif->name[0] == 'l' && netif->name[1] == 'o')) {
+ LWIP_DEBUGF(NETIF_DEBUG, ("netif_find_by_name: found lo\n"));
+ return netif;
+ }
+
+ if (strcmp(netif->full_name, name) == 0) {
+ LWIP_DEBUGF(NETIF_DEBUG, ("netif_find_by_name: found %s\n", name));
+ return netif;
+ }
+ }
+
+ LWIP_DEBUGF(NETIF_DEBUG, ("netif_find_by_name: didn't find %s\n", name));
+ return NULL;
+}
+
+static err_t netifapi_do_find_by_name(struct tcpip_api_call_data *m)
+{
+ /* cast through void* to silence alignment warnings.
+ * We know it works because the structs have been instantiated as struct netifapi_msg */
+ struct netifapi_msg *msg = (struct netifapi_msg *)(void *)m;
+ msg->netif = netif_find_by_name(msg->msg.ifs.name);
+ return ERR_OK;
+}
+
+struct netif *netifapi_netif_find_by_name(const char *name)
+{
+ struct netif *netif = NULL;
+ NETIFAPI_VAR_DECLARE(msg);
+ NETIFAPI_VAR_ALLOC(msg);
+ NETIFAPI_VAR_REF(msg).netif = NULL;
+#if LWIP_MPU_COMPATIBLE
+ if (strncpy_s(NETIFAPI_VAR_REF(msg).msg.ifs.name, NETIF_NAMESIZE, name, NETIF_NAMESIZE - 1)) {
+ NETIFAPI_VAR_FREE(msg);
+ return netif;
+ }
+ NETIFAPI_VAR_REF(msg).msg.ifs.name[NETIF_NAMESIZE - 1] = '\0';
+#else
+ NETIFAPI_VAR_REF(msg).msg.ifs.name = (char *)name;
+#endif /* LWIP_MPU_COMPATIBLE */
+
+ (void)tcpip_api_call(netifapi_do_find_by_name, &API_VAR_REF(msg).call);
+ netif = msg.netif;
+ NETIFAPI_VAR_FREE(msg);
+ return netif;
+}
+
+#if LWIP_IPV6
+int ip6addr_aton(const char *cp, ip6_addr_t *addr)
+{
+ const int ipv6_blocks = 8;
+ u16_t current_block_index = 0;
+ u16_t current_block_value = 0;
+ u16_t addr16[ipv6_blocks];
+ u16_t *a16 = (u16_t *)addr->addr;
+ int squash_pos = ipv6_blocks;
+ int i;
+ const char *sc = cp;
+ const char *ss = cp-1;
+
+ for (; ; sc++) {
+ if (current_block_index >= ipv6_blocks) {
+ return 0; // address too long
+ }
+ if (*sc == 0) {
+ if (sc - ss == 1) {
+ if (squash_pos != current_block_index) {
+ return 0; // empty address or address ends with a single ':'
+ } // else address ends with one valid "::"
+ } else {
+ addr16[current_block_index++] = current_block_value;
+ }
+ break;
+ } else if (*sc == ':') {
+ if (sc - ss == 1) {
+ if (sc != cp || sc[1] != ':') {
+ return 0; // address begins with a single ':' or contains ":::"
+ } // else address begins with one valid "::"
+ } else {
+ addr16[current_block_index++] = current_block_value;
+ }
+ if (sc[1] == ':') {
+ if (squash_pos != ipv6_blocks) {
+ return 0; // more than one "::"
+ }
+ squash_pos = current_block_index;
+ sc++;
+ }
+ ss = sc; // ss points to the recent ':' position
+ current_block_value = 0;
+ } else if (lwip_isxdigit(*sc) && (sc - ss) < 5) { // 4 hex-digits at most
+ current_block_value = (current_block_value << 4) +
+ (*sc | ('a' - 'A')) - '0' - ('a' - '9' - 1) * (*sc >= 'A');
+#if LWIP_IPV4
+ } else if (*sc == '.' && current_block_index < ipv6_blocks - 1) {
+ ip4_addr_t ip4;
+ int ret = ip4addr_aton(ss+1, &ip4);
+ if (!ret) {
+ return 0;
+ }
+ ip4.addr = lwip_ntohl(ip4.addr);
+ addr16[current_block_index++] = (u16_t)(ip4.addr >> 16);
+ addr16[current_block_index++] = (u16_t)(ip4.addr);
+ break;
+#endif /* LWIP_IPV4 */
+ } else {
+ return 0; // unexpected char or too many digits
+ }
+ }
+
+ if (squash_pos == ipv6_blocks && current_block_index != ipv6_blocks) {
+ return 0; // address too short
+ }
+ if (squash_pos != ipv6_blocks && current_block_index == ipv6_blocks) {
+ return 0; // unexpected "::" in address
+ }
+
+ for (i = 0; i < squash_pos; ++i) {
+ a16[i] = lwip_htons(addr16[i]);
+ }
+ for (; i < ipv6_blocks - current_block_index + squash_pos; ++i) {
+ a16[i] = 0;
+ }
+ for (; i < ipv6_blocks; ++i) {
+ a16[i] = lwip_htons(addr16[i - ipv6_blocks + current_block_index]);
+ }
+
+ return 1;
+}
+#endif /* LWIP_IPV6 */
diff --git a/components/net/lwip-2.1/porting/include/arch/cc.h b/components/net/lwip-2.1/porting/include/arch/cc.h
new file mode 100644
index 00000000..746bf9e9
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/arch/cc.h
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LWIP_PORTING_CC_H_
+#define _LWIP_PORTING_CC_H_
+
+#include
+#include
+#include "securec.h"
+#include "log.h"
+
+#ifdef htons
+#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS
+#endif
+
+#define LWIP_PROVIDE_ERRNO 1
+#define __SIZEOF_POINTER__ 4 // 32位系统
+
+#define LOS_TASK_STATUS_DETACHED 0x0100 // 预留字段
+
+#if defined(__arm__) && defined(__ARMCC_VERSION)
+ /* Keil uVision4 tools */
+ #define PACK_STRUCT_BEGIN __packed
+ #define PACK_STRUCT_STRUCT
+ #define PACK_STRUCT_END
+ #define PACK_STRUCT_FIELD(fld) fld
+ #define ALIGNED(n) __align(n)
+#elif defined (__IAR_SYSTEMS_ICC__)
+ /* IAR Embedded Workbench tools */
+ #define PACK_STRUCT_BEGIN __packed
+ #define PACK_STRUCT_STRUCT
+ #define PACK_STRUCT_END
+ #define PACK_STRUCT_FIELD(fld) fld
+ // #error NEEDS ALIGNED
+#else
+ /* GCC tools (CodeSourcery) */
+ #define PACK_STRUCT_BEGIN
+ #define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
+ #define PACK_STRUCT_END
+ #define PACK_STRUCT_FIELD(fld) fld
+ #define ALIGNED(n) __attribute__((aligned (n)))
+#endif
+
+#define LWIP_RAND rand
+
+extern void HilogPrintf(const char *fmt, ...);
+
+#ifndef HILOG_INFO
+#define HILOG_INFO(...)
+#ifndef HILOG_MODULE_APP
+#define HILOG_MODULE_APP 0
+#endif
+#endif
+
+#ifndef HILOG_ERROR
+#define HILOG_ERROR(...)
+#endif
+
+#define LWIP_PLATFORM_DIAG(vars) HilogPrintf vars
+#define LWIP_PLATFORM_ASSERT(x) do {HILOG_ERROR(HILOG_MODULE_APP, \
+ "Assertion \"%s\" errno %d line %d in %s\n", \
+ x, errno, __LINE__, __FILE__);} while (0)
+
+#define mem_clib_malloc LWIP_MEM_ALLOC
+#define mem_clib_free LWIP_MEM_FREE
+#define mem_clib_calloc LWIP_MEM_CALLOC
+
+#define init_waitqueue_head(...)
+#define poll_check_waiters(...)
+#define IOCTL_CMD_CASE_HANDLER()
+#define DF_NADDR(addr)
+
+#define DNS_SERVER_ADDRESS(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("114.114.114.114")))
+#define DNS_SERVER_ADDRESS_SECONDARY(ipaddr) (ip4_addr_set_u32(ipaddr, ipaddr_addr("114.114.115.115")))
+
+#endif /* _LWIP_PORTING_CC_H_ */
diff --git a/components/net/lwip-2.1/porting/include/arch/perf.h b/components/net/lwip-2.1/porting/include/arch/perf.h
new file mode 100644
index 00000000..43147ef7
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/arch/perf.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LWIP_PORTING_PERF_H_
+#define _LWIP_PORTING_PERF_H_
+
+#if LWIP_PERF
+
+#define PERF_START do { /* something to do */ } while (0)
+#define PERF_STOP(x) do { /* something to do */ } while (0)
+
+#endif
+
+#endif /* _LWIP_PORTING_PERF_H_ */
diff --git a/kal/posix/src/pthread_impl.h b/components/net/lwip-2.1/porting/include/arch/sys_arch.h
similarity index 69%
rename from kal/posix/src/pthread_impl.h
rename to components/net/lwip-2.1/porting/include/arch/sys_arch.h
index 1ede97de..95f7f80a 100644
--- a/kal/posix/src/pthread_impl.h
+++ b/components/net/lwip-2.1/porting/include/arch/sys_arch.h
@@ -1,69 +1,72 @@
-/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef PTHREAD_IMPL_H_
-#define PTHREAD_IMPL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct __pthread_attr_s pthread_attr_t;
-#define __DEFINED_pthread_attr_t
-
-#ifdef __cplusplus
-}
-#endif
-
-#include
-#include
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct __pthread_attr_s {
- unsigned int detachstate;
- unsigned int schedpolicy;
- struct sched_param schedparam;
- unsigned int inheritsched;
- unsigned int scope;
- unsigned int stackaddr_set;
- void* stackaddr;
- unsigned int stacksize_set;
- size_t stacksize;
-} pthread_attr_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // PTHREAD_IMPL_H_
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LWIP_PORTING_SYS_ARCH_H_
+#define _LWIP_PORTING_SYS_ARCH_H_
+
+#include
+#include "memory_pool.h"
+#include "los_mux.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Mutex
+ */
+typedef uint32_t sys_mutex_t;
+
+/**
+ * Semaphore
+ */
+typedef uint32_t sys_sem_t;
+
+/**
+ * MessageBox
+ */
+typedef uint32_t sys_mbox_t;
+
+/**
+ * Protector
+ */
+typedef void *sys_prot_t;
+
+/**
+ * Thread
+ */
+typedef uint32_t sys_thread_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LWIP_PORTING_SYS_ARCH_H_ */
diff --git a/components/net/lwip-2.1/porting/include/lwip/lwipopts.h b/components/net/lwip-2.1/porting/include/lwip/lwipopts.h
new file mode 100644
index 00000000..7d077758
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/lwip/lwipopts.h
@@ -0,0 +1,299 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LWIP_PORTING_LWIPOPTS_H_
+#define _LWIP_PORTING_LWIPOPTS_H_
+
+// lwIP debug options, comment the ones you don't want
+#define LWIP_DEBUG 0
+#if LWIP_DEBUG
+#define ETHARP_DEBUG LWIP_DBG_OFF
+#define NETIF_DEBUG LWIP_DBG_OFF
+#define PBUF_DEBUG LWIP_DBG_OFF
+#define API_LIB_DEBUG LWIP_DBG_OFF
+#define API_MSG_DEBUG LWIP_DBG_OFF
+#define SOCKETS_DEBUG LWIP_DBG_OFF
+#define ICMP_DEBUG LWIP_DBG_OFF
+#define IGMP_DEBUG LWIP_DBG_OFF
+#define INET_DEBUG LWIP_DBG_OFF
+#define IP_DEBUG LWIP_DBG_OFF
+#define DRIVERIF_DEBUG LWIP_DBG_OFF
+#define IP_REASS_DEBUG LWIP_DBG_OFF
+#define RAW_DEBUG LWIP_DBG_OFF
+#define MEM_DEBUG LWIP_DBG_OFF
+#define MEMP_DEBUG LWIP_DBG_OFF
+#define SYS_DEBUG LWIP_DBG_OFF
+#define TIMERS_DEBUG LWIP_DBG_OFF
+#define TCP_DEBUG LWIP_DBG_OFF
+#define TCP_ERR_DEBUG LWIP_DBG_OFF
+#define TCP_INPUT_DEBUG LWIP_DBG_OFF
+#define TCP_FR_DEBUG LWIP_DBG_OFF
+#define TCP_RTO_DEBUG LWIP_DBG_OFF
+#define TCP_CWND_DEBUG LWIP_DBG_OFF
+#define TCP_WND_DEBUG LWIP_DBG_OFF
+#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
+#define TCP_RST_DEBUG LWIP_DBG_OFF
+#define TCP_QLEN_DEBUG LWIP_DBG_OFF
+#define TCP_SACK_DEBUG LWIP_DBG_OFF
+#define TCP_TLP_DEBUG LWIP_DBG_OFF
+#define UDP_DEBUG LWIP_DBG_OFF
+#define TCPIP_DEBUG LWIP_DBG_OFF
+#define SLIP_DEBUG LWIP_DBG_OFF
+#define DHCP_DEBUG LWIP_DBG_OFF
+#define AUTOIP_DEBUG LWIP_DBG_OFF
+#define DNS_DEBUG LWIP_DBG_OFF
+#define TFTP_DEBUG LWIP_DBG_OFF
+#define SYS_ARCH_DEBUG LWIP_DBG_OFF
+#define SNTP_DEBUG LWIP_DBG_OFF
+#define IP6_DEBUG LWIP_DBG_OFF
+#define DHCP6_DEBUG LWIP_DBG_OFF
+#define DRV_STS_DEBUG LWIP_DBG_OFF
+#endif
+
+// Options only in new opt.h
+#define LWIP_SOCKET_SELECT 0
+#define LWIP_SOCKET_POLL 1
+
+// Options in old opt.h that differs from new opt.h
+#define MEM_ALIGNMENT __SIZEOF_POINTER__
+#define MEMP_NUM_NETDB 8
+#define IP_REASS_MAXAGE 3
+#define IP_SOF_BROADCAST 1
+#define IP_SOF_BROADCAST_RECV 1
+#define LWIP_MULTICAST_PING 1
+#define LWIP_RAW 1
+#define LWIP_DHCP_AUTOIP_COOP_TRIES 64
+#define TCP_LISTEN_BACKLOG 1
+#define TCP_DEFAULT_LISTEN_BACKLOG 16
+
+#define LWIP_WND_SCALE 1
+#define TCP_RCV_SCALE 7
+
+#define LWIP_NETIF_HOSTNAME 1
+#define LWIP_NETIF_TX_SINGLE_PBUF 1
+#define LWIP_NETCONN_FULLDUPLEX 1 // Caution
+#define LWIP_COMPAT_SOCKETS 2
+#define LWIP_POSIX_SOCKETS_IO_NAMES 0
+#define LWIP_TCP_KEEPALIVE 1
+#define RECV_BUFSIZE_DEFAULT 65535
+#define SO_REUSE_RXTOALL 1
+
+#define LWIP_CHECKSUM_ON_COPY 1
+#define LWIP_IPV6 1
+#define LWIP_IPV6_NUM_ADDRESSES 5
+#define LWIP_ND6_NUM_PREFIXES 10
+#define LWIP_IPV6_DHCP6 1
+#define LWIP_IPV6_DHCP6_STATEFUL 1
+
+// Options in old lwipopts.h
+#define ARP_QUEUEING 1
+#define DEFAULT_ACCEPTMBOX_SIZE 32
+#define DEFAULT_RAW_RECVMBOX_SIZE 128
+#define DEFAULT_TCP_RECVMBOX_SIZE 128
+#define DEFAULT_UDP_RECVMBOX_SIZE 128
+#define ETHARP_SUPPORT_STATIC_ENTRIES 1
+#define ETH_PAD_SIZE 2
+#define IP_REASS_MAX_PBUFS (((65535) / (IP_FRAG_MAX_MTU - 20 - 8) + 1) * MEMP_NUM_REASSDATA)
+#define LWIP_COMPAT_SOCKETS 2
+#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_OFF
+#define LWIP_DHCP 1
+#define LWIP_DNS 1
+#define LWIP_ETHERNET 1
+#define LWIP_HAVE_LOOPIF 1
+#define LWIP_IGMP 1
+#define LWIP_NETIF_API 1
+#define LWIP_NETIF_LINK_CALLBACK 1
+#define LWIP_NETIF_LOOPBACK 1
+#define LWIP_POSIX_SOCKETS_IO_NAMES 0
+#define LWIP_RAW 1
+#define CONFIG_NFILE_DESCRIPTORS 1
+#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
+#define LWIP_SO_RCVBUF 1
+#define LWIP_SO_RCVTIMEO 1
+#define LWIP_SO_SNDTIMEO 1
+#define LWIP_STATS_DISPLAY 1
+#define MEM_LIBC_MALLOC 1
+#define MEMP_NUM_ARP_QUEUE (65535 * LWIP_CONFIG_NUM_SOCKETS / (IP_FRAG_MAX_MTU - 20 - 8))
+#define MEMP_NUM_NETBUF (65535 * 3 * LWIP_CONFIG_NUM_SOCKETS / (IP_FRAG_MAX_MTU - 20 - 8))
+#define MEMP_NUM_NETCONN LWIP_CONFIG_NUM_SOCKETS
+#define MEMP_NUM_PBUF LWIP_CONFIG_NUM_SOCKETS*2
+#define MEMP_NUM_RAW_PCB LWIP_CONFIG_NUM_SOCKETS
+#define MEMP_NUM_REASSDATA (IP_REASS_MAX_MEM_SIZE / 65535)
+#define MEMP_NUM_TCPIP_MSG_API 64
+#define MEMP_NUM_TCPIP_MSG_INPKT 512
+#define MEMP_NUM_TCP_PCB LWIP_CONFIG_NUM_SOCKETS
+#define MEMP_NUM_TCP_PCB_LISTEN LWIP_CONFIG_NUM_SOCKETS
+#define MEMP_NUM_TCP_SEG (((TCP_SND_BUF * 3 / 2) + TCP_WND) * LWIP_CONFIG_NUM_SOCKETS / TCP_MSS)
+#define MEMP_NUM_UDP_PCB LWIP_CONFIG_NUM_SOCKETS
+#define MEM_SIZE (4*1024*1024) // (512*1024)
+#define PBUF_POOL_BUFSIZE 1550
+#define PBUF_POOL_SIZE 64
+#define SO_REUSE 1
+#define TCPIP_MBOX_SIZE 512
+#define TCPIP_THREAD_PRIO 5
+#define TCPIP_THREAD_STACKSIZE 0x6000
+#define TCP_MAXRTX 64
+#define TCP_MSS 1400
+#define TCP_SND_BUF 65535
+#define TCP_SND_QUEUELEN (8 * TCP_SND_BUF) / TCP_MSS
+#define TCP_TTL 255
+#define TCP_WND 32768
+#define UDP_TTL 255
+
+// Options in old lwipopts.h but kept in Defaults with new opt.h
+#define IP_FORWARD 0
+#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
+#define LWIP_ICMP 1
+#define LWIP_NETCONN 1
+#define LWIP_SOCKET 1
+#define LWIP_STATS 1
+#define LWIP_TCP 1
+#define LWIP_UDP 1
+#define NO_SYS 0
+#define TCP_QUEUE_OOSEQ LWIP_TCP
+
+// Change some options for lwIP 2.1.2
+#undef TCP_MAXRTX
+#define TCP_MAXRTX 12
+
+#undef LWIP_COMPAT_SOCKETS
+#define LWIP_COMPAT_SOCKETS 0
+
+#define MEMP_NUM_SYS_TIMEOUT (LWIP_NUM_SYS_TIMEOUT_INTERNAL + (LWIP_IPV6 * LWIP_IPV6_DHCP6))
+
+#undef DEFAULT_ACCEPTMBOX_SIZE
+#define DEFAULT_ACCEPTMBOX_SIZE LWIP_CONFIG_NUM_SOCKETS
+
+#undef TCP_MSS
+#define TCP_MSS (IP_FRAG_MAX_MTU - 20 - 20)
+
+#undef IP_SOF_BROADCAST_RECV
+#define IP_SOF_BROADCAST_RECV 0
+
+/**
+ * Defines whether to enable debugging for driver module.
+ */
+#ifndef DRIVERIF_DEBUG
+#define DRIVERIF_DEBUG LWIP_DBG_OFF
+#endif
+
+// Options for old lwipopts.h
+#define IP_FRAG_MAX_MTU 1500
+#define LWIP_CONFIG_NUM_SOCKETS 128
+#define IP_REASS_MAX_MEM_SIZE (MEM_SIZE / 4)
+
+// Options for enhancement code, same for old lwipopts.h
+#define LWIP_NETIF_PROMISC 1
+#define LWIP_TFTP LOSCFG_NET_LWIP_SACK_TFTP
+#define LWIP_DHCPS 1
+#define LWIP_ENABLE_NET_CAPABILITY 1
+#define LWIP_ENABLE_CAP_NET_BROADCAST 0
+
+// Options for GT
+#undef LWIP_NETIF_PROMISC
+#define LWIP_NETIF_PROMISC 0
+
+#undef LWIP_ICMP
+#define LWIP_ICMP 0
+
+#undef LWIP_DHCP
+#define LWIP_DHCP 0
+
+#undef LWIP_IGMP
+#define LWIP_IGMP 0
+
+#undef LWIP_IPV6
+#define LWIP_IPV6 0
+
+#undef LWIP_IPV6_DHCP6
+#define LWIP_IPV6_DHCP6 0
+
+#undef TCP_SND_BUF
+#define TCP_SND_BUF (65535 / 3)
+
+#undef TCP_WND
+#define TCP_WND ((TCP_SND_BUF * 2) / 3)
+
+#undef TCP_SND_QUEUELEN
+#define TCP_SND_QUEUELEN (2 * (TCP_SND_BUF / TCP_MSS))
+
+#undef MEMP_NUM_NETDB
+#define MEMP_NUM_NETDB 1
+
+#undef MEMP_NUM_ARP_QUEUE
+#define MEMP_NUM_ARP_QUEUE 4
+
+#undef MEMP_NUM_NETBUF
+#define MEMP_NUM_NETBUF 12
+
+#undef MEMP_NUM_NETCONN
+#define MEMP_NUM_NETCONN 32
+
+#undef MEMP_NUM_PBUF
+#define MEMP_NUM_PBUF 0
+
+#undef PBUF_POOL_SIZE
+#define PBUF_POOL_SIZE 0
+
+#undef MEMP_NUM_RAW_PCB
+#define MEMP_NUM_RAW_PCB 8
+
+#undef MEMP_NUM_REASSDATA
+#define MEMP_NUM_REASSDATA 12
+
+#undef MEMP_NUM_TCPIP_MSG_API
+#define MEMP_NUM_TCPIP_MSG_API 32
+
+#undef MEMP_NUM_TCPIP_MSG_INPKT
+#define MEMP_NUM_TCPIP_MSG_INPKT 32
+
+#undef MEMP_NUM_TCP_PCB
+#define MEMP_NUM_TCP_PCB 8
+
+#undef MEMP_NUM_TCP_PCB_LISTEN
+#define MEMP_NUM_TCP_PCB_LISTEN 4
+
+#undef MEMP_NUM_TCP_SEG
+#define MEMP_NUM_TCP_SEG 64
+
+#undef MEMP_NUM_UDP_PCB
+#define MEMP_NUM_UDP_PCB 4
+
+#undef TCPIP_THREAD_STACKSIZE
+#define TCPIP_THREAD_STACKSIZE 0x1000
+
+#undef LWIP_SOCKET_SELECT
+#define LWIP_SOCKET_SELECT 1
+
+// use PBUF_RAM instead of PBUF_POOL in udp_input
+#define USE_PBUF_RAM_UDP_INPUT 1
+
+#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
diff --git a/components/net/lwip-2.1/porting/include/lwip/netif.h b/components/net/lwip-2.1/porting/include/lwip/netif.h
new file mode 100644
index 00000000..421a5fb6
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/lwip/netif.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LWIP_PORTING_NETIF_H_
+#define _LWIP_PORTING_NETIF_H_
+
+#define netif_find netifapi_netif_find_by_name
+
+#if LWIP_DHCPS
+#define LWIP_NETIF_CLIENT_DATA_INDEX_DHCP LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, \
+ LWIP_NETIF_CLIENT_DATA_INDEX_DHCPS
+#endif
+
+#define LWIP_NETIF_FULLNAME 16
+#define linkoutput linkoutput; \
+ void (*drv_send)(struct netif *netif, struct pbuf *p); \
+ u8_t (*drv_set_hwaddr)(struct netif *netif, u8_t *addr, u8_t len); \
+ void (*drv_config)(struct netif *netif, u32_t config_flags, u8_t setBit); \
+ char full_name[LWIP_NETIF_FULLNAME]; \
+ u16_t link_layer_type
+#include_next
+#undef linkoutput
+#if LWIP_DHCPS
+#undef LWIP_NETIF_CLIENT_DATA_INDEX_DHCP
+#endif
+
+#include // For ETHARP_HWADDR_LEN, by `hieth-sf src/interface.c' and `wal/wal_net.c'
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// redefine NETIF_NAMESIZE which was defined in netif.h
+#undef NETIF_NAMESIZE
+#define NETIF_NAMESIZE LWIP_NETIF_FULLNAME
+
+#define LOOPBACK_IF 0 // 772
+#define ETHERNET_DRIVER_IF 1
+#define WIFI_DRIVER_IF 801
+#define BT_PROXY_IF 802
+
+err_t driverif_init(struct netif *netif);
+void driverif_input(struct netif *netif, struct pbuf *p);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LWIP_PORTING_NETIF_H_ */
diff --git a/components/net/lwip-2.1/porting/include/lwip/netifapi.h b/components/net/lwip-2.1/porting/include/lwip/netifapi.h
new file mode 100644
index 00000000..44858b7c
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/lwip/netifapi.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LWIP_PORTING_NETIFAPI_H_
+#define _LWIP_PORTING_NETIFAPI_H_
+
+#include_next
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+err_t netifapi_dhcps_start(struct netif *netif, char *start_ip, u16_t ip_num);
+err_t netifapi_dhcps_stop(struct netif *netif);
+
+#define netifapi_dhcp_cleanup(n) netifapi_netif_common(n, dhcp_cleanup, NULL)
+#define netifapi_dhcp_is_bound(n) netifapi_netif_common(n, NULL, dhcp_is_bound)
+
+void netifapi_netif_rmv_ip6_address(struct netif *netif, ip_addr_t *ipaddr);
+struct netif *netifapi_netif_find_by_name(const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LWIP_PORTING_NETIFAPI_H_ */
diff --git a/components/net/lwip-2.1/porting/include/lwipopts.h b/components/net/lwip-2.1/porting/include/lwipopts.h
new file mode 100644
index 00000000..4f1ab721
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/lwipopts.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LITEOS_M_LWIPOPTS_H__
+#define __LITEOS_M_LWIPOPTS_H__
+
+// Just redirect
+#include "lwip/lwipopts.h"
+
+#endif // __LITEOS_M_LWIPOPTS_H__
diff --git a/components/net/lwip-2.1/porting/include/netdb.h b/components/net/lwip-2.1/porting/include/netdb.h
new file mode 100644
index 00000000..5043cf0a
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/netdb.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __LITEOS_NETDB_PORTING_H__
+#define __LITEOS_NETDB_PORTING_H__
+
+#include "lwip/netdb.h"
+
+struct hostent *gethostbyname(const char *name);
+
+#endif // __LITEOS_NETDB_PORTING_H__
\ No newline at end of file
diff --git a/components/net/lwip-2.1/porting/include/sys/socket.h b/components/net/lwip-2.1/porting/include/sys/socket.h
new file mode 100644
index 00000000..c5f27a60
--- /dev/null
+++ b/components/net/lwip-2.1/porting/include/sys/socket.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SYS_SOCKET_PORTING_H
+#define _SYS_SOCKET_PORTING_H
+
+#include "lwip/sockets.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int socket (int, int, int);
+
+int bind (int, const struct sockaddr *, socklen_t);
+int connect (int, const struct sockaddr *, socklen_t);
+int listen (int, int);
+int accept (int, struct sockaddr *__restrict, socklen_t *__restrict);
+
+int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
+int getpeername (int, struct sockaddr *__restrict, socklen_t *__restrict);
+
+ssize_t send (int, const void *, size_t, int);
+ssize_t recv (int, void *, size_t, int);
+ssize_t sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
+ssize_t recvfrom (int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
+ssize_t sendmsg (int, const struct msghdr *, int);
+ssize_t recvmsg (int, struct msghdr *, int);
+
+int getsockopt (int, int, int, void *__restrict, socklen_t *__restrict);
+int setsockopt (int, int, int, const void *, socklen_t);
+
+const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
+int inet_pton(int af, const char *src, void *dst);
+
+int shutdown (int, int);
+int closesocket(int sockfd);
+
+int ioctlsocket(int s, long cmd, void *argp);
+
+#if LWIP_SOCKET_SELECT
+int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout);
+#endif
+#if LWIP_SOCKET_POLL
+int poll(struct pollfd *fds, nfds_t nfds, int timeout);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/components/net/lwip-2.1/porting/src/driverif.c b/components/net/lwip-2.1/porting/src/driverif.c
new file mode 100644
index 00000000..d16ba5cc
--- /dev/null
+++ b/components/net/lwip-2.1/porting/src/driverif.c
@@ -0,0 +1,357 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#define LWIP_NETIF_HOSTNAME_DEFAULT "default"
+#define LINK_SPEED_OF_YOUR_NETIF_IN_BPS 100000000 // 100Mbps
+
+#define link_rx_drop cachehit
+#define link_rx_overrun cachehit
+
+#define LWIP_STATIC static
+
+#define NETIF_NAME_PREFIX_MAX_LENGTH 10
+#define NETIF_NAME_PREFIX_ETH "eth"
+#define NETIF_NAME_PREFIX_WIFI "wlan"
+#define NETIF_NAME_PREFIX_BT "bt"
+
+#ifndef LWIP_NETIF_IFINDEX_MAX_EX
+#define LWIP_NETIF_IFINDEX_MAX_EX 255
+#endif
+
+LWIP_STATIC void driverif_get_ifname_prefix(struct netif *netif, char *prefix, int prefixLen)
+{
+ if (prefix == NULL || netif == NULL) {
+ LWIP_ASSERT("invalid param", 0);
+ return;
+ }
+ switch (netif->link_layer_type) {
+ case ETHERNET_DRIVER_IF:
+ strcpy_s(prefix, prefixLen, NETIF_NAME_PREFIX_ETH);
+ break;
+ case WIFI_DRIVER_IF:
+ strcpy_s(prefix, prefixLen, NETIF_NAME_PREFIX_WIFI);
+ break;
+ case BT_PROXY_IF:
+ strcpy_s(prefix, prefixLen, NETIF_NAME_PREFIX_BT);
+ break;
+ default:
+ LWIP_ASSERT("invalid link_layer_type", 0);
+ break;
+ }
+}
+
+LWIP_STATIC void driverif_init_ifname(struct netif *netif)
+{
+ struct netif *tmpnetif = NULL;
+ char prefix[NETIF_NAME_PREFIX_MAX_LENGTH] = {0};
+
+ driverif_get_ifname_prefix(netif, prefix, NETIF_NAME_PREFIX_MAX_LENGTH);
+ netif->name[0] = prefix[0];
+ netif->name[1] = prefix[1];
+
+ if (netif->full_name[0] != '\0') {
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("netif already has fullname %s\n", netif->full_name));
+ return;
+ }
+ for (int i = 0; i < LWIP_NETIF_IFINDEX_MAX_EX; ++i) {
+ if (snprintf_s(netif->full_name, sizeof(netif->full_name), sizeof(netif->full_name) - 1,
+ "%s%d", prefix, i) < 0) {
+ break;
+ }
+ NETIF_FOREACH(tmpnetif) {
+ if (strcmp(tmpnetif->full_name, netif->full_name) == 0) {
+ break;
+ }
+ }
+ if (tmpnetif == NULL) {
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("set fullname success %s\n", netif->full_name));
+ return;
+ }
+ }
+ netif->full_name[0] = '\0';
+}
+
+/*
+ * This function should do the actual transmission of the packet. The packet is
+ * contained in the pbuf that is passed to the function. This pbuf
+ * might be chained.
+ *
+ * @param netif the lwip network interface structure for this driverif
+ * @param p the MAC packet to send (e.g. IP packet including MAC_addresses and type)
+ * @return ERR_OK if the packet could be sent
+ * an err_t value if the packet couldn't be sent
+ *
+ * @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
+ * strange results. You might consider waiting for space in the DMA queue
+ * to become availale since the stack doesn't retry to send a packet
+ * dropped because of memory failure (except for the TCP timers).
+ */
+
+LWIP_STATIC err_t driverif_output(struct netif *netif, struct pbuf *p)
+{
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_output : send packet pbuf 0x%p of length %"U16_F" through netif 0x%p\n", \
+ (void *)p, p->tot_len, (void *)netif));
+
+#if PF_PKT_SUPPORT
+ if (all_pkt_raw_pcbs != NULL) {
+ p->flags = (u16_t)(p->flags & ~(PBUF_FLAG_LLMCAST | PBUF_FLAG_LLBCAST | PBUF_FLAG_HOST));
+ p->flags |= PBUF_FLAG_OUTGOING;
+ (void)raw_pkt_input(p, netif, NULL);
+ }
+#endif
+
+#if ETH_PAD_SIZE
+ (void)pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */
+#endif
+
+ netif->drv_send(netif, p);
+
+#if ETH_PAD_SIZE
+ (void)pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
+#endif
+ MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
+ LINK_STATS_INC(link.xmit);
+
+ return ERR_OK;
+}
+
+void driverif_input_proc(struct netif *netif, struct pbuf *p)
+{
+ u16_t ethhdr_type;
+ struct eth_hdr *ethhdr = NULL;
+ err_t ret = ERR_VAL;
+
+ ethhdr = (struct eth_hdr *)p->payload;
+ ethhdr_type = ntohs(ethhdr->type);
+
+ switch (ethhdr_type) {
+ /* IP or ARP packet? */
+ case ETHTYPE_IP:
+ case ETHTYPE_IPV6:
+ case ETHTYPE_ARP:
+#if ETHARP_SUPPORT_VLAN
+ case ETHTYPE_VLAN:
+#endif /* ETHARP_SUPPORT_VLAN */
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet of type %"U16_F"\n", ethhdr_type));
+ /* full packet send to tcpip_thread to process */
+ if (netif->input != NULL) {
+ ret = netif->input(p, netif);
+ }
+
+ if (ret != ERR_OK) {
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input: IP input error\n"));
+ (void)pbuf_free(p);
+ LINK_STATS_INC(link.drop);
+ LINK_STATS_INC(link.link_rx_drop);
+ if (ret == ERR_MEM) {
+ MIB2_STATS_NETIF_INC(netif, ifinoverruns);
+ LINK_STATS_INC(link.link_rx_overrun);
+ }
+ } else {
+ LINK_STATS_INC(link.recv);
+ }
+ break;
+
+ default:
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet is of unsupported type %"U16_F"\n", \
+ ethhdr_type));
+ (void)pbuf_free(p);
+ LINK_STATS_INC(link.drop);
+ LINK_STATS_INC(link.link_rx_drop);
+ break;
+ }
+}
+
+/*
+ * This function should be called by network driver to pass the input packet to LwIP.
+ * Before calling this API, driver has to keep the packet in pbuf structure. Driver has to
+ * call pbuf_alloc() with type as PBUF_RAM to create pbuf structure. Then driver
+ * has to pass the pbuf structure to this API. This will add the pbuf into the TCPIP thread.
+ * Once this packet is processed by TCPIP thread, pbuf will be freed. Driver is not required to
+ * free the pbuf.
+ *
+ * @param netif the lwip network interface structure for this driverif
+ * @param p packet in pbuf structure format
+ */
+void driverif_input(struct netif *netif, struct pbuf *p)
+{
+#if PF_PKT_SUPPORT
+#if (DRIVERIF_DEBUG & LWIP_DBG_OFF)
+ u16_t ethhdr_type;
+ struct eth_hdr* ethhdr = NULL;
+#endif
+ err_t ret = ERR_VAL;
+#endif
+
+ LWIP_ERROR("driverif_input : invalid arguments", ((netif != NULL) && (p != NULL)), return);
+
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : going to receive input packet. netif 0x%p, pbuf 0x%p, \
+ packet_length %"U16_F"\n", (void *)netif, (void *)p, p->tot_len));
+
+ /* points to packet payload, which starts with an Ethernet header */
+ MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
+ if (p->len < SIZEOF_ETH_HDR) {
+ (void)pbuf_free(p);
+ LINK_STATS_INC(link.drop);
+ LINK_STATS_INC(link.link_rx_drop);
+ return;
+ }
+
+#if PF_PKT_SUPPORT
+#if (DRIVERIF_DEBUG & LWIP_DBG_OFF)
+ ethhdr = (struct eth_hdr *)p->payload;
+ ethhdr_type = ntohs(ethhdr->type);
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet of type %"U16_F" netif->input=%p\n", \
+ ethhdr_type, netif->input));
+#endif
+
+ /* full packet send to tcpip_thread to process */
+ if (netif->input) {
+ ret = netif->input(p, netif);
+ }
+ if (ret != ERR_OK) {
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input: IP input error\n"));
+ (void)pbuf_free(p);
+ LINK_STATS_INC(link.drop);
+ LINK_STATS_INC(link.link_rx_drop);
+ if (ret == ERR_MEM) {
+ LINK_STATS_INC(link.link_rx_overrun);
+ }
+ } else {
+ LINK_STATS_INC(link.recv);
+ }
+
+#else
+ driverif_input_proc(netif, p);
+#endif
+
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_input : received packet is processed\n"));
+}
+
+/*
+ * Should be called at the beginning of the program to set up the
+ * network interface. It calls the function low_level_init() to do the
+ * actual setup of the hardware.
+ *
+ * This function should be passed as a parameter to netif_add().
+ *
+ * @param netif the lwip network interface structure for this driverif
+ * @return ERR_OK if the loopif is initialized
+ * ERR_MEM on Allocation Failure
+ * any other err_t on error
+ */
+err_t driverif_init(struct netif *netif)
+{
+ u16_t link_layer_type;
+
+ if (netif == NULL) {
+ return ERR_IF;
+ }
+ link_layer_type = netif->link_layer_type;
+ LWIP_ERROR("driverif_init : invalid link_layer_type in netif", \
+ ((link_layer_type == ETHERNET_DRIVER_IF) \
+ || (link_layer_type == WIFI_DRIVER_IF \
+ || link_layer_type == BT_PROXY_IF)), \
+ return ERR_IF);
+
+ LWIP_ERROR("driverif_init : netif hardware length is greater than maximum supported", \
+ (netif->hwaddr_len <= NETIF_MAX_HWADDR_LEN), return ERR_IF);
+
+ LWIP_ERROR("driverif_init : drv_send is null", (netif->drv_send != NULL), return ERR_IF);
+
+#if LWIP_NETIF_PROMISC
+ LWIP_ERROR("driverif_init : drv_config is null", (netif->drv_config != NULL), return ERR_IF);
+#endif
+
+#if LWIP_NETIF_HOSTNAME
+ /* Initialize interface hostname */
+ netif->hostname = LWIP_NETIF_HOSTNAME_DEFAULT;
+#endif /* LWIP_NETIF_HOSTNAME */
+
+ /*
+ * Initialize the snmp variables and counters inside the struct netif.
+ * The last argument should be replaced with your link speed, in units
+ * of bits per second.
+ */
+ NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, LINK_SPEED_OF_YOUR_NETIF_IN_BPS);
+
+ netif->output = etharp_output;
+ netif->linkoutput = driverif_output;
+
+ /* init the netif's full name */
+ driverif_init_ifname(netif);
+
+ /* maximum transfer unit */
+ netif->mtu = IP_FRAG_MAX_MTU;
+
+ /* device capabilities */
+ /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
+ netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP |
+#if DRIVER_STATUS_CHECK
+ NETIF_FLAG_DRIVER_RDY |
+#endif
+#if LWIP_IGMP
+ NETIF_FLAG_IGMP |
+#endif
+
+ /**
+ @page RFC-2710 RFC-2710
+ @par Compliant Sections
+ Section 5. Node State Transition Diagram
+ @par Behavior Description
+ MLD messages are sent for multicast addresses whose scope is 2
+ (link-local), including Solicited-Node multicast addresses.\n
+ Behavior:Stack will send MLD6 report /Done to solicited node multicast address
+ if the LWIP_MLD6_ENABLE_MLD_ON_DAD is enabled. By default, this is disabled.
+ */
+ /* Enable sending MLD report /done for solicited address during neighbour discovery */
+#if LWIP_IPV6 && LWIP_IPV6_MLD
+#if LWIP_MLD6_ENABLE_MLD_ON_DAD
+ NETIF_FLAG_MLD6 |
+#endif /* LWIP_MLD6_ENABLE_MLD_ON_DAD */
+#endif
+ NETIF_FLAG_LINK_UP;
+
+#if DRIVER_STATUS_CHECK
+ netif->waketime = -1;
+#endif /* DRIVER_STATUS_CHECK */
+ LWIP_DEBUGF(DRIVERIF_DEBUG, ("driverif_init : Initialized netif 0x%p\n", (void *)netif));
+ return ERR_OK;
+}
diff --git a/components/net/lwip-2.1/porting/src/lwip_init.c b/components/net/lwip-2.1/porting/src/lwip_init.c
new file mode 100644
index 00000000..88e7ed81
--- /dev/null
+++ b/components/net/lwip-2.1/porting/src/lwip_init.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+#include
+#include "lwip/tcpip.h"
+#include "ohos_init.h"
+void TcpIpPortingInit()
+{
+ tcpip_init(NULL, NULL);
+}
+SYSEX_SERVICE_INIT(TcpIpPortingInit);
diff --git a/components/net/lwip-2.1/porting/src/netdb_porting.c b/components/net/lwip-2.1/porting/src/netdb_porting.c
new file mode 100644
index 00000000..df905f71
--- /dev/null
+++ b/components/net/lwip-2.1/porting/src/netdb_porting.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "netdb.h"
+
+struct hostent *gethostbyname(const char *name)
+{
+ if (name == NULL) {
+ return NULL;
+ }
+ return lwip_gethostbyname(name);
+}
\ No newline at end of file
diff --git a/components/net/lwip-2.1/porting/src/sockets_porting.c b/components/net/lwip-2.1/porting/src/sockets_porting.c
new file mode 100644
index 00000000..32deb8fd
--- /dev/null
+++ b/components/net/lwip-2.1/porting/src/sockets_porting.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip/priv/sockets_priv.h"
+#include
+
+#if !LWIP_COMPAT_SOCKETS
+
+#define CHECK_NULL_PTR(ptr) do { if ((ptr) == NULL) { set_errno(EFAULT); return -1; } } while (0)
+
+int accept(int s, struct sockaddr *addr, socklen_t *addrlen)
+{
+ return lwip_accept(s, addr, addrlen);
+}
+
+int bind(int s, const struct sockaddr *name, socklen_t namelen)
+{
+ CHECK_NULL_PTR(name);
+ if (namelen < sizeof(*name)) {
+ set_errno(EINVAL);
+ return -1;
+ }
+ return lwip_bind(s, name, namelen);
+}
+
+int shutdown(int s, int how)
+{
+ return lwip_shutdown(s, how);
+}
+
+int getpeername(int s, struct sockaddr *name, socklen_t *namelen)
+{
+ CHECK_NULL_PTR(name);
+ CHECK_NULL_PTR(namelen);
+ return lwip_getpeername(s, name, namelen);
+}
+
+int getsockname(int s, struct sockaddr *name, socklen_t *namelen)
+{
+ CHECK_NULL_PTR(name);
+ CHECK_NULL_PTR(namelen);
+ return lwip_getsockname(s, name, namelen);
+}
+
+int getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
+{
+ return lwip_getsockopt(s, level, optname, optval, optlen);
+}
+
+int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
+{
+ return lwip_setsockopt(s, level, optname, optval, optlen);
+}
+
+int closesocket(int s)
+{
+ return lwip_close(s);
+}
+
+int connect(int s, const struct sockaddr *name, socklen_t namelen)
+{
+ CHECK_NULL_PTR(name);
+ if (namelen < sizeof(*name)) {
+ set_errno(EINVAL);
+ return -1;
+ }
+ return lwip_connect(s, name, namelen);
+}
+
+int listen(int s, int backlog)
+{
+ return lwip_listen(s, backlog);
+}
+
+ssize_t recv(int s, void *mem, size_t len, int flags)
+{
+ CHECK_NULL_PTR(mem);
+ return lwip_recv(s, mem, len, flags);
+}
+
+ssize_t recvfrom(int s, void *mem, size_t len, int flags,
+ struct sockaddr *from, socklen_t *fromlen)
+{
+ CHECK_NULL_PTR(mem);
+ return lwip_recvfrom(s, mem, len, flags, from, fromlen);
+}
+
+ssize_t recvmsg(int s, struct msghdr *message, int flags)
+{
+ CHECK_NULL_PTR(message);
+ if (message->msg_iovlen) {
+ CHECK_NULL_PTR(message->msg_iov);
+ }
+ return lwip_recvmsg(s, message, flags);
+}
+
+ssize_t send(int s, const void *dataptr, size_t size, int flags)
+{
+ CHECK_NULL_PTR(dataptr);
+ return lwip_send(s, dataptr, size, flags);
+}
+
+ssize_t sendmsg(int s, const struct msghdr *message, int flags)
+{
+ return lwip_sendmsg(s, message, flags);
+}
+
+ssize_t sendto(int s, const void *dataptr, size_t size, int flags,
+ const struct sockaddr *to, socklen_t tolen)
+{
+ CHECK_NULL_PTR(dataptr);
+ if (to && tolen < sizeof(*to)) {
+ set_errno(EINVAL);
+ return -1;
+ }
+ return lwip_sendto(s, dataptr, size, flags, to, tolen);
+}
+
+int socket(int domain, int type, int protocol)
+{
+ return lwip_socket(domain, type, protocol);
+}
+
+const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
+{
+ return lwip_inet_ntop(af, src, dst, size);
+}
+
+int inet_pton(int af, const char *src, void *dst)
+{
+ return lwip_inet_pton(af, src, dst);
+}
+
+int ioctlsocket(int s, long cmd, void *argp)
+{
+ return lwip_ioctl(s, cmd, argp);
+}
+
+#if LWIP_SOCKET_SELECT
+int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout)
+{
+ return lwip_select(maxfdp1, readset, writeset, exceptset, timeout);
+}
+#endif
+
+#if LWIP_SOCKET_POLL
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
+{
+ return lwip_poll(fds, nfds, timeout);
+}
+#endif
+
+#endif /* !LWIP_COMPAT_SOCKETS */
\ No newline at end of file
diff --git a/components/net/lwip-2.1/porting/src/sys_arch.c b/components/net/lwip-2.1/porting/src/sys_arch.c
new file mode 100755
index 00000000..1c1ae6f3
--- /dev/null
+++ b/components/net/lwip-2.1/porting/src/sys_arch.c
@@ -0,0 +1,342 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "cmsis_os2.h"
+#include
+#include
+
+#define YES 1
+#define NO 0
+#define LOSCFG_KERNEL_SMP NO
+
+#if (LOSCFG_KERNEL_SMP == YES)
+SPIN_LOCK_INIT(arch_protect_spin);
+static u32_t lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
+static int lwprot_count = 0;
+#endif /* LOSCFG_KERNEL_SMP == YES */
+
+#define ROUND_UP_DIV(val, div) (((val) + (div) - 1) / (div))
+#define LWIP_LOG_BUF_SIZE 64
+
+/**
+ * Thread and System misc
+ */
+sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio)
+{
+ UINT32 taskID = LOS_ERRNO_TSK_ID_INVALID;
+ UINT32 ret;
+ TSK_INIT_PARAM_S task = {0};
+
+ /* Create host Task */
+ task.pfnTaskEntry = (TSK_ENTRY_FUNC)thread;
+ task.uwStackSize = stackSize;
+ task.pcName = (char *)name;
+ task.usTaskPrio = prio;
+ task.uwArg = (UINTPTR)arg;
+ task.uwResved = LOS_TASK_STATUS_DETACHED;
+ ret = LOS_TaskCreate(&taskID, &task);
+ if (ret != LOS_OK) {
+ LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: LOS_TaskCreate error %u\n", ret));
+ return -1;
+ }
+
+ return taskID;
+}
+
+void sys_init(void)
+{
+ /* set rand seed to make random sequence diff on every startup */
+ UINT32 seedhsb, seedlsb;
+ HalGetCpuCycle(&seedhsb, &seedlsb);
+ srand(seedlsb);
+}
+
+u32_t sys_now(void)
+{
+ /* Lwip docs mentioned like wraparound is not a problem in this funtion */
+ return (u32_t)osKernelGetTickCount();
+}
+
+/**
+ * Protector
+ */
+sys_prot_t sys_arch_protect(void)
+{
+#if (LOSCFG_KERNEL_SMP == YES)
+ /* Note that we are using spinlock instead of mutex for LiteOS-SMP here:
+ * 1. spinlock is more effective for short critical region protection.
+ * 2. this function is called only in task context, not in interrupt handler.
+ * so it's not needed to disable interrupt.
+ */
+ if (lwprot_thread != LOS_CurTaskIDGet()) {
+ /* We are locking the spinlock where it has not been locked before
+ * or is being locked by another thread */
+ LOS_SpinLock(&arch_protect_spin);
+ lwprot_thread = LOS_CurTaskIDGet();
+ lwprot_count = 1;
+ } else {
+ /* It is already locked by THIS thread */
+ lwprot_count++;
+ }
+#else
+ LOS_TaskLock();
+#endif /* LOSCFG_KERNEL_SMP == YES */
+ return 0; /* return value is unused */
+}
+
+void sys_arch_unprotect(sys_prot_t pval)
+{
+ LWIP_UNUSED_ARG(pval);
+#if (LOSCFG_KERNEL_SMP == YES)
+ if (lwprot_thread == LOS_CurTaskIDGet()) {
+ lwprot_count--;
+ if (lwprot_count == 0) {
+ lwprot_thread = LOS_ERRNO_TSK_ID_INVALID;
+ LOS_SpinUnlock(&arch_protect_spin);
+ }
+ }
+#else
+ LOS_TaskUnlock();
+#endif /* LOSCFG_KERNEL_SMP == YES */
+}
+
+/**
+ * MessageBox
+ */
+err_t sys_mbox_new(sys_mbox_t *mbox, int size)
+{
+ CHAR qName[] = "lwIP";
+ UINT32 ret = LOS_QueueCreate(qName, (UINT16)size, mbox, 0, sizeof(void *));
+ switch (ret) {
+ case LOS_OK:
+ return ERR_OK;
+ case LOS_ERRNO_QUEUE_CB_UNAVAILABLE:
+ case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY:
+ return ERR_MEM;
+ default:
+ break;
+ }
+ LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueCreate error %u\n", __FUNCTION__, ret));
+ return ERR_ARG;
+}
+
+void sys_mbox_post(sys_mbox_t *mbox, void *msg)
+{
+ /* Caution: the second parameter is NOT &msg */
+ UINT32 ret = LOS_QueueWrite(*mbox, msg, sizeof(char *), LOS_WAIT_FOREVER);
+ if (ret != LOS_OK) {
+ LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueWrite error %u\n", __FUNCTION__, ret));
+ }
+}
+
+err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
+{
+ /* Caution: the second parameter is NOT &msg */
+ UINT32 ret = LOS_QueueWrite(*mbox, msg, sizeof(char *), 0);
+ switch (ret) {
+ case LOS_OK:
+ return ERR_OK;
+ case LOS_ERRNO_QUEUE_ISFULL:
+ return ERR_MEM;
+ default:
+ break;
+ }
+ LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueWrite error %u\n", __FUNCTION__, ret));
+ return ERR_ARG;
+}
+
+err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg);
+
+u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeoutMs)
+{
+ void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
+ UINT64 tick = ROUND_UP_DIV((UINT64)timeoutMs * LOSCFG_BASE_CORE_TICK_PER_SECOND, OS_SYS_MS_PER_SECOND);
+ UINT32 ret = LOS_QueueRead(*mbox, msg ? msg : &ignore, sizeof(void *), tick ? (UINT32)tick : LOS_WAIT_FOREVER);
+ switch (ret) {
+ case LOS_OK:
+ return ERR_OK;
+ case LOS_ERRNO_QUEUE_ISEMPTY:
+ case LOS_ERRNO_QUEUE_TIMEOUT:
+ return SYS_ARCH_TIMEOUT;
+ default:
+ break;
+ }
+ LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueRead error %u\n", __FUNCTION__, ret));
+ return SYS_ARCH_TIMEOUT; /* Errors should be treated as timeout */
+}
+
+u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
+{
+ void *ignore = 0; /* if msg==NULL, the fetched msg should be dropped */
+ UINT32 ret = LOS_QueueRead(*mbox, msg ? msg : &ignore, sizeof(void *), 0);
+ switch (ret) {
+ case LOS_OK:
+ return ERR_OK;
+ case LOS_ERRNO_QUEUE_ISEMPTY:
+ return SYS_MBOX_EMPTY;
+ case LOS_ERRNO_QUEUE_TIMEOUT:
+ return SYS_ARCH_TIMEOUT;
+ default:
+ break;
+ }
+ LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_QueueRead error %u\n", __FUNCTION__, ret));
+ return SYS_MBOX_EMPTY; /* Errors should be treated as timeout */
+}
+
+void sys_mbox_free(sys_mbox_t *mbox)
+{
+ (void)LOS_QueueDelete(*mbox);
+}
+
+int sys_mbox_valid(sys_mbox_t *mbox)
+{
+ QUEUE_INFO_S queueInfo;
+ return LOS_OK == LOS_QueueInfoGet(*mbox, &queueInfo);
+}
+
+void sys_mbox_set_invalid(sys_mbox_t *mbox)
+{
+ *mbox = LOSCFG_BASE_IPC_QUEUE_LIMIT;
+}
+
+/**
+ * Semaphore
+ */
+err_t sys_sem_new(sys_sem_t *sem, u8_t count)
+{
+ UINT32 ret = LOS_SemCreate(count, sem);
+ if (ret != LOS_OK) {
+ return ERR_ARG;
+ }
+
+ return ERR_OK;
+}
+
+void sys_sem_signal(sys_sem_t *sem)
+{
+ (void)LOS_SemPost(*sem);
+}
+
+u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeoutMs)
+{
+ UINT64 tick = ROUND_UP_DIV((UINT64)timeoutMs * LOSCFG_BASE_CORE_TICK_PER_SECOND, OS_SYS_MS_PER_SECOND);
+ UINT32 ret = LOS_SemPend(*sem, tick ? (UINT32)tick : LOS_WAIT_FOREVER); // timeoutMs 0 means wait forever
+ switch (ret) {
+ case LOS_OK:
+ return ERR_OK;
+ case LOS_ERRNO_SEM_TIMEOUT:
+ return SYS_ARCH_TIMEOUT;
+ default:
+ break;
+ }
+ LWIP_DEBUGF(SYS_DEBUG, ("%s: LOS_SemPend error %u\n", __FUNCTION__, ret));
+ return SYS_ARCH_TIMEOUT; /* Errors should be treated as timeout */
+}
+
+void sys_sem_free(sys_sem_t *sem)
+{
+ (void)LOS_SemDelete(*sem);
+}
+
+int sys_sem_valid(sys_sem_t *sem)
+{
+ return *sem != LOSCFG_BASE_IPC_SEM_LIMIT;
+}
+
+void sys_sem_set_invalid(sys_sem_t *sem)
+{
+ *sem = LOSCFG_BASE_IPC_SEM_LIMIT;
+}
+
+/**
+ * Mutex
+ */
+err_t sys_mutex_new(sys_mutex_t *mutex)
+{
+ UINT32 ret = LOS_MuxCreate(mutex);
+ if (ret != LOS_OK) {
+ return ERR_ARG;
+ }
+
+ return ERR_OK;
+}
+
+void sys_mutex_lock(sys_mutex_t *mutex)
+{
+ (void)LOS_MuxPend(*mutex, LOS_WAIT_FOREVER);
+}
+
+void sys_mutex_unlock(sys_mutex_t *mutex)
+{
+ (void)LOS_MuxPost(*mutex);
+}
+
+void sys_mutex_free(sys_mutex_t *mutex)
+{
+ (void)LOS_MuxDelete(*mutex);
+}
+
+int sys_mutex_valid(sys_mutex_t *mutex)
+{
+ return *mutex != LOSCFG_BASE_IPC_MUX_LIMIT;
+}
+
+void sys_mutex_set_invalid(sys_mutex_t *mutex)
+{
+ *mutex = LOSCFG_BASE_IPC_MUX_LIMIT;
+}
+
+void HilogPrintf(const char *fmt, ...)
+{
+ if ((fmt == NULL) || (strlen(fmt) == 0)) {
+ return;
+ }
+
+ int len;
+ char buf[LWIP_LOG_BUF_SIZE] = {0};
+ va_list ap;
+ va_start(ap, fmt);
+ len = vsprintf_s(buf, sizeof(buf) - 1, fmt, ap);
+ va_end(ap);
+ if (len < 0) {
+ HILOG_INFO(HILOG_MODULE_APP, "log param invalid or buf is not enough.");
+ return;
+ }
+ HILOG_INFO(HILOG_MODULE_APP, buf);
+}
diff --git a/components/net/test/lwip_test.h b/components/net/test/lwip_test.h
new file mode 100644
index 00000000..a873a59d
--- /dev/null
+++ b/components/net/test/lwip_test.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LWIP_TEST_H
+#define LWIP_TEST_H
+
+#include
+#include "log.h"
+#include "securec.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int g_testCase;
+extern int g_testError;
+extern int g_testTemp;
+#define LWIP_TEST_RET_OK 0
+#define LWIP_TEST_RET_ERR 1
+
+#define LOCALHOST "127.0.0.1"
+#define STACK_IP LOCALHOST
+#define STACK_PORT 2277
+#define PEER_PORT STACK_PORT
+#define SERVER_PORT STACK_PORT
+#define CLIENT_PORT 2288
+#define PEER_IP LOCALHOST
+#define BUF_SIZE (128 * 1)
+#define IOV_LENGTH 2
+#define STACK_TEST_SIZE (0x800UL)
+
+#define ICUNIT_ASSERT_NOT_EQUAL(a, b, c) if ((a) == (b)) { \
+ g_testError = (c); \
+ LWIP_ASSERT("lwip test", 0); \
+ }
+#define ICUNIT_ASSERT_EQUAL(a, b, c) if ((a) != (b)) { \
+ g_testError = (c); \
+ LWIP_ASSERT("lwip test", 0); \
+ }
+
+#define LogPrintln(fmt, ...) \
+ HILOG_INFO(HILOG_MODULE_APP, fmt "%c", \
+ ##__VA_ARGS__, \
+ ('\n' == " "fmt[sizeof(" "fmt)-2]) ? '\0' : '\n') // trailing newline is auto appended
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LWIP_TEST_H */
diff --git a/components/net/test/net_socket_test_001.c b/components/net/test/net_socket_test_001.c
new file mode 100644
index 00000000..a92e9ba2
--- /dev/null
+++ b/components/net/test/net_socket_test_001.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+
+#define TEST_CASE 110
+
+int SocketTest(void)
+{
+ LogPrintln("net_socket_test_001.c enter");
+ g_testCase = TEST_CASE;
+ int fd = socket(0, 0, 0);
+ LWIP_ASSERT("socket invalid param.", fd == -1);
+ return LWIP_TEST_RET_OK;
+}
diff --git a/components/net/test/net_socket_test_002.c b/components/net/test/net_socket_test_002.c
new file mode 100644
index 00000000..7abdfb13
--- /dev/null
+++ b/components/net/test/net_socket_test_002.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+
+#define MSG "Hi, I am UDP"
+#define TEST_CASE 120
+
+static char g_buf[BUF_SIZE + 1] = { 0 };
+
+int UdpTest(void)
+{
+ LogPrintln("net_socket_test_002.c enter");
+ g_testCase = TEST_CASE;
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ int ret;
+ struct msghdr msg = { 0 };
+ struct iovec iov[IOV_LENGTH] = { 0 };
+ int recvCount = 0;
+
+ /* socket creation */
+ sfd = socket(AF_INET, SOCK_DGRAM, 0);
+ LWIP_ASSERT("socket invalid param.", sfd != -1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT);
+ ret = bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LWIP_ASSERT("socket invalid param.", ret == 0);
+
+ /* send */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), MSG);
+ ret = sendto(sfd, g_buf, strlen(MSG), 0, (struct sockaddr*)&clnAddr,
+ (socklen_t)sizeof(clnAddr));
+ LWIP_ASSERT("socket invalid param.", ret != -1);
+
+ ret = ioctlsocket(sfd, FIONREAD, &recvCount);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 1);
+ LogPrintln("udp recv count %d", recvCount);
+
+ /* recv */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ ret = recvfrom(sfd, g_buf, sizeof(g_buf), 0, (struct sockaddr*)&clnAddr,
+ &clnAddrLen);
+ LWIP_ASSERT("socket invalid param.", ret == strlen(MSG));
+
+ /* sendmsg */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), MSG);
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = IOV_LENGTH;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = strlen(MSG);
+ iov[1].iov_base = g_buf;
+ iov[1].iov_len = strlen(MSG);
+ ret = sendmsg(sfd, &msg, 0);
+ LWIP_ASSERT("socket invalid param.", ret == IOV_LENGTH * strlen(MSG));
+
+ /* recvmsg */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)memset_s(&msg, sizeof(msg), 0, sizeof(msg));
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = sizeof(g_buf);
+ ret = recvmsg(sfd, &msg, 0);
+ LWIP_ASSERT("socket invalid param.", ret == IOV_LENGTH * strlen(MSG));
+
+ /* close socket */
+ ret = closesocket(sfd);
+ LWIP_ASSERT("socket invalid param.", ret != -1);
+ return LWIP_TEST_RET_OK;
+}
+
diff --git a/components/net/test/net_socket_test_003.c b/components/net/test/net_socket_test_003.c
new file mode 100644
index 00000000..120d5822
--- /dev/null
+++ b/components/net/test/net_socket_test_003.c
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include "lwipopts.h"
+#include
+#include
+
+#define SRV_MSG "Hi, I am TCP server"
+#define CLI_MSG "Hi, I am TCP client"
+#define TEST_CASE 130
+
+static char g_buf[BUF_SIZE + 1] = { 0 };
+extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio);
+
+static int SampleTcpServer()
+{
+ g_testCase++;
+ int sfd, lsfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ struct msghdr msg = { 0 };
+ struct iovec iov[IOV_LENGTH] = { 0 };
+ int ret;
+
+ /* tcp server */
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create server socket inet stream: %d", lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, 1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT);
+ ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("bind socket %d to %s:%d: %d", lsfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+
+ ret = listen(lsfd, 0);
+ LogPrintln("listen socket %d: %d", lsfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 3);
+
+ sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
+ LogPrintln("accept socket %d: %d <%s:%d>", lsfd, sfd, inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 4);
+
+ /* send */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), SRV_MSG);
+ ret = send(sfd, g_buf, strlen(SRV_MSG), 0);
+ LogPrintln("server send on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), 5);
+
+ /* recv */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ ret = recv(sfd, g_buf, sizeof(g_buf), 0);
+ LogPrintln("server recv on socket %d: %d", sfd, ret);
+ LogPrintln("ser:%s", g_buf);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), 6);
+
+ /* sendmsg */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), SRV_MSG);
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = IOV_LENGTH;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = strlen(SRV_MSG);
+ iov[1].iov_base = g_buf;
+ iov[1].iov_len = strlen(SRV_MSG);
+ ret = sendmsg(sfd, &msg, 0);
+ LogPrintln("sendmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, IOV_LENGTH * strlen(SRV_MSG), 7);
+
+ /* recvmsg */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)memset_s(&msg, sizeof(msg), 0, sizeof(msg));
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = sizeof(g_buf);
+ ret = recvmsg(sfd, &msg, 0);
+ LogPrintln("recvmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, IOV_LENGTH * strlen(CLI_MSG), 8);
+
+ ret = shutdown(sfd, SHUT_RDWR);
+ LogPrintln("shutdown socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 9);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 10);
+ ret = closesocket(lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 11);
+
+ return 0;
+}
+
+static int SampleTcpClient()
+{
+ g_testCase++;
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ int ret;
+ struct msghdr msg = { 0 };
+ struct iovec iov[IOV_LENGTH] = { 0 };
+ struct sockaddr addr;
+ socklen_t addrLen = sizeof(addr);
+
+ /* tcp client connection */
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create client socket inet stream: %d", sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 10);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ srvAddr.sin_port = htons(PEER_PORT);
+ ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("connect socket %d to %s:%d: %d", sfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 11);
+
+ /* test getpeername */
+ ret = getpeername(sfd, &addr, &addrLen);
+ LogPrintln("getpeername %d %s:%d: %d", \
+ sfd, inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr), ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 12);
+ ICUNIT_ASSERT_EQUAL(addrLen, sizeof(struct sockaddr_in), 13);
+ ICUNIT_ASSERT_EQUAL(((struct sockaddr_in*)&addr)->sin_addr.s_addr, \
+ inet_addr(PEER_IP), 14);
+
+ /* test getsockname */
+ ret = getsockname(sfd, &addr, &addrLen);
+ LogPrintln("getsockname %d %s:%d: %d", \
+ sfd, inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr), ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 15);
+ ICUNIT_ASSERT_EQUAL(addrLen, sizeof(struct sockaddr_in), 16);
+ ICUNIT_ASSERT_EQUAL(((struct sockaddr_in*)&addr)->sin_addr.s_addr, \
+ inet_addr(STACK_IP), 17);
+
+ /* send */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), CLI_MSG);
+ ret = send(sfd, g_buf, strlen(CLI_MSG), 0);
+ LogPrintln("client send on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), 18);
+
+ /* recv */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ ret = recv(sfd, g_buf, sizeof(g_buf), 0);
+ LogPrintln("client recv on socket %d: %d", sfd, ret);
+ LogPrintln("cli:%s", g_buf);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), 19);
+
+ /* sendmsg */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), CLI_MSG);
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = IOV_LENGTH;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = strlen(CLI_MSG);
+ iov[1].iov_base = g_buf;
+ iov[1].iov_len = strlen(CLI_MSG);
+ ret = sendmsg(sfd, &msg, 0);
+ LogPrintln("sendmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 2 * strlen(CLI_MSG), 20);
+
+ /* recvmsg */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)memset_s(&msg, sizeof(msg), 0, sizeof(msg));
+ msg.msg_name = &clnAddr;
+ msg.msg_namelen = sizeof(clnAddr);
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+ iov[0].iov_base = g_buf;
+ iov[0].iov_len = sizeof(g_buf);
+ ret = recvmsg(sfd, &msg, 0);
+ LogPrintln("recvmsg on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, IOV_LENGTH * strlen(SRV_MSG), 21);
+
+ ret = shutdown(sfd, SHUT_RDWR);
+ LogPrintln("shutdown socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 22);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+ return 0;
+}
+
+static void TcpServerRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpServer();
+}
+
+static void TcpClientRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpClient();
+}
+
+void TcpTest()
+{
+ LogPrintln("net_socket_test_003.c enter");
+ g_testCase = TEST_CASE;
+ int ret;
+ ret = sys_thread_new("tcp_server", TcpServerRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+
+ ret = sys_thread_new("tcp_client", TcpClientRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 24);
+}
diff --git a/components/net/test/net_socket_test_004.c b/components/net/test/net_socket_test_004.c
new file mode 100644
index 00000000..e1a84101
--- /dev/null
+++ b/components/net/test/net_socket_test_004.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+
+#define TEST_CASE 140
+#define OPT_TIMEOUT 1000
+
+int SockOptTest()
+{
+ LogPrintln("net_socket_test_004.c enter");
+ g_testCase = TEST_CASE;
+ int ret, error, flag;
+ struct timeval timeout;
+ socklen_t len;
+
+ int fd = socket(AF_INET, SOCK_STREAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(fd, -1, 1);
+
+ error = -1;
+ len = sizeof(error);
+ ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
+ LogPrintln("getsockopt(%d, SOL_SOCKET, SO_ERROR, &error, &len)=%d, error=%d, len=%d, errno=%d", \
+ fd, ret, error, len, errno);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+ ICUNIT_ASSERT_EQUAL(error, 0, 3);
+
+ len = sizeof(timeout);
+ ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 4);
+
+ timeout.tv_sec = OPT_TIMEOUT;
+ len = sizeof(timeout);
+ ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 5);
+
+ (void)memset_s(&timeout, len, 0, len);
+ ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 6);
+ ICUNIT_ASSERT_EQUAL(timeout.tv_sec, OPT_TIMEOUT, 7);
+
+ error = -1;
+ len = sizeof(error);
+ ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
+ LogPrintln("getsockopt(%d, SOL_SOCKET, SO_ERROR, &error, &len)=%d, error=%d, len=%d, errno=%d", \
+ fd, ret, error, len, errno);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 8);
+ ICUNIT_ASSERT_EQUAL(error, 0, 9);
+
+ flag = 1;
+ ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
+ LogPrintln("setsockopt(TCP_NODELAY) ret=%d", ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 10);
+
+ ret = closesocket(fd);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 11);
+
+ return LWIP_TEST_RET_OK;
+}
diff --git a/components/net/test/net_socket_test_005.c b/components/net/test/net_socket_test_005.c
new file mode 100644
index 00000000..c7ec4289
--- /dev/null
+++ b/components/net/test/net_socket_test_005.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+
+#define TEST_CASE 150
+
+int ByteOrderTest(void)
+{
+ LogPrintln("net_socket_test_005.c enter");
+#if BYTE_ORDER == LITTLE_ENDIAN
+ g_testCase = TEST_CASE + 1;
+ uint32_t hl = ntohl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(hl, 0x78563412, 1);
+
+ uint32_t nl = htonl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(nl, 0x78563412, 2);
+
+ uint16_t hs = ntohs(0x1234);
+ ICUNIT_ASSERT_EQUAL(hs, 0x3412, 3);
+
+ uint16_t ns = htons(0x1234);
+ ICUNIT_ASSERT_EQUAL(ns, 0x3412, 4);
+#else
+ g_testCase = TEST_CASE;
+ uint32_t hl = ntohl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(hl, 0x12345678, 5);
+
+ uint32_t nl = htonl(0x12345678);
+ ICUNIT_ASSERT_EQUAL(nl, 0x12345678, 6);
+
+ uint16_t hs = ntohs(0x1234);
+ ICUNIT_ASSERT_EQUAL(hs, 0x1234, 7);
+
+ uint16_t ns = htons(0x1234);
+ ICUNIT_ASSERT_EQUAL(ns, 0x1234, 8);
+#endif
+ return LWIP_TEST_RET_OK;
+}
diff --git a/components/net/test/net_socket_test_006.c b/components/net/test/net_socket_test_006.c
new file mode 100644
index 00000000..59a2789b
--- /dev/null
+++ b/components/net/test/net_socket_test_006.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+
+#define TEST_CASE 160
+#define TEMP_BUF_SIZE 32
+int InetTest()
+{
+ LogPrintln("net_socket_test_006.c enter");
+ g_testCase = TEST_CASE;
+ struct in_addr in;
+ int ret = inet_pton(AF_INET, "300.10.10.10", &in);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 1);
+
+ ret = inet_pton(AF_INET, "10.11.12.13", &in);
+ ICUNIT_ASSERT_EQUAL(ret, 1, 2);
+#if BYTE_ORDER == LITTLE_ENDIAN
+ g_testCase++;
+ ICUNIT_ASSERT_EQUAL(in.s_addr, 0x0d0c0b0a, 3);
+#else
+ ICUNIT_ASSERT_EQUAL(in.s_addr, 0x0a0b0c0d, 4);
+#endif
+
+ const char *p = inet_ntoa(in);
+ ICUNIT_ASSERT_EQUAL(strcmp(p, "10.11.12.13"), 0, 5);
+
+ char buf[TEMP_BUF_SIZE];
+ p = inet_ntop(AF_INET, &in, buf, sizeof(buf));
+ ICUNIT_ASSERT_EQUAL(p, buf, 6);
+ ICUNIT_ASSERT_EQUAL(strcmp(p, "10.11.12.13"), 0, 7);
+
+ return LWIP_TEST_RET_OK;
+}
diff --git a/components/net/test/net_socket_test_007.c b/components/net/test/net_socket_test_007.c
new file mode 100644
index 00000000..70845d1f
--- /dev/null
+++ b/components/net/test/net_socket_test_007.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include "lwipopts.h"
+#include
+#include
+
+static char g_buf[BUF_SIZE + 1] = { 0 };
+static char g_buf_temp[BUF_SIZE + 1] = { 0 };
+
+#define SEND_UDP_COUNT 10000 // send count
+#define TEST_CASE 170
+
+extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio);
+static void UdpTestMoreTask(void *p)
+{
+ (void)p;
+ LogPrintln("net_socket_test_007.c enter");
+ if (g_testCase < TEST_CASE) {
+ g_testCase = TEST_CASE;
+ } else {
+ g_testCase++;
+ }
+
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ int ret;
+ int i;
+
+ /* socket creation */
+ sfd = socket(AF_INET, SOCK_DGRAM, 0);
+ LWIP_ASSERT("socket invalid param.", sfd != -1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT);
+ ret = bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LWIP_ASSERT("socket invalid param.", ret == 0);
+
+ /* send */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ clnAddr.sin_port = htons(PEER_PORT);
+ if (g_buf_temp[0] == '\0') {
+ for (i = 0; i < BUF_SIZE; i++) {
+ g_buf_temp[i] = 'U';
+ }
+ g_buf_temp[BUF_SIZE] = '\0';
+ }
+
+ LogPrintln("udp begin send");
+ for (i = 0; i < SEND_UDP_COUNT; i++) {
+ ret = memcpy_s(g_buf, sizeof(g_buf), g_buf_temp, sizeof(g_buf_temp));
+ ICUNIT_ASSERT_EQUAL(ret, EOK, 1);
+ ret = sendto(sfd, g_buf, BUF_SIZE, 0, (struct sockaddr*)&clnAddr, (socklen_t)sizeof(clnAddr));
+ LWIP_ASSERT("socket invalid param.", ret != -1);
+
+ /* recv */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ ret = recvfrom(sfd, g_buf, sizeof(g_buf), 0, (struct sockaddr*)&clnAddr,
+ &clnAddrLen);
+ LWIP_ASSERT("socket invalid param.", ret == BUF_SIZE);
+ }
+ LogPrintln("udp end send");
+
+ /* close socket */
+ ret = closesocket(sfd);
+ LWIP_ASSERT("socket invalid param.", ret != -1);
+}
+
+void UdpTestMore()
+{
+ int ret;
+ ret = sys_thread_new("udp_more", UdpTestMoreTask, NULL,
+ STACK_TEST_SIZE * 2, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 10);
+}
+
diff --git a/components/net/test/net_socket_test_008.c b/components/net/test/net_socket_test_008.c
new file mode 100644
index 00000000..6248d53d
--- /dev/null
+++ b/components/net/test/net_socket_test_008.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include "lwipopts.h"
+#include
+#include
+
+#define SEND_TCP_COUNT 1000 // send count
+#define STACK_PORT_8 2288
+#define TEST_CASE 180
+
+static char g_serverSendBuf[BUF_SIZE + 1] = { 0 };
+static char g_clientRecvBuf[BUF_SIZE + 1] = { 0 };
+
+extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio);
+
+static void InitMsgBuf()
+{
+ int i;
+ if (g_serverSendBuf[0] != '\0') {
+ return;
+ }
+ for (i = 0; i < BUF_SIZE; i++) {
+ g_serverSendBuf[i] = 'S';
+ }
+ g_serverSendBuf[BUF_SIZE] = '\0';
+}
+
+static int SampleTcpServer()
+{
+ g_testCase++;
+ int sfd, lsfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ int ret;
+ int i;
+
+ /* tcp server */
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create server socket inet stream: %d", lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, 1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT_8);
+ ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("bind socket %d to %s:%d: %d", lsfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+
+ ret = listen(lsfd, 0);
+ LogPrintln("listen socket %d: %d", lsfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 3);
+
+ sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
+ LogPrintln("accept socket %d: %d <%s:%d>", lsfd, sfd, inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 4);
+
+ for (i = 0; i < SEND_TCP_COUNT; i++) {
+ /* send */
+ ret = send(sfd, g_serverSendBuf, BUF_SIZE, 0);
+ ICUNIT_ASSERT_EQUAL(ret, BUF_SIZE, 5);
+ }
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 7);
+ ret = closesocket(lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 8);
+ return 0;
+}
+
+static int SampleTcpClient()
+{
+ g_testCase++;
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ int ret;
+ int i;
+ struct sockaddr addr;
+ socklen_t addrLen = sizeof(addr);
+ int recvCount = 0;
+
+ /* tcp client connection */
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create client socket inet stream: %d", sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 7);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ srvAddr.sin_port = htons(STACK_PORT_8);
+ ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("connect socket %d to %s:%d: %d", sfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 8);
+
+ /* test getpeername */
+ ret = getpeername(sfd, &addr, &addrLen);
+ LogPrintln("getpeername %d %s:%d: %d",
+ sfd, inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr), ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 9);
+ ICUNIT_ASSERT_EQUAL(addrLen, sizeof(struct sockaddr_in), 10);
+ ICUNIT_ASSERT_EQUAL(((struct sockaddr_in*)&addr)->sin_addr.s_addr, \
+ inet_addr(PEER_IP), 11);
+
+ /* test getsockname */
+ ret = getsockname(sfd, &addr, &addrLen);
+ LogPrintln("getsockname %d %s:%d: %d",
+ sfd, inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr), ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 12);
+ ICUNIT_ASSERT_EQUAL(addrLen, sizeof(struct sockaddr_in), 13);
+ ICUNIT_ASSERT_EQUAL(((struct sockaddr_in*)&addr)->sin_addr.s_addr, \
+ inet_addr(STACK_IP), 14);
+
+ LogPrintln("tcp begin recv");
+ for (i = 0; i < 2 * SEND_TCP_COUNT; i++) {
+ /* recv */
+ (void)memset_s(g_clientRecvBuf, sizeof(g_clientRecvBuf), 0, sizeof(g_clientRecvBuf));
+ ret = recv(sfd, g_clientRecvBuf, BUF_SIZE, 0);
+ recvCount += ret;
+ if (recvCount >= BUF_SIZE * SEND_TCP_COUNT) {
+ LogPrintln("client recv on socket %d: %d, i = %d", sfd, recvCount, i);
+ break;
+ }
+ }
+ ICUNIT_ASSERT_EQUAL(recvCount, BUF_SIZE * SEND_TCP_COUNT, recvCount);
+ LogPrintln("tcp end recv");
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 17);
+ return 0;
+}
+
+static void TcpServerRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpServer();
+}
+
+static void TcpClientRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpClient();
+}
+
+void TcpTestMore()
+{
+ LogPrintln("net_socket_test_008.c enter");
+ if (g_testCase < TEST_CASE) {
+ g_testCase = TEST_CASE;
+ }
+
+ int ret;
+ InitMsgBuf();
+ ret = sys_thread_new("tcp_server_more", TcpServerRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 17);
+
+ ret = sys_thread_new("tcp_client_more", TcpClientRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 18);
+}
diff --git a/components/net/test/net_socket_test_009.c b/components/net/test/net_socket_test_009.c
new file mode 100644
index 00000000..282d1a10
--- /dev/null
+++ b/components/net/test/net_socket_test_009.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include "lwipopts.h"
+#include
+#include
+
+#define SRV_MSG "Hi, I am TCP server"
+#define CLI_MSG "Hi, I am TCP client"
+
+#define TEST_CASE 190
+#define STACK_PORT_9 2299
+#define TIME_OUT 10 // timeout 10s
+
+static char g_buf[BUF_SIZE + 1] = { 0 };
+
+extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio);
+
+static int SampleTcpServer()
+{
+#if LWIP_SOCKET_SELECT
+ g_testCase++;
+ int sfd, lsfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ fd_set fdsr;
+ struct timeval tv;
+ int ret;
+
+ /* tcp server */
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create server socket inet stream: %d", lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, 1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT_9);
+ ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("bind socket %d to %s:%d: %d", lsfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+
+ ret = listen(lsfd, 0);
+ LogPrintln("listen socket %d: %d", lsfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 3);
+
+ FD_ZERO(&fdsr);
+ FD_SET(lsfd, &fdsr);
+ // timeout setting
+ tv.tv_sec = TIME_OUT;
+ tv.tv_usec = 0;
+
+ ret = select(lsfd + 1, &fdsr, NULL, NULL, &tv);
+ if (ret < 0) {
+ LogPrintln("select error");
+ ICUNIT_ASSERT_EQUAL(-1, 0, 4);
+ } else if (ret == 0) {
+ LogPrintln("select timeout");
+ ICUNIT_ASSERT_EQUAL(-1, 0, 5);
+ }
+
+ sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
+ LogPrintln("accept socket %d: %d <%s:%d>", lsfd, sfd, inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 6);
+
+ /* send */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), SRV_MSG);
+ ret = send(sfd, g_buf, strlen(SRV_MSG), 0);
+ LogPrintln("server send on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), 7);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 8);
+ ret = closesocket(lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 9);
+#endif
+ return 0;
+}
+
+static int SampleTcpClient()
+{
+#if LWIP_SOCKET_SELECT
+ g_testCase++;
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ int ret;
+
+ /* tcp client connection */
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create client socket inet stream: %d", sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 10);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ srvAddr.sin_port = htons(STACK_PORT_9);
+ ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("connect socket %d to %s:%d: %d", sfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 11);
+
+ /* recv */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ ret = recv(sfd, g_buf, sizeof(g_buf), 0);
+ LogPrintln("client recv on socket %d: %d", sfd, ret);
+ LogPrintln("cli:%s", g_buf);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), 12);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 13);
+#endif
+ return 0;
+}
+
+static void TcpServerRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpServer();
+}
+
+static void TcpClientRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpClient();
+}
+
+void TcpTestSelect()
+{
+ LogPrintln("net_socket_test_009.c enter");
+ g_testCase = TEST_CASE;
+ int ret;
+ ret = sys_thread_new("tcp_server_select", TcpServerRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+
+ ret = sys_thread_new("tcp_client_select", TcpClientRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 24);
+}
diff --git a/components/net/test/net_socket_test_010.c b/components/net/test/net_socket_test_010.c
new file mode 100644
index 00000000..9b5d8434
--- /dev/null
+++ b/components/net/test/net_socket_test_010.c
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include "lwipopts.h"
+#include
+#include
+
+#define SRV_MSG "Hi, I am TCP server"
+#define CLI_MSG "Hi, I am TCP client"
+
+#define TEST_CASE 200
+#define STACK_PORT_10 2230
+#define POLL_OPEN_MAX 10
+#define TIME_OUT (1000 * 10) // timeout 10s
+static char g_buf[BUF_SIZE + 1] = { 0 };
+
+extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio);
+
+static int SampleTcpServer()
+{
+#if LWIP_SOCKET_POLL
+ g_testCase++;
+ int sfd, lsfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ struct pollfd client[POLL_OPEN_MAX] = {0};
+ int ret;
+
+ /* tcp server */
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create server socket inet stream: %d", lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, 1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT_10);
+ ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("bind socket %d to %s:%d: %d", lsfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+
+ ret = listen(lsfd, 0);
+ LogPrintln("listen socket %d: %d", lsfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 3);
+
+ client[0].fd = lsfd;
+ client[0].events = POLLIN;
+ ret = poll(client, 1, TIME_OUT);
+ if (ret < 0) {
+ LogPrintln("poll error");
+ ICUNIT_ASSERT_EQUAL(-1, 0, 4);
+ } else if (ret == 0) {
+ LogPrintln("poll timeout");
+ ICUNIT_ASSERT_EQUAL(-1, 0, 5);
+ }
+
+ sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
+ LogPrintln("accept socket %d: %d <%s:%d>", lsfd, sfd, inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 6);
+
+ /* recv */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ ret = recv(sfd, g_buf, sizeof(g_buf), 0);
+ LogPrintln("server recv on socket %d: %d", sfd, ret);
+ LogPrintln("ser:%s", g_buf);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), 7);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 8);
+ ret = closesocket(lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 9);
+#endif
+ return 0;
+}
+
+static int SampleTcpClient()
+{
+#if LWIP_SOCKET_POLL
+ g_testCase++;
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ int ret;
+
+ /* tcp client connection */
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+ LogPrintln("create client socket inet stream: %d", sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 10);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ srvAddr.sin_port = htons(STACK_PORT_10);
+ ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LogPrintln("connect socket %d to %s:%d: %d", sfd, inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 11);
+
+ /* send */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), CLI_MSG);
+ ret = send(sfd, g_buf, strlen(CLI_MSG), 0);
+ LogPrintln("client send on socket %d: %d", sfd, ret);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(CLI_MSG), 12);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 13);
+#endif
+ return 0;
+}
+
+static void TcpServerRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpServer();
+}
+
+static void TcpClientRoutine(void *p)
+{
+ (void)p;
+ (void)SampleTcpClient();
+}
+
+void TcpTestPoll()
+{
+ LogPrintln("net_socket_test_010.c enter");
+ g_testCase = TEST_CASE;
+ int ret;
+ ret = sys_thread_new("tcp_server_poll", TcpServerRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+
+ ret = sys_thread_new("tcp_client_poll", TcpClientRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 24);
+}
diff --git a/components/net/test/net_socket_test_011.c b/components/net/test/net_socket_test_011.c
new file mode 100644
index 00000000..e324143b
--- /dev/null
+++ b/components/net/test/net_socket_test_011.c
@@ -0,0 +1,440 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "lwip/prot/iana.h"
+
+#define MSG "Hi, I am testing BT netif."
+#define STACK_IP_BT "192.168.167.1"
+#define PEER_IP_BT "100.100.100.100"
+#define GATEWAY_IP_BT "192.168.167.239"
+#define NETIF_MAC "121212"
+#define PEER_MAC "454545"
+#define NETIF_NAME_BT "bt1000"
+#define TEST_CASE 210
+static char g_buf[BUF_SIZE + 1] = { 0 };
+struct netif *btProxyNf = NULL;
+
+static void ReplayArpTask();
+static void ArpPackageProc(struct netif *netif, struct pbuf *p);
+extern void driverif_input(struct netif *netif, struct pbuf *p);
+static void ReplayArpEncodeEthernet(struct netif *netif, struct pbuf *p);
+
+static void ReplayUdpEncodeEthernet(struct netif *netif, struct pbuf *p)
+{
+ int ret;
+ ret = pbuf_add_header(p, SIZEOF_ETH_HDR);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 1);
+
+ struct eth_hdr *ethhdr;
+ ethhdr = (struct eth_hdr *)p->payload;
+ ethhdr->type = lwip_htons(ETHTYPE_IP);
+ SMEMCPY(ðhdr->dest, NETIF_MAC, ETH_HWADDR_LEN);
+ SMEMCPY(ðhdr->src, PEER_MAC, ETH_HWADDR_LEN);
+
+ driverif_input(netif, p);
+}
+
+static void ReplayUdpEncodeIp(struct pbuf *p, ip4_addr_t *src, ip4_addr_t *dest)
+{
+ struct ip_hdr *iphdr;
+ int ret;
+#if CHECKSUM_GEN_IP_INLINE
+ u32_t chk_sum = 0;
+#endif /* CHECKSUM_GEN_IP_INLINE */
+
+ // ip header
+ ret = pbuf_add_header(p, IP_HLEN);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+ iphdr = (struct ip_hdr *)p->payload;
+ IPH_TTL_SET(iphdr, UDP_TTL);
+ IPH_PROTO_SET(iphdr, IP_PROTO_UDP);
+
+#if CHECKSUM_GEN_IP_INLINE
+ chk_sum += PP_NTOHS(IP_PROTO_UDP | (ttl << 8));
+#endif /* CHECKSUM_GEN_IP_INLINE */
+
+ /* dest cannot be NULL here */
+ ip4_addr_copy(iphdr->dest, *dest);
+#if CHECKSUM_GEN_IP_INLINE
+ chk_sum += ip4_addr_get_u32(&iphdr->dest) & 0xFFFF;
+ chk_sum += ip4_addr_get_u32(&iphdr->dest) >> 16;
+#endif /* CHECKSUM_GEN_IP_INLINE */
+
+ u16_t ip_hlen = IP_HLEN;
+ IPH_VHL_SET(iphdr, 4, ip_hlen / 4);
+ IPH_TOS_SET(iphdr, 0);
+#if CHECKSUM_GEN_IP_INLINE
+ chk_sum += PP_NTOHS(tos | (iphdr->_v_hl << 8));
+#endif /* CHECKSUM_GEN_IP_INLINE */
+ IPH_LEN_SET(iphdr, lwip_htons(p->tot_len));
+#if CHECKSUM_GEN_IP_INLINE
+ chk_sum += iphdr->_len;
+#endif /* CHECKSUM_GEN_IP_INLINE */
+ IPH_OFFSET_SET(iphdr, 0);
+ IPH_ID_SET(iphdr, lwip_htons(0));
+#if CHECKSUM_GEN_IP_INLINE
+ chk_sum += iphdr->_id;
+#endif /* CHECKSUM_GEN_IP_INLINE */
+ ip4_addr_copy(iphdr->src, *src);
+
+#if CHECKSUM_GEN_IP_INLINE
+ chk_sum += ip4_addr_get_u32(&iphdr->src) & 0xFFFF;
+ chk_sum += ip4_addr_get_u32(&iphdr->src) >> 16;
+ chk_sum = (chk_sum >> 16) + (chk_sum & 0xFFFF);
+ chk_sum = (chk_sum >> 16) + chk_sum;
+ chk_sum = ~chk_sum;
+ IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_IP) {
+ iphdr->_chksum = (u16_t)chk_sum; /* network order */
+ }
+#if LWIP_CHECKSUM_CTRL_PER_NETIF
+ else {
+ IPH_CHKSUM_SET(iphdr, 0);
+ }
+#endif /* LWIP_CHECKSUM_CTRL_PER_NETIF */
+#else /* CHECKSUM_GEN_IP_INLINE */
+ IPH_CHKSUM_SET(iphdr, 0);
+#if CHECKSUM_GEN_IP
+ IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_IP) {
+ IPH_CHKSUM_SET(iphdr, inet_chksum(iphdr, ip_hlen));
+ }
+#endif /* CHECKSUM_GEN_IP */
+#endif /* CHECKSUM_GEN_IP_INLINE */
+
+ ReplayUdpEncodeEthernet(btProxyNf, p);
+}
+
+static void ReplayUdp(void *ptemp)
+{
+ struct udp_hdr *udphdr;
+ ip4_addr_t sipaddr, dipaddr;
+ int size = strlen(MSG);
+ int ret;
+ (void)ptemp;
+
+ LogPrintln("encode udp replay packet");
+ inet_pton(AF_INET, PEER_IP_BT, &sipaddr);
+ inet_pton(AF_INET, STACK_IP_BT, &dipaddr);
+
+ struct pbuf *p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM);
+ u16_t chksum = LWIP_CHKSUM_COPY(p->payload, MSG, size);
+
+ // udp header
+ ret = pbuf_add_header(p, UDP_HLEN);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 1);
+ udphdr = (struct udp_hdr *)p->payload;
+ udphdr->src = lwip_htons(STACK_PORT);
+ udphdr->dest = lwip_htons(STACK_PORT);
+ udphdr->len = lwip_htons(p->tot_len);
+ /* in UDP, 0 checksum means 'no checksum' */
+ u16_t udpchksum = ip_chksum_pseudo_partial(p, IP_PROTO_UDP, p->tot_len, UDP_HLEN, &sipaddr, &dipaddr);
+ u32_t acc = udpchksum + (u16_t)~(chksum);
+ udpchksum = FOLD_U32T(acc);
+ if (udpchksum == 0x0000) {
+ udpchksum = 0xffff;
+ }
+ udphdr->chksum = udpchksum;
+ udphdr->chksum = 0;
+
+ ReplayUdpEncodeIp(p, &sipaddr, &dipaddr);
+}
+
+static void ReplayUdpTask()
+{
+ int ret;
+ ret = sys_thread_new("replay_udp", ReplayUdp, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 3);
+}
+
+static void ParsePackageIpUdp(struct netif *netif, struct pbuf *btBuf)
+{
+ // get scr_addr and dest_addr from ip head
+ const struct ip_hdr *iphdr;
+ iphdr = (const struct ip_hdr *)btBuf->payload;
+ ip4_addr_p_t ip4_addr_scr = iphdr->src;
+ ip4_addr_p_t ip4_addr_dest = iphdr->dest;
+ char buf[32];
+ int dataLen;
+
+ // get scr_port and dest port from tcp head
+ u16_t scr_port, dest_port;
+ void *data;
+ struct udp_hdr *udphdr;
+ udphdr = (struct udp_hdr *)((u8_t *)iphdr + IPH_HL_BYTES(iphdr));
+ scr_port = udphdr->src;
+ dest_port = udphdr->dest;
+ data = (void *)((u8_t *)udphdr + UDP_HLEN);
+
+ LogPrintln("======Bt netif send package======");
+ LogPrintln("netif full name %s", netif->full_name);
+ (void)inet_ntop(AF_INET, &ip4_addr_scr.addr, buf, sizeof(buf));
+ LogPrintln("package src ip %s", buf);
+ (void)inet_ntop(AF_INET, &ip4_addr_dest.addr, buf, sizeof(buf));
+ LogPrintln("package dest ip %s", buf);
+ LogPrintln("package src port %d", lwip_ntohs(scr_port));
+ LogPrintln("package dest port %d", lwip_ntohs(dest_port));
+ LogPrintln("send data %s", (char *)data);
+ dataLen = lwip_ntohs(udphdr->len) - UDP_HLEN;
+ LogPrintln("send data length %d", dataLen);
+ ICUNIT_ASSERT_EQUAL(dataLen, strlen(MSG), 4);
+ LogPrintln("=================================");
+
+ // 回应udp报文
+ ReplayUdpTask();
+}
+
+static void ParsePackageEthernet(struct netif *netif, struct pbuf *p)
+{
+ u16_t next_hdr_offset = SIZEOF_ETH_HDR;
+ // get src mac and dest mac
+ struct eth_hdr *ethhdr;
+ ethhdr = (struct eth_hdr *)p->payload;
+ u16_t type = ethhdr->type;
+
+ LogPrintln("ParsePackageEthernet type is %d", type);
+ switch (type) {
+#if LWIP_IPV4 && LWIP_ARP
+ /* IP packet? */
+ case PP_HTONS(ETHTYPE_IP): // 0x0008
+ if (!(netif->flags & NETIF_FLAG_ETHARP)) {
+ return;
+ }
+ /* skip Ethernet header (min. size checked above) */
+ if (pbuf_remove_header(p, next_hdr_offset)) {
+ return;
+ } else {
+ /* pass to IP layer */
+ ParsePackageIpUdp(netif, p);
+ }
+ break;
+
+ case PP_HTONS(ETHTYPE_ARP): // 0x0608
+ if (!(netif->flags & NETIF_FLAG_ETHARP)) {
+ return;
+ }
+ /* skip Ethernet header (min. size checked above) */
+ if (pbuf_remove_header(p, next_hdr_offset)) {
+ return;
+ } else {
+ /* pass p to ARP module */
+ LogPrintln("recv arp packet");
+ ArpPackageProc(netif, p);
+ }
+ break;
+#endif /* LWIP_IPV4 && LWIP_ARP */
+
+ default:
+ LogPrintln("type is other %d", type);
+ break;
+ }
+}
+
+static void BtProxySend(struct netif *netif, struct pbuf *p)
+{
+ if (netif == NULL || p == NULL) {
+ LogPrintln("%s : netif = NUll or p = NULL!", __func__);
+ return;
+ }
+#if ETH_PAD_SIZE
+ (void)pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */
+#endif
+ ParsePackageEthernet(netif, p);
+}
+
+static struct netif *CreateBtNetIf()
+{
+ struct netif *btNetif = NULL;
+ btNetif = (struct netif *)malloc(sizeof(struct netif));
+ if (btNetif == NULL) {
+ LogPrintln("%s fail : netif malloc fail!", __func__);
+ LWIP_ASSERT("btNetif malloc fail.", 0);
+ return NULL;
+ }
+ (void)memset_s(btNetif, sizeof(struct netif), 0, sizeof(struct netif));
+ btNetif->drv_send = BtProxySend;
+ btNetif->link_layer_type = BT_PROXY_IF;
+ btNetif->hwaddr_len = ETH_HWADDR_LEN;
+ (void)memcpy_s(&btNetif->hwaddr, sizeof(btNetif->hwaddr), NETIF_MAC, ETH_HWADDR_LEN);
+ (void)memcpy_s(&btNetif->full_name, sizeof(btNetif->full_name), NETIF_NAME_BT, sizeof(NETIF_NAME_BT));
+ ip4_addr_t gw, ipaddr, netmask;
+ IP4_ADDR(&gw, 192, 168, 167, 239);
+ IP4_ADDR(&ipaddr, 192, 168, 167, 1);
+ IP4_ADDR(&netmask, 255, 255, 255, 255);
+ int ret = 0;
+ if ((ret = netifapi_netif_add(btNetif, &ipaddr, &netmask, &gw, btNetif, driverif_init, tcpip_input)) != ERR_OK) {
+ LogPrintln("%s : netifapi_netif_add fail!,ret=%d", __func__, ret);
+ LWIP_ASSERT("btNetif add fail.", 0);
+ return NULL;
+ }
+ LogPrintln("netifapi_netif_add success!");
+ netif_set_link_up(btNetif);
+ netifapi_netif_set_up(btNetif);
+ return btNetif;
+}
+
+int UdpTestNetif(void)
+{
+ LogPrintln("net_socket_test_011.c enter");
+ g_testCase = TEST_CASE;
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ struct ifreq nif;
+ int ret;
+
+ // 注册网卡
+ btProxyNf = CreateBtNetIf();
+
+ /* socket creation */
+ sfd = socket(AF_INET, SOCK_DGRAM, 0);
+ LWIP_ASSERT("socket invalid param.", sfd != -1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP_BT);
+ srvAddr.sin_port = htons(STACK_PORT);
+ ret = bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ LWIP_ASSERT("socket invalid param.", ret == 0);
+
+ /* 指定网卡接口 */
+ char *inface = NETIF_NAME_BT;
+ (void)strcpy_s(nif.ifr_name, sizeof(nif.ifr_name), inface);
+ if (setsockopt(sfd, SOL_SOCKET, SO_BINDTODEVICE, (char *)&nif, sizeof(nif)) < 0) {
+ LogPrintln("set intaface fail");
+ LWIP_ASSERT("set intaface fail.", 0);
+ }
+
+ /* send */
+ clnAddr.sin_family = AF_INET;
+ clnAddr.sin_addr.s_addr = inet_addr(PEER_IP_BT);
+ clnAddr.sin_port = htons(PEER_PORT);
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ (void)strcpy_s(g_buf, sizeof(g_buf), MSG);
+ ret = sendto(sfd, g_buf, strlen(MSG), 0, (struct sockaddr*)&clnAddr,
+ (socklen_t)sizeof(clnAddr));
+ LogPrintln("client send success: %d", sfd);
+ LWIP_ASSERT("socket invalid param.", ret != -1);
+
+ /* recv */
+ (void)memset_s(g_buf, sizeof(g_buf), 0, sizeof(g_buf));
+ ret = recvfrom(sfd, g_buf, sizeof(g_buf), 0, (struct sockaddr*)&clnAddr,
+ &clnAddrLen);
+ LWIP_ASSERT("socket invalid param.", ret == strlen(MSG));
+ LogPrintln("cli recv: %s", g_buf);
+
+ /* close socket */
+ ret = closesocket(sfd);
+ LWIP_ASSERT("socket invalid param.", ret != -1);
+ return LWIP_TEST_RET_OK;
+}
+
+static void ArpPackageProc(struct netif *netif, struct pbuf *p)
+{
+ struct etharp_hdr *hdr;
+ ip4_addr_t sipaddr, dipaddr;
+ hdr = (struct etharp_hdr *)p->payload;
+
+ if (hdr->opcode != PP_HTONS(ARP_REQUEST)) {
+ LogPrintln("opcode %d is not arp request", hdr->opcode);
+ return;
+ }
+
+ inet_pton(AF_INET, GATEWAY_IP_BT, &sipaddr);
+ inet_pton(AF_INET, STACK_IP_BT, &dipaddr);
+ if (memcmp(&hdr->dipaddr, &sipaddr, sizeof(ip4_addr_t)) != EOK) {
+ LogPrintln("hdr->dipaddr %u is invalid", hdr->dipaddr);
+ return;
+ }
+
+ // 回应arp报文
+ ReplayArpTask();
+}
+
+static void ReplayArpEncodeEthernet(struct netif *netif, struct pbuf *p)
+{
+ int ret;
+ ret = pbuf_add_header(p, SIZEOF_ETH_HDR);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 1);
+
+ struct eth_hdr *ethhdr;
+ ethhdr = (struct eth_hdr *)p->payload;
+ ethhdr->type = lwip_htons(ETHTYPE_ARP);
+ SMEMCPY(ðhdr->dest, NETIF_MAC, ETH_HWADDR_LEN);
+ SMEMCPY(ðhdr->src, PEER_MAC, ETH_HWADDR_LEN);
+
+ driverif_input(netif, p);
+}
+
+static void ReplayArp(void *ptemp)
+{
+ struct etharp_hdr *hdr;
+ ip4_addr_t sipaddr, dipaddr;
+
+ (void)ptemp;
+ LogPrintln("encode arp replay packet");
+ inet_pton(AF_INET, GATEWAY_IP_BT, &sipaddr);
+ inet_pton(AF_INET, STACK_IP_BT, &dipaddr);
+ struct pbuf *p = pbuf_alloc(PBUF_LINK, SIZEOF_ETHARP_HDR, PBUF_RAM);
+ hdr = (struct etharp_hdr *)p->payload;
+ hdr->opcode = PP_HTONS(ARP_REPLY);
+ /* Write the ARP MAC-Addresses */
+ SMEMCPY(&hdr->shwaddr, PEER_MAC, ETH_HWADDR_LEN);
+ SMEMCPY(&hdr->dhwaddr, NETIF_MAC, ETH_HWADDR_LEN);
+ /* Copy struct ip4_addr_wordaligned to aligned ip4_addr, to support compilers without
+ * structure packing. */
+ IPADDR_WORDALIGNED_COPY_FROM_IP4_ADDR_T(&hdr->sipaddr, &sipaddr);
+ IPADDR_WORDALIGNED_COPY_FROM_IP4_ADDR_T(&hdr->dipaddr, &dipaddr);
+ hdr->hwtype = PP_HTONS(LWIP_IANA_HWTYPE_ETHERNET);
+ hdr->proto = PP_HTONS(ETHTYPE_IP);
+ /* set hwlen and protolen */
+ hdr->hwlen = ETH_HWADDR_LEN;
+ hdr->protolen = sizeof(ip4_addr_t);
+
+ ReplayArpEncodeEthernet(btProxyNf, p);
+}
+
+static void ReplayArpTask()
+{
+ int ret;
+ ret = sys_thread_new("replay_arp", ReplayArp, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+}
\ No newline at end of file
diff --git a/components/net/test/net_socket_test_012.c b/components/net/test/net_socket_test_012.c
new file mode 100755
index 00000000..63073535
--- /dev/null
+++ b/components/net/test/net_socket_test_012.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include "lwipopts.h"
+#include
+#include
+
+#define SRV_MSG "Hi, I am TCP server"
+#define CLI_MSG "Hi, I am TCP client"
+#define TEST_CASE 220
+#define TEST_COUNT 100
+#define STACK_PORT_TCP_DUP_START 3000
+
+static int g_portServer = STACK_PORT_TCP_DUP_START;
+static int g_portClient = STACK_PORT_TCP_DUP_START;
+
+static char g_bufServer[BUF_SIZE + 1] = { 0 };
+static char g_bufClient[BUF_SIZE + 1] = { 0 };
+extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio);
+
+static int SampleTcpServer()
+{
+ int sfd, lsfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ int ret;
+
+ /* tcp server */
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, 1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(g_portServer);
+ g_portServer++;
+ ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+
+ ret = listen(lsfd, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 3);
+
+ sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 4);
+
+ /* send */
+ (void)memset_s(g_bufServer, sizeof(g_bufServer), 0, sizeof(g_bufServer));
+ (void)strcpy_s(g_bufServer, sizeof(g_bufServer), SRV_MSG);
+ ret = send(sfd, g_bufServer, strlen(SRV_MSG), 0);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), 5);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 10);
+ ret = closesocket(lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 11);
+
+ return 0;
+}
+
+static int SampleTcpClient()
+{
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ int ret;
+
+ /* tcp client connection */
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 10);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ srvAddr.sin_port = htons(g_portClient);
+ g_portClient++;
+ ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ ICUNIT_ASSERT_EQUAL(ret, 0, 11);
+
+ /* recv */
+ (void)memset_s(g_bufClient, sizeof(g_bufClient), 0, sizeof(g_bufClient));
+ ret = recv(sfd, g_bufClient, sizeof(g_bufClient), 0);
+ ICUNIT_ASSERT_EQUAL(ret, strlen(SRV_MSG), 19);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+ return 0;
+}
+
+static void TcpServerRoutine(void *p)
+{
+ (void)p;
+ g_testCase++;
+
+ int i;
+ for (i = 0; i < TEST_COUNT; i++) {
+ (void)SampleTcpServer();
+ }
+ LogPrintln("tcp server g_portServer = %d", g_portServer);
+}
+
+static void TcpClientRoutine(void *p)
+{
+ (void)p;
+ g_testCase++;
+
+ int i;
+ for (i = 0; i < TEST_COUNT; i++) {
+ (void)SampleTcpClient();
+ }
+ LogPrintln("tcp server g_portClient = %d", g_portClient);
+}
+
+void TcpTestDup()
+{
+ LogPrintln("net_socket_test_012.c enter");
+ g_testCase = TEST_CASE;
+ int ret;
+ ret = sys_thread_new("tcp_server_dup", TcpServerRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+
+ ret = sys_thread_new("tcp_client_dup", TcpClientRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 24);
+}
diff --git a/components/net/test/net_socket_test_013.c b/components/net/test/net_socket_test_013.c
new file mode 100755
index 00000000..325393ac
--- /dev/null
+++ b/components/net/test/net_socket_test_013.c
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "lwip_test.h"
+#include "lwipopts.h"
+#include
+#include
+
+#define TEST_CASE 230
+#define STACK_PORT_TCP_LONG 2231
+#define TCP_LONG_BUF_SIZE (2 * 1024)
+
+extern sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stackSize, int prio);
+
+static int SampleTcpServer()
+{
+ int sfd, lsfd;
+ struct sockaddr_in srvAddr = { 0 };
+ struct sockaddr_in clnAddr = { 0 };
+ socklen_t clnAddrLen = sizeof(clnAddr);
+ int ret;
+ static char serverBuf[TCP_LONG_BUF_SIZE] = {0};
+
+ /* tcp server */
+ lsfd = socket(AF_INET, SOCK_STREAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(lsfd, -1, 1);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
+ srvAddr.sin_port = htons(STACK_PORT_TCP_LONG);
+ ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ ICUNIT_ASSERT_EQUAL(ret, 0, 2);
+
+ ret = listen(lsfd, 0);
+ ICUNIT_ASSERT_EQUAL(ret, 0, 3);
+
+ sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 4);
+
+ /* send */
+ ret = send(sfd, serverBuf, TCP_LONG_BUF_SIZE, 0);
+ ICUNIT_ASSERT_EQUAL(ret, TCP_LONG_BUF_SIZE, 6);
+
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 7);
+ ret = closesocket(lsfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 8);
+
+ return 0;
+}
+
+static int SampleTcpClient()
+{
+ int sfd;
+ struct sockaddr_in srvAddr = { 0 };
+ int ret, i;
+ int recvCount = 0;
+ static char clientBuf[TCP_LONG_BUF_SIZE] = {0};
+
+ /* tcp client connection */
+ sfd = socket(AF_INET, SOCK_STREAM, 0);
+ ICUNIT_ASSERT_NOT_EQUAL(sfd, -1, 9);
+
+ srvAddr.sin_family = AF_INET;
+ srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
+ srvAddr.sin_port = htons(STACK_PORT_TCP_LONG);
+ ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
+ ICUNIT_ASSERT_EQUAL(ret, 0, 10);
+
+ /* recv */
+ for (i = 0; i < TCP_LONG_BUF_SIZE; i++) {
+ ret = recv(sfd, clientBuf, TCP_LONG_BUF_SIZE, 0);
+ recvCount += ret;
+ if (recvCount >= TCP_LONG_BUF_SIZE) {
+ LogPrintln("client recv on socket %d: %d, i = %d", sfd, recvCount, i);
+ break;
+ }
+ }
+ ICUNIT_ASSERT_NOT_EQUAL(i, TCP_LONG_BUF_SIZE, 12);
+ ret = closesocket(sfd);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 13);
+ return 0;
+}
+
+static void TcpServerRoutine(void *p)
+{
+ (void)p;
+ g_testCase++;
+ (void)SampleTcpServer();
+}
+
+static void TcpClientRoutine(void *p)
+{
+ (void)p;
+ g_testCase++;
+ (void)SampleTcpClient();
+}
+
+void TcpTestLong()
+{
+ LogPrintln("net_socket_test_013.c enter");
+ g_testCase = TEST_CASE;
+ int ret;
+ ret = sys_thread_new("tcp_server_long", TcpServerRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 23);
+
+ ret = sys_thread_new("tcp_client_long", TcpClientRoutine, NULL,
+ STACK_TEST_SIZE, TCPIP_THREAD_PRIO);
+ ICUNIT_ASSERT_NOT_EQUAL(ret, -1, 24);
+}
diff --git a/components/net/test/test_main.c b/components/net/test/test_main.c
new file mode 100644
index 00000000..125b9dd0
--- /dev/null
+++ b/components/net/test/test_main.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "sys/socket.h"
+#include "hos_cmsis_adp.h"
+
+#define LWIP_TEST_TIMEOUT 1000 // timeout 1s
+#define LWIP_TEST_COUNT_FLAG 100
+
+#define SOCKET_TEST 310
+#define UDP_TEST 320
+#define TCP_TEST 330
+#define OPT_TEST 340
+#define ORDER_TEST 350
+#define INET_TEST 360
+#define UDP_MORE_TEST 370
+#define TCP_MORE_TEST 380
+#define TCP_SELECT_TEST 390
+#define TCP_POLL_TEST 400
+#define NETIF_TEST 410
+#define TCP_DUP_TEST 420
+#define TCP_LONG_TEST 430
+
+int g_lwipTimerCount = 0;
+int g_testCase = LWIP_TEST_COUNT_FLAG;
+int g_testError = 0;
+int g_testTemp = LWIP_TEST_COUNT_FLAG;
+extern void abort(void);
+extern int SocketTest(void);
+extern int UdpTest(void);
+extern void TcpTest();
+extern int SockOptTest();
+extern int ByteOrderTest(void);
+extern int InetTest();
+extern int UdpTestMore(void);
+extern void TcpTestMore();
+extern void TcpTestSelect();
+extern void TcpTestPoll();
+extern int UdpTestNetif(void);
+extern void TcpTestDup();
+extern void TcpTestLong();
+
+// time out 1s
+static void LwipTestTimeoutCallback(void const *argument)
+{
+ g_lwipTimerCount++;
+ switch (g_lwipTimerCount) {
+ case SOCKET_TEST:
+ SocketTest();
+ break;
+ case UDP_TEST:
+ UdpTest();
+ break;
+ case TCP_TEST:
+ TcpTest();
+ break;
+ case OPT_TEST:
+ SockOptTest();
+ break;
+ case ORDER_TEST:
+ ByteOrderTest();
+ break;
+ case INET_TEST:
+ InetTest();
+ break;
+ case UDP_MORE_TEST:
+ UdpTestMore();
+ break;
+ case TCP_MORE_TEST:
+ TcpTestMore();
+ break;
+ case TCP_SELECT_TEST:
+ TcpTestSelect();
+ break;
+ case TCP_POLL_TEST:
+ TcpTestPoll();
+ break;
+ case NETIF_TEST:
+ UdpTestNetif();
+ break;
+ case TCP_DUP_TEST:
+ TcpTestDup();
+ break;
+ case TCP_LONG_TEST:
+ TcpTestLong();
+ break;
+ default:
+ break;
+ }
+}
+
+osTimerId_t g_lwipTestTimerId = NULL;
+
+void LwipTestStartTimer(uint32 timeout)
+{
+ osStatus_t status;
+ if (g_lwipTestTimerId != NULL) {
+ status = osTimerStart(g_lwipTestTimerId, timeout);
+ if (status != osOK) {
+ return;
+ }
+ } else {
+ g_lwipTestTimerId = osTimerNew((osTimerFunc_t)LwipTestTimeoutCallback, osTimerPeriodic, NULL, NULL);
+ if (g_lwipTestTimerId == NULL) {
+ return;
+ }
+ status = osTimerStart(g_lwipTestTimerId, timeout);
+ if (status != osOK) {
+ return;
+ }
+ }
+}
+
+void LwipTestEnter()
+{
+ LwipTestStartTimer(LWIP_TEST_TIMEOUT);
+}
diff --git a/figures/OpenHarmony-LiteOS-M核内核架构图.png b/figures/OpenHarmony-LiteOS-M核内核架构图.png
new file mode 100644
index 00000000..63a10e4e
Binary files /dev/null and b/figures/OpenHarmony-LiteOS-M核内核架构图.png differ
diff --git a/figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png b/figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png
new file mode 100644
index 00000000..63a10e4e
Binary files /dev/null and b/figures/architecture-of-openharmony-the-liteos-cortex-m-kernel.png differ
diff --git a/kal/BUILD.gn b/kal/BUILD.gn
new file mode 100644
index 00000000..05c2d2ad
--- /dev/null
+++ b/kal/BUILD.gn
@@ -0,0 +1,55 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+declare_args() {
+ enable_ohos_kernel_liteos_m_cmsis = true
+ enable_ohos_kernel_liteos_m_posix = true
+}
+
+static_library("kal") {
+ sources = [ "kal.c" ]
+
+ include_dirs = [
+ "../kernel/arch/include",
+ "../kernel/include",
+ "../utils",
+ "../kal/cmsis",
+ "../kal",
+ ]
+
+ deps = []
+
+ if (enable_ohos_kernel_liteos_m_cmsis == true) {
+ deps += [ "cmsis/" ]
+ }
+
+ if (enable_ohos_kernel_liteos_m_posix == true) {
+ deps += [ "posix/" ]
+ }
+}
diff --git a/kal/cmsis/BUILD.gn b/kal/cmsis/BUILD.gn
new file mode 100644
index 00000000..7cb21e4e
--- /dev/null
+++ b/kal/cmsis/BUILD.gn
@@ -0,0 +1,41 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("cmsis") {
+ sources = [ "cmsis_liteos.c" ]
+
+ include_dirs = [
+ "//third_party/bounds_checking_function/include",
+ "../../kernel/include",
+ "../../kernel/arch/include",
+ "../../utils",
+ "../../kal/cmsis",
+ "../../kal",
+ ]
+}
diff --git a/kal/cmsis/LICENSE.txt b/kal/cmsis/LICENSE.txt
new file mode 100644
index 00000000..8dada3ed
--- /dev/null
+++ b/kal/cmsis/LICENSE.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/kal/cmsis/README.OpenSource b/kal/cmsis/README.OpenSource
new file mode 100644
index 00000000..c05284e1
--- /dev/null
+++ b/kal/cmsis/README.OpenSource
@@ -0,0 +1,11 @@
+[
+ {
+ "Name" : "CMSIS",
+ "License" : "Apache License V2.0",
+ "License File" : "LICENSE.txt",
+ "Version Number" : "5.7.0",
+ "Owner" : "denny.shenwei@huawei.com",
+ "Upstream URL" : "http://www.arm.com/zh/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php",
+ "Description" : "The Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for microcontrollers that are based on Arm® Cortex® processors"
+ }
+]
diff --git a/kal/cmsis/cmsis_liteos.c b/kal/cmsis/cmsis_liteos.c
index ab11efd3..0b745fc5 100644
--- a/kal/cmsis/cmsis_liteos.c
+++ b/kal/cmsis/cmsis_liteos.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/cmsis/cmsis_liteos2.c b/kal/cmsis/cmsis_liteos2.c
index 88e4eef0..c37552a8 100755
--- a/kal/cmsis/cmsis_liteos2.c
+++ b/kal/cmsis/cmsis_liteos2.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/cmsis/cmsis_os.h b/kal/cmsis/cmsis_os.h
index d1763533..7363fe79 100644
--- a/kal/cmsis/cmsis_os.h
+++ b/kal/cmsis/cmsis_os.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/cmsis/hos_cmsis_adp.h b/kal/cmsis/hos_cmsis_adp.h
index ac477169..d513d6f9 100644
--- a/kal/cmsis/hos_cmsis_adp.h
+++ b/kal/cmsis/hos_cmsis_adp.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/kal.c b/kal/kal.c
index 4cbc6b2f..4e8e5b14 100755
--- a/kal/kal.c
+++ b/kal/kal.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/kal.h b/kal/kal.h
index daa19c8f..2dbcd1eb 100755
--- a/kal/kal.h
+++ b/kal/kal.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/posix/BUILD.gn b/kal/posix/BUILD.gn
new file mode 100644
index 00000000..aaacb08c
--- /dev/null
+++ b/kal/posix/BUILD.gn
@@ -0,0 +1,49 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("posix") {
+ sources = [
+ "src/errno.c",
+ "src/libc.c",
+ "src/malloc.c",
+ "src/pthread.c",
+ "src/pthread_attr.c",
+ "src/pthread_mutex.c",
+ "src/semaphore.c",
+ "src/time.c",
+ ]
+
+ include_dirs = [
+ "include",
+ "../../kernel/arch/include",
+ "../../kernel/include",
+ "../../utils",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/kal/posix/include/COPYRIGHT b/kal/posix/include/COPYRIGHT
new file mode 100644
index 00000000..e6472371
--- /dev/null
+++ b/kal/posix/include/COPYRIGHT
@@ -0,0 +1,190 @@
+musl as a whole is licensed under the following standard MIT license:
+
+----------------------------------------------------------------------
+Copyright © 2005-2020 Rich Felker, et al.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+----------------------------------------------------------------------
+
+Authors/contributors include:
+
+A. Wilcox
+Ada Worcester
+Alex Dowad
+Alex Suykov
+Alexander Monakov
+Andre McCurdy
+Andrew Kelley
+Anthony G. Basile
+Aric Belsito
+Arvid Picciani
+Bartosz Brachaczek
+Benjamin Peterson
+Bobby Bingham
+Boris Brezillon
+Brent Cook
+Chris Spiegel
+Clément Vasseur
+Daniel Micay
+Daniel Sabogal
+Daurnimator
+David Carlier
+David Edelsohn
+Denys Vlasenko
+Dmitry Ivanov
+Dmitry V. Levin
+Drew DeVault
+Emil Renner Berthing
+Fangrui Song
+Felix Fietkau
+Felix Janda
+Gianluca Anzolin
+Hauke Mehrtens
+He X
+Hiltjo Posthuma
+Isaac Dunham
+Jaydeep Patil
+Jens Gustedt
+Jeremy Huntwork
+Jo-Philipp Wich
+Joakim Sindholt
+John Spencer
+Julien Ramseier
+Justin Cormack
+Kaarle Ritvanen
+Khem Raj
+Kylie McClain
+Leah Neukirchen
+Luca Barbato
+Luka Perkov
+M Farkas-Dyck (Strake)
+Mahesh Bodapati
+Markus Wichmann
+Masanori Ogino
+Michael Clark
+Michael Forney
+Mikhail Kremnyov
+Natanael Copa
+Nicholas J. Kain
+orc
+Pascal Cuoq
+Patrick Oppenlander
+Petr Hosek
+Petr Skocik
+Pierre Carrier
+Reini Urban
+Rich Felker
+Richard Pennington
+Ryan Fairfax
+Samuel Holland
+Segev Finer
+Shiz
+sin
+Solar Designer
+Stefan Kristiansson
+Stefan O'Rear
+Szabolcs Nagy
+Timo Teräs
+Trutz Behn
+Valentin Ochs
+Will Dietz
+William Haddon
+William Pitcock
+
+Portions of this software are derived from third-party works licensed
+under terms compatible with the above MIT license:
+
+The TRE regular expression implementation (src/regex/reg* and
+src/regex/tre*) is Copyright © 2001-2008 Ville Laurikari and licensed
+under a 2-clause BSD license (license text in the source files). The
+included version has been heavily modified by Rich Felker in 2012, in
+the interests of size, simplicity, and namespace cleanliness.
+
+Much of the math library code (src/math/* and src/complex/*) is
+Copyright © 1993,2004 Sun Microsystems or
+Copyright © 2003-2011 David Schultz or
+Copyright © 2003-2009 Steven G. Kargl or
+Copyright © 2003-2009 Bruce D. Evans or
+Copyright © 2008 Stephen L. Moshier or
+Copyright © 2017-2018 Arm Limited
+and labelled as such in comments in the individual source files. All
+have been licensed under extremely permissive terms.
+
+The ARM memcpy code (src/string/arm/memcpy_el.S) is Copyright © 2008
+The Android Open Source Project and is licensed under a two-clause BSD
+license. It was taken from Bionic libc, used on Android.
+
+The implementation of DES for crypt (src/crypt/crypt_des.c) is
+Copyright © 1994 David Burren. It is licensed under a BSD license.
+
+The implementation of blowfish crypt (src/crypt/crypt_blowfish.c) was
+originally written by Solar Designer and placed into the public
+domain. The code also comes with a fallback permissive license for use
+in jurisdictions that may not recognize the public domain.
+
+The smoothsort implementation (src/stdlib/qsort.c) is Copyright © 2011
+Valentin Ochs and is licensed under an MIT-style license.
+
+The x86_64 port was written by Nicholas J. Kain and is licensed under
+the standard MIT terms.
+
+The mips and microblaze ports were originally written by Richard
+Pennington for use in the ellcc project. The original code was adapted
+by Rich Felker for build system and code conventions during upstream
+integration. It is licensed under the standard MIT terms.
+
+The mips64 port was contributed by Imagination Technologies and is
+licensed under the standard MIT terms.
+
+The powerpc port was also originally written by Richard Pennington,
+and later supplemented and integrated by John Spencer. It is licensed
+under the standard MIT terms.
+
+All other files which have no copyright comments are original works
+produced specifically for use as part of this library, written either
+by Rich Felker, the main author of the library, or by one or more
+contibutors listed above. Details on authorship of individual files
+can be found in the git version control history of the project. The
+omission of copyright and license comments in each file is in the
+interest of source tree size.
+
+In addition, permission is hereby granted for all public header files
+(include/* and arch/*/bits/*) and crt files intended to be linked into
+applications (crt/*, ldso/dlstart.c, and arch/*/crt_arch.h) to omit
+the copyright notice and permission notice otherwise required by the
+license, and to use these files without any requirement of
+attribution. These files include substantial contributions from:
+
+Bobby Bingham
+John Spencer
+Nicholas J. Kain
+Rich Felker
+Richard Pennington
+Stefan Kristiansson
+Szabolcs Nagy
+
+all of whom have explicitly granted such permission.
+
+This file previously contained text expressing a belief that most of
+the files covered by the above exception were sufficiently trivial not
+to be subject to copyright, resulting in confusion over whether it
+negated the permissions granted in the license. In the spirit of
+permissive licensing, and of not having licensing issues being an
+obstacle to adoption, that text has been removed.
diff --git a/kal/posix/include/README b/kal/posix/include/README
index 2b0dffc5..43a29cc1 100644
--- a/kal/posix/include/README
+++ b/kal/posix/include/README
@@ -1,28 +1,3 @@
** DO NOT EDIT FILES HERE **
-
-These header files are copied from musl ("//third_party/musl") except `libc.h'.
-
-musl as a whole is licensed under the following standard MIT license:
-
-----------------------------------------------------------------------
-Copyright © 2005-2020 Rich Felker, et al.
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------
+These header files are copied from musl ("//third_party/musl") except `libc.h',
+you can see the license information of MUSL in COPYRIGHT file.
diff --git a/kal/posix/include/README.OpenSource b/kal/posix/include/README.OpenSource
new file mode 100644
index 00000000..e426562c
--- /dev/null
+++ b/kal/posix/include/README.OpenSource
@@ -0,0 +1,11 @@
+[
+ {
+ "Name" : "musl",
+ "License" : "MIT License",
+ "License File" : "COPYRIGHT",
+ "Version Number" : "1.2.0",
+ "Owner" : "jianghan2@huawei.com",
+ "Upstream URL" : "http://www.musl-libc.org/",
+ "Description" : "musl is an MIT-licensed implementation of the standard C library"
+ }
+]
diff --git a/kal/posix/include/bits/alltypes.h b/kal/posix/include/bits/alltypes.h
old mode 100644
new mode 100755
index 696ed211..909d60d5
--- a/kal/posix/include/bits/alltypes.h
+++ b/kal/posix/include/bits/alltypes.h
@@ -492,9 +492,35 @@ typedef unsigned short sa_family_t;
#define __DEFINED_sa_family_t
#endif
+#if (defined(__NEED_sched_param) || defined(__NEED_pthread_attr_t)) && !defined(__DEFINED_sched_param)
+struct sched_param {
+ int sched_priority;
+ int __reserved1;
+#if _REDIR_TIME64
+ long __reserved2[4];
+#else
+ struct {
+ time_t __reserved1;
+ long __reserved2;
+ } __reserved2[2];
+#endif
+ int __reserved3;
+};
+#define __DEFINED_sched_param
+#endif
#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
-typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t;
+typedef struct {
+ unsigned int detachstate;
+ unsigned int schedpolicy;
+ struct sched_param schedparam;
+ unsigned int inheritsched;
+ unsigned int scope;
+ unsigned int stackaddr_set;
+ void *stackaddr;
+ unsigned int stacksize_set;
+ size_t stacksize;
+} pthread_attr_t;
#define __DEFINED_pthread_attr_t
#endif
diff --git a/kal/posix/include/libc.h b/kal/posix/include/libc.h
old mode 100755
new mode 100644
index cfec7955..d021fc6b
--- a/kal/posix/include/libc.h
+++ b/kal/posix/include/libc.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/posix/include/limits.h b/kal/posix/include/limits.h
index 20fda4a1..5b40fda7 100644
--- a/kal/posix/include/limits.h
+++ b/kal/posix/include/limits.h
@@ -2,6 +2,7 @@
#define _LIMITS_H
#ifdef __ICCARM__ /* for iar */
+#define PTHREAD_STACK_MIN LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE
#include_next
#else
@@ -68,7 +69,7 @@
/* Implementation choices... */
#define PTHREAD_KEYS_MAX 128
-#define PTHREAD_STACK_MIN 2048
+#define PTHREAD_STACK_MIN LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
#define SEM_VALUE_MAX 0x7fffffff
#define SEM_NSEMS_MAX 256
diff --git a/kal/posix/include/pthread.h b/kal/posix/include/pthread.h
index 5dd71ec0..8291cdef 100644
--- a/kal/posix/include/pthread.h
+++ b/kal/posix/include/pthread.h
@@ -26,7 +26,6 @@ extern "C" {
#define __NEED_size_t
#include
-
#include
#include
@@ -82,7 +81,7 @@ extern "C" {
int pthread_create(pthread_t *__restrict, const pthread_attr_t *__restrict, void *(*)(void *), void *__restrict);
int pthread_detach(pthread_t);
-_Noreturn void pthread_exit(void *);
+void pthread_exit(void *);
int pthread_join(pthread_t, void **);
#ifdef __GNUC__
diff --git a/kal/posix/include/sched.h b/kal/posix/include/sched.h
index 822f464e..605bf91b 100644
--- a/kal/posix/include/sched.h
+++ b/kal/posix/include/sched.h
@@ -9,6 +9,7 @@ extern "C" {
#define __NEED_struct_timespec
#define __NEED_pid_t
#define __NEED_time_t
+#define __NEED_sched_param
#ifdef _GNU_SOURCE
#define __NEED_size_t
@@ -16,20 +17,6 @@ extern "C" {
#include
-struct sched_param {
- int sched_priority;
- int __reserved1;
-#if _REDIR_TIME64
- long __reserved2[4];
-#else
- struct {
- time_t __reserved1;
- long __reserved2;
- } __reserved2[2];
-#endif
- int __reserved3;
-};
-
int sched_get_priority_max(int);
int sched_get_priority_min(int);
int sched_getparam(pid_t, struct sched_param *);
diff --git a/kal/posix/include/signal.h b/kal/posix/include/signal.h
old mode 100644
new mode 100755
diff --git a/kal/posix/include/sys/capability.h b/kal/posix/include/sys/capability.h
index 23e9bb07..b7dd8f72 100644
--- a/kal/posix/include/sys/capability.h
+++ b/kal/posix/include/sys/capability.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/posix/src/errno.c b/kal/posix/src/errno.c
index 0d3bda0d..790cc5e0 100644
--- a/kal/posix/src/errno.c
+++ b/kal/posix/src/errno.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/posix/src/libc.c b/kal/posix/src/libc.c
index dd48eba0..a4018d5e 100644
--- a/kal/posix/src/libc.c
+++ b/kal/posix/src/libc.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/posix/src/libc_config.h b/kal/posix/src/libc_config.h
index eca96f86..0529ba33 100644
--- a/kal/posix/src/libc_config.h
+++ b/kal/posix/src/libc_config.h
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
- * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef LIBC_CONFIG_H_
-#define LIBC_CONFIG_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef LIBC_VERSION_STR
-#define LIBC_VERSION_STR "1.0.0-LiteOS_M"
-#endif
-
-#ifndef LIBC_VERSION_NUM
-#define LIBC_VERSION_NUM 0x00010000
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // LIBC_CONFIG_H_
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBC_CONFIG_H_
+#define LIBC_CONFIG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef LIBC_VERSION_STR
+#define LIBC_VERSION_STR "1.0.0-LiteOS_M"
+#endif
+
+#ifndef LIBC_VERSION_NUM
+#define LIBC_VERSION_NUM 0x00010000
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // LIBC_CONFIG_H_
diff --git a/kal/posix/src/malloc.c b/kal/posix/src/malloc.c
index c594837c..8b9a26f8 100644
--- a/kal/posix/src/malloc.c
+++ b/kal/posix/src/malloc.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -27,93 +27,93 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "securec.h"
-#include "los_config.h"
-#include "los_memory.h"
-
-#ifdef __cplusplus
-#if __cplusplus
-extern "C" {
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
-
-void *calloc(size_t nitems, size_t size)
-{
- size_t real_size;
- void *ptr = NULL;
-
- if (nitems == 0 || size == 0) {
- return NULL;
- }
-
- real_size = (size_t)(nitems * size);
- ptr = LOS_MemAlloc(OS_SYS_MEM_ADDR, real_size);
- if (ptr != NULL) {
- (void)memset_s(ptr, real_size, 0, real_size);
- }
- return ptr;
-}
-
-void free(void *ptr)
-{
- if (ptr == NULL) {
- return;
- }
-
- LOS_MemFree(OS_SYS_MEM_ADDR, ptr);
-}
-
-void *malloc(size_t size)
-{
- if (size == 0) {
- return NULL;
- }
-
- return LOS_MemAlloc(OS_SYS_MEM_ADDR, size);
-}
-
-void *zalloc(size_t size)
-{
- void *ptr = NULL;
-
- if (size == 0) {
- return NULL;
- }
-
- ptr = LOS_MemAlloc(OS_SYS_MEM_ADDR, size);
- if (ptr != NULL) {
- (void)memset_s(ptr, size, 0, size);
- }
- return ptr;
-}
-
-void *memalign(size_t boundary, size_t size)
-{
- if (size == 0) {
- return NULL;
- }
-
- return LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, boundary);
-}
-
-void *realloc(void *ptr, size_t size)
-{
- if (ptr == NULL) {
- return malloc(size);
- }
-
- if (size == 0) {
- free(ptr);
- return NULL;
- }
-
- return LOS_MemRealloc(OS_SYS_MEM_ADDR, ptr, size);
-}
-
-#ifdef __cplusplus
-#if __cplusplus
-}
-#endif /* __cpluscplus */
-#endif /* __cpluscplus */
+ */
+
+#include "securec.h"
+#include "los_config.h"
+#include "los_memory.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+void *calloc(size_t nitems, size_t size)
+{
+ size_t real_size;
+ void *ptr = NULL;
+
+ if (nitems == 0 || size == 0) {
+ return NULL;
+ }
+
+ real_size = (size_t)(nitems * size);
+ ptr = LOS_MemAlloc(OS_SYS_MEM_ADDR, real_size);
+ if (ptr != NULL) {
+ (void)memset_s(ptr, real_size, 0, real_size);
+ }
+ return ptr;
+}
+
+void free(void *ptr)
+{
+ if (ptr == NULL) {
+ return;
+ }
+
+ LOS_MemFree(OS_SYS_MEM_ADDR, ptr);
+}
+
+void *malloc(size_t size)
+{
+ if (size == 0) {
+ return NULL;
+ }
+
+ return LOS_MemAlloc(OS_SYS_MEM_ADDR, size);
+}
+
+void *zalloc(size_t size)
+{
+ void *ptr = NULL;
+
+ if (size == 0) {
+ return NULL;
+ }
+
+ ptr = LOS_MemAlloc(OS_SYS_MEM_ADDR, size);
+ if (ptr != NULL) {
+ (void)memset_s(ptr, size, 0, size);
+ }
+ return ptr;
+}
+
+void *memalign(size_t boundary, size_t size)
+{
+ if (size == 0) {
+ return NULL;
+ }
+
+ return LOS_MemAllocAlign(OS_SYS_MEM_ADDR, size, boundary);
+}
+
+void *realloc(void *ptr, size_t size)
+{
+ if (ptr == NULL) {
+ return malloc(size);
+ }
+
+ if (size == 0) {
+ free(ptr);
+ return NULL;
+ }
+
+ return LOS_MemRealloc(OS_SYS_MEM_ADDR, ptr, size);
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/kal/posix/src/pthread.c b/kal/posix/src/pthread.c
index 2ef0dcc5..a7e8893e 100644
--- a/kal/posix/src/pthread.c
+++ b/kal/posix/src/pthread.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "pthread_impl.h"
+#include "pthread.h"
#include
#include
#include
@@ -91,6 +91,8 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
return ENOMEM;
}
+ pthreadData->startRoutine = startRoutine;
+ pthreadData->param = arg;
taskInitParam.pcName = pthreadData->name;
taskInitParam.pfnTaskEntry = PthreadEntry;
taskInitParam.uwArg = (UINT32)(UINTPTR)pthreadData;
@@ -176,7 +178,7 @@ int pthread_join(pthread_t thread, void **retval)
}
while (LOS_TaskStatusGet((UINT32)thread, &taskStatus) == LOS_OK) {
- usleep(10000);
+ (void)LOS_TaskDelay(10); /* 10: Waiting for the end of thread execution. */
}
return 0;
diff --git a/kal/posix/src/pthread_attr.c b/kal/posix/src/pthread_attr.c
index c5dfeda6..d5e6d7b4 100644
--- a/kal/posix/src/pthread_attr.c
+++ b/kal/posix/src/pthread_attr.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "pthread_impl.h"
+#include "pthread.h"
#include
#include
#include "los_config.h"
diff --git a/kal/posix/src/pthread_mutex.c b/kal/posix/src/pthread_mutex.c
old mode 100644
new mode 100755
index 98b7ba2d..1b71d9ab
--- a/kal/posix/src/pthread_mutex.c
+++ b/kal/posix/src/pthread_mutex.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/posix/src/semaphore.c b/kal/posix/src/semaphore.c
index a640df62..395ed30b 100644
--- a/kal/posix/src/semaphore.c
+++ b/kal/posix/src/semaphore.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kal/posix/src/time.c b/kal/posix/src/time.c
index 8c61d8c6..e9fdb3af 100755
--- a/kal/posix/src/time.c
+++ b/kal/posix/src/time.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,6 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define _GNU_SOURCE
#include
#include
#include
@@ -88,7 +89,7 @@ STATIC const UINT8 g_montbl[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
#ifndef OFFSET_TO_MINUTE
#define OFFSET_TO_MINUTE(time) (((time) < 0) ? (-(time)) : (time))
#endif
-/* The highest 31 bytes, 1 indicates eastern time zone0 indicates western time zone */
+/* The highest 31 bytes, 1 indicates eastern time zone,0 indicates western time zone */
#ifndef TIME_ZONE_SIGN
#define TIME_ZONE_SIGN(time) ((time) >> 31)
#endif
@@ -96,8 +97,7 @@ STATIC const UINT8 g_montbl[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
#define DIV(a, b) (((a) / (b)) - ((a) % (b) < 0))
#define LEAPS_THRU_END_OF(y) (DIV (y, 4) - DIV (y, 100) + DIV (y, 400))
-/* 946656000000ms is the UTC 2000-01-01 00:00:00 */
-static UINT64 g_rtcTimeBase = 946656000000;
+static UINT64 g_rtcTimeBase = 0;
static UINT64 g_systickBase = 0;
/*
@@ -291,7 +291,7 @@ int timer_gettime(timer_t timerID, struct itimerspec *value)
{
UINT32 tick = 0;
SWTMR_CTRL_S *swtmr = NULL;
- UINT32 swtmrID = (UINT16)(UINTPTR)timerID;
+ UINT32 swtmrID = (UINT32)(UINTPTR)timerID;
UINT32 ret;
if (value == NULL) {
@@ -491,8 +491,6 @@ time_t time(time_t *timer)
UINT64 usec = 0;
time_t sec;
INT32 rtcRet;
- UINT32 offsetSec;
- HalGetRtcTimeZone(&g_rtcTimeZone);
rtcRet = HalGetRtcTime(&usec);
if (rtcRet != 0) {
@@ -507,12 +505,7 @@ time_t time(time_t *timer)
} else {
sec = usec / OS_SYS_US_PER_SECOND;
}
- offsetSec = (OFFSET_TO_MINUTE(g_rtcTimeZone)) * SECS_PER_MIN;
- if (TIME_ZONE_SIGN(g_rtcTimeZone)) {
- sec += (time_t)offsetSec;
- } else {
- sec -= (time_t)offsetSec;
- }
+
if (timer != NULL) {
*timer = sec;
}
@@ -727,4 +720,4 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
HalSetRtcTime(g_rtcTimeBase, &usec);
HalSetRtcTimeZone(g_rtcTimeZone);
return 0;
-}
\ No newline at end of file
+}
diff --git a/kernel/BUILD.gn b/kernel/BUILD.gn
new file mode 100644
index 00000000..1853f638
--- /dev/null
+++ b/kernel/BUILD.gn
@@ -0,0 +1,66 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("kernel") {
+ sources = [
+ "src/los_event.c",
+ "src/los_init.c",
+ "src/los_mux.c",
+ "src/los_queue.c",
+ "src/los_sem.c",
+ "src/los_swtmr.c",
+ "src/los_task.c",
+ "src/los_tick.c",
+ "src/mm/los_membox.c",
+ "src/mm/los_memory.c",
+ ]
+
+ include_dirs = [
+ "include",
+ "arch/include",
+ "../components/cpup",
+ "../components/exchook",
+ "../utils",
+ "//third_party/bounds_checking_function/include",
+ ]
+
+ if ("$board_cpu" == "cortex-m3") {
+ deps = [ "arch/arm/cortex-m3/gcc/:arch" ]
+ } else if ("$board_cpu" == "cortex-m4") {
+ deps = [ "arch/arm/cortex-m4/gcc/:arch" ]
+ } else if ("$board_cpu" == "cortex-m7") {
+ deps = [ "arch/arm/cortex-m7/gcc/:arch" ]
+ } else if ("$board_cpu" == "cortex-m33") {
+ deps = [ "arch/arm/cortex-m33/gcc/:arch" ]
+ } else if ("$board_cpu" == "") {
+ if ("$board_arch" == "rv32imac" || "$board_arch" == "rv32imafdc") {
+ deps = [ "arch/risc-v/riscv32/gcc:arch" ]
+ }
+ }
+}
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/CMSIS END USER LICENCE AGREEMENT.pdf b/kernel/arch/arm/cortex-m3/keil/cmsis/CMSIS END USER LICENCE AGREEMENT.pdf
new file mode 100644
index 00000000..aabdddc5
Binary files /dev/null and b/kernel/arch/arm/cortex-m3/keil/cmsis/CMSIS END USER LICENCE AGREEMENT.pdf differ
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/LICENSE b/kernel/arch/arm/cortex-m3/keil/cmsis/LICENSE
new file mode 100644
index 00000000..d7019a32
--- /dev/null
+++ b/kernel/arch/arm/cortex-m3/keil/cmsis/LICENSE
@@ -0,0 +1,25 @@
+Copyright (c) 2009 - 2013 ARM LIMITED
+
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+- Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+- Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+- Neither the name of ARM nor the names of its contributors may be used
+ to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/README.OpenSource b/kernel/arch/arm/cortex-m3/keil/cmsis/README.OpenSource
new file mode 100755
index 00000000..648a9025
--- /dev/null
+++ b/kernel/arch/arm/cortex-m3/keil/cmsis/README.OpenSource
@@ -0,0 +1,11 @@
+[
+ {
+ "Name" : "CMSIS",
+ "License" : "BSD 3-Clause License",
+ "License File" : "LICENSE",
+ "Version Number" : "3.2",
+ "Owner" : "denny.shenwei@huawei.com",
+ "Upstream URL" : "http://www.arm.com/zh/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php",
+ "Description" : "The Cortex Microcontroller Software Interface Standard (CMSIS) is a vendor-independent hardware abstraction layer for microcontrollers that are based on Arm® Cortex® processors"
+ }
+]
diff --git a/kernel/arch/arm/cortex-m3/keil/cmsis/README.txt b/kernel/arch/arm/cortex-m3/keil/cmsis/README.txt
new file mode 100644
index 00000000..d4872be6
--- /dev/null
+++ b/kernel/arch/arm/cortex-m3/keil/cmsis/README.txt
@@ -0,0 +1,37 @@
+* -------------------------------------------------------------------
+* Copyright (C) 2011-2013 ARM Limited. All rights reserved.
+*
+* Date: 18 March 2013
+* Revision: V3.20
+*
+* Project: Cortex Microcontroller Software Interface Standard (CMSIS)
+* Title: Release Note for CMSIS
+*
+* -------------------------------------------------------------------
+
+
+NOTE - Open the index.html file to access CMSIS documentation
+
+
+The Cortex Microcontroller Software Interface Standard (CMSIS) provides a single standard across all
+Cortex-Mx processor series vendors. It enables code re-use and code sharing across software projects
+and reduces time-to-market for new embedded applications.
+
+CMSIS is released under the terms of the end user license agreement ("CMSIS END USER LICENCE AGREEMENT.pdf").
+Any user of the software package is bound to the terms and conditions of the end user license agreement.
+
+
+You will find the following sub-directories:
+
+Documentation - Contains CMSIS documentation.
+
+DSP_Lib - MDK project files, Examples and source files etc.. to build the
+ CMSIS DSP Software Library for Cortex-M0, Cortex-M3, Cortex-M4 processors.
+
+Include - CMSIS Core Support and CMSIS DSP Include Files.
+
+Lib - CMSIS DSP Libraries.
+
+RTOS - CMSIS RTOS API template header file.
+
+SVD - CMSIS SVD Schema files and Conversion Utility.
diff --git a/kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h b/kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h
index 2e6121c3..e57c6a9b 100644
--- a/kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_atomic.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -56,7 +56,6 @@ extern "C" {
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
diff --git a/kernel/arch/arm/cortex-m3/keil/los_arch_context.h b/kernel/arch/arm/cortex-m3/keil/los_arch_context.h
index 4759cb69..972f2fde 100644
--- a/kernel/arch/arm/cortex-m3/keil/los_arch_context.h
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_context.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h b/kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
index 3ffd4bff..b3ab442f 100755
--- a/kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
#if (OS_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
diff --git a/kernel/arch/arm/cortex-m3/keil/los_arch_timer.h b/kernel/arch/arm/cortex-m3/keil/los_arch_timer.h
index 2f38c220..59159c0c 100644
--- a/kernel/arch/arm/cortex-m3/keil/los_arch_timer.h
+++ b/kernel/arch/arm/cortex-m3/keil/los_arch_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m3/keil/los_context.c b/kernel/arch/arm/cortex-m3/keil/los_context.c
index 0534d705..72e33a02 100755
--- a/kernel/arch/arm/cortex-m3/keil/los_context.c
+++ b/kernel/arch/arm/cortex-m3/keil/los_context.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -149,17 +149,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
-void HalBackTrace()
-{
-}
-
-#if (LOSCFG_MEM_LEAKCHECK == 1)
-VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
- UINTPTR stackStart, UINTPTR stackEnd)
-{
-}
-#endif
-
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;
diff --git a/kernel/arch/arm/cortex-m3/keil/los_dispatch.S b/kernel/arch/arm/cortex-m3/keil/los_dispatch.S
index be6145e1..ba53feb6 100644
--- a/kernel/arch/arm/cortex-m3/keil/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m3/keil/los_dispatch.S
@@ -1,6 +1,6 @@
;
-; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
-; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+; Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without modification,
; are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m3/keil/los_exc.S b/kernel/arch/arm/cortex-m3/keil/los_exc.S
index 65e17a52..2da36fb4 100644
--- a/kernel/arch/arm/cortex-m3/keil/los_exc.S
+++ b/kernel/arch/arm/cortex-m3/keil/los_exc.S
@@ -1,6 +1,6 @@
;
-; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
-; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+; Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without modification,
; are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m3/keil/los_interrupt.c b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c
index 824c20e5..3ac32488 100755
--- a/kernel/arch/arm/cortex-m3/keil/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m3/keil/los_interrupt.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -51,12 +51,56 @@ UINT32 g_intCount = 0;
#pragma data_alignment=0x100
LITE_OS_SEC_VEC
#endif
-HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
-HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_HANDLER_FUNC;
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
+ }
+}
+
#else
-HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
+ }
+}
#endif
__weak VOID SysTick_Handler(VOID)
@@ -132,12 +176,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
- if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
- g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
+ if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
+ g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
- if (g_hwiSlaveForm[hwiIndex] != 0) {
- g_hwiSlaveForm[hwiIndex]();
+ if (g_hwiHandlerForm[hwiIndex] != 0) {
+ g_hwiHandlerForm[hwiIndex]();
}
#endif
diff --git a/kernel/arch/arm/cortex-m3/keil/los_startup.s b/kernel/arch/arm/cortex-m3/keil/los_startup.s
index 876e597e..04b99451 100644
--- a/kernel/arch/arm/cortex-m3/keil/los_startup.s
+++ b/kernel/arch/arm/cortex-m3/keil/los_startup.s
@@ -1,26 +1,38 @@
-;/*----------------------------------------------------------------------------
-;* Huawei - LiteOS
+;
+; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+; Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+;
+; Redistribution and use in source and binary forms, with or without modification,
+; are permitted provided that the following conditions are met:
+;
+; 1. Redistributions of source code must retain the above copyright notice, this list of
+; conditions and the following disclaimer.
+;
+; 2. Redistributions in binary form must reproduce the above copyright notice, this list
+; of conditions and the following disclaimer in the documentation and/or other materials
+; provided with the distribution.
+;
+; 3. Neither the name of the copyright holder nor the names of its contributors may be used
+; to endorse or promote products derived from this software without specific prior written
+; permission.
+;
+; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+; THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+; PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+; CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+; EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+; OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+; ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+;
;*----------------------------------------------------------------------------
;* Name: LOS_VENDOR.S
;* Purpose: Thread scheduler
;* Rev.: V1.0.0
;*----------------------------------------------------------------------------
-;*
-
-;* Copyright (c) 2014, Huawei Technologies Co., Ltd.
-;* All rights reserved.
-;* Permission to use, copy, modify, and distribute this software for any
-;* purpose with or without fee is hereby granted, provided that the above
-;* copyright notice and this permission notice appear in all copies.
-
-;*THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-;*WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-;*MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-;*ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-;*WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-;*ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-;*OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-;*---------------------------------------------------------------------------*/
PRESERVE8
diff --git a/kernel/arch/arm/cortex-m3/keil/los_timer.c b/kernel/arch/arm/cortex-m3/keil/los_timer.c
index 572ffe18..dd0e4a46 100755
--- a/kernel/arch/arm/cortex-m3/keil/los_timer.c
+++ b/kernel/arch/arm/cortex-m3/keil/los_timer.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -67,6 +67,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
+ g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
diff --git a/kernel/arch/arm/cortex-m33/gcc/BUILD.gn b/kernel/arch/arm/cortex-m33/gcc/BUILD.gn
new file mode 100644
index 00000000..d289c391
--- /dev/null
+++ b/kernel/arch/arm/cortex-m33/gcc/BUILD.gn
@@ -0,0 +1,46 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("arch") {
+ sources = [
+ "los_context.c",
+ "los_dispatch.S",
+ "los_exc.S",
+ "los_interrupt.c",
+ "los_timer.c",
+ ]
+
+ include_dirs = [
+ "../../../../../kernel/arch/include",
+ "../../../../../kernel/include",
+ "../../../../../utils",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_arch_atomic.h b/kernel/arch/arm/cortex-m33/gcc/los_arch_atomic.h
index 2e6121c3..e57c6a9b 100644
--- a/kernel/arch/arm/cortex-m33/gcc/los_arch_atomic.h
+++ b/kernel/arch/arm/cortex-m33/gcc/los_arch_atomic.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -56,7 +56,6 @@ extern "C" {
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_arch_context.h b/kernel/arch/arm/cortex-m33/gcc/los_arch_context.h
index 4759cb69..972f2fde 100644
--- a/kernel/arch/arm/cortex-m33/gcc/los_arch_context.h
+++ b/kernel/arch/arm/cortex-m33/gcc/los_arch_context.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_arch_interrupt.h b/kernel/arch/arm/cortex-m33/gcc/los_arch_interrupt.h
index 3ffd4bff..b3ab442f 100755
--- a/kernel/arch/arm/cortex-m33/gcc/los_arch_interrupt.h
+++ b/kernel/arch/arm/cortex-m33/gcc/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
#if (OS_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_arch_timer.h b/kernel/arch/arm/cortex-m33/gcc/los_arch_timer.h
index 2f38c220..59159c0c 100644
--- a/kernel/arch/arm/cortex-m33/gcc/los_arch_timer.h
+++ b/kernel/arch/arm/cortex-m33/gcc/los_arch_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_context.c b/kernel/arch/arm/cortex-m33/gcc/los_context.c
index f15654fa..a9f795b3 100644
--- a/kernel/arch/arm/cortex-m33/gcc/los_context.c
+++ b/kernel/arch/arm/cortex-m33/gcc/los_context.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_dispatch.S b/kernel/arch/arm/cortex-m33/gcc/los_dispatch.S
index aa56c140..298e7409 100644
--- a/kernel/arch/arm/cortex-m33/gcc/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m33/gcc/los_dispatch.S
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_exc.S b/kernel/arch/arm/cortex-m33/gcc/los_exc.S
index 36d25456..16116b09 100644
--- a/kernel/arch/arm/cortex-m33/gcc/los_exc.S
+++ b/kernel/arch/arm/cortex-m33/gcc/los_exc.S
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c b/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c
index dfd3135e..1313dc7a 100755
--- a/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m33/gcc/los_interrupt.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -46,12 +46,56 @@ UINT32 g_intCount = 0;
/*lint -restore*/
-HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
-HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_HANDLER_FUNC;
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
+ }
+}
+
#else
-HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
+ }
+}
#endif
/* ****************************************************************************
@@ -122,12 +166,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
- if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
- g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
+ if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
+ g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
- if (g_hwiSlaveForm[hwiIndex] != 0) {
- g_hwiSlaveForm[hwiIndex]();
+ if (g_hwiHandlerForm[hwiIndex] != 0) {
+ g_hwiHandlerForm[hwiIndex]();
}
#endif
diff --git a/kernel/arch/arm/cortex-m33/gcc/los_timer.c b/kernel/arch/arm/cortex-m33/gcc/los_timer.c
index de38c3b0..5e7cffa1 100644
--- a/kernel/arch/arm/cortex-m33/gcc/los_timer.c
+++ b/kernel/arch/arm/cortex-m33/gcc/los_timer.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -66,6 +66,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
+ g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
diff --git a/kernel/arch/arm/cortex-m4/gcc/BUILD.gn b/kernel/arch/arm/cortex-m4/gcc/BUILD.gn
new file mode 100644
index 00000000..d97c5a6d
--- /dev/null
+++ b/kernel/arch/arm/cortex-m4/gcc/BUILD.gn
@@ -0,0 +1,47 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("arch") {
+ sources = [
+ "los_context.c",
+ "los_dispatch.S",
+ "los_exc.S",
+ "los_interrupt.c",
+ "los_mpu.c",
+ "los_timer.c",
+ ]
+
+ include_dirs = [
+ "../../../../../kernel/arch/include",
+ "../../../../../kernel/include",
+ "../../../../../utils",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_arch_atomic.h b/kernel/arch/arm/cortex-m4/gcc/los_arch_atomic.h
index 2e6121c3..e57c6a9b 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_arch_atomic.h
+++ b/kernel/arch/arm/cortex-m4/gcc/los_arch_atomic.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -56,7 +56,6 @@ extern "C" {
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_arch_context.h b/kernel/arch/arm/cortex-m4/gcc/los_arch_context.h
index 4759cb69..9dd2a874 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_arch_context.h
+++ b/kernel/arch/arm/cortex-m4/gcc/los_arch_context.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -41,7 +41,7 @@ extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
-typedef struct tagTskContext {
+typedef struct TagTskContext {
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S16;
@@ -128,4 +128,3 @@ extern VOID HalStartToRun(VOID);
#endif /* __cpluscplus */
#endif /* _LOS_ARCH_CONTEXT_H */
-
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_arch_interrupt.h b/kernel/arch/arm/cortex-m4/gcc/los_arch_interrupt.h
index 6a271023..7582b28f 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_arch_interrupt.h
+++ b/kernel/arch/arm/cortex-m4/gcc/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
#if (OS_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
@@ -461,6 +434,8 @@ extern VOID HalPendSV(VOID);
#define OS_NVIC_INT_ENABLE_SIZE 0x20
#define OS_NVIC_INT_PRI_SIZE 0xF0
#define OS_NVIC_EXCPRI_SIZE 0xC
+#define OS_NVIC_INT_CTRL_SIZE 4
+#define OS_NVIC_SHCSR_SIZE 4
#define OS_NVIC_INT_PEND_SIZE OS_NVIC_INT_ACT_SIZE
#define OS_NVIC_INT_ACT_SIZE OS_NVIC_INT_ENABLE_SIZE
@@ -474,15 +449,14 @@ extern VOID HalPendSV(VOID);
#define OS_EXC_EVENT 0x00000001
/**
- *@ingroup los_exc
+ * @ingroup los_exc
* the struct of register files
*
* description: the register files that saved when exception triggered
*
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
*/
-typedef struct tagExcContext {
- //handler save
+typedef struct TagExcContext {
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
UINT32 S16;
@@ -511,7 +485,7 @@ typedef struct tagExcContext {
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
- //auto save
+ /* auto save */
UINT32 uwSP;
UINT32 uwR0;
UINT32 uwR1;
@@ -557,7 +531,7 @@ VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT
* @attention:
*
*
- *@param uwArraySize [IN] Memory size of exception.
+ * @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
@@ -576,202 +550,164 @@ VOID HalHwiInit();
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the bus status register was being pushed.
*/
#define OS_EXC_BF_STKERR 1
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the bus status register was out of the stack.
*/
#define OS_EXC_BF_UNSTKERR 2
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Bus status register imprecise data access violation.
*/
#define OS_EXC_BF_IMPRECISERR 3
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Bus status register exact data access violation.
*/
#define OS_EXC_BF_PRECISERR 4
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Bus status register access violation while pointing.
*/
#define OS_EXC_BF_IBUSERR 5
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the memory management status register was being pushed.
*/
#define OS_EXC_MF_MSTKERR 6
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the memory management status register was out of the stack.
*/
#define OS_EXC_MF_MUNSTKERR 7
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Memory management status register data access violation.
*/
#define OS_EXC_MF_DACCVIOL 8
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Memory management status register access violation.
*/
#define OS_EXC_MF_IACCVIOL 9
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
+ * @ingroup los_exc
+ * Cortex-M4 exception types: ncorrect usage indicating that the divisor is zero during the division operation.
*/
#define OS_EXC_UF_DIVBYZERO 10
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Usage error, error caused by unaligned access.
*/
#define OS_EXC_UF_UNALIGNED 11
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Incorrect usage attempting to execute coprocessor related instruction.
*/
#define OS_EXC_UF_NOCP 12
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,在异常返回时试图非法地加载EXC_RETURN到PC
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
*/
#define OS_EXC_UF_INVPC 13
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图切入ARM状态
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Incorrect usage, attempting to cut to ARM state.
*/
#define OS_EXC_UF_INVSTATE 14
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Incorrect usage. Executed instruction whose code is undefined.
*/
#define OS_EXC_UF_UNDEFINSTR 15
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:NMI中断
+ * @ingroup los_exc
+ * Cortex-M4 exception types: NMI
*/
#define OS_EXC_CAUSE_NMI 16
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:硬fault
+ * @ingroup los_exc
+ * Cortex-M4 exception types: hard fault
*/
#define OS_EXC_CAUSE_HARDFAULT 17
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:任务处理函数退出
+ * @ingroup los_exc
+ * Cortex-M4 exception types: The task handler exits.
*/
#define OS_EXC_CAUSE_TASK_EXIT 18
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:致命错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: A fatal error.
*/
#define OS_EXC_CAUSE_FATAL_ERR 19
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:调试事件导致的硬fault
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Hard Fault caused by a debug event.
*/
#define OS_EXC_CAUSE_DEBUGEVT 20
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:取向量时发生的硬fault
+ * @ingroup los_exc
+ * Cortex-M4 exception types: A hard fault that occurs when a quantity is oriented.
*/
#define OS_EXC_CAUSE_VECTBL 21
/**
- *@ingroup los_exc
- * 异常信息结构体
+ * @ingroup los_exc
+ * Exception information structure
*
- * 描述:M4平台下的异常触发时保存的异常信息
+ * Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
*
*/
-typedef struct tagExcInfo {
- /**< 异常发生阶段: 0表示异常发生在初始化中,1表示异常发生在任务中,2表示异常发生在中断中 */
+typedef struct TagExcInfo {
+ /**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
- /**< 异常类型,出异常时对照上面列出的1-19号 */
+ /**< Exception type. When exceptions occur, check the numbers 1 - 19 listed above */
UINT16 type;
- /**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
+ /**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
- /**< 在中断中发生异常,表示中断号。在任务中发生异常,表示任务id,如果发生在初始化中,则为0xffffffff */
+ /**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
- /**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
+ /**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
UINT16 nestCnt;
- /**< 保留 */
+ /**< reserve */
UINT16 reserved;
- /**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
- EXC_CONTEXT_S * context;
+ /**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
+ EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
extern UINT32 g_intCount;
-
-static VOID OsExcSave2DDR(VOID);
-VOID OsExcInfoDisplay(ExcInfo *exc);
-
extern UINT8 g_uwExcTbl[32];
+extern ExcInfo g_excInfo;
-
-
-typedef struct tagExcInfoCallBackArray {
- ExcInfoType uwType;
- UINT32 uwValid;
- EXC_INFO_SAVE_CALLBACK pFnExcInfoCb;
- VOID* pArg;
-} ExcInfoArray;
-
-
-
-#define MAX_SCENE_INFO_SIZE (8 + sizeof(ExcInfo) - 4 + sizeof(EXC_CONTEXT_S))
-#define MAX_TSK_INFO_SIZE (8 + sizeof(TSK_INFO_S) * (LOSCFG_BASE_CORE_TSK_LIMIT + 1))
#define MAX_INT_INFO_SIZE (8 + 0x164)
-#if (LOSCFG_BASE_IPC_QUEUE == 1)
-#define MAX_QUEUE_INFO_SIZE (8 + sizeof(QUEUE_INFO_S) * LOSCFG_BASE_IPC_QUEUE_LIMIT)
-#else
-#define MAX_QUEUE_INFO_SIZE (0)
-#endif
-
-#if (LOSCFG_BASE_CORE_EXC_TSK_SWITCH == 1)
-#define MAX_SWITCH_INFO_SIZE (8 + (sizeof(UINT32) + sizeof(CHAR) * LOS_TASK_NAMELEN) * OS_TASK_SWITCH_INFO_COUNT)
-#else
-#define MAX_SWITCH_INFO_SIZE (0)
-#endif
-
-#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
-#define MAX_MEM_INFO_SIZE (8 + sizeof(MEM_INFO_S) * OS_SYS_MEM_NUM)
-#else
-#define MAX_MEM_INFO_SIZE (0)
-#endif
-
-#define MAX_EXC_MEM_SIZE ( 4 + MAX_SCENE_INFO_SIZE + MAX_TSK_INFO_SIZE + MAX_QUEUE_INFO_SIZE + MAX_INT_INFO_SIZE + MAX_SWITCH_INFO_SIZE + MAX_MEM_INFO_SIZE + 4)
-
-
-
#ifdef __cplusplus
#if __cplusplus
}
@@ -779,4 +715,3 @@ typedef struct tagExcInfoCallBackArray {
#endif /* __cpluscplus */
#endif /* _LOS_EXC_H */
-
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_arch_timer.h b/kernel/arch/arm/cortex-m4/gcc/los_arch_timer.h
index 2f38c220..59159c0c 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_arch_timer.h
+++ b/kernel/arch/arm/cortex-m4/gcc/los_arch_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_context.c b/kernel/arch/arm/cortex-m4/gcc/los_context.c
index f15654fa..52dd0013 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_context.c
+++ b/kernel/arch/arm/cortex-m4/gcc/los_context.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -28,11 +28,12 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_config.h"
-#include "los_task.h"
+
+#include "los_context.h"
#include "securec.h"
-#include "los_interrupt.h"
#include "los_arch_context.h"
+#include "los_task.h"
+#include "los_interrupt.h"
#include "los_arch_interrupt.h"
#include "los_arch_timer.h"
@@ -64,7 +65,8 @@ LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
{
LOS_IntLock();
- for(;;);
+ while (1) {
+ }
}
/* ****************************************************************************
@@ -149,11 +151,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
-void HalBackTrace()
-{
-
-}
-
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;
@@ -170,5 +167,3 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
}
#endif /* __cplusplus */
#endif /* __cplusplus */
-
-
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_dispatch.S b/kernel/arch/arm/cortex-m4/gcc/los_dispatch.S
index 78523d94..648cb7c9 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m4/gcc/los_dispatch.S
@@ -1,7 +1,40 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
.syntax unified
.arch armv7e-m
+.fpu fpv5-d16
.thumb
+.equ OS_FPU_CPACR, 0xE000ED88
+.equ OS_FPU_CPACR_ENABLE, 0x00F00000
.equ OS_NVIC_INT_CTRL, 0xE000ED04
.equ OS_NVIC_SYSPRI2, 0xE000ED20
.equ OS_NVIC_PENDSV_PRI, 0xF0F00000
@@ -42,15 +75,31 @@ HalStartToRun:
strh r7, [r0 , #4]
ldr r12, [r0]
+
+ ldr.w r1, =OS_FPU_CPACR
+ ldr r1, [r1]
+ and r1, r1, #OS_FPU_CPACR_ENABLE
+ cmp r1, #OS_FPU_CPACR_ENABLE
+ bne __DisabledFPU
+ add r12, r12, #100
+
+ ldmfd r12!, {R0-R7}
+ add r12, r12, #72
+ msr psp, r12
+ vpush {s0}
+ vpop {s0}
+ mov lr, r5
+ cpsie i
+ bx r6
+
+__DisabledFPU:
add r12, r12, #36
ldmfd r12!, {r0-r7}
msr psp, r12
mov lr, r5
-
cpsie I
bx r6
-
.fnend
@@ -111,11 +160,17 @@ HalPendSV:
cpsid I
HalTaskSwitch:
-
mrs r0, psp
stmfd r0!, {r4-r12}
+ ldr.w r3, =OS_FPU_CPACR
+ ldr r3, [r3]
+ and r3, r3, #OS_FPU_CPACR_ENABLE
+ cmp r3, #OS_FPU_CPACR_ENABLE
+ bne __DisabledFPU1
+ vstmdb r0!, {d8-d15}
+__DisabledFPU1:
ldr r5, =g_losTask
ldr r6, [r5]
str r0, [r6]
@@ -137,13 +192,16 @@ HalTaskSwitch:
orr r7, r7, r8
strh r7, [r0 , #4]
- ldr r1, [r0]
+ ldr r1, [r0]
+ and r3, r3, #OS_FPU_CPACR_ENABLE
+ cmp r3, #OS_FPU_CPACR_ENABLE
+ bne __DisabledFPU2
+ vldmia r1!, {d8-d15}
+__DisabledFPU2:
ldmfd r1!, {r4-r12}
msr psp, r1
msr PRIMASK, r12
-
-
bx lr
.fnend
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_exc.S b/kernel/arch/arm/cortex-m4/gcc/los_exc.S
index 2b6df84e..5de06ad5 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_exc.S
+++ b/kernel/arch/arm/cortex-m4/gcc/los_exc.S
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -224,7 +224,7 @@ HalExcUsageFault:
LDR R0, =OS_NVIC_FSR
LDR R0, [R0]
- MOV R1, #0x030F
+ MOVW R1, #0x030F
LSL R1, R1, #16
AND R0, R0, R1
MOV R12, #0
@@ -281,7 +281,7 @@ _ExcInMSP:
PUSH {R3}
MRS R12, PRIMASK // store message-->exc: disable int?
PUSH {R4-R12} // store message-->exc: {R4-R12}
- #VPUSH {D8-D15} // FPU
+ #VPUSH {D8-D15} // FPU
B _handleEntry
.fnend
@@ -291,10 +291,10 @@ _NoFloatInMsp:
.fnstart
.cantunwind
ADD R3, R13, #32
- PUSH {R3} // save IRQ SP // store message-->exc: MSP(R13)
+ PUSH {R3} // store message-->exc: MSP(R13)
- MRS R12, PRIMASK // store message-->exc: disable int?
- PUSH {R4-R12} // store message-->exc: {R4-R12}
+ MRS R12, PRIMASK // store message-->exc: disable int?
+ PUSH {R4-R12} // store message-->exc: {R4-R12}
ORR R0, R0, #FLAG_NO_FLOAT
B _handleEntry
.fnend
@@ -320,7 +320,7 @@ _hwiActiveCheckNext:
LDR R2, =g_taskScheduled
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
@@ -333,7 +333,7 @@ _hwiActiveCheckNext:
MRS R3, PSP
ADD R12, R3, #104
- PUSH {R12} // save task SP
+ PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
@@ -341,8 +341,8 @@ _hwiActiveCheckNext:
// copy auto saved task register
LDMFD R3!, {R4-R11} // R4-R11 store PSP reg(auto push when exc in task)
- #VLDMIA R3!, {D8-D15} // FPU
- #VSTMDB R2!, {D8-D15} // FPU
+ #VLDMIA R3!, {D8-D15} // FPU
+ #VSTMDB R2!, {D8-D15} // FPU
STMFD R2!, {R4-R11}
B _handleEntry
.fnend
@@ -352,12 +352,12 @@ _hwiActiveCheckNext:
_NoFloatInPsp:
.fnstart
.cantunwind
- MOV R2, R13 //no auto push floating registers
+ MOV R2, R13 //no auto push floating registers
SUB R13, #32 // add 8 Bytes reg(for STMFD)
MRS R3, PSP
ADD R12, R3, #32
- PUSH {R12} // save task SP
+ PUSH {R12} // save task SP
MRS R12, PRIMASK
PUSH {R4-R12}
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c b/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c
index 132c00c8..e9306787 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m4/gcc/los_interrupt.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,12 +29,11 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
+#include
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include
#include "los_debug.h"
#include "los_task.h"
-#include "los_tick.h"
#ifdef __cplusplus
#if __cplusplus
@@ -43,8 +42,8 @@ extern "C" {
#endif /* __cplusplus */
/*lint -save -e40 -e522 -e533*/
-
UINT32 g_intCount = 0;
+
/*lint -restore*/
#ifdef __ICCARM__
#pragma location = ".data.vector"
@@ -52,14 +51,63 @@ UINT32 g_intCount = 0;
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
#endif
-HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
-HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_HANDLER_FUNC;
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
+ }
+}
+
#else
-HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
+ }
+}
#endif
+WEAK VOID SysTick_Handler(VOID)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalIntNumGet
Description : Get a interrupt number
@@ -91,6 +139,16 @@ LITE_OS_SEC_TEXT_MINOR VOID HalHwiDefaultHandler(VOID)
while (1) {}
}
+WEAK VOID HalPreInterruptHandler(UINT32 arg)
+{
+ return;
+}
+
+WEAK VOID HalAftInterruptHandler(UINT32 arg)
+{
+ return;
+}
+
/* ****************************************************************************
Function : HalInterrupt
Description : Hardware interrupt entry function
@@ -115,15 +173,20 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
hwiIndex = HalIntNumGet();
+ HalPreInterruptHandler(hwiIndex);
+
#if (OS_HWI_WITH_ARG == 1)
- if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
- g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
+ if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
+ g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
- if (g_hwiSlaveForm[hwiIndex] != 0) {
- g_hwiSlaveForm[hwiIndex]();
+ if (g_hwiHandlerForm[hwiIndex] != 0) {
+ g_hwiHandlerForm[hwiIndex]();
}
#endif
+
+ HalAftInterruptHandler(hwiIndex);
+
intSave = LOS_IntLock();
g_intCount--;
LOS_IntRestore(intSave);
@@ -141,10 +204,10 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T mode,
- HWI_PROC_FUNC handler,
- HWI_ARG_T arg)
+ HWI_PRIOR_T hwiPrio,
+ HWI_MODE_T mode,
+ HWI_PROC_FUNC handler,
+ HWI_ARG_T arg)
{
UINTPTR intSave;
@@ -204,8 +267,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
return LOS_OK;
}
-#define OS_NVIC_INT_CTRL_SIZE 4
-#define OS_NVIC_SHCSR_SIZE 4
#define FAULT_STATUS_REG_BIT 32
#define USGFAULT (1 << 18)
#define BUSFAULT (1 << 17)
@@ -213,9 +274,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
#define DIV0FAULT (1 << 4)
#define HARDFAULT_IRQN (-13)
-static ExcInfoArray g_excArray[OS_EXC_TYPE_MAX];
-
-static ExcInfo g_excInfo = {0};
+ExcInfo g_excInfo = {0};
UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
0, 0, 0, 0, 0, 0, OS_EXC_UF_DIVBYZERO, OS_EXC_UF_UNALIGNED,
@@ -224,15 +283,20 @@ UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
0, 0, 0, OS_EXC_MF_MSTKERR, OS_EXC_MF_MUNSTKERR, 0, OS_EXC_MF_DACCVIOL, OS_EXC_MF_IACCVIOL
};
+#if (LOSCFG_KERNEL_PRINTF != 0)
UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
{
UINT32 *base = NULL;
- UINT32 len = 0, i, j;
+ UINT32 len, i, j;
#define OS_NR_NVIC_EXC_DUMP_Types 7
- UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE,
- OS_NVIC_INT_ACT_BASE, OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL};
- UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE,
- OS_NVIC_INT_ACT_SIZE, OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE};
+ UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_Types] = {
+ OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE, OS_NVIC_INT_ACT_BASE,
+ OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL
+ };
+ UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {
+ OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, OS_NVIC_INT_ACT_SIZE,
+ OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE
+ };
char strRgEnable[] = "enable";
char strRgPending[] = "pending";
char strRgActive[] = "active";
@@ -240,7 +304,10 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
char strRgException[] = "exception";
char strRgShcsr[] = "shcsr";
char strRgIntCtrl[] = "control";
- char *strRgs[] = {strRgEnable, strRgPending, strRgActive, strRgPriority, strRgException, strRgShcsr, strRgIntCtrl};
+ char *strRgs[] = {
+ strRgEnable, strRgPending, strRgActive, strRgPriority,
+ strRgException, strRgShcsr, strRgIntCtrl
+ };
(VOID)index;
(VOID)excContent;
@@ -249,7 +316,7 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
base = (UINT32 *)rgNvicBases[i];
len = rgNvicLens[i];
PRINTK("interrupt %s register, base address: 0x%x, size: 0x%x\n", strRgs[i], base, len);
- len = (len >> 2);
+ len = (len >> 2); /* 2: Gets the next register offset */
for (j = 0; j < len; j++) {
PRINTK("0x%x ", *(base + j));
}
@@ -257,6 +324,7 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
}
return 0;
}
+#endif
UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
{
@@ -288,20 +356,9 @@ UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
return 0;
}
-VOID HalDumpMsg(VOID)
-{
- UINT32 index = 0;
- for (index = 0; index < (OS_EXC_TYPE_MAX - 1); index++) {
- if (g_excArray[index].uwValid == FALSE) {
- continue;
- }
- g_excArray[index].pFnExcInfoCb(index, g_excArray[index].pArg);
- }
-}
-
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
{
- UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT;
+ UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; /* 16: Get Exception Type */
g_intCount++;
g_excInfo.nestCnt++;
@@ -329,22 +386,9 @@ LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, U
} else {
g_excInfo.context = excBufAddr;
}
- HalDumpMsg();
- HalSysExit();
-}
-VOID HalExcRegister(ExcInfoType type, EXC_INFO_SAVE_CALLBACK func, VOID *arg)
-{
- ExcInfoArray *excInfo = NULL;
- if ((type >= OS_EXC_TYPE_MAX) || (func == NULL)) {
- PRINT_ERR("HalExcRegister ERROR!\n");
- return;
- }
- excInfo = &(g_excArray[type]);
- excInfo->uwType = type;
- excInfo->pFnExcInfoCb = func;
- excInfo->pArg = arg;
- excInfo->uwValid = TRUE;
+ OsDoExcHook(EXC_INTERRUPT);
+ HalSysExit();
}
/* ****************************************************************************
@@ -360,7 +404,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
- for (index = 2; index < OS_VECTOR_CNT; index++) {
+ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
@@ -371,6 +415,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
g_hwiForm[UsageFault_IRQn + OS_SYS_VECTOR_CNT] = HalExcUsageFault;
g_hwiForm[SVCall_IRQn + OS_SYS_VECTOR_CNT] = HalExcSvcCall;
g_hwiForm[PendSV_IRQn + OS_SYS_VECTOR_CNT] = HalPendSV;
+ g_hwiForm[SysTick_IRQn + OS_SYS_VECTOR_CNT] = SysTick_Handler;
/* Interrupt vector table location */
SCB->VTOR = (UINT32)(UINTPTR)g_hwiForm;
@@ -384,9 +429,6 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
/* Enable DIV 0 and unaligned exception */
*(volatile UINT32 *)OS_NVIC_CCR |= DIV0FAULT;
- HalExcRegister(OS_EXC_TYPE_CONTEXT, (EXC_INFO_SAVE_CALLBACK)HalExcContextDump, NULL);
- HalExcRegister(OS_EXC_TYPE_NVIC, (EXC_INFO_SAVE_CALLBACK)HalExcNvicDump, NULL);
-
return;
}
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_mpu.c b/kernel/arch/arm/cortex-m4/gcc/los_mpu.c
new file mode 100644
index 00000000..07c4991c
--- /dev/null
+++ b/kernel/arch/arm/cortex-m4/gcc/los_mpu.c
@@ -0,0 +1,207 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "los_mpu.h"
+#include "los_config.h"
+#include "los_context.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
+
+#define SIZE_4G_BYTE 0x100000000
+#define MPU_MAX_REGION_NUM 16
+typedef enum {
+ MPU_AP_FORBID_USER_FORBID = 0x0, /* Privileged:No access Unprivileged:No access */
+ MPU_AP_RW_USER_FORBID = 0x1, /* Privileged:Read/Write Unprivileged:No access */
+ MPU_AP_RW_USER_RO = 0x2, /* Privileged:Read/Write Unprivileged:Read-only */
+ MPU_AP_RW_USER_RW = 0x3, /* Privileged:Read/Write Unprivileged:Read/Write */
+ MPU_AP_NA_USER_NA = 0x4, /* Privileged:UNPREDICTABLE Unprivileged:UNPREDICTABLE */
+ MPU_AP_RO_USER_FORBID = 0x5, /* Privileged:Read-only Unprivileged:No access */
+ MPU_AP_RO_USER_RO = 0x6, /* Privileged:Read-only Unprivileged:Read-only */
+} MpuApConfig;
+
+VOID HalMpuEnable(UINT32 defaultRegionEnable)
+{
+ UINTPTR intSave = HalIntLock();
+ MPU->CTRL = (MPU_CTRL_ENABLE_Msk | ((defaultRegionEnable << MPU_CTRL_PRIVDEFENA_Pos) & MPU_CTRL_PRIVDEFENA_Msk));
+ SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
+ __DSB();
+ __ISB();
+ HalIntRestore(intSave);
+}
+VOID HalMpuDisable(VOID)
+{
+ UINTPTR intSave = HalIntLock();
+ MPU->CTRL = 0;
+ __DSB();
+ __ISB();
+ HalIntRestore(intSave);
+}
+
+STATIC VOID HalMpuRASRAddMemAttr(MPU_CFG_PARA *para, UINT32 *RASR)
+{
+ BOOL cachable = 0;
+ BOOL buffable = 0;
+ switch (para->memType) {
+ case MPU_MEM_ON_CHIP_ROM:
+ case MPU_MEM_ON_CHIP_RAM:
+ cachable = 1;
+ buffable = 0;
+ break;
+ case MPU_MEM_XIP_PSRAM:
+ cachable = 1;
+ buffable = 1;
+ break;
+ case MPU_MEM_XIP_NOR_FLASH:
+ cachable = 0;
+ buffable = 1;
+ break;
+ default:
+ break;
+ }
+ (*RASR) |= ((cachable << MPU_RASR_C_Pos) | (buffable << MPU_RASR_B_Pos));
+}
+
+STATIC UINT32 HalMpuEncodeSize(UINT64 size)
+{
+ UINT32 encodeSize = 0;
+ if (size > SIZE_4G_BYTE) {
+ return 0;
+ }
+ if ((size & 0x1F) != 0) { /* size sould aligned to 32 byte at least. */
+ return 0;
+ }
+ size = (size >> 2);
+ while (size != 0) {
+ if (((size & 1) != 0) && ((size & 0xFFFFFFFE) != 0)) { /* size != 2^x (5 <= x <= 32) 128B - 4GB */
+ return 0;
+ }
+ size = (size >> 1);
+ encodeSize++;
+ }
+ return encodeSize;
+}
+
+STATIC UINT32 HalMpuEncodeAP(MpuAccessPermission permission)
+{
+ UINT32 ap;
+ switch (permission) {
+ case MPU_RW_BY_PRIVILEGED_ONLY:
+ ap = MPU_AP_RW_USER_FORBID;
+ break;
+ case MPU_RW_ANY:
+ ap = MPU_AP_RW_USER_RW;
+ break;
+ case MPU_RO_BY_PRIVILEGED_ONLY:
+ ap = MPU_AP_RO_USER_FORBID;
+ break;
+ case MPU_RO_ANY:
+ ap = MPU_AP_RO_USER_RO;
+ break;
+ default:
+ ap = MPU_AP_RW_USER_RW;
+ break;
+ }
+ return ap;
+}
+
+STATIC UINT32 HalMpuGetRASR(UINT32 encodeSize, MPU_CFG_PARA *para)
+{
+ UINT32 RASR;
+ UINT32 ap;
+ ap = HalMpuEncodeAP(para->permission);
+ RASR = MPU_RASR_ENABLE_Msk;
+ RASR |= ((encodeSize << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk);
+ RASR |= ((ap << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | ((para->executable << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) |
+ ((para->shareability << MPU_RASR_S_Pos) & MPU_RASR_S_Msk);
+ HalMpuRASRAddMemAttr(para, &RASR);
+ return RASR;
+}
+
+UINT32 HalMpuSetRegion(UINT32 regionId, MPU_CFG_PARA *para)
+{
+ UINT32 RASR;
+ UINT32 RBAR;
+ UINT32 RNR;
+ UINT32 encodeSize;
+ UINTPTR intSave;
+ UINT64 size;
+
+ if ((regionId >= MPU_MAX_REGION_NUM)||(para == NULL)) {
+ return LOS_NOK;
+ }
+ RNR = regionId;
+ encodeSize = HalMpuEncodeSize(para->size);
+ if (encodeSize == 0) {
+ return LOS_NOK;
+ }
+ size = para->size - 1; /* size aligned after encode check */
+ if ((para->baseAddr & size) != 0) { /* base addr should aligned to region size */
+ return LOS_NOK;
+ }
+ RBAR = para->baseAddr & MPU_RBAR_ADDR_Msk;
+ RASR = HalMpuGetRASR(encodeSize, para);
+ intSave = HalIntLock();
+ MPU->RNR = RNR;
+ MPU->RBAR = RBAR;
+ MPU->RASR = RASR;
+ __DSB();
+ __ISB();
+ HalIntRestore(intSave);
+ return LOS_OK;
+}
+
+UINT32 HalMpuDisableRegion(UINT32 regionId)
+{
+ volatile UINT32 type;
+ UINTPTR intSave;
+ if (regionId >= MPU_MAX_REGION_NUM) {
+ return LOS_NOK;
+ }
+ intSave = HalIntLock();
+ type = MPU->TYPE;
+ if ((MPU_TYPE_DREGION_Msk & type) != 0) {
+ MPU->RNR = regionId;
+ MPU->RASR = 0;
+ __DSB();
+ __ISB();
+ }
+ HalIntRestore(intSave);
+ return LOS_OK;
+}
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __cpluscplus */
diff --git a/kernel/arch/arm/cortex-m4/gcc/los_timer.c b/kernel/arch/arm/cortex-m4/gcc/los_timer.c
index 2486a29e..1a75deb0 100644
--- a/kernel/arch/arm/cortex-m4/gcc/los_timer.c
+++ b/kernel/arch/arm/cortex-m4/gcc/los_timer.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -28,19 +28,19 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+#include "los_timer.h"
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
-#include "los_timer.h"
#include "los_context.h"
+
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
-
-
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
@@ -48,7 +48,7 @@ Input : none
output : none
return : LOS_OK - Success , or LOS_ERRNO_TICK_CFG_INVALID - failed
**************************************************************************** */
-LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
+WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
{
UINT32 ret;
@@ -65,6 +65,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
#endif
#endif
+
+ g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
@@ -76,6 +78,15 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalTickStart(OS_TICK_HANDLER *handler)
return LOS_OK;
}
+VOID HalSysTickReload(UINT32 cyclesPerTick)
+{
+ SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
+ NVIC_ClearPendingIRQ(SysTick_IRQn);
+ SysTick->LOAD = (UINT32)(cyclesPerTick - 1UL); /* set reload register */
+ SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
+ SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
+}
+
/* ****************************************************************************
Function : HalSysTickCurrCycleGet
Description : Get System cycle count
@@ -186,46 +197,59 @@ static BOOL g_sysSleepFlag = FALSE;
VOID HalTickLock(VOID)
{
- SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
+ SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
VOID HalTickUnlock(VOID)
{
- SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
+ SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
BOOL HalGetSysSleepFlag(VOID)
{
- return g_sysSleepFlag;
+ return g_sysSleepFlag;
}
VOID HalClearSysSleepFlag(VOID)
{
- g_sysSleepFlag = FALSE;
+ g_sysSleepFlag = FALSE;
}
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
{
- __DSB();
- __WFI();
- __ISB();
+ __DSB();
+ __WFI();
+ __ISB();
}
-//extern unsigned int SystemCoreClock;
-void HalDelay(UINT32 ticks)
+WEAK VOID HalDelay(UINT32 ticks)
{
-#if 0
- UINT32 delayTimes;
- /* there are 4 machine cycle in loop */
- if ((ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES)) >= 0xffffffff) {
- delayTimes = 0xffffffff;
- } else {
- delayTimes = ticks * (SystemCoreClock / MACHINE_CYCLE_DEALAY_TIMES);
- }
- while (delayTimes) {
- delayTimes = delayTimes - 1;
- }
-#endif
+ return;
+}
+
+WEAK UINT64 HalGetExpandTick(VOID)
+{
+ return LOS_OK;
+}
+
+WEAK INT32 HalGetRtcTime(UINT64 *usec)
+{
+ return LOS_OK;
+}
+
+WEAK INT32 HalGetRtcTimeZone(INT32 *timeZone)
+{
+ return LOS_OK;
+}
+
+WEAK INT32 HalSetRtcTime(UINT64 utcTime, UINT64 *usec)
+{
+ return LOS_OK;
+}
+
+WEAK INT32 HalSetRtcTimeZone(INT32 timeZone)
+{
+ return LOS_OK;
}
#ifdef __cplusplus
diff --git a/kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h b/kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h
index 2e6121c3..e57c6a9b 100644
--- a/kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_atomic.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -56,7 +56,6 @@ extern "C" {
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
diff --git a/kernel/arch/arm/cortex-m4/iar/los_arch_context.h b/kernel/arch/arm/cortex-m4/iar/los_arch_context.h
index 4759cb69..afd1810a 100644
--- a/kernel/arch/arm/cortex-m4/iar/los_arch_context.h
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_context.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -41,7 +41,7 @@ extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
-typedef struct tagTskContext {
+typedef struct TagTskContext {
#if ((defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined(__FPU_USED) && (__FPU_USED == 1U)))
UINT32 S16;
diff --git a/kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h b/kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
index 3ffd4bff..8353a4e0 100755
--- a/kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
#if (OS_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
@@ -476,15 +449,14 @@ extern VOID HalPendSV(VOID);
#define OS_EXC_EVENT 0x00000001
/**
- *@ingroup los_exc
+ * @ingroup los_exc
* the struct of register files
*
* description: the register files that saved when exception triggered
*
* notes:the following register with prefix 'uw' correspond to the registers in the cpu data sheet.
*/
-typedef struct tagExcContext {
- //handler save
+typedef struct TagExcContext {
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
UINT32 S16;
@@ -513,7 +485,7 @@ typedef struct tagExcContext {
UINT32 uwR10;
UINT32 uwR11;
UINT32 uwPriMask;
- //auto save
+ /* auto save */
UINT32 uwSP;
UINT32 uwR0;
UINT32 uwR1;
@@ -559,7 +531,7 @@ VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT
* @attention:
*
*
- *@param uwArraySize [IN] Memory size of exception.
+ * @param uwArraySize [IN] Memory size of exception.
*
* @retval: None
* @par Dependency:
@@ -578,155 +550,155 @@ VOID HalHwiInit();
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器入栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the bus status register was being pushed.
*/
#define OS_EXC_BF_STKERR 1
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器出栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the bus status register was out of the stack.
*/
#define OS_EXC_BF_UNSTKERR 2
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器不精确的数据访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Bus status register imprecise data access violation.
*/
#define OS_EXC_BF_IMPRECISERR 3
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器精确的数据访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Bus status register exact data access violation.
*/
#define OS_EXC_BF_PRECISERR 4
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:总线状态寄存器取指时的访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Bus status register access violation while pointing.
*/
#define OS_EXC_BF_IBUSERR 5
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器入栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the memory management status register was being pushed.
*/
#define OS_EXC_MF_MSTKERR 6
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器出栈时发生错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: An error occurred while the memory management status register was out of the stack.
*/
#define OS_EXC_MF_MUNSTKERR 7
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器数据访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Memory management status register data access violation.
*/
#define OS_EXC_MF_DACCVIOL 8
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:存储器管理状态寄存器取指访问违例
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Memory management status register access violation.
*/
#define OS_EXC_MF_IACCVIOL 9
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,表示除法运算时除数为零
+ * @ingroup los_exc
+ * Cortex-M4 exception types: ncorrect usage indicating that the divisor is zero during the division operation.
*/
#define OS_EXC_UF_DIVBYZERO 10
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,未对齐访问导致的错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Usage error, error caused by unaligned access.
*/
#define OS_EXC_UF_UNALIGNED 11
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图执行协处理器相关指令
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Incorrect usage attempting to execute coprocessor related instruction.
*/
#define OS_EXC_UF_NOCP 12
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,在异常返回时试图非法地加载EXC_RETURN到PC
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Usage error attempting to load EXC_RETURN to PC illegally on exception return.
*/
#define OS_EXC_UF_INVPC 13
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,试图切入ARM状态
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Incorrect usage, attempting to cut to ARM state.
*/
#define OS_EXC_UF_INVSTATE 14
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:用法错误,执行的指令其编码是未定义的——解码不能
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Incorrect usage. Executed instruction whose code is undefined.
*/
#define OS_EXC_UF_UNDEFINSTR 15
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:NMI中断
+ * @ingroup los_exc
+ * Cortex-M4 exception types: NMI
*/
#define OS_EXC_CAUSE_NMI 16
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:硬fault
+ * @ingroup los_exc
+ * Cortex-M4 exception types: hard fault
*/
#define OS_EXC_CAUSE_HARDFAULT 17
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:任务处理函数退出
+ * @ingroup los_exc
+ * Cortex-M4 exception types: The task handler exits.
*/
#define OS_EXC_CAUSE_TASK_EXIT 18
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:致命错误
+ * @ingroup los_exc
+ * Cortex-M4 exception types: A fatal error.
*/
#define OS_EXC_CAUSE_FATAL_ERR 19
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:调试事件导致的硬fault
+ * @ingroup los_exc
+ * Cortex-M4 exception types: Hard Fault caused by a debug event.
*/
#define OS_EXC_CAUSE_DEBUGEVT 20
/**
- *@ingroup los_exc
- *Cortex-M3异常具体类型:取向量时发生的硬fault
+ * @ingroup los_exc
+ * Cortex-M4 exception types: A hard fault that occurs when a quantity is oriented.
*/
#define OS_EXC_CAUSE_VECTBL 21
/**
- *@ingroup los_exc
- * 异常信息结构体
+ * @ingroup los_exc
+ * Exception information structure
*
- * 描述:M4平台下的异常触发时保存的异常信息
+ * Description: Exception information saved when an exception is triggered on the Cortex-M4 platform.
*
*/
-typedef struct tagExcInfo {
- /**< 异常发生阶段: 0表示异常发生在初始化中,1表示异常发生在任务中,2表示异常发生在中断中 */
+typedef struct TagExcInfo {
+ /**< Exception occurrence phase: 0 means that an exception occurs in initialization, 1 means that an exception occurs in a task, and 2 means that an exception occurs in an interrupt */
UINT16 phase;
- /**< 异常类型,出异常时对照上面列出的1-19号 */
+ /**< Exception type. When exceptions occur, check the numbers 1 - 19 listed above */
UINT16 type;
- /**< 若为精确地址访问错误表示异常发生时的错误访问地址 */
+ /**< If the exact address access error indicates the wrong access address when the exception occurred */
UINT32 faultAddr;
- /**< 在中断中发生异常,表示中断号。在任务中发生异常,表示任务id,如果发生在初始化中,则为0xffffffff */
+ /**< An exception occurs in an interrupt, indicating the interrupt number. An exception occurs in the task, indicating the task ID, or 0xFFFFFFFF if it occurs during initialization */
UINT32 thrdPid;
- /**< 异常嵌套个数,目前仅支持第一次进入异常时执行注册的钩子函数 */
+ /**< Number of nested exceptions. Currently only registered hook functions are supported when an exception is entered for the first time */
UINT16 nestCnt;
- /**< 保留 */
+ /**< reserve */
UINT16 reserved;
- /**< 自动压栈浮点寄存器的异常发生时刻的硬件上下文 */
- EXC_CONTEXT_S * context;
+ /**< Hardware context at the time an exception to the automatic stack floating-point register occurs */
+ EXC_CONTEXT_S *context;
} ExcInfo;
extern UINT32 g_curNestCount;
diff --git a/kernel/arch/arm/cortex-m4/iar/los_arch_timer.h b/kernel/arch/arm/cortex-m4/iar/los_arch_timer.h
index 2f38c220..59159c0c 100644
--- a/kernel/arch/arm/cortex-m4/iar/los_arch_timer.h
+++ b/kernel/arch/arm/cortex-m4/iar/los_arch_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m4/iar/los_context.c b/kernel/arch/arm/cortex-m4/iar/los_context.c
index 1c6b2935..52dd0013 100755
--- a/kernel/arch/arm/cortex-m4/iar/los_context.c
+++ b/kernel/arch/arm/cortex-m4/iar/los_context.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -28,11 +28,12 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "los_config.h"
-#include "los_task.h"
+
+#include "los_context.h"
#include "securec.h"
-#include "los_interrupt.h"
#include "los_arch_context.h"
+#include "los_task.h"
+#include "los_interrupt.h"
#include "los_arch_interrupt.h"
#include "los_arch_timer.h"
@@ -64,7 +65,8 @@ LITE_OS_SEC_TEXT_INIT VOID HalArchInit()
LITE_OS_SEC_TEXT_MINOR VOID HalSysExit(VOID)
{
LOS_IntLock();
- for(;;);
+ while (1) {
+ }
}
/* ****************************************************************************
@@ -149,78 +151,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
-void HalBackTrace()
-{
-
-}
-
-#if (LOSCFG_MEM_LEAKCHECK == 1)
-#define CODE_SECTION_NAME ".text"
-#pragma section=CODE_SECTION_NAME
-#define CODE_START_ADDR ((UINTPTR)__section_begin(CODE_SECTION_NAME))
-#define CODE_END_ADDR ((UINTPTR)__section_end(CODE_SECTION_NAME))
-
-/* check the disassembly instruction is 'BL' or 'BLX' */
-STATIC INLINE BOOL HalInsIsBlOrBlx(UINTPTR addr)
-{
-#define BL_INS_MASK 0xF800
-#define BL_INS_HIGH 0xF800
-#define BL_INS_LOW 0xF000
-#define BLX_INX_MASK 0xFF00
-#define BLX_INX 0x4700
- UINT16 ins1 = *((UINT16 *)addr);
- UINT16 ins2 = *((UINT16 *)(addr + 2)); /* 2: Thumb instruction is two bytes. */
-
- if (((ins2 & BL_INS_MASK) == BL_INS_HIGH) && ((ins1 & BL_INS_MASK) == BL_INS_LOW)) {
- return TRUE;
- } else if ((ins2 & BLX_INX_MASK) == BLX_INX) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
- UINTPTR stackStart, UINTPTR stackEnd)
-{
- if (LR == NULL) {
- return;
- }
-
- UINT32 count = 0;
- UINT32 index = 0;
- UINTPTR sp = stackStart;
- UINTPTR pc;
-
- /* copy called function address */
- for (; sp < stackEnd; sp += sizeof(UINTPTR)) {
- /* the *sp value may be LR, so need decrease a word to PC */
- pc = *((UINTPTR *)sp) - sizeof(UINTPTR);
- /* the Cortex-M using thumb instruction, so the pc must be an odd number */
- if ((pc & 0x1) == 0) {
- continue;
- }
- /* fix the PC address in thumb mode */
- pc = *((UINTPTR *)sp) - 1;
- if ((pc >= CODE_START_ADDR) && (pc <= CODE_END_ADDR) &&(count < LRSize) &&
- HalInsIsBlOrBlx(pc - sizeof(UINTPTR))) {
- if (index++ < jumpCount) {
- continue;
- }
- LR[count++] = pc;
- if (count == LRSize) {
- break;
- }
- }
- }
-
- /* if linkReg is not enough,clean up the last of the effective LR as the end. */
- if (count < LRSize) {
- LR[count] = 0;
- }
-}
-#endif
-
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;
@@ -237,5 +167,3 @@ LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
}
#endif /* __cplusplus */
#endif /* __cplusplus */
-
-
diff --git a/kernel/arch/arm/cortex-m4/iar/los_dispatch.S b/kernel/arch/arm/cortex-m4/iar/los_dispatch.S
index 09b88b9c..e4c88527 100755
--- a/kernel/arch/arm/cortex-m4/iar/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m4/iar/los_dispatch.S
@@ -1,6 +1,6 @@
;
-; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
-; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+; Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without modification,
; are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m4/iar/los_exc.S b/kernel/arch/arm/cortex-m4/iar/los_exc.S
index cb112a49..b28b112a 100644
--- a/kernel/arch/arm/cortex-m4/iar/los_exc.S
+++ b/kernel/arch/arm/cortex-m4/iar/los_exc.S
@@ -1,6 +1,6 @@
;
-; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
-; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+; Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without modification,
; are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m4/iar/los_interrupt.c b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c
index f8a3898b..e9306787 100755
--- a/kernel/arch/arm/cortex-m4/iar/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m4/iar/los_interrupt.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,9 +29,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_interrupt.h"
+#include
#include "los_context.h"
#include "los_arch_interrupt.h"
-#include
#include "los_debug.h"
#include "los_task.h"
@@ -51,15 +51,59 @@ UINT32 g_intCount = 0;
#elif defined(__CC_ARM) || defined(__GNUC__)
LITE_OS_SEC_VEC
#endif
-HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
-HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_HANDLER_FUNC;
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
+ }
+}
+
#else
-HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
+ }
+}
#endif
-__weak VOID SysTick_Handler(VOID)
+WEAK VOID SysTick_Handler(VOID)
{
return;
}
@@ -132,12 +176,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
- if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
- g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
+ if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
+ g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
- if (g_hwiSlaveForm[hwiIndex] != 0) {
- g_hwiSlaveForm[hwiIndex]();
+ if (g_hwiHandlerForm[hwiIndex] != 0) {
+ g_hwiHandlerForm[hwiIndex]();
}
#endif
@@ -160,10 +204,10 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
Return : LOS_OK on success or error code on failure
**************************************************************************** */
LITE_OS_SEC_TEXT_INIT UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T mode,
- HWI_PROC_FUNC handler,
- HWI_ARG_T arg)
+ HWI_PRIOR_T hwiPrio,
+ HWI_MODE_T mode,
+ HWI_PROC_FUNC handler,
+ HWI_ARG_T arg)
{
UINTPTR intSave;
@@ -243,12 +287,16 @@ UINT8 g_uwExcTbl[FAULT_STATUS_REG_BIT] = {
UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
{
UINT32 *base = NULL;
- UINT32 len = 0, i, j;
+ UINT32 len, i, j;
#define OS_NR_NVIC_EXC_DUMP_Types 7
- UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE,
- OS_NVIC_INT_ACT_BASE, OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL};
- UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE,
- OS_NVIC_INT_ACT_SIZE, OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE};
+ UINT32 rgNvicBases[OS_NR_NVIC_EXC_DUMP_Types] = {
+ OS_NVIC_SETENA_BASE, OS_NVIC_SETPEND_BASE, OS_NVIC_INT_ACT_BASE,
+ OS_NVIC_PRI_BASE, OS_NVIC_EXCPRI_BASE, OS_NVIC_SHCSR, OS_NVIC_INT_CTRL
+ };
+ UINT32 rgNvicLens[OS_NR_NVIC_EXC_DUMP_Types] = {
+ OS_NVIC_INT_ENABLE_SIZE, OS_NVIC_INT_PEND_SIZE, OS_NVIC_INT_ACT_SIZE,
+ OS_NVIC_INT_PRI_SIZE, OS_NVIC_EXCPRI_SIZE, OS_NVIC_SHCSR_SIZE, OS_NVIC_INT_CTRL_SIZE
+ };
char strRgEnable[] = "enable";
char strRgPending[] = "pending";
char strRgActive[] = "active";
@@ -256,7 +304,10 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
char strRgException[] = "exception";
char strRgShcsr[] = "shcsr";
char strRgIntCtrl[] = "control";
- char *strRgs[] = {strRgEnable, strRgPending, strRgActive, strRgPriority, strRgException, strRgShcsr, strRgIntCtrl};
+ char *strRgs[] = {
+ strRgEnable, strRgPending, strRgActive, strRgPriority,
+ strRgException, strRgShcsr, strRgIntCtrl
+ };
(VOID)index;
(VOID)excContent;
@@ -265,7 +316,7 @@ UINT32 HalExcNvicDump(UINT32 index, UINT32 *excContent)
base = (UINT32 *)rgNvicBases[i];
len = rgNvicLens[i];
PRINTK("interrupt %s register, base address: 0x%x, size: 0x%x\n", strRgs[i], base, len);
- len = (len >> 2);
+ len = (len >> 2); /* 2: Gets the next register offset */
for (j = 0; j < len; j++) {
PRINTK("0x%x ", *(base + j));
}
@@ -307,7 +358,7 @@ UINT32 HalExcContextDump(UINT32 index, UINT32 *excContent)
LITE_OS_SEC_TEXT_INIT VOID HalExcHandleEntry(UINT32 excType, UINT32 faultAddr, UINT32 pid, EXC_CONTEXT_S *excBufAddr)
{
- UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT;
+ UINT16 tmpFlag = (excType >> 16) & OS_NULL_SHORT; /* 16: Get Exception Type */
g_intCount++;
g_excInfo.nestCnt++;
@@ -353,7 +404,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit()
UINT32 index;
g_hwiForm[0] = 0; /* [0] Top of Stack */
g_hwiForm[1] = Reset_Handler; /* [1] reset */
- for (index = 2; index < OS_VECTOR_CNT; index++) {
+ for (index = 2; index < OS_VECTOR_CNT; index++) { /* 2: The starting position of the interrupt */
g_hwiForm[index] = (HWI_PROC_FUNC)HalHwiDefaultHandler;
}
/* Exception handler register */
diff --git a/kernel/arch/arm/cortex-m4/iar/los_mpu.c b/kernel/arch/arm/cortex-m4/iar/los_mpu.c
old mode 100644
new mode 100755
index 5e4194d7..07c4991c
--- a/kernel/arch/arm/cortex-m4/iar/los_mpu.c
+++ b/kernel/arch/arm/cortex-m4/iar/los_mpu.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m4/iar/los_timer.c b/kernel/arch/arm/cortex-m4/iar/los_timer.c
index 77a418b6..1a75deb0 100755
--- a/kernel/arch/arm/cortex-m4/iar/los_timer.c
+++ b/kernel/arch/arm/cortex-m4/iar/los_timer.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -28,19 +28,19 @@
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
+#include "los_timer.h"
#include "los_config.h"
#include "los_tick.h"
#include "los_arch_interrupt.h"
-#include "los_timer.h"
#include "los_context.h"
+
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
-
-
/* ****************************************************************************
Function : HalTickStart
Description : Configure Tick Interrupt Start
@@ -65,6 +65,8 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
OsSetVector(SysTick_IRQn, (HWI_PROC_FUNC)handler);
#endif
#endif
+
+ g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
@@ -195,34 +197,34 @@ static BOOL g_sysSleepFlag = FALSE;
VOID HalTickLock(VOID)
{
- SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
+ SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
}
VOID HalTickUnlock(VOID)
{
- SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
+ SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
BOOL HalGetSysSleepFlag(VOID)
{
- return g_sysSleepFlag;
+ return g_sysSleepFlag;
}
VOID HalClearSysSleepFlag(VOID)
{
- g_sysSleepFlag = FALSE;
+ g_sysSleepFlag = FALSE;
}
VOID HalEnterSleep(LOS_SysSleepEnum sleep)
{
- __DSB();
- __WFI();
- __ISB();
+ __DSB();
+ __WFI();
+ __ISB();
}
WEAK VOID HalDelay(UINT32 ticks)
{
-
+ return;
}
WEAK UINT64 HalGetExpandTick(VOID)
diff --git a/kernel/arch/arm/cortex-m7/gcc/BUILD.gn b/kernel/arch/arm/cortex-m7/gcc/BUILD.gn
new file mode 100644
index 00000000..d289c391
--- /dev/null
+++ b/kernel/arch/arm/cortex-m7/gcc/BUILD.gn
@@ -0,0 +1,46 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("arch") {
+ sources = [
+ "los_context.c",
+ "los_dispatch.S",
+ "los_exc.S",
+ "los_interrupt.c",
+ "los_timer.c",
+ ]
+
+ include_dirs = [
+ "../../../../../kernel/arch/include",
+ "../../../../../kernel/include",
+ "../../../../../utils",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_arch_atomic.h b/kernel/arch/arm/cortex-m7/gcc/los_arch_atomic.h
index 2e6121c3..e57c6a9b 100644
--- a/kernel/arch/arm/cortex-m7/gcc/los_arch_atomic.h
+++ b/kernel/arch/arm/cortex-m7/gcc/los_arch_atomic.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -56,7 +56,6 @@ extern "C" {
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_arch_context.h b/kernel/arch/arm/cortex-m7/gcc/los_arch_context.h
index 4759cb69..972f2fde 100644
--- a/kernel/arch/arm/cortex-m7/gcc/los_arch_context.h
+++ b/kernel/arch/arm/cortex-m7/gcc/los_arch_context.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_arch_interrupt.h b/kernel/arch/arm/cortex-m7/gcc/los_arch_interrupt.h
index 3ffd4bff..b3ab442f 100755
--- a/kernel/arch/arm/cortex-m7/gcc/los_arch_interrupt.h
+++ b/kernel/arch/arm/cortex-m7/gcc/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
#if (OS_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_arch_timer.h b/kernel/arch/arm/cortex-m7/gcc/los_arch_timer.h
index 2f38c220..59159c0c 100644
--- a/kernel/arch/arm/cortex-m7/gcc/los_arch_timer.h
+++ b/kernel/arch/arm/cortex-m7/gcc/los_arch_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_context.c b/kernel/arch/arm/cortex-m7/gcc/los_context.c
index f15654fa..e4da9f80 100644
--- a/kernel/arch/arm/cortex-m7/gcc/los_context.c
+++ b/kernel/arch/arm/cortex-m7/gcc/los_context.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -149,11 +149,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
-void HalBackTrace()
-{
-
-}
-
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_dispatch.S b/kernel/arch/arm/cortex-m7/gcc/los_dispatch.S
index aa56c140..298e7409 100644
--- a/kernel/arch/arm/cortex-m7/gcc/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m7/gcc/los_dispatch.S
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_exc.S b/kernel/arch/arm/cortex-m7/gcc/los_exc.S
index 46f01bf8..927ed35e 100644
--- a/kernel/arch/arm/cortex-m7/gcc/los_exc.S
+++ b/kernel/arch/arm/cortex-m7/gcc/los_exc.S
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c b/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c
index 40ac32bf..173c6d52 100755
--- a/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m7/gcc/los_interrupt.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -46,12 +46,56 @@ UINT32 g_intCount = 0;
/*lint -restore*/
-HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC __attribute__((aligned(0x100))) g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
-HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_HANDLER_FUNC;
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
+ }
+}
+
#else
-HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
+ }
+}
#endif
/* ****************************************************************************
@@ -122,12 +166,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
- if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
- g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
+ if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
+ g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
- if (g_hwiSlaveForm[hwiIndex] != 0) {
- g_hwiSlaveForm[hwiIndex]();
+ if (g_hwiHandlerForm[hwiIndex] != 0) {
+ g_hwiHandlerForm[hwiIndex]();
}
#endif
diff --git a/kernel/arch/arm/cortex-m7/gcc/los_timer.c b/kernel/arch/arm/cortex-m7/gcc/los_timer.c
index 9cfbdfa8..dfbf29bf 100755
--- a/kernel/arch/arm/cortex-m7/gcc/los_timer.c
+++ b/kernel/arch/arm/cortex-m7/gcc/los_timer.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -66,6 +66,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
+ g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
diff --git a/kernel/arch/arm/cortex-m7/iar/los_arch_atomic.h b/kernel/arch/arm/cortex-m7/iar/los_arch_atomic.h
index 2e6121c3..e57c6a9b 100644
--- a/kernel/arch/arm/cortex-m7/iar/los_arch_atomic.h
+++ b/kernel/arch/arm/cortex-m7/iar/los_arch_atomic.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -56,7 +56,6 @@ extern "C" {
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
{
@@ -92,7 +91,6 @@ STATIC INLINE INT32 HalAtomicXchg32bits(volatile INT32 *v, INT32 val)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
{
@@ -129,7 +127,6 @@ STATIC INLINE INT32 HalAtomicDecRet(volatile INT32 *v)
* @par Dependency:
* los_atomic.h: the header file that contains the API declaration.
* @see
- * @since Huawei LiteOS V100R001C00
*/
STATIC INLINE BOOL HalAtomicCmpXchg32bits(volatile INT32 *v, INT32 val, INT32 oldVal)
{
diff --git a/kernel/arch/arm/cortex-m7/iar/los_arch_context.h b/kernel/arch/arm/cortex-m7/iar/los_arch_context.h
index 4759cb69..972f2fde 100644
--- a/kernel/arch/arm/cortex-m7/iar/los_arch_context.h
+++ b/kernel/arch/arm/cortex-m7/iar/los_arch_context.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/iar/los_arch_interrupt.h b/kernel/arch/arm/cortex-m7/iar/los_arch_interrupt.h
old mode 100644
new mode 100755
index 3ffd4bff..b3ab442f
--- a/kernel/arch/arm/cortex-m7/iar/los_arch_interrupt.h
+++ b/kernel/arch/arm/cortex-m7/iar/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -309,45 +309,18 @@ extern UINT32 _BootVectors[];
*/
#define OS_EXC_SYS_TICK 15
-/* *
- * @ingroup los_hwi
- * hardware interrupt form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT];
-
#if (OS_HWI_WITH_ARG == 1)
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVectonr(num, vector, arg) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT].pParm = (VOID *)arg; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg);
#else
-/* *
- * @ingroup los_hwi
- * hardware interrupt Slave form mapping handling function array.
- */
-extern HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT];
-
/* *
* @ingroup los_hwi
* Set interrupt vector table.
*/
-#define OsSetVector(num, vector) \
- do { \
- g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt; \
- g_hwiSlaveForm[num + OS_SYS_VECTOR_CNT] = vector; \
- } while(0)
+extern VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector);
#endif
/* *
diff --git a/kernel/arch/arm/cortex-m7/iar/los_arch_timer.h b/kernel/arch/arm/cortex-m7/iar/los_arch_timer.h
index 2f38c220..59159c0c 100644
--- a/kernel/arch/arm/cortex-m7/iar/los_arch_timer.h
+++ b/kernel/arch/arm/cortex-m7/iar/los_arch_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/iar/los_context.c b/kernel/arch/arm/cortex-m7/iar/los_context.c
index 2c12e0ab..e4da9f80 100644
--- a/kernel/arch/arm/cortex-m7/iar/los_context.c
+++ b/kernel/arch/arm/cortex-m7/iar/los_context.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -149,80 +149,6 @@ LITE_OS_SEC_TEXT_INIT VOID *HalTskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)context;
}
-void HalBackTrace()
-{
-
-}
-
-#ifdef __ICCARM__
-#if (LOSCFG_MEM_LEAKCHECK == 1)
-#define CODE_SECTION_NAME ".text"
-#pragma section=CODE_SECTION_NAME
-#define CODE_START_ADDR ((UINTPTR)__section_begin(CODE_SECTION_NAME))
-#define CODE_END_ADDR ((UINTPTR)__section_end(CODE_SECTION_NAME))
-
-/* check the disassembly instruction is 'BL' or 'BLX' */
-STATIC INLINE BOOL HalInsIsBlOrBlx(UINTPTR addr)
-{
-#define BL_INS_MASK 0xF800
-#define BL_INS_HIGH 0xF800
-#define BL_INS_LOW 0xF000
-#define BLX_INX_MASK 0xFF00
-#define BLX_INX 0x4700
- UINT16 ins1 = *((UINT16 *)addr);
- UINT16 ins2 = *((UINT16 *)(addr + 2)); /* 2: Thumb instruction is two bytes. */
-
- if (((ins2 & BL_INS_MASK) == BL_INS_HIGH) && ((ins1 & BL_INS_MASK) == BL_INS_LOW)) {
- return TRUE;
- } else if ((ins2 & BLX_INX_MASK) == BLX_INX) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
- UINTPTR stackStart, UINTPTR stackEnd)
-{
- if (LR == NULL) {
- return;
- }
-
- UINT32 count = 0;
- UINT32 index = 0;
- UINTPTR sp = stackStart;
- UINTPTR pc;
-
- /* copy called function address */
- for (; sp < stackEnd; sp += sizeof(UINTPTR)) {
- /* the *sp value may be LR, so need decrease a word to PC */
- pc = *((UINTPTR *)sp) - sizeof(UINTPTR);
- /* the Cortex-M using thumb instruction, so the pc must be an odd number */
- if ((pc & 0x1) == 0) {
- continue;
- }
- /* fix the PC address in thumb mode */
- pc = *((UINTPTR *)sp) - 1;
- if ((pc >= CODE_START_ADDR) && (pc <= CODE_END_ADDR) &&(count < LRSize) &&
- HalInsIsBlOrBlx(pc - sizeof(UINTPTR))) {
- if (index++ < jumpCount) {
- continue;
- }
- LR[count++] = pc;
- if (count == LRSize) {
- break;
- }
- }
- }
-
- /* if linkReg is not enough,clean up the last of the effective LR as the end. */
- if (count < LRSize) {
- LR[count] = 0;
- }
-}
-#endif
-#endif
-
LITE_OS_SEC_TEXT_INIT UINT32 HalStartSchedule(OS_TICK_HANDLER handler)
{
UINT32 ret;
diff --git a/kernel/arch/arm/cortex-m7/iar/los_dispatch.S b/kernel/arch/arm/cortex-m7/iar/los_dispatch.S
old mode 100644
new mode 100755
index 09b88b9c..e4c88527
--- a/kernel/arch/arm/cortex-m7/iar/los_dispatch.S
+++ b/kernel/arch/arm/cortex-m7/iar/los_dispatch.S
@@ -1,6 +1,6 @@
;
-; Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
-; Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+; Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+; Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
;
; Redistribution and use in source and binary forms, with or without modification,
; are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/iar/los_exc.S b/kernel/arch/arm/cortex-m7/iar/los_exc.S
index 45e11851..59d7dd57 100644
--- a/kernel/arch/arm/cortex-m7/iar/los_exc.S
+++ b/kernel/arch/arm/cortex-m7/iar/los_exc.S
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/arm/cortex-m7/iar/los_interrupt.c b/kernel/arch/arm/cortex-m7/iar/los_interrupt.c
old mode 100644
new mode 100755
index 3efcfdc0..d0985d9d
--- a/kernel/arch/arm/cortex-m7/iar/los_interrupt.c
+++ b/kernel/arch/arm/cortex-m7/iar/los_interrupt.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -47,12 +47,56 @@ UINT32 g_intCount = 0;
/*lint -restore*/
#pragma location = ".data.vector"
#pragma data_alignment=0x100
-HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiForm[OS_VECTOR_CNT] = {0};
#if (OS_HWI_WITH_ARG == 1)
-HWI_SLAVE_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+typedef struct {
+ HWI_PROC_FUNC pfnHandler;
+ VOID *pParm;
+} HWI_HANDLER_FUNC;
+
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_HANDLER_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {{ (HWI_PROC_FUNC)0, (HWI_ARG_T)0 }};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector, VOID *arg)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = (HWI_PROC_FUNC)HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pfnHandler = vector;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT].pParm = arg;
+ }
+}
+
#else
-HWI_PROC_FUNC g_hwiSlaveForm[OS_VECTOR_CNT] = {0};
+/* *
+ * @ingroup los_hwi
+ * hardware interrupt handler form mapping handling function array.
+ */
+STATIC HWI_PROC_FUNC g_hwiHandlerForm[OS_VECTOR_CNT] = {0};
+
+/* *
+ * @ingroup los_hwi
+ * Set interrupt vector table.
+ */
+VOID OsSetVector(UINT32 num, HWI_PROC_FUNC vector)
+{
+ if ((num + OS_SYS_VECTOR_CNT) < OS_VECTOR_CNT) {
+ g_hwiForm[num + OS_SYS_VECTOR_CNT] = HalInterrupt;
+ g_hwiHandlerForm[num + OS_SYS_VECTOR_CNT] = vector;
+ }
+}
#endif
WEAK VOID SysTick_Handler(VOID)
@@ -128,12 +172,12 @@ LITE_OS_SEC_TEXT VOID HalInterrupt(VOID)
HalPreInterruptHandler(hwiIndex);
#if (OS_HWI_WITH_ARG == 1)
- if (g_hwiSlaveForm[hwiIndex].pfnHandler != 0) {
- g_hwiSlaveForm[hwiIndex].pfnHandler((VOID *)g_hwiSlaveForm[hwiIndex].pParm);
+ if (g_hwiHandlerForm[hwiIndex].pfnHandler != 0) {
+ g_hwiHandlerForm[hwiIndex].pfnHandler((VOID *)g_hwiHandlerForm[hwiIndex].pParm);
}
#else
- if (g_hwiSlaveForm[hwiIndex] != 0) {
- g_hwiSlaveForm[hwiIndex]();
+ if (g_hwiHandlerForm[hwiIndex] != 0) {
+ g_hwiHandlerForm[hwiIndex]();
}
#endif
diff --git a/kernel/arch/arm/cortex-m7/iar/los_mpu.c b/kernel/arch/arm/cortex-m7/iar/los_mpu.c
old mode 100644
new mode 100755
index 5e4194d7..5970e8ae
--- a/kernel/arch/arm/cortex-m7/iar/los_mpu.c
+++ b/kernel/arch/arm/cortex-m7/iar/los_mpu.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_mpu.h"
-#include "los_config.h"
#include "los_context.h"
#ifdef __cplusplus
diff --git a/kernel/arch/arm/cortex-m7/iar/los_timer.c b/kernel/arch/arm/cortex-m7/iar/los_timer.c
old mode 100644
new mode 100755
index 9cfbdfa8..dfbf29bf
--- a/kernel/arch/arm/cortex-m7/iar/los_timer.c
+++ b/kernel/arch/arm/cortex-m7/iar/los_timer.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -66,6 +66,7 @@ WEAK UINT32 HalTickStart(OS_TICK_HANDLER *handler)
#endif
#endif
+ g_sysClock = OS_SYS_CLOCK;
g_cyclesPerTick = OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND;
g_ullTickCount = 0;
diff --git a/kernel/arch/include/los_arch.h b/kernel/arch/include/los_arch.h
index 37775978..7ba4f7ae 100755
--- a/kernel/arch/include/los_arch.h
+++ b/kernel/arch/include/los_arch.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -41,15 +41,7 @@ extern "C" {
#endif /* __cpluscplus */
#endif /* __cpluscplus */
-
-VOID HalArchInit();
-void HalBackTrace();
-#define LOS_BackTrace HalBackTrace
-
-#if (LOSCFG_MEM_LEAKCHECK == 1)
-VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
- UINTPTR stackStart, UINTPTR stackEnd);
-#endif
+VOID HalArchInit(VOID);
#ifdef __cplusplus
#if __cplusplus
diff --git a/kernel/arch/include/los_atomic.h b/kernel/arch/include/los_atomic.h
index 6ff27f8d..1fc14913 100644
--- a/kernel/arch/include/los_atomic.h
+++ b/kernel/arch/include/los_atomic.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/include/los_context.h b/kernel/arch/include/los_context.h
index ebb1a4c4..058d7104 100644
--- a/kernel/arch/include/los_context.h
+++ b/kernel/arch/include/los_context.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/include/los_interrupt.h b/kernel/arch/include/los_interrupt.h
index 0125f1dd..fb13b5d2 100755
--- a/kernel/arch/include/los_interrupt.h
+++ b/kernel/arch/include/los_interrupt.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -58,16 +58,10 @@ typedef UINT32 HWI_ARG_T;
#if (OS_HWI_WITH_ARG == 1)
typedef VOID (*HWI_PROC_FUNC)(VOID *parm);
-typedef struct {
- HWI_PROC_FUNC pfnHandler;
- VOID *pParm;
-} HWI_SLAVE_FUNC;
-
#else
-
typedef VOID (*HWI_PROC_FUNC)(void);
-
#endif
+
UINT32 HalIsIntAcvive(VOID);
#define OS_INT_ACTIVE (HalIsIntAcvive())
#define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
@@ -128,10 +122,10 @@ extern UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum);
* @see None.
*/
extern UINT32 HalHwiCreate(HWI_HANDLE_T hwiNum,
- HWI_PRIOR_T hwiPrio,
- HWI_MODE_T mode,
- HWI_PROC_FUNC handler,
- HWI_ARG_T arg);
+ HWI_PRIOR_T hwiPrio,
+ HWI_MODE_T mode,
+ HWI_PROC_FUNC handler,
+ HWI_ARG_T arg);
#ifdef __cplusplus
#if __cplusplus
diff --git a/kernel/arch/include/los_mpu.h b/kernel/arch/include/los_mpu.h
old mode 100644
new mode 100755
index 7e4f1da4..17f1cc70
--- a/kernel/arch/include/los_mpu.h
+++ b/kernel/arch/include/los_mpu.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/include/los_timer.h b/kernel/arch/include/los_timer.h
index e27cb40f..e216c3f4 100755
--- a/kernel/arch/include/los_timer.h
+++ b/kernel/arch/include/los_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -53,8 +53,8 @@ extern "C" {
#define MACHINE_CYCLE_DEALAY_TIMES (LOSCFG_BASE_CORE_TICK_PER_SECOND << 2)
typedef enum {
- OS_SYS_NORMAL_SLEEP = 0,
- OS_SYS_DEEP_SLEEP,
+ OS_SYS_NORMAL_SLEEP = 0,
+ OS_SYS_DEEP_SLEEP,
} LOS_SysSleepEnum;
VOID HalTickLock(VOID);
diff --git a/kernel/arch/risc-v/riscv32/gcc/BUILD.gn b/kernel/arch/risc-v/riscv32/gcc/BUILD.gn
new file mode 100644
index 00000000..03d5a9cb
--- /dev/null
+++ b/kernel/arch/risc-v/riscv32/gcc/BUILD.gn
@@ -0,0 +1,47 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("arch") {
+ sources = [
+ "los_context.c",
+ "los_dispatch.S",
+ "los_exc.S",
+ "los_interrupt.c",
+ "los_timer.c",
+ ]
+
+ include_dirs = [
+ "../../../../../kernel/arch/include",
+ "../../../../../kernel/include",
+ "../../../../../utils",
+ "./",
+ "./asm",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/kernel/arch/risc-v/asm/soc_common.h b/kernel/arch/risc-v/riscv32/gcc/asm/soc_common.h
similarity index 98%
rename from kernel/arch/risc-v/asm/soc_common.h
rename to kernel/arch/risc-v/riscv32/gcc/asm/soc_common.h
index 7247e6cb..7032ada1 100644
--- a/kernel/arch/risc-v/asm/soc_common.h
+++ b/kernel/arch/risc-v/riscv32/gcc/asm/soc_common.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/risc-v/los_arch_context.h b/kernel/arch/risc-v/riscv32/gcc/los_arch_context.h
similarity index 96%
rename from kernel/arch/risc-v/los_arch_context.h
rename to kernel/arch/risc-v/riscv32/gcc/los_arch_context.h
index 864d8a40..5eb0ee0e 100644
--- a/kernel/arch/risc-v/los_arch_context.h
+++ b/kernel/arch/risc-v/riscv32/gcc/los_arch_context.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -148,7 +148,6 @@ extern VOID HalStartToRun(VOID);
* @par Dependency:
* los_hw.h: the header file that contains the API declaration.
* @see None.
- * @since Huawei LiteOS V200R002C00
*/
extern VOID wfi(VOID);
@@ -168,7 +167,6 @@ extern VOID wfi(VOID);
* @par Dependency:
* los_hw.h: the header file that contains the API declaration.
* @see None.
- * @since Huawei LiteOS V200R002C00
*/
extern VOID mb(VOID);
@@ -188,7 +186,6 @@ extern VOID mb(VOID);
* @par Dependency:
* los_hw.h: the header file that contains the API declaration.
* @see None.
- * @since Huawei LiteOS V200R002C00
*/
extern VOID dsb(VOID);
diff --git a/kernel/arch/risc-v/los_arch_interrupt.h b/kernel/arch/risc-v/riscv32/gcc/los_arch_interrupt.h
similarity index 95%
rename from kernel/arch/risc-v/los_arch_interrupt.h
rename to kernel/arch/risc-v/riscv32/gcc/los_arch_interrupt.h
index f318311d..a0ec90b0 100755
--- a/kernel/arch/risc-v/los_arch_interrupt.h
+++ b/kernel/arch/risc-v/riscv32/gcc/los_arch_interrupt.h
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/risc-v/los_arch_timer.h b/kernel/arch/risc-v/riscv32/gcc/los_arch_timer.h
similarity index 92%
rename from kernel/arch/risc-v/los_arch_timer.h
rename to kernel/arch/risc-v/riscv32/gcc/los_arch_timer.h
index 2f38c220..59159c0c 100644
--- a/kernel/arch/risc-v/los_arch_timer.h
+++ b/kernel/arch/risc-v/riscv32/gcc/los_arch_timer.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/risc-v/los_context.c b/kernel/arch/risc-v/riscv32/gcc/los_context.c
similarity index 98%
rename from kernel/arch/risc-v/los_context.c
rename to kernel/arch/risc-v/riscv32/gcc/los_context.c
index 79e5f445..ed79418d 100644
--- a/kernel/arch/risc-v/los_context.c
+++ b/kernel/arch/risc-v/riscv32/gcc/los_context.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/risc-v/los_dispatch.S b/kernel/arch/risc-v/riscv32/gcc/los_dispatch.S
similarity index 99%
rename from kernel/arch/risc-v/los_dispatch.S
rename to kernel/arch/risc-v/riscv32/gcc/los_dispatch.S
index b0edbadb..cf49ae8b 100644
--- a/kernel/arch/risc-v/los_dispatch.S
+++ b/kernel/arch/risc-v/riscv32/gcc/los_dispatch.S
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/risc-v/los_exc.S b/kernel/arch/risc-v/riscv32/gcc/los_exc.S
similarity index 98%
rename from kernel/arch/risc-v/los_exc.S
rename to kernel/arch/risc-v/riscv32/gcc/los_exc.S
index b90375ff..70703a41 100755
--- a/kernel/arch/risc-v/los_exc.S
+++ b/kernel/arch/risc-v/riscv32/gcc/los_exc.S
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/arch/risc-v/los_interrupt.c b/kernel/arch/risc-v/riscv32/gcc/los_interrupt.c
similarity index 80%
rename from kernel/arch/risc-v/los_interrupt.c
rename to kernel/arch/risc-v/riscv32/gcc/los_interrupt.c
index 8983ec37..6d0faf94 100755
--- a/kernel/arch/risc-v/los_interrupt.c
+++ b/kernel/arch/risc-v/riscv32/gcc/los_interrupt.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -67,12 +67,6 @@ const CHAR g_excInformation[RISCV_EXC_TYPE_NUM][50] = {
{ "Store/AMO page fault!" },
};
-#define RA_OFFSET 4
-#define FP_OFFSET 8
-#define OS_MAX_BACKTRACE 15
-#define FP_ALIGN(value) (((UINT32)(value) & (UINT32)(LOSCFG_STACK_POINT_ALIGN_SIZE - 1)) == 0)
-#define FP_CHECK(value) (HalBackTraceFpCheck(value) && ((UINT32)(value) != FP_INIT_VALUE) && FP_ALIGN(value))
-
LITE_OS_SEC_BSS UINT32 g_intCount = 0;
LITE_OS_SEC_BSS UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM];
LITE_OS_SEC_DATA_INIT HWI_HANDLE_FORM_S g_hwiForm[OS_HWI_MAX_NUM] = {
@@ -223,50 +217,6 @@ LITE_OS_SEC_TEXT UINT32 HalHwiDelete(HWI_HANDLE_T hwiNum)
return LOS_OK;
}
-STATIC VOID BackTraceSub(UINT32 fp)
-{
- UINT32 backFp = fp;
- UINT32 tmpFp;
- UINT32 backRa;
- UINT32 count = 0;
-
- while (FP_CHECK(backFp)) {
- tmpFp = backFp;
- backRa = *((UINT32 *)(UINTPTR)(tmpFp - RA_OFFSET));
- backFp = *((UINT32 *)(UINTPTR)(tmpFp - FP_OFFSET));
- PRINTK("traceback %u -- ra = 0x%x fp = 0x%x\n", count, backRa, backFp);
-
- count++;
-
- if ((count == OS_MAX_BACKTRACE) || (backFp == tmpFp) || \
- (!HalBackTraceRaCheck(backRa))) {
- break;
- }
- }
- PRINTK("*******backtrace end*******\n");
-}
-
-STATIC VOID BackTrace(UINT32 fp)
-{
- PRINTK("*******backtrace begin*******\n");
-
- BackTraceSub(fp);
-}
-
-STATIC VOID ExcBackTrace(UINT32 fp, UINT32 ra)
-{
- UINT32 backFp;
- if (FP_CHECK(fp)) {
- backFp = *((UINT32 *)(UINTPTR)(fp - RA_OFFSET));
- if ((backFp != ra) && FP_CHECK(backFp)) {
- fp = backFp;
- }
- BackTrace(fp);
- } else {
- PRINTK("fp error, back trace failed!\n");
- }
-}
-
STATIC VOID DisplayTaskInfo(VOID)
{
TSK_INFO_S taskInfo;
@@ -287,6 +237,23 @@ STATIC VOID DisplayTaskInfo(VOID)
return;
}
+STATIC VOID ExcBackTrace(VOID)
+{
+ UINTPTR LR[LOSCFG_BACKTRACE_DEPTH] = {0};
+ UINT32 index;
+
+ OsBackTraceHookCall(LR, LOSCFG_BACKTRACE_DEPTH, 1); /* 1: Ignore the one layer call relationship within the function. */
+
+ PRINTK("----- traceback start -----\r\n");
+ for (index = 0; index < LOSCFG_BACKTRACE_DEPTH; index++) {
+ if (LR[index] == 0) {
+ break;
+ }
+ PRINTK("traceback %d -- lr = 0x%x\r\n", index, LR[index]);
+ }
+ PRINTK("----- traceback end -----\r\n");
+}
+
STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
{
const TaskContext *taskContext = &(exc->context->taskContext);
@@ -327,7 +294,7 @@ STATIC VOID ExcInfoDisplayContext(const LosExcInfo *exc)
PRINTK("t5 = 0x%x\n", taskContext->t5);
PRINTK("t6 = 0x%x\n", taskContext->t6);
- ExcBackTrace(taskContext->s0, taskContext->ra);
+ ExcBackTrace();
}
STATIC VOID ExcInfoDisplay(const LosExcContext *excBufAddr)
@@ -358,7 +325,6 @@ VOID HalExcEntry(const LosExcContext *excBufAddr)
UINT32 ret;
g_excInfo.type = excBufAddr->mcause & 0x1FF;
g_excInfo.context = (LosExcContext *)excBufAddr;
-
if (g_excInfo.nestCnt > 2) { /* 2: Number of layers of exception nesting */
PRINTK("hard faule!\n\r");
goto SYSTEM_DEATH;
@@ -384,60 +350,6 @@ SYSTEM_DEATH:
}
}
-LITE_OS_SEC_TEXT VOID HalTaskBackTrace(UINT32 taskID)
-{
- LosTaskCB *taskCB = NULL;
-
- if (taskID >= g_taskMaxNum) {
- PRINT_ERR("\r\nTask PID is invalid!\n");
- return;
- }
-
- taskCB = OS_TCB_FROM_TID(taskID);
- if ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) || (taskCB->taskEntry == NULL) ||
- (taskCB->taskName == NULL)) {
- PRINT_ERR("\r\nThe task is not created!\n");
- return;
- }
-
- if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
- HalBackTrace();
- return;
- }
-
- PRINTK("taskName = %s\n", taskCB->taskName);
- PRINTK("taskID = 0x%x\n", taskCB->taskID);
- PRINTK("curr ra = 0x%08x\n", ((TaskContext *)(taskCB->stackPointer))->ra);
- ExcBackTrace(((TaskContext *)(taskCB->stackPointer))->s0, ((TaskContext *)(taskCB->stackPointer))->ra);
-}
-
-LITE_OS_SEC_TEXT VOID HalBackTrace(VOID)
-{
- UINT32 fp = GetFp();
- PRINTK("taskName = %s\n", g_losTask.runTask->taskName);
- PRINTK("taskID = %u\n", g_losTask.runTask->taskID);
- PRINTK("curr fp = 0x%08x \n", fp);
- BackTrace(fp);
-}
-
-#if (LOSCFG_MEM_LEAKCHECK == 1)
-VOID HalRecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount,
- UINTPTR stackStart, UINTPTR stackEnd)
-{
-}
-#endif
-
-/* stack protector */
-UINT32 __stack_chk_guard = 0xd00a0dff;
-
-VOID __stack_chk_fail(VOID)
-{
- OsDoExcHook(EXC_STACKOVERFLOW);
- /* __builtin_return_address is a builtin function, building in gcc */
- LOS_Panic("stack-protector: Kernel stack is corrupted in: %p\n",
- __builtin_return_address(0));
-}
-
#ifdef __cplusplus
#if __cplusplus
}
diff --git a/kernel/arch/risc-v/los_timer.c b/kernel/arch/risc-v/riscv32/gcc/los_timer.c
similarity index 94%
rename from kernel/arch/risc-v/los_timer.c
rename to kernel/arch/risc-v/riscv32/gcc/los_timer.c
index 495372bf..9c6e4585 100755
--- a/kernel/arch/risc-v/los_timer.c
+++ b/kernel/arch/risc-v/riscv32/gcc/los_timer.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/include/los_config.h b/kernel/include/los_config.h
index 9767d117..04290cde 100755
--- a/kernel/include/los_config.h
+++ b/kernel/include/los_config.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -433,11 +433,35 @@ extern UINT8 *m_aucSysMem0;
/**
* @ingroup los_config
* Configuration memory leak detection
+ * @attention
+ * Need to enable backtrace module synchronously by configuration LOSCFG_BACKTRACE_TYPE,
+ * and call LOS_BackTraceInit to complete initialization before the memory pool is initialized.
*/
#ifndef LOSCFG_MEM_LEAKCHECK
#define LOSCFG_MEM_LEAKCHECK 0
#endif
+/**
+ * @ingroup los_config
+ * The default is 4, which means that the function call stack is recorded from the kernel interface,
+ * such as LOS_MemAlloc/LOS_MemAllocAlign/LOS_MemRealloc/LOS_MemFree. If you want to further ignore
+ * the number of function call layers, you can increase this value appropriately.
+ * @attention
+ * The default is in the IAR tool. Under different compilation environments, this value needs to be adjusted.
+ */
+#ifndef LOSCFG_MEM_OMIT_LR_CNT
+#define LOSCFG_MEM_OMIT_LR_CNT 4
+#endif
+
+/**
+ * @ingroup los_config
+ * The record number of layers of the function call relationship starting from the number of
+ * ignored layers(LOSCFG_MEM_OMIT_LR_CNT).
+ */
+#ifndef LOSCFG_MEM_RECORD_LR_CNT
+#define LOSCFG_MEM_RECORD_LR_CNT 3
+#endif
+
/**
* @ingroup los_config
* Configuration memory leak recorded num
@@ -546,6 +570,29 @@ extern UINT8 *m_aucSysMem0;
#define LOSCFG_KERNEL_PRINTF 1
#endif
+/* =============================================================================
+ backtrace configuration
+============================================================================= */
+/**
+ * @ingroup los_config
+ * Configuration backtrace type
+ * 0: Close stack analysis module.
+ * 1: Call stack analysis for cortex-m series.
+ * 2: Call stack analysis for risc-v.
+ * others: Not currently supported.
+ */
+#ifndef LOSCFG_BACKTRACE_TYPE
+#define LOSCFG_BACKTRACE_TYPE 0
+#endif
+
+/**
+ * @ingroup los_config
+ * Configuration backtrace depth.
+ */
+#ifndef LOSCFG_BACKTRACE_DEPTH
+#define LOSCFG_BACKTRACE_DEPTH 15
+#endif
+
#ifdef __cplusplus
#if __cplusplus
}
diff --git a/kernel/include/los_event.h b/kernel/include/los_event.h
index 7e0c0cf1..933215af 100644
--- a/kernel/include/los_event.h
+++ b/kernel/include/los_event.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/include/los_membox.h b/kernel/include/los_membox.h
index ba6e990b..cc65225e 100755
--- a/kernel/include/los_membox.h
+++ b/kernel/include/los_membox.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -236,7 +236,7 @@ extern VOID LOS_ShowBox(VOID *pool);
* be abnormal.
*
*
- * @param boxMem [IN] Type #VOID* Pointer to the calculate membox.
+ * @param boxMem [IN] Type #VOID* Pointer to the calculate membox.
* @param maxBlk [OUT] Type #UINT32* Record membox max block.
* @param blkCnt [OUT] Type #UINT32* Record membox block count alreay allocated.
* @param blkSize [OUT] Type #UINT32* Record membox block size.
diff --git a/kernel/include/los_memory.h b/kernel/include/los_memory.h
index 667b6956..ee95e3d6 100755
--- a/kernel/include/los_memory.h
+++ b/kernel/include/los_memory.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -58,23 +58,6 @@ UINT32 OsMemExcInfoGet(UINT32 memNumMax, MemInfoCB *memExcInfo);
#define OS_SYS_MEM_ADDR LOSCFG_SYS_HEAP_ADDR
#if (LOSCFG_MEM_LEAKCHECK == 1)
-
-/**
- * @ingroup los_memory
- * The default is 5, which means that the function call stack is recorded from the kernel interface,
- * such as LOS_MemAlloc/LOS_MemAllocAlign/LOS_MemRealloc/LOS_MemFree. If you want to further ignore
- * the number of function call layers, you can increase this value appropriately.
- *
- */
-#define LOS_OMIT_LR_CNT 5
-
-/**
- * @ingroup los_memory
- * The record number of layers of the function call relationship starting from the number of
- * ignored layers(LOS_OMIT_LR_CNT).
- */
-#define LOS_RECORD_LR_CNT 3
-
/**
* @ingroup los_memory
* @brief Print function call stack information of all used nodes.
diff --git a/kernel/include/los_mux.h b/kernel/include/los_mux.h
index 0a8ad6aa..8e5a1295 100644
--- a/kernel/include/los_mux.h
+++ b/kernel/include/los_mux.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/include/los_queue.h b/kernel/include/los_queue.h
index fb6cff77..68c1cc50 100644
--- a/kernel/include/los_queue.h
+++ b/kernel/include/los_queue.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/include/los_sem.h b/kernel/include/los_sem.h
index 3da51967..ebe148cb 100644
--- a/kernel/include/los_sem.h
+++ b/kernel/include/los_sem.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/include/los_swtmr.h b/kernel/include/los_swtmr.h
old mode 100755
new mode 100644
index bce51ff9..9842e48f
--- a/kernel/include/los_swtmr.h
+++ b/kernel/include/los_swtmr.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/include/los_task.h b/kernel/include/los_task.h
old mode 100755
new mode 100644
index d3d135aa..5ef1a695
--- a/kernel/include/los_task.h
+++ b/kernel/include/los_task.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -1651,8 +1651,8 @@ typedef struct {
typedef struct {
LOS_DL_LIST *sortLink;
- UINT16 cursor;
- UINT16 reserved;
+ UINT16 cursor;
+ UINT16 reserved;
} TaskSortLinkAttr;
/**
diff --git a/kernel/include/los_tick.h b/kernel/include/los_tick.h
index 36b2f50b..ea8f51d1 100644
--- a/kernel/include/los_tick.h
+++ b/kernel/include/los_tick.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/src/los_event.c b/kernel/src/los_event.c
index 3862a173..f1ab2af6 100644
--- a/kernel/src/los_event.c
+++ b/kernel/src/los_event.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/src/los_init.c b/kernel/src/los_init.c
index bf932d40..50a344cc 100755
--- a/kernel/src/los_init.c
+++ b/kernel/src/los_init.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -192,6 +192,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
}
#endif
+#ifdef LOSCFG_TEST
+ //ret = los_TestInit();
+ //if (ret != LOS_OK) {
+ // PRINT_ERR("los_TestInit error\n");
+ // return ret;
+ //}
+#endif
+
#if (LOSCFG_PLATFORM_EXC == 1)
OsExcMsgDumpInit();
#endif
diff --git a/kernel/src/los_mux.c b/kernel/src/los_mux.c
index b0395f98..87cdf5a1 100644
--- a/kernel/src/los_mux.c
+++ b/kernel/src/los_mux.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -30,7 +30,6 @@
*/
#include "los_config.h"
#include "los_interrupt.h"
-#include "los_arch.h"
#include "los_mux.h"
#include "los_memory.h"
#include "los_debug.h"
@@ -170,9 +169,6 @@ STATIC_INLINE UINT32 OsMuxValidCheck(LosMuxCB *muxPended)
if (g_losTaskLock) {
PRINT_ERR("!!!LOS_ERRNO_MUX_PEND_IN_LOCK!!!\n");
-#if (LOSCFG_PLATFORM_EXC == 1)
- LOS_BackTrace();
-#endif
return LOS_ERRNO_MUX_PEND_IN_LOCK;
}
diff --git a/kernel/src/los_queue.c b/kernel/src/los_queue.c
index 66320371..c68ace3f 100755
--- a/kernel/src/los_queue.c
+++ b/kernel/src/los_queue.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/src/los_sem.c b/kernel/src/los_sem.c
index e9b89420..830625a1 100755
--- a/kernel/src/los_sem.c
+++ b/kernel/src/los_sem.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -29,7 +29,6 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "los_config.h"
-#include "los_arch.h"
#include "los_sem.h"
#include "los_memory.h"
#include "los_interrupt.h"
@@ -195,17 +194,11 @@ STATIC_INLINE UINT32 OsSemValidCheck(LosSemCB *semPended)
if (OS_INT_ACTIVE) {
PRINT_ERR("!!!LOS_ERRNO_SEM_PEND_INTERR!!!\n");
-#if (LOSCFG_PLATFORM_EXC == 1)
- LOS_BackTrace();
-#endif
return LOS_ERRNO_SEM_PEND_INTERR;
}
if (g_losTaskLock) {
PRINT_ERR("!!!LOS_ERRNO_SEM_PEND_IN_LOCK!!!\n");
-#if (LOSCFG_PLATFORM_EXC == 1)
- LOS_BackTrace();
-#endif
return LOS_ERRNO_SEM_PEND_IN_LOCK;
}
diff --git a/kernel/src/los_swtmr.c b/kernel/src/los_swtmr.c
old mode 100755
new mode 100644
index 82fcccf0..1d02a048
--- a/kernel/src/los_swtmr.c
+++ b/kernel/src/los_swtmr.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/src/los_task.c b/kernel/src/los_task.c
index dc017313..9a86444a 100755
--- a/kernel/src/los_task.c
+++ b/kernel/src/los_task.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -39,6 +39,7 @@
#include "los_cpup.h"
#endif
#include "los_debug.h"
+
#ifdef __cplusplus
#if __cplusplus
extern "C" {
@@ -240,7 +241,7 @@ LITE_OS_SEC_TEXT WEAK VOID OsIdleTask(VOID)
{
while (1) {
OsRecyleFinishedTask();
-#if (LOSCFG_KERNEL_RUNSTOP == YES)
+#if (LOSCFG_KERNEL_RUNSTOP == 1)
HalEnterSleep(OS_SYS_NORMAL_SLEEP);
#endif
}
@@ -1656,8 +1657,6 @@ VOID LOS_Schedule(VOID)
LOS_IntRestore(intSave);
}
-
-
#if (LOSCFG_BASE_CORE_TIMESLICE == 1)
LITE_OS_SEC_BSS OsTaskRobin g_taskTimeSlice;
diff --git a/kernel/src/los_tick.c b/kernel/src/los_tick.c
old mode 100755
new mode 100644
index ab01331d..ea4e66d7
--- a/kernel/src/los_tick.c
+++ b/kernel/src/los_tick.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -30,9 +30,9 @@
*/
#include "los_tick.h"
-#include "los_config.h"
#include "los_task.h"
#include "los_swtmr.h"
+#include "los_config.h"
#ifdef __cplusplus
#if __cplusplus
diff --git a/kernel/src/mm/los_membox.c b/kernel/src/mm/los_membox.c
index f007aa8d..a4c12015 100755
--- a/kernel/src/mm/los_membox.c
+++ b/kernel/src/mm/los_membox.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/kernel/src/mm/los_memory.c b/kernel/src/mm/los_memory.c
index 73499c4f..7f12d9fa 100755
--- a/kernel/src/mm/los_memory.c
+++ b/kernel/src/mm/los_memory.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -36,7 +36,6 @@
#include "los_memory.h"
#include "los_task.h"
#include "los_debug.h"
-#include "los_timer.h"
#ifdef LOSCFG_LIB_LIBC
#endif
@@ -48,21 +47,7 @@ extern "C" {
/* Used to cut non-essential functions. */
#define OS_MEM_EXPAND_ENABLE 0
-#define OS_MEM_PRINT_DEBUG 0
-
-#if OS_MEM_PRINT_DEBUG
-#define MEM_TRACE_MALLOC 0
-#define MEM_TRACE_FREE 1
-#define MEM_TRACE_MEMALIGN 2
-#define MEM_TRACE_REALLOC 3
-
-STATIC INLINE UINT64 OsMemClockGetCycles(VOID)
-{
- UINT32 cntHi, cntLo;
- HalGetCpuCycle(&cntHi, &cntLo);
- return (((UINT64)cntHi << 32) + cntLo); /* 32: 32 bits left to form 64 bits. */
-}
-#endif
+#define OS_MEM_TRACE 0
UINT8 *m_aucSysMem0 = NULL;
@@ -81,9 +66,8 @@ VOID *g_poolHead = NULL;
/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
#define OS_MEM_SMALL_BUCKET_COUNT 31
#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
-/* Giving OS_MEM_FREE_LIST_NUM free lists for each large bucket. */
+/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
#define OS_MEM_LARGE_BUCKET_COUNT 24
-#define OS_MEM_FREE_LIST_NUM (1 << OS_MEM_SLI)
/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
#define OS_MEM_LARGE_START_BUCKET 7
@@ -109,7 +93,7 @@ STATIC INLINE UINT16 OsMemFLS(UINT32 bitmap)
STATIC INLINE UINT32 OsMemLog2(UINT32 size)
{
- return OsMemFLS(size);
+ return (size > 0) ? OsMemFLS(size) : 0;
}
/* Get the first level: f = log2(size). */
@@ -118,13 +102,19 @@ STATIC INLINE UINT32 OsMemFlGet(UINT32 size)
if (size < OS_MEM_SMALL_BUCKET_MAX_SIZE) {
return ((size >> 2) - 1); /* 2: The small bucket setup is 4. */
}
- return OsMemLog2(size);
+ return (OsMemLog2(size) - OS_MEM_LARGE_START_BUCKET + OS_MEM_SMALL_BUCKET_COUNT);
}
/* Get the second level: s = (size - 2^f) * 2^SLI / 2^f. */
STATIC INLINE UINT32 OsMemSlGet(UINT32 size, UINT32 fl)
{
- return (((size << OS_MEM_SLI) >> fl) - OS_MEM_FREE_LIST_NUM);
+ if ((fl < OS_MEM_SMALL_BUCKET_COUNT) || (size < OS_MEM_SMALL_BUCKET_MAX_SIZE)) {
+ PRINT_ERR("fl or size is too small, fl = %u, size = %u\n", fl, size);
+ return 0;
+ }
+
+ UINT32 sl = (size << OS_MEM_SLI) >> (fl - OS_MEM_SMALL_BUCKET_COUNT + OS_MEM_LARGE_START_BUCKET);
+ return (sl - (1 << OS_MEM_SLI));
}
/* The following is the memory algorithm related macro definition and interface implementation. */
@@ -134,7 +124,7 @@ struct OsMemNodeHead {
UINT32 magic;
#endif
#if (LOSCFG_MEM_LEAKCHECK == 1)
- UINTPTR linkReg[LOS_RECORD_LR_CNT];
+ UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
#endif
union {
struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
@@ -197,49 +187,67 @@ struct OsMemPoolHead {
#if (LOSCFG_MEM_FREE_BY_TASKID == 1)
#define OS_MEM_NODE_USED_FLAG (1U << 25)
#define OS_MEM_NODE_ALIGNED_FLAG (1U << 24)
-#define OS_MEM_NODE_LAST_FLAG (1U << 23) /* Sentinel Node */
#if (LOSCFG_MEM_LEAKCHECK == 1)
-#define OS_MEM_NODE_LEAK_FLAG (1U << 22)
+#define OS_MEM_NODE_LEAK_FLAG (1U << 23)
+#else
+#define OS_MEM_NODE_LEAK_FLAG 0
+#endif
+#if (OS_MEM_EXPAND_ENABLE == 1)
+#define OS_MEM_NODE_LAST_FLAG (1U << 22) /* Sentinel Node */
+#else
+#define OS_MEM_NODE_LAST_FLAG 0
#endif
#else
#define OS_MEM_NODE_USED_FLAG (1U << 31)
#define OS_MEM_NODE_ALIGNED_FLAG (1U << 30)
-#define OS_MEM_NODE_LAST_FLAG (1U << 29) /* Sentinel Node */
#if (LOSCFG_MEM_LEAKCHECK == 1)
-#define OS_MEM_NODE_LEAK_FLAG (1U << 28)
+#define OS_MEM_NODE_LEAK_FLAG (1U << 29)
+#else
+#define OS_MEM_NODE_LEAK_FLAG 0
+#endif
+#if (OS_MEM_EXPAND_ENABLE == 1)
+#define OS_MEM_NODE_LAST_FLAG (1U << 28) /* Sentinel Node */
+#else
+#define OS_MEM_NODE_LAST_FLAG 0
#endif
#endif
-#if (LOSCFG_MEM_LEAKCHECK == 1)
#define OS_MEM_NODE_ALIGNED_AND_USED_FLAG \
- (OS_MEM_NODE_USED_FLAG | OS_MEM_NODE_ALIGNED_FLAG | OS_MEM_NODE_LAST_FLAG | OS_MEM_NODE_LEAK_FLAG)
-#else
-#define OS_MEM_NODE_ALIGNED_AND_USED_FLAG \
- (OS_MEM_NODE_USED_FLAG | OS_MEM_NODE_ALIGNED_FLAG | OS_MEM_NODE_LAST_FLAG)
-#endif
+ (OS_MEM_NODE_USED_FLAG | OS_MEM_NODE_ALIGNED_FLAG | OS_MEM_NODE_LEAK_FLAG | OS_MEM_NODE_LAST_FLAG)
#define OS_MEM_NODE_GET_ALIGNED_FLAG(sizeAndFlag) \
((sizeAndFlag) & OS_MEM_NODE_ALIGNED_FLAG)
#define OS_MEM_NODE_SET_ALIGNED_FLAG(sizeAndFlag) \
- ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_ALIGNED_FLAG))
-#define OS_MEM_NODE_GET_ALIGNED_GAPSIZE(sizeAndFlag) \
- ((sizeAndFlag) & ~OS_MEM_NODE_ALIGNED_FLAG)
+ (sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_ALIGNED_FLAG)
#define OS_MEM_NODE_GET_USED_FLAG(sizeAndFlag) \
((sizeAndFlag) & OS_MEM_NODE_USED_FLAG)
#define OS_MEM_NODE_SET_USED_FLAG(sizeAndFlag) \
- ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_USED_FLAG))
+ (sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_USED_FLAG)
#define OS_MEM_NODE_GET_SIZE(sizeAndFlag) \
((sizeAndFlag) & ~OS_MEM_NODE_ALIGNED_AND_USED_FLAG)
+
+#define OS_MEM_GAPSIZE_USED_FLAG 0x80000000U
+#define OS_MEM_GAPSIZE_ALIGNED_FLAG 0x40000000U
+#define OS_MEM_GET_ALIGNED_GAPSIZE(gapsize) \
+ ((gapsize) & ~OS_MEM_GAPSIZE_ALIGNED_FLAG)
+#define OS_MEM_GET_GAPSIZE_ALIGNED_FLAG(gapsize) \
+ ((gapsize) & OS_MEM_GAPSIZE_ALIGNED_FLAG)
+#define OS_MEM_SET_GAPSIZE_ALIGNED_FLAG(gapsize) \
+ (gapsize) = ((gapsize) | OS_MEM_GAPSIZE_ALIGNED_FLAG)
+#define OS_MEM_GET_GAPSIZE_USED_FLAG(gapsize) \
+ ((gapsize) & OS_MEM_GAPSIZE_USED_FLAG)
+#define OS_MEM_GAPSIZE_CHECK(gapsize) \
+ (OS_MEM_GET_GAPSIZE_ALIGNED_FLAG(gapsize) && \
+ OS_MEM_GET_GAPSIZE_USED_FLAG(gapsize))
+
#define OS_MEM_NODE_SET_LAST_FLAG(sizeAndFlag) \
- ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_LAST_FLAG))
+ (sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_LAST_FLAG)
#define OS_MEM_NODE_GET_LAST_FLAG(sizeAndFlag) \
((sizeAndFlag) & OS_MEM_NODE_LAST_FLAG)
-#if (LOSCFG_MEM_LEAKCHECK == 1)
#define OS_MEM_NODE_GET_LEAK_FLAG(sizeAndFlag) \
((sizeAndFlag) & OS_MEM_NODE_LEAK_FLAG)
#define OS_MEM_NODE_SET_LEAK_FLAG(sizeAndFlag) \
- ((sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_LEAK_FLAG))
-#endif
+ (sizeAndFlag) = ((sizeAndFlag) | OS_MEM_NODE_LEAK_FLAG)
#define OS_MEM_ALIGN_SIZE sizeof(UINTPTR)
#define OS_MEM_IS_POW_TWO(value) ((((UINTPTR)(value)) & ((UINTPTR)(value) - 1)) == 0)
@@ -468,7 +476,7 @@ VOID LOS_MemExpandEnable(VOID *pool)
#if (LOSCFG_MEM_LEAKCHECK == 1)
struct OsMemLeakCheckInfo {
struct OsMemNodeHead *node;
- UINTPTR linkReg[LOS_RECORD_LR_CNT];
+ UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
};
struct OsMemLeakCheckInfo g_leakCheckRecord[LOSCFG_MEM_LEAKCHECK_RECORD_MAX_NUM] = {0};
@@ -498,16 +506,8 @@ STATIC INLINE VOID OsMemLeakCheckInit(VOID)
STATIC INLINE VOID OsMemLinkRegisterRecord(struct OsMemNodeHead *node)
{
- UINT32 taskID = LOS_CurTaskIDGet();
- if (taskID == LOS_ERRNO_TSK_ID_INVALID) {
- return;
- }
-
- LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
- UINTPTR stackStart = (UINTPTR)taskCB->stackPointer;
- UINTPTR stackEnd = stackStart + taskCB->stackSize;
-
- HalRecordLR(node->linkReg, LOS_RECORD_LR_CNT, LOS_OMIT_LR_CNT, stackStart, stackEnd);
+ (VOID)memset_s(node->linkReg, sizeof(node->linkReg), 0, sizeof(node->linkReg));
+ OsBackTraceHookCall(node->linkReg, LOSCFG_MEM_RECORD_LR_CNT, LOSCFG_MEM_OMIT_LR_CNT);
}
STATIC INLINE VOID OsMemUsedNodePrint(struct OsMemNodeHead *node)
@@ -515,8 +515,8 @@ STATIC INLINE VOID OsMemUsedNodePrint(struct OsMemNodeHead *node)
UINT32 count;
if (OS_MEM_NODE_GET_USED_FLAG(node->sizeAndFlag)) {
- PRINTK("0x%x: ", node);
- for (count = 0; count < LOS_RECORD_LR_CNT; count++) {
+ PRINTK("0x%x: 0x%x ", node, OS_MEM_NODE_GET_SIZE(node->sizeAndFlag));
+ for (count = 0; count < LOSCFG_MEM_RECORD_LR_CNT; count++) {
PRINTK(" 0x%x ", node->linkReg[count]);
}
PRINTK("\n");
@@ -541,8 +541,8 @@ VOID LOS_MemUsedNodeShow(VOID *pool)
UINT32 intSave;
UINT32 count;
- PRINTK("\n\rnode ");
- for (count = 0; count < LOS_RECORD_LR_CNT; count++) {
+ PRINTK("\n\rnode size ");
+ for (count = 0; count < LOSCFG_MEM_RECORD_LR_CNT; count++) {
PRINTK(" LR[%u] ", count);
}
PRINTK("\n");
@@ -582,12 +582,12 @@ STATIC VOID OsMemNodeBacktraceInfo(const struct OsMemNodeHead *tmpNode,
{
int i;
PRINTK("\n broken node head LR info: \n");
- for (i = 0; i < LOS_RECORD_LR_CNT; i++) {
+ for (i = 0; i < LOSCFG_MEM_RECORD_LR_CNT; i++) {
PRINTK(" LR[%d]:0x%x\n", i, tmpNode->linkReg[i]);
}
PRINTK("\n pre node head LR info: \n");
- for (i = 0; i < LOS_RECORD_LR_CNT; i++) {
+ for (i = 0; i < LOSCFG_MEM_RECORD_LR_CNT; i++) {
PRINTK(" LR[%d]:0x%x\n", i, preNode->linkReg[i]);
}
}
@@ -597,12 +597,12 @@ STATIC VOID OsMemNodeBacktraceInfo(const struct OsMemNodeHead *tmpNode,
STATIC INLINE UINT32 OsMemFreeListIndexGet(UINT32 size)
{
UINT32 fl = OsMemFlGet(size);
- if (size < OS_MEM_SMALL_BUCKET_MAX_SIZE) {
+ if (fl < OS_MEM_SMALL_BUCKET_COUNT) {
return fl;
}
UINT32 sl = OsMemSlGet(size, fl);
- return (OS_MEM_SMALL_BUCKET_COUNT + ((fl - OS_MEM_LARGE_START_BUCKET) << OS_MEM_SLI) + sl);
+ return (OS_MEM_SMALL_BUCKET_COUNT + ((fl - OS_MEM_SMALL_BUCKET_COUNT) << OS_MEM_SLI) + sl);
}
STATIC INLINE struct OsMemFreeNodeHead *OsMemFindCurSuitableBlock(struct OsMemPoolHead *poolHead,
@@ -641,11 +641,11 @@ STATIC INLINE struct OsMemFreeNodeHead *OsMemFindNextSuitableBlock(VOID *pool, U
UINT32 mask;
do {
- if (size < OS_MEM_SMALL_BUCKET_MAX_SIZE) {
+ if (fl < OS_MEM_SMALL_BUCKET_COUNT) {
index = fl;
} else {
sl = OsMemSlGet(size, fl);
- curIndex = ((fl - OS_MEM_LARGE_START_BUCKET) << OS_MEM_SLI) + sl + OS_MEM_SMALL_BUCKET_COUNT;
+ curIndex = ((fl - OS_MEM_SMALL_BUCKET_COUNT) << OS_MEM_SLI) + sl + OS_MEM_SMALL_BUCKET_COUNT;
index = curIndex + 1;
}
@@ -906,6 +906,11 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
}
#endif
+#if OS_MEM_TRACE
+ LOS_TraceReg(LOS_TRACE_MEM_TIME, OsMemTimeTrace, LOS_TRACE_MEM_TIME_NAME, LOS_TRACE_ENABLE);
+ LOS_TraceReg(LOS_TRACE_MEM_INFO, OsMemInfoTrace, LOS_TRACE_MEM_INFO_NAME, LOS_TRACE_ENABLE);
+#endif
+
return LOS_OK;
}
@@ -922,6 +927,11 @@ UINT32 LOS_MemDeInit(VOID *pool)
OsMemPoolDeinit(pool);
+#if OS_MEM_TRACE
+ LOS_TraceUnreg(LOS_TRACE_MEM_TIME);
+ LOS_TraceUnreg(LOS_TRACE_MEM_INFO);
+#endif
+
return LOS_OK;
}
@@ -993,8 +1003,8 @@ retry:
VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
{
-#if OS_MEM_PRINT_DEBUG
- UINT64 start = OsMemClockGetCycles();
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
#endif
if ((pool == NULL) || (size == 0)) {
@@ -1018,17 +1028,17 @@ VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
} while (0);
MEM_UNLOCK(poolHead, intSave);
-#if OS_MEM_PRINT_DEBUG
- UINT64 end = OsMemClockGetCycles();
- UINT32 timeUsed = end - start;
- PRINTK("type = %d, timeUsed = %d\n", MEM_TRACE_MALLOC, timeUsed);
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_MALLOC, timeUsed);
LOS_MEM_POOL_STATUS poolStatus = {0};
(VOID)LOS_MemInfoGet(pool, &poolStatus);
UINT8 fragment = 100 - poolStatus.maxFreeNodeSize * 100 / poolStatus.totalFreeSize; /* 100: percent denominator. */
UINT8 usage = LOS_MemTotalUsedGet(pool) * 100 / LOS_MemPoolSizeGet(pool); /* 100: percent denominator. */
- PRINTK("usage = %d, fragment = %d, maxFreeSize = %d, totalFreeSize = %d\n", usage, fragment,
- poolStatus.maxFreeNodeSize, poolStatus.totalFreeSize);
+ LOS_Trace(LOS_TRACE_MEM_INFO, (UINTPTR)pool & MEM_POOL_ADDR_MASK, fragment, usage, poolStatus.totalFreeSize,
+ poolStatus.maxFreeNodeSize, poolStatus.usedNodeNum, poolStatus.freeNodeNum);
#endif
return ptr;
@@ -1036,8 +1046,8 @@ VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary)
{
-#if OS_MEM_PRINT_DEBUG
- UINT64 start = OsMemClockGetCycles();
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
#endif
UINT32 gapSize;
@@ -1082,16 +1092,16 @@ VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary)
gapSize = (UINT32)((UINTPTR)alignedPtr - (UINTPTR)ptr);
struct OsMemUsedNodeHead *allocNode = (struct OsMemUsedNodeHead *)ptr - 1;
OS_MEM_NODE_SET_ALIGNED_FLAG(allocNode->header.sizeAndFlag);
- OS_MEM_NODE_SET_ALIGNED_FLAG(gapSize);
+ OS_MEM_SET_GAPSIZE_ALIGNED_FLAG(gapSize);
*(UINT32 *)((UINTPTR)alignedPtr - sizeof(gapSize)) = gapSize;
ptr = alignedPtr;
} while (0);
MEM_UNLOCK(poolHead, intSave);
-#if OS_MEM_PRINT_DEBUG
- UINT64 end = OsMemClockGetCycles();
- UINT32 timeUsed = end - start;
- PRINTK("type = %d, timeUsed = %d\n", MEM_TRACE_MEMALIGN, timeUsed);
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_MEMALIGN, timeUsed);
#endif
return ptr;
@@ -1239,10 +1249,32 @@ STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead
return ret;
}
+STATIC INLINE VOID *OsGetRealPtr(const VOID *pool, VOID *ptr)
+{
+ VOID *realPtr = ptr;
+ UINT32 gapSize = *((UINT32 *)((UINTPTR)ptr - sizeof(UINT32)));
+
+ if (OS_MEM_GAPSIZE_CHECK(gapSize)) {
+ PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
+ return NULL;
+ }
+
+ if (OS_MEM_GET_GAPSIZE_ALIGNED_FLAG(gapSize)) {
+ gapSize = OS_MEM_GET_ALIGNED_GAPSIZE(gapSize);
+ if ((gapSize & (OS_MEM_ALIGN_SIZE - 1)) ||
+ (gapSize > ((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE - (UINTPTR)pool))) {
+ PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
+ return NULL;
+ }
+ realPtr = (VOID *)((UINTPTR)ptr - (UINTPTR)gapSize);
+ }
+ return realPtr;
+}
+
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
{
-#if OS_MEM_PRINT_DEBUG
- UINT64 start = OsMemClockGetCycles();
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
#endif
if ((pool == NULL) || (ptr == NULL) || !OS_MEM_IS_ALIGNED(pool, sizeof(VOID *)) ||
@@ -1257,30 +1289,19 @@ UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
MEM_LOCK(poolHead, intSave);
do {
- UINT32 gapSize = *(UINT32 *)((UINTPTR)ptr - sizeof(UINT32));
- if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize) && OS_MEM_NODE_GET_USED_FLAG(gapSize)) {
- PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
+ ptr = OsGetRealPtr(pool, ptr);
+ if (ptr == NULL) {
break;
}
-
node = (struct OsMemNodeHead *)((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE);
-
- if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize)) {
- gapSize = OS_MEM_NODE_GET_ALIGNED_GAPSIZE(gapSize);
- if ((gapSize & (OS_MEM_ALIGN_SIZE - 1)) || (gapSize > ((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE))) {
- PRINT_ERR("illegal gapSize: 0x%x\n", gapSize);
- break;
- }
- node = (struct OsMemNodeHead *)((UINTPTR)ptr - gapSize - OS_MEM_NODE_HEAD_SIZE);
- }
ret = OsMemFree(poolHead, node);
} while (0);
MEM_UNLOCK(poolHead, intSave);
-#if OS_MEM_PRINT_DEBUG
- UINT64 end = OsMemClockGetCycles();
- UINT32 timeUsed = end - start;
- PRINTK("type = %d, timeUsed = %d\n", MEM_TRACE_FREE, timeUsed);
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_FREE, timeUsed);
#endif
return ret;
@@ -1291,13 +1312,14 @@ STATIC INLINE VOID OsMemReAllocSmaller(VOID *pool, UINT32 allocSize, struct OsMe
#if (LOSCFG_MEM_WATERLINE == 1)
struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
#endif
+ node->sizeAndFlag = nodeSize;
if ((allocSize + OS_MEM_MIN_LEFT_SIZE) <= nodeSize) {
OsMemSplitNode(pool, node, allocSize);
- OS_MEM_NODE_SET_USED_FLAG(node->sizeAndFlag);
#if (LOSCFG_MEM_WATERLINE == 1)
poolInfo->info.curUsedSize -= nodeSize - allocSize;
#endif
}
+ OS_MEM_NODE_SET_USED_FLAG(node->sizeAndFlag);
#if (LOSCFG_MEM_LEAKCHECK == 1)
OsMemLinkRegisterRecord(node);
#endif
@@ -1312,33 +1334,13 @@ STATIC INLINE VOID OsMemMergeNodeForReAllocBigger(VOID *pool, UINT32 allocSize,
if ((allocSize + OS_MEM_MIN_LEFT_SIZE) <= node->sizeAndFlag) {
OsMemSplitNode(pool, node, allocSize);
}
+ OS_MEM_NODE_SET_USED_FLAG(node->sizeAndFlag);
OsMemWaterUsedRecord((struct OsMemPoolHead *)pool, node->sizeAndFlag - nodeSize);
#if (LOSCFG_MEM_LEAKCHECK == 1)
OsMemLinkRegisterRecord(node);
#endif
}
-STATIC INLINE VOID *OsGetRealPtr(const VOID *pool, VOID *ptr)
-{
- VOID *realPtr = ptr;
- UINT32 gapSize = *((UINT32 *)((UINTPTR)ptr - sizeof(UINT32)));
-
- if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize) && OS_MEM_NODE_GET_USED_FLAG(gapSize)) {
- PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
- return NULL;
- }
- if (OS_MEM_NODE_GET_ALIGNED_FLAG(gapSize)) {
- gapSize = OS_MEM_NODE_GET_ALIGNED_GAPSIZE(gapSize);
- if ((gapSize & (OS_MEM_ALIGN_SIZE - 1)) ||
- (gapSize > ((UINTPTR)ptr - OS_MEM_NODE_HEAD_SIZE - (UINTPTR)pool))) {
- PRINT_ERR("[%s:%d]gapSize:0x%x error\n", __FUNCTION__, __LINE__, gapSize);
- return NULL;
- }
- realPtr = (VOID *)((UINTPTR)ptr - (UINTPTR)gapSize);
- }
- return realPtr;
-}
-
STATIC INLINE VOID *OsMemRealloc(struct OsMemPoolHead *pool, const VOID *ptr,
struct OsMemNodeHead *node, UINT32 size, UINT32 intSave)
{
@@ -1374,8 +1376,8 @@ STATIC INLINE VOID *OsMemRealloc(struct OsMemPoolHead *pool, const VOID *ptr,
VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size)
{
-#if OS_MEM_PRINT_DEBUG
- UINT64 start = OsMemClockGetCycles();
+#if OS_MEM_TRACE
+ UINT64 start = HalClockGetCycles();
#endif
if ((pool == NULL) || OS_MEM_NODE_GET_USED_FLAG(size) || OS_MEM_NODE_GET_ALIGNED_FLAG(size)) {
@@ -1416,10 +1418,10 @@ VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size)
} while (0);
MEM_UNLOCK(poolHead, intSave);
-#if OS_MEM_PRINT_DEBUG
- UINT64 end = OsMemClockGetCycles();
- UINT32 timeUsed = end - start;
- PRINTK("type = %d, timeUsed = %d\n", MEM_TRACE_REALLOC, timeUsed);
+#if OS_MEM_TRACE
+ UINT64 end = HalClockGetCycles();
+ UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
+ LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_REALLOC, timeUsed);
#endif
return newPtr;
diff --git a/readme.md b/readme.md
deleted file mode 100644
index fd4a7930..00000000
--- a/readme.md
+++ /dev/null
@@ -1,3 +0,0 @@
-详见:https://gitee.com/openharmony/docs/blob/master/readme/内核子系统README.md
-
-see: https://gitee.com/openharmony/docs/blob/master/docs-en/readme/kernel-subsystem.md
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c b/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c
index cba8a6e5..afd2b73e 100644
--- a/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c
+++ b/targets/cortex-m3_stm32f103_simulator_keil/Driver/STM32F103/uart.c
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include
#include "los_compiler.h"
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/main.c b/targets/cortex-m3_stm32f103_simulator_keil/main.c
index b5d61ca1..ac576ab0 100755
--- a/targets/cortex-m3_stm32f103_simulator_keil/main.c
+++ b/targets/cortex-m3_stm32f103_simulator_keil/main.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/targets/cortex-m3_stm32f103_simulator_keil/target_config.h b/targets/cortex-m3_stm32f103_simulator_keil/target_config.h
index 34ede252..7d797435 100755
--- a/targets/cortex-m3_stm32f103_simulator_keil/target_config.h
+++ b/targets/cortex-m3_stm32f103_simulator_keil/target_config.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -92,6 +92,10 @@ extern unsigned char g_memStart[];
#define LOSCFG_SYS_HEAP_SIZE 0x00013000
#define LOSCFG_MEM_MUL_POOL 1
#define OS_SYS_MEM_NUM 20
+/*=============================================================================
+ Exception module configuration
+=============================================================================*/
+#define LOSCFG_PLATFORM_EXC 1
/* =============================================================================
printf module configuration
============================================================================= */
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/LICENSE.pdf b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/LICENSE.pdf
new file mode 100644
index 00000000..9d4bdbc0
Binary files /dev/null and b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/LICENSE.pdf differ
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/CMSIS_END_USER_LICENCE_AGREEMENT.pdf b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/CMSIS_END_USER_LICENCE_AGREEMENT.pdf
new file mode 100644
index 00000000..b3743669
Binary files /dev/null and b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/CMSIS_END_USER_LICENCE_AGREEMENT.pdf differ
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h
index ed8d5dc9..2a533f16 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h
@@ -74,8 +74,7 @@
/* #define STM32F427_437xx */ /*!< STM32F427VG, STM32F427VI, STM32F427ZG, STM32F427ZI, STM32F427IG, STM32F427II,
STM32F437VG, STM32F437VI, STM32F437ZG, STM32F437ZI, STM32F437IG, STM32F437II Devices */
- #define STM32F429_439xx
- /*!< STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI, STM32F429BG, STM32F429BI,
+ #define STM32F429_439xx /*!< STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI, STM32F429BG, STM32F429BI,
STM32F429NG, STM32F439NI, STM32F429IG, STM32F429II, STM32F439VG, STM32F439VI,
STM32F439ZG, STM32F439ZI, STM32F439BG, STM32F439BI, STM32F439NG, STM32F439NI,
STM32F439IG and STM32F439II Devices */
@@ -129,7 +128,7 @@
In this case, these drivers will not be included and the application code will
be based on direct access to peripherals registers
*/
- /*#define USE_STDPERIPH_DRIVER */
+ #define USE_STDPERIPH_DRIVER
#endif /* USE_STDPERIPH_DRIVER */
/**
@@ -12023,7 +12022,6 @@ typedef struct
/**
* @}
*/
-#define USE_STDPERIPH_DRIVER 1
#ifdef USE_STDPERIPH_DRIVER
#include "stm32f4xx_conf.h"
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
index 00482d0f..e0fa6628 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c
@@ -473,13 +473,6 @@ static void SystemInit_ExtMemCtl(void);
* @{
*/
-//__root uint32_t SystemCoreClock = __SYSTEM_CLOCK_64M;
-
-//void SystemCoreClockUpdate(void)
-//{
-// SystemCoreClock = __SYSTEM_CLOCK_64M;
-//}
-
/**
* @brief Setup the microcontroller system
* Initialize the Embedded Flash Interface, the PLL and update the
@@ -526,7 +519,6 @@ void SystemInit(void)
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
- SystemCoreClockUpdate();
}
/**
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/README.txt b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/README.txt
new file mode 100644
index 00000000..44bef569
--- /dev/null
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/Libraries/CMSIS/README.txt
@@ -0,0 +1,42 @@
+* -------------------------------------------------------------------
+* Copyright (C) 2011-2014 ARM Limited. All rights reserved.
+*
+* Date: 17 February 2014
+* Revision: V4.00
+*
+* Project: Cortex Microcontroller Software Interface Standard (CMSIS)
+* Title: Release Note for CMSIS
+*
+* -------------------------------------------------------------------
+
+
+NOTE - Open the index.html file to access CMSIS documentation
+
+
+The Cortex Microcontroller Software Interface Standard (CMSIS) provides a single standard across all
+Cortex-Mx processor series vendors. It enables code re-use and code sharing across software projects
+and reduces time-to-market for new embedded applications.
+
+CMSIS is released under the terms of the end user license agreement ("CMSIS_END_USER_LICENCE_AGREEMENT.pdf").
+Any user of the software package is bound to the terms and conditions of the end user license agreement.
+
+
+You will find the following sub-directories:
+
+Documentation - Contains CMSIS documentation.
+
+DSP_Lib - MDK project files, Examples and source files etc.. to build the
+ CMSIS DSP Software Library for Cortex-M0, Cortex-M3, Cortex-M4 processors.
+
+Include - CMSIS Core Support and CMSIS DSP Include Files.
+
+Lib - CMSIS DSP Libraries.
+
+RTOS - CMSIS RTOS API template header file.
+
+Driver - CMSIS Peripheral Driver Interface.
+
+Pack - CMSIS Software Packs.
+ Mechanism to install software, device support, APIs, and example projects.
+
+SVD - CMSIS SVD Schema files and Conversion Utility.
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/MCD-ST Liberty SW License Agreement V2.pdf b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/MCD-ST Liberty SW License Agreement V2.pdf
new file mode 100644
index 00000000..d61f4300
Binary files /dev/null and b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/MCD-ST Liberty SW License Agreement V2.pdf differ
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.c
index 2927fe5d..be08fa94 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.c
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.c
@@ -1,5 +1,36 @@
-#include "los_arch_interrupt.h"
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
#include "los_tick.h"
+#include "los_arch_interrupt.h"
#include "stm324x9i_eval.h"
/**
@@ -29,13 +60,11 @@ void USART_Config(void)
STM_EVAL_COMInit(COM1, &USART_InitStructure);
}
-extern void OsTickHandler(void);
void SysTick_Handler(void)
{
OsTickHandler();
}
-extern void HalPendSV(void);
void PendSV_Handler(void)
{
HalPendSV();
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.h
index a0255485..4f0c0ebe 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.h
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/board/iar_stm32f429ig_fire-challenger.h
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
/**
* @brief Configures the USART Peripheral.
* @param None
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c
index 4516ef00..5f505fbd 100755
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/dprintf.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -168,6 +168,12 @@ void __dprintf(char const *fmt, va_list ap,
}
}
+void HalConsoleOutput(LogModuleType type, const char *fmt, va_list ap)
+{
+ (void)type;
+ __dprintf(fmt, ap, fputc, 0);
+}
+
int printf(char const *fmt, ...)
{
va_list ap;
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c
old mode 100755
new mode 100644
index e54d3ae2..82ce033f
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/main.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -102,11 +102,11 @@ LITE_OS_SEC_TEXT_INIT int main(void)
printf("\n\rhello world!!\n\r");
ret = LOS_KernelInit();
- taskSample();
if (ret == LOS_OK) {
+ taskSample();
LOS_Start();
}
-
+
while (1) {
__asm volatile("wfi");
}
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep
old mode 100644
new mode 100755
index eb10e772..bb2ab3ac
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.dep
@@ -1,287 +1,444 @@
2
- 4111223328
+ 207883413
Debug
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
- $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.S
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
- $PROJ_DIR$\Debug\Obj\los_membox.pbi
- $PROJ_DIR$\Debug\Obj\los_memstat.pbi
- $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.o
- $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
- $PROJ_DIR$\Debug\Obj\los_memcheck.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.o
- $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.pbi
- $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.o
- $PROJ_DIR$\Debug\Obj\los_memory.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.pbi
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_hash.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.pbi
- $PROJ_DIR$\Debug\Obj\los_hw_exc.o
- $PROJ_DIR$\Debug\Obj\los_priqueue.o
- $PROJ_DIR$\Debug\Obj\los_memory.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.pbi
- $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.o
- $PROJ_DIR$\Debug\Obj\los_cpup.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.pbi
- $PROJ_DIR$\Debug\Obj\los_queue.pbi
- $PROJ_DIR$\Debug\Obj\los_dispatch.o
- $PROJ_DIR$\Debug\Obj\los_mux.o
- $PROJ_DIR$\Debug\Obj\los_cpup.pbi
- $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.h
- $PROJ_DIR$\..\..\..\utils\los_compiler.h
- $PROJ_DIR$\Debug\Obj\los_memcheck.pbi
- $PROJ_DIR$\Debug\Obj\los_interrupt.o
- $PROJ_DIR$\Debug\Obj\los_interrupt.pbi
- $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.pbi
- $TOOLKIT_DIR$\lib\dl7M_tlf.a
- $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.o
- $PROJ_DIR$\Debug\Obj\dprintf.pbi
- $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.h
- $TOOLKIT_DIR$\inc\c\yvals.h
- $PROJ_DIR$\Debug\Obj\misc.o
- $PROJ_DIR$\Debug\Obj\los_init.__cstat.et
- $TOOLKIT_DIR$\inc\c\DLib_Product.h
- $TOOLKIT_DIR$\inc\c\DLib_Defaults.h
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
+ $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+ $PROJ_DIR$\..\..\..\utils\los_debug.c
+ $PROJ_DIR$\..\..\..\utils\los_error.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_event.c
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
+ $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_init.c
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_mux.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_timer.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
$PROJ_DIR$\..\..\..\components\cpup\los_cpup.h
- $TOOLKIT_DIR$\inc\c\stdio.h
$PROJ_DIR$\..\..\..\kernel\include\los_swtmr.h
- $PROJ_DIR$\Debug\Obj\los_cppsupport.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_hw.o
- $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\stm32_eval_legacy.h
$PROJ_DIR$\Debug\Obj\misc.pbi
- $PROJ_DIR$\Debug\Obj\los_hw.pbi
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rng.h
$TOOLKIT_DIR$\inc\c\ycheck.h
- $PROJ_DIR$\Debug\Obj\los_hw_tick.o
+ $TOOLKIT_DIR$\inc\c\stdio.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rng.h
$PROJ_DIR$\Debug\Obj\los_hw_exc_iar.o
- $PROJ_DIR$\Debug\Obj\main.pbi
- $PROJ_DIR$\config\stm32f429xG.icf
- $PROJ_DIR$\Debug\Obj\los_dispatch_iar.o
+ $PROJ_DIR$\Debug\Obj\los_hw.o
$PROJ_DIR$\Debug\Obj\los_memory.pbi
- $PROJ_DIR$\..\..\..\kernel\include\los_sem.h
- $PROJ_DIR$\Debug\Obj\los_err.__cstat.et
$TOOLKIT_DIR$\inc\c\ysizet.h
- $PROJ_DIR$\Debug\Obj\los_exc.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_err.__cstat.et
$PROJ_DIR$\Debug\Exe\los_demo.out
- $PROJ_DIR$\Debug\Obj\los_hw.__cstat.et
$PROJ_DIR$\Debug\Obj\los_exc.pbi
+ $PROJ_DIR$\Debug\Obj\los_cppsupport.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_hw.pbi
+ $PROJ_DIR$\..\..\..\kernel\include\los_sem.h
+ $PROJ_DIR$\Debug\Obj\los_hw.__cstat.et
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_ltdc.h
$PROJ_DIR$\Debug\Obj\los_cppsupport.o
+ $PROJ_DIR$\config\stm32f429xG.icf
$PROJ_DIR$\..\..\..\kernel\include\los_config.h
$PROJ_DIR$\Debug\Obj\dprintf.o
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rtc.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_tim.h
- $PROJ_DIR$\Debug\Obj\los_hw_tick.pbi
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_wwdg.h
+ $PROJ_DIR$\Debug\Obj\main.pbi
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\Common\stm32_eval_legacy.h
+ $PROJ_DIR$\Debug\Obj\los_dispatch_iar.o
+ $PROJ_DIR$\Debug\Obj\los_exc.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_hw_tick.pbi
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_syscfg.h
- $PROJ_DIR$\Debug\Obj\los_membox.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_memstat.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash.h
- $PROJ_DIR$\Debug\Obj\los_cppsupport.pbi
- $PROJ_DIR$\..\..\..\utils\los_debug.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_exti.h
- $PROJ_DIR$\Debug\Obj\dprintf.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_event.__cstat.et
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_pwr.h
- $TOOLKIT_DIR$\inc\c\DLib_Config_Full.h
- $PROJ_DIR$\..\..\..\kernel\include\los_task.h
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma2d.h
- $TOOLKIT_DIR$\CMSIS\Include\core_cm4.h
- $TOOLKIT_DIR$\CMSIS\Include\cmsis_compiler.h
- $PROJ_DIR$\Debug\Obj\los_timeslice.pbi
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rcc.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_usart.h
- $PROJ_DIR$\Debug\Obj\los_misc.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_hw_tick.o
+ $TOOLKIT_DIR$\inc\c\DLib_Defaults.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.pbi
+ $PROJ_DIR$\Debug\Obj\los_memory.o
+ $PROJ_DIR$\Debug\Obj\los_memcheck.pbi
+ $TOOLKIT_DIR$\lib\dl7M_tlf.a
+ $PROJ_DIR$\Debug\Obj\los_cpup.pbi
+ $PROJ_DIR$\Debug\Obj\los_interrupt.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.pbi
+ $PROJ_DIR$\Debug\Obj\los_memory.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_cpup.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_dispatch.o
+ $PROJ_DIR$\Debug\Obj\los_mux.o
+ $PROJ_DIR$\Debug\Obj\los_hw_exc.o
+ $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.h
+ $PROJ_DIR$\..\..\..\utils\los_compiler.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.o
+ $TOOLKIT_DIR$\inc\c\yvals.h
+ $PROJ_DIR$\Debug\Obj\misc.o
+ $PROJ_DIR$\Debug\Obj\los_interrupt.pbi
+ $PROJ_DIR$\Debug\Obj\los_init.__cstat.et
+ $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.h
+ $TOOLKIT_DIR$\inc\c\DLib_Product.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.pbi
+ $PROJ_DIR$\Debug\Obj\los_queue.pbi
+ $PROJ_DIR$\Debug\Obj\los_priqueue.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.pbi
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_hash.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.pbi
+ $PROJ_DIR$\Debug\Obj\dprintf.pbi
$TOOLKIT_DIR$\inc\c\iccarm_builtin.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_usart.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_crc.h
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
- $PROJ_DIR$\..\..\..\kernel\src\los_mux.c
- $PROJ_DIR$\Debug\Obj\main.o
- $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
- $PROJ_DIR$\..\..\..\utils\los_error.c
- $PROJ_DIR$\..\..\..\kernel\src\los_tick.c
- $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
- $PROJ_DIR$\..\..\..\kernel\src\los_task.c
- $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
- $PROJ_DIR$\..\..\..\kernel\src\los_init.c
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
- $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
- $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
- $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\iar\startup_stm32f429_439xx.s
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
- $PROJ_DIR$\..\dprintf.c
- $PROJ_DIR$\..\..\..\kernel\src\los_event.c
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
- $PROJ_DIR$\..\target_config.h
- $PROJ_DIR$\..\..\..\kernel\src\los_err.c
- $PROJ_DIR$\..\main.c
- $TOOLKIT_DIR$\inc\c\stdlib.h
- $PROJ_DIR$\..\..\..\kernel\include\los_memory.h
- $PROJ_DIR$\..\..\..\kernel\include\los_event.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sdio.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_adc.h
+ $TOOLKIT_DIR$\inc\c\DLib_Config_Full.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_exti.h
+ $PROJ_DIR$\Debug\Obj\main.o
$PROJ_DIR$\Debug\Obj\los_tick.__cstat.et
- $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.o
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dbgmcu.h
- $PROJ_DIR$\Debug\Obj\los_demo.pbd
- $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_can.h
+ $PROJ_DIR$\Debug\Obj\los_cppsupport.pbi
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.h
+ $TOOLKIT_DIR$\inc\c\stdlib.h
+ $PROJ_DIR$\Debug\Obj\dprintf.__cstat.et
+ $PROJ_DIR$\..\..\..\utils\los_debug.h
+ $PROJ_DIR$\Debug\Obj\los_event.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_timeslice.pbi
+ $PROJ_DIR$\Debug\Obj\los_misc.__cstat.et
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_err.c
+ $PROJ_DIR$\Debug\Obj\los_membox.__cstat.et
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_rcc.h
+ $TOOLKIT_DIR$\CMSIS\Include\cmsis_compiler.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_task.h
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
+ $PROJ_DIR$\..\..\..\kernel\include\los_memory.h
+ $TOOLKIT_DIR$\CMSIS\Include\core_cm4.h
+ $PROJ_DIR$\Debug\Obj\los_memstat.__cstat.et
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_flash.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_event.h
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma2d.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_pwr.h
$PROJ_DIR$\..\..\..\kernel\include\los_membox.h
$PROJ_DIR$\Debug\Obj\los_cpup.o
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fmc.h
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_spi.h
- $PROJ_DIR$\Debug\Obj\main.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma.h
+ $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.o
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dbgmcu.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_exti.__cstat.et
$PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securec.h
- $PROJ_DIR$\..\..\..\kernel\include\los_queue.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dac.h
- $PROJ_DIR$\..\..\..\kernel\include\los_tick.h
- $PROJ_DIR$\..\..\..\utils\los_list.h
+ $TOOLKIT_DIR$\inc\c\stddef.h
+ $TOOLKIT_DIR$\inc\c\string.h
+ $PROJ_DIR$\Debug\Obj\los_demo.pbd
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_can.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_sai.h
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.__cstat.et
+ $PROJ_DIR$\Debug\Obj\main.__cstat.et
+ $PROJ_DIR$\..\..\..\kernel\include\los_queue.h
$PROJ_DIR$\..\..\..\utils\los_error.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_iwdg.h
- $TOOLKIT_DIR$\inc\c\stddef.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dac.h
$PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dcmi.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_i2c.h
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\misc.h
- $TOOLKIT_DIR$\inc\c\string.h
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_dma.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_tick.h
$TOOLKIT_DIR$\inc\c\errno.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.__cstat.et
- $PROJ_DIR$\Debug\Obj\system_stm32f4xx.pbi
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_fmc.h
$PROJ_DIR$\Debug\Obj\misc.__cstat.et
+ $PROJ_DIR$\Debug\Obj\system_stm32f4xx.pbi
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\misc.h
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_i2c.h
$PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.pbi
$PROJ_DIR$\Debug\Obj\los_queue.o
- $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_mux.pbi
- $PROJ_DIR$\Debug\Obj\los_sys.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_error.pbi
- $TOOLKIT_DIR$\lib\m7M_tls.a
- $PROJ_DIR$\..\..\..\kernel\include\los_mux.h
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
- $PROJ_DIR$\Debug\Obj\los_task.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_sys.pbi
- $PROJ_DIR$\Debug\Obj\system_stm32f4xx.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_queue.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.__cstat.et
- $TOOLKIT_DIR$\inc\c\stdarg.h
- $PROJ_DIR$\Debug\Obj\los_error.o
- $PROJ_DIR$\Debug\Obj\startup_stm32f429_439xx.o
- $PROJ_DIR$\Debug\Obj\los_timeslice.__cstat.et
- $PROJ_DIR$\..\stm32f4xx_conf.h
- $TOOLKIT_DIR$\inc\c\cmsis_iar.h
- $PROJ_DIR$\Debug\Obj\stm324x9i_eval.__cstat.et
- $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.__cstat.et
- $TOOLKIT_DIR$\inc\c\DLib_Product_string.h
- $PROJ_DIR$\Debug\Obj\los_mux.__cstat.et
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_gpio.h
- $PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securectype.h
- $PROJ_DIR$\Debug\List\los_demo.map
- $PROJ_DIR$\Debug\Obj\los_swtmr.__cstat.et
+ $PROJ_DIR$\..\..\..\utils\los_list.h
$PROJ_DIR$\Debug\Obj\los_event.pbi
$PROJ_DIR$\Debug\Obj\los_sem.pbi
- $PROJ_DIR$\Debug\Obj\los_err.pbi
+ $TOOLKIT_DIR$\inc\c\cmsis_iar.h
$PROJ_DIR$\Debug\Obj\stm324x9i_eval.pbi
$PROJ_DIR$\Debug\Obj\los_swtmr.pbi
- $PROJ_DIR$\Debug\Obj\los_tick.pbi
- $PROJ_DIR$\Debug\Obj\stm324x9i_eval.o
- $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_sem.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_event.o
- $PROJ_DIR$\Debug\Obj\los_err.o
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_cryp.h
- $PROJ_DIR$\Debug\Obj\los_misc.pbi
- $PROJ_DIR$\Debug\Obj\los_membox.o
+ $PROJ_DIR$\..\stm32f4xx_conf.h
+ $PROJ_DIR$\..\..\..\kernel\include\los_mux.h
+ $PROJ_DIR$\Debug\Obj\los_task.__cstat.et
+ $TOOLKIT_DIR$\lib\m7M_tls.a
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_tim.__cstat.et
+ $TOOLKIT_DIR$\inc\c\stdarg.h
+ $PROJ_DIR$\Debug\Obj\los_sys.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_timeslice.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm324x9i_eval.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_mux.__cstat.et
+ $PROJ_DIR$\Debug\List\los_demo.map
+ $PROJ_DIR$\Debug\Obj\los_err.pbi
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_mux.pbi
+ $PROJ_DIR$\Debug\Obj\los_error.pbi
+ $PROJ_DIR$\Debug\Obj\los_sys.pbi
+ $PROJ_DIR$\Debug\Obj\los_queue.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_error.o
+ $TOOLKIT_DIR$\inc\c\DLib_Product_string.h
+ $PROJ_DIR$\Debug\Obj\los_swtmr.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.__cstat.et
+ $PROJ_DIR$\Debug\Obj\startup_stm32f429_439xx.o
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_gpio.h
+ $PROJ_DIR$\Debug\Obj\system_stm32f4xx.__cstat.et
+ $PROJ_DIR$\..\..\..\components\bounds_checking_function\include\securectype.h
$PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.o
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
- $PROJ_DIR$\Debug\Obj\los_sys.o
- $TOOLKIT_DIR$\inc\c\DLib_Product_stdlib.h
- $TOOLKIT_DIR$\lib\rt7M_tl.a
- $PROJ_DIR$\Debug\Obj\los_memstat.o
- $PROJ_DIR$\Debug\Obj\los_tick.o
+ $PROJ_DIR$\Debug\Obj\stm324x9i_eval.o
$PROJ_DIR$\Debug\Obj\los_misc.o
$PROJ_DIR$\Debug\Obj\los_task.o
+ $PROJ_DIR$\..\..\..\kernel\src\los_misc.c
+ $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_version.h
+ $PROJ_DIR$\Debug\Obj\los_err.o
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.__cstat.et
+ $PROJ_DIR$\Debug\Obj\los_event.o
+ $PROJ_DIR$\Debug\Obj\los_sys.o
+ $PROJ_DIR$\Debug\Obj\los_swtmr.o
+ $PROJ_DIR$\Debug\Obj\los_sem.__cstat.et
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.h
+ $PROJ_DIR$\Debug\Obj\los_memcheck.o
+ $PROJ_DIR$\Debug\Obj\los_tick.pbi
+ $PROJ_DIR$\Debug\Obj\los_membox.o
+ $TOOLKIT_DIR$\inc\c\DLib_Product_stdlib.h
$PROJ_DIR$\Debug\Obj\los_task.pbi
+ $PROJ_DIR$\Debug\Obj\los_memstat.o
+ $PROJ_DIR$\Debug\Obj\los_misc.pbi
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
+ $PROJ_DIR$\Debug\Obj\los_tick.o
$PROJ_DIR$\Debug\Obj\los_hw_tick.__cstat.et
$PROJ_DIR$\Debug\Obj\los_priqueue.pbi
- $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.h
- $PROJ_DIR$\Debug\Obj\los_swtmr.o
$PROJ_DIR$\Debug\Obj\stm32f4xx_gpio.pbi
- $PROJ_DIR$\Debug\Obj\los_memcheck.o
+ $PROJ_DIR$\Debug\Obj\iar_stm32f429ig_fire-challenger.__cstat.et
$TOOLKIT_DIR$\inc\c\stdint.h
+ $TOOLKIT_DIR$\lib\rt7M_tl.a
$PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.__cstat.et
- $PROJ_DIR$\..\..\..\kernel\src\los_misc.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\inc\stm32f4xx_cryp.h
$TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_compiler.h
$PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c
- $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_version.h
- $PROJ_DIR$\Debug\Obj\stm32f4xx_rcc.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_timeslice.o
- $TOOLKIT_DIR$\lib\shb_l.a
- $PROJ_DIR$\Debug\Obj\los_sem.o
$TOOLKIT_DIR$\CMSIS\Core\Include\core_cm4.h
- $TOOLKIT_DIR$\CMSIS\Core\Include\mpu_armv7.h
- $PROJ_DIR$\Debug\Obj\los_priqueue.__cstat.et
- $PROJ_DIR$\Debug\Obj\los_init.o
- $PROJ_DIR$\Debug\Obj\system_stm32f4xx.o
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.h
- $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_iccarm.h
+ $PROJ_DIR$\Debug\Obj\los_sem.o
$PROJ_DIR$\Debug\Obj\los_init.pbi
+ $PROJ_DIR$\Debug\Obj\los_context.o
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.h
+ $TOOLKIT_DIR$\lib\shb_l.a
+ $TOOLKIT_DIR$\CMSIS\Core\Include\cmsis_iccarm.h
+ $PROJ_DIR$\Debug\Obj\los_priqueue.__cstat.et
+ $PROJ_DIR$\Debug\Obj\system_stm32f4xx.o
+ $PROJ_DIR$\Debug\Obj\los_timer.o
+ $TOOLKIT_DIR$\CMSIS\Core\Include\mpu_armv7.h
+ $PROJ_DIR$\Debug\Obj\los_debug.o
+ $PROJ_DIR$\Debug\Obj\los_init.o
+ $PROJ_DIR$\Debug\Obj\los_timeslice.o
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
+ $PROJ_DIR$\Debug\Obj\los_memstat.pbi
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_usart.o
+ $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.o
+ $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h
+ $PROJ_DIR$\Debug\Obj\los_memcheck.__cstat.et
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_syscfg.pbi
+ $PROJ_DIR$\Debug\Obj\stm32f4xx_wwdg.o
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\iar\startup_stm32f429_439xx.s
+ $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
+ $PROJ_DIR$\..\dprintf.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
+ $PROJ_DIR$\..\target_config.h
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
+ $PROJ_DIR$\..\main.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_tick.c
+ $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_task.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
+ $PROJ_DIR$\Debug\Obj\los_membox.pbi
+ $PROJ_DIR$\Debug\Obj\los_debug.pbi
+ $PROJ_DIR$\Debug\Obj\los_timer.pbi
+ $PROJ_DIR$\Debug\Obj\los_exc.o
+ $PROJ_DIR$\Debug\Obj\los_context.pbi
+ $PROJ_DIR$\..\..\..\kernel\arch\include\los_interrupt.h
+ $PROJ_DIR$\..\..\..\kernel\arch\include\los_context.h
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.c
BICOMP
- 76
+ 253
ICCARM
- 57
-
-
- __cstat
- 219
+ 208
-
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.S
+
- BICOMP
- 225 46 185 92 96 13 99 139 161 42 241 191 78 55 156 72 235 236 136 84 157 135 97 206 152 70 91 32 89 45 129 87 230 228 56 100 149 81 160 88 74 147 75 77 18 142 159 145 155 153
+ AARM
+ 252
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
+
- ICCARM
- 153 156 32 99 42 46 89 45 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
+ AARM
+ 58
-
+
$PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
BICOMP
- 35
+ 66
+
+
+ ICCARM
+ 54
+
+
+
+
+ BICOMP
+ 199 131 36 64 38 134 226 62 69 205 215 138 39 121 92 79 84 147 81 106 110 113 40 76 129 122 19 152 101 239 48 108 178 203 211 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 209 89 132 107 126 141
+
+
+ ICCARM
+ 89 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 92 101 132 126 209 107 141
+
+
+
+
+ $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+
+
+ BICOMP
+ 53
+
+
+ __cstat
+ 57
+
+
+ ICCARM
+ 112
+
+
+
+
+ BICOMP
+ 203 39 48 138 121 226 64 19 131 38 134 101 62 239 108 178 81 106 110 113 40 76 129 122 92 89 36 79 84 69 205 199 147 215 211 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 209 16 132 107 126 141
+
+
+ ICCARM
+ 16 89 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 101 132 126 209 107 141 92
+
+
+
+
+ $PROJ_DIR$\..\..\..\utils\los_debug.c
+
+
+ BICOMP
+ 250
+
+
+ ICCARM
+ 216
+
+
+
+
+ $PROJ_DIR$\..\..\..\utils\los_error.c
+
+
+ BICOMP
+ 162
+
+
+ ICCARM
+ 165
+
+
+
+
+ BICOMP
+ 64 69 62 79 84 126 48
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_event.c
+
+
+ BICOMP
+ 142
+
+
+ __cstat
+ 93
+
+
+ ICCARM
+ 181
+
+
+
+
+ BICOMP
+ 113 62 122 226 239 178 106 76 126 108 81 110 40 129 209 64 48 203 19 131 138 38 39 121 134 89 132 107 79 84 69 141 36 205 199 147 215 211 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 101
+
+
+ ICCARM
+ 101 132 126 62 79 64 48 84 69 209 107 141 89 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
+
+
+ BICOMP
+ 249
+
+
+ __cstat
+ 98
+
+
+ ICCARM
+ 188
+
+
+
+
+ BICOMP
+ 19 39 103 64 189 138 121 92 166 25 62 239 199 147 131 38 134 226 36 111 152 133 205 215 81 106 110 113 40 76 129 122 89 172 20 119 90 118 48 84 69 79 108 178 203 211 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 117 141
+
+
+ ICCARM
+ 117 172 20 19 64 48 84 69 25 119 166 90 189 118 133 89 36 239 62 79 226 104 199 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 111 103 141 92
+
+
+
+
+ $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
+
+
+ BICOMP
+ 88
+
+
+ __cstat
+ 29
ICCARM
@@ -291,211 +448,65 @@
BICOMP
- 225 149 72 42 74 145 13 32 45 235 236 160 75 142 83 99 89 185 100 81 88 147 77 18 159 155 56 181 90 129 46 87 230 228 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 240 91 153 134 156 154
+ 69 64 62 79 48 84 61
ICCARM
- 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 83 90 153 156 240 134 154
+ 61 62 79 64 48 84 69
- $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_init.c
BICOMP
- 82
-
-
- ICCARM
- 71
+ 207
__cstat
+ 67
+
+
+ ICCARM
+ 217
+
+
+
+
+ BICOMP
+ 48 138 226 121 203 39 64 19 131 38 134 141 107 103 89 92 239 62 108 178 81 106 110 113 40 76 129 122 126 36 125 148 79 84 69 205 199 147 215 211 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 101 132 209
+
+
+ ICCARM
+ 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 125 141 103 148 101 132 126 209 107 89 92
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
+
+
+ BICOMP
+ 24
+
+
+ __cstat
+ 56
+
+
+ ICCARM
50
BICOMP
- 45 42 32 99 46 89 31
+ 25 108 226 83 64 19 80 92 119 69 178 127 128 101 172 20 90 118 48 84 36 79 203 199 85 82 202 33 132 141 103 89 111 152 133 166 189 239 62 205 147 211 115 170 99 46 137 21 109 107 126 117 215 81 131 106 138 110 38 113 39 40 76 121 129 134 122 209
ICCARM
- 31 32 99 42 46 89 45
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
-
-
- BICOMP
- 54
-
-
- ICCARM
- 51
-
-
- __cstat
- 68
-
-
-
-
- BICOMP
- 99 240 32 65 42 46 89 56 150 153 134 156 45 154 192 90 181 163 48 162 132 158 189 212
-
-
- ICCARM
- 90 153 156 32 99 42 46 89 45 240 134 154 150 192 48 56 65 162 189 132 212 158 163
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
-
-
- AARM
- 20
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch.S
-
-
- AARM
- 28
-
-
-
-
- [ROOT_NODE]
-
-
- ILINK
- 67 193
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
-
-
- BICOMP
- 177
-
-
- ICCARM
- 211
-
-
- __cstat
- 171
-
-
-
-
- BICOMP
- 142 99 129 160 13 32 75 87 149 74 145 42 46 186 100 81 88 147 77 18 159 155 72 156 89 45 93 225 185 94 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 153
-
-
- ICCARM
- 153 156 32 99 42 46 89 45 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c
-
-
- BICOMP
- 220
-
-
- ICCARM
- 21
-
-
- __cstat
- 237
-
-
-
-
- ICCARM
- 151 154 32 99 42 46 89 45 90 153 156 240 134 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\Debug\Exe\los_demo.out
-
-
- ILINK
- 193
-
-
-
-
- ILINK
- 60 73 138 71 144 28 205 204 51 20 57 238 34 208 224 16 214 216 29 168 234 222 217 215 104 43 183 201 39 24 209 11 36 8 15 239 233 213 173 38
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
-
-
- BICOMP
- 6
-
-
- ICCARM
- 208
-
-
- __cstat
- 79
-
-
-
-
- BICOMP
- 56 75 133 42 212 160 142 83 189 65 32 129 225 185 149 74 145 13 72 143 181 163 235 236 100 81 88 147 77 18 159 155 91 192 48 162 132 158 46 89 45 99 87 230 228 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 150 154
-
-
- ICCARM
- 150 192 48 56 42 46 89 45 65 162 189 132 212 158 163 91 72 129 32 99 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 143 133 154 83
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
-
-
- BICOMP
- 26
-
-
- ICCARM
- 8
-
-
- __cstat
- 169
-
-
-
-
- BICOMP
- 160 13 142 75 225 185 46 89 149 74 145 235 236 42 45 241 99 100 81 88 147 77 18 159 155 96 87 230 228 56 136 139 84 191 157 135 78 97 161 206 55 152 92 70
-
-
- ICCARM
- 97 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 77 161 206 18 55 142 152 159 92 145 70 155
+ 117 172 20 19 64 48 84 69 25 119 166 90 189 118 133 103 36 239 62 79 226 104 199 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 141 101 132 126 209 107 89 92 111
@@ -504,88 +515,333 @@
BICOMP
- 170
-
-
- ICCARM
- 29
+ 161
__cstat
- 190
+ 156
+
+
+ ICCARM
+ 59
BICOMP
- 32 228 75 42 160 142 13 240 46 56 149 74 145 133 156 129 87 230 100 81 88 147 77 18 159 155 91 83 90 153 134 99 89 45 154 72 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 174
+ 62 203 39 64 138 121 226 209 48 19 131 38 134 103 126 239 108 178 81 106 110 113 40 76 129 122 89 92 101 132 107 79 84 69 141 36 205 199 147 215 211 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 148
ICCARM
- 174 90 153 156 32 99 42 46 89 45 240 134 154 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 133 83
+ 148 101 132 126 62 79 64 48 84 69 209 107 141 89 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 103 92
- $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
BICOMP
- 30
-
-
- ICCARM
- 144
+ 71
__cstat
- 25
+ 164
+
+
+ ICCARM
+ 140
BICOMP
- 228 75 46 160 142 13 42 56 149 74 145 90 32 129 87 230 100 81 88 147 77 18 159 155 83 91 72 99 89 45 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 240 47 153 134 156 154
+ 226 106 62 76 103 92 84 113 122 64 101 79 199 147 81 110 40 129 19 36 209 125 69 205 215 131 138 38 39 121 134 117 111 89 239 48 108 178 203 211 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 172 25 152 133 20 119 90 118 166 189 141 132 107 126
ICCARM
- 47 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 153 156 240 134 154 83
+ 89 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 117 172 20 25 119 166 90 189 118 133 125 141 111 103 101 132 126 209 107 92
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_timer.c
BICOMP
- 23
+ 251
ICCARM
- 15
+ 214
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
+
+
+ BICOMP
+ 143
__cstat
- 226
+ 184
+
+
+ ICCARM
+ 206
BICOMP
- 136 13 97 228 42 157 152 56 84 135 206 70 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+ 64 82 84 33 132 199 85 202 226 89 79 205 215 83 127 80 128 107 62 69 141 36 147 211 115 170 99 46 137 21 109 103 92 101 209 126 48 239 108 178 203 19 81 131 106 138 110 38 113 39 40 76 121 129 134 122 31
ICCARM
- 77 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 161 206 18 55 142 152 159 92 145 70 155
+ 31 101 132 126 62 79 64 48 84 69 209 107 141 103 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 89 92
- $PROJ_DIR$\..\..\..\utils\los_error.c
+ [ROOT_NODE]
+
+
+ ILINK
+ 27 157
+
+
+
+
+ $PROJ_DIR$\Debug\Exe\los_demo.out
+
+
+ ILINK
+ 157
+
+
+
+
+ ILINK
+ 35 37 114 34 112 58 179 181 23 60 47 217 54 188 186 50 191 175 59 140 206 183 176 194 86 65 169 174 73 63 173 224 74 222 229 213 210 200 150 52
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
BICOMP
- 172
+ 51
+
+
+ __cstat
+ 227
+
+
+ ICCARM
+ 186
+
+
+
+
+ ICCARM
+ 111 103 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 141
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_err.c
+
+
+ BICOMP
+ 158
+
+
+ __cstat
+ 26
+
+
+ ICCARM
+ 179
+
+
+
+
+ ICCARM
+ 126 62 79 64 48 84 69
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
+
+
+ BICOMP
+ 221
+
+
+ __cstat
+ 105
+
+
+ ICCARM
+ 191
+
+
+
+
+ ICCARM
+ 92 62 79 64 48 84 69 89 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
+
+
+ BICOMP
+ 28
+
+
+ __cstat
+ 44
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
+
+
+ AARM
+ 43
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_misc.c
+
+
+ BICOMP
+ 192
+
+
+ __cstat
+ 95
+
+
+ ICCARM
+ 175
+
+
+
+
+ ICCARM
+ 89 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 101 132 126 209 107 141
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
+
+
+ AARM
+ 22
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c
+
+
+ BICOMP
+ 94
+
+
+ __cstat
+ 154
+
+
+ ICCARM
+ 218
+
+
+
+
+ BICOMP
+ 79 131 108 38 134 226 62 138 39 121 64 48 144 81 106 110 113 40 76 129 122 101 36 239 84 69 104 199 147 100 19 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 209 89 132 107 126 141
+
+
+ ICCARM
+ 89 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 101 132 126 209 107 141
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
+
+
+ BICOMP
+ 70
+
+
+ __cstat
+ 151
+
+
+ ICCARM
+ 74
+
+
+
+
+ BICOMP
+ 226 83 80 203 64 127 128 19 85 82 202 33 108 178 115 170 99 46 137 21 109 205 199 147 215 48 84 69 211 79 81 131 106 138 110 38 113 39 40 76 121 129 134 122
+
+
+ ICCARM
+ 39 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 80 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
+
+
+ BICOMP
+ 136
+
+
+ __cstat
+ 171
+
+
+ ICCARM
+ 213
+
+
+
+
+ BICOMP
+ 110 226 215 129 205 79 81 40 199 64 69 211 106 113 76 122 147 48 84 131 138 38 39 121 134 108 178 203 19 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33
+
+
+ ICCARM
+ 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_sys.c
+
+
+ BICOMP
+ 163
+
+
+ __cstat
+ 153
ICCARM
@@ -595,392 +851,34 @@
BICOMP
- 42 45 32 99 89 156 46
+ 121 79 239 138 226 62 39 108 131 38 134 64 48 144 81 106 110 113 40 76 129 122 36 126 84 69 104 199 147 100 19 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33 132
+
+
+ ICCARM
+ 132 126 62 79 64 48 84 69 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
- $PROJ_DIR$\..\..\..\kernel\src\los_tick.c
-
-
- BICOMP
- 200
-
-
- ICCARM
- 215
-
-
- __cstat
- 137
-
-
-
-
- ICCARM
- 153 156 32 99 42 46 89 45 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 240 134 154 49
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
-
-
- BICOMP
- 199
-
-
- ICCARM
- 222
-
-
- __cstat
- 194
-
-
-
-
- ICCARM
- 150 192 48 56 42 46 89 45 65 162 189 132 212 158 163 91 72 129 32 99 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 49 90 153 156 240 134 154 133 151 83
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_task.c
-
-
- BICOMP
- 218
-
-
- ICCARM
- 217
-
-
- __cstat
- 176
-
-
-
-
- ICCARM
- 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 150 192 48 65 162 189 132 212 158 163 63 90 153 156 240 134 154 174 133 91 47 83
-
-
-
-
- $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
-
-
- BICOMP
- 167
-
-
- ICCARM
- 138
-
-
- __cstat
- 202
-
-
-
-
- BICOMP
- 70 135 13 56 84 206 228 42 136 157 97 152 87 230 139 191 96 78 161 55 92 52 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155 221
-
-
- ICCARM
- 221 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 52
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
-
-
- BICOMP
- 37
-
-
- ICCARM
- 39
-
-
- __cstat
- 141
-
-
-
-
- BICOMP
- 88 236 159 13 235 99 100 77 225 42 45 241 81 147 18 155 185 46 89 149 160 74 75 142 145 87 230 228 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70
-
-
- ICCARM
- 84 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
-
-
- BICOMP
- 223
-
-
- ICCARM
- 24
-
-
- __cstat
- 188
-
-
-
-
- BICOMP
- 88 236 159 13 235 99 100 77 225 42 45 241 81 147 18 155 185 46 89 149 160 74 75 142 145 96 87 230 228 56 136 139 84 191 157 135 78 97 161 206 55 152 92 70
-
-
- ICCARM
- 191 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
-
-
- BICOMP
- 19
-
-
- ICCARM
- 209
-
-
- __cstat
- 231
-
-
-
-
- BICOMP
- 157 228 42 152 136 97 13 56 84 135 206 70 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
-
-
- ICCARM
- 96 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memcheck.c
-
-
- BICOMP
- 33
-
-
- ICCARM
- 224
-
-
- __cstat
- 10
-
-
-
-
- ICCARM
- 143 133 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 154
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_init.c
-
-
- BICOMP
- 242
-
-
- ICCARM
- 238
-
-
- __cstat
- 44
-
-
-
-
- BICOMP
- 46 160 13 142 228 75 42 56 149 74 145 154 134 133 91 83 129 32 87 230 100 81 88 147 77 18 159 155 156 72 151 174 99 89 45 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 90 153 240
-
-
- ICCARM
- 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 151 154 133 174 90 153 156 240 134 91 83
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memstat.c
-
-
- BICOMP
- 7
-
-
- ICCARM
- 214
-
-
- __cstat
- 80
-
-
-
-
- ICCARM
- 83 32 99 42 46 89 45 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
-
-
- BICOMP
- 27
-
-
- ICCARM
- 168
-
-
- __cstat
- 179
-
-
-
-
- BICOMP
- 13 81 32 18 133 83 89 147 155 42 90 99 225 185 100 88 77 159 56 72 240 151 45 235 236 149 160 74 75 142 145 150 143 91 129 46 87 230 228 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 192 65 181 163 48 162 132 158 189 212 154 153 134 156
-
-
- ICCARM
- 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 150 192 48 65 162 189 132 212 158 163 151 154 143 133 90 153 156 240 134 83
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
-
-
- BICOMP
- 14
-
-
- ICCARM
- 11
-
-
- __cstat
- 164
-
-
-
-
- BICOMP
- 70 135 13 56 84 206 228 42 136 157 97 152 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
-
-
- ICCARM
- 78 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
-
-
- BICOMP
- 198
-
-
- ICCARM
- 201
-
-
- __cstat
- 187
-
-
-
-
- BICOMP
- 96 92 87 139 161 13 230 191 78 55 149 52 228 56 42 136 84 157 135 97 206 152 70 160 235 225 185 236 46 89 45 241 99 100 81 88 74 147 75 77 18 142 159 145 155 221
-
-
- ICCARM
- 221 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 52
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_priqueue.c
BICOMP
196
- ICCARM
- 234
+ __cstat
+ 212
- __cstat
- 203
+ ICCARM
+ 72
-
- BICOMP
- 42 135 89 70 153 225 84 206 13 91 99 235 236 136 157 97 152 134 32 45 154 72 185 241 139 191 96 78 161 55 92 133 83 90 240 156 46 129 87 230 228 56 100 149 81 160 88 74 147 75 77 18 142 159 145 155 63
-
ICCARM
- 63 90 153 156 32 99 42 46 89 45 240 134 154 133 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 91 83
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
-
-
- BICOMP
- 53
-
-
- ICCARM
- 43
-
-
- __cstat
- 166
-
-
-
-
- BICOMP
- 92 96 13 87 139 161 230 191 78 55 228 56 42 136 84 157 135 97 206 152 70 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
-
-
- ICCARM
- 161 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 206 18 55 142 152 159 92 145 70 155
+ 125 141 62 79 64 48 84 69 101 132 126 209 107 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
@@ -989,34 +887,84 @@
AARM
- 183
+ 169
- $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
BICOMP
- 165
-
-
- ICCARM
- 239
+ 146
__cstat
- 178
+ 167
+
+
+ ICCARM
+ 183
+
+
+
+
+ ICCARM
+ 117 172 20 19 64 48 84 69 25 119 166 90 189 118 133 89 36 239 62 79 226 104 199 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 17 101 132 126 209 107 141 103 125 92
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
+
+
+ BICOMP
+ 18
+
+
+ __cstat
+ 135
+
+
+ ICCARM
+ 65
BICOMP
- 88 13 236 159 235 99 100 77 225 42 45 241 81 147 18 155 185 46 89 149 160 74 75 142 145 87 230 228 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70
+ 109 99 226 108 115 137 178 170 46 21 203 19 64 83 85 127 82 80 202 128 33 205 199 147 215 48 84 69 211 79 81 131 106 138 110 38 113 39 40 76 121 129 134 122
ICCARM
- 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
+ 137 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
+
+
+ BICOMP
+ 145
+
+
+ __cstat
+ 155
+
+
+ ICCARM
+ 174
+
+
+
+
+ BICOMP
+ 99 109 108 115 137 226 178 170 46 21 131 42 203 19 64 83 85 127 82 80 202 128 33 138 205 199 147 215 48 84 69 211 79 81 106 110 38 113 39 40 76 121 129 134 122 185
+
+
+ ICCARM
+ 185 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 42
@@ -1025,129 +973,214 @@
BICOMP
- 40
-
-
- ICCARM
- 73
+ 78
__cstat
- 85
+ 91
+
+
+ ICCARM
+ 37
BICOMP
- 99 149 42 225 185 74 145 13 221 65 160 75 142 83 56 235 236 100 81 88 147 77 18 159 155 48 97 46 89 45 32 87 230 228 241 136 139 84 191 157 96 135 78 161 206 55 152 92 70 181 52
+ 79 131 64 199 147 38 134 226 185 25 138 39 121 92 19 205 215 81 106 110 113 40 76 129 122 20 80 48 84 69 62 108 178 203 211 83 115 85 170 127 99 82 46 137 202 21 128 109 33 152 42
ICCARM
- 48 56 42 46 89 45 65 83 32 99 97 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 77 161 206 18 55 142 152 159 92 145 70 155 221 52
+ 20 19 64 48 84 69 25 92 62 79 80 226 104 199 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 40 137 202 76 21 121 128 129 109 134 33 122 185 42
- $PROJ_DIR$\..\..\..\kernel\src\los_event.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
BICOMP
- 195
-
-
- ICCARM
- 204
-
-
- __cstat
- 86
-
-
-
-
- BICOMP
- 147 32 155 13 129 230 81 18 156 87 100 88 77 159 240 42 46 228 56 149 160 74 75 142 145 91 153 134 99 89 45 154 72 235 225 185 236 241 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 90
-
-
- ICCARM
- 90 153 156 32 99 42 46 89 45 240 134 154 91 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
-
-
- BICOMP
- 62
-
-
- ICCARM
- 16
-
-
- __cstat
- 22
-
-
-
-
- BICOMP
- 65 87 13 136 42 56 97 83 162 45 230 157 152 90 192 48 132 158 46 89 72 99 228 225 84 135 206 70 153 154 133 91 143 181 163 189 212 129 32 235 185 241 139 191 96 78 161 55 92 134 156 150 236 100 149 81 160 88 74 147 75 77 18 142 159 145 155 240
-
-
- ICCARM
- 150 192 48 56 42 46 89 45 65 162 189 132 212 158 163 133 72 129 32 99 13 93 225 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 154 90 153 156 240 134 91 83 143
-
-
-
-
- $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
-
-
- BICOMP
- 17
-
-
- ICCARM
- 36
+ 55
__cstat
180
+
+ ICCARM
+ 173
+
BICOMP
- 13 136 97 228 42 157 152 56 84 135 206 70 87 230 139 191 96 78 161 55 92 235 225 185 236 46 89 45 241 99 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+ 127 203 64 128 83 80 226 19 85 82 202 33 108 178 115 170 99 46 137 21 109 205 199 147 215 48 84 69 211 79 81 131 106 138 110 38 113 39 40 76 121 129 134 122
ICCARM
- 75 13 93 225 56 42 46 89 45 94 186 99 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 97 77 161 206 18 55 142 152 159 92 145 70 155
+ 99 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
- $PROJ_DIR$\..\..\..\kernel\src\los_err.c
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
+
+
+ BICOMP
+ 77
+
+
+ __cstat
+ 160
+
+
+ ICCARM
+ 222
+
+
+
+
+ BICOMP
+ 138 226 121 39 199 147 48 84 131 38 134 205 215 64 69 211 79 81 106 110 113 40 76 129 122 99 108 178 203 19 83 115 85 170 127 82 46 80 137 202 21 128 109 33
+
+
+ ICCARM
+ 80 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
+
+
+ BICOMP
+ 75
+
+
+ __cstat
+ 201
+
+
+ ICCARM
+ 229
+
+
+
+
+ BICOMP
+ 83 226 80 203 64 127 128 19 85 82 202 33 108 178 115 170 99 46 137 21 109 205 199 147 215 48 84 69 211 79 81 131 106 138 110 38 113 39 40 76 121 129 134 122
+
+
+ ICCARM
+ 40 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
BICOMP
197
- ICCARM
- 205
+ __cstat
+ 168
- __cstat
- 64
+ ICCARM
+ 63
+
+ BICOMP
+ 110 215 129 226 205 79 81 40 199 64 69 211 106 113 76 122 147 48 84 131 138 38 39 121 134 99 108 178 203 19 83 115 85 170 127 82 46 80 137 202 21 128 109 33
+
ICCARM
- 156 32 99 42 46 89 45
+ 170 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_tick.c
+
+
+ BICOMP
+ 45
+
+
+ __cstat
+ 195
+
+
+ ICCARM
+ 47
+
+
+
+
+ BICOMP
+ 199 48 147 109 99 226 79 115 137 64 211 170 46 21 126 36 205 215 83 85 127 82 80 202 128 33 89 62 84 69 239 108 178 203 19 81 131 106 138 110 38 113 39 40 76 121 129 134 122 132
+
+
+ ICCARM
+ 132 126 62 79 64 48 84 69 89 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw.c
+
+
+ BICOMP
+ 30
+
+
+ __cstat
+ 32
+
+
+ ICCARM
+ 23
+
+
+
+
+ BICOMP
+ 79 209 62 25 64 48 84 19 117 132 107 126 69 141 172 101 152 133 20 119 90 118 166 189
+
+
+ ICCARM
+ 101 132 126 62 79 64 48 84 69 209 107 141 117 172 20 19 25 119 166 90 189 118 133
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
+
+
+ BICOMP
+ 49
+
+
+ __cstat
+ 116
+
+
+ ICCARM
+ 73
+
+
+
+
+ BICOMP
+ 110 215 129 226 205 79 81 40 199 64 69 211 106 113 76 122 147 48 84 131 138 38 39 121 134 108 178 203 19 83 115 85 170 127 99 82 46 80 137 202 21 128 109 33
+
+
+ ICCARM
+ 85 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122
@@ -1156,113 +1189,261 @@
BICOMP
- 59
-
-
- ICCARM
- 104
+ 41
__cstat
- 148
+ 124
+
+
+ ICCARM
+ 86
BICOMP
- 13 139 32 99 161 225 185 96 92 83 45 241 191 78 55 72 41 89 240 235 236 42 136 84 157 135 97 206 152 70 90 91 156 46 153 134 154 129 87 230 228 56 100 149 81 160 88 74 147 75 77 18 142 159 145 155
+ 80 226 100 19 83 48 127 128 36 92 79 64 107 199 147 85 82 202 33 68 126 62 132 239 104 115 170 99 46 137 21 109 101 254 84 69 255 141 108 144 81 131 106 138 110 38 113 39 40 76 121 129 134 122
ICCARM
- 153 156 32 99 42 46 89 45 90 240 134 154 72 129 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 91 83 41
+ 132 126 62 79 64 48 84 69 101 209 107 141 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 89 92 68
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_exc.c
+ $PROJ_DIR$\..\..\..\kernel\src\los_tick.c
BICOMP
- 69
+ 187
__cstat
- 66
+ 87
+
+
+ ICCARM
+ 194
+
+
+ ICCARM
+ 132 126 62 79 64 48 84 69 36 239 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 101 209 107 141 17
+
+
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_dispatch_iar.S
+ $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
+
+
+ BICOMP
+ 139
+
+
+ __cstat
+ 198
+
+
+ ICCARM
+ 114
+
+
+
+
+ BICOMP
+ 33 82 226 19 85 202 203 64 83 127 80 128 108 178 115 170 99 46 137 21 109 42 205 199 147 215 48 84 69 211 79 81 131 106 138 110 38 113 39 40 76 121 129 134 122 185
+
+
+ ICCARM
+ 185 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 42
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_task.c
+
+
+ BICOMP
+ 190
+
+
+ __cstat
+ 149
+
+
+ ICCARM
+ 176
+
+
+
+
+ ICCARM
+ 36 239 62 79 64 48 84 69 226 104 199 19 100 144 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 46 39 80 40 137 202 76 21 121 128 129 109 134 33 122 117 172 20 25 119 166 90 189 118 133 31 101 132 126 209 107 141 148 103 89 16 92
+
+
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
+
+
+ BICOMP
+ 228
+
+
+ __cstat
+ 123
+
+
+ ICCARM
+ 224
+
+
+
+
+ BICOMP
+ 33 82 226 19 85 202 203 64 83 127 80 128 108 178 115 170 99 46 137 21 109 205 199 147 215 48 84 69 211 79 81 131 106 138 110 38 113 39 40 76 121 129 134 122
+
+
+ ICCARM
+ 46 226 104 199 19 64 48 84 69 100 144 79 108 147 83 81 115 131 85 106 170 138 127 110 99 38 82 113 39 80 40 137 202 76 21 121 128 129 109 134 33 122
+
+
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc.S
AARM
- 61
+ 60
-
- $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_hw_exc_iar.S
-
-
- AARM
- 58
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_misc.c
-
-
- BICOMP
- 207
-
-
- ICCARM
- 216
-
-
- __cstat
- 98
-
-
-
-
- ICCARM
- 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 153 156 240 134 154
-
-
-
-
- $PROJ_DIR$\..\..\..\kernel\src\los_timeslice.c
-
-
- BICOMP
- 95
-
-
- ICCARM
- 232
-
-
- __cstat
- 184
-
-
-
-
- BICOMP
- 99 149 87 74 145 13 32 160 75 142 42 46 186 100 81 88 147 77 18 159 155 90 72 129 89 45 93 225 185 94 56 136 139 84 191 157 96 135 78 97 161 206 55 152 92 70 240 91 153 134 156 154
-
-
- ICCARM
- 91 72 129 32 99 42 46 89 45 13 93 225 56 94 186 87 185 136 100 139 149 84 81 191 160 157 88 96 74 135 147 78 75 97 77 161 206 18 55 142 152 159 92 145 70 155 90 153 156 240 134 154
-
-
-
[MULTI_TOOL]
ILINK
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_context.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_interrupt.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\utils\los_debug.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\utils\los_error.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_event.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_membox.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\components\cppsupport\los_cppsupport.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_init.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\mm\los_memory.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_mux.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_queue.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\arch\arm\cortex-m4\iar\los_timer.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_sem.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_tim.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_swtmr.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\misc.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Utilities\STM32_EVAL\STM324x9I_EVAL\stm324x9i_eval.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\dprintf.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_rcc.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_usart.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_wwdg.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_gpio.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_exti.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\main.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_tick.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\board\iar_stm32f429ig_fire-challenger.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\..\..\kernel\src\los_task.c
+ ICCARM
+
+
+ $PROJ_DIR$\..\Libraries\STM32F4xx_StdPeriph_Driver\src\stm32f4xx_syscfg.c
+ ICCARM
+
[REBUILD_ALL]
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp
index 0439b2fb..8f1086bc 100755
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewp
@@ -312,7 +312,7 @@
CCDiagWarnAreErr
- 0
+ 1
CCCompilerRuntimeInfo
@@ -354,6 +354,7 @@
$PROJ_DIR$\..\Utilities\STM32_EVAL\Common
$PROJ_DIR$\..\..\..\components\bounds_checking_function\include
$PROJ_DIR$\..\..\..\utils
+ $PROJ_DIR$\..\..\..\components\exchook
CCStdIncCheck
@@ -653,7 +654,7 @@
OOCOutputFile
- los_demo.srec
+
OOCCommandLineProducer
@@ -1671,7 +1672,7 @@
OOCOutputFile
-
+ los_demo.srec
OOCCommandLineProducer
@@ -2078,6 +2079,9 @@
$PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+
+ $PROJ_DIR$\..\..\..\components\exchook\los_exc_info.c
+
$PROJ_DIR$\..\..\..\components\exchook\los_exchook.c
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt
index 17f39437..79613153 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/los_demo.ewt
@@ -2397,9 +2397,18 @@
$PROJ_DIR$\..\..\..\components\cpup\los_cpup.c
+
+ $PROJ_DIR$\..\..\..\components\exchook\los_exc_info.c
+
+
+ $PROJ_DIR$\..\..\..\components\exchook\los_exchook.c
+
utils
+
+ $PROJ_DIR$\..\..\..\utils\los_debug.c
+
$PROJ_DIR$\..\..\..\utils\los_error.c
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.crun b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.crun
deleted file mode 100644
index 62c21bb9..00000000
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.crun
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- 1
-
-
- *
- *
- *
- 0
- 1
-
-
-
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dbgdt b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dbgdt
deleted file mode 100644
index 7a993b0f..00000000
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dbgdt
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dnx b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dnx
deleted file mode 100644
index df4ced72..00000000
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.dnx
+++ /dev/null
@@ -1,100 +0,0 @@
-
-
-
- 0
- 0
- 1
- 0
- 1
- 0
-
-
- 0
- 0
- 1
- 0
- 1
-
-
- 0
- 1
- 90
- 1
- 1
- 1
- main
- 0
- 50
-
-
- 1
-
-
- 1
- 0
- 1
- 0
- 1
-
-
- 10000000
- 0
- 1
-
-
- 1748958015
-
-
- _ 0
- _ 0
-
-
- _ 0
-
-
- 0
-
-
- 0
-
-
- _ 0
- _ 0
-
-
- 0
- 1
-
-
- _ 0
- _ ""
- _ 0
-
-
- _ 0
- _ ""
-
-
- 0
- 1
- 0
- 0
-
-
-
- 0
-
-
- 1
-
-
- 0
-
-
- 0
-
-
- 0
- 0
-
-
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.wsdt b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.wsdt
deleted file mode 100644
index 4af2c723..00000000
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/project/settings/los_demo.wsdt
+++ /dev/null
@@ -1,464 +0,0 @@
-
-
-
-
- los_demo/Debug
-
-
-
-
- 34048
- 34049
- 34050
- 34051
- 34052
- 34053
- 34054
- 34055
- 34056
- 34057
- 34058
- 34059
- 34060
- 34061
- 34062
- 34063
- 34064
- 34065
-
-
-
-
- - 34000
- - 34001
- - 0
-
-
-
-
- - 57600
- - 57601
- - 57603
- - 33024
- - 0
- - 57607
- - 0
- - 57635
- - 57634
- - 57637
- - 0
- - 57643
- - 57644
- - 0
- - 33090
- - 33057
- - 57636
- - 57640
- - 57641
- - 33026
- - 33065
- - 33063
- - 33064
- - 33053
- - 33054
- - 0
- - 33035
- - 33036
- - 34399
- - 0
- - 33038
- - 33039
- - 0
-
-
-
-
- 190
- 30
- 30
- 30
-
-
- los_demo
- los_demo/liteos_m
- los_demo/liteos_m/components
- los_demo/liteos_m/utils
- los_demo/st_iar
- los_demo/st_iar/startup
- los_demo/st_iar/utils
-
-
-
- 24
- 1863
- 2
-
- 0
- -1
-
-
- 14
- 10
-
-
- 1
- 1
- 0
- 0
- 1
- 1
- 1
- 8A000000480040E1000001000000198000000200000001DC000001000000578600000100000013860000170000002981000003000000268100001200000078840000010000001086000005000000158100000200000084860000010000000D86000002000000239200000100000020810000020000000F810000050000005F86000001000000EA800000020000000D8000000600000001E10000010000001D810000050000000C8100006E00000003DC00000100000004860000010000002881000001000000018600000100000000DC0000010000005686000018000000178100000100000003840000050000000084000001000000808C000001000000778400000100000014810000020000000C8600000100000028E10000350000000E840000010000000081000001000000D7840000010000001A8600000100000009860000010000001F810000020000005E8600001000000003E1000006000000ECFFFFFF010000000E81000009000000E98000000300000000E10000020000000B81000006000000058400000100000002DC00000100000014860000010000004981000001000000008600000100000005810000010000000284000006000000558600000200000011860000050000001681000001000000248100000200000010840000010000000E860000010000004681000006000000EA840000010000002181000003000000608600002200000002E10000010000005D8600000200000008860000010000001E810000030000000D810000140000000586000001000000C086000001000000
-
-
- 13000D8400000F84000008840000FFFFFFFF54840000328100001C810000098400007784000007840000808C0000D4840000818400007D8400008284000083840000848400000E84000030840000
- 10000484000045000000318400004C0000000F8100001C00000020810000240000000C81000019000000068400004700000003840000440000000E8100001B0000001F810000230000000B8100001C00000005840000460000000284000043000000328400004D000000108400004A0000000D8100001E0000000A84000048000000
-
-
- 0
- 0A0000000A0000006E0000006E000000
- 00000000F00300008007000003040000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 1
-
-
- 4294967295
- 80F8FFFF4900000086F9FFFF52030000
- 0000000032000000060100003B030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 1
-
-
- 34050
- 000000001700000022010000C8000000
- 04000000570300007C070000D6030000
- 32768
- 0
- 0
- 32767
- 0
-
-
- 1
-
-
- 21
- 1408
- 375
- 93
- 2
- D:\code\c\tmp\liteos_m\targets\cortex-m4_stm32f429ig_fire-challenger_iar\project\BuildLog.log
- 0
- -1
-
-
- 34052
- 000000001700000022010000C8000000
- 04000000570300007C070000D6030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
- 2
- $WS_DIR/CMSISPackAgentLog.log
- 0
- -1
-
-
- 34054
- 000000001700000022010000C8000000
- 04000000570300007C070000D6030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
- 666
- 95
- 1142
- 2
-
- 0
- -1
-
-
- 34055
- 000000001700000022010000C8000000
- 04000000570300007C070000D6030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
- 666
- 95
- 1142
- 2
-
- 0
- -1
-
-
- 34056
- 000000001700000022010000C8000000
- 04000000570300007C070000D6030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
- 571
- 95
- 856
- 380
- 2
-
- 0
- -1
-
-
- 34057
- 000000001700000022010000C8000000
- 04000000570300007C070000D6030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
- 666
- 95
- 1142
- 2
-
- 0
- -1
-
-
- 34059
- 000000001700000022010000C8000000
- 04000000570300007C070000D6030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
- 2
-
- 0
- -1
-
-
- 34063
- 80F8FFFF17000000A2F9FFFFC8000000
- 04000000570300007C070000D6030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 1
-
-
- 34051
- 000000001700000080020000A8000000
- 00000000000000008002000091000000
- 32768
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
-
- 34053
- 000000001700000022010000C8000000
- 000000000000000022010000B1000000
- 32768
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
-
- 34058
- 00000000170000000601000078010000
- 040000004A0000000201000021030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
- 2147483647
- 1
-
-
- 34060
- 00000000170000000601000078010000
- 0000000046000000060100003B030000
- 4096
- 0
- 0
- 32767
- 0
-
-
- 1
-
-
- 34061
- 80F8FFFF17000000A2F9FFFFC8000000
- 000000000000000022010000B1000000
- 32768
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
-
- 34062
- 80F8FFFF17000000A2F9FFFFC8000000
- 000000000000000022010000B1000000
- 32768
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
-
- 34064
- 80F8FFFF17000000A2F9FFFFC8000000
- 000000000000000022010000B1000000
- 32768
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
-
- 34065
- 80F8FFFF17000000A2F9FFFFC8000000
- 000000000000000022010000B1000000
- 32768
- 0
- 0
- 32767
- 0
-
-
- 0
-
-
-
- 000000000C000000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000E85000000000000000000000000000000000000010000000E850000010000000E850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000D85000000000000000000000000000000000000010000000D850000010000000D850000000000000010000001000000FFFFFFFFFFFFFFFF06010000320000000A0100003B030000010000000200001004000000010000000000000000000000FFFFFFFF020000000A8500000C850000FFFF02000B004354616262656450616E65001000000100000080F8FFFF4900000086F9FFFF520300000000000032000000060100003B030000000000004010005602000000FFFEFF1C53006F0075007200630065002000420072006F00770073006500720020002D0020004E006F007400200065006E00610062006C0065006400000000000A85000001000000FFFFFFFFFFFFFFFFFFFEFF0957006F0072006B0073007000610063006500010000000C85000001000000FFFFFFFFFFFFFFFF01000000000000000000000000000000000000000000000001000000FFFFFFFF0A85000001000000FFFFFFFF0A850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000058500000000000000000000000000000000000001000000058500000100000005850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000038500000000000000000000000000000000000001000000038500000100000003850000000000000080000001000000FFFFFFFFFFFFFFFF000000003B030000800700003F030000010000000100001004000000010000000000000000000000FFFFFFFF080000000285000004850000068500000785000008850000098500000B8500000F8500000180008000000100000080F8FFFF560300000000000007040000000000003F03000080070000F0030000000000004080005608000000FFFEFF054200750069006C006400010000000285000001000000FFFFFFFFFFFFFFFFFFFEFF0E43004D005300490053002D005000610063006B0020004C006F006700000000000485000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300000000000685000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000785000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000885000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000B85000001000000FFFFFFFFFFFFFFFFFFFEFF094400650062007500670020004C006F006700010000000F85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0285000001000000FFFFFFFF02850000000000000000000000000000
-
-
- CMSIS-Pack
- 00200000010000000200FFFF01001100434D4643546F6F6C426172427574746F6ED0840000000004000C000000FFFEFF0000000000000000000000000001000000010000000180D1840000000000000D000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF0A43004D005300490053002D005000610063006B002F000000
-
-
- 34048
- 0A0000000A0000006E0000006E000000
- FE020000180000004303000032000000
- 8192
- 1
- 0
- 47
- 0
-
-
- 1
-
-
- Main
- 00200000010000002000FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000036000000FFFEFF000000000000000000000000000100000001000000018001E100000000000037000000FFFEFF000000000000000000000000000100000001000000018003E100000000000039000000FFFEFF000000000000000000000000000100000001000000018000810000000000001A000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E10000000000003C000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E10000000004003E000000FFFEFF000000000000000000000000000100000001000000018022E10000000004003D000000FFFEFF000000000000000000000000000100000001000000018025E100000000000040000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE100000000040043000000FFFEFF00000000000000000000000000010000000100000001802CE100000000040044000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6E4281000000000000FFFFFFFFFFFEFF0001000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF0096000000000000000000018021810000000004002D000000FFFEFF000000000000000000000000000100000001000000018024E10000000000003F000000FFFEFF000000000000000000000000000100000001000000018028E100000000040041000000FFFEFF000000000000000000000000000100000001000000018029E100000000000042000000FFFEFF000000000000000000000000000100000001000000018002810000000000001C000000FFFEFF0000000000000000000000000001000000010000000180298100000000000031000000FFFEFF000000000000000000000000000100000001000000018027810000000000002F000000FFFEFF0000000000000000000000000001000000010000000180288100000000000030000000FFFEFF00000000000000000000000000010000000100000001801D8100000000040029000000FFFEFF00000000000000000000000000010000000100000001801E810000000004002A000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B8100000000000020000000FFFEFF00000000000000000000000000010000000100000001800C8100000000000021000000FFFEFF00000000000000000000000000010000000100000001805F8600000000000035000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800E8100000000000023000000FFFEFF00000000000000000000000000010000000100000001800F8100000000000024000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00E8020000
-
-
- 34049
- 0A0000000A0000006E0000006E000000
- 0000000018000000FE02000032000000
- 8192
- 1
- 0
- 744
- 0
-
-
- 1
-
-
-
-
- 010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000001000000010000000000000001000000FFFEFF122400570053005F0044004900520024005C002E002E005C006D00610069006E002E00630001000000FFFF010014004966436F6E74656E7453746F72616765496D706CFFFEFF00FFFEFFFF20013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E0030003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0030003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0030003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF066D00610069006E002E00630000000000FFFFFFFFFFFFFFFF0000000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000001000000020000008AF9FFFF490000000000000052030000
-
-
-
-
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_conf.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_conf.h
index f588717b..bfb69a74 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_conf.h
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_conf.h
@@ -1,6 +1,6 @@
/**
******************************************************************************
- * @file ADC/ADC_DMA/stm32f4xx_conf.h
+ * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_conf.h
* @author MCD Application Team
* @version V1.8.0
* @date 04-November-2016
@@ -51,7 +51,7 @@
#include "stm32f4xx_wwdg.h"
#include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */
-#if defined (STM32F429_439xx)
+#if defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
#include "stm32f4xx_cryp.h"
#include "stm32f4xx_hash.h"
#include "stm32f4xx_rng.h"
@@ -62,9 +62,9 @@
#include "stm32f4xx_fmc.h"
#include "stm32f4xx_ltdc.h"
#include "stm32f4xx_sai.h"
-#endif /* STM32F429_439xx */
+#endif /* STM32F429_439xx || STM32F446xx || STM32F469_479xx */
-#if defined (STM32F427_437xx)
+#if defined(STM32F427_437xx)
#include "stm32f4xx_cryp.h"
#include "stm32f4xx_hash.h"
#include "stm32f4xx_rng.h"
@@ -76,7 +76,7 @@
#include "stm32f4xx_sai.h"
#endif /* STM32F427_437xx */
-#if defined (STM32F40_41xxx)
+#if defined(STM32F40_41xxx)
#include "stm32f4xx_cryp.h"
#include "stm32f4xx_hash.h"
#include "stm32f4xx_rng.h"
@@ -86,6 +86,56 @@
#include "stm32f4xx_fsmc.h"
#endif /* STM32F40_41xxx */
+#if defined(STM32F410xx)
+#include "stm32f4xx_rng.h"
+#include "stm32f4xx_dac.h"
+#endif /* STM32F410xx */
+
+#if defined(STM32F411xE)
+#include "stm32f4xx_flash_ramfunc.h"
+#endif /* STM32F411xE */
+
+#if defined(STM32F446xx) || defined(STM32F469_479xx)
+#include "stm32f4xx_qspi.h"
+#endif /* STM32F446xx || STM32F469_479xx */
+
+#if defined(STM32F410xx) || defined(STM32F446xx)
+#include "stm32f4xx_fmpi2c.h"
+#endif /* STM32F410xx || STM32F446xx */
+
+#if defined(STM32F446xx)
+#include "stm32f4xx_spdifrx.h"
+#include "stm32f4xx_cec.h"
+#endif /* STM32F446xx */
+
+#if defined(STM32F469_479xx)
+#include "stm32f4xx_dsi.h"
+#endif /* STM32F469_479xx */
+
+#if defined(STM32F410xx)
+#include "stm32f4xx_lptim.h"
+#endif /* STM32F410xx */
+
+#if defined(STM32F412xG)
+#include "stm32f4xx_rng.h"
+#include "stm32f4xx_can.h"
+#include "stm32f4xx_qspi.h"
+#include "stm32f4xx_rng.h"
+#include "stm32f4xx_fsmc.h"
+#include "stm32f4xx_dfsdm.h"
+#endif /* STM32F412xG */
+
+#if defined(STM32F413_423xx)
+#include "stm32f4xx_cryp.h"
+#include "stm32f4xx_fmpi2c.h"
+#include "stm32f4xx_rng.h"
+#include "stm32f4xx_can.h"
+#include "stm32f4xx_qspi.h"
+#include "stm32f4xx_rng.h"
+#include "stm32f4xx_fsmc.h"
+#include "stm32f4xx_dfsdm.h"
+#endif /* STM32F413_423xx */
+
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.c b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.c
index 9a643d15..662443c0 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.c
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.c
@@ -1,28 +1,35 @@
/**
******************************************************************************
- * @file Project/STM32F4xx_StdPeriph_Template/stm32f4xx_it.c
+ * @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.c
* @author MCD Application Team
- * @version V1.0.0
- * @date 30-September-2011
+ * @version V1.8.0
+ * @date 04-November-2016
* @brief Main Interrupt Service Routines.
- * This file provides template for all exceptions handler and
+ * This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
- * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
- * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
- * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
- * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
- * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ * © COPYRIGHT 2016 STMicroelectronics
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * © COPYRIGHT 2011 STMicroelectronics
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_it.h"
+#include "main.h"
/** @addtogroup Template_Project
* @{
@@ -40,7 +47,7 @@
/******************************************************************************/
/**
- * @brief This function handles NMI exception.
+ * @brief This function handles NMI exception.
* @param None
* @retval None
*/
@@ -105,7 +112,7 @@ void UsageFault_Handler(void)
* @param None
* @retval None
*/
-__weak void SVC_Handler(void)
+void SVC_Handler(void)
{
}
@@ -123,7 +130,7 @@ void DebugMon_Handler(void)
* @param None
* @retval None
*/
-__weak void PendSV_Handler(void)
+void PendSV_Handler(void)
{
}
@@ -132,27 +139,30 @@ __weak void PendSV_Handler(void)
* @param None
* @retval None
*/
-__weak void SysTick_Handler(void)
+void SysTick_Handler(void)
{
-
+ TimingDelay_Decrement();
}
+/******************************************************************************/
+/* STM32F4xx Peripherals Interrupt Handlers */
+/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
+/* available peripheral interrupt handler's name please refer to the startup */
+/* file (startup_stm32f4xx.s). */
+/******************************************************************************/
+
/**
- * @brief This function handles EXTI 3 interrupt request.
+ * @brief This function handles PPP interrupt request.
* @param None
* @retval None
*/
-__weak void EXTI9_5_IRQHandler(void)
+/*void PPP_IRQHandler(void)
{
-}
+}*/
/**
- * @brief This function handles EXTI 15-10 interrupt request.
- * @param None
- * @retval None
- */
-__weak void EXTI15_10_IRQHandler(void)
-{
-}
+ * @}
+ */
-/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
+
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.h
index 77a61e50..f4c2ef42 100644
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.h
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/stm32f4xx_it.h
@@ -2,22 +2,28 @@
******************************************************************************
* @file Project/STM32F4xx_StdPeriph_Templates/stm32f4xx_it.h
* @author MCD Application Team
- * @version V1.0.0
- * @date 30-September-2011
+ * @version V1.8.0
+ * @date 04-November-2016
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
- * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
- * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
- * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
- * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
- * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
- * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+ * © COPYRIGHT 2016 STMicroelectronics
+ *
+ * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.st.com/software_license_agreement_liberty_v2
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*
- * © COPYRIGHT 2011 STMicroelectronics
******************************************************************************
- */
+ */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_IT_H
@@ -51,4 +57,4 @@ void SysTick_Handler(void);
#endif /* __STM32F4xx_IT_H */
-/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h
index 50b8fcd0..6f6b8721 100755
--- a/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h
+++ b/targets/cortex-m4_stm32f429ig_fire-challenger_iar/target_config.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -48,7 +48,7 @@ extern "C" {
/*=============================================================================
System clock module configuration
=============================================================================*/
-#define OS_SYS_CLOCK 180000000
+#define OS_SYS_CLOCK 64000000
#define LOSCFG_BASE_CORE_TICK_PER_SECOND (1000UL)
#define LOSCFG_BASE_CORE_TICK_HW_TIME 0
/*=============================================================================
@@ -92,6 +92,10 @@ extern "C" {
=============================================================================*/
#define LOSCFG_MEM_MUL_POOL 1
#define OS_SYS_MEM_NUM 20
+/*=============================================================================
+ Exception module configuration
+=============================================================================*/
+#define LOSCFG_PLATFORM_EXC 1
/* =============================================================================
printf module configuration
============================================================================= */
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/Core/Inc/task_sample.h b/targets/cortex-m7_nucleo_f767zi_gcc/Core/Inc/task_sample.h
index bd8cc782..408f7ff8 100644
--- a/targets/cortex-m7_nucleo_f767zi_gcc/Core/Inc/task_sample.h
+++ b/targets/cortex-m7_nucleo_f767zi_gcc/Core/Inc/task_sample.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/Core/Src/syscalls.c b/targets/cortex-m7_nucleo_f767zi_gcc/Core/Src/syscalls.c
deleted file mode 100644
index 1b4932cb..00000000
--- a/targets/cortex-m7_nucleo_f767zi_gcc/Core/Src/syscalls.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* Support files for GNU libc. Files in the system namespace go here.
- Files in the C namespace (ie those that do not start with an
- underscore) go in .c. */
-
-#include <_ansi.h>
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-
-#define FreeRTOS
-#define MAX_STACK_SIZE 0x2000
-
-extern int __io_putchar(int ch) __attribute__((weak));
-extern int __io_getchar(void) __attribute__((weak));
-
-#ifndef FreeRTOS
- register char * stack_ptr asm("sp");
-#endif
-
-
-
-
-caddr_t _sbrk(int incr)
-{
- extern char end asm("end");
- static char *heap_end;
- char *prev_heap_end,*min_stack_ptr;
-
- if (heap_end == 0)
- heap_end = &end;
-
- prev_heap_end = heap_end;
-
-#ifdef FreeRTOS
- /* Use the NVIC offset register to locate the main stack pointer. */
- min_stack_ptr = (char*)(*(unsigned int *)*(unsigned int *)0xE000ED08);
- /* Locate the STACK bottom address */
- min_stack_ptr -= MAX_STACK_SIZE;
-
- if (heap_end + incr > min_stack_ptr)
-#else
- if (heap_end + incr > stack_ptr)
-#endif
- {
-// write(1, "Heap and stack collision\n", 25);
-// abort();
- errno = ENOMEM;
- return (caddr_t) -1;
- }
-
- heap_end += incr;
-
- return (caddr_t) prev_heap_end;
-}
-
-/*
- * _gettimeofday primitive (Stub function)
- * */
-int _gettimeofday (struct timeval * tp, struct timezone * tzp)
-{
- /* Return fixed data for the timezone. */
- if (tzp)
- {
- tzp->tz_minuteswest = 0;
- tzp->tz_dsttime = 0;
- }
-
- return 0;
-}
-void initialise_monitor_handles()
-{
-}
-
-int _getpid(void)
-{
- return 1;
-}
-
-int _kill(int pid, int sig)
-{
- errno = EINVAL;
- return -1;
-}
-
-void _exit (int status)
-{
- _kill(status, -1);
- while (1) {}
-}
-
-int _write(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- __io_putchar( *ptr++ );
- }
- return len;
-}
-
-int _close(int file)
-{
- return -1;
-}
-
-int _fstat(int file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _isatty(int file)
-{
- return 1;
-}
-
-int _lseek(int file, int ptr, int dir)
-{
- return 0;
-}
-
-int _read(int file, char *ptr, int len)
-{
- int DataIdx;
-
- for (DataIdx = 0; DataIdx < len; DataIdx++)
- {
- *ptr++ = __io_getchar();
- }
-
- return len;
-}
-
-int _open(char *path, int flags, ...)
-{
- /* Pretend like we always fail */
- return -1;
-}
-
-int _wait(int *status)
-{
- errno = ECHILD;
- return -1;
-}
-
-int _unlink(char *name)
-{
- errno = ENOENT;
- return -1;
-}
-
-int _times(struct tms *buf)
-{
- return -1;
-}
-
-int _stat(char *file, struct stat *st)
-{
- st->st_mode = S_IFCHR;
- return 0;
-}
-
-int _link(char *old, char *new)
-{
- errno = EMLINK;
- return -1;
-}
-
-int _fork(void)
-{
- errno = EAGAIN;
- return -1;
-}
-
-int _execve(char *name, char **argv, char **env)
-{
- errno = ENOMEM;
- return -1;
-}
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/Core/Src/task_sample.c b/targets/cortex-m7_nucleo_f767zi_gcc/Core/Src/task_sample.c
index 8835b5c6..5729406b 100644
--- a/targets/cortex-m7_nucleo_f767zi_gcc/Core/Src/task_sample.c
+++ b/targets/cortex-m7_nucleo_f767zi_gcc/Core/Src/task_sample.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/Drivers/CMSIS/LICENSE.txt b/targets/cortex-m7_nucleo_f767zi_gcc/Drivers/CMSIS/LICENSE.txt
new file mode 100644
index 00000000..c0ee8129
--- /dev/null
+++ b/targets/cortex-m7_nucleo_f767zi_gcc/Drivers/CMSIS/LICENSE.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/Drivers/CMSIS/README.md b/targets/cortex-m7_nucleo_f767zi_gcc/Drivers/CMSIS/README.md
new file mode 100644
index 00000000..08861a65
--- /dev/null
+++ b/targets/cortex-m7_nucleo_f767zi_gcc/Drivers/CMSIS/README.md
@@ -0,0 +1,104 @@
+# CMSIS Version 5
+
+The branch *master* of this GitHub repository contains the CMSIS Version 5.4.0. The [documentation](http://arm-software.github.io/CMSIS_5/General/html/index.html) is available under http://arm-software.github.io/CMSIS_5/General/html/index.html
+
+Use [Issues](https://github.com/ARM-software/CMSIS_5#issues-and-labels) to provide feedback and report problems for CMSIS Version 5.
+
+**Note:** The branch *develop* of this GitHub repository reflects our current state of development and is constantly updated. It gives our users and partners contiguous access to the CMSIS development. It allows you to review the work and provide feedback or create pull requests for contributions.
+
+A [pre-built documentation](http://www.keil.com/pack/doc/CMSIS_Dev/index.html) is updated from time to time, but may be also generated using the instructions under [Generate CMSIS Pack for Release](https://github.com/ARM-software/CMSIS_5#generate-cmsis-pack-for-release).
+
+## Implemented Enhancements
+ - CMSIS-Core-A, RTX5: implementation for Cortex-A5/A7/A9
+ - Support for Armv8-M Architecture (Mainline and Baseline) as well as devices Cortex-M23 and Cortex-M33
+ - CMSIS-RTOS2: RTX 5 is now available for IAR, GCC, Arm Compiler 5, Arm Compiler 6
+ - CMSIS-RTOS2: FreeRTOS adoption (release) is available https://github.com/ARM-software/CMSIS-FreeRTOS
+ - CMSIS-NN: Bare metal Neural Network function library.
+ - CMSIS-DAP v2: with WinUSB for faster communication and separate pipe for SWO support
+ - Config Wizard extension: access enum’s for configuration information
+
+## Further Planned Enhancements
+ - CMSIS-Zone: management of complex system
+ - CMSIS-Pack:
+ - System Description SDF Format: describe more complex debug topologies than with a Debug Description in a tool agnostic way
+ - Github based workflow: allows to develop software packs using github infra-structure
+ - Flash algorithm via debugger: Some TurstZone enable devices cannot execute RAM. Commands that allow flash programming will be added to Debug Description.
+ - CPDSC project file format: allows project templates that are agnostic of an IDE
+ - Minimize need for IDE specific settings: CMSIS-Pack supports IDE specific parameters. Analyze and minimize
+
+For further details see also the [Slides of the Embedded World CMSIS Partner Meeting](https://github.com/ARM-software/CMSIS_5/blob/develop/CMSIS_EW2018.pdf).
+
+## Directory Structure
+
+| Directory | Content |
+| --------------- | ---------------------------------------------- |
+| CMSIS/Core | CMSIS-Core related files (for release) |
+| CMSIS/DAP | CMSIS-DAP related files and examples |
+| CMSIS/Driver | CMSIS-Driver API headers and template files |
+| CMSIS/DSP | CMSIS-DSP related files |
+| CMSIS/NN | CMSIS-NN related files |
+| CMSIS/RTOS | RTOS v1 related files (for Cortex-M) |
+| CMSIS/RTOS2 | RTOS v2 related files (for Cortex-M & Armv8-M) |
+| CMSIS/Pack | CMSIS-Pack examples and tutorials |
+| CMSIS/DoxyGen | Source of the documentation |
+| CMSIS/Utilities | Utility programs |
+
+## Generate CMSIS Pack for Release
+
+This GitHub development repository contains already pre-built libraries of various software components (DSP, RTOS, RTOS2).
+These libraries are validated for release.
+
+To build a complete CMSIS pack for installation the following additional tools are required:
+ - **doxygen.exe** Version: 1.8.6 (Documentation Generator)
+ - **mscgen.exe** Version: 0.20 (Message Sequence Chart Converter)
+ - **7z.exe (7-Zip)** Version: 16.02 (File Archiver)
+
+Using these tools, you can generate on a Windows PC:
+ - **CMSIS Software Pack** using the batch file **gen_pack.bat** (located in ./CMSIS/Utilities). This batch file also generates the documentation.
+
+ - **CMSIS Documentation** using the batch file **genDoc.bat** (located in ./CMSIS/Doxygen).
+
+The file ./CMSIS/DoxyGen/How2Doc.txt describes the rules for creating API documentation.
+
+## License
+
+Arm CMSIS is licensed under Apache-2.0.
+
+## Contributions and Pull Requests
+
+Contributions are accepted under Apache-2.0. Only submit contributions where you have authored all of the code.
+
+### Issues and Labels
+
+Please feel free to raise an [issue on GitHub](https://github.com/ARM-software/CMSIS_5/issues)
+to report misbehavior (i.e. bugs) or start discussions about enhancements. This
+is your best way to interact directly with the maintenance team and the community.
+We encourage you to append implementation suggestions as this helps to decrease the
+workload of the very limited maintenance team.
+
+We will be monitoring and responding to issues as best we can.
+Please attempt to avoid filing duplicates of open or closed items when possible.
+In the spirit of openness we will be tagging issues with the following:
+
+- **bug** – We consider this issue to be a bug that will be investigated.
+
+- **wontfix** - We appreciate this issue but decided not to change the current behavior.
+
+- **enhancement** – Denotes something that will be implemented soon.
+
+- **future** - Denotes something not yet schedule for implementation.
+
+- **out-of-scope** - We consider this issue loosely related to CMSIS. It might by implemented outside of CMSIS. Let us know about your work.
+
+- **question** – We have further questions to this issue. Please review and provide feedback.
+
+- **documentation** - This issue is a documentation flaw that will be improved in future.
+
+- **review** - This issue is under review. Please be patient.
+
+- **DONE** - We consider this issue as resolved - please review and close it. In case of no further activity this issues will be closed after a week.
+
+- **duplicate** - This issue is already addressed elsewhere, see comment with provided references.
+
+- **Important Information** - We provide essential informations regarding planned or resolved major enhancements.
+
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/LICENSE.pdf b/targets/cortex-m7_nucleo_f767zi_gcc/LICENSE.pdf
new file mode 100644
index 00000000..9d4bdbc0
Binary files /dev/null and b/targets/cortex-m7_nucleo_f767zi_gcc/LICENSE.pdf differ
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/Makefile b/targets/cortex-m7_nucleo_f767zi_gcc/Makefile
index 594f8cef..fd624e96 100644
--- a/targets/cortex-m7_nucleo_f767zi_gcc/Makefile
+++ b/targets/cortex-m7_nucleo_f767zi_gcc/Makefile
@@ -37,7 +37,6 @@ BUILD_DIR = build
# C sources
C_SOURCES = \
Core/Src/main.c \
-Core/Src/syscalls.c \
Core/Src/stm32f7xx_it.c \
Core/Src/stm32f7xx_hal_msp.c \
Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c \
diff --git a/targets/cortex-m7_nucleo_f767zi_gcc/target_config.h b/targets/cortex-m7_nucleo_f767zi_gcc/target_config.h
old mode 100755
new mode 100644
index 5e61737b..a49fbd69
--- a/targets/cortex-m7_nucleo_f767zi_gcc/target_config.h
+++ b/targets/cortex-m7_nucleo_f767zi_gcc/target_config.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/targets/riscv_sifive_fe310_gcc/target_config.h b/targets/riscv_sifive_fe310_gcc/target_config.h
new file mode 100755
index 00000000..d301e288
--- /dev/null
+++ b/targets/riscv_sifive_fe310_gcc/target_config.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be used
+ * to endorse or promote products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _TARGETS_CONFIG_H
+#define _TARGETS_CONFIG_H
+
+#include "soc.h"
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+#define OS_SYS_CLOCK 10000000UL
+
+#define LOSCFG_BASE_CORE_TICK_PER_SECOND 1000
+
+/****************************** System clock module configuration ****************************/
+#define LOSCFG_BASE_CORE_TIMER_NUM 7
+
+/****************************** Task module configuration ********************************/
+#define LOSCFG_BASE_CORE_TSK_LIMIT 20 // max num task
+#define LOSCFG_BASE_CORE_TSK_IDLE_STACK_SIZE (0x500U) // IDLE task stack
+#define LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE (0x2D0U) // default stack
+#define LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE (0x130U)
+#define LOSCFG_BASE_CORE_TIMESLICE 1 // task-ROBIN moduel cutting switch
+#define LOSCFG_BASE_CORE_TIMESLICE_TIMEOUT 10
+/****************************** Semaphore module configuration ******************************/
+#define LOSCFG_BASE_IPC_SEM 1
+#define LOSCFG_BASE_IPC_SEM_LIMIT 10 // the max sem-numb
+/****************************** mutex module configuration ******************************/
+#define LOSCFG_BASE_IPC_MUX 1
+#define LOSCFG_BASE_IPC_MUX_LIMIT 10 // the max mutex-num
+/****************************** Queue module configuration ********************************/
+#define LOSCFG_BASE_IPC_QUEUE 1
+#define LOSCFG_BASE_IPC_QUEUE_LIMIT 10 //the max queue-numb
+
+/****************************** Software timer module configuration **************************/
+#define LOSCFG_BASE_CORE_SWTMR 1
+#define LOSCFG_BASE_CORE_SWTMR_LIMIT 10 // the max SWTMR numb
+
+/****************************** Memory module configuration **************************/
+#define LOSCFG_MEM_MUL_POOL 1
+#define OS_SYS_MEM_NUM 20
+/*=============================================================================
+ Exception module configuration
+=============================================================================*/
+#define LOSCFG_PLATFORM_EXC 0
+/* =============================================================================
+ printf module configuration
+============================================================================= */
+#define LOSCFG_KERNEL_PRINTF 1
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* __cplusplus */
+
+
+#endif /* _TARGETS_CONFIG_H */
diff --git a/utils/BUILD.gn b/utils/BUILD.gn
new file mode 100644
index 00000000..86fa3693
--- /dev/null
+++ b/utils/BUILD.gn
@@ -0,0 +1,42 @@
+# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
+# Copyright (c) 2020-2021, Huawei Device Co., Ltd. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice, this list of
+# conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice, this list
+# of conditions and the following disclaimer in the documentation and/or other materials
+# provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its contributors may be used
+# to endorse or promote products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+static_library("utils") {
+ sources = [
+ "los_debug.c",
+ "los_error.c",
+ ]
+
+ include_dirs = [
+ "../kernel/include",
+ "../kernel/arch/include",
+ "./",
+ "//third_party/bounds_checking_function/include",
+ ]
+}
diff --git a/utils/los_compiler.h b/utils/los_compiler.h
index 73683993..94d08417 100755
--- a/utils/los_compiler.h
+++ b/utils/los_compiler.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/utils/los_debug.c b/utils/los_debug.c
old mode 100644
new mode 100755
index 83566565..3ecb2d0d
--- a/utils/los_debug.c
+++ b/utils/los_debug.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -51,6 +51,24 @@ STATIC const CHAR *g_logString[] = {
#endif
STATIC ExcHookFn g_excHook;
+STATIC BACK_TRACE_HOOK g_backTraceHook = NULL;
+
+VOID OsBackTraceHookSet(BACK_TRACE_HOOK hook)
+{
+ if (g_backTraceHook == NULL) {
+ g_backTraceHook = hook;
+ }
+}
+
+VOID OsBackTraceHookCall(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount)
+{
+ if (g_backTraceHook != NULL) {
+ g_backTraceHook(LR, LRSize, jumpCount);
+ } else {
+ PRINT_ERR("Record LR failed, because of g_backTraceHook is not registered, "
+ "should call LOS_BackTraceInit firstly\n");
+ }
+}
VOID OsExcHookRegister(ExcHookFn excHookFn)
{
diff --git a/utils/los_debug.h b/utils/los_debug.h
index fef97e0e..424290bd 100755
--- a/utils/los_debug.h
+++ b/utils/los_debug.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@@ -165,6 +165,9 @@ extern VOID HalConsoleOutput(LogModuleType type, INT32 level, const CHAR *fmt, .
} while (0)
#endif
+typedef VOID (*BACK_TRACE_HOOK)(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount);
+extern VOID OsBackTraceHookSet(BACK_TRACE_HOOK hook);
+extern VOID OsBackTraceHookCall(UINTPTR *LR, UINT32 LRSize, UINT32 jumpCount);
/**
* @ingroup los_trace
diff --git a/utils/los_error.c b/utils/los_error.c
index 9a762fbd..38cf2cde 100644
--- a/utils/los_error.c
+++ b/utils/los_error.c
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/utils/los_error.h b/utils/los_error.h
index 7d24989c..3c090722 100644
--- a/utils/los_error.h
+++ b/utils/los_error.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/utils/los_list.h b/utils/los_list.h
index fbd622c0..9f1bb94e 100644
--- a/utils/los_list.h
+++ b/utils/los_list.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
diff --git a/utils/los_reg.h b/utils/los_reg.h
index d3c91203..24bf63d1 100644
--- a/utils/los_reg.h
+++ b/utils/los_reg.h
@@ -1,6 +1,6 @@
/*
- * Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
- * Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
+ * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: