update openharmony 1.0.1
This commit is contained in:
parent
e351799d39
commit
73a7b66116
|
@ -1,13 +0,0 @@
|
|||
### 该问题是怎么引起的?
|
||||
|
||||
|
||||
|
||||
### 重现步骤
|
||||
|
||||
|
||||
|
||||
### 报错信息
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
### 相关的Issue
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
### 描述(做了什么,变更了什么)
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
/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
|
||||
|
|
|
@ -1,68 +1,82 @@
|
|||
# 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"
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -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"
|
||||
|
@ -278,19 +272,6 @@ config NULL_ADDRESS_PROTECT
|
|||
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"
|
||||
source "../../drivers/adapter/khdf/liteos/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 "../../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
|
||||
|
|
6
LICENSE
6
LICENSE
|
@ -1,5 +1,5 @@
|
|||
Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
@ -25,4 +25,4 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -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,14 +51,33 @@ 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 = vfat
|
||||
FSTYPE = jffs2
|
||||
endif
|
||||
ROOTFS_DIR = $(OUT)/rootfs
|
||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||
|
@ -100,21 +117,14 @@ endif
|
|||
##### make dynload #####
|
||||
-include $(LITEOS_MK_PATH)/dynload.mk
|
||||
|
||||
ifeq ($(findstring y, $(LOSCFG_PLATFORM_HI3518EV300)$(LOSCFG_PLATFORM_HI3516DV300)), y)
|
||||
VENDOR_BOARD_INCLUDE := $(LITEOSTOPDIR)/../../vendor/hisi/hi35xx/$(LITEOS_PLATFORM)/config/board
|
||||
else ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
||||
VENDOR_BOARD_INCLUDE := $(LITEOSTOPDIR)/../../device/qemu/arm/$(LITEOS_PLATFORM)/config/board
|
||||
else
|
||||
$(error "No VENDOR_BOARD_INCLUDE defined")
|
||||
endif
|
||||
#-----need move when make version-----#
|
||||
##### make lib #####
|
||||
$(__LIBS): $(OUT) $(CXX_INCLUDE)
|
||||
|
||||
$(OUT): $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)mkdir -p $(OUT)/lib
|
||||
$(HIDE)$(CC) -I$(LITEOS_PLATFORM_BASE)/include -I$(VENDOR_BOARD_INCLUDE) \
|
||||
-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):
|
||||
|
@ -127,14 +137,10 @@ $(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)
|
||||
|
@ -185,6 +191,7 @@ $(ROOTFS): $(ROOTFSDIR)
|
|||
$(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
|
||||
|
||||
|
@ -193,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
|
||||
|
@ -210,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
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
# 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)**
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
# 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)**
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -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:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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));
|
||||
|
@ -595,10 +606,6 @@ void *ShellEntry(void *argv)
|
|||
}
|
||||
|
||||
while (1) {
|
||||
/* is console ready for shell ? */
|
||||
if (ret != SH_OK)
|
||||
break;
|
||||
|
||||
n = read(0, &ch, 1);
|
||||
if (n == 1) {
|
||||
ShellCmdLineParse(ch, (OutputFunc)printf, shellCB);
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
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
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -29,11 +29,10 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_TFTPC_H
|
||||
#define LWIP_HDR_TFTPC_H
|
||||
#ifndef TFTPC_H
|
||||
#define TFTPC_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "types_adapt.h"
|
||||
|
||||
#if LWIP_TFTP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
|
@ -307,4 +306,4 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
|
|||
|
||||
#endif /* LWIP_TFTP */
|
||||
|
||||
#endif /* LWIP_HDR_TFTPC_H */
|
||||
#endif /* TFTPC_H */
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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 */
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* 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 */
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -31,29 +31,24 @@
|
|||
|
||||
/* TFTP Client utility */
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "tftpc.h"
|
||||
|
||||
#if LWIP_TFTP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/sockets.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/tftpc.h"
|
||||
#include "fcntl.h"
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <securec.h>
|
||||
|
||||
/* Function Declarations */
|
||||
#ifdef LOSCFG_NET_LWIP_SACK_TFTP
|
||||
|
@ -1088,7 +1083,6 @@ u32_t lwip_tftp_put_file_by_filename(u32_t ulHostAddr, u16_t usTftpServPort, u8_
|
|||
&stServerAddr, pstSendBuf);
|
||||
|
||||
(void)lwip_close(iSockNum);
|
||||
close(fp);
|
||||
mem_free(pucBuffer);
|
||||
|
||||
ulErrCode = TFTPC_FILEOPEN_ERROR;
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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 \
|
||||
|
@ -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 | \
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
switch (flags & (VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_WRITE)) {
|
||||
STATIC UINT32 OsCvtSecAccessFlagsToMMUFlags(UINT32 flags)
|
||||
{
|
||||
UINT32 mmuFlags = 0;
|
||||
|
||||
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_WRITE:
|
||||
mmuFlags |= MMU_DESCRIPTOR_L1_AP_P_RW_U_NA;
|
||||
break;
|
||||
case VM_MAP_REGION_FLAG_PERM_USER:
|
||||
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 | 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;
|
||||
}
|
||||
|
||||
switch (flags & (VM_MAP_REGION_FLAG_PERM_USER | VM_MAP_REGION_FLAG_PERM_WRITE)) {
|
||||
STATIC UINT32 OsCvtPte2AccessFlagsToMMUFlags(UINT32 flags)
|
||||
{
|
||||
UINT32 mmuFlags = 0;
|
||||
|
||||
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_WRITE:
|
||||
mmuFlags |= MMU_DESCRIPTOR_L2_AP_P_RW_U_NA;
|
||||
break;
|
||||
case VM_MAP_REGION_FLAG_PERM_USER:
|
||||
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 | 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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -32,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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -341,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)
|
||||
|
@ -422,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;
|
||||
}
|
||||
|
@ -544,6 +544,7 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
|||
OsProcessExitCodeCoreDumpSet(runProcess);
|
||||
#endif
|
||||
OsProcessExitCodeSignalSet(runProcess, SIGUSR2);
|
||||
|
||||
/* kill user exc process */
|
||||
LOS_Exit(OS_PRO_EXIT_OK);
|
||||
|
||||
|
@ -784,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);
|
||||
}
|
||||
|
||||
|
@ -1005,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");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1021,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();
|
||||
|
@ -1070,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) {}
|
||||
}
|
||||
|
||||
|
@ -1092,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
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -53,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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,233 +1,251 @@
|
|||
/*
|
||||
* 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 */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -339,6 +339,23 @@ STATIC INLINE VOID LOS_IntRestore(UINT32 intSave)
|
|||
ArchIntRestore(intSave);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Gets the maximum number of interrupts supported by the system.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to gets the maximum number of interrupts supported by the system.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval None.
|
||||
* @par Dependency:
|
||||
* <ul><li>los_hwi.h: the header file that contains the API declaration.</li></ul>
|
||||
*/
|
||||
extern UINT32 LOS_GetSystemHwiMaximum(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hwi
|
||||
* @brief Create a hardware interrupt.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -28,6 +28,7 @@
|
|||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
include $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/lite.mk
|
||||
|
||||
MODULE_NAME := usb_base
|
||||
|
||||
|
@ -120,12 +121,20 @@ ifeq ($(LOSCFG_DRIVERS_USB_MASS_STORAGE), y)
|
|||
LOCAL_SRCS += $(STORAGE_SRC)/umass.c
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_USB_HID_CLASS), y)
|
||||
ifeq ($(LOSCFG_DRIVERS_USB_HID_CLASS)_$(LOSCFG_DRIVERS_HDF_INPUT), y_y)
|
||||
LOCAL_FLAGS += -I$(LITEOSTOPDIR)/../../drivers/framework/model/input/driver \
|
||||
-I$(LITEOSTOPDIR)/../../drivers/framework/include/core \
|
||||
-I$(LITEOSTOPDIR)/../../drivers/framework/core/common/include/host \
|
||||
-I$(LITEOSTOPDIR)/../../drivers/framework/utils \
|
||||
-I$(LITEOSTOPDIR)/../../drivers/framework/osal \
|
||||
-I$(LITEOSTOPDIR)/../../drivers/framework/ability/sbuf/include \
|
||||
-I$(LITEOSTOPDIR)/../../drivers/framework/include/osal \
|
||||
-I$(LITEOSTOPDIR)/../../third_party/FreeBSD/sys/dev/evdev
|
||||
|
||||
LOCAL_SRCS += $(INPUT_SRC)/uhid.c \
|
||||
$(CORE_SRC)/usb_hid.c
|
||||
endif
|
||||
|
||||
LOCAL_FLAGS += $(LITEOS_GCOV_OPTS)
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
include $(HDF_DRIVER)
|
||||
|
|
30
build.sh
30
build.sh
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
@ -30,20 +30,26 @@
|
|||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
set -e
|
||||
|
||||
echo "sh param:$1,$2,$3"
|
||||
source="tools/build/config/$1_release.config"
|
||||
echo "sh param:$1,$2,$3,$4,$5,$6,$7"
|
||||
destination=".config"
|
||||
tee=""
|
||||
outdir="../..$3/test_info/gen/kernel/test"
|
||||
if [ "$5" = "tee" ]; then
|
||||
tee="_tee"
|
||||
fi
|
||||
productName="$(basename $7)"
|
||||
source="tools/build/config/${productName}_release.config"
|
||||
if [ "$2" = "clang" ]; then
|
||||
if [ "$3" = "debug" ]; then
|
||||
source="tools/build/config/debug/$1_$2.config"
|
||||
if [ "$4" = "debug" ]; then
|
||||
source="tools/build/config/debug/${productName}_$2$tee.config"
|
||||
else
|
||||
source="tools/build/config/$1_$2_release.config"
|
||||
source="tools/build/config/${productName}_$2_release$tee.config"
|
||||
fi
|
||||
elif [ "$2" = "gcc" ]; then
|
||||
if [ "$3" = "debug" ]; then
|
||||
source="tools/build/config/$1_debug_shell.config"
|
||||
if [ "$4" = "debug" ]; then
|
||||
source="tools/build/config/${productName}_debug_shell$tee.config"
|
||||
else
|
||||
source="tools/build/config/$1_release.config"
|
||||
source="tools/build/config/${productName}_release$tee.config"
|
||||
fi
|
||||
fi
|
||||
if [ -d "./out" ]; then
|
||||
|
@ -53,3 +59,7 @@ if [ -f "$destination" ]; then
|
|||
rm -rf $destination
|
||||
fi
|
||||
cp $source $destination
|
||||
|
||||
mkdir -p $outdir
|
||||
cp kernel_test.sources $outdir
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -43,6 +43,9 @@
|
|||
#include "limits.h"
|
||||
#include "los_typedef.h"
|
||||
#include "time.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "los_queue_pri.h"
|
||||
|
||||
|
@ -71,11 +74,23 @@ extern "C" {
|
|||
/* not suppurt prio */
|
||||
#define MQ_PRIO_MAX 1
|
||||
|
||||
typedef union send_receive_t {
|
||||
unsigned oth : 3;
|
||||
unsigned grp : 6;
|
||||
unsigned usr : 9;
|
||||
short data;
|
||||
} mode_s;
|
||||
|
||||
/* TYPE DEFINITIONS */
|
||||
struct mqarray {
|
||||
UINT32 mq_id : 31;
|
||||
UINT32 unlinkflag : 1;
|
||||
char *mq_name;
|
||||
UINT32 unlink_ref;
|
||||
mode_s mode_data; /* mode data of mqueue */
|
||||
uid_t euid; /* euid of mqueue */
|
||||
gid_t egid; /* egid of mqueue */
|
||||
fd_set mq_fdset; /* mqueue sysFd bit map */
|
||||
LosQueueCB *mqcb;
|
||||
struct mqpersonal *mq_personal;
|
||||
};
|
||||
|
@ -84,7 +99,9 @@ struct mqpersonal {
|
|||
struct mqarray *mq_posixdes;
|
||||
struct mqpersonal *mq_next;
|
||||
int mq_flags;
|
||||
int mq_mode; /* Mode of mqueue */
|
||||
UINT32 mq_status;
|
||||
UINT32 mq_refcount;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -400,6 +417,8 @@ extern int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen,
|
|||
extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
|
||||
unsigned int *msgPrio, const struct timespec *absTimeout);
|
||||
|
||||
extern void mqueue_refer(int sysFd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -36,6 +36,8 @@
|
|||
#include "time_posix.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_vm_map.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "fs_file.h"
|
||||
#include "user_copy.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -46,9 +48,14 @@ extern "C" {
|
|||
|
||||
#define FNONBLOCK O_NONBLOCK
|
||||
|
||||
#ifndef MAX_MQ_FD
|
||||
#define MAX_MQ_FD CONFIG_NQUEUE_DESCRIPTORS
|
||||
#endif
|
||||
|
||||
/* GLOBALS */
|
||||
STATIC struct mqarray g_queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT];
|
||||
STATIC pthread_mutex_t g_mqueueMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||
STATIC struct mqpersonal *g_mqPrivBuf[MAX_MQ_FD];
|
||||
|
||||
/* LOCAL FUNCTIONS */
|
||||
STATIC INLINE INT32 MqNameCheck(const CHAR *mqName)
|
||||
|
@ -100,7 +107,6 @@ STATIC INLINE struct mqarray *GetMqueueCBByName(const CHAR *name)
|
|||
return &(g_queueTable[index]);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -114,6 +120,10 @@ STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
|
|||
}
|
||||
|
||||
mqueueCB->mqcb = NULL;
|
||||
/* When mqueue-list head node needed free ,reset the mode_data */
|
||||
mqueueCB->mode_data.data = 0;
|
||||
mqueueCB->euid = -1;
|
||||
mqueueCB->egid = -1;
|
||||
|
||||
ret = LOS_QueueDelete(mqueueCB->mq_id);
|
||||
switch (ret) {
|
||||
|
@ -152,7 +162,7 @@ STATIC int SaveMqueueName(const CHAR *mqName, struct mqarray *mqueueCB)
|
|||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR *mqName, INT32 openFlag)
|
||||
STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR *mqName, INT32 openFlag, UINT32 mode)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
UINT32 mqueueID;
|
||||
|
@ -191,10 +201,13 @@ STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR
|
|||
}
|
||||
|
||||
mqueueCB->unlinkflag = FALSE;
|
||||
mqueueCB->unlink_ref = 0;
|
||||
mqueueCB->mq_personal->mq_status = MQ_USE_MAGIC;
|
||||
mqueueCB->mq_personal->mq_next = NULL;
|
||||
mqueueCB->mq_personal->mq_posixdes = mqueueCB;
|
||||
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
|
||||
mqueueCB->mq_personal->mq_mode = mode;
|
||||
mqueueCB->mq_personal->mq_refcount = 0;
|
||||
|
||||
return mqueueCB->mq_personal;
|
||||
ERROUT:
|
||||
|
@ -228,6 +241,7 @@ STATIC struct mqpersonal *DoMqueueOpen(struct mqarray *mqueueCB, INT32 openFlag)
|
|||
privateMqPersonal->mq_posixdes = mqueueCB;
|
||||
privateMqPersonal->mq_flags = openFlag;
|
||||
privateMqPersonal->mq_status = MQ_USE_MAGIC;
|
||||
privateMqPersonal->mq_refcount = 0;
|
||||
|
||||
return privateMqPersonal;
|
||||
|
||||
|
@ -235,14 +249,226 @@ ERROUT:
|
|||
return (struct mqpersonal *)-1;
|
||||
}
|
||||
|
||||
/* Translate a sysFd into privateMqPersonal */
|
||||
STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
|
||||
{
|
||||
INT32 sysFd = (INT32)personal;
|
||||
INT32 id = sysFd - MQUEUE_FD_OFFSET;
|
||||
|
||||
/* Filter illegal id */
|
||||
if ((id < 0) || (id >= MAX_MQ_FD)) {
|
||||
errno = EBADF;
|
||||
return NULL;
|
||||
}
|
||||
return g_mqPrivBuf[id];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alloc sysFd, storage mq private data, set using bit.
|
||||
*
|
||||
* @param maxfdp: Maximum allowed application of mqueue sysFd.
|
||||
* @param fdset: Mqueue sysFd bit map.
|
||||
* @param privateMqPersonal: Private data.
|
||||
* @return the index of the new fd; -1 on error
|
||||
*/
|
||||
STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
|
||||
{
|
||||
INT32 i;
|
||||
struct mqarray *mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
fd_set *fdset = &mqueueCB->mq_fdset;
|
||||
for (i = 0; i < maxfdp; i++) {
|
||||
/* sysFd: used bit setting, and get the index of swtmrID buffer */
|
||||
if (!(fdset && FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
|
||||
FD_SET(i + MQUEUE_FD_OFFSET, fdset);
|
||||
if (!g_mqPrivBuf[i]) {
|
||||
g_mqPrivBuf[i] = mqueueCB->mq_personal;
|
||||
return i + MQUEUE_FD_OFFSET;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* there are no more mq sysFd to use, free the personal */
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
|
||||
privateMqPersonal = NULL;
|
||||
mqueueCB->mq_personal = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
STATIC VOID MqFreeSysFd(struct mqarray *mqueueCB, mqd_t personal)
|
||||
{
|
||||
INT32 sysFd = (INT32)personal;
|
||||
fd_set *fdset = &mqueueCB->mq_fdset;
|
||||
if (fdset && FD_ISSET(sysFd, fdset)) {
|
||||
FD_CLR(sysFd, fdset);
|
||||
g_mqPrivBuf[sysFd - MQUEUE_FD_OFFSET] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Mqueue fd reference count */
|
||||
void mqueue_refer(int sysFd)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
/* Get the personal sysFd and reset personal fd -1 */
|
||||
privateMqPersonal = MqGetPrivDataBuff((mqd_t)sysFd);
|
||||
if (privateMqPersonal == NULL) {
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
if (mqueueCB == NULL) {
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
privateMqPersonal->mq_refcount++;
|
||||
mqueueCB->unlink_ref++;
|
||||
OUT_UNLOCK:
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
}
|
||||
|
||||
STATIC INT32 MqTryClose(struct mqpersonal *privateMqPersonal)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
if (mqueueCB == NULL) {
|
||||
errno = ENFILE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (privateMqPersonal->mq_refcount == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
privateMqPersonal->mq_refcount--;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INT32 MqTryUnlink(struct mqarray *mqueueCB)
|
||||
{
|
||||
if (mqueueCB->unlink_ref == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
mqueueCB->unlink_ref--;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Set the mode data bit,for consumer's mode comparing. */
|
||||
STATIC INT32 MqueueModeAnalysisSet(struct mqpersonal *privateMqPersonal)
|
||||
{
|
||||
UINT32 mode;
|
||||
UINT32 intSave;
|
||||
User *user = NULL;
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
|
||||
if ((INT32)(UINTPTR)privateMqPersonal < 0) {
|
||||
return -1;
|
||||
}
|
||||
/* Get mqueueCB of first time creating mqueue */
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
if (mqueueCB == NULL) {
|
||||
errno = ENFILE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
mode = mqueueCB->mq_personal->mq_mode;
|
||||
/* Set mqueue gid uid */
|
||||
SCHEDULER_LOCK(intSave);
|
||||
user = OsCurrUserGet();
|
||||
mqueueCB->euid = user->effUserID;
|
||||
mqueueCB->egid = user->effGid;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
/* Set mode data bit */
|
||||
if (mode & S_IRUSR) {
|
||||
mqueueCB->mode_data.usr |= S_IRUSR;
|
||||
}
|
||||
if (mode & S_IWUSR) {
|
||||
mqueueCB->mode_data.usr |= S_IWUSR;
|
||||
}
|
||||
if (mode & S_IRGRP) {
|
||||
mqueueCB->mode_data.grp |= S_IRGRP;
|
||||
}
|
||||
if (mode & S_IWGRP) {
|
||||
mqueueCB->mode_data.grp |= S_IWGRP;
|
||||
}
|
||||
if (mode & S_IROTH) {
|
||||
mqueueCB->mode_data.oth |= S_IROTH;
|
||||
}
|
||||
if (mode & S_IWOTH) {
|
||||
mqueueCB->mode_data.oth |= S_IWOTH;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC INT32 GetPermissionOfVisitor(struct mqarray *mqueueCB)
|
||||
{
|
||||
uid_t euid;
|
||||
gid_t egid;
|
||||
UINT32 intSave;
|
||||
User *user = NULL;
|
||||
|
||||
if (mqueueCB == NULL) {
|
||||
errno = ENOENT;
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
/* Get the visitor process euid and egid */
|
||||
SCHEDULER_LOCK(intSave);
|
||||
user = OsCurrUserGet();
|
||||
euid = user->effUserID;
|
||||
egid = user->effGid;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
/* root */
|
||||
if (euid == 0) {
|
||||
return ENOERR;
|
||||
}
|
||||
if (euid == mqueueCB->euid) { /* usr */
|
||||
if (!((mqueueCB->mode_data.usr & S_IRUSR) || (mqueueCB->mode_data.usr & S_IWUSR))) {
|
||||
errno = EACCES;
|
||||
goto ERR_OUT;
|
||||
}
|
||||
} else if (egid == mqueueCB->egid) { /* grp */
|
||||
if (!((mqueueCB->mode_data.grp & S_IRGRP) || (mqueueCB->mode_data.grp & S_IWGRP))) {
|
||||
errno = EACCES;
|
||||
goto ERR_OUT;
|
||||
}
|
||||
} else { /* oth */
|
||||
if (!((mqueueCB->mode_data.oth & S_IROTH) || (mqueueCB->mode_data.oth & S_IWOTH))) {
|
||||
errno = EACCES;
|
||||
goto ERR_OUT;
|
||||
}
|
||||
}
|
||||
return ENOERR;
|
||||
|
||||
ERR_OUT:
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
STATIC INT32 GetMqueueAttr(struct mq_attr *defaultAttr, struct mq_attr *attr)
|
||||
{
|
||||
if (attr != NULL) {
|
||||
if (LOS_ArchCopyFromUser(defaultAttr, attr, sizeof(struct mq_attr))) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
if ((defaultAttr->mq_maxmsg < 0) || (defaultAttr->mq_maxmsg > (long int)USHRT_MAX) ||
|
||||
(defaultAttr->mq_msgsize < 0) || (defaultAttr->mq_msgsize > (long int)(USHRT_MAX - sizeof(UINT32)))) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
mqd_t mq_open(const char *mqName, int openFlag, ...)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = (struct mqpersonal *)-1;
|
||||
struct mq_attr *attr = NULL;
|
||||
struct mq_attr defaultAttr = { 0, MQ_MAX_MSG_NUM, MQ_MAX_MSG_LEN, 0 };
|
||||
int retVal;
|
||||
va_list ap;
|
||||
int sysFd;
|
||||
mqd_t mqFd = -1;
|
||||
unsigned int mode = 0;
|
||||
|
||||
if (MqNameCheck(mqName) == -1) {
|
||||
return (mqd_t)-1;
|
||||
|
@ -259,56 +485,62 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
|
|||
privateMqPersonal = DoMqueueOpen(mqueueCB, openFlag);
|
||||
} else {
|
||||
va_start(ap, openFlag);
|
||||
(VOID)va_arg(ap, int);
|
||||
mode = va_arg(ap, unsigned int);
|
||||
attr = va_arg(ap, struct mq_attr *);
|
||||
va_end(ap);
|
||||
|
||||
if (attr != NULL) {
|
||||
retVal = LOS_ArchCopyFromUser(&defaultAttr, attr, sizeof(struct mq_attr));
|
||||
if (retVal != 0) {
|
||||
errno = EFAULT;
|
||||
goto OUT;
|
||||
}
|
||||
if ((defaultAttr.mq_maxmsg < 0) || (defaultAttr.mq_maxmsg > (long int)USHRT_MAX) ||
|
||||
(defaultAttr.mq_msgsize < 0) || (defaultAttr.mq_msgsize > (long int)(USHRT_MAX - sizeof(UINT32)))) {
|
||||
errno = EINVAL;
|
||||
goto OUT;
|
||||
}
|
||||
if (GetMqueueAttr(&defaultAttr, attr)) {
|
||||
goto OUT;
|
||||
}
|
||||
privateMqPersonal = DoMqueueCreate(&defaultAttr, mqName, openFlag);
|
||||
privateMqPersonal = DoMqueueCreate(&defaultAttr, mqName, openFlag, mode);
|
||||
}
|
||||
/* Set mode data bit ,just for the first node */
|
||||
if (MqueueModeAnalysisSet(privateMqPersonal)) {
|
||||
goto OUT;
|
||||
}
|
||||
} else {
|
||||
if (mqueueCB == NULL) {
|
||||
errno = ENOENT;
|
||||
if (GetPermissionOfVisitor(mqueueCB)) {
|
||||
goto OUT;
|
||||
}
|
||||
privateMqPersonal = DoMqueueOpen(mqueueCB, openFlag);
|
||||
}
|
||||
|
||||
OUT:
|
||||
if ((INT32)(UINTPTR)privateMqPersonal > 0) {
|
||||
/* alloc sysFd */
|
||||
sysFd = MqAllocSysFd(MAX_MQ_FD, privateMqPersonal);
|
||||
if (sysFd == -1) {
|
||||
errno = ENFILE;
|
||||
}
|
||||
mqFd = (mqd_t)sysFd;
|
||||
}
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
return (mqd_t)privateMqPersonal;
|
||||
return mqFd;
|
||||
}
|
||||
|
||||
int mq_close(mqd_t personal)
|
||||
{
|
||||
INT32 ret = 0;
|
||||
INT32 ret = -1;
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
struct mqpersonal *tmp = NULL;
|
||||
|
||||
if (!LOS_IsKernelAddressRange(personal, sizeof(struct mqpersonal))) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
|
||||
/* Get the personal sysFd and reset personal fd -1 */
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = (struct mqpersonal *)personal;
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
|
||||
/* there have other thread used the fd */
|
||||
if (!MqTryClose(privateMqPersonal)) {
|
||||
ret = 0;
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
if (mqueueCB->mq_personal == NULL) {
|
||||
errno = EBADF;
|
||||
|
@ -332,6 +564,7 @@ int mq_close(mqd_t personal)
|
|||
}
|
||||
/* flag no use */
|
||||
privateMqPersonal->mq_status = 0;
|
||||
MqFreeSysFd(mqueueCB, personal);
|
||||
|
||||
/* free the personal */
|
||||
ret = LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
|
||||
|
@ -354,8 +587,8 @@ int OsMqGetAttr(mqd_t personal, struct mq_attr *mqAttr)
|
|||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
|
||||
if (!LOS_IsKernelAddressRange(personal, sizeof(struct mqpersonal))) {
|
||||
errno = EBADF;
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -365,7 +598,6 @@ int OsMqGetAttr(mqd_t personal, struct mq_attr *mqAttr)
|
|||
}
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = (struct mqpersonal *)personal;
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
|
@ -385,8 +617,8 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
|
|||
{
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
|
||||
if (!LOS_IsKernelAddressRange(personal, sizeof(struct mqpersonal))) {
|
||||
errno = EBADF;
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -396,7 +628,6 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
|
|||
}
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = (struct mqpersonal *)personal;
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
|
@ -404,7 +635,7 @@ int OsMqSetAttr(mqd_t personal, const struct mq_attr *mqSetAttr, struct mq_attr
|
|||
}
|
||||
|
||||
if (mqOldAttr != NULL) {
|
||||
(VOID)OsMqGetAttr((mqd_t)privateMqPersonal, mqOldAttr);
|
||||
(VOID)OsMqGetAttr(personal, mqOldAttr);
|
||||
}
|
||||
|
||||
privateMqPersonal->mq_flags = (INT32)((UINT32)privateMqPersonal->mq_flags & (UINT32)(~FNONBLOCK)); /* clear */
|
||||
|
@ -438,10 +669,13 @@ int mq_unlink(const char *mqName)
|
|||
errno = ENOENT;
|
||||
goto ERROUT_UNLOCK;
|
||||
}
|
||||
|
||||
if (!MqTryUnlink(mqueueCB)) {
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
return 0;
|
||||
}
|
||||
if (mqueueCB->mq_personal != NULL) {
|
||||
mqueueCB->unlinkflag = TRUE;
|
||||
} else {
|
||||
} else if (mqueueCB->unlink_ref == 0) {
|
||||
ret = DoMqueueDelete(mqueueCB);
|
||||
}
|
||||
|
||||
|
@ -476,8 +710,7 @@ STATIC INT32 ConvertTimeout(long flags, const struct timespec *absTimeout, UINT6
|
|||
|
||||
STATIC INLINE BOOL MqParamCheck(mqd_t personal, const char *msg, size_t msgLen)
|
||||
{
|
||||
if (!LOS_IsKernelAddressRange(personal, sizeof(struct mqpersonal))) {
|
||||
errno = EBADF;
|
||||
if (personal < 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -507,11 +740,14 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
|
|||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
|
||||
OS_MQ_GOTO_ERROUT_IF(!MqParamCheck(personal, msg, msgLen), errno);
|
||||
|
||||
OS_MQ_GOTO_ERROUT_IF(msgPrio > (MQ_PRIO_MAX - 1), EINVAL);
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = (struct mqpersonal *)personal;
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
goto ERROUT_UNLOCK;
|
||||
}
|
||||
|
||||
OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
|
||||
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
|
@ -554,7 +790,10 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
|
|||
}
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = (struct mqpersonal *)personal;
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
goto ERROUT_UNLOCK;
|
||||
}
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
goto ERROUT_UNLOCK;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2019, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020, Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
|
@ -36,6 +36,7 @@
|
|||
#include "stdio.h"
|
||||
#include "map_error.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue