Merge branch 'master' of gitee.com:openharmony/kernel_liteos_a into misc

This commit is contained in:
wcc 2021-07-27 01:40:59 +00:00 committed by Gitee
commit 09d5bcc22d
648 changed files with 8430 additions and 2078 deletions

6
.gitignore vendored
View File

@ -16,9 +16,9 @@ cscope*
tags
# Menuconfig temp files
/include/config
/include/generated
.config*
/config.h
.config
.config.old
# Build temp files
/platform/board.ld

343
BUILD.gn
View File

@ -28,57 +28,330 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/subsystem/lite_subsystem.gni")
declare_args() {
tee_enable = false
}
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
tee = ""
if (tee_enable) {
tee = "_tee"
}
productName = get_path_info(product_path, "file")
config_file = "${productName}_release.config"
if (ohos_build_compiler == "clang") {
if (ohos_build_type == "debug") {
config_file = "debug/${productName}_${ohos_build_compiler}${tee}.config"
} else {
config_file = "${productName}_${ohos_build_compiler}_release${tee}.config"
}
} else if (ohos_build_compiler == "gcc") {
if (ohos_build_type == "debug") {
config_file = "${productName}_debug_shell${tee}.config"
} else {
config_file = "${productName}_release${tee}.config"
}
}
liteos_config_file = rebase_path("tools/build/config/$config_file")
# we prefer use product specified config file
f = "$product_path/config/${ohos_build_type}${tee}.config"
if (exec_script("//build/lite/run_shell_cmd.py", [ "if [ -f $f ]; then echo true; else echo false; fi" ], "value")) {
liteos_config_file = f
}
print("liteos_config_file:", liteos_config_file)
exec_script("//build/lite/run_shell_cmd.py", [ "which genconfig || pip install --user kconfiglib" ])
exec_script("//build/lite/run_shell_cmd.py",
[
"env" +
" CONFIG_=LOSCFG_" +
" KCONFIG_CONFIG_HEADER='y=true'" +
" KCONFIG_CONFIG=$liteos_config_file" +
" DEVICE_PATH=$device_path" +
" srctree=" + rebase_path(".") +
" genconfig" +
" --header-path $LITEOS_MENUCONFIG_H" +
" --file-list kconfig_files.txt" +
" --env-list kconfig_env.txt" +
" --config-out config.gni",
])
import("liteos.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",
"$LITEOSTHIRDPARTY/FreeBSD",
"$LITEOSTHIRDPARTY/musl",
"$LITEOSTHIRDPARTY/zlib",
"$LITEOSTHIRDPARTY/FatFs",
"$LITEOSTHIRDPARTY/Linux_Kernel",
"$LITEOSTHIRDPARTY/lwip",
"$LITEOSTHIRDPARTY/NuttX",
"$LITEOSTHIRDPARTY/mtd-utils",
]
}
declare_args() {
enable_ohos_kernel_liteos_a_ext_build = true
LOSCFG_TEST_APPS = false
tee_enable = ""
liteos_arch_cflags = []
if (defined(LOSCFG_ARCH_ARM)) {
mcpu = LOSCFG_ARCH_CPU
if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) {
mcpu += "+nofp"
}
liteos_arch_cflags += [ "-mcpu=$mcpu" ]
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
liteos_arch_cflags += [
"-mfloat-abi=softfp",
"-mfpu=$LOSCFG_ARCH_FPU",
]
}
}
lite_subsystem("kernel") {
subsystem_components = []
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
if (ohos_build_compiler == "clang") {
cc += " --target=$target_triple"
}
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" ]
deps += [ "//kernel/liteos_a/testsuites/unittest:unittest" ]
config("arch_config") {
cflags = liteos_arch_cflags
asmflags = cflags
ldflags = cflags
}
config("as_objs_libc_flags") {
defines = [ "__ASSEMBLY__" ]
# linux style macros
if (defined(LOSCFG_ARCH_ARM_V7A) || defined(LOSCFG_ARCH_ARM_V7R) ||
defined(LOSCFG_ARCH_ARM_V7M)) {
defines += [ "__LINUX_ARM_ARCH__=7" ]
} else if (defined(LOSCFG_ARCH_ARM_V8A) || defined(LOSCFG_ARCH_ARM_V8R) ||
defined(LOSCFG_ARCH_ARM_V8M)) {
defines += [ "__LINUX_ARM_ARCH__=8" ]
}
}
config("std_include") {
std_include = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-file-name=include" ], "trim string")
include_dirs = [ std_include ]
}
config("public") {
configs = [
"arch:public",
"platform:public",
"kernel:public",
"compat:public",
"bsd:public",
"fs:public",
"drivers:public",
"security:public",
"net:public",
"shell:public",
"lib:public",
":std_include",
]
}
config("los_nostdinc") {
cflags = [ "-nostdinc" ]
}
config("los_nostdlib") {
ldflags = [ "-nostdlib" ]
}
config("los_common") {
cflags = [
"-imacros",
"$LITEOS_MENUCONFIG_H",
]
defines = [ "__LITEOS__" ]
cflags_c = [ "-std=c99" ]
cflags += [
"-fno-pic",
"-fno-builtin",
"-Wall",
"-Werror",
"-fms-extensions",
"-Wno-address-of-packed-member",
"-fno-strict-aliasing",
"-fno-common",
"-fsigned-char",
"-Wpointer-arith",
"-Wstrict-prototypes",
"-Winvalid-pch",
"-ffunction-sections",
"-fdata-sections",
"-fno-exceptions",
"-fno-omit-frame-pointer",
"-fno-short-enums",
]
if (defined(LOSCFG_QUICK_START)) {
cflags -= [ "-Werror" ]
}
if (defined(LOSCFG_COMPILE_DEBUG)) {
cflags += [
"-O0",
"-g",
"-gdwarf-2",
]
} else {
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Oz",
"-flto",
]
} else {
cflags += [ "-O2" ]
}
}
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
cflags += [ "-fstack-protector-all" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
cflags += [ "-fstack-protector-strong" ]
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
cflags += [
"-fstack-protector",
"--param",
"ssp-buffer-size=4",
]
} else {
cflags += [ "-fno-stack-protector" ]
}
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [ "-fno-aggressive-loop-optimizations" ]
if (!defined(LOSCFG_ARCH_ARM_AARCH64)) {
cflags += [
"-mno-unaligned-access",
"-mthumb-interwork",
]
}
}
if (defined(LOSCFG_THUMB)) {
cflags += [
"-mthumb",
"-Wa,-mimplicit-it=thumb",
]
}
asmflags = cflags
}
config("los_config") {
configs = [
":los_common",
":arch_config",
":los_nostdinc",
":los_nostdlib",
]
}
liteos_name = "liteos2"
liteos_out = rebase_path("$target_out_dir/$liteos_name")
executable(liteos_name) {
configs = [] # clear default configs
configs += [ ":los_config" ]
ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=" + rebase_path("$liteos_out.map"),
"-Wl,--no-eh-frame-hdr",
"-Wl,--whole-archive",
]
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
libs = [ libgcc ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
} else {
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
ldflags += [ "-nostartfiles" ]
}
output_dir = target_out_dir
deps = [
":modules",
]
}
build_ext_component("build_liteos_bin") {
deps = [ ":$liteos_name" ]
exec_path = rebase_path(target_out_dir)
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
liteos = rebase_path("$target_out_dir/unstripped/bin/$liteos_name")
command = "$objcopy -O binary $liteos $liteos_out.bin"
command += " && sh -c '$objdump -t $liteos | sort >$liteos_out.sym.sorted'"
command += " && sh -c '$objdump -d $liteos >$liteos_out.asm'"
}
group("modules") {
deps = [
"arch",
"bsd",
"compat",
"drivers",
"fs",
"kernel",
"lib",
"net",
"platform",
"security",
"shell",
"syscall",
]
}
group("apps") {
deps = [ "apps" ]
}
group("tests") {
deps = [ "testsuites" ]
}
group("kernel") {
deps = [
":make",
":tests",
]
}
group("liteos_a") {
deps = [
":apps",
":kernel",
":tests",
]
}
build_ext_component("make") {
exec_path = rebase_path(".", root_build_dir)
tee_enable = "false"
if (board_name == "hi3516dv300" && enable_tee_ree) {
tee_enable = "tee"
}
outdir = rebase_path(get_path_info(".", "out_dir"))
sysroot_path = rebase_path(ohos_current_sysroot)
arch_cflags = string_join(" ", target_arch_cflags)
command = "./build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\" $outdir \"${ohos_version}\" ${sysroot_path} \"${arch_cflags}\""
command = "./build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} \"${tee_enable}\""
command += " \"${device_company}\" \"${product_path}\" $outdir \"${ohos_version}\" ${sysroot_path} \"${arch_cflags}\""
command += " \"${device_path}\""
}

63
Kconfig
View File

@ -52,15 +52,19 @@ endmenu
menu "Platform"
######################### config options of bsp #####################
source "../../kernel/liteos_a/platform/Kconfig"
source "platform/Kconfig"
######################### config options of cpu arch ################
source "../../kernel/liteos_a/arch/Kconfig"
source "arch/Kconfig"
######################### config options of rootfs #####################
source "../../kernel/liteos_a/kernel/common/Kconfig"
source "kernel/common/rootfs/Kconfig"
######################### config options of patchfs #####################
source "../../kernel/liteos_a/kernel/common/patchfs/Kconfig"
source "kernel/common/patchfs/Kconfig"
######################### config options of blackbox #####################
source "kernel/common/blackbox/Kconfig"
######################### config options of hidumper #####################
source "kernel/common/hidumper/Kconfig"
config QUICK_START
bool "Enable QUICK_START"
@ -71,27 +75,25 @@ config QUICK_START
endmenu
######################### config options of kernel #####################
source "../../kernel/liteos_a/kernel/Kconfig"
source "kernel/Kconfig"
######################### config options of lib ########################
source "../../kernel/liteos_a/lib/Kconfig"
source "lib/Kconfig"
######################### config options of compatibility ##############
menu "Compat"
source "../../kernel/liteos_a/compat/posix/Kconfig"
source "../../kernel/liteos_a/bsd/Kconfig"
source "compat/posix/Kconfig"
source "bsd/Kconfig"
endmenu
######################### config options of framework ##################
#source "../../frameworks/m2mcomm/Kconfig"
######################## config options of filesystem ##################
menu "FileSystem"
source "../../kernel/liteos_a/fs/vfs/Kconfig"
source "../../kernel/liteos_a/fs/fat/Kconfig"
source "../../kernel/liteos_a/fs/ramfs/Kconfig"
source "../../kernel/liteos_a/fs/romfs/Kconfig"
source "../../kernel/liteos_a/fs/nfs/Kconfig"
source "../../kernel/liteos_a/fs/proc/Kconfig"
source "../../kernel/liteos_a/fs/jffs2/Kconfig"
source "fs/vfs/Kconfig"
source "fs/fat/Kconfig"
source "fs/ramfs/Kconfig"
source "fs/romfs/Kconfig"
source "fs/nfs/Kconfig"
source "fs/proc/Kconfig"
source "fs/jffs2/Kconfig"
source "fs/zpfs/Kconfig"
config ENABLE_READ_BUFFER
bool "Enable read buffer Option"
default n
@ -117,7 +119,7 @@ config MAX_PATH_CACHE_SIZE
endmenu
######################## config options of net ############################
source "../../kernel/liteos_a/net/Kconfig"
source "net/Kconfig"
######################## config options of debug ########################
menu "Debug"
@ -162,9 +164,16 @@ config ENABLE_MAGICKEY
config THUMB
bool "Enable Thumb"
default n
select INTERWORK_THUMB
help
Answer Y to build thumb version. This will make LiteOS smaller.
config INTERWORK_THUMB
bool "Enable interwork Thumb" if THUMB
default n
help
Answer Y to enable interwork thumb.
config PLATFORM_DVFS
bool "Enable Dvfs"
default n
@ -219,14 +228,14 @@ config DEBUG_SEMAPHORE
help
Answer Y to enable debug semaphore.
source "../../kernel/liteos_a/shell/Kconfig"
source "shell/Kconfig"
config NET_LWIP_SACK_TFTP
bool "Enable Tftp"
default y
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
help
Answer Y to enable LiteOS support tftp cmd and tftp tool.
source "../../kernel/liteos_a/net/telnet/Kconfig"
source "net/telnet/Kconfig"
config SCHED_DEBUG
bool "Enable sched debug Feature"
default n
@ -265,7 +274,7 @@ config MEM_LEAKCHECK
help
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
config BASE_MEM_NODE_INTEGRITY_CHECK
bool "Enable integrity check or not "
bool "Enable integrity check or not"
default n
depends on DEBUG_VERSION && MEM_DEBUG
config MEM_WATERLINE
@ -290,20 +299,24 @@ config DRIVERS
help
Answer Y to enable LiteOS support driver.
source "../../kernel/liteos_a/bsd/dev/usb/Kconfig"
source "bsd/dev/usb/Kconfig"
source "../../drivers/adapter/khdf/liteos/Kconfig"
# Device driver Kconfig import
osource "$(DEVICE_PATH)/drivers/Kconfig"
source "drivers/char/mem/Kconfig"
source "drivers/char/quickstart/Kconfig"
source "drivers/char/random/Kconfig"
source "../../drivers/liteos/tzdriver/Kconfig"
source "drivers/char/video/Kconfig"
source "../../drivers/liteos/tzdriver/Kconfig"
source "../../drivers/liteos/hievent/Kconfig"
endmenu
menu "Security"
source "../../kernel/liteos_a/security/Kconfig"
source "security/Kconfig"
endmenu
menu "Test"

View File

