Compare commits

..

2 Commits

Author SHA1 Message Date
openharmony_ci
b7030357cd !469 -- 为hispark_taurus打开ADC模块编译宏
Merge pull request !469 from 王亚枫/OpenHarmony-2.3-Beta
2021-07-27 14:26:11 +00:00
yafeng_wang
6b4aa6a4c9 feat: Open macro for ADC moudule
Signed-off-by: yafeng_wang <wangyafeng15@huawei.com>
2021-07-27 21:39:27 +08:00
402 changed files with 4474 additions and 9575 deletions

6
.gitignore vendored
View File

@@ -17,9 +17,9 @@ tags
# Menuconfig temp files
/config.h
/defconfig
/.config
/.config.old
.config
.config.old
# Build temp files
/platform/board.ld
/out

359
BUILD.gn
View File

@@ -28,346 +28,47 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//build/lite/config/component/lite_component.gni")
declare_args() {
tee_enable = false
liteos_name = "OHOS_Image"
}
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
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/kernel_configs/${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",
[
"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")
import("//build/lite/config/subsystem/lite_subsystem.gni")
generate_notice_file("kernel_notice_file") {
module_name = "kernel"
module_source_dir_list = [
"$LITEOSTHIRDPARTY/FreeBSD",
"$LITEOSTHIRDPARTY/musl",
"$LITEOSTHIRDPARTY/zlib",
"$LITEOSTHIRDPARTY/FatFs",
"$LITEOSTHIRDPARTY/Linux_Kernel",
"$LITEOSTHIRDPARTY/lwip",
"$LITEOSTHIRDPARTY/NuttX",
"$LITEOSTHIRDPARTY/mtd-utils",
"//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",
]
}
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",
declare_args() {
enable_ohos_kernel_liteos_a_ext_build = true
LOSCFG_TEST_APPS = false
tee_enable = ""
}
lite_subsystem("kernel") {
subsystem_components = []
if (enable_ohos_kernel_liteos_a_ext_build == false) {
subsystem_components += [
"//kernel/liteos_a/kernel",
"//kernel/liteos_a/net",
"//kernel/liteos_a/lib",
"//kernel/liteos_a/compat",
"//kernel/liteos_a/fs",
"//kernel/liteos_a/arch:platform_cpu",
]
}
}
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
if (ohos_build_compiler == "clang") {
cc += " --target=$target_triple"
}
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")
cflags = [
"-isystem",
std_include,
]
asmflags = cflags
}
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",
]
configs += [
"$HDFTOPDIR:public",
"//drivers/liteos:public",
]
if (HAVE_DEVICE_SDK) {
configs += [ "$device_path:public" ]
}
}
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 (LOSCFG_SHELL) {
subsystem_components += [ "//kernel/liteos_a/shell" ]
}
}
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" ]
deps = [ ":make" ]
deps += [ "//kernel/liteos_a/testsuites/unittest:unittest" ]
}
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",
":std_include",
]
}
executable("liteos") {
configs = [] # clear default configs
configs += [ ":los_config" ]
configs += [ ":public" ]
ldflags = [
"-static",
"-Wl,--gc-sections",
"-Wl,-Map=$liteos_name.map",
"-Wl,--no-eh-frame-hdr",
]
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 += [ "-Wl,-nostartfiles" ]
}
output_dir = target_out_dir
output_name = liteos_name
deps = [
":modules",
]
}
copy("copy_liteos") {
deps = [ ":liteos" ]
sources = [ "$target_out_dir/unstripped/bin/$liteos_name" ]
outputs = [ "$root_out_dir/{{source_file_part}}" ]
}
build_ext_component("build_kernel_image") {
deps = [ ":copy_liteos" ]
exec_path = rebase_path(root_out_dir)
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
command += " && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
}
group("modules") {
deps = [
"arch",
"bsd",
"compat",
"drivers",
"fs",
"kernel",
"lib",
"net",
"platform",
"security",
"shell",
"syscall",
]
deps += [
"$HDFTOPDIR",
"//drivers/liteos",
]
if (HAVE_DEVICE_SDK) {
deps += [ device_path ]
}
}
group("apps") {
deps = [ "apps" ]
}
group("tests") {
deps = [ "testsuites" ]
}
group("kernel") {
deps = [ ":build_kernel_image" ]
}
group("liteos_a") {
deps = [
":apps",
":kernel",
":tests",
]
}
build_ext_component("make") {

13
Kconfig
View File

@@ -58,7 +58,7 @@ source "platform/Kconfig"
source "arch/Kconfig"
######################### config options of rootfs #####################
source "kernel/common/rootfs/Kconfig"
source "kernel/common/Kconfig"
######################### config options of patchfs #####################
source "kernel/common/patchfs/Kconfig"
######################### config options of blackbox #####################
@@ -93,7 +93,6 @@ 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
@@ -164,16 +163,9 @@ 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
@@ -303,7 +295,8 @@ source "bsd/dev/usb/Kconfig"
source "../../drivers/adapter/khdf/liteos/Kconfig"
# Device driver Kconfig import
osource "$(DEVICE_PATH)/drivers/Kconfig"
osource "$(DEVICE_PATH)/Kconfig"
osource "$(DEVICE_PATH)/config/Kconfig"
source "drivers/char/mem/Kconfig"
source "drivers/char/quickstart/Kconfig"

240
Makefile
View File

@@ -27,64 +27,37 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
LITEOSTOPDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
LITEOSTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
export OS=$(shell uname -s)
ifneq ($(OS), Linux)
LITEOSTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTOPDIR))/./)
endif
LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
export LITEOSTOPDIR
export LITEOSTHIRDPARTY
RM = -rm -rf
MAKE = make
__LIBS = libs
APPS = apps
ROOTFSDIR = rootfsdir
ROOTFS = rootfs
LITEOS_TARGET = liteos
LITEOS_LIBS_TARGET = libs
# by the following eval, we would got some variables like these:
# ohos_root_path=/xx
# ohos_board=hispark_taurus
# ohos_kernel=liteos_a
# ohos_product=ipcamera_hispark_taurus
# ohos_product_path=/xx/vendor/hisilicon/hispark_taurus
# ohos_device_path=/xx/device/hisilicon/hispark_taurus/sdk_liteos
ohos_kernel ?= liteos_a
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
ifneq ($(ohos_kernel),liteos_a)
$(error The selected product ($(ohos_product)) is not a liteos_a kernel type product)
endif
LITEOS_LIBS_TARGET = libs_target
LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform
export CONFIG_=LOSCFG_
export srctree=$(LITEOSTOPDIR)
SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot
export SYSROOT_PATH
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
export LITEOS_MENUCONFIG_H
CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
export CONFIG_FILE
ifeq ($(PRODUCT_PATH),)
PRODUCT_PATH:=$(ohos_product_path)
endif
export PRODUCT_PATH
ifeq ($(DEVICE_PATH),)
DEVICE_PATH:=$(ohos_device_path)
endif
export DEVICE_PATH
ifeq ($(TEE:1=y),y)
tee = _tee
endif
ifeq ($(RELEASE:1=y),y)
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/release$(tee).config
else
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
export PRODUCT_PATH=$(LITEOSTOPDIR)/../../device/hisilicon/drivers
endif
KCONFIG_CONFIG ?= $(CONFIG)
export KCONFIG_CONFIG
ifeq ($(shell which menuconfig),)
$(shell pip install --user kconfiglib >/dev/null)
endif
$(shell env CONFIG_=$(CONFIG_) PRODUCT_PATH=$(PRODUCT_PATH) olddefconfig >/dev/null)
-include $(LITEOSTOPDIR)/tools/build/config.mk
@@ -104,36 +77,41 @@ ROOTFS_DIR = $(OUT)/rootfs
ROOTFS_ZIP = $(OUT)/rootfs.zip
VERSION =
define HELP =
-------------------------------------------------------
Usage: make [TARGET]... [PARAMETER=VALUE]...
SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot
export SYSROOT_PATH
Targets:
help: display this help and exit
clean: clean compiled objects
cleanall: clean all build outputs
all: make liteos kernel image and rootfs image (Default target)
rootfs: make a original rootfs image
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
$(LITEOS_TARGET): make liteos kernel image
update_config: update product kernel config (use menuconfig)
test: make the testsuits_app and put it into the rootfs dir
test_apps: make a rootfs img with the testsuits_app in it
Parameters:
FSTYPE: value should be one of (jffs2 vfat yaffs2)
TEE: boolean value(1 or y for true), enable tee
RELEASE: boolean value(1 or y for true), build release version
CONFIG: kernel config file to be use
-------------------------------------------------------
endef
export HELP
all: $(LITEOS_TARGET) $(ROOTFS)
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
help:
$(HIDE)echo "$$HELP"
$(HIDE)echo "-------------------------------------------------------"
$(HIDE)echo "1.====make help: get help infomation of make"
$(HIDE)echo "2.====make: make a debug version based the .config"
$(HIDE)echo "3.====make debug: make a debug version based the .config"
$(HIDE)echo "4.====make release: make a release version for all platform"
$(HIDE)echo "5.====make release PLATFORM=xxx: make a release version only for platform xxx"
$(HIDE)echo "6.====make rootfsdir: make a original rootfs dir"
$(HIDE)echo "7.====make rootfs FSTYPE=***: make a original rootfs img"
$(HIDE)echo "8.====make test: make the testsuits_app and put it into the rootfs dir"
$(HIDE)echo "9.====make test_apps FSTYPE=***: make a rootfs img with the testsuits_app in it"
$(HIDE)echo "xxx should be one of (hi3516cv300 hi3516ev200 hi3556av100/cortex-a53_aarch32 hi3559av100/cortex-a53_aarch64)"
$(HIDE)echo "*** should be one of (jffs2)"
$(HIDE)echo "-------------------------------------------------------"
debug:
$(HIDE)echo "=============== make a debug version ==============="
$(HIDE) $(MAKE) all
release:
ifneq ($(PLATFORM),)
$(HIDE)echo "=============== make a release version for platform $(PLATFORM) ==============="
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh $(PLATFORM)
else
$(HIDE)echo "================make a release version for all platform ==============="
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh
endif
##### make sysroot #####
sysroot:
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
ifeq ($(wildcard $(SYSROOT_PATH)/usr/include/$(LLVM_TARGET)/),)
@@ -142,74 +120,104 @@ endif
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
endif
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
$(KCONFIG_CMDS):
$(HIDE)$@ $(args)
##### make dynload #####
-include $(LITEOS_MK_PATH)/dynload.mk
$(LITEOS_MENUCONFIG_H) $(CONFIG_FILE): $(KCONFIG_CONFIG)
$(HIDE)genconfig --config-out $(CONFIG_FILE) --header-path $(LITEOS_MENUCONFIG_H) $(args)
#-----need move when make version-----#
##### make lib #####
$(__LIBS): $(OUT) $(CXX_INCLUDE)
update_config:
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)"
$(OUT): $(LITEOS_MENUCONFIG_H)
$(HIDE)mkdir -p $(OUT)/lib
$(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \
-I$(LITEOS_PLATFORM_BASE)/include -imacros $< -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
-o $(LITEOS_PLATFORM_BASE)/board.ld -P
prepare: $(LITEOS_MENUCONFIG_H)
$(HIDE)mkdir -p $(OUT)/musl $(OUT)/lib $(BUILD)
$(BUILD):
$(HIDE)mkdir -p $(BUILD)
$(LITEOS_LIBS_TARGET): prepare
$(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:
$(HIDE)menuconfig
##### menuconfig end #######
$(LITEOS_MENUCONFIG_H): .config
$(HIDE)genconfig
$(LITEOS_TARGET): $(__LIBS) sysroot
$(HIDE)touch $(LOSCFG_ENTRY_SRC)
$(HIDE)for dir in $(LITEOS_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).map
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).objsize
$(LITEOS_TARGET): $(LITEOS_TARGET_DIR)/$(LITEOS_TARGET).bin
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).sym.sorted
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).asm
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).size
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
do $(MAKE) -C $$dir all || exit 1; \
done
$(OUT)/$(LITEOS_TARGET): $(LITEOS_LIBS_TARGET)
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) -Map=$@.map -o $@ --start-group $(LITEOS_LIBDEP) --end-group
$(OUT)/$(LITEOS_TARGET).map: $(OUT)/$(LITEOS_TARGET)
$(OUT)/$(LITEOS_TARGET).objsize: $(LITEOS_LIBS_TARGET)
$(SIZE) -t --common $(OUT)/lib/*.a >$@
$(LITEOS_TARGET_DIR)/$(LITEOS_TARGET).bin: $(OUT)/$(LITEOS_TARGET)
$(OBJCOPY) -O binary $< $@
$(OUT)/$(LITEOS_TARGET).sym.sorted: $(OUT)/$(LITEOS_TARGET)
$(OBJDUMP) -t $< |sort >$@
$(OUT)/$(LITEOS_TARGET).asm: $(OUT)/$(LITEOS_TARGET)
$(OBJDUMP) -d $< >$@
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
$(NM) -S --size-sort $< >$@
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group
# $(SIZE) -t --common $(OUT)/lib/*.a >$(OUT)/$@.objsize
$(OBJCOPY) -O binary $(OUT)/$@ $(LITEOS_TARGET_DIR)/$@.bin
$(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted
$(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
# $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
$(APPS): prepare
$(APPS): $(LITEOS_TARGET) sysroot
$(HIDE)$(MAKE) -C apps all
$(ROOTFS): $(APPS)
prepare:
$(HIDE)mkdir -p $(OUT)/musl
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
$(HIDE)cp -fp $$($(CC) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
$(HIDE)cp -fp $$($(GPP) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CXXFLAGS) -print-file-name=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 -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
endif
$(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
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libgcc_s.so.1 $(OUT)/musl
$(STRIP) $(OUT)/musl/*
endif
$(ROOTFSDIR): prepare $(APPS)
$(HIDE)$(MAKE) clean -C apps
$(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
$(ROOTFS): $(ROOTFSDIR)
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
clean:
$(HIDE)for dir in $(LITEOS_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
do $(MAKE) -C $$dir clean|| exit 1; \
done
$(HIDE)$(MAKE) -C apps clean
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H) $(CONFIG_FILE)
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
$(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
$(HIDE)$(RM) include/config include/generated
$(HIDE)$(MAKE) cleanrootfs
$(HIDE)echo "clean $(LITEOS_PLATFORM) finish"
cleanall: clean
$(HIDE)$(RM) $(LITEOSTOPDIR)/out
$(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_PLATFORM_BASE)/board.ld
$(HIDE)echo "clean all done"
.PHONY: all clean cleanall prepare sysroot help update_config
.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET)
cleanrootfs:
$(HIDE)$(RM) $(OUT)/rootfs
$(HIDE)$(RM) $(OUT)/rootfs.zip
$(HIDE)$(RM) $(OUT)/rootfs.img
update_all_config:
$(HIDE)shopt -s globstar && for f in tools/build/config/**/*.config ; \
do \
echo updating $$f; \
test -f $$f && cp $$f .config && olddefconfig && savedefconfig --out $$f; \
done
update_config:
$(HIDE)test -f "$(CONFIG)" && cp "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(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)

