提交 2a2d7bae 编写于 作者: Y YOUR_NAME

Merge remote-tracking branch 'upstream/master'

### 该问题是怎么引起的?
### 重现步骤
### 报错信息
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
/out
/fs/proc
/test
/include
.config*
......@@ -22,4 +21,3 @@ platform/include/menuconfig.h
platform/board.ld
apps/init/init
apps/shell/shell
lib/libc/musl
# 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.
import("//build/lite/config/subsystem/lite_subsystem.gni")
declare_args() {
enable_ohos_kernel_liteos_a_ext_build = true
LOSCFG_TEST_APPS = false
}
lite_subsystem("kernel") {
subsystem_components = []
if (enable_ohos_kernel_liteos_a_ext_build == false) {
subsystem_components += [
"//kernel/liteos_a/kernel",
"//kernel/liteos_a/net",
"//kernel/liteos_a/lib",
"//kernel/liteos_a/compat",
"//kernel/liteos_a/fs",
"//kernel/liteos_a/arch:platform_cpu",
]
if (LOSCFG_SHELL) {
subsystem_components += [ "//kernel/liteos_a/shell" ]
}
} else {
deps = [":make"]
}
}
action("make") {
script = "//build/lite/build_ext_components.py"
outputs = [ "$target_gen_dir/liteos_a_build_log.txt" ]
exec_path = rebase_path(rebase_path(".", root_build_dir))
outdir = rebase_path(get_path_info(".", "out_dir"))
command = "make clean OUTDIR=$outdir && make rootfs VERSION=\"${ohos_version}\" -j 16 OUTDIR=$outdir"
args = [
"--path=$exec_path",
"--prebuilts=sh build.sh ${board_name} ${ohos_build_compiler} ${ohos_build_type}",
"--command=${command}"
]
}
# 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.
import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/subsystem/lite_subsystem.gni")
generate_notice_file("kernel_notice_file") {
module_name = "kernel"
module_source_dir_list = [
"//third_party/FreeBSD",
"//third_party/musl",
"//third_party/zlib",
"//third_party/FatFs",
"//third_party/Linux_Kernel",
"//third_party/lwip",
"//third_party/NuttX",
"//third_party/mtd-utils",
]
}
declare_args() {
enable_ohos_kernel_liteos_a_ext_build = true
LOSCFG_TEST_APPS = false
tee_enable = ""
}
lite_subsystem("kernel") {
subsystem_components = []
if (enable_ohos_kernel_liteos_a_ext_build == false) {
subsystem_components += [
"//kernel/liteos_a/kernel",
"//kernel/liteos_a/net",
"//kernel/liteos_a/lib",
"//kernel/liteos_a/compat",
"//kernel/liteos_a/fs",
"//kernel/liteos_a/arch:platform_cpu",
]
if (LOSCFG_SHELL) {
subsystem_components += [ "//kernel/liteos_a/shell" ]
}
} else {
deps = [ ":make" ]
}
}
build_ext_component("make") {
exec_path = rebase_path(".", root_build_dir)
tee_enable = "false"
if (board_name == "hi3516dv300" && enable_tee_ree) {
tee_enable = "tee"
}
prebuilts = "sh build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\""
outdir = rebase_path(get_path_info(".", "out_dir"))
command = "make clean OUTDIR=$outdir && make rootfs VERSION=\"${ohos_version}\" -j 16 OUTDIR=$outdir"
}
# 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:
......@@ -42,11 +42,11 @@ choice
config COMPILER_HIMIX_32
bool "arm-linux-ohoseabi"
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7
config COMPILER_CLANG_LLVM
bool "clang-llvm"
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7
endchoice
endmenu
......@@ -61,6 +61,15 @@ source "../../kernel/liteos_a/arch/Kconfig"
######################### config options of rootfs #####################
source "../../kernel/liteos_a/kernel/common/Kconfig"
######################### config options of patchfs #####################
source "../../kernel/liteos_a/kernel/common/patchfs/Kconfig"
config QUICK_START
bool "Enable QUICK_START"
default n
depends on DRIVERS && FS_VFS
help
Answer Y to enable LiteOS support quick start.
endmenu
######################### config options of kernel #####################
......@@ -84,6 +93,12 @@ source "../../kernel/liteos_a/fs/ramfs/Kconfig"
source "../../kernel/liteos_a/fs/nfs/Kconfig"
source "../../kernel/liteos_a/fs/proc/Kconfig"
source "../../kernel/liteos_a/fs/jffs2/Kconfig"
source "../../kernel/liteos_a/fs/zpfs/Kconfig"
config ENABLE_READ_BUFFER
bool "Enable read buffer Option"
default n
help
Answer Y to add enable read buffer Option.
endmenu
######################## config options of net ############################
......@@ -197,6 +212,13 @@ config EXC_INTERACTION
Answer Y to enable exception interaction for LiteOS, when the system enter exception, user can also interact with system by shell
command like readreg, writereg,task,hwi.
config SCHED_DEBUG
bool "Enable sched debug Feature"
default n
depends on DEBUG_VERSION
help
If you wish to build LiteOS with support for sched debug.
config USER_INIT_DEBUG
bool "Enable user init Debug"
default n
......@@ -221,30 +243,6 @@ config MEM_DEBUG
help
Answer Y to enable LiteOS support mem debug.
config MEM_MUL_MODULE
bool "Enable Memory module statistics"
default n
depends on MEM_DEBUG
help
Answer Y to enable LiteOS support memory statistics depend on different module
config MEM_MUL_POOL
bool "Enable Memory multi-pool control"
default y
depends on DEBUG_VERSION && MEM_DEBUG
help
Answer Y to enable LiteOS support memory multi-pool control
config MEM_HEAD_BACKUP
bool "Enable Node Head Backup"
default 0
depends on DEBUG_VERSION && MEM_DEBUG
help
Answer Y to enable node head backup
config MEM_RECORDINFO
bool "Enable Mem Record"
default n
depends on DEBUG_VERSION && MEM_DEBUG
help
Answer Y to enable mem record
config MEM_LEAKCHECK
bool "Enable Function call stack of Mem operation recorded"
default n
......@@ -255,14 +253,10 @@ config BASE_MEM_NODE_INTEGRITY_CHECK
bool "Enable integrity check or not "
default n
depends on DEBUG_VERSION && MEM_DEBUG
config BASE_MEM_NODE_SIZE_CHECK
bool "Enable size check or not"
config MEM_WATERLINE
bool "Enable memory pool waterline or not"
default n
depends on DEBUG_VERSION && MEM_DEBUG
config SLAB_INFO_STATISTIC
bool "Enable SLAB Statistic"
default n
depends on DEBUG_VERSION && KERNEL_MEM_SLAB && MEM_DEBUG
config VM_OVERLAP_CHECK
bool "Enable VM overlap check or not"
......@@ -274,23 +268,10 @@ config VM_OVERLAP_CHECK
config NULL_ADDRESS_PROTECT
bool "Enable NULL Address protect"
default n
depends on (PLATFORM_HI3518EV200 || PLATFORM_HI3516CV300 || PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300) && DEBUG_VERSION
depends on (PLATFORM_HI3518EV200 || PLATFORM_HI3516CV300 || PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7) && DEBUG_VERSION
help
Answer Y to set mem address 0~1M prohibit to access, read or write will trigger exception.
choice
prompt "Enable Uart"
default DRIVERS_HDF_PLATFORM_UART
help
Enable simple uart (without vfs) only for litekernel.
Enable general uart (with vfs) for full code.
source "../../vendor/hisi/hi35xx/platform/uart/Kconfig"
config PLATFORM_UART_WITHOUT_VFS
bool "Simple Uart"
config PLATFORM_NO_UART
bool "NO Uart"
endchoice
endmenu
######################## config options os drivers ########################
......@@ -301,42 +282,13 @@ config DRIVERS
help
Answer Y to enable LiteOS support driver.
source "../../vendor/hisi/hi35xx/platform/hiedmac/Kconfig"
source "../../kernel/liteos_a/bsd/dev/usb/Kconfig"
source "../../drivers/hdf/lite/Kconfig"
config DRIVERS_NETDEV
bool "Enable Net Device"
default y
depends on DRIVERS && NET_LWIP_SACK
help
Answer Y to enable LiteOS support net device.
choice
depends on DRIVERS_NETDEV
prompt "MAC"
default n
help
Enable higmac for hi3516a hi3519 hi3559a_cortex-a53_aarch64.
Enable hieth-sf for hi3516cv300 hi3516ev200 and hi3518ev200.
source "../../vendor/hisi/hi35xx/platform/hieth-sf/Kconfig"
endchoice
source "../../drivers/liteos/mem/Kconfig"
source "../../vendor/hisi/hi35xx/platform/mmc/Kconfig"
config DRIVERS_MTD
bool "Enable MTD"
default y
depends on DRIVERS && FS_VFS
help
Answer Y to enable LiteOS support jffs2 multipartion.
source "../../drivers/adapter/khdf/liteos/Kconfig"
source "../../vendor/hisi/hi35xx/platform/mtd/spi_nor/Kconfig"
source "../../drivers/liteos/random/Kconfig"
source "drivers/char/mem/Kconfig"
source "drivers/char/random/Kconfig"
source "../../drivers/liteos/tzdriver/Kconfig"
source "../../drivers/liteos/video/Kconfig"
source "drivers/char/video/Kconfig"
source "../../drivers/liteos/hievent/Kconfig"
endmenu
......
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.
# 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:
......@@ -38,8 +38,6 @@ LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
export LITEOSTOPDIR
export LITEOSTHIRDPARTY
-include $(LITEOSTOPDIR)/tools/build/config.mk
RM = -rm -rf
MAKE = make
__LIBS = libs
......@@ -53,12 +51,34 @@ LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h
LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform
LITEOS_PLATFORM_MENUCONFIG_H = $(LITEOS_PLATFORM_BASE)/include/menuconfig.h
ifeq ($(LOSCFG_PLATFORM_HI3518EV300), y)
export CONFIG_=LOSCFG_
MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
ifeq ($(OS), Linux)
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/mconf
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/conf
else
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/kconfig-mconf.exe
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/kconfig-conf.exe
endif
$(shell env CONFIG_=$(CONFIG_) $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH))
-include $(LITEOSTOPDIR)/tools/build/config.mk
ifeq ($(LOSCFG_STORAGE_SPINOR), y)
FSTYPE = jffs2
endif
ifeq ($(LOSCFG_PLATFORM_HI3516DV300), y)
ifeq ($(LOSCFG_STORAGE_EMMC), y)
FSTYPE = vfat
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
VERSION =
......@@ -103,8 +123,8 @@ $(__LIBS): $(OUT) $(CXX_INCLUDE)
$(OUT): $(LITEOS_MENUCONFIG_H)
$(HIDE)mkdir -p $(OUT)/lib
$(HIDE)$(CC) -I$(LITEOS_PLATFORM_BASE)/include -I$(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board \
-E $(LITEOS_PLATFORM_BASE)/board.ld.S \
$(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \
-I$(LITEOS_PLATFORM_BASE)/include -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
-o $(LITEOS_PLATFORM_BASE)/board.ld -P
$(BUILD):
......@@ -117,15 +137,12 @@ $(LITEOS_LIBS_TARGET): $(__LIBS)
$(HIDE)echo "=============== make lib done ==============="
##### make menuconfig #####
export CONFIG_=LOSCFG_
MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
menuconfig:$(MENUCONFIG_PATH)/mconf
menuconfig:$(MENUCONFIG_MCONF)
$< $(KCONFIG_FILE_PATH)
genconfig:$(MENUCONFIG_PATH)/conf
genconfig:$(MENUCONFIG_CONF)
$(HIDE)mkdir -p include/config include/generated
$< --olddefconfig $(KCONFIG_FILE_PATH)
$< --silentoldconfig $(KCONFIG_FILE_PATH)
-mv -f $(LITEOS_MENUCONFIG_H) $(LITEOS_PLATFORM_MENUCONFIG_H)
##### menuconfig end #######
......@@ -165,15 +182,16 @@ endif
$(ROOTFSDIR): prepare $(APPS)
$(HIDE)$(MAKE) clean -C apps
$(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR))
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR)
ifneq ($(VERSION),)
$(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR))
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
endif
$(ROOTFS): $(ROOTFSDIR)
$(HIDE)$(shell $(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE))
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
ifneq ($(OUT), $(LITEOS_TARGET_DIR))
rm -rf $(LITEOS_TARGET_DIR)rootfs
$(HIDE)mv $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)rootfs
endif
......@@ -182,7 +200,7 @@ clean:
do $(MAKE) -C $$dir clean|| exit 1; \
done
$(HIDE)$(MAKE) -C apps clean
$(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(OUT) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
$(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
$(HIDE)$(RM) $(LITEOS_PLATFORM_MENUCONFIG_H)
$(HIDE)$(RM) include
$(HIDE)$(MAKE) cleanrootfs
......@@ -199,4 +217,14 @@ cleanrootfs:
$(HIDE)$(RM) $(OUT)/rootfs.zip
$(HIDE)$(RM) $(OUT)/rootfs.img
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help
update_all_config:
$(HIDE)shopt -s globstar && for f in tools/build/config/**/*.config ; \
do \
echo updating $$f; \
test -f $$f && cp $$f .config && $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig $$f $(KCONFIG_FILE_PATH); \
done
%.config:
$(HIDE)test -f tools/build/config/$@ && cp tools/build/config/$@ .config && $(MENUCONFIG_MCONF) $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig tools/build/config/$@ $(KCONFIG_FILE_PATH)
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config
# LiteOS Cortex-A<a name="EN-US_TOPIC_0000001096612501"></a>
- [Introduction](#section11660541593)
- [Directory Structure](#section161941989596)
- [Constraints](#section119744591305)
- [Usage](#section741617511812)
- [Preparations](#section1579912573329)
- [Source Code Acquisition](#section11443189655)
- [Compilation and Building](#section2081013992812)
- [Repositories Involved](#section1371113476307)
## Introduction<a name="section11660541593"></a>
The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on the Huawei LiteOS kernel. Huawei LiteOS is a lightweight operating system \(OS\) built for the Internet of Things \(IoT\) field. With the rapid development of the IoT industry, OpenHarmony LiteOS Cortex-A brings small-sized, low-power, and high-performance experience and builds a unified and open ecosystem for developers. In addition, it provides rich kernel mechanisms, more comprehensive Portable Operating System Interface \(POSIX\), and a unified driver framework, Hardware Driver Foundation \(HDF\), which offers unified access for device developers and friendly development experience for application developers. [Figure1](#fig27311582210) shows the architecture of the OpenHarmony LiteOS Cortex-A kernel.
**Figure 1** Architecture of the OpenHarmony LiteOS Cortex-A kernel<a name="fig27311582210"></a>
![](figures/architecture-of-the-openharmony-liteos-cortex-a-kernel.png "architecture-of-the-openharmony-liteos-cortex-a-kernel")
## Directory Structure<a name="section161941989596"></a>
```
/kernel/liteos_a
├── apps # User-space init and shell application programs
├── arch # System architecture, such as ARM
│ └── arm # Code for ARM architecture
├── bsd # Code of the driver and adaptation layer module related to the FreeBSD, such as the USB module
├── compat # Kernel API compatibility
│ └── posix # POSIX APIs
├── drivers # Kernel driver
│ └── char # Character device
│ ├── mem # Driver for accessing physical input/output (I/O) devices
│ ├── quickstart # APIs for quick start of the system
│ ├── random # Driver for random number generators
│ └── video # Framework of the framebuffer driver
├── fs # File system module, which mainly derives from the NuttX open-source project
│ ├── fat # FAT file system
│ ├── jffs2 # JFFS2 file system
│ ├── include # Header files exposed externally
│ ├── nfs # NFS file system
│ ├── proc # proc file system
│ ├── ramfs # RAMFS file system
│ └── vfs # VFS layer
├── kernel # Kernel modules including the process, memory, and IPC modules
│ ├── base # Basic kernel modules including the scheduling and memory modules
│ ├── common # Common components used by the kernel
│ ├── extended # Extended kernel modules including the dynamic loading, vDSO, and LiteIPC modules
│ ├── include # Header files exposed externally
│ └── user # Init process loading
├── lib # Kernel library
├── net # Network module, which mainly derives from the lwIP open-source project
├── platform # Code for supporting different systems on a chip (SOCs), such as Hi3516D V300
│ ├── hw # Logic code related to clocks and interupts
│ ├── include # Header files exposed externally
│ └── uart # Logic code related to the serial port
├── platform # Code for supporting different systems on a chip (SOCs), such as Hi3516D V300
├── security # Code related to security features, including process permission management and virtual ID mapping management
├── syscall # System calling
└── tools # Building tools as well as related configuration and code
```
## Constraints<a name="section119744591305"></a>
- Programming languages: C and C++
- Applicable development boards: Hi3518E V300 and Hi3516D V300
- Hi3518E V300 uses the JFFS2 file system by default, and Hi3516D V300 uses the FAT file system by default.
## Usage<a name="section741617511812"></a>
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/introduction-to-the-hi3518-development-board.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/introduction-to-the-hi3516-development-board.md). You can develop and run your applications based on both development boards.
### Preparations<a name="section1579912573329"></a>
You need to set up the compilation environment on Linux.
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/setting-up-the-hi3518-development-environment.md).
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/setting-up-the-hi3516-development-environment.md).
### Source Code Acquisition<a name="section11443189655"></a>
Download and decompress a set of source code on a Linux server to acquire the [source code](https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz). For more acquisition methods, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/docs-en/get-code/source-code-acquisition.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 Hi3518](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/developing-the-first-example-program-running-on-hi3518.md)
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/docs-en/quick-start/developing-the-first-example-program-running-on-hi3516.md)
## Repositories Involved<a name="section1371113476307"></a>
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos)
**[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a)**
# LiteOS-A内核<a name="ZH-CN_TOPIC_0000001096612501"></a>
- [简介](#section11660541593)
- [目录](#section161941989596)
- [约束](#section119744591305)
- [使用说明](#section741617511812)
- [准备](#section1579912573329)
- [获取源码](#section11443189655)
- [编译构建](#section2081013992812)
- [相关仓](#section1371113476307)
## 简介<a name="section11660541593"></a>
OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代内核,Huawei LiteOS是面向IoT领域构建的轻量级物联网操作系统。在IoT产业高速发展的潮流中,OpenHarmony LiteOS-A内核能够带给用户小体积、低功耗、高性能的体验以及统一开放的生态系统能力,新增了丰富的内核机制、更加全面的POSIX标准接口以及统一驱动框架**HDF**(OpenHarmony Driver Foundation)等,为设备厂商提供了更统一的接入方式,为OpenHarmony的应用开发者提供了更友好的开发体验。图1为OpenHarmony LiteOS-A内核架构图:
**图 1** OpenHarmony LiteOS-A内核架构图<a name="fig27311582210"></a>
![](figures/OpenHarmony-LiteOS-A内核架构图.png "OpenHarmony-LiteOS-A内核架构图")
## 目录<a name="section161941989596"></a>
```
/kernel/liteos_a
├── apps # 用户态的init和shell应用程序
├── arch # 体系架构的目录,如arm等
│ └── arm # arm架构代码
├── bsd # freebsd相关的驱动和适配层模块代码引入,例如USB等
├── compat # 内核接口兼容性目录
│ └── posix # posix相关接口
├── drivers # 内核驱动
│ └── char # 字符设备
│ ├── mem # 访问物理IO设备驱动
│ ├── quickstart # 系统快速启动接口目录
│ ├── random # 随机数设备驱动
│ └── video # framebuffer驱动框架
├── fs # 文件系统模块,主要来源于NuttX开源项目
│ ├── fat # fat文件系统
│ ├── jffs2 # jffs2文件系统
│ ├── include # 对外暴露头文件存放目录
│ ├── nfs # nfs文件系统
│ ├── proc # proc文件系统
│ ├── ramfs # ramfs文件系统
│ └── vfs # vfs层
├── kernel # 进程、内存、IPC等模块
│ ├── base # 基础内核,包括调度、内存等模块
│ ├── common # 内核通用组件
│ ├── extended # 扩展内核,包括动态加载、vdso、liteipc等模块
│ ├── include # 对外暴露头文件存放目录
│ └── user # 加载init进程
├── lib # 内核的lib库
├── net # 网络模块,主要来源于lwip开源项目
├── platform # 支持不同的芯片平台代码,如Hi3516DV300等
│ ├── hw # 时钟与中断相关逻辑代码
│ ├── include # 对外暴露头文件存放目录
│ └── uart # 串口相关逻辑代码
├── platform # 支持不同的芯片平台代码,如Hi3516DV300等
├── security # 安全特性相关的代码,包括进程权限管理和虚拟id映射管理
├── syscall # 系统调用
└── tools # 构建工具及相关配置和代码
```
## 约束<a name="section119744591305"></a>
- 开发语言:C/C++;
- 适用于Hi3518EV300、Hi3516DV300单板;
- Hi3518EV300默认使用jffs2文件系统,Hi3516DV300默认使用FAT文件系统。
## 使用说明<a name="section741617511812"></a>
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))单板,开发者可基于两种单板开发运行自己的应用程序。
### 准备<a name="section1579912573329"></a>
开发者需要在Linux上搭建编译环境:
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/quick-start/Hi3518%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83.md)
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/quick-start/Hi3516%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83.md)
### 获取源码<a name="section11443189655"></a>
在Linux服务器上下载并解压一套源代码,获取源码([下载链接](https://repo.huaweicloud.com/harmonyos/os/1.0/code-1.0.tar.gz))。更多源码获取方式,参考[源码获取](https://gitee.com/openharmony/docs/blob/master/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md)
### 编译构建<a name="section2081013992812"></a>
开发者开发第一个应用程序可参考:
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/quick-start/%E5%BC%80%E5%8F%91Hi3518%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.md)
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/quick-start/%E5%BC%80%E5%8F%91Hi3516%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%A4%BA%E4%BE%8B.md)
## 相关仓<a name="section1371113476307"></a>
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos)
**[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a)**
# 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:
......@@ -38,7 +38,7 @@ all: $(APPS)
# Make
$(APPS):
ifneq ($(APP_SUBDIRS), )
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir ; done
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir || exit 1; done
endif
clean:
......
# 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:
......
# 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:
......@@ -43,6 +43,12 @@ ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses -Wnonnull $(LLVM_SYSROOT)
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
endif
ifeq ($(LOSCFG_QUICK_START), y)
LDCFLAGS += --static
CFLAGS += -DLOSCFG_QUICK_START
endif
INITNAME := init
all: $(INITNAME)
......
/*
* 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:
......@@ -35,11 +35,41 @@
#include <unistd.h>
#include <sys/wait.h>
#ifdef LOSCFG_QUICK_START
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#define QUICKSTART_IOC_MAGIC 'T'
#define QUICKSTART_INITSTEP2 _IO(QUICKSTART_IOC_MAGIC, 0)
#define WAIT_FOR_SAMPLE 300000 // wait 300ms for sample
#endif
int main(int argc, char * const *argv)
{
int ret;
const char *shellPath = "/bin/shell";
#ifdef LOSCFG_QUICK_START
const char *samplePath = "/dev/shm/sample_quickstart";
ret = fork();
if (ret < 0) {
printf("Failed to fork for sample_quickstart\n");
} else if (ret == 0) {
(void)execve(samplePath, NULL, NULL);
exit(0);
}
usleep(WAIT_FOR_SAMPLE);
int fd = open("/dev/quickstart", O_RDONLY);
if (fd != -1) {
ioctl(fd, QUICKSTART_INITSTEP2);
close(fd);
}
#endif
ret = fork();
if (ret < 0) {
printf("Failed to fork for shell\n");
......
# 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:
......@@ -38,3 +38,7 @@ endif
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
APP_SUBDIRS += init
endif
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
APP_SUBDIRS += tftp
endif
# 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......@@ -98,6 +98,8 @@ int main()
int ret = SH_NOK;
ShellCB *shellCB = NULL;
setbuf(stdout, NULL);
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) {
goto ERR_OUT1;
......
/*
* 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:
......@@ -406,7 +406,7 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
}
output = (char *)malloc(len + 1);
if (output == NULL) {
printf("malloc failure in %s[%d]", __FUNCTION__, __LINE__);
printf("malloc failure in %s[%d]\n", __FUNCTION__, __LINE__);
return (unsigned int)SH_ERROR;
}
......
/*
* 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:
......
/*
* 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:
......@@ -61,9 +61,19 @@ char *GetCmdline(ShellCB *shellCB)
}
cmdNode = SH_LIST_ENTRY(cmdkey->list.pstNext, CmdKeyLink, list);
if (cmdNode == NULL) {
(void)pthread_mutex_unlock(&shellCB->keyMutex);
return NULL;
}
SH_ListDelete(&(cmdNode->list));
(void)pthread_mutex_unlock(&shellCB->keyMutex);
if (strlen(cmdNode->cmdString) == 0) {
free(cmdNode);
return NULL;
}
return cmdNode->cmdString;
}
......@@ -73,7 +83,8 @@ static void ShellSaveHistoryCmd(char *string, ShellCB *shellCB)
CmdKeyLink *cmdkey = SH_LIST_ENTRY(string, CmdKeyLink, cmdString);
CmdKeyLink *cmdNxt = NULL;
if ((string == NULL) || (*string == '\n') || (strlen(string) == 0)) {
if (*string == '\n') {
free(cmdkey);
return;
}
......@@ -87,7 +98,7 @@ static void ShellSaveHistoryCmd(char *string, ShellCB *shellCB)
}
}
if (cmdHistory->count == CMD_HISTORY_LEN) {
if (cmdHistory->count >= CMD_HISTORY_LEN) {
cmdNxt = SH_LIST_ENTRY(cmdHistory->list.pstNext, CmdKeyLink, list);
SH_ListDelete(&(cmdNxt->list));
SH_ListTailInsert(&(cmdHistory->list), &(cmdkey->list));
......
# 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.
ROOT_DIR := $(dir $(shell pwd))/tftp/
ifeq ($(APPSTOPDIR), )
APPSTOPDIR := $(shell pwd)/../
LITEOSTOPDIR = $(APPSTOPDIR)/../
endif
include $(ROOT_DIR)/../config.mk
APPS_OUT := $(OUT)/bin
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
LOCAL_SRCS = $(wildcard src/*.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncpy_s.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memcpy_s.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memset_s.c)
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncat_s.c)
LOCAL_OBJ := $(LOCAL_SRCS:.c=.o)
LOCAL_INCLUDE := \
-I $(ROOT_DIR)/include/ \
-I $(SECUREC_DIR)/include/\
LOCAL_FLAGS += $(CFLAGS)
LDPATH := -L$(ROOT_DIR)/
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses $(LLVM_SYSROOT)
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
endif
TARGETNAME := tftp
all: $(TARGETNAME)
$(LOCAL_OBJ): %.o : %.c
$(HIDE) $(CC) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
$(TARGETNAME): $(LOCAL_OBJ)
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(TARGETNAME) $^ $(LDCFLAGS)
$(HIDE) mkdir -p $(APPS_OUT)
$(HIDE) $(MV) $(TARGETNAME) $(APPS_OUT)
$(HIDE) $(RM) $(LOCAL_OBJ)
clean:
$(HIDE) $(RM) $(LOCAL_OBJ)
$(HIDE) $(RM) $(TARGETNAME)
.PHONY: all $(TARGETNAME) clean
/*
* 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 TFTPC_H
#define TFTPC_H
#include "types_adapt.h"
#if LWIP_TFTP /* don't build if not configured for use in lwipopts.h */
#if defined (__cplusplus) && __cplusplus
extern "C" {
#endif
#define TFTP_NULL_UINT32 ((u32_t)0xffffffffUL)
#define TFTP_NULL_INT32 -1
/** @cond liteos
* @defgroup TFTP_Interfaces
* @ingroup Enums
* * This section contains the TFTP enums.
*/
/**
*
* This Enum is used to specify the transfer mode of the file to be handled by TFTP client.
*/
typedef enum tagTFTPC_TransferMode {
TRANSFER_MODE_ASCII = 0, /**< Indicates that the mode of transfer is ASCII. */
TRANSFER_MODE_BINARY, /**< Indicates that the mode of transfer is Binary */
TRANSFER_MODE_BUTT /**< Indicates invalid transfer mode.*/
} TFTPC_TRANSFER_MODE_E;
/**
* This Enum is used to specify the transfer mode to be handled by TFTP client
* This Enum indicates the TFTP client transfer mode of the file
*/
typedef enum tagTFTPC_ErrCode {
TFTPC_SOCKET_FAILURE = 1, /**< Error while creating UDP socket. */
TFTPC_BIND_FAILURE = 2, /**< Error while binding to the UDP socket. */
TFTPC_SELECT_ERROR = 3, /**< Error returned by select() system call. */
TFTPC_RECVFROM_ERROR = 4, /**< Error while receiving data from the peer. */
TFTPC_SENDTO_ERROR = 5, /**< Error while sending data to the peer. */
TFTPC_FILE_NOT_FOUND = 6, /**< Requested file is not found. */
/**< This is the error sent by the server when host name cannot be resolved. */
TFTPC_CANNOT_RESOLVE_HOSTNAME = 7,
TFTPC_INVALID_PARAVALUE = 8, /**< Input parameters passed to TFTP interfaces are invalid. */
/**< Error detected in TFTP packet or the error received from the TFTP server. */
TFTPC_PROTO_ERROR = 9,
/**< Error during packet synchronization while sending or unexpected packet is received. */
TFTPC_SYNC_FAILURE = 10,
/**< File size limit crossed, Max block can be 0xFFFF, each block containing 512 bytes. */
TFTPC_FILE_TOO_BIG = 11,
TFTPC_SRC_FILENAME_LENGTH_ERROR = 12, /**< File name length greater than 256. */
TFTPC_IP_NOT_WITHIN_RANGE = 13, /**< Host name IP is not valid. */
TFTPC_ACCESS_ERROR = 14, /**< TFTP server returned file access error. */
/**< TFTP server returned error signifying that the DISK is full to write. */
TFTPC_DISK_FULL = 15,
TFTPC_FILE_EXISTS = 16, /**< TFTP server returned error signifying that the file exists. */
/**< tftp_put_file_by_filename returned error signifying that the source file name do not exist. */
TFTPC_FILE_NOT_EXIST = 17,
TFTPC_MEMALLOC_ERROR = 18, /**< Memory allocation failed in TFTP client. */
TFTPC_FILEOPEN_ERROR = 19, /**< File open failed. */
TFTPC_FILEREAD_ERROR = 20, /**< File read error. */
TFTPC_FILECREATE_ERROR = 21, /**< File create error. */
TFTPC_FILEWRITE_ERROR = 22, /**< File write error. */
TFTPC_TIMEOUT_ERROR = 23, /**< Max time expired while waiting for file to be received. */
/**< Error when the received packet is less than 4 bytes (error length) or greater than 512 bytes. */
TFTPC_PKT_SIZE_ERROR = 24,
TFTPC_ERROR_NOT_DEFINED = 25, /**< Returned by TFTP server for protocol user error. */
TFTPC_DEST_PATH_LENGTH_ERROR = 26, /**< If the destination file path length is greater than 256. */
TFTPC_UNKNOWN_TRANSFER_ID = 27, /**< Returned by TFTP server for undefined transfer ID. */
/**< IOCTL function failed at TFTP client while setting the socket to non-block. */
TFTPC_IOCTLSOCKET_FAILURE = 28,
TFTPC_MEMCPY_FAILURE = 29 /**< TFTP memcpy failure. */
} TFTPC_ERR_CODE_E;
typedef enum tagTFTPC_OpCode {
TFTPC_OP_RRQ = 1, /* read request */
TFTPC_OP_WRQ, /* write request */
TFTPC_OP_DATA, /* data packet */
TFTPC_OP_ACK, /* acknowledgement */
TFTPC_OP_ERROR, /* error code */
TFTPC_OP_OPT /* option code */
} TFTPC_OPCODE_E;
typedef enum tagTFTPC_PROTOCOL_ErrCode {
TFTPC_PROTOCOL_USER_DEFINED = 0,
TFTPC_PROTOCOL_FILE_NOT_FOUND,
TFTPC_PROTOCOL_ACCESS_ERROR,
TFTPC_PROTOCOL_DISK_FULL,
TFTPC_PROTOCOL_PROTO_ERROR,
TFTPC_PROTOCOL_UNKNOWN_TRANSFER_ID,
TFTPC_PROTOCOL_FILE_EXISTS,
TFTPC_PROTOCOL_CANNOT_RESOLVE_HOSTNAME
} TFTPC_PROT_ERRCODE_E;
#ifndef TFTPC_MAX_SEND_REQ_ATTEMPTS
#define TFTPC_MAX_SEND_REQ_ATTEMPTS 5 /* tftp max attempts */
#endif
#ifndef TFTPC_TIMEOUT_PERIOD
#define TFTPC_TIMEOUT_PERIOD 5 /* tftp timeout period,unit :s */
#endif
#define TFTPC_SERVER_PORT 69 /* tftp server well known port no. */
/* MAX file size in TFTP is 32 MB.
Reason for keeping 75 here , is ((75*512=38400bytes)/1024) = 37MB. So the recv/Send Loop can
receive the complete MAX message from the network
*/
#define TFTPC_MAX_WAIT_IN_LOOP 75
#define TFTP_BLKSIZE 512 /* data block size (IEN-133) */
#define TFTP_HDRSIZE 4 /* TFTP header size */
#define TFTP_PKTSIZE (TFTP_BLKSIZE + TFTP_HDRSIZE) /* Packet size */
#define TFTP_MAX_MODE_SIZE 9 /* max size of mode string */
#define TFTP_MAXERRSTRSIZE 100 /* max size of error message string */
#define TFTP_MAX_PATH_LENGTH 256 /* Max path or filename length */
#define TFTP_MAX_BLK_NUM (0xFFFFL) /* MAximum block number */
/* IP address not including reserved IPs(0 and 127) and multicast addresses(Class D) */
#define TFTPC_IP_ADDR_MIN 0x01000000
#define TFTPC_IP_ADDR_EX_RESV 0x7effffff
#define TFTPC_IP_ADDR_CLASS_B 0x80000000
#define TFTPC_IP_ADDR_EX_CLASS_DE 0xdfffffff
#define TFTPC_FOUR 4 /* minimum packet size */
/****************************************************************************/
/* Structure definitions */
/****************************************************************************/
/* Tftp data packet */
typedef struct tagTFTPC_DATA {
u16_t usBlknum; /* block number */
u8_t ucDataBuf[TFTP_BLKSIZE]; /* Actual data */
} TFTPC_DATA_S;
/* TFTP error packet */
typedef struct tagTFTPC_ERROR {
u16_t usErrNum; /* error number */
u8_t ucErrMesg[TFTP_MAXERRSTRSIZE]; /* error message */
} TFTPC_ERROR_S;
/* TFTP packet format */
typedef struct tagTFTPC_PACKET {
u16_t usOpcode; /* Opcode value */
union {
/* it contains mode and filename */
s8_t ucName_Mode[TFTP_MAX_PATH_LENGTH + TFTP_MAX_MODE_SIZE];
u16_t usBlknum; /* Block Number */
TFTPC_DATA_S stTFTP_Data; /* Data Packet */
TFTPC_ERROR_S stTFTP_Err; /* Error Packet */
} u;
} TFTPC_PACKET_S;
/** @defgroup TFTP_Interfaces
* This section contains the TFTP Interfaces
*/
/*
Func Name: lwip_tftp_get_file_by_filename
*/
/**
* @ingroup TFTP_Interfaces
* @brief
* This API gets the source file from the server. It then stores the received file in the destination path
* on the client system.
*
* @param[in] ulHostAddr IP address of Host. This is the TFTP server IP. [NA]
* @param[in] usTftpServPort TFTP server port. If the value is passed as 0 then the default TFTP
* PORT 69 is used. [NA]
* @param[in] ucTftpTransMode File transfer mode, either TRANSFER_MODE_BINARY or TRANSFER_MODE_ASCII. [NA]
* @param[in] szSrcFileName Source file in the tftp server. [NA]
* @param[in] szDestDirPath Destination file path in the in the client. [NA]
* @param[out] [N/A]
*
* @return
* ERR_OK: On success \n
* TFTPC_ERR_CODE_E: On failure
*
* @note
* \n
* The behavior of this API is such that if the destination file already exists, it will be overwritten.
*/
u32_t lwip_tftp_get_file_by_filename(u32_t ulHostAddr,
u16_t usTftpServPort,
u8_t ucTftpTransMode,
s8_t *szSrcFileName,
s8_t *szDestDirPath);
/* @defgroup TFTP_Interfaces
* This section contains the TFTP Interfaces
*/
/*
Func Name: lwip_tftp_put_file_by_filename
*/
/**
* @ingroup TFTP_Interfaces
* @brief
* This API reads the contents of the source file on the client system and sends it to the server and
* server then receives the data and stores it in the specified destination path.
*
* @param[in] ulHostAddr Indicates the IP address of Host. This is the TFTP server IP.
* @param[in] usTftpServPort Indicates the TFTP server port. If the value is passed as 0 then the default TFTP
* PORT 69 is used.
* @param[in] ucTftpTransMode Indicates the file transfer mode, either TRANSFER_MODE_BINARY or TRANSFER_MODE_ASCII.
* @param[in] szSrcFileName Indicates the source file in the client.
* @param[in] szDestDirPath Indicates the destination file path on the tftp server.
*
* @return
* ERR_OK: On success \n
* TFTPC_ERR_CODE_E: On failure
*
*/
u32_t lwip_tftp_put_file_by_filename(u32_t ulHostAddr,
u16_t usTftpServPort,
u8_t cTftpTransMode,
s8_t *szSrcFileName,
s8_t *szDestDirPath);
#ifdef TFTP_TO_RAWMEM
/* @defgroup TFTP_Interfaces
* This section contains the TFTP Interfaces
*/
/*
Func Name: lwip_tftp_get_file_by_filename_to_rawmem
*/
/**
* @ingroup TFTP_Interfaces
* @brief
* This API gets the source file from the server. It then stores the received file in the target memory
* on the client system.
*
* @param[in] ulHostAddr Indicates the IP address of the Host. This is the TFTP server IP.
* @param[in] usTftpServPort Indicates the TFTP server port. If the value is passed as 0 then the default TFTP
* PORT 69 is used.
* @param[in] ucTftpTransMode Indicates the File transfer mode, either TRANSFER_MODE_BINARY or TRANSFER_MODE_ASCII.
* @param[in] szSrcFileName Indicates the Source file in the TFTP server.
* @param[in] szDestMemAddr Indicates the target memory address in the client.
* @param[in/out] ulFileLength Indicates the target memory address can cache the size of the content,
and The real size of the Source file.
*
* @return
* ERR_OK: On success \n
* TFTPC_ERR_CODE_E: On failure
* @note
* 1.You must define TFTP_TO_RAWMEM when using this API. \n
* 2.The behavior of this API is such that if the destination file already exists, it will be overwritten.
* @endcond
*/
u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
u16_t usTftpServPort,
u8_t ucTftpTransMode,
s8_t *szSrcFileName,
s8_t *szDestMemAddr,
u32_t *ulFileLength);
#endif
#if defined (__cplusplus) && __cplusplus
}
#endif
#endif /* LWIP_TFTP */
#endif /* TFTPC_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 TYPES_ADAPT_H
#define TYPES_ADAPT_H
#include <stdint.h>
#include <stdbool.h>
#include <inttypes.h>
#define LWIP_TFTP 1
#define LOSCFG_NET_LWIP_SACK_TFTP 1
#define LOSCFG_SHELL_CMD_DEBUG 1
#define u8_t uint8_t
#define s8_t int8_t
#define u16_t uint16_t
#define s16_t int16_t
#define u32_t uint32_t
#define s32_t int32_t
#define X8_F "02" PRIx8
#define U16_F PRIu16
#define S16_F PRId16
#define X16_F PRIx16
#define U32_F PRIu32
#define S32_F PRId32
#define X32_F PRIx32
#define SZT_F PRIuPTR
#define PRINTK(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define LWIP_ASSERT(msg, expr) assert(expr)
#define LWIP_DEBUGF(module, msg) PRINTK msg
#define LOS_OK 0
#define LOS_NOK 1
#define ERR_OK 0
#define EOK 0
#define mem_malloc malloc
#define mem_free free
#define lwip_socket socket
#define lwip_ioctl ioctl
#define lwip_close close
#define lwip_bind bind
#define lwip_sendto sendto
#define lwip_recvfrom recvfrom
#define IPADDR_NONE INADDR_NONE
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)
#define SHELLCMD_ENTRY(l, cmdType, cmdKey, paraNum, cmdHook) \
int main(int argc, const char **argv) \
{ \
return (int)cmdHook(argc, argv); \
}
typedef u32_t (*CmdCallBackFunc)(u32_t argc, const char **argv);
#endif /* TYPES_ADAPT_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 <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>
#include <assert.h>
#include "tftpc.h"
#ifdef LOSCFG_NET_LWIP_SACK_TFTP
static int tcpip_init_finish = 1;
static char *TftpError[] = {
"TFTP transfer finish\n",
"Error while creating UDP socket\n",
"Error while binding to the UDP socket\n",
"Error returned by select() system call\n",
"Error while receiving data from the peer\n",
"Error while sending data to the peer\n",
"Requested file is not found\n",
"This is the error sent by the server when hostname cannot be resolved\n",
"Input paramters passed to TFTP interfaces are invalid\n",
"Error detected in TFTP packet or the error received from the TFTP server\n",
"Error during packet synhronization while sending or unexpected packet is received\n",
"File size limit crossed, Max block can be 0xFFFF, each block containing 512 bytes\n",
"File name lenght greater than 256\n",
"Hostname IP is not valid\n",
"TFTP server returned file access error\n",
"TFTP server returned error signifying that the DISK is full to write\n",
"TFTP server returned error signifying that the file exist\n",
"The source file name do not exisits\n",
"Memory allocaion failed in TFTP client\n",
"File open failed\n",
"File read error\n",
"File create error\n",
"File write error\n",
"Max time expired while waiting for file to be recived\n",
"Error when the received packet is less than 4bytes(error lenght) or greater than 512bytes\n",
"Returned by TFTP server for protocol user error\n",
"The destination file path length greater than 256\n",
"Returned by TFTP server for undefined transfer ID\n",
"IOCTL fucntion failed at TFTP client while setting the socket to non-block\n",
};
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#endif
u32_t osShellTftp(int argc, const char **argv)
{
u32_t ulRemoteAddr = IPADDR_NONE;
const u16_t usTftpServPort = 69;
u8_t ucTftpGet = 0;
s8_t *szLocalFileName = NULL;
s8_t *szRemoteFileName = NULL;
u32_t ret;
int i = 1;
if (argc < 1 || argv == NULL) {
goto usage;
}
if (!tcpip_init_finish) {
PRINTK("%s: tcpip_init have not been called\n", __FUNCTION__);
return LOS_NOK;
}
while (i < argc) {
if (strcmp(argv[i], "-p") == 0) {
ucTftpGet = 0;
i++;
continue;
}
if (strcmp(argv[i], "-g") == 0) {
ucTftpGet = 1;
i++;
continue;
}
if (strcmp(argv[i], "-l") == 0 && ((i + 1) < argc)) {
szLocalFileName = (s8_t *)argv[i + 1];
i += 2;
continue;
}
if (strcmp(argv[i], "-r") == 0 && ((i + 1) < argc)) {
szRemoteFileName = (s8_t *)argv[i + 1];
i += 2;
continue;
}
if ((i + 1) == argc) {
ulRemoteAddr = inet_addr(argv[i]);
break;
}
goto usage;
}
if (ulRemoteAddr == IPADDR_NONE || szLocalFileName == NULL || szRemoteFileName == NULL) {
goto usage;
}
if (ucTftpGet) {
ret = lwip_tftp_get_file_by_filename(ntohl(ulRemoteAddr), usTftpServPort,
TRANSFER_MODE_BINARY, szRemoteFileName, szLocalFileName);
} else {
ret = lwip_tftp_put_file_by_filename(ntohl(ulRemoteAddr), usTftpServPort,
TRANSFER_MODE_BINARY, szLocalFileName, szRemoteFileName);
}
LWIP_ASSERT("TFTP UNKNOW ERROR!", ret < ARRAY_SIZE(TftpError));
PRINTK("%s", TftpError[ret]);
if (ret) {
return LOS_NOK;
} else {
return LOS_OK;
}
usage:
PRINTK("usage:\nTransfer a file from/to tftp server\n");
PRINTK("tftp <-g/-p> -l FullPathLocalFile -r RemoteFile Host\n");
return LOS_NOK;
}
#ifdef LOSCFG_SHELL_CMD_DEBUG
SHELLCMD_ENTRY(tftp_shellcmd, CMD_TYPE_EX, "tftp", XARGS, (CmdCallBackFunc)(uintptr_t)osShellTftp);
#endif /* LOSCFG_SHELL_CMD_DEBUG */
#endif /* LOSCFG_NET_LWIP_SACK_TFTP */
此差异已折叠。
文件模式从 100755 更改为 100644
# 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:
......
# 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:
......@@ -35,6 +35,7 @@ LOCAL_SRCS := $(wildcard src/*.c) $(wildcard src/*.S)
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/kernel/base/include \
-I $(LITEOSTOPDIR)/kernel/extended/include \
-I $(LITEOSTOPDIR)/kernel/extended/dynload/include \
-I $(LITEOSTOPDIR)/arch/arm/arm/include \
ifeq ($(LITEOS_ARM_ARCH), -march=armv7-a)
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......@@ -104,6 +104,8 @@ extern "C" {
((x) << MMU_DESCRIPTOR_L1_TEX_SHIFT) /* type extension */
#define MMU_DESCRIPTOR_L1_TYPE_STRONGLY_ORDERED \
(MMU_DESCRIPTOR_L1_TEX(MMU_DESCRIPTOR_TEX_0) | MMU_DESCRIPTOR_NON_CACHEABLE)
#define MMU_DESCRIPTOR_L1_TYPE_NORMAL_NOCACHE \
(MMU_DESCRIPTOR_L1_TEX(MMU_DESCRIPTOR_TEX_1) | MMU_DESCRIPTOR_NON_CACHEABLE)
#define MMU_DESCRIPTOR_L1_TYPE_DEVICE_SHARED \
(MMU_DESCRIPTOR_L1_TEX(MMU_DESCRIPTOR_TEX_0) | MMU_DESCRIPTOR_WRITE_BACK_ALLOCATE)
#define MMU_DESCRIPTOR_L1_TYPE_DEVICE_NON_SHARED \
......@@ -141,6 +143,8 @@ extern "C" {
((x) << MMU_DESCRIPTOR_L2_TEX_SHIFT) /* type extension */
#define MMU_DESCRIPTOR_L2_TYPE_STRONGLY_ORDERED \
(MMU_DESCRIPTOR_L2_TEX(MMU_DESCRIPTOR_TEX_0) | MMU_DESCRIPTOR_NON_CACHEABLE)
#define MMU_DESCRIPTOR_L2_TYPE_NORMAL_NOCACHE \
(MMU_DESCRIPTOR_L2_TEX(MMU_DESCRIPTOR_TEX_1) | MMU_DESCRIPTOR_NON_CACHEABLE)
#define MMU_DESCRIPTOR_L2_TYPE_DEVICE_SHARED \
(MMU_DESCRIPTOR_L2_TEX(MMU_DESCRIPTOR_TEX_0) | MMU_DESCRIPTOR_WRITE_BACK_ALLOCATE)
#define MMU_DESCRIPTOR_L2_TYPE_DEVICE_NON_SHARED \
......@@ -158,7 +162,7 @@ extern "C" {
#define MMU_DESCRIPTOR_L2_AP01_0 (MMU_DESCRIPTOR_L2_AP01(0))
#define MMU_DESCRIPTOR_L2_AP01_1 (MMU_DESCRIPTOR_L2_AP01(1))
#define MMU_DESCRIPTOR_L2_AP01_3 (MMU_DESCRIPTOR_L2_AP01(3))
#define MMU_DESCRIPTOR_L2_AP_P_NA_U_NA (MMUDESCRIPTOR_L2_AP2_0 | MMU_DESCRIPTOR_L2_AP01_0)
#define MMU_DESCRIPTOR_L2_AP_P_NA_U_NA (MMU_DESCRIPTOR_L2_AP2_0 | MMU_DESCRIPTOR_L2_AP01_0)
#define MMU_DESCRIPTOR_L2_AP_P_RW_U_RW (MMU_DESCRIPTOR_L2_AP2_0 | MMU_DESCRIPTOR_L2_AP01_3)
#define MMU_DESCRIPTOR_L2_AP_P_RW_U_NA (MMU_DESCRIPTOR_L2_AP2_0 | MMU_DESCRIPTOR_L2_AP01_1)
#define MMU_DESCRIPTOR_L2_AP_P_RO_U_RO (MMU_DESCRIPTOR_L2_AP2_1 | MMU_DESCRIPTOR_L2_AP01_3)
......@@ -208,6 +212,12 @@ extern "C" {
MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT | \
MMU_DESCRIPTOR_L1_AP_P_RW_U_NA)
#define MMU_INITIAL_MAP_NORMAL_NOCACHE \
(MMU_DESCRIPTOR_L1_TYPE_SECTION | \
MMU_DESCRIPTOR_L1_TYPE_NORMAL_NOCACHE | \
MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT | \
MMU_DESCRIPTOR_L1_AP_P_RW_U_NA)
#define MMU_INITIAL_MAP_DEVICE \
(MMU_DESCRIPTOR_L1_TYPE_SECTION | \
MMU_DESCRIPTOR_L1_TYPE_DEVICE_SHARED | \
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......@@ -52,7 +52,8 @@ STATIC INLINE VOID OsSetCurrCpuSp(UINTPTR regSp)
extern UINT32 OsGetSystemStatus(VOID);
extern VOID BackTraceSub(UINTPTR regFP);
extern VOID OsExcInit(VOID);
extern VOID OsKillUserProcess(UINTPTR sp);
extern BOOL OsSystemExcIsReset(VOID);
#ifdef __cplusplus
#if __cplusplus
}
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......@@ -91,11 +91,6 @@ STATIC INT32 OsMapParamCheck(UINT32 flags, VADDR_T vaddr, PADDR_T paddr)
}
#endif
if (!(flags & VM_MAP_REGION_FLAG_PERM_READ)) {
VM_ERR("miss read flag");
return LOS_ERRNO_VM_INVALID_ARGS;
}
/* paddr and vaddr must be aligned */
if (!MMU_DESCRIPTOR_IS_L2_SIZE_ALIGNED(vaddr) || !MMU_DESCRIPTOR_IS_L2_SIZE_ALIGNED(paddr)) {
return LOS_ERRNO_VM_INVALID_ARGS;
......@@ -114,6 +109,9 @@ STATIC VOID OsCvtPte2AttsToFlags(PTE_T l1Entry, PTE_T l2Entry, UINT32 *flags)
switch (l2Entry & MMU_DESCRIPTOR_L2_TEX_TYPE_MASK) {
case MMU_DESCRIPTOR_L2_TYPE_STRONGLY_ORDERED:
*flags |= VM_MAP_REGION_FLAG_STRONGLY_ORDERED;
break;
case MMU_DESCRIPTOR_L2_TYPE_NORMAL_NOCACHE:
*flags |= VM_MAP_REGION_FLAG_UNCACHED;
break;
case MMU_DESCRIPTOR_L2_TYPE_DEVICE_SHARED:
......@@ -208,10 +206,10 @@ STATIC VOID OsTryUnmapL1PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 sca
}
}
/* convert user level mmu flags to L1 descriptors flags */
STATIC UINT32 OsCvtSecFlagsToAttrs(UINT32 flags)
STATIC UINT32 OsCvtSecCacheFlagsToMMUFlags(UINT32 flags)
{
UINT32 mmuFlags = MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT;
UINT32 mmuFlags = 0;
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
case VM_MAP_REGION_FLAG_CACHED:
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
......@@ -219,33 +217,63 @@ STATIC UINT32 OsCvtSecFlagsToAttrs(UINT32 flags)
mmuFlags |= MMU_DESCRIPTOR_L1_SECTION_SHAREABLE;
#endif
break;
case VM_MAP_REGION_FLAG_WRITE_COMBINING:
case VM_MAP_REGION_FLAG_UNCACHED:
case VM_MAP_REGION_FLAG_STRONGLY_ORDERED:
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_STRONGLY_ORDERED;
break;
case VM_MAP_REGION_FLAG_UNCACHED:
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_NORMAL_NOCACHE;
break;
case VM_MAP_REGION_FLAG_UNCACHED_DEVICE:
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_DEVICE_SHARED;
break;
default:
return LOS_ERRNO_VM_INVALID_ARGS;
}
return mmuFlags;
}
STATIC UINT32 OsCvtSecAccessFlagsToMMUFlags(UINT32 flags)
{
UINT32 mmuFlags = 0;
switch (flags & (VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_WRITE)) {
switch (flags & (VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE)) {
case 0:
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_NA_U_NA;
break;
case VM_MAP_REGION_FLAG_PERM_READ:
case VM_MAP_REGION_FLAG_PERM_USER:
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_RO_U_NA;
break;
case VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_READ:
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_RO_U_RO;
break;
case VM_MAP_REGION_FLAG_PERM_WRITE:
case VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE:
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_RW_U_NA;
break;
case VM_MAP_REGION_FLAG_PERM_USER:
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_RO_U_RO;
break;
case VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_WRITE:
case VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE:
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_RW_U_RW;
break;
default:
break;
}
return mmuFlags;
}
/* convert user level mmu flags to L1 descriptors flags */
STATIC UINT32 OsCvtSecFlagsToAttrs(UINT32 flags)
{
UINT32 mmuFlags;
mmuFlags = OsCvtSecCacheFlagsToMMUFlags(flags);
if (mmuFlags == LOS_ERRNO_VM_INVALID_ARGS) {
return mmuFlags;
}
mmuFlags |= MMU_DESCRIPTOR_L1_SMALL_DOMAIN_CLIENT;
mmuFlags |= OsCvtSecAccessFlagsToMMUFlags(flags);
if (!(flags & VM_MAP_REGION_FLAG_PERM_EXECUTE)) {
mmuFlags |= MMU_DESCRIPTOR_L1_SECTION_XN;
......@@ -271,6 +299,9 @@ STATIC VOID OsCvtSecAttsToFlags(PTE_T l1Entry, UINT32 *flags)
switch (l1Entry & MMU_DESCRIPTOR_L1_TEX_TYPE_MASK) {
case MMU_DESCRIPTOR_L1_TYPE_STRONGLY_ORDERED:
*flags |= VM_MAP_REGION_FLAG_STRONGLY_ORDERED;
break;
case MMU_DESCRIPTOR_L1_TYPE_NORMAL_NOCACHE:
*flags |= VM_MAP_REGION_FLAG_UNCACHED;
break;
case MMU_DESCRIPTOR_L1_TYPE_DEVICE_SHARED:
......@@ -494,8 +525,7 @@ STATIC VOID OsMapL1PTE(LosArchMmu *archMmu, PTE_T *pte1Ptr, vaddr_t vaddr, UINT3
OsSavePte1(OsGetPte1Ptr(archMmu->virtTtb, vaddr), *pte1Ptr);
}
/* convert user level mmu flags to L2 descriptors flags */
STATIC UINT32 OsCvtPte2FlagsToAttrs(uint32_t flags)
STATIC UINT32 OsCvtPte2CacheFlagsToMMUFlags(UINT32 flags)
{
UINT32 mmuFlags = 0;
......@@ -506,33 +536,61 @@ STATIC UINT32 OsCvtPte2FlagsToAttrs(uint32_t flags)
#endif
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
break;
case VM_MAP_REGION_FLAG_WRITE_COMBINING:
case VM_MAP_REGION_FLAG_UNCACHED:
case VM_MAP_REGION_FLAG_STRONGLY_ORDERED:
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_STRONGLY_ORDERED;
break;
case VM_MAP_REGION_FLAG_UNCACHED:
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_NORMAL_NOCACHE;
break;
case VM_MAP_REGION_FLAG_UNCACHED_DEVICE:
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_DEVICE_SHARED;
break;
default:
return LOS_ERRNO_VM_INVALID_ARGS;
}
return mmuFlags;
}
STATIC UINT32 OsCvtPte2AccessFlagsToMMUFlags(UINT32 flags)
{
UINT32 mmuFlags = 0;
switch (flags & (VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_WRITE)) {
switch (flags & (VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE)) {
case 0:
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_NA_U_NA;
break;
case VM_MAP_REGION_FLAG_PERM_READ:
case VM_MAP_REGION_FLAG_PERM_USER:
mmuFlags |= MMU_DESCRIPTOR_L2_AP_P_RO_U_NA;
break;
case VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_READ:
mmuFlags |= MMU_DESCRIPTOR_L2_AP_P_RO_U_RO;
break;
case VM_MAP_REGION_FLAG_PERM_WRITE:
case VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE:
mmuFlags |= MMU_DESCRIPTOR_L2_AP_P_RW_U_NA;
break;
case VM_MAP_REGION_FLAG_PERM_USER:
mmuFlags |= MMU_DESCRIPTOR_L2_AP_P_RO_U_RO;
break;
case VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_WRITE:
case VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE:
mmuFlags |= MMU_DESCRIPTOR_L2_AP_P_RW_U_RW;
break;
default:
break;
}
return mmuFlags;
}
/* convert user level mmu flags to L2 descriptors flags */
STATIC UINT32 OsCvtPte2FlagsToAttrs(UINT32 flags)
{
UINT32 mmuFlags;
mmuFlags = OsCvtPte2CacheFlagsToMMUFlags(flags);
if (mmuFlags == LOS_ERRNO_VM_INVALID_ARGS) {
return mmuFlags;
}
mmuFlags |= OsCvtPte2AccessFlagsToMMUFlags(flags);
if (!(flags & VM_MAP_REGION_FLAG_PERM_EXECUTE)) {
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_SMALL_PAGE_XN;
......@@ -624,8 +682,7 @@ STATUS_T LOS_ArchMmuChangeProt(LosArchMmu *archMmu, VADDR_T vaddr, size_t count,
status = LOS_ArchMmuUnmap(archMmu, vaddr, 1);
if (status < 0) {
VM_ERR("invalid args:aspace %p, vaddr %p, count %d",
__FUNCTION__, __LINE__, archMmu, vaddr, count);
VM_ERR("invalid args:aspace %p, vaddr %p, count %d", archMmu, vaddr, count);
return LOS_NOK;
}
......@@ -832,7 +889,7 @@ STATIC VOID OsSetKSectionAttr(VOID)
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE);
if (status != (kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
VM_ERR("unmap failed, status: %d", status);
VM_ERR("mmap failed, status: %d", status);
return;
}
LOS_VmSpaceReserve(kSpace, kmallocLength, bssEndBoundary);
......
/*
* 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:
......@@ -34,8 +34,8 @@
* @ingroup kernel
*/
#include "los_typedef.h"
#include "los_asid.h"
#include "los_bitmap.h"
#include "los_spinlock.h"
#include "los_mmu_descriptor_v6.h"
......
/*
* 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,20 +32,11 @@
#include "asm.h"
#include "arch_config.h"
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
.extern OsLockDepCheckOut
#endif
.extern g_taskSpin
.extern g_percpu
.global OsStartToRun
.extern OsSchedToUserReleaseLock
.global OsTaskSchedule
.global OsTaskContextLoad
.global OsIrqHandler
.global ArchSpinUnlock
.global OsSchedToUserSpinUnlock
.equ OS_TASK_STATUS_RUNNING, 0x0010U
.equ OS_PERCPU_STRUCT_SIZE, 0x28U
.equ OS_PERCPU_TASK_LOCK_OFFSET, 0x14U
.fpu vfpv4
/* macros to align and unalign the stack on 8 byte boundary for ABI compliance */
......@@ -88,26 +79,6 @@
#endif
.endm
/* R0: new task */
OsStartToRun:
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE)
LDRH R1, [R0, #4]
ORR R1, #OS_TASK_STATUS_RUNNING
STRH R1, [R0, #4]
/* R0 is new task, save it on tpidrprw */
MCR p15, 0, R0, c13, c0, 4
ISB
VPUSH {S0} /* fpu */
VPOP {S0}
VPUSH {D0}
VPOP {D0}
B OsTaskContextLoad
/*
* R0: new task
* R1: run task
......@@ -152,24 +123,11 @@ OsTaskContextLoad:
BNE OsKernelTaskLoad
#ifdef LOSCFG_KERNEL_SMP
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
/* 8 bytes stack align */
SUB SP, SP, #4
LDR R0, =g_taskSpin
BL OsLockDepCheckOut
BL OsSchedToUserReleaseLock
ADD SP, SP, #4
#endif
/* R0 = &g_taskSpin.rawLock */
LDR R0, =g_taskSpin
BL ArchSpinUnlock
LDR R2, =g_percpu
MRC P15, 0, R3, C0, C0, 5
UXTB R3, R3
MOV R1, #OS_PERCPU_STRUCT_SIZE
MLA R3, R1, R3, R2
MOV R2, #0
STR R2, [R3, #OS_PERCPU_TASK_LOCK_OFFSET]
#endif
MVN R3, #CPSR_INT_DISABLE
AND R4, R4, R3
......@@ -245,9 +203,7 @@ OsIrqFromKernel:
/* process pending signals */
BL OsTaskProcSignal
/* check if needs to schedule */
CMP R0, #0
BLNE OsSchedPreempt
BL OsSchedIrqEndCheckNeedSched
MOV R0,SP
MOV R1,R7
......
/*
* 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:
......@@ -55,6 +55,7 @@
#include "los_vm_phys.h"
#include "los_vm_fault.h"
#include "los_vm_common.h"
#include "los_load_elf.h"
#include "arm.h"
#include "los_bitmap.h"
#include "los_process_pri.h"
......@@ -255,6 +256,39 @@ STATIC const CHAR *g_excTypeString[] = {
"irq"
};
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
{
struct file *curFilep = NULL;
struct file *lastFilep = NULL;
LosVmMapRegion *curRegion = NULL;
LosVmMapRegion *lastRegion = NULL;
if ((region == NULL) || (runProcess == NULL)) {
return 0;
}
if (!LOS_IsRegionFileValid(region)) {
return region->range.base;
}
lastRegion = region;
do {
curRegion = lastRegion;
lastRegion = LOS_RegionFind(runProcess->vmSpace, curRegion->range.base - 1);
if ((lastRegion == NULL) || !LOS_IsRegionFileValid(lastRegion)) {
goto DONE;
}
curFilep = curRegion->unTypeData.rf.file;
lastFilep = lastRegion->unTypeData.rf.file;
} while (!strcmp(curFilep->f_path, lastFilep->f_path));
DONE:
if (curRegion->range.base == EXEC_MMAP_BASE) {
return 0;
}
return curRegion->range.base;
}
STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
{
LosTaskCB *runTask = OsCurrTaskGet();
......@@ -289,7 +323,7 @@ STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)excBufAddr->PC);
if (region != NULL) {
PrintExcInfo("in %s ---> 0x%x", OsGetRegionNameOrFilePath(region),
(VADDR_T)excBufAddr->PC - region->range.base);
(VADDR_T)excBufAddr->PC - OsGetTextRegionBase(region, runProcess));
}
}
......@@ -297,7 +331,7 @@ STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)excBufAddr->ULR);
if (region != NULL) {
PrintExcInfo("in %s ---> 0x%x", OsGetRegionNameOrFilePath(region),
(VADDR_T)excBufAddr->ULR - region->range.base);
(VADDR_T)excBufAddr->ULR - OsGetTextRegionBase(region, runProcess));
}
PrintExcInfo("\nusp = 0x%x", excBufAddr->USP);
} else {
......@@ -307,7 +341,7 @@ STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
excBufAddr->SP);
}
PrintExcInfo("fp = 0x%x\n", excBufAddr->R11);
PrintExcInfo("\nfp = 0x%x\n", excBufAddr->R11);
}
STATIC VOID OsExcRegsInfo(const ExcContext *excBufAddr)
......@@ -388,7 +422,7 @@ STATIC VOID OsDumpExcVaddrRegion(LosVmSpace *space, LosVmMapRegion *region)
mmuFlag = FALSE;
}
PrintExcInfo(" 0x%08x 0x%08x 0x%08x\n",
startVaddr, LOS_PaddrToKVaddr(startPaddr), pageCount << PAGE_SHIFT);
startVaddr, LOS_PaddrToKVaddr(startPaddr), (UINT32)pageCount << PAGE_SHIFT);
pageCount = 0;
startPaddr = 0;
}
......@@ -510,6 +544,7 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
OsProcessExitCodeCoreDumpSet(runProcess);
#endif
OsProcessExitCodeSignalSet(runProcess, SIGUSR2);
/* kill user exc process */
LOS_Exit(OS_PRO_EXIT_OK);
......@@ -750,9 +785,9 @@ VOID OsBackTrace(VOID)
{
UINT32 regFP = Get_Fp();
LosTaskCB *runTask = OsCurrTaskGet();
PRINTK("OsBackTrace fp = 0x%x\n", regFP);
PRINTK("runTask->taskName = %s\n", runTask->taskName);
PRINTK("runTask->taskID = %u\n", runTask->taskID);
PrintExcInfo("OsBackTrace fp = 0x%x\n", regFP);
PrintExcInfo("runTask->taskName = %s\n", runTask->taskName);
PrintExcInfo("runTask->taskID = %u\n", runTask->taskID);
BackTrace(regFP);
}
......@@ -971,6 +1006,35 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
#endif
}
}
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_FS_VFS
/* Wait for the end of the Console task to avoid multicore printing code */
OsWaitConsoleSendTaskPend(OsCurrTaskGet()->taskID);
#endif
#endif
}
LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
{
#ifdef LOSCFG_DEBUG_VERSION
LosVmSpace *space = NULL;
VADDR_T vaddr;
#endif
/* You are not allowed to add any other print information before this exception information */
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
#ifdef LOSCFG_DEBUG_VERSION
vaddr = ROUNDDOWN(far, PAGE_SIZE);
space = LOS_SpaceGet(vaddr);
if (space != NULL) {
LOS_DumpMemRegion(vaddr);
}
#endif
PrintExcInfo("##################excFrom: User!####################\n");
} else {
PrintExcInfo("##################excFrom: kernel!###################\n");
}
}
/*
......@@ -987,19 +1051,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
OsExcPriorDisposal(excBufAddr);
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_FS_VFS
/* Wait for the end of the Console task to avoid multicore printing code */
OsWaitConsoleSendTaskPend(OsCurrTaskGet()->taskID);
#endif
#endif
/* You are not allowed to add any other print information before this exception information */
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
PrintExcInfo("##################excFrom: User!####################\n");
} else {
PrintExcInfo("##################excFrom: kernel###################!\n");
}
OsPrintExcHead(far);
#if (LOSCFG_KERNEL_SMP == YES)
OsAllCpuStatusOutput();
......@@ -1036,6 +1088,15 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
#ifdef LOSCFG_EXC_INTERACTION
OsExcInteractionTaskKeep();
#endif
#ifdef LOSCFG_SHELL_CMD_DEBUG
SystemRebootFunc rebootHook = OsGetRebootHook();
if ((OsSystemExcIsReset() == TRUE) && (rebootHook != NULL)) {
LOS_Mdelay(3000); /* 3000: System dead, delay 3 seconds after system restart */
rebootHook();
}
#endif
while (1) {}
}
......@@ -1058,6 +1119,46 @@ VOID __stack_chk_fail(VOID)
__builtin_return_address(0));
}
VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCount)
{
UINT32 count = 0;
UINT32 index = 0;
UINT32 stackStart, stackEnd;
LosTaskCB *taskCB = NULL;
UINTPTR framePtr, tmpFramePtr, linkReg;
if (LR == NULL) {
return;
}
/* if LR array is not enough,just record LRSize. */
if (LRSize < recordCount) {
recordCount = LRSize;
}
taskCB = OsCurrTaskGet();
stackStart = taskCB->topOfStack;
stackEnd = stackStart + taskCB->stackSize;
framePtr = Get_Fp();
while ((framePtr > stackStart) && (framePtr < stackEnd) && IS_ALIGNED(framePtr, sizeof(CHAR *))) {
tmpFramePtr = framePtr;
linkReg = *(UINTPTR *)framePtr;
if (index >= jumpCount) {
LR[count++] = linkReg;
if (count == recordCount) {
break;
}
}
index++;
framePtr = *(UINTPTR *)(tmpFramePtr - sizeof(UINTPTR));
}
/* if linkReg is not enough,clean up the last of the effective LR as the end. */
if (count < recordCount) {
LR[count] = 0;
}
}
#ifdef __cplusplus
#if __cplusplus
}
......
/*
* 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:
......
/*
* 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:
......@@ -57,7 +57,11 @@
.global _osExceptPrefetchAbortHdl
.global _osExceptSwiHdl
.global _osExceptUndefInstrHdl
#if defined(LOSCFG_CC_STACKPROTECTOR_ALL) || \
defined(LOSCFG_CC_STACKPROTECTOR_STRONG) || \
defined(LOSCFG_CC_STACKPROTECTOR)
.global __stack_chk_guard_setup
#endif
.fpu vfpv4
......@@ -147,15 +151,22 @@
.endm
#endif
#if defined(LOSCFG_CC_STACKPROTECTOR_ALL) || \
defined(LOSCFG_CC_STACKPROTECTOR_STRONG) || \
defined(LOSCFG_CC_STACKPROTECTOR)
@ Description: Stack-Protector Init
__stack_chk_guard_setup:
PUSH {FP, LR}
#if defined(LOSCFG_PLATFORM_HI3516DV300) || defined(LOSCFG_PLATFORM_HI3518EV300)
/* Randomize __stack_chk_quard using platform-specific function. */
BL OsRandomStackGuard
LDR R1, =__stack_chk_guard
MOV R3, R0
ORR R2, R3, #0X80000000
STR R2, [R1]
#endif
POP {FP, PC}
#endif
@ Description: Undefined instruction exception handler
_osExceptUndefInstrHdl:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......@@ -31,11 +31,11 @@
#include "los_hwi.h"
#include "los_memory.h"
#include "los_tickless_pri.h"
#include "los_spinlock.h"
#ifdef LOSCFG_KERNEL_CPUP
#include "los_cpup_pri.h"
#endif
#include "los_sched_pri.h"
#ifdef __cplusplus
#if __cplusplus
......@@ -68,6 +68,11 @@ CHAR *OsGetHwiFormName(UINT32 index)
return g_hwiFormName[index];
}
UINT32 LOS_GetSystemHwiMaximum(VOID)
{
return OS_HWI_MAX_NUM;
}
typedef VOID (*HWI_PROC_FUNC0)(VOID);
typedef VOID (*HWI_PROC_FUNC2)(INT32, VOID *);
VOID OsInterrupt(UINT32 intNum)
......@@ -75,16 +80,16 @@ VOID OsInterrupt(UINT32 intNum)
HwiHandleForm *hwiForm = NULL;
UINT32 *intCnt = NULL;
/* Must keep the operation at the beginning of the interface */
intCnt = &g_intCount[ArchCurrCpuid()];
*intCnt = *intCnt + 1;
OsSchedIrqStartTime();
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqStart();
#endif
#ifdef LOSCFG_KERNEL_TICKLESS
OsTicklessUpdate(intNum);
#endif
hwiForm = (&g_hwiForm[intNum]);
#ifndef LOSCFG_NO_SHARED_IRQ
while (hwiForm->pstNext != NULL) {
......@@ -107,10 +112,13 @@ VOID OsInterrupt(UINT32 intNum)
#endif
++g_hwiFormCnt[intNum];
*intCnt = *intCnt - 1;
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
OsCpupIrqEnd(intNum);
#endif
OsSchedIrqUpdateUsedTime();
/* Must keep the operation at the end of the interface */
*intCnt = *intCnt - 1;
}
STATIC HWI_ARG_T OsHwiCpIrqParam(const HwiIrqParam *irqParam)
......
/*
* 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:
......@@ -112,6 +112,20 @@ __exception_handlers:
/* Startup code which will get the machine into supervisor mode */
.global reset_vector
.type reset_vector,function
#ifdef LOSCFG_QUICK_START
__quickstart_args_start:
.fill 512,1,0
__quickstart_args_end:
.global OsGetArgsAddr
.type OsGetArgsAddr,function
OsGetArgsAddr:
ldr r0, =__quickstart_args_start
bx lr
#endif
reset_vector:
/* clear register TPIDRPRW */
mov r0, #0
......@@ -122,6 +136,20 @@ reset_vector:
bic r0, #(1<<2 | 1<<0)
mcr p15, 0, r0, c1, c0, 0
/* enable fpu+neon */
#ifndef LOSCFG_TEE_ENABLE
MRC p15, 0, r0, c1, c1, 2
ORR r0, r0, #0xC00
BIC r0, r0, #0xC000
MCR p15, 0, r0, c1, c1, 2
LDR r0, =(0xF << 20)
MCR p15, 0, r0, c1, c0, 2
ISB
#endif
MOV r3, #0x40000000
VMSR FPEXC, r3
/* r11: delta of physical address and virtual address */
adr r11, pa_va_offset
ldr r0, [r11]
......@@ -156,10 +184,13 @@ reloc_img_to_bottom_loop:
reloc_img_to_bottom_done:
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it */
add r4, r4, r11
bl page_table_clear
mov r0, r4
mov r1, #0
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
bl memset
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
......@@ -169,7 +200,6 @@ reloc_img_to_bottom_done:
add r4, r4, r11
ldr r4, [r4]
add r4, r4, r11 /* r4: jump pagetable paddr */
bl page_table_clear
/* build 1M section mapping, in order to jump va during turing on mmu:pa == pa, va == pa */
mov r6, pc
......@@ -233,20 +263,6 @@ warm_reset:
sub r0, r0, r2
mov sp, r0
/* enable fpu+neon */
#ifndef LOSCFG_TEE_ENABLE
MRC p15, 0, r0, c1, c1, 2
ORR r0, r0, #0xC00
BIC r0, r0, #0xC000
MCR p15, 0, r0, c1, c1, 2
LDR r0, =(0xF << 20)
MCR p15, 0, r0, c1, c0, 2
#endif
MOV r3, #0x40000000
VMSR FPEXC, r3
LDR r0, =__exception_handlers
MCR p15, 0, r0, c12, c0, 0
......@@ -254,14 +270,11 @@ warm_reset:
bne cpu_start
clear_bss:
ldr r1, =__bss_start
ldr r0, =__bss_start
ldr r2, =__bss_end
mov r0, #0
bss_loop:
cmp r1, r2
strlo r0, [r1], #4
blo bss_loop
mov r1, #0
sub r2, r2, r0
bl memset
#if defined(LOSCFG_CC_STACKPROTECTOR_ALL) || \
defined(LOSCFG_CC_STACKPROTECTOR_STRONG) || \
......@@ -371,20 +384,6 @@ sp_set:
mov sp, r2
bx lr /* set sp */
/*
* r4: page table base address
* r5 and r6 will be used as variable
*/
page_table_clear:
mov r5, #0
mov r6, #0
0:
str r5, [r4, r6, lsl #2]
add r6, #1
cmp r6, #0x1000 /* r6 < 4096 */
blt 0b
bx lr
/*
* r4: page table base address
* r6: physical address
......
/*
* 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,7 +53,6 @@
.extern __bss_start
.extern __bss_end
.extern hal_clock_initialize_start
.extern los_bss_init
.extern _osExceptFiqHdl
.extern _osExceptAddrAbortHdl
.extern _osExceptDataAbortHdl
......@@ -119,6 +118,20 @@ reset_vector:
bic r0, #(1<<2 | 1<<0)
mcr p15, 0, r0, c1, c0, 0
/* enable fpu+neon */
#ifndef LOSCFG_TEE_ENABLE
MRC p15, 0, r0, c1, c1, 2
ORR r0, r0, #0xC00
BIC r0, r0, #0xC000
MCR p15, 0, r0, c1, c1, 2
LDR r0, =(0xF << 20)
MCR p15, 0, r0, c1, c0, 2
ISB
#endif
MOV r3, #0x40000000
VMSR FPEXC, r3
/* r11: delta of physical address and virtual address */
adr r11, pa_va_offset
ldr r0, [r11]
......@@ -148,10 +161,14 @@ reloc_img_to_bottom_loop:
reloc_img_to_bottom_done:
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it */
add r4, r4, r11
bl page_table_clear
mov r0, r4
mov r1, #0
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
bl memset
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
......@@ -161,7 +178,6 @@ reloc_img_to_bottom_done:
add r4, r4, r11
ldr r4, [r4]
add r4, r4, r11 /* r4: jump pagetable paddr */
bl page_table_clear
/* build 1M section mapping, in order to jump va during turing on mmu:pa == pa, va == pa */
mov r6, pc
......@@ -246,14 +262,11 @@ warm_reset:
bne cpu_start
clear_bss:
ldr r1, =__bss_start
ldr r0, =__bss_start
ldr r2, =__bss_end
mov r0, #0
bss_loop:
cmp r1, r2
strlo r0, [r1], #4
blo bss_loop
mov r1, #0
sub r2, r2, r0
bl memset
#if defined(LOSCFG_CC_STACKPROTECTOR_ALL) || \
defined(LOSCFG_CC_STACKPROTECTOR_STRONG) || \
......@@ -339,20 +352,6 @@ sp_set:
mov sp, r2
bx lr /* set sp */
/*
* r4: page table base address
* r5 and r6 will be used as variable
*/
page_table_clear:
mov r5, #0
mov r6, #0
0:
str r5, [r4, r6, lsl #2]
add r6, #1
cmp r6, #0x1000 /* r6 < 4096 */
blt 0b
bx lr
/*
* r4: page table base address
* r6: physical address
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
/*
* 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.
*/
/**
* @defgroup los_exc Exception handling
* @ingroup kernel
*/
#ifndef _LOS_EXC_H
#define _LOS_EXC_H
#include "los_typedef.h"
#include "arch_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/**
* @ingroup los_exc
* Register information structure
*
* Description: register information stored when an exception occurs on an LPC2458 platform.
*
* Note: The following register names without uw are the register names used in the chip manual.
*/
#ifdef LOSCFG_ARCH_ARM_AARCH64
#define EXC_GEN_REGS_NUM 30
typedef struct {
UINT64 X[EXC_GEN_REGS_NUM]; /**< Register X0-X29 */
UINT64 LR; /**< Program returning address. X30 */
UINT64 SP;
UINT64 regELR;
UINT64 SPSR;
} ExcContext;
#else
typedef struct {
UINT32 USP; /**< User mode stack pointer */
UINT32 ULR; /**< User mode program returning address */
UINT32 regCPSR; /**< Current program status register (CPSR) */
UINT32 R0; /**< Register R0 */
UINT32 R1; /**< Register R1 */
UINT32 R2; /**< Register R2 */
UINT32 R3; /**< Register R3 */
UINT32 R4; /**< Register R4 */
UINT32 R5; /**< Register R5 */
UINT32 R6; /**< Register R6 */
UINT32 R7; /**< Register R7 */
UINT32 R8; /**< Register R8 */
UINT32 R9; /**< Register R9 */
UINT32 R10; /**< Register R10 */
UINT32 R11; /**< Register R11 */
UINT32 R12; /**< Register R12 */
UINT32 SP; /**< Stack pointer */
UINT32 LR; /**< Program returning address. */
UINT32 PC; /**< PC pointer of the exceptional function */
} ExcContext;
#endif
/**
* @ingroup los_exc
* Exception information structure
*
* Description: exception information stored when an exception occurs on an LPC2458 platform.
*
*/
typedef struct {
UINT16 phase; /**< Phase in which an exception occurs */
UINT16 type; /**< Exception type */
UINT16 nestCnt; /**< Count of nested exception */
UINT16 reserved; /**< Reserved for alignment */
ExcContext *context; /**< Hardware context when an exception occurs */
} ExcInfo;
/**
* @ingroup los_exc
* @brief Kernel FP Register address obtain function.
*
* @par Description:
* The API is used to obtain the FP Register address.
* @attention None.
*
* @param None.
*
* @retval #UINTPTR The FP Register address.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
STATIC INLINE UINTPTR Get_Fp(VOID)
{
UINTPTR regFp;
#ifdef LOSCFG_ARCH_ARM_AARCH64
__asm__ __volatile__("mov %0, X29" : "=r"(regFp));
#else
__asm__ __volatile__("mov %0, fp" : "=r"(regFp));
#endif
return regFp;
}
/**
* @ingroup los_exc
* @brief Define an exception handling function hook.
*
* @par Description:
* This API is used to define the exception handling function hook based on the type of
* the exception handling function and record exceptions.
* @attention None.
*
* @param None.
*
* @retval None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
typedef VOID (*EXC_PROC_FUNC)(UINT32, ExcContext *, UINT32, UINT32);
/**
* @ingroup los_exc
* @brief Register an exception handling hook.
*
* @par Description:
* This API is used to register an exception handling hook.
* @attention If the hook is registered for multiple times, the hook registered at the last time is effective.
* @attention The hook can be registered as NULL, indicating that the hook registration is canceled.
* @param excHook [IN] Type #EXC_PROC_FUNC: hook function.
*
* @retval #LOS_OK The exception handling hook is successfully registered.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
extern UINT32 LOS_ExcRegHook(EXC_PROC_FUNC excHook);
/**
* @ingroup los_exc
* @brief Kernel panic function.
*
* @par Description:
* Stack function that prints kernel panics.
* @attention After this function is called and stack information is printed, the system will fail to respond.
* @attention The input parameter can be NULL.
* @param fmt [IN] Type #CHAR* : variadic argument.
*
* @retval #None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
VOID LOS_Panic(const CHAR *fmt, ...);
/**
* @ingroup los_exc
* @brief Kernel backtrace function.
*
* @par Description:
* Backtrace function that prints task call stack information traced from the running task.
* @attention None.
*
* @param None.
*
* @retval #None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID OsBackTrace(VOID);
/**
* @ingroup los_exc
* @brief Kernel task backtrace function.
*
* @par Description:
* Backtrace function that prints task call stack information traced from the input task.
* @attention
* <ul>
* <li>The input taskID should be valid.</li>
* </ul>
*
* @param taskID [IN] Type #UINT32 Task ID.
*
* @retval #None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID OsTaskBackTrace(UINT32 taskID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_EXC_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.
*/
/**
* @defgroup los_exc Exception handling
* @ingroup kernel
*/
#ifndef _LOS_EXC_H
#define _LOS_EXC_H
#include "los_typedef.h"
#include "arch_config.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/**
* @ingroup los_exc
* Register information structure
*
* Description: register information stored when an exception occurs on an LPC2458 platform.
*
* Note: The following register names without uw are the register names used in the chip manual.
*/
#ifdef LOSCFG_ARCH_ARM_AARCH64
#define EXC_GEN_REGS_NUM 30
typedef struct {
UINT64 X[EXC_GEN_REGS_NUM]; /**< Register X0-X29 */
UINT64 LR; /**< Program returning address. X30 */
UINT64 SP;
UINT64 regELR;
UINT64 SPSR;
} ExcContext;
#else
typedef struct {
UINT32 USP; /**< User mode stack pointer */
UINT32 ULR; /**< User mode program returning address */
UINT32 regCPSR; /**< Current program status register (CPSR) */
UINT32 R0; /**< Register R0 */
UINT32 R1; /**< Register R1 */
UINT32 R2; /**< Register R2 */
UINT32 R3; /**< Register R3 */
UINT32 R4; /**< Register R4 */
UINT32 R5; /**< Register R5 */
UINT32 R6; /**< Register R6 */
UINT32 R7; /**< Register R7 */
UINT32 R8; /**< Register R8 */
UINT32 R9; /**< Register R9 */
UINT32 R10; /**< Register R10 */
UINT32 R11; /**< Register R11 */
UINT32 R12; /**< Register R12 */
UINT32 SP; /**< Stack pointer */
UINT32 LR; /**< Program returning address. */
UINT32 PC; /**< PC pointer of the exceptional function */
} ExcContext;
#endif
/**
* @ingroup los_exc
* Exception information structure
*
* Description: exception information stored when an exception occurs on an LPC2458 platform.
*
*/
typedef struct {
UINT16 phase; /**< Phase in which an exception occurs */
UINT16 type; /**< Exception type */
UINT16 nestCnt; /**< Count of nested exception */
UINT16 reserved; /**< Reserved for alignment */
ExcContext *context; /**< Hardware context when an exception occurs */
} ExcInfo;
/**
* @ingroup los_exc
* @brief Kernel FP Register address obtain function.
*
* @par Description:
* The API is used to obtain the FP Register address.
* @attention None.
*
* @param None.
*
* @retval #UINTPTR The FP Register address.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
STATIC INLINE UINTPTR Get_Fp(VOID)
{
UINTPTR regFp;
#ifdef LOSCFG_ARCH_ARM_AARCH64
__asm__ __volatile__("mov %0, X29" : "=r"(regFp));
#else
__asm__ __volatile__("mov %0, fp" : "=r"(regFp));
#endif
return regFp;
}
/**
* @ingroup los_exc
* @brief Define an exception handling function hook.
*
* @par Description:
* This API is used to define the exception handling function hook based on the type of
* the exception handling function and record exceptions.
* @attention None.
*
* @param None.
*
* @retval None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
typedef VOID (*EXC_PROC_FUNC)(UINT32, ExcContext *, UINT32, UINT32);
/**
* @ingroup los_exc
* @brief Register an exception handling hook.
*
* @par Description:
* This API is used to register an exception handling hook.
* @attention If the hook is registered for multiple times, the hook registered at the last time is effective.
* @attention The hook can be registered as NULL, indicating that the hook registration is canceled.
* @param excHook [IN] Type #EXC_PROC_FUNC: hook function.
*
* @retval #LOS_OK The exception handling hook is successfully registered.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
extern UINT32 LOS_ExcRegHook(EXC_PROC_FUNC excHook);
/**
* @ingroup los_exc
* @brief Kernel panic function.
*
* @par Description:
* Stack function that prints kernel panics.
* @attention After this function is called and stack information is printed, the system will fail to respond.
* @attention The input parameter can be NULL.
* @param fmt [IN] Type #CHAR* : variadic argument.
*
* @retval #None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
VOID LOS_Panic(const CHAR *fmt, ...);
/**
* @ingroup los_exc
* @brief record LR function.
*
* @par Description:
* @attention
* @param LR [IN] Type #UINTPTR * LR buffer.
* @param recordCount [IN] Type UINT32 record LR lay number.
* @param jumpCount [IN] Type UINT32 ignore LR lay number.
*
* @retval #None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCount);
/**
* @ingroup los_exc
* @brief Kernel backtrace function.
*
* @par Description:
* Backtrace function that prints task call stack information traced from the running task.
* @attention None.
*
* @param None.
*
* @retval #None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID OsBackTrace(VOID);
/**
* @ingroup los_exc
* @brief Kernel task backtrace function.
*
* @par Description:
* Backtrace function that prints task call stack information traced from the input task.
* @attention
* <ul>
* <li>The input taskID should be valid.</li>
* </ul>
*
* @param taskID [IN] Type #UINT32 Task ID.
*
* @retval #None.
*
* @par Dependency:
* los_exc.h: the header file that contains the API declaration.
* @see None.
*/
extern VOID OsTaskBackTrace(UINT32 taskID);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_EXC_H */
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
此差异已折叠。
/*
* 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:
......
/*
* 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:
......
/*
* 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:
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册