@ -47,22 +47,29 @@ ROOTFS = rootfs
LITEOS_TARGET = liteos
LITEOS_LIBS_TARGET = libs_target
LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h
LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform
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
ifeq ($(PRODUCT_PATH),)
export PRODUCT_PATH=$(shell hb env|grep "product path:"|sed 's/.*: //g')
endif
ifeq ($(DEVICE_PATH),)
export DEVICE_PATH=$(shell hb env|grep "device path:"|sed 's/.*: //g')
endif
$(shell env CONFIG_=$(CONFIG_) $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH))
ifeq ($(TEE:1=y),y)
tee = _tee
endif
ifeq ($(RELEASE:1=y),y)
CONFIG ?= $(PRODUCT_PATH)/config/release$(tee).config
else
CONFIG ?= $(PRODUCT_PATH)/config/debug$(tee).config
endif
ifeq ($(shell which menuconfig),)
$(shell pip install --user kconfiglib >/dev/null)
endif
$(shell env CONFIG_=$(CONFIG_) DEVICE_PATH=$(DEVICE_PATH) olddefconfig >/dev/null)
-include $(LITEOSTOPDIR)/tools/build/config.mk
@ -116,6 +123,15 @@ else
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh
endif
##### make sysroot #####
sysroot:
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
ifeq ($(wildcard $(SYSROOT_PATH)/usr/include/$(LLVM_TARGET)/),)
$(HIDE)$(MAKE) -C $(SYSROOT_PATH)/build TARGETS=liteos_a_user
endif
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
endif
##### make dynload #####
-include $(LITEOS_MK_PATH)/dynload.mk
@ -132,26 +148,21 @@ $(OUT): $(LITEOS_MENUCONFIG_H)
$(BUILD):
$(HIDE)mkdir -p $(BUILD)
$(LITEOS_LIBS_TARGET): $(__LIBS)
$(LITEOS_LIBS_TARGET): $(__LIBS) sysroot
$(HIDE)for dir in $(LIB_SUBDIRS); \
do $(MAKE) -C $$dir all || exit 1; \
done
$(HIDE)echo "=============== make lib done ==============="
##### make menuconfig #####
menuconfig:$(MENUCONFIG_MCONF)
$< $(KCONFIG_FILE_PATH)
genconfig:$(MENUCONFIG_CONF)
$(HIDE)mkdir -p include/config include/generated
$< --olddefconfig $(KCONFIG_FILE_PATH)
$< --silentoldconfig $(KCONFIG_FILE_PATH)
menuconfig:
$(HIDE)menuconfig
##### menuconfig end #######
$(LITEOS_MENUCONFIG_H): .config
$(HIDE)$(MAKE) genconfig
$(HIDE)genconfig
$(LITEOS_TARGET): $(__LIBS)
$(LITEOS_TARGET): $(__LIBS) sysroot
$(HIDE)touch $(LOSCFG_ENTRY_SRC)
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
@ -165,18 +176,14 @@ $(LITEOS_TARGET): $(__LIBS)
$(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
# $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
$(APPS): $(LITEOS_TARGET)
$(APPS): $(LITEOS_TARGET) sysroot
$(HIDE)$(MAKE) -C apps all
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
MULTILIB := $(patsubst $(shell $(CC) --target=$(LLVM_TARGET) $(ARCH_CFLAGS) -print-file-name=lib/$(LLVM_TARGET)/)%,%,$(dir $(shell $(CC) --target=$(LLVM_TARGET) $(ARCH_CFLAGS) -print-libgcc-file-name)))
endif
prepare:
$(HIDE)mkdir -p $(OUT)/musl
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
$(HIDE)cp -f $(SYSROOT_PATH)/usr/lib/$(LLVM_TARGET)/$(MULTILIB)/libc.so $(OUT)/musl
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/$(MULTILIB)/libc++.so $(OUT)/musl
$(HIDE)cp -f $$($(CC) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
$(HIDE)cp -f $$($(GPP) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
else
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
@ -186,7 +193,7 @@ endif
$(ROOTFSDIR): prepare $(APPS)
$(HIDE)$(MAKE) clean -C apps
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
ifneq ($(VERSION),)
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
endif
@ -218,10 +225,11 @@ 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); \
test -f $$f && cp $$f .config && olddefconfig && savedefconfig --out $$f; \
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)
update_config:
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)"
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config update_config
.PHONY: prepare sysroot cleanrootfs $(ROOTFS) $(ROOTFSDIR) $(APPS) menuconfig $(LITEOS_LIBS_TARGET) $(__LIBS) $(OUT)

50
apps/BUILD.gn Normal file
View File

@ -0,0 +1,50 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
group("apps") {
deps = []
if (defined(LOSCFG_SHELL)) {
deps += [
"shell",
#"mksh",
#"toybox",
]
}
if (defined(LOSCFG_USER_INIT_DEBUG)) {
#deps += [ "init" ]
}
if (defined(LOSCFG_NET_LWIP_SACK_TFTP)) {
deps += [ "tftp" ]
}
}

53
apps/init/BUILD.gn Normal file
View File

@ -0,0 +1,53 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
executable("init") {
sources = [ "src/init.c" ]
cflags = [ "-fPIE" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Wno-shift-op-parentheses",
"-Wno-bitwise-op-parentheses",
"-Wnonnull",
]
}
ldflags = [
"-pie",
"-s",
]
if (defined(LOSCFG_QUICK_START)) {
ldflags += [ "--static" ]
}
}

40
apps/mksh/BUILD.gn Normal file
View File

@ -0,0 +1,40 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/component/lite_component.gni")
import("//kernel/liteos_a/liteos.gni")
group("mksh") {
deps = [ ":build_mksh" ]
}
build_ext_component("build_mksh") {
exec_path = rebase_path(target_out_dir)
command = "make -C $LITEOSTHIRDPARTY/mksh"
}

View File

@ -34,15 +34,16 @@ LITEOSTOPDIR = $(MKSH_DIR)/../../
include $(MKSH_DIR)/../config.mk
APPS_OUT := $(OUT)/bin
ETC_OUT := $(OUT)/etc
BUILD_DIR := $(MKSH_DIR)/build
BUILD_LOG := $(MKSH_DIR)/build.log
TARGET_OS := OpenHarmony
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -Oz -fstack-protector-strong -D_FORTIFY_SOURCE=2
LOCAL_CFLAGS += --target=arm-liteos $(LLVM_SYSROOT)
LOCAL_CFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
LOCAL_CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
LOCAL_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2 --target=arm-liteos $(LLVM_SYSROOT)
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2 --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
all:$(MKSH)
@ -61,6 +62,8 @@ endif
$(HIDE)$(STRIP) $(MKSH)
$(HIDE)mkdir -p $(APPS_OUT)
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
$(HIDE)mkdir -p $(ETC_OUT)
$(HIDE)$(CP) -rf $(BUILD_DIR)/.mkshrc $(ETC_OUT)/
clean:
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)

View File

@ -33,6 +33,8 @@ APP_SUBDIRS :=
ifeq ($(LOSCFG_SHELL), y)
APP_SUBDIRS += shell
APP_SUBDIRS += mksh
APP_SUBDIRS += toybox
endif
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
@ -42,9 +44,3 @@ endif
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
APP_SUBDIRS += tftp
endif
#only enable for qemu now
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
APP_SUBDIRS += mksh
APP_SUBDIRS += toybox
endif

58
apps/shell/BUILD.gn Normal file
View File

@ -0,0 +1,58 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
executable("shell") {
sources = [
"builtin/cd.c",
"src/main.c",
"src/shcmd.c",
"src/shcmdparse.c",
"src/shmsg.c",
]
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
include_dirs = [ "include" ]
cflags = [ "-fPIE" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Wno-shift-op-parentheses",
"-Wno-bitwise-op-parentheses",
]
}
ldflags = [
"-pie",
"-s",
]
}

55
apps/tftp/BUILD.gn Normal file
View File

@ -0,0 +1,55 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
executable("tftp") {
sources = [
"src/main.c",
"src/tftpc.c",
]
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
include_dirs = [ "include" ]
cflags = [ "-fPIE" ]
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
cflags += [
"-Wno-shift-op-parentheses",
"-Wno-bitwise-op-parentheses",
]
}
ldflags = [
"-pie",
"-s",
]
}

40
apps/toybox/BUILD.gn Normal file
View File

@ -0,0 +1,40 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/component/lite_component.gni")
import("//kernel/liteos_a/liteos.gni")
group("toybox") {
deps = [ ":build_toybox" ]
}
build_ext_component("build_toybox") {
exec_path = rebase_path(target_out_dir)
command = "make -C $LITEOSTHIRDPARTY/toybox"
}

View File

@ -46,8 +46,8 @@ else
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
endif
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=arm-liteos $(LLVM_SYSROOT)" CC="$(CC)" OUTNAME=$(OUTNAME) \
LDFLAGS="--target=arm-liteos $(LLVM_SYSROOT)" \
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=$(LLVM_TARGET) $(LLVM_SYSROOT)" CC="$(CC)" OUTNAME=$(OUTNAME) \
LDFLAGS="--target=$(LLVM_TARGET) $(LLVM_SYSROOT)" \
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
$(HIDE)$(STRIP) $(TOYBOX)

View File

@ -1,7 +1,6 @@
CONFIG_GETTY=y
CONFIG_MDEV=y
CONFIG_MDEV_CONF=y
# CONFIG_BASENAME is not set
# CONFIG_CAL is not set
# CONFIG_CAT is not set
# CONFIG_CATV is not set
# CONFIG_CKSUM is not set
# CONFIG_CRC32 is not set
@ -13,6 +12,7 @@ CONFIG_MDEV_CONF=y
# CONFIG_CUT is not set
# CONFIG_DF is not set
# CONFIG_DIRNAME is not set
# CONFIG_ECHO is not set
# CONFIG_ENV is not set
# CONFIG_EXPAND is not set
# CONFIG_FALSE is not set
@ -128,7 +128,6 @@ CONFIG_MDEV_CONF=y
# CONFIG_READAHEAD is not set
# CONFIG_READLINK is not set
# CONFIG_REALPATH is not set
# CONFIG_REBOOT is not set
# CONFIG_RESET is not set
# CONFIG_REV is not set
# CONFIG_RMMOD is not set
@ -179,3 +178,9 @@ CONFIG_MDEV_CONF=y
# CONFIG_SEQ is not set
# CONFIG_SU is not set
# CONFIG_SYNC is not set
#
# pending (see toys/pending/README)
#
# CONFIG_GETTY is not set
# CONFIG_MDEV is not set
# CONFIG_MDEV_CONF is not set

44
arch/BUILD.gn Normal file
View File

@ -0,0 +1,44 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
group("arch") {
deps = []
if (defined(LOSCFG_ARCH_ARM)) {
deps += [ "arm" ]
}
}
config("public") {
configs = []
if (defined(LOSCFG_ARCH_ARM)) {
configs += [ "arm:public" ]
}
}

47
arch/arm/BUILD.gn Normal file
View File

@ -0,0 +1,47 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
group("arm") {
deps = [ "gic" ]
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
deps += [ "arm" ]
}
}
config("public") {
include_dirs = [ "include" ]
configs = []
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
configs += [ "arm:public" ]
} else if (defined(LOSCFG_ARCH_ARM_AARCH64)) {
configs += [ "aarch64:public" ]
}
}

82
arch/arm/arm/BUILD.gn Normal file
View File

@ -0,0 +1,82 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_name = LOSCFG_ARCH_CPU
kernel_module(module_name) {
sources = [
"src/arm_generic_timer.c",
"src/clear_user.S",
"src/hw_user_get.S",
"src/hw_user_put.S",
"src/jmp.S",
"src/los_arch_mmu.c",
"src/los_asid.c",
"src/los_dispatch.S",
"src/los_exc.c",
"src/los_hw.c",
"src/los_hw_exc.S",
"src/los_hw_runstop.S",
"src/los_hw_tick.c",
"src/los_hwi.c",
"src/strncpy_from_user.c",
"src/strnlen_user.c",
"src/user_copy.c",
]
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
sources += [ "src/armv7a/cache.S" ]
}
if (defined(LOSCFG_KERNEL_SMP)) {
sources += [ "src/startup/reset_vector_mp.S" ]
} else {
sources += [ "src/startup/reset_vector_up.S" ]
}
include_dirs = [ "src/include" ]
if (defined(LOSCFG_GDB)) {
configs += [ "$LITEOSTOPDIR:as_objs_libc_flags" ]
}
public_configs = [ ":public" ]
}
group("arm") {
public_deps = [ ":$module_name" ]
}
config("public") {
include_dirs = [
"include",
"src/include",
]
}

View File

@ -145,7 +145,7 @@ STATIC INLINE VOID ArchCurrUserTaskSet(UINTPTR val)
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
return ARM_SYSREG_READ(MPIDR) & MPIDR_CPUID_MASK;
#else
return 0;

View File

@ -51,7 +51,7 @@
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
g_firstPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
g_tempPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
@ -218,7 +218,7 @@ STATIC UINT32 OsCvtSecCacheFlagsToMMUFlags(UINT32 flags)
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
case VM_MAP_REGION_FLAG_CACHED:
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
mmuFlags |= MMU_DESCRIPTOR_L1_SECTION_SHAREABLE;
#endif
break;
@ -544,7 +544,7 @@ STATIC UINT32 OsCvtPte2CacheFlagsToMMUFlags(UINT32 flags)
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
case VM_MAP_REGION_FLAG_CACHED:
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
mmuFlags |= MMU_DESCRIPTOR_L2_SHAREABLE;
#endif
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
@ -871,7 +871,7 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
kSpace->archMmu.virtTtb = (PTE_T *)g_firstPageTable;
kSpace->archMmu.physTtb = LOS_PaddrQuery(kSpace->archMmu.virtTtb);
status = LOS_ArchMmuUnmap(&kSpace->archMmu, virtAddr,
(bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
(bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
if (status != ((bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
VM_ERR("unmap failed, status: %d", status);
return;
@ -882,8 +882,8 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
flags |= VM_MAP_REGION_FLAG_UNCACHED;
}
status = LOS_ArchMmuMap(&kSpace->archMmu, virtAddr, SYS_MEM_BASE,
(textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
flags);
(textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
flags);
if (status != ((textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
VM_ERR("mmap failed, status: %d", status);
return;
@ -910,9 +910,9 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
flags |= VM_MAP_REGION_FLAG_UNCACHED;
}
status = LOS_ArchMmuMap(&kSpace->archMmu, bssEndBoundary,
SYS_MEM_BASE + bssEndBoundary - virtAddr,
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
flags);
SYS_MEM_BASE + bssEndBoundary - virtAddr,
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
flags);
if (status != (kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
VM_ERR("mmap failed, status: %d", status);
return;

View File

@ -38,7 +38,6 @@
#include "los_excinfo_pri.h"
#endif
#include "los_sys_stack_pri.h"
#include "los_stackinfo_pri.h"
#ifdef LOSCFG_COREDUMP
#include "los_coredump.h"
#endif
@ -62,6 +61,9 @@
#ifdef LOSCFG_FS_VFS
#include "console.h"
#endif
#ifdef LOSCFG_BLACKBOX
#include "los_blackbox.h"
#endif
#define INVALID_CPUID 0xFFFF
@ -75,7 +77,7 @@ VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr);
UINT32 g_curNestCount[LOSCFG_KERNEL_CORE_NUM] = { 0 };
BOOL g_excFromUserMode[LOSCFG_KERNEL_CORE_NUM];
STATIC EXC_PROC_FUNC g_excHook = (EXC_PROC_FUNC)OsExcHook;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
STATIC SPIN_LOCK_INIT(g_excSerializerSpin);
STATIC UINT32 g_currHandleExcPID = OS_INVALID_VALUE;
STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
@ -531,7 +533,7 @@ STATIC VOID OsExcRestore(VOID)
g_excFromUserMode[currCpuID] = FALSE;
g_intCount[currCpuID] = 0;
g_curNestCount[currCpuID] = 0;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
OsPercpuGet()->excFlag = CPU_RUNNING;
#endif
OsPercpuGet()->taskLockCnt = 0;
@ -548,7 +550,7 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
return;
}
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
LOS_SpinLock(&g_excSerializerSpin);
if (g_nextExcWaitCpu != INVALID_CPUID) {
g_currHandleExcCpuID = g_nextExcWaitCpu;
@ -563,12 +565,15 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
#endif
runProcess->processStatus &= ~OS_PROCESS_FLAG_EXIT;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
#ifdef LOSCFG_FS_VFS
OsWakeConsoleSendTask();
#endif
#endif
#ifdef LOSCFG_BLACKBOX
BBoxNotifyError("USER_CRASH", MODULE_SYSTEM, "Crash in user", 0);
#endif
SCHEDULER_LOCK(intSave);
#ifdef LOSCFG_SAVE_EXCINFO
OsProcessExitCodeCoreDumpSet(runProcess);
@ -716,14 +721,14 @@ VOID BackTraceSub(UINTPTR regFP)
while (IsValidFP(backFP, stackStart, stackEnd, &kvaddr) == TRUE) {
tmpFP = backFP;
#ifdef LOSCFG_COMPILER_CLANG_LLVM
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidFP(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
return;
}
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
#else
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
if (IsValidFP(tmpFP - POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
return;
@ -909,7 +914,7 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
#endif /* __LINUX_ARM_ARCH__ */
#endif /* LOSCFG_GDB */
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
#define EXC_WAIT_INTER 50U
#define EXC_WAIT_TIME 2000U
@ -1007,7 +1012,7 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
OsWaitOtherCoresHandleExcEnd(currCpuID);
} else {
if (g_excFromUserMode[g_currHandleExcCpuID] == TRUE) {
if ((g_currHandleExcCpuID < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuID] == TRUE)) {
g_currHandleExcCpuID = currCpuID;
LOS_SpinUnlock(&g_excSerializerSpin);
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
@ -1027,7 +1032,7 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
STATIC VOID OsCheckCpuStatus(VOID)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
OsCheckAllCpuStatus();
#else
g_currHandleExcCpuID = ArchCurrCpuid();
@ -1048,7 +1053,7 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
OsCheckCpuStatus();
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
#ifdef LOSCFG_FS_VFS
/* Wait for the end of the Console task to avoid multicore printing code */
OsWaitConsoleSendTaskPend(OsCurrTaskGet()->taskID);
@ -1058,6 +1063,11 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
{
#ifdef LOSCFG_BLACKBOX
#ifdef LOSCFG_SAVE_EXCINFO
SetExcInfoIndex(0);
#endif
#endif
#ifdef LOSCFG_KERNEL_VM
/* You are not allowed to add any other print information before this exception information */
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
@ -1113,7 +1123,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
OsPrintExcHead(far);
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
OsAllCpuStatusOutput();
#endif
@ -1125,7 +1135,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
if (g_curNestCount[ArchCurrCpuid()] == 1) {
#ifdef LOSCFG_SAVE_EXCINFO
if (func != NULL) {
#ifndef LOSCFG_BLACKBOX
SetExcInfoIndex(0);
#endif
OsSysStateSave(&intCount, &lockCount);
OsRecordExcInfoTime();
OsSysStateRestore(intCount, lockCount);
@ -1154,6 +1166,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
}
#endif
#ifdef LOSCFG_BLACKBOX
BBoxNotifyError(EVENT_PANIC, MODULE_SYSTEM, "Crash in kernel", 1);
#endif
while (1) {}
}
@ -1168,7 +1183,7 @@ __attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
}
/* stack protector */
UINT32 __stack_chk_guard = 0xd00a0dff;
USED UINT32 __stack_chk_guard = 0xd00a0dff;
VOID __stack_chk_fail(VOID)
{
@ -1200,7 +1215,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
framePtr = Get_Fp();
while ((framePtr > stackStart) && (framePtr < stackEnd) && IS_ALIGNED(framePtr, sizeof(CHAR *))) {
tmpFramePtr = framePtr;
#ifdef LOSCFG_COMPILER_CLANG_LLVM
linkReg = *(UINTPTR *)(tmpFramePtr + sizeof(UINTPTR));
#else
linkReg = *(UINTPTR *)framePtr;
#endif
if (index >= jumpCount) {
LR[count++] = linkReg;
if (count == recordCount) {
@ -1208,7 +1227,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
}
}
index++;
#ifdef LOSCFG_COMPILER_CLANG_LLVM
framePtr = *(UINTPTR *)framePtr;
#else
framePtr = *(UINTPTR *)(tmpFramePtr - sizeof(UINTPTR));
#endif
}
/* if linkReg is not enough,clean up the last of the effective LR as the end. */

View File

@ -105,7 +105,15 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
{
VOID *cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
LosTaskCB *task = OsCurrTaskGet();
sig_cb *sigcb = &task->sig;
VOID *cloneStack = NULL;
if (sigcb->sigContext != NULL) {
cloneStack = (VOID *)((UINTPTR)sigcb->sigContext - sizeof(TaskContext));
} else {
cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
}
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
((TaskContext *)childStack)->R0 = 0;

41
arch/arm/gic/BUILD.gn Normal file
View File

@ -0,0 +1,41 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = []
if (defined(LOSCFG_ARCH_GIC_V2)) {
sources += [ "gic_v2.c" ]
} else if (defined(LOSCFG_ARCH_GIC_V3)) {
sources += [ "gic_v3.c" ]
}
}

View File

@ -40,7 +40,7 @@ STATIC_ASSERT(OS_USER_HWI_MAX <= 1020, "hwi max is too large!");
STATIC UINT32 g_curIrqNum = 0;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/*
* filter description
* 0b00: forward to the cpu interfaces specified in cpu_mask
@ -144,7 +144,7 @@ VOID HalIrqInit(VOID)
/* enable gic distributor control */
GIC_REG_32(GICD_CTLR) = 1;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/* register inter-processor interrupt */
(VOID)LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
(VOID)LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);

View File

@ -48,7 +48,7 @@ STATIC INLINE UINT64 MpidrToAffinity(UINT64 mpidr)
(MPIDR_AFF_LEVEL(mpidr, 0)));
}
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
STATIC UINT32 NextCpu(UINT32 cpu, UINT32 cpuMask)
{
@ -399,7 +399,7 @@ VOID HalIrqInit(VOID)
HalIrqInitPercpu();
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/* register inter-processor interrupt */
LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);

View File

@ -49,7 +49,7 @@ extern VOID HalIrqClear(UINT32 vector);
extern CHAR *HalIrqVersion(VOID);
extern UINT32 HalCurIrqGet(VOID);
extern UINT32 HalIrqSetPrio(UINT32 vector, UINT8 priority);
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
extern VOID HalIrqSendIpi(UINT32 target, UINT32 ipi);
extern VOID HalIrqSetAffinity(UINT32 vector, UINT32 cpuMask);
#endif

86
bsd/BUILD.gn Normal file
View File

@ -0,0 +1,86 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_COMPAT_BSD)
module_name = "libbsd"
kernel_module(module_name) {
sources = [
"kern/bus_if.c",
"kern/device_if.c",
"kern/kern_condvar.c",
"kern/kern_timeout.c",
"kern/subr_bus.c",
"kern/subr_kobj.c",
]
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
sources += [
"arm/autoconf.c",
"arm/hw_user_copy.S",
"arm/in_cksum.c",
"arm/in_cksum_arm.S",
"arm/nexus.c",
]
}
if (defined(LOSCFG_DRIVERS_RANDOM)) {
sources += [
"crypto/rijndael/rijndael-alg-fst.c",
"crypto/rijndael/rijndael-api-fst.c",
"crypto/sha2/sha256c.c",
"dev/random/hash.c",
"dev/random/yarrow.c",
"libkern/explicit_bzero.c",
]
}
public_configs = [ ":public" ]
}
group("bsd") {
public_deps = [ ":$module_name" ]
deps = [
"compat/linuxkpi",
"dev/usb",
]
}
config("public") {
include_dirs = [
".",
"kern",
]
configs = [
"compat/linuxkpi:public",
"dev/usb:public",
]
}

View File

@ -1,6 +1,14 @@
config COMPAT_BSD
bool "Enable FreeBSD"
default y
select COMPAT_LINUXKPI
help
Answer Y to enable LiteOS support FreeBSD.
config COMPAT_LINUXKPI
bool "Enable linuxkpi" if COMPAT_BSD
default y
help
Answer Y to enable LiteOS support compatible layer for linuxkpi.

View File

@ -0,0 +1,57 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_COMPAT_BSD)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"src/adp.c",
"src/linux_completion.c",
"src/linux_interrupt.c",
"src/linux_sched.c",
"src/linux_semaphore.c",
"src/linux_timer.c",
"src/linux_wakelock.c",
"src/linux_workqueue.c",
"src/prctl.c",
"src/tzdst.c",
]
if (defined(LOSCFG_HRTIMER_ENABLE)) {
sources += [ "src/linux_hrtimer.c" ]
}
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -1 +0,0 @@
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd.h

View File

@ -1 +0,0 @@
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd_list.h

154
bsd/dev/usb/BUILD.gn Normal file
View File

@ -0,0 +1,154 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_DRIVERS_USB)
module_name = "usb_base"
kernel_module(module_name) {
sources = [
"implementation/bsd_busspace.c",
"implementation/bsd_kernel.c",
"implementation/usb_btree.c",
"implementation/usb_busdma_loader.c",
"implementation/usb_init.c",
"implementation/usb_version.c",
"usb_debug.c",
]
if (defined(LOSCFG_DRIVERS_USB)) {
sources += [
"controller/usb_controller.c",
"quirk/usb_quirk.c",
"usb_dev.c",
"usb_device.c",
"usb_dynamic.c",
"usb_error.c",
"usb_generic.c",
"usb_handle_request.c",
"usb_hub.c",
"usb_if.c",
"usb_lookup.c",
"usb_mbuf.c",
"usb_parse.c",
"usb_process.c",
"usb_request.c",
"usb_transfer.c",
"usb_util.c",
]
}
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM)) {
sources += [ "net/if_cdce.c" ]
}
if (defined(LOSCFG_DRIVERS_USB_ETHERNET)) {
sources += [
"net/if_axe.c",
"net/if_axge.c",
]
}
if (defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
sources += [ "net/if_urndis.c" ]
}
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
defined(LOSCFG_DRIVERS_USB_ETHERNET) ||
defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
sources += [
"net/usb_eth_drv.c",
"net/usb_ethernet.c",
]
}
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
defined(LOSCFG_DRIVERS_USB_SERIAL)) {
sources += [
"serial/u3g.c",
"serial/usb_serial.c",
]
}
if (defined(LOSCFG_DRIVERS_USB_HOST_EHCI)) {
sources += [
"controller/ehci.c",
"controller/ehci_pci.c",
]
}
if (defined(LOSCFG_DRIVERS_USB_HOST_XHCI) ||
defined(LOSCFG_DRIVERS_USB_HOST_XHCI_FOR_PORT2)) {
sources += [
"controller/xhci.c",
"controller/xhci_pci.c",
]
}
if (defined(LOSCFG_DRIVERS_USB_WIRELESS)) {
sources += [ "linux_usb.c" ]
}
if (defined(LOSCFG_DRIVERS_USB_MASS_STORAGE)) {
sources += [ "storage/umass.c" ]
}
if (defined(LOSCFG_DRIVERS_USB_HID_CLASS) &&
defined(LOSCFG_DRIVERS_HDF_INPUT)) {
sources += [
"input/uhid.c",
"usb_hid.c",
]
include_dirs = [
"//drivers/framework/model/input/driver",
"//drivers/framework/include/core",
"//drivers/framework/core/common/include/host",
"//drivers/framework/utils",
"//drivers/framework/osal",
"//drivers/framework/ability/sbuf/include",
"//drivers/framework/include/osal",
]
}
configs += [
"$HDFTOPDIR:hdf_config"
]
public_configs = [ ":public" ]
}
group("usb") {
public_deps = [ ":$module_name" ]
}
config("public") {
include_dirs = [ "." ]
include_dirs += [ "$LITEOSTHIRDPARTY/FreeBSD/sys/dev/evdev" ]
}

View File

@ -15,7 +15,7 @@ config DRIVERS_USB_HOST_DRIVER
choice
depends on DRIVERS_USB_HOST_DRIVER
prompt "USB HCD"
default y
default DRIVERS_USB_HOST_EHCI
help
Enable EHCI for USB 2.0.
Enable XHCI for USB 3.0

View File

@ -41,50 +41,40 @@ outdir=${8}
ohos_version=${9}
sysroot_path=${10}
arch_cflags=${11}
device_path=${12}
echo "${board_name}" "${device_company}"
echo "sh param:" "$@"
function main() {
destination=".config"
config_file=""
tee=""
if [ "${tee_enable}" = "tee" ]; then
if [ "${tee_enable}" = "true" ]; then
tee="_tee"
fi
config_file="${product_path}/config/${ohos_build_type}${tee}.config"
if [ -f "${config_file}" ]; then
cp "${config_file}" "${destination}"
return
fi
product_name=$(basename "${product_path}")
source="tools/build/config/${product_name}_release.config"
config_file="${product_name}_release.config"
if [ "${ohos_build_compiler}" = "clang" ]; then
if [ "${ohos_build_type}" = "debug" ]; then
config_file="${product_name}_${ohos_build_compiler}${tee}.config"
source="tools/build/config/debug/${config_file}"
config_file="debug/${product_name}_${ohos_build_compiler}${tee}.config"
else
config_file="${product_name}_${ohos_build_compiler}_release${tee}.config"
source="tools/build/config/${config_file}"
fi
elif [ "${ohos_build_compiler}" = "gcc" ]; then
if [ "${ohos_build_type}" = "debug" ]; then
config_file="${product_name}_debug_shell${tee}.config"
source="tools/build/config/${config_file}"
else
config_file="${product_name}_release${tee}.config"
source="tools/build/config/${config_file}"
fi
fi
if [ -d "./out" ]; then
rm -rf ./out
fi
if [ -f "${destination}" ]; then
rm -rf ${destination}
fi
if [ ! -f "${source}" ]; then
source="${product_path}/config/sys/${config_file}"
fi
cp "${source}" ${destination}
test_info_outdir="../..${root_build_dir}/test_info/gen/kernel/test"
mkdir -p "${test_info_outdir}"
cp kernel_test.sources "${test_info_outdir}"
cp "tools/build/config/${config_file}" "${destination}"
}
if [ "x" != "x${sysroot_path}" ]; then
@ -95,6 +85,10 @@ if [ "x" != "x${arch_cflags}" ]; then
export ARCH_CFLAGS="${arch_cflags}"
fi
export OUTDIR="${outdir}"
export PRODUCT_PATH="${product_path}"
export DEVICE_PATH="${device_path}"
main && \
make clean OUTDIR="${outdir}" PRODUCT_PATH="${product_path}" && \
make -j rootfs VERSION="${ohos_version}" OUTDIR="${outdir}" PRODUCT_PATH="${product_path}"
make clean && \
make -j rootfs VERSION="${ohos_version}"

19
tools/scripts/make_rootfs/rootfs.sh → compat/BUILD.gn Executable file → Normal file
View File

@ -1,5 +1,3 @@
#!/bin/bash
#
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
@ -28,12 +26,13 @@
# 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.
set -e
BIN_DIR=$1
LIB_DIR=$2
ROOTFS_DIR=$3
FSTYPE=$4
CUR_DIR=$(dirname $(readlink -f "$0"))
. ${CUR_DIR}/rootfsdir.sh ${BIN_DIR} ${LIB_DIR} ${ROOTFS_DIR}
. ${CUR_DIR}/rootfsimg.sh ${ROOTFS_DIR} ${FSTYPE}
import("//kernel/liteos_a/liteos.gni")
group("compat") {
deps = [ "posix" ]
}
config("public") {
configs = [ "posix:public" ]
}

55
compat/posix/BUILD.gn Normal file
View File

@ -0,0 +1,55 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_COMPAT_POSIX)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"src/map_error.c",
"src/misc.c",
"src/mqueue.c",
"src/posix_memalign.c",
"src/pthread.c",
"src/pthread_attr.c",
"src/pthread_cond.c",
"src/pthread_mutex.c",
"src/sched.c",
"src/semaphore.c",
"src/socket.c",
"src/time.c",
]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -38,7 +38,7 @@
#include "mqueue.h"
#include "semaphore.h"
#include "los_process_pri.h"
#include "los_hw.h"
/*
* Supply some suitable values for constants that may not be present
@ -54,17 +54,27 @@
int uname(struct utsname *name)
{
INT32 ret;
const char *cpuInfo = NULL;
if (name == NULL) {
return -EFAULT;
}
(VOID)strncpy_s(name->sysname, sizeof(name->sysname), KERNEL_NAME, strlen(KERNEL_NAME) + 1);
(VOID)strncpy_s(name->nodename, sizeof(name->nodename), "hisilicon", strlen("hisilicon") + 1);
ret = snprintf_s(name->version, sizeof(name->version), sizeof(name->version) - 1, "%s %u.%u.%u.%u %s %s\n",
ret = snprintf_s(name->version, sizeof(name->version), sizeof(name->version) - 1, "%s %u.%u.%u.%u %s %s",
KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, __DATE__, __TIME__);
if (ret < 0) {
return -EIO;
}
name->machine[0] = '\0';
cpuInfo = LOS_CpuInfo();
(VOID)strncpy_s(name->machine, sizeof(name->machine), cpuInfo, sizeof(name->machine));
ret = snprintf_s(name->release, sizeof(name->release), sizeof(name->release) - 1, "%u.%u.%u.%u",
KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE);
if (ret < 0) {
return -EIO;
}
name->domainname[0] = '\0';
return 0;
}

View File

@ -204,7 +204,7 @@ STATIC UINT32 InitPthreadData(pthread_t threadID, pthread_attr_t *userAttr,
PRINT_ERR("%s: %d, err: %d\n", __FUNCTION__, __LINE__, err);
return LOS_NOK;
}
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
if (userAttr->cpuset.__bits[0] > 0) {
taskCB->cpuAffiMask = (UINT16)userAttr->cpuset.__bits[0];
}

View File

@ -49,7 +49,7 @@ int pthread_attr_init(pthread_attr_t *attr)
attr->stacksize_set = 1;
attr->stacksize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
attr->cpuset.__bits[0] = 0;
#endif
@ -239,7 +239,7 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stackSize)
*/
int pthread_attr_setaffinity_np(pthread_attr_t* attr, size_t cpusetsize, const cpu_set_t* cpuset)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
if (attr == NULL) {
return EINVAL;
}
@ -264,7 +264,7 @@ int pthread_attr_setaffinity_np(pthread_attr_t* attr, size_t cpusetsize, const c
*/
int pthread_attr_getaffinity_np(const pthread_attr_t* attr, size_t cpusetsize, cpu_set_t* cpuset)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
if ((attr == NULL) || (cpuset == NULL) || (cpusetsize != sizeof(cpu_set_t))) {
return EINVAL;
}

View File

@ -61,7 +61,7 @@ int sched_get_priority_max(int policy)
*/
int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT32 taskID = (UINT32)pid;
UINT32 ret;
@ -93,7 +93,7 @@ int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
*/
int sched_getaffinity(pid_t pid, size_t set_size, cpu_set_t* set)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT32 taskID = (UINT32)pid;
UINT16 cpuAffiMask;

View File

@ -456,7 +456,7 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
{
uint64_t runtime;
UINT32 intSave;
UINT32 tid = ((UINT32) ~((clockID) >> CPUCLOCK_ID_OFFSET));
UINT32 tid = ((UINT32) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
if (OS_TID_CHECK_INVALID(tid)) {
return -EINVAL;
@ -482,7 +482,7 @@ static int ProcessGetCputime(clockid_t clockID, struct timespec *ats)
{
UINT64 runtime;
UINT32 intSave;
const pid_t pid = ((pid_t) ~((clockID) >> CPUCLOCK_ID_OFFSET));
const pid_t pid = ((pid_t) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
LosProcessCB *spcb = NULL;
if (OsProcessIDUserCheckInvalid(pid) || pid < 0) {
@ -524,7 +524,7 @@ static int GetCputime(clockid_t clockID, struct timespec *tp)
static int CheckClock(const clockid_t clockID)
{
int error = 0;
const pid_t pid = ((pid_t) ~((clockID) >> CPUCLOCK_ID_OFFSET));
const pid_t pid = ((pid_t) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
if (!((UINT32)clockID & CPUCLOCK_PERTHREAD_MASK)) {
LosProcessCB *spcb = NULL;

70
drivers/BUILD.gn Normal file
View File

@ -0,0 +1,70 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
cmd = "if [ -f $device_path/drivers/BUILD.gn ]; then echo true; else echo false; fi"
HAVE_DEVICE_DRIVERS = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
module_switch = defined(LOSCFG_DRIVERS)
group("drivers") {
if (module_switch) {
deps = [
"block/disk",
"char/bch",
"char/mem",
"char/quickstart",
"char/random",
"char/video",
"mtd/multi_partition",
"//drivers/adapter/khdf/liteos",
"//drivers/liteos",
]
if (HAVE_DEVICE_DRIVERS) {
deps += [ "$device_path/drivers" ]
}
}
}
config("public") {
configs = [
"block/disk:public",
"char/bch:public",
"char/mem:public",
"char/quickstart:public",
"char/random:public",
"char/video:public",
"mtd/multi_partition:public",
"//drivers/adapter/khdf/liteos:public",
"//drivers/liteos:public",
]
if (HAVE_DEVICE_DRIVERS) {
configs += [ "$device_path/drivers:public" ]
}
}

View File

@ -0,0 +1,45 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_FAT_DISK)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"src/disk.c",
"src/disk_shellcmd.c",
]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -725,6 +725,9 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName);
*/
INT32 los_get_diskid_byname(const CHAR *diskName);
los_disk *los_get_mmcdisk_bytype(UINT8 type);
#ifdef __cplusplus
#if __cplusplus
}

View File

@ -187,6 +187,22 @@ INT32 los_get_diskid_byname(const CHAR *diskName)
return diskID;
}
los_disk *los_get_mmcdisk_bytype(UINT8 type)
{
const CHAR *mmcDevHead = "/dev/mmcblk";
for (INT32 diskId = 0; diskId < SYS_MAX_DISK; diskId++) {
los_disk *disk = get_disk(diskId);
if (disk == NULL) {
continue;
} else if ((disk->type == type) && (strncmp(disk->disk_name, mmcDevHead, strlen(mmcDevHead)) == 0)) {
return disk;
}
}
PRINT_ERR("Cannot find the mmc disk!\n");
return NULL;
}
VOID OsSetUsbStatus(UINT32 diskID)
{
if (diskID < SYS_MAX_DISK) {

52
drivers/char/bch/BUILD.gn Normal file
View File

@ -0,0 +1,52 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_VFS_BLOCK_DEVICE)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_driver.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_register.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_unregister.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_cache.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_read.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_sem.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_setup.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_teardown.c",
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_write.c",
]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

42
drivers/char/mem/BUILD.gn Normal file
View File

@ -0,0 +1,42 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_DRIVERS_MEM)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [ "src/mem.c" ]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -0,0 +1,42 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_DRIVERS_QUICKSTART)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [ "src/quickstart.c" ]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -0,0 +1,46 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_DRIVERS_RANDOM)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [ "src/random.c" ]
if (defined(LOSCFG_HW_RANDOM_ENABLE)) {
sources += [ "src/random_hw.c" ]
}
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -65,7 +65,7 @@ static int RandomHwClose(struct file *filep)
static int RandomHwIoctl(struct file *filep, int cmd, unsigned long arg)
{
int ret;
int ret = -1;
switch (cmd) {
default:
@ -77,7 +77,7 @@ static int RandomHwIoctl(struct file *filep, int cmd, unsigned long arg)
static ssize_t RandomHwRead(struct file *filep, char *buffer, size_t buflen)
{
int ret;
int ret = -1;
if (g_randomOp.read != NULL) {
ret = g_randomOp.read(buffer, buflen);

View File

@ -0,0 +1,42 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_DRIVERS_VIDEO)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [ "$LITEOSTHIRDPARTY/NuttX/drivers/video/fb.c" ]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "$LITEOSTHIRDPARTY/NuttX/include/nuttx/video" ]
}

View File

@ -0,0 +1,54 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_VFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"src/mtd_partition.c",
"src/mtd_shellcmd.c",
]
include_dirs = [
"$LITEOSTOPDIR/fs/jffs2/include",
"//device/hisilicon/drivers/include/mtd/common/include",
]
if (defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)) {
include_dirs += [ "//device/qemu/drivers/cfiflash" ]
}
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

56
fs/BUILD.gn Normal file
View File

@ -0,0 +1,56 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
group("fs") {
deps = [
"fat",
"fat/virpart",
"jffs2",
"nfs",
"proc",
"ramfs",
"romfs",
"vfs",
"vfs/bcache",
"zpfs",
]
}
config("public") {
include_dirs = [ "include" ]
configs = [
"vfs:public",
"vfs/bcache:public",
"fat:public",
"fat/virpart:public",
"proc:public",
]
}

55
fs/fat/BUILD.gn Normal file
View File

@ -0,0 +1,55 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_FAT)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"os_adapt/fat_shellcmd.c",
"os_adapt/fatfs.c",
"os_adapt/format.c",
]
sources += [
"$LITEOSTHIRDPARTY/FatFs/source/diskio.c",
"$LITEOSTHIRDPARTY/FatFs/source/ff.c",
"$LITEOSTHIRDPARTY/FatFs/source/ffsystem.c",
"$LITEOSTHIRDPARTY/FatFs/source/ffunicode.c",
]
include_dirs = [ "os_adapt" ]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "$LITEOSTHIRDPARTY/FatFs/source" ]
}

View File

@ -46,6 +46,7 @@
#include "los_tables.h"
#include "user_copy.h"
#include "los_vm_filemap.h"
#include "los_hash.h"
#include <time.h>
#include <errno.h>
#include <dirent.h>
@ -53,7 +54,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "los_hash.h"
#include <fcntl.h>
struct VnodeOps fatfs_vops; /* forward define */
@ -190,7 +191,7 @@ static int fatfs_sync(unsigned long mountflags, FATFS *fs)
{
#ifdef LOSCFG_FS_FAT_CACHE
los_part *part = NULL;
if (mountflags != MS_NOSYNC) {
if (!(mountflags & (MS_NOSYNC | MS_RDONLY))) {
part = get_part((INT)fs->pdrv);
if (part == NULL) {
return -ENODEV;
@ -238,7 +239,8 @@ static mode_t fatfs_get_mode(BYTE attribute, mode_t fs_mode)
return fs_mode;
}
static enum VnodeType fatfstype_2_vnodetype(BYTE type) {
static enum VnodeType fatfstype_2_vnodetype(BYTE type)
{
switch (type) {
case AM_ARC:
return VNODE_TYPE_REG;
@ -286,7 +288,7 @@ static FRESULT init_cluster(DIR_FILE *pdfp, DIR *dp_new, FATFS *fs, int type, co
mem_set(dir, 0, SS(fs));
if (type == AM_LNK && target) {
/* Write target to symlink */
strcpy_s((char *)dir, SS(fs), target);
(void)strcpy_s((char *)dir, SS(fs), target);
} else {
/* Write the dir cluster */
mem_set(dir, 0, SS(fs));
@ -735,6 +737,7 @@ off64_t fatfs_lseek64(struct file *filep, off64_t offset, int whence)
struct Vnode *vp = filep->f_vnode;
DIR_FILE *dfp = (DIR_FILE *)vp->data;
FILINFO *finfo = &(dfp->fno);
struct Mount *mount = vp->originMount;
FSIZE_t fpos;
FRESULT result;
int ret;
@ -772,6 +775,17 @@ off64_t fatfs_lseek64(struct file *filep, off64_t offset, int whence)
if (ret == FALSE) {
return -EBUSY;
}
if (fpos > finfo->fsize) {
if ((filep->f_oflags & O_ACCMODE) == O_RDONLY) {
result = FR_DENIED;
goto ERROR_EXIT;
}
if (mount->mountFlags & MS_RDONLY) {
result = FR_WRITE_PROTECTED;
goto ERROR_EXIT;
}
}
fp->obj.sclust = finfo->sclst;
fp->obj.objsize = finfo->fsize;
@ -903,11 +917,13 @@ int fatfs_fallocate64(struct file *filep, int mode, off64_t offset, off64_t len)
return -EBUSY;
}
result = f_expand(fp, (FSIZE_t)offset, (FSIZE_t)len, 1);
if (result == FR_OK && finfo->sclst == 0) {
finfo->sclst = fp->obj.sclust;
if (result == FR_OK) {
if (finfo->sclst == 0) {
finfo->sclst = fp->obj.sclust;
}
result = f_sync(fp);
}
result = f_sync(fp);
unlock_fs(fs, FR_OK);
unlock_fs(fs, result);
return -fatfs_2_vfs(result);
}
@ -1400,6 +1416,9 @@ int fatfs_stat(struct Vnode *vp, struct stat* sp)
time = fattime_transfer(finfo->fdate, finfo->ftime);
sp->st_mtime = time;
/* Adapt to kstat member "long tv_sec" */
sp->__st_mtim32.tv_sec = (long)time;
unlock_fs(fs, FR_OK);
return 0;
}

47
fs/fat/virpart/BUILD.gn Normal file
View File

@ -0,0 +1,47 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_FAT_VIRTUAL_PARTITION)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"src/virpart.c",
"src/virpartff.c",
]
include_dirs = [ "../os_adapt" ]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -473,7 +473,7 @@ off64_t file_seek64(struct file *filep, off64_t offset, int whence);
*
****************************************************************************/
int files_allocate(struct Vnode *vnode, int oflags, off_t pos,void *priv, int minfd);
int files_allocate(struct Vnode *vnode, int oflags, off_t pos, void *priv, int minfd);
/****************************************************************************
* Name: files_close

75
fs/jffs2/BUILD.gn Normal file
View File

@ -0,0 +1,75 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_JFFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"src/jffs2_hash.c",
"src/vfs_jffs2.c",
]
sources += [
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/background.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/build.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr_rtime.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr_rubin.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr_zlib.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/debug.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/dir.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/erase.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/file.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/fs.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/gc.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/malloc.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/nodelist.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/nodemgmt.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/read.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/readinode.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/scan.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/summary.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/super.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/write.c",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/writev.c",
]
include_dirs = [
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2",
"$LITEOSTHIRDPARTY/Linux_Kernel/fs",
]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -123,7 +123,7 @@ int VfsJffs2Bind(struct Mount *mnt, struct Vnode *blkDriver, const void *data)
partNo = p->patitionnum;
ret = jffs2_mount(partNo, &rootNode);
ret = jffs2_mount(partNo, &rootNode, mnt->mountFlags);
if (ret != 0) {
LOS_MuxUnlock(&g_jffs2FsLock);
return ret;
@ -323,7 +323,7 @@ ssize_t VfsJffs2Write(struct file *filep, const char *buffer, size_t bufLen)
c = JFFS2_SB_INFO(node->i_sb);
pos = filep->f_pos;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
struct super_block *sb = node->i_sb;
UINT16 gcCpuMask = LOS_TaskCpuAffiGet(sb->s_gc_thread);
UINT32 curTaskId = LOS_CurTaskIDGet();
@ -717,14 +717,17 @@ ssize_t VfsJffs2Readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
int VfsJffs2Unlink(struct Vnode *parentVnode, struct Vnode *targetVnode, const char *path)
{
int ret;
struct jffs2_inode *parentInode = (struct jffs2_inode *)parentVnode->data;
struct jffs2_inode *targetInode = (struct jffs2_inode *)targetVnode->data;
struct jffs2_inode *parentInode = NULL;
struct jffs2_inode *targetInode = NULL;
if (!parentVnode || !targetVnode) {
PRINTK("%s-%d parentVnode=%x, targetVnode=%x\n", __FUNCTION__, __LINE__, parentVnode, targetVnode);
return -EINVAL;
}
parentInode = (struct jffs2_inode *)parentVnode->data;
targetInode = (struct jffs2_inode *)targetVnode->data;
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
ret = jffs2_unlink(parentInode, targetInode, (const unsigned char *)path);
@ -804,6 +807,11 @@ int VfsJffs2Stat(struct Vnode *pVnode, struct stat *buf)
buf->st_mtime = node->i_mtime;
buf->st_ctime = node->i_ctime;
/* Adapt to kstat member long tv_sec */
buf->__st_atim32.tv_sec = (long)node->i_atime;
buf->__st_mtim32.tv_sec = (long)node->i_mtime;
buf->__st_ctim32.tv_sec = (long)node->i_ctime;
LOS_MuxUnlock(&g_jffs2FsLock);
return 0;

40
fs/nfs/BUILD.gn Normal file
View File

@ -0,0 +1,40 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_NFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"$LITEOSTHIRDPARTY/NuttX/fs/nfs/nfs_adapter.c",
"$LITEOSTHIRDPARTY/NuttX/fs/nfs/nfs_util.c",
"$LITEOSTHIRDPARTY/NuttX/fs/nfs/rpc_clnt.c",
]
}

View File

@ -25,23 +25,31 @@
# 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.
static_library("fs_proc") {
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_PROC)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"os_adapt/fd_proc.c",
"os_adapt/fs_cache_proc.c",
"os_adapt/kernel_trace_proc.c",
"os_adapt/mounts_proc.c",
"os_adapt/power_proc.c",
"os_adapt/proc_init.c",
"os_adapt/vfs_proc.c",
"os_adapt/proc_vfs.c",
"os_adapt/process_proc.c",
"os_adapt/uptime_proc.c",
"os_adapt/vmm_proc.c",
"src/proc_file.c",
"src/proc_shellcmd.c",
"src/pseudofs.c",
"src/seq_file.c",
]
include_dirs = [ "include" ]
if (LOSCFG_LLTREPORT) {
cflags += [
"-fprofile-arcs",
"-ftest-coverage",
]
}
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -32,9 +32,9 @@
#include <sys/statfs.h>
#include <sys/mount.h>
#include "proc_fs.h"
#include "los_trace.h"
#ifdef LOSCFG_KERNEL_TRACE
#include "los_trace.h"
static int KernelTraceProcFill(struct SeqBuf *m, void *v)
{
(void)v;

36
fs/ramfs/BUILD.gn Normal file
View File

@ -0,0 +1,36 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_RAMFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [ "$LITEOSTHIRDPARTY/NuttX/fs/tmpfs/fs_tmpfs.c" ]
}

39
fs/romfs/BUILD.gn Normal file
View File

@ -0,0 +1,39 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_ROMFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"$LITEOSTHIRDPARTY/NuttX/fs/romfs/fs_romfs.c",
"$LITEOSTHIRDPARTY/NuttX/fs/romfs/fs_romfsutil.c",
]
}