83
OAT.xml
View File

@@ -1,83 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
-->
<configuration>
<oatconfig>
<licensefile></licensefile>
<policylist>
<policy name="projectPolicy" desc="">
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
</policy>
</policylist>
<filefilterlist>
<filefilter name="defaultFilter" desc="文件属于FreeBSD仓库软连接本仓库屏蔽告警在FreeBSD仓库进行处理">
<filteritem type="filepath" name="bsd/.*" desc="文件属于FreeBSD仓库软连接本仓库屏蔽告警在FreeBSD仓库进行处理"/>
<filteritem type="filepath" name="kernel/extended" desc="文件属于Nuttx仓库软连接本仓库屏蔽告警在Nuttx仓库进行处理"/>
<filteritem type="filepath" name="fs/include/fs" desc="文件属于Nuttx仓库软连接本仓库屏蔽告警在Nuttx仓库进行处理"/>
</filefilter>
<filefilter name="defaultFilter" desc="Files not to check">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="defaultPolicyFilter" desc="Filters for compatibilitylicense header policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
</filefilter>
</filefilterlist>
<licensematcherlist>
<!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
<licensetext name="
uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
" desc=""/>
<licensetext name="
uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
" desc=""/>
</licensematcher-->
</licensematcherlist>
</oatconfig>
</configuration>

View File

@@ -67,27 +67,26 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
## Usage<a name="section741617511812"></a>
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on both development boards.
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3518-development-board.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3516-development-board.md). You can develop and run your applications based on both development boards.
### Preparations<a name="section1579912573329"></a>
You need to set up the compilation environment on Linux.
- [Compilation environment on Linux](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-lin.md)
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-setting.md).
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-setting.md).
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3518-development-environment.md).
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3516-development-environment.md).
### Source Code Acquisition<a name="section11443189655"></a>
Download and decompress a set of source code on a Linux server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
Download and decompress a set of source code on a Linux server to acquire the [source code](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz). For more acquisition methods, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/source-code-acquisition.md).
### Compilation and Building<a name="section2081013992812"></a>
For details about how to develop the first application, see:
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-running.md)
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3518.md)
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-running.md)
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3516.md)
## Repositories Involved<a name="section1371113476307"></a>

View File

@@ -68,27 +68,26 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
## 使用說明<a name="section741617511812"></a>
OpenHarmony LiteOS-A內核支持Hi3518EV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md)、Hi3516DV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
OpenHarmony LiteOS-A內核支持Hi3518EV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md)、Hi3516DV300[介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
### 準備<a name="section1579912573329"></a>
開發者需要在Linux上搭建編譯環境
- [Ubuntu編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
- Hi3518EV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md)
- Hi3516DV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
- Hi3518EV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md)
- Hi3516DV300單板參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83.md)
### 獲取源碼<a name="section11443189655"></a>
在Linux服務器上下載並解壓一套源代碼源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
在Linux服務器上下載並解壓一套源代碼獲取源碼([下載鏈結](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz))。更多源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md)。
### 編譯構建<a name="section2081013992812"></a>
開發者開發第一個應用程序可參考:
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3518%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.md)
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3516%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%A4%BA%E4%BE%8B.md)。
## 相關倉<a name="section1371113476307"></a>

View File

@@ -67,27 +67,26 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
## 使用说明<a name="section741617511812"></a>
OpenHarmony LiteOS-A内核支持Hi3518EV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md)、Hi3516DV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))单板,开发者可基于两种单板开发运行自己的应用程序。
OpenHarmony LiteOS-A内核支持Hi3518EV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md)、Hi3516DV300[介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))单板,开发者可基于两种单板开发运行自己的应用程序。
### 准备<a name="section1579912573329"></a>
开发者需要在Linux上搭建编译环境
- [Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
- Hi3518EV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md)
- Hi3516DV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
- Hi3518EV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF.md)
- Hi3516DV300单板参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF.md)
### 获取源码<a name="section11443189655"></a>
在Linux服务器上下载并解压一套源代码源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
在Linux服务器上下载并解压一套源代码获取源码([下载链接](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz))。更多源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md)。
### 编译构建<a name="section2081013992812"></a>
开发者开发第一个应用程序可参考:
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md)
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E8%BF%90%E8%A1%8CHello-OHOS-4.md)
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E8%BF%90%E8%A1%8CHello-OHOS.md)。
## 相关仓<a name="section1371113476307"></a>

View File

@@ -1,50 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
}

View File

@@ -27,7 +27,7 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
LITEOSTOPDIR := $(shell pwd)/../
LITEOSTOPDIR = $(shell pwd)/../
include $(LITEOSTOPDIR)/.config
include ./config.mk

View File

@@ -1,53 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
}

View File

@@ -1,95 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
copy("copy_mksh_src") {
sources = [ "$LITEOSTHIRDPARTY/mksh" ]
outputs = [ "$target_out_dir/mksh_build" ]
}
build_ext_component("build_mksh") {
deps = [ ":copy_mksh_src" ]
deps += [ "//prebuilts/lite/sysroot" ]
exec_path = rebase_path("$target_out_dir/mksh_build")
cflags = [
"-flto",
"-fdata-sections",
"-ffunction-sections",
"-Oz",
"-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2",
"-DMKSH_DISABLE_TTY_WARNING",
"-DMKSH_SMALL=1",
"-DMKSH_ASSUME_UTF8=1",
"-DMKSH_SMALL_BUT_FAST=0",
"-DMKSH_S_NOVI=1",
"-DHAVE_CAN_FSTACKPROTECTORSTRONG=1",
"-DMKSH_LESS_CMDLINE_EDITING",
"-DMKSH_LESS_BUILDINS",
"-DMKSH_NO_INITCOMS",
"-DADAPT_FOR_LITEOS_A",
]
cflags = string_join(" ", cflags)
extra_flags = string_join(" ", target_arch_cflags)
if (ohos_build_compiler == "clang") {
extra_flags += " --target=$target_triple"
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
}
command = "rm -rf .git && env"
command += " CC=\"$ohos_current_cc_command\""
command += " TARGET_OS=OpenHarmony"
command += " CFLAGS=\"$cflags $extra_flags\""
command += " LDFLAGS=\"-Wl,--gc-sections -flto -O2\""
command += " sh ./Build.sh -r"
# copy mksh and .mkshrc to out dir
command += " && mkdir -p "
command += rebase_path("$root_out_dir/bin", exec_path)
command += " && install -D mksh "
command += rebase_path("$root_out_dir/unstripped/bin/mksh", exec_path)
command += " && $ohos_current_strip_command mksh -o "
command += rebase_path("$root_out_dir/bin/mksh", exec_path)
command += " && install -D .mkshrc "
command += rebase_path("$root_out_dir/etc/.mkshrc", exec_path)
outputs = [
"$root_out_dir/unstripped/bin/mksh",
"$root_out_dir/bin/mksh",
"$root_out_dir/etc/.mkshrc",
]
}

View File

@@ -39,16 +39,11 @@ BUILD_DIR := $(MKSH_DIR)/build
BUILD_LOG := $(MKSH_DIR)/build.log
TARGET_OS := OpenHarmony
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -fstack-protector-strong -D_FORTIFY_SOURCE=2
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -Oz -fstack-protector-strong -D_FORTIFY_SOURCE=2
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
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
LOCAL_CFLAGS += -Oz --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
else
LOCAL_CFLAGS += -O2
endif
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2 --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
all:$(MKSH)
@@ -69,10 +64,8 @@ endif
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
$(HIDE)mkdir -p $(ETC_OUT)
$(HIDE)$(CP) -rf $(BUILD_DIR)/.mkshrc $(ETC_OUT)/
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
clean:
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)
.PHONY: all $(MKSH) clean

View File

@@ -33,8 +33,8 @@ APP_SUBDIRS :=
ifeq ($(LOSCFG_SHELL), y)
APP_SUBDIRS += shell
#APP_SUBDIRS += mksh
#APP_SUBDIRS += toybox
APP_SUBDIRS += mksh
APP_SUBDIRS += toybox
endif
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)

View File

@@ -1,58 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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",
]
}

View File

@@ -35,7 +35,7 @@
#include "semaphore.h"
#include "securec.h"
#include "unistd.h"
#include <sys/syscall.h>
ShellCB *g_shellCB = NULL;
@@ -88,44 +88,11 @@ OUT:
return ret;
}
static int DoShellExec(char **argv)
{
int i, j;
int len = 0;
int ret = SH_NOK;
char *cmdLine = NULL;
for (i = 0; argv[i]; i++) {
len += strlen(argv[i]);
}
len += i + 1;
cmdLine = (char *)malloc(len);
if (!cmdLine) {
return ret;
}
memset_s(cmdLine, len, 0, len);
for(j = 0; j < i; j++) {
strcat_s(cmdLine, len, argv[j]);
strcat_s(cmdLine, len, " ");
}
cmdLine[len - 2] = '\0';
ret = syscall(__NR_shellexec, argv[0], cmdLine);
free(cmdLine);
return ret;
}
int main(int argc, char **argv)
int main()
{
int ret = SH_NOK;
ShellCB *shellCB = NULL;
if (!strcmp(argv[0], "shell") && argv[1]) {
ret = DoShellExec(argv + 1);
return ret;
}
setbuf(stdout, NULL);
shellCB = (ShellCB *)malloc(sizeof(ShellCB));

View File

@@ -1,55 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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",
]
}

View File

@@ -1,80 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
copy("copy_toybox_src") {
sources = [ "$LITEOSTHIRDPARTY/toybox" ]
outputs = [ "$target_out_dir/toybox_build" ]
}
copy("copy_toybox_config") {
deps = [ ":copy_toybox_src" ]
sources = [ "liteos_a_custom.config" ]
outputs = [ "$target_out_dir/{{source_file_part}}" ]
}
build_ext_component("build_toybox") {
deps = [ ":copy_toybox_src", ":copy_toybox_config" ]
deps += [ "//prebuilts/lite/sysroot" ]
exec_path = rebase_path("$target_out_dir/toybox_build")
cflags = [
"-fstack-protector-strong",
"-D_FORTIFY_SOURCE=2",
]
cflags = string_join(" ", cflags)
extra_flags = string_join(" ", target_arch_cflags)
if (ohos_build_compiler == "clang") {
extra_flags += " --target=$target_triple"
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
}
command = "rm -rf .git && cp -rfp porting/liteos_a/. . && env"
command += " CC=\"$ohos_current_cc_command\""
command += " STRIP=\"$ohos_current_strip_command\""
command += " OUTNAME=toybox"
command += " CFLAGS=\"$cflags $extra_flags\""
command += " make toybox"
command += " && install -D toybox "
command += rebase_path("$root_out_dir/bin/toybox", exec_path)
command += " && install -D generated/unstripped/toybox "
command += rebase_path("$root_out_dir/unstripped/bin/toybox", exec_path)
outputs = [
"$root_out_dir/unstripped/bin/toybox",
"$root_out_dir/bin/toybox",
]
}

View File

@@ -38,13 +38,6 @@ BUILD_DIR := $(TOYBOX_DIR)/build
BUILD_LOG := $(TOYBOX_DIR)/build.log
OUTNAME := $(TOYBOX)
CFLAGS := -D_FORTIFY_SOURCE=2 -fstack-protector-strong
LDFLAGS :=
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
CFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
LDFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
endif
$(TOYBOX):
ifneq ($(wildcard $(BUILD_DIR)),)
$(HIDE)echo "not clean, rebuilding now";
@@ -53,14 +46,13 @@ else
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
endif
$(HIDE)CFLAGS="$(CFLAGS)" CC="$(CC)" OUTNAME="$(OUTNAME)" \
LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
$(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)
$(HIDE)mkdir -p $(APPS_OUT)
$(HIDE)$(CP) $(TOYBOX) $(APPS_OUT)
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
clean:
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG)

View File

@@ -1,6 +1,7 @@
# CONFIG_BASENAME is not set
CONFIG_GETTY=y
CONFIG_MDEV=y
CONFIG_MDEV_CONF=y
# 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
@@ -12,7 +13,6 @@
# 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,6 +128,7 @@
# 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
@@ -178,9 +179,3 @@
# 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

View File

@@ -1,44 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
}

View File

@@ -1,47 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
}

View File

@@ -76,6 +76,7 @@ ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/src/include
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
LITEOS_CXXINCLUDE += $(ARCH_INCLUDE)
# expose FPU info to assembly code
ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y)

View File

@@ -1,78 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
config("public") {
include_dirs = [
"include",
"src/include",
]
}

View File

@@ -105,15 +105,7 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
{
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 *cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
((TaskContext *)childStack)->R0 = 0;

View File

@@ -1,41 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -1,86 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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,14 +1,6 @@
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

@@ -1,57 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

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

View File

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

View File

@@ -1,150 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}
config("public") {
include_dirs = [ "." ]
include_dirs += [ "$LITEOSTHIRDPARTY/FreeBSD/sys/dev/evdev" ]
}

View File

@@ -46,14 +46,14 @@ device_path=${12}
echo "${board_name}" "${device_company}"
echo "sh param:" "$@"
destination="defconfig"
function main() {
destination=".config"
tee=""
if [ "${tee_enable}" = "true" ]; then
tee="_tee"
fi
config_file="${product_path}/kernel_configs/${ohos_build_type}${tee}.config"
config_file="${product_path}/config/${ohos_build_type}${tee}.config"
if [ -f "${config_file}" ]; then
cp "${config_file}" "${destination}"
return
@@ -85,12 +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}"
OUTDIR="${outdir}"
CONFIG="$(realpath ${destination})"
main && \
make clean CONFIG="$CONFIG" OUTDIR="$OUTDIR" && \
make -j all VERSION="${ohos_version}" CONFIG="$CONFIG" OUTDIR="$OUTDIR"
make clean && \
make -j rootfs VERSION="${ohos_version}"

View File

@@ -1,38 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("compat") {
deps = [ "posix" ]
}
config("public") {
configs = [ "posix:public" ]
}

View File

@@ -1,55 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -81,11 +81,6 @@ typedef union send_receive_t {
short data;
} mode_s;
struct mqnotify {
pid_t pid;
struct sigevent notify;
};
/* TYPE DEFINITIONS */
struct mqarray {
UINT32 mq_id : 31;
@@ -95,7 +90,7 @@ struct mqarray {
mode_s mode_data; /* mode data of mqueue */
uid_t euid; /* euid of mqueue */
gid_t egid; /* egid of mqueue */
struct mqnotify mq_notify;
fd_set mq_fdset; /* mqueue sysFd bit map */
LosQueueCB *mqcb;
struct mqpersonal *mq_personal;
};
@@ -422,8 +417,7 @@ extern int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen,
extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
unsigned int *msgPrio, const struct timespec *absTimeout);
extern void MqueueRefer(int sysFd);
extern int OsMqNotify(mqd_t personal, const struct sigevent *sigev);
extern void mqueue_refer(int sysFd);
#ifdef __cplusplus
#if __cplusplus

View File

@@ -30,15 +30,13 @@
*/
#include "sys/types.h"
#include "sys/resource.h"
#include "unistd.h"
#include "stdio.h"
#include "pthread.h"
#include "sys/utsname.h"
#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,27 +52,17 @@
int uname(struct utsname *name)
{
INT32 ret;
const char *cpuInfo = NULL;
if (name == NULL) {
return -EFAULT;
}
(VOID)strcpy_s(name->sysname, sizeof(name->sysname), KERNEL_NAME);
(VOID)strcpy_s(name->nodename, sizeof(name->nodename), "hisilicon");
ret = sprintf_s(name->version, sizeof(name->version), "%s %u.%u.%u.%u %s %s",
(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",
KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, __DATE__, __TIME__);
if (ret < 0) {
return -EIO;
}
cpuInfo = LOS_CpuInfo();
(VOID)strcpy_s(name->machine, sizeof(name->machine), cpuInfo);
ret = sprintf_s(name->release, sizeof(name->release), "%u.%u.%u.%u",
KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE);
if (ret < 0) {
return -EIO;
}
name->machine[0] = '\0';
name->domainname[0] = '\0';
return 0;
}
@@ -152,50 +140,3 @@ pid_t getpid(void)
return ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
}
int getrlimit(int resource, struct rlimit *rlim)
{
LosProcessCB *pcb = OsCurrProcessGet();
switch (resource) {
case RLIMIT_NOFILE:
case RLIMIT_FSIZE:
break;
default:
return -EINVAL;
}
rlim->rlim_cur = pcb->pl_rlimit[resource].rlim_cur;
rlim->rlim_max = pcb->pl_rlimit[resource].rlim_max;
return 0;
}
#define FSIZE_RLIMIT 0XFFFFFFFF
#ifndef NR_OPEN_DEFAULT
#define NR_OPEN_DEFAULT 1024
#endif
int setrlimit(int resource, const struct rlimit *rlim)
{
LosProcessCB *pcb = OsCurrProcessGet();
if (rlim->rlim_cur > rlim->rlim_max) {
return -EINVAL;
}
switch (resource) {
case RLIMIT_NOFILE:
if (rlim->rlim_max > NR_OPEN_DEFAULT) {
return -EPERM;
}
break;
case RLIMIT_FSIZE:
if (rlim->rlim_max > FSIZE_RLIMIT) {
return -EPERM;
}
break;
default:
return -EINVAL;
}
pcb->pl_rlimit[resource].rlim_cur = rlim->rlim_cur;
pcb->pl_rlimit[resource].rlim_max = rlim->rlim_max;
return 0;
}

View File

@@ -49,7 +49,6 @@
#endif
/* GLOBALS */
STATIC fd_set g_queueFdSet;
STATIC struct mqarray g_queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT];
STATIC pthread_mutex_t g_mqueueMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
STATIC struct mqpersonal *g_mqPrivBuf[MAX_MQ_FD];
@@ -121,7 +120,6 @@ STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
mqueueCB->mode_data.data = 0;
mqueueCB->euid = -1;
mqueueCB->egid = -1;
mqueueCB->mq_notify.pid = 0;
ret = LOS_QueueDelete(mqueueCB->mq_id);
switch (ret) {
@@ -206,7 +204,6 @@ STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
mqueueCB->mq_personal->mq_mode = mode;
mqueueCB->mq_personal->mq_refcount = 0;
mqueueCB->mq_notify.pid = 0;
return mqueueCB->mq_personal;
ERROUT:
@@ -248,44 +245,6 @@ ERROUT:
return (struct mqpersonal *)-1;
}
STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
{
struct mqarray *mqueueCB = NULL;
struct mqpersonal *tmp = NULL;
mqueueCB = privateMqPersonal->mq_posixdes;
if (mqueueCB == NULL || mqueueCB->mq_personal == NULL) {
errno = EBADF;
return LOS_NOK;
}
/* find the personal and remove */
if (mqueueCB->mq_personal == privateMqPersonal) {
mqueueCB->mq_personal = privateMqPersonal->mq_next;
} else {
for (tmp = mqueueCB->mq_personal; tmp->mq_next != NULL; tmp = tmp->mq_next) {
if (tmp->mq_next == privateMqPersonal) {
break;
}
}
if (tmp->mq_next == NULL) {
errno = EBADF;
return LOS_NOK;
}
tmp->mq_next = privateMqPersonal->mq_next;
}
/* flag no use */
privateMqPersonal->mq_status = 0;
/* free the personal */
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
if ((mqueueCB->unlinkflag == TRUE) && (mqueueCB->mq_personal == NULL)) {
return DoMqueueDelete(mqueueCB);
}
return LOS_OK;
}
/* Translate a sysFd into privateMqPersonal */
STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
{
@@ -311,24 +270,29 @@ STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
{
INT32 i;
fd_set *fdset = &g_queueFdSet;
struct mqarray *mqueueCB = privateMqPersonal->mq_posixdes;
fd_set *fdset = &mqueueCB->mq_fdset;
for (i = 0; i < maxfdp; i++) {
/* sysFd: used bit setting, and get the index of swtmrID buffer */
if (fdset && !(FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
if (!(fdset && FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
FD_SET(i + MQUEUE_FD_OFFSET, fdset);
if (!g_mqPrivBuf[i]) {
g_mqPrivBuf[i] = privateMqPersonal;
g_mqPrivBuf[i] = mqueueCB->mq_personal;
return i + MQUEUE_FD_OFFSET;
}
}
}
/* there are no more mq sysFd to use, free the personal */
LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
privateMqPersonal = NULL;
mqueueCB->mq_personal = NULL;
return -1;
}
STATIC VOID MqFreeSysFd(mqd_t personal)
STATIC VOID MqFreeSysFd(struct mqarray *mqueueCB, mqd_t personal)
{
INT32 sysFd = (INT32)personal;
fd_set *fdset = &g_queueFdSet;
fd_set *fdset = &mqueueCB->mq_fdset;
if (fdset && FD_ISSET(sysFd, fdset)) {
FD_CLR(sysFd, fdset);
g_mqPrivBuf[sysFd - MQUEUE_FD_OFFSET] = NULL;
@@ -336,7 +300,7 @@ STATIC VOID MqFreeSysFd(mqd_t personal)
}
/* Mqueue fd reference count */
void MqueueRefer(int sysFd)
void mqueue_refer(int sysFd)
{
struct mqarray *mqueueCB = NULL;
struct mqpersonal *privateMqPersonal = NULL;
@@ -351,11 +315,10 @@ void MqueueRefer(int sysFd)
if (mqueueCB == NULL) {
goto OUT_UNLOCK;
}
privateMqPersonal->mq_refcount++;
mqueueCB->unlink_ref++;
OUT_UNLOCK:
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return;
}
STATIC INT32 MqTryClose(struct mqpersonal *privateMqPersonal)
@@ -374,6 +337,15 @@ STATIC INT32 MqTryClose(struct mqpersonal *privateMqPersonal)
return FALSE;
}
STATIC INT32 MqTryUnlink(struct mqarray *mqueueCB)
{
if (mqueueCB->unlink_ref == 0) {
return TRUE;
}
mqueueCB->unlink_ref--;
return FALSE;
}
/* Set the mode data bit,for consumer's mode comparing. */
STATIC INT32 MqueueModeAnalysisSet(struct mqpersonal *privateMqPersonal)
{
@@ -520,9 +492,6 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
}
/* Set mode data bit ,just for the first node */
if (MqueueModeAnalysisSet(privateMqPersonal)) {
if ((INT32)(UINTPTR)privateMqPersonal > 0) {
(VOID)DoMqueueClose(privateMqPersonal);
}
goto OUT;
}
} else {
@@ -531,18 +500,15 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
}
privateMqPersonal = DoMqueueOpen(mqueueCB, openFlag);
}
OUT:
if ((INT32)(UINTPTR)privateMqPersonal > 0) {
/* alloc sysFd */
sysFd = MqAllocSysFd(MAX_MQ_FD, privateMqPersonal);
if (sysFd == -1) {
/* there are no more mq sysFd to use, close the personal */
(VOID)DoMqueueClose(privateMqPersonal);
errno = ENFILE;
}
mqFd = (mqd_t)sysFd;
}
OUT:
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return mqFd;
}
@@ -550,7 +516,9 @@ OUT:
int mq_close(mqd_t personal)
{
INT32 ret = -1;
struct mqarray *mqueueCB = NULL;
struct mqpersonal *privateMqPersonal = NULL;
struct mqpersonal *tmp = NULL;
(VOID)pthread_mutex_lock(&g_mqueueMutex);
@@ -564,18 +532,47 @@ int mq_close(mqd_t personal)
errno = EBADF;
goto OUT_UNLOCK;
}
/* there have other thread used the fd */
if (!MqTryClose(privateMqPersonal)) {
ret = 0;
goto OUT_UNLOCK;
}
ret = DoMqueueClose(privateMqPersonal);
if (ret < 0) {
mqueueCB = privateMqPersonal->mq_posixdes;
if (mqueueCB->mq_personal == NULL) {
errno = EBADF;
goto OUT_UNLOCK;
}
MqFreeSysFd(personal);
/* find the personal and remove */
if (mqueueCB->mq_personal == privateMqPersonal) {
mqueueCB->mq_personal = privateMqPersonal->mq_next;
} else {
for (tmp = mqueueCB->mq_personal; tmp->mq_next != NULL; tmp = tmp->mq_next) {
if (tmp->mq_next == privateMqPersonal) {
break;
}
}
if (tmp->mq_next == NULL) {
errno = EBADF;
goto OUT_UNLOCK;
}
tmp->mq_next = privateMqPersonal->mq_next;
}
/* flag no use */
privateMqPersonal->mq_status = 0;
MqFreeSysFd(mqueueCB, personal);
/* free the personal */
ret = LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
if (ret != LOS_OK) {
errno = EFAULT;
ret = -1;
goto OUT_UNLOCK;
}
if ((mqueueCB->unlinkflag == TRUE) && (mqueueCB->mq_personal == NULL)) {
ret = DoMqueueDelete(mqueueCB);
}
OUT_UNLOCK:
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return ret;
@@ -668,7 +665,10 @@ int mq_unlink(const char *mqName)
errno = ENOENT;
goto ERROUT_UNLOCK;
}
if (!MqTryUnlink(mqueueCB)) {
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return 0;
}
if (mqueueCB->mq_personal != NULL) {
mqueueCB->unlinkflag = TRUE;
} else if (mqueueCB->unlink_ref == 0) {
@@ -717,35 +717,6 @@ STATIC INLINE BOOL MqParamCheck(mqd_t personal, const char *msg, size_t msgLen)
return TRUE;
}
/*
* Send realtime a signal to process which registered itself
* successfully by mq_notify.
*/
static void MqSendNotify(struct mqarray *mqueueCB)
{
struct mqnotify *mqnotify = &mqueueCB->mq_notify;
if ((mqnotify->pid) && (mqueueCB->mqcb->readWriteableCnt[OS_QUEUE_READ] == 0)) {
siginfo_t info;
switch (mqnotify->notify.sigev_notify) {
case SIGEV_SIGNAL:
/* sends signal */
/* Create the siginfo structure */
info.si_signo = mqnotify->notify.sigev_signo;
info.si_code = SI_MESGQ;
info.si_value = mqnotify->notify.sigev_value;
OsDispatch(mqnotify->pid, &info, OS_USER_KILL_PERMISSION);
break;
case SIGEV_NONE:
default:
break;
}
/* after notification unregisters process */
mqnotify->pid = 0;
}
}
#define OS_MQ_GOTO_ERROUT_UNLOCK_IF(expr, errcode) \
if (expr) { \
errno = errcode; \
@@ -783,10 +754,6 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
mqueueID = mqueueCB->mq_id;
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
if (LOS_ListEmpty(&mqueueCB->mqcb->readWriteList[OS_QUEUE_READ])) {
MqSendNotify(mqueueCB);
}
err = LOS_QueueWriteCopy(mqueueID, (VOID *)msg, (UINT32)msgLen, (UINT32)absTicks);
if (map_errno(err) != ENOERR) {
goto ERROUT;
@@ -865,82 +832,4 @@ ssize_t mq_receive(mqd_t personal, char *msg_ptr, size_t msg_len, unsigned int *
return mq_timedreceive(personal, msg_ptr, msg_len, msg_prio, NULL);
}
STATIC INLINE BOOL MqNotifyParamCheck(mqd_t personal, const struct sigevent *sigev)
{
if (personal < 0) {
errno = EBADF;
goto ERROUT;
}
if (sigev != NULL) {
if (sigev->sigev_notify != SIGEV_NONE && sigev->sigev_notify != SIGEV_SIGNAL) {
errno = EINVAL;
goto ERROUT;
}
if (sigev->sigev_notify == SIGEV_SIGNAL && !GOOD_SIGNO(sigev->sigev_signo)) {
errno = EINVAL;
goto ERROUT;
}
}
return TRUE;
ERROUT:
return FALSE;
}
int OsMqNotify(mqd_t personal, const struct sigevent *sigev)
{
struct mqarray *mqueueCB = NULL;
struct mqnotify *mqnotify = NULL;
struct mqpersonal *privateMqPersonal = NULL;
if (!MqNotifyParamCheck(personal, sigev)) {
goto ERROUT;
}
(VOID)pthread_mutex_lock(&g_mqueueMutex);
privateMqPersonal = MqGetPrivDataBuff(personal);
if (privateMqPersonal == NULL) {
goto OUT_UNLOCK;
}
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
errno = EBADF;
goto OUT_UNLOCK;
}
mqueueCB = privateMqPersonal->mq_posixdes;
mqnotify = &mqueueCB->mq_notify;
if (sigev == NULL) {
if (mqnotify->pid == LOS_GetCurrProcessID()) {
mqnotify->pid = 0;
}
} else if (mqnotify->pid != 0) {
errno = EBUSY;
goto OUT_UNLOCK;
} else {
switch (sigev->sigev_notify) {
case SIGEV_NONE:
mqnotify->notify.sigev_notify = SIGEV_NONE;
break;
case SIGEV_SIGNAL:
mqnotify->notify.sigev_signo = sigev->sigev_signo;
mqnotify->notify.sigev_value = sigev->sigev_value;
mqnotify->notify.sigev_notify = SIGEV_SIGNAL;
break;
default:
break;
}
mqnotify->pid = LOS_GetCurrProcessID();
}
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
return 0;
OUT_UNLOCK:
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
ERROUT:
return -1;
}
#endif

View File

@@ -452,25 +452,11 @@ int clock_settime(clockid_t clockID, const struct timespec *tp)
}
#ifdef LOSCFG_KERNEL_CPUP
inline UINT32 GetTidFromClockID(clockid_t clockID)
{
// In musl/src/thread/pthread_getcpuclockid.c, we know 'clockid = (-tid - 1) * 8 + 6'
UINT32 tid = -(clockID - 6) / 8 - 1; // 6 8 1 inverse operation from clockID to tid
return tid;
}
inline const pid_t GetPidFromClockID(clockid_t clockID)
{
// In musl/src/time/clock_getcpuclockid.c, we know 'clockid = (-pid - 1) * 8 + 2'
const pid_t pid = -(clockID - 2) / 8 - 1; // 2 8 1 inverse operation from clockID to pid
return pid;
}
static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
{
uint64_t runtime;
UINT32 intSave;
UINT32 tid = GetTidFromClockID(clockID);
UINT32 tid = ((UINT32) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
if (OS_TID_CHECK_INVALID(tid)) {
return -EINVAL;
@@ -496,7 +482,7 @@ static int ProcessGetCputime(clockid_t clockID, struct timespec *ats)
{
UINT64 runtime;
UINT32 intSave;
const pid_t pid = GetPidFromClockID(clockID);
const pid_t pid = ((pid_t) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
LosProcessCB *spcb = NULL;
if (OsProcessIDUserCheckInvalid(pid) || pid < 0) {
@@ -538,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 = GetPidFromClockID(clockID);
const pid_t pid = ((pid_t) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
if (!((UINT32)clockID & CPUCLOCK_PERTHREAD_MASK)) {
LosProcessCB *spcb = NULL;
@@ -964,11 +950,11 @@ int timer_getoverrun(timer_t timerID)
return (overRun > DELAYTIMER_MAX) ? DELAYTIMER_MAX : overRun;
}
STATIC INT32 DoNanoSleep(UINT64 nanoseconds)
STATIC INT32 DoNanoSleep(UINT64 useconds)
{
UINT32 ret;
ret = LOS_TaskDelay(OsNS2Tick(nanoseconds));
ret = LOS_TaskDelay(OsUS2Tick(useconds));
if (ret == LOS_OK || ret == LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK) {
return 0;
}
@@ -977,12 +963,12 @@ STATIC INT32 DoNanoSleep(UINT64 nanoseconds)
int usleep(unsigned useconds)
{
return DoNanoSleep((UINT64)useconds * OS_SYS_NS_PER_US);
return DoNanoSleep((UINT64)useconds);
}
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
UINT64 nanoseconds;
UINT64 useconds;
INT32 ret = -1;
(VOID)rmtp;
@@ -993,14 +979,14 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
return ret;
}
nanoseconds = (UINT64)rqtp->tv_sec * OS_SYS_NS_PER_SECOND + rqtp->tv_nsec;
useconds = (UINT64)rqtp->tv_sec * OS_SYS_US_PER_SECOND + rqtp->tv_nsec / OS_SYS_NS_PER_US;
return DoNanoSleep(nanoseconds);
return DoNanoSleep(useconds);
}
unsigned int sleep(unsigned int seconds)
{
return DoNanoSleep((UINT64)seconds * OS_SYS_NS_PER_SECOND);
return DoNanoSleep((UINT64)seconds * OS_SYS_US_PER_SECOND);
}
double difftime(time_t time2, time_t time1)

View File

@@ -1 +0,0 @@
tools/build/config.mk

61
config.mk Normal file
View File

@@ -0,0 +1,61 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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.
############### this is a makefile that you can config it ###############
-include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk
TOP_LD_PATH = $(LITEOSTOPDIR)
SCRIPTS_PATH = $(LITEOS_SCRIPTPATH)
LITEOS_MK_PATH = $(MK_PATH)
LITEOS_SUBDIRS = $(LIB_SUBDIRS)
LIB_BIGODIR = $(LITEOS_LIB_BIGODIR)
##### liteos tables -u ldflags #####
-include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk
LITEOS_COPTS := $(LITEOS_COPTS_DEBUG) $(LITEOS_COPTS_BASE) \
$(LITEOS_COPTS_EXTRA) $(LITEOS_CORE_COPTS)
LITEOS_CXXOPTS := $(LITEOS_CXXOPTS_BASE)
LITEOS_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_EXTKERNEL_INCLUDE) \
$(LITEOS_COMPAT_INCLUDE) $(LITEOS_FS_INCLUDE) \
$(LITEOS_NET_INCLUDE) $(LITEOS_LIB_INCLUDE) \
$(LITEOS_DRIVERS_INCLUDE) $(LOSCFG_TOOLS_DEBUG_INCLUDE) \
$(LITEOS_PLATFORM_INCLUDE) $(LITEOS_DFX_INCLUDE) \
$(LITEOS_SECURITY_INCLUDE)
LITEOS_LIBDEP := $(LITEOS_BASELIB)
LITEOS_ASFLAGS := $(LITEOS_ASOPTS) $(LITEOS_INCLUDE)
LITEOS_CFLAGS := $(LITEOS_COPTS) $(LITEOS_CMACRO) \
$(LITEOS_CMACRO_TEST) $(LITEOS_IMAGE_MACRO) \
$(LITEOS_INCLUDE)
LITEOS_CXXFLAGS := $(LITEOS_CXXOPTS) $(LITEOS_CXXMACRO) \
$(LITEOS_CMACRO) $(LITEOS_CXXINCLUDE)
LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \
$(LITEOS_LD_SCRIPT)

View File

@@ -1,54 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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("drivers") {
deps = [
"block/disk",
"char/bch",
"char/mem",
"char/quickstart",
"char/random",
"char/video",
"mtd/multi_partition",
]
}
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",
]
}

View File

@@ -1,45 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -1422,13 +1422,10 @@ DISK_FIND_ERROR:
INT32 los_disk_deinit(INT32 diskID)
{
int ret;
los_disk *disk = get_disk(diskID);
if (disk == NULL) {
return -EINVAL;
}
ret = ForceUmountDev(disk->dev);
PRINTK("warning: %s lost, force umount ret = %d\n", disk->disk_name, ret);
DISK_LOCK(&disk->disk_mutex);

View File

@@ -1,52 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}

View File

@@ -1,42 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -1,42 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -1,46 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -1,42 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -1,54 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}

View File

@@ -1,56 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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",
]
}

View File

@@ -1,55 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -239,7 +239,7 @@ 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:
@@ -292,8 +292,7 @@ static FRESULT init_cluster(DIR_FILE *pdfp, DIR *dp_new, FATFS *fs, int type, co
} else {
/* Write the dir cluster */
mem_set(dir, 0, SS(fs));
/* 11, the The max length of of the short file name, Create "." entry */
mem_set(dir + DIR_Name, ' ', 11);
mem_set(dir + DIR_Name, ' ', 11); /* Create "." entry */
dir[DIR_Name] = '.';
dir[DIR_Attr] = AM_DIR;
st_clust(fs, dir, *clust);
@@ -449,8 +448,6 @@ static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, st
dp_new->obj.objsize = 0;
} else if (type == AM_LNK) {
dp_new->obj.objsize = strlen(target);
} else {
finfo_new->fsize = fs->csize * SS(fs);
}
ret = VnodeAlloc(&fatfs_vops, &vp);
@@ -560,7 +557,6 @@ int fatfs_lookup(struct Vnode *parent, const char *path, int len, struct Vnode *
vp->mode = fatfs_get_mode(finfo->fattrib, fs->fs_mode);
if (finfo->fattrib & AM_DIR) {
vp->type = VNODE_TYPE_DIR;
finfo->fsize = fs->csize * SS(fs);
} else {
vp->type = VNODE_TYPE_REG;
}
@@ -1185,7 +1181,6 @@ int fatfs_mount(struct Mount *mnt, struct Vnode *blk_device, const void *data)
dfp->fno.ftime = 0;
dfp->fno.fattrib = AM_DIR;
dfp->fno.sclst = 0;
dfp->fno.fsize = fs->csize * SS(fs);
dfp->fno.fname[0] = '/'; /* Mark as root dir */
dfp->fno.fname[1] = '\0';
LOS_ListInit(&(dfp->fno.fp_list));
@@ -1417,17 +1412,10 @@ int fatfs_stat(struct Vnode *vp, struct stat* sp)
sp->st_gid = fs->fs_gid;
sp->st_size = finfo->fsize;
sp->st_blksize = fs->csize * SS(fs);
if (finfo->fattrib & AM_ARC) {
sp->st_blocks = finfo->fsize ? ((finfo->fsize - 1) / SS(fs) / fs->csize + 1) : 0;
} else {
sp->st_blocks = fs->csize;
}
sp->st_blocks = finfo->fsize ? ((finfo->fsize - 1) / SS(fs) / fs->csize + 1) : 0;
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;
}

View File

@@ -1,47 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -37,11 +37,12 @@
#define _MAX_ENTRYLENGTH 16 /* MAX virtual partition name length */
#define _MAX_VIRVOLUMES 5 /* MAX virtual partition number */
typedef struct virtual_partition_info {
char *devpartpath; /* need set virtual partition, e.g. /dev/mmcblk0p0 */
int virpartnum; /* virtual partition numbers, MAX number is 5 */
double virpartpercent[_MAX_VIRVOLUMES]; /* every virtual partition percent,e.g 0.6,0.3,0.1 */
char virpartname[_MAX_VIRVOLUMES][_MAX_ENTRYLENGTH + 1]; /* every virtual partition name, MAX length is 16 */
typedef struct virtual_partition_info
{
char *devpartpath; /* need set virtual partition, e.g. /dev/mmcblk0p0 */
int virpartnum; /* virtual partition numbers, MAX number is 5 */
double virpartpercent[_MAX_VIRVOLUMES]; /* every virtual partition percent,e.g 0.6,0.3,0.1 */
char virpartname[_MAX_VIRVOLUMES][_MAX_ENTRYLENGTH + 1]; /* every virtual partition name, MAX length is 16 */
} virpartinfo;
extern char g_devPartName[DISK_NAME + 1];

View File

@@ -1 +0,0 @@
../../../../../third_party/NuttX/fs/vfs/include/driver.h

298
fs/include/fs/driver.h Normal file
View File

@@ -0,0 +1,298 @@
/****************************************************************************
* include/fs/fs.h
*
* Copyright (C) 2007-2009, 2011-2013, 2015-2018 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX 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 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef _FS_DRIVER_H_
#define _FS_DRIVER_H_
#include <sys/stat.h>
#include "vnode.h"
#include "fs/file.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
/* This structure provides information about the state of a block driver */
struct geometry
{
bool geo_available; /* true: The device is available */
bool geo_mediachanged; /* true: The media has changed since last query */
bool geo_writeenabled; /* true: It is okay to write to this device */
unsigned long long geo_nsectors; /* Number of sectors on the device */
size_t geo_sectorsize; /* Size of one sector */
};
/* This structure is provided by block devices when they register with the
* system. It is used by file systems to perform filesystem transfers. It
* differs from the normal driver vtable in several ways -- most notably in
* that it deals in struct Vnode vs. struct filep.
*/
struct block_operations
{
int (*open)(struct Vnode *vnode);
int (*close)(struct Vnode *vnode);
ssize_t (*read)(struct Vnode *vnode, unsigned char *buffer,
unsigned long long start_sector, unsigned int nsectors);
ssize_t (*write)(struct Vnode *vnode, const unsigned char *buffer,
unsigned long long start_sector, unsigned int nsectors);
int (*geometry)(struct Vnode *vnode, struct geometry *geometry);
int (*ioctl)(struct Vnode *vnode, int cmd, unsigned long arg);
int (*unlink)(struct Vnode *vnode);
};
struct drv_data
{
const void *ops;
mode_t mode;
void *priv;
};
/****************************************************************************
* Name: register_driver
*
* Description:
* Register a character driver vnode the pseudo file system.
*
* Input Parameters:
* path - The path to the vnode to create
* fops - The file operations structure
* mode - Access privileges (not used)
* priv - Private, user data that will be associated with the vnode.
*
* Returned Value:
* Zero on success (with the vnode point in 'vnode'); A negated errno
* value is returned on a failure (all error values returned by
* vnode_reserve):
*
* EINVAL - 'path' is invalid for this operation
* EEXIST - An vnode already exists at 'path'
* ENOMEM - Failed to allocate in-memory resources for the operation
*
* Attention:
* This function should be called after los_vfs_init has been called.
* The parameter path must point a valid string, which end with the terminating null byte.
* The total length of parameter path must less than the value defined by PATH_MAX.
* The prefix of the parameter path must be /dev/.
* The fops must pointed the right functions, otherwise the system will crash when the device is being operated.
*
****************************************************************************/
int register_driver(const char *path,
const struct file_operations_vfs *fops, mode_t mode,
void *priv);
/****************************************************************************
* Name: register_blockdriver
*
* Description:
* Register a block driver vnode the pseudo file system.
*
* Attention:
* This function should be called after los_vfs_init has been called.
* The parameter path must point a valid string, which end with the terminating null byte.
* The length of parameter path must be less than the value defined by PATH_MAX.
* The prefix of the parameter path must be '/dev/'.
* The bops must pointed the right functions, otherwise the system will crash when the device is being operated.
*
* Input Parameters:
* path - The path to the vnode to create
* bops - The block driver operations structure
* mode - Access privileges (not used)
* priv - Private, user data that will be associated with the vnode.
*
* Returned Value:
* Zero on success (with the vnode point in 'vnode'); A negated errno
* value is returned on a failure (all error values returned by
* vnode_reserve):
*
* EINVAL - 'path' is invalid for this operation
* EEXIST - An vnode already exists at 'path'
* ENOMEM - Failed to allocate in-memory resources for the operation
*
****************************************************************************/
int register_blockdriver(const char *path,
const struct block_operations *bops,
mode_t mode, void *priv);
/****************************************************************************
* Name: unregister_driver
*
* Description:
* Remove the character driver vnode at 'path' from the pseudo-file system
*
* Returned Value:
* Zero on success (with the vnode point in 'vnode'); A negated errno
* value is returned on a failure (all error values returned by
* vnode_reserve):
*
* EBUSY - Resource is busy ,not permit for this operation.
* ENOENT - 'path' is invalid for this operation.
*
* Attention:
* This function should be called after register_blockdriver has been called.
* The parameter path must point a valid string, which end with the terminating null byte.
* The total length of parameter path must less than the value defined by PATH_MAX.
* The block device node referred by parameter path must be really exist.
****************************************************************************/
int unregister_driver(const char *path);
/****************************************************************************
* Name: unregister_blockdriver
*
* Description:
* Remove the block driver vnode at 'path' from the pseudo-file system
*
* Input Parameters:
* path - The path that the vnode to be destroyed.
*
* Returned Value:
* Zero on success (with the vnode point in 'vnode'); A negated errno
* value is returned on a failure (all error values returned by
* vnode_reserve):
*
* EBUSY - Resource is busy ,not permit for this operation.
* ENOENT - 'path' is invalid for this operation.
*
* Attention:
* This function should be called after register_blockdriver has been called.
* The parameter path must point a valid string, which end with the terminating null byte.
* The total length of parameter path must less than the value defined by PATH_MAX.
* The block device node referred by parameter path must be really exist.
*
****************************************************************************/
int unregister_blockdriver(const char *path);
/****************************************************************************
* Name: open_blockdriver
*
* Description:
* Return the vnode of the block driver specified by 'pathname'
*
* Input Parameters:
* pathname - the full path to the block driver to be opened
* mountflags - if MS_RDONLY is not set, then driver must support write
* operations (see include/sys/mount.h)
* ppvnode - address of the location to return the vnode reference
*
* Returned Value:
* Returns zero on success or a negated errno on failure:
*
* EINVAL - pathname or pvnode is NULL
* ENOENT - No block driver of this name is registered
* ENOTBLK - The vnode associated with the pathname is not a block driver
* EACCESS - The MS_RDONLY option was not set but this driver does not
* support write access
*
* Aattention:
* The parameter path must point a valid string, which end with the terminating null byte.
* The total length of parameter path must less than the value defined by PATH_MAX.
* The parameter ppvnode must point a valid memory, which size must be enough for storing struct Vnode.
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int open_blockdriver(const char *pathname, int mountflags,
struct Vnode **ppvnode);
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: find_blockdriver
*
* Description:
* Return the inode of the block driver specified by 'pathname'
*
* Input Parameters:
* pathname - The full path to the block driver to be located
* mountflags - If MS_RDONLY is not set, then driver must support write
* operations (see include/sys/mount.h)
* ppinode - Address of the location to return the inode reference
*
* Returned Value:
* Returns zero on success or a negated errno on failure:
*
* ENOENT - No block driver of this name is registered
* ENOTBLK - The inode associated with the pathname is not a block driver
* EACCESS - The MS_RDONLY option was not set but this driver does not
* support write access
*
****************************************************************************/
int find_blockdriver(const char *pathname, int mountflags,
struct Vnode **vpp);
/****************************************************************************
* Name: close_blockdriver
*
* Description:
* Call the close method and release the vnode
*
* Input Parameters:
* vnode - reference to the vnode of a block driver opened by open_blockdriver
*
* Returned Value:
* Returns zero on success or a negated errno on failure:
*
* EINVAL - vnode is NULL
* ENOTBLK - The vnode is not a block driver
*
* Attention:
* This function should be called after open_blockdriver has been called.
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int close_blockdriver(struct Vnode *vnode);
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _FS_DRIVER_H_ */

View File

@@ -46,7 +46,6 @@ struct fd_table_s {
unsigned int max_fds;
struct file_table_s *ft_fds; /* process fd array associate with system fd */
fd_set *proc_fds;
fd_set *cloexec_fds;
sem_t ft_sem; /* manage access to the file table */
};
@@ -71,7 +70,7 @@ struct files_struct *dup_fd(struct files_struct *oldf);
struct files_struct *alloc_files(void);
void delete_files(struct files_struct *files);
void delete_files(LosProcessCB *processCB, struct files_struct *files);
struct files_struct *create_files_snapshot(const struct files_struct *oldf);
@@ -80,10 +79,4 @@ void delete_files_snapshot(struct files_struct *files);
int alloc_fd(int minfd);
void alloc_std_fd(struct fd_table_s *fdt);
void FileTableLock(struct fd_table_s *fdt);
void FileTableUnLock(struct fd_table_s *fdt);
struct fd_table_s *GetFdTable(void);
#endif

View File

@@ -1 +0,0 @@
../../../../../third_party/NuttX/fs/vfs/include/file.h

594
fs/include/fs/file.h Normal file
View File

@@ -0,0 +1,594 @@
/****************************************************************************
* include/fs/file.h
*
* Copyright (C) 2007-2009, 2011-2013, 2015-2018 Gregory Nutt. All rights
* reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX 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 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#ifndef __INCLUDE_FS_FILE_H
#define __INCLUDE_FS_FILE_H
/****************************************************************************
* Included Files
****************************************************************************/
#include "vfs_config.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "semaphore.h"
#include "poll.h"
#include "los_vm_map.h"
#include "los_atomic.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
#ifndef VFS_ERROR
#define VFS_ERROR -1
#endif
#ifndef OK
#define OK 0
#endif
/* This is the underlying representation of an open file. A file
* descriptor is an index into an array of such types. The type associates
* the file descriptor to the file state and to a set of vnode operations.
*/
struct Vnode;
struct file
{
unsigned int f_magicnum; /* file magic number */
int f_oflags; /* Open mode flags */
struct Vnode *f_vnode; /* Driver interface */
loff_t f_pos; /* File position */
unsigned long f_refcount; /* reference count */
char *f_path; /* File fullpath */
void *f_priv; /* Per file driver private data */
const char *f_relpath; /* realpath */
struct page_mapping *f_mapping; /* mapping file to memory */
void *f_dir; /* DIR struct for iterate the directory if open a directory */
const struct file_operations_vfs *ops;
int fd;
};
/* This defines a list of files indexed by the file descriptor */
#if CONFIG_NFILE_DESCRIPTORS > 0
struct filelist
{
sem_t fl_sem; /* Manage access to the file list */
struct file fl_files[CONFIG_NFILE_DESCRIPTORS];
};
extern struct filelist tg_filelist;
#endif
/* This structure is provided by devices when they are registered with the
* system. It is used to call back to perform device specific operations.
*/
struct file_operations_vfs
{
/* The device driver open method differs from the mountpoint open method */
int (*open)(struct file *filep);
/* The following methods must be identical in signature and position because
* the struct file_operations and struct mountp_operations are treated like
* unions.
*/
int (*close)(struct file *filep);
ssize_t (*read)(struct file *filep, char *buffer, size_t buflen);
ssize_t (*write)(struct file *filep, const char *buffer, size_t buflen);
off_t (*seek)(struct file *filep, off_t offset, int whence);
int (*ioctl)(struct file *filep, int cmd, unsigned long arg);
int (*mmap)(struct file* filep, struct VmMapRegion *region);
/* The two structures need not be common after this point */
#ifndef CONFIG_DISABLE_POLL
int (*poll)(struct file *filep, poll_table *fds);
#endif
int (*stat)(struct file *filep, struct stat* st);
int (*fallocate)(struct file* filep, int mode, off_t offset, off_t len);
int (*fallocate64)(struct file *filep, int mode, off64_t offset, off64_t len);
int (*fsync)(struct file *filep);
ssize_t (*readpage)(struct file *filep, char *buffer, size_t buflen);
int (*unlink)(struct Vnode *vnode);
};
/* file mapped in VMM pages */
struct page_mapping {
LOS_DL_LIST page_list; /* all pages */
SPIN_LOCK_S list_lock; /* lock protecting it */
LosMux mux_lock; /* mutex lock */
unsigned long nrpages; /* number of total pages */
unsigned long flags;
Atomic ref; /* reference counting */
struct file *host; /* owner of this mapping */
};
/* map: full_path(owner) <-> mapping */
struct file_map {
LOS_DL_LIST head;
LosMux lock; /* lock to protect this mapping */
struct page_mapping mapping;
int name_len;
char *rename;
char owner[0]; /* owner: full path of file */
};
/****************************************************************************
* Name: files_initlist
*
* Description:
* Initializes the list of files for a new task
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
void files_initlist(struct filelist *list);
#endif
/****************************************************************************
* Name: files_releaselist
*
* Description:
* Release a reference to the file list
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
void files_releaselist(struct filelist *list);
#endif
/****************************************************************************
* Name: file_dup2
*
* Description:
* Assign an vnode to a specific files structure. This is the heart of
* dup2.
*
* Equivalent to the non-standard fs_dupfd2() function except that it
* accepts struct file instances instead of file descriptors and it does
* not set the errno variable.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is return on
* any failure.
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int file_dup2(struct file *filep1, struct file *filep2);
#endif
/****************************************************************************
* Name: fs_dupfd OR dup
*
* Description:
* Clone a file descriptor 'fd' to an arbitrary descriptor number (any value
* greater than or equal to 'minfd'). If socket descriptors are
* implemented, then this is called by dup() for the case of file
* descriptors. If socket descriptors are not implemented, then this
* function IS dup().
*
* This alternative naming is used when dup could operate on both file and
* socket descriptors to avoid drawing unused socket support into the link.
*
* Returned Value:
* fs_dupfd is sometimes an OS internal function and sometimes is a direct
* substitute for dup(). So it must return an errno value as though it
* were dup().
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int fs_dupfd(int fd, int minfd);
#endif
/****************************************************************************
* Name: file_dup
*
* Description:
* Equivalent to the non-standard fs_dupfd() function except that it
* accepts a struct file instance instead of a file descriptor and does
* not set the errno variable.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure.
*
****************************************************************************/
int file_dup(struct file *filep, int minfd);
/****************************************************************************
* Name: fs_dupfd2 OR dup2
*
* Description:
* Clone a file descriptor to a specific descriptor number. If socket
* descriptors are implemented, then this is called by dup2() for the
* case of file descriptors. If socket descriptors are not implemented,
* then this function IS dup2().
*
* This alternative naming is used when dup2 could operate on both file and
* socket descriptors to avoid drawing unused socket support into the link.
*
* Returned Value:
* fs_dupfd2 is sometimes an OS internal function and sometimes is a direct
* substitute for dup2(). So it must return an errno value as though it
* were dup2().
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int fs_dupfd2(int fd1, int fd2);
#endif
/****************************************************************************
* Name: fs_ioctl
*
* Description:
* Perform device specific operations.
*
* Input Parameters:
* fd File/socket descriptor of device
* req The ioctl command
* arg The argument of the ioctl cmd
*
* Returned Value:
* >=0 on success (positive non-zero values are cmd-specific)
* -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
* EFAULT
* 'arg' references an inaccessible memory area.
* EINVAL
* 'cmd' or 'arg' is not valid.
* ENOTTY
* 'fd' is not associated with a character special device.
* ENOTTY
* The specified request does not apply to the kind of object that the
* descriptor 'fd' references.
*
****************************************************************************/
#ifdef CONFIG_LIBC_IOCTL_VARIADIC
int fs_ioctl(int fd, int req, unsigned long arg);
#endif
/****************************************************************************
* Name: lib_sendfile
*
* Description:
* Transfer a file
*
****************************************************************************/
#ifdef CONFIG_NET_SENDFILE
ssize_t lib_sendfile(int outfd, int infd, off_t *offset, size_t count);
#endif
/****************************************************************************
* Name: fs_getfilep
*
* Description:
* Given a file descriptor, return the corresponding instance of struct
* file. NOTE that this function will currently fail if it is provided
* with a socket descriptor.
*
* Input Parameters:
* fd - The file descriptor
* filep - The location to return the struct file instance
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure.
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int fs_getfilep(int fd, struct file **filep);
#endif
/****************************************************************************
* Name: file_read
*
* Description:
* file_read() is an internal OS interface. It is functionally similar to
* the standard read() interface except:
*
* - It does not modify the errno variable,
* - It is not a cancellation point,
* - It does not handle socket descriptors, and
* - It accepts a file structure instance instead of file descriptor.
*
* Input Parameters:
* filep - File structure instance
* buf - User-provided to save the data
* nbytes - The maximum size of the user-provided buffer
*
* Returned Value:
* The positive non-zero number of bytes read on success, 0 on if an
* end-of-file condition, or a negated errno value on any failure.
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
ssize_t file_read(struct file *filep, void *buf, size_t nbytes);
#endif
/****************************************************************************
* Name: file_write
*
* Description:
* Equivalent to the standard write() function except that is accepts a
* struct file instance instead of a file descriptor. Currently used
* only by aio_write();
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
ssize_t file_write(struct file *filep, const void *buf, size_t nbytes);
#endif
/****************************************************************************
* Name: file_pread
*
* Description:
* Equivalent to the standard pread function except that is accepts a
* struct file instance instead of a file descriptor. Currently used
* only by aio_read();
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
ssize_t file_pread(struct file *filep, void *buf, size_t nbytes,
off_t offset);
#endif
/****************************************************************************
* Name: file_pwrite
*
* Description:
* Equivalent to the standard pwrite function except that is accepts a
* struct file instance instead of a file descriptor. Currently used
* only by aio_write();
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
ssize_t file_pwrite(struct file *filep, const void *buf,
size_t nbytes, off_t offset);
#endif
/****************************************************************************
* Name: file_seek
*
* Description:
* Equivalent to the standard lseek() function except that is accepts a
* struct file instance instead of a file descriptor. Currently used
* only by net_sendfile()
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
off_t file_seek(struct file *filep, off_t offset, int whence);
#endif
/****************************************************************************
* Name: file_fsync
*
* Description:
* Equivalent to the standard fsync() function except that is accepts a
* struct file instance instead of a file descriptor and it does not set
* the errno variable.
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int file_fsync(struct file *filep);
#endif
/****************************************************************************
* Name: file_vfcntl
*
* Description:
* Similar to the standard vfcntl function except that is accepts a struct
* struct file instance instead of a file descriptor.
*
* Input Parameters:
* filep - Instance for struct file for the opened file.
* cmd - Indentifies the operation to be performed.
* ap - Variable argument following the command.
*
* Returned Value:
* The nature of the return value depends on the command. Non-negative
* values indicate success. Failures are reported as negated errno
* values.
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
int file_vfcntl(struct file *filep, int cmd, va_list ap);
#endif
/****************************************************************************
* Name: file_seek64
*
* Description:
* Equivalent to the standard lseek64() function except that is accepts a
* struct file instance instead of a file descriptor. Currently used
* only by net_sendfile()
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
off64_t file_seek64(struct file *filep, off64_t offset, int whence);
#endif
/****************************************************************************
* Name: files_allocate
*
* Description:
* Allocate a struct files instance and associate it with an vnode instance.
* Returns the file descriptor == index into the files array.
*
****************************************************************************/
int files_allocate(struct Vnode *vnode, int oflags, off_t pos, void *priv, int minfd);
/****************************************************************************
* Name: files_close
*
* Description:
* Close an vnode (if open)
*
* Assumuptions:
* Caller holds the list semaphore because the file descriptor will be freed.
*
****************************************************************************/
int files_close(int fd);
/****************************************************************************
* Name: files_release
*
* Assumuptions:
* Similar to files_close(). Called only from open() logic on error
* conditions.
*
****************************************************************************/
void files_release(int fd);
/****************************************************************************
* Name: files_initialize
*
* Description:
* This is called from the FS initialization logic to configure the files.
*
****************************************************************************/
void WEAK files_initialize(void);
int vfs_normalize_path(const char *directory, const char *filename, char **pathname);
int vfs_normalize_pathat(int fd, const char *filename, char **pathname);
struct filelist *sched_getfiles(void);
/* fs/fs_sendfile.c *************************************************/
/****************************************************************************
* Name: sendfile
*
* Description:
* Copy data between one file descriptor and another.
*
****************************************************************************/
ssize_t sendfile(int outfd, int infd, off_t *offset, size_t count);
/**
* @ingroup fs
* @brief get the path by a given file fd.
*
* @par Description:
* The function is used for getting the path by a given file fd.
*
* @attention
* <ul>
* <li>Only support file fd, not any dir fd.</li>
* </ul>
*
* @param fd [IN] Type #int file fd.
* @param path [IN] Type #char ** address of the location to return the path reference.
*
* @retval #0 get path success
* @retval #~0 get path failed
*
* @par Dependency:
* <ul><li>fs.h: the header file that contains the API declaration.</li></ul>
* @see
*
* @since 2020-1-8
*/
int get_path_from_fd(int fd, char **path);
bool get_bit(int i);
int AllocProcessFd(void);
int AllocLowestProcessFd(int minFd);
int AllocSpecifiedProcessFd(int procFd);
int AllocAndAssocProcessFd(int sysFd, int minFd);
int AllocAndAssocSystemFd(int procFd, int minFd);
void AssociateSystemFd(int procFd, int sysFd);
int DisassociateProcessFd(int procFd);
int GetAssociatedSystemFd(int procFd);
int CheckProcessFd(int procFd);
void FreeProcessFd(int procFd);
int CopyFdToProc(int fd, unsigned int targetPid);
int CloseProcFd(int fd, unsigned int targetPid);
void lsfd(void);
void set_sd_sync_fn(int (*sync_fn)(int));
struct Vnode *files_get_openfile(int fd);
void poll_wait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p);
int follow_symlink(int dirfd, const char *path, struct Vnode **vnode, char **fullpath);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* __INCLUDE_FS_FILE_H */

View File

@@ -33,7 +33,6 @@
#define FS_OPERATION_H
#include "fs/file.h"
#include "fs/fd_table.h"
#ifdef __cplusplus
#if __cplusplus
@@ -138,11 +137,6 @@ extern int update_file_path(const char *old_path, const char *new_path);
void los_vfs_init(void);
void CloseOnExec(struct files_struct *files);
void SetCloexecFlag(int procFd);
bool CheckCloexecFlag(int procFd);
void ClearCloexecFlag(int procFd);
void clear_fd(int fd);
/**
@@ -310,23 +304,7 @@ extern int los_set_systime_status(BOOL b_status);
struct IATTR;
extern int chattr(const char *pathname, struct IATTR *attr);
#define CONTINE_NUTTX_FCNTL 0XFF0F
/**
* @ingroup fs
*
* @par Description:
* The VfsFcntl function shall manipulate file descriptor.
*
* @retval #0 On success.
* @retval #-1 On failure with errno set.
* @retval CONTINE_NUTTX_FCNTL doesn't support some cmds in VfsFcntl, needs to continue going through Nuttx vfs operation.</li>
*
* @par Dependency:
* <ul><li>fs.h</li></ul>
* @see None
*/
extern int VfsFcntl(int fd, int cmd, ...);
/**
* @ingroup fs
*

View File

@@ -45,7 +45,6 @@ struct Mount {
const struct MountOps *ops; /* operations of mount */
struct Vnode *vnodeBeCovered; /* vnode we mounted on */
struct Vnode *vnodeCovered; /* syncer vnode */
struct Vnode *vnodeDev; /* dev vnode */
LIST_HEAD vnodeList; /* list of vnodes */
int vnodeSize; /* size of vnode list */
LIST_HEAD activeVnodeList; /* list of active vnodes */
@@ -71,5 +70,4 @@ typedef int (*foreach_mountpoint_t)(const char *devpoint,
struct Mount* MountAlloc(struct Vnode* vnode, struct MountOps* mop);
LIST_HEAD* GetMountList(void);
int foreach_mountpoint(foreach_mountpoint_t handler, void *arg);
int ForceUmountDev(struct Vnode *dev);
#endif

View File

@@ -1,75 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -205,7 +205,7 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct
if (newVnode) {
if (newVnode->data == NULL) {
LOS_Panic("#####VfsHashGet error#####\n");
}
}
newVnode->parent = parentVnode;
*ppVnode = newVnode;
return 0;
@@ -591,16 +591,13 @@ int VfsJffs2Chattr(struct Vnode *pVnode, struct IATTR *attr)
int VfsJffs2Rmdir(struct Vnode *parentVnode, struct Vnode *targetVnode, const char *path)
{
int ret;
struct jffs2_inode *parentInode = NULL;
struct jffs2_inode *targetInode = NULL;
struct jffs2_inode *parentInode = (struct jffs2_inode *)parentVnode->data;
struct jffs2_inode *targetInode = (struct jffs2_inode *)targetVnode->data;
if (!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_rmdir(parentInode, targetInode, (const unsigned char *)path);
@@ -810,11 +807,6 @@ 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;

View File

@@ -1,40 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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,31 +25,23 @@
# 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("//kernel/liteos_a/liteos.gni")
module_switch = defined(LOSCFG_FS_PROC)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
static_library("fs_proc") {
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/proc_vfs.c",
"os_adapt/process_proc.c",
"os_adapt/uptime_proc.c",
"os_adapt/vmm_proc.c",
"src/proc_file.c",
"os_adapt/vfs_proc.c",
"src/proc_shellcmd.c",
"src/pseudofs.c",
"src/seq_file.c",
]
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
if (LOSCFG_LLTREPORT) {
cflags += [
"-fprofile-arcs",
"-ftest-coverage",
]
}
}

View File

@@ -75,7 +75,7 @@ static void FillFdInfo(struct SeqBuf *seqBuf, struct filelist *fileList, unsigne
}
if (hasPrivilege) {
(void)LosBufPrintf(seqBuf, "%u\t%d\t%6d <%d>\t%s\n", pid, fd, sysFd, filp->f_refcount, name);
(void)LosBufPrintf(seqBuf, "%u\t%d\t%d\t%s\n", pid, fd, sysFd, name);
} else {
(void)LosBufPrintf(seqBuf, "%u\t%d\t%s\n", pid, fd, name);
}
@@ -101,7 +101,7 @@ static int FdProcFill(struct SeqBuf *seqBuf, void *v)
}
pidNum = LOS_GetUsedPIDList(pidList, pidMaxNum);
hasPrivilege = true;
(void)LosBufPrintf(seqBuf, "%s\t%s\t%6s %s\t%s\n", "Pid", "Fd", "SysFd", "<ref>", "Name");
(void)LosBufPrintf(seqBuf, "Pid\tFd\tSysFd\tName\n");
} else {
pidNum = 1;
pidList = (unsigned int *)malloc(pidNum * sizeof(unsigned int));

View File

@@ -40,8 +40,7 @@
#define CLEAR_PATH_CACHE "clear pathcache"
#define CLEAR_PAGE_CACHE "clear pagecache"
static char* VnodeTypeToStr(enum VnodeType type)
{
static char* VnodeTypeToStr(enum VnodeType type) {
switch (type) {
case VNODE_TYPE_UNKNOWN:
return "UKN";
@@ -136,9 +135,9 @@ static int PageCacheMapProcess(struct SeqBuf *buf)
static int FsCacheInfoFill(struct SeqBuf *buf, void *arg)
{
int vnodeFree = 0;
int vnodeActive = 0;
int vnodeVirtual = 0;
int vnodeFree= 0;
int vnodeActive= 0;
int vnodeVirtual= 0;
int vnodeTotal = 0;
int pathCacheTotal = 0;

View File

@@ -1,36 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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" ]
}

View File

@@ -1,39 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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",
]
}

View File

@@ -1,119 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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/fullpath.c",
"operation/vfs_chattr.c",
"operation/vfs_check.c",
"operation/vfs_cloexec.c",
"operation/vfs_fallocate.c",
"operation/vfs_fallocate64.c",
"operation/vfs_fcntl.c",
"operation/vfs_file_mapping.c",
"operation/vfs_force_umount.c",
"operation/vfs_init.c",
"operation/vfs_other.c",
"operation/vfs_preadv.c",
"operation/vfs_procfd.c",
"operation/vfs_pwritev.c",
"operation/vfs_readv.c",
"operation/vfs_utime.c",
"operation/vfs_writev.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" ]
}

View File

@@ -1,42 +0,0 @@
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. 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

@@ -43,7 +43,7 @@ struct PathCache {
LIST_ENTRY hashEntry; /* list entry for buckets in the hash table */
uint8_t nameLen; /* length of path component */
#ifdef LOSCFG_DEBUG_VERSION
int hit; /* cache hit count */
int hit; /* cache hit count*/
#endif
char name[0]; /* path component name */
};

View File

@@ -39,7 +39,7 @@
typedef LOS_DL_LIST LIST_HEAD;
typedef LOS_DL_LIST LIST_ENTRY;
#define VNODE_FLAG_MOUNT_NEW (1 << 0) /* new mount vnode */
#define VNODE_FLAG_MOUNT_NEW (1 << 0) /* new mount vnode*/
#define VNODE_FLAG_MOUNT_ORIGIN (1 << 1) /* origin vnode */
#define V_CREATE (1 << 0)
@@ -76,17 +76,18 @@ typedef LOS_DL_LIST LIST_ENTRY;
#define CHG_MTIME 32
#define CHG_CTIME 64
struct IATTR {
/* This structure is used for record vnode attr. */
unsigned int attr_chg_valid;
unsigned int attr_chg_flags;
unsigned attr_chg_mode;
unsigned attr_chg_uid;
unsigned attr_chg_gid;
unsigned attr_chg_size;
unsigned attr_chg_atime;
unsigned attr_chg_mtime;
unsigned attr_chg_ctime;
struct IATTR
{
/* This structure is used for record vnode attr. */
unsigned int attr_chg_valid;
unsigned int attr_chg_flags;
unsigned attr_chg_mode;
unsigned attr_chg_uid;
unsigned attr_chg_gid;
unsigned attr_chg_size;
unsigned attr_chg_atime;
unsigned attr_chg_mtime;
unsigned attr_chg_ctime;
};
/*

View File

@@ -37,7 +37,7 @@
#include "lwip/sockets.h"
#endif
void FileTableLock(struct fd_table_s *fdt)
static void FileTableLock(struct fd_table_s *fdt)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&fdt->ft_sem) != 0) {
@@ -49,7 +49,7 @@ void FileTableLock(struct fd_table_s *fdt)
}
}
void FileTableUnLock(struct fd_table_s *fdt)
static void FileTableUnLock(struct fd_table_s *fdt)
{
int ret = sem_post(&fdt->ft_sem);
if (ret == -1) {
@@ -78,7 +78,7 @@ static int AssignProcessFd(const struct fd_table_s *fdt, int minFd)
return VFS_ERROR;
}
struct fd_table_s *GetFdTable(void)
static struct fd_table_s *GetFdTable(void)
{
struct fd_table_s *fdt = NULL;
struct files_struct *procFiles = OsCurrProcessGet()->files;
@@ -197,7 +197,6 @@ void FreeProcessFd(int procFd)
FileTableLock(fdt);
FD_CLR(procFd, fdt->proc_fds);
FD_CLR(procFd, fdt->cloexec_fds);
fdt->ft_fds[procFd].sysFd = -1;
FileTableUnLock(fdt);
}
@@ -318,7 +317,7 @@ static void FdRefer(int sysFd)
#endif
#if defined(LOSCFG_COMPAT_POSIX)
if ((sysFd >= MQUEUE_FD_OFFSET) && (sysFd < (MQUEUE_FD_OFFSET + CONFIG_NQUEUE_DESCRIPTORS))) {
MqueueRefer(sysFd);
mqueue_refer(sysFd);
}
#endif
}
@@ -468,7 +467,6 @@ int CloseProcFd(int procFd, unsigned int targetPid)
/* clean the fd set */
FD_CLR(procFd, fdt->proc_fds);
FD_CLR(procFd, fdt->cloexec_fds);
fdt->ft_fds[procFd].sysFd = -1;
if (sem_post(&semId) == -1) {
PRINTK("sem_post error, errno %d \n", get_errno());

View File

@@ -460,10 +460,8 @@ void sync(void)
{
(void)sd_sync_fn(0);
(void)sd_sync_fn(1);
return;
}
#endif
PRINT_ERR("Unsupport syscall %s\n", __FUNCTION__);
}
static char *ls_get_fullpath(const char *path, struct dirent *pdirent)

View File

@@ -1,97 +0,0 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. 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.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include "fs/file.h"
#include "fs/fs_operation.h"
#include "fs/fd_table.h"
#include "unistd.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void CloseOnExec(struct files_struct *files)
{
int sysFd;
if ((files == NULL) || (files->fdt == NULL)) {
return;
}
for (int i = 0; i < files->fdt->max_fds; i++) {
if (FD_ISSET(i, files->fdt->proc_fds) &&
FD_ISSET(i, files->fdt->cloexec_fds)) {
sysFd = DisassociateProcessFd(i);
close(sysFd);
FreeProcessFd(i);
}
}
}
void SetCloexecFlag(int procFd)
{
struct fd_table_s *fdt = GetFdTable();
if (fdt == NULL) {
return;
}
FileTableLock(fdt);
FD_SET(procFd, fdt->cloexec_fds);
FileTableUnLock(fdt);
return;
}
bool CheckCloexecFlag(int procFd)
{
bool isCloexec = 0;
struct fd_table_s *fdt = GetFdTable();
if (fdt == NULL) {
return false;
}
FileTableLock(fdt);
isCloexec = FD_ISSET(procFd, fdt->cloexec_fds);
FileTableUnLock(fdt);
return isCloexec;
}
void ClearCloexecFlag(int procFd)
{
struct fd_table_s *fdt = GetFdTable();
if (fdt == NULL) {
return;
}
FileTableLock(fdt);
FD_CLR(procFd, fdt->cloexec_fds);
FileTableUnLock(fdt);
return;
}

View File

@@ -1,104 +0,0 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. 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.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include "fs/file.h"
#include "fs/fd_table.h"
#include "fs/fs_operation.h"
#include "sys/types.h"
#include "sys/uio.h"
/****************************************************************************
* Private Functions
****************************************************************************/
static int FcntlDupFd(int procfd, int leastFd)
{
int sysfd = GetAssociatedSystemFd(procfd);
if ((sysfd < 0) || (sysfd >= CONFIG_NFILE_DESCRIPTORS)) {
return -EBADF;
}
if (CheckProcessFd(leastFd) != OK) {
return -EINVAL;
}
int dupFd = AllocLowestProcessFd(leastFd);
if (dupFd < 0) {
return -EMFILE;
}
files_refer(sysfd);
AssociateSystemFd(dupFd, sysfd);
return dupFd;
}
/****************************************************************************
* Public Functions
****************************************************************************/
int VfsFcntl(int procfd, int cmd, ...)
{
va_list ap;
int ret = 0;
va_start(ap, cmd);
switch (cmd) {
case F_DUPFD:
{
int arg = va_arg(ap, int);
ret = FcntlDupFd(procfd, arg);
}
break;
case F_GETFD:
{
bool isCloexec = CheckCloexecFlag(procfd);
ret = isCloexec ? FD_CLOEXEC : 0;
}
break;
case F_SETFD:
{
int oflags = va_arg(ap, int);
if (oflags & FD_CLOEXEC) {
SetCloexecFlag(procfd);
} else {
ClearCloexecFlag(procfd);
}
}
break;
default:
ret = CONTINE_NUTTX_FCNTL;
break;
}
va_end(ap);
return ret;
}

View File

@@ -1,391 +0,0 @@
/*
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "fs/mount.h"
#include "fs/dirent_fs.h"
#include "fs/file.h"
#include "vnode.h"
#include "path_cache.h"
/* vnode operations returns EIO */
static int ErrorVopCreate (struct Vnode *parent, const char *name, int mode, struct Vnode **vnode)
{
return -EIO;
}
static int ErrorVopLookup (struct Vnode *parent, const char *name, int len, struct Vnode **vnode)
{
return -EIO;
}
static int ErrorVopOpen (struct Vnode *vnode, int fd, int mode, int flags)
{
return -EIO;
}
static int ErrorVopClose (struct Vnode *vnode)
{
/* already closed at force umount, do nothing here */
return OK;
}
static int ErrorVopReclaim (struct Vnode *vnode)
{
return -EIO;
}
static int ErrorVopUnlink (struct Vnode *parent, struct Vnode *vnode, const char *fileName)
{
return -EIO;
}
static int ErrorVopRmdir (struct Vnode *parent, struct Vnode *vnode, const char *dirName)
{
return -EIO;
}
static int ErrorVopMkdir (struct Vnode *parent, const char *dirName, mode_t mode, struct Vnode **vnode)
{
return -EIO;
}
static int ErrorVopReaddir (struct Vnode *vnode, struct fs_dirent_s *dir)
{
return -EIO;
}
static int ErrorVopOpendir (struct Vnode *vnode, struct fs_dirent_s *dir)
{
return -EIO;
}
static int ErrorVopRewinddir (struct Vnode *vnode, struct fs_dirent_s *dir)
{
return -EIO;
}
static int ErrorVopClosedir (struct Vnode *vnode, struct fs_dirent_s *dir)
{
/* already closed at force umount, do nothing here */
return OK;
}
static int ErrorVopGetattr (struct Vnode *vnode, struct stat *st)
{
return -EIO;
}
static int ErrorVopSetattr (struct Vnode *vnode, struct stat *st)
{
return -EIO;
}
static int ErrorVopChattr (struct Vnode *vnode, struct IATTR *attr)
{
return -EIO;
}
static int ErrorVopRename (struct Vnode *src, struct Vnode *dstParent, const char *srcName, const char *dstName)
{
return -EIO;
}
static int ErrorVopTruncate (struct Vnode *vnode, off_t len)
{
return -EIO;
}
static int ErrorVopTruncate64 (struct Vnode *vnode, off64_t len)
{
return -EIO;
}
static int ErrorVopFscheck (struct Vnode *vnode, struct fs_dirent_s *dir)
{
return -EIO;
}
static int ErrorVopLink (struct Vnode *src, struct Vnode *dstParent, struct Vnode **dst, const char *dstName)
{
return -EIO;
}
static int ErrorVopSymlink (struct Vnode *parentVnode, struct Vnode **newVnode, const char *path, const char *target)
{
return -EIO;
}
static ssize_t ErrorVopReadlink (struct Vnode *vnode, char *buffer, size_t bufLen)
{
return -EIO;
}
static struct VnodeOps g_errorVnodeOps = {
.Create = ErrorVopCreate,
.Lookup = ErrorVopLookup,
.Open = ErrorVopOpen,
.Close = ErrorVopClose,
.Reclaim = ErrorVopReclaim,
.Unlink = ErrorVopUnlink,
.Rmdir = ErrorVopRmdir,
.Mkdir = ErrorVopMkdir,
.Readdir = ErrorVopReaddir,
.Opendir = ErrorVopOpendir,
.Rewinddir = ErrorVopRewinddir,
.Closedir = ErrorVopClosedir,
.Getattr = ErrorVopGetattr,
.Setattr = ErrorVopSetattr,
.Chattr = ErrorVopChattr,
.Rename = ErrorVopRename,
.Truncate = ErrorVopTruncate,
.Truncate64 = ErrorVopTruncate64,
.Fscheck = ErrorVopFscheck,
.Link = ErrorVopLink,
.Symlink = ErrorVopSymlink,
.Readlink = ErrorVopReadlink,
};
/* file operations returns EIO */
static int ErrorFopOpen (struct file *filep)
{
return -EIO;
}
static int ErrorFopClose (struct file *filep)
{
/* already closed at force umount, do nothing here */
return OK;
}
static ssize_t ErrorFopRead (struct file *filep, char *buffer, size_t buflen)
{
return -EIO;
}
static ssize_t ErrorFopWrite (struct file *filep, const char *buffer, size_t buflen)
{
return -EIO;
}
static off_t ErrorFopSeek (struct file *filep, off_t offset, int whence)
{
return -EIO;
}
static int ErrorFopIoctl (struct file *filep, int cmd, unsigned long arg)
{
return -EIO;
}
static int ErrorFopMmap (struct file* filep, struct VmMapRegion *region)
{
return -EIO;
}
static int ErrorFopPoll (struct file *filep, poll_table *fds)
{
return -EIO;
}
static int ErrorFopStat (struct file *filep, struct stat* st)
{
return -EIO;
}
static int ErrorFopFallocate (struct file* filep, int mode, off_t offset, off_t len)
{
return -EIO;
}
static int ErrorFopFallocate64 (struct file *filep, int mode, off64_t offset, off64_t len)
{
return -EIO;
}
static int ErrorFopFsync (struct file *filep)
{
return -EIO;
}
static ssize_t ErrorFopReadpage (struct file *filep, char *buffer, size_t buflen)
{
return -EIO;
}
static int ErrorFopUnlink (struct Vnode *vnode)
{
return -EIO;
}
static struct file_operations_vfs g_errorFileOps = {
.open = ErrorFopOpen,
.close = ErrorFopClose,
.read = ErrorFopRead,
.write = ErrorFopWrite,
.seek = ErrorFopSeek,
.ioctl = ErrorFopIoctl,
.mmap = ErrorFopMmap,
.poll = ErrorFopPoll,
.stat = ErrorFopStat,
.fallocate = ErrorFopFallocate,
.fallocate64 = ErrorFopFallocate64,
.fsync = ErrorFopFsync,
.readpage = ErrorFopReadpage,
.unlink = ErrorFopUnlink,
};
static struct Mount* GetDevMountPoint(struct Vnode *dev)
{
struct Mount *mnt = NULL;
LIST_HEAD *mntList = GetMountList();
LOS_DL_LIST_FOR_EACH_ENTRY(mnt, mntList, struct Mount, mountList) {
if (mnt->vnodeDev == dev) {
return mnt;
}
}
return NULL;
}
static void DirPreClose(struct fs_dirent_s *dirp)
{
struct Vnode *node = NULL;
if (dirp == NULL || dirp->fd_root == NULL) {
return;
}
node = dirp->fd_root;
if (node->vop && node->vop->Closedir) {
node->vop->Closedir(node, dirp);
}
}
static void FilePreClose(struct file *filep, const struct file_operations_vfs *ops)
{
if (filep->f_oflags & O_DIRECTORY) {
DirPreClose(filep->f_dir);
return;
}
if (ops && ops->close) {
ops->close(filep);
}
}
static void FileDisableAndClean(struct Mount *mnt)
{
struct filelist *flist = &tg_filelist;
struct file *filep = NULL;
const struct file_operations_vfs *originOps;
for (int i = 3; i < CONFIG_NFILE_DESCRIPTORS; i++) {
if (!get_bit(i)) {
continue;
}
filep = &flist->fl_files[i];
if (filep == NULL || filep->f_vnode == NULL) {
continue;
}
if (filep->f_vnode->originMount != mnt) {
continue;
}
originOps = filep->ops;
filep->ops = &g_errorFileOps;
FilePreClose(filep, originOps);
}
}
static void VnodeTryFree(struct Vnode *vnode)
{
if (vnode->useCount == 0) {
VnodeFree(vnode);
return;
}
VnodePathCacheFree(vnode);
LOS_ListDelete(&(vnode->hashEntry));
LOS_ListDelete(&vnode->actFreeEntry);
if (vnode->vop->Reclaim) {
vnode->vop->Reclaim(vnode);
}
vnode->vop = &g_errorVnodeOps;
vnode->fop = &g_errorFileOps;
}
static void VnodeTryFreeAll(struct Mount *mount)
{
struct Vnode *vnode = NULL;
struct Vnode *nextVnode = NULL;
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(vnode, nextVnode, GetVnodeActiveList(), struct Vnode, actFreeEntry) {
if ((vnode->originMount != mount) || (vnode->flag & VNODE_FLAG_MOUNT_NEW)) {
continue;
}
VnodeTryFree(vnode);
}
}
int ForceUmountDev(struct Vnode *dev)
{
int ret;
struct Vnode *origin;
struct filelist *flist = &tg_filelist;
if (dev == NULL) {
return -EINVAL;
}
(void)sem_wait(&flist->fl_sem);
VnodeHold();
struct Mount *mnt = GetDevMountPoint(dev);
if (mnt == NULL) {
VnodeDrop();
(void)sem_post(&flist->fl_sem);
return -ENXIO;
}
origin = mnt->vnodeBeCovered;
FileDisableAndClean(mnt);
VnodeTryFreeAll(mnt);
ret = mnt->ops->Unmount(mnt, &dev);
if (ret != OK) {
PRINT_ERR("unmount in fs failed, ret = %d, errno = %d\n", ret, errno);
}
LOS_ListDelete(&mnt->mountList);
free(mnt);
origin->newMount = NULL;
origin->flag &= ~(VNODE_FLAG_MOUNT_ORIGIN);
VnodeDrop();
(void)sem_post(&flist->fl_sem);
return OK;
}

View File

@@ -367,6 +367,7 @@ int VnodeLookup(const char *path, struct Vnode **result, uint32_t flags)
int ret = PreProcess(path, &startVnode, &normalizedPath);
if (ret != LOS_OK) {
PRINT_ERR("[VFS]lookup failed, invalid path=%s err = %d\n", path, ret);
goto OUT_FREE_PATH;
}
@@ -384,7 +385,6 @@ int VnodeLookup(const char *path, struct Vnode **result, uint32_t flags)
if (currentDir == NULL || *currentDir == '\0') {
// return target or parent vnode as result
*result = currentVnode;
goto OUT_FREE_PATH;
} else if (VfsVnodePermissionCheck(currentVnode, EXEC_OP)) {
ret = -EACCES;
goto OUT_FREE_PATH;

View File

@@ -27,13 +27,16 @@
# 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_ZPFS)
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
static_library("fs_zpfs") {
sources = [
"vfs_zpfs.c",
"zpfs.c",
]
if (LOSCFG_LLTREPORT) {
cflags += [
"-fprofile-arcs",
"-ftest-coverage",
]
}
}

View File

@@ -25,25 +25,32 @@
# 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("//kernel/liteos_a/liteos.gni")
import("//build/lite/config/component/lite_component.gni")
group("kernel") {
deps = [
lite_component("kernel") {
features = [
"base",
"common",
"extended",
"syscall",
"user",
]
}
config("public") {
include_dirs = [ "include" ]
configs = [
"base:public",
"common:public",
"extended:public",
"user:public",
]
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" ]
}
}

View File

@@ -25,37 +25,33 @@
# 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("//kernel/liteos_a/liteos.gni")
module_name = get_path_info(rebase_path("."), "name")
kernel_module(module_name) {
static_library("base") {
sources = [
"core/los_bitmap.c",
"core/los_process.c",
"core/los_sortlink.c",
"core/los_swtmr.c",
"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",
"ipc/los_signal.c",
"mem/bestfit/los_memory.c",
"mem/bestfit/los_multipledlinkhead.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",
@@ -63,32 +59,22 @@ kernel_module(module_name) {
"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",
"sched/sched_sq/los_sortlink.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",
"vm/filemap.c",
"vm/pmm.c",
"vm/vm.c",
"vm/vmm.c",
]
if (defined(LOSCFG_SHELL_CMD_DEBUG)) {
configs += [ "$HDFTOPDIR:hdf_config" ]
}
public_configs = [ ":public" ]
}
config("public") {
include_dirs = [ "include" ]
include_dirs = [
"include",
"../extended/include",
"../extended/vdso/include",
"../extended/dynload/include",
"../include",
"mem",
]
}

View File

@@ -48,4 +48,4 @@ LOCAL_INCLUDE := \
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
include $(MODULE)
include $(HDF_DRIVER)

View File

@@ -39,7 +39,6 @@
#include "asm/page.h"
#ifdef LOSCFG_FS_VFS
#include "fs/fd_table.h"
#include "fs/fs_operation.h"
#endif
#include "time.h"
#include "user_copy.h"
@@ -58,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_processRecycleList;
LITE_OS_SEC_DATA_INIT STATIC LOS_DL_LIST g_processRecyleList;
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;
@@ -291,7 +290,7 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
#ifdef LOSCFG_FS_VFS
if (OsProcessIsUserMode(processCB)) {
delete_files(processCB->files);
delete_files(processCB, processCB->files);
}
processCB->files = NULL;
#endif
@@ -332,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_processRecycleList, &childCB->pendList);
LOS_ListHeadInsert(&g_processRecyleList, &childCB->pendList);
} else if (childCB->processStatus & OS_PROCESS_FLAG_GROUP_LEADER) {
LOS_ListTailInsert(&g_processRecycleList, &childCB->pendList);
LOS_ListTailInsert(&g_processRecyleList, &childCB->pendList);
} else {
OsInsertPCBToFreeList(childCB);
}
@@ -414,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_processRecycleList, &processCB->pendList);
LOS_ListHeadInsert(&g_processRecyleList, &processCB->pendList);
OsRunTaskToDelete(runTask);
return;
}
@@ -438,7 +437,7 @@ STATIC UINT32 OsProcessInit(VOID)
(VOID)memset_s(g_processCBArray, size, 0, size);
LOS_ListInit(&g_freeProcess);
LOS_ListInit(&g_processRecycleList);
LOS_ListInit(&g_processRecyleList);
for (index = 0; index < g_processMaxNum; index++) {
g_processCBArray[index].processID = index;
@@ -458,14 +457,14 @@ STATIC UINT32 OsProcessInit(VOID)
return LOS_OK;
}
LITE_OS_SEC_TEXT VOID OsProcessCBRecycleToFree(VOID)
LITE_OS_SEC_TEXT VOID OsProcessCBRecyleToFree(VOID)
{
UINT32 intSave;
LosProcessCB *processCB = NULL;
SCHEDULER_LOCK(intSave);
while (!LOS_ListEmpty(&g_processRecycleList)) {
processCB = OS_PCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_processRecycleList));
while (!LOS_ListEmpty(&g_processRecyleList)) {
processCB = OS_PCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_processRecyleList));
if (!(processCB->processStatus & OS_PROCESS_FLAG_EXIT)) {
break;
}
@@ -488,7 +487,7 @@ LITE_OS_SEC_TEXT VOID OsProcessCBRecycleToFree(VOID)
LOS_ListDelete(&processCB->pendList);
if ((processCB->processStatus & OS_PROCESS_FLAG_GROUP_LEADER) ||
(processCB->processStatus & OS_PROCESS_STATUS_ZOMBIES)) {
LOS_ListTailInsert(&g_processRecycleList, &processCB->pendList);
LOS_ListTailInsert(&g_processRecyleList, &processCB->pendList);
} else {
/* Clear the bottom 4 bits of process status */
OsInsertPCBToFreeList(processCB);
@@ -526,7 +525,7 @@ STATIC VOID OsDeInitPCB(LosProcessCB *processCB)
processCB->processStatus &= ~OS_PROCESS_STATUS_INIT;
processCB->processStatus |= OS_PROCESS_FLAG_EXIT;
LOS_ListHeadInsert(&g_processRecycleList, &processCB->pendList);
LOS_ListHeadInsert(&g_processRecyleList, &processCB->pendList);
SCHEDULER_UNLOCK(intSave);
(VOID)LOS_MemFree(m_aucSysMem1, group);
@@ -1006,7 +1005,7 @@ WAIT_BACK:
return LOS_OK;
}
STATIC UINT32 OsWaitRecycleChildProcess(const LosProcessCB *childCB, UINT32 intSave, INT32 *status)
STATIC UINT32 OsWaitRecycleChildPorcess(const LosProcessCB *childCB, UINT32 intSave, INT32 *status)
{
ProcessGroup *group = NULL;
UINT32 pid = childCB->processID;
@@ -1082,7 +1081,7 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
}
if (childCB != NULL) {
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status);
return (INT32)OsWaitRecycleChildPorcess(childCB, intSave, status);
}
if ((options & LOS_WAIT_WNOHANG) != 0) {
@@ -1105,7 +1104,7 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
goto ERROR;
}
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status);
return (INT32)OsWaitRecycleChildPorcess(childCB, intSave, status);
ERROR:
SCHEDULER_UNLOCK(intSave);
@@ -1307,8 +1306,8 @@ LITE_OS_SEC_TEXT UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR
LOS_VmSpaceFree(oldSpace);
#ifdef LOSCFG_FS_VFS
CloseOnExec((struct files_struct *)oldFiles);
delete_files_snapshot((struct files_struct *)oldFiles);
delete_files(OsCurrProcessGet(), (struct files_struct *)oldFiles);
alloc_std_fd(OsCurrProcessGet()->files->fdt);
#endif
OsSwtmrRecycle(processCB->processID);

