Compare commits
43 Commits
OpenHarmon
...
OpenHarmon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80e24fa9db | ||
|
|
15bded54c9 | ||
|
|
2a0db42072 | ||
|
|
de82bf893a | ||
|
|
a0bb06189d | ||
|
|
a8513ae614 | ||
|
|
0c203c1e57 | ||
|
|
93658ba478 | ||
|
|
58aea01f5a | ||
|
|
d39ed70c65 | ||
|
|
3e6bab5158 | ||
|
|
672cff7ee5 | ||
|
|
3ad07bc40f | ||
|
|
1e8d5baf8c | ||
|
|
b744cfa164 | ||
|
|
51a24eaeb2 | ||
|
|
07fb6c150e | ||
|
|
7ceaf68832 | ||
|
|
309e7569f8 | ||
|
|
e42cb26b14 | ||
|
|
8ab4c9a6bc | ||
|
|
a40dc411b2 | ||
|
|
ebe33aa2f6 | ||
|
|
ece0e8ae06 | ||
|
|
c059be5ec8 | ||
|
|
723b3ff8e2 | ||
|
|
7cf342c29f | ||
|
|
3b9ccc839e | ||
|
|
4f1e1619a5 | ||
|
|
6523c496c8 | ||
|
|
7648648887 | ||
|
|
1c0bbb66de | ||
|
|
d44f3904cf | ||
|
|
5cbb83dc6e | ||
|
|
13fa3d4403 | ||
|
|
e9522d44bf | ||
|
|
f30790c5c8 | ||
|
|
a0bb801f67 | ||
|
|
170aa8ba6f | ||
|
|
83b0e8f867 | ||
|
|
6b5d6be42d | ||
|
|
8b27064848 | ||
|
|
1ad74ab8e4 |
@@ -1,6 +1,6 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
|
||||
36
.gitignore
vendored
36
.gitignore
vendored
@@ -1,25 +1,23 @@
|
||||
# General ignored file types
|
||||
/out
|
||||
/test
|
||||
/include
|
||||
.config*
|
||||
cscope*
|
||||
tags
|
||||
.vscode
|
||||
*.o
|
||||
.idea
|
||||
*.img
|
||||
*.swp
|
||||
*.rej
|
||||
*.orig
|
||||
*.a
|
||||
*.so
|
||||
*.swp
|
||||
|
||||
# IDE settings
|
||||
.vscode
|
||||
.idea
|
||||
.config.cmd
|
||||
.settings
|
||||
.cproject
|
||||
.project
|
||||
|
||||
# VIM files
|
||||
cscope*
|
||||
tags
|
||||
|
||||
# Menuconfig temp files
|
||||
/config.h
|
||||
.config
|
||||
.config.old
|
||||
|
||||
# Build temp files
|
||||
/platform/board.ld
|
||||
/out
|
||||
platform/include/menuconfig.h
|
||||
platform/board.ld
|
||||
apps/init/init
|
||||
apps/shell/shell
|
||||
|
||||
12
BUILD.gn
Normal file → Executable file
12
BUILD.gn
Normal file → Executable file
@@ -67,16 +67,16 @@ lite_subsystem("kernel") {
|
||||
}
|
||||
} else {
|
||||
deps = [ ":make" ]
|
||||
deps += [ "//kernel/liteos_a/testsuites/unittest:unittest" ]
|
||||
}
|
||||
}
|
||||
|
||||
build_ext_component("make") {
|
||||
exec_path = rebase_path(".", root_build_dir)
|
||||
tee_enable = "false"
|
||||
if (board_name == "hi3516dv300" && enable_tee_ree) {
|
||||
tee_enable = "tee"
|
||||
}
|
||||
prebuilts = "sh build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\""
|
||||
outdir = rebase_path(get_path_info(".", "out_dir"))
|
||||
sysroot_path = rebase_path(ohos_current_sysroot)
|
||||
arch_cflags = string_join(" ", target_arch_cflags)
|
||||
command = "./build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} \"${tee_enable}\""
|
||||
command += " \"${device_company}\" \"${product_path}\" $outdir \"${ohos_version}\" ${sysroot_path} \"${arch_cflags}\""
|
||||
command += " \"${device_path}\""
|
||||
command = "make clean OUTDIR=$outdir && make rootfs VERSION=\"${ohos_version}\" -j 16 OUTDIR=$outdir"
|
||||
}
|
||||
|
||||
105
Kconfig
Normal file → Executable file
105
Kconfig
Normal file → Executable file
@@ -42,9 +42,11 @@ choice
|
||||
|
||||
config COMPILER_HIMIX_32
|
||||
bool "arm-linux-ohoseabi"
|
||||
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7
|
||||
|
||||
config COMPILER_CLANG_LLVM
|
||||
bool "clang-llvm"
|
||||
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7
|
||||
|
||||
endchoice
|
||||
endmenu
|
||||
@@ -52,19 +54,15 @@ endmenu
|
||||
menu "Platform"
|
||||
|
||||
######################### config options of bsp #####################
|
||||
source "platform/Kconfig"
|
||||
source "../../kernel/liteos_a/platform/Kconfig"
|
||||
|
||||
######################### config options of cpu arch ################
|
||||
source "arch/Kconfig"
|
||||
source "../../kernel/liteos_a/arch/Kconfig"
|
||||
|
||||
######################### config options of rootfs #####################
|
||||
source "kernel/common/Kconfig"
|
||||
source "../../kernel/liteos_a/kernel/common/Kconfig"
|
||||
######################### config options of patchfs #####################
|
||||
source "kernel/common/patchfs/Kconfig"
|
||||
######################### config options of blackbox #####################
|
||||
source "kernel/common/blackbox/Kconfig"
|
||||
######################### config options of hidumper #####################
|
||||
source "kernel/common/hidumper/Kconfig"
|
||||
source "../../kernel/liteos_a/kernel/common/patchfs/Kconfig"
|
||||
|
||||
config QUICK_START
|
||||
bool "Enable QUICK_START"
|
||||
@@ -75,50 +73,36 @@ config QUICK_START
|
||||
endmenu
|
||||
|
||||
######################### config options of kernel #####################
|
||||
source "kernel/Kconfig"
|
||||
source "../../kernel/liteos_a/kernel/Kconfig"
|
||||
######################### config options of lib ########################
|
||||
source "lib/Kconfig"
|
||||
source "../../kernel/liteos_a/lib/Kconfig"
|
||||
######################### config options of compatibility ##############
|
||||
menu "Compat"
|
||||
source "compat/posix/Kconfig"
|
||||
source "bsd/Kconfig"
|
||||
source "../../kernel/liteos_a/compat/posix/Kconfig"
|
||||
source "../../kernel/liteos_a/bsd/Kconfig"
|
||||
endmenu
|
||||
|
||||
######################### config options of framework ##################
|
||||
#source "../../frameworks/m2mcomm/Kconfig"
|
||||
|
||||
######################## config options of filesystem ##################
|
||||
menu "FileSystem"
|
||||
source "fs/vfs/Kconfig"
|
||||
source "fs/fat/Kconfig"
|
||||
source "fs/ramfs/Kconfig"
|
||||
source "fs/romfs/Kconfig"
|
||||
source "fs/nfs/Kconfig"
|
||||
source "fs/proc/Kconfig"
|
||||
source "fs/jffs2/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/vfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/fat/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/ramfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/nfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/proc/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/jffs2/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/zpfs/Kconfig"
|
||||
config ENABLE_READ_BUFFER
|
||||
bool "Enable read buffer Option"
|
||||
default n
|
||||
depends on FS_VFS
|
||||
help
|
||||
Answer Y to add enable read buffer Option.
|
||||
|
||||
config MAX_VNODE_SIZE
|
||||
int "Vnode max number"
|
||||
range 0 512
|
||||
default 512
|
||||
depends on FS_VFS
|
||||
help
|
||||
vnode number, range from 0 to 512.
|
||||
|
||||
config MAX_PATH_CACHE_SIZE
|
||||
int "PathCache max number"
|
||||
range 0 1024
|
||||
default 512
|
||||
depends on FS_VFS
|
||||
help
|
||||
pathCache number, range from 0 to 1024.
|
||||
endmenu
|
||||
|
||||
######################## config options of net ############################
|
||||
source "net/Kconfig"
|
||||
source "../../kernel/liteos_a/net/Kconfig"
|
||||
|
||||
######################## config options of debug ########################
|
||||
menu "Debug"
|
||||
@@ -137,7 +121,6 @@ config PLATFORM_ADAPT
|
||||
config ENABLE_OOM_LOOP_TASK
|
||||
bool "Enable Oom loop task"
|
||||
default n
|
||||
depends on KERNEL_VM
|
||||
help
|
||||
Answer Y to enable oom loop kthread to check system out of memory.
|
||||
|
||||
@@ -165,7 +148,6 @@ config THUMB
|
||||
default n
|
||||
help
|
||||
Answer Y to build thumb version. This will make LiteOS smaller.
|
||||
|
||||
config PLATFORM_DVFS
|
||||
bool "Enable Dvfs"
|
||||
default n
|
||||
@@ -174,12 +156,6 @@ config PLATFORM_DVFS
|
||||
Answer Y to enable LiteOS support dynamic voltage and frequency scaling feature for
|
||||
low power consumption.
|
||||
|
||||
config SAVE_EXCINFO
|
||||
bool "Enable Saving Exception Information"
|
||||
default n
|
||||
help
|
||||
Answer Y to enable LiteOS support saving exception information to storage medium.
|
||||
|
||||
config DEBUG_VERSION
|
||||
bool "Enable a Debug Version"
|
||||
default n
|
||||
@@ -220,14 +196,22 @@ config DEBUG_SEMAPHORE
|
||||
help
|
||||
Answer Y to enable debug semaphore.
|
||||
|
||||
source "shell/Kconfig"
|
||||
source "../../kernel/liteos_a/shell/Kconfig"
|
||||
config NET_LWIP_SACK_TFTP
|
||||
bool "Enable Tftp"
|
||||
default y
|
||||
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
|
||||
help
|
||||
Answer Y to enable LiteOS support tftp cmd and tftp tool.
|
||||
source "net/telnet/Kconfig"
|
||||
source "../../kernel/liteos_a/net/telnet/Kconfig"
|
||||
config EXC_INTERACTION
|
||||
bool "Enable exc interaction"
|
||||
default n
|
||||
depends on SHELL
|
||||
help
|
||||
Answer Y to enable exception interaction for LiteOS, when the system enter exception, user can also interact with system by shell
|
||||
command like readreg, writereg,task,hwi.
|
||||
|
||||
config SCHED_DEBUG
|
||||
bool "Enable sched debug Feature"
|
||||
default n
|
||||
@@ -266,7 +250,7 @@ config MEM_LEAKCHECK
|
||||
help
|
||||
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
|
||||
config BASE_MEM_NODE_INTEGRITY_CHECK
|
||||
bool "Enable integrity check or not"
|
||||
bool "Enable integrity check or not "
|
||||
default n
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
config MEM_WATERLINE
|
||||
@@ -281,6 +265,13 @@ config VM_OVERLAP_CHECK
|
||||
help
|
||||
Answer Y to enable vm overlap check.
|
||||
|
||||
config NULL_ADDRESS_PROTECT
|
||||
bool "Enable NULL Address protect"
|
||||
default n
|
||||
depends on (PLATFORM_HI3518EV200 || PLATFORM_HI3516CV300 || PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7) && DEBUG_VERSION
|
||||
help
|
||||
Answer Y to set mem address 0~1M prohibit to access, read or write will trigger exception.
|
||||
|
||||
endmenu
|
||||
|
||||
######################## config options os drivers ########################
|
||||
@@ -291,31 +282,19 @@ config DRIVERS
|
||||
help
|
||||
Answer Y to enable LiteOS support driver.
|
||||
|
||||
source "bsd/dev/usb/Kconfig"
|
||||
source "../../kernel/liteos_a/bsd/dev/usb/Kconfig"
|
||||
source "../../drivers/adapter/khdf/liteos/Kconfig"
|
||||
|
||||
# Device driver Kconfig import
|
||||
osource "$(DEVICE_PATH)/Kconfig"
|
||||
osource "$(DEVICE_PATH)/config/Kconfig"
|
||||
|
||||
source "drivers/char/mem/Kconfig"
|
||||
source "drivers/char/quickstart/Kconfig"
|
||||
source "drivers/char/random/Kconfig"
|
||||
source "drivers/char/video/Kconfig"
|
||||
|
||||
source "../../drivers/liteos/tzdriver/Kconfig"
|
||||
source "drivers/char/video/Kconfig"
|
||||
source "../../drivers/liteos/hievent/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Security"
|
||||
source "security/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "Test"
|
||||
config ENABLE_KERNEL_TEST
|
||||
bool "Enable Kernel Test"
|
||||
default n
|
||||
source "../../kernel/liteos_a/security/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "Stack Smashing Protector (SSP) Compiler Feature"
|
||||
|
||||
87
Makefile
Normal file → Executable file
87
Makefile
Normal file → Executable file
@@ -47,17 +47,23 @@ ROOTFS = rootfs
|
||||
|
||||
LITEOS_TARGET = liteos
|
||||
LITEOS_LIBS_TARGET = libs_target
|
||||
LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h
|
||||
LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform
|
||||
LITEOS_PLATFORM_MENUCONFIG_H = $(LITEOS_PLATFORM_BASE)/include/menuconfig.h
|
||||
|
||||
export CONFIG_=LOSCFG_
|
||||
ifeq ($(PRODUCT_PATH),)
|
||||
export PRODUCT_PATH=$(LITEOSTOPDIR)/../../device/hisilicon/drivers
|
||||
MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
|
||||
KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
|
||||
|
||||
ifeq ($(OS), Linux)
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/mconf
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/conf
|
||||
else
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/kconfig-mconf.exe
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/kconfig-conf.exe
|
||||
endif
|
||||
|
||||
ifeq ($(shell which menuconfig),)
|
||||
$(shell pip install --user kconfiglib >/dev/null)
|
||||
endif
|
||||
$(shell env CONFIG_=$(CONFIG_) PRODUCT_PATH=$(PRODUCT_PATH) olddefconfig >/dev/null)
|
||||
$(shell env CONFIG_=$(CONFIG_) $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH))
|
||||
|
||||
-include $(LITEOSTOPDIR)/tools/build/config.mk
|
||||
|
||||
@@ -77,9 +83,6 @@ ROOTFS_DIR = $(OUT)/rootfs
|
||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||
VERSION =
|
||||
|
||||
SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot
|
||||
export SYSROOT_PATH
|
||||
|
||||
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
|
||||
lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
|
||||
|
||||
@@ -111,15 +114,6 @@ else
|
||||
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh
|
||||
endif
|
||||
|
||||
##### make sysroot #####
|
||||
sysroot:
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
ifeq ($(wildcard $(SYSROOT_PATH)/usr/include/$(LLVM_TARGET)/),)
|
||||
$(HIDE)$(MAKE) -C $(SYSROOT_PATH)/build TARGETS=liteos_a_user
|
||||
endif
|
||||
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
|
||||
endif
|
||||
|
||||
##### make dynload #####
|
||||
-include $(LITEOS_MK_PATH)/dynload.mk
|
||||
|
||||
@@ -130,27 +124,34 @@ $(__LIBS): $(OUT) $(CXX_INCLUDE)
|
||||
$(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 \
|
||||
-I$(LITEOS_PLATFORM_BASE)/include -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
|
||||
-o $(LITEOS_PLATFORM_BASE)/board.ld -P
|
||||
|
||||
$(BUILD):
|
||||
$(HIDE)mkdir -p $(BUILD)
|
||||
|
||||
$(LITEOS_LIBS_TARGET): $(__LIBS) sysroot
|
||||
$(LITEOS_LIBS_TARGET): $(__LIBS)
|
||||
$(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:$(MENUCONFIG_MCONF)
|
||||
$< $(KCONFIG_FILE_PATH)
|
||||
|
||||
genconfig:$(MENUCONFIG_CONF)
|
||||
$(HIDE)mkdir -p include/config include/generated
|
||||
$< --olddefconfig $(KCONFIG_FILE_PATH)
|
||||
$< --silentoldconfig $(KCONFIG_FILE_PATH)
|
||||
-mv -f $(LITEOS_MENUCONFIG_H) $(LITEOS_PLATFORM_MENUCONFIG_H)
|
||||
##### menuconfig end #######
|
||||
|
||||
$(LITEOS_MENUCONFIG_H): .config
|
||||
$(HIDE)genconfig
|
||||
|
||||
$(LITEOS_TARGET): $(__LIBS) sysroot
|
||||
$(LITEOS_MENUCONFIG_H):
|
||||
ifneq ($(LITEOS_PLATFORM_MENUCONFIG_H), $(wildcard $(LITEOS_PLATFORM_MENUCONFIG_H)))
|
||||
$(HIDE)$(MAKE) genconfig
|
||||
endif
|
||||
$(LITEOS_TARGET): $(__LIBS)
|
||||
$(HIDE)touch $(LOSCFG_ENTRY_SRC)
|
||||
|
||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
|
||||
@@ -164,14 +165,14 @@ $(LITEOS_TARGET): $(__LIBS) sysroot
|
||||
$(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
|
||||
# $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
|
||||
|
||||
$(APPS): $(LITEOS_TARGET) sysroot
|
||||
$(APPS): $(LITEOS_TARGET)
|
||||
$(HIDE)$(MAKE) -C apps all
|
||||
|
||||
prepare:
|
||||
$(HIDE)mkdir -p $(OUT)/musl
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
$(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
|
||||
$(HIDE)cp -f $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/usr/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4/libc.so $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/a7_softfp_neon-vfpv4/libc++.so $(OUT)/musl
|
||||
else
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
|
||||
@@ -181,14 +182,18 @@ endif
|
||||
|
||||
$(ROOTFSDIR): prepare $(APPS)
|
||||
$(HIDE)$(MAKE) clean -C apps
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR)
|
||||
ifneq ($(VERSION),)
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
|
||||
endif
|
||||
|
||||
$(ROOTFS): $(ROOTFSDIR)
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
|
||||
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
|
||||
ifneq ($(OUT), $(LITEOS_TARGET_DIR))
|
||||
rm -rf $(LITEOS_TARGET_DIR)rootfs
|
||||
$(HIDE)mv $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)rootfs
|
||||
endif
|
||||
|
||||
clean:
|
||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
|
||||
@@ -196,13 +201,16 @@ clean:
|
||||
done
|
||||
$(HIDE)$(MAKE) -C apps clean
|
||||
$(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
|
||||
$(HIDE)$(RM) include/config include/generated
|
||||
$(HIDE)$(RM) $(LITEOS_PLATFORM_MENUCONFIG_H)
|
||||
$(HIDE)$(RM) include
|
||||
$(HIDE)$(MAKE) cleanrootfs
|
||||
$(HIDE)echo "clean $(LITEOS_PLATFORM) finish"
|
||||
|
||||
cleanall: clean
|
||||
$(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_PLATFORM_BASE)/board.ld
|
||||
$(HIDE)echo "clean all done"
|
||||
cleanall:
|
||||
$(HIDE)$(RM) $(LITEOSTOPDIR)/out
|
||||
$(HIDE)find $(LITEOS_PLATFORM_BASE)/ -name board.ld -exec rm -rf {} \;
|
||||
$(HIDE)cd sample/sample_osdrv;make clean;cd ../..;
|
||||
$(HIDE)echo "clean all"
|
||||
|
||||
cleanrootfs:
|
||||
$(HIDE)$(RM) $(OUT)/rootfs
|
||||
@@ -213,11 +221,10 @@ 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; \
|
||||
test -f $$f && cp $$f .config && $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig $$f $(KCONFIG_FILE_PATH); \
|
||||
done
|
||||
|
||||
update_config:
|
||||
$(HIDE)test -f "$(CONFIG)" && cp "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)"
|
||||
%.config:
|
||||
$(HIDE)test -f tools/build/config/$@ && cp tools/build/config/$@ .config && $(MENUCONFIG_MCONF) $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig tools/build/config/$@ $(KCONFIG_FILE_PATH)
|
||||
|
||||
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config update_config
|
||||
.PHONY: prepare sysroot cleanrootfs $(ROOTFS) $(ROOTFSDIR) $(APPS) menuconfig $(LITEOS_LIBS_TARGET) $(__LIBS) $(OUT)
|
||||
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
# LiteOS-A內核<a name="ZH-CN_TOPIC_0000001096612501"></a>
|
||||
|
||||
- [簡介](#section11660541593)
|
||||
- [目錄](#section161941989596)
|
||||
- [約束](#section119744591305)
|
||||
- [使用說明](#section741617511812)
|
||||
- [準備](#section1579912573329)
|
||||
- [獲取源碼](#section11443189655)
|
||||
- [編譯構建](#section2081013992812)
|
||||
|
||||
- [相關倉](#section1371113476307)
|
||||
|
||||
## 簡介<a name="section11660541593"></a>
|
||||
|
||||
OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代內核,Huawei LiteOS是面向IoT領域構建的輕量級物聯網操作系統。在IoT產業高速發展的潮流中,OpenHarmony LiteOS-A內核能夠帶給用戶小體積、低功耗、高性能的體驗以及統一開放的生態系統能力,新增了豐富的內核機制、更加全面的POSIX標準接口以及統一驅動框架**HDF**(OpenHarmony Driver Foundation)等,為設備廠商提供了更統一的接入方式,為OpenHarmony的應用開發者提供了更友好的開發體驗。圖1為OpenHarmony LiteOS-A內核架構圖:
|
||||
|
||||
**圖 1** OpenHarmony LiteOS-A內核架構圖<a name="fig27311582210"></a>
|
||||
|
||||

|
||||
|
||||
## 目錄<a name="section161941989596"></a>
|
||||
|
||||
```
|
||||
/kernel/liteos_a
|
||||
├── apps # 用戶態的init和shell應用程序
|
||||
├── arch # 體系架構的目錄,如arm等
|
||||
│ └── arm # arm架構代碼
|
||||
├── bsd # freebsd相關的驅動和適配層模塊代碼引入,例如USB等
|
||||
├── compat # 內核接口兼容性目錄
|
||||
│ └── posix # posix相關接口
|
||||
├── drivers # 內核驅動
|
||||
│ └── char # 字符設備
|
||||
│ ├── mem # 訪問物理IO設備驅動
|
||||
│ ├── quickstart # 系統快速啟動接口目錄
|
||||
│ ├── random # 隨機數設備驅動
|
||||
│ └── video # framebuffer驅動框架
|
||||
├── fs # 文件系統模塊,主要來源於NuttX開源項目
|
||||
│ ├── fat # fat文件系統
|
||||
│ ├── jffs2 # jffs2文件系統
|
||||
│ ├── include # 對外暴露頭文件存放目錄
|
||||
│ ├── nfs # nfs文件系統
|
||||
│ ├── proc # proc文件系統
|
||||
│ ├── ramfs # ramfs文件系統
|
||||
│ └── vfs # vfs層
|
||||
├── kernel # 進程、內存、IPC等模塊
|
||||
│ ├── base # 基礎內核,包括調度、內存等模塊
|
||||
│ ├── common # 內核通用組件
|
||||
│ ├── extended # 擴展內核,包括動態加載、vdso、liteipc等模塊
|
||||
│ ├── include # 對外暴露頭文件存放目錄
|
||||
│ └── user # 加載init進程
|
||||
├── lib # 內核的lib庫
|
||||
├── net # 網絡模塊,主要來源於lwip開源項目
|
||||
├── platform # 支持不同的芯片平台代碼,如Hi3516DV300等
|
||||
│ ├── hw # 時鐘與中斷相關邏輯代碼
|
||||
│ ├── include # 對外暴露頭文件存放目錄
|
||||
│ └── uart # 串口相關邏輯代碼
|
||||
├── platform # 支持不同的芯片平台代碼,如Hi3516DV300等
|
||||
├── security # 安全特性相關的代碼,包括進程權限管理和虛擬id映射管理
|
||||
├── syscall # 系統調用
|
||||
└── tools # 構建工具及相關配置和代碼
|
||||
```
|
||||
|
||||
## 約束<a name="section119744591305"></a>
|
||||
|
||||
- 開發語言:C/C++;
|
||||
- 適用於Hi3518EV300、Hi3516DV300單板;
|
||||
- Hi3518EV300默認使用jffs2文件系統,Hi3516DV300默認使用FAT文件系統。
|
||||
|
||||
## 使用說明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openharmony/docs/blob/master/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上搭建編譯環境:
|
||||
|
||||
- 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://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/%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/%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>
|
||||
|
||||
[內核子系統](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
|
||||
|
||||
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
|
||||
|
||||
**kernel\_liteos\_a**
|
||||
@@ -73,8 +73,8 @@ OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openhar
|
||||
|
||||
开发者需要在Linux上搭建编译环境:
|
||||
|
||||
- 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)。
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E6%90%AD%E5%BB%BA%E7%8E%AF%E5%A2%83.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>
|
||||
|
||||
@@ -84,9 +84,9 @@ OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openhar
|
||||
|
||||
开发者开发第一个应用程序可参考:
|
||||
|
||||
- [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 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/%E8%BF%90%E8%A1%8CHello-OHOS.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>
|
||||
|
||||
|
||||
61
TODOList.md
61
TODOList.md
@@ -1,61 +0,0 @@
|
||||
- liteos_m易用性
|
||||
- [ ] liteos_m开发者手册
|
||||
- [ ] 低功耗框架及实现(含投票机制)
|
||||
- [ ] dump增强(配套解析工具)
|
||||
- [ ] 全内存dump(配套解析工具)
|
||||
- [ ] 实现完整L0 OHOS的qemu仿真
|
||||
- [ ] Shell + AT
|
||||
|
||||
- liteos_m能力增强
|
||||
- [ ] liteos_m支持elf动态加载
|
||||
- [ ] 基于MPU/PMP的多任务简化隔离
|
||||
- [ ] 基于MPU/PMP的多BIN隔离及灌段隔离
|
||||
- [ ] 扩展支持中断嵌套
|
||||
- [ ] 支持arm9架构
|
||||
- [ ] 支持xtensa架构
|
||||
|
||||
- 文件系统增强
|
||||
- [ ] 提供一种好用且开源的NandFlash文件系统
|
||||
- [ ] 面向fat32、jffs2持续性能优化,做到极致
|
||||
- [ ] fat32支持fast seek(现有fast seek限制文件扩展,需要改造)
|
||||
- [ ] 支持软链接
|
||||
- [ ] 头文件引用关系整理
|
||||
- [ ] 接口层去nuttx
|
||||
- [ ] 文件系统去大锁
|
||||
|
||||
- liteos_a支持三方芯片易移植性
|
||||
- [ ] 启动框架重构
|
||||
- [ ] musl库归一化
|
||||
- [ ] 去C库预编译
|
||||
- [ ] 宏配置依赖关系整理
|
||||
- [ ] 典型商用配置场景整理并导入门禁(1V1映射,去缺页,去隔离,单进程等等)
|
||||
- [ ] 编译框架整合到gn
|
||||
- [ ] 实现基于python的kconfig可视化配置
|
||||
|
||||
- liteos_a易用性
|
||||
- [ ] 实现L1 LiteOS-A及上层鸿蒙组件的qemu仿真
|
||||
- [ ] liteos_a开发者手册
|
||||
- [ ] mksh移植
|
||||
- [ ] toybox命令集
|
||||
- [ ] trace、backtrace、dump解析工具等
|
||||
- procfs适配
|
||||
- [ ] ifconfig、fd、free等
|
||||
|
||||
- liteos_a能力增强
|
||||
- [ ] 单链表整改(SMP多核性能)
|
||||
- [ ] 快启
|
||||
- [ ] 典型高频函数C库性能优化
|
||||
- [ ] rwlock
|
||||
|
||||
- liteos_a三方库移植
|
||||
- [ ] libuv、dlna、benchmark、iperf、perf、tcpdump 等等
|
||||
- C库能力补全
|
||||
- [ ] epoll实现
|
||||
|
||||
- 测试验证
|
||||
- [ ] syzkaller、difuze等
|
||||
|
||||
- 探索性课题
|
||||
- [ ] 基于rust重写liteos_m基础内核
|
||||
- [ ] 用户态驱动(对比业界并增强)
|
||||
- [ ] 用户态文件系统
|
||||
5
apps/Makefile
Normal file → Executable file
5
apps/Makefile
Normal file → Executable file
@@ -27,10 +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)/../
|
||||
|
||||
include $(LITEOSTOPDIR)/.config
|
||||
include ./config.mk
|
||||
include ../.config
|
||||
include ./module.mk
|
||||
|
||||
HIDE := @
|
||||
|
||||
8
apps/config.mk
Normal file → Executable file
8
apps/config.mk
Normal file → Executable file
@@ -44,7 +44,7 @@ CFLAGS := -std=c99 -fno-exceptions $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
CXXFLAGS := -std=c++11 -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
LDCFLAGS := -lc
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH) $(ARCH_CFLAGS)
|
||||
LLVM_SYSROOT := --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
||||
LDCXXFLGS := -lc++ -lc++abi -lc
|
||||
else
|
||||
BASE_OPTS += -Wl,-z,relro,-z,now
|
||||
@@ -55,6 +55,6 @@ COMMON_INCLUDE := -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
||||
# alias variable config
|
||||
HIDE := @
|
||||
MAKE := make
|
||||
RM := rm -rf
|
||||
CP := cp -rf
|
||||
MV := mv -f
|
||||
RM := -rm -rf
|
||||
CP := -cp -rf
|
||||
MV := -mv
|
||||
|
||||
0
apps/init/Makefile
Normal file → Executable file
0
apps/init/Makefile
Normal file → Executable file
13
apps/init/src/init.c
Normal file → Executable file
13
apps/init/src/init.c
Normal file → Executable file
@@ -49,8 +49,7 @@
|
||||
int main(int argc, char * const *argv)
|
||||
{
|
||||
int ret;
|
||||
pid_t gid;
|
||||
const char *shellPath = "/bin/mksh";
|
||||
const char *shellPath = "/bin/shell";
|
||||
|
||||
#ifdef LOSCFG_QUICK_START
|
||||
const char *samplePath = "/dev/shm/sample_quickstart";
|
||||
@@ -75,16 +74,6 @@ int main(int argc, char * const *argv)
|
||||
if (ret < 0) {
|
||||
printf("Failed to fork for shell\n");
|
||||
} else if (ret == 0) {
|
||||
gid = getpgrp();
|
||||
if (gid < 0) {
|
||||
printf("get group id failed, pgrpid %d, errno %d\n", gid, errno);
|
||||
exit(0);
|
||||
}
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
exit(0);
|
||||
}
|
||||
(void)execve(shellPath, NULL, NULL);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -1,71 +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.
|
||||
|
||||
MKSH := mksh
|
||||
|
||||
MKSH_DIR := $(shell pwd)/
|
||||
LITEOSTOPDIR = $(MKSH_DIR)/../../
|
||||
include $(MKSH_DIR)/../config.mk
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
ETC_OUT := $(OUT)/etc
|
||||
BUILD_DIR := $(MKSH_DIR)/build
|
||||
BUILD_LOG := $(MKSH_DIR)/build.log
|
||||
TARGET_OS := OpenHarmony
|
||||
|
||||
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -Oz -fstack-protector-strong -D_FORTIFY_SOURCE=2
|
||||
LOCAL_CFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
||||
LOCAL_CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
||||
LOCAL_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2 --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
||||
|
||||
all:$(MKSH)
|
||||
|
||||
$(MKSH):
|
||||
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Rebuild.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
else
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(MKSH)/. $(BUILD_DIR)
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Build.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && CC=$(CC) TARGET_OS=$(TARGET_OS) CFLAGS="$(LOCAL_CFLAGS)" LDFLAGS="$(LOCAL_LDFLAGS)" ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
endif
|
||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/$(MKSH) .
|
||||
$(HIDE)$(STRIP) $(MKSH)
|
||||
$(HIDE)mkdir -p $(APPS_OUT)
|
||||
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
|
||||
$(HIDE)mkdir -p $(ETC_OUT)
|
||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/.mkshrc $(ETC_OUT)/
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)
|
||||
|
||||
.PHONY: all $(MKSH) clean
|
||||
4
apps/module.mk
Normal file → Executable file
4
apps/module.mk
Normal file → Executable file
@@ -29,12 +29,10 @@
|
||||
|
||||
APP_SUBDIRS :=
|
||||
|
||||
##build modules config##
|
||||
##compile modules config##
|
||||
|
||||
ifeq ($(LOSCFG_SHELL), y)
|
||||
APP_SUBDIRS += shell
|
||||
APP_SUBDIRS += mksh
|
||||
APP_SUBDIRS += toybox
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
||||
|
||||
0
apps/shell/Makefile
Normal file → Executable file
0
apps/shell/Makefile
Normal file → Executable file
15
apps/shell/builtin/cd.c
Normal file → Executable file
15
apps/shell/builtin/cd.c
Normal file → Executable file
@@ -37,6 +37,11 @@
|
||||
#include "shcmd.h"
|
||||
#include "sherr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int Chdir(const char *tgtDir)
|
||||
{
|
||||
@@ -48,9 +53,17 @@ int Chdir(const char *tgtDir)
|
||||
|
||||
ret = chdir(tgtDir);
|
||||
if (ret == 0) {
|
||||
ret = OsShellSetWorkingDirtectory(tgtDir, strlen(tgtDir) + 1); /* 1: the length of '\0' */
|
||||
ret = OsShellSetWorkingDirtectory(tgtDir, strlen(tgtDir) + 1); /* 1: the length of '\0' */
|
||||
if (ret != SH_NOK) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
0
apps/shell/include/shcmd.h
Normal file → Executable file
0
apps/shell/include/shcmd.h
Normal file → Executable file
0
apps/shell/include/shell.h
Normal file → Executable file
0
apps/shell/include/shell.h
Normal file → Executable file
@@ -350,14 +350,35 @@ static inline void SH_ListHeadInsertList(SH_List *oldList, SH_List *newList)
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param type [IN] Structure name.
|
||||
* @param member [IN] Name of the member of which the offset is to be measured.
|
||||
* @param type [IN] Structure name.
|
||||
* @param field [IN] Name of the field of which the offset is to be measured.
|
||||
*
|
||||
* @retval Offset of the field to the structure address.
|
||||
* @par Dependency:
|
||||
* <ul><li>shell_list.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
*/
|
||||
#define OFFSET_OF_FIELD(type, field) ((uintptr_t)&((type *)0)->field)
|
||||
|
||||
/**
|
||||
* @ingroup shell_list
|
||||
* @brief Obtain the pointer to a doubly linked list in a structure.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to obtain the pointer to a doubly linked list in a structure.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>None.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param type [IN] Structure name.
|
||||
* @param member [IN] Member name of the doubly linked list in the structure.
|
||||
*
|
||||
* @retval Pointer to the doubly linked list in the structure.
|
||||
* @par Dependency:
|
||||
* <ul><li>shell_list.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see
|
||||
*/
|
||||
#define LOS_OFF_SET_OF(type, member) ((uintptr_t)&((type *)0)->member)
|
||||
|
||||
/**
|
||||
|
||||
0
apps/shell/include/shmsg.h
Normal file → Executable file
0
apps/shell/include/shmsg.h
Normal file → Executable file
0
apps/shell/include/show.h
Normal file → Executable file
0
apps/shell/include/show.h
Normal file → Executable file
10
apps/shell/src/main.c
Normal file → Executable file
10
apps/shell/src/main.c
Normal file → Executable file
@@ -36,6 +36,11 @@
|
||||
#include "securec.h"
|
||||
#include "unistd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
ShellCB *g_shellCB = NULL;
|
||||
|
||||
@@ -134,3 +139,8 @@ ERR_OUT1:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
21
apps/shell/src/shcmd.c
Normal file → Executable file
21
apps/shell/src/shcmd.c
Normal file → Executable file
@@ -36,6 +36,11 @@
|
||||
#include "dirent.h"
|
||||
#include "securec.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
|
||||
#define CTRL_C 0x03 /* 0x03: ctrl+c ASCII */
|
||||
@@ -80,7 +85,7 @@ static int OsStrSeparateTabStrGet(const char **tabStr, CmdParsed *parsed, unsign
|
||||
if ((strlen(shiftStr) == 0) || (tempStr[strlen(tempStr) - 1] != shiftStr[strlen(shiftStr) - 1])) {
|
||||
*tabStr = "";
|
||||
} else {
|
||||
if (OsCmdParse(shiftStr, parsed)) {
|
||||
if (OsCmdTokenSplit(shiftStr, ' ', parsed)) {
|
||||
free(tempStr);
|
||||
return (int)SH_ERROR;
|
||||
}
|
||||
@@ -196,7 +201,7 @@ static int OsSurePrintAll(unsigned int count)
|
||||
char readChar = 0;
|
||||
printf("\nDisplay all %u possibilities?(y/n)", count);
|
||||
while (1) {
|
||||
if (read(STDIN_FILENO, &readChar, 1) != 1) {
|
||||
if (read(0, &readChar, 1) != 1) {
|
||||
return (int)SH_ERROR;
|
||||
}
|
||||
if ((readChar == 'n') || (readChar == 'N') || (readChar == CTRL_C)) {
|
||||
@@ -448,15 +453,20 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
|
||||
free(outputBak);
|
||||
return SH_OK;
|
||||
}
|
||||
|
||||
int OsTabCompletion(char *cmdKey, unsigned int *len)
|
||||
{
|
||||
int count;
|
||||
char *cmdMainStr = cmdKey;
|
||||
|
||||
if ((cmdKey == NULL) || (len == NULL)) {
|
||||
return (int)SH_ERROR;
|
||||
}
|
||||
|
||||
/* cut left space */
|
||||
while (*cmdMainStr == 0x20) {
|
||||
cmdMainStr++;
|
||||
}
|
||||
|
||||
count = OsTabMatchFile(cmdKey, len);
|
||||
|
||||
return count;
|
||||
@@ -594,3 +604,8 @@ unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
10
apps/shell/src/shcmdparse.c
Normal file → Executable file
10
apps/shell/src/shcmdparse.c
Normal file → Executable file
@@ -32,6 +32,11 @@
|
||||
#include "shcmd.h"
|
||||
#include "sherr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Filter out double quote or single-quoted strings at both ends
|
||||
@@ -152,3 +157,8 @@ unsigned int OsCmdParse(char *cmdStr, CmdParsed *cmdParsed)
|
||||
return OsCmdTokenSplit(cmdStr, ' ', cmdParsed);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
23
apps/shell/src/shmsg.c
Normal file → Executable file
23
apps/shell/src/shmsg.c
Normal file → Executable file
@@ -42,6 +42,11 @@
|
||||
#include "shell_pri.h"
|
||||
#include "shcmd.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
char *GetCmdline(ShellCB *shellCB)
|
||||
@@ -333,7 +338,6 @@ static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len
|
||||
{
|
||||
int ret;
|
||||
pid_t forkPid;
|
||||
pid_t gid;
|
||||
|
||||
if (strncmp(cmdline, SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
|
||||
forkPid = fork();
|
||||
@@ -346,16 +350,6 @@ static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len
|
||||
exit(1);
|
||||
}
|
||||
|
||||
gid = getpgrp();
|
||||
if (gid < 0) {
|
||||
printf("get group id failed, pgrpid %d, errno %d\n", gid, errno);
|
||||
}
|
||||
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
}
|
||||
|
||||
ret = execve((const char *)cmdParsed->paramArray[0], (char * const *)cmdParsed->paramArray, NULL);
|
||||
if (ret == -1) {
|
||||
perror("execve");
|
||||
@@ -583,7 +577,7 @@ int ShellTaskInit(ShellCB *shellCB)
|
||||
|
||||
static int ShellKernelReg(unsigned int shellHandle)
|
||||
{
|
||||
return ioctl(STDIN_FILENO, CONSOLE_CONTROL_REG_USERTASK, shellHandle);
|
||||
return ioctl(0, CONSOLE_CONTROL_REG_USERTASK, shellHandle);
|
||||
}
|
||||
|
||||
void *ShellEntry(void *argv)
|
||||
@@ -646,3 +640,8 @@ int ShellEntryInit(ShellCB *shellCB)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,60 +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.
|
||||
|
||||
TOYBOX:= toybox
|
||||
|
||||
TOYBOX_DIR := $(shell pwd)
|
||||
LITEOSTOPDIR = $(TOYBOX_DIR)/../../
|
||||
include $(TOYBOX_DIR)/../config.mk
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
BUILD_DIR := $(TOYBOX_DIR)/build
|
||||
BUILD_LOG := $(TOYBOX_DIR)/build.log
|
||||
OUTNAME := $(TOYBOX)
|
||||
|
||||
$(TOYBOX):
|
||||
ifneq ($(wildcard $(BUILD_DIR)),)
|
||||
$(HIDE)echo "not clean, rebuilding now";
|
||||
else
|
||||
$(HIDE)mkdir $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
|
||||
endif
|
||||
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=$(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)
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG)
|
||||
|
||||
.PHONY: all $(TOYBOX) clean
|
||||
@@ -1,181 +0,0 @@
|
||||
CONFIG_GETTY=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_MDEV_CONF=y
|
||||
# CONFIG_CAL is not set
|
||||
# CONFIG_CATV is not set
|
||||
# CONFIG_CKSUM is not set
|
||||
# CONFIG_CRC32 is not set
|
||||
# CONFIG_CMP is not set
|
||||
# CONFIG_COMM is not set
|
||||
# CONFIG_CP_PRESERVE is not set
|
||||
# CONFIG_INSTALL is not set
|
||||
# CONFIG_CPIO is not set
|
||||
# CONFIG_CUT is not set
|
||||
# CONFIG_DF is not set
|
||||
# CONFIG_DIRNAME is not set
|
||||
# CONFIG_ENV is not set
|
||||
# CONFIG_EXPAND is not set
|
||||
# CONFIG_FALSE is not set
|
||||
# CONFIG_FILE is not set
|
||||
# CONFIG_FIND is not set
|
||||
# CONFIG_GETCONF is not set
|
||||
# CONFIG_GREP is not set
|
||||
# CONFIG_EGREP is not set
|
||||
# CONFIG_FGREP is not set
|
||||
# CONFIG_HEAD is not set
|
||||
# CONFIG_ICONV is not set
|
||||
# CONFIG_ID is not set
|
||||
# CONFIG_GROUPS is not set
|
||||
# CONFIG_LOGNAME is not set
|
||||
# CONFIG_WHOAMI is not set
|
||||
# CONFIG_LINK is not set
|
||||
# CONFIG_LN is not set
|
||||
# CONFIG_LOGGER is not set
|
||||
# CONFIG_MKFIFO is not set
|
||||
# CONFIG_NICE is not set
|
||||
# CONFIG_NL is not set
|
||||
# CONFIG_NOHUP is not set
|
||||
# CONFIG_OD is not set
|
||||
# CONFIG_PASTE is not set
|
||||
# CONFIG_PATCH is not set
|
||||
# CONFIG_PRINTF is not set
|
||||
# CONFIG_IOTOP is not set
|
||||
# CONFIG_PGREP is not set
|
||||
# CONFIG_PKILL is not set
|
||||
# CONFIG_PWD is not set
|
||||
# CONFIG_RENICE is not set
|
||||
# CONFIG_SED is not set
|
||||
# CONFIG_SLEEP is not set
|
||||
# CONFIG_SORT is not set
|
||||
# CONFIG_SORT_FLOAT is not set
|
||||
# CONFIG_SPLIT is not set
|
||||
# CONFIG_STRINGS is not set
|
||||
# CONFIG_TAIL is not set
|
||||
# CONFIG_TAR is not set
|
||||
# CONFIG_TEE is not set
|
||||
# CONFIG_TEST is not set
|
||||
# CONFIG_TIME is not set
|
||||
# CONFIG_TRUE is not set
|
||||
# CONFIG_TTY is not set
|
||||
# CONFIG_ULIMIT is not set
|
||||
# CONFIG_ARCH is not set
|
||||
# CONFIG_UNIQ is not set
|
||||
# CONFIG_UNLINK is not set
|
||||
# CONFIG_UUDECODE is not set
|
||||
# CONFIG_UUENCODE is not set
|
||||
# CONFIG_WC is not set
|
||||
# CONFIG_WHO is not set
|
||||
# CONFIG_XARGS is not set
|
||||
# CONFIG_ACPI is not set
|
||||
# CONFIG_ASCII is not set
|
||||
# CONFIG_BASE64 is not set
|
||||
# CONFIG_BLKID is not set
|
||||
# CONFIG_FSTYPE is not set
|
||||
# CONFIG_BLOCKDEV is not set
|
||||
# CONFIG_BUNZIP2 is not set
|
||||
# CONFIG_BZCAT is not set
|
||||
# CONFIG_CHROOT is not set
|
||||
# CONFIG_CHRT is not set
|
||||
# CONFIG_CHVT is not set
|
||||
# CONFIG_CLEAR is not set
|
||||
# CONFIG_COUNT is not set
|
||||
# CONFIG_DEVMEM is not set
|
||||
# CONFIG_DOS2UNIX is not set
|
||||
# CONFIG_UNIX2DOS is not set
|
||||
# CONFIG_EJECT is not set
|
||||
# CONFIG_FACTOR is not set
|
||||
# CONFIG_FALLOCATE is not set
|
||||
# CONFIG_FLOCK is not set
|
||||
# CONFIG_FMT is not set
|
||||
# CONFIG_FREERAMDISK is not set
|
||||
# CONFIG_FSFREEZE is not set
|
||||
# CONFIG_FSYNC is not set
|
||||
# CONFIG_HELP_EXTRAS is not set
|
||||
# CONFIG_HEXEDIT is not set
|
||||
# CONFIG_HWCLOCK is not set
|
||||
# CONFIG_I2CDETECT is not set
|
||||
# CONFIG_I2CDUMP is not set
|
||||
# CONFIG_I2CGET is not set
|
||||
# CONFIG_I2CSET is not set
|
||||
# CONFIG_INOTIFYD is not set
|
||||
# CONFIG_INSMOD is not set
|
||||
# CONFIG_IONICE is not set
|
||||
# CONFIG_IORENICE is not set
|
||||
# CONFIG_LOGIN is not set
|
||||
# CONFIG_LOSETUP is not set
|
||||
# CONFIG_LSATTR is not set
|
||||
# CONFIG_CHATTR is not set
|
||||
# CONFIG_LSMOD is not set
|
||||
# CONFIG_LSPCI is not set
|
||||
# CONFIG_LSPCI_TEXT is not set
|
||||
# CONFIG_LSUSB is not set
|
||||
# CONFIG_MAKEDEVS is not set
|
||||
# CONFIG_MCOOKIE is not set
|
||||
# CONFIG_MIX is not set
|
||||
# CONFIG_MKPASSWD is not set
|
||||
# CONFIG_MKSWAP is not set
|
||||
# CONFIG_MODINFO is not set
|
||||
# CONFIG_MOUNTPOINT is not set
|
||||
# CONFIG_NBD_CLIENT is not set
|
||||
# CONFIG_UNSHARE is not set
|
||||
# CONFIG_NSENTER is not set
|
||||
# CONFIG_ONEIT is not set
|
||||
# CONFIG_PARTPROBE is not set
|
||||
# CONFIG_PIVOT_ROOT is not set
|
||||
# CONFIG_PMAP is not set
|
||||
# CONFIG_PRINTENV is not set
|
||||
# CONFIG_PWDX is not set
|
||||
# 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
|
||||
# CONFIG_SETFATTR is not set
|
||||
# CONFIG_SETSID is not set
|
||||
# CONFIG_SHRED is not set
|
||||
# CONFIG_STAT is not set
|
||||
# CONFIG_SWAPOFF is not set
|
||||
# CONFIG_SWAPON is not set
|
||||
# CONFIG_SWITCH_ROOT is not set
|
||||
# CONFIG_SYSCTL is not set
|
||||
# CONFIG_TAC is not set
|
||||
# CONFIG_NPROC is not set
|
||||
# CONFIG_TASKSET is not set
|
||||
# CONFIG_TIMEOUT is not set
|
||||
# CONFIG_TRUNCATE is not set
|
||||
# CONFIG_UPTIME is not set
|
||||
# CONFIG_USLEEP is not set
|
||||
# CONFIG_UUIDGEN is not set
|
||||
# CONFIG_VCONFIG is not set
|
||||
# CONFIG_VMSTAT is not set
|
||||
# CONFIG_W is not set
|
||||
# CONFIG_WATCH is not set
|
||||
# CONFIG_WHICH is not set
|
||||
# CONFIG_XXD is not set
|
||||
# CONFIG_YES is not set
|
||||
# CONFIG_FTPGET is not set
|
||||
# CONFIG_FTPPUT is not set
|
||||
# CONFIG_MICROCOM is not set
|
||||
# CONFIG_NETCAT is not set
|
||||
# CONFIG_NETCAT_LISTEN is not set
|
||||
# CONFIG_NETSTAT is not set
|
||||
# CONFIG_RFKILL is not set
|
||||
# CONFIG_SNTP is not set
|
||||
# CONFIG_TUNCTL is not set
|
||||
# CONFIG_DMESG is not set
|
||||
# CONFIG_GUNZIP is not set
|
||||
# CONFIG_ZCAT is not set
|
||||
# CONFIG_HOSTNAME is not set
|
||||
# CONFIG_DNSDOMAINNAME is not set
|
||||
# CONFIG_KILLALL is not set
|
||||
# CONFIG_MD5SUM is not set
|
||||
# CONFIG_SHA1SUM is not set
|
||||
# CONFIG_MKNOD is not set
|
||||
# CONFIG_MKTEMP is not set
|
||||
# CONFIG_PASSWD is not set
|
||||
# CONFIG_PIDOF is not set
|
||||
# CONFIG_SEQ is not set
|
||||
# CONFIG_SU is not set
|
||||
# CONFIG_SYNC is not set
|
||||
0
arch/Kconfig
Normal file → Executable file
0
arch/Kconfig
Normal file → Executable file
@@ -75,29 +75,3 @@ config ARCH_CORTEX_A7
|
||||
config ARCH_CPU
|
||||
string
|
||||
default "cortex-a7" if ARCH_CORTEX_A7
|
||||
|
||||
#
|
||||
# Supported GIC version
|
||||
#
|
||||
|
||||
choice
|
||||
prompt "GIC version"
|
||||
default ARCH_GIC_V2
|
||||
help
|
||||
Interrupt Controller.
|
||||
|
||||
config ARCH_GIC_V2
|
||||
bool "GIC Version 2"
|
||||
help
|
||||
This GIC(General Interrupt Controller) version 2 driver is compatatble with
|
||||
GIC version 1 and version 2.
|
||||
|
||||
config ARCH_GIC_V3
|
||||
bool "GIC Version 3"
|
||||
depends on ARCH_ARM_V8A || ARCH_ARM_V8R
|
||||
help
|
||||
General Interrupt Controller version 3.
|
||||
|
||||
endchoice
|
||||
|
||||
|
||||
|
||||
@@ -42,10 +42,7 @@ LITEOS_ARCH_ARM :=
|
||||
endif
|
||||
|
||||
LITEOS_BASELIB += -l$(LOSCFG_ARCH_CPU)
|
||||
LITEOS_BASELIB += -lgic
|
||||
|
||||
LIB_SUBDIRS += arch/arm/$(LITEOS_ARCH_ARM)
|
||||
LIB_SUBDIRS += arch/arm/gic
|
||||
|
||||
# CPU compile options
|
||||
ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
|
||||
@@ -65,7 +62,7 @@ LITEOS_FPU_OPTS := -mfpu=$(LOSCFG_ARCH_FPU)
|
||||
LITEOS_GCCLIB := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_ARCH_FPU)
|
||||
endif
|
||||
|
||||
LITEOS_CORE_COPTS = $(or $(ARCH_CFLAGS),$(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS))
|
||||
LITEOS_CORE_COPTS = $(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS)
|
||||
LITEOS_INTERWORK += $(LITEOS_CORE_COPTS)
|
||||
LITEOS_NODEBUG += $(LITEOS_CORE_COPTS)
|
||||
LITEOS_ASOPTS += $(LITEOS_CPU_OPTS)
|
||||
|
||||
0
arch/arm/arm/Makefile
Normal file → Executable file
0
arch/arm/arm/Makefile
Normal file → Executable file
1
arch/arm/arm/include/arch_config.h
Normal file → Executable file
1
arch/arm/arm/include/arch_config.h
Normal file → Executable file
@@ -32,6 +32,7 @@
|
||||
#ifndef _ARCH_CONFIG_H
|
||||
#define _ARCH_CONFIG_H
|
||||
|
||||
#include "menuconfig.h"
|
||||
|
||||
#define CPSR_INT_DISABLE 0xC0 /* Disable both FIQ and IRQ */
|
||||
#define CPSR_IRQ_DISABLE 0x80 /* IRQ disabled when =1 */
|
||||
|
||||
4
arch/arm/arm/include/arm.h
Normal file → Executable file
4
arch/arm/arm/include/arm.h
Normal file → Executable file
@@ -36,6 +36,10 @@
|
||||
#define CPSR_MODE_USR 0x10
|
||||
#define CPSR_MODE_MASK 0x1f
|
||||
|
||||
#define DSB __asm__ volatile("dsb" ::: "memory")
|
||||
#define ISB __asm__ volatile("isb" ::: "memory")
|
||||
#define DMB __asm__ volatile("dmb" ::: "memory")
|
||||
|
||||
STATIC INLINE UINT32 OsArmReadSctlr(VOID)
|
||||
{
|
||||
UINT32 val;
|
||||
|
||||
0
arch/arm/arm/include/arm_user_copy.h
Normal file → Executable file
0
arch/arm/arm/include/arm_user_copy.h
Normal file → Executable file
0
arch/arm/arm/include/arm_user_get.h
Normal file → Executable file
0
arch/arm/arm/include/arm_user_get.h
Normal file → Executable file
0
arch/arm/arm/include/arm_user_put.h
Normal file → Executable file
0
arch/arm/arm/include/arm_user_put.h
Normal file → Executable file
21
arch/arm/arm/include/los_hw_cpu.h
Normal file → Executable file
21
arch/arm/arm/include/los_hw_cpu.h
Normal file → Executable file
@@ -51,7 +51,6 @@ extern "C" {
|
||||
#define DSB __asm__ volatile("dsb" ::: "memory")
|
||||
#define DMB __asm__ volatile("dmb" ::: "memory")
|
||||
#define ISB __asm__ volatile("isb" ::: "memory")
|
||||
#define WFI __asm__ volatile("wfi" ::: "memory")
|
||||
#define BARRIER __asm__ volatile("":::"memory")
|
||||
|
||||
#define ARM_SYSREG_READ(REG) \
|
||||
@@ -145,7 +144,7 @@ STATIC INLINE VOID ArchCurrUserTaskSet(UINTPTR val)
|
||||
|
||||
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
return ARM_SYSREG_READ(MPIDR) & MPIDR_CPUID_MASK;
|
||||
#else
|
||||
return 0;
|
||||
@@ -189,24 +188,6 @@ STATIC INLINE UINT32 ArchIntUnlock(VOID)
|
||||
return intSave;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID ArchIrqDisable(VOID)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cpsid i "
|
||||
:
|
||||
:
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
STATIC INLINE VOID ArchIrqEnable(VOID)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"cpsie i "
|
||||
:
|
||||
:
|
||||
: "memory", "cc");
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
STATIC INLINE UINT32 ArchIntLock(VOID)
|
||||
|
||||
0
arch/arm/arm/include/los_mmu_descriptor_v6.h
Normal file → Executable file
0
arch/arm/arm/include/los_mmu_descriptor_v6.h
Normal file → Executable file
@@ -37,6 +37,7 @@
|
||||
#define __LOS_TLB_V6_H__
|
||||
|
||||
#include "los_typedef.h"
|
||||
#include "menuconfig.h"
|
||||
#include "arm.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,100 +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 "asm.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
// size_t _arm_clear_user(void *addr, size_t bytes)
|
||||
FUNCTION(_arm_clear_user)
|
||||
push {r0-r6, lr}
|
||||
cmp r1, #0
|
||||
beq .Lclear_user_return
|
||||
tst r0, #7
|
||||
beq .Lclear_user_aligned
|
||||
|
||||
.Lclear_user_byte:
|
||||
mov r2, #0
|
||||
0: strb r2, [r0], #1
|
||||
subs r1, r1, #1
|
||||
beq .Lclear_user_return
|
||||
tst r0, #7
|
||||
bne 0b
|
||||
|
||||
.Lclear_user_aligned:
|
||||
eor r3, r3
|
||||
eor r4, r4
|
||||
bics r2, r1, #15
|
||||
bne .Lclear_user_16bytes
|
||||
bics r2, r1, #7
|
||||
bne .Lclear_user_8bytes
|
||||
b .Lclear_user_remaining
|
||||
|
||||
.Lclear_user_16bytes:
|
||||
eor r5, r5
|
||||
eor r6, r6
|
||||
1: stmia r0!, {r3, r4, r5, r6}
|
||||
subs r2, r2, #16
|
||||
bne 1b
|
||||
ands r1, r1, #15
|
||||
beq .Lclear_user_return
|
||||
bics r2, r1, #7
|
||||
beq .Lclear_user_remaining
|
||||
|
||||
.Lclear_user_8bytes:
|
||||
2: stmia r0!, {r3, r4}
|
||||
ands r1, r1, #7
|
||||
beq .Lclear_user_return
|
||||
|
||||
.Lclear_user_remaining:
|
||||
mov r2, #0
|
||||
3: strb r2, [r0], #1
|
||||
subs r1, r1, #1
|
||||
bne 3b
|
||||
|
||||
.Lclear_user_return:
|
||||
pop {r0-r6, lr}
|
||||
mov r0, #0
|
||||
bx lr
|
||||
|
||||
.Lclear_user_err:
|
||||
pop {r0, r1}
|
||||
sub r0, r2, r0
|
||||
sub r0, r1, r0
|
||||
pop {r2-r6, lr}
|
||||
bx lr
|
||||
|
||||
.pushsection __exc_table, "a"
|
||||
.long 0b, .Lclear_user_err
|
||||
.long 1b, .Lclear_user_err
|
||||
.long 2b, .Lclear_user_err
|
||||
.long 3b, .Lclear_user_err
|
||||
.popsection
|
||||
0
arch/arm/arm/src/hw_user_get.S
Normal file → Executable file
0
arch/arm/arm/src/hw_user_get.S
Normal file → Executable file
0
arch/arm/arm/src/hw_user_put.S
Normal file → Executable file
0
arch/arm/arm/src/hw_user_put.S
Normal file → Executable file
0
arch/arm/arm/src/include/asm.h
Normal file → Executable file
0
arch/arm/arm/src/include/asm.h
Normal file → Executable file
@@ -40,6 +40,11 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
STATIC INLINE VOID OsSetCurrCpuSp(UINTPTR regSp)
|
||||
{
|
||||
__asm__ __volatile__("mov sp, %0" :: "r"(regSp));
|
||||
}
|
||||
|
||||
#define OS_SYSTEM_NORMAL 0
|
||||
#define OS_SYSTEM_EXC_CURR_CPU 1
|
||||
#define OS_SYSTEM_EXC_OTHER_CPU 2
|
||||
|
||||
57
arch/arm/arm/src/include/los_hw_pri.h
Normal file → Executable file
57
arch/arm/arm/src/include/los_hw_pri.h
Normal file → Executable file
@@ -34,7 +34,8 @@
|
||||
|
||||
#include "los_base.h"
|
||||
#include "los_hw.h"
|
||||
|
||||
#include "los_process_pri.h"
|
||||
#include "los_signal.h"
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -55,44 +56,23 @@ typedef struct {
|
||||
UINT32 regFPSCR; /* FPSCR */
|
||||
UINT32 regFPEXC; /* FPEXC */
|
||||
#endif
|
||||
UINT32 R4;
|
||||
UINT32 R5;
|
||||
UINT32 R6;
|
||||
UINT32 R7;
|
||||
UINT32 R8;
|
||||
UINT32 R9;
|
||||
UINT32 R10;
|
||||
UINT32 R11;
|
||||
|
||||
/* It has the same structure as IrqContext */
|
||||
UINT32 reserved2; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
|
||||
UINT32 reserved1; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
|
||||
UINT32 USP; /**< User mode sp register */
|
||||
UINT32 ULR; /**< User mode lr register */
|
||||
UINT32 R0;
|
||||
UINT32 R1;
|
||||
UINT32 R2;
|
||||
UINT32 R3;
|
||||
UINT32 R12;
|
||||
UINT32 LR;
|
||||
UINT32 PC;
|
||||
UINT32 regCPSR;
|
||||
UINT32 resved; /* It's stack 8 aligned */
|
||||
UINT32 regPSR;
|
||||
UINT32 R[GEN_REGS_NUM]; /* R0-R12 */
|
||||
UINT32 SP; /* R13 */
|
||||
UINT32 LR; /* R14 */
|
||||
UINT32 PC; /* R15 */
|
||||
} TaskContext;
|
||||
|
||||
typedef struct {
|
||||
UINT32 reserved2; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
|
||||
UINT32 reserved1; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
|
||||
UINT32 USP; /**< User mode sp register */
|
||||
UINT32 ULR; /**< User mode lr register */
|
||||
UINT32 R0;
|
||||
UINT32 R1;
|
||||
UINT32 R2;
|
||||
UINT32 R3;
|
||||
UINT32 R12;
|
||||
UINT32 LR;
|
||||
UINT32 PC;
|
||||
UINT32 regCPSR;
|
||||
} IrqContext;
|
||||
#if !defined(LOSCFG_ARCH_FPU_DISABLE)
|
||||
UINT64 D[FP_REGS_NUM]; /* D0-D31 */
|
||||
UINT32 regFPSCR; /* FPSCR */
|
||||
UINT32 regFPEXC; /* FPEXC */
|
||||
#endif
|
||||
UINT32 resved;
|
||||
TASK_IRQ_CONTEXT
|
||||
} TaskIrqContext;
|
||||
|
||||
/*
|
||||
* Description : task stack initialization
|
||||
@@ -102,9 +82,8 @@ typedef struct {
|
||||
* Return : pointer to the task context
|
||||
*/
|
||||
extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
|
||||
extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize);
|
||||
extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
|
||||
extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
|
||||
extern VOID OsUserCloneParentStack(LosTaskCB *childTaskCB, LosTaskCB *parentTaskCB);
|
||||
extern VOID OsUserTaskStackInit(TaskContext *context, TSK_ENTRY_FUNC taskEntry, UINTPTR stack);
|
||||
extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);
|
||||
extern void arm_inv_cache_range(UINTPTR start, UINTPTR end);
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ extern VOID OsIncHwiFormCnt(UINT32 index);
|
||||
extern UINT32 OsGetHwiFormCnt(UINT32 index);
|
||||
extern CHAR *OsGetHwiFormName(UINT32 index);
|
||||
extern VOID OsInterrupt(UINT32 intNum);
|
||||
extern VOID OsSyscallHandleInit(VOID);
|
||||
extern VOID SyscallHandleInit(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
128
arch/arm/arm/src/los_arch_mmu.c
Normal file → Executable file
128
arch/arm/arm/src/los_arch_mmu.c
Normal file → Executable file
@@ -45,13 +45,16 @@
|
||||
#include "los_vm_boot.h"
|
||||
#include "los_mmu_descriptor_v6.h"
|
||||
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
|
||||
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
|
||||
g_firstPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
|
||||
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
|
||||
g_tempPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
|
||||
@@ -67,11 +70,6 @@ STATIC INLINE PTE_T *OsGetPte2BasePtr(PTE_T pte1)
|
||||
return LOS_PaddrToKVaddr(pa);
|
||||
}
|
||||
|
||||
VADDR_T *OsGFirstTableGet(VOID)
|
||||
{
|
||||
return (VADDR_T *)g_firstPageTable;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsUnmapL1Invalid(vaddr_t *vaddr, UINT32 *count)
|
||||
{
|
||||
UINT32 unmapCount;
|
||||
@@ -148,6 +146,7 @@ STATIC VOID OsCvtPte2AttsToFlags(PTE_T l1Entry, PTE_T l2Entry, UINT32 *flags)
|
||||
|
||||
STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Paddr)
|
||||
{
|
||||
LosVmPage *vmPage = NULL;
|
||||
UINT32 index;
|
||||
PTE_T ttEntry;
|
||||
/* check if any l1 entry points to this l2 table */
|
||||
@@ -157,9 +156,8 @@ STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Pa
|
||||
return;
|
||||
}
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* we can free this l2 table */
|
||||
LosVmPage *vmPage = LOS_VmPageGet(l2Paddr);
|
||||
vmPage = LOS_VmPageGet(l2Paddr);
|
||||
if (vmPage == NULL) {
|
||||
LOS_Panic("bad page table paddr %#x\n", l2Paddr);
|
||||
return;
|
||||
@@ -167,9 +165,6 @@ STATIC VOID OsPutL2Table(const LosArchMmu *archMmu, UINT32 l1Index, paddr_t l2Pa
|
||||
|
||||
LOS_ListDelete(&vmPage->node);
|
||||
LOS_PhysPageFree(vmPage);
|
||||
#else
|
||||
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, LOS_PaddrToKVaddr(l2Paddr));
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC VOID OsTryUnmapL1PTE(const LosArchMmu *archMmu, vaddr_t vaddr, UINT32 scanIndex, UINT32 scanCount)
|
||||
@@ -218,7 +213,7 @@ STATIC UINT32 OsCvtSecCacheFlagsToMMUFlags(UINT32 flags)
|
||||
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
|
||||
case VM_MAP_REGION_FLAG_CACHED:
|
||||
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
mmuFlags |= MMU_DESCRIPTOR_L1_SECTION_SHAREABLE;
|
||||
#endif
|
||||
break;
|
||||
@@ -375,14 +370,13 @@ STATIC UINT32 OsUnmapSection(LosArchMmu *archMmu, vaddr_t *vaddr, UINT32 *count)
|
||||
return MMU_DESCRIPTOR_L2_NUMBERS_PER_L1;
|
||||
}
|
||||
|
||||
|
||||
BOOL OsArchMmuInit(LosArchMmu *archMmu, VADDR_T *virtTtb)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsAllocAsid(&archMmu->asid) != LOS_OK) {
|
||||
VM_ERR("alloc arch mmu asid failed");
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
status_t retval = LOS_MuxInit(&archMmu->mtx, NULL);
|
||||
if (retval != LOS_OK) {
|
||||
@@ -486,6 +480,7 @@ STATIC STATUS_T OsGetL2Table(LosArchMmu *archMmu, UINT32 l1Index, paddr_t *ppa)
|
||||
UINT32 index;
|
||||
PTE_T ttEntry;
|
||||
VADDR_T *kvaddr = NULL;
|
||||
LosVmPage *vmPage = NULL;
|
||||
UINT32 l2Offset = (MMU_DESCRIPTOR_L2_SMALL_SIZE / MMU_DESCRIPTOR_L1_SMALL_L2_TABLES_PER_PAGE) *
|
||||
(l1Index & (MMU_DESCRIPTOR_L1_SMALL_L2_TABLES_PER_PAGE - 1));
|
||||
/* lookup an existing l2 page table */
|
||||
@@ -498,22 +493,14 @@ STATIC STATUS_T OsGetL2Table(LosArchMmu *archMmu, UINT32 l1Index, paddr_t *ppa)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* not found: allocate one (paddr) */
|
||||
LosVmPage *vmPage = LOS_PhysPageAlloc();
|
||||
vmPage = LOS_PhysPageAlloc();
|
||||
if (vmPage == NULL) {
|
||||
VM_ERR("have no memory to save l2 page");
|
||||
return LOS_ERRNO_VM_NO_MEMORY;
|
||||
}
|
||||
LOS_ListAdd(&archMmu->ptList, &vmPage->node);
|
||||
kvaddr = OsVmPageToVaddr(vmPage);
|
||||
#else
|
||||
kvaddr = LOS_MemAlloc(OS_SYS_MEM_ADDR, MMU_DESCRIPTOR_L2_SMALL_SIZE);
|
||||
if (kvaddr == NULL) {
|
||||
VM_ERR("have no memory to save l2 page");
|
||||
return LOS_ERRNO_VM_NO_MEMORY;
|
||||
}
|
||||
#endif
|
||||
(VOID)memset_s(kvaddr, MMU_DESCRIPTOR_L2_SMALL_SIZE, 0, MMU_DESCRIPTOR_L2_SMALL_SIZE);
|
||||
|
||||
/* get physical address */
|
||||
@@ -544,7 +531,7 @@ STATIC UINT32 OsCvtPte2CacheFlagsToMMUFlags(UINT32 flags)
|
||||
|
||||
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
|
||||
case VM_MAP_REGION_FLAG_CACHED:
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
mmuFlags |= MMU_DESCRIPTOR_L2_SHAREABLE;
|
||||
#endif
|
||||
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
|
||||
@@ -764,26 +751,21 @@ VOID LOS_ArchMmuContextSwitch(LosArchMmu *archMmu)
|
||||
ttbcr |= MMU_DESCRIPTOR_TTBCR_PD0;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* from armv7a arm B3.10.4, we should do synchronization changes of ASID and TTBR. */
|
||||
OsArmWriteContextidr(LOS_GetKVmSpace()->archMmu.asid);
|
||||
ISB;
|
||||
#endif
|
||||
OsArmWriteTtbr0(ttbr);
|
||||
ISB;
|
||||
OsArmWriteTtbcr(ttbcr);
|
||||
ISB;
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (archMmu) {
|
||||
OsArmWriteContextidr(archMmu->asid);
|
||||
ISB;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmPage *page = NULL;
|
||||
/* free all of the pages allocated in archMmu->ptList */
|
||||
while ((page = LOS_ListRemoveHeadType(&archMmu->ptList, LosVmPage, node)) != NULL) {
|
||||
@@ -792,7 +774,6 @@ STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
|
||||
|
||||
OsArmWriteTlbiasid(archMmu->asid);
|
||||
OsFreeAsid(archMmu->asid);
|
||||
#endif
|
||||
(VOID)LOS_MuxDestroy(&archMmu->mtx);
|
||||
return LOS_OK;
|
||||
}
|
||||
@@ -825,34 +806,38 @@ STATIC VOID OsSwitchTmpTTB(VOID)
|
||||
ISB;
|
||||
}
|
||||
|
||||
STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
VADDR_T *OsGFirstTableGet()
|
||||
{
|
||||
return (VADDR_T *)g_firstPageTable;
|
||||
}
|
||||
|
||||
STATIC VOID OsSetKSectionAttr(VOID)
|
||||
{
|
||||
UINT32 offset = virtAddr - KERNEL_VMM_BASE;
|
||||
/* every section should be page aligned */
|
||||
UINTPTR textStart = (UINTPTR)&__text_start + offset;
|
||||
UINTPTR textEnd = (UINTPTR)&__text_end + offset;
|
||||
UINTPTR rodataStart = (UINTPTR)&__rodata_start + offset;
|
||||
UINTPTR rodataEnd = (UINTPTR)&__rodata_end + offset;
|
||||
UINTPTR ramDataStart = (UINTPTR)&__ram_data_start + offset;
|
||||
UINTPTR bssEnd = (UINTPTR)&__bss_end + offset;
|
||||
UINTPTR textStart = (UINTPTR)&__text_start;
|
||||
UINTPTR textEnd = (UINTPTR)&__text_end;
|
||||
UINTPTR rodataStart = (UINTPTR)&__rodata_start;
|
||||
UINTPTR rodataEnd = (UINTPTR)&__rodata_end;
|
||||
UINTPTR ramDataStart = (UINTPTR)&__ram_data_start;
|
||||
UINTPTR bssEnd = (UINTPTR)&__bss_end;
|
||||
UINT32 bssEndBoundary = ROUNDUP(bssEnd, MB);
|
||||
LosArchMmuInitMapping mmuKernelMappings[] = {
|
||||
{
|
||||
.phys = SYS_MEM_BASE + textStart - virtAddr,
|
||||
.phys = SYS_MEM_BASE + textStart - KERNEL_VMM_BASE,
|
||||
.virt = textStart,
|
||||
.size = ROUNDUP(textEnd - textStart, MMU_DESCRIPTOR_L2_SMALL_SIZE),
|
||||
.flags = VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_EXECUTE,
|
||||
.name = "kernel_text"
|
||||
},
|
||||
{
|
||||
.phys = SYS_MEM_BASE + rodataStart - virtAddr,
|
||||
.phys = SYS_MEM_BASE + rodataStart - KERNEL_VMM_BASE,
|
||||
.virt = rodataStart,
|
||||
.size = ROUNDUP(rodataEnd - rodataStart, MMU_DESCRIPTOR_L2_SMALL_SIZE),
|
||||
.flags = VM_MAP_REGION_FLAG_PERM_READ,
|
||||
.name = "kernel_rodata"
|
||||
},
|
||||
{
|
||||
.phys = SYS_MEM_BASE + ramDataStart - virtAddr,
|
||||
.phys = SYS_MEM_BASE + ramDataStart - KERNEL_VMM_BASE,
|
||||
.virt = ramDataStart,
|
||||
.size = ROUNDUP(bssEndBoundary - ramDataStart, MMU_DESCRIPTOR_L2_SMALL_SIZE),
|
||||
.flags = VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE,
|
||||
@@ -862,29 +847,26 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
LosVmSpace *kSpace = LOS_GetKVmSpace();
|
||||
status_t status;
|
||||
UINT32 length;
|
||||
paddr_t oldTtPhyBase;
|
||||
int i;
|
||||
LosArchMmuInitMapping *kernelMap = NULL;
|
||||
UINT32 kmallocLength;
|
||||
UINT32 flags;
|
||||
|
||||
/* use second-level mapping of default READ and WRITE */
|
||||
kSpace->archMmu.virtTtb = (PTE_T *)g_firstPageTable;
|
||||
kSpace->archMmu.physTtb = LOS_PaddrQuery(kSpace->archMmu.virtTtb);
|
||||
status = LOS_ArchMmuUnmap(&kSpace->archMmu, virtAddr,
|
||||
(bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
if (status != ((bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
status = LOS_ArchMmuUnmap(&kSpace->archMmu, KERNEL_VMM_BASE,
|
||||
(bssEndBoundary - KERNEL_VMM_BASE) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
if (status != ((bssEndBoundary - KERNEL_VMM_BASE) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("unmap failed, status: %d", status);
|
||||
return;
|
||||
}
|
||||
|
||||
flags = VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE | VM_MAP_REGION_FLAG_PERM_EXECUTE;
|
||||
if (uncached) {
|
||||
flags |= VM_MAP_REGION_FLAG_UNCACHED;
|
||||
}
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, virtAddr, SYS_MEM_BASE,
|
||||
(textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
if (status != ((textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, KERNEL_VMM_BASE, SYS_MEM_BASE,
|
||||
(textStart - KERNEL_VMM_BASE) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE |
|
||||
VM_MAP_REGION_FLAG_PERM_EXECUTE);
|
||||
if (status != ((textStart - KERNEL_VMM_BASE) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("mmap failed, status: %d", status);
|
||||
return;
|
||||
}
|
||||
@@ -892,9 +874,6 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
length = sizeof(mmuKernelMappings) / sizeof(LosArchMmuInitMapping);
|
||||
for (i = 0; i < length; i++) {
|
||||
kernelMap = &mmuKernelMappings[i];
|
||||
if (uncached) {
|
||||
kernelMap->flags |= VM_MAP_REGION_FLAG_UNCACHED;
|
||||
}
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, kernelMap->virt, kernelMap->phys,
|
||||
kernelMap->size >> MMU_DESCRIPTOR_L2_SMALL_SHIFT, kernelMap->flags);
|
||||
if (status != (kernelMap->size >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
@@ -904,29 +883,16 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
LOS_VmSpaceReserve(kSpace, kernelMap->size, kernelMap->virt);
|
||||
}
|
||||
|
||||
kmallocLength = virtAddr + SYS_MEM_SIZE_DEFAULT - bssEndBoundary;
|
||||
flags = VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE;
|
||||
if (uncached) {
|
||||
flags |= VM_MAP_REGION_FLAG_UNCACHED;
|
||||
}
|
||||
kmallocLength = KERNEL_VMM_BASE + SYS_MEM_SIZE_DEFAULT - bssEndBoundary;
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, bssEndBoundary,
|
||||
SYS_MEM_BASE + bssEndBoundary - virtAddr,
|
||||
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
SYS_MEM_BASE + bssEndBoundary - KERNEL_VMM_BASE,
|
||||
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
VM_MAP_REGION_FLAG_PERM_READ | VM_MAP_REGION_FLAG_PERM_WRITE);
|
||||
if (status != (kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("mmap failed, status: %d", status);
|
||||
return;
|
||||
}
|
||||
LOS_VmSpaceReserve(kSpace, kmallocLength, bssEndBoundary);
|
||||
}
|
||||
|
||||
STATIC VOID OsKSectionNewAttrEnable(VOID)
|
||||
{
|
||||
LosVmSpace *kSpace = LOS_GetKVmSpace();
|
||||
paddr_t oldTtPhyBase;
|
||||
|
||||
kSpace->archMmu.virtTtb = (PTE_T *)g_firstPageTable;
|
||||
kSpace->archMmu.physTtb = LOS_PaddrQuery(kSpace->archMmu.virtTtb);
|
||||
|
||||
/* we need free tmp ttbase */
|
||||
oldTtPhyBase = OsArmReadTtbr0();
|
||||
@@ -960,10 +926,14 @@ VOID OsInitMappingStartUp(VOID)
|
||||
|
||||
OsSwitchTmpTTB();
|
||||
|
||||
OsSetKSectionAttr(KERNEL_VMM_BASE, FALSE);
|
||||
OsSetKSectionAttr(UNCACHED_VMM_BASE, TRUE);
|
||||
OsKSectionNewAttrEnable();
|
||||
OsSetKSectionAttr();
|
||||
|
||||
OsArchMmuInitPerCPU();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
@@ -39,8 +39,11 @@
|
||||
#include "los_spinlock.h"
|
||||
#include "los_mmu_descriptor_v6.h"
|
||||
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
STATIC SPIN_LOCK_INIT(g_cpuAsidLock);
|
||||
STATIC UINTPTR g_asidPool[BITMAP_NUM_WORDS(1UL << MMU_ARM_ASID_BITS)];
|
||||
@@ -69,5 +72,9 @@ VOID OsFreeAsid(UINT32 asid)
|
||||
LOS_BitmapClrNBits(g_asidPool, asid, 1);
|
||||
LOS_SpinUnlockRestore(&g_cpuAsidLock, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
147
arch/arm/arm/src/los_dispatch.S
Normal file → Executable file
147
arch/arm/arm/src/los_dispatch.S
Normal file → Executable file
@@ -32,7 +32,6 @@
|
||||
#include "asm.h"
|
||||
#include "arch_config.h"
|
||||
|
||||
.extern OsSaveSignalContext
|
||||
.extern OsSchedToUserReleaseLock
|
||||
.global OsTaskSchedule
|
||||
.global OsTaskContextLoad
|
||||
@@ -86,16 +85,17 @@
|
||||
*/
|
||||
OsTaskSchedule:
|
||||
MRS R2, CPSR
|
||||
STMFD SP!, {LR}
|
||||
STMFD SP!, {LR}
|
||||
/* jump sp */
|
||||
SUB SP, SP, #4
|
||||
|
||||
/* push r0-r12*/
|
||||
STMFD SP!, {R0-R12}
|
||||
STMFD SP!, {R2}
|
||||
STMFD SP!, {LR}
|
||||
STMFD SP!, {LR}
|
||||
STMFD SP!, {R12}
|
||||
|
||||
/* jump R0 - R3 USP, ULR reserved */
|
||||
SUB SP, SP, #(8 * 4)
|
||||
|
||||
/* push R4 - R11*/
|
||||
STMFD SP!, {R4-R11}
|
||||
/* 8 bytes stack align */
|
||||
SUB SP, SP, #4
|
||||
|
||||
/* save fpu registers */
|
||||
PUSH_FPU_REGS R2
|
||||
@@ -113,88 +113,131 @@ OsTaskContextLoad:
|
||||
/* restore fpu registers */
|
||||
POP_FPU_REGS R2
|
||||
|
||||
LDMFD SP!, {R4-R11}
|
||||
LDR R3, [SP, #(11 * 4)]
|
||||
AND R0, R3, #CPSR_MASK_MODE
|
||||
/* 8 bytes stack align */
|
||||
ADD SP, SP, #4
|
||||
|
||||
LDMFD SP!, {R0}
|
||||
MOV R4, R0
|
||||
AND R0, R0, #CPSR_MASK_MODE
|
||||
CMP R0, #CPSR_USER_MODE
|
||||
BNE OsKernelTaskLoad
|
||||
|
||||
MVN R2, #CPSR_INT_DISABLE
|
||||
AND R3, R3, R2
|
||||
STR R3, [SP, #(11 * 4)]
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/* 8 bytes stack align */
|
||||
SUB SP, SP, #4
|
||||
BL OsSchedToUserReleaseLock
|
||||
ADD SP, SP, #4
|
||||
#endif
|
||||
|
||||
/* jump sp, reserved */
|
||||
ADD SP, SP, #(2 * 4)
|
||||
MVN R3, #CPSR_INT_DISABLE
|
||||
AND R4, R4, R3
|
||||
MSR SPSR_cxsf, R4
|
||||
|
||||
/* restore r0-r12, lr */
|
||||
LDMFD SP!, {R0-R12}
|
||||
LDMFD SP, {R13, R14}^
|
||||
ADD SP, SP, #(2 * 4)
|
||||
LDMFD SP!, {R0-R3, R12, LR}
|
||||
RFEIA SP!
|
||||
LDMFD SP!, {PC}^
|
||||
|
||||
OsKernelTaskLoad:
|
||||
ADD SP, SP, #(4 * 4)
|
||||
LDMFD SP!, {R0-R3, R12, LR}
|
||||
RFEIA SP!
|
||||
MSR SPSR_cxsf, R4
|
||||
/* restore r0-r12, lr */
|
||||
LDMFD SP!, {R0-R12}
|
||||
ADD SP, SP, #4
|
||||
LDMFD SP!, {LR, PC}^
|
||||
|
||||
OsIrqHandler:
|
||||
SUB LR, LR, #4
|
||||
|
||||
/* Save pc and cpsr to svc sp, ARMv6 and above support */
|
||||
SRSFD #0x13!
|
||||
/* push r0-r3 to irq stack */
|
||||
STMFD SP, {R0-R3}
|
||||
SUB R0, SP, #(4 * 4)
|
||||
MRS R1, SPSR
|
||||
MOV R2, LR
|
||||
|
||||
/* disable irq, switch to svc mode */
|
||||
CPSID i, #0x13
|
||||
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
/* push spsr and pc in svc stack */
|
||||
STMFD SP!, {R1, R2}
|
||||
STMFD SP, {LR}
|
||||
|
||||
AND R3, R1, #CPSR_MASK_MODE
|
||||
CMP R3, #CPSR_USER_MODE
|
||||
BNE OsIrqFromKernel
|
||||
|
||||
/* push user sp, lr in svc stack */
|
||||
STMFD SP, {R13, R14}^
|
||||
SUB SP, SP, #(4 * 4)
|
||||
STR R4, [SP, #0]
|
||||
|
||||
OsIrqFromKernel:
|
||||
/* from svc not need save sp and lr */
|
||||
SUB SP, SP, #(2 * 4)
|
||||
|
||||
/* pop r0-r3 form irq stack*/
|
||||
LDMFD R0, {R0-R3}
|
||||
|
||||
/* push caller saved regs as trashed regs in svc stack */
|
||||
STMFD SP!, {R0-R3, R12}
|
||||
|
||||
/* 8 bytes stack align */
|
||||
SUB SP, SP, #4
|
||||
|
||||
/*
|
||||
* save fpu regs in case in case those been
|
||||
* altered in interrupt handlers.
|
||||
*/
|
||||
PUSH_FPU_REGS R0
|
||||
|
||||
#ifdef LOSCFG_IRQ_USE_STANDALONE_STACK
|
||||
PUSH {R4}
|
||||
MOV R4, SP
|
||||
EXC_SP_SET __svc_stack_top, OS_EXC_SVC_STACK_SIZE, R1, R2
|
||||
#endif
|
||||
|
||||
BLX HalIrqHandler
|
||||
|
||||
#ifdef LOSCFG_IRQ_USE_STANDALONE_STACK
|
||||
MOV SP, R4
|
||||
POP {R4}
|
||||
#endif
|
||||
|
||||
/* process pending signals */
|
||||
BLX OsTaskProcSignal
|
||||
BLX OsSchedIrqEndCheckNeedSched
|
||||
BL OsTaskProcSignal
|
||||
|
||||
BL OsSchedIrqEndCheckNeedSched
|
||||
|
||||
MOV R0,SP
|
||||
MOV R1,R7
|
||||
BL OsSaveSignalContextIrq
|
||||
|
||||
/* restore fpu regs */
|
||||
POP_FPU_REGS R0
|
||||
LDR R4, [SP, #0]
|
||||
POP_FPU_REGS R0
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* Obtain the CPSR to determine the mode the system is in when the interrupt is triggered */
|
||||
LDR R3, [SP, #(11 * 4)]
|
||||
AND R1, R3, #CPSR_MASK_MODE
|
||||
CMP R1, #CPSR_USER_MODE
|
||||
BNE 1f
|
||||
ADD SP, SP, #4
|
||||
|
||||
OsIrqContextRestore:
|
||||
LDR R0, [SP, #(4 * 7)]
|
||||
MSR SPSR_cxsf, R0
|
||||
AND R0, R0, #CPSR_MASK_MODE
|
||||
CMP R0, #CPSR_USER_MODE
|
||||
|
||||
LDMFD SP!, {R0-R3, R12}
|
||||
|
||||
BNE OsIrqContextRestoreToKernel
|
||||
|
||||
MOV R0, SP
|
||||
STR R7, [SP, #0]
|
||||
/* sp - sizeof(IrqContext) */
|
||||
SUB SP, SP, #(12 * 4)
|
||||
MOV R1, SP
|
||||
BLX OsSaveSignalContext
|
||||
MOV SP, R0
|
||||
1:
|
||||
#endif
|
||||
ADD SP, SP, #(2 * 4)
|
||||
/* load user sp and lr, and jump cpsr */
|
||||
LDMFD SP, {R13, R14}^
|
||||
ADD SP, SP, #(2 * 4)
|
||||
LDMFD SP!, {R0-R3, R12, LR}
|
||||
RFEIA SP!
|
||||
ADD SP, SP, #(3 * 4)
|
||||
|
||||
/* return to user mode */
|
||||
LDMFD SP!, {PC}^
|
||||
|
||||
OsIrqContextRestoreToKernel:
|
||||
/* svc mode not load sp */
|
||||
ADD SP, SP, #4
|
||||
LDMFD SP!, {LR}
|
||||
/* jump cpsr and return to svc mode */
|
||||
ADD SP, SP, #4
|
||||
LDMFD SP!, {PC}^
|
||||
|
||||
FUNCTION(ArchSpinLock)
|
||||
mov r1, #1
|
||||
|
||||
279
arch/arm/arm/src/los_exc.c
Normal file → Executable file
279
arch/arm/arm/src/los_exc.c
Normal file → Executable file
@@ -34,10 +34,14 @@
|
||||
#include "los_printf_pri.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_hw_pri.h"
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
#ifdef LOSCFG_SHELL_EXCINFO
|
||||
#include "los_excinfo_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_EXC_INTERACTION
|
||||
#include "los_exc_interaction_pri.h"
|
||||
#endif
|
||||
#include "los_sys_stack_pri.h"
|
||||
#include "los_stackinfo_pri.h"
|
||||
#ifdef LOSCFG_COREDUMP
|
||||
#include "los_coredump.h"
|
||||
#endif
|
||||
@@ -51,9 +55,7 @@
|
||||
#include "los_vm_phys.h"
|
||||
#include "los_vm_fault.h"
|
||||
#include "los_vm_common.h"
|
||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||
#include "los_load_elf.h"
|
||||
#endif
|
||||
#include "arm.h"
|
||||
#include "los_bitmap.h"
|
||||
#include "los_process_pri.h"
|
||||
@@ -61,10 +63,12 @@
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "console.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
#include "los_blackbox.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define INVALID_CPUID 0xFFFF
|
||||
#define OS_EXC_VMM_NO_REGION 0x0U
|
||||
@@ -77,7 +81,7 @@ VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr);
|
||||
UINT32 g_curNestCount[LOSCFG_KERNEL_CORE_NUM] = { 0 };
|
||||
BOOL g_excFromUserMode[LOSCFG_KERNEL_CORE_NUM];
|
||||
STATIC EXC_PROC_FUNC g_excHook = (EXC_PROC_FUNC)OsExcHook;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
STATIC SPIN_LOCK_INIT(g_excSerializerSpin);
|
||||
STATIC UINT32 g_currHandleExcPID = OS_INVALID_VALUE;
|
||||
STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
|
||||
@@ -103,7 +107,11 @@ STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
|
||||
(IS_ALIGNED((ptr), sizeof(CHAR *))))
|
||||
|
||||
STATIC const StackInfo g_excStack[] = {
|
||||
{ &__undef_stack, OS_EXC_UNDEF_STACK_SIZE, "udf_stack" },
|
||||
{ &__abt_stack, OS_EXC_ABT_STACK_SIZE, "abt_stack" },
|
||||
{ &__fiq_stack, OS_EXC_FIQ_STACK_SIZE, "fiq_stack" },
|
||||
{ &__svc_stack, OS_EXC_SVC_STACK_SIZE, "svc_stack" },
|
||||
{ &__irq_stack, OS_EXC_IRQ_STACK_SIZE, "irq_stack" },
|
||||
{ &__exc_stack, OS_EXC_STACK_SIZE, "exc_stack" }
|
||||
};
|
||||
|
||||
@@ -177,32 +185,20 @@ STATIC INT32 OsDecodeDataFSR(UINT32 regDFSR)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT32 fsr)
|
||||
{
|
||||
BOOL instructionFault = FALSE;
|
||||
PRINT_INFO("page fault entry!!!\n");
|
||||
BOOL instruction_fault = FALSE;
|
||||
UINT32 pfFlags = 0;
|
||||
UINT32 fsrFlag;
|
||||
BOOL write = FALSE;
|
||||
UINT32 ret;
|
||||
|
||||
PRINT_INFO("page fault entry!!!\n");
|
||||
if (OsGetSystemStatus() == OS_SYSTEM_EXC_CURR_CPU) {
|
||||
return LOS_ERRNO_VM_NOT_FOUND;
|
||||
}
|
||||
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
|
||||
BOOL irqEnable = !(LOS_SpinHeld(&g_taskSpin) && (OsPercpuGet()->taskLockCnt != 0));
|
||||
if (irqEnable) {
|
||||
ArchIrqEnable();
|
||||
} else {
|
||||
PrintExcInfo("[ERR][%s] may be held scheduler lock when entering [%s] on cpu [%u]\n",
|
||||
OsCurrTaskGet()->taskName, __FUNCTION__, ArchCurrCpuid());
|
||||
}
|
||||
#else
|
||||
ArchIrqEnable();
|
||||
#endif
|
||||
|
||||
if (excType == OS_EXCEPT_PREFETCH_ABORT) {
|
||||
instructionFault = TRUE;
|
||||
instruction_fault = TRUE;
|
||||
} else {
|
||||
write = !!BIT_GET(fsr, WNR_BIT);
|
||||
}
|
||||
@@ -220,27 +216,14 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
|
||||
BOOL user = (frame->regCPSR & CPSR_MODE_MASK) == CPSR_MODE_USR;
|
||||
pfFlags |= write ? VM_MAP_PF_FLAG_WRITE : 0;
|
||||
pfFlags |= user ? VM_MAP_PF_FLAG_USER : 0;
|
||||
pfFlags |= instructionFault ? VM_MAP_PF_FLAG_INSTRUCTION : 0;
|
||||
pfFlags |= instruction_fault ? VM_MAP_PF_FLAG_INSTRUCTION : 0;
|
||||
pfFlags |= VM_MAP_PF_FLAG_NOT_PRESENT;
|
||||
OsSigIntLock();
|
||||
ret = OsVmPageFaultHandler(far, pfFlags, frame);
|
||||
OsSigIntUnlock();
|
||||
break;
|
||||
return OsVmPageFaultHandler(far, pfFlags, frame);
|
||||
}
|
||||
default:
|
||||
ret = LOS_ERRNO_VM_NOT_FOUND;
|
||||
break;
|
||||
return LOS_ERRNO_VM_NOT_FOUND;
|
||||
}
|
||||
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
|
||||
if (irqEnable) {
|
||||
ArchIrqDisable();
|
||||
}
|
||||
#else
|
||||
ArchIrqDisable();
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsExcType(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr)
|
||||
{
|
||||
@@ -273,7 +256,6 @@ STATIC const CHAR *g_excTypeString[] = {
|
||||
"irq"
|
||||
};
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
|
||||
{
|
||||
struct file *curFilep = NULL;
|
||||
@@ -301,52 +283,41 @@ STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProc
|
||||
} while (!strcmp(curFilep->f_path, lastFilep->f_path));
|
||||
|
||||
DONE:
|
||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||
if (curRegion->range.base == EXEC_MMAP_BASE) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return curRegion->range.base;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
|
||||
{
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
LosVmMapRegion *region = NULL;
|
||||
|
||||
PrintExcInfo("excType: %s\n"
|
||||
"processName = %s\n"
|
||||
"processID = %u\n"
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
"process aspace = 0x%08x -> 0x%08x\n"
|
||||
#endif
|
||||
"taskName = %s\n"
|
||||
"taskID = %u\n",
|
||||
g_excTypeString[excType],
|
||||
runProcess->processName,
|
||||
runProcess->processID,
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
runProcess->vmSpace->base,
|
||||
runProcess->vmSpace->base + runProcess->vmSpace->size,
|
||||
#endif
|
||||
runTask->taskName,
|
||||
runTask->taskID);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsProcessIsUserMode(runProcess)) {
|
||||
PrintExcInfo("task user stack = 0x%08x -> 0x%08x\n",
|
||||
runTask->userMapBase, runTask->userMapBase + runTask->userMapSize);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
PrintExcInfo("task kernel stack = 0x%08x -> 0x%08x\n",
|
||||
runTask->topOfStack, runTask->topOfStack + runTask->stackSize);
|
||||
}
|
||||
|
||||
PrintExcInfo("pc = 0x%x ", excBufAddr->PC);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmMapRegion *region = NULL;
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
if (LOS_IsUserAddress((vaddr_t)excBufAddr->PC)) {
|
||||
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)excBufAddr->PC);
|
||||
@@ -363,9 +334,7 @@ STATIC VOID OsExcSysInfo(UINT32 excType, const ExcContext *excBufAddr)
|
||||
(VADDR_T)excBufAddr->ULR - OsGetTextRegionBase(region, runProcess));
|
||||
}
|
||||
PrintExcInfo("\nusp = 0x%x", excBufAddr->USP);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
PrintExcInfo("\nklr = 0x%x\n"
|
||||
"ksp = 0x%x\n",
|
||||
excBufAddr->LR,
|
||||
@@ -417,7 +386,6 @@ EXC_PROC_FUNC OsExcRegHookGet(VOID)
|
||||
return g_excHook;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VOID OsDumpExcVaddrRegion(LosVmSpace *space, LosVmMapRegion *region)
|
||||
{
|
||||
INT32 i, numPages, pageCount;
|
||||
@@ -503,7 +471,6 @@ STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFalgs)
|
||||
OsDumpProcessUsedMemRegion(runProcess, runspace, vmmFalgs);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||
{
|
||||
@@ -526,31 +493,31 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID OsExcRestore(VOID)
|
||||
STATIC VOID OsExcRestore(UINTPTR taskStackPointer)
|
||||
{
|
||||
UINT32 currCpuID = ArchCurrCpuid();
|
||||
|
||||
g_excFromUserMode[currCpuID] = FALSE;
|
||||
g_intCount[currCpuID] = 0;
|
||||
g_curNestCount[currCpuID] = 0;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
OsPercpuGet()->excFlag = CPU_RUNNING;
|
||||
#endif
|
||||
OsPercpuGet()->taskLockCnt = 0;
|
||||
|
||||
OsSetCurrCpuSp(taskStackPointer);
|
||||
}
|
||||
|
||||
STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 currCpu = ArchCurrCpuid();
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
if (g_nextExcWaitCpu != INVALID_CPUID) {
|
||||
g_currHandleExcCpuID = g_nextExcWaitCpu;
|
||||
@@ -565,37 +532,21 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
#endif
|
||||
runProcess->processStatus &= ~OS_PROCESS_FLAG_EXIT;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsExcRestore(excBufAddr->SP);
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
OsWakeConsoleSendTask();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
BBoxNotifyError("USER_CRASH", MODULE_SYSTEM, "Crash in user", 0);
|
||||
#endif
|
||||
SCHEDULER_LOCK(intSave);
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
#ifdef LOSCFG_SHELL_EXCINFO
|
||||
OsProcessExitCodeCoreDumpSet(runProcess);
|
||||
#endif
|
||||
OsProcessExitCodeSignalSet(runProcess, SIGUSR2);
|
||||
|
||||
/* An exception was raised by a task that is not the current main thread during the exit process of
|
||||
* the current process.
|
||||
*/
|
||||
if ((runProcess->processStatus & OS_PROCESS_FLAG_EXIT) && (runProcess->threadGroupID != runTask->taskID)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
/* Exception handling All operations should be kept prior to that operation */
|
||||
OsExcRestore();
|
||||
OsTaskToExit(runTask, OS_PRO_EXIT_OK);
|
||||
} else {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
/* Exception handling All operations should be kept prior to that operation */
|
||||
OsExcRestore();
|
||||
/* kill user exc process */
|
||||
LOS_Exit(OS_PRO_EXIT_OK);
|
||||
}
|
||||
/* kill user exc process */
|
||||
LOS_Exit(OS_PRO_EXIT_OK);
|
||||
|
||||
/* User mode exception handling failed , which normally does not exist */
|
||||
g_curNestCount[currCpu]++;
|
||||
@@ -606,17 +557,18 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
/* this function is used to validate fp or validate the checking range start and end. */
|
||||
STATIC INLINE BOOL IsValidFP(UINTPTR regFP, UINTPTR start, UINTPTR end, vaddr_t *vaddr)
|
||||
{
|
||||
LosProcessCB *runProcess = NULL;
|
||||
LosVmSpace *runspace = NULL;
|
||||
VADDR_T kvaddr = regFP;
|
||||
PADDR_T paddr;
|
||||
|
||||
if (!((regFP > start) && (regFP < end) && IS_ALIGNED(regFP, sizeof(CHAR *)))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
PADDR_T paddr;
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
LosVmSpace *runspace = runProcess->vmSpace;
|
||||
runProcess = OsCurrProcessGet();
|
||||
runspace = runProcess->vmSpace;
|
||||
if (runspace == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -627,7 +579,6 @@ STATIC INLINE BOOL IsValidFP(UINTPTR regFP, UINTPTR start, UINTPTR end, vaddr_t
|
||||
|
||||
kvaddr = (PADDR_T)(UINTPTR)LOS_PaddrToKVaddr(paddr);
|
||||
}
|
||||
#endif
|
||||
if (vaddr != NULL) {
|
||||
*vaddr = kvaddr;
|
||||
}
|
||||
@@ -696,10 +647,8 @@ VOID BackTraceSub(UINTPTR regFP)
|
||||
UINTPTR stackStart, stackEnd;
|
||||
UINTPTR backFP = regFP;
|
||||
UINT32 count = 0;
|
||||
LosVmMapRegion *region = NULL;
|
||||
VADDR_T kvaddr;
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
#endif
|
||||
|
||||
if (FindSuitableStack(regFP, &stackStart, &stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback error fp = 0x%x\n", regFP);
|
||||
@@ -735,19 +684,14 @@ VOID BackTraceSub(UINTPTR regFP)
|
||||
}
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosVmMapRegion *region = NULL;
|
||||
if (LOS_IsUserAddress((VADDR_T)backLR) == TRUE) {
|
||||
region = LOS_RegionFind(runProcess->vmSpace, (VADDR_T)backLR);
|
||||
region = LOS_RegionFind(OsCurrProcessGet()->vmSpace, (VADDR_T)backLR);
|
||||
}
|
||||
if (region != NULL) {
|
||||
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x lr in %s --> 0x%x\n", count, backLR, backFP,
|
||||
OsGetRegionNameOrFilePath(region),
|
||||
backLR - OsGetTextRegionBase(region, runProcess));
|
||||
OsGetRegionNameOrFilePath(region), backLR - region->range.base);
|
||||
region = NULL;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
PrintExcInfo("traceback %u -- lr = 0x%x fp = 0x%x\n", count, backLR, backFP);
|
||||
}
|
||||
count++;
|
||||
@@ -782,9 +726,8 @@ VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr)
|
||||
#ifndef LOSCFG_DEBUG_VERSION
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] != TRUE) {
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
OsDumpProcessUsedMemNode(OS_EXC_VMM_NO_REGION);
|
||||
#endif
|
||||
|
||||
OsExcStackInfo();
|
||||
#ifndef LOSCFG_DEBUG_VERSION
|
||||
}
|
||||
@@ -844,7 +787,7 @@ VOID OsTaskBackTrace(UINT32 taskID)
|
||||
}
|
||||
PRINTK("TaskName = %s\n", taskCB->taskName);
|
||||
PRINTK("TaskID = 0x%x\n", taskCB->taskID);
|
||||
BackTrace(((TaskContext *)(taskCB->stackPointer))->R11); /* R11 : FP */
|
||||
BackTrace(((TaskContext *)(taskCB->stackPointer))->R[11]); /* R11 : FP */
|
||||
}
|
||||
|
||||
VOID OsBackTrace(VOID)
|
||||
@@ -914,7 +857,7 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
|
||||
#endif /* __LINUX_ARM_ARCH__ */
|
||||
#endif /* LOSCFG_GDB */
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#define EXC_WAIT_INTER 50U
|
||||
#define EXC_WAIT_TIME 2000U
|
||||
|
||||
@@ -963,6 +906,7 @@ STATIC VOID WaitAllCpuStop(UINT32 cpuID)
|
||||
|
||||
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
|
||||
{
|
||||
OsProcessSuspendAllTask();
|
||||
while (1) {
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
if ((g_currHandleExcCpuID == INVALID_CPUID) || (g_currHandleExcCpuID == currCpuID)) {
|
||||
@@ -980,7 +924,7 @@ STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
STATIC VOID OsCheckAllCpuStatus(UINTPTR taskStackPointer)
|
||||
{
|
||||
UINT32 currCpuID = ArchCurrCpuid();
|
||||
UINT32 ret, target;
|
||||
@@ -989,7 +933,6 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
LOCKDEP_CLEAR_LOCKS();
|
||||
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
/* Only the current nuclear anomaly */
|
||||
if (g_currHandleExcCpuID == INVALID_CPUID) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
g_currHandleExcPID = OsCurrProcessGet()->processID;
|
||||
@@ -999,20 +942,19 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
||||
}
|
||||
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
||||
/* Both cores raise exceptions, and the current core is a user-mode exception.
|
||||
* Both cores are abnormal and come from the same process
|
||||
*/
|
||||
if (OsCurrProcessGet()->processID == g_currHandleExcPID) {
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
OsExcRestore();
|
||||
ret = LOS_TaskDelete(OsCurrTaskGet()->taskID);
|
||||
LOS_Panic("%s supend task :%u failed: 0x%x\n", __FUNCTION__, OsCurrTaskGet()->taskID, ret);
|
||||
OsExcRestore(taskStackPointer);
|
||||
while (1) {
|
||||
ret = LOS_TaskSuspend(OsCurrTaskGet()->taskID);
|
||||
PrintExcInfo("%s supend task :%u failed: 0x%x\n", __FUNCTION__, OsCurrTaskGet()->taskID, ret);
|
||||
}
|
||||
}
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
|
||||
OsWaitOtherCoresHandleExcEnd(currCpuID);
|
||||
} else {
|
||||
if ((g_currHandleExcCpuID < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuID] == TRUE)) {
|
||||
if (g_excFromUserMode[g_currHandleExcCpuID] == TRUE) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
@@ -1030,17 +972,22 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsCheckCpuStatus(VOID)
|
||||
STATIC VOID OsCheckCpuStatus(UINTPTR taskStackPointer)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsCheckAllCpuStatus();
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
OsCheckAllCpuStatus(taskStackPointer);
|
||||
#else
|
||||
(VOID)taskStackPointer;
|
||||
g_currHandleExcCpuID = ArchCurrCpuid();
|
||||
#endif
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
UINT16 runCount;
|
||||
#endif
|
||||
|
||||
if ((excBufAddr->regCPSR & CPSR_MASK_MODE) == CPSR_USER_MODE) {
|
||||
g_minAddr = USER_ASPACE_BASE;
|
||||
g_maxAddr = USER_ASPACE_BASE + USER_ASPACE_SIZE;
|
||||
@@ -1051,9 +998,25 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
g_excFromUserMode[ArchCurrCpuid()] = FALSE;
|
||||
}
|
||||
|
||||
OsCheckCpuStatus();
|
||||
OsCheckCpuStatus(excBufAddr->SP);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
while (1) {
|
||||
OsProcessSuspendAllTask();
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
LOS_SpinLock(&g_taskSpin);
|
||||
runCount = OS_PROCESS_GET_RUNTASK_COUNT(OsCurrProcessGet()->processStatus);
|
||||
LOS_SpinUnlock(&g_taskSpin);
|
||||
if (runCount == 1) {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
/* Wait for the end of the Console task to avoid multicore printing code */
|
||||
OsWaitConsoleSendTaskPend(OsCurrTaskGet()->taskID);
|
||||
@@ -1063,45 +1026,26 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
|
||||
{
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
SetExcInfoIndex(0);
|
||||
#ifdef LOSCFG_DEBUG_VERSION
|
||||
LosVmSpace *space = NULL;
|
||||
VADDR_T vaddr;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
|
||||
/* You are not allowed to add any other print information before this exception information */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
#ifdef LOSCFG_DEBUG_VERSION
|
||||
VADDR_T vaddr = ROUNDDOWN(far, PAGE_SIZE);
|
||||
LosVmSpace *space = LOS_SpaceGet(vaddr);
|
||||
vaddr = ROUNDDOWN(far, PAGE_SIZE);
|
||||
space = LOS_SpaceGet(vaddr);
|
||||
if (space != NULL) {
|
||||
LOS_DumpMemRegion(vaddr);
|
||||
}
|
||||
#endif
|
||||
PrintExcInfo("##################excFrom: User!####################\n");
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
PrintExcInfo("##################excFrom: kernel!###################\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
STATIC VOID OsSysStateSave(UINT32 *intCount, UINT32 *lockCount)
|
||||
{
|
||||
*intCount = g_intCount[ArchCurrCpuid()];
|
||||
*lockCount = OsPercpuGet()->taskLockCnt;
|
||||
g_intCount[ArchCurrCpuid()] = 0;
|
||||
OsPercpuGet()->taskLockCnt = 0;
|
||||
}
|
||||
|
||||
STATIC VOID OsSysStateRestore(UINT32 intCount, UINT32 lockCount)
|
||||
{
|
||||
g_intCount[ArchCurrCpuid()] = intCount;
|
||||
OsPercpuGet()->taskLockCnt = lockCount;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Description : EXC handler entry
|
||||
* Input : excType --- exc type
|
||||
@@ -1109,11 +1053,6 @@ STATIC VOID OsSysStateRestore(UINT32 intCount, UINT32 lockCount)
|
||||
*/
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr)
|
||||
{
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
UINT32 intCount;
|
||||
UINT32 lockCount;
|
||||
#endif
|
||||
|
||||
/* Task scheduling is not allowed during exception handling */
|
||||
OsPercpuGet()->taskLockCnt++;
|
||||
|
||||
@@ -1123,24 +1062,22 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
|
||||
OsPrintExcHead(far);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
OsAllCpuStatusOutput();
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
#ifdef LOSCFG_SHELL_EXCINFO
|
||||
log_read_write_fn func = GetExcInfoRW();
|
||||
#endif
|
||||
|
||||
if (g_excHook != NULL) {
|
||||
if (g_curNestCount[ArchCurrCpuid()] == 1) {
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
#ifdef LOSCFG_SHELL_EXCINFO
|
||||
if (func != NULL) {
|
||||
#ifndef LOSCFG_BLACKBOX
|
||||
SetExcInfoIndex(0);
|
||||
#endif
|
||||
OsSysStateSave(&intCount, &lockCount);
|
||||
g_intCount[ArchCurrCpuid()] = 0;
|
||||
OsRecordExcInfoTime();
|
||||
OsSysStateRestore(intCount, lockCount);
|
||||
g_intCount[ArchCurrCpuid()] = 1;
|
||||
}
|
||||
#endif
|
||||
g_excHook(excType, excBufAddr, far, fsr);
|
||||
@@ -1148,15 +1085,18 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
OsCallStackInfo();
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
#ifdef LOSCFG_SHELL_EXCINFO
|
||||
if (func != NULL) {
|
||||
PrintExcInfo("Be sure flash space bigger than GetExcInfoIndex():0x%x\n", GetExcInfoIndex());
|
||||
OsSysStateSave(&intCount, &lockCount);
|
||||
g_intCount[ArchCurrCpuid()] = 0;
|
||||
func(GetRecordAddr(), GetRecordSpace(), 0, GetExcInfoBuf());
|
||||
OsSysStateRestore(intCount, lockCount);
|
||||
g_intCount[ArchCurrCpuid()] = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef LOSCFG_EXC_INTERACTION
|
||||
OsExcInteractionTaskKeep();
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_SHELL_CMD_DEBUG
|
||||
SystemRebootFunc rebootHook = OsGetRebootHook();
|
||||
@@ -1166,9 +1106,6 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
BBoxNotifyError(EVENT_PANIC, MODULE_SYSTEM, "Crash in kernel", 1);
|
||||
#endif
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
@@ -1179,11 +1116,10 @@ __attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
UartVprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
__asm__ __volatile__("swi 0");
|
||||
while (1);
|
||||
}
|
||||
|
||||
/* stack protector */
|
||||
USED UINT32 __stack_chk_guard = 0xd00a0dff;
|
||||
UINT32 __stack_chk_guard = 0xd00a0dff;
|
||||
|
||||
VOID __stack_chk_fail(VOID)
|
||||
{
|
||||
@@ -1215,11 +1151,7 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
framePtr = Get_Fp();
|
||||
while ((framePtr > stackStart) && (framePtr < stackEnd) && IS_ALIGNED(framePtr, sizeof(CHAR *))) {
|
||||
tmpFramePtr = framePtr;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
linkReg = *(UINTPTR *)(tmpFramePtr + sizeof(UINTPTR));
|
||||
#else
|
||||
linkReg = *(UINTPTR *)framePtr;
|
||||
#endif
|
||||
if (index >= jumpCount) {
|
||||
LR[count++] = linkReg;
|
||||
if (count == recordCount) {
|
||||
@@ -1227,11 +1159,7 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
}
|
||||
}
|
||||
index++;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
framePtr = *(UINTPTR *)framePtr;
|
||||
#else
|
||||
framePtr = *(UINTPTR *)(tmpFramePtr - sizeof(UINTPTR));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* if linkReg is not enough,clean up the last of the effective LR as the end. */
|
||||
@@ -1240,3 +1168,8 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
76
arch/arm/arm/src/los_hw.c
Normal file → Executable file
76
arch/arm/arm/src/los_hw.c
Normal file → Executable file
@@ -32,6 +32,12 @@
|
||||
#include "los_hw_pri.h"
|
||||
#include "los_task_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* support cpu vendors */
|
||||
CpuVendor g_cpuTable[] = {
|
||||
/* armv7-a */
|
||||
@@ -71,10 +77,13 @@ VOID OsTaskEntrySetupLoopFrame(UINT32 arg0)
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag)
|
||||
{
|
||||
UINT32 index = 1;
|
||||
TaskContext *taskContext = NULL;
|
||||
|
||||
if (initFlag == TRUE) {
|
||||
OsStackInit(topStack, stackSize);
|
||||
}
|
||||
TaskContext *taskContext = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
||||
taskContext = (TaskContext *)(((UINTPTR)topStack + stackSize) - sizeof(TaskContext));
|
||||
|
||||
/* initialize the task context */
|
||||
#ifdef LOSCFG_GDB
|
||||
@@ -83,17 +92,22 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
|
||||
taskContext->PC = (UINTPTR)OsTaskEntry;
|
||||
#endif
|
||||
taskContext->LR = (UINTPTR)OsTaskExit; /* LR should be kept, to distinguish it's THUMB or ARM instruction */
|
||||
taskContext->R0 = taskID; /* R0 */
|
||||
taskContext->resved = 0x0;
|
||||
taskContext->R[0] = taskID; /* R0 */
|
||||
taskContext->R[index++] = 0x01010101; /* R1, 0x01010101 : reg initialed magic word */
|
||||
for (; index < GEN_REGS_NUM; index++) {
|
||||
taskContext->R[index] = taskContext->R[index - 1] + taskContext->R[1]; /* R2 - R12 */
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_INTERWORK_THUMB
|
||||
taskContext->regCPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
|
||||
taskContext->regPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
|
||||
#else
|
||||
taskContext->regCPSR = PSR_MODE_SVC_ARM; /* CPSR (Enable IRQ and FIQ interrupts, ARM-mode) */
|
||||
taskContext->regPSR = PSR_MODE_SVC_ARM; /* CPSR (Enable IRQ and FIQ interrupts, ARM-mode) */
|
||||
#endif
|
||||
|
||||
#if !defined(LOSCFG_ARCH_FPU_DISABLE)
|
||||
/* 0xAAA0000000000000LL : float reg initialed magic word */
|
||||
for (UINT32 index = 0; index < FP_REGS_NUM; index++) {
|
||||
for (index = 0; index < FP_REGS_NUM; index++) {
|
||||
taskContext->D[index] = 0xAAA0000000000000LL + index; /* D0 - D31 */
|
||||
}
|
||||
taskContext->regFPSCR = 0;
|
||||
@@ -103,49 +117,58 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
|
||||
return (VOID *)taskContext;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
|
||||
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(LosTaskCB *childTaskCB, LosTaskCB *parentTaskCB)
|
||||
{
|
||||
VOID *cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
|
||||
TaskContext *context = (TaskContext *)childTaskCB->stackPointer;
|
||||
VOID *cloneStack = (VOID *)(((UINTPTR)parentTaskCB->topOfStack + parentTaskCB->stackSize) - sizeof(TaskContext));
|
||||
|
||||
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
|
||||
((TaskContext *)childStack)->R0 = 0;
|
||||
LOS_ASSERT(parentTaskCB->taskStatus & OS_TASK_STATUS_RUNNING);
|
||||
|
||||
(VOID)memcpy_s(childTaskCB->stackPointer, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
|
||||
context->R[0] = 0;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, TSK_ENTRY_FUNC taskEntry, UINTPTR stack)
|
||||
{
|
||||
LOS_ASSERT(context != NULL);
|
||||
|
||||
#ifdef LOSCFG_INTERWORK_THUMB
|
||||
context->regCPSR = PSR_MODE_USR_THUMB;
|
||||
context->regPSR = PSR_MODE_USR_THUMB;
|
||||
#else
|
||||
context->regCPSR = PSR_MODE_USR_ARM;
|
||||
context->regPSR = PSR_MODE_USR_ARM;
|
||||
#endif
|
||||
context->R0 = stack;
|
||||
context->USP = TRUNCATE(stack, LOSCFG_STACK_POINT_ALIGN_SIZE);
|
||||
context->ULR = 0;
|
||||
context->R[0] = stack;
|
||||
context->SP = TRUNCATE(stack, LOSCFG_STACK_POINT_ALIGN_SIZE);
|
||||
context->LR = 0;
|
||||
context->PC = (UINTPTR)taskEntry;
|
||||
}
|
||||
|
||||
VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param)
|
||||
VOID Sev(VOID)
|
||||
{
|
||||
IrqContext *newSp = (IrqContext *)signalContext;
|
||||
(VOID)memcpy_s(signalContext, sizeof(IrqContext), sp, sizeof(IrqContext));
|
||||
newSp->PC = sigHandler;
|
||||
newSp->R0 = signo;
|
||||
newSp->R1 = param;
|
||||
__asm__ __volatile__ ("sev" : : : "memory");
|
||||
}
|
||||
|
||||
DEPRECATED VOID Dmb(VOID)
|
||||
VOID Wfe(VOID)
|
||||
{
|
||||
__asm__ __volatile__ ("wfe" : : : "memory");
|
||||
}
|
||||
|
||||
VOID Wfi(VOID)
|
||||
{
|
||||
__asm__ __volatile__ ("wfi" : : : "memory");
|
||||
}
|
||||
|
||||
VOID Dmb(VOID)
|
||||
{
|
||||
__asm__ __volatile__ ("dmb" : : : "memory");
|
||||
}
|
||||
|
||||
DEPRECATED VOID Dsb(VOID)
|
||||
VOID Dsb(VOID)
|
||||
{
|
||||
__asm__ __volatile__("dsb" : : : "memory");
|
||||
}
|
||||
|
||||
DEPRECATED VOID Isb(VOID)
|
||||
VOID Isb(VOID)
|
||||
{
|
||||
__asm__ __volatile__("isb" : : : "memory");
|
||||
}
|
||||
@@ -169,3 +192,8 @@ VOID DCacheInvRange(UINT32 start, UINT32 end)
|
||||
arm_inv_cache_range(start, end);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
301
arch/arm/arm/src/los_hw_exc.S
Normal file → Executable file
301
arch/arm/arm/src/los_hw_exc.S
Normal file → Executable file
@@ -47,10 +47,9 @@
|
||||
.extern OsDataAbortExcHandleEntry
|
||||
#endif
|
||||
#endif
|
||||
.extern OsSaveSignalContext
|
||||
.extern OsRestorSignalContext
|
||||
.extern OsArmSharedPageFault
|
||||
.extern OsArmA32SyscallHandle
|
||||
.extern LOS_Exit
|
||||
|
||||
.global _osExceptFiqHdl
|
||||
.global _osExceptAddrAbortHdl
|
||||
@@ -64,6 +63,7 @@
|
||||
.global __stack_chk_guard_setup
|
||||
#endif
|
||||
|
||||
|
||||
.fpu vfpv4
|
||||
|
||||
.macro PUSH_FPU_REGS reg1
|
||||
@@ -173,77 +173,67 @@ _osExceptUndefInstrHdl:
|
||||
#ifdef LOSCFG_GDB
|
||||
GDB_HANDLE OsUndefIncExcHandleEntry
|
||||
#else
|
||||
SRSFD #CPSR_SVC_MODE! @ Save pc and cpsr to svc sp, ARMv6 and above support
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to svc mode, and disable all interrupt
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
STMFD SP, {R13, R14}^ @ push user sp and lr
|
||||
SUB SP, SP, #(2 * 4)
|
||||
MOV R2, #0
|
||||
MOV R3, #0
|
||||
STMFD SP!, {R2-R3} @ far and fsr fields, are 0 under this anomaly
|
||||
STMFD SP!, {R4-R11}
|
||||
@ LR offset to return from this exception: 0.
|
||||
STMFD SP, {R0-R7} @ Push working registers, but don`t change SP.
|
||||
|
||||
MOV R0, #OS_EXCEPT_UNDEF_INSTR @ Set exception ID to OS_EXCEPT_UNDEF_INSTR.
|
||||
|
||||
B _osExceptDispatch @ Branch to global exception handler.
|
||||
|
||||
#endif
|
||||
|
||||
@ Description: Software interrupt exception handler
|
||||
_osExceptSwiHdl:
|
||||
SRSFD #CPSR_SVC_MODE! @ Save pc and cpsr to svc sp, ARMv6 and above support
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
STMFD SP, {R13, R14}^
|
||||
SUB SP, SP, #(4 * 4) @ push user sp and lr and jump reserved field
|
||||
STR R7, [SP, #0] @ Save system call number to reserved2 filed
|
||||
SUB SP, SP, #(4 * 16)
|
||||
STMIA SP, {R0-R12}
|
||||
MRS R3, SPSR
|
||||
MOV R4, LR
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SYSCALL
|
||||
LDR R3, [SP, #(11 * 4)]
|
||||
AND R1, R3, #CPSR_MASK_MODE @ Interrupted mode
|
||||
CMP R1, #CPSR_USER_MODE @ User mode
|
||||
BNE _osKernelSVCHandler @ Branch if not user mode
|
||||
AND R1, R3, #CPSR_MASK_MODE @ Interrupted mode
|
||||
CMP R1, #CPSR_USER_MODE @ User mode
|
||||
BNE OsKernelSVCHandler @ Branch if not user mode
|
||||
|
||||
CMP R7, #119 @ __NR_sigreturn
|
||||
BNE _osIsSyscall
|
||||
@ we enter from user mode, we need get the values of USER mode r13(sp) and r14(lr).
|
||||
@ stmia with ^ will return the user mode registers (provided that r15 is not in the register list).
|
||||
MOV R0, SP
|
||||
BLX OsRestorSignalContext
|
||||
MOV SP, R0
|
||||
B _osSyscallReturn
|
||||
|
||||
_osIsSyscall:
|
||||
STMFD SP!, {R4-R11}
|
||||
|
||||
STMFD SP!, {R3} @ Save the CPSR
|
||||
ADD R3, SP, #(4 * 17) @ Offset to pc/cpsr storage
|
||||
STMFD R3!, {R4} @ Save the CPSR and r15(pc)
|
||||
STMFD R3, {R13, R14}^ @ Save user mode r13(sp) and r14(lr)
|
||||
SUB SP, SP, #4
|
||||
PUSH_FPU_REGS R1
|
||||
|
||||
MOV R0, SP
|
||||
MOV FP, #0 @ Init frame pointer
|
||||
MOV FP, #0 @ Init frame pointer
|
||||
CPSIE I
|
||||
BLX OsArmA32SyscallHandle
|
||||
CPSID I
|
||||
|
||||
POP_FPU_REGS R1
|
||||
LDMFD SP!, {R4-R11}
|
||||
ADD SP, SP,#4
|
||||
LDMFD SP!, {R3} @ Fetch the return SPSR
|
||||
MSR SPSR_cxsf, R3 @ Set the return mode SPSR
|
||||
|
||||
MOV R0, SP
|
||||
SUB SP, SP, #(12 * 4) @ sp - sizeof(IrqContext), reserved for signal
|
||||
MOV R1, SP
|
||||
BLX OsSaveSignalContext
|
||||
MOV SP, R0
|
||||
@ we are leaving to user mode, we need to restore the values of USER mode r13(sp) and r14(lr).
|
||||
@ ldmia with ^ will return the user mode registers (provided that r15 is not in the register list)
|
||||
|
||||
_osSyscallReturn:
|
||||
LDR R7, [SP, #0]
|
||||
ADD SP, SP, #(2 * 4) @ jump reserved filed
|
||||
LDMFD SP!, {R0-R12}
|
||||
LDMFD SP, {R13, R14}^ @ Restore user mode R13/R14
|
||||
ADD SP, SP, #(2 * 4)
|
||||
LDMFD SP!, {R0-R3, R12, LR}
|
||||
RFEIA SP! @ Return to user
|
||||
LDMFD SP!, {PC}^ @ Return to user
|
||||
|
||||
OsKernelSVCHandler:
|
||||
ADD R0, SP, #(4 * 16)
|
||||
MOV R5, R0
|
||||
STMFD R0!, {R4} @ Store PC
|
||||
STMFD R0!, {R4}
|
||||
STMFD R0!, {R5}
|
||||
|
||||
STMFD SP!, {R3} @ Push task`s CPSR (i.e. exception SPSR).
|
||||
SUB SP, SP, #(4 * 2) @ user sp and lr
|
||||
|
||||
_osKernelSVCHandler:
|
||||
#endif
|
||||
MOV R0, #0
|
||||
STR R0, [SP, #0]
|
||||
STR R0, [SP, #4]
|
||||
STMFD SP!, {R4-R11}
|
||||
MOV R0, #OS_EXCEPT_SWI @ Set exception ID to OS_EXCEPT_SWI.
|
||||
B _osExceptDispatch @ Branch to global exception handler.
|
||||
|
||||
B _osExceptionSwi @ Branch to global exception handler.
|
||||
|
||||
@ Description: Prefectch abort exception handler
|
||||
_osExceptPrefetchAbortHdl:
|
||||
@@ -253,37 +243,18 @@ _osExceptPrefetchAbortHdl:
|
||||
#endif
|
||||
#else
|
||||
SUB LR, LR, #4 @ LR offset to return from this exception: -4.
|
||||
STMFD SP, {R0-R7} @ Push working registers, but don`t change SP.
|
||||
MOV R5, LR
|
||||
MRS R1, SPSR
|
||||
|
||||
SRSFD #CPSR_SVC_MODE! @ Save pc and cpsr to svc sp, ARMv6 and above support
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to svc mode, and disable all interrupt
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
STMFD SP, {R13, R14}^
|
||||
SUB SP, SP, #(2 * 4)
|
||||
MOV R0, #OS_EXCEPT_PREFETCH_ABORT @ Set exception ID to OS_EXCEPT_PREFETCH_ABORT.
|
||||
|
||||
MRC P15, 0, R2, C6, C0, 2
|
||||
MRC P15, 0, R3, C5, C0, 1
|
||||
STMFD SP!, {R2-R3} @ Save far and fsr
|
||||
STMFD SP!, {R4-R11}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LDR R0, [SP, #(19 * 4)]
|
||||
AND R0, R0, #CPSR_MASK_MODE @ Interrupted mode
|
||||
CMP R0, #CPSR_USER_MODE @ User mode
|
||||
BNE _osKernelExceptPrefetchAbortHdl
|
||||
|
||||
MOV R1, SP
|
||||
PUSH_FPU_REGS R0
|
||||
|
||||
MOV R0, #OS_EXCEPT_PREFETCH_ABORT
|
||||
BLX OsArmSharedPageFault
|
||||
CMP R0, #0
|
||||
|
||||
POP_FPU_REGS R0
|
||||
BEQ _osExcPageFaultReturn
|
||||
#endif
|
||||
AND R4, R1, #CPSR_MASK_MODE @ Interrupted mode
|
||||
CMP R4, #CPSR_USER_MODE @ User mode
|
||||
BEQ _osExcPageFault @ Branch if user mode
|
||||
|
||||
_osKernelExceptPrefetchAbortHdl:
|
||||
MOV R0, #OS_EXCEPT_PREFETCH_ABORT
|
||||
MOV LR, R5
|
||||
B _osExceptDispatch @ Branch to global exception handler.
|
||||
#endif
|
||||
|
||||
@@ -295,105 +266,118 @@ _osExceptDataAbortHdl:
|
||||
#endif
|
||||
#else
|
||||
SUB LR, LR, #8 @ LR offset to return from this exception: -8.
|
||||
STMFD SP, {R0-R7} @ Push working registers, but don`t change SP.
|
||||
MOV R5, LR
|
||||
MRS R1, SPSR
|
||||
|
||||
SRSFD #CPSR_SVC_MODE! @ Save pc and cpsr to svc sp, ARMv6 and above support
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to svc mode, and disable all interrupt
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
STMFD SP, {R13, R14}^
|
||||
SUB SP, SP, #(2 * 4)
|
||||
MOV R0, #OS_EXCEPT_DATA_ABORT @ Set exception ID to OS_EXCEPT_DATA_ABORT.
|
||||
|
||||
MRC P15, 0, R2, C6, C0, 0
|
||||
MRC P15, 0, R3, C5, C0, 0
|
||||
STMFD SP!, {R2-R3} @ Save far and fsr
|
||||
STMFD SP!, {R4-R11}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
MOV R1, SP
|
||||
PUSH_FPU_REGS R0
|
||||
|
||||
MOV R0, #OS_EXCEPT_DATA_ABORT @ Set exception ID to OS_EXCEPT_DATA_ABORT.
|
||||
BLX OsArmSharedPageFault
|
||||
CMP R0, #0
|
||||
POP_FPU_REGS R0
|
||||
BEQ _osExcPageFaultReturn
|
||||
#endif
|
||||
|
||||
MOV R0, #OS_EXCEPT_DATA_ABORT
|
||||
B _osExceptDispatch
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
_osExcPageFaultReturn:
|
||||
LDMFD SP!, {R4-R11}
|
||||
|
||||
MOV R0, SP
|
||||
STR R7, [SP, #0]
|
||||
SUB SP, SP, #(12 * 4) @ sp - sizeof(IrqContext), reserved for signal
|
||||
MOV R1, SP
|
||||
BLX OsSaveSignalContext
|
||||
MOV SP, R0
|
||||
|
||||
ADD SP, SP, #(2 * 4)
|
||||
LDMFD SP, {R13, R14}^
|
||||
ADD SP, SP, #(2 * 4) @ Jump reserved fileds
|
||||
LDMFD SP!, {R0-R3, R12, LR}
|
||||
RFEIA SP!
|
||||
B _osExcPageFault
|
||||
#endif
|
||||
|
||||
@ Description: Address abort exception handler
|
||||
_osExceptAddrAbortHdl:
|
||||
SUB LR, LR, #8 @ LR offset to return from this exception: -8.
|
||||
|
||||
SRSFD #CPSR_SVC_MODE! @ Save pc and cpsr to svc sp, ARMv6 and above support
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to svc mode, and disable all interrupt
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
STMFD SP, {R13, R14}^
|
||||
SUB SP, SP, #(2 * 4)
|
||||
|
||||
MOV R2, #0
|
||||
MOV R3, #0
|
||||
STMFD SP!, {R2-R3} @ far and fsr fields, are 0 under this anomaly
|
||||
STMFD SP!, {R4-R11}
|
||||
STMFD SP, {R0-R7} @ Push working registers, but don`t change SP.
|
||||
|
||||
MOV R0, #OS_EXCEPT_ADDR_ABORT @ Set exception ID to OS_EXCEPT_ADDR_ABORT.
|
||||
|
||||
B _osExceptDispatch @ Branch to global exception handler.
|
||||
|
||||
@ Description: Fast interrupt request exception handler
|
||||
_osExceptFiqHdl:
|
||||
SUB LR, LR, #4 @ LR offset to return from this exception: -4.
|
||||
STMFD SP, {R0-R7} @ Push working registers.
|
||||
|
||||
SRSFD #CPSR_SVC_MODE! @ Save pc and cpsr to svc sp, ARMv6 and above support
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to svc mode, and disable all interrupt
|
||||
STMFD SP!, {R0-R3, R12, LR}
|
||||
STMFD SP, {R13, R14}^
|
||||
SUB SP, SP, #(2 * 4)
|
||||
MOV R0, #OS_EXCEPT_FIQ @ Set exception ID to OS_EXCEPT_FIQ.
|
||||
|
||||
MOV R2, #0
|
||||
MOV R3, #0
|
||||
STMFD SP!, {R2-R3} @ far and fsr fields, are 0 under this anomaly
|
||||
B _osExceptDispatch @ Branch to global exception handler.
|
||||
|
||||
_osExcPageFault:
|
||||
SUB R3, SP, #(8 * 4) @ Save the start address of working registers.
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to SVC mode, and disable all interrupts
|
||||
MOV R2, SP
|
||||
STMFD SP!, {R5} @ Push original PC
|
||||
STMFD SP!, {LR} @ Push original svc LR
|
||||
STMFD SP!, {R2} @ Push original svc SP
|
||||
STMFD SP!, {R8-R12} @ Push original R12-R8,
|
||||
LDMFD R3!, {R4-R11} @ Move original R7-R0 from exception stack to original stack.
|
||||
STMFD SP!, {R4-R11}
|
||||
STMFD SP!, {R1}
|
||||
SUB SP, SP, #8
|
||||
STMIA SP, {R13, R14}^ @ Save user mode r13(sp) and r14(lr)
|
||||
|
||||
MOV R4, SP
|
||||
BIC SP, SP, #7
|
||||
PUSH_FPU_REGS R1
|
||||
|
||||
CMP R0, #OS_EXCEPT_DATA_ABORT
|
||||
BNE 1f
|
||||
MRC P15, 0, R2, C6, C0, 0
|
||||
MRC P15, 0, R3, C5, C0, 0
|
||||
B 2f
|
||||
1: MRC P15, 0, R2, C6, C0, 2
|
||||
MRC P15, 0, R3, C5, C0, 1
|
||||
|
||||
2: MOV R1, R4
|
||||
MOV R5, R0
|
||||
MOV R8, R2
|
||||
MOV R9, R3
|
||||
CPSIE I
|
||||
BLX OsArmSharedPageFault
|
||||
CPSID I
|
||||
|
||||
POP_FPU_REGS R1
|
||||
MOV SP, R4
|
||||
CMP R0, #0
|
||||
BEQ _OsExcReturn
|
||||
|
||||
MOV R0, R5 @ exc type
|
||||
B _osExceptionSwi
|
||||
|
||||
@ Description: Exception handler
|
||||
@ Parameter : R0 Exception Type
|
||||
@ Regs Hold : R3 Exception`s CPSR
|
||||
_osExceptDispatch:
|
||||
LDR R8, [SP, #(8 * 4)] @ Get far
|
||||
LDR R9, [SP, #(9 * 4)] @ Get fsr
|
||||
|
||||
ADD R2, SP, #(20 * 4) @ sp + sizeof(ExcContext), position of SVC stack before exception
|
||||
STR R2, [SP, #(8 * 4)] @ Save svc sp
|
||||
|
||||
MOV R1, SP
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LDR R2, [SP, #(19 * 4)] @ Get CPSR
|
||||
AND R2, R2, #CPSR_MASK_MODE @ Interrupted mode
|
||||
CMP R2, #CPSR_USER_MODE @ User mode
|
||||
BEQ _osExceptionGetSP
|
||||
#endif
|
||||
MRS R2, SPSR @ Save CPSR before exception.
|
||||
MOV R1, LR @ Save PC before exception.
|
||||
SUB R3, SP, #(8 * 4) @ Save the start address of working registers.
|
||||
|
||||
MSR CPSR_c, #(CPSR_INT_DISABLE | CPSR_SVC_MODE) @ Switch to SVC mode, and disable all interrupts
|
||||
MOV R5, SP
|
||||
EXC_SP_SET __exc_stack_top, OS_EXC_STACK_SIZE, R6, R7
|
||||
|
||||
STMFD SP!, {R1} @ Push Exception PC
|
||||
STMFD SP!, {LR} @ Push SVC LR
|
||||
STMFD SP!, {R5} @ Push SVC SP
|
||||
STMFD SP!, {R8-R12} @ Push original R12-R8,
|
||||
LDMFD R3!, {R4-R11} @ Move original R7-R0 from exception stack to original stack.
|
||||
STMFD SP!, {R4-R11}
|
||||
STMFD SP!, {R2} @ Push task`s CPSR (i.e. exception SPSR).
|
||||
|
||||
CMP R0, #OS_EXCEPT_DATA_ABORT
|
||||
BNE 1f
|
||||
MRC P15, 0, R8, C6, C0, 0
|
||||
MRC P15, 0, R9, C5, C0, 0
|
||||
B 3f
|
||||
1: CMP R0, #OS_EXCEPT_PREFETCH_ABORT
|
||||
BNE 2f
|
||||
MRC P15, 0, R8, C6, C0, 2
|
||||
MRC P15, 0, R9, C5, C0, 1
|
||||
B 3f
|
||||
2: MOV R8, #0
|
||||
MOV R9, #0
|
||||
|
||||
3: AND R2, R2, #CPSR_MASK_MODE
|
||||
CMP R2, #CPSR_USER_MODE @ User mode
|
||||
BNE 4f
|
||||
STMFD SP, {R13, R14}^ @ save user mode sp and lr
|
||||
4:
|
||||
SUB SP, SP, #(4 * 2)
|
||||
|
||||
_osExceptionSwi:
|
||||
MOV R1, SP @ The second argument to the exception
|
||||
|
||||
MRC P15, 0, R4, C0, C0, 5
|
||||
AND R4, R4, #MPIDR_CPUID_MASK @ Get Current cpu id
|
||||
LSL R2, R4, #2
|
||||
@@ -421,4 +405,19 @@ _osExceptionGetSP:
|
||||
LDR R5, =OsExcHandleEntry @ OsExcHandleEntry(UINT32 excType, ExcContext * excBufAddr)
|
||||
BX R5
|
||||
|
||||
_OsExcReturn:
|
||||
LDR R0, [SP, #(2 * 4)]
|
||||
AND R0, R0, #CPSR_MASK_MODE
|
||||
CMP R0, #CPSR_USER_MODE @ User mode
|
||||
BNE _OsExcReturnToKernel
|
||||
LDMFD SP, {R13, R14}^ @ load user mode sp and lr
|
||||
|
||||
_OsExcReturnToKernel:
|
||||
ADD SP, SP, #(2 * 4)
|
||||
LDMFD SP!, {R1}
|
||||
MSR SPSR_cxsf, R1 @ Set the return mode SPSR
|
||||
LDMFD SP!, {R0-R12}
|
||||
ADD SP, SP, #4
|
||||
LDMFD SP!, {LR, PC}^
|
||||
|
||||
.end
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
#include "los_sys_pri.h"
|
||||
#include "los_hwi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsTickInit(UINT32 systemClock, UINT32 tickPerSecond)
|
||||
{
|
||||
@@ -60,8 +65,10 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_GetCpuCycle(UINT32 *highCnt, UINT32 *lowCnt)
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR UINT64 LOS_CurrNanosec(VOID)
|
||||
{
|
||||
UINT64 cycle = HalClockGetCycles();
|
||||
return (cycle / g_sysClock) * OS_SYS_NS_PER_SECOND + (cycle % g_sysClock) * OS_SYS_NS_PER_SECOND / g_sysClock;
|
||||
DOUBLE nanos;
|
||||
|
||||
nanos = (DOUBLE)HalClockGetCycles() * OS_SYS_NS_PER_SECOND / g_sysClock;
|
||||
return (UINT64)nanos;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_Udelay(UINT32 usecs)
|
||||
@@ -74,3 +81,8 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_Mdelay(UINT32 msecs)
|
||||
HalDelayUs(msecs * 1000); /* 1000 : 1ms = 1000us */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
#endif
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* spinlock for hwi module, only available on SMP mode */
|
||||
LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
|
||||
@@ -347,3 +352,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_HwiDelete(HWI_HANDLE_T hwiNum, HwiIrqParam *irq
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
70
arch/arm/arm/src/startup/reset_vector_mp.S
Normal file → Executable file
70
arch/arm/arm/src/startup/reset_vector_mp.S
Normal file → Executable file
@@ -37,9 +37,17 @@
|
||||
|
||||
|
||||
.global __exc_stack_top
|
||||
.global __irq_stack_top
|
||||
.global __fiq_stack_top
|
||||
.global __svc_stack_top
|
||||
.global __abt_stack_top
|
||||
.global __undef_stack_top
|
||||
.global __exc_stack
|
||||
.global __irq_stack
|
||||
.global __fiq_stack
|
||||
.global __svc_stack
|
||||
.global __abt_stack
|
||||
.global __undef_stack
|
||||
|
||||
.extern __bss_start
|
||||
.extern __bss_end
|
||||
@@ -107,9 +115,9 @@ __exception_handlers:
|
||||
.global reset_vector
|
||||
.type reset_vector,function
|
||||
|
||||
#ifdef LOSCFG_BOOTENV_RAM
|
||||
#ifdef LOSCFG_QUICK_START
|
||||
__quickstart_args_start:
|
||||
.fill LOSCFG_BOOTENV_RAMSIZE,1,0
|
||||
.fill 512,1,0
|
||||
__quickstart_args_end:
|
||||
|
||||
.global OsGetArgsAddr
|
||||
@@ -176,7 +184,6 @@ reloc_img_to_bottom_loop:
|
||||
sub r11, r11, r12 /* r11: eventual address offset */
|
||||
|
||||
reloc_img_to_bottom_done:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it */
|
||||
add r4, r4, r11
|
||||
mov r0, r4
|
||||
@@ -205,20 +212,41 @@ reloc_img_to_bottom_done:
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
|
||||
rsb r7, r11, r6, lsl #20 /* r7: va */
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||
#endif
|
||||
|
||||
bl _bootaddr_setup
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
|
||||
bl mmu_setup /* set up the mmu */
|
||||
#endif
|
||||
|
||||
/* clear out the interrupt and exception stack and set magic num to check the overflow */
|
||||
ldr r0, =__svc_stack
|
||||
ldr r0, =__undef_stack
|
||||
ldr r1, =__exc_stack_top
|
||||
bl stack_init
|
||||
|
||||
STACK_MAGIC_SET __undef_stack, #OS_EXC_UNDEF_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __abt_stack, #OS_EXC_ABT_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __irq_stack, #OS_EXC_IRQ_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __fiq_stack, #OS_EXC_FIQ_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __svc_stack, #OS_EXC_SVC_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __exc_stack, #OS_EXC_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
|
||||
warm_reset:
|
||||
/* initialize interrupt/exception environments */
|
||||
mov r0, #(CPSR_IRQ_DISABLE |CPSR_FIQ_DISABLE|CPSR_IRQ_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __irq_stack_top, #OS_EXC_IRQ_STACK_SIZE
|
||||
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_UNDEF_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __undef_stack_top, #OS_EXC_UNDEF_STACK_SIZE
|
||||
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_ABT_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __abt_stack_top, #OS_EXC_ABT_STACK_SIZE
|
||||
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_FIQ_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __fiq_stack_top, #OS_EXC_FIQ_STACK_SIZE
|
||||
|
||||
/* initialize CPSR (machine state register) */
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SVC_MODE)
|
||||
msr cpsr, r0
|
||||
@@ -266,7 +294,7 @@ clear_bss:
|
||||
|
||||
_start_hang:
|
||||
b _start_hang
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
|
||||
mmu_setup:
|
||||
mov r12, #0
|
||||
mcr p15, 0, r12, c8, c7, 0 /* Set c8 to control the TLB and set the mapping to invalid */
|
||||
@@ -302,7 +330,7 @@ mmu_setup:
|
||||
isb
|
||||
sub lr, r11 /* adjust lr with delta of physical address and virtual address */
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
.code 32
|
||||
|
||||
.global reset_platform
|
||||
@@ -318,7 +346,6 @@ reset_platform:
|
||||
mov pc, r0 // Jump to reset vector
|
||||
#endif
|
||||
cpu_start:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4 = physical address of translation table and clear it */
|
||||
add r4, r4, r11
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS
|
||||
@@ -329,7 +356,6 @@ cpu_start:
|
||||
add r4, r4, r11 /* r4 = tt_trampoline paddr */
|
||||
|
||||
bl mmu_setup
|
||||
#endif
|
||||
bl secondary_cpu_start
|
||||
b .
|
||||
|
||||
@@ -368,7 +394,6 @@ sp_set:
|
||||
* r10: flags
|
||||
* r9 and r12 will be used as variable
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
@@ -387,7 +412,7 @@ page_table_build_loop:
|
||||
subs r8, #1 /* sizes-- */
|
||||
bne page_table_build_loop
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
/*
|
||||
* init stack to initial value
|
||||
* r0 is stack mem start, r1 is stack mem end
|
||||
@@ -440,7 +465,6 @@ _bootaddr_setup:
|
||||
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
vdup.8 q0, r1
|
||||
@@ -452,7 +476,7 @@ memset_optimized_loop:
|
||||
vstmia r3!, {d0 - d7}
|
||||
bge memset_optimized_loop
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
init_done:
|
||||
.long 0xDEADB00B
|
||||
|
||||
@@ -469,6 +493,22 @@ init_flag:
|
||||
.section ".int_stack", "wa", %nobits
|
||||
.align 3
|
||||
|
||||
__undef_stack:
|
||||
.space OS_EXC_UNDEF_STACK_SIZE * CORE_NUM
|
||||
__undef_stack_top:
|
||||
|
||||
__abt_stack:
|
||||
.space OS_EXC_ABT_STACK_SIZE * CORE_NUM
|
||||
__abt_stack_top:
|
||||
|
||||
__irq_stack:
|
||||
.space OS_EXC_IRQ_STACK_SIZE * CORE_NUM
|
||||
__irq_stack_top:
|
||||
|
||||
__fiq_stack:
|
||||
.space OS_EXC_FIQ_STACK_SIZE * CORE_NUM
|
||||
__fiq_stack_top:
|
||||
|
||||
__svc_stack:
|
||||
.space OS_EXC_SVC_STACK_SIZE * CORE_NUM
|
||||
__svc_stack_top:
|
||||
|
||||
60
arch/arm/arm/src/startup/reset_vector_up.S
Normal file → Executable file
60
arch/arm/arm/src/startup/reset_vector_up.S
Normal file → Executable file
@@ -38,9 +38,17 @@
|
||||
|
||||
|
||||
.global __exc_stack_top
|
||||
.global __irq_stack_top
|
||||
.global __fiq_stack_top
|
||||
.global __svc_stack_top
|
||||
.global __abt_stack_top
|
||||
.global __undef_stack_top
|
||||
.global __exc_stack
|
||||
.global __irq_stack
|
||||
.global __fiq_stack
|
||||
.global __svc_stack
|
||||
.global __abt_stack
|
||||
.global __undef_stack
|
||||
|
||||
.extern __bss_start
|
||||
.extern __bss_end
|
||||
@@ -153,7 +161,6 @@ reloc_img_to_bottom_loop:
|
||||
sub r11, r11, r12 /* r11: eventual address offset */
|
||||
|
||||
reloc_img_to_bottom_done:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4: physical address of translation table and clear it */
|
||||
add r4, r4, r11
|
||||
mov r0, r4
|
||||
@@ -161,6 +168,7 @@ reloc_img_to_bottom_done:
|
||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||
|
||||
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
||||
@@ -184,7 +192,7 @@ reloc_img_to_bottom_done:
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||
|
||||
bl mmu_setup /* set up the mmu */
|
||||
#endif
|
||||
|
||||
/* get cpuid and keep it in r11 */
|
||||
mrc p15, 0, r11, c0, c0, 5
|
||||
and r11, r11, #MPIDR_CPUID_MASK
|
||||
@@ -193,15 +201,36 @@ reloc_img_to_bottom_done:
|
||||
|
||||
excstatck_loop:
|
||||
/* clear out the interrupt and exception stack and set magic num to check the overflow */
|
||||
ldr r0, =__svc_stack
|
||||
ldr r0, =__undef_stack
|
||||
ldr r1, =__exc_stack_top
|
||||
bl stack_init
|
||||
|
||||
STACK_MAGIC_SET __undef_stack, #OS_EXC_UNDEF_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __abt_stack, #OS_EXC_ABT_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __irq_stack, #OS_EXC_IRQ_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __fiq_stack, #OS_EXC_FIQ_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __svc_stack, #OS_EXC_SVC_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
STACK_MAGIC_SET __exc_stack, #OS_EXC_STACK_SIZE, OS_STACK_MAGIC_WORD
|
||||
|
||||
excstatck_loop_done:
|
||||
warm_reset:
|
||||
/* initialize interrupt/exception environments */
|
||||
mov r0, #(CPSR_IRQ_DISABLE |CPSR_FIQ_DISABLE|CPSR_IRQ_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __irq_stack_top, #OS_EXC_IRQ_STACK_SIZE
|
||||
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_UNDEF_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __undef_stack_top, #OS_EXC_UNDEF_STACK_SIZE
|
||||
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_ABT_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __abt_stack_top, #OS_EXC_ABT_STACK_SIZE
|
||||
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_FIQ_MODE)
|
||||
msr cpsr, r0
|
||||
EXC_SP_SET __fiq_stack_top, #OS_EXC_FIQ_STACK_SIZE
|
||||
|
||||
/* initialize CPSR (machine state register) */
|
||||
mov r0, #(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SVC_MODE)
|
||||
msr cpsr, r0
|
||||
@@ -258,7 +287,6 @@ clear_bss:
|
||||
_start_hang:
|
||||
b _start_hang
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
mmu_setup:
|
||||
mov r12, #0
|
||||
mcr p15, 0, r12, c8, c7, 0 /* Set c8 to control the TLB and set the mapping to invalid */
|
||||
@@ -295,7 +323,7 @@ mmu_setup:
|
||||
|
||||
sub lr, r11 /* adjust lr with delta of physical address and virtual address */
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
.code 32
|
||||
|
||||
.global reset_platform
|
||||
@@ -334,7 +362,6 @@ sp_set:
|
||||
* r10: flags
|
||||
* r9 and r12 will be used as variable
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
@@ -353,7 +380,7 @@ page_table_build_loop:
|
||||
subs r8, #1 /* sizes-- */
|
||||
bne page_table_build_loop
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
/*
|
||||
* init stack to initial value
|
||||
* r0 is stack mem start, r1 is stack mem end
|
||||
@@ -406,7 +433,6 @@ _bootaddr_setup:
|
||||
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
vdup.8 q0, r1
|
||||
@@ -418,7 +444,7 @@ memset_optimized_loop:
|
||||
vstmia r3!, {d0 - d7}
|
||||
bge memset_optimized_loop
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
init_done:
|
||||
.long 0xDEADB00B
|
||||
|
||||
@@ -435,6 +461,22 @@ init_flag:
|
||||
.section ".int_stack", "wa", %nobits
|
||||
.align 3
|
||||
|
||||
__undef_stack:
|
||||
.space OS_EXC_UNDEF_STACK_SIZE * CORE_NUM
|
||||
__undef_stack_top:
|
||||
|
||||
__abt_stack:
|
||||
.space OS_EXC_ABT_STACK_SIZE * CORE_NUM
|
||||
__abt_stack_top:
|
||||
|
||||
__irq_stack:
|
||||
.space OS_EXC_IRQ_STACK_SIZE * CORE_NUM
|
||||
__irq_stack_top:
|
||||
|
||||
__fiq_stack:
|
||||
.space OS_EXC_FIQ_STACK_SIZE * CORE_NUM
|
||||
__fiq_stack_top:
|
||||
|
||||
__svc_stack:
|
||||
.space OS_EXC_SVC_STACK_SIZE * CORE_NUM
|
||||
__svc_stack_top:
|
||||
|
||||
10
arch/arm/arm/src/strncpy_from_user.c
Normal file → Executable file
10
arch/arm/arm/src/strncpy_from_user.c
Normal file → Executable file
@@ -33,6 +33,11 @@
|
||||
#include "los_user_get.h"
|
||||
#include "los_vm_map.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INT32 LOS_StrncpyFromUser(CHAR *dst, const CHAR *src, INT32 count)
|
||||
{
|
||||
@@ -62,3 +67,8 @@ INT32 LOS_StrncpyFromUser(CHAR *dst, const CHAR *src, INT32 count)
|
||||
return offset;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
10
arch/arm/arm/src/strnlen_user.c
Normal file → Executable file
10
arch/arm/arm/src/strnlen_user.c
Normal file → Executable file
@@ -33,6 +33,11 @@
|
||||
#include "los_user_get.h"
|
||||
#include "los_vm_map.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INT32 LOS_StrnlenUser(const CHAR *src, INT32 count)
|
||||
{
|
||||
@@ -61,3 +66,8 @@ INT32 LOS_StrnlenUser(const CHAR *src, INT32 count)
|
||||
return count + 1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
21
arch/arm/arm/src/user_copy.c
Normal file → Executable file
21
arch/arm/arm/src/user_copy.c
Normal file → Executable file
@@ -31,11 +31,15 @@
|
||||
|
||||
#include "user_copy.h"
|
||||
#include "arm_user_copy.h"
|
||||
#include "arm_user_clear.h"
|
||||
#include "securec.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_vm_map.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
size_t arch_copy_from_user(void *dst, const void *src, size_t len)
|
||||
{
|
||||
@@ -97,11 +101,22 @@ INT32 LOS_UserMemClear(unsigned char *buf, UINT32 len)
|
||||
if (!LOS_IsUserAddressRange((vaddr_t)(UINTPTR)buf, len)) {
|
||||
(VOID)memset_s(buf, len, 0, len);
|
||||
} else {
|
||||
if (_arm_clear_user(buf, len)) {
|
||||
return -EFAULT;
|
||||
unsigned char *tmp = (unsigned char *)LOS_MemAlloc(OS_SYS_MEM_ADDR, len);
|
||||
if (tmp == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
(VOID)memset_s(tmp, len, 0, len);
|
||||
if (_arm_user_copy(buf, tmp, len) != 0) {
|
||||
ret = -EFAULT;
|
||||
}
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, tmp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
@@ -1,48 +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.
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
# LOCAL_SRCS := $(wildcard *.c)
|
||||
|
||||
ifeq ($(LOSCFG_ARCH_GIC_V2), y)
|
||||
LOCAL_SRCS := gic_v2.c
|
||||
else ifeq ($(LOSCFG_ARCH_GIC_V3), y)
|
||||
LOCAL_SRCS := gic_v3.c
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/base/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/arm/src/include \
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||
include $(MODULE)
|
||||
0
arch/arm/include/in_cksum.h
Normal file → Executable file
0
arch/arm/include/in_cksum.h
Normal file → Executable file
29
arch/arm/include/los_exc.h
Normal file → Executable file
29
arch/arm/include/los_exc.h
Normal file → Executable file
@@ -63,29 +63,26 @@ typedef struct {
|
||||
UINT64 SPSR;
|
||||
} ExcContext;
|
||||
#else
|
||||
/* It has the same structure as TaskContext */
|
||||
typedef struct {
|
||||
UINT32 R4;
|
||||
UINT32 R5;
|
||||
UINT32 R6;
|
||||
UINT32 R7;
|
||||
UINT32 R8;
|
||||
UINT32 R9;
|
||||
UINT32 R10;
|
||||
UINT32 R11;
|
||||
|
||||
UINT32 SP; /**< svc sp */
|
||||
UINT32 reserved; /**< Reserved, multiplexing register */
|
||||
UINT32 USP;
|
||||
UINT32 ULR;
|
||||
UINT32 USP; /**< User mode stack pointer */
|
||||
UINT32 ULR; /**< User mode program returning address */
|
||||
UINT32 regCPSR; /**< Current program status register (CPSR) */
|
||||
UINT32 R0; /**< Register R0 */
|
||||
UINT32 R1; /**< Register R1 */
|
||||
UINT32 R2; /**< Register R2 */
|
||||
UINT32 R3; /**< Register R3 */
|
||||
UINT32 R4; /**< Register R4 */
|
||||
UINT32 R5; /**< Register R5 */
|
||||
UINT32 R6; /**< Register R6 */
|
||||
UINT32 R7; /**< Register R7 */
|
||||
UINT32 R8; /**< Register R8 */
|
||||
UINT32 R9; /**< Register R9 */
|
||||
UINT32 R10; /**< Register R10 */
|
||||
UINT32 R11; /**< Register R11 */
|
||||
UINT32 R12; /**< Register R12 */
|
||||
UINT32 SP; /**< Stack pointer */
|
||||
UINT32 LR; /**< Program returning address. */
|
||||
UINT32 PC; /**< PC pointer of the exceptional function */
|
||||
UINT32 regCPSR;
|
||||
} ExcContext;
|
||||
#endif
|
||||
|
||||
@@ -186,7 +183,7 @@ extern UINT32 LOS_ExcRegHook(EXC_PROC_FUNC excHook);
|
||||
* los_exc.h: the header file that contains the API declaration.
|
||||
* @see None.
|
||||
*/
|
||||
NORETURN VOID LOS_Panic(const CHAR *fmt, ...);
|
||||
VOID LOS_Panic(const CHAR *fmt, ...);
|
||||
|
||||
/**
|
||||
* @ingroup los_exc
|
||||
|
||||
128
arch/arm/include/los_hw.h
Normal file → Executable file
128
arch/arm/include/los_hw.h
Normal file → Executable file
@@ -77,6 +77,134 @@ extern UINT64 g_cpuMap[];
|
||||
#define CPU_MAP_GET(cpuid) g_cpuMap[(cpuid)]
|
||||
#define CPU_MAP_SET(cpuid, hwid) g_cpuMap[(cpuid)] = (hwid)
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief Set Event.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to send an event to all cores within a muti-processor system.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API is not implemented.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval #None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* los_hw.h: the header file that contains the API declaration.
|
||||
* @see wfe.
|
||||
*/
|
||||
extern VOID Sev(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief Wait for event.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to suspend execution until events occurs if the event register is not set.</li>
|
||||
* </ul>
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>This API is not implemented.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval #None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* los_hw.h: the header file that contains the API declaration.
|
||||
* @see sev.
|
||||
*/
|
||||
extern VOID Wfe(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief Wait for interrupt.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to suspend execution until interrupt or a debug request occurs.</li>
|
||||
* </ul>
|
||||
* @attention None.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval #None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* los_hw.h: the header file that contains the API declaration.
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID Wfi(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief Data Memory Barrier.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used as a memory barrier</li>
|
||||
* </ul>
|
||||
* @attention None.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval #None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* los_hw.h: the header file that contains the API declaration.
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID Dmb(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief Data Synchronization Barrier.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used as a special kind of memory barrier</li>
|
||||
* </ul>
|
||||
* @attention None.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval #None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* los_hw.h: the header file that contains the API declaration.
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID Dsb(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief Instruction Synchronization Barrier.
|
||||
*
|
||||
* @par Description:
|
||||
* <ul>
|
||||
* <li>This API is used to flush the pipeline in the processor,
|
||||
* so that all instructions following the ISB are fetched from cache or memory,
|
||||
* after the instruction has been completed.</li>
|
||||
* </ul>
|
||||
* @attention None.
|
||||
*
|
||||
* @param None.
|
||||
*
|
||||
* @retval #None.
|
||||
*
|
||||
* @par Dependency:
|
||||
* los_hw.h: the header file that contains the API declaration.
|
||||
* @see None.
|
||||
*/
|
||||
extern VOID Isb(VOID);
|
||||
|
||||
/**
|
||||
* @ingroup los_hw
|
||||
* @brief Invalidate instruction cache.
|
||||
|
||||
0
arch/arm/include/los_hwi.h
Normal file → Executable file
0
arch/arm/include/los_hwi.h
Normal file → Executable file
0
arch/arm/include/los_strncpy_from_user.h
Normal file → Executable file
0
arch/arm/include/los_strncpy_from_user.h
Normal file → Executable file
0
arch/arm/include/los_strnlen_user.h
Normal file → Executable file
0
arch/arm/include/los_strnlen_user.h
Normal file → Executable file
@@ -44,11 +44,19 @@ extern "C" {
|
||||
extern UINTPTR __stack_startup;
|
||||
extern UINTPTR __stack_startup_top;
|
||||
#else
|
||||
extern UINTPTR __fiq_stack_top;
|
||||
extern UINTPTR __svc_stack_top;
|
||||
extern UINTPTR __abt_stack_top;
|
||||
extern UINTPTR __undef_stack_top;
|
||||
extern UINTPTR __exc_stack_top;
|
||||
extern UINTPTR __fiq_stack;
|
||||
extern UINTPTR __svc_stack;
|
||||
extern UINTPTR __abt_stack;
|
||||
extern UINTPTR __undef_stack;
|
||||
extern UINTPTR __exc_stack;
|
||||
#endif
|
||||
extern UINTPTR __irq_stack_top;
|
||||
extern UINTPTR __irq_stack;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
0
arch/arm/include/los_user_get.h
Normal file → Executable file
0
arch/arm/include/los_user_get.h
Normal file → Executable file
0
arch/arm/include/los_user_put.h
Normal file → Executable file
0
arch/arm/include/los_user_put.h
Normal file → Executable file
0
arch/arm/include/user_copy.h
Normal file → Executable file
0
arch/arm/include/user_copy.h
Normal file → Executable file
0
bsd/Kconfig
Normal file → Executable file
0
bsd/Kconfig
Normal file → Executable file
0
bsd/compat/linuxkpi/Makefile
Normal file → Executable file
0
bsd/compat/linuxkpi/Makefile
Normal file → Executable file
2
bsd/dev/usb/Kconfig
Normal file → Executable file
2
bsd/dev/usb/Kconfig
Normal file → Executable file
@@ -15,7 +15,7 @@ config DRIVERS_USB_HOST_DRIVER
|
||||
choice
|
||||
depends on DRIVERS_USB_HOST_DRIVER
|
||||
prompt "USB HCD"
|
||||
default DRIVERS_USB_HOST_EHCI
|
||||
default y
|
||||
help
|
||||
Enable EHCI for USB 2.0.
|
||||
Enable XHCI for USB 3.0
|
||||
|
||||
0
bsd/dev/usb/Makefile
Normal file → Executable file
0
bsd/dev/usb/Makefile
Normal file → Executable file
1
bsd/dev/usb/storage/umass_fs.h
Symbolic link
1
bsd/dev/usb/storage/umass_fs.h
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../../third_party/NuttX/include/nuttx/usb/storage.h
|
||||
95
build.sh
95
build.sh
@@ -30,65 +30,44 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
set -e
|
||||
|
||||
board_name=${1}
|
||||
ohos_build_compiler=${2}
|
||||
root_build_dir=${3}
|
||||
ohos_build_type=${4}
|
||||
tee_enable=${5}
|
||||
device_company=${6}
|
||||
product_path=${7}
|
||||
outdir=${8}
|
||||
ohos_version=${9}
|
||||
sysroot_path=${10}
|
||||
arch_cflags=${11}
|
||||
device_path=${12}
|
||||
|
||||
echo "${board_name}" "${device_company}"
|
||||
echo "sh param:" "$@"
|
||||
|
||||
function main() {
|
||||
destination=".config"
|
||||
tee=""
|
||||
if [ "${tee_enable}" = "true" ]; then
|
||||
tee="_tee"
|
||||
fi
|
||||
|
||||
config_file="${product_path}/config/${ohos_build_type}${tee}.config"
|
||||
if [ -f "${config_file}" ]; then
|
||||
cp "${config_file}" "${destination}"
|
||||
return
|
||||
fi
|
||||
|
||||
product_name=$(basename "${product_path}")
|
||||
config_file="${product_name}_release.config"
|
||||
if [ "${ohos_build_compiler}" = "clang" ]; then
|
||||
if [ "${ohos_build_type}" = "debug" ]; then
|
||||
config_file="debug/${product_name}_${ohos_build_compiler}${tee}.config"
|
||||
else
|
||||
config_file="${product_name}_${ohos_build_compiler}_release${tee}.config"
|
||||
fi
|
||||
elif [ "${ohos_build_compiler}" = "gcc" ]; then
|
||||
if [ "${ohos_build_type}" = "debug" ]; then
|
||||
config_file="${product_name}_debug_shell${tee}.config"
|
||||
else
|
||||
config_file="${product_name}_release${tee}.config"
|
||||
fi
|
||||
fi
|
||||
cp "tools/build/config/${config_file}" "${destination}"
|
||||
}
|
||||
|
||||
if [ "x" != "x${sysroot_path}" ]; then
|
||||
export SYSROOT_PATH=${sysroot_path}
|
||||
echo "sh param:$1,$2,$3,$4,$5,$6,$7"
|
||||
destination=".config"
|
||||
config_file=""
|
||||
tee=""
|
||||
outdir="../..$3/test_info/gen/kernel/test"
|
||||
if [ "$5" = "tee" ]; then
|
||||
tee="_tee"
|
||||
fi
|
||||
|
||||
if [ "x" != "x${arch_cflags}" ]; then
|
||||
export ARCH_CFLAGS="${arch_cflags}"
|
||||
product_name="$(basename $7)"
|
||||
source="tools/build/config/${product_name}_release.config"
|
||||
if [ "$2" = "clang" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${product_name}_$2$tee.config"
|
||||
source="tools/build/config/debug/$config_file"
|
||||
else
|
||||
config_file="${product_name}_$2_release$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
fi
|
||||
elif [ "$2" = "gcc" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${product_name}_debug_shell$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
else
|
||||
config_file="${product_name}_release$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
fi
|
||||
fi
|
||||
if [ -d "./out" ]; then
|
||||
rm -rf ./out
|
||||
fi
|
||||
if [ -f "$destination" ]; then
|
||||
rm -rf $destination
|
||||
fi
|
||||
if [ ! -f "$source" ]; then
|
||||
source="$7/config/sys/$config_file"
|
||||
fi
|
||||
cp $source $destination
|
||||
|
||||
export OUTDIR="${outdir}"
|
||||
export PRODUCT_PATH="${product_path}"
|
||||
export DEVICE_PATH="${device_path}"
|
||||
mkdir -p $outdir
|
||||
cp kernel_test.sources $outdir
|
||||
|
||||
main && \
|
||||
make clean && \
|
||||
make -j rootfs VERSION="${ohos_version}"
|
||||
|
||||
0
compat/posix/Kconfig
Normal file → Executable file
0
compat/posix/Kconfig
Normal file → Executable file
0
compat/posix/include/mqueue.h
Normal file → Executable file
0
compat/posix/include/mqueue.h
Normal file → Executable file
9
compat/posix/include/time_posix.h
Normal file → Executable file
9
compat/posix/include/time_posix.h
Normal file → Executable file
@@ -42,13 +42,6 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct ksigevent {
|
||||
union sigval sigev_value;
|
||||
int sigev_signo;
|
||||
int sigev_notify;
|
||||
int sigev_tid;
|
||||
};
|
||||
|
||||
/* internal functions */
|
||||
STATIC INLINE BOOL ValidTimeSpec(const struct timespec *tp)
|
||||
{
|
||||
@@ -85,8 +78,6 @@ STATIC INLINE VOID OsTick2TimeSpec(struct timespec *tp, UINT32 tick)
|
||||
tp->tv_nsec = (long)(ns % OS_SYS_NS_PER_SECOND);
|
||||
}
|
||||
|
||||
int OsTimerCreate(clockid_t, struct ksigevent *__restrict, timer_t *__restrict);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
#include "los_sem.h"
|
||||
#include "los_task.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int map_errno(UINT32 err)
|
||||
{
|
||||
@@ -91,7 +96,7 @@ int map_errno(UINT32 err)
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
case LOS_ERRNO_SEM_PENDED:
|
||||
case LOS_ERRNO_EVENT_SHOULD_NOT_DESTROY:
|
||||
case LOS_ERRNO_EVENT_SHOULD_NOT_DESTORY:
|
||||
errno = EBUSY;
|
||||
break;
|
||||
case LOS_ERRNO_SEM_PEND_IN_LOCK:
|
||||
@@ -110,3 +115,8 @@ int map_errno(UINT32 err)
|
||||
return errno;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
10
compat/posix/src/misc.c
Normal file → Executable file
10
compat/posix/src/misc.c
Normal file → Executable file
@@ -37,6 +37,11 @@
|
||||
#include "mqueue.h"
|
||||
#include "semaphore.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Supply some suitable values for constants that may not be present
|
||||
@@ -140,3 +145,8 @@ pid_t getpid(void)
|
||||
return ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
24
compat/posix/src/mqueue.c
Normal file → Executable file
24
compat/posix/src/mqueue.c
Normal file → Executable file
@@ -30,7 +30,6 @@
|
||||
*/
|
||||
|
||||
#include "mqueue.h"
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "fcntl.h"
|
||||
#include "pthread.h"
|
||||
#include "map_error.h"
|
||||
@@ -38,9 +37,14 @@
|
||||
#include "los_memory.h"
|
||||
#include "los_vm_map.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "fs/file.h"
|
||||
#include "fs_file.h"
|
||||
#include "user_copy.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define FNONBLOCK O_NONBLOCK
|
||||
|
||||
@@ -740,8 +744,11 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
goto ERROUT_UNLOCK;
|
||||
}
|
||||
|
||||
OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
|
||||
OS_MQ_GOTO_ERROUT_UNLOCK_IF(privateMqPersonal->mq_status != MQ_USE_MAGIC, EBADF);
|
||||
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
OS_MQ_GOTO_ERROUT_UNLOCK_IF(msgLen > (size_t)(mqueueCB->mqcb->queueSize - sizeof(UINT32)), EMSGSIZE);
|
||||
@@ -784,7 +791,10 @@ ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen, unsigned int *
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL || privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
if (privateMqPersonal == NULL) {
|
||||
goto ERROUT_UNLOCK;
|
||||
}
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
goto ERROUT_UNLOCK;
|
||||
}
|
||||
@@ -832,4 +842,8 @@ 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);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
#include "los_typedef.h"
|
||||
#include "los_memory.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int posix_memalign(void **memAddr, size_t alignment, size_t size)
|
||||
{
|
||||
@@ -47,3 +52,8 @@ int posix_memalign(void **memAddr, size_t alignment, size_t size)
|
||||
return ENOERR;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
14
compat/posix/src/pthread.c
Normal file → Executable file
14
compat/posix/src/pthread.c
Normal file → Executable file
@@ -38,6 +38,11 @@
|
||||
#include "los_process_pri.h"
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Array of pthread control structures. A pthread_t object is
|
||||
@@ -204,7 +209,7 @@ STATIC UINT32 InitPthreadData(pthread_t threadID, pthread_attr_t *userAttr,
|
||||
PRINT_ERR("%s: %d, err: %d\n", __FUNCTION__, __LINE__, err);
|
||||
return LOS_NOK;
|
||||
}
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
if (userAttr->cpuset.__bits[0] > 0) {
|
||||
taskCB->cpuAffiMask = (UINT16)userAttr->cpuset.__bits[0];
|
||||
}
|
||||
@@ -435,7 +440,7 @@ int pthread_detach(pthread_t thread)
|
||||
/* Set state to detached and kick any joinees to make them return. */
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (!(detached->task->taskStatus & OS_TASK_STATUS_EXIT)) {
|
||||
ret = OsTaskSetDetachUnsafe(detached->task);
|
||||
ret = OsTaskSetDeatchUnsafe(detached->task);
|
||||
if (ret == ESRCH) {
|
||||
ret = LOS_OK;
|
||||
} else if (ret == LOS_OK) {
|
||||
@@ -804,3 +809,8 @@ int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize, cpu_set_t* cpuse
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
#include "pthread.h"
|
||||
#include "pprivate.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int pthread_attr_init(pthread_attr_t *attr)
|
||||
{
|
||||
@@ -49,7 +54,7 @@ int pthread_attr_init(pthread_attr_t *attr)
|
||||
attr->stacksize_set = 1;
|
||||
attr->stacksize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
attr->cpuset.__bits[0] = 0;
|
||||
#endif
|
||||
|
||||
@@ -239,7 +244,7 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stackSize)
|
||||
*/
|
||||
int pthread_attr_setaffinity_np(pthread_attr_t* attr, size_t cpusetsize, const cpu_set_t* cpuset)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
if (attr == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -264,7 +269,7 @@ int pthread_attr_setaffinity_np(pthread_attr_t* attr, size_t cpusetsize, const c
|
||||
*/
|
||||
int pthread_attr_getaffinity_np(const pthread_attr_t* attr, size_t cpusetsize, cpu_set_t* cpuset)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
if ((attr == NULL) || (cpuset == NULL) || (cpusetsize != sizeof(cpu_set_t))) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -275,3 +280,8 @@ int pthread_attr_getaffinity_np(const pthread_attr_t* attr, size_t cpusetsize, c
|
||||
return ENOERR;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
10
compat/posix/src/pthread_cond.c
Normal file → Executable file
10
compat/posix/src/pthread_cond.c
Normal file → Executable file
@@ -36,6 +36,11 @@
|
||||
#include "los_atomic.h"
|
||||
#include "los_event_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define BROADCAST_EVENT 1
|
||||
#define COND_COUNTER_STEP 0x0004U
|
||||
@@ -346,3 +351,8 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
10
compat/posix/src/pthread_mutex.c
Normal file → Executable file
10
compat/posix/src/pthread_mutex.c
Normal file → Executable file
@@ -31,6 +31,11 @@
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t *attr)
|
||||
{
|
||||
@@ -134,3 +139,8 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||
return LOS_MuxUnlock(mutex);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -35,6 +35,11 @@
|
||||
#include "unistd.h"
|
||||
#include "los_task_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int sched_get_priority_min(int policy)
|
||||
{
|
||||
@@ -61,7 +66,7 @@ int sched_get_priority_max(int policy)
|
||||
*/
|
||||
int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
UINT32 taskID = (UINT32)pid;
|
||||
UINT32 ret;
|
||||
|
||||
@@ -93,7 +98,7 @@ int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
|
||||
*/
|
||||
int sched_getaffinity(pid_t pid, size_t set_size, cpu_set_t* set)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
UINT32 taskID = (UINT32)pid;
|
||||
UINT16 cpuAffiMask;
|
||||
|
||||
@@ -138,3 +143,8 @@ int __sched_cpucount(size_t set_size, const cpu_set_t* set)
|
||||
return count;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
10
compat/posix/src/semaphore.c
Normal file → Executable file
10
compat/posix/src/semaphore.c
Normal file → Executable file
@@ -34,6 +34,11 @@
|
||||
#include "map_error.h"
|
||||
#include "time_posix.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Initialize semaphore to value, shared is not supported in Huawei LiteOS. */
|
||||
int sem_init(sem_t *sem, int shared, unsigned int value)
|
||||
@@ -192,3 +197,8 @@ int sem_unlink(const char *name)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
212
compat/posix/src/time.c
Normal file → Executable file
212
compat/posix/src/time.c
Normal file → Executable file
@@ -50,8 +50,11 @@
|
||||
#include "los_swtmr_pri.h"
|
||||
#include "los_sys_pri.h"
|
||||
|
||||
#define CPUCLOCK_PERTHREAD_MASK 4
|
||||
#define CPUCLOCK_ID_OFFSET 3
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Do a time package defined return. This requires the error code
|
||||
@@ -277,7 +280,7 @@ STATIC VOID OsGetHwTime(struct timespec64 *hwTime)
|
||||
{
|
||||
UINT64 nowNsec;
|
||||
|
||||
nowNsec = LOS_CurrNanosec();
|
||||
nowNsec = hi_sched_clock();
|
||||
hwTime->tv_sec = nowNsec / OS_SYS_NS_PER_SECOND;
|
||||
hwTime->tv_nsec = nowNsec - hwTime->tv_sec * OS_SYS_NS_PER_SECOND;
|
||||
}
|
||||
@@ -428,6 +431,7 @@ int clock_settime(clockid_t clockID, const struct timespec *tp)
|
||||
case CLOCK_BOOTTIME:
|
||||
case CLOCK_REALTIME_ALARM:
|
||||
case CLOCK_BOOTTIME_ALARM:
|
||||
case CLOCK_SGI_CYCLE:
|
||||
case CLOCK_TAI:
|
||||
case CLOCK_THREAD_CPUTIME_ID:
|
||||
TIME_RETURN(ENOTSUP);
|
||||
@@ -451,119 +455,13 @@ int clock_settime(clockid_t clockID, const struct timespec *tp)
|
||||
return settimeofday(&tv, NULL);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
|
||||
{
|
||||
uint64_t runtime;
|
||||
UINT32 intSave;
|
||||
UINT32 tid = ((UINT32) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
|
||||
|
||||
if (OS_TID_CHECK_INVALID(tid)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
LosTaskCB *task = OsGetTaskCB(tid);
|
||||
|
||||
if (OsCurrTaskGet()->processID != task->processID) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
runtime = task->taskCpup.allTime;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
ats->tv_sec = runtime / OS_SYS_NS_PER_SECOND;
|
||||
ats->tv_nsec = runtime % OS_SYS_NS_PER_SECOND;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ProcessGetCputime(clockid_t clockID, struct timespec *ats)
|
||||
{
|
||||
UINT64 runtime;
|
||||
UINT32 intSave;
|
||||
const pid_t pid = ((pid_t) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
|
||||
LosProcessCB *spcb = NULL;
|
||||
|
||||
if (OsProcessIDUserCheckInvalid(pid) || pid < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
spcb = OS_PCB_FROM_PID(pid);
|
||||
if (OsProcessIsUnused(spcb)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
runtime = spcb->processCpup.allTime;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
ats->tv_sec = runtime / OS_SYS_NS_PER_SECOND;
|
||||
ats->tv_nsec = runtime % OS_SYS_NS_PER_SECOND;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int GetCputime(clockid_t clockID, struct timespec *tp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (clockID >= 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if ((UINT32)clockID & CPUCLOCK_PERTHREAD_MASK) {
|
||||
ret = PthreadGetCputime(clockID, tp);
|
||||
} else {
|
||||
ret = ProcessGetCputime(clockID, tp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int CheckClock(const clockid_t clockID)
|
||||
{
|
||||
int error = 0;
|
||||
const pid_t pid = ((pid_t) ~((UINT32)(clockID) >> CPUCLOCK_ID_OFFSET));
|
||||
|
||||
if (!((UINT32)clockID & CPUCLOCK_PERTHREAD_MASK)) {
|
||||
LosProcessCB *spcb = NULL;
|
||||
if (OsProcessIDUserCheckInvalid(pid) || pid < 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
spcb = OS_PCB_FROM_PID(pid);
|
||||
if (OsProcessIsUnused(spcb)) {
|
||||
error = -EINVAL;
|
||||
}
|
||||
} else {
|
||||
error = -EINVAL;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static int CpuClockGetres(const clockid_t clockID, struct timespec *tp)
|
||||
{
|
||||
if (clockID > 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int error = CheckClock(clockID);
|
||||
if (!error) {
|
||||
error = ProcessGetCputime(clockID, tp);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
#endif
|
||||
|
||||
int clock_gettime(clockid_t clockID, struct timespec *tp)
|
||||
{
|
||||
UINT32 intSave;
|
||||
struct timespec64 tmp = {0};
|
||||
struct timespec64 hwTime = {0};
|
||||
|
||||
if (clockID > MAX_CLOCKS) {
|
||||
if ((clockID > MAX_CLOCKS) || (clockID < CLOCK_REALTIME)) {
|
||||
goto ERROUT;
|
||||
}
|
||||
|
||||
@@ -600,22 +498,16 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
|
||||
case CLOCK_BOOTTIME:
|
||||
case CLOCK_REALTIME_ALARM:
|
||||
case CLOCK_BOOTTIME_ALARM:
|
||||
case CLOCK_SGI_CYCLE:
|
||||
case CLOCK_TAI:
|
||||
TIME_RETURN(ENOTSUP);
|
||||
default:
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
int ret = GetCputime(clockID, tp);
|
||||
TIME_RETURN(-ret);
|
||||
#else
|
||||
TIME_RETURN(EINVAL);
|
||||
#endif
|
||||
}
|
||||
goto ERROUT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
ERROUT:
|
||||
ERROUT:
|
||||
TIME_RETURN(EINVAL);
|
||||
}
|
||||
|
||||
@@ -645,17 +537,11 @@ int clock_getres(clockid_t clockID, struct timespec *tp)
|
||||
case CLOCK_BOOTTIME:
|
||||
case CLOCK_REALTIME_ALARM:
|
||||
case CLOCK_BOOTTIME_ALARM:
|
||||
case CLOCK_SGI_CYCLE:
|
||||
case CLOCK_TAI:
|
||||
TIME_RETURN(ENOTSUP);
|
||||
default:
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
{
|
||||
int ret = CpuClockGetres(clockID, tp);
|
||||
TIME_RETURN(-ret);
|
||||
}
|
||||
#else
|
||||
TIME_RETURN(EINVAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
TIME_RETURN(0);
|
||||
@@ -678,6 +564,7 @@ int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct
|
||||
case CLOCK_BOOTTIME:
|
||||
case CLOCK_REALTIME_ALARM:
|
||||
case CLOCK_BOOTTIME_ALARM:
|
||||
case CLOCK_SGI_CYCLE:
|
||||
case CLOCK_TAI:
|
||||
if (flags == 0 || flags == TIMER_ABSTIME) {
|
||||
TIME_RETURN(ENOTSUP);
|
||||
@@ -693,60 +580,45 @@ int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct
|
||||
|
||||
typedef struct {
|
||||
int sigev_signo;
|
||||
pid_t pid;
|
||||
unsigned int tid;
|
||||
UINT32 pid;
|
||||
union sigval sigev_value;
|
||||
} swtmr_proc_arg;
|
||||
|
||||
static VOID SwtmrProc(UINTPTR tmrArg)
|
||||
{
|
||||
INT32 sig, ret;
|
||||
UINT32 intSave;
|
||||
unsigned int intSave;
|
||||
int sig;
|
||||
pid_t pid;
|
||||
siginfo_t info;
|
||||
LosTaskCB *stcb = NULL;
|
||||
|
||||
swtmr_proc_arg *arg = (swtmr_proc_arg *)tmrArg;
|
||||
OS_GOTO_EXIT_IF(arg == NULL, EINVAL);
|
||||
if (arg == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
sig = arg->sigev_signo;
|
||||
sig = arg->sigev_signo + 1;
|
||||
pid = arg->pid;
|
||||
OS_GOTO_EXIT_IF(!GOOD_SIGNO(sig), EINVAL);
|
||||
/* Make sure that the para is valid */
|
||||
if (!GOOD_SIGNO(sig) || pid <= 0) {
|
||||
return;
|
||||
}
|
||||
if (OS_PID_CHECK_INVALID(pid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create the siginfo structure */
|
||||
info.si_signo = sig;
|
||||
info.si_code = SI_TIMER;
|
||||
info.si_value.sival_ptr = arg->sigev_value.sival_ptr;
|
||||
|
||||
/* Send signals to threads or processes */
|
||||
if (arg->tid > 0) {
|
||||
/* Make sure that the para is valid */
|
||||
OS_GOTO_EXIT_IF(OS_TID_CHECK_INVALID(arg->tid), EINVAL);
|
||||
stcb = OsGetTaskCB(arg->tid);
|
||||
ret = OsUserProcessOperatePermissionsCheck(stcb, stcb->processID);
|
||||
OS_GOTO_EXIT_IF(ret != LOS_OK, -ret);
|
||||
/* Send the signal */
|
||||
SCHEDULER_LOCK(intSave);
|
||||
OsDispatch(pid, &info, OS_USER_KILL_PERMISSION);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
/* Dispatch the signal to thread, bypassing normal task group thread
|
||||
* dispatch rules. */
|
||||
SCHEDULER_LOCK(intSave);
|
||||
ret = OsTcbDispatch(stcb, &info);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
OS_GOTO_EXIT_IF(ret != LOS_OK, -ret);
|
||||
} else {
|
||||
/* Make sure that the para is valid */
|
||||
OS_GOTO_EXIT_IF(pid <= 0 || OS_PID_CHECK_INVALID(pid), EINVAL);
|
||||
/* Dispatch the signal to process */
|
||||
SCHEDULER_LOCK(intSave);
|
||||
OsDispatch(pid, &info, OS_USER_KILL_PERMISSION);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
return;
|
||||
EXIT:
|
||||
PRINT_ERR("Dsipatch signals failed!, ret: %d\r\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
int OsTimerCreate(clockid_t clockID, struct ksigevent *evp, timer_t *timerID)
|
||||
int timer_create(clockid_t clockID, struct sigevent *evp, timer_t *timerID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT16 swtmrID;
|
||||
@@ -776,9 +648,7 @@ int OsTimerCreate(clockid_t clockID, struct ksigevent *evp, timer_t *timerID)
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
arg->tid = evp ? evp->sigev_tid : 0;
|
||||
arg->sigev_signo = signo;
|
||||
arg->sigev_signo = signo - 1;
|
||||
arg->pid = LOS_GetCurrProcessID();
|
||||
arg->sigev_value.sival_ptr = evp ? evp->sigev_value.sival_ptr : NULL;
|
||||
ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, SwtmrProc, &swtmrID, (UINTPTR)arg);
|
||||
@@ -999,8 +869,8 @@ clock_t clock(VOID)
|
||||
clock_t clockMsec;
|
||||
UINT64 nowNsec;
|
||||
|
||||
nowNsec = LOS_CurrNanosec();
|
||||
clockMsec = (clock_t)(nowNsec / (OS_SYS_NS_PER_SECOND / CLOCKS_PER_SEC));
|
||||
nowNsec = hi_sched_clock();
|
||||
clockMsec = (clock_t)(nowNsec / OS_SYS_NS_PER_MS);
|
||||
|
||||
return clockMsec;
|
||||
}
|
||||
@@ -1031,16 +901,15 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* To avoid creating an invalid timer after the timer has already been create */
|
||||
if (processCB->timerID == (timer_t)(UINTPTR)MAX_INVALID_TIMER_VID) {
|
||||
ret = OsTimerCreate(CLOCK_REALTIME, NULL, &timerID);
|
||||
ret = timer_create(CLOCK_REALTIME, NULL, &timerID);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* The initialization of this global timer must be in spinlock
|
||||
* OsTimerCreate cannot be located in spinlock.
|
||||
* timer_create cannot be located in spinlock.
|
||||
*/
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (processCB->timerID == (timer_t)(UINTPTR)MAX_INVALID_TIMER_VID) {
|
||||
@@ -1097,7 +966,7 @@ int getitimer(int which, struct itimerval *value)
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VDSO
|
||||
VOID OsVdsoTimeGet(VdsoDataPage *vdsoDataPage)
|
||||
VOID OsGetVdsoTime(VdsoDataPage *vdsoDataPage)
|
||||
{
|
||||
UINT32 intSave;
|
||||
struct timespec64 tmp = {0};
|
||||
@@ -1121,3 +990,8 @@ VOID OsVdsoTimeGet(VdsoDataPage *vdsoDataPage)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -31,7 +31,12 @@
|
||||
|
||||
#include "fcntl.h"
|
||||
#include "linux/kernel.h"
|
||||
#include "fs/driver.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
static int MemOpen(struct file *filep)
|
||||
{
|
||||
@@ -43,19 +48,18 @@ static int MemClose(struct file *filep)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t MemRead(struct file *filep, char *buffer, size_t buflen)
|
||||
static ssize_t MemRead(FAR struct file *filep, FAR char *buffer, size_t buflen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t MemWrite(struct file *filep, const char *buffer, size_t buflen)
|
||||
static ssize_t MemWrite(FAR struct file *filep, FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t MemMap(struct file *filep, LosVmMapRegion *region)
|
||||
static ssize_t MemMap(FAR struct file *filep, FAR LosVmMapRegion *region)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
size_t size = region->range.size;
|
||||
PADDR_T paddr = region->pgOff << PAGE_SHIFT;
|
||||
VADDR_T vaddr = region->range.base;
|
||||
@@ -74,10 +78,7 @@ static ssize_t MemMap(struct file *filep, LosVmMapRegion *region)
|
||||
if (LOS_ArchMmuMap(&space->archMmu, vaddr, paddr, size >> PAGE_SHIFT, region->regionFlags) <= 0) {
|
||||
return -EAGAIN;
|
||||
}
|
||||
#else
|
||||
UNUSED(filep);
|
||||
UNUSED(region);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -99,3 +100,9 @@ int DevMemRegister(void)
|
||||
{
|
||||
return register_driver("/dev/mem", &g_memDevOps, 0666, 0); /* 0666: file mode */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
config DRIVERS_QUICKSTART
|
||||
bool "Enable QUICKSTART"
|
||||
default y
|
||||
depends on DRIVERS && FS_VFS
|
||||
help
|
||||
Answer Y to enable LiteOS support quickstart frame dev.
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@@ -28,8 +29,8 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_USER_CLEAR_H
|
||||
#define _ARM_USER_CLEAR_H
|
||||
#ifndef __LOS_QUICK_START_H__
|
||||
#define __LOS_QUICK_START_H__
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
@@ -39,7 +40,7 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
size_t _arm_clear_user(void *addr, size_t bytes);
|
||||
extern int DevQuickStartRegister(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -47,4 +48,4 @@ size_t _arm_clear_user(void *addr, size_t bytes);
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _ARM_USER_CLEAR_H */
|
||||
#endif
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@@ -28,8 +29,10 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LOS_BLACKBOX_DETECTOR_H
|
||||
#define LOS_BLACKBOX_DETECTOR_H
|
||||
#ifndef __LOS_QUICK_START_PRI_H__
|
||||
#define __LOS_QUICK_START_PRI_H__
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -37,10 +40,8 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
int UploadEventByFile(const char *filePath);
|
||||
int UploadEventByStream(const char *buf, size_t bufSize);
|
||||
unsigned int OsSystemInitStep2(void);
|
||||
extern VOID SystemInit2(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -48,4 +49,4 @@ int UploadEventByStream(const char *buf, size_t bufSize);
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
#endif /* __LOS_QUICK_START_PRI_H__ */
|
||||
117
drivers/char/quickstart/src/qucikstart.c
Normal file
117
drivers/char/quickstart/src/qucikstart.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_quick_start_pri.h"
|
||||
#include "bits/ioctl.h"
|
||||
#include "fcntl.h"
|
||||
#include "linux/kernel.h"
|
||||
|
||||
#define QUICKSTART_IOC_MAGIC 'T'
|
||||
#define QUICKSTART_INITSTEP2 _IO(QUICKSTART_IOC_MAGIC, 0)
|
||||
#define QUICKSTART_UNREGISTER _IO(QUICKSTART_IOC_MAGIC, 1)
|
||||
#define QUICKSTART_NODE "/dev/quickstart"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
static int QuickstartOpen(struct file *filep)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int QuickstartClose(struct file *filep)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SystemInitStep2(void)
|
||||
{
|
||||
static int once = 0;
|
||||
/* Only one call is allowed */
|
||||
if (once != 0) {
|
||||
return;
|
||||
}
|
||||
once = 1;
|
||||
|
||||
unsigned int ret = OsSystemInitStep2();
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("systemInitStep2 failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
static int QuickstartDevUnregister(void)
|
||||
{
|
||||
return unregister_driver(QUICKSTART_NODE);
|
||||
}
|
||||
|
||||
static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
switch (cmd) {
|
||||
case QUICKSTART_INITSTEP2:
|
||||
SystemInitStep2();
|
||||
break;
|
||||
case QUICKSTART_UNREGISTER:
|
||||
QuickstartDevUnregister();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct file_operations_vfs g_quickstartDevOps = {
|
||||
QuickstartOpen, /* open */
|
||||
QuickstartClose, /* close */
|
||||
NULL, /* read */
|
||||
NULL, /* write */
|
||||
NULL, /* seek */
|
||||
QuickstartIoctl, /* ioctl */
|
||||
NULL, /* mmap */
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
NULL, /* poll */
|
||||
#endif
|
||||
NULL, /* unlink */
|
||||
};
|
||||
|
||||
int DevQuickStartRegister(void)
|
||||
{
|
||||
return register_driver(QUICKSTART_NODE, &g_quickstartDevOps, 0666, 0); /* 0666: file mode */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
@@ -1,142 +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.
|
||||
*/
|
||||
|
||||
#include "los_dev_quickstart.h"
|
||||
#include "fcntl.h"
|
||||
#include "linux/kernel.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "fs/file.h"
|
||||
#include "fs/driver.h"
|
||||
|
||||
EVENT_CB_S g_qsEvent;
|
||||
static SysteminitHook g_systemInitFunc[QS_STAGE_CNT] = {0};
|
||||
static char g_callOnce[QS_STAGE_CNT] = {0};
|
||||
|
||||
static int QuickstartOpen(struct file *filep)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int QuickstartClose(struct file *filep)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int QuickstartNotify(unsigned int events)
|
||||
{
|
||||
int ret = LOS_EventWrite((PEVENT_CB_S)&g_qsEvent, events);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
|
||||
ret = -EINVAL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define WAITLIMIT 300000 /* 5min = 5*60*1000*1tick(1ms) */
|
||||
|
||||
static int QuickstartListen(unsigned long arg)
|
||||
{
|
||||
QuickstartListenArgs args;
|
||||
if (copy_from_user(&args, (QuickstartListenArgs __user *)arg, sizeof(QuickstartListenArgs)) != LOS_OK) {
|
||||
PRINT_ERR("%s,%d,failed!\n", __FUNCTION__, __LINE__);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (args.wait > WAITLIMIT) {
|
||||
args.wait = WAITLIMIT;
|
||||
PRINT_ERR("%s wait arg is too longer, set to WAITLIMIT!\n", __FUNCTION__);
|
||||
}
|
||||
int ret = LOS_EventRead((PEVENT_CB_S)&g_qsEvent, args.events, LOS_WAITMODE_AND | LOS_WAITMODE_CLR, args.wait);
|
||||
if (ret != args.events && ret != 0) { /* 0: nowait is normal case */
|
||||
PRINT_ERR("%s,%d:0x%x\n", __FUNCTION__, __LINE__, ret);
|
||||
ret = -EINVAL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void QuickstartHookRegister(LosSysteminitHook hooks)
|
||||
{
|
||||
for (int i = 0; i < QS_STAGE_CNT; i++) {
|
||||
g_systemInitFunc[i] = hooks.func[i];
|
||||
}
|
||||
}
|
||||
|
||||
static int QuickstartStageWorking(unsigned int level)
|
||||
{
|
||||
if ((level < QS_STAGE_CNT) && (g_callOnce[level] == 0) && (g_systemInitFunc[level] != NULL)) {
|
||||
g_callOnce[level] = 1; /* 1: Already called */
|
||||
g_systemInitFunc[level]();
|
||||
} else {
|
||||
PRINT_WARN("Trigger quickstart,but doing nothing!!\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int QuickstartDevUnlink(struct Vnode *node)
|
||||
{
|
||||
(void)node;
|
||||
return unregister_driver(QUICKSTART_NODE);
|
||||
}
|
||||
|
||||
static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
ssize_t ret;
|
||||
if (cmd == QUICKSTART_NOTIFY) {
|
||||
return QuickstartNotify(arg);
|
||||
}
|
||||
|
||||
if (OsGetUserInitProcessID() != LOS_GetCurrProcessID()) {
|
||||
PRINT_ERR("Permission denios!\n");
|
||||
return -EACCES;
|
||||
}
|
||||
switch (cmd) {
|
||||
case QUICKSTART_LISTEN:
|
||||
ret = QuickstartListen(arg);
|
||||
break;
|
||||
default:
|
||||
ret = QuickstartStageWorking(cmd - QUICKSTART_STAGE(QS_STAGE1)); /* ioctl cmd converted to stage level */
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct file_operations_vfs g_quickstartDevOps = {
|
||||
.open = QuickstartOpen, /* open */
|
||||
.close = QuickstartClose, /* close */
|
||||
.ioctl = QuickstartIoctl, /* ioctl */
|
||||
.unlink = QuickstartDevUnlink, /* unlink */
|
||||
};
|
||||
|
||||
int QuickstartDevRegister(void)
|
||||
{
|
||||
LOS_EventInit(&g_qsEvent);
|
||||
return register_driver(QUICKSTART_NODE, &g_quickstartDevOps, 0644, 0); /* 0644: file mode */
|
||||
}
|
||||
|
||||
@@ -32,8 +32,12 @@
|
||||
#include "los_random.h"
|
||||
#include "fcntl.h"
|
||||
#include "linux/kernel.h"
|
||||
#include "fs/driver.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
static unsigned long g_randomMax = 0x7FFFFFFF;
|
||||
|
||||
@@ -54,7 +58,7 @@ static unsigned long g_seed = 1;
|
||||
|
||||
int RanOpen(struct file *filep)
|
||||
{
|
||||
g_seed = (unsigned long)(LOS_CurrNanosec() & 0xffffffff);
|
||||
g_seed = (unsigned long)(hi_sched_clock() & 0xffffffff);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -92,7 +96,7 @@ ssize_t RanRead(struct file *filep, char *buffer, size_t buflen)
|
||||
return (buflen - len); /* return a successful len */
|
||||
}
|
||||
|
||||
static ssize_t RanMap(struct file *filep, LosVmMapRegion *region)
|
||||
static ssize_t RanMap(FAR struct file* filep, FAR LosVmMapRegion *region)
|
||||
{
|
||||
PRINTK("%s %d, mmap is not support\n", __FUNCTION__, __LINE__);
|
||||
return 0;
|
||||
@@ -117,3 +121,8 @@ int DevRandomRegister(void)
|
||||
return register_driver("/dev/random", &g_ranDevOps, 0666, 0); /* 0666: file mode */
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "fcntl.h"
|
||||
#include "hisoc/random.h"
|
||||
#include "linux/kernel.h"
|
||||
#include "fs/driver.h"
|
||||
|
||||
static RandomOperations g_randomOp;
|
||||
void RandomOperationsInit(const RandomOperations *r)
|
||||
@@ -65,7 +64,7 @@ static int RandomHwClose(struct file *filep)
|
||||
|
||||
static int RandomHwIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret = -1;
|
||||
int ret;
|
||||
|
||||
switch (cmd) {
|
||||
default:
|
||||
@@ -77,7 +76,7 @@ static int RandomHwIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
static ssize_t RandomHwRead(struct file *filep, char *buffer, size_t buflen)
|
||||
{
|
||||
int ret = -1;
|
||||
int ret;
|
||||
|
||||
if (g_randomOp.read != NULL) {
|
||||
ret = g_randomOp.read(buffer, buflen);
|
||||
@@ -90,7 +89,7 @@ static ssize_t RandomHwRead(struct file *filep, char *buffer, size_t buflen)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static ssize_t RandomMap(struct file *filep, LosVmMapRegion *region)
|
||||
static ssize_t RandomMap(FAR struct file *filep, FAR LosVmMapRegion *region)
|
||||
{
|
||||
PRINTK("%s %d, mmap is not support\n", __FUNCTION__, __LINE__);
|
||||
return 0;
|
||||
@@ -121,3 +120,8 @@ int DevUrandomRegister(void)
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
2
fs/fat/Kconfig
Normal file → Executable file
2
fs/fat/Kconfig
Normal file → Executable file
@@ -39,5 +39,5 @@ config FS_FAT_VOLUMES
|
||||
|
||||
config FS_FAT_DISK
|
||||
bool "Enable partinfo for storage device"
|
||||
depends on FS_VFS && (FS_FAT || DRIVERS_MMC || DRIVERS_USB)
|
||||
depends on FS_FAT || DRIVERS_MMC || DRIVERS_USB
|
||||
default y
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user