116
fs/vfs/BUILD.gn Normal file
View File

@ -0,0 +1,116 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_VFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"operation/fs_chattr.c",
"operation/fs_check.c",
"operation/fs_fallocate.c",
"operation/fs_fallocate64.c",
"operation/fs_file.c",
"operation/fs_file_mapping.c",
"operation/fs_init.c",
"operation/fs_other.c",
"operation/fs_preadv.c",
"operation/fs_pwritev.c",
"operation/fs_readv.c",
"operation/fs_utime.c",
"operation/fs_writev.c",
"operation/fullpath.c",
"vfs_cmd/vfs_shellcmd.c",
]
sources += [
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_closedir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_opendir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_readdir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_rewinddir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_seekdir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_telldir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_blockproxy.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_closeblockdriver.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_findblockdriver.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_openblockdriver.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_registerblockdriver.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_registerdriver.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_unregisterblockdriver.c",
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_unregisterdriver.c",
"$LITEOSTHIRDPARTY/NuttX/fs/inode/fs_files.c",
"$LITEOSTHIRDPARTY/NuttX/fs/mount/fs_foreachmountpoint.c",
"$LITEOSTHIRDPARTY/NuttX/fs/mount/fs_mount.c",
"$LITEOSTHIRDPARTY/NuttX/fs/mount/fs_umount.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_close.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dup.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dup2.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dupfd.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dupfd2.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_fcntl.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_fsync.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_getfilep.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_ioctl.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_link.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_lseek.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_lseek64.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_mkdir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_open.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_poll.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pread.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pread64.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pwrite.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pwrite64.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_read.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_readlink.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_rename.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_rmdir.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_select.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_sendfile.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_stat.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_statfs.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_symlink.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_truncate.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_truncate64.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_unlink.c",
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_write.c",
"$LITEOSTOPDIR/fs/vfs/mount.c",
"$LITEOSTOPDIR/fs/vfs/path_cache.c",
"$LITEOSTOPDIR/fs/vfs/vnode.c",
"$LITEOSTOPDIR/fs/vfs/vnode_hash.c",
]
include_dirs = [ "$LITEOSTOPDIR/syscall" ]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

42
fs/vfs/bcache/BUILD.gn Normal file
View File

@ -0,0 +1,42 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_FAT_CACHE)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [ "src/bcache.c" ]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "../include/bcache" ]
}

View File

@ -41,6 +41,8 @@
#include "stdlib.h"
#include "sys/stat.h"
#include "vnode.h"
#include "fs/mount.h"
#include <fcntl.h>
/****************************************************************************
* Static Functions
@ -69,6 +71,11 @@ int chattr(const char *pathname, struct IATTR *attr)
goto errout_with_lock;
}
if ((vnode->originMount) && (vnode->originMount->mountFlags & MS_RDONLY)) {
ret = -EROFS;
goto errout_with_lock;
}
/* The way we handle the stat depends on the type of vnode that we
* are dealing with.
*/

View File

