pull/3/head
eee 1 year ago
parent e906e8aaca
commit 6ff2b24e95

@ -0,0 +1,11 @@
### 该问题是怎么引起的?
### 重现步骤
### 报错信息

@ -0,0 +1,21 @@
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
### 是否需要同步至release3.0LTS ... )分支?
必须选择一项在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
- [ ] 是,需要同步的分支:
- [ ] 否
理由:

@ -0,0 +1,24 @@
# General ignored file types
*.o
*.a
*.so
*.swp
# IDE settings
.vscode
.idea
.settings
.cproject
.project
# VIM files
cscope*
tags
# Menuconfig temp files
/config.h
/.config
/.config.old
# Build temp files
/out

@ -34,9 +34,7 @@ LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
declare_args() {
tee_enable = false
liteos_name = "OHOS_Image"
liteos_container_enable = false
liteos_skip_make = false
liteos_is_mini = false
}
tee = ""
@ -130,9 +128,7 @@ config("stdinc_config") {
"-isystem",
std_include,
]
if (!defined(LOSCFG_LIBC_NEWLIB)) {
cflags += [ "-nostdinc" ]
}
asmflags = cflags
}
@ -202,10 +198,6 @@ config("warn_config") {
]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-Wno-address-of-packed-member" ]
cflags += [
"-Wno-unused-but-set-variable",
"-Wno-strict-prototypes",
]
}
asmflags = cflags
}
@ -244,28 +236,6 @@ config("misc_config") {
asmflags = cflags
}
config("container_config") {
if (liteos_container_enable) {
cflags = [
"-DLOSCFG_KERNEL_CONTAINER",
"-DLOSCFG_PID_CONTAINER",
"-DLOSCFG_UTS_CONTAINER",
"-DLOSCFG_MNT_CONTAINER",
"-DLOSCFG_CHROOT",
"-DLOSCFG_IPC_CONTAINER",
"-DLOSCFG_TIME_CONTAINER",
"-DLOSCFG_USER_CONTAINER",
"-DLOSCFG_NET_CONTAINER",
"-DLOSCFG_PROC_PROCESS_DIR",
"-DLOSCFG_KERNEL_PLIMITS",
"-DLOSCFG_KERNEL_MEM_PLIMIT",
"-DLOSCFG_KERNEL_IPC_PLIMIT",
"-DLOSCFG_KERNEL_DEV_PLIMIT",
"-DLOSCFG_KERNEL_SCHED_PLIMIT",
]
}
}
config("los_config") {
configs = [
":arch_config",
@ -276,7 +246,6 @@ config("los_config") {
":ssp_config",
":warn_config",
":misc_config",
":container_config",
]
}
@ -299,7 +268,7 @@ config("public") {
configs += [
"$HDFTOPDIR:public",
"$DRIVERS_LITEOS_DIR:public",
"//drivers/liteos:public",
]
if (HAVE_DEVICE_SDK) {
@ -320,12 +289,11 @@ group("modules") {
"security",
"shell",
"syscall",
"testsuites/kernel:kernel_test",
]
deps += [
"$DRIVERS_LITEOS_DIR",
"$HDFTOPDIR",
"//drivers/liteos",
HDFTOPDIR,
]
if (HAVE_DEVICE_SDK) {
@ -346,17 +314,13 @@ group("kernel") {
}
group("liteos_a") {
deps = [ ":kernel" ]
if (!liteos_is_mini) {
deps += [
deps = [
":apps",
":kernel",
":make",
":tests",
"$THIRDPARTY_MUSL_DIR/scripts/build_lite:strip",
"//prebuilts/lite/sysroot/build:strip",
]
if (liteos_skip_make == false) {
deps += [ ":make" ]
}
}
}
executable("liteos") {
@ -372,17 +336,6 @@ executable("liteos") {
"-Wl,--no-eh-frame-hdr",
]
if (defined(LOSCFG_LIBC_NEWLIB)) {
ldflags += [
"-Wl,--wrap=_free_r",
"-Wl,--wrap,_malloc_usable_size_r",
"-Wl,--wrap,_malloc_r",
"-Wl,--wrap,_memalign_r",
"-Wl,--wrap,_realloc_r",
"-Wl,--wrap,_fseeko_r",
]
ldflags -= [ "-nostdlib" ]
}
libgcc = exec_script("//build/lite/run_shell_cmd.py",
[ "$cc -print-libgcc-file-name" ],
"trim string")
@ -394,7 +347,7 @@ executable("liteos") {
} else {
ldflags +=
[ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
ldflags += [ "-nostartfiles" ]
ldflags += [ "-Wl,-nostartfiles" ]
inputs = [ "tools/build/liteos.ld" ]
}

@ -235,12 +235,7 @@ config SCHED_DEBUG
depends on DEBUG_VERSION
help
If you wish to build LiteOS with support for sched debug.
config SCHED_EDF_DEBUG
bool "Enable sched EDF debug Feature"
default n
depends on SCHED_DEBUG
help
If you wish to build LiteOS with support for sched debug.
config USER_INIT_DEBUG
bool "Enable user init Debug"
default n
@ -270,7 +265,7 @@ config MEM_LEAKCHECK
default n
depends on DEBUG_VERSION && MEM_DEBUG
help
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the information of mem node.
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the informations of mem node.
config BASE_MEM_NODE_INTEGRITY_CHECK
bool "Enable integrity check or not"
default n

@ -82,6 +82,9 @@ endif
ifeq ($(LOSCFG_STORAGE_SPINAND), y)
FSTYPE = yaffs2
endif
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
FSTYPE = jffs2
endif
ROOTFS_DIR = $(OUT)/rootfs
ROOTFS_ZIP = $(OUT)/rootfs.zip
@ -118,7 +121,7 @@ sysroot:
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
ifeq ($(origin SYSROOT_PATH),file)
$(HIDE)mkdir -p $(SYSROOT_PATH)/build && cd $(SYSROOT_PATH)/build && \
ln -snf $(LITEOSTOPDIR)/../../third_party/musl/scripts/build_lite/Makefile && \
ln -snf $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/build/Makefile && \
$(MAKE) TARGETS=liteos_a_user \
ARCH=$(ARCH) \
TARGET=$(LOSCFG_LLVM_TARGET) \

@ -15,7 +15,7 @@
-->
<!--
This is the configuration file template for OpenHarmony OSS Audit Tool. Please copy it to your project root dir and modify it by referring to OpenHarmony/tools_oat/README.
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
-->
<configuration>
@ -24,7 +24,6 @@
<policylist>
<policy name="projectPolicy" desc="">
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="copyright" name="Huawei Device Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
</policy>
</policylist>
@ -39,7 +38,7 @@
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for license header policies">
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->

@ -4,10 +4,10 @@
- [Directory Structure](#section161941989596)
- [Constraints](#section119744591305)
- [Usage](#section741617511812)
- [Preparations](#section1579912573329)
- [Source Code Acquisition](#section11443189655)
- [Compilation and Building](#section2081013992812)
- [Contribution](#section1371123476304)
- [Preparations](#section1579912573329)
- [Source Code Acquisition](#section11443189655)
- [Compilation and Building](#section2081013992812)
- [Repositories Involved](#section1371113476307)
## Introduction<a name="section11660541593"></a>
@ -67,33 +67,24 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
## Usage<a name="section741617511812"></a>
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-appendix-hi3516.md). You can develop and run your applications based on this development board.
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on this development board.
### Preparations<a name="section1579912573329"></a>
You need to set up the compilation environment on Ubuntu.
You need to set up the compilation environment on Linux.
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/Readme-EN.md)
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup.md)
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md).
### Source Code Acquisition<a name="section11443189655"></a>
Download and decompress a set of source code on a Ubuntu server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
Download and decompress a set of source code on a Linux server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
### Compilation and Building<a name="section2081013992812"></a>
For details about how to develop the first application, see: [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)
For compilation, please refer to the [compilation instructions](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-pkg-3516-build.md).
## Contribution<a name="section1371123476304"></a>
[How to involve](https://gitee.com/openharmony/docs/blob/HEAD/en/contribute/contribution-guide.md)
[Commit message spec](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
[C&C++ Secure Coding Guide](https://gitee.com/openharmony/docs/blob/master/en/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
For details about how to develop the first application, see:
[LiteOS-A Kernel Coding Style Guide](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)
## Repositories Involved<a name="section1371113476307"></a>

@ -4,10 +4,10 @@
- [目錄](#section161941989596)
- [約束](#section119744591305)
- [使用說明](#section741617511812)
- [準備](#section1579912573329)
- [獲取源碼](#section11443189655)
- [編譯構建](#section2081013992812)
- [貢獻](#section1371123476304)
- [準備](#section1579912573329)
- [獲取源碼](#section11443189655)
- [編譯構建](#section2081013992812)
- [相關倉](#section1371113476307)
## 簡介<a name="section11660541593"></a>
@ -67,33 +67,24 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
## 使用說明<a name="section741617511812"></a>
OpenHarmony LiteOS-A內核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md)單板,開發者可基於此單板開發運行自己的應用程序。
OpenHarmony LiteOS-A內核支持Hi3516DV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)單板,開發者可基於此單板開發運行自己的應用程序。
### 準備<a name="section1579912573329"></a>
開發者需要在Ubuntu上搭建編譯環境:
開發者需要在Linux上搭建編譯環境:
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md);
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
- Hi3516DV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 獲取源碼<a name="section11443189655"></a>
Ubuntu服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
Linux服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
### 編譯構建<a name="section2081013992812"></a>
開發者開發第一個應用程序可參考:[helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)。
編譯可以參考:[編譯指導](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md)
## 貢獻<a name="section1371123476304"></a>
[如何貢獻](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
[Commit message規範](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
[OpenHarmony C&C++ 安全編程指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
開發者開發第一個應用程序可參考:
[LiteOS-A 內核編碼規範指南](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
## 相關倉<a name="section1371113476307"></a>

@ -4,10 +4,10 @@
- [目录](#section161941989596)
- [约束](#section119744591305)
- [使用说明](#section741617511812)
- [准备](#section1579912573329)
- [获取源码](#section11443189655)
- [编译构建](#section2081013992812)
- [贡献](#section1371123476304)
- [准备](#section1579912573329)
- [获取源码](#section11443189655)
- [编译构建](#section2081013992812)
- [相关仓](#section1371113476307)
## 简介<a name="section11660541593"></a>
@ -33,7 +33,6 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
│ ├── quickstart # 系统快速启动接口目录
│ ├── random # 随机数设备驱动
│ └── video # framebuffer驱动框架
├── figures # 内核架构图
├── fs # 文件系统模块主要来源于NuttX开源项目
│ ├── fat # fat文件系统
│ ├── jffs2 # jffs2文件系统
@ -55,9 +54,7 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
│ ├── include # 对外暴露头文件存放目录
│ └── uart # 串口相关逻辑代码
├── security # 安全特性相关的代码包括进程权限管理和虚拟id映射管理
├── shell # 接收用户输入的命令,内核去执行
├── syscall # 系统调用
├── testsuilts # 测试套件
└── tools # 构建工具及相关配置和代码
```
@ -69,35 +66,24 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
## 使用说明<a name="section741617511812"></a>
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-appendix-hi3516.md)单板。开发者可基于此单板开发运行自己的应用程序。
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)单板。开发者可基于此单板开发运行自己的应用程序。
### 准备<a name="section1579912573329"></a>
开发者需要在Ubuntu上搭建编译环境:
开发者需要在Linux上搭建编译环境:
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md);
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
- Hi3516DV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
### 获取源码<a name="section11443189655"></a>
Ubuntu服务器源码获取方式参考: [源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
Linux服务器上下载并解压一套源代码源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
### 编译构建<a name="section2081013992812"></a>
如果这是您的首次应用程序开发,可参考:[helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-helloworld.md)。
编译可以参考:[编译指导](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-pkg-3516-build.md)
测试参考:[单元测试](testsuites/unittest/tools/README.md)
## 贡献<a name="section1371123476304"></a>
[如何贡献](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/contribute/%E5%8F%82%E4%B8%8E%E8%B4%A1%E7%8C%AE.md)
[Commit message规范](https://gitee.com/openharmony/kernel_liteos_a/wikis/Commit%20message%20%E8%A7%84%E8%8C%83)
[OpenHarmony C&C++ 安全编程指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/contribute/OpenHarmony-c-cpp-secure-coding-guide.md)
开发者开发第一个应用程序可参考:
[LiteOS-A 内核编码规范指南](https://gitee.com/openharmony/kernel_liteos_a/wikis/LiteOS-A%20%E5%86%85%E6%A0%B8%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83%E6%8C%87%E5%8D%97)
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
## 相关仓<a name="section1371113476307"></a>

@ -58,10 +58,6 @@ APP_SUBDIRS += mksh
APP_SUBDIRS += toybox
endif
ifeq ($(LOSCFG_KERNEL_LMS), y)
APP_SUBDIRS += lms
endif
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
APP_SUBDIRS += init
endif

@ -73,5 +73,5 @@ executable("sample_usr_lms") {
"-Wl,--wrap=strcpy",
"-Wl,--wrap=strcat",
]
deps = [ "$LITEOSTOPDIR/kernel/extended/lms/usr:usrlmslib" ]
deps = [ "//kernel/liteos_a/kernel/extended/lms/usr:usrlmslib" ]
}

@ -180,8 +180,7 @@ static void LmsStrcpyTest(void)
return;
}
char *testStr = "bbbbbbbbbbbbbbbbb";
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n",
(int)strlen(testStr) + 1);
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
strcpy(buf, testStr);
free(buf);
printf("\n-------- LmsStrcpyTest End --------\n");
@ -231,7 +230,7 @@ int main(int argc, char * const *argv)
printf("\n############### Lms Test start ###############\n");
char *tmp = (char *)malloc(5000); /* 5000: test mem size */
if (tmp == NULL) {
return -1;
return;
}
LmsMallocTest();
LmsReallocTest();
@ -246,5 +245,4 @@ int main(int argc, char * const *argv)
LmsFreeTest();
free(tmp);
printf("\n############### Lms Test End ###############\n");
return 0;
}

@ -29,7 +29,7 @@
import("//build/lite/config/component/lite_component.gni")
import("//kernel/liteos_a/liteos.gni")
import("$THIRDPARTY_MKSH_DIR/mksh.gni")
import("//third_party/mksh/mksh.gni")
group("mksh") {
deps = [ ":build_mksh" ]
@ -42,7 +42,7 @@ copy("copy_mksh_src") {
build_ext_component("build_mksh") {
deps = [ ":copy_mksh_src" ]
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
deps += [ "//prebuilts/lite/sysroot" ]
exec_path = rebase_path("$target_out_dir/mksh_build")
cflags = [

@ -62,7 +62,7 @@ int main(int argc, char **argv)
PerfStop(fd);
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "read") == 0) {
size_t size = strtoul(argv[THREE_ARGS - 1], NULL, 0);
if (size == 0) {
if (size <= 0) {
goto EXIT:
}

@ -32,15 +32,13 @@
#ifndef _SHELL_PRI_H
#define _SHELL_PRI_H
#include "shell.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
extern void ShellEntry(ShellCB *shellCB);
extern void *ShellEntry(void *argv);
extern void *ShellTask(void *argv);
#ifdef __cplusplus

@ -32,7 +32,6 @@
#ifndef _SHMSG_H
#define _SHMSG_H
#include "shell_list.h"
#include "shell.h"
#ifdef __cplusplus
@ -62,7 +61,8 @@ extern "C" {
typedef void (* OutputFunc)(const char *fmt, ...);
extern int ShellTaskInit(ShellCB *shellCB);
extern void ChildExec(const char *cmdName, char *const paramArray[], bool foreground);
extern int ShellEntryInit(ShellCB *shellCB);
extern void ChildExec(const char *cmdName, char *const paramArray[]);
extern void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB);
extern int ShellNotify(ShellCB *shellCB);

@ -31,25 +31,22 @@
#define _GNU_SOURCE
#include <signal.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/syscall.h>
#include "show.h"
#include "shmsg.h"
#include "shcmd.h"
#include "shell_pri.h"
#include "semaphore.h"
#include "securec.h"
#include "unistd.h"
#include <sys/syscall.h>
ShellCB *g_shellCB = NULL;
ShellCB *OsGetShellCb(void)
ShellCB *OsGetShellCb()
{
return g_shellCB;
}
static void ShellDeinit(ShellCB *shellCB)
void ShellDeinit(ShellCB *shellCB)
{
(void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex);
@ -65,23 +62,32 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
ret = ShellTaskInit(shellCB);
if (ret != SH_OK) {
return ret;
goto OUT;
}
ret = ShellEntryInit(shellCB);
if (ret != SH_OK) {
goto OUT;
}
shellCB->shellEntryHandle = pthread_self();
return 0;
(void)pthread_join(shellCB->shellTaskHandle, NULL);
(void)pthread_join(shellCB->shellEntryHandle, NULL);
OUT:
ShellDeinit(shellCB);
return ret;
}
static int DoShellExec(char **argv)
@ -92,7 +98,7 @@ static int DoShellExec(char **argv)
char *cmdLine = NULL;
if (strncmp(argv[0], SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
ChildExec(argv[1], argv + 1, FALSE);
ChildExec(argv[1], argv + 1);
}
for (i = 0; argv[i]; i++) {
len += strlen(argv[i]);
@ -119,22 +125,11 @@ static int DoShellExec(char **argv)
return ret;
}
static void ShellSigChildHook(int sig)
{
(void)sig;
while (waitpid(-1, NULL, WNOHANG) > 0) {
continue;
}
}
int main(int argc, char **argv)
{
int ret = SH_NOK;
ShellCB *shellCB = NULL;
(void)signal(SIGCHLD, ShellSigChildHook);
if (argc > 1) {
ret = DoShellExec(argv + 1);
return ret;
@ -144,7 +139,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) {
return SH_NOK;
goto ERR_OUT1;
}
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) {
@ -170,14 +165,7 @@ int main(int argc, char **argv)
sem_init(&shellCB->shellSem, 0, 0);
g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) {
ShellDeinit(shellCB);
g_shellCB = NULL;
return ret;
}
ShellEntry(shellCB);
return OsShellCreateTask(shellCB);
ERR_OUT3:
(void)pthread_mutex_destroy(&shellCB->historyMutex);

@ -351,7 +351,7 @@ char *GetCmdName(const char *cmdline, unsigned int len)
return cmdName;
}
void ChildExec(const char *cmdName, char *const paramArray[], bool foreground)
void ChildExec(const char *cmdName, char *const paramArray[])
{
int ret;
pid_t gid;
@ -367,13 +367,11 @@ void ChildExec(const char *cmdName, char *const paramArray[], bool foreground)
exit(1);
}
if (!foreground) {
ret = tcsetpgrp(STDIN_FILENO, gid);
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
exit(1);
}
}
ret = execve(cmdName, paramArray, NULL);
if (ret == -1) {
@ -406,30 +404,20 @@ int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
exit(ret);
}
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, CmdParsed *cmdParsed)
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, const CmdParsed *cmdParsed)
{
bool foreground = FALSE;
int ret;
pid_t forkPid;
if (strncmp(cmdline, CMD_EXEC_COMMAND, CMD_EXEC_COMMAND_BYTES) == 0) {
if ((cmdParsed->paramCnt > 1) && (strcmp(cmdParsed->paramArray[cmdParsed->paramCnt - 1], "&") == 0)) {
free(cmdParsed->paramArray[cmdParsed->paramCnt - 1]);
cmdParsed->paramArray[cmdParsed->paramCnt - 1] = NULL;
cmdParsed->paramCnt--;
foreground = TRUE;
}
forkPid = fork();
if (forkPid < 0) {
printf("Failed to fork from shell\n");
printf("Faild to fork from shell\n");
return;
} else if (forkPid == 0) {
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray, foreground);
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray);
} else {
if (!foreground) {
(void)waitpid(forkPid, 0, 0);
}
waitpid(forkPid, 0, 0);
ret = tcsetpgrp(STDIN_FILENO, getpid());
if (ret != 0) {
printf("tcsetpgrp failed, errno %d\n", errno);
@ -579,10 +567,20 @@ static void ExecCmdline(const char *cmdline)
free(output);
}
void RecycleZombieChild(void)
{
while (waitpid(-1, NULL, WNOHANG) > 0) {
continue;
}
}
static void ShellCmdProcess(ShellCB *shellCB)
{
char *buf = NULL;
while (1) {
char *buf = GetCmdline(shellCB);
/* recycle zombine child process */
RecycleZombieChild();
buf = GetCmdline(shellCB);
if (buf == NULL) {
break;
}
@ -656,19 +654,25 @@ static int ShellKernelReg(unsigned int shellHandle)
return ioctl(STDIN_FILENO, CONSOLE_CONTROL_REG_USERTASK, shellHandle);
}
void ShellEntry(ShellCB *shellCB)
void *ShellEntry(void *argv)
{
char ch;
int ret;
int n;
pid_t tid = syscall(__NR_gettid);
ShellCB *shellCB = (ShellCB *)argv;
if (shellCB == NULL) {
return;
return NULL;
}
(void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
ret = prctl(PR_SET_NAME, "ShellEntry");
if (ret != SH_OK) {
return NULL;
}
ret = ShellKernelReg((int)tid);
if (ret != 0) {
printf("another shell is already running!\n");
@ -681,5 +685,32 @@ void ShellEntry(ShellCB *shellCB)
ShellCmdLineParse(ch, (OutputFunc)printf, shellCB);
}
}
return;
return NULL;
}
int ShellEntryInit(ShellCB *shellCB)
{
int ret;
size_t stackSize = SHELL_ENTRY_STACKSIZE;
void *arg = NULL;
pthread_attr_t attr;
if (shellCB == NULL) {
return SH_NOK;
}
ret = pthread_attr_init(&attr);
if (ret != SH_OK) {
return SH_NOK;
}
pthread_attr_setstacksize(&attr, stackSize);
arg = (void *)shellCB;
ret = pthread_create(&shellCB->shellEntryHandle, &attr, &ShellEntry, arg);
if (ret != SH_OK) {
return SH_NOK;
}
return ret;
}

@ -500,7 +500,7 @@ static void lwip_tftp_send_error(s32_t iSockNum, u32_t ulError, const char *szEr
}
}
/* INTERFACE to get a file using filename
/* INTEFACE to get a file using filename
ulHostAddr - IP address of Host
szSrcFileName - Source file
szDestDirPath - Destination file path
@ -1419,7 +1419,7 @@ err_handler:
}
#ifdef TFTP_TO_RAWMEM
/* INTERFACE to get a file using filename
/* INTEFACE to get a file using filename
ulHostAddr - IP address of Host
szSrcFileName - Source file
szDestMemAddr - The target memory address in the client
@ -1437,8 +1437,10 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
{
s32_t iSockNum = TFTP_NULL_INT32;
u32_t ulSrcStrLen;
u32_t lDestStrLen;
u32_t ulSize;
u32_t ulRecvSize = TFTP_NULL_UINT32;
s32_t iErrCode;
u32_t ulErrCode;
u16_t usReadReq;
u16_t usTempServPort;

@ -29,7 +29,7 @@
import("//build/lite/config/component/lite_component.gni")
import("//kernel/liteos_a/liteos.gni")
import("$THIRDPARTY_TOYBOX_DIR/toybox.gni")
import("//third_party/toybox/toybox.gni")
group("toybox") {
deps = [ ":build_toybox" ]
@ -51,7 +51,7 @@ build_ext_component("build_toybox") {
":copy_toybox_config",
":copy_toybox_src",
]
deps += [ "$THIRDPARTY_MUSL_DIR:sysroot_lite" ]
deps += [ "//prebuilts/lite/sysroot" ]
exec_path = rebase_path("$target_out_dir/toybox_build")
cflags = [

@ -70,7 +70,7 @@ static void TraceRead(int fd, size_t size)
{
ssize_t i;
ssize_t len;
if (size == 0) {
if (size <= 0) {
return;
}

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -102,7 +102,7 @@ typedef struct {
* Return : pointer to the task context
*/
extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfStask, UINT32 parentStackSize);
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize);
extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);

@ -55,8 +55,8 @@ extern "C" {
#define HWI_IS_REGISTED(num) ((&g_hwiForm[num])->pstNext != NULL)
#endif
extern VOID OsHwiInit(VOID);
extern VOID OsIncHwiFormCnt(UINT16 cpuid, UINT32 index);
extern UINT32 OsGetHwiFormCnt(UINT16 cpuid, UINT32 index);
extern VOID OsIncHwiFormCnt(UINT32 index);
extern UINT32 OsGetHwiFormCnt(UINT32 index);
extern CHAR *OsGetHwiFormName(UINT32 index);
extern VOID OsInterrupt(UINT32 intNum);
extern VOID OsSyscallHandleInit(VOID);

@ -74,7 +74,7 @@
STATIC UINTPTR g_minAddr;
STATIC UINTPTR g_maxAddr;
STATIC UINT32 g_currHandleExcCpuid = INVALID_CPUID;
STATIC UINT32 g_currHandleExcCpuID = INVALID_CPUID;
VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr);
UINT32 g_curNestCount[LOSCFG_KERNEL_CORE_NUM] = { 0 };
BOOL g_excFromUserMode[LOSCFG_KERNEL_CORE_NUM];
@ -88,7 +88,6 @@ STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
#define OS_MAX_BACKTRACE 15U
#define DUMPSIZE 128U
#define DUMPREGS 12U
#define COM_REGS 4U
#define INSTR_SET_MASK 0x01000020U
#define THUMB_INSTR_LEN 2U
#define ARM_INSTR_LEN 4U
@ -113,11 +112,11 @@ STATIC const StackInfo g_excStack[] = {
UINT32 OsGetSystemStatus(VOID)
{
UINT32 flag;
UINT32 cpuid = g_currHandleExcCpuid;
UINT32 cpuID = g_currHandleExcCpuID;
if (cpuid == INVALID_CPUID) {
if (cpuID == INVALID_CPUID) {
flag = OS_SYSTEM_NORMAL;
} else if (cpuid == ArchCurrCpuid()) {
} else if (cpuID == ArchCurrCpuid()) {
flag = OS_SYSTEM_EXC_CURR_CPU;
} else {
flag = OS_SYSTEM_EXC_OTHER_CPU;
@ -517,22 +516,13 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
return;
}
for (excReg = &(excBufAddr->R0); count < COM_REGS; excReg++, count++) {
for (excReg = &(excBufAddr->R0); count <= DUMPREGS; excReg++, count++) {
if (IS_VALID_ADDR(*excReg)) {
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
OsDumpMemByte(DUMPSIZE, ((*excReg) - (DUMPSIZE >> 1)));
}
}
for (excReg = &(excBufAddr->R4); count < DUMPREGS; excReg++, count++) {
if (IS_VALID_ADDR(*excReg)) {
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
OsDumpMemByte(DUMPSIZE, ((*excReg) - (DUMPSIZE >> 1)));
}
}
if (IS_VALID_ADDR(excBufAddr->R12)) {
PrintExcInfo("\ndump mem around R12:%p", excBufAddr->R12);
OsDumpMemByte(DUMPSIZE, (excBufAddr->R12 - (DUMPSIZE >> 1)));
}
if (IS_VALID_ADDR(excBufAddr->SP)) {
PrintExcInfo("\ndump mem around SP:%p", excBufAddr->SP);
OsDumpMemByte(DUMPSIZE, (excBufAddr->SP - (DUMPSIZE >> 1)));
@ -541,11 +531,11 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
STATIC VOID OsExcRestore(VOID)
{
UINT32 currCpuid = ArchCurrCpuid();
UINT32 currCpuID = ArchCurrCpuid();
g_excFromUserMode[currCpuid] = FALSE;
g_intCount[currCpuid] = 0;
g_curNestCount[currCpuid] = 0;
g_excFromUserMode[currCpuID] = FALSE;
g_intCount[currCpuID] = 0;
g_curNestCount[currCpuID] = 0;
#ifdef LOSCFG_KERNEL_SMP
OsCpuStatusSet(CPU_RUNNING);
#endif
@ -566,15 +556,15 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
#ifdef LOSCFG_KERNEL_SMP
LOS_SpinLock(&g_excSerializerSpin);
if (g_nextExcWaitCpu != INVALID_CPUID) {
g_currHandleExcCpuid = g_nextExcWaitCpu;
g_currHandleExcCpuID = g_nextExcWaitCpu;
g_nextExcWaitCpu = INVALID_CPUID;
} else {
g_currHandleExcCpuid = INVALID_CPUID;
g_currHandleExcCpuID = INVALID_CPUID;
}
g_currHandleExcPID = OS_INVALID_VALUE;
LOS_SpinUnlock(&g_excSerializerSpin);
#else
g_currHandleExcCpuid = INVALID_CPUID;
g_currHandleExcCpuID = INVALID_CPUID;
#endif
#ifdef LOSCFG_KERNEL_SMP
@ -655,7 +645,6 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
const StackInfo *stack = NULL;
vaddr_t kvaddr;
#ifdef LOSCFG_KERNEL_VM
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
taskCB = OsCurrTaskGet();
stackStart = taskCB->userMapBase;
@ -666,7 +655,6 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
}
return found;
}
#endif
/* Search in the task stacks */
for (index = 0; index < g_taskMaxNum; index++) {
@ -991,14 +979,14 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
#define EXC_WAIT_INTER 50U
#define EXC_WAIT_TIME 2000U
STATIC VOID WaitAllCpuStop(UINT32 cpuid)
STATIC VOID WaitAllCpuStop(UINT32 cpuID)
{
UINT32 i;
UINT32 time = 0;
while (time < EXC_WAIT_TIME) {
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
if ((i != cpuid) && !OsCpuStatusIsHalt(i)) {
if ((i != cpuID) && !OsCpuStatusIsHalt(i)) {
LOS_Mdelay(EXC_WAIT_INTER);
time += EXC_WAIT_INTER;
break;
@ -1012,19 +1000,19 @@ STATIC VOID WaitAllCpuStop(UINT32 cpuid)
return;
}
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuid)
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
{
while (1) {
LOS_SpinLock(&g_excSerializerSpin);
if ((g_currHandleExcCpuid == INVALID_CPUID) || (g_currHandleExcCpuid == currCpuid)) {
g_currHandleExcCpuid = currCpuid;
if ((g_currHandleExcCpuID == INVALID_CPUID) || (g_currHandleExcCpuID == currCpuID)) {
g_currHandleExcCpuID = currCpuID;
g_currHandleExcPID = OsCurrProcessGet()->processID;
LOS_SpinUnlock(&g_excSerializerSpin);
break;
}
if (g_nextExcWaitCpu == INVALID_CPUID) {
g_nextExcWaitCpu = currCpuid;
g_nextExcWaitCpu = currCpuID;
}
LOS_SpinUnlock(&g_excSerializerSpin);
LOS_Mdelay(EXC_WAIT_INTER);
@ -1033,7 +1021,7 @@ STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuid)
STATIC VOID OsCheckAllCpuStatus(VOID)
{
UINT32 currCpuid = ArchCurrCpuid();
UINT32 currCpuID = ArchCurrCpuid();
UINT32 ret, target;
OsCpuStatusSet(CPU_EXC);
@ -1041,17 +1029,17 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
LOS_SpinLock(&g_excSerializerSpin);
/* Only the current CPU anomaly */
if (g_currHandleExcCpuid == INVALID_CPUID) {
g_currHandleExcCpuid = currCpuid;
if (g_currHandleExcCpuID == INVALID_CPUID) {
g_currHandleExcCpuID = currCpuID;
g_currHandleExcPID = OsCurrProcessGet()->processID;
LOS_SpinUnlock(&g_excSerializerSpin);
#ifndef LOSCFG_SAVE_EXCINFO
if (g_excFromUserMode[currCpuid] == FALSE) {
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuid));
if (g_excFromUserMode[currCpuID] == FALSE) {
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
}
#endif
} else if (g_excFromUserMode[currCpuid] == TRUE) {
} else if (g_excFromUserMode[currCpuID] == TRUE) {
/* Both cores raise exceptions, and the current core is a user-mode exception.
* Both cores are abnormal and come from the same process
*/
@ -1063,12 +1051,12 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
}
LOS_SpinUnlock(&g_excSerializerSpin);
OsWaitOtherCoresHandleExcEnd(currCpuid);
OsWaitOtherCoresHandleExcEnd(currCpuID);
} else {
if ((g_currHandleExcCpuid < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuid] == TRUE)) {
g_currHandleExcCpuid = currCpuid;
if ((g_currHandleExcCpuID < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuID] == TRUE)) {
g_currHandleExcCpuID = currCpuID;
LOS_SpinUnlock(&g_excSerializerSpin);
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuid));
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
} else {
LOS_SpinUnlock(&g_excSerializerSpin);
@ -1078,7 +1066,7 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
#ifndef LOSCFG_SAVE_EXCINFO
/* use halt ipi to stop other active cores */
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
WaitAllCpuStop(currCpuid);
WaitAllCpuStop(currCpuID);
}
#endif
}
@ -1089,7 +1077,7 @@ STATIC VOID OsCheckCpuStatus(VOID)
#ifdef LOSCFG_KERNEL_SMP
OsCheckAllCpuStatus();
#else
g_currHandleExcCpuid = ArchCurrCpuid();
g_currHandleExcCpuID = ArchCurrCpuid();
#endif
}

@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 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:
@ -103,7 +103,7 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
return (VOID *)taskContext;
}
VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfStack, UINT32 parentStackSize)
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
{
LosTaskCB *task = OsCurrTaskGet();
sig_cb *sigcb = &task->sig;
@ -117,10 +117,6 @@ VOID OsUserCloneParentStack(VOID *childStack, UINTPTR sp, UINTPTR parentTopOfSta
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
((TaskContext *)childStack)->R0 = 0;
if (sp != 0) {
((TaskContext *)childStack)->USP = TRUNCATE(sp, LOSCFG_STACK_POINT_ALIGN_SIZE);
((TaskContext *)childStack)->ULR = 0;
}
}
LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)

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

Loading…
Cancel
Save