Compare commits
4 Commits
OpenHarmon
...
OpenHarmon
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83b0e8f867 | ||
|
|
6b5d6be42d | ||
|
|
8b27064848 | ||
|
|
1ad74ab8e4 |
@@ -1,11 +0,0 @@
|
||||
### 该问题是怎么引起的?
|
||||
|
||||
|
||||
|
||||
### 重现步骤
|
||||
|
||||
|
||||
|
||||
### 报错信息
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
### 描述(做了什么,变更了什么)
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
35
.gitignore
vendored
35
.gitignore
vendored
@@ -1,24 +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
|
||||
/out
|
||||
platform/include/menuconfig.h
|
||||
platform/board.ld
|
||||
apps/init/init
|
||||
apps/shell/shell
|
||||
|
||||
376
BUILD.gn
Normal file → Executable file
376
BUILD.gn
Normal file → Executable file
@@ -28,361 +28,55 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
|
||||
declare_args() {
|
||||
tee_enable = false
|
||||
liteos_name = "OHOS_Image"
|
||||
liteos_skip_make = false
|
||||
}
|
||||
|
||||
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
|
||||
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
|
||||
|
||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||
|
||||
tee = ""
|
||||
if (tee_enable) {
|
||||
tee = "_tee"
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
liteos_config_file = "${ohos_build_type}${tee}.config"
|
||||
}
|
||||
|
||||
liteos_config_file = rebase_path(liteos_config_file, "", "$product_path/kernel_configs")
|
||||
print("liteos_config_file:", liteos_config_file)
|
||||
|
||||
exec_script("//build/lite/run_shell_cmd.py",
|
||||
[
|
||||
"env" +
|
||||
" CONFIG_=LOSCFG_" +
|
||||
" KCONFIG_CONFIG_HEADER='y=true'" +
|
||||
" KCONFIG_CONFIG=$liteos_config_file" +
|
||||
" DEVICE_PATH=$device_path" +
|
||||
" srctree=" + rebase_path(".") +
|
||||
" genconfig" +
|
||||
" --header-path $LITEOS_MENUCONFIG_H" +
|
||||
" --file-list kconfig_files.txt" +
|
||||
" --env-list kconfig_env.txt" +
|
||||
" --config-out config.gni",
|
||||
], "", [ liteos_config_file ])
|
||||
|
||||
import("liteos.gni")
|
||||
|
||||
assert(ARCH != "", "ARCH not set!")
|
||||
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
|
||||
assert(tee_enable == defined(LOSCFG_TEE_ENABLE), "TEE switch not match!")
|
||||
import("//build/lite/config/subsystem/lite_subsystem.gni")
|
||||
|
||||
generate_notice_file("kernel_notice_file") {
|
||||
module_name = "kernel"
|
||||
module_source_dir_list = [
|
||||
"$LITEOSTHIRDPARTY/FreeBSD",
|
||||
"$LITEOSTHIRDPARTY/musl",
|
||||
"$LITEOSTHIRDPARTY/zlib",
|
||||
"$LITEOSTHIRDPARTY/FatFs",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel",
|
||||
"$LITEOSTHIRDPARTY/lwip",
|
||||
"$LITEOSTHIRDPARTY/NuttX",
|
||||
"$LITEOSTHIRDPARTY/mtd-utils",
|
||||
"//third_party/FreeBSD",
|
||||
"//third_party/musl",
|
||||
"//third_party/zlib",
|
||||
"//third_party/FatFs",
|
||||
"//third_party/Linux_Kernel",
|
||||
"//third_party/lwip",
|
||||
"//third_party/NuttX",
|
||||
"//third_party/mtd-utils",
|
||||
]
|
||||
}
|
||||
|
||||
liteos_arch_cflags = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
mcpu = LOSCFG_ARCH_CPU
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) {
|
||||
mcpu += "+nofp"
|
||||
}
|
||||
liteos_arch_cflags += [ "-mcpu=$mcpu" ]
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
liteos_arch_cflags += [
|
||||
"-mfloat-abi=softfp",
|
||||
"-mfpu=$LOSCFG_ARCH_FPU",
|
||||
declare_args() {
|
||||
enable_ohos_kernel_liteos_a_ext_build = true
|
||||
LOSCFG_TEST_APPS = false
|
||||
tee_enable = ""
|
||||
}
|
||||
|
||||
lite_subsystem("kernel") {
|
||||
subsystem_components = []
|
||||
|
||||
if (enable_ohos_kernel_liteos_a_ext_build == false) {
|
||||
subsystem_components += [
|
||||
"//kernel/liteos_a/kernel",
|
||||
"//kernel/liteos_a/net",
|
||||
"//kernel/liteos_a/lib",
|
||||
"//kernel/liteos_a/compat",
|
||||
"//kernel/liteos_a/fs",
|
||||
"//kernel/liteos_a/arch:platform_cpu",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
cc += " --target=$target_triple"
|
||||
}
|
||||
|
||||
config("arch_config") {
|
||||
cflags = liteos_arch_cflags
|
||||
asmflags = cflags
|
||||
ldflags = cflags
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += ["-mthumb-interwork"]
|
||||
if (LOSCFG_SHELL) {
|
||||
subsystem_components += [ "//kernel/liteos_a/shell" ]
|
||||
}
|
||||
}
|
||||
if (defined(LOSCFG_THUMB)) {
|
||||
cflags += [ "-mthumb" ]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-mimplicit-it=thumb" ]
|
||||
} else {
|
||||
cflags += [ "-Wa,-mimplicit-it=thumb" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config("stdinc_config") {
|
||||
std_include = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-file-name=include" ], "trim string")
|
||||
cflags = [
|
||||
"-isystem",
|
||||
std_include,
|
||||
]
|
||||
cflags += [ "-nostdinc" ]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("ssp_config") {
|
||||
cflags = []
|
||||
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
|
||||
cflags += [ "-fstack-protector-all" ]
|
||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
|
||||
cflags += [ "-fstack-protector-strong" ]
|
||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
|
||||
cflags += [
|
||||
"-fstack-protector",
|
||||
"--param",
|
||||
"ssp-buffer-size=4",
|
||||
]
|
||||
} else {
|
||||
cflags += [ "-fno-stack-protector" ]
|
||||
deps = [ ":make" ]
|
||||
}
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("optimize_config") {
|
||||
cflags = []
|
||||
if (defined(LOSCFG_COMPILE_DEBUG)) {
|
||||
cflags += [
|
||||
"-g",
|
||||
"-gdwarf-2",
|
||||
]
|
||||
optimization_cflag = "-O0"
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
|
||||
optimization_cflag = "-O2"
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
optimization_cflag = "-Oz"
|
||||
} else {
|
||||
optimization_cflag = "-Os"
|
||||
}
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_LTO)) {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-flto=thin" ]
|
||||
} else {
|
||||
cflags += [ "-flto" ]
|
||||
}
|
||||
}
|
||||
cflags += [ optimization_cflag ]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("kconfig_config") {
|
||||
cflags = [
|
||||
"-imacros",
|
||||
"$LITEOS_MENUCONFIG_H",
|
||||
]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("warn_config") {
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wpointer-arith",
|
||||
"-Wstrict-prototypes",
|
||||
"-Winvalid-pch",
|
||||
"-Wno-address-of-packed-member",
|
||||
]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("dialect_config") {
|
||||
cflags_c = [ "-std=c99" ]
|
||||
cflags_cc = [ "-std=c++11" ]
|
||||
}
|
||||
|
||||
config("misc_config") {
|
||||
defines = [ "__LITEOS__" ]
|
||||
if (!defined(LOSCFG_DEBUG_VERSION)) {
|
||||
defines += [ "NDEBUG" ]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-fno-pic",
|
||||
"-fno-builtin",
|
||||
"-fms-extensions",
|
||||
"-fno-strict-aliasing",
|
||||
"-fno-common",
|
||||
"-fsigned-char",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-fno-exceptions",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fno-short-enums",
|
||||
"-mno-unaligned-access",
|
||||
]
|
||||
|
||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-fno-aggressive-loop-optimizations" ]
|
||||
}
|
||||
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("los_config") {
|
||||
configs = [
|
||||
":arch_config",
|
||||
":kconfig_config",
|
||||
":stdinc_config",
|
||||
":dialect_config",
|
||||
":optimize_config",
|
||||
":ssp_config",
|
||||
":warn_config",
|
||||
":misc_config",
|
||||
]
|
||||
}
|
||||
|
||||
executable("liteos") {
|
||||
configs = [] # clear default configs
|
||||
configs += [ ":arch_config" ]
|
||||
configs += [ ":public" ]
|
||||
|
||||
ldflags = [
|
||||
"-static",
|
||||
"-nostdlib",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-Map=$liteos_name.map",
|
||||
"-Wl,--no-eh-frame-hdr",
|
||||
]
|
||||
|
||||
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
|
||||
libs = [ libgcc ]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
|
||||
inputs = [ "tools/build/liteos_llvm.ld" ]
|
||||
} else {
|
||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
||||
ldflags += [ "-Wl,-nostartfiles" ]
|
||||
inputs = [ "tools/build/liteos.ld" ]
|
||||
}
|
||||
|
||||
inputs += [ "$root_out_dir/board.ld" ]
|
||||
|
||||
output_dir = target_out_dir
|
||||
|
||||
deps = [
|
||||
"platform:copy_board.ld",
|
||||
":modules",
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_liteos") {
|
||||
deps = [ ":liteos" ]
|
||||
sources = [ "$target_out_dir/unstripped/bin/liteos" ]
|
||||
outputs = [ "$root_out_dir/$liteos_name" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_kernel_image") {
|
||||
deps = [ ":copy_liteos" ]
|
||||
exec_path = rebase_path(root_out_dir)
|
||||
|
||||
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
||||
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
||||
|
||||
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
|
||||
command += " && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
||||
}
|
||||
|
||||
config("public") {
|
||||
configs = [
|
||||
"arch:public",
|
||||
"platform:public",
|
||||
"kernel:public",
|
||||
"compat:public",
|
||||
"bsd:public",
|
||||
"fs:public",
|
||||
"drivers:public",
|
||||
"security:public",
|
||||
"net:public",
|
||||
"shell:public",
|
||||
"lib:public",
|
||||
]
|
||||
|
||||
configs += [
|
||||
"$HDFTOPDIR:public",
|
||||
"//drivers/liteos:public",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
configs += [ "$device_path:public" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("modules") {
|
||||
deps = [
|
||||
"arch",
|
||||
"bsd",
|
||||
"compat",
|
||||
"drivers",
|
||||
"fs",
|
||||
"kernel",
|
||||
"lib",
|
||||
"net",
|
||||
"platform",
|
||||
"security",
|
||||
"shell",
|
||||
"syscall",
|
||||
]
|
||||
|
||||
deps += [
|
||||
HDFTOPDIR,
|
||||
"//drivers/liteos",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
deps += [ device_path ]
|
||||
}
|
||||
}
|
||||
|
||||
group("apps") {
|
||||
deps = [ "apps" ]
|
||||
}
|
||||
|
||||
group("tests") {
|
||||
deps = [ "testsuites" ]
|
||||
}
|
||||
|
||||
group("kernel") {
|
||||
deps = [ ":build_kernel_image" ]
|
||||
}
|
||||
|
||||
group("liteos_a") {
|
||||
deps = [
|
||||
":apps",
|
||||
":kernel",
|
||||
":tests",
|
||||
]
|
||||
}
|
||||
|
||||
build_ext_component("make") {
|
||||
exec_path = rebase_path(".", root_build_dir)
|
||||
outdir = rebase_path("$target_out_dir/${target_name}_out")
|
||||
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\" \"$compile_prefix\" \"$liteos_config_file\""
|
||||
if (liteos_skip_make) {
|
||||
print("build_ext_component \"$target_name\" skipped:", command)
|
||||
command = "true"
|
||||
tee_enable = "false"
|
||||
if (board_name == "hi3516dv300" && enable_tee_ree) {
|
||||
tee_enable = "tee"
|
||||
}
|
||||
prebuilts = "sh build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\""
|
||||
outdir = rebase_path(get_path_info(".", "out_dir"))
|
||||
command = "make clean OUTDIR=$outdir && make rootfs VERSION=\"${ohos_version}\" -j 16 OUTDIR=$outdir"
|
||||
}
|
||||
|
||||
174
Kconfig
Normal file → Executable file
174
Kconfig
Normal file → Executable file
@@ -26,82 +26,43 @@
|
||||
# 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.
|
||||
|
||||
#
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see extra/config/Kconfig-language.txt
|
||||
#
|
||||
mainmenu "Huawei LiteOS Configuration"
|
||||
|
||||
menu "Compiler"
|
||||
choice
|
||||
prompt "Compiler type"
|
||||
prompt "LiteOS_Compiler_Type"
|
||||
default COMPILER_CLANG_LLVM
|
||||
help
|
||||
Choose compiler type.
|
||||
Enable arm-himix100 or aarch64-himix100 or compiler.
|
||||
|
||||
config COMPILER_GCC
|
||||
bool "GCC"
|
||||
|
||||
config CROSS_COMPILE
|
||||
string "GCC cross-compile toolchain prefix"
|
||||
depends on COMPILER_GCC
|
||||
default "arm-linux-ohoseabi-" if ARCH_ARM_AARCH32
|
||||
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"
|
||||
|
||||
config LLVM_TARGET
|
||||
string "Clang LLVM target"
|
||||
depends on COMPILER_CLANG_LLVM
|
||||
default "arm-liteos" if ARCH_ARM_AARCH32
|
||||
bool "clang-llvm"
|
||||
depends on PLATFORM_HI3518EV300 || PLATFORM_HI3516DV300 || PLATFORM_QEMU_ARM_VIRT_CA7
|
||||
|
||||
endchoice
|
||||
|
||||
config COMPILE_DEBUG
|
||||
bool "Enable debug options"
|
||||
default n
|
||||
help
|
||||
Answer Y to add -g option in compile command.
|
||||
|
||||
config COMPILE_OPTIMIZE
|
||||
bool "Enable code optimization options"
|
||||
default y
|
||||
help
|
||||
Answer Y to add optimization options for efficient code.
|
||||
The final binary size will be smaller and execute faster.
|
||||
But the debugging experience may be worst somehow.
|
||||
|
||||
config COMPILE_OPTIMIZE_SIZE
|
||||
bool "Enable code size optimization options" if COMPILE_OPTIMIZE
|
||||
default y
|
||||
help
|
||||
Answer Y to add optimization options for small code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be a bit longer.
|
||||
|
||||
config COMPILE_LTO
|
||||
bool "Enable link time optimization (LTO)" if COMPILE_OPTIMIZE_SIZE
|
||||
default y
|
||||
help
|
||||
Answer Y to add lto options for more smaller code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be much longer.
|
||||
|
||||
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/rootfs/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"
|
||||
@@ -112,59 +73,44 @@ 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 "fs/zpfs/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"
|
||||
config GDB
|
||||
bool "Enable gdb functions"
|
||||
config COMPILE_DEBUG
|
||||
bool "Enable GCC -g Option"
|
||||
default n
|
||||
help
|
||||
Answer Y to enable gdb functions.
|
||||
Answer Y to add -g option in gcc command. But the LiteOS size will be much larger.
|
||||
|
||||
config PLATFORM_ADAPT
|
||||
bool "Enable Os_adapt"
|
||||
@@ -175,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.
|
||||
|
||||
@@ -201,10 +146,8 @@ config ENABLE_MAGICKEY
|
||||
config THUMB
|
||||
bool "Enable Thumb"
|
||||
default n
|
||||
depends on ARCH_ARM
|
||||
help
|
||||
Answer Y to build thumb version. This will make LiteOS smaller.
|
||||
|
||||
config PLATFORM_DVFS
|
||||
bool "Enable Dvfs"
|
||||
default n
|
||||
@@ -213,19 +156,13 @@ 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
|
||||
help
|
||||
If you do not select this option that means you enable a release version for LiteOS.
|
||||
It also means you do not want to use debug modules, like shell,telnet,tftp,nfs and
|
||||
memory check, etc.
|
||||
It also means you do not want to use debug modules, like shell,telnet,tftp,
|
||||
,nfs,ramfs proc and memory check.
|
||||
If you select this option that means you enable a debug version for LiteOS.
|
||||
That means you want a opposite behaviour compared to release version.
|
||||
|
||||
@@ -259,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
|
||||
@@ -305,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
|
||||
@@ -320,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 ########################
|
||||
@@ -330,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
|
||||
source "$(DEVICE_PATH)/drivers/Kconfig"
|
||||
|
||||
source "drivers/char/mem/Kconfig"
|
||||
source "drivers/char/quickstart/Kconfig"
|
||||
source "drivers/char/random/Kconfig"
|
||||
source "drivers/char/video/Kconfig"
|
||||
source "drivers/char/trace/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"
|
||||
|
||||
286
Makefile
Normal file → Executable file
286
Makefile
Normal file → Executable file
@@ -27,57 +27,45 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
LITEOSTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
|
||||
export OS=$(shell uname -s)
|
||||
ifneq ($(OS), Linux)
|
||||
LITEOSTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTOPDIR))/./)
|
||||
endif
|
||||
|
||||
LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
|
||||
|
||||
export LITEOSTOPDIR
|
||||
export LITEOSTHIRDPARTY
|
||||
|
||||
RM = -rm -rf
|
||||
MAKE = make
|
||||
__LIBS = libs
|
||||
APPS = apps
|
||||
ROOTFSDIR = rootfsdir
|
||||
ROOTFS = rootfs
|
||||
|
||||
LITEOS_TARGET = liteos
|
||||
LITEOS_LIBS_TARGET = libs
|
||||
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
|
||||
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
|
||||
|
||||
ohos_kernel ?= liteos_a
|
||||
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
|
||||
ifneq ($(ohos_kernel),liteos_a)
|
||||
$(error The selected product ($(ohos_product)) is not a liteos_a kernel type product)
|
||||
endif
|
||||
|
||||
ifeq ($(PRODUCT_PATH),)
|
||||
PRODUCT_PATH:=$(ohos_product_path)
|
||||
endif
|
||||
|
||||
ifeq ($(DEVICE_PATH),)
|
||||
DEVICE_PATH:=$(ohos_device_path)
|
||||
endif
|
||||
|
||||
ifeq ($(TEE:1=y),y)
|
||||
tee = _tee
|
||||
endif
|
||||
ifeq ($(RELEASE:1=y),y)
|
||||
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/release$(tee).config
|
||||
else
|
||||
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
|
||||
endif
|
||||
|
||||
KCONFIG_CONFIG ?= $(CONFIG)
|
||||
SYSROOT_PATH ?= $(OUT)/sysroot
|
||||
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
|
||||
LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
||||
|
||||
# export los_config.mk related environment variables
|
||||
export LITEOS_MENUCONFIG_H
|
||||
export LITEOS_CONFIG_FILE
|
||||
|
||||
# export subdir Makefile related environment variables
|
||||
export SYSROOT_PATH
|
||||
export PRODUCT_PATH
|
||||
export DEVICE_PATH
|
||||
|
||||
# export kconfig related environment variables
|
||||
export CONFIG_=LOSCFG_
|
||||
export srctree=$(LITEOSTOPDIR)
|
||||
MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
|
||||
KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
ifeq ($(OS), Linux)
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/mconf
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/conf
|
||||
else
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/kconfig-mconf.exe
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/kconfig-conf.exe
|
||||
endif
|
||||
|
||||
$(shell env CONFIG_=$(CONFIG_) $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH))
|
||||
|
||||
-include $(LITEOSTOPDIR)/tools/build/config.mk
|
||||
|
||||
ifeq ($(LOSCFG_STORAGE_SPINOR), y)
|
||||
FSTYPE = jffs2
|
||||
@@ -93,118 +81,150 @@ FSTYPE = jffs2
|
||||
endif
|
||||
ROOTFS_DIR = $(OUT)/rootfs
|
||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||
VERSION =
|
||||
|
||||
define HELP =
|
||||
Usage: make [TARGET]... [PARAMETER=VALUE]...
|
||||
|
||||
Targets:
|
||||
help: display this help and exit
|
||||
clean: clean compiled objects
|
||||
cleanall: clean all build outputs
|
||||
all: make liteos kernel image and rootfs image (Default target)
|
||||
$(APPS): build all apps
|
||||
$(ROOTFS): make a original rootfs image
|
||||
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
|
||||
$(LITEOS_TARGET): make liteos kernel image
|
||||
update_config: update product kernel config (use menuconfig)
|
||||
xxconfig: invoke xxconfig command of kconfiglib (xxconfig is one of $(KCONFIG_CMDS))
|
||||
|
||||
Parameters:
|
||||
FSTYPE: value should be one of (jffs2 vfat yaffs2)
|
||||
TEE: boolean value(1 or y for true), enable tee
|
||||
RELEASE: boolean value(1 or y for true), build release version
|
||||
CONFIG: kernel config file to be use
|
||||
args: arguments for xxconfig command
|
||||
endef
|
||||
export HELP
|
||||
|
||||
all: $(LITEOS_TARGET) $(ROOTFS)
|
||||
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
|
||||
lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
|
||||
|
||||
help:
|
||||
$(HIDE)echo "$$HELP"
|
||||
$(HIDE)echo "-------------------------------------------------------"
|
||||
$(HIDE)echo "1.====make help: get help infomation of make"
|
||||
$(HIDE)echo "2.====make: make a debug version based the .config"
|
||||
$(HIDE)echo "3.====make debug: make a debug version based the .config"
|
||||
$(HIDE)echo "4.====make release: make a release version for all platform"
|
||||
$(HIDE)echo "5.====make release PLATFORM=xxx: make a release version only for platform xxx"
|
||||
$(HIDE)echo "6.====make rootfsdir: make a original rootfs dir"
|
||||
$(HIDE)echo "7.====make rootfs FSTYPE=***: make a original rootfs img"
|
||||
$(HIDE)echo "8.====make test: make the testsuits_app and put it into the rootfs dir"
|
||||
$(HIDE)echo "9.====make test_apps FSTYPE=***: make a rootfs img with the testsuits_app in it"
|
||||
$(HIDE)echo "xxx should be one of (hi3516cv300 hi3516ev200 hi3556av100/cortex-a53_aarch32 hi3559av100/cortex-a53_aarch64)"
|
||||
$(HIDE)echo "*** should be one of (jffs2)"
|
||||
$(HIDE)echo "-------------------------------------------------------"
|
||||
|
||||
sysroot:
|
||||
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
ifeq ($(origin SYSROOT_PATH),file)
|
||||
$(HIDE)mkdir -p $(SYSROOT_PATH)/build && cd $(SYSROOT_PATH)/build && \
|
||||
ln -snf $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/build/Makefile && \
|
||||
$(MAKE) TARGETS=liteos_a_user \
|
||||
ARCH=$(ARCH) \
|
||||
TARGET=$(LOSCFG_LLVM_TARGET) \
|
||||
ARCH_CFLAGS="$(LITEOS_CORE_COPTS) -w" \
|
||||
TOPDIR="$(LITEOSTOPDIR)/../.." \
|
||||
SYSROOTDIR="$(SYSROOT_PATH)" \
|
||||
CLANG="$(LITEOS_COMPILER_PATH)clang" \
|
||||
BUILD_ALL_MULTILIB=false \
|
||||
BUILD_DEBUG=$(if $(patsubst y,,$(or $(RELEASE:1=y),n)),true,false)
|
||||
endif
|
||||
debug:
|
||||
$(HIDE)echo "=============== make a debug version ==============="
|
||||
$(HIDE) $(MAKE) all
|
||||
|
||||
release:
|
||||
ifneq ($(PLATFORM),)
|
||||
$(HIDE)echo "=============== make a release version for platform $(PLATFORM) ==============="
|
||||
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh $(PLATFORM)
|
||||
else
|
||||
$(HIDE)echo "================make a release version for all platform ==============="
|
||||
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh
|
||||
endif
|
||||
|
||||
$(filter-out menuconfig,$(KCONFIG_CMDS)):
|
||||
$(HIDE)$@ $(args)
|
||||
##### make dynload #####
|
||||
-include $(LITEOS_MK_PATH)/dynload.mk
|
||||
|
||||
$(LITEOS_CONFIG_FILE): $(KCONFIG_CONFIG)
|
||||
$(HIDE)env KCONFIG_CONFIG=$< genconfig --config-out $@ --header-path $(LITEOS_MENUCONFIG_H)
|
||||
#-----need move when make version-----#
|
||||
##### make lib #####
|
||||
$(__LIBS): $(OUT) $(CXX_INCLUDE)
|
||||
|
||||
update_config menuconfig:
|
||||
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig $(args) && savedefconfig --out "$(CONFIG)"
|
||||
$(OUT): $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)mkdir -p $(OUT)/lib
|
||||
$(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \
|
||||
-I$(LITEOS_PLATFORM_BASE)/include -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
|
||||
-o $(LITEOS_PLATFORM_BASE)/board.ld -P
|
||||
|
||||
$(LITEOS_LIBS_TARGET): sysroot
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
||||
$(BUILD):
|
||||
$(HIDE)mkdir -p $(BUILD)
|
||||
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).map
|
||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).objsize
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).bin
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).sym.sorted
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).asm
|
||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).size
|
||||
$(LITEOS_LIBS_TARGET): $(__LIBS)
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir all || exit 1; \
|
||||
done
|
||||
$(HIDE)echo "=============== make lib done ==============="
|
||||
|
||||
$(OUT)/$(LITEOS_TARGET): $(LITEOS_LIBS_TARGET)
|
||||
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) -Map=$@.map -o $@ --start-group $(LITEOS_LIBDEP) --end-group
|
||||
$(OUT)/$(LITEOS_TARGET).map: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OUT)/$(LITEOS_TARGET).objsize: $(LITEOS_LIBS_TARGET)
|
||||
$(SIZE) -t --common $(OUT)/lib/*.a >$@
|
||||
$(OUT)/$(LITEOS_TARGET).bin: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(OUT)/$(LITEOS_TARGET).sym.sorted: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJDUMP) -t $< |sort >$@
|
||||
$(OUT)/$(LITEOS_TARGET).asm: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJDUMP) -d $< >$@
|
||||
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
|
||||
$(NM) -S --size-sort $< >$@
|
||||
##### make menuconfig #####
|
||||
menuconfig:$(MENUCONFIG_MCONF)
|
||||
$< $(KCONFIG_FILE_PATH)
|
||||
|
||||
$(APPS): sysroot
|
||||
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):
|
||||
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); \
|
||||
do $(MAKE) -C $$dir all || exit 1; \
|
||||
done
|
||||
|
||||
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group
|
||||
# $(SIZE) -t --common $(OUT)/lib/*.a >$(OUT)/$@.objsize
|
||||
$(OBJCOPY) -O binary $(OUT)/$@ $(LITEOS_TARGET_DIR)/$@.bin
|
||||
$(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted
|
||||
$(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
|
||||
# $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
|
||||
|
||||
$(APPS): $(LITEOS_TARGET)
|
||||
$(HIDE)$(MAKE) -C apps all
|
||||
|
||||
$(ROOTFS): $(APPS)
|
||||
prepare:
|
||||
$(HIDE)mkdir -p $(OUT)/musl
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(GPP) $(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 -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libgcc_s.so.1) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libgcc_s.so.1 $(OUT)/musl
|
||||
$(STRIP) $(OUT)/musl/*
|
||||
endif
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR)
|
||||
$(HIDE)shopt -s nullglob && $(STRIP) $(ROOTFS_DIR)/bin/* $(ROOTFS_DIR)/lib/*
|
||||
|
||||
$(ROOTFSDIR): prepare $(APPS)
|
||||
$(HIDE)$(MAKE) clean -C apps
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR)
|
||||
ifneq ($(VERSION),)
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
|
||||
endif
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
|
||||
|
||||
$(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)if [ -d $(SYSROOT_PATH)/build ]; then $(MAKE) -C $(SYSROOT_PATH)/build clean; fi
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS) apps; do $(MAKE) -C $$dir clean || exit 1; done
|
||||
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
|
||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir clean|| exit 1; \
|
||||
done
|
||||
$(HIDE)$(MAKE) -C apps clean
|
||||
$(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
|
||||
$(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_CONFIG_FILE)
|
||||
$(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"
|
||||
|
||||
.PHONY: all clean cleanall sysroot help update_config
|
||||
.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET) $(KCONFIG_CONFIG)
|
||||
cleanrootfs:
|
||||
$(HIDE)$(RM) $(OUT)/rootfs
|
||||
$(HIDE)$(RM) $(OUT)/rootfs.zip
|
||||
$(HIDE)$(RM) $(OUT)/rootfs.img
|
||||
|
||||
update_all_config:
|
||||
$(HIDE)shopt -s globstar && for f in tools/build/config/**/*.config ; \
|
||||
do \
|
||||
echo updating $$f; \
|
||||
test -f $$f && cp $$f .config && $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig $$f $(KCONFIG_FILE_PATH); \
|
||||
done
|
||||
|
||||
%.config:
|
||||
$(HIDE)test -f tools/build/config/$@ && cp tools/build/config/$@ .config && $(MENUCONFIG_MCONF) $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig tools/build/config/$@ $(KCONFIG_FILE_PATH)
|
||||
|
||||
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config
|
||||
|
||||
83
OAT.xml
83
OAT.xml
@@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
|
||||
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="文件属于FreeBSD仓库软连接,本仓库屏蔽告警,在FreeBSD仓库进行处理">
|
||||
<filteritem type="filepath" name="bsd/.*" desc="文件属于FreeBSD仓库软连接,本仓库屏蔽告警,在FreeBSD仓库进行处理"/>
|
||||
<filteritem type="filepath" name="kernel/extended" desc="文件属于Nuttx仓库软连接,本仓库屏蔽告警,在Nuttx仓库进行处理"/>
|
||||
<filteritem type="filepath" name="fs/include/fs" desc="文件属于Nuttx仓库软连接,本仓库屏蔽告警,在Nuttx仓库进行处理"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
|
||||
</filefilterlist>
|
||||
<licensematcherlist>
|
||||
<!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
|
||||
<licensetext name="
|
||||
uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
<licensetext name="
|
||||
uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
</licensematcher-->
|
||||
</licensematcherlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
13
README.md
13
README.md
@@ -67,27 +67,26 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
|
||||
|
||||
## Usage<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on both development boards.
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3518-development-board.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3516-development-board.md). You can develop and run your applications based on both development boards.
|
||||
|
||||
### Preparations<a name="section1579912573329"></a>
|
||||
|
||||
You need to set up the compilation environment on Linux.
|
||||
|
||||
- [Compilation environment on Linux](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-lin.md)
|
||||
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-setting.md).
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-setting.md).
|
||||
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3518-development-environment.md).
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3516-development-environment.md).
|
||||
|
||||
### Source Code Acquisition<a name="section11443189655"></a>
|
||||
|
||||
Download and decompress a set of source code on a Linux server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
|
||||
Download and decompress a set of source code on a Linux server to acquire the [source code](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz). For more acquisition methods, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/source-code-acquisition.md).
|
||||
|
||||
### Compilation and Building<a name="section2081013992812"></a>
|
||||
|
||||
For details about how to develop the first application, see:
|
||||
|
||||
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-running.md)
|
||||
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3518.md)
|
||||
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-running.md)
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3516.md)
|
||||
|
||||
## Repositories Involved<a name="section1371113476307"></a>
|
||||
|
||||
|
||||
@@ -1,99 +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/oem_minitinier_des_3518.md))、Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
|
||||
|
||||
### 準備<a name="section1579912573329"></a>
|
||||
|
||||
開發者需要在Linux上搭建編譯環境:
|
||||
|
||||
- [Ubuntu編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- Hi3516DV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
|
||||
### 獲取源碼<a name="section11443189655"></a>
|
||||
|
||||
在Linux服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||
|
||||
### 編譯構建<a name="section2081013992812"></a>
|
||||
|
||||
開發者開發第一個應用程序可參考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.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**
|
||||
13
README_zh.md
13
README_zh.md
@@ -67,27 +67,26 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
|
||||
|
||||
## 使用说明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))单板,开发者可基于两种单板开发运行自己的应用程序。
|
||||
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))单板,开发者可基于两种单板开发运行自己的应用程序。
|
||||
|
||||
### 准备<a name="section1579912573329"></a>
|
||||
|
||||
开发者需要在Linux上搭建编译环境:
|
||||
|
||||
- [Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%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>
|
||||
|
||||
在Linux服务器上下载并解压一套源代码,源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||
在Linux服务器上下载并解压一套源代码,获取源码([下载链接](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz))。更多源码获取方式,参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md)。
|
||||
|
||||
### 编译构建<a name="section2081013992812"></a>
|
||||
|
||||
开发者开发第一个应用程序可参考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3518%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.md);
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3516%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%A4%BA%E4%BE%8B.md)。
|
||||
|
||||
## 相关仓<a name="section1371113476307"></a>
|
||||
|
||||
|
||||
20
apps/Makefile
Normal file → Executable file
20
apps/Makefile
Normal file → Executable file
@@ -27,21 +27,23 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
APPSTOPDIR := $(shell pwd)
|
||||
LITEOSTOPDIR ?= $(APPSTOPDIR)/..
|
||||
export LITEOSTOPDIR
|
||||
export APPSTOPDIR
|
||||
include ../.config
|
||||
include ./module.mk
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
HIDE := @
|
||||
APPS := app
|
||||
|
||||
all:
|
||||
all: $(APPS)
|
||||
|
||||
# Make
|
||||
$(APPS):
|
||||
ifneq ($(APP_SUBDIRS), )
|
||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir || exit 1; done
|
||||
endif
|
||||
|
||||
clean:
|
||||
ifneq ($(APP_SUBDIRS), )
|
||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done
|
||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean; done
|
||||
endif
|
||||
|
||||
.PHONY: all clean
|
||||
.PHONY: all $(APPS) clean
|
||||
|
||||
114
apps/app.mk
114
apps/app.mk
@@ -1,114 +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.
|
||||
|
||||
OBJOUT := $(BUILD)$(dir $(subst $(LITEOSTOPDIR),,$(shell pwd)))$(APP_NAME)
|
||||
|
||||
APP := $(OUT)/bin/$(APP_NAME)
|
||||
|
||||
# create a separate list of objects per source type
|
||||
|
||||
LOCAL_CSRCS := $(filter %.c,$(LOCAL_SRCS))
|
||||
LOCAL_CPPSRCS := $(filter %.cpp,$(LOCAL_SRCS))
|
||||
LOCAL_ASMSRCS := $(filter %.S,$(LOCAL_SRCS))
|
||||
LOCAL_ASMSRCS2 := $(filter %.s,$(LOCAL_SRCS))
|
||||
LOCAL_CCSRCS := $(filter %.cc,$(LOCAL_SRCS))
|
||||
|
||||
LOCAL_COBJS := $(patsubst %.c,$(OBJOUT)/%.o,$(LOCAL_CSRCS))
|
||||
LOCAL_CPPOBJS := $(patsubst %.cpp,$(OBJOUT)/%.o,$(LOCAL_CPPSRCS))
|
||||
LOCAL_ASMOBJS := $(patsubst %.S,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS))
|
||||
LOCAL_ASMOBJS2 := $(patsubst %.s,$(OBJOUT)/%.o,$(LOCAL_ASMSRCS2))
|
||||
LOCAL_CCOBJS := $(patsubst %.cc,$(OBJOUT)/%.o,$(LOCAL_CCSRCS))
|
||||
|
||||
LOCAL_OBJS := $(LOCAL_COBJS) $(LOCAL_CPPOBJS) $(LOCAL_ASMOBJS) $(LOCAL_ASMOBJS2) $(LOCAL_CCOBJS)
|
||||
|
||||
LOCAL_CGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CHS))
|
||||
LOCAL_CPPGCH := $(patsubst %.h,%.h.gch,$(LOCAL_CPPHS))
|
||||
|
||||
all : $(APP)
|
||||
|
||||
define ECHO =
|
||||
ifeq ($$(HIDE),@)
|
||||
_$(1) := $($(1))
|
||||
$(1) = echo " $(1)" $$(patsubst $$(OUT)/%,%,$$@) && $$(_$(1))
|
||||
endif
|
||||
endef
|
||||
$(foreach cmd,CC GPP AS,$(eval $(call ECHO,$(cmd))))
|
||||
|
||||
LOCAL_FLAGS += -MD -MP
|
||||
-include $(LOCAL_OBJS:%.o=%.d)
|
||||
|
||||
$(LOCAL_COBJS): $(OBJOUT)/%.o: %.c
|
||||
$(HIDE)$(OBJ_MKDIR)
|
||||
$(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) -c $< -o $@
|
||||
|
||||
$(LOCAL_CPPOBJS): $(OBJOUT)/%.o: %.cpp
|
||||
$(HIDE)$(OBJ_MKDIR)
|
||||
$(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
|
||||
|
||||
$(LOCAL_ASMOBJS): $(OBJOUT)/%.o: %.S
|
||||
$(HIDE)$(OBJ_MKDIR)
|
||||
$(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
|
||||
|
||||
$(LOCAL_ASMOBJS2): $(OBJOUT)/%.o: %.s
|
||||
$(HIDE)$(OBJ_MKDIR)
|
||||
$(HIDE)$(AS) $(ASFLAGS) $(LOCAL_FLAGS) $(LOCAL_ASFLAGS) -c $< -o $@
|
||||
|
||||
$(LOCAL_CCOBJS): $(OBJOUT)/%.o: %.cc
|
||||
$(HIDE)$(OBJ_MKDIR)
|
||||
$(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -c $< -o $@
|
||||
|
||||
$(LOCAL_CGCH): %.h.gch : %.h
|
||||
$(HIDE)$(CC) $(CFLAGS) $(LOCAL_FLAGS) $(LOCAL_CFLAGS) $> $^
|
||||
|
||||
$(LOCAL_CPPGCH): %.h.gch : %.h
|
||||
$(HIDE)$(GPP) $(CXXFLAGS) $(LOCAL_FLAGS) $(LOCAL_CPPFLAGS) -x c++-header $> $^
|
||||
|
||||
LOCAL_GCH := $(LOCAL_CGCH) $(LOCAL_CPPGCH)
|
||||
|
||||
$(LOCAL_OBJS): $(LOCAL_GCH)
|
||||
$(APP): $(LOCAL_OBJS)
|
||||
$(HIDE)$(OBJ_MKDIR)
|
||||
$(HIDE)$(GPP) $(LDFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(APP) $(OBJOUT) $(LOCAL_GCH) *.bak *~
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
# clear some variables we set here
|
||||
LOCAL_CSRCS :=
|
||||
LOCAL_CPPSRCS :=
|
||||
LOCAL_ASMSRCS :=
|
||||
LOCAL_COBJS :=
|
||||
LOCAL_CPPOBJS :=
|
||||
LOCAL_ASMOBJS :=
|
||||
LOCAL_ASMOBJS2 :=
|
||||
|
||||
# LOCAL_OBJS is passed back
|
||||
#LOCAL_OBJS :=
|
||||
66
apps/config.mk
Normal file → Executable file
66
apps/config.mk
Normal file → Executable file
@@ -27,54 +27,34 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# common dir config
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
# output dir config
|
||||
OBJOUT := $(APPSTOPDIR)/out
|
||||
APPSOUT := $(OBJOUT)/apps
|
||||
LIBSOUT := $(OBJOUT)/libs
|
||||
IMGOUT := $(OUT)
|
||||
|
||||
# common flags config
|
||||
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_XOPEN_SOURCE=700 $(LITEOS_GCOV_OPTS)
|
||||
BASE_OPTS := -ffunction-sections -fdata-sections -fno-omit-frame-pointer -D_GNU_SOURCE \
|
||||
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
ASFLAGS :=
|
||||
CFLAGS := $(LITEOS_COPTS) $(BASE_OPTS) -fPIE
|
||||
CXXFLAGS := $(LITEOS_CXXOPTS) $(BASE_OPTS) -fPIE
|
||||
LDFLAGS := $(LITEOS_CORE_COPTS) -pie -Wl,-z,relro,-z,now -O2
|
||||
|
||||
CFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib,$(CFLAGS))
|
||||
CXXFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib -nostdinc++,$(CXXFLAGS))
|
||||
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=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
||||
LDCXXFLGS := -lc++ -lc++abi -lc
|
||||
else
|
||||
BASE_OPTS += -Wl,-z,relro,-z,now
|
||||
LDCXXFLGS := -lstdc++ -lsupc++ -lc
|
||||
endif
|
||||
COMMON_INCLUDE := -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
||||
|
||||
# alias variable config
|
||||
HIDE := @
|
||||
MAKE := make
|
||||
RM := rm -rf
|
||||
CP := cp -rf
|
||||
MV := mv -f
|
||||
|
||||
APP := $(APPSTOPDIR)/app.mk
|
||||
|
||||
##build modules config##
|
||||
APP_SUBDIRS :=
|
||||
|
||||
ifeq ($(LOSCFG_SHELL), y)
|
||||
APP_SUBDIRS += shell
|
||||
APP_SUBDIRS += mksh
|
||||
APP_SUBDIRS += toybox
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
||||
APP_SUBDIRS += init
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
|
||||
APP_SUBDIRS += tftp
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_TRACE), y)
|
||||
APP_SUBDIRS += trace
|
||||
endif
|
||||
|
||||
# clear all local variables
|
||||
LOCAL_FLAGS :=
|
||||
LOCAL_CFLAGS :=
|
||||
LOCAL_CPPFLAGS :=
|
||||
LOCAL_ASFLAGS :=
|
||||
LOCAL_SRCS :=
|
||||
LOCAL_CHS :=
|
||||
LOCAL_CPPHS :=
|
||||
RM := -rm -rf
|
||||
CP := -cp -rf
|
||||
MV := -mv
|
||||
|
||||
36
apps/init/Makefile
Normal file → Executable file
36
apps/init/Makefile
Normal file → Executable file
@@ -27,15 +27,43 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
INIT_DIR := $(dir $(shell pwd))/init/
|
||||
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(INIT_DIR)/../config.mk
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
LOCAL_SRCS := src/init.c
|
||||
LOCAL_OBJ := src/init.o
|
||||
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses -Wnonnull $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_QUICK_START), y)
|
||||
LDFLAGS += --static
|
||||
LDCFLAGS += --static
|
||||
CFLAGS += -DLOSCFG_QUICK_START
|
||||
endif
|
||||
|
||||
include $(APP)
|
||||
INITNAME := init
|
||||
|
||||
all: $(INITNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(CFLAGS) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(INITNAME):$(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(INITNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(INITNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(INITNAME)
|
||||
|
||||
.PHONY: all $(INITNAME) clean
|
||||
|
||||
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,99 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("mksh") {
|
||||
deps = [ ":build_mksh" ]
|
||||
}
|
||||
|
||||
copy("copy_mksh_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/mksh" ]
|
||||
outputs = [ "$target_out_dir/mksh_build" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_mksh") {
|
||||
deps = [ ":copy_mksh_src" ]
|
||||
deps += [ "//prebuilts/lite/sysroot" ]
|
||||
exec_path = rebase_path("$target_out_dir/mksh_build")
|
||||
|
||||
cflags = [
|
||||
"-flto",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fstack-protector-strong",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
"-DMKSH_DISABLE_TTY_WARNING",
|
||||
"-DMKSH_SMALL=1",
|
||||
"-DMKSH_ASSUME_UTF8=1",
|
||||
"-DMKSH_SMALL_BUT_FAST=0",
|
||||
"-DMKSH_S_NOVI=1",
|
||||
"-DHAVE_CAN_FSTACKPROTECTORSTRONG=1",
|
||||
"-DMKSH_LESS_CMDLINE_EDITING",
|
||||
"-DMKSH_LESS_BUILDINS",
|
||||
"-DMKSH_NO_INITCOMS",
|
||||
"-DADAPT_FOR_LITEOS_A",
|
||||
]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-Oz" ]
|
||||
} else {
|
||||
cflags += [ "-O2" ]
|
||||
}
|
||||
cflags = string_join(" ", cflags)
|
||||
|
||||
extra_flags = string_join(" ", target_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
extra_flags += " --target=$target_triple"
|
||||
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
|
||||
}
|
||||
|
||||
command = "rm -rf .git && env"
|
||||
command += " CC=\"$ohos_current_cc_command\""
|
||||
command += " TARGET_OS=OpenHarmony"
|
||||
command += " CFLAGS=\"$cflags $extra_flags\""
|
||||
command += " LDFLAGS=\"-Wl,--gc-sections -flto -O2\""
|
||||
command += " sh ./Build.sh -r"
|
||||
|
||||
# copy mksh and .mkshrc to out dir
|
||||
command += " && mkdir -p "
|
||||
command += rebase_path("$root_out_dir/bin", exec_path)
|
||||
command += " && install -D mksh "
|
||||
command += rebase_path("$root_out_dir/unstripped/bin/mksh", exec_path)
|
||||
command += " && $ohos_current_strip_command mksh -o "
|
||||
command += rebase_path("$root_out_dir/bin/mksh", exec_path)
|
||||
command += " && install -D .mkshrc "
|
||||
command += rebase_path("$root_out_dir/etc/.mkshrc", exec_path)
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/unstripped/bin/mksh",
|
||||
"$root_out_dir/bin/mksh",
|
||||
"$root_out_dir/etc/.mkshrc",
|
||||
]
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
BUILD_DIR := $(OUT)/mksh_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
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
|
||||
CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
CFLAGS += -Wno-error
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
$(HIDE)cd $(BUILD_DIR) && sh ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
else
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/mksh/. $(BUILD_DIR)
|
||||
$(HIDE)cd $(BUILD_DIR) && CC="$(CC)" TARGET_OS=OpenHarmony CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" sh ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
endif
|
||||
$(HIDE)mkdir -p $(OUT)/bin/ $(OUT)/etc/
|
||||
$(HIDE)$(STRIP) $(BUILD_DIR)/mksh -o $(OUT)/bin/mksh
|
||||
$(HIDE)$(CP) $(BUILD_DIR)/.mkshrc $(OUT)/etc/
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
.PHONY: all clean
|
||||
16
kernel/extended/hook/Makefile → apps/module.mk
Normal file → Executable file
16
kernel/extended/hook/Makefile → apps/module.mk
Normal file → Executable file
@@ -27,10 +27,18 @@
|
||||
# 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
|
||||
APP_SUBDIRS :=
|
||||
|
||||
MODULE_NAME := $(notdir $(shell pwd))
|
||||
##compile modules config##
|
||||
|
||||
LOCAL_SRCS := $(wildcard *.c)
|
||||
ifeq ($(LOSCFG_SHELL), y)
|
||||
APP_SUBDIRS += shell
|
||||
endif
|
||||
|
||||
include $(MODULE)
|
||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
||||
APP_SUBDIRS += init
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
|
||||
APP_SUBDIRS += tftp
|
||||
endif
|
||||
@@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("shell") {
|
||||
sources = [
|
||||
"builtin/cd.c",
|
||||
"src/main.c",
|
||||
"src/shcmd.c",
|
||||
"src/shcmdparse.c",
|
||||
"src/shmsg.c",
|
||||
]
|
||||
|
||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
51
apps/shell/Makefile
Normal file → Executable file
51
apps/shell/Makefile
Normal file → Executable file
@@ -27,19 +27,52 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
SHELL_DIR := $(dir $(shell pwd))/shell/
|
||||
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(SHELL_DIR)/../config.mk
|
||||
APPS_OUT := $(OUT)/bin
|
||||
|
||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||
SECUREC_INCLUDE := $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
||||
|
||||
LOCAL_SRCS = $(wildcard src/*.c builtin/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
|
||||
LOCAL_SRCS = $(wildcard src/main.c)\
|
||||
$(wildcard src/shcmd.c)\
|
||||
$(wildcard src/shmsg.c)\
|
||||
$(wildcard src/shcmdparse.c)\
|
||||
$(wildcard builtin/cd.c)
|
||||
LOCAL_SRCS += $(wildcard $(LITEOSTHIRDPARTY)/bounds_checking_function/src/*.c)
|
||||
LOCAL_OBJ := $(LOCAL_SRCS:.c=.o)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I include \
|
||||
-I $(SECUREC_DIR)/include
|
||||
-I $(SHELL_DIR)/include/ \
|
||||
-I $(SECUREC_INCLUDE)\
|
||||
|
||||
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||
LOCAL_FLAGS += $(CFLAGS)
|
||||
|
||||
include $(APP)
|
||||
LDPATH := -L$(SHELL_DIR)/
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
SHELLNAME := shell
|
||||
|
||||
all: $(SHELLNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(SHELLNAME): $(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(SHELLNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(SHELLNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(SHELLNAME)
|
||||
|
||||
.PHONY: all $(SHELLNAME) clean
|
||||
|
||||
17
apps/shell/builtin/cd.c
Normal file → Executable file
17
apps/shell/builtin/cd.c
Normal file → Executable file
@@ -29,12 +29,19 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include "unistd.h"
|
||||
#include "shcmd.h"
|
||||
#include "sherr.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
int Chdir(const char *tgtDir)
|
||||
{
|
||||
@@ -46,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)
|
||||
|
||||
/**
|
||||
|
||||
10
apps/shell/include/shmsg.h
Normal file → Executable file
10
apps/shell/include/shmsg.h
Normal file → Executable file
@@ -43,13 +43,8 @@ extern "C" {
|
||||
#define SHELL_ENTRY_STACKSIZE 0x1000
|
||||
#define SHELL_TASK_STACKSIZE 0x3000
|
||||
|
||||
#define SHELL_EXEC_COMMAND "exec"
|
||||
#define SHELL_EXEC_COMMAND_BYTES 4
|
||||
#define CMD_EXEC_COMMAND SHELL_EXEC_COMMAND" "
|
||||
#define CMD_EXEC_COMMAND_BYTES (SHELL_EXEC_COMMAND_BYTES+1)
|
||||
#define CMD_EXIT_COMMAND "exit"
|
||||
#define CMD_EXIT_COMMAND_BYTES 4
|
||||
#define CMD_EXIT_CODE_BASE_DEC 10
|
||||
#define SHELL_EXEC_COMMAND "exec "
|
||||
#define SHELL_EXEC_COMMAND_BYTES 5
|
||||
|
||||
#define CONSOLE_IOC_MAGIC 'c'
|
||||
#define CONSOLE_CONTROL_REG_USERTASK _IO(CONSOLE_IOC_MAGIC, 7)
|
||||
@@ -62,7 +57,6 @@ extern "C" {
|
||||
typedef void (*OutputFunc)(const char *fmt, ...);
|
||||
extern int ShellTaskInit(ShellCB *shellCB);
|
||||
extern int ShellEntryInit(ShellCB *shellCB);
|
||||
extern void ChildExec(const char *cmdName, char *const paramArray[]);
|
||||
extern void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB);
|
||||
extern int ShellNotify(ShellCB *shellCB);
|
||||
|
||||
|
||||
6
apps/shell/include/show.h
Normal file → Executable file
6
apps/shell/include/show.h
Normal file → Executable file
@@ -42,10 +42,10 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern char *OsShellGetWorkingDirtectory(void);
|
||||
extern unsigned int OsShellInit(void);
|
||||
extern char *OsShellGetWorkingDirtectory();
|
||||
extern unsigned int OsShellInit();
|
||||
extern int OsShellDeinit(ShellCB *shellCB);
|
||||
extern ShellCB *OsGetShellCb(void);
|
||||
extern ShellCB *OsGetShellCb();
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
52
apps/shell/src/main.c
Normal file → Executable file
52
apps/shell/src/main.c
Normal file → Executable file
@@ -29,15 +29,18 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "show.h"
|
||||
#include "shmsg.h"
|
||||
#include "shcmd.h"
|
||||
#include "semaphore.h"
|
||||
#include "securec.h"
|
||||
#include "unistd.h"
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
ShellCB *g_shellCB = NULL;
|
||||
|
||||
@@ -90,47 +93,11 @@ OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int DoShellExec(char **argv)
|
||||
{
|
||||
int i, j;
|
||||
int len = 0;
|
||||
int ret = SH_NOK;
|
||||
char *cmdLine = NULL;
|
||||
|
||||
if (strncmp(argv[0], SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
|
||||
ChildExec(argv[1], argv + 1);
|
||||
}
|
||||
for (i = 0; argv[i]; i++) {
|
||||
len += strlen(argv[i]);
|
||||
}
|
||||
len += i + 1;
|
||||
cmdLine = (char *)malloc(len);
|
||||
if (!cmdLine) {
|
||||
return ret;
|
||||
}
|
||||
memset_s(cmdLine, len, 0, len);
|
||||
|
||||
for(j = 0; j < i; j++) {
|
||||
strcat_s(cmdLine, len, argv[j]);
|
||||
strcat_s(cmdLine, len, " ");
|
||||
}
|
||||
|
||||
cmdLine[len - 2] = '\0';
|
||||
ret = syscall(__NR_shellexec, argv[0], cmdLine);
|
||||
free(cmdLine);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main()
|
||||
{
|
||||
int ret = SH_NOK;
|
||||
ShellCB *shellCB = NULL;
|
||||
|
||||
if (argc > 1) {
|
||||
ret = DoShellExec(argv + 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
|
||||
@@ -172,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
|
||||
|
||||
121
apps/shell/src/shmsg.c
Normal file → Executable file
121
apps/shell/src/shmsg.c
Normal file → Executable file
@@ -29,8 +29,6 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "stdio.h"
|
||||
#include "unistd.h"
|
||||
@@ -44,10 +42,12 @@
|
||||
#include "shell_pri.h"
|
||||
#include "shcmd.h"
|
||||
|
||||
#define CHAR_CTRL_C '\x03'
|
||||
#define CHAR_CTRL_DEL '\x7F'
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define VISIABLE_CHAR(ch) ((ch) > 0x1F && (ch) < 0x7F)
|
||||
|
||||
char *GetCmdline(ShellCB *shellCB)
|
||||
{
|
||||
@@ -205,21 +205,7 @@ void ParseEnterKey(OutputFunc outputFunc, ShellCB *shellCB)
|
||||
shellCB->shellBuf[shellCB->shellBufOffset] = '\0';
|
||||
}
|
||||
NOTIFY:
|
||||
shellCB->shellBufOffset = 0;
|
||||
ShellTaskNotify(shellCB);
|
||||
}
|
||||
|
||||
void ParseCancelKey(OutputFunc outputFunc, ShellCB *shellCB)
|
||||
{
|
||||
if ((shellCB == NULL) || (outputFunc == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shellCB->shellBufOffset <= (SHOW_MAX_LEN - 1)) {
|
||||
shellCB->shellBuf[0] = CHAR_CTRL_C;
|
||||
shellCB->shellBuf[1] = '\0';
|
||||
}
|
||||
|
||||
outputFunc("\n");
|
||||
shellCB->shellBufOffset = 0;
|
||||
ShellTaskNotify(shellCB);
|
||||
}
|
||||
@@ -255,7 +241,7 @@ void ParseTabKey(OutputFunc outputFunc, ShellCB *shellCB)
|
||||
|
||||
void ParseNormalChar(char ch, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
{
|
||||
if ((shellCB == NULL) || (outputFunc == NULL) || !VISIABLE_CHAR(ch)) {
|
||||
if ((shellCB == NULL) || (outputFunc == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -273,7 +259,7 @@ void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
const char ch = c;
|
||||
int ret;
|
||||
|
||||
if ((shellCB->shellBufOffset == 0) && (ch != '\n') && (ch != CHAR_CTRL_C) && (ch != '\0')) {
|
||||
if ((shellCB->shellBufOffset == 0) && (ch != '\n') && (ch != '\0')) {
|
||||
(void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
|
||||
}
|
||||
|
||||
@@ -282,11 +268,8 @@ void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB)
|
||||
case '\n': /* enter */
|
||||
ParseEnterKey(outputFunc, shellCB);
|
||||
break;
|
||||
case CHAR_CTRL_C: /* ctrl + c */
|
||||
ParseCancelKey(outputFunc, shellCB);
|
||||
break;
|
||||
case '\b': /* backspace */
|
||||
case CHAR_CTRL_DEL: /* delete(0x7F) */
|
||||
case 0x7F: /* delete(0x7F) */
|
||||
ParseDeleteKey(outputFunc, shellCB);
|
||||
break;
|
||||
case '\t': /* tab */
|
||||
@@ -351,80 +334,29 @@ char *GetCmdName(const char *cmdline, unsigned int len)
|
||||
return cmdName;
|
||||
}
|
||||
|
||||
void ChildExec(const char *cmdName, char *const paramArray[])
|
||||
{
|
||||
int ret;
|
||||
pid_t gid;
|
||||
|
||||
ret = setpgrp();
|
||||
if (ret == -1) {
|
||||
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(cmdName, paramArray, NULL);
|
||||
if (ret == -1) {
|
||||
perror("execve");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (strlen(cmdName) != CMD_EXIT_COMMAND_BYTES || strncmp(cmdName, CMD_EXIT_COMMAND, CMD_EXIT_COMMAND_BYTES) != 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cmdParsed->paramCnt > 1) {
|
||||
printf("exit: too many arguments\n");
|
||||
return -1;
|
||||
}
|
||||
if (cmdParsed->paramCnt == 1) {
|
||||
char *p;
|
||||
ret = strtol(cmdParsed->paramArray[0], &p, CMD_EXIT_CODE_BASE_DEC);
|
||||
if (*p != '\0') {
|
||||
printf("exit: bad number: %s\n", cmdParsed->paramArray[0]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, const CmdParsed *cmdParsed)
|
||||
{
|
||||
int ret;
|
||||
pid_t forkPid;
|
||||
|
||||
if (strncmp(cmdline, CMD_EXEC_COMMAND, CMD_EXEC_COMMAND_BYTES) == 0) {
|
||||
if (strncmp(cmdline, SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
|
||||
forkPid = fork();
|
||||
if (forkPid < 0) {
|
||||
printf("Faild to fork from shell\n");
|
||||
return;
|
||||
} else if (forkPid == 0) {
|
||||
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray);
|
||||
} else {
|
||||
waitpid(forkPid, 0, 0);
|
||||
ret = tcsetpgrp(STDIN_FILENO, getpid());
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
ret = setpgrp();
|
||||
if (ret == -1) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = execve((const char *)cmdParsed->paramArray[0], (char * const *)cmdParsed->paramArray, NULL);
|
||||
if (ret == -1) {
|
||||
perror("execve");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (CheckExit(cmdName, cmdParsed) < 0) {
|
||||
return;
|
||||
}
|
||||
(void)syscall(__NR_shellexec, cmdName, cmdline);
|
||||
}
|
||||
}
|
||||
@@ -479,7 +411,7 @@ unsigned int PreHandleCmdline(const char *input, char **output, unsigned int *ou
|
||||
unsigned int removeLen = strlen("./"); /* "./" needs to be removed if it exists */
|
||||
unsigned int ret;
|
||||
char *newCmd = NULL;
|
||||
char *execCmd = CMD_EXEC_COMMAND;
|
||||
char *execCmd = SHELL_EXEC_COMMAND;
|
||||
const char *cmdBuf = input;
|
||||
unsigned int cmdBufLen = strlen(cmdBuf);
|
||||
char *shiftStr = (char *)malloc(cmdBufLen + 1);
|
||||
@@ -582,11 +514,7 @@ static void ShellCmdProcess(ShellCB *shellCB)
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
if (buf[0] == CHAR_CTRL_C) {
|
||||
printf("^C");
|
||||
buf[0] = '\n';
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
ExecCmdline(buf);
|
||||
ShellSaveHistoryCmd(buf, shellCB);
|
||||
shellCB->cmdMaskKeyLink = shellCB->cmdHistoryKeyLink;
|
||||
@@ -649,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)
|
||||
@@ -712,3 +640,8 @@ int ShellEntryInit(ShellCB *shellCB)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("tftp") {
|
||||
sources = [
|
||||
"src/main.c",
|
||||
"src/tftpc.c",
|
||||
]
|
||||
|
||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -27,19 +27,51 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
ROOT_DIR := $(dir $(shell pwd))/tftp/
|
||||
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(ROOT_DIR)/../config.mk
|
||||
APPS_OUT := $(OUT)/bin
|
||||
|
||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||
|
||||
LOCAL_SRCS = $(wildcard src/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncpy_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memcpy_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memset_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncat_s.c)
|
||||
LOCAL_OBJ := $(LOCAL_SRCS:.c=.o)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I include \
|
||||
-I $(SECUREC_DIR)/include
|
||||
-I $(ROOT_DIR)/include/ \
|
||||
-I $(SECUREC_DIR)/include/\
|
||||
|
||||
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||
LOCAL_FLAGS += $(CFLAGS)
|
||||
|
||||
include $(APP)
|
||||
LDPATH := -L$(ROOT_DIR)/
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
TARGETNAME := tftp
|
||||
|
||||
all: $(TARGETNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(TARGETNAME): $(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(TARGETNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(TARGETNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(TARGETNAME)
|
||||
|
||||
.PHONY: all $(TARGETNAME) clean
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("toybox") {
|
||||
deps = [ ":build_toybox" ]
|
||||
}
|
||||
|
||||
copy("copy_toybox_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/toybox" ]
|
||||
outputs = [ "$target_out_dir/toybox_build" ]
|
||||
}
|
||||
|
||||
copy("copy_toybox_config") {
|
||||
deps = [ ":copy_toybox_src" ]
|
||||
sources = [ "liteos_a_custom.config" ]
|
||||
outputs = [ "$target_out_dir/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_toybox") {
|
||||
deps = [ ":copy_toybox_src", ":copy_toybox_config" ]
|
||||
deps += [ "//prebuilts/lite/sysroot" ]
|
||||
exec_path = rebase_path("$target_out_dir/toybox_build")
|
||||
|
||||
cflags = [
|
||||
"-fstack-protector-strong",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
]
|
||||
cflags = string_join(" ", cflags)
|
||||
|
||||
extra_flags = string_join(" ", target_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
extra_flags += " --target=$target_triple"
|
||||
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
|
||||
}
|
||||
|
||||
command = "rm -rf .git && cp -rfp porting/liteos_a/. . && env"
|
||||
command += " CC=\"$ohos_current_cc_command\""
|
||||
command += " STRIP=\"$ohos_current_strip_command\""
|
||||
command += " OUTNAME=toybox"
|
||||
command += " CFLAGS=\"$cflags $extra_flags\""
|
||||
command += " make toybox"
|
||||
command += " && install -D toybox "
|
||||
command += rebase_path("$root_out_dir/bin/toybox", exec_path)
|
||||
command += " && install -D generated/unstripped/toybox "
|
||||
command += rebase_path("$root_out_dir/unstripped/bin/toybox", exec_path)
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/unstripped/bin/toybox",
|
||||
"$root_out_dir/bin/toybox",
|
||||
]
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
BUILD_DIR := $(OUT)/toybox_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
CFLAGS += -Wno-error
|
||||
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)),)
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
else
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/porting/liteos_a/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) liteos_a_custom.config $(BUILD_DIR)/../
|
||||
endif
|
||||
$(HIDE)unset KCONFIG_CONFIG CROSS_COMPILE && \
|
||||
env CC="$(CC)" OUTNAME="$(OUT)/bin/toybox" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
|
||||
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
.PHONY: all clean
|
||||
@@ -1,186 +0,0 @@
|
||||
# CONFIG_BASENAME is not set
|
||||
# CONFIG_CAL is not set
|
||||
# CONFIG_CAT is not set
|
||||
# CONFIG_CATV is not set
|
||||
# CONFIG_CKSUM is not set
|
||||
# CONFIG_CRC32 is not set
|
||||
# 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_ECHO 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_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
|
||||
#
|
||||
# pending (see toys/pending/README)
|
||||
#
|
||||
# CONFIG_GETTY is not set
|
||||
# CONFIG_MDEV is not set
|
||||
# CONFIG_MDEV_CONF is not set
|
||||
@@ -1,36 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := src/trace.c
|
||||
|
||||
include $(APP)
|
||||
@@ -1,135 +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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define TRACE_IOC_MAGIC 'T'
|
||||
#define TRACE_START _IO(TRACE_IOC_MAGIC, 1)
|
||||
#define TRACE_STOP _IO(TRACE_IOC_MAGIC, 2)
|
||||
#define TRACE_RESET _IO(TRACE_IOC_MAGIC, 3)
|
||||
#define TRACE_DUMP _IO(TRACE_IOC_MAGIC, 4)
|
||||
#define TRACE_SET_MASK _IO(TRACE_IOC_MAGIC, 5)
|
||||
|
||||
#define TRACE_USR_MAX_PARAMS 3
|
||||
typedef struct {
|
||||
unsigned int eventType;
|
||||
uintptr_t identity;
|
||||
uintptr_t params[TRACE_USR_MAX_PARAMS];
|
||||
} UsrEventInfo;
|
||||
|
||||
static void TraceUsage(void)
|
||||
{
|
||||
printf("\nUsage: ./trace [start] Start to trace events.\n");
|
||||
printf("\nUsage: ./trace [stop] Stop trace.\n");
|
||||
printf("\nUsage: ./trace [reset] Clear the trace record buffer.\n");
|
||||
printf("\nUsage: ./trace [dump 0/1] Format printf trace data,"
|
||||
"0/1 stands for whether to send data to studio for analysis.\n");
|
||||
printf("\nUsage: ./trace [mask num] Set trace filter event mask.\n");
|
||||
printf("\nUsage: ./trace [read nBytes] Read nBytes raw data from trace buffer.\n");
|
||||
printf("\nUsage: ./trace [write type id params..] Write a user event, no more than 3 parameters.\n");
|
||||
}
|
||||
|
||||
static void TraceRead(int fd, size_t size)
|
||||
{
|
||||
ssize_t i;
|
||||
ssize_t len;
|
||||
char *buffer = (char *)malloc(size);
|
||||
if (buffer == NULL) {
|
||||
printf("Read buffer malloc failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
len = read(fd, buffer, size);
|
||||
for (i = 0; i < len; i++) {
|
||||
printf("%02x ", buffer[i] & 0xFF);
|
||||
}
|
||||
printf("\n");
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
static void TraceWrite(int fd, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
UsrEventInfo info = {0};
|
||||
info.eventType = strtoul(argv[2], NULL, 0);
|
||||
info.identity = strtoul(argv[3], NULL, 0);
|
||||
int paramNum = (argc - 4) > TRACE_USR_MAX_PARAMS ? TRACE_USR_MAX_PARAMS : (argc - 4);
|
||||
|
||||
for (i = 0; i < paramNum; i++) {
|
||||
info.params[i] = strtoul(argv[4 + i], NULL, 0);
|
||||
}
|
||||
(void)write(fd, &info, sizeof(UsrEventInfo));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd = open("/dev/trace", O_RDWR);
|
||||
if (fd == -1) {
|
||||
printf("Trace open failed.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (argc == 1) {
|
||||
TraceUsage();
|
||||
} else if (argc == 2 && strcmp(argv[1], "start") == 0) {
|
||||
ioctl(fd, TRACE_START, NULL);
|
||||
} else if (argc == 2 && strcmp(argv[1], "stop") == 0) {
|
||||
ioctl(fd, TRACE_STOP, NULL);
|
||||
} else if (argc == 2 && strcmp(argv[1], "reset") == 0) {
|
||||
ioctl(fd, TRACE_RESET, NULL);
|
||||
} else if (argc == 3 && strcmp(argv[1], "mask") == 0) {
|
||||
size_t mask = strtoul(argv[2], NULL, 0);
|
||||
ioctl(fd, TRACE_SET_MASK, mask);
|
||||
} else if (argc == 3 && strcmp(argv[1], "dump") == 0) {
|
||||
size_t flag = strtoul(argv[2], NULL, 0);
|
||||
ioctl(fd, TRACE_DUMP, flag);
|
||||
} else if (argc == 3 && strcmp(argv[1], "read") == 0) {
|
||||
size_t size = strtoul(argv[2], NULL, 0);
|
||||
TraceRead(fd, size);
|
||||
} else if (argc >= 4 && strcmp(argv[1], "write") == 0) {
|
||||
TraceWrite(fd, argc, argv);
|
||||
} else {
|
||||
printf("Unsupported trace command.\n");
|
||||
TraceUsage();
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("arch") {
|
||||
deps = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
deps += [ "arm" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("public") {
|
||||
configs = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
configs += [ "arm:public" ]
|
||||
}
|
||||
}
|
||||
0
arch/Kconfig
Normal file → Executable file
0
arch/Kconfig
Normal file → Executable file
@@ -1,40 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("arm") {
|
||||
deps = [ "gic" ]
|
||||
deps += [ ARCH ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
configs = [ "$ARCH:public" ]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -36,16 +36,13 @@ LOSCFG_ARCH_FPU_STRIP := $(subst $\",,$(LOSCFG_ARCH_FPU))
|
||||
LOSCFG_ARCH_FPU = $(LOSCFG_ARCH_FPU_STRIP)
|
||||
|
||||
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
|
||||
ARCH := arm
|
||||
LITEOS_ARCH_ARM := arm
|
||||
else ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
|
||||
ARCH := aarch64
|
||||
LITEOS_ARCH_ARM :=
|
||||
endif
|
||||
|
||||
LITEOS_BASELIB += -l$(LOSCFG_ARCH_CPU)
|
||||
LITEOS_BASELIB += -lgic
|
||||
|
||||
LIB_SUBDIRS += arch/arm/$(ARCH)
|
||||
LIB_SUBDIRS += arch/arm/gic
|
||||
LIB_SUBDIRS += arch/arm/$(LITEOS_ARCH_ARM)
|
||||
|
||||
# CPU compile options
|
||||
ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
|
||||
@@ -65,15 +62,18 @@ 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)
|
||||
LITEOS_CXXOPTS_BASE += $(LITEOS_CORE_COPTS)
|
||||
|
||||
ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/src/include
|
||||
|
||||
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
|
||||
LITEOS_CXXINCLUDE += $(ARCH_INCLUDE)
|
||||
|
||||
# expose FPU info to assembly code
|
||||
ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y)
|
||||
@@ -83,3 +83,17 @@ else ifeq ($(LOSCFG_ARCH_FPU_VFP_D16), y)
|
||||
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y)
|
||||
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32
|
||||
endif
|
||||
|
||||
# extra definition for other module
|
||||
LITEOS_CPU_TYPE = $(LOSCFG_ARCH_CPU)
|
||||
LITEOS_ARM_ARCH := -march=$(subst $\",,$(LOSCFG_ARCH_ARM_VER))
|
||||
|
||||
# linux style macros
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7M) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8A) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8R) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8M) = -D__LINUX_ARM_ARCH__=8
|
||||
|
||||
AS_OBJS_LIBC_FLAGS += $(LINUX_ARCH_y)
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_name = LOSCFG_ARCH_CPU
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/arm_generic_timer.c",
|
||||
"src/clear_user.S",
|
||||
"src/hw_user_get.S",
|
||||
"src/hw_user_put.S",
|
||||
"src/jmp.S",
|
||||
"src/los_arch_mmu.c",
|
||||
"src/los_asid.c",
|
||||
"src/los_dispatch.S",
|
||||
"src/los_exc.c",
|
||||
"src/los_hw.c",
|
||||
"src/los_hw_exc.S",
|
||||
"src/los_hw_runstop.S",
|
||||
"src/los_hw_tick.c",
|
||||
"src/los_hwi.c",
|
||||
"src/strncpy_from_user.c",
|
||||
"src/strnlen_user.c",
|
||||
"src/user_copy.c",
|
||||
"src/smp.c",
|
||||
]
|
||||
|
||||
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
|
||||
sources += [ "src/armv7a/cache.S" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_KERNEL_SMP)) {
|
||||
sources += [ "src/startup/reset_vector_mp.S" ]
|
||||
} else {
|
||||
sources += [ "src/startup/reset_vector_up.S" ]
|
||||
}
|
||||
|
||||
include_dirs = [ "src/include" ]
|
||||
|
||||
if (defined(LOSCFG_GDB)) {
|
||||
configs += [ ":as_objs_libc_flags" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"src/include",
|
||||
]
|
||||
}
|
||||
|
||||
config("as_objs_libc_flags") {
|
||||
defines = [ "__ASSEMBLY__" ]
|
||||
|
||||
# linux style macros
|
||||
if (defined(LOSCFG_ARCH_ARM_V7A) || defined(LOSCFG_ARCH_ARM_V7R) || defined(LOSCFG_ARCH_ARM_V7M)) {
|
||||
defines += [ "__LINUX_ARM_ARCH__=7" ]
|
||||
} else if (defined(LOSCFG_ARCH_ARM_V8A) || defined(LOSCFG_ARCH_ARM_V8R) || defined(LOSCFG_ARCH_ARM_V8M)) {
|
||||
defines += [ "__LINUX_ARM_ARCH__=8" ]
|
||||
}
|
||||
}
|
||||
12
arch/arm/arm/Makefile
Normal file → Executable file
12
arch/arm/arm/Makefile
Normal file → Executable file
@@ -38,7 +38,7 @@ LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/extended/dynload/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/arm/include \
|
||||
|
||||
ifeq ($(LOSCFG_ARCH_ARM_VER), "armv7-a")
|
||||
ifeq ($(LITEOS_ARM_ARCH), -march=armv7-a)
|
||||
LOCAL_SRCS += $(wildcard src/armv7a/*.S)
|
||||
endif
|
||||
|
||||
@@ -50,16 +50,6 @@ endif
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
AS_OBJS_LIBC_FLAGS = -D__ASSEMBLY__
|
||||
# linux style macros
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7M) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8A) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8R) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8M) = -D__LINUX_ARM_ARCH__=8
|
||||
AS_OBJS_LIBC_FLAGS += $(LINUX_ARCH_y)
|
||||
|
||||
ifeq ($(LOSCFG_GDB), y)
|
||||
LOCAL_FLAGS += $(AS_OBJS_LIBC_FLAGS)
|
||||
endif
|
||||
|
||||
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;
|
||||
|
||||
@@ -1,50 +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.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_USER_CLEAR_H
|
||||
#define _ARM_USER_CLEAR_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
size_t _arm_clear_user(void *addr, size_t bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _ARM_USER_CLEAR_H */
|
||||
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
23
arch/arm/arm/include/los_hw_cpu.h
Normal file → Executable file
23
arch/arm/arm/include/los_hw_cpu.h
Normal file → Executable file
@@ -51,10 +51,7 @@ 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 WFE __asm__ volatile("wfe" ::: "memory")
|
||||
#define SEV __asm__ volatile("sev" ::: "memory")
|
||||
|
||||
#define ARM_SYSREG_READ(REG) \
|
||||
({ \
|
||||
@@ -147,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;
|
||||
@@ -191,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
|
||||
|
||||
130
arch/arm/arm/src/los_arch_mmu.c
Normal file → Executable file
130
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,35 +751,29 @@ 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) {
|
||||
LOS_PhysPageFree(page);
|
||||
}
|
||||
|
||||
OsArmWriteTlbiasidis(archMmu->asid);
|
||||
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
|
||||
|
||||
310
arch/arm/arm/src/los_exc.c
Normal file → Executable file
310
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,28 +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:
|
||||
OsArmWriteTlbimvaais(ROUNDDOWN(far, PAGE_SIZE));
|
||||
ret = LOS_OK;
|
||||
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)
|
||||
{
|
||||
@@ -274,11 +256,10 @@ STATIC const CHAR *g_excTypeString[] = {
|
||||
"irq"
|
||||
};
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
|
||||
{
|
||||
struct Vnode *curVnode = NULL;
|
||||
struct Vnode *lastVnode = NULL;
|
||||
struct file *curFilep = NULL;
|
||||
struct file *lastFilep = NULL;
|
||||
LosVmMapRegion *curRegion = NULL;
|
||||
LosVmMapRegion *lastRegion = NULL;
|
||||
|
||||
@@ -297,57 +278,46 @@ STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProc
|
||||
if ((lastRegion == NULL) || !LOS_IsRegionFileValid(lastRegion)) {
|
||||
goto DONE;
|
||||
}
|
||||
curVnode = curRegion->unTypeData.rf.vnode;
|
||||
lastVnode = lastRegion->unTypeData.rf.vnode;
|
||||
} while (curVnode == lastVnode);
|
||||
curFilep = curRegion->unTypeData.rf.file;
|
||||
lastFilep = lastRegion->unTypeData.rf.file;
|
||||
} 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);
|
||||
@@ -364,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,
|
||||
@@ -418,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;
|
||||
@@ -455,7 +422,7 @@ STATIC VOID OsDumpExcVaddrRegion(LosVmSpace *space, LosVmMapRegion *region)
|
||||
mmuFlag = FALSE;
|
||||
}
|
||||
PrintExcInfo(" 0x%08x 0x%08x 0x%08x\n",
|
||||
startVaddr, (UINTPTR)LOS_PaddrToKVaddr(startPaddr), (UINT32)pageCount << PAGE_SHIFT);
|
||||
startVaddr, LOS_PaddrToKVaddr(startPaddr), (UINT32)pageCount << PAGE_SHIFT);
|
||||
pageCount = 0;
|
||||
startPaddr = 0;
|
||||
}
|
||||
@@ -504,7 +471,6 @@ STATIC VOID OsDumpProcessUsedMemNode(UINT16 vmmFalgs)
|
||||
OsDumpProcessUsedMemRegion(runProcess, runspace, vmmFalgs);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||
{
|
||||
@@ -516,7 +482,7 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||
|
||||
for (excReg = &(excBufAddr->R0); count <= DUMPREGS; excReg++, count++) {
|
||||
if (IS_VALID_ADDR(*excReg)) {
|
||||
PrintExcInfo("\ndump mem around R%u:0x%x", count, (*excReg));
|
||||
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
|
||||
OsDumpMemByte(DUMPSIZE, ((*excReg) - (DUMPSIZE >> 1)));
|
||||
}
|
||||
}
|
||||
@@ -527,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;
|
||||
@@ -566,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]++;
|
||||
@@ -607,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;
|
||||
}
|
||||
@@ -628,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;
|
||||
}
|
||||
@@ -697,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);
|
||||
@@ -721,34 +669,20 @@ VOID BackTraceSub(UINTPTR regFP)
|
||||
|
||||
while (IsValidFP(backFP, stackStart, stackEnd, &kvaddr) == TRUE) {
|
||||
tmpFP = backFP;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
if (IsValidFP(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
|
||||
return;
|
||||
}
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
#else
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
if (IsValidFP(tmpFP - POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
|
||||
return;
|
||||
}
|
||||
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++;
|
||||
@@ -783,9 +717,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
|
||||
}
|
||||
@@ -812,7 +745,7 @@ VOID OsCallStackInfo(VOID)
|
||||
PrintExcInfo("runTask->stackPointer = 0x%x\n"
|
||||
"runTask->topOfStack = 0x%x\n"
|
||||
"text_start:0x%x,text_end:0x%x\n",
|
||||
(UINTPTR)stackPointer, runTask->topOfStack, &__text_start, &__text_end);
|
||||
stackPointer, runTask->topOfStack, &__text_start, &__text_end);
|
||||
|
||||
while ((stackPointer > (UINT32 *)runTask->topOfStack) && (count < OS_MAX_BACKTRACE)) {
|
||||
if ((*stackPointer > (UINTPTR)(&__text_start)) &&
|
||||
@@ -845,7 +778,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)
|
||||
@@ -915,7 +848,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
|
||||
|
||||
@@ -964,6 +897,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)) {
|
||||
@@ -981,7 +915,7 @@ STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
STATIC VOID OsCheckAllCpuStatus(UINTPTR taskStackPointer)
|
||||
{
|
||||
UINT32 currCpuID = ArchCurrCpuid();
|
||||
UINT32 ret, target;
|
||||
@@ -990,32 +924,28 @@ 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;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
if (g_excFromUserMode[currCpuID] == FALSE) {
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
||||
}
|
||||
#endif
|
||||
} 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));
|
||||
@@ -1025,26 +955,30 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
while (1) {}
|
||||
}
|
||||
}
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
|
||||
/* use halt ipi to stop other active cores */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
||||
WaitAllCpuStop(currCpuID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#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;
|
||||
@@ -1055,9 +989,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);
|
||||
@@ -1067,45 +1017,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
|
||||
@@ -1113,11 +1044,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++;
|
||||
|
||||
@@ -1127,24 +1053,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);
|
||||
@@ -1152,15 +1076,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();
|
||||
@@ -1170,9 +1097,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) {}
|
||||
}
|
||||
|
||||
@@ -1183,11 +1107,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)
|
||||
{
|
||||
@@ -1219,11 +1142,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) {
|
||||
@@ -1231,11 +1150,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. */
|
||||
@@ -1244,3 +1159,8 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
86
arch/arm/arm/src/los_hw.c
Normal file → Executable file
86
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_THUMB
|
||||
taskContext->regCPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
|
||||
#ifdef LOSCFG_INTERWORK_THUMB
|
||||
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,57 +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)
|
||||
{
|
||||
LosTaskCB *task = OsCurrTaskGet();
|
||||
sig_cb *sigcb = &task->sig;
|
||||
VOID *cloneStack = NULL;
|
||||
TaskContext *context = (TaskContext *)childTaskCB->stackPointer;
|
||||
VOID *cloneStack = (VOID *)(((UINTPTR)parentTaskCB->topOfStack + parentTaskCB->stackSize) - sizeof(TaskContext));
|
||||
|
||||
if (sigcb->sigContext != NULL) {
|
||||
cloneStack = (VOID *)((UINTPTR)sigcb->sigContext - sizeof(TaskContext));
|
||||
} else {
|
||||
cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
|
||||
}
|
||||
LOS_ASSERT(parentTaskCB->taskStatus & OS_TASK_STATUS_RUNNING);
|
||||
|
||||
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
|
||||
((TaskContext *)childStack)->R0 = 0;
|
||||
(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_THUMB
|
||||
context->regCPSR = PSR_MODE_USR_THUMB;
|
||||
#ifdef LOSCFG_INTERWORK_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");
|
||||
}
|
||||
@@ -177,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 */
|
||||
|
||||
@@ -36,7 +36,12 @@
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#include "los_sched_pri.h"
|
||||
#include "los_hook.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);
|
||||
@@ -84,7 +89,7 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqStart();
|
||||
#endif
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum);
|
||||
|
||||
hwiForm = (&g_hwiForm[intNum]);
|
||||
#ifndef LOSCFG_NO_SHARED_IRQ
|
||||
while (hwiForm->pstNext != NULL) {
|
||||
@@ -107,7 +112,6 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
#endif
|
||||
++g_hwiFormCnt[intNum];
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum);
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqEnd(intNum);
|
||||
#endif
|
||||
@@ -348,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 */
|
||||
|
||||
@@ -1,106 +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 "smp.h"
|
||||
#include "arch_config.h"
|
||||
#include "los_base.h"
|
||||
#include "los_hw.h"
|
||||
#include "los_atomic.h"
|
||||
#include "los_arch_mmu.h"
|
||||
#include "los_init_pri.h"
|
||||
#include "gic_common.h"
|
||||
#include "los_task_pri.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
|
||||
extern VOID reset_vector(VOID);
|
||||
|
||||
struct OsCpuInit {
|
||||
ArchCpuStartFunc cpuStart;
|
||||
VOID *arg;
|
||||
Atomic initFlag;
|
||||
};
|
||||
|
||||
STATIC struct OsCpuInit g_cpuInit[CORE_NUM - 1] = {0};
|
||||
|
||||
VOID HalArchCpuOn(UINT32 cpuNum, ArchCpuStartFunc func, struct SmpOps *ops, VOID *arg)
|
||||
{
|
||||
struct OsCpuInit *cpuInit = &g_cpuInit[cpuNum - 1];
|
||||
UINTPTR startEntry = (UINTPTR)&reset_vector - KERNEL_VMM_BASE + SYS_MEM_BASE;
|
||||
INT32 ret = 0;
|
||||
|
||||
cpuInit->cpuStart = func;
|
||||
cpuInit->arg = arg;
|
||||
cpuInit->initFlag = 0;
|
||||
|
||||
DCacheFlushRange((UINTPTR)cpuInit, (UINTPTR)cpuInit + sizeof(struct OsCpuInit));
|
||||
|
||||
LOS_ASSERT(ops != NULL);
|
||||
|
||||
|
||||
ret = ops->SmpCpuOn(cpuNum, startEntry);
|
||||
if (ret < 0) {
|
||||
PRINT_ERR("cpu start failed, cpu num: %u, ret: %d\n", cpuNum, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
while (!LOS_AtomicRead(&cpuInit->initFlag)) {
|
||||
WFE;
|
||||
}
|
||||
}
|
||||
|
||||
VOID HalSecondaryCpuStart(VOID)
|
||||
{
|
||||
UINT32 cpuid = ArchCurrCpuid();
|
||||
struct OsCpuInit *cpuInit = &g_cpuInit[cpuid - 1];
|
||||
|
||||
OsCurrTaskSet(OsGetMainTask());
|
||||
|
||||
LOS_AtomicSet(&cpuInit->initFlag, 1);
|
||||
SEV;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
OsArchMmuInitPerCPU();
|
||||
#endif
|
||||
|
||||
/* store each core's hwid */
|
||||
CPU_MAP_SET(cpuid, OsHwIDGet());
|
||||
HalIrqInitPercpu();
|
||||
OsInitCall(LOS_INIT_LEVEL_ARCH);
|
||||
|
||||
cpuInit->cpuStart(cpuInit->arg);
|
||||
|
||||
while (1) {
|
||||
WFI;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
138
arch/arm/arm/src/startup/reset_vector_mp.S
Normal file → Executable file
138
arch/arm/arm/src/startup/reset_vector_mp.S
Normal file → Executable file
@@ -28,7 +28,6 @@
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define ASSEMBLY
|
||||
#include "arch_config.h"
|
||||
#include "los_vm_boot.h"
|
||||
@@ -38,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
|
||||
@@ -55,14 +62,10 @@
|
||||
.extern __stack_chk_guard_setup
|
||||
.extern g_firstPageTable
|
||||
.extern g_mmuJumpPageTable
|
||||
.extern g_archMmuInitMapping
|
||||
.extern HalSecondaryCpuStart
|
||||
|
||||
.equ MPIDR_CPUID_MASK, 0xffU
|
||||
|
||||
.fpu neon-vfpv4
|
||||
.syntax unified
|
||||
.arch armv7-a
|
||||
.fpu vfpv4
|
||||
.arm
|
||||
|
||||
/* param0 is stack bottom, param1 is stack size, r12 hold cpu id */
|
||||
@@ -80,6 +83,14 @@
|
||||
bl excstack_magic
|
||||
.endm
|
||||
|
||||
/* param0 is physical address, param1 virtual address, param2 is sizes, param3 is flag */
|
||||
.macro PAGE_TABLE_SET param0, param1, param2, param3
|
||||
ldr r6, =\param0
|
||||
ldr r7, =\param1
|
||||
ldr r8, =\param2
|
||||
ldr r10, =\param3
|
||||
bl page_table_build
|
||||
.endm
|
||||
.code 32
|
||||
.section ".vectors","ax"
|
||||
|
||||
@@ -102,9 +113,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
|
||||
@@ -171,23 +182,19 @@ 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
|
||||
mov r1, #0
|
||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||
bl memset
|
||||
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
||||
|
||||
ldr r5, =g_archMmuInitMapping
|
||||
add r5, r5, r11
|
||||
init_mmu_loop:
|
||||
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||
cmp r8, 0 /* if size = 0, the mmu init done */
|
||||
beq init_mmu_done
|
||||
bl page_table_build
|
||||
b init_mmu_loop
|
||||
init_mmu_done:
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||
add r4, r4, r11
|
||||
@@ -204,17 +211,40 @@ init_mmu_done:
|
||||
rsb r7, r11, r6, lsl #20 /* r7: va */
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||
|
||||
bl _bootaddr_setup
|
||||
|
||||
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
|
||||
@@ -262,7 +292,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 */
|
||||
@@ -298,7 +328,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
|
||||
@@ -313,9 +343,7 @@ reset_platform:
|
||||
mov r0, #0
|
||||
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
|
||||
@@ -326,9 +354,7 @@ cpu_start:
|
||||
add r4, r4, r11 /* r4 = tt_trampoline paddr */
|
||||
|
||||
bl mmu_setup
|
||||
#endif
|
||||
|
||||
bl HalSecondaryCpuStart
|
||||
bl secondary_cpu_start
|
||||
b .
|
||||
|
||||
secondary_cpu_init:
|
||||
@@ -366,11 +392,10 @@ sp_set:
|
||||
* r10: flags
|
||||
* r9 and r12 will be used as variable
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r10, r6
|
||||
bfc r10, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r10
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r9
|
||||
add r8, r8, #(1 << 20)
|
||||
sub r8, r8, #1
|
||||
lsr r6, #20 /* r6 = physical address / MB */
|
||||
@@ -378,14 +403,14 @@ page_table_build:
|
||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||
|
||||
page_table_build_loop:
|
||||
orr r12, r9, r6, lsl #20 /* r12: flags | physAddr */
|
||||
orr r12, r10, r6, lsl #20 /* r12: flags | physAddr */
|
||||
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
||||
add r6, #1 /* physAddr+ */
|
||||
add r7, #1 /* l1Index++ */
|
||||
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
|
||||
@@ -420,19 +445,24 @@ excstack_magic_loop:
|
||||
blt excstack_magic_loop
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
vdup.8 q0, r1
|
||||
vmov q1, q0
|
||||
vmov q2, q0
|
||||
vmov q3, q0
|
||||
memset_optimized_loop:
|
||||
subs r2, #64
|
||||
vstmia r3!, {d0 - d7}
|
||||
bge memset_optimized_loop
|
||||
/*
|
||||
* 0xe51ff004 = "ldr pc, [pc, #-4]"
|
||||
* next addr value will be the real booting addr
|
||||
*/
|
||||
_bootaddr_setup:
|
||||
mov r0, #0
|
||||
ldr r1, =0xe51ff004
|
||||
str r1, [r0]
|
||||
|
||||
add r0, r0, #4
|
||||
ldr r1, =SYS_MEM_BASE
|
||||
str r1, [r0]
|
||||
|
||||
dsb
|
||||
isb
|
||||
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
init_done:
|
||||
.long 0xDEADB00B
|
||||
|
||||
@@ -449,6 +479,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:
|
||||
|
||||
132
arch/arm/arm/src/startup/reset_vector_up.S
Normal file → Executable file
132
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
|
||||
@@ -54,13 +62,10 @@
|
||||
.extern __stack_chk_guard_setup
|
||||
.extern g_firstPageTable
|
||||
.extern g_mmuJumpPageTable
|
||||
.extern g_archMmuInitMapping
|
||||
|
||||
.equ MPIDR_CPUID_MASK, 0xffU
|
||||
|
||||
.fpu neon-vfpv4
|
||||
.syntax unified
|
||||
.arch armv7-a
|
||||
.fpu vfpv4
|
||||
.arm
|
||||
|
||||
/* param0 is stack bottom, param1 is stack size, r11 hold cpu id */
|
||||
@@ -78,6 +83,14 @@
|
||||
bl excstack_magic
|
||||
.endm
|
||||
|
||||
/* param0 is physical address, param1 virtual address, param2 is sizes, param3 is flag */
|
||||
.macro PAGE_TABLE_SET param0, param1, param2, param3
|
||||
ldr r6, =\param0
|
||||
ldr r7, =\param1
|
||||
ldr r8, =\param2
|
||||
ldr r10, =\param3
|
||||
bl page_table_build
|
||||
.endm
|
||||
.code 32
|
||||
.section ".vectors","ax"
|
||||
|
||||
@@ -146,23 +159,20 @@ 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
|
||||
mov r1, #0
|
||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||
bl memset
|
||||
|
||||
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
||||
|
||||
ldr r5, =g_archMmuInitMapping
|
||||
add r5, r5, r11
|
||||
init_mmu_loop:
|
||||
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||
cmp r8, 0 /* if size = 0, the mmu init done */
|
||||
beq init_mmu_done
|
||||
bl page_table_build
|
||||
b init_mmu_loop
|
||||
init_mmu_done:
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||
add r4, r4, r11
|
||||
@@ -180,7 +190,7 @@ init_mmu_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
|
||||
@@ -189,15 +199,36 @@ init_mmu_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
|
||||
@@ -227,6 +258,9 @@ warm_reset:
|
||||
LDR r0, =__exception_handlers
|
||||
MCR p15, 0, r0, c12, c0, 0
|
||||
|
||||
cmp r11, #0
|
||||
bne cpu_start
|
||||
|
||||
clear_bss:
|
||||
ldr r0, =__bss_start
|
||||
ldr r2, =__bss_end
|
||||
@@ -251,7 +285,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 */
|
||||
@@ -288,7 +321,7 @@ mmu_setup:
|
||||
|
||||
sub lr, r11 /* adjust lr with delta of physical address and virtual address */
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
.code 32
|
||||
|
||||
.global reset_platform
|
||||
@@ -303,6 +336,11 @@ reset_platform:
|
||||
mov r0, #0
|
||||
mov pc, r0 // Jump to reset vector
|
||||
#endif
|
||||
cpu_start:
|
||||
bl secondary_cpu_start
|
||||
b .
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* set sp for current cpu
|
||||
@@ -322,11 +360,10 @@ sp_set:
|
||||
* r10: flags
|
||||
* r9 and r12 will be used as variable
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r10, r6
|
||||
bfc r10, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r10
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r9
|
||||
add r8, r8, #(1 << 20)
|
||||
sub r8, r8, #1
|
||||
lsr r6, #20 /* r6 = physical address / MB */
|
||||
@@ -334,14 +371,14 @@ page_table_build:
|
||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||
|
||||
page_table_build_loop:
|
||||
orr r12, r9, r6, lsl #20 /* r12: flags | physAddr */
|
||||
orr r12, r10, r6, lsl #20 /* r12: flags | physAddr */
|
||||
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
||||
add r6, #1 /* physAddr+ */
|
||||
add r7, #1 /* l1Index++ */
|
||||
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
|
||||
@@ -376,19 +413,24 @@ excstack_magic_loop:
|
||||
blt excstack_magic_loop
|
||||
bx lr
|
||||
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
vdup.8 q0, r1
|
||||
vmov q1, q0
|
||||
vmov q2, q0
|
||||
vmov q3, q0
|
||||
memset_optimized_loop:
|
||||
subs r2, #64
|
||||
vstmia r3!, {d0 - d7}
|
||||
bge memset_optimized_loop
|
||||
/*
|
||||
* 0xe51ff004 = "ldr pc, [pc, #-4]"
|
||||
* next addr value will be the real booting addr
|
||||
*/
|
||||
_bootaddr_setup:
|
||||
mov r0, #0
|
||||
ldr r1, =0xe51ff004
|
||||
str r1, [r0]
|
||||
|
||||
add r0, r0, #4
|
||||
ldr r1, =SYS_MEM_BASE
|
||||
str r1, [r0]
|
||||
|
||||
dsb
|
||||
isb
|
||||
|
||||
bx lr
|
||||
#endif
|
||||
|
||||
init_done:
|
||||
.long 0xDEADB00B
|
||||
|
||||
@@ -405,6 +447,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:
|
||||
|
||||
12
arch/arm/arm/src/strncpy_from_user.c
Normal file → Executable file
12
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)
|
||||
{
|
||||
@@ -46,7 +51,7 @@ INT32 LOS_StrncpyFromUser(CHAR *dst, const CHAR *src, INT32 count)
|
||||
}
|
||||
|
||||
maxCount = (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)src, (size_t)count)) ? \
|
||||
count : (INT32)(USER_ASPACE_TOP_MAX - (UINTPTR)src);
|
||||
count : (USER_ASPACE_TOP_MAX - (UINTPTR)src);
|
||||
|
||||
for (i = 0; i < maxCount; ++i) {
|
||||
if (LOS_GetUser(&character, src + offset) != LOS_OK) {
|
||||
@@ -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,41 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = []
|
||||
|
||||
if (defined(LOSCFG_ARCH_GIC_V2)) {
|
||||
sources += [ "gic_v2.c" ]
|
||||
} else if (defined(LOSCFG_ARCH_GIC_V3)) {
|
||||
sources += [ "gic_v3.c" ]
|
||||
}
|
||||
}
|
||||
@@ -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
8
bsd/Kconfig
Normal file → Executable file
8
bsd/Kconfig
Normal file → Executable file
@@ -1,14 +1,6 @@
|
||||
config COMPAT_BSD
|
||||
bool "Enable FreeBSD"
|
||||
default y
|
||||
select COMPAT_LINUXKPI
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support FreeBSD.
|
||||
|
||||
config COMPAT_LINUXKPI
|
||||
bool "Enable linuxkpi" if COMPAT_BSD
|
||||
default y
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support compatible layer for linuxkpi.
|
||||
|
||||
@@ -33,8 +33,8 @@ MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard kern/*.c)
|
||||
|
||||
LOCAL_SRCS += $(wildcard $(ARCH)/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(ARCH)/*.S)
|
||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.S)
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
|
||||
LOCAL_SRCS += $(wildcard crypto/rijndael/*.c) \
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_COMPAT_BSD)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/adp.c",
|
||||
"src/linux_completion.c",
|
||||
"src/linux_interrupt.c",
|
||||
"src/linux_sched.c",
|
||||
"src/linux_semaphore.c",
|
||||
"src/linux_timer.c",
|
||||
"src/linux_wakelock.c",
|
||||
"src/linux_workqueue.c",
|
||||
"src/prctl.c",
|
||||
"src/tzdst.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_HRTIMER_ENABLE)) {
|
||||
sources += [ "src/linux_hrtimer.c" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
0
bsd/compat/linuxkpi/Makefile
Normal file → Executable file
0
bsd/compat/linuxkpi/Makefile
Normal file → Executable file
1
bsd/compat/linuxkpi/include/linux/mtd/mtd.h
Symbolic link
1
bsd/compat/linuxkpi/include/linux/mtd/mtd.h
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd.h
|
||||
1
bsd/compat/linuxkpi/include/linux/mtd/mtd_list.h
Symbolic link
1
bsd/compat/linuxkpi/include/linux/mtd/mtd_list.h
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd_list.h
|
||||
@@ -1,150 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_USB)
|
||||
module_name = "usb_base"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"implementation/bsd_busspace.c",
|
||||
"implementation/bsd_kernel.c",
|
||||
"implementation/usb_btree.c",
|
||||
"implementation/usb_busdma_loader.c",
|
||||
"implementation/usb_init.c",
|
||||
"implementation/usb_version.c",
|
||||
"usb_debug.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB)) {
|
||||
sources += [
|
||||
"controller/usb_controller.c",
|
||||
"quirk/usb_quirk.c",
|
||||
"usb_dev.c",
|
||||
"usb_device.c",
|
||||
"usb_dynamic.c",
|
||||
"usb_error.c",
|
||||
"usb_generic.c",
|
||||
"usb_handle_request.c",
|
||||
"usb_hub.c",
|
||||
"usb_if.c",
|
||||
"usb_lookup.c",
|
||||
"usb_mbuf.c",
|
||||
"usb_parse.c",
|
||||
"usb_process.c",
|
||||
"usb_request.c",
|
||||
"usb_transfer.c",
|
||||
"usb_util.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM)) {
|
||||
sources += [ "net/if_cdce.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_ETHERNET)) {
|
||||
sources += [
|
||||
"net/if_axe.c",
|
||||
"net/if_axge.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
|
||||
sources += [ "net/if_urndis.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
|
||||
defined(LOSCFG_DRIVERS_USB_ETHERNET) ||
|
||||
defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
|
||||
sources += [
|
||||
"net/usb_eth_drv.c",
|
||||
"net/usb_ethernet.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
|
||||
defined(LOSCFG_DRIVERS_USB_SERIAL)) {
|
||||
sources += [
|
||||
"serial/u3g.c",
|
||||
"serial/usb_serial.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HOST_EHCI)) {
|
||||
sources += [
|
||||
"controller/ehci.c",
|
||||
"controller/ehci_pci.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HOST_XHCI) ||
|
||||
defined(LOSCFG_DRIVERS_USB_HOST_XHCI_FOR_PORT2)) {
|
||||
sources += [
|
||||
"controller/xhci.c",
|
||||
"controller/xhci_pci.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_WIRELESS)) {
|
||||
sources += [ "linux_usb.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_MASS_STORAGE)) {
|
||||
sources += [ "storage/umass.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HID_CLASS) &&
|
||||
defined(LOSCFG_DRIVERS_HDF_INPUT)) {
|
||||
sources += [
|
||||
"input/uhid.c",
|
||||
"usb_hid.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"//drivers/framework/model/input/driver",
|
||||
"//drivers/framework/include/core",
|
||||
"//drivers/framework/core/common/include/host",
|
||||
"//drivers/framework/utils",
|
||||
"//drivers/framework/osal",
|
||||
"//drivers/framework/ability/sbuf/include",
|
||||
"//drivers/framework/include/osal",
|
||||
]
|
||||
}
|
||||
|
||||
configs += [
|
||||
"$HDFTOPDIR:hdf_config"
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
include_dirs += [ "$LITEOSTHIRDPARTY/FreeBSD/sys/dev/evdev" ]
|
||||
}
|
||||
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
|
||||
70
build.sh
70
build.sh
@@ -30,40 +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}
|
||||
compile_prefix=${13}
|
||||
liteos_config_file=${14}
|
||||
|
||||
echo "sh param:" "$@"
|
||||
|
||||
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}"
|
||||
productName="$(basename $7)"
|
||||
source="tools/build/config/${productName}_release.config"
|
||||
if [ "$2" = "clang" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${productName}_$2$tee.config"
|
||||
source="tools/build/config/debug/$config_file"
|
||||
else
|
||||
config_file="${productName}_$2_release$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
fi
|
||||
elif [ "$2" = "gcc" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${productName}_debug_shell$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
else
|
||||
config_file="${productName}_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 PRODUCT_PATH="${product_path}"
|
||||
export DEVICE_PATH="${device_path}"
|
||||
mkdir -p $outdir
|
||||
cp kernel_test.sources $outdir
|
||||
|
||||
export OUTDIR="${outdir}"
|
||||
export KCONFIG_CONFIG="${liteos_config_file}"
|
||||
export LITEOS_MENUCONFIG_H="${outdir}/config.h"
|
||||
export LITEOS_CONFIG_FILE="${outdir}/.config"
|
||||
export LITEOS_COMPILER_PATH="${compile_prefix%/*}/"
|
||||
export CROSS_COMPILE="${compile_prefix##*/}"
|
||||
|
||||
mkdir -p "${outdir}"
|
||||
make -j all VERSION="${ohos_version}"
|
||||
|
||||
59
bundle.json
59
bundle.json
@@ -1,59 +0,0 @@
|
||||
{
|
||||
"name": "@ohos/kernel_liteos_a",
|
||||
"version": "",
|
||||
"description": "liteos-a内核",
|
||||
"homePage": "https://gitee.com/openharmony",
|
||||
"license": "BSD 3-clause",
|
||||
"repository": "https://gitee.com/openharmony/kernel_liteos_a",
|
||||
"domain": "os",
|
||||
"language": "",
|
||||
"publishAs": "code-segment",
|
||||
"private": false,
|
||||
"scripts": {},
|
||||
"tags": [
|
||||
"kernel"
|
||||
],
|
||||
"keywords": [
|
||||
"kernel",
|
||||
"liteos-a"
|
||||
],
|
||||
"envs": [],
|
||||
"dirs": [],
|
||||
"author": {
|
||||
"name": "",
|
||||
"email": "",
|
||||
"url": ""
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "",
|
||||
"email": "",
|
||||
"url": ""
|
||||
}
|
||||
],
|
||||
"segment": {
|
||||
"destPath": "kernel/liteos_a"
|
||||
},
|
||||
"component": {
|
||||
"name": "liteos-a",
|
||||
"subsystem": "liteos_a",
|
||||
"syscap": [
|
||||
"SystemCapability.Kernel.liteos-a"
|
||||
],
|
||||
"features": [],
|
||||
"adated_system_type": [
|
||||
"small"
|
||||
],
|
||||
"rom": "",
|
||||
"ram": "",
|
||||
"deps": {
|
||||
"components": [],
|
||||
"third_party": []
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [],
|
||||
"inner_kits": [],
|
||||
"test": []
|
||||
}
|
||||
}
|
||||
}
|
||||
0
compat/posix/Kconfig
Normal file → Executable file
0
compat/posix/Kconfig
Normal file → Executable file
10
compat/posix/include/mqueue.h
Normal file → Executable file
10
compat/posix/include/mqueue.h
Normal file → Executable file
@@ -81,11 +81,6 @@ typedef union send_receive_t {
|
||||
short data;
|
||||
} mode_s;
|
||||
|
||||
struct mqnotify {
|
||||
pid_t pid;
|
||||
struct sigevent notify;
|
||||
};
|
||||
|
||||
/* TYPE DEFINITIONS */
|
||||
struct mqarray {
|
||||
UINT32 mq_id : 31;
|
||||
@@ -95,7 +90,7 @@ struct mqarray {
|
||||
mode_s mode_data; /* mode data of mqueue */
|
||||
uid_t euid; /* euid of mqueue */
|
||||
gid_t egid; /* egid of mqueue */
|
||||
struct mqnotify mq_notify;
|
||||
fd_set mq_fdset; /* mqueue sysFd bit map */
|
||||
LosQueueCB *mqcb;
|
||||
struct mqpersonal *mq_personal;
|
||||
};
|
||||
@@ -422,8 +417,7 @@ extern int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen,
|
||||
extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
|
||||
unsigned int *msgPrio, const struct timespec *absTimeout);
|
||||
|
||||
extern void MqueueRefer(int sysFd);
|
||||
extern int OsMqNotify(mqd_t personal, const struct sigevent *sigev);
|
||||
extern void mqueue_refer(int sysFd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user