@ -406,7 +406,7 @@ int CopyFdToProc(int fd, unsigned int targetPid)
return -ESRCH;
}
procFd = AssignProcessFd(fdt, 3);
procFd = AssignProcessFd(fdt, 3); // minfd is 3
if (procFd < 0) {
if (sem_post(&semId) == -1) {
PRINT_ERR("sem_post error, errno %d \n", get_errno());

View File

@ -35,7 +35,9 @@
#include "dirent.h"
#include "unistd.h"
#include "sys/select.h"
#include "sys/mount.h"
#include "sys/stat.h"
#include "sys/statfs.h"
#include "sys/prctl.h"
#include "fs/fd_table.h"
#include "fs/file.h"
@ -256,30 +258,70 @@ char *getcwd(char *buf, size_t n)
int chmod(const char *path, mode_t mode)
{
int result;
struct stat buf;
struct IATTR attr = {0};
attr.attr_chg_mode = mode;
attr.attr_chg_valid = CHG_MODE; /* change mode */
int ret;
result = stat(path, &buf);
if (result != ENOERR) {
ret = chattr(path, &attr);
if (ret < 0) {
return VFS_ERROR;
}
return OK;
}
int chown(const char *pathname, uid_t owner, gid_t group)
{
struct IATTR attr = {0};
attr.attr_chg_valid = 0;
int ret;
if (owner != (uid_t)-1) {
attr.attr_chg_uid = owner;
attr.attr_chg_valid |= CHG_UID;
}
if (group != (gid_t)-1) {
attr.attr_chg_gid = group;
attr.attr_chg_valid |= CHG_GID;
}
ret = chattr(pathname, &attr);
if (ret < 0) {
return VFS_ERROR;
}
/* no access/permission control for files now, just return OK if stat is okay*/
return OK;
}
int access(const char *path, int amode)
{
int result;
int ret;
struct stat buf;
struct statfs fsBuf;
result = stat(path, &buf);
ret = statfs(path, &fsBuf);
if (ret != 0) {
if (get_errno() != ENOSYS) {
return VFS_ERROR;
}
/* dev has no statfs ops, need devfs to handle this in feature */
}
if (result != ENOERR) {
if ((fsBuf.f_flags & MS_RDONLY) && ((unsigned int)amode & W_OK)) {
set_errno(EROFS);
return VFS_ERROR;
}
ret = stat(path, &buf);
if (ret != 0) {
return VFS_ERROR;
}
if (VfsPermissionCheck(buf.st_uid, buf.st_gid, buf.st_mode, amode)) {
set_errno(EACCES);
return VFS_ERROR;
}
/* no access/permission control for files now, just return OK if stat is okay*/
return OK;
}

View File

@ -37,9 +37,11 @@
#include "vfs_config.h"
#include "sys/stat.h"
#include "vnode.h"
#include "fs/mount.h"
#include "string.h"
#include "stdlib.h"
#include "utime.h"
#include <fcntl.h>
/****************************************************************************
* Global Functions
@ -79,6 +81,12 @@ int utime(const char *path, const struct utimbuf *ptimes)
goto errout_with_path;
}
if ((vnode->originMount) && (vnode->originMount->mountFlags & MS_RDONLY)) {
VnodeDrop();
ret = -EROFS;
goto errout_with_path;
}
if (vnode->vop && vnode->vop->Chattr) {
if (ptimes == NULL) {
/* get current seconds */

View File

@ -27,16 +27,13 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
static_library("fs_zpfs") {
import("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_ZPFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"vfs_zpfs.c",
"zpfs.c",
]
if (LOSCFG_LLTREPORT) {
cflags += [
"-fprofile-arcs",
"-ftest-coverage",
]
}
}

View File

@ -25,32 +25,25 @@
# 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.
import("//build/lite/config/component/lite_component.gni")
import("//kernel/liteos_a/liteos.gni")
lite_component("kernel") {
features = [
group("kernel") {
deps = [
"base",
"syscall",
"common",
"extended",
"user",
]
if (LOSCFG_KERNEL_CPUP) {
features += [ "extended/cpup" ]
}
if (LOSCFG_KERNEL_MPU) {
features += [ "extended/mpu" ]
}
if (LOSCFG_KERNEL_CPPSUPPORT) {
features += [ "extended/cppsupport" ]
}
if (LOSCFG_KERNEL_DYNLOAD) {
features += [ "extended/dynload" ]
}
if (LOSCFG_KERNEL_TRACE) {
features += [ "extended/trace" ]
}
if (LOSCFG_KERNEL_VDSO) {
features += [ "extended/vdso" ]
}
}
config("public") {
include_dirs = [ "include" ]
configs = [
"base:public",
"common:public",
"extended:public",
"user:public",
]
}

View File

@ -25,9 +25,12 @@
# 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.
static_library("base") {
import("//kernel/liteos_a/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
sources = [
"core/los_bitmap.c",
"core/los_process.c",
@ -36,22 +39,24 @@ static_library("base") {
"core/los_sys.c",
"core/los_task.c",
"core/los_tick.c",
"core/los_timeslice.c",
"ipc/los_event.c",
"ipc/los_futex.c",
"ipc/los_ipcdebug.c",
"ipc/los_mux.c",
"ipc/los_mux_debug.c",
"ipc/los_queue.c",
"ipc/los_queue_debug.c",
"ipc/los_rwlock.c",
"ipc/los_sem.c",
"ipc/los_sem_debug.c",
"mem/bestfit/los_memory.c",
"mem/bestfit/los_multipledlinkhead.c",
"ipc/los_signal.c",
"mem/common/los_memstat.c",
"mem/membox/los_membox.c",
"mem/tlsf/los_memory.c",
"misc/kill_shellcmd.c",
"misc/los_misc.c",
"misc/los_stackinfo.c",
"misc/mempt_shellcmd.c",
"misc/panic_shellcmd.c",
"misc/swtmr_shellcmd.c",
"misc/sysinfo_shellcmd.c",
"misc/task_shellcmd.c",
@ -59,22 +64,33 @@ static_library("base") {
"mp/los_lockdep.c",
"mp/los_mp.c",
"mp/los_percpu.c",
"mp/los_spinlock.c",
"mp/los_stat.c",
"om/los_err.c",
"sched/sched_sq/los_priqueue.c",
"sched/sched_sq/los_sched.c",
"vm/filemap.c",
"vm/pmm.c",
"vm/vm.c",
"vm/vmm.c",
"vm/los_vm_boot.c",
"vm/los_vm_dump.c",
"vm/los_vm_fault.c",
"vm/los_vm_filemap.c",
"vm/los_vm_iomap.c",
"vm/los_vm_map.c",
"vm/los_vm_page.c",
"vm/los_vm_phys.c",
"vm/los_vm_scan.c",
"vm/los_vm_syscall.c",
"vm/oom.c",
"vm/shm.c",
]
include_dirs = [
"include",
"../extended/include",
"../extended/vdso/include",
"../extended/dynload/include",
"../include",
"mem",
]
if (defined(LOSCFG_SHELL_CMD_DEBUG)) {
configs += [
"$HDFTOPDIR:hdf_config"
]
}
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
}

View File

@ -57,7 +57,7 @@
LITE_OS_SEC_BSS LosProcessCB *g_processCBArray = NULL;
LITE_OS_SEC_DATA_INIT STATIC LOS_DL_LIST g_freeProcess;
LITE_OS_SEC_DATA_INIT STATIC LOS_DL_LIST g_processRecyleList;
LITE_OS_SEC_DATA_INIT STATIC LOS_DL_LIST g_processRecycleList;
LITE_OS_SEC_BSS UINT32 g_userInitProcess = OS_INVALID_VALUE;
LITE_OS_SEC_BSS UINT32 g_kernelInitProcess = OS_INVALID_VALUE;
LITE_OS_SEC_BSS UINT32 g_kernelIdleProcess = OS_INVALID_VALUE;
@ -183,7 +183,7 @@ VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID)
{
taskCB->waitID = wakePID;
OsSchedTaskWake(taskCB);
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
LOS_MpSchedule(OS_MP_CPU_ALL);
#endif
}
@ -312,7 +312,7 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
}
#endif
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
if (OsProcessIsUserMode(processCB)) {
LiteIpcPoolDelete(&(processCB->ipcInfo));
(VOID)memset_s(&(processCB->ipcInfo), sizeof(ProcIpcInfo), 0, sizeof(ProcIpcInfo));
@ -331,9 +331,9 @@ LITE_OS_SEC_TEXT STATIC VOID OsRecycleZombiesProcess(LosProcessCB *childCB, Proc
LOS_ListDelete(&childCB->pendList);
if (childCB->processStatus & OS_PROCESS_FLAG_EXIT) {
LOS_ListHeadInsert(&g_processRecyleList, &childCB->pendList);
LOS_ListHeadInsert(&g_processRecycleList, &childCB->pendList);
} else if (childCB->processStatus & OS_PROCESS_FLAG_GROUP_LEADER) {
LOS_ListTailInsert(&g_processRecyleList, &childCB->pendList);
LOS_ListTailInsert(&g_processRecycleList, &childCB->pendList);
} else {
OsInsertPCBToFreeList(childCB);
}
@ -413,7 +413,7 @@ STATIC VOID OsProcessNaturalExit(LosTaskCB *runTask, UINT32 status)
#ifdef LOSCFG_KERNEL_VM
(VOID)OsKill(processCB->parentProcessID, SIGCHLD, OS_KERNEL_KILL_PERMISSION);
#endif
LOS_ListHeadInsert(&g_processRecyleList, &processCB->pendList);
LOS_ListHeadInsert(&g_processRecycleList, &processCB->pendList);
OsRunTaskToDelete(runTask);
return;
}
@ -437,7 +437,7 @@ STATIC UINT32 OsProcessInit(VOID)
(VOID)memset_s(g_processCBArray, size, 0, size);
LOS_ListInit(&g_freeProcess);
LOS_ListInit(&g_processRecyleList);
LOS_ListInit(&g_processRecycleList);
for (index = 0; index < g_processMaxNum; index++) {
g_processCBArray[index].processID = index;
@ -457,14 +457,14 @@ STATIC UINT32 OsProcessInit(VOID)
return LOS_OK;
}
LITE_OS_SEC_TEXT VOID OsProcessCBRecyleToFree(VOID)
LITE_OS_SEC_TEXT VOID OsProcessCBRecycleToFree(VOID)
{
UINT32 intSave;
LosProcessCB *processCB = NULL;
SCHEDULER_LOCK(intSave);
while (!LOS_ListEmpty(&g_processRecyleList)) {
processCB = OS_PCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_processRecyleList));
while (!LOS_ListEmpty(&g_processRecycleList)) {
processCB = OS_PCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_processRecycleList));
if (!(processCB->processStatus & OS_PROCESS_FLAG_EXIT)) {
break;
}
@ -487,7 +487,7 @@ LITE_OS_SEC_TEXT VOID OsProcessCBRecyleToFree(VOID)
LOS_ListDelete(&processCB->pendList);
if ((processCB->processStatus & OS_PROCESS_FLAG_GROUP_LEADER) ||
(processCB->processStatus & OS_PROCESS_STATUS_ZOMBIES)) {
LOS_ListTailInsert(&g_processRecyleList, &processCB->pendList);
LOS_ListTailInsert(&g_processRecycleList, &processCB->pendList);
} else {
/* Clear the bottom 4 bits of process status */
OsInsertPCBToFreeList(processCB);
@ -525,7 +525,7 @@ STATIC VOID OsDeInitPCB(LosProcessCB *processCB)
processCB->processStatus &= ~OS_PROCESS_STATUS_INIT;
processCB->processStatus |= OS_PROCESS_FLAG_EXIT;
LOS_ListHeadInsert(&g_processRecyleList, &processCB->pendList);
LOS_ListHeadInsert(&g_processRecycleList, &processCB->pendList);
SCHEDULER_UNLOCK(intSave);
(VOID)LOS_MemFree(m_aucSysMem1, group);
@ -685,7 +685,7 @@ STATIC UINT32 OsProcessCreateInit(LosProcessCB *processCB, UINT32 flags, const C
goto EXIT;
}
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
if (OsProcessIsUserMode(processCB)) {
ret = LiteIpcPoolInit(&(processCB->ipcInfo));
if (ret != LOS_OK) {
@ -1005,7 +1005,7 @@ WAIT_BACK:
return LOS_OK;
}
STATIC UINT32 OsWaitRecycleChildPorcess(const LosProcessCB *childCB, UINT32 intSave, INT32 *status)
STATIC UINT32 OsWaitRecycleChildProcess(const LosProcessCB *childCB, UINT32 intSave, INT32 *status)
{
ProcessGroup *group = NULL;
UINT32 pid = childCB->processID;
@ -1081,7 +1081,7 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
}
if (childCB != NULL) {
return (INT32)OsWaitRecycleChildPorcess(childCB, intSave, status);
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status);
}
if ((options & LOS_WAIT_WNOHANG) != 0) {
@ -1104,7 +1104,7 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
goto ERROR;
}
return (INT32)OsWaitRecycleChildPorcess(childCB, intSave, status);
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status);
ERROR:
SCHEDULER_UNLOCK(intSave);
@ -1294,7 +1294,7 @@ LITE_OS_SEC_TEXT UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR
return ret;
}
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
ret = LiteIpcPoolInit(&(processCB->ipcInfo));
if (ret != LOS_OK) {
return LOS_NOK;
@ -1690,7 +1690,7 @@ STATIC UINT32 OsCopyProcessResources(UINT32 flags, LosProcessCB *child, LosProce
return ret;
}
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
if (OsProcessIsUserMode(child)) {
ret = LiteIpcPoolReInit(&child->ipcInfo, (const ProcIpcInfo *)(&run->ipcInfo));
if (ret != LOS_OK) {

View File

@ -122,12 +122,12 @@ STATIC INLINE UINT64 OsGetSortLinkNextExpireTime(SortLinkAttribute *sortHeader,
return expirTime;
}
STATIC Percpu *OsFindIdleCpu(UINT16 *ildeCpuID)
STATIC Percpu *OsFindIdleCpu(UINT16 *idleCpuID)
{
Percpu *idleCpu = OsPercpuGetByID(0);
*ildeCpuID = 0;
*idleCpuID = 0;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT16 cpuID = 1;
UINT32 nodeNum = idleCpu->taskSortLink.nodeNum + idleCpu->swtmrSortLink.nodeNum;
@ -136,7 +136,7 @@ STATIC Percpu *OsFindIdleCpu(UINT16 *ildeCpuID)
UINT32 temp = cpu->taskSortLink.nodeNum + cpu->swtmrSortLink.nodeNum;
if (nodeNum > temp) {
idleCpu = cpu;
*ildeCpuID = cpuID;
*idleCpuID = cpuID;
}
cpuID++;
@ -174,7 +174,7 @@ VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, Sort
LOS_SpinLockSave(spinLock, &intSave);
SET_SORTLIST_VALUE(node, startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK);
OsAddNode2SortLink(sortLinkHeader, node);
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
node->cpuid = idleCpu;
if (idleCpu != ArchCurrCpuid()) {
LOS_MpSchedule(CPUID_TO_AFFI_MASK(idleCpu));
@ -186,7 +186,7 @@ VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, Sort
VOID OsDeleteSortLink(SortLinkList *node, SortLinkType type)
{
UINT32 intSave;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
Percpu *cpu = OsPercpuGetByID(node->cpuid);
#else
Percpu *cpu = OsPercpuGetByID(0);

View File

@ -38,7 +38,7 @@
#include "los_task_pri.h"
#if (LOSCFG_BASE_CORE_SWTMR == YES)
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
#if (LOSCFG_BASE_CORE_SWTMR_LIMIT <= 0)
#error "swtmr maxnum cannot be zero"
#endif /* LOSCFG_BASE_CORE_SWTMR_LIMIT <= 0 */
@ -84,7 +84,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrTaskCreate(VOID)
swtmrTask.pcName = "Swt_Task";
swtmrTask.usTaskPrio = 0;
swtmrTask.uwResved = LOS_TASK_STATUS_DETACHED;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
swtmrTask.usCpuAffiMask = CPUID_TO_AFFI_MASK(cpuid);
#endif
ret = LOS_TaskCreate(&swtmrTaskID, &swtmrTask);
@ -533,4 +533,4 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrID)
return ret;
}
#endif /* LOSCFG_BASE_CORE_SWTMR */
#endif /* LOSCFG_BASE_CORE_SWTMR_ENABLE */

View File

@ -51,10 +51,10 @@
#ifdef LOSCFG_KERNEL_CPUP
#include "los_cpup_pri.h"
#endif
#if (LOSCFG_BASE_CORE_SWTMR == YES)
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
#include "los_swtmr_pri.h"
#endif
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
#include "hm_liteipc.h"
#endif
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK
@ -67,7 +67,7 @@
LITE_OS_SEC_BSS LosTaskCB *g_taskCBArray;
LITE_OS_SEC_BSS LOS_DL_LIST g_losFreeTask;
LITE_OS_SEC_BSS LOS_DL_LIST g_taskRecyleList;
LITE_OS_SEC_BSS LOS_DL_LIST g_taskRecycleList;
LITE_OS_SEC_BSS UINT32 g_taskMaxNum;
LITE_OS_SEC_BSS UINT32 g_taskScheduled; /* one bit for each cores */
LITE_OS_SEC_BSS EVENT_CB_S g_resourceEvent;
@ -98,7 +98,7 @@ VOID OsSetMainTask()
g_mainTask[i].taskStatus = OS_TASK_STATUS_UNUSED;
g_mainTask[i].taskID = LOSCFG_BASE_CORE_TSK_LIMIT;
g_mainTask[i].priority = OS_TASK_PRIORITY_LOWEST;
#if (LOSCFG_KERNEL_SMP_LOCKDEP == YES)
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
g_mainTask[i].lockDep.lockDepth = 0;
g_mainTask[i].lockDep.waitLock = NULL;
#endif
@ -201,14 +201,14 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
(VOID)memset_s(g_taskCBArray, size, 0, size);
LOS_ListInit(&g_losFreeTask);
LOS_ListInit(&g_taskRecyleList);
LOS_ListInit(&g_taskRecycleList);
for (index = 0; index < g_taskMaxNum; index++) {
g_taskCBArray[index].taskStatus = OS_TASK_STATUS_UNUSED;
g_taskCBArray[index].taskID = index;
LOS_ListTailInsert(&g_losFreeTask, &g_taskCBArray[index].pendList);
}
#if (LOSCFG_KERNEL_TRACE == YES)
#ifdef LOSCFG_KERNEL_TRACE
LOS_TraceReg(LOS_TRACE_TASK, OsTaskTrace, LOS_TRACE_TASK_NAME, LOS_TRACE_ENABLE);
#endif
@ -240,7 +240,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
taskInitParam.pcName = "Idle";
taskInitParam.usTaskPrio = OS_TASK_PRIORITY_LOWEST;
taskInitParam.processID = OsGetIdleProcessID();
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
#endif
ret = LOS_TaskCreateOnly(idleTaskID, &taskInitParam);
@ -381,7 +381,7 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskStackAlloc(VOID **topStack, UINT32 stack
STATIC INLINE UINT32 OsTaskSyncCreate(LosTaskCB *taskCB)
{
#if (LOSCFG_KERNEL_SMP_TASK_SYNC == YES)
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
UINT32 ret = LOS_SemCreate(0, &taskCB->syncSignal);
if (ret != LOS_OK) {
return LOS_ERRNO_TSK_MP_SYNC_RESOURCE;
@ -394,7 +394,7 @@ STATIC INLINE UINT32 OsTaskSyncCreate(LosTaskCB *taskCB)
STATIC INLINE VOID OsTaskSyncDestroy(UINT32 syncSignal)
{
#if (LOSCFG_KERNEL_SMP_TASK_SYNC == YES)
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
(VOID)LOS_SemDelete(syncSignal);
#else
(VOID)syncSignal;
@ -403,7 +403,7 @@ STATIC INLINE VOID OsTaskSyncDestroy(UINT32 syncSignal)
LITE_OS_SEC_TEXT UINT32 OsTaskSyncWait(const LosTaskCB *taskCB)
{
#if (LOSCFG_KERNEL_SMP_TASK_SYNC == YES)
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
UINT32 ret = LOS_OK;
LOS_ASSERT(LOS_SpinHeld(&g_taskSpin));
@ -428,7 +428,7 @@ LITE_OS_SEC_TEXT UINT32 OsTaskSyncWait(const LosTaskCB *taskCB)
STATIC INLINE VOID OsTaskSyncWake(const LosTaskCB *taskCB)
{
#if (LOSCFG_KERNEL_SMP_TASK_SYNC == YES)
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
(VOID)OsSemPostUnsafe(taskCB->syncSignal, NULL);
#else
(VOID)taskCB;
@ -450,8 +450,8 @@ LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
UINT32 intSave;
SCHEDULER_LOCK(intSave);
while (!LOS_ListEmpty(&g_taskRecyleList)) {
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecyleList));
while (!LOS_ListEmpty(&g_taskRecycleList)) {
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecycleList));
LOS_ListDelete(&taskCB->pendList);
SCHEDULER_UNLOCK(intSave);
@ -485,7 +485,7 @@ LITE_OS_SEC_TEXT VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
processCB->processID, taskCB->taskID, mapBase, mapSize, ret);
}
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
LiteIpcRemoveServiceHandle(taskCB);
#endif
}
@ -494,7 +494,7 @@ LITE_OS_SEC_TEXT VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
topOfStack = taskCB->topOfStack;
taskCB->topOfStack = 0;
#if (LOSCFG_KERNEL_SMP_TASK_SYNC == YES)
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
syncSignal = taskCB->syncSignal;
taskCB->syncSignal = LOSCFG_BASE_IPC_SEM_LIMIT;
#endif
@ -523,12 +523,12 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskCBInitBase(LosTaskCB *taskCB,
taskCB->taskEntry = initParam->pfnTaskEntry;
taskCB->signal = SIGNAL_NONE;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
taskCB->currCpu = OS_TASK_INVALID_CPUID;
taskCB->cpuAffiMask = (initParam->usCpuAffiMask) ?
initParam->usCpuAffiMask : LOSCFG_KERNEL_CPU_MASK;
#endif
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
LOS_ListInit(&(taskCB->msgListHead));
#endif
taskCB->policy = (initParam->policy == LOS_SCHED_FIFO) ? LOS_SCHED_FIFO : LOS_SCHED_RR;
@ -654,7 +654,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
LOS_ERREND_TCB_INIT:
(VOID)LOS_MemFree(pool, topStack);
LOS_ERREND_REWIND_SYNC:
#if (LOSCFG_KERNEL_SMP_TASK_SYNC == YES)
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
OsTaskSyncDestroy(taskCB->syncSignal);
#endif
LOS_ERREND_REWIND_TCB:
@ -769,7 +769,7 @@ LITE_OS_SEC_TEXT_INIT STATIC BOOL OsTaskSuspendCheckOnRun(LosTaskCB *taskCB, UIN
/* init default out return value */
*ret = LOS_OK;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/* ASYNCHRONIZED. No need to do task lock checking */
if (taskCB->currCpu != ArchCurrCpuid()) {
taskCB->signal = SIGNAL_SUSPEND;
@ -888,7 +888,7 @@ LITE_OS_SEC_TEXT VOID OsRunTaskToDelete(LosTaskCB *runTask)
LOS_ListDelete(&runTask->threadList);
processCB->threadNumber--;
LOS_ListTailInsert(&g_taskRecyleList, &runTask->pendList);
LOS_ListTailInsert(&g_taskRecycleList, &runTask->pendList);
OsEventWriteUnsafe(&g_resourceEvent, OS_RESOURCE_EVENT_FREE, FALSE, NULL);
OsSchedResched();
@ -909,7 +909,7 @@ STATIC BOOL OsRunTaskToDeleteCheckOnRun(LosTaskCB *taskCB, UINT32 *ret)
/* init default out return value */
*ret = LOS_OK;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/* ASYNCHRONIZED. No need to do task lock checking */
if (taskCB->currCpu != ArchCurrCpuid()) {
/*
@ -962,7 +962,7 @@ STATIC VOID OsTaskDeleteInactive(LosProcessCB *processCB, LosTaskCB *taskCB)
LOS_ListDelete(&taskCB->threadList);
processCB->threadNumber--;
LOS_ListTailInsert(&g_taskRecyleList, &taskCB->pendList);
LOS_ListTailInsert(&g_taskRecycleList, &taskCB->pendList);
return;
}
@ -994,7 +994,7 @@ LITE_OS_SEC_TEXT UINT32 OsTaskDeleteUnsafe(LosTaskCB *taskCB, UINT32 status, UIN
SCHEDULER_LOCK(intSave);
}
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
LOS_ASSERT(OsPercpuGet()->taskLockCnt == 1);
#else
LOS_ASSERT(OsPercpuGet()->taskLockCnt == 0);
@ -1235,7 +1235,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInf
LITE_OS_SEC_TEXT BOOL OsTaskCpuAffiSetUnsafe(UINT32 taskID, UINT16 newCpuAffiMask, UINT16 *oldCpuAffiMask)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
taskCB->cpuAffiMask = newCpuAffiMask;
@ -1286,7 +1286,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuAffiSet(UINT32 taskID, UINT16 cpuAffiMa
LITE_OS_SEC_TEXT_MINOR UINT16 LOS_TaskCpuAffiGet(UINT32 taskID)
{
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
#define INVALID_CPU_AFFI_MASK 0
LosTaskCB *taskCB = NULL;
UINT16 cpuAffiMask;
@ -1346,7 +1346,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTaskProcSignal(VOID)
/* suspend killed task may fail, ignore the result */
(VOID)LOS_TaskSuspend(runTask->taskID);
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
} else if (runTask->signal & SIGNAL_AFFI) {
runTask->signal &= ~SIGNAL_AFFI;
@ -1406,13 +1406,14 @@ STATIC VOID OsExitGroupActiveTaskKilled(LosProcessCB *processCB, LosTaskCB *task
INT32 ret;
taskCB->taskStatus |= OS_TASK_FLAG_EXIT_KILL;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/* The other core that the thread is running on and is currently running in a non-system call */
if (!taskCB->sig.sigIntLock && (taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
taskCB->signal = SIGNAL_KILL;
LOS_MpSchedule(taskCB->currCpu);
} else
#endif
#ifdef LOSCFG_KERNEL_VM
{
ret = OsTaskKillUnsafe(taskCB->taskID, SIGKILL);
if (ret != LOS_OK) {
@ -1420,6 +1421,7 @@ STATIC VOID OsExitGroupActiveTaskKilled(LosProcessCB *processCB, LosTaskCB *task
taskCB->processID, OsCurrTaskGet()->taskID, taskCB->taskID, ret);
}
}
#endif
if (!(taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN)) {
taskCB->taskStatus |= OS_TASK_FLAG_PTHREAD_JOIN;
@ -1648,7 +1650,7 @@ STATIC VOID OsResourceRecoveryTask(VOID)
if (ret & (OS_RESOURCE_EVENT_FREE | OS_RESOURCE_EVENT_OOM)) {
OsTaskCBRecycleToFree();
OsProcessCBRecyleToFree();
OsProcessCBRecycleToFree();
}
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK

View File

@ -57,7 +57,7 @@ LITE_OS_SEC_TEXT VOID OsTickHandler(VOID)
OsVdsoTimevalUpdate();
#endif
#if (LOSCFG_BASE_CORE_TICK_HW_TIME == YES)
#ifdef LOSCFG_BASE_CORE_TICK_HW_TIME
HalClockIrqClear(); /* diff from every platform */
#endif

View File

@ -43,7 +43,7 @@ extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
typedef enum {
CPU_RUNNING = 0, /* cpu is running */
CPU_HALT, /* cpu in the halt */
@ -66,7 +66,7 @@ typedef struct {
UINT32 swtmrTaskID; /* software timer task id */
UINT32 schedFlag; /* pending scheduler flag */
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT32 excFlag; /* cpu halt or exc flag */
#endif
} Percpu;

View File

@ -36,7 +36,7 @@
#include "los_sem_pri.h"
#include "los_process.h"
#include "los_vm_map.h"
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
#include "hm_liteipc.h"
#endif
#ifdef LOSCFG_SECURITY_CAPABILITY
@ -97,12 +97,12 @@ typedef struct ProcessCB {
volatile UINT32 threadNumber; /**< Number of threads alive under this process */
UINT32 threadCount; /**< Total number of threads created under this process */
LOS_DL_LIST waitList; /**< The process holds the waitLits to support wait/waitpid */
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT32 timerCpu; /**< CPU core number of this task is delayed or pended */
#endif
UINTPTR sigHandler; /**< Signal handler */
sigset_t sigShare; /**< Signal share bit */
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
ProcIpcInfo ipcInfo; /**< Memory pool for lite ipc */
#endif
#ifdef LOSCFG_KERNEL_VM
@ -443,7 +443,7 @@ extern UINTPTR __user_init_bss;
extern UINTPTR __user_init_end;
extern UINTPTR __user_init_load_addr;
extern UINT32 OsSystemProcessCreate(VOID);
extern VOID OsProcessCBRecyleToFree(VOID);
extern VOID OsProcessCBRecycleToFree(VOID);
extern VOID OsProcessResourcesToFree(LosProcessCB *processCB);
extern VOID OsProcessExit(LosTaskCB *runTask, INT32 status);
extern UINT32 OsUserInitProcess(VOID);

View File

@ -112,7 +112,7 @@ STATIC INLINE BOOL OsPreemptableInSched(VOID)
{
BOOL preemptable = FALSE;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/*
* For smp systems, schedule must hold the task spinlock, and this counter
* will increase by 1 in that case.

View File

@ -50,7 +50,7 @@ typedef enum {
typedef struct {
LOS_DL_LIST sortLinkNode;
UINT64 responseTime;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT32 cpuid;
#endif
} SortLinkList;

View File

@ -45,7 +45,9 @@
#include "los_cpup_pri.h"
#endif
#ifdef LOSCFG_KERNEL_TRACE
#include "los_trace.h"
#endif
#ifdef __cplusplus
#if __cplusplus
@ -344,14 +346,14 @@ typedef struct {
INT32 errorNo; /**< Error Num */
UINT32 signal; /**< Task signal */
sig_cb sig;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT16 currCpu; /**< CPU core number of this task is running on */
UINT16 lastCpu; /**< CPU core number of this task is running on last time */
UINT16 cpuAffiMask; /**< CPU affinity mask, support up to 16 cores */
#if (LOSCFG_KERNEL_SMP_TASK_SYNC == YES)
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
UINT32 syncSignal; /**< Synchronization for signal handling */
#endif
#if (LOSCFG_KERNEL_SMP_LOCKDEP == YES)
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
LockDep lockDep;
#endif
#endif
@ -368,7 +370,7 @@ typedef struct {
UINTPTR waitID; /**< Wait for the PID or GID of the child process */
UINT16 waitFlag; /**< The type of child process that is waiting, belonging to a group or parent,
a specific child process, or any child process */
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
UINT32 ipcStatus;
LOS_DL_LIST msgListHead;
BOOL accessMap[LOSCFG_BASE_CORE_TSK_LIMIT];

View File

@ -35,7 +35,7 @@
#include "los_mp.h"
#include "los_percpu_pri.h"
#include "los_sched_pri.h"
#if (LOSCFG_BASE_CORE_SWTMR == YES)
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
#include "los_exc.h"
#endif

View File

@ -199,6 +199,9 @@ STATIC INLINE VOID OsFutexReplaceQueueListHeadNode(FutexNode *oldHeadNode, Futex
LOS_DL_LIST *futexList = oldHeadNode->futexList.pstPrev;
LOS_ListDelete(&oldHeadNode->futexList);
LOS_ListHeadInsert(futexList, &newHeadNode->futexList);
if ((newHeadNode->queueList.pstNext == NULL) || (newHeadNode->queueList.pstPrev == NULL)) {
LOS_ListInit(&newHeadNode->queueList);
}
}
STATIC INLINE VOID OsFutexDeleteKeyFromFutexList(FutexNode *node)
@ -319,11 +322,10 @@ STATIC VOID OsFutexInsertNewFutexKeyToHash(FutexNode *node)
futexList != &(hashNode->lockList);
futexList = futexList->pstNext) {
headNode = OS_FUTEX_FROM_FUTEXLIST(futexList);
if (node->key <= headNode->key) {
if (node->key <= headNode->key) {
LOS_ListTailInsert(&(headNode->futexList), &(node->futexList));
break;
}
}
EXIT:
@ -797,6 +799,7 @@ EXIT_UNLOCK_ERR:
STATIC INT32 OsFutexRequeueInsertNewKey(UINTPTR newFutexKey, INT32 newIndex, FutexNode *oldHeadNode)
{
BOOL queueListIsEmpty = FALSE;
INT32 ret;
UINT32 intSave;
LosTaskCB *task = NULL;
@ -817,25 +820,33 @@ STATIC INT32 OsFutexRequeueInsertNewKey(UINTPTR newFutexKey, INT32 newIndex, Fut
nextNode = OS_FUTEX_FROM_QUEUELIST(queueList);
SCHEDULER_LOCK(intSave);
if (LOS_ListEmpty(&nextNode->pendList)) {
queueList = queueList->pstNext;
if (LOS_ListEmpty(queueList)) {
queueListIsEmpty = TRUE;
} else {
queueList = queueList->pstNext;
}
OsFutexDeinitFutexNode(nextNode);
SCHEDULER_UNLOCK(intSave);
if (queueList->pstNext != NULL) {
continue;
} else {
if (queueListIsEmpty) {
return LOS_OK;
}
continue;
}
task = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(nextNode->pendList)));
queueList = queueList->pstNext;
if (LOS_ListEmpty(queueList)) {
queueListIsEmpty = TRUE;
} else {
queueList = queueList->pstNext;
}
LOS_ListDelete(&nextNode->queueList);
ret = OsFutexInsertTasktoPendList(&newHeadNode, nextNode, task);
SCHEDULER_UNLOCK(intSave);
if (ret != LOS_OK) {
PRINT_ERR("Futex requeue insert new key failed!\n");
}
} while (queueList->pstNext != NULL);
} while (!queueListIsEmpty);
return LOS_OK;
}

View File

@ -38,7 +38,7 @@
#include "los_sched_pri.h"
#if (LOSCFG_BASE_IPC_MUX == YES)
#ifdef LOSCFG_BASE_IPC_MUX
#define MUTEXATTR_TYPE_MASK 0x0FU
LITE_OS_SEC_TEXT UINT32 LOS_MuxAttrInit(LosMuxAttr *attr)
@ -560,5 +560,5 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxUnlock(LosMux *mutex)
return ret;
}
#endif /* (LOSCFG_BASE_IPC_MUX == YES) */
#endif /* LOSCFG_BASE_IPC_MUX */

View File

@ -38,7 +38,7 @@
#include "los_percpu_pri.h"
#if (LOSCFG_BASE_IPC_QUEUE == YES)
#ifdef LOSCFG_BASE_IPC_QUEUE
#if (LOSCFG_BASE_IPC_QUEUE_LIMIT <= 0)
#error "queue maxnum cannot be zero"
#endif /* LOSCFG_BASE_IPC_QUEUE_LIMIT <= 0 */
@ -493,5 +493,5 @@ QUEUE_END:
return ret;
}
#endif /* (LOSCFG_BASE_IPC_QUEUE == YES) */
#endif /* LOSCFG_BASE_IPC_QUEUE */

View File

@ -40,7 +40,7 @@
#include "los_percpu_pri.h"
#if (LOSCFG_BASE_IPC_SEM == YES)
#ifdef LOSCFG_BASE_IPC_SEM
#if (LOSCFG_BASE_IPC_SEM_LIMIT <= 0)
#error "sem maxnum cannot be zero"
@ -283,5 +283,5 @@ LITE_OS_SEC_TEXT UINT32 LOS_SemPost(UINT32 semHandle)
return ret;
}
#endif /* (LOSCFG_BASE_IPC_SEM == YES) */
#endif /* LOSCFG_BASE_IPC_SEM */

View File

@ -101,11 +101,13 @@ STATIC UINT32 OsPendingTaskWake(LosTaskCB *taskCB, INT32 signo)
case OS_TASK_WAIT_SIGNAL:
OsSigWaitTaskWake(taskCB, signo);
break;
#ifdef LOSCFG_KERNEL_LITEIPC
case OS_TASK_WAIT_LITEIPC:
taskCB->ipcStatus &= ~IPC_THREAD_STATUS_PEND;
OsTaskWakeClearPendMask(taskCB);
OsSchedTaskWake(taskCB);
break;
#endif
case OS_TASK_WAIT_FUTEX:
OsFutexNodeDeleteFromFutexHash(&taskCB->futex, TRUE, NULL, NULL);
OsTaskWakeClearPendMask(taskCB);
@ -132,7 +134,7 @@ int OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info)
if (masked) {
/* If signal is in wait list and mask list, need unblock it */
if (LOS_ListEmpty(&sigcb->waitList) ||
(!LOS_ListEmpty(&sigcb->waitList) && !OsSigIsMember(&sigcb->sigwaitmask, info->si_signo))) {
(!LOS_ListEmpty(&sigcb->waitList) && !OsSigIsMember(&sigcb->sigwaitmask, info->si_signo))) {
OsSigAddSet(&sigcb->sigPendFlag, info->si_signo);
}
} else {
@ -308,7 +310,7 @@ int OsSigProcessSend(LosProcessCB *spcb, siginfo_t *sigInfo)
.receivedTcb = NULL
};
if (info.sigInfo == NULL){
if (info.sigInfo == NULL) {
return -EFAULT;
}
@ -676,6 +678,7 @@ VOID *OsRestorSignalContext(VOID *sp)
LosProcessCB *process = OsCurrProcessGet();
VOID *saveContext = sigcb->sigContext;
sigcb->sigContext = NULL;
sigcb->count--;
process->sigShare = 0;
OsProcessExitCodeSignalClear(process);

View File

@ -147,7 +147,7 @@ struct OsMemPoolInfo {
VOID *pool;
UINT32 totalSize;
UINT32 attr;
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
UINT32 waterLine; /* Maximum usage size in a memory pool */
UINT32 curUsedSize; /* Current usage size in a memory pool */
#endif
@ -230,7 +230,7 @@ STATIC INLINE VOID OsMemNodeSetTaskID(struct OsMemUsedNodeHead *node)
}
#endif
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
STATIC INLINE VOID OsMemWaterUsedRecord(struct OsMemPoolHead *pool, UINT32 size)
{
pool->info.curUsedSize += size;
@ -775,7 +775,7 @@ STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
endNode->ptr.prev = newNode;
OS_MEM_NODE_SET_USED_FLAG(endNode->sizeAndFlag);
#endif
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
poolHead->info.curUsedSize = sizeof(struct OsMemPoolHead) + OS_MEM_NODE_HEAD_SIZE;
poolHead->info.waterLine = poolHead->info.curUsedSize;
#endif
@ -1171,7 +1171,7 @@ STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead
return ret;
}
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
pool->info.curUsedSize -= OS_MEM_NODE_GET_SIZE(node->sizeAndFlag);
#endif
@ -1256,14 +1256,14 @@ UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
STATIC INLINE VOID OsMemReAllocSmaller(VOID *pool, UINT32 allocSize, struct OsMemNodeHead *node, UINT32 nodeSize)
{
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
struct OsMemPoolHead *poolInfo = (struct OsMemPoolHead *)pool;
#endif
node->sizeAndFlag = nodeSize;
if ((allocSize + OS_MEM_NODE_HEAD_SIZE + OS_MEM_MIN_ALLOC_SIZE) <= nodeSize) {
OsMemSplitNode(pool, node, allocSize);
OS_MEM_NODE_SET_USED_FLAG(node->sizeAndFlag);
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
poolInfo->info.curUsedSize -= nodeSize - allocSize;
#endif
}
@ -1603,7 +1603,7 @@ STATIC VOID OsMemPoolHeadCheck(const struct OsMemPoolHead *pool)
OUT:
if (flag) {
PRINTK("mem pool info: poolAddr: %#x, poolSize: 0x%x\n", pool, pool->info.totalSize);
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
PRINTK("mem pool info: poolWaterLine: 0x%x, poolCurUsedSize: 0x%x\n", pool->info.waterLine,
pool->info.curUsedSize);
#endif
@ -1844,7 +1844,7 @@ UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus)
OsMemInfoGet(poolInfo, tmpNode, poolStatus);
}
#endif
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
poolStatus->usageWaterLine = poolInfo->info.waterLine;
#endif
MEM_UNLOCK(poolInfo, intSave);
@ -1861,7 +1861,7 @@ STATIC VOID OsMemInfoPrint(VOID *pool)
return;
}
#if defined(OS_MEM_WATERLINE) && (OS_MEM_WATERLINE == YES)
#ifdef LOSCFG_MEM_WATERLINE
PRINTK("pool addr pool size used size free size "
"max free node size used node num free node num UsageWaterLine\n");
PRINTK("--------------- -------- ------- -------- "

View File

@ -35,7 +35,6 @@
#include "shell.h"
#endif
#include "los_swtmr_pri.h"
#include "watchdog_if.h"
#ifdef LOSCFG_SHELL_CMD_DEBUG
@ -46,6 +45,7 @@ LITE_OS_SEC_TEXT_MINOR BOOL OsSystemExcIsReset(VOID)
return systemExcReset;
}
#ifdef LOSCFG_DRIVERS_HDF_PLATFORM_WATCHDOG
#include "watchdog_if.h"
#define WATCHDOG_TIMER_INTERVAL 5 // 5 seconds
#define WATCHDOG_TIMER_INTERVAL_HALF (WATCHDOG_TIMER_INTERVAL / 2)

View File

@ -119,9 +119,21 @@ UINT32 OsShellCmdSwtmrCntGet(VOID)
LITE_OS_SEC_TEXT_MINOR VOID OsShellCmdSystemInfoGet(VOID)
{
UINT8 isTaskEnable = YES;
UINT8 isSemEnable = LOSCFG_BASE_IPC_SEM;
UINT8 isQueueEnable = LOSCFG_BASE_IPC_QUEUE;
UINT8 isSwtmrEnable = LOSCFG_BASE_CORE_SWTMR;
#ifdef LOSCFG_BASE_IPC_SEM
UINT8 isSemEnable = YES;
#else
UINT8 isSemEnable = NO;
#endif
#ifdef LOSCFG_BASE_IPC_QUEUE
UINT8 isQueueEnable = YES;
#else
UINT8 isQueueEnable = NO;
#endif
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
UINT8 isSwtmrEnable = YES;
#else
UINT8 isSwtmrEnable = NO;
#endif
PRINTK("\n Module Used Total Enabled\n");
PRINTK("--------------------------------------------\n");

View File

@ -85,12 +85,18 @@ STATIC UINT32 *taskWaterLine = NULL;
#define OS_TASK_ALL_INFO_LEN (g_taskMaxNum * (sizeof(LosTaskCB) + sizeof(UINT32)))
#ifdef LOSCFG_FS_VFS
#if defined(LOSCFG_BLACKBOX) && defined(LOSCFG_SAVE_EXCINFO)
#define SaveExcInfo(arg, ...) WriteExcInfoToBuf(arg, ##__VA_ARGS__)
#else
#define SaveExcInfo(arg, ...)
#endif
#define PROCESS_INFO_SHOW(seqBuf, arg...) do { \
if (seqBuf != NULL) { \
(void)LosBufPrintf((struct SeqBuf *)seqBuf, ##arg); \
} else { \
PRINTK(arg); \
} \
SaveExcInfo(arg); \
} while (0)
#else
#define PROCESS_INFO_SHOW(seqBuf, arg...) PRINTK(arg)
@ -428,7 +434,7 @@ EXIT:
STATIC VOID OsShellCmdTskInfoTitle(VOID *seqBuf, UINT16 flag)
{
PROCESS_INFO_SHOW(seqBuf, "\r\n TID PID ");
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
PROCESS_INFO_SHOW(seqBuf, "Affi CPU ");
#endif
PROCESS_INFO_SHOW(seqBuf, " Status StackSize WaterLine ");
@ -456,7 +462,7 @@ STATIC INLINE VOID OsShellTskInfoData(const LosTaskCB *taskCB, VOID *seqBuf, UIN
#endif
PROCESS_INFO_SHOW(seqBuf, " %4u%5u", taskCB->taskID, taskCB->processID);
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
PROCESS_INFO_SHOW(seqBuf, "%#5x%4d ", taskCB->cpuAffiMask, (INT16)(taskCB->currCpu));
#endif

View File

@ -37,7 +37,7 @@
#include "los_exc.h"
#if (LOSCFG_KERNEL_SMP_LOCKDEP == YES)
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
#define LOCKDEP_GET_NAME(lockDep, index) (((SPIN_LOCK_S *)((lockDep)->heldLocks[(index)].lockPtr))->name)
#define LOCKDEP_GET_ADDR(lockDep, index) ((lockDep)->heldLocks[(index)].lockAddr)

View File

@ -36,7 +36,7 @@
#include "los_swtmr.h"
#include "los_task_pri.h"
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
VOID LOS_MpSchedule(UINT32 target)
{

View File

@ -30,7 +30,7 @@
*/
#include "los_spinlock.h"
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
#include "los_sched_pri.h"

View File

@ -32,7 +32,7 @@
#include "los_task_pri.h"
#if (LOSCFG_KERNEL_SCHED_STATISTICS == YES)
#ifdef LOSCFG_KERNEL_SCHED_STATISTICS
#define HIGHTASKPRI 16
#define NS_PER_MS 1000000
#define DECIMAL_TO_PERCENTAGE 100
@ -212,7 +212,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsShellMpStaticStart(VOID)
for (loop = 0; loop < g_taskMaxNum; loop++) {
taskCB = (((LosTaskCB *)g_taskCBArray) + loop);
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
cpuid = taskCB->currCpu;
#endif
if ((UINT32)(OS_TASK_INVALID_CPUID) == cpuid) {
@ -293,7 +293,7 @@ LITE_OS_SEC_TEXT_MINOR VOID OsShellMpStaticStop(VOID)
for (loop = 0; loop < g_taskMaxNum; loop++) {
taskCB = (((LosTaskCB *)g_taskCBArray) + loop);
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
cpuid = taskCB->currCpu;
#endif
if (cpuid == (UINT32)(OS_TASK_INVALID_CPUID)) {

View File

@ -39,7 +39,7 @@
#endif
#include "los_hw_tick_pri.h"
#include "los_tick_pri.h"
#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
#include "los_stackinfo_pri.h"
#endif
#include "los_mp.h"
@ -443,7 +443,7 @@ STATIC INLINE VOID OsSchedWakePendTimeTask(UINT64 currTime, LosTaskCB *taskCB, B
if (tempStatus & (OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) {
taskCB->taskStatus &= ~(OS_TASK_STATUS_PENDING | OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY);
if (tempStatus & OS_TASK_STATUS_PENDING) {
#if (LOSCFG_KERNEL_LITEIPC == YES)
#ifdef LOSCFG_KERNEL_LITEIPC
taskCB->ipcStatus &= ~IPC_THREAD_STATUS_PEND;
#endif
taskCB->taskStatus |= OS_TASK_STATUS_TIMEOUT;
@ -819,7 +819,7 @@ STATIC LosTaskCB *OsGetTopTask(VOID)
UINT32 bitmap;
LosTaskCB *newTask = NULL;
UINT32 processBitmap = g_sched->queueBitmap;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
UINT32 cpuid = ArchCurrCpuid();
#endif
@ -830,11 +830,11 @@ STATIC LosTaskCB *OsGetTopTask(VOID)
while (bitmap) {
priority = CLZ(bitmap);
LOS_DL_LIST_FOR_EACH_ENTRY(newTask, &queueList->priQueueList[priority], LosTaskCB, pendList) {
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
if (newTask->cpuAffiMask & (1U << cpuid)) {
#endif
goto FIND_TASK;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
}
#endif
}
@ -869,7 +869,7 @@ VOID OsSchedStart(VOID)
OsSchedSetStartTime(HalClockGetCycles());
newTask->startTime = OsGerCurrSchedTimeCycle();
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/*
* attention: current cpu needs to be set, in case first task deletion
* may fail because this flag mismatch with the real current cpu.
@ -889,7 +889,7 @@ VOID OsSchedStart(VOID)
OsTaskContextLoad(newTask);
}
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
VOID OsSchedToUserReleaseLock(VOID)
{
/* The scheduling lock needs to be released before returning to user mode */
@ -900,7 +900,7 @@ VOID OsSchedToUserReleaseLock(VOID)
}
#endif
#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
STATIC VOID OsTaskStackCheck(LosTaskCB *runTask, LosTaskCB *newTask)
{
if (!OS_STACK_MAGIC_CHECK(runTask->topOfStack)) {
@ -917,9 +917,9 @@ STATIC VOID OsTaskStackCheck(LosTaskCB *runTask, LosTaskCB *newTask)
STATIC INLINE VOID OsSchedSwitchCheck(LosTaskCB *runTask, LosTaskCB *newTask)
{
#if (LOSCFG_BASE_CORE_TSK_MONITOR == YES)
#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
OsTaskStackCheck(runTask, newTask);
#endif /* LOSCFG_BASE_CORE_TSK_MONITOR == YES */
#endif /* LOSCFG_BASE_CORE_TSK_MONITOR */
OsTraceTaskSchedule(newTask, runTask);
}
@ -955,7 +955,7 @@ STATIC VOID OsSchedTaskSwicth(LosTaskCB *runTask, LosTaskCB *newTask)
runTask->taskStatus &= ~OS_TASK_STATUS_RUNNING;
newTask->taskStatus |= OS_TASK_STATUS_RUNNING;
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
/* mask new running task's owner processor */
runTask->currCpu = OS_TASK_INVALID_CPUID;
newTask->currCpu = ArchCurrCpuid();
@ -1043,7 +1043,7 @@ VOID OsSchedIrqEndCheckNeedSched(VOID)
VOID OsSchedResched(VOID)
{
LOS_ASSERT(LOS_SpinHeld(&g_taskSpin));
#if (LOSCFG_KERNEL_SMP == YES)
#ifdef LOSCFG_KERNEL_SMP
LOS_ASSERT(OsPercpuGet()->taskLockCnt == 1);
#else
LOS_ASSERT(OsPercpuGet()->taskLockCnt == 0);

View File

@ -41,10 +41,12 @@
#include "los_vm_fault.h"
#include "los_process_pri.h"
#include "los_vm_lock.h"
#ifdef LOSCFG_FS_VFS
#include "vnode.h"
#endif
#ifndef UNUSED
#define UNUSED(x) (VOID)x
#define UNUSED(x) (VOID)(x)
#endif
#ifdef LOSCFG_DEBUG_VERSION

View File

@ -34,7 +34,6 @@
#include "los_vm_zone.h"
#include "los_vm_common.h"
#include "los_vm_map.h"
#include "los_vm_lock.h"
#include "los_memory.h"

View File

@ -37,7 +37,7 @@
#include "los_vm_phys.h"
#include "los_vm_filemap.h"
#include "los_process_pri.h"
#if (LOSCFG_BASE_CORE_SWTMR == YES)
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
#include "los_swtmr_pri.h"
#endif
@ -55,12 +55,12 @@ LITE_OS_SEC_TEXT_MINOR STATIC UINT32 OomScoreProcess(LosProcessCB *candidateProc
{
UINT32 actualPm;
#if (LOSCFG_KERNEL_SMP != YES)
#ifndef LOSCFG_KERNEL_SMP
(VOID)LOS_MuxAcquire(&candidateProcess->vmSpace->regionMux);
#endif
/* we only consider actual physical memory here. */
OsUProcessPmUsage(candidateProcess->vmSpace, NULL, &actualPm);
#if (LOSCFG_KERNEL_SMP != YES)
#ifndef LOSCFG_KERNEL_SMP
(VOID)LOS_MuxRelease(&candidateProcess->vmSpace->regionMux);
#endif
return actualPm;

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