View File

@@ -36,6 +36,7 @@
#include "los_sched_pri.h"
#include "los_mp.h"
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHeader)
{
LOS_ListInit(&sortLinkHeader->sortLink);
@@ -86,25 +87,45 @@ VOID OsDeleteNodeSortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortL
STATIC INLINE UINT64 OsGetSortLinkNextExpireTime(SortLinkAttribute *sortHeader, UINT64 startTime)
{
UINT64 expirTime = 0;
UINT64 nextExpirTime = 0;
LOS_DL_LIST *head = &sortHeader->sortLink;
LOS_DL_LIST *list = head->pstNext;
if (LOS_ListEmpty(head)) {
return OS_SCHED_MAX_RESPONSE_TIME - OS_TICK_RESPONSE_PRECISION;
return (UINT64)-1;
}
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
if (listSorted->responseTime <= (startTime + OS_TICK_RESPONSE_PRECISION)) {
return startTime + OS_TICK_RESPONSE_PRECISION;
do {
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
if (listSorted->responseTime <= startTime) {
expirTime = startTime;
list = list->pstNext;
} else {
nextExpirTime = listSorted->responseTime;
break;
}
} while (list != head);
if (expirTime == 0) {
return nextExpirTime;
}
return listSorted->responseTime;
if (nextExpirTime == 0) {
return expirTime;
}
if ((nextExpirTime - expirTime) <= OS_US_PER_TICK) {
return nextExpirTime;
}
return expirTime;
}
STATIC Percpu *OsFindIdleCpu(UINT16 *idleCpuID)
STATIC Percpu *OsFindIdleCpu(UINT16 *ildeCpuID)
{
Percpu *idleCpu = OsPercpuGetByID(0);
*idleCpuID = 0;
*ildeCpuID = 0;
#ifdef LOSCFG_KERNEL_SMP
UINT16 cpuID = 1;
@@ -115,7 +136,7 @@ STATIC Percpu *OsFindIdleCpu(UINT16 *idleCpuID)
UINT32 temp = cpu->taskSortLink.nodeNum + cpu->swtmrSortLink.nodeNum;
if (nodeNum > temp) {
idleCpu = cpu;
*idleCpuID = cpuID;
*ildeCpuID = cpuID;
}
cpuID++;
@@ -210,7 +231,7 @@ UINT64 OsGetNextExpireTime(UINT64 startTime)
UINT32 OsSortLinkGetTargetExpireTime(const SortLinkList *targetSortList)
{
UINT64 currTimes = OsGetCurrSchedTimeCycle();
UINT64 currTimes = OsGerCurrSchedTimeCycle();
if (currTimes >= targetSortList->responseTime) {
return 0;
}

View File

@@ -178,9 +178,10 @@ ERROR:
* Description: Start Software Timer
* Input : swtmr --- Need to start software timer
*/
LITE_OS_SEC_TEXT VOID OsSwtmrStart(UINT64 currTime, SWTMR_CTRL_S *swtmr)
LITE_OS_SEC_TEXT VOID OsSwtmrStart(SWTMR_CTRL_S *swtmr)
{
UINT32 ticks;
UINT64 currTime = OsGerCurrSchedTimeCycle();
if ((swtmr->uwOverrun == 0) && ((swtmr->ucMode == LOS_SWTMR_MODE_ONCE) ||
(swtmr->ucMode == LOS_SWTMR_MODE_OPP) ||
@@ -191,8 +192,10 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStart(UINT64 currTime, SWTMR_CTRL_S *swtmr)
}
swtmr->ucState = OS_SWTMR_STATUS_TICKING;
OsAdd2SortLink(&swtmr->stSortList, swtmr->startTime, ticks, OS_SORT_LINK_SWTMR);
OsSchedUpdateExpireTime(currTime);
OsAdd2SortLink(&swtmr->stSortList, currTime, ticks, OS_SORT_LINK_SWTMR);
if (OS_SCHEDULER_ACTIVE) {
OsSchedUpdateExpireTime(currTime);
}
return;
}
@@ -208,7 +211,7 @@ STATIC INLINE VOID OsSwtmrDelete(SWTMR_CTRL_S *swtmr)
swtmr->uwOwnerPid = 0;
}
STATIC INLINE VOID OsWakePendTimeSwtmr(Percpu *cpu, UINT64 currTime, SWTMR_CTRL_S *swtmr)
STATIC INLINE VOID OsWakePendTimeSwtmr(Percpu *cpu, SWTMR_CTRL_S *swtmr)
{
LOS_SpinLock(&g_swtmrSpin);
SwtmrHandlerItemPtr swtmrHandler = (SwtmrHandlerItemPtr)LOS_MemboxAlloc(g_swtmrHandlerPool);
@@ -233,7 +236,7 @@ STATIC INLINE VOID OsWakePendTimeSwtmr(Percpu *cpu, UINT64 currTime, SWTMR_CTRL_
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
} else {
swtmr->uwOverrun++;
OsSwtmrStart(currTime, swtmr);
OsSwtmrStart(swtmr);
}
LOS_SpinUnlock(&g_swtmrSpin);
@@ -261,15 +264,15 @@ LITE_OS_SEC_TEXT VOID OsSwtmrScan(VOID)
}
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
UINT64 currTime = OsGetCurrSchedTimeCycle();
UINT64 currTime = OsGerCurrSchedTimeCycle();
while (sortList->responseTime <= currTime) {
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
swtmr->startTime = GET_SORTLIST_VALUE(sortList);
OsDeleteNodeSortLink(swtmrSortLink, sortList);
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
OsWakePendTimeSwtmr(cpu, currTime, swtmr);
OsWakePendTimeSwtmr(cpu, swtmr);
LOS_SpinLock(&cpu->swtmrSortLinkSpin);
if (LOS_ListEmpty(listObject)) {
@@ -302,7 +305,9 @@ LITE_OS_SEC_TEXT STATIC VOID OsSwtmrStop(SWTMR_CTRL_S *swtmr)
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
swtmr->uwOverrun = 0;
OsSchedUpdateExpireTime(OsGetCurrSchedTimeCycle());
if (OS_SCHEDULER_ACTIVE) {
OsSchedUpdateExpireTime(OsGerCurrSchedTimeCycle());
}
}
/*
@@ -398,8 +403,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID)
OsSwtmrStop(swtmr);
/* fall-through */
case OS_SWTMR_STATUS_CREATED:
swtmr->startTime = OsGetCurrSchedTimeCycle();
OsSwtmrStart(swtmr->startTime, swtmr);
OsSwtmrStart(swtmr);
break;
default:
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;

View File

@@ -37,7 +37,7 @@
LITE_OS_SEC_TEXT_MINOR UINT64 LOS_TickCountGet(VOID)
{
return OsGetCurrSchedTimeCycle() / OS_CYCLE_PER_TICK;
return OsGerCurrSchedTimeCycle() / OS_CYCLE_PER_TICK;
}
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_CyclePerTickGet(VOID)
@@ -59,11 +59,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_Tick2MS(UINT32 tick)
return ((UINT64)tick * OS_SYS_MS_PER_SECOND) / LOSCFG_BASE_CORE_TICK_PER_SECOND;
}
LITE_OS_SEC_TEXT_MINOR UINT32 OsNS2Tick(UINT64 nanoseconds)
LITE_OS_SEC_TEXT_MINOR UINT32 OsUS2Tick(UINT64 microsec)
{
const UINT32 nsPerTick = OS_SYS_NS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND;
const UINT32 usPerTick = OS_SYS_US_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND;
UINT64 ticks = (nanoseconds + nsPerTick - 1) / nsPerTick;
UINT64 ticks = (microsec + usPerTick - 1) / usPerTick;
if (ticks > OS_MAX_VALUE) {
ticks = OS_MAX_VALUE;
}

View File

@@ -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_taskRecycleList;
LITE_OS_SEC_BSS LOS_DL_LIST g_taskRecyleList;
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;
@@ -201,7 +201,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
(VOID)memset_s(g_taskCBArray, size, 0, size);
LOS_ListInit(&g_losFreeTask);
LOS_ListInit(&g_taskRecycleList);
LOS_ListInit(&g_taskRecyleList);
for (index = 0; index < g_taskMaxNum; index++) {
g_taskCBArray[index].taskStatus = OS_TASK_STATUS_UNUSED;
g_taskCBArray[index].taskID = index;
@@ -450,8 +450,8 @@ LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
UINT32 intSave;
SCHEDULER_LOCK(intSave);
while (!LOS_ListEmpty(&g_taskRecycleList)) {
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecycleList));
while (!LOS_ListEmpty(&g_taskRecyleList)) {
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecyleList));
LOS_ListDelete(&taskCB->pendList);
SCHEDULER_UNLOCK(intSave);
@@ -599,9 +599,6 @@ LITE_OS_SEC_TEXT LosTaskCB *OsGetFreeTaskCB(VOID)
if (LOS_ListEmpty(&g_losFreeTask)) {
SCHEDULER_UNLOCK(intSave);
PRINT_ERR("No idle TCB in the system!\n");
#ifdef LOSCFG_DEBUG_VERSION
(VOID)OsShellCmdTskInfoGet(OS_ALL_TASK_MASK, NULL, OS_PROCESS_INFO_ALL);
#endif
return NULL;
}
@@ -891,7 +888,7 @@ LITE_OS_SEC_TEXT VOID OsRunTaskToDelete(LosTaskCB *runTask)
LOS_ListDelete(&runTask->threadList);
processCB->threadNumber--;
LOS_ListTailInsert(&g_taskRecycleList, &runTask->pendList);
LOS_ListTailInsert(&g_taskRecyleList, &runTask->pendList);
OsEventWriteUnsafe(&g_resourceEvent, OS_RESOURCE_EVENT_FREE, FALSE, NULL);
OsSchedResched();
@@ -965,7 +962,7 @@ STATIC VOID OsTaskDeleteInactive(LosProcessCB *processCB, LosTaskCB *taskCB)
LOS_ListDelete(&taskCB->threadList);
processCB->threadNumber--;
LOS_ListTailInsert(&g_taskRecycleList, &taskCB->pendList);
LOS_ListTailInsert(&g_taskRecyleList, &taskCB->pendList);
return;
}
@@ -1653,7 +1650,7 @@ STATIC VOID OsResourceRecoveryTask(VOID)
if (ret & (OS_RESOURCE_EVENT_FREE | OS_RESOURCE_EVENT_OOM)) {
OsTaskCBRecycleToFree();
OsProcessCBRecycleToFree();
OsProcessCBRecyleToFree();
}
#ifdef LOSCFG_ENABLE_OOM_LOOP_TASK

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