Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b0f642b493 | |||
| 6c36623ac7 | |||
| 9078efccd1 | |||
| b7c4acfb78 | |||
| aaa3cc9d7b | |||
| dc8853bb78 | |||
| 892201f67b | |||
| 91709a3599 | |||
| d9752abcb4 | |||
| 12cc392f46 | |||
| 62aa4aa0b1 | |||
| 929a282bad | |||
| 8bb15bf8e7 | |||
| aec7840626 | |||
| e43e252e14 | |||
| ba4ed5a599 | |||
| 55bdf174b8 | |||
| c8c3034709 | |||
| f32154f9cb | |||
| 60d3f6d5da | |||
| 44279b256a | |||
| 951d233676 | |||
| ca70dc4dd1 | |||
| a693cd4198 | |||
| f249db759d | |||
| 6f0c5d10e2 | |||
| ca8909b8e3 | |||
| 431c9e9d61 | |||
| d71db99932 | |||
| 6b54224726 | |||
| 9ac04e886a | |||
| 06b0396945 | |||
| bb3590a448 | |||
| 027fa6136a | |||
| 532f96d746 | |||
| d2bc8f2f1b | |||
| e5c7549bc2 | |||
| 832001a6af | |||
| 7d7188c737 | |||
| 88a0caae24 | |||
| 99824916dd | |||
| 42fdaffe76 | |||
| ed7defbd43 | |||
| de8257bc82 | |||
| 19b39b1bff | |||
| 5e07663374 | |||
| f9a907772f | |||
| 007f385396 | |||
| 463bc0546f | |||
| 0c93a9b4f8 | |||
| d30a009ba5 | |||
| 4bee53a610 | |||
| 81b474813b | |||
| dc9ec6856f | |||
| 658fafe83b | |||
| f3562e490c | |||
| 9888185fcb | |||
| 055295b6d1 | |||
| c26ca519f7 | |||
| df35eb513d | |||
| 7cb2ad67bf | |||
| 98ca8441fe | |||
| 3393479c52 | |||
| aa5b2c7641 | |||
| 7661aedcc9 | |||
| c97178f2f6 | |||
| 8839fdd399 | |||
| a3b480b18e | |||
| defedb6fdf | |||
| 1ec8d5a454 | |||
| 7c577d8963 | |||
| 6e2a4be155 | |||
| 682ae82158 | |||
| e828cbdeac | |||
| 45a128a4f0 | |||
| 83bff88f7f | |||
| 181322a3c1 | |||
| 5369b6aa23 | |||
| 0e260949c9 | |||
| 8b267dc690 | |||
| d16bfd005a | |||
| 40297a6dbc | |||
| 752aa49018 | |||
| 5569b1d1ec | |||
| 9549f5ebd0 | |||
| aa1cd245a5 | |||
| ec366df863 | |||
| 555e0681be | |||
| dc3cc094a7 | |||
| 3bb3173604 |
@@ -17,7 +17,6 @@ tags
|
|||||||
|
|
||||||
# Menuconfig temp files
|
# Menuconfig temp files
|
||||||
/config.h
|
/config.h
|
||||||
/defconfig
|
|
||||||
/.config
|
/.config
|
||||||
/.config.old
|
/.config.old
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import("//build/lite/config/component/lite_component.gni")
|
|||||||
declare_args() {
|
declare_args() {
|
||||||
tee_enable = false
|
tee_enable = false
|
||||||
liteos_name = "OHOS_Image"
|
liteos_name = "OHOS_Image"
|
||||||
|
liteos_skip_make = false
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
|
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
|
||||||
@@ -44,30 +45,11 @@ if (tee_enable) {
|
|||||||
tee = "_tee"
|
tee = "_tee"
|
||||||
}
|
}
|
||||||
|
|
||||||
productName = get_path_info(product_path, "file")
|
declare_args() {
|
||||||
config_file = "${productName}_release.config"
|
liteos_config_file = "${ohos_build_type}${tee}.config"
|
||||||
if (ohos_build_compiler == "clang") {
|
|
||||||
if (ohos_build_type == "debug") {
|
|
||||||
config_file = "debug/${productName}_${ohos_build_compiler}${tee}.config"
|
|
||||||
} else {
|
|
||||||
config_file = "${productName}_${ohos_build_compiler}_release${tee}.config"
|
|
||||||
}
|
|
||||||
} else if (ohos_build_compiler == "gcc") {
|
|
||||||
if (ohos_build_type == "debug") {
|
|
||||||
config_file = "${productName}_debug_shell${tee}.config"
|
|
||||||
} else {
|
|
||||||
config_file = "${productName}_release${tee}.config"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
liteos_config_file = rebase_path("tools/build/config/$config_file")
|
|
||||||
|
|
||||||
# we prefer use product specified config file
|
|
||||||
f = "$product_path/kernel_configs/${ohos_build_type}${tee}.config"
|
|
||||||
if (exec_script("//build/lite/run_shell_cmd.py", [ "if [ -f $f ]; then echo true; else echo false; fi" ], "value")) {
|
|
||||||
liteos_config_file = f
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
liteos_config_file = rebase_path(liteos_config_file, "", "$product_path/kernel_configs")
|
||||||
print("liteos_config_file:", liteos_config_file)
|
print("liteos_config_file:", liteos_config_file)
|
||||||
|
|
||||||
exec_script("//build/lite/run_shell_cmd.py",
|
exec_script("//build/lite/run_shell_cmd.py",
|
||||||
@@ -83,10 +65,14 @@ exec_script("//build/lite/run_shell_cmd.py",
|
|||||||
" --file-list kconfig_files.txt" +
|
" --file-list kconfig_files.txt" +
|
||||||
" --env-list kconfig_env.txt" +
|
" --env-list kconfig_env.txt" +
|
||||||
" --config-out config.gni",
|
" --config-out config.gni",
|
||||||
])
|
], "", [ liteos_config_file ])
|
||||||
|
|
||||||
import("liteos.gni")
|
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!")
|
||||||
|
|
||||||
generate_notice_file("kernel_notice_file") {
|
generate_notice_file("kernel_notice_file") {
|
||||||
module_name = "kernel"
|
module_name = "kernel"
|
||||||
module_source_dir_list = [
|
module_source_dir_list = [
|
||||||
@@ -125,30 +111,197 @@ config("arch_config") {
|
|||||||
cflags = liteos_arch_cflags
|
cflags = liteos_arch_cflags
|
||||||
asmflags = cflags
|
asmflags = cflags
|
||||||
ldflags = cflags
|
ldflags = cflags
|
||||||
}
|
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||||
|
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||||
config("as_objs_libc_flags") {
|
cflags += ["-mthumb-interwork"]
|
||||||
defines = [ "__ASSEMBLY__" ]
|
}
|
||||||
|
}
|
||||||
# linux style macros
|
if (defined(LOSCFG_THUMB)) {
|
||||||
if (defined(LOSCFG_ARCH_ARM_V7A) || defined(LOSCFG_ARCH_ARM_V7R) ||
|
cflags += [ "-mthumb" ]
|
||||||
defined(LOSCFG_ARCH_ARM_V7M)) {
|
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||||
defines += [ "__LINUX_ARM_ARCH__=7" ]
|
cflags += [ "-mimplicit-it=thumb" ]
|
||||||
} else if (defined(LOSCFG_ARCH_ARM_V8A) || defined(LOSCFG_ARCH_ARM_V8R) ||
|
} else {
|
||||||
defined(LOSCFG_ARCH_ARM_V8M)) {
|
cflags += [ "-Wa,-mimplicit-it=thumb" ]
|
||||||
defines += [ "__LINUX_ARM_ARCH__=8" ]
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config("std_include") {
|
config("stdinc_config") {
|
||||||
std_include = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-file-name=include" ], "trim string")
|
std_include = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-file-name=include" ], "trim string")
|
||||||
cflags = [
|
cflags = [
|
||||||
"-isystem",
|
"-isystem",
|
||||||
std_include,
|
std_include,
|
||||||
]
|
]
|
||||||
|
cflags += [ "-nostdinc" ]
|
||||||
asmflags = cflags
|
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" ]
|
||||||
|
}
|
||||||
|
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") {
|
config("public") {
|
||||||
configs = [
|
configs = [
|
||||||
"arch:public",
|
"arch:public",
|
||||||
@@ -174,156 +327,6 @@ config("public") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config("los_nostdinc") {
|
|
||||||
cflags = [ "-nostdinc" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
config("los_nostdlib") {
|
|
||||||
ldflags = [ "-nostdlib" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
config("los_common") {
|
|
||||||
cflags = [
|
|
||||||
"-imacros",
|
|
||||||
"$LITEOS_MENUCONFIG_H",
|
|
||||||
]
|
|
||||||
|
|
||||||
defines = [ "__LITEOS__" ]
|
|
||||||
|
|
||||||
cflags_c = [ "-std=c99" ]
|
|
||||||
|
|
||||||
cflags += [
|
|
||||||
"-fno-pic",
|
|
||||||
"-fno-builtin",
|
|
||||||
"-Wall",
|
|
||||||
"-Werror",
|
|
||||||
"-fms-extensions",
|
|
||||||
"-Wno-address-of-packed-member",
|
|
||||||
"-fno-strict-aliasing",
|
|
||||||
"-fno-common",
|
|
||||||
"-fsigned-char",
|
|
||||||
"-Wpointer-arith",
|
|
||||||
"-Wstrict-prototypes",
|
|
||||||
"-Winvalid-pch",
|
|
||||||
"-ffunction-sections",
|
|
||||||
"-fdata-sections",
|
|
||||||
"-fno-exceptions",
|
|
||||||
"-fno-omit-frame-pointer",
|
|
||||||
"-fno-short-enums",
|
|
||||||
]
|
|
||||||
|
|
||||||
if (defined(LOSCFG_QUICK_START)) {
|
|
||||||
cflags -= [ "-Werror" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined(LOSCFG_COMPILE_DEBUG)) {
|
|
||||||
cflags += [
|
|
||||||
"-O0",
|
|
||||||
"-g",
|
|
||||||
"-gdwarf-2",
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [
|
|
||||||
"-Oz",
|
|
||||||
"-flto",
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
cflags += [ "-O2" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
|
|
||||||
cflags += [ "-fstack-protector-all" ]
|
|
||||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
|
|
||||||
cflags += [ "-fstack-protector-strong" ]
|
|
||||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
|
|
||||||
cflags += [
|
|
||||||
"-fstack-protector",
|
|
||||||
"--param",
|
|
||||||
"ssp-buffer-size=4",
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
cflags += [ "-fno-stack-protector" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [ "-fno-aggressive-loop-optimizations" ]
|
|
||||||
if (!defined(LOSCFG_ARCH_ARM_AARCH64)) {
|
|
||||||
cflags += [
|
|
||||||
"-mno-unaligned-access",
|
|
||||||
"-mthumb-interwork",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined(LOSCFG_THUMB)) {
|
|
||||||
cflags += [
|
|
||||||
"-mthumb",
|
|
||||||
"-Wa,-mimplicit-it=thumb",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
asmflags = cflags
|
|
||||||
}
|
|
||||||
|
|
||||||
config("los_config") {
|
|
||||||
configs = [
|
|
||||||
":los_common",
|
|
||||||
":arch_config",
|
|
||||||
":los_nostdinc",
|
|
||||||
":los_nostdlib",
|
|
||||||
":std_include",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
executable("liteos") {
|
|
||||||
configs = [] # clear default configs
|
|
||||||
configs += [ ":los_config" ]
|
|
||||||
configs += [ ":public" ]
|
|
||||||
|
|
||||||
ldflags = [
|
|
||||||
"-static",
|
|
||||||
"-Wl,--gc-sections",
|
|
||||||
"-Wl,-Map=$liteos_name.map",
|
|
||||||
"-Wl,--no-eh-frame-hdr",
|
|
||||||
]
|
|
||||||
|
|
||||||
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
|
|
||||||
libs = [ libgcc ]
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
|
|
||||||
} else {
|
|
||||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
|
||||||
ldflags += [ "-Wl,-nostartfiles" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
output_dir = target_out_dir
|
|
||||||
output_name = liteos_name
|
|
||||||
|
|
||||||
deps = [
|
|
||||||
":modules",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
copy("copy_liteos") {
|
|
||||||
deps = [ ":liteos" ]
|
|
||||||
sources = [ "$target_out_dir/unstripped/bin/$liteos_name" ]
|
|
||||||
outputs = [ "$root_out_dir/{{source_file_part}}" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
build_ext_component("build_kernel_image") {
|
|
||||||
deps = [ ":copy_liteos" ]
|
|
||||||
exec_path = rebase_path(root_out_dir)
|
|
||||||
|
|
||||||
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
|
||||||
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
|
||||||
|
|
||||||
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
|
|
||||||
command += " && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
|
||||||
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
|
||||||
}
|
|
||||||
|
|
||||||
group("modules") {
|
group("modules") {
|
||||||
deps = [
|
deps = [
|
||||||
"arch",
|
"arch",
|
||||||
@@ -341,7 +344,7 @@ group("modules") {
|
|||||||
]
|
]
|
||||||
|
|
||||||
deps += [
|
deps += [
|
||||||
"$HDFTOPDIR",
|
HDFTOPDIR,
|
||||||
"//drivers/liteos",
|
"//drivers/liteos",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -372,10 +375,14 @@ group("liteos_a") {
|
|||||||
|
|
||||||
build_ext_component("make") {
|
build_ext_component("make") {
|
||||||
exec_path = rebase_path(".", root_build_dir)
|
exec_path = rebase_path(".", root_build_dir)
|
||||||
outdir = rebase_path(get_path_info(".", "out_dir"))
|
outdir = rebase_path("$target_out_dir/${target_name}_out")
|
||||||
sysroot_path = rebase_path(ohos_current_sysroot)
|
sysroot_path = rebase_path(ohos_current_sysroot)
|
||||||
arch_cflags = string_join(" ", target_arch_cflags)
|
arch_cflags = string_join(" ", target_arch_cflags)
|
||||||
command = "./build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} \"${tee_enable}\""
|
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_company\" \"$product_path\" \"$outdir\" \"$ohos_version\" \"$sysroot_path\" \"$arch_cflags\""
|
||||||
command += " \"${device_path}\""
|
command += " \"$device_path\" \"$compile_prefix\" \"$liteos_config_file\""
|
||||||
|
if (liteos_skip_make) {
|
||||||
|
print("build_ext_component \"$target_name\" skipped:", command)
|
||||||
|
command = "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,27 +26,64 @@
|
|||||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
|
||||||
#
|
|
||||||
# For a description of the syntax of this configuration file,
|
|
||||||
# see extra/config/Kconfig-language.txt
|
|
||||||
#
|
|
||||||
mainmenu "Huawei LiteOS Configuration"
|
mainmenu "Huawei LiteOS Configuration"
|
||||||
|
|
||||||
menu "Compiler"
|
menu "Compiler"
|
||||||
choice
|
choice
|
||||||
prompt "LiteOS_Compiler_Type"
|
prompt "Compiler type"
|
||||||
default COMPILER_CLANG_LLVM
|
default COMPILER_CLANG_LLVM
|
||||||
help
|
help
|
||||||
Enable arm-himix100 or aarch64-himix100 or compiler.
|
Choose compiler type.
|
||||||
|
|
||||||
config COMPILER_HIMIX_32
|
config COMPILER_GCC
|
||||||
bool "arm-linux-ohoseabi"
|
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_CLANG_LLVM
|
config COMPILER_CLANG_LLVM
|
||||||
bool "clang-llvm"
|
bool "Clang"
|
||||||
|
|
||||||
|
config LLVM_TARGET
|
||||||
|
string "Clang LLVM target"
|
||||||
|
depends on COMPILER_CLANG_LLVM
|
||||||
|
default "arm-liteos" if ARCH_ARM_AARCH32
|
||||||
|
|
||||||
endchoice
|
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
|
endmenu
|
||||||
|
|
||||||
menu "Platform"
|
menu "Platform"
|
||||||
@@ -123,11 +160,11 @@ source "net/Kconfig"
|
|||||||
|
|
||||||
######################## config options of debug ########################
|
######################## config options of debug ########################
|
||||||
menu "Debug"
|
menu "Debug"
|
||||||
config COMPILE_DEBUG
|
config GDB
|
||||||
bool "Enable GCC -g Option"
|
bool "Enable gdb functions"
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Answer Y to add -g option in gcc command. But the LiteOS size will be much larger.
|
Answer Y to enable gdb functions.
|
||||||
|
|
||||||
config PLATFORM_ADAPT
|
config PLATFORM_ADAPT
|
||||||
bool "Enable Os_adapt"
|
bool "Enable Os_adapt"
|
||||||
@@ -164,16 +201,10 @@ config ENABLE_MAGICKEY
|
|||||||
config THUMB
|
config THUMB
|
||||||
bool "Enable Thumb"
|
bool "Enable Thumb"
|
||||||
default n
|
default n
|
||||||
select INTERWORK_THUMB
|
depends on ARCH_ARM
|
||||||
help
|
help
|
||||||
Answer Y to build thumb version. This will make LiteOS smaller.
|
Answer Y to build thumb version. This will make LiteOS smaller.
|
||||||
|
|
||||||
config INTERWORK_THUMB
|
|
||||||
bool "Enable interwork Thumb" if THUMB
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Answer Y to enable interwork thumb.
|
|
||||||
|
|
||||||
config PLATFORM_DVFS
|
config PLATFORM_DVFS
|
||||||
bool "Enable Dvfs"
|
bool "Enable Dvfs"
|
||||||
default n
|
default n
|
||||||
@@ -193,8 +224,8 @@ config DEBUG_VERSION
|
|||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
If you do not select this option that means you enable a release version for LiteOS.
|
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,
|
It also means you do not want to use debug modules, like shell,telnet,tftp,nfs and
|
||||||
,nfs,ramfs proc and memory check.
|
memory check, etc.
|
||||||
If you select this option that means you enable a debug version for LiteOS.
|
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.
|
That means you want a opposite behaviour compared to release version.
|
||||||
|
|
||||||
@@ -303,12 +334,13 @@ source "bsd/dev/usb/Kconfig"
|
|||||||
source "../../drivers/adapter/khdf/liteos/Kconfig"
|
source "../../drivers/adapter/khdf/liteos/Kconfig"
|
||||||
|
|
||||||
# Device driver Kconfig import
|
# Device driver Kconfig import
|
||||||
osource "$(DEVICE_PATH)/drivers/Kconfig"
|
source "$(DEVICE_PATH)/drivers/Kconfig"
|
||||||
|
|
||||||
source "drivers/char/mem/Kconfig"
|
source "drivers/char/mem/Kconfig"
|
||||||
source "drivers/char/quickstart/Kconfig"
|
source "drivers/char/quickstart/Kconfig"
|
||||||
source "drivers/char/random/Kconfig"
|
source "drivers/char/random/Kconfig"
|
||||||
source "drivers/char/video/Kconfig"
|
source "drivers/char/video/Kconfig"
|
||||||
|
source "drivers/char/trace/Kconfig"
|
||||||
|
|
||||||
source "../../drivers/liteos/tzdriver/Kconfig"
|
source "../../drivers/liteos/tzdriver/Kconfig"
|
||||||
source "../../drivers/liteos/hievent/Kconfig"
|
source "../../drivers/liteos/hievent/Kconfig"
|
||||||
|
|||||||
@@ -27,52 +27,28 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
LITEOSTOPDIR := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
|
LITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||||
LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
|
|
||||||
|
|
||||||
export LITEOSTOPDIR
|
export LITEOSTOPDIR
|
||||||
export LITEOSTHIRDPARTY
|
|
||||||
|
|
||||||
APPS = apps
|
APPS = apps
|
||||||
ROOTFS = rootfs
|
ROOTFS = rootfs
|
||||||
LITEOS_TARGET = liteos
|
LITEOS_TARGET = liteos
|
||||||
LITEOS_LIBS_TARGET = libs
|
LITEOS_LIBS_TARGET = libs
|
||||||
|
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
|
||||||
|
|
||||||
# by the following eval, we would got some variables like these:
|
|
||||||
# ohos_root_path=/xx
|
|
||||||
# ohos_board=hispark_taurus
|
|
||||||
# ohos_kernel=liteos_a
|
|
||||||
# ohos_product=ipcamera_hispark_taurus
|
|
||||||
# ohos_product_path=/xx/vendor/hisilicon/hispark_taurus
|
|
||||||
# ohos_device_path=/xx/device/hisilicon/hispark_taurus/sdk_liteos
|
|
||||||
ohos_kernel ?= liteos_a
|
ohos_kernel ?= liteos_a
|
||||||
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
|
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
|
||||||
|
|
||||||
ifneq ($(ohos_kernel),liteos_a)
|
ifneq ($(ohos_kernel),liteos_a)
|
||||||
$(error The selected product ($(ohos_product)) is not a liteos_a kernel type product)
|
$(error The selected product ($(ohos_product)) is not a liteos_a kernel type product)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
export CONFIG_=LOSCFG_
|
|
||||||
export srctree=$(LITEOSTOPDIR)
|
|
||||||
|
|
||||||
SYSROOT_PATH ?= $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot
|
|
||||||
export SYSROOT_PATH
|
|
||||||
|
|
||||||
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
|
|
||||||
export LITEOS_MENUCONFIG_H
|
|
||||||
|
|
||||||
CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
|
||||||
export CONFIG_FILE
|
|
||||||
|
|
||||||
ifeq ($(PRODUCT_PATH),)
|
ifeq ($(PRODUCT_PATH),)
|
||||||
PRODUCT_PATH:=$(ohos_product_path)
|
PRODUCT_PATH:=$(ohos_product_path)
|
||||||
endif
|
endif
|
||||||
export PRODUCT_PATH
|
|
||||||
|
|
||||||
ifeq ($(DEVICE_PATH),)
|
ifeq ($(DEVICE_PATH),)
|
||||||
DEVICE_PATH:=$(ohos_device_path)
|
DEVICE_PATH:=$(ohos_device_path)
|
||||||
endif
|
endif
|
||||||
export DEVICE_PATH
|
|
||||||
|
|
||||||
ifeq ($(TEE:1=y),y)
|
ifeq ($(TEE:1=y),y)
|
||||||
tee = _tee
|
tee = _tee
|
||||||
@@ -84,9 +60,24 @@ CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
KCONFIG_CONFIG ?= $(CONFIG)
|
KCONFIG_CONFIG ?= $(CONFIG)
|
||||||
export KCONFIG_CONFIG
|
SYSROOT_PATH ?= $(OUT)/sysroot
|
||||||
|
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
|
||||||
|
LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
||||||
|
|
||||||
-include $(LITEOSTOPDIR)/tools/build/config.mk
|
# 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)
|
||||||
|
|
||||||
|
include $(LITEOSTOPDIR)/config.mk
|
||||||
|
|
||||||
ifeq ($(LOSCFG_STORAGE_SPINOR), y)
|
ifeq ($(LOSCFG_STORAGE_SPINOR), y)
|
||||||
FSTYPE = jffs2
|
FSTYPE = jffs2
|
||||||
@@ -102,10 +93,8 @@ FSTYPE = jffs2
|
|||||||
endif
|
endif
|
||||||
ROOTFS_DIR = $(OUT)/rootfs
|
ROOTFS_DIR = $(OUT)/rootfs
|
||||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||||
VERSION =
|
|
||||||
|
|
||||||
define HELP =
|
define HELP =
|
||||||
-------------------------------------------------------
|
|
||||||
Usage: make [TARGET]... [PARAMETER=VALUE]...
|
Usage: make [TARGET]... [PARAMETER=VALUE]...
|
||||||
|
|
||||||
Targets:
|
Targets:
|
||||||
@@ -113,19 +102,19 @@ Targets:
|
|||||||
clean: clean compiled objects
|
clean: clean compiled objects
|
||||||
cleanall: clean all build outputs
|
cleanall: clean all build outputs
|
||||||
all: make liteos kernel image and rootfs image (Default target)
|
all: make liteos kernel image and rootfs image (Default target)
|
||||||
rootfs: make a original rootfs image
|
$(APPS): build all apps
|
||||||
|
$(ROOTFS): make a original rootfs image
|
||||||
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
|
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
|
||||||
$(LITEOS_TARGET): make liteos kernel image
|
$(LITEOS_TARGET): make liteos kernel image
|
||||||
update_config: update product kernel config (use menuconfig)
|
update_config: update product kernel config (use menuconfig)
|
||||||
test: make the testsuits_app and put it into the rootfs dir
|
xxconfig: invoke xxconfig command of kconfiglib (xxconfig is one of $(KCONFIG_CMDS))
|
||||||
test_apps: make a rootfs img with the testsuits_app in it
|
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
FSTYPE: value should be one of (jffs2 vfat yaffs2)
|
FSTYPE: value should be one of (jffs2 vfat yaffs2)
|
||||||
TEE: boolean value(1 or y for true), enable tee
|
TEE: boolean value(1 or y for true), enable tee
|
||||||
RELEASE: boolean value(1 or y for true), build release version
|
RELEASE: boolean value(1 or y for true), build release version
|
||||||
CONFIG: kernel config file to be use
|
CONFIG: kernel config file to be use
|
||||||
-------------------------------------------------------
|
args: arguments for xxconfig command
|
||||||
endef
|
endef
|
||||||
export HELP
|
export HELP
|
||||||
|
|
||||||
@@ -135,34 +124,39 @@ help:
|
|||||||
$(HIDE)echo "$$HELP"
|
$(HIDE)echo "$$HELP"
|
||||||
|
|
||||||
sysroot:
|
sysroot:
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
|
||||||
ifeq ($(wildcard $(SYSROOT_PATH)/usr/include/$(LLVM_TARGET)/),)
|
|
||||||
$(HIDE)$(MAKE) -C $(SYSROOT_PATH)/build TARGETS=liteos_a_user
|
|
||||||
endif
|
|
||||||
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
|
$(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
|
||||||
endif
|
endif
|
||||||
|
|
||||||
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
|
$(filter-out menuconfig,$(KCONFIG_CMDS)):
|
||||||
$(KCONFIG_CMDS):
|
|
||||||
$(HIDE)$@ $(args)
|
$(HIDE)$@ $(args)
|
||||||
|
|
||||||
$(LITEOS_MENUCONFIG_H) $(CONFIG_FILE): $(KCONFIG_CONFIG)
|
$(LITEOS_CONFIG_FILE): $(KCONFIG_CONFIG)
|
||||||
$(HIDE)genconfig --config-out $(CONFIG_FILE) --header-path $(LITEOS_MENUCONFIG_H) $(args)
|
$(HIDE)env KCONFIG_CONFIG=$< genconfig --config-out $@ --header-path $(LITEOS_MENUCONFIG_H)
|
||||||
|
|
||||||
update_config:
|
update_config menuconfig:
|
||||||
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig && savedefconfig --out "$(CONFIG)"
|
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig $(args) && savedefconfig --out "$(CONFIG)"
|
||||||
|
|
||||||
prepare: $(LITEOS_MENUCONFIG_H)
|
$(LITEOS_LIBS_TARGET): sysroot
|
||||||
$(HIDE)mkdir -p $(OUT)/musl $(OUT)/lib $(BUILD)
|
$(HIDE)for dir in $(LIB_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
||||||
|
|
||||||
$(LITEOS_LIBS_TARGET): prepare
|
|
||||||
$(HIDE)touch $(LOSCFG_ENTRY_SRC)
|
|
||||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
|
||||||
|
|
||||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
|
||||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).map
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).map
|
||||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).objsize
|
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).objsize
|
||||||
$(LITEOS_TARGET): $(LITEOS_TARGET_DIR)/$(LITEOS_TARGET).bin
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).bin
|
||||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).sym.sorted
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).sym.sorted
|
||||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).asm
|
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).asm
|
||||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).size
|
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).size
|
||||||
@@ -172,7 +166,7 @@ $(OUT)/$(LITEOS_TARGET): $(LITEOS_LIBS_TARGET)
|
|||||||
$(OUT)/$(LITEOS_TARGET).map: $(OUT)/$(LITEOS_TARGET)
|
$(OUT)/$(LITEOS_TARGET).map: $(OUT)/$(LITEOS_TARGET)
|
||||||
$(OUT)/$(LITEOS_TARGET).objsize: $(LITEOS_LIBS_TARGET)
|
$(OUT)/$(LITEOS_TARGET).objsize: $(LITEOS_LIBS_TARGET)
|
||||||
$(SIZE) -t --common $(OUT)/lib/*.a >$@
|
$(SIZE) -t --common $(OUT)/lib/*.a >$@
|
||||||
$(LITEOS_TARGET_DIR)/$(LITEOS_TARGET).bin: $(OUT)/$(LITEOS_TARGET)
|
$(OUT)/$(LITEOS_TARGET).bin: $(OUT)/$(LITEOS_TARGET)
|
||||||
$(OBJCOPY) -O binary $< $@
|
$(OBJCOPY) -O binary $< $@
|
||||||
$(OUT)/$(LITEOS_TARGET).sym.sorted: $(OUT)/$(LITEOS_TARGET)
|
$(OUT)/$(LITEOS_TARGET).sym.sorted: $(OUT)/$(LITEOS_TARGET)
|
||||||
$(OBJDUMP) -t $< |sort >$@
|
$(OBJDUMP) -t $< |sort >$@
|
||||||
@@ -181,35 +175,36 @@ $(OUT)/$(LITEOS_TARGET).asm: $(OUT)/$(LITEOS_TARGET)
|
|||||||
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
|
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
|
||||||
$(NM) -S --size-sort $< >$@
|
$(NM) -S --size-sort $< >$@
|
||||||
|
|
||||||
$(APPS): prepare
|
$(APPS): sysroot
|
||||||
$(HIDE)$(MAKE) -C apps all
|
$(HIDE)$(MAKE) -C apps all
|
||||||
|
|
||||||
$(ROOTFS): $(APPS)
|
$(ROOTFS): $(APPS)
|
||||||
|
$(HIDE)mkdir -p $(OUT)/musl
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||||
$(HIDE)cp -fp $$($(CC) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
||||||
$(HIDE)cp -fp $$($(GPP) --target=$(LLVM_TARGET) --sysroot=$(SYSROOT_PATH) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
|
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
|
||||||
else
|
else
|
||||||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
$(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 $$($(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 -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
|
||||||
endif
|
endif
|
||||||
$(STRIP) $(OUT)/musl/*
|
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR)
|
||||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
$(HIDE)shopt -s nullglob && $(STRIP) $(ROOTFS_DIR)/bin/* $(ROOTFS_DIR)/lib/*
|
||||||
ifneq ($(VERSION),)
|
ifneq ($(VERSION),)
|
||||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/releaseinfo.sh "$(VERSION)" $(ROOTFS_DIR)
|
||||||
endif
|
endif
|
||||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
|
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsimg.sh $(ROOTFS_DIR) $(FSTYPE)
|
||||||
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
|
$(HIDE)cd $(ROOTFS_DIR)/.. && zip -r $(ROOTFS_ZIP) $(ROOTFS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done
|
$(HIDE)if [ -d $(SYSROOT_PATH)/build ]; then $(MAKE) -C $(SYSROOT_PATH)/build clean; fi
|
||||||
$(HIDE)$(MAKE) -C apps clean
|
$(HIDE)for dir in $(LIB_SUBDIRS) apps; do $(MAKE) -C $$dir clean || exit 1; done
|
||||||
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H) $(CONFIG_FILE)
|
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H)
|
||||||
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
|
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
|
||||||
|
|
||||||
cleanall: clean
|
cleanall: clean
|
||||||
$(HIDE)$(RM) $(LITEOSTOPDIR)/out
|
$(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_CONFIG_FILE)
|
||||||
$(HIDE)echo "clean all done"
|
$(HIDE)echo "clean all done"
|
||||||
|
|
||||||
.PHONY: all clean cleanall prepare sysroot help update_config
|
.PHONY: all clean cleanall sysroot help update_config
|
||||||
.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET)
|
.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET) $(KCONFIG_CONFIG)
|
||||||
|
|||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
- liteos_m易用性
|
|
||||||
- [ ] liteos_m开发者手册
|
|
||||||
- [ ] 低功耗框架及实现(含投票机制)
|
|
||||||
- [ ] dump增强(配套解析工具)
|
|
||||||
- [ ] 全内存dump(配套解析工具)
|
|
||||||
- [ ] 实现完整L0 OHOS的qemu仿真
|
|
||||||
- [ ] Shell + AT
|
|
||||||
|
|
||||||
- liteos_m能力增强
|
|
||||||
- [ ] liteos_m支持elf动态加载
|
|
||||||
- [ ] 基于MPU/PMP的多任务简化隔离
|
|
||||||
- [ ] 基于MPU/PMP的多BIN隔离及灌段隔离
|
|
||||||
- [ ] 扩展支持中断嵌套
|
|
||||||
- [ ] 支持arm9架构
|
|
||||||
- [ ] 支持xtensa架构
|
|
||||||
|
|
||||||
- 文件系统增强
|
|
||||||
- [ ] 提供一种好用且开源的NandFlash文件系统
|
|
||||||
- [ ] 面向fat32、jffs2持续性能优化,做到极致
|
|
||||||
- [ ] fat32支持fast seek(现有fast seek限制文件扩展,需要改造)
|
|
||||||
- [ ] 支持软链接
|
|
||||||
- [ ] 头文件引用关系整理
|
|
||||||
- [ ] 接口层去nuttx
|
|
||||||
- [ ] 文件系统去大锁
|
|
||||||
|
|
||||||
- liteos_a支持三方芯片易移植性
|
|
||||||
- [ ] 启动框架重构
|
|
||||||
- [ ] musl库归一化
|
|
||||||
- [ ] 去C库预编译
|
|
||||||
- [ ] 宏配置依赖关系整理
|
|
||||||
- [ ] 典型商用配置场景整理并导入门禁(1V1映射,去缺页,去隔离,单进程等等)
|
|
||||||
- [ ] 编译框架整合到gn
|
|
||||||
- [ ] 实现基于python的kconfig可视化配置
|
|
||||||
|
|
||||||
- liteos_a易用性
|
|
||||||
- [ ] 实现L1 LiteOS-A及上层鸿蒙组件的qemu仿真
|
|
||||||
- [ ] liteos_a开发者手册
|
|
||||||
- [ ] mksh移植
|
|
||||||
- [ ] toybox命令集
|
|
||||||
- [ ] trace、backtrace、dump解析工具等
|
|
||||||
- procfs适配
|
|
||||||
- [ ] ifconfig、fd、free等
|
|
||||||
|
|
||||||
- liteos_a能力增强
|
|
||||||
- [ ] 单链表整改(SMP多核性能)
|
|
||||||
- [ ] 快启
|
|
||||||
- [ ] 典型高频函数C库性能优化
|
|
||||||
- [ ] rwlock
|
|
||||||
|
|
||||||
- liteos_a三方库移植
|
|
||||||
- [ ] libuv、dlna、benchmark、iperf、perf、tcpdump 等等
|
|
||||||
- C库能力补全
|
|
||||||
- [ ] epoll实现
|
|
||||||
|
|
||||||
- 测试验证
|
|
||||||
- [ ] syzkaller、difuze等
|
|
||||||
|
|
||||||
- 探索性课题
|
|
||||||
- [ ] 基于rust重写liteos_m基础内核
|
|
||||||
- [ ] 用户态驱动(对比业界并增强)
|
|
||||||
- [ ] 用户态文件系统
|
|
||||||
@@ -47,4 +47,8 @@ group("apps") {
|
|||||||
if (defined(LOSCFG_NET_LWIP_SACK_TFTP)) {
|
if (defined(LOSCFG_NET_LWIP_SACK_TFTP)) {
|
||||||
deps += [ "tftp" ]
|
deps += [ "tftp" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined(LOSCFG_DRIVERS_TRACE)) {
|
||||||
|
deps += [ "trace" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-14
@@ -27,26 +27,21 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
LITEOSTOPDIR := $(shell pwd)/../
|
APPSTOPDIR := $(shell pwd)
|
||||||
|
LITEOSTOPDIR ?= $(APPSTOPDIR)/..
|
||||||
|
export LITEOSTOPDIR
|
||||||
|
export APPSTOPDIR
|
||||||
|
|
||||||
include $(LITEOSTOPDIR)/.config
|
include $(APPSTOPDIR)/config.mk
|
||||||
include ./config.mk
|
|
||||||
include ./module.mk
|
|
||||||
|
|
||||||
HIDE := @
|
all:
|
||||||
APPS := app
|
|
||||||
|
|
||||||
all: $(APPS)
|
|
||||||
|
|
||||||
# Make
|
|
||||||
$(APPS):
|
|
||||||
ifneq ($(APP_SUBDIRS), )
|
ifneq ($(APP_SUBDIRS), )
|
||||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir || exit 1; done
|
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
ifneq ($(APP_SUBDIRS), )
|
ifneq ($(APP_SUBDIRS), )
|
||||||
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean; done
|
$(HIDE) for dir in $(APP_SUBDIRS); do $(MAKE) -C $$dir clean || exit 1; done
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: all $(APPS) clean
|
.PHONY: all clean
|
||||||
|
|||||||
+114
@@ -0,0 +1,114 @@
|
|||||||
|
# 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 :=
|
||||||
+40
-20
@@ -27,30 +27,18 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
# common dir config
|
|
||||||
include $(LITEOSTOPDIR)/config.mk
|
include $(LITEOSTOPDIR)/config.mk
|
||||||
|
|
||||||
# output dir config
|
|
||||||
OBJOUT := $(APPSTOPDIR)/out
|
|
||||||
APPSOUT := $(OBJOUT)/apps
|
|
||||||
LIBSOUT := $(OBJOUT)/libs
|
|
||||||
IMGOUT := $(OUT)
|
|
||||||
|
|
||||||
# common flags config
|
# common flags config
|
||||||
BASE_OPTS := -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-common -fno-strict-aliasing -D_GNU_SOURCE \
|
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE $(LITEOS_GCOV_OPTS)
|
||||||
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(LITEOS_GCOV_OPTS)
|
|
||||||
|
|
||||||
CFLAGS := -std=c99 -fno-exceptions $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
ASFLAGS :=
|
||||||
CXXFLAGS := -std=c++11 -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
CFLAGS := $(LITEOS_COPTS) $(BASE_OPTS) -fPIE
|
||||||
LDCFLAGS := -lc
|
CXXFLAGS := $(LITEOS_CXXOPTS) $(BASE_OPTS) -fPIE
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
LDFLAGS := $(LITEOS_CORE_COPTS) -pie -Wl,-z,relro,-z,now -O2
|
||||||
LLVM_SYSROOT := --sysroot=$(SYSROOT_PATH) $(ARCH_CFLAGS)
|
|
||||||
LDCXXFLGS := -lc++ -lc++abi -lc
|
CFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib,$(CFLAGS))
|
||||||
else
|
CXXFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib -nostdinc++,$(CXXFLAGS))
|
||||||
BASE_OPTS += -Wl,-z,relro,-z,now
|
|
||||||
LDCXXFLGS := -lstdc++ -lsupc++ -lc
|
|
||||||
endif
|
|
||||||
COMMON_INCLUDE := -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
|
||||||
|
|
||||||
# alias variable config
|
# alias variable config
|
||||||
HIDE := @
|
HIDE := @
|
||||||
@@ -58,3 +46,35 @@ MAKE := make
|
|||||||
RM := rm -rf
|
RM := rm -rf
|
||||||
CP := cp -rf
|
CP := cp -rf
|
||||||
MV := mv -f
|
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 :=
|
||||||
|
|||||||
+2
-16
@@ -32,22 +32,8 @@ import("//kernel/liteos_a/liteos.gni")
|
|||||||
executable("init") {
|
executable("init") {
|
||||||
sources = [ "src/init.c" ]
|
sources = [ "src/init.c" ]
|
||||||
|
|
||||||
cflags = [ "-fPIE" ]
|
|
||||||
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [
|
|
||||||
"-Wno-shift-op-parentheses",
|
|
||||||
"-Wno-bitwise-op-parentheses",
|
|
||||||
"-Wnonnull",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
ldflags = [
|
|
||||||
"-pie",
|
|
||||||
"-s",
|
|
||||||
]
|
|
||||||
|
|
||||||
if (defined(LOSCFG_QUICK_START)) {
|
if (defined(LOSCFG_QUICK_START)) {
|
||||||
ldflags += [ "--static" ]
|
ldflags = [ "--static" ]
|
||||||
|
defines = [ "LOSCFG_QUICK_START" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-32
@@ -27,43 +27,15 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
INIT_DIR := $(dir $(shell pwd))/init/
|
include $(APPSTOPDIR)/config.mk
|
||||||
|
|
||||||
ifeq ($(APPSTOPDIR), )
|
APP_NAME := $(notdir $(shell pwd))
|
||||||
APPSTOPDIR := $(shell pwd)/../
|
|
||||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
|
||||||
endif
|
|
||||||
include $(INIT_DIR)/../config.mk
|
|
||||||
|
|
||||||
APPS_OUT := $(OUT)/bin
|
|
||||||
LOCAL_SRCS := src/init.c
|
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)
|
ifeq ($(LOSCFG_QUICK_START), y)
|
||||||
LDCFLAGS += --static
|
LDFLAGS += --static
|
||||||
CFLAGS += -DLOSCFG_QUICK_START
|
CFLAGS += -DLOSCFG_QUICK_START
|
||||||
endif
|
endif
|
||||||
|
|
||||||
INITNAME := init
|
include $(APP)
|
||||||
|
|
||||||
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
|
|
||||||
|
|||||||
+5
-1
@@ -48,7 +48,6 @@ build_ext_component("build_mksh") {
|
|||||||
"-flto",
|
"-flto",
|
||||||
"-fdata-sections",
|
"-fdata-sections",
|
||||||
"-ffunction-sections",
|
"-ffunction-sections",
|
||||||
"-Oz",
|
|
||||||
"-fstack-protector-strong",
|
"-fstack-protector-strong",
|
||||||
"-D_FORTIFY_SOURCE=2",
|
"-D_FORTIFY_SOURCE=2",
|
||||||
"-DMKSH_DISABLE_TTY_WARNING",
|
"-DMKSH_DISABLE_TTY_WARNING",
|
||||||
@@ -62,6 +61,11 @@ build_ext_component("build_mksh") {
|
|||||||
"-DMKSH_NO_INITCOMS",
|
"-DMKSH_NO_INITCOMS",
|
||||||
"-DADAPT_FOR_LITEOS_A",
|
"-DADAPT_FOR_LITEOS_A",
|
||||||
]
|
]
|
||||||
|
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||||
|
cflags += [ "-Oz" ]
|
||||||
|
} else {
|
||||||
|
cflags += [ "-O2" ]
|
||||||
|
}
|
||||||
cflags = string_join(" ", cflags)
|
cflags = string_join(" ", cflags)
|
||||||
|
|
||||||
extra_flags = string_join(" ", target_arch_cflags)
|
extra_flags = string_join(" ", target_arch_cflags)
|
||||||
|
|||||||
+16
-38
@@ -27,52 +27,30 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
MKSH := mksh
|
include $(APPSTOPDIR)/config.mk
|
||||||
|
|
||||||
MKSH_DIR := $(shell pwd)/
|
BUILD_DIR := $(OUT)/mksh_build
|
||||||
LITEOSTOPDIR = $(MKSH_DIR)/../../
|
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||||
include $(MKSH_DIR)/../config.mk
|
|
||||||
|
|
||||||
APPS_OUT := $(OUT)/bin
|
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
|
||||||
ETC_OUT := $(OUT)/etc
|
CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||||
BUILD_DIR := $(MKSH_DIR)/build
|
CFLAGS += -Wno-error
|
||||||
BUILD_LOG := $(MKSH_DIR)/build.log
|
LDFLAGS += -Wl,--gc-sections
|
||||||
TARGET_OS := OpenHarmony
|
|
||||||
|
|
||||||
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -fstack-protector-strong -D_FORTIFY_SOURCE=2
|
all:
|
||||||
LOCAL_CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
|
||||||
LOCAL_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
|
||||||
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2
|
|
||||||
|
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
|
||||||
LOCAL_CFLAGS += -Oz --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
|
||||||
else
|
|
||||||
LOCAL_CFLAGS += -O2
|
|
||||||
endif
|
|
||||||
|
|
||||||
all:$(MKSH)
|
|
||||||
|
|
||||||
$(MKSH):
|
|
||||||
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
|
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
|
||||||
$(HIDE)echo "not clean, rebuilding now"
|
$(HIDE)echo "not clean, rebuilding now"
|
||||||
$(HIDE)chmod +x $(BUILD_DIR)/Rebuild.sh
|
$(HIDE)cd $(BUILD_DIR) && sh ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||||
$(HIDE)cd $(BUILD_DIR) && ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
|
||||||
else
|
else
|
||||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(MKSH)/. $(BUILD_DIR)
|
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/mksh/. $(BUILD_DIR)
|
||||||
$(HIDE)chmod +x $(BUILD_DIR)/Build.sh
|
$(HIDE)cd $(BUILD_DIR) && CC="$(CC)" TARGET_OS=OpenHarmony CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" sh ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||||
$(HIDE)cd $(BUILD_DIR) && CC=$(CC) TARGET_OS=$(TARGET_OS) CFLAGS="$(LOCAL_CFLAGS)" LDFLAGS="$(LOCAL_LDFLAGS)" ./Build.sh -r > $(BUILD_LOG) 2>&1
|
|
||||||
endif
|
endif
|
||||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/$(MKSH) .
|
$(HIDE)mkdir -p $(OUT)/bin/ $(OUT)/etc/
|
||||||
$(HIDE)$(STRIP) $(MKSH)
|
$(HIDE)$(STRIP) $(BUILD_DIR)/mksh -o $(OUT)/bin/mksh
|
||||||
$(HIDE)mkdir -p $(APPS_OUT)
|
$(HIDE)$(CP) $(BUILD_DIR)/.mkshrc $(OUT)/etc/
|
||||||
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
|
|
||||||
$(HIDE)mkdir -p $(ETC_OUT)
|
|
||||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/.mkshrc $(ETC_OUT)/
|
|
||||||
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)
|
$(HIDE)$(RM) $(BUILD_DIR)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
.PHONY: all $(MKSH) clean
|
|
||||||
|
|||||||
@@ -41,18 +41,4 @@ executable("shell") {
|
|||||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||||
|
|
||||||
include_dirs = [ "include" ]
|
include_dirs = [ "include" ]
|
||||||
|
|
||||||
cflags = [ "-fPIE" ]
|
|
||||||
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [
|
|
||||||
"-Wno-shift-op-parentheses",
|
|
||||||
"-Wno-bitwise-op-parentheses",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
ldflags = [
|
|
||||||
"-pie",
|
|
||||||
"-s",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-42
@@ -27,52 +27,19 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
SHELL_DIR := $(dir $(shell pwd))/shell/
|
include $(APPSTOPDIR)/config.mk
|
||||||
|
|
||||||
ifeq ($(APPSTOPDIR), )
|
APP_NAME := $(notdir $(shell pwd))
|
||||||
APPSTOPDIR := $(shell pwd)/../
|
|
||||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
|
||||||
endif
|
|
||||||
include $(SHELL_DIR)/../config.mk
|
|
||||||
APPS_OUT := $(OUT)/bin
|
|
||||||
|
|
||||||
SECUREC_INCLUDE := $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||||
|
|
||||||
LOCAL_SRCS = $(wildcard src/main.c)\
|
LOCAL_SRCS = $(wildcard src/*.c builtin/*.c)
|
||||||
$(wildcard src/shcmd.c)\
|
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.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 := \
|
LOCAL_INCLUDE := \
|
||||||
-I $(SHELL_DIR)/include/ \
|
-I include \
|
||||||
-I $(SECUREC_INCLUDE)\
|
-I $(SECUREC_DIR)/include
|
||||||
|
|
||||||
LOCAL_FLAGS += $(CFLAGS)
|
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||||
|
|
||||||
LDPATH := -L$(SHELL_DIR)/
|
include $(APP)
|
||||||
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
|
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
extern char *OsShellGetWorkingDirtectory();
|
extern char *OsShellGetWorkingDirtectory(void);
|
||||||
extern unsigned int OsShellInit();
|
extern unsigned int OsShellInit(void);
|
||||||
extern int OsShellDeinit(ShellCB *shellCB);
|
extern int OsShellDeinit(ShellCB *shellCB);
|
||||||
extern ShellCB *OsGetShellCb();
|
extern ShellCB *OsGetShellCb(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|||||||
@@ -38,18 +38,4 @@ executable("tftp") {
|
|||||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||||
|
|
||||||
include_dirs = [ "include" ]
|
include_dirs = [ "include" ]
|
||||||
|
|
||||||
cflags = [ "-fPIE" ]
|
|
||||||
|
|
||||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
|
||||||
cflags += [
|
|
||||||
"-Wno-shift-op-parentheses",
|
|
||||||
"-Wno-bitwise-op-parentheses",
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
ldflags = [
|
|
||||||
"-pie",
|
|
||||||
"-s",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-39
@@ -27,51 +27,19 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
ROOT_DIR := $(dir $(shell pwd))/tftp/
|
include $(APPSTOPDIR)/config.mk
|
||||||
|
|
||||||
ifeq ($(APPSTOPDIR), )
|
APP_NAME := $(notdir $(shell pwd))
|
||||||
APPSTOPDIR := $(shell pwd)/../
|
|
||||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
|
||||||
endif
|
|
||||||
include $(ROOT_DIR)/../config.mk
|
|
||||||
APPS_OUT := $(OUT)/bin
|
|
||||||
|
|
||||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||||
|
|
||||||
LOCAL_SRCS = $(wildcard src/*.c)
|
LOCAL_SRCS = $(wildcard src/*.c)
|
||||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncpy_s.c)
|
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.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 := \
|
LOCAL_INCLUDE := \
|
||||||
-I $(ROOT_DIR)/include/ \
|
-I include \
|
||||||
-I $(SECUREC_DIR)/include/\
|
-I $(SECUREC_DIR)/include
|
||||||
|
|
||||||
LOCAL_FLAGS += $(CFLAGS)
|
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||||
|
|
||||||
LDPATH := -L$(ROOT_DIR)/
|
include $(APP)
|
||||||
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
|
|
||||||
|
|||||||
+14
-29
@@ -27,42 +27,27 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
TOYBOX:= toybox
|
include $(APPSTOPDIR)/config.mk
|
||||||
|
|
||||||
TOYBOX_DIR := $(shell pwd)
|
BUILD_DIR := $(OUT)/toybox_build
|
||||||
LITEOSTOPDIR = $(TOYBOX_DIR)/../../
|
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||||
include $(TOYBOX_DIR)/../config.mk
|
|
||||||
|
|
||||||
APPS_OUT := $(OUT)/bin
|
CFLAGS += -Wno-error
|
||||||
BUILD_DIR := $(TOYBOX_DIR)/build
|
|
||||||
BUILD_LOG := $(TOYBOX_DIR)/build.log
|
|
||||||
OUTNAME := $(TOYBOX)
|
|
||||||
|
|
||||||
CFLAGS := -D_FORTIFY_SOURCE=2 -fstack-protector-strong
|
all:
|
||||||
LDFLAGS :=
|
|
||||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
|
||||||
CFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
|
||||||
LDFLAGS += --target=$(LLVM_TARGET) $(LLVM_SYSROOT)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(TOYBOX):
|
|
||||||
ifneq ($(wildcard $(BUILD_DIR)),)
|
ifneq ($(wildcard $(BUILD_DIR)),)
|
||||||
$(HIDE)echo "not clean, rebuilding now";
|
$(HIDE)echo "not clean, rebuilding now"
|
||||||
else
|
else
|
||||||
$(HIDE)mkdir $(BUILD_DIR)
|
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
|
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/. $(BUILD_DIR)
|
||||||
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
|
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/porting/liteos_a/. $(BUILD_DIR)
|
||||||
|
$(HIDE)$(CP) liteos_a_custom.config $(BUILD_DIR)/../
|
||||||
endif
|
endif
|
||||||
|
$(HIDE)unset KCONFIG_CONFIG CROSS_COMPILE && \
|
||||||
$(HIDE)CFLAGS="$(CFLAGS)" CC="$(CC)" OUTNAME="$(OUTNAME)" \
|
env CC="$(CC)" OUTNAME="$(OUT)/bin/toybox" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
|
||||||
LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
|
|
||||||
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
||||||
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
|
|
||||||
$(HIDE)mkdir -p $(APPS_OUT)
|
|
||||||
$(HIDE)$(CP) $(TOYBOX) $(APPS_OUT)
|
|
||||||
$(HIDE)$(RM) $(BUILD_DIR) $(BUILD_LOG)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG)
|
$(HIDE)$(RM) $(BUILD_DIR)
|
||||||
|
|
||||||
.PHONY: all $(TOYBOX) clean
|
.PHONY: all clean
|
||||||
|
|||||||
@@ -27,8 +27,8 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
DYNLOADTESTDIR := $(LITEOSTOPDIR)/test/kernel/sample/kernel_extend/dynload
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
export DYNLOADTESTDIR
|
|
||||||
|
|
||||||
##### command to test dynload #####
|
executable("trace") {
|
||||||
-include $(DYNLOADTESTDIR)/test_dynload.mk
|
sources = [ "src/trace.c" ]
|
||||||
|
}
|
||||||
@@ -1,53 +1,36 @@
|
|||||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
# are permitted provided that the following conditions are met:
|
# are permitted provided that the following conditions are met:
|
||||||
#
|
#
|
||||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
# conditions and the following disclaimer.
|
# conditions and the following disclaimer.
|
||||||
#
|
#
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
# 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
|
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
# provided with the distribution.
|
# provided with the distribution.
|
||||||
#
|
#
|
||||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
# 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
|
# to endorse or promote products derived from this software without specific prior written
|
||||||
# permission.
|
# permission.
|
||||||
#
|
#
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
SRC_MODULES := fs/proc
|
include $(APPSTOPDIR)/config.mk
|
||||||
|
|
||||||
ifeq ($(LOSCFG_USER_TEST_LLT), y)
|
APP_NAME := $(notdir $(shell pwd))
|
||||||
LLT_MODULES := fs/proc/llt
|
|
||||||
endif
|
LOCAL_SRCS := src/trace.c
|
||||||
|
|
||||||
ifeq ($(LOSCFG_USER_TEST_SMOKE), y)
|
include $(APP)
|
||||||
SMOKE_MODULES := fs/proc/smoke
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(LOSCFG_USER_TEST_FULL), y)
|
|
||||||
FULL_MODULES := fs/proc/full
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(LOSCFG_USER_TEST_PRESSURE), y)
|
|
||||||
PRESSURE_MODULES := fs/proc/pressure
|
|
||||||
endif
|
|
||||||
|
|
||||||
LOCAL_MODULES := $(SRC_MODULES) $(LLT_MODULES) $(PRESSURE_MODULES) $(SMOKE_MODULES) $(FULL_MODULES)
|
|
||||||
|
|
||||||
LOCAL_SRCS += $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.c))
|
|
||||||
LOCAL_CHS += $(foreach dir,$(LOCAL_MODULES),$(wildcard $(dir)/*.h))
|
|
||||||
|
|
||||||
LOCAL_FLAGS += -I./fs/proc
|
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
+2
-9
@@ -31,17 +31,10 @@ import("//kernel/liteos_a/liteos.gni")
|
|||||||
|
|
||||||
group("arm") {
|
group("arm") {
|
||||||
deps = [ "gic" ]
|
deps = [ "gic" ]
|
||||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
deps += [ ARCH ]
|
||||||
deps += [ "arm" ]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config("public") {
|
config("public") {
|
||||||
include_dirs = [ "include" ]
|
include_dirs = [ "include" ]
|
||||||
configs = []
|
configs = [ "$ARCH:public" ]
|
||||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
|
||||||
configs += [ "arm:public" ]
|
|
||||||
} else if (defined(LOSCFG_ARCH_ARM_AARCH64)) {
|
|
||||||
configs += [ "aarch64:public" ]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-21
@@ -36,15 +36,15 @@ LOSCFG_ARCH_FPU_STRIP := $(subst $\",,$(LOSCFG_ARCH_FPU))
|
|||||||
LOSCFG_ARCH_FPU = $(LOSCFG_ARCH_FPU_STRIP)
|
LOSCFG_ARCH_FPU = $(LOSCFG_ARCH_FPU_STRIP)
|
||||||
|
|
||||||
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
|
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
|
||||||
LITEOS_ARCH_ARM := arm
|
ARCH := arm
|
||||||
else ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
|
else ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
|
||||||
LITEOS_ARCH_ARM :=
|
ARCH := aarch64
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LITEOS_BASELIB += -l$(LOSCFG_ARCH_CPU)
|
LITEOS_BASELIB += -l$(LOSCFG_ARCH_CPU)
|
||||||
LITEOS_BASELIB += -lgic
|
LITEOS_BASELIB += -lgic
|
||||||
|
|
||||||
LIB_SUBDIRS += arch/arm/$(LITEOS_ARCH_ARM)
|
LIB_SUBDIRS += arch/arm/$(ARCH)
|
||||||
LIB_SUBDIRS += arch/arm/gic
|
LIB_SUBDIRS += arch/arm/gic
|
||||||
|
|
||||||
# CPU compile options
|
# CPU compile options
|
||||||
@@ -66,14 +66,12 @@ LITEOS_GCCLIB := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
LITEOS_CORE_COPTS = $(or $(ARCH_CFLAGS),$(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS))
|
LITEOS_CORE_COPTS = $(or $(ARCH_CFLAGS),$(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_ASOPTS += $(LITEOS_CPU_OPTS)
|
||||||
LITEOS_CXXOPTS_BASE += $(LITEOS_CORE_COPTS)
|
LITEOS_CXXOPTS_BASE += $(LITEOS_CORE_COPTS)
|
||||||
|
|
||||||
ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
|
ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
|
||||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/include \
|
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/include \
|
||||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/src/include
|
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include
|
||||||
|
|
||||||
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
|
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
|
||||||
|
|
||||||
@@ -85,17 +83,3 @@ else ifeq ($(LOSCFG_ARCH_FPU_VFP_D16), y)
|
|||||||
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y)
|
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y)
|
||||||
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32
|
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32
|
||||||
endif
|
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)
|
|
||||||
|
|||||||
+13
-1
@@ -49,6 +49,7 @@ kernel_module(module_name) {
|
|||||||
"src/strncpy_from_user.c",
|
"src/strncpy_from_user.c",
|
||||||
"src/strnlen_user.c",
|
"src/strnlen_user.c",
|
||||||
"src/user_copy.c",
|
"src/user_copy.c",
|
||||||
|
"src/smp.c",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
|
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
|
||||||
@@ -64,7 +65,7 @@ kernel_module(module_name) {
|
|||||||
include_dirs = [ "src/include" ]
|
include_dirs = [ "src/include" ]
|
||||||
|
|
||||||
if (defined(LOSCFG_GDB)) {
|
if (defined(LOSCFG_GDB)) {
|
||||||
configs += [ "$LITEOSTOPDIR:as_objs_libc_flags" ]
|
configs += [ ":as_objs_libc_flags" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
public_configs = [ ":public" ]
|
public_configs = [ ":public" ]
|
||||||
@@ -76,3 +77,14 @@ config("public") {
|
|||||||
"src/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" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+11
-1
@@ -38,7 +38,7 @@ LOCAL_INCLUDE := \
|
|||||||
-I $(LITEOSTOPDIR)/kernel/extended/dynload/include \
|
-I $(LITEOSTOPDIR)/kernel/extended/dynload/include \
|
||||||
-I $(LITEOSTOPDIR)/arch/arm/arm/include \
|
-I $(LITEOSTOPDIR)/arch/arm/arm/include \
|
||||||
|
|
||||||
ifeq ($(LITEOS_ARM_ARCH), -march=armv7-a)
|
ifeq ($(LOSCFG_ARCH_ARM_VER), "armv7-a")
|
||||||
LOCAL_SRCS += $(wildcard src/armv7a/*.S)
|
LOCAL_SRCS += $(wildcard src/armv7a/*.S)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -50,6 +50,16 @@ endif
|
|||||||
|
|
||||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
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)
|
ifeq ($(LOSCFG_GDB), y)
|
||||||
LOCAL_FLAGS += $(AS_OBJS_LIBC_FLAGS)
|
LOCAL_FLAGS += $(AS_OBJS_LIBC_FLAGS)
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ extern "C" {
|
|||||||
#define ISB __asm__ volatile("isb" ::: "memory")
|
#define ISB __asm__ volatile("isb" ::: "memory")
|
||||||
#define WFI __asm__ volatile("wfi" ::: "memory")
|
#define WFI __asm__ volatile("wfi" ::: "memory")
|
||||||
#define BARRIER __asm__ volatile("":::"memory")
|
#define BARRIER __asm__ volatile("":::"memory")
|
||||||
|
#define WFE __asm__ volatile("wfe" ::: "memory")
|
||||||
|
#define SEV __asm__ volatile("sev" ::: "memory")
|
||||||
|
|
||||||
#define ARM_SYSREG_READ(REG) \
|
#define ARM_SYSREG_READ(REG) \
|
||||||
({ \
|
({ \
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _ARCH_SMP_H
|
||||||
|
#define _ARCH_SMP_H
|
||||||
|
|
||||||
|
#include "los_config.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
struct SmpOps {
|
||||||
|
INT32 (*SmpCpuOn)(UINT32 cpuNum, UINTPTR startEntry); /* The startEntry is physical addr. */
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef VOID (*ArchCpuStartFunc)(VOID *arg);
|
||||||
|
|
||||||
|
VOID HalArchCpuOn(UINT32 cpuNum, ArchCpuStartFunc func, struct SmpOps *ops, VOID *arg);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif /* _ARCH_SMP_H */
|
||||||
|
|
||||||
@@ -790,7 +790,7 @@ STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
|
|||||||
LOS_PhysPageFree(page);
|
LOS_PhysPageFree(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
OsArmWriteTlbiasid(archMmu->asid);
|
OsArmWriteTlbiasidis(archMmu->asid);
|
||||||
OsFreeAsid(archMmu->asid);
|
OsFreeAsid(archMmu->asid);
|
||||||
#endif
|
#endif
|
||||||
(VOID)LOS_MuxDestroy(&archMmu->mtx);
|
(VOID)LOS_MuxDestroy(&archMmu->mtx);
|
||||||
|
|||||||
@@ -228,7 +228,8 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
ret = LOS_ERRNO_VM_NOT_FOUND;
|
OsArmWriteTlbimvaais(ROUNDDOWN(far, PAGE_SIZE));
|
||||||
|
ret = LOS_OK;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
|
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
|
||||||
@@ -276,8 +277,8 @@ STATIC const CHAR *g_excTypeString[] = {
|
|||||||
#ifdef LOSCFG_KERNEL_VM
|
#ifdef LOSCFG_KERNEL_VM
|
||||||
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
|
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
|
||||||
{
|
{
|
||||||
struct file *curFilep = NULL;
|
struct Vnode *curVnode = NULL;
|
||||||
struct file *lastFilep = NULL;
|
struct Vnode *lastVnode = NULL;
|
||||||
LosVmMapRegion *curRegion = NULL;
|
LosVmMapRegion *curRegion = NULL;
|
||||||
LosVmMapRegion *lastRegion = NULL;
|
LosVmMapRegion *lastRegion = NULL;
|
||||||
|
|
||||||
@@ -296,9 +297,9 @@ STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProc
|
|||||||
if ((lastRegion == NULL) || !LOS_IsRegionFileValid(lastRegion)) {
|
if ((lastRegion == NULL) || !LOS_IsRegionFileValid(lastRegion)) {
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
curFilep = curRegion->unTypeData.rf.file;
|
curVnode = curRegion->unTypeData.rf.vnode;
|
||||||
lastFilep = lastRegion->unTypeData.rf.file;
|
lastVnode = lastRegion->unTypeData.rf.vnode;
|
||||||
} while (!strcmp(curFilep->f_path, lastFilep->f_path));
|
} while (curVnode == lastVnode);
|
||||||
|
|
||||||
DONE:
|
DONE:
|
||||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||||
@@ -994,10 +995,12 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
|||||||
g_currHandleExcCpuID = currCpuID;
|
g_currHandleExcCpuID = currCpuID;
|
||||||
g_currHandleExcPID = OsCurrProcessGet()->processID;
|
g_currHandleExcPID = OsCurrProcessGet()->processID;
|
||||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||||
|
#ifndef LOSCFG_SAVE_EXCINFO
|
||||||
if (g_excFromUserMode[currCpuID] == FALSE) {
|
if (g_excFromUserMode[currCpuID] == FALSE) {
|
||||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||||
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
||||||
/* Both cores raise exceptions, and the current core is a user-mode exception.
|
/* Both cores raise exceptions, and the current core is a user-mode exception.
|
||||||
* Both cores are abnormal and come from the same process
|
* Both cores are abnormal and come from the same process
|
||||||
@@ -1022,11 +1025,12 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
|||||||
while (1) {}
|
while (1) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifndef LOSCFG_SAVE_EXCINFO
|
||||||
/* use halt ipi to stop other active cores */
|
/* use halt ipi to stop other active cores */
|
||||||
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
||||||
WaitAllCpuStop(currCpuID);
|
WaitAllCpuStop(currCpuID);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
|
|||||||
taskContext->LR = (UINTPTR)OsTaskExit; /* LR should be kept, to distinguish it's THUMB or ARM instruction */
|
taskContext->LR = (UINTPTR)OsTaskExit; /* LR should be kept, to distinguish it's THUMB or ARM instruction */
|
||||||
taskContext->R0 = taskID; /* R0 */
|
taskContext->R0 = taskID; /* R0 */
|
||||||
|
|
||||||
#ifdef LOSCFG_INTERWORK_THUMB
|
#ifdef LOSCFG_THUMB
|
||||||
taskContext->regCPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
|
taskContext->regCPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
|
||||||
#else
|
#else
|
||||||
taskContext->regCPSR = PSR_MODE_SVC_ARM; /* CPSR (Enable IRQ and FIQ interrupts, ARM-mode) */
|
taskContext->regCPSR = PSR_MODE_SVC_ARM; /* CPSR (Enable IRQ and FIQ interrupts, ARM-mode) */
|
||||||
@@ -123,7 +123,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR tas
|
|||||||
{
|
{
|
||||||
LOS_ASSERT(context != NULL);
|
LOS_ASSERT(context != NULL);
|
||||||
|
|
||||||
#ifdef LOSCFG_INTERWORK_THUMB
|
#ifdef LOSCFG_THUMB
|
||||||
context->regCPSR = PSR_MODE_USR_THUMB;
|
context->regCPSR = PSR_MODE_USR_THUMB;
|
||||||
#else
|
#else
|
||||||
context->regCPSR = PSR_MODE_USR_ARM;
|
context->regCPSR = PSR_MODE_USR_ARM;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "los_cpup_pri.h"
|
#include "los_cpup_pri.h"
|
||||||
#endif
|
#endif
|
||||||
#include "los_sched_pri.h"
|
#include "los_sched_pri.h"
|
||||||
|
#include "los_hook.h"
|
||||||
|
|
||||||
/* spinlock for hwi module, only available on SMP mode */
|
/* spinlock for hwi module, only available on SMP mode */
|
||||||
LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
|
LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
|
||||||
@@ -84,7 +84,7 @@ VOID OsInterrupt(UINT32 intNum)
|
|||||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||||
OsCpupIrqStart();
|
OsCpupIrqStart();
|
||||||
#endif
|
#endif
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum);
|
||||||
hwiForm = (&g_hwiForm[intNum]);
|
hwiForm = (&g_hwiForm[intNum]);
|
||||||
#ifndef LOSCFG_NO_SHARED_IRQ
|
#ifndef LOSCFG_NO_SHARED_IRQ
|
||||||
while (hwiForm->pstNext != NULL) {
|
while (hwiForm->pstNext != NULL) {
|
||||||
@@ -107,6 +107,7 @@ VOID OsInterrupt(UINT32 intNum)
|
|||||||
#endif
|
#endif
|
||||||
++g_hwiFormCnt[intNum];
|
++g_hwiFormCnt[intNum];
|
||||||
|
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum);
|
||||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||||
OsCpupIrqEnd(intNum);
|
OsCpupIrqEnd(intNum);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ASSEMBLY
|
#define ASSEMBLY
|
||||||
#include "arch_config.h"
|
#include "arch_config.h"
|
||||||
#include "los_vm_boot.h"
|
#include "los_vm_boot.h"
|
||||||
@@ -54,6 +55,8 @@
|
|||||||
.extern __stack_chk_guard_setup
|
.extern __stack_chk_guard_setup
|
||||||
.extern g_firstPageTable
|
.extern g_firstPageTable
|
||||||
.extern g_mmuJumpPageTable
|
.extern g_mmuJumpPageTable
|
||||||
|
.extern g_archMmuInitMapping
|
||||||
|
.extern HalSecondaryCpuStart
|
||||||
|
|
||||||
.equ MPIDR_CPUID_MASK, 0xffU
|
.equ MPIDR_CPUID_MASK, 0xffU
|
||||||
|
|
||||||
@@ -77,14 +80,6 @@
|
|||||||
bl excstack_magic
|
bl excstack_magic
|
||||||
.endm
|
.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
|
.code 32
|
||||||
.section ".vectors","ax"
|
.section ".vectors","ax"
|
||||||
|
|
||||||
@@ -184,12 +179,15 @@ reloc_img_to_bottom_done:
|
|||||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||||
|
|
||||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
ldr r5, =g_archMmuInitMapping
|
||||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
add r5, r5, r11
|
||||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
init_mmu_loop:
|
||||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
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 */
|
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||||
add r4, r4, r11
|
add r4, r4, r11
|
||||||
@@ -205,9 +203,7 @@ reloc_img_to_bottom_done:
|
|||||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
|
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
|
||||||
rsb r7, r11, r6, lsl #20 /* r7: va */
|
rsb r7, r11, r6, lsl #20 /* r7: va */
|
||||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||||
#endif
|
|
||||||
bl _bootaddr_setup
|
|
||||||
#ifdef LOSCFG_KERNEL_MMU
|
|
||||||
bl mmu_setup /* set up the mmu */
|
bl mmu_setup /* set up the mmu */
|
||||||
#endif
|
#endif
|
||||||
/* clear out the interrupt and exception stack and set magic num to check the overflow */
|
/* clear out the interrupt and exception stack and set magic num to check the overflow */
|
||||||
@@ -317,6 +313,7 @@ reset_platform:
|
|||||||
mov r0, #0
|
mov r0, #0
|
||||||
mov pc, r0 // Jump to reset vector
|
mov pc, r0 // Jump to reset vector
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cpu_start:
|
cpu_start:
|
||||||
#ifdef LOSCFG_KERNEL_MMU
|
#ifdef LOSCFG_KERNEL_MMU
|
||||||
ldr r4, =g_firstPageTable /* r4 = physical address of translation table and clear it */
|
ldr r4, =g_firstPageTable /* r4 = physical address of translation table and clear it */
|
||||||
@@ -330,7 +327,8 @@ cpu_start:
|
|||||||
|
|
||||||
bl mmu_setup
|
bl mmu_setup
|
||||||
#endif
|
#endif
|
||||||
bl secondary_cpu_start
|
|
||||||
|
bl HalSecondaryCpuStart
|
||||||
b .
|
b .
|
||||||
|
|
||||||
secondary_cpu_init:
|
secondary_cpu_init:
|
||||||
@@ -370,9 +368,9 @@ sp_set:
|
|||||||
*/
|
*/
|
||||||
#ifdef LOSCFG_KERNEL_MMU
|
#ifdef LOSCFG_KERNEL_MMU
|
||||||
page_table_build:
|
page_table_build:
|
||||||
mov r9, r6
|
mov r10, r6
|
||||||
bfc r9, #20, #12 /* r9: pa % MB */
|
bfc r10, #20, #12 /* r9: pa % MB */
|
||||||
add r8, r8, r9
|
add r8, r8, r10
|
||||||
add r8, r8, #(1 << 20)
|
add r8, r8, #(1 << 20)
|
||||||
sub r8, r8, #1
|
sub r8, r8, #1
|
||||||
lsr r6, #20 /* r6 = physical address / MB */
|
lsr r6, #20 /* r6 = physical address / MB */
|
||||||
@@ -380,7 +378,7 @@ page_table_build:
|
|||||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||||
|
|
||||||
page_table_build_loop:
|
page_table_build_loop:
|
||||||
orr r12, r10, r6, lsl #20 /* r12: flags | physAddr */
|
orr r12, r9, r6, lsl #20 /* r12: flags | physAddr */
|
||||||
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
||||||
add r6, #1 /* physAddr+ */
|
add r6, #1 /* physAddr+ */
|
||||||
add r7, #1 /* l1Index++ */
|
add r7, #1 /* l1Index++ */
|
||||||
@@ -422,24 +420,6 @@ excstack_magic_loop:
|
|||||||
blt excstack_magic_loop
|
blt excstack_magic_loop
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_MMU
|
#ifdef LOSCFG_KERNEL_MMU
|
||||||
memset_optimized:
|
memset_optimized:
|
||||||
mov r3, r0
|
mov r3, r0
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
.extern __stack_chk_guard_setup
|
.extern __stack_chk_guard_setup
|
||||||
.extern g_firstPageTable
|
.extern g_firstPageTable
|
||||||
.extern g_mmuJumpPageTable
|
.extern g_mmuJumpPageTable
|
||||||
|
.extern g_archMmuInitMapping
|
||||||
|
|
||||||
.equ MPIDR_CPUID_MASK, 0xffU
|
.equ MPIDR_CPUID_MASK, 0xffU
|
||||||
|
|
||||||
@@ -77,14 +78,6 @@
|
|||||||
bl excstack_magic
|
bl excstack_magic
|
||||||
.endm
|
.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
|
.code 32
|
||||||
.section ".vectors","ax"
|
.section ".vectors","ax"
|
||||||
|
|
||||||
@@ -161,12 +154,15 @@ reloc_img_to_bottom_done:
|
|||||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||||
|
|
||||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
ldr r5, =g_archMmuInitMapping
|
||||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
add r5, r5, r11
|
||||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
init_mmu_loop:
|
||||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
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 */
|
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||||
add r4, r4, r11
|
add r4, r4, r11
|
||||||
@@ -231,9 +227,6 @@ warm_reset:
|
|||||||
LDR r0, =__exception_handlers
|
LDR r0, =__exception_handlers
|
||||||
MCR p15, 0, r0, c12, c0, 0
|
MCR p15, 0, r0, c12, c0, 0
|
||||||
|
|
||||||
cmp r11, #0
|
|
||||||
bne cpu_start
|
|
||||||
|
|
||||||
clear_bss:
|
clear_bss:
|
||||||
ldr r0, =__bss_start
|
ldr r0, =__bss_start
|
||||||
ldr r2, =__bss_end
|
ldr r2, =__bss_end
|
||||||
@@ -310,11 +303,6 @@ reset_platform:
|
|||||||
mov r0, #0
|
mov r0, #0
|
||||||
mov pc, r0 // Jump to reset vector
|
mov pc, r0 // Jump to reset vector
|
||||||
#endif
|
#endif
|
||||||
cpu_start:
|
|
||||||
bl secondary_cpu_start
|
|
||||||
b .
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set sp for current cpu
|
* set sp for current cpu
|
||||||
@@ -336,9 +324,9 @@ sp_set:
|
|||||||
*/
|
*/
|
||||||
#ifdef LOSCFG_KERNEL_MMU
|
#ifdef LOSCFG_KERNEL_MMU
|
||||||
page_table_build:
|
page_table_build:
|
||||||
mov r9, r6
|
mov r10, r6
|
||||||
bfc r9, #20, #12 /* r9: pa % MB */
|
bfc r10, #20, #12 /* r9: pa % MB */
|
||||||
add r8, r8, r9
|
add r8, r8, r10
|
||||||
add r8, r8, #(1 << 20)
|
add r8, r8, #(1 << 20)
|
||||||
sub r8, r8, #1
|
sub r8, r8, #1
|
||||||
lsr r6, #20 /* r6 = physical address / MB */
|
lsr r6, #20 /* r6 = physical address / MB */
|
||||||
@@ -346,7 +334,7 @@ page_table_build:
|
|||||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||||
|
|
||||||
page_table_build_loop:
|
page_table_build_loop:
|
||||||
orr r12, r10, r6, lsl #20 /* r12: flags | physAddr */
|
orr r12, r9, r6, lsl #20 /* r12: flags | physAddr */
|
||||||
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
str r12, [r4, r7, lsl #2] /* gPgTable[l1Index] = physAddr | flags */
|
||||||
add r6, #1 /* physAddr+ */
|
add r6, #1 /* physAddr+ */
|
||||||
add r7, #1 /* l1Index++ */
|
add r7, #1 /* l1Index++ */
|
||||||
@@ -388,24 +376,6 @@ excstack_magic_loop:
|
|||||||
blt excstack_magic_loop
|
blt excstack_magic_loop
|
||||||
bx lr
|
bx lr
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_MMU
|
#ifdef LOSCFG_KERNEL_MMU
|
||||||
memset_optimized:
|
memset_optimized:
|
||||||
mov r3, r0
|
mov r3, r0
|
||||||
|
|||||||
+2
-2
@@ -33,8 +33,8 @@ MODULE_NAME := $(notdir $(shell pwd))
|
|||||||
|
|
||||||
LOCAL_SRCS := $(wildcard kern/*.c)
|
LOCAL_SRCS := $(wildcard kern/*.c)
|
||||||
|
|
||||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.c)
|
LOCAL_SRCS += $(wildcard $(ARCH)/*.c)
|
||||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.S)
|
LOCAL_SRCS += $(wildcard $(ARCH)/*.S)
|
||||||
|
|
||||||
ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
|
ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
|
||||||
LOCAL_SRCS += $(wildcard crypto/rijndael/*.c) \
|
LOCAL_SRCS += $(wildcard crypto/rijndael/*.c) \
|
||||||
|
|||||||
@@ -42,41 +42,11 @@ ohos_version=${9}
|
|||||||
sysroot_path=${10}
|
sysroot_path=${10}
|
||||||
arch_cflags=${11}
|
arch_cflags=${11}
|
||||||
device_path=${12}
|
device_path=${12}
|
||||||
|
compile_prefix=${13}
|
||||||
|
liteos_config_file=${14}
|
||||||
|
|
||||||
echo "${board_name}" "${device_company}"
|
|
||||||
echo "sh param:" "$@"
|
echo "sh param:" "$@"
|
||||||
|
|
||||||
destination="defconfig"
|
|
||||||
function main() {
|
|
||||||
tee=""
|
|
||||||
if [ "${tee_enable}" = "true" ]; then
|
|
||||||
tee="_tee"
|
|
||||||
fi
|
|
||||||
|
|
||||||
config_file="${product_path}/kernel_configs/${ohos_build_type}${tee}.config"
|
|
||||||
if [ -f "${config_file}" ]; then
|
|
||||||
cp "${config_file}" "${destination}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
product_name=$(basename "${product_path}")
|
|
||||||
config_file="${product_name}_release.config"
|
|
||||||
if [ "${ohos_build_compiler}" = "clang" ]; then
|
|
||||||
if [ "${ohos_build_type}" = "debug" ]; then
|
|
||||||
config_file="debug/${product_name}_${ohos_build_compiler}${tee}.config"
|
|
||||||
else
|
|
||||||
config_file="${product_name}_${ohos_build_compiler}_release${tee}.config"
|
|
||||||
fi
|
|
||||||
elif [ "${ohos_build_compiler}" = "gcc" ]; then
|
|
||||||
if [ "${ohos_build_type}" = "debug" ]; then
|
|
||||||
config_file="${product_name}_debug_shell${tee}.config"
|
|
||||||
else
|
|
||||||
config_file="${product_name}_release${tee}.config"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
cp "tools/build/config/${config_file}" "${destination}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "x" != "x${sysroot_path}" ]; then
|
if [ "x" != "x${sysroot_path}" ]; then
|
||||||
export SYSROOT_PATH=${sysroot_path}
|
export SYSROOT_PATH=${sysroot_path}
|
||||||
fi
|
fi
|
||||||
@@ -88,9 +58,12 @@ fi
|
|||||||
export PRODUCT_PATH="${product_path}"
|
export PRODUCT_PATH="${product_path}"
|
||||||
export DEVICE_PATH="${device_path}"
|
export DEVICE_PATH="${device_path}"
|
||||||
|
|
||||||
OUTDIR="${outdir}"
|
export OUTDIR="${outdir}"
|
||||||
CONFIG="$(realpath ${destination})"
|
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##*/}"
|
||||||
|
|
||||||
main && \
|
mkdir -p "${outdir}"
|
||||||
make clean CONFIG="$CONFIG" OUTDIR="$OUTDIR" && \
|
make -j all VERSION="${ohos_version}"
|
||||||
make -j all VERSION="${ohos_version}" CONFIG="$CONFIG" OUTDIR="$OUTDIR"
|
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ module_switch = defined(LOSCFG_COMPAT_POSIX)
|
|||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
sources = [
|
||||||
|
"src/errno.c",
|
||||||
|
"src/malloc.c",
|
||||||
"src/map_error.c",
|
"src/map_error.c",
|
||||||
"src/misc.c",
|
"src/misc.c",
|
||||||
"src/mqueue.c",
|
"src/mqueue.c",
|
||||||
@@ -44,6 +46,8 @@ kernel_module(module_name) {
|
|||||||
"src/sched.c",
|
"src/sched.c",
|
||||||
"src/semaphore.c",
|
"src/semaphore.c",
|
||||||
"src/socket.c",
|
"src/socket.c",
|
||||||
|
"src/stdio.c",
|
||||||
|
"src/stdlib.c",
|
||||||
"src/time.c",
|
"src/time.c",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* 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 "errno.h"
|
||||||
|
#include "los_errno.h"
|
||||||
|
#include "los_task_pri.h"
|
||||||
|
|
||||||
|
/* the specific errno get or set in interrupt service routine */
|
||||||
|
static int errno_isr;
|
||||||
|
|
||||||
|
int *__errno_location(void)
|
||||||
|
{
|
||||||
|
LosTaskCB *runTask = NULL;
|
||||||
|
|
||||||
|
if (OS_INT_INACTIVE) {
|
||||||
|
runTask = OsCurrTaskGet();
|
||||||
|
return &runTask->errorNo;
|
||||||
|
} else {
|
||||||
|
return &errno_isr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int *__errno(void) __attribute__((__weak__, __alias__("__errno_location")));
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* 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 "stdlib.h"
|
||||||
|
#include "string.h"
|
||||||
|
#include "los_vm_map.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocates the requested memory and returns a pointer to it. The requested
|
||||||
|
* size is nitems each size bytes long (total memory requested is nitems*size).
|
||||||
|
* The space is initialized to all zero bits.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *calloc(size_t nitems, size_t size)
|
||||||
|
{ /*lint !e578*/
|
||||||
|
size_t real_size;
|
||||||
|
void *ptr = NULL;
|
||||||
|
|
||||||
|
if (nitems == 0 || size == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
real_size = (size_t)(nitems * size);
|
||||||
|
ptr = LOS_KernelMalloc((UINT32) real_size);
|
||||||
|
if (ptr != NULL) {
|
||||||
|
(void) memset_s((void *) ptr, real_size, 0, real_size);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Deallocates the memory previously allocated by a call to calloc, malloc, or
|
||||||
|
* realloc. The argument ptr points to the space that was previously allocated.
|
||||||
|
* If ptr points to a memory block that was not allocated with calloc, malloc,
|
||||||
|
* or realloc, or is a space that has been deallocated, then the result is undefined.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void free(void *ptr)
|
||||||
|
{
|
||||||
|
if (ptr == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOS_KernelFree(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Allocates the requested memory and returns a pointer to it. The requested
|
||||||
|
* size is size bytes. The value of the space is indeterminate.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *malloc(size_t size)
|
||||||
|
{ /*lint !e31 !e10*/
|
||||||
|
if (size == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LOS_KernelMalloc((UINT32) size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *zalloc(size_t size)
|
||||||
|
{ /*lint !e10*/
|
||||||
|
void *ptr = NULL;
|
||||||
|
|
||||||
|
if (size == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr = LOS_KernelMalloc((UINT32) size);
|
||||||
|
if (ptr != NULL) {
|
||||||
|
(void) memset_s(ptr, size, 0, size);
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* allocates a block of size bytes whose address is a multiple of boundary.
|
||||||
|
* The boundary must be a power of two!
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *memalign(size_t boundary, size_t size)
|
||||||
|
{
|
||||||
|
if (size == 0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LOS_KernelMallocAlign((UINT32) size, (UINT32) boundary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attempts to resize the memory block pointed to by ptr that was previously
|
||||||
|
* allocated with a call to malloc or calloc. The contents pointed to by ptr are
|
||||||
|
* unchanged. If the value of size is greater than the previous size of the
|
||||||
|
* block, then the additional bytes have an undeterminate value. If the value
|
||||||
|
* of size is less than the previous size of the block, then the difference of
|
||||||
|
* bytes at the end of the block are freed. If ptr is null, then it behaves like
|
||||||
|
* malloc. If ptr points to a memory block that was not allocated with calloc
|
||||||
|
* or malloc, or is a space that has been deallocated, then the result is
|
||||||
|
* undefined. If the new space cannot be allocated, then the contents pointed
|
||||||
|
* to by ptr are unchanged. If size is zero, then the memory block is completely
|
||||||
|
* freed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void *realloc(void *ptr, size_t size)
|
||||||
|
{
|
||||||
|
if (ptr == NULL) {
|
||||||
|
ptr = malloc(size);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (size == 0) {
|
||||||
|
free(ptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LOS_KernelRealloc(ptr, (UINT32) size);
|
||||||
|
}
|
||||||
@@ -138,3 +138,8 @@ int __sched_cpucount(size_t set_size, const cpu_set_t* set)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int sched_yield()
|
||||||
|
{
|
||||||
|
(void)LOS_TaskYield();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* 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 <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#ifdef LOSCFG_FS_VFS
|
||||||
|
#include <fs/fs.h>
|
||||||
|
|
||||||
|
off_t _lseek(int fd, off_t offset, int whence)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
struct file *filep = NULL;
|
||||||
|
|
||||||
|
/* Get the file structure corresponding to the file descriptor. */
|
||||||
|
ret = fs_getfilep(fd, &filep);
|
||||||
|
if (ret < 0) {
|
||||||
|
/* The errno value has already been set */
|
||||||
|
return (off_t)-get_errno();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* libc seekdir function should set the whence to SEEK_SET, so we can discard
|
||||||
|
* the whence argument here */
|
||||||
|
if (filep->f_oflags & O_DIRECTORY) {
|
||||||
|
/* defensive coding */
|
||||||
|
if (filep->f_dir == NULL) {
|
||||||
|
return (off_t)-EINVAL;
|
||||||
|
}
|
||||||
|
if (offset == 0) {
|
||||||
|
rewinddir(filep->f_dir);
|
||||||
|
} else {
|
||||||
|
seekdir(filep->f_dir, offset);
|
||||||
|
}
|
||||||
|
ret = telldir(filep->f_dir);
|
||||||
|
if (ret < 0) {
|
||||||
|
return (off_t)-get_errno();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then let file_seek do the real work */
|
||||||
|
ret = file_seek(filep, offset, whence);
|
||||||
|
if (ret < 0) {
|
||||||
|
return -get_errno();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
off64_t _lseek64(int fd, int offsetHigh, int offsetLow, off64_t *result, int whence)
|
||||||
|
{
|
||||||
|
off64_t ret;
|
||||||
|
struct file *filep = NULL;
|
||||||
|
off64_t offset = ((off64_t)offsetHigh << 32) + (uint)offsetLow; /* 32: offsetHigh is high 32 bits */
|
||||||
|
|
||||||
|
/* Get the file structure corresponding to the file descriptor. */
|
||||||
|
ret = fs_getfilep(fd, &filep);
|
||||||
|
if (ret < 0) {
|
||||||
|
/* The errno value has already been set */
|
||||||
|
return (off64_t)-get_errno();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* libc seekdir function should set the whence to SEEK_SET, so we can discard
|
||||||
|
* the whence argument here */
|
||||||
|
if (filep->f_oflags & O_DIRECTORY) {
|
||||||
|
/* defensive coding */
|
||||||
|
if (filep->f_dir == NULL) {
|
||||||
|
return (off64_t)-EINVAL;
|
||||||
|
}
|
||||||
|
if (offsetLow == 0) {
|
||||||
|
rewinddir(filep->f_dir);
|
||||||
|
} else {
|
||||||
|
seekdir(filep->f_dir, offsetLow);
|
||||||
|
}
|
||||||
|
ret = telldir(filep->f_dir);
|
||||||
|
if (ret < 0) {
|
||||||
|
return (off64_t)-get_errno();
|
||||||
|
}
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Then let file_seek do the real work */
|
||||||
|
ret = file_seek64(filep, offset, whence);
|
||||||
|
if (ret < 0) {
|
||||||
|
return (off64_t)-get_errno();
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
*result = ret;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -29,40 +29,43 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/statfs.h>
|
#include <stdlib.h>
|
||||||
#include <sys/mount.h>
|
#include <stdint.h>
|
||||||
#include "proc_fs.h"
|
#include <errno.h>
|
||||||
|
#include "los_printf.h"
|
||||||
|
#include "los_exc.h"
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
char *getenv(const char *name)
|
||||||
#include "los_trace.h"
|
|
||||||
static int KernelTraceProcFill(struct SeqBuf *m, void *v)
|
|
||||||
{
|
{
|
||||||
(void)v;
|
return NULL;
|
||||||
if (m == NULL) {
|
|
||||||
return -LOS_EPERM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m->buf == NULL) {
|
|
||||||
m->buf = (char *)LOS_TraceBufDataGet(&(m->size), &(m->count));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct ProcFileOperations KERNEL_TRACE_PROC_FOPS = {
|
void srand(unsigned s)
|
||||||
.read = KernelTraceProcFill,
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void ProcKernelTraceInit(void)
|
|
||||||
{
|
{
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
return srandom(s);
|
||||||
struct ProcDirEntry *pde = CreateProcEntry("ktrace", 0, NULL);
|
|
||||||
if (pde == NULL) {
|
|
||||||
PRINT_ERR("create /proc/ktrace error!\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pde->procFileOps = &KERNEL_TRACE_PROC_FOPS;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rand(void)
|
||||||
|
{
|
||||||
|
return random();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _exit(int status)
|
||||||
|
{
|
||||||
|
PRINT_ERR("%s NOT SUPPORT\n", __FUNCTION__);
|
||||||
|
errno = ENOSYS;
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void exit(int status)
|
||||||
|
{
|
||||||
|
PRINT_ERR("%s NOT SUPPORT\n", __FUNCTION__);
|
||||||
|
errno = ENOSYS;
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void abort(void)
|
||||||
|
{
|
||||||
|
LOS_Panic("System was being aborted\n");
|
||||||
|
while (1);
|
||||||
|
}
|
||||||
@@ -1135,3 +1135,19 @@ VOID OsVdsoTimeGet(VdsoDataPage *vdsoDataPage)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
time_t time(time_t *t)
|
||||||
|
{
|
||||||
|
struct timeval tp;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Get the current time from the system */
|
||||||
|
ret = gettimeofday(&tp, (struct timezone *)NULL);
|
||||||
|
if (ret == LOS_OK) {
|
||||||
|
/* Return the seconds since the epoch */
|
||||||
|
if (t) {
|
||||||
|
*t = tp.tv_sec;
|
||||||
|
}
|
||||||
|
return tp.tv_sec;
|
||||||
|
}
|
||||||
|
return (time_t)OS_ERROR;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
# are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
# provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
# to endorse or promote products derived from this software without specific prior written
|
||||||
|
# permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
############### this is a makefile that you can config it ###############
|
||||||
|
-include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk
|
||||||
|
##### liteos tables -u ldflags #####
|
||||||
|
-include $(LITEOSTOPDIR)/tools/build/mk/liteos_tables_ldflags.mk
|
||||||
|
|
||||||
|
LITEOS_COPTS := $(LITEOS_COPTS_DEBUG) $(LITEOS_COPTS_BASE) \
|
||||||
|
$(LITEOS_COPTS_EXTRA) $(LITEOS_CORE_COPTS)
|
||||||
|
LITEOS_CXXOPTS := $(LITEOS_CXXOPTS_BASE)
|
||||||
|
LITEOS_INCLUDE := $(LITEOS_KERNEL_INCLUDE) $(LITEOS_EXTKERNEL_INCLUDE) \
|
||||||
|
$(LITEOS_COMPAT_INCLUDE) $(LITEOS_FS_INCLUDE) \
|
||||||
|
$(LITEOS_NET_INCLUDE) $(LITEOS_LIB_INCLUDE) \
|
||||||
|
$(LITEOS_DRIVERS_INCLUDE) $(LOSCFG_TOOLS_DEBUG_INCLUDE) \
|
||||||
|
$(LITEOS_PLATFORM_INCLUDE) $(LITEOS_DFX_INCLUDE) \
|
||||||
|
$(LITEOS_SECURITY_INCLUDE)
|
||||||
|
LITEOS_LIBDEP := $(LITEOS_BASELIB)
|
||||||
|
LITEOS_ASFLAGS := $(LITEOS_ASOPTS) $(LITEOS_INCLUDE)
|
||||||
|
LITEOS_CFLAGS := $(LITEOS_COPTS) $(LITEOS_CMACRO) \
|
||||||
|
$(LITEOS_CMACRO_TEST) $(LITEOS_IMAGE_MACRO) \
|
||||||
|
$(LITEOS_INCLUDE)
|
||||||
|
LITEOS_CXXFLAGS := $(LITEOS_CXXOPTS) $(LITEOS_CXXMACRO) \
|
||||||
|
$(LITEOS_CMACRO) $(LITEOS_CXXINCLUDE)
|
||||||
|
LITEOS_LDFLAGS := $(LITEOS_LD_OPTS) $(LITEOS_LD_PATH) \
|
||||||
|
$(LITEOS_LD_SCRIPT)
|
||||||
|
|
||||||
|
# clear all local variables
|
||||||
|
LOCAL_FLAGS :=
|
||||||
|
LOCAL_CFLAGS :=
|
||||||
|
LOCAL_CPPFLAGS :=
|
||||||
|
LOCAL_ASFLAGS :=
|
||||||
|
LOCAL_SRCS :=
|
||||||
|
LOCAL_CHS :=
|
||||||
|
LOCAL_CPPHS :=
|
||||||
@@ -36,6 +36,7 @@ group("drivers") {
|
|||||||
"char/mem",
|
"char/mem",
|
||||||
"char/quickstart",
|
"char/quickstart",
|
||||||
"char/random",
|
"char/random",
|
||||||
|
"char/trace",
|
||||||
"char/video",
|
"char/video",
|
||||||
"mtd/multi_partition",
|
"mtd/multi_partition",
|
||||||
]
|
]
|
||||||
@@ -49,6 +50,7 @@ config("public") {
|
|||||||
"char/quickstart:public",
|
"char/quickstart:public",
|
||||||
"char/random:public",
|
"char/random:public",
|
||||||
"char/video:public",
|
"char/video:public",
|
||||||
|
"char/trace:public",
|
||||||
"mtd/multi_partition:public",
|
"mtd/multi_partition:public",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Executable → Regular
+10
-27
@@ -1,5 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
#
|
#
|
||||||
@@ -29,31 +27,16 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
set -e
|
import("//kernel/liteos_a/liteos.gni")
|
||||||
declare CROSS_COMPILER="$1"
|
|
||||||
declare HMOS_TOP_DIR="$2"
|
|
||||||
declare gcc_path=${HMOS_TOP_DIR}/../../prebuilts/gcc/linux-x86/arm/arm-linux-ohoseabi-gcc
|
|
||||||
declare windows_gcc_path=${HMOS_TOP_DIR}/../../prebuilts/gcc/win-x86/arm/arm-linux-ohoseabi-gcc
|
|
||||||
function get_compiler_path()
|
|
||||||
{
|
|
||||||
local system=$(uname -s)
|
|
||||||
local user_gcc="${CROSS_COMPILER}"gcc
|
|
||||||
local gcc_install_path=$(which "${user_gcc}")
|
|
||||||
|
|
||||||
if [ "$system" != "Linux" ] ; then
|
module_switch = defined(LOSCFG_DRIVERS_TRACE)
|
||||||
if [ -e "${windows_gcc_path}" ] ; then
|
module_name = "trace_dev"
|
||||||
gcc_install_path=$windows_gcc_path
|
kernel_module(module_name) {
|
||||||
else
|
sources = [ "src/trace.c" ]
|
||||||
gcc_install_path=$(dirname $gcc_install_path)/../
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if [ -e "${gcc_path}" ] ; then
|
|
||||||
gcc_install_path=$gcc_path
|
|
||||||
else
|
|
||||||
gcc_install_path=$(dirname $gcc_install_path)/../
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$gcc_install_path"
|
public_configs = [ ":public" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
config("public") {
|
||||||
|
include_dirs = [ "include" ]
|
||||||
}
|
}
|
||||||
get_compiler_path
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
config DRIVERS_TRACE
|
||||||
|
bool "Enable TRACE DRIVER"
|
||||||
|
default y
|
||||||
|
depends on DRIVERS && FS_VFS && KERNEL_TRACE
|
||||||
|
help
|
||||||
|
Answer Y to enable LiteOS support trace in userspace.
|
||||||
@@ -27,20 +27,14 @@
|
|||||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
APP_SUBDIRS :=
|
include $(LITEOSTOPDIR)/config.mk
|
||||||
|
|
||||||
##build modules config##
|
MODULE_NAME := trace_dev
|
||||||
|
|
||||||
ifeq ($(LOSCFG_SHELL), y)
|
LOCAL_SRCS := $(wildcard src/*.c)
|
||||||
APP_SUBDIRS += shell
|
|
||||||
#APP_SUBDIRS += mksh
|
|
||||||
#APP_SUBDIRS += toybox
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/drivers/char/trace/include
|
||||||
APP_SUBDIRS += init
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
|
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||||
APP_SUBDIRS += tftp
|
|
||||||
endif
|
include $(MODULE)
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LOS_DEV_TRACE_H__
|
||||||
|
#define __LOS_DEV_TRACE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
int DevTraceRegister(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#if __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "fcntl.h"
|
||||||
|
#include "linux/kernel.h"
|
||||||
|
#include "sys/ioctl.h"
|
||||||
|
#include "fs/driver.h"
|
||||||
|
#include "los_dev_trace.h"
|
||||||
|
#include "los_trace.h"
|
||||||
|
#include "los_hook.h"
|
||||||
|
#include "los_init.h"
|
||||||
|
|
||||||
|
#define TRACE_DRIVER "/dev/trace"
|
||||||
|
#define TRACE_DRIVER_MODE 0666
|
||||||
|
|
||||||
|
/* trace ioctl */
|
||||||
|
#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)
|
||||||
|
|
||||||
|
static int TraceOpen(struct file *filep)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int TraceClose(struct file *filep)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t TraceRead(struct file *filep, char *buffer, size_t buflen)
|
||||||
|
{
|
||||||
|
/* trace record buffer read */
|
||||||
|
ssize_t len = buflen;
|
||||||
|
OfflineHead *records;
|
||||||
|
int ret;
|
||||||
|
int realLen;
|
||||||
|
|
||||||
|
if (len % sizeof(unsigned int)) {
|
||||||
|
PRINT_ERR("Buffer size not aligned by 4 bytes\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
records = LOS_TraceRecordGet();
|
||||||
|
if (records == NULL) {
|
||||||
|
PRINT_ERR("Trace read failed, check whether trace mode is set to offline\n");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
realLen = buflen < records->totalLen ? buflen : records->totalLen;
|
||||||
|
ret = LOS_CopyFromKernel((void *)buffer, buflen, (void *)records, realLen);
|
||||||
|
if (ret != 0) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return realLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t TraceWrite(struct file *filep, const char *buffer, size_t buflen)
|
||||||
|
{
|
||||||
|
/* trace usr event here */
|
||||||
|
int ret;
|
||||||
|
UsrEventInfo *info = NULL;
|
||||||
|
int infoLen = sizeof(UsrEventInfo);
|
||||||
|
|
||||||
|
if (buflen != infoLen) {
|
||||||
|
PRINT_ERR("Buffer size not %d bytes\n", infoLen);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
info = LOS_MemAlloc(m_aucSysMem0, infoLen);
|
||||||
|
if (info == NULL) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
memset_s(info, infoLen, 0, infoLen);
|
||||||
|
|
||||||
|
ret = LOS_CopyToKernel(info, infoLen, buffer, buflen);
|
||||||
|
if (ret != 0) {
|
||||||
|
LOS_MemFree(m_aucSysMem0, info);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_USR_EVENT, info, infoLen);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int TraceIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
case TRACE_START:
|
||||||
|
return LOS_TraceStart();
|
||||||
|
case TRACE_STOP:
|
||||||
|
LOS_TraceStop();
|
||||||
|
break;
|
||||||
|
case TRACE_RESET:
|
||||||
|
LOS_TraceReset();
|
||||||
|
break;
|
||||||
|
case TRACE_DUMP:
|
||||||
|
LOS_TraceRecordDump((BOOL)arg);
|
||||||
|
break;
|
||||||
|
case TRACE_SET_MASK:
|
||||||
|
LOS_TraceEventMaskSet((UINT32)arg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
PRINT_ERR("Unknown trace ioctl cmd:%d\n", cmd);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct file_operations_vfs g_traceDevOps = {
|
||||||
|
TraceOpen, /* open */
|
||||||
|
TraceClose, /* close */
|
||||||
|
TraceRead, /* read */
|
||||||
|
TraceWrite, /* write */
|
||||||
|
NULL, /* seek */
|
||||||
|
TraceIoctl, /* ioctl */
|
||||||
|
NULL, /* mmap */
|
||||||
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
|
NULL, /* poll */
|
||||||
|
#endif
|
||||||
|
NULL, /* unlink */
|
||||||
|
};
|
||||||
|
|
||||||
|
int DevTraceRegister(void)
|
||||||
|
{
|
||||||
|
return register_driver(TRACE_DRIVER, &g_traceDevOps, TRACE_DRIVER_MODE, 0); /* 0666: file mode */
|
||||||
|
}
|
||||||
|
|
||||||
|
LOS_MODULE_INIT(DevTraceRegister, LOS_INIT_LEVEL_KMOD_EXTENDED);
|
||||||
@@ -37,10 +37,7 @@ kernel_module(module_name) {
|
|||||||
"src/mtd_shellcmd.c",
|
"src/mtd_shellcmd.c",
|
||||||
]
|
]
|
||||||
|
|
||||||
include_dirs = [
|
include_dirs = [ "$LITEOSTOPDIR/fs/jffs2/include" ]
|
||||||
"$LITEOSTOPDIR/fs/jffs2/include",
|
|
||||||
"//device/hisilicon/drivers/include/mtd/common/include",
|
|
||||||
]
|
|
||||||
|
|
||||||
if (defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)) {
|
if (defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)) {
|
||||||
include_dirs += [ "//device/qemu/drivers/cfiflash" ]
|
include_dirs += [ "//device/qemu/drivers/cfiflash" ]
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ LOCAL_SRCS := $(wildcard src/*.c)
|
|||||||
|
|
||||||
LOCAL_INCLUDE := \
|
LOCAL_INCLUDE := \
|
||||||
-I $(LITEOSTOPDIR)/fs/jffs2/include \
|
-I $(LITEOSTOPDIR)/fs/jffs2/include \
|
||||||
-I $(LITEOSTOPDIR)/drivers/mtd/multi_partition/include \
|
-I $(LITEOSTOPDIR)/../../drivers/framework/model/storage/include \
|
||||||
-I $(LITEOSTOPDIR)/../../device/hisilicon/drivers/include/mtd/common/include
|
-I $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/model/storage/include
|
||||||
|
|
||||||
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
||||||
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/drivers/cfiflash
|
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/drivers/cfiflash
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
#include "los_config.h"
|
#include "los_config.h"
|
||||||
#include "los_mux.h"
|
#include "los_mux.h"
|
||||||
#include "fs/driver.h"
|
#include "fs/driver.h"
|
||||||
#include "mtd_common.h"
|
#include "mtd_legacy_lite.h"
|
||||||
|
|
||||||
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||||
#include "cfiflash.h"
|
#include "cfiflash.h"
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ LOCAL_INCLUDE := \
|
|||||||
-I $(LITEOSTOPDIR)/fs/fat/os_adapt \
|
-I $(LITEOSTOPDIR)/fs/fat/os_adapt \
|
||||||
-I $(LITEOSTOPDIR)/fs/fat/virpart/include \
|
-I $(LITEOSTOPDIR)/fs/fat/virpart/include \
|
||||||
-I $(LITEOSTOPDIR)/fs/vfs \
|
-I $(LITEOSTOPDIR)/fs/vfs \
|
||||||
-I $(LITEOSTHIRDPARTY)/NuttX/include
|
|
||||||
|
|
||||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "user_copy.h"
|
#include "user_copy.h"
|
||||||
#include "los_vm_filemap.h"
|
#include "los_vm_filemap.h"
|
||||||
#include "los_hash.h"
|
#include "los_hash.h"
|
||||||
|
#include "los_vm_common.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@@ -2180,6 +2181,207 @@ ERROUT:
|
|||||||
return -fatfs_2_vfs(res);
|
return -fatfs_2_vfs(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t fatfs_readpage(struct Vnode *vnode, char *buff, off_t pos)
|
||||||
|
{
|
||||||
|
FATFS *fs = (FATFS *)(vnode->originMount->data);
|
||||||
|
DIR_FILE *dfp = (DIR_FILE *)(vnode->data);
|
||||||
|
FILINFO *finfo = &(dfp->fno);
|
||||||
|
FAT_ENTRY *ep = &(dfp->fat_entry);
|
||||||
|
DWORD clust;
|
||||||
|
DWORD sclust;
|
||||||
|
QWORD sect;
|
||||||
|
QWORD step;
|
||||||
|
QWORD n;
|
||||||
|
size_t position; /* byte offset */
|
||||||
|
BYTE *buf = (BYTE *)buff;
|
||||||
|
size_t buflen = PAGE_SIZE;
|
||||||
|
FRESULT result;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = lock_fs(fs);
|
||||||
|
if (ret == FALSE) {
|
||||||
|
result = FR_TIMEOUT;
|
||||||
|
goto ERROR_OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finfo->fsize <= pos) {
|
||||||
|
result = FR_OK;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ep->clst == 0) {
|
||||||
|
ep->clst = finfo->sclst;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos >= ep->pos) {
|
||||||
|
clust = ep->clst;
|
||||||
|
position = ep->pos;
|
||||||
|
} else {
|
||||||
|
clust = finfo->sclst;
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get to the current cluster */
|
||||||
|
n = pos / SS(fs) / fs->csize - position / SS(fs) / fs->csize;
|
||||||
|
while (n--) {
|
||||||
|
clust = get_fat(&(dfp->f_dir.obj), clust);
|
||||||
|
if ((clust == BAD_CLUSTER) || (clust == DISK_ERROR)) {
|
||||||
|
result = FR_DISK_ERR;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get to the currnet sector */
|
||||||
|
sect = clst2sect(fs, clust);
|
||||||
|
sect += (pos / SS(fs)) & (fs->csize - 1);
|
||||||
|
|
||||||
|
/* How many sectors do we need to read once */
|
||||||
|
if (fs->csize < buflen / SS(fs)) {
|
||||||
|
step = fs->csize;
|
||||||
|
} else {
|
||||||
|
step = buflen / SS(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
sclust = clust;
|
||||||
|
while (n < buflen / SS(fs)) {
|
||||||
|
if (disk_read(fs->pdrv, buf, sect, step) != RES_OK) {
|
||||||
|
result = FR_DISK_ERR;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
}
|
||||||
|
n += step;
|
||||||
|
if (n >= buflen / SS(fs)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* As cluster size is aligned, it must jump to next cluster when cluster size is less than pagesize */
|
||||||
|
clust = get_fat(&(dfp->f_dir.obj), clust);
|
||||||
|
if ((clust == BAD_CLUSTER) || (clust == DISK_ERROR)) {
|
||||||
|
result = FR_DISK_ERR;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
} else if (fatfs_is_last_cluster(fs, clust)) {
|
||||||
|
break; /* read end */
|
||||||
|
}
|
||||||
|
sect = clst2sect(fs, clust);
|
||||||
|
buf += step * SS(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
ep->clst = sclust;
|
||||||
|
ep->pos = pos;
|
||||||
|
|
||||||
|
unlock_fs(fs, FR_OK);
|
||||||
|
|
||||||
|
return (ssize_t)min(finfo->fsize - pos, n * SS(fs));
|
||||||
|
|
||||||
|
ERROR_UNLOCK:
|
||||||
|
unlock_fs(fs, result);
|
||||||
|
ERROR_OUT:
|
||||||
|
return -fatfs_2_vfs(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t fatfs_writepage(struct Vnode *vnode, char *buff, off_t pos, size_t buflen)
|
||||||
|
{
|
||||||
|
FATFS *fs = (FATFS *)(vnode->originMount->data);
|
||||||
|
DIR_FILE *dfp = (DIR_FILE *)(vnode->data);
|
||||||
|
FILINFO *finfo = &(dfp->fno);
|
||||||
|
FAT_ENTRY *ep = &(dfp->fat_entry);
|
||||||
|
DWORD clust;
|
||||||
|
DWORD sclst;
|
||||||
|
QWORD sect;
|
||||||
|
QWORD step;
|
||||||
|
QWORD n;
|
||||||
|
size_t position; /* byte offset */
|
||||||
|
BYTE *buf = (BYTE *)buff;
|
||||||
|
FRESULT result;
|
||||||
|
FIL fil;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = lock_fs(fs);
|
||||||
|
if (ret == FALSE) {
|
||||||
|
result = FR_TIMEOUT;
|
||||||
|
goto ERROR_OUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finfo->fsize <= pos) {
|
||||||
|
result = FR_OK;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ep->clst == 0) {
|
||||||
|
ep->clst = finfo->sclst;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos >= ep->pos) {
|
||||||
|
clust = ep->clst;
|
||||||
|
position = ep->pos;
|
||||||
|
} else {
|
||||||
|
clust = finfo->sclst;
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get to the current cluster */
|
||||||
|
n = pos / SS(fs) / fs->csize - position / SS(fs) / fs->csize;
|
||||||
|
while (n--) {
|
||||||
|
clust = get_fat(&(dfp->f_dir.obj), clust);
|
||||||
|
if ((clust == BAD_CLUSTER) || (clust == DISK_ERROR)) {
|
||||||
|
result = FR_DISK_ERR;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get to the currnet sector */
|
||||||
|
sect = clst2sect(fs, clust);
|
||||||
|
sect += (pos / SS(fs)) & (fs->csize - 1);
|
||||||
|
|
||||||
|
/* How many sectors do we need to read once */
|
||||||
|
if (fs->csize < buflen / SS(fs)) {
|
||||||
|
step = fs->csize;
|
||||||
|
} else {
|
||||||
|
step = buflen / SS(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
sclst = clust;
|
||||||
|
while (n < buflen / SS(fs)) {
|
||||||
|
if (disk_write(fs->pdrv, buf, sect, step) != RES_OK) {
|
||||||
|
result = FR_DISK_ERR;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
}
|
||||||
|
n += step;
|
||||||
|
if (n >= buflen / SS(fs)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* As cluster size is aligned, it must jump to next cluster when cluster size is less than pagesize */
|
||||||
|
clust = get_fat(&(dfp->f_dir.obj), clust);
|
||||||
|
if ((clust == BAD_CLUSTER) || (clust == DISK_ERROR)) {
|
||||||
|
result = FR_DISK_ERR;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
} else if (fatfs_is_last_cluster(fs, clust)) {
|
||||||
|
break; /* read end */
|
||||||
|
}
|
||||||
|
sect = clst2sect(fs, clust);
|
||||||
|
buf += step * SS(fs);
|
||||||
|
}
|
||||||
|
|
||||||
|
ep->clst = sclst;
|
||||||
|
ep->pos = pos;
|
||||||
|
|
||||||
|
fil.obj.fs = fs;
|
||||||
|
if (update_filbuff(finfo, &fil, NULL) < 0) {
|
||||||
|
result = FR_DISK_ERR;
|
||||||
|
goto ERROR_UNLOCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
unlock_fs(fs, FR_OK);
|
||||||
|
|
||||||
|
return (ssize_t)min(finfo->fsize - pos, n * SS(fs));
|
||||||
|
ERROR_UNLOCK:
|
||||||
|
unlock_fs(fs, result);
|
||||||
|
ERROR_OUT:
|
||||||
|
return -fatfs_2_vfs(result);
|
||||||
|
}
|
||||||
|
|
||||||
struct VnodeOps fatfs_vops = {
|
struct VnodeOps fatfs_vops = {
|
||||||
/* file ops */
|
/* file ops */
|
||||||
.Getattr = fatfs_stat,
|
.Getattr = fatfs_stat,
|
||||||
@@ -2187,6 +2389,8 @@ struct VnodeOps fatfs_vops = {
|
|||||||
.Lookup = fatfs_lookup,
|
.Lookup = fatfs_lookup,
|
||||||
.Rename = fatfs_rename,
|
.Rename = fatfs_rename,
|
||||||
.Create = fatfs_create,
|
.Create = fatfs_create,
|
||||||
|
.ReadPage = fatfs_readpage,
|
||||||
|
.WritePage = fatfs_writepage,
|
||||||
.Unlink = fatfs_unlink,
|
.Unlink = fatfs_unlink,
|
||||||
.Reclaim = fatfs_reclaim,
|
.Reclaim = fatfs_reclaim,
|
||||||
.Truncate = fatfs_truncate,
|
.Truncate = fatfs_truncate,
|
||||||
|
|||||||
@@ -41,81 +41,6 @@ extern "C" {
|
|||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
/* vfs/fs_file_mapping.c ****************************************************/
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: init_file_mapping
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Init the global management structure of path <-> page_mapping
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern UINT32 init_file_mapping(void);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: add_mapping
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Create a new path <-> page_mapping mapping and add to global list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern void add_mapping(struct file *filep, const char *fullpath);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: find_mapping
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Find the page_mapping for path in global list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern struct page_mapping *find_mapping(const char *path);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: remove_mapping
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Drop all the page-caches for the file, and then remove mapping between
|
|
||||||
* the file and pagecache.
|
|
||||||
* ex_filp NULL: do not exclude any file, just matching the fullpath;
|
|
||||||
* ex_filp not NULL: exclude it, which means, ex_filp can be open.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern int remove_mapping(const char *fullpath);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: rename_mapping
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Rename the mapping from global path <-> page_mapping list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern void rename_mapping(const char *src, const char *dst);
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: dec_mapping
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Decrease the refcnt of mapping.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern void dec_mapping_nolock(struct page_mapping *mapping);
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: update_file_path
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Update the path in file descriptors when do renaming.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
extern int update_file_path(const char *old_path, const char *new_path);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup fs
|
* @ingroup fs
|
||||||
* @brief Initializes the vfs filesystem
|
* @brief Initializes the vfs filesystem
|
||||||
|
|||||||
@@ -201,13 +201,13 @@ int VfsJffs2Lookup(struct Vnode *parentVnode, const char *path, int len, struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void)VfsHashGet(parentVnode->originMount, node->i_ino, &newVnode, NULL, NULL);
|
(void)VfsHashGet(parentVnode->originMount, node->i_ino, &newVnode, NULL, NULL);
|
||||||
LOS_MuxUnlock(&g_jffs2FsLock);
|
|
||||||
if (newVnode) {
|
if (newVnode) {
|
||||||
if (newVnode->data == NULL) {
|
if (newVnode->data == NULL) {
|
||||||
LOS_Panic("#####VfsHashGet error#####\n");
|
LOS_Panic("#####VfsHashGet error#####\n");
|
||||||
}
|
}
|
||||||
newVnode->parent = parentVnode;
|
newVnode->parent = parentVnode;
|
||||||
*ppVnode = newVnode;
|
*ppVnode = newVnode;
|
||||||
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ret = VnodeAlloc(&g_jffs2Vops, &newVnode);
|
ret = VnodeAlloc(&g_jffs2Vops, &newVnode);
|
||||||
@@ -276,7 +276,7 @@ int VfsJffs2Close(struct file *filep)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t VfsJffs2Read(struct file *filep, char *buffer, size_t bufLen)
|
ssize_t VfsJffs2ReadPage(struct Vnode *vnode, char *buffer, off_t off)
|
||||||
{
|
{
|
||||||
struct jffs2_inode *node = NULL;
|
struct jffs2_inode *node = NULL;
|
||||||
struct jffs2_inode_info *f = NULL;
|
struct jffs2_inode_info *f = NULL;
|
||||||
@@ -285,6 +285,32 @@ ssize_t VfsJffs2Read(struct file *filep, char *buffer, size_t bufLen)
|
|||||||
|
|
||||||
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
|
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
|
||||||
|
|
||||||
|
node = (struct jffs2_inode *)vnode->data;
|
||||||
|
f = JFFS2_INODE_INFO(node);
|
||||||
|
c = JFFS2_SB_INFO(node->i_sb);
|
||||||
|
|
||||||
|
off_t pos = min(node->i_size, off);
|
||||||
|
ssize_t len = min(PAGE_SIZE, (node->i_size - pos));
|
||||||
|
ret = jffs2_read_inode_range(c, f, (unsigned char *)buffer, off, len);
|
||||||
|
if (ret) {
|
||||||
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
node->i_atime = Jffs2CurSec();
|
||||||
|
|
||||||
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t VfsJffs2Read(struct file *filep, char *buffer, size_t bufLen)
|
||||||
|
{
|
||||||
|
struct jffs2_inode *node = NULL;
|
||||||
|
struct jffs2_inode_info *f = NULL;
|
||||||
|
struct jffs2_sb_info *c = NULL;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
|
||||||
node = (struct jffs2_inode *)filep->f_vnode->data;
|
node = (struct jffs2_inode *)filep->f_vnode->data;
|
||||||
f = JFFS2_INODE_INFO(node);
|
f = JFFS2_INODE_INFO(node);
|
||||||
c = JFFS2_SB_INFO(node->i_sb);
|
c = JFFS2_SB_INFO(node->i_sb);
|
||||||
@@ -293,7 +319,6 @@ ssize_t VfsJffs2Read(struct file *filep, char *buffer, size_t bufLen)
|
|||||||
off_t len = min(bufLen, (node->i_size - pos));
|
off_t len = min(bufLen, (node->i_size - pos));
|
||||||
ret = jffs2_read_inode_range(c, f, (unsigned char *)buffer, filep->f_pos, len);
|
ret = jffs2_read_inode_range(c, f, (unsigned char *)buffer, filep->f_pos, len);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
PRINTK("VfsJffs2Read(): read_inode_range failed %d\n", ret);
|
|
||||||
LOS_MuxUnlock(&g_jffs2FsLock);
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -305,6 +330,59 @@ ssize_t VfsJffs2Read(struct file *filep, char *buffer, size_t bufLen)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t VfsJffs2WritePage(struct Vnode *vnode, char *buffer, off_t pos, size_t buflen)
|
||||||
|
{
|
||||||
|
struct jffs2_inode *node = NULL;
|
||||||
|
struct jffs2_inode_info *f = NULL;
|
||||||
|
struct jffs2_sb_info *c = NULL;
|
||||||
|
struct jffs2_raw_inode ri = {0};
|
||||||
|
struct IATTR attr = {0};
|
||||||
|
int ret;
|
||||||
|
uint32_t writtenLen;
|
||||||
|
|
||||||
|
LOS_MuxLock(&g_jffs2FsLock, (uint32_t)JFFS2_WAITING_FOREVER);
|
||||||
|
|
||||||
|
node = (struct jffs2_inode *)vnode->data;
|
||||||
|
f = JFFS2_INODE_INFO(node);
|
||||||
|
c = JFFS2_SB_INFO(node->i_sb);
|
||||||
|
|
||||||
|
if (pos < 0) {
|
||||||
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ri.ino = cpu_to_je32(f->inocache->ino);
|
||||||
|
ri.mode = cpu_to_jemode(node->i_mode);
|
||||||
|
ri.uid = cpu_to_je16(node->i_uid);
|
||||||
|
ri.gid = cpu_to_je16(node->i_gid);
|
||||||
|
ri.atime = ri.ctime = ri.mtime = cpu_to_je32(Jffs2CurSec());
|
||||||
|
|
||||||
|
if (pos > node->i_size) {
|
||||||
|
int err;
|
||||||
|
attr.attr_chg_valid = CHG_SIZE;
|
||||||
|
attr.attr_chg_size = pos;
|
||||||
|
err = jffs2_setattr(node, &attr);
|
||||||
|
if (err) {
|
||||||
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ri.isize = cpu_to_je32(node->i_size);
|
||||||
|
|
||||||
|
ret = jffs2_write_inode_range(c, f, &ri, (unsigned char *)buffer, pos, buflen, &writtenLen);
|
||||||
|
if (ret) {
|
||||||
|
node->i_mtime = node->i_ctime = je32_to_cpu(ri.mtime);
|
||||||
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
node->i_mtime = node->i_ctime = je32_to_cpu(ri.mtime);
|
||||||
|
|
||||||
|
LOS_MuxUnlock(&g_jffs2FsLock);
|
||||||
|
|
||||||
|
return (ssize_t)writtenLen;
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t VfsJffs2Write(struct file *filep, const char *buffer, size_t bufLen)
|
ssize_t VfsJffs2Write(struct file *filep, const char *buffer, size_t bufLen)
|
||||||
{
|
{
|
||||||
struct jffs2_inode *node = NULL;
|
struct jffs2_inode *node = NULL;
|
||||||
@@ -878,6 +956,8 @@ const struct MountOps jffs_operations = {
|
|||||||
struct VnodeOps g_jffs2Vops = {
|
struct VnodeOps g_jffs2Vops = {
|
||||||
.Lookup = VfsJffs2Lookup,
|
.Lookup = VfsJffs2Lookup,
|
||||||
.Create = VfsJffs2Create,
|
.Create = VfsJffs2Create,
|
||||||
|
.ReadPage = VfsJffs2ReadPage,
|
||||||
|
.WritePage = VfsJffs2WritePage,
|
||||||
.Rename = VfsJffs2Rename,
|
.Rename = VfsJffs2Rename,
|
||||||
.Mkdir = VfsJffs2Mkdir,
|
.Mkdir = VfsJffs2Mkdir,
|
||||||
.Getattr = VfsJffs2Stat,
|
.Getattr = VfsJffs2Stat,
|
||||||
|
|||||||
@@ -3,5 +3,6 @@ config FS_NFS
|
|||||||
default y
|
default y
|
||||||
depends on FS_VFS
|
depends on FS_VFS
|
||||||
depends on NET_LWIP_SACK
|
depends on NET_LWIP_SACK
|
||||||
|
depends on DEBUG_VERSION
|
||||||
help
|
help
|
||||||
Answer Y to enable LiteOS support nfs filesystem.
|
Answer Y to enable LiteOS support nfs filesystem.
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ include $(LITEOSTOPDIR)/config.mk
|
|||||||
MODULE_NAME := $(notdir $(shell pwd))
|
MODULE_NAME := $(notdir $(shell pwd))
|
||||||
|
|
||||||
LOCAL_SRCS := $(wildcard $(LITEOSTHIRDPARTY)/NuttX/fs/nfs/*.c)
|
LOCAL_SRCS := $(wildcard $(LITEOSTHIRDPARTY)/NuttX/fs/nfs/*.c)
|
||||||
LOCAL_INCLUDE := -I $(wildcard $(LITEOSTHIRDPARTY)/NuttX/include)
|
|
||||||
|
|
||||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ kernel_module(module_name) {
|
|||||||
sources = [
|
sources = [
|
||||||
"os_adapt/fd_proc.c",
|
"os_adapt/fd_proc.c",
|
||||||
"os_adapt/fs_cache_proc.c",
|
"os_adapt/fs_cache_proc.c",
|
||||||
"os_adapt/kernel_trace_proc.c",
|
|
||||||
"os_adapt/mounts_proc.c",
|
"os_adapt/mounts_proc.c",
|
||||||
"os_adapt/power_proc.c",
|
"os_adapt/power_proc.c",
|
||||||
"os_adapt/proc_init.c",
|
"os_adapt/proc_init.c",
|
||||||
|
|||||||
@@ -51,8 +51,6 @@ void ProcVmmInit(void);
|
|||||||
|
|
||||||
void ProcProcessInit(void);
|
void ProcProcessInit(void);
|
||||||
|
|
||||||
void ProcKernelTraceInit(void);
|
|
||||||
|
|
||||||
int ProcMatch(unsigned int len, const char *name, struct ProcDirEntry *pde);
|
int ProcMatch(unsigned int len, const char *name, struct ProcDirEntry *pde);
|
||||||
|
|
||||||
struct ProcDirEntry *ProcFindEntry(const char *path);
|
struct ProcDirEntry *ProcFindEntry(const char *path);
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ extern "C" {
|
|||||||
typedef unsigned short fmode_t;
|
typedef unsigned short fmode_t;
|
||||||
#define PROC_ERROR (-1)
|
#define PROC_ERROR (-1)
|
||||||
|
|
||||||
|
/* Default file mode for procfs */
|
||||||
|
#define PROCFS_DEFAULT_MODE 0550
|
||||||
|
|
||||||
/* 64bit hashes as llseek() offset (for directories) */
|
/* 64bit hashes as llseek() offset (for directories) */
|
||||||
#define FMODE_64BITHASH ((fmode_t)0x400)
|
#define FMODE_64BITHASH ((fmode_t)0x400)
|
||||||
/* 32bit hashes as llseek() offset (for directories) */
|
/* 32bit hashes as llseek() offset (for directories) */
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ static void FillFdInfo(struct SeqBuf *seqBuf, struct filelist *fileList, unsigne
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasPrivilege) {
|
if (hasPrivilege) {
|
||||||
(void)LosBufPrintf(seqBuf, "%u\t%d\t%6d <%d>\t%s\n", pid, fd, sysFd, filp->f_refcount, name);
|
(void)LosBufPrintf(seqBuf, "%u\t%d\t%6d <%d>\t%s\n", pid, fd, sysFd, filp ? filp->f_refcount : 1, name);
|
||||||
} else {
|
} else {
|
||||||
(void)LosBufPrintf(seqBuf, "%u\t%d\t%s\n", pid, fd, name);
|
(void)LosBufPrintf(seqBuf, "%u\t%d\t%s\n", pid, fd, name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,9 +71,9 @@ static int VnodeListProcess(struct SeqBuf *buf, LIST_HEAD* list)
|
|||||||
struct Vnode *nextItem = NULL;
|
struct Vnode *nextItem = NULL;
|
||||||
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, list, struct Vnode, actFreeEntry) {
|
LOS_DL_LIST_FOR_EACH_ENTRY_SAFE(item, nextItem, list, struct Vnode, actFreeEntry) {
|
||||||
LosBufPrintf(buf, "%-10p %-10p %-10p %10p 0x%08x %-3d %-4s %-3d %-3d %o\n",
|
LosBufPrintf(buf, "%-10p %-10p %-10p %10p 0x%08x %-3d %-4s %-3d %-3d %-8o\t%s\n",
|
||||||
item, item->parent, item->data, item->vop, item->hash, item->useCount,
|
item, item->parent, item->data, item->vop, item->hash, item->useCount,
|
||||||
VnodeTypeToStr(item->type), item->gid, item->uid, item->mode);
|
VnodeTypeToStr(item->type), item->gid, item->uid, item->mode, item->filePath);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ static int PageCacheEntryProcess(struct SeqBuf *buf, struct page_mapping *mappin
|
|||||||
int total = 0;
|
int total = 0;
|
||||||
LosFilePage *fpage = NULL;
|
LosFilePage *fpage = NULL;
|
||||||
|
|
||||||
if (mapping == NULL) {
|
if (mapping->nrpages == 0) {
|
||||||
LosBufPrintf(buf, "null]\n");
|
LosBufPrintf(buf, "null]\n");
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
@@ -119,18 +119,18 @@ static int PageCacheEntryProcess(struct SeqBuf *buf, struct page_mapping *mappin
|
|||||||
|
|
||||||
static int PageCacheMapProcess(struct SeqBuf *buf)
|
static int PageCacheMapProcess(struct SeqBuf *buf)
|
||||||
{
|
{
|
||||||
struct file_map *mapList = GetFileMappingList();
|
LIST_HEAD *vnodeList = GetVnodeActiveList();
|
||||||
char *name = NULL;
|
struct page_mapping *mapping = NULL;
|
||||||
struct file_map *curMap = NULL;
|
struct Vnode *vnode = NULL;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
(VOID)LOS_MuxLock(&mapList->lock, LOS_WAIT_FOREVER);
|
VnodeHold();
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY(curMap, &mapList->head, struct file_map, head) {
|
LOS_DL_LIST_FOR_EACH_ENTRY(vnode, vnodeList, struct Vnode, actFreeEntry) {
|
||||||
name = curMap->rename ? curMap->rename: curMap->owner;
|
mapping = &vnode->mapping;
|
||||||
LosBufPrintf(buf, "%s:[", name);
|
LosBufPrintf(buf, "%p, %s:[", vnode, vnode->filePath);
|
||||||
total += PageCacheEntryProcess(buf, &curMap->mapping);
|
total += PageCacheEntryProcess(buf, mapping);
|
||||||
}
|
}
|
||||||
(VOID)LOS_MuxUnlock(&mapList->lock);
|
VnodeDrop();
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void ProcFsInit(void)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = mkdir(PROCFS_MOUNT_POINT, 0);
|
ret = mkdir(PROCFS_MOUNT_POINT, PROCFS_DEFAULT_MODE);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
PRINT_ERR("failed to mkdir %s, errno = %d\n", PROCFS_MOUNT_POINT, get_errno());
|
PRINT_ERR("failed to mkdir %s, errno = %d\n", PROCFS_MOUNT_POINT, get_errno());
|
||||||
return;
|
return;
|
||||||
@@ -63,7 +63,6 @@ void ProcFsInit(void)
|
|||||||
#endif
|
#endif
|
||||||
ProcProcessInit();
|
ProcProcessInit();
|
||||||
ProcUptimeInit();
|
ProcUptimeInit();
|
||||||
ProcKernelTraceInit();
|
|
||||||
ProcFsCacheInit();
|
ProcFsCacheInit();
|
||||||
ProcFdInit();
|
ProcFdInit();
|
||||||
#ifdef LOSCFG_KERNEL_PM
|
#ifdef LOSCFG_KERNEL_PM
|
||||||
|
|||||||
@@ -41,8 +41,6 @@
|
|||||||
#include "los_tables.h"
|
#include "los_tables.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#define PROCFS_DEFAULT_MODE 0555
|
|
||||||
|
|
||||||
#ifdef LOSCFG_FS_PROC
|
#ifdef LOSCFG_FS_PROC
|
||||||
static struct VnodeOps g_procfsVops;
|
static struct VnodeOps g_procfsVops;
|
||||||
static struct file_operations_vfs g_procfsFops;
|
static struct file_operations_vfs g_procfsFops;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ static struct ProcFile g_procPf = {
|
|||||||
|
|
||||||
static struct ProcDirEntry g_procRootDirEntry = {
|
static struct ProcDirEntry g_procRootDirEntry = {
|
||||||
.nameLen = 5,
|
.nameLen = 5,
|
||||||
.mode = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH,
|
.mode = S_IFDIR | PROCFS_DEFAULT_MODE,
|
||||||
.count = ATOMIC_INIT(1),
|
.count = ATOMIC_INIT(1),
|
||||||
.procFileOps = NULL,
|
.procFileOps = NULL,
|
||||||
.parent = &g_procRootDirEntry,
|
.parent = &g_procRootDirEntry,
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ include $(LITEOSTOPDIR)/config.mk
|
|||||||
MODULE_NAME := $(notdir $(shell pwd))
|
MODULE_NAME := $(notdir $(shell pwd))
|
||||||
|
|
||||||
LOCAL_SRCS := $(wildcard $(LITEOSTHIRDPARTY)/NuttX/fs/tmpfs/*.c)
|
LOCAL_SRCS := $(wildcard $(LITEOSTHIRDPARTY)/NuttX/fs/tmpfs/*.c)
|
||||||
LOCAL_INCLUDE := -I $(wildcard $(LITEOSTHIRDPARTY)/NuttX/include)
|
|
||||||
|
|
||||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -40,7 +40,6 @@ kernel_module(module_name) {
|
|||||||
"operation/vfs_fallocate.c",
|
"operation/vfs_fallocate.c",
|
||||||
"operation/vfs_fallocate64.c",
|
"operation/vfs_fallocate64.c",
|
||||||
"operation/vfs_fcntl.c",
|
"operation/vfs_fcntl.c",
|
||||||
"operation/vfs_file_mapping.c",
|
|
||||||
"operation/vfs_force_umount.c",
|
"operation/vfs_force_umount.c",
|
||||||
"operation/vfs_init.c",
|
"operation/vfs_init.c",
|
||||||
"operation/vfs_other.c",
|
"operation/vfs_other.c",
|
||||||
@@ -110,7 +109,10 @@ kernel_module(module_name) {
|
|||||||
"$LITEOSTOPDIR/fs/vfs/vnode_hash.c",
|
"$LITEOSTOPDIR/fs/vfs/vnode_hash.c",
|
||||||
]
|
]
|
||||||
|
|
||||||
include_dirs = [ "$LITEOSTOPDIR/syscall" ]
|
include_dirs = [
|
||||||
|
"$LITEOSTOPDIR/syscall",
|
||||||
|
"$LITEOSTOPDIR/fs/zpfs/include",
|
||||||
|
]
|
||||||
public_configs = [ ":public" ]
|
public_configs = [ ":public" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ LOCAL_INCLUDE := \
|
|||||||
-I $(LITEOSTOPDIR)/drivers/mtd/multi_partition/include\
|
-I $(LITEOSTOPDIR)/drivers/mtd/multi_partition/include\
|
||||||
-I $(LITEOSTOPDIR)/fs/vfs/include/operation\
|
-I $(LITEOSTOPDIR)/fs/vfs/include/operation\
|
||||||
-I $(LITEOSTOPDIR)/syscall\
|
-I $(LITEOSTOPDIR)/syscall\
|
||||||
|
-I $(LITEOSTOPDIR)/fs/zpfs/include
|
||||||
|
|
||||||
ifeq ($(LOSCFG_FS_FAT), y)
|
ifeq ($(LOSCFG_FS_FAT), y)
|
||||||
LOCAL_INCLUDE += -I $(LITEOSTHIRDPARTY)/FatFs/source
|
LOCAL_INCLUDE += -I $(LITEOSTHIRDPARTY)/FatFs/source
|
||||||
|
|||||||
@@ -125,12 +125,16 @@ struct Vnode {
|
|||||||
LIST_ENTRY actFreeEntry; /* vnode active/free list entry */
|
LIST_ENTRY actFreeEntry; /* vnode active/free list entry */
|
||||||
struct Mount *originMount; /* fs info about this vnode */
|
struct Mount *originMount; /* fs info about this vnode */
|
||||||
struct Mount *newMount; /* fs info about who mount on this vnode */
|
struct Mount *newMount; /* fs info about who mount on this vnode */
|
||||||
|
char *filePath; /* file path of the vnode */
|
||||||
|
struct page_mapping mapping; /* page mapping of the vnode */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VnodeOps {
|
struct VnodeOps {
|
||||||
int (*Create)(struct Vnode *parent, const char *name, int mode, struct Vnode **vnode);
|
int (*Create)(struct Vnode *parent, const char *name, int mode, struct Vnode **vnode);
|
||||||
int (*Lookup)(struct Vnode *parent, const char *name, int len, struct Vnode **vnode);
|
int (*Lookup)(struct Vnode *parent, const char *name, int len, struct Vnode **vnode);
|
||||||
int (*Open)(struct Vnode *vnode, int fd, int mode, int flags);
|
int (*Open)(struct Vnode *vnode, int fd, int mode, int flags);
|
||||||
|
ssize_t (*ReadPage)(struct Vnode *vnode, char *buffer, off_t pos);
|
||||||
|
ssize_t (*WritePage)(struct Vnode *vnode, char *buffer, off_t pos, size_t buflen);
|
||||||
int (*Close)(struct Vnode *vnode);
|
int (*Close)(struct Vnode *vnode);
|
||||||
int (*Reclaim)(struct Vnode *vnode);
|
int (*Reclaim)(struct Vnode *vnode);
|
||||||
int (*Unlink)(struct Vnode *parent, struct Vnode *vnode, const char *fileName);
|
int (*Unlink)(struct Vnode *parent, struct Vnode *vnode, const char *fileName);
|
||||||
@@ -159,6 +163,7 @@ int VnodeDevInit(void);
|
|||||||
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **vnode);
|
int VnodeAlloc(struct VnodeOps *vop, struct Vnode **vnode);
|
||||||
int VnodeFree(struct Vnode *vnode);
|
int VnodeFree(struct Vnode *vnode);
|
||||||
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
|
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags);
|
||||||
|
int VnodeLookupAt(const char *path, struct Vnode **vnode, uint32_t flags, struct Vnode *orgVnode);
|
||||||
int VnodeHold(void);
|
int VnodeHold(void);
|
||||||
int VnodeDrop(void);
|
int VnodeDrop(void);
|
||||||
void VnodeRefDec(struct Vnode *vnode);
|
void VnodeRefDec(struct Vnode *vnode);
|
||||||
|
|||||||
@@ -50,7 +50,10 @@ void CloseOnExec(struct files_struct *files)
|
|||||||
if (FD_ISSET(i, files->fdt->proc_fds) &&
|
if (FD_ISSET(i, files->fdt->proc_fds) &&
|
||||||
FD_ISSET(i, files->fdt->cloexec_fds)) {
|
FD_ISSET(i, files->fdt->cloexec_fds)) {
|
||||||
sysFd = DisassociateProcessFd(i);
|
sysFd = DisassociateProcessFd(i);
|
||||||
close(sysFd);
|
if (sysFd >= 0) {
|
||||||
|
close(sysFd);
|
||||||
|
}
|
||||||
|
|
||||||
FreeProcessFd(i);
|
FreeProcessFd(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,303 +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 "fs/file.h"
|
|
||||||
#include "fs/file.h"
|
|
||||||
#include "fs/fs_operation.h"
|
|
||||||
#include "unistd.h"
|
|
||||||
#include "los_mux.h"
|
|
||||||
#include "los_list.h"
|
|
||||||
#include "los_atomic.h"
|
|
||||||
#include "los_vm_filemap.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
|
|
||||||
static struct file_map g_file_mapping = {0};
|
|
||||||
|
|
||||||
uint init_file_mapping()
|
|
||||||
{
|
|
||||||
uint ret;
|
|
||||||
|
|
||||||
LOS_ListInit(&g_file_mapping.head);
|
|
||||||
|
|
||||||
ret = LOS_MuxInit(&g_file_mapping.lock, NULL);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
PRINT_ERR("Create mutex for file map of page cache failed, (ret=%u)\n", ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void clear_file_mapping(const struct page_mapping *mapping)
|
|
||||||
{
|
|
||||||
unsigned int i = 3; /* file start fd */
|
|
||||||
struct file *filp = NULL;
|
|
||||||
|
|
||||||
while (i < CONFIG_NFILE_DESCRIPTORS) {
|
|
||||||
filp = &tg_filelist.fl_files[i];
|
|
||||||
if (filp->f_mapping == mapping) {
|
|
||||||
filp->f_mapping = NULL;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct page_mapping *find_mapping_nolock(const char *fullpath)
|
|
||||||
{
|
|
||||||
char *map_name = NULL;
|
|
||||||
struct file_map *fmap = NULL;
|
|
||||||
int name_len = strlen(fullpath);
|
|
||||||
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY(fmap, &g_file_mapping.head, struct file_map, head) {
|
|
||||||
map_name = fmap->rename ? fmap->rename: fmap->owner;
|
|
||||||
if ((name_len == fmap->name_len) && !strcmp(map_name, fullpath)) {
|
|
||||||
return &fmap->mapping;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void add_mapping(struct file *filep, const char *fullpath)
|
|
||||||
{
|
|
||||||
int path_len;
|
|
||||||
status_t retval;
|
|
||||||
struct file_map *fmap = NULL;
|
|
||||||
struct page_mapping *mapping = NULL;
|
|
||||||
|
|
||||||
if (filep == NULL || fullpath == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(VOID)LOS_MuxLock(&g_file_mapping.lock, LOS_WAIT_FOREVER);
|
|
||||||
mapping = find_mapping_nolock(fullpath);
|
|
||||||
if (mapping) {
|
|
||||||
LOS_AtomicInc(&mapping->ref);
|
|
||||||
filep->f_mapping = mapping;
|
|
||||||
mapping->host = filep;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
path_len = strlen(fullpath);
|
|
||||||
|
|
||||||
fmap = (struct file_map *)zalloc(sizeof(struct file_map) + path_len + 1);
|
|
||||||
if (!fmap) {
|
|
||||||
PRINT_WARN("%s %d, Mem alloc failed.\n", __FUNCTION__, __LINE__);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOS_AtomicSet(&fmap->mapping.ref, 1);
|
|
||||||
|
|
||||||
fmap->name_len = path_len;
|
|
||||||
(void)strcpy_s(fmap->owner, path_len + 1, fullpath);
|
|
||||||
|
|
||||||
LOS_ListInit(&fmap->mapping.page_list);
|
|
||||||
LOS_SpinInit(&fmap->mapping.list_lock);
|
|
||||||
retval = LOS_MuxInit(&fmap->mapping.mux_lock, NULL);
|
|
||||||
if (retval != LOS_OK) {
|
|
||||||
PRINT_ERR("%s %d, Create mutex for mapping.mux_lock failed, status: %d\n", __FUNCTION__, __LINE__, retval);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOS_ListTailInsert(&g_file_mapping.head, &fmap->head);
|
|
||||||
|
|
||||||
filep->f_mapping = &fmap->mapping;
|
|
||||||
filep->f_mapping->host = filep;
|
|
||||||
|
|
||||||
out:
|
|
||||||
(VOID)LOS_MuxUnlock(&g_file_mapping.lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int remove_mapping_nolock(struct page_mapping *mapping)
|
|
||||||
{
|
|
||||||
struct file_map *fmap = NULL;
|
|
||||||
|
|
||||||
if (mapping == NULL) {
|
|
||||||
set_errno(EINVAL);
|
|
||||||
return EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
(VOID)LOS_MuxDestroy(&mapping->mux_lock);
|
|
||||||
clear_file_mapping(mapping);
|
|
||||||
OsFileCacheRemove(mapping);
|
|
||||||
fmap = LOS_DL_LIST_ENTRY(mapping, struct file_map, mapping);
|
|
||||||
LOS_ListDelete(&fmap->head);
|
|
||||||
if (fmap->rename) {
|
|
||||||
LOS_MemFree(m_aucSysMem0, fmap->rename);
|
|
||||||
}
|
|
||||||
LOS_MemFree(m_aucSysMem0, fmap);
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void dec_mapping_nolock(struct page_mapping *mapping)
|
|
||||||
{
|
|
||||||
if (mapping == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(VOID)LOS_MuxLock(&g_file_mapping.lock, LOS_WAIT_FOREVER);
|
|
||||||
if (LOS_AtomicRead(&mapping->ref) > 0) {
|
|
||||||
LOS_AtomicDec(&mapping->ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (LOS_AtomicRead(&mapping->ref) <= 0) {
|
|
||||||
remove_mapping_nolock(mapping);
|
|
||||||
} else {
|
|
||||||
OsFileCacheFlush(mapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
(VOID)LOS_MuxUnlock(&g_file_mapping.lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int remove_mapping(const char *fullpath)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct filelist *f_list = NULL;
|
|
||||||
struct page_mapping *mapping = NULL;
|
|
||||||
|
|
||||||
f_list = &tg_filelist;
|
|
||||||
ret = sem_wait(&f_list->fl_sem);
|
|
||||||
if (ret < 0) {
|
|
||||||
PRINTK("sem_wait error, ret=%d\n", ret);
|
|
||||||
return VFS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
(VOID)LOS_MuxLock(&g_file_mapping.lock, LOS_WAIT_FOREVER);
|
|
||||||
|
|
||||||
mapping = find_mapping_nolock(fullpath);
|
|
||||||
if (mapping) {
|
|
||||||
ret = remove_mapping_nolock(mapping);
|
|
||||||
}
|
|
||||||
|
|
||||||
(VOID)LOS_MuxUnlock(&g_file_mapping.lock);
|
|
||||||
|
|
||||||
(void)sem_post(&f_list->fl_sem);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void rename_mapping(const char *src_path, const char *dst_path)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
char *tmp = NULL;
|
|
||||||
int path_len;
|
|
||||||
struct file_map *fmap = NULL;
|
|
||||||
struct page_mapping *mapping = NULL;
|
|
||||||
|
|
||||||
if (src_path == NULL || dst_path == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
path_len = strlen(dst_path);
|
|
||||||
|
|
||||||
/* protect the whole list in case of this node been deleted just after we found it */
|
|
||||||
|
|
||||||
(VOID)LOS_MuxLock(&g_file_mapping.lock, LOS_WAIT_FOREVER);
|
|
||||||
|
|
||||||
mapping = find_mapping_nolock(src_path);
|
|
||||||
if (!mapping) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
fmap = LOS_DL_LIST_ENTRY(mapping, struct file_map, mapping);
|
|
||||||
|
|
||||||
tmp = LOS_MemAlloc(m_aucSysMem0, path_len + 1);
|
|
||||||
if (!tmp) {
|
|
||||||
PRINT_ERR("%s-%d: Mem alloc failed, path length(%d)\n", __FUNCTION__, __LINE__, path_len);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
ret = strncpy_s(tmp, path_len, dst_path, strlen(dst_path));
|
|
||||||
if (ret != 0) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem0, tmp);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp[path_len] = '\0';
|
|
||||||
fmap->rename = tmp;
|
|
||||||
|
|
||||||
out:
|
|
||||||
(VOID)LOS_MuxUnlock(&g_file_mapping.lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int update_file_path(const char *old_path, const char *new_path)
|
|
||||||
{
|
|
||||||
struct filelist *f_list = NULL;
|
|
||||||
struct file *filp = NULL;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
f_list = &tg_filelist;
|
|
||||||
ret = sem_wait(&f_list->fl_sem);
|
|
||||||
if (ret < 0) {
|
|
||||||
PRINTK("sem_wait error, ret=%d\n", ret);
|
|
||||||
return VFS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
(VOID)LOS_MuxLock(&g_file_mapping.lock, LOS_WAIT_FOREVER);
|
|
||||||
for (int i = 3; i < CONFIG_NFILE_DESCRIPTORS; i++) {
|
|
||||||
if (!get_bit(i)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
filp = &tg_filelist.fl_files[i];
|
|
||||||
if (filp->f_path == NULL || strcmp(filp->f_path, old_path)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int len = strlen(new_path) + 1;
|
|
||||||
char *tmp_path = LOS_MemAlloc(m_aucSysMem0, len);
|
|
||||||
if (tmp_path == NULL) {
|
|
||||||
PRINT_ERR("%s-%d: Mem alloc failed, path length(%d)\n", __FUNCTION__, __LINE__, len);
|
|
||||||
ret = VFS_ERROR;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
ret = strncpy_s(tmp_path, strlen(new_path) + 1, new_path, len);
|
|
||||||
if (ret != 0) {
|
|
||||||
(VOID)LOS_MemFree(m_aucSysMem0, tmp_path);
|
|
||||||
PRINT_ERR("%s-%d: strcpy failed.\n", __FUNCTION__, __LINE__);
|
|
||||||
ret = VFS_ERROR;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
free(filp->f_path);
|
|
||||||
filp->f_path = tmp_path;
|
|
||||||
}
|
|
||||||
ret = LOS_OK;
|
|
||||||
|
|
||||||
out:
|
|
||||||
(VOID)LOS_MuxUnlock(&g_file_mapping.lock);
|
|
||||||
(void)sem_post(&f_list->fl_sem);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOSCFG_DEBUG_VERSION
|
|
||||||
struct file_map* GetFileMappingList(void)
|
|
||||||
{
|
|
||||||
return &g_file_mapping;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@@ -265,6 +265,10 @@ static struct Mount* GetDevMountPoint(struct Vnode *dev)
|
|||||||
{
|
{
|
||||||
struct Mount *mnt = NULL;
|
struct Mount *mnt = NULL;
|
||||||
LIST_HEAD *mntList = GetMountList();
|
LIST_HEAD *mntList = GetMountList();
|
||||||
|
if (mntList == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
LOS_DL_LIST_FOR_EACH_ENTRY(mnt, mntList, struct Mount, mountList) {
|
LOS_DL_LIST_FOR_EACH_ENTRY(mnt, mntList, struct Mount, mountList) {
|
||||||
if (mnt->vnodeDev == dev) {
|
if (mnt->vnodeDev == dev) {
|
||||||
return mnt;
|
return mnt;
|
||||||
@@ -302,7 +306,7 @@ static void FileDisableAndClean(struct Mount *mnt)
|
|||||||
{
|
{
|
||||||
struct filelist *flist = &tg_filelist;
|
struct filelist *flist = &tg_filelist;
|
||||||
struct file *filep = NULL;
|
struct file *filep = NULL;
|
||||||
const struct file_operations_vfs *originOps;
|
const struct file_operations_vfs *originOps = NULL;
|
||||||
|
|
||||||
for (int i = 3; i < CONFIG_NFILE_DESCRIPTORS; i++) {
|
for (int i = 3; i < CONFIG_NFILE_DESCRIPTORS; i++) {
|
||||||
if (!get_bit(i)) {
|
if (!get_bit(i)) {
|
||||||
@@ -355,7 +359,7 @@ static void VnodeTryFreeAll(struct Mount *mount)
|
|||||||
int ForceUmountDev(struct Vnode *dev)
|
int ForceUmountDev(struct Vnode *dev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct Vnode *origin;
|
struct Vnode *origin = NULL;
|
||||||
struct filelist *flist = &tg_filelist;
|
struct filelist *flist = &tg_filelist;
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|||||||
@@ -79,14 +79,7 @@ void los_vfs_init(void)
|
|||||||
PRINT_ERR("los_vfs_init VnodeDevInit failed error %d\n", retval);
|
PRINT_ERR("los_vfs_init VnodeDevInit failed error %d\n", retval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
|
||||||
retval = init_file_mapping();
|
|
||||||
if (retval != LOS_OK) {
|
|
||||||
PRINT_ERR("Page cache file map init failed\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
g_vfs_init = true;
|
g_vfs_init = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+52
-6
@@ -65,6 +65,7 @@ int VnodesInit(void)
|
|||||||
}
|
}
|
||||||
g_rootVnode->mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR;
|
g_rootVnode->mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR;
|
||||||
g_rootVnode->type = VNODE_TYPE_DIR;
|
g_rootVnode->type = VNODE_TYPE_DIR;
|
||||||
|
g_rootVnode->filePath = "/";
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
@@ -155,6 +156,11 @@ int VnodeAlloc(struct VnodeOps *vop, struct Vnode **newVnode)
|
|||||||
LOS_ListTailInsert(&g_vnodeActiveList, &(vnode->actFreeEntry));
|
LOS_ListTailInsert(&g_vnodeActiveList, &(vnode->actFreeEntry));
|
||||||
vnode->vop = vop;
|
vnode->vop = vop;
|
||||||
}
|
}
|
||||||
|
LOS_ListInit(&vnode->mapping.page_list);
|
||||||
|
LOS_SpinInit(&vnode->mapping.list_lock);
|
||||||
|
(VOID)LOS_MuxInit(&vnode->mapping.mux_lock, NULL);
|
||||||
|
vnode->mapping.host = vnode;
|
||||||
|
|
||||||
VnodeDrop();
|
VnodeDrop();
|
||||||
|
|
||||||
*newVnode = vnode;
|
*newVnode = vnode;
|
||||||
@@ -182,6 +188,9 @@ int VnodeFree(struct Vnode *vnode)
|
|||||||
vnode->vop->Reclaim(vnode);
|
vnode->vop->Reclaim(vnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (vnode->filePath) {
|
||||||
|
free(vnode->filePath);
|
||||||
|
}
|
||||||
if (vnode->vop == &g_devfsOps) {
|
if (vnode->vop == &g_devfsOps) {
|
||||||
/* for dev vnode, just free it */
|
/* for dev vnode, just free it */
|
||||||
free(vnode->data);
|
free(vnode->data);
|
||||||
@@ -360,14 +369,23 @@ STEP_FINISH:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VnodeLookup(const char *path, struct Vnode **result, uint32_t flags)
|
int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struct Vnode *orgVnode)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
int vnodePathLen;
|
||||||
|
char *vnodePath = NULL;
|
||||||
struct Vnode *startVnode = NULL;
|
struct Vnode *startVnode = NULL;
|
||||||
char *normalizedPath = NULL;
|
char *normalizedPath = NULL;
|
||||||
|
|
||||||
int ret = PreProcess(path, &startVnode, &normalizedPath);
|
if (orgVnode != NULL) {
|
||||||
if (ret != LOS_OK) {
|
startVnode = orgVnode;
|
||||||
goto OUT_FREE_PATH;
|
normalizedPath = strdup(path);
|
||||||
|
} else {
|
||||||
|
ret = PreProcess(path, &startVnode, &normalizedPath);
|
||||||
|
if (ret != LOS_OK) {
|
||||||
|
PRINT_ERR("[VFS]lookup failed, invalid path err = %d\n", ret);
|
||||||
|
goto OUT_FREE_PATH;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (normalizedPath[0] == '/' && normalizedPath[1] == '\0') {
|
if (normalizedPath[0] == '/' && normalizedPath[1] == '\0') {
|
||||||
@@ -384,7 +402,12 @@ int VnodeLookup(const char *path, struct Vnode **result, uint32_t flags)
|
|||||||
if (currentDir == NULL || *currentDir == '\0') {
|
if (currentDir == NULL || *currentDir == '\0') {
|
||||||
// return target or parent vnode as result
|
// return target or parent vnode as result
|
||||||
*result = currentVnode;
|
*result = currentVnode;
|
||||||
goto OUT_FREE_PATH;
|
if (currentVnode->filePath == NULL) {
|
||||||
|
currentVnode->filePath = normalizedPath;
|
||||||
|
} else {
|
||||||
|
free(normalizedPath);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
} else if (VfsVnodePermissionCheck(currentVnode, EXEC_OP)) {
|
} else if (VfsVnodePermissionCheck(currentVnode, EXEC_OP)) {
|
||||||
ret = -EACCES;
|
ret = -EACCES;
|
||||||
goto OUT_FREE_PATH;
|
goto OUT_FREE_PATH;
|
||||||
@@ -394,16 +417,36 @@ int VnodeLookup(const char *path, struct Vnode **result, uint32_t flags)
|
|||||||
// no such file, lookup failed
|
// no such file, lookup failed
|
||||||
goto OUT_FREE_PATH;
|
goto OUT_FREE_PATH;
|
||||||
}
|
}
|
||||||
|
if (currentVnode->filePath == NULL) {
|
||||||
|
vnodePathLen = currentDir - normalizedPath;
|
||||||
|
vnodePath = malloc(vnodePathLen + 1);
|
||||||
|
if (vnodePath == NULL) {
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto OUT_FREE_PATH;
|
||||||
|
}
|
||||||
|
ret = strncpy_s(vnodePath, vnodePathLen + 1, normalizedPath, vnodePathLen);
|
||||||
|
if (ret != EOK) {
|
||||||
|
ret = -ENAMETOOLONG;
|
||||||
|
free(vnodePath);
|
||||||
|
goto OUT_FREE_PATH;
|
||||||
|
}
|
||||||
|
currentVnode->filePath = vnodePath;
|
||||||
|
currentVnode->filePath[vnodePathLen] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OUT_FREE_PATH:
|
OUT_FREE_PATH:
|
||||||
if (normalizedPath) {
|
if (normalizedPath) {
|
||||||
free(normalizedPath);
|
free(normalizedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VnodeLookup(const char *path, struct Vnode **vnode, uint32_t flags)
|
||||||
|
{
|
||||||
|
return VnodeLookupAt(path, vnode, flags, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void ChangeRootInternal(struct Vnode *rootOld, char *dirname)
|
static void ChangeRootInternal(struct Vnode *rootOld, char *dirname)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
@@ -522,6 +565,9 @@ int VnodeCreate(struct Vnode *parent, const char *name, int mode, struct Vnode *
|
|||||||
newVnode->uid = parent->uid;
|
newVnode->uid = parent->uid;
|
||||||
newVnode->gid = parent->gid;
|
newVnode->gid = parent->gid;
|
||||||
newVnode->mode = mode;
|
newVnode->mode = mode;
|
||||||
|
/* The 'name' here is not full path, but for device we don't depend on this path, it's just a name for DFx.
|
||||||
|
When we have devfs, we can get a fullpath. */
|
||||||
|
newVnode->filePath = strdup(name);
|
||||||
|
|
||||||
*vnode = newVnode;
|
*vnode = newVnode;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+4
-2
@@ -33,7 +33,9 @@ module_switch = defined(LOSCFG_FS_ZPFS)
|
|||||||
module_name = get_path_info(rebase_path("."), "name")
|
module_name = get_path_info(rebase_path("."), "name")
|
||||||
kernel_module(module_name) {
|
kernel_module(module_name) {
|
||||||
sources = [
|
sources = [
|
||||||
"vfs_zpfs.c",
|
"src/vfs_zpfs.c",
|
||||||
"zpfs.c",
|
"src/zpfs.c",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
include_dirs = [ "include" ]
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-8
@@ -31,14 +31,10 @@ include $(LITEOSTOPDIR)/config.mk
|
|||||||
|
|
||||||
MODULE_NAME := $(notdir $(shell pwd))
|
MODULE_NAME := $(notdir $(shell pwd))
|
||||||
|
|
||||||
LOCAL_SRCS := $(wildcard *.c)
|
LOCAL_SRCS := $(wildcard src/*.c)
|
||||||
LOCAL_INCLUDE = \
|
LOCAL_INCLUDE := \
|
||||||
-I $(LITEOSTOPDIR)/fs/include \
|
-I $(LITEOSTOPDIR)/fs/zpfs/include
|
||||||
-I $(LITEOSTOPDIR)/fs/zpfs \
|
|
||||||
-I $(LITEOSTOPDIR)/../../third_party/NuttX/liteos/fs/include\
|
|
||||||
-I $(LITEOSTOPDIR)/../../third_party/NuttX/liteos/fs/include/inode
|
|
||||||
|
|
||||||
LOCAL_FLAGS := $(LITEOS_GCOV_OPTS)
|
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||||
|
|
||||||
include $(MODULE)
|
include $(MODULE)
|
||||||
|
|
||||||
|
|||||||
@@ -1,458 +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 "vfs_zpfs.h"
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/statfs.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include "fs/dirent_fs.h"
|
|
||||||
#include "inode/inode.h"
|
|
||||||
#include "internal.h"
|
|
||||||
#include "los_tables.h"
|
|
||||||
#include "los_vm_filemap.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_FS_ZPFS
|
|
||||||
|
|
||||||
static int CheckEntryExist(const struct ZpfsEntry *zpfsEntry, char **fPath, struct stat *buf)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct inode *inode = zpfsEntry->mountedInode;
|
|
||||||
const char *path = zpfsEntry->mountedPath;
|
|
||||||
const char *relPath = zpfsEntry->mountedRelpath;
|
|
||||||
int len = strlen(path) + strlen(relPath) + 1;
|
|
||||||
int fullLen = len + 1;
|
|
||||||
char *fullPath = (char *)malloc(fullLen);
|
|
||||||
if (fullPath == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = snprintf_s(fullPath, fullLen, len, "%s/%s", path, relPath);
|
|
||||||
if (ret < 0) {
|
|
||||||
free(fullPath);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (inode->u.i_mops->stat != NULL) {
|
|
||||||
ret = inode->u.i_mops->stat(inode, fullPath, buf);
|
|
||||||
} else {
|
|
||||||
ret = -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fPath == NULL) {
|
|
||||||
free(fullPath);
|
|
||||||
} else {
|
|
||||||
*fPath = fullPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct inode *GetRelInodeFromVInode(const ZpfsConfig *zpfsCfg,
|
|
||||||
const char* relPath, struct stat *buf, char **finalPath)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct ZpfsEntry entry;
|
|
||||||
|
|
||||||
for (int i = 0; i < zpfsCfg->entryCount; i++) {
|
|
||||||
entry.mountedPath = zpfsCfg->orgEntry[i].mountedRelpath;
|
|
||||||
entry.mountedRelpath = (char*)relPath;
|
|
||||||
entry.mountedInode = zpfsCfg->orgEntry[i].mountedInode;
|
|
||||||
ret = CheckEntryExist(&entry, finalPath, buf);
|
|
||||||
if (ret == OK) {
|
|
||||||
return entry.mountedInode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: VfsZpfsRealInode
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the inode which is hidden.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* The relative path.
|
|
||||||
* Returned Value:
|
|
||||||
* finalPath the relative path of the mount point.
|
|
||||||
* OK
|
|
||||||
* NULL memory is not enough.
|
|
||||||
****************************************************************************/
|
|
||||||
static inline struct inode *VfsZpfsRealInode(const ZpfsConfig *zpfsCfg, const char *relPath, char **finalPath)
|
|
||||||
{
|
|
||||||
struct stat buf;
|
|
||||||
struct inode *inode = GetRelInodeFromVInode(zpfsCfg, relPath, &buf, finalPath);
|
|
||||||
return inode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsOpen(struct file *file, const char *relPath, int oflAgs, mode_t mode)
|
|
||||||
{
|
|
||||||
char *finalPath = NULL;
|
|
||||||
struct inode *swapInode = NULL;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
struct inode *inode = file->f_inode;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(inode);
|
|
||||||
inode = VfsZpfsRealInode(zpfsCfg, relPath, &finalPath);
|
|
||||||
if ((inode == NULL) || (!inode->u.i_mops->open)) {
|
|
||||||
if (finalPath) {
|
|
||||||
free(finalPath);
|
|
||||||
}
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
swapInode = file->f_inode;
|
|
||||||
file->f_inode = inode;
|
|
||||||
ret = inode->u.i_mops->open(file, finalPath, oflAgs, mode);
|
|
||||||
free(finalPath);
|
|
||||||
finalPath = NULL;
|
|
||||||
file->f_inode = swapInode;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsClose(struct file *file)
|
|
||||||
{
|
|
||||||
struct inode *swapInode = NULL;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
struct inode *inode = file->f_inode;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(inode);
|
|
||||||
inode = VfsZpfsRealInode(zpfsCfg, file->f_relpath, NULL);
|
|
||||||
if ((inode == NULL) || (!inode->u.i_mops->close)) {
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
swapInode = file->f_inode;
|
|
||||||
file->f_inode = inode;
|
|
||||||
ret = inode->u.i_mops->close(file);
|
|
||||||
file->f_inode = swapInode;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t VfsZpfsRead(struct file *file, char *buffer, size_t bufLen)
|
|
||||||
{
|
|
||||||
struct inode *swapInode = NULL;
|
|
||||||
ssize_t sret;
|
|
||||||
|
|
||||||
struct inode *inode = file->f_inode;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(inode);
|
|
||||||
inode = VfsZpfsRealInode(zpfsCfg, file->f_relpath, NULL);
|
|
||||||
if ((inode == NULL) || (!inode->u.i_mops->read)) {
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
swapInode = file->f_inode;
|
|
||||||
file->f_inode = inode;
|
|
||||||
sret = inode->u.i_mops->read(file, buffer, bufLen);
|
|
||||||
file->f_inode = swapInode;
|
|
||||||
|
|
||||||
return sret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static off_t VfsZpfsLseek(struct file *file, off_t offset, int whence)
|
|
||||||
{
|
|
||||||
off_t off;
|
|
||||||
struct inode *swapInode = NULL;
|
|
||||||
|
|
||||||
struct inode *inode = file->f_inode;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(inode);
|
|
||||||
inode = VfsZpfsRealInode(zpfsCfg, file->f_relpath, NULL);
|
|
||||||
if ((inode == NULL) || (!inode->u.i_mops->seek)) {
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
swapInode = file->f_inode;
|
|
||||||
file->f_inode = inode;
|
|
||||||
off = inode->u.i_mops->seek(file, offset, whence);
|
|
||||||
file->f_inode = swapInode;
|
|
||||||
return off;
|
|
||||||
}
|
|
||||||
|
|
||||||
static loff_t VfsZpfsLseek64(struct file *file, loff_t offset, int whence)
|
|
||||||
{
|
|
||||||
loff_t off;
|
|
||||||
struct inode *swapInode = NULL;
|
|
||||||
|
|
||||||
struct inode *inode = file->f_inode;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(inode);
|
|
||||||
inode = VfsZpfsRealInode(zpfsCfg, file->f_relpath, NULL);
|
|
||||||
if ((inode == NULL) || (!inode->u.i_mops->seek64)) {
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
swapInode = file->f_inode;
|
|
||||||
file->f_inode = inode;
|
|
||||||
off = inode->u.i_mops->seek64(file, offset, whence);
|
|
||||||
file->f_inode = swapInode;
|
|
||||||
return off;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsDup(const struct file *oldFile, struct file *newFile)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct inode *inode = oldFile->f_inode;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(inode);
|
|
||||||
inode = VfsZpfsRealInode(zpfsCfg, oldFile->f_relpath, NULL);
|
|
||||||
if ((inode == NULL) || (!inode->u.i_mops->dup)) {
|
|
||||||
return -ENOSYS;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = inode->u.i_mops->dup(oldFile, newFile);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsOpenDir(struct inode *mountpt, const char *relPath, struct fs_dirent_s *dir)
|
|
||||||
{
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(mountpt);
|
|
||||||
if (!VfsZpfsRealInode(zpfsCfg, relPath, NULL)) {
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
struct ZpfsDir *zpfsDir = malloc(sizeof(struct ZpfsDir));
|
|
||||||
if (zpfsDir == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
zpfsDir->relPath = strdup(relPath);
|
|
||||||
if (zpfsDir->relPath == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
zpfsDir->index = zpfsCfg->entryCount;
|
|
||||||
zpfsDir->openEntry = -1;
|
|
||||||
dir->u.zpfs = (void*)zpfsDir;
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void CloseEntry(const struct ZpfsConfig *zpfsCfg, struct fs_dirent_s *dir, const int index)
|
|
||||||
{
|
|
||||||
struct inode *inode = zpfsCfg->orgEntry[index].mountedInode;
|
|
||||||
if (inode->u.i_mops->closedir != NULL) {
|
|
||||||
inode->u.i_mops->closedir(inode, dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsCloseDir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|
||||||
{
|
|
||||||
struct ZpfsDir *zpfsDir = (struct ZpfsDir *)(dir->u.zpfs);
|
|
||||||
if (zpfsDir->relPath) {
|
|
||||||
free(zpfsDir->relPath);
|
|
||||||
zpfsDir->relPath = NULL;
|
|
||||||
}
|
|
||||||
free(zpfsDir);
|
|
||||||
zpfsDir = NULL;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int IsExistInEntries(const struct ZpfsConfig *zpfsCfg, const char* relPath, const int index)
|
|
||||||
{
|
|
||||||
struct ZpfsEntry entry;
|
|
||||||
struct stat buf;
|
|
||||||
for (int i = index; i >= 0; i--) {
|
|
||||||
entry.mountedPath = zpfsCfg->orgEntry[i].mountedRelpath;
|
|
||||||
entry.mountedRelpath = (char *)relPath;
|
|
||||||
entry.mountedInode = zpfsCfg->orgEntry[i].mountedInode;
|
|
||||||
if (CheckEntryExist(&entry, NULL, &buf) == OK) {
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int OpenEntry(const struct ZpfsConfig *zpfsCfg,
|
|
||||||
const struct ZpfsDir *zpfsDir, struct fs_dirent_s *dir, const int index)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
char *fullPath;
|
|
||||||
char *path = (char *)zpfsCfg->orgEntry[index].mountedRelpath;
|
|
||||||
char *relPath = zpfsDir->relPath;
|
|
||||||
struct inode *curInode = zpfsCfg->orgEntry[index].mountedInode;
|
|
||||||
int len = strlen(path) + strlen(relPath) + 1;
|
|
||||||
int fullLen = len + 1;
|
|
||||||
fullPath = (char *)malloc(fullLen);
|
|
||||||
if (fullPath == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
ret = snprintf_s(fullPath, fullLen, len, "%s/%s", path, relPath);
|
|
||||||
if (ret < 0) {
|
|
||||||
free(fullPath);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
ret = -ENOSYS;
|
|
||||||
if (curInode->u.i_mops->opendir != NULL) {
|
|
||||||
ret = curInode->u.i_mops->opendir(curInode, fullPath, dir);
|
|
||||||
}
|
|
||||||
free(fullPath);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsReadDir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
struct inode *oldInode = NULL;
|
|
||||||
struct inode *curInode = NULL;
|
|
||||||
struct ZpfsDir *zpfsDir = (struct ZpfsDir *)dir->u.zpfs;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(mountpt);
|
|
||||||
|
|
||||||
int index = zpfsDir->index;
|
|
||||||
do {
|
|
||||||
if (zpfsDir->openEntry == -1) {
|
|
||||||
zpfsDir->index--;
|
|
||||||
index = zpfsDir->index;
|
|
||||||
if (index < 0) {
|
|
||||||
ret = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ret = OpenEntry(zpfsCfg, zpfsDir, dir, index);
|
|
||||||
if (ret != OK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
zpfsDir->openEntry = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
curInode = zpfsCfg->orgEntry[index].mountedInode;
|
|
||||||
oldInode = dir->fd_root;
|
|
||||||
dir->fd_root = curInode;
|
|
||||||
ret = curInode->u.i_mops->readdir(curInode, dir);
|
|
||||||
dir->fd_root = oldInode;
|
|
||||||
if (ret != OK) {
|
|
||||||
if (index >= 0) {
|
|
||||||
CloseEntry(zpfsCfg, dir, index);
|
|
||||||
zpfsDir->openEntry = -1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (IsExistInEntries(zpfsCfg, dir->fd_dir[0].d_name, (index - 1)) == OK) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ret = 1; // 1 means current op return one file
|
|
||||||
dir->fd_position++;
|
|
||||||
dir->fd_dir[0].d_off = dir->fd_position;
|
|
||||||
dir->fd_dir[0].d_reclen = (uint16_t)sizeof(struct dirent);
|
|
||||||
break;
|
|
||||||
} while (1);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsRewindDir(struct inode *mountpt, struct fs_dirent_s *dir)
|
|
||||||
{
|
|
||||||
PRINT_DEBUG("%s NOT support!\n", __FUNCTION__);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsBind(struct inode *blkDriver, const void *data, void **handle, const char *relPath)
|
|
||||||
{
|
|
||||||
if (data == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
(*handle) = (void*)data;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsUnbind(void *handle, struct inode **blkDriver)
|
|
||||||
{
|
|
||||||
struct inode *node = NULL;
|
|
||||||
ZpfsConfig *zpfsCfg = NULL;
|
|
||||||
if (handle != NULL) {
|
|
||||||
zpfsCfg = (ZpfsConfig *)handle;
|
|
||||||
node = inode_unlink(zpfsCfg->patchTarget);
|
|
||||||
INODE_SET_TYPE(node, FSNODEFLAG_DELETED);
|
|
||||||
if (node != zpfsCfg->patchInode) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsStatFs(struct inode *mountpt, struct statfs *buf)
|
|
||||||
{
|
|
||||||
if (buf == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
(void)memset_s(buf, sizeof(struct statfs), 0, sizeof(struct statfs));
|
|
||||||
buf->f_type = ZPFS_MAGIC;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int VfsZpfsStat(struct inode *mountpt, const char *relPath, struct stat *buf)
|
|
||||||
{
|
|
||||||
struct inode *inode = NULL;
|
|
||||||
ZpfsConfig *zpfsCfg = GetZpfsConfig(mountpt);
|
|
||||||
inode = GetRelInodeFromVInode(zpfsCfg, relPath, buf, NULL);
|
|
||||||
if (inode == NULL) {
|
|
||||||
return -ENOENT;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct mountpt_operations zpfsOperations = {
|
|
||||||
VfsZpfsOpen, /* open */
|
|
||||||
VfsZpfsClose, /* close */
|
|
||||||
VfsZpfsRead, /* read */
|
|
||||||
NULL, /* write */
|
|
||||||
VfsZpfsLseek, /* seek */
|
|
||||||
NULL, /* ioctl */
|
|
||||||
OsVfsFileMmap, /* mmap */
|
|
||||||
NULL, /* sync */
|
|
||||||
VfsZpfsDup, /* dup */
|
|
||||||
NULL, /* fstat */
|
|
||||||
NULL, /* truncate */
|
|
||||||
VfsZpfsOpenDir, /* opendir */
|
|
||||||
VfsZpfsCloseDir, /* closedir */
|
|
||||||
VfsZpfsReadDir, /* readdir */
|
|
||||||
VfsZpfsRewindDir, /* rewinddir */
|
|
||||||
VfsZpfsBind, /* bind */
|
|
||||||
VfsZpfsUnbind, /* unbind */
|
|
||||||
VfsZpfsStatFs, /* statfs */
|
|
||||||
NULL, /* virstatfs */
|
|
||||||
NULL, /* unlink */
|
|
||||||
NULL, /* mkdir */
|
|
||||||
NULL, /* rmdir */
|
|
||||||
NULL, /* rename */
|
|
||||||
VfsZpfsStat, /* stat */
|
|
||||||
NULL, /* utime */
|
|
||||||
NULL, /* chattr */
|
|
||||||
VfsZpfsLseek64, /* seek64 */
|
|
||||||
NULL, /* getlabel */
|
|
||||||
NULL, /* fallocate */
|
|
||||||
NULL, /* fallocate64 */
|
|
||||||
NULL, /* truncate64 */
|
|
||||||
NULL, /* fscheck */
|
|
||||||
NULL, /* map_pages */
|
|
||||||
NULL, /* readpage */
|
|
||||||
NULL, /* writepage */
|
|
||||||
};
|
|
||||||
|
|
||||||
FSMAP_ENTRY(zpfs_fsmap, ZPFS_NAME, zpfsOperations, FALSE, FALSE);
|
|
||||||
|
|
||||||
#endif // LOSCFG_FS_ZPFS
|
|
||||||
-464
@@ -1,464 +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 "vfs_zpfs.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/statfs.h>
|
|
||||||
|
|
||||||
#include "fs/dirent_fs.h"
|
|
||||||
#include "inode/inode.h"
|
|
||||||
#include "internal.h"
|
|
||||||
#include "los_tables.h"
|
|
||||||
|
|
||||||
#ifdef LOSCFG_FS_ZPFS
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: CheckEntryExist
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* check if entry is exist or not.
|
|
||||||
* Input Parameters:
|
|
||||||
* The path
|
|
||||||
* Returned Value:
|
|
||||||
* true or false, it is true for the exist of path.
|
|
||||||
****************************************************************************/
|
|
||||||
bool CheckEntryExist(const char *entry)
|
|
||||||
{
|
|
||||||
struct stat64 stat64Info;
|
|
||||||
struct stat statInfo;
|
|
||||||
|
|
||||||
if (stat64(entry, &stat64Info) == 0) {
|
|
||||||
if (S_ISDIR(stat64Info.st_mode) != 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (stat(entry, &statInfo) == 0) {
|
|
||||||
if (S_ISDIR(statInfo.st_mode) != 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: GetZpfsConfig
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* get the zpfs configuration
|
|
||||||
* Input Parameters:
|
|
||||||
* void
|
|
||||||
* Returned Value:
|
|
||||||
* g_zpfsConfig Save the patch gobal data.
|
|
||||||
****************************************************************************/
|
|
||||||
ZpfsConfig *GetZpfsConfig(const struct inode *inode)
|
|
||||||
{
|
|
||||||
ZpfsConfig *zpfsCfg = (ZpfsConfig*)(inode->i_private);
|
|
||||||
return zpfsCfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: GetSourceList
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Get the source path list.
|
|
||||||
* eg: /patch/etc:/patch/etc1:/patch/etc2
|
|
||||||
* Input Parameters:
|
|
||||||
* source: /patch/etc:/patch/etc1:/patch/etc2
|
|
||||||
* sourcelist: output path arry
|
|
||||||
* num: output list num
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK The mounted folder parameter is right.
|
|
||||||
* EINVAL The mounted folder parameter is wrong.
|
|
||||||
* ENOMEM The memory is not enough
|
|
||||||
****************************************************************************/
|
|
||||||
static int GetSourceList(const char *source, char *sourceList[ZPFS_LEVELS], int *num)
|
|
||||||
{
|
|
||||||
char *subSource = NULL;
|
|
||||||
char *path = NULL;
|
|
||||||
char *subPath = NULL;
|
|
||||||
int index;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
subSource = strdup(source);
|
|
||||||
if (subSource == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
subPath = strtok_r(subSource, ":", &path);
|
|
||||||
for (*num = 0; *num < ZPFS_LEVELS && subPath != NULL; (*num)++) {
|
|
||||||
sourceList[*num] = strdup(subPath);
|
|
||||||
if (sourceList[*num] == NULL) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
subPath = strtok_r(NULL, ":", &path);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (subPath != NULL || *num == 0) {
|
|
||||||
PRINTK("source path num %d error\n", *num);
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(subSource);
|
|
||||||
return OK;
|
|
||||||
|
|
||||||
EXIT:
|
|
||||||
free(subSource);
|
|
||||||
for (index = 0; index < *num; index++) {
|
|
||||||
free(sourceList[index]);
|
|
||||||
sourceList[index] = NULL;
|
|
||||||
}
|
|
||||||
*num = 0;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: CheckInputParamsFormat
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* check the mounted folder format and validity. MAX three segment.
|
|
||||||
* eg: /patch/etc:/patch/etc1:/patch/etc2
|
|
||||||
* Input Parameters:
|
|
||||||
* check the mounted folder. eg:
|
|
||||||
* source: /patch/etc:/patch/etc1:/patch/etc2
|
|
||||||
* target: /etc
|
|
||||||
*
|
|
||||||
* Returned Value:
|
|
||||||
* OK The mounted folder parameter is right.
|
|
||||||
* EINVAL The mounted folder parameter is wrong.
|
|
||||||
* ENOMEM The memory is not enough
|
|
||||||
****************************************************************************/
|
|
||||||
static int CheckInputParamsFormat(const char *source, const char *target)
|
|
||||||
{
|
|
||||||
char *sourceList[ZPFS_LEVELS] = {0};
|
|
||||||
int num = 0;
|
|
||||||
int ret;
|
|
||||||
int index;
|
|
||||||
bool isTargetValid = false;
|
|
||||||
|
|
||||||
if (source == NULL || target == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = GetSourceList(source, sourceList, &num);
|
|
||||||
if (ret != OK) {
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (index = 0; index < num; index++) {
|
|
||||||
if (!CheckEntryExist(sourceList[index])) {
|
|
||||||
ret = -ENOENT;
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
/* target must same with one source path */
|
|
||||||
if (strcmp(target, sourceList[index]) == 0) {
|
|
||||||
isTargetValid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isTargetValid) {
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto EXIT;
|
|
||||||
}
|
|
||||||
ret = OK;
|
|
||||||
EXIT:
|
|
||||||
for (index = 0; index < num; index++) {
|
|
||||||
free(sourceList[index]);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ZpfsFreeEntry(ZpfsEntry *zpfsEntry)
|
|
||||||
{
|
|
||||||
if (zpfsEntry->mountedPath != NULL) {
|
|
||||||
free(zpfsEntry->mountedPath);
|
|
||||||
zpfsEntry->mountedPath = NULL;
|
|
||||||
}
|
|
||||||
if (zpfsEntry->mountedRelpath != NULL) {
|
|
||||||
free(zpfsEntry->mountedRelpath);
|
|
||||||
zpfsEntry->mountedRelpath = NULL;
|
|
||||||
}
|
|
||||||
zpfsEntry->mountedInode = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: ZpfsFreeConfig
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Umount the patch file system,
|
|
||||||
* Delete the global patch data and the mount pseudo point.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* void
|
|
||||||
* Returned Value:
|
|
||||||
* void
|
|
||||||
****************************************************************************/
|
|
||||||
void ZpfsFreeConfig(ZpfsConfig *zpfsCfg)
|
|
||||||
{
|
|
||||||
struct inode *pInode = NULL;
|
|
||||||
if (zpfsCfg == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pInode = zpfsCfg->patchInode;
|
|
||||||
if (pInode != NULL) {
|
|
||||||
INODE_SET_TYPE(pInode, FSNODEFLAG_DELETED);
|
|
||||||
inode_release(pInode);
|
|
||||||
pInode = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < zpfsCfg->entryCount; i++) {
|
|
||||||
ZpfsFreeEntry(&(zpfsCfg->orgEntry[i]));
|
|
||||||
}
|
|
||||||
if (zpfsCfg->patchTarget != NULL) {
|
|
||||||
free(zpfsCfg->patchTarget);
|
|
||||||
zpfsCfg->patchTarget = NULL;
|
|
||||||
}
|
|
||||||
free(zpfsCfg);
|
|
||||||
zpfsCfg = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: IsTargetMounted
|
|
||||||
* Description:
|
|
||||||
* The mount patch target path must be the mounted path.
|
|
||||||
* Input Parameters:
|
|
||||||
* target: The mount point
|
|
||||||
* Returned Value:
|
|
||||||
* OK
|
|
||||||
* EINVAL The mount patch target path is not the mounted path.
|
|
||||||
****************************************************************************/
|
|
||||||
static int IsTargetMounted(const char *target)
|
|
||||||
{
|
|
||||||
struct inode *inode = NULL;
|
|
||||||
char *path = NULL;
|
|
||||||
struct statfs buf;
|
|
||||||
|
|
||||||
if (!CheckEntryExist(target)) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
inode = inode_search((const char **)&target, (struct inode**)NULL,
|
|
||||||
(struct inode**)NULL, (const char **)&path);
|
|
||||||
if (inode == NULL || !INODE_IS_MOUNTPT(inode)) {
|
|
||||||
PRINT_ERR("Can't to mount to this inode %s\n", target);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
if ((inode->u.i_mops != NULL) && (inode->u.i_mops->statfs != NULL)) {
|
|
||||||
if (inode->u.i_mops->statfs(inode, &buf) == OK) {
|
|
||||||
if (buf.f_type == ZPFS_MAGIC) {
|
|
||||||
return -EEXIST;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (path == NULL || path[0] == '\0') {
|
|
||||||
return -EEXIST;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: SaveZpfsParameter
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* When the patch file system is mounted, the patch gobal data is built.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* source: The mounted patch folder
|
|
||||||
* target: The mount point
|
|
||||||
* Returned Value:
|
|
||||||
* OK Save the patch gobal data.
|
|
||||||
* ENOMEM The memory is not enough.
|
|
||||||
* EBADMSG There is no data.
|
|
||||||
****************************************************************************/
|
|
||||||
static int SaveZpfsParameter(const char *source, const char *target, struct ZpfsConfig *zpfsCfg)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
const char *path = NULL;
|
|
||||||
int num = 0;
|
|
||||||
int index;
|
|
||||||
char *sourceList[ZPFS_LEVELS] = {0};
|
|
||||||
|
|
||||||
/* save the mount point */
|
|
||||||
zpfsCfg->patchTarget = strdup(target);
|
|
||||||
if (zpfsCfg->patchTarget == NULL) {
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* save the mount folder inode */
|
|
||||||
zpfsCfg->patchTargetInode = inode_search((const char **)&target,
|
|
||||||
(struct inode**)NULL, (struct inode**)NULL, &path);
|
|
||||||
if (zpfsCfg->patchTargetInode == NULL) {
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = GetSourceList(source, sourceList, &num);
|
|
||||||
if (ret != OK) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
zpfsCfg->entryCount = num;
|
|
||||||
for (index = 0; index < num; index++) {
|
|
||||||
zpfsCfg->orgEntry[index].mountedPath = sourceList[index];
|
|
||||||
|
|
||||||
/* save the mounted folder inode */
|
|
||||||
zpfsCfg->orgEntry[index].mountedInode = inode_search((const char **)&sourceList[index],
|
|
||||||
(struct inode**)NULL, (struct inode**)NULL, &path);
|
|
||||||
if (zpfsCfg->orgEntry[index].mountedInode == NULL) {
|
|
||||||
ret = -EINVAL;
|
|
||||||
goto ERROR_PROCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* save the mounted relative path */
|
|
||||||
zpfsCfg->orgEntry[index].mountedRelpath = (char*)path;
|
|
||||||
}
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
|
|
||||||
ERROR_PROCESS:
|
|
||||||
for (index = 0; index < num; index++) {
|
|
||||||
free(sourceList[index]);
|
|
||||||
sourceList[index] = NULL;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: ZpfsPrepare
|
|
||||||
* Description:
|
|
||||||
* The main function of mount zpfs.
|
|
||||||
* Input Parameters:
|
|
||||||
* source: The mounted parameter
|
|
||||||
* target: The mount path
|
|
||||||
* inodePtr: the new inode info of target
|
|
||||||
* force: It is true for zpfs
|
|
||||||
* Returned Value:
|
|
||||||
* OK
|
|
||||||
* EINVAL The parameter is wrong.
|
|
||||||
* ENOMEM It is not enough memory.
|
|
||||||
****************************************************************************/
|
|
||||||
int ZpfsPrepare(const char *source, const char *target, struct inode **inodePtr, bool force)
|
|
||||||
{
|
|
||||||
/* Check the mounted folder parameter */
|
|
||||||
int ret = CheckInputParamsFormat(source, target);
|
|
||||||
if (ret != OK) {
|
|
||||||
PRINT_ERR("Parameter is err source:%s target:%s.\n", source, target);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The mount target path must be the mounted path */
|
|
||||||
ret = IsTargetMounted(target);
|
|
||||||
if (ret != OK) {
|
|
||||||
PRINT_ERR("Can't to mount to this inode %s\n", target);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZpfsConfig *zpfsCfg = (ZpfsConfig*) malloc(sizeof(struct ZpfsConfig));
|
|
||||||
if (zpfsCfg == NULL) {
|
|
||||||
PRINT_ERR("Memory is not enought.\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
(void)memset_s(zpfsCfg, sizeof(struct ZpfsConfig), 0, sizeof(struct ZpfsConfig));
|
|
||||||
|
|
||||||
/* Save the patch global data */
|
|
||||||
ret = SaveZpfsParameter(source, target, zpfsCfg);
|
|
||||||
if (ret != OK) {
|
|
||||||
ZpfsFreeConfig(zpfsCfg);
|
|
||||||
PRINT_ERR("Memory is not enought.\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create the patch inode */
|
|
||||||
ret = inode_reserve_rootdir(target, inodePtr, force);
|
|
||||||
if (ret != OK) {
|
|
||||||
ZpfsFreeConfig(zpfsCfg);
|
|
||||||
PRINT_ERR("failed to create mounted inode.\n");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
zpfsCfg->patchInode = *inodePtr;
|
|
||||||
(*inodePtr)->i_private = zpfsCfg;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: ZpfsCleanUp
|
|
||||||
* Description:
|
|
||||||
* Clean the configuration of zpfs.
|
|
||||||
* Input Parameters:
|
|
||||||
* target: The mount path
|
|
||||||
* Returned Value:
|
|
||||||
* void
|
|
||||||
****************************************************************************/
|
|
||||||
void ZpfsCleanUp(const void *node, const char *target)
|
|
||||||
{
|
|
||||||
struct statfs buf;
|
|
||||||
struct inode *inode = (struct inode *)node;
|
|
||||||
if ((target == NULL) || (inode == NULL) ||
|
|
||||||
(inode->u.i_mops == NULL) ||
|
|
||||||
(inode->u.i_mops->statfs == NULL)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (inode->u.i_mops->statfs(inode, &buf) == OK) {
|
|
||||||
if (buf.f_type == ZPFS_MAGIC) {
|
|
||||||
ZpfsConfig *zpfsCfg = inode->i_private;
|
|
||||||
if (strcmp(zpfsCfg->patchTarget, target) == 0) {
|
|
||||||
ZpfsFreeConfig(zpfsCfg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsZpfsFileSystem(struct inode *inode)
|
|
||||||
{
|
|
||||||
struct statfs buf;
|
|
||||||
if (inode == NULL || inode->u.i_mops == NULL ||
|
|
||||||
inode->u.i_mops->statfs == NULL) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (inode->u.i_mops->statfs(inode, &buf) == OK) {
|
|
||||||
if (buf.f_type == ZPFS_MAGIC) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LOSCFG_FS_ZPFS
|
|
||||||
+78
-2
@@ -110,12 +110,88 @@ config KERNEL_VDSO
|
|||||||
help
|
help
|
||||||
If you wish to speed up some system calls.
|
If you wish to speed up some system calls.
|
||||||
|
|
||||||
|
config KERNEL_HOOK
|
||||||
|
bool "Enable Hook Feature"
|
||||||
|
default n
|
||||||
|
depends on KERNEL_EXTKERNEL && DEBUG_VERSION
|
||||||
|
|
||||||
config KERNEL_TRACE
|
config KERNEL_TRACE
|
||||||
bool "Enable Trace Feature"
|
bool "Enable Trace Feature"
|
||||||
default n
|
default n
|
||||||
depends on KERNEL_EXTKERNEL && DEBUG_VERSION
|
depends on KERNEL_HOOK
|
||||||
|
|
||||||
|
config TRACE_MSG_EXTEND
|
||||||
|
bool "Enable Record more extended content"
|
||||||
|
default n
|
||||||
|
depends on KERNEL_TRACE
|
||||||
|
|
||||||
|
config TRACE_FRAME_CORE_MSG
|
||||||
|
bool "Record cpuid, hardware interrupt status, task lock status"
|
||||||
|
default n
|
||||||
|
depends on TRACE_MSG_EXTEND
|
||||||
|
|
||||||
|
config TRACE_FRAME_EVENT_COUNT
|
||||||
|
bool "Record event count, which indicate the sequence of happend events"
|
||||||
|
default n
|
||||||
|
depends on TRACE_MSG_EXTEND
|
||||||
|
|
||||||
|
config TRACE_FRAME_MAX_PARAMS
|
||||||
|
int "Record max params"
|
||||||
|
default 3
|
||||||
|
depends on KERNEL_TRACE
|
||||||
help
|
help
|
||||||
If you wish to record LiteOS's task and interrupt switch trace.
|
Make sure the max value is bigger than the number defined by each #MODULE#_#TYPE#_PARMAS in los_trace.h, e.g. TASK_SWITCH_PARAMS
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Trace work mode"
|
||||||
|
default RECORDER_MODE_OFFLINE
|
||||||
|
depends on KERNEL_TRACE
|
||||||
|
|
||||||
|
config RECORDER_MODE_ONLINE
|
||||||
|
bool "Online mode"
|
||||||
|
select TRACE_CLIENT_INTERACT
|
||||||
|
|
||||||
|
config RECORDER_MODE_OFFLINE
|
||||||
|
bool "Offline mode"
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config TRACE_BUFFER_SIZE
|
||||||
|
int "Trace record buffer size"
|
||||||
|
default 10000
|
||||||
|
|
||||||
|
config TRACE_CLIENT_INTERACT
|
||||||
|
bool "Enable Trace Client Visualization and Control"
|
||||||
|
default n
|
||||||
|
depends on KERNEL_TRACE
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Trace Pipeline for Data Transmission"
|
||||||
|
depends on TRACE_CLIENT_INTERACT
|
||||||
|
|
||||||
|
config TRACE_PIPELINE_SERIAL
|
||||||
|
bool "Via Serial"
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Trace Control"
|
||||||
|
default TRACE_CONTROL_VIA_SHELL
|
||||||
|
depends on TRACE_CLIENT_INTERACT
|
||||||
|
help
|
||||||
|
If you wish to control Trace's start/stop etc.,dynamically by Trace Client.
|
||||||
|
|
||||||
|
config TRACE_CONTROL_VIA_SHELL
|
||||||
|
bool "Via Shell"
|
||||||
|
select LOSCFG_SHELL
|
||||||
|
|
||||||
|
config TRACE_CONTROL_AGENT
|
||||||
|
bool "Via Trace Agent Task"
|
||||||
|
|
||||||
|
config TRACE_NO_CONTROL
|
||||||
|
bool "No Control"
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
config KERNEL_SHM
|
config KERNEL_SHM
|
||||||
bool "Enable Shared Memory"
|
bool "Enable Shared Memory"
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ kernel_module(module_name) {
|
|||||||
"core/los_sys.c",
|
"core/los_sys.c",
|
||||||
"core/los_task.c",
|
"core/los_task.c",
|
||||||
"core/los_tick.c",
|
"core/los_tick.c",
|
||||||
|
"core/los_smp.c",
|
||||||
"ipc/los_event.c",
|
"ipc/los_event.c",
|
||||||
"ipc/los_futex.c",
|
"ipc/los_futex.c",
|
||||||
"ipc/los_ipcdebug.c",
|
"ipc/los_ipcdebug.c",
|
||||||
|
|||||||
+150
-12
@@ -133,6 +133,59 @@ STATIC ProcessGroup *OsFindProcessGroup(UINT32 gid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC INT32 OsSendSignalToSpecifyProcessGroup(ProcessGroup *group, siginfo_t *info, INT32 permission)
|
||||||
|
{
|
||||||
|
INT32 ret, success, err;
|
||||||
|
LosProcessCB *childCB = NULL;
|
||||||
|
|
||||||
|
success = 0;
|
||||||
|
ret = -LOS_ESRCH;
|
||||||
|
LOS_DL_LIST_FOR_EACH_ENTRY(childCB, &(group->processList), LosProcessCB, subordinateGroupList) {
|
||||||
|
if (childCB->processID == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = OsDispatch(childCB->processID, info, permission);
|
||||||
|
success |= !err;
|
||||||
|
ret = err;
|
||||||
|
}
|
||||||
|
/* At least one success. */
|
||||||
|
return success ? LOS_OK : ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT INT32 OsSendSignalToAllProcess(siginfo_t *info, INT32 permission)
|
||||||
|
{
|
||||||
|
INT32 ret, success, err;
|
||||||
|
ProcessGroup *group = NULL;
|
||||||
|
|
||||||
|
success = 0;
|
||||||
|
err = OsSendSignalToSpecifyProcessGroup(g_processGroup, info, permission);
|
||||||
|
success |= !err;
|
||||||
|
ret = err;
|
||||||
|
/* all processes group */
|
||||||
|
LOS_DL_LIST_FOR_EACH_ENTRY(group, &g_processGroup->groupList, ProcessGroup, groupList) {
|
||||||
|
/* all processes in the process group. */
|
||||||
|
err = OsSendSignalToSpecifyProcessGroup(group, info, permission);
|
||||||
|
success |= !err;
|
||||||
|
ret = err;
|
||||||
|
}
|
||||||
|
return success ? LOS_OK : ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT INT32 OsSendSignalToProcessGroup(INT32 pid, siginfo_t *info, INT32 permission)
|
||||||
|
{
|
||||||
|
ProcessGroup *group = NULL;
|
||||||
|
/* Send SIG to all processes in process group PGRP.
|
||||||
|
If PGRP is zero, send SIG to all processes in
|
||||||
|
the current process's process group. */
|
||||||
|
group = OsFindProcessGroup(pid ? -pid : LOS_GetCurrProcessGroupID());
|
||||||
|
if (group == NULL) {
|
||||||
|
return -LOS_ESRCH;
|
||||||
|
}
|
||||||
|
/* all processes in the process group. */
|
||||||
|
return OsSendSignalToSpecifyProcessGroup(group, info, permission);
|
||||||
|
}
|
||||||
|
|
||||||
STATIC LosProcessCB *OsFindGroupExitProcess(ProcessGroup *group, INT32 pid)
|
STATIC LosProcessCB *OsFindGroupExitProcess(ProcessGroup *group, INT32 pid)
|
||||||
{
|
{
|
||||||
LosProcessCB *childCB = NULL;
|
LosProcessCB *childCB = NULL;
|
||||||
@@ -289,6 +342,12 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
|
|||||||
OsCurrProcessGet()->processID, processCB->processID);
|
OsCurrProcessGet()->processID, processCB->processID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef LOSCFG_KERNEL_VM
|
||||||
|
if (OsProcessIsUserMode(processCB)) {
|
||||||
|
(VOID)OsVmSpaceRegionFree(processCB->vmSpace);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef LOSCFG_FS_VFS
|
#ifdef LOSCFG_FS_VFS
|
||||||
if (OsProcessIsUserMode(processCB)) {
|
if (OsProcessIsUserMode(processCB)) {
|
||||||
delete_files(processCB->files);
|
delete_files(processCB->files);
|
||||||
@@ -315,7 +374,7 @@ LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
|
|||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||||
if (OsProcessIsUserMode(processCB)) {
|
if (OsProcessIsUserMode(processCB)) {
|
||||||
LiteIpcPoolDelete(&(processCB->ipcInfo));
|
LiteIpcPoolDelete(&(processCB->ipcInfo), processCB->processID);
|
||||||
(VOID)memset_s(&(processCB->ipcInfo), sizeof(ProcIpcInfo), 0, sizeof(ProcIpcInfo));
|
(VOID)memset_s(&(processCB->ipcInfo), sizeof(ProcIpcInfo), 0, sizeof(ProcIpcInfo));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -493,11 +552,11 @@ LITE_OS_SEC_TEXT VOID OsProcessCBRecycleToFree(VOID)
|
|||||||
/* Clear the bottom 4 bits of process status */
|
/* Clear the bottom 4 bits of process status */
|
||||||
OsInsertPCBToFreeList(processCB);
|
OsInsertPCBToFreeList(processCB);
|
||||||
}
|
}
|
||||||
SCHEDULER_UNLOCK(intSave);
|
|
||||||
#ifdef LOSCFG_KERNEL_VM
|
#ifdef LOSCFG_KERNEL_VM
|
||||||
|
SCHEDULER_UNLOCK(intSave);
|
||||||
(VOID)LOS_VmSpaceFree(space);
|
(VOID)LOS_VmSpaceFree(space);
|
||||||
#endif
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
@@ -1006,12 +1065,19 @@ WAIT_BACK:
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC UINT32 OsWaitRecycleChildProcess(const LosProcessCB *childCB, UINT32 intSave, INT32 *status)
|
STATIC UINT32 OsWaitRecycleChildProcess(const LosProcessCB *childCB, UINT32 intSave, INT32 *status, siginfo_t *info)
|
||||||
{
|
{
|
||||||
ProcessGroup *group = NULL;
|
ProcessGroup *group = NULL;
|
||||||
UINT32 pid = childCB->processID;
|
UINT32 pid = childCB->processID;
|
||||||
UINT16 mode = childCB->processMode;
|
UINT16 mode = childCB->processMode;
|
||||||
INT32 exitCode = childCB->exitCode;
|
INT32 exitCode = childCB->exitCode;
|
||||||
|
UINT32 uid = 0;
|
||||||
|
|
||||||
|
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||||
|
if (childCB->user != NULL) {
|
||||||
|
uid = childCB->user->userID;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
OsRecycleZombiesProcess((LosProcessCB *)childCB, &group);
|
OsRecycleZombiesProcess((LosProcessCB *)childCB, &group);
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
@@ -1023,7 +1089,33 @@ STATIC UINT32 OsWaitRecycleChildProcess(const LosProcessCB *childCB, UINT32 intS
|
|||||||
*status = exitCode;
|
*status = exitCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* get signal info */
|
||||||
|
if (info != NULL) {
|
||||||
|
siginfo_t tempinfo = { 0 };
|
||||||
|
|
||||||
|
tempinfo.si_signo = SIGCHLD;
|
||||||
|
tempinfo.si_errno = 0;
|
||||||
|
tempinfo.si_pid = pid;
|
||||||
|
tempinfo.si_uid = uid;
|
||||||
|
/*
|
||||||
|
* Process exit code
|
||||||
|
* 31 15 8 7 0
|
||||||
|
* | | exit code | core dump | signal |
|
||||||
|
*/
|
||||||
|
if ((exitCode & 0x7f) == 0) {
|
||||||
|
tempinfo.si_code = CLD_EXITED;
|
||||||
|
tempinfo.si_status = (exitCode >> 8U);
|
||||||
|
} else {
|
||||||
|
tempinfo.si_code = (exitCode & 0x80) ? CLD_DUMPED : CLD_KILLED;
|
||||||
|
tempinfo.si_status = (exitCode & 0x7f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode == OS_USER_MODE) {
|
||||||
|
(VOID)LOS_ArchCopyToUser((VOID *)(info), (const VOID *)(&(tempinfo)), sizeof(siginfo_t));
|
||||||
|
} else {
|
||||||
|
(VOID)memcpy_s((VOID *)(info), sizeof(siginfo_t), (const VOID *)(&(tempinfo)), sizeof(siginfo_t));
|
||||||
|
}
|
||||||
|
}
|
||||||
(VOID)LOS_MemFree(m_aucSysMem1, group);
|
(VOID)LOS_MemFree(m_aucSysMem1, group);
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
@@ -1057,7 +1149,7 @@ STATIC UINT32 OsWaitOptionsCheck(UINT32 options)
|
|||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, VOID *rusage)
|
STATIC INT32 OsWait(INT32 pid, USER INT32 *status, USER siginfo_t *info, UINT32 options, VOID *rusage)
|
||||||
{
|
{
|
||||||
(VOID)rusage;
|
(VOID)rusage;
|
||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
@@ -1066,11 +1158,6 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
|
|||||||
LosProcessCB *processCB = NULL;
|
LosProcessCB *processCB = NULL;
|
||||||
LosTaskCB *runTask = NULL;
|
LosTaskCB *runTask = NULL;
|
||||||
|
|
||||||
ret = OsWaitOptionsCheck(options);
|
|
||||||
if (ret != LOS_OK) {
|
|
||||||
return -ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
processCB = OsCurrProcessGet();
|
processCB = OsCurrProcessGet();
|
||||||
runTask = OsCurrTaskGet();
|
runTask = OsCurrTaskGet();
|
||||||
@@ -1082,7 +1169,7 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (childCB != NULL) {
|
if (childCB != NULL) {
|
||||||
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status);
|
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((options & LOS_WAIT_WNOHANG) != 0) {
|
if ((options & LOS_WAIT_WNOHANG) != 0) {
|
||||||
@@ -1105,13 +1192,64 @@ LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, V
|
|||||||
goto ERROR;
|
goto ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status);
|
return (INT32)OsWaitRecycleChildProcess(childCB, intSave, status, info);
|
||||||
|
|
||||||
ERROR:
|
ERROR:
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT INT32 LOS_Wait(INT32 pid, USER INT32 *status, UINT32 options, VOID *rusage)
|
||||||
|
{
|
||||||
|
(VOID)rusage;
|
||||||
|
UINT32 ret;
|
||||||
|
|
||||||
|
ret = OsWaitOptionsCheck(options);
|
||||||
|
if (ret != LOS_OK) {
|
||||||
|
return -ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OsWait(pid, status, NULL, options, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC UINT32 OsWaitidOptionsCheck(UINT32 options)
|
||||||
|
{
|
||||||
|
UINT32 flag = LOS_WAIT_WNOHANG | LOS_WAIT_WSTOPPED | LOS_WAIT_WCONTINUED | LOS_WAIT_WEXITED | LOS_WAIT_WNOWAIT;
|
||||||
|
|
||||||
|
flag = ~flag & options;
|
||||||
|
if ((flag != 0) || (options == 0)) {
|
||||||
|
return LOS_EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* only support LOS_WAIT_WNOHANG | LOS_WAIT_WEXITED
|
||||||
|
* notsupport LOS_WAIT_WSTOPPED | LOS_WAIT_WCONTINUED | LOS_WAIT_WNOWAIT
|
||||||
|
*/
|
||||||
|
if ((options & (LOS_WAIT_WSTOPPED | LOS_WAIT_WCONTINUED | LOS_WAIT_WNOWAIT)) != 0) {
|
||||||
|
return LOS_EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OS_INT_ACTIVE) {
|
||||||
|
return LOS_EINTR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
LITE_OS_SEC_TEXT INT32 LOS_Waitid(INT32 pid, USER siginfo_t *info, UINT32 options, VOID *rusage)
|
||||||
|
{
|
||||||
|
(VOID)rusage;
|
||||||
|
UINT32 ret;
|
||||||
|
|
||||||
|
/* check options value */
|
||||||
|
ret = OsWaitidOptionsCheck(options);
|
||||||
|
if (ret != LOS_OK) {
|
||||||
|
return -ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OsWait(pid, NULL, info, options, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
STATIC UINT32 OsSetProcessGroupCheck(const LosProcessCB *processCB, UINT32 gid)
|
STATIC UINT32 OsSetProcessGroupCheck(const LosProcessCB *processCB, UINT32 gid)
|
||||||
{
|
{
|
||||||
LosProcessCB *runProcessCB = OsCurrProcessGet();
|
LosProcessCB *runProcessCB = OsCurrProcessGet();
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||||
|
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "los_smp.h"
|
||||||
|
#include "arch_config.h"
|
||||||
|
#include "los_atomic.h"
|
||||||
|
#include "los_task_pri.h"
|
||||||
|
#include "los_init_pri.h"
|
||||||
|
#include "los_process_pri.h"
|
||||||
|
#include "los_sched_pri.h"
|
||||||
|
#include "los_swtmr_pri.h"
|
||||||
|
|
||||||
|
#ifdef LOSCFG_KERNEL_SMP
|
||||||
|
STATIC struct SmpOps *g_smpOps = NULL;
|
||||||
|
|
||||||
|
STATIC VOID OsSmpSecondaryInit(VOID *arg)
|
||||||
|
{
|
||||||
|
UNUSED(arg);
|
||||||
|
OsInitCall(LOS_INIT_LEVEL_PLATFORM);
|
||||||
|
|
||||||
|
OsCurrProcessSet(OS_PCB_FROM_PID(OsGetKernelInitProcessID()));
|
||||||
|
OsInitCall(LOS_INIT_LEVEL_KMOD_BASIC);
|
||||||
|
|
||||||
|
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
||||||
|
OsSwtmrInit();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
OsInitCall(LOS_INIT_LEVEL_KMOD_EXTENDED);
|
||||||
|
|
||||||
|
OsIdleTaskCreate();
|
||||||
|
OsInitCall(LOS_INIT_LEVEL_KMOD_TASK);
|
||||||
|
|
||||||
|
OsSchedStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID LOS_SmpOpsSet(struct SmpOps *ops)
|
||||||
|
{
|
||||||
|
g_smpOps = ops;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID OsSmpInit(VOID)
|
||||||
|
{
|
||||||
|
UINT32 cpuNum = 1; /* Start the secondary cpus. */
|
||||||
|
|
||||||
|
if (g_smpOps == NULL) {
|
||||||
|
PRINT_ERR("Must call the interface(LOS_SmpOpsSet) to register smp operations firstly!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; cpuNum < CORE_NUM; cpuNum++) {
|
||||||
|
HalArchCpuOn(cpuNum, OsSmpSecondaryInit, g_smpOps, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "los_sched_pri.h"
|
#include "los_sched_pri.h"
|
||||||
#include "los_sortlink_pri.h"
|
#include "los_sortlink_pri.h"
|
||||||
#include "los_task_pri.h"
|
#include "los_task_pri.h"
|
||||||
|
#include "los_hook.h"
|
||||||
|
|
||||||
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
||||||
#if (LOSCFG_BASE_CORE_SWTMR_LIMIT <= 0)
|
#if (LOSCFG_BASE_CORE_SWTMR_LIMIT <= 0)
|
||||||
@@ -268,7 +268,8 @@ LITE_OS_SEC_TEXT VOID OsSwtmrScan(VOID)
|
|||||||
swtmr->startTime = GET_SORTLIST_VALUE(sortList);
|
swtmr->startTime = GET_SORTLIST_VALUE(sortList);
|
||||||
OsDeleteNodeSortLink(swtmrSortLink, sortList);
|
OsDeleteNodeSortLink(swtmrSortLink, sortList);
|
||||||
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
||||||
|
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
|
||||||
OsWakePendTimeSwtmr(cpu, currTime, swtmr);
|
OsWakePendTimeSwtmr(cpu, currTime, swtmr);
|
||||||
|
|
||||||
LOS_SpinLock(&cpu->swtmrSortLinkSpin);
|
LOS_SpinLock(&cpu->swtmrSortLinkSpin);
|
||||||
@@ -362,7 +363,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval,
|
|||||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||||
SET_SORTLIST_VALUE(&swtmr->stSortList, OS_SORT_LINK_INVALID_TIME);
|
SET_SORTLIST_VALUE(&swtmr->stSortList, OS_SORT_LINK_INVALID_TIME);
|
||||||
*swtmrID = swtmr->usTimerID;
|
*swtmrID = swtmr->usTimerID;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SWTMR_CREATE, swtmr);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,6 +408,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SWTMR_UNLOCK(intSave);
|
SWTMR_UNLOCK(intSave);
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SWTMR_START, swtmr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,6 +448,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStop(UINT16 swtmrID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SWTMR_UNLOCK(intSave);
|
SWTMR_UNLOCK(intSave);
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SWTMR_STOP, swtmr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,6 +529,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SWTMR_UNLOCK(intSave);
|
SWTMR_UNLOCK(intSave);
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SWTMR_DELETE, swtmr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
#include "los_vm_map.h"
|
#include "los_vm_map.h"
|
||||||
#include "los_vm_syscall.h"
|
#include "los_vm_syscall.h"
|
||||||
#include "los_signal.h"
|
#include "los_signal.h"
|
||||||
|
#include "los_hook.h"
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
#ifdef LOSCFG_KERNEL_CPUP
|
||||||
#include "los_cpup_pri.h"
|
#include "los_cpup_pri.h"
|
||||||
@@ -208,10 +209,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
|
|||||||
LOS_ListTailInsert(&g_losFreeTask, &g_taskCBArray[index].pendList);
|
LOS_ListTailInsert(&g_losFreeTask, &g_taskCBArray[index].pendList);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
LOS_TraceReg(LOS_TRACE_TASK, OsTaskTrace, LOS_TRACE_TASK_NAME, LOS_TRACE_ENABLE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = OsSchedInit();
|
ret = OsSchedInit();
|
||||||
|
|
||||||
EXIT:
|
EXIT:
|
||||||
@@ -501,6 +498,7 @@ LITE_OS_SEC_TEXT VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
|||||||
OsTaskKernelResourcesToFree(syncSignal, topOfStack);
|
OsTaskKernelResourcesToFree(syncSignal, topOfStack);
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
|
OsClearSigInfoTmpList(&(taskCB->sig));
|
||||||
OsInsertTCBToFreeList(taskCB);
|
OsInsertTCBToFreeList(taskCB);
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
}
|
}
|
||||||
@@ -652,6 +650,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S
|
|||||||
}
|
}
|
||||||
|
|
||||||
*taskID = taskCB->taskID;
|
*taskID = taskCB->taskID;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_TASK_CREATE, taskCB);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
||||||
LOS_ERREND_TCB_INIT:
|
LOS_ERREND_TCB_INIT:
|
||||||
@@ -820,7 +819,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 OsTaskSuspend(LosTaskCB *taskCB)
|
|||||||
}
|
}
|
||||||
|
|
||||||
taskCB->taskStatus |= OS_TASK_STATUS_SUSPENDED;
|
taskCB->taskStatus |= OS_TASK_STATUS_SUSPENDED;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTOSUSPENDEDLIST, taskCB);
|
||||||
if (taskCB == OsCurrTaskGet()) {
|
if (taskCB == OsCurrTaskGet()) {
|
||||||
OsSchedResched();
|
OsSchedResched();
|
||||||
}
|
}
|
||||||
@@ -990,7 +989,7 @@ LITE_OS_SEC_TEXT UINT32 OsTaskDeleteUnsafe(LosTaskCB *taskCB, UINT32 status, UIN
|
|||||||
OsWriteResourceEvent(OS_RESOURCE_EVENT_FREE);
|
OsWriteResourceEvent(OS_RESOURCE_EVENT_FREE);
|
||||||
return errRet;
|
return errRet;
|
||||||
}
|
}
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_TASK_DELETE, taskCB);
|
||||||
if (mode == OS_USER_MODE) {
|
if (mode == OS_USER_MODE) {
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
OsTaskResourcesToFree(taskCB);
|
OsTaskResourcesToFree(taskCB);
|
||||||
@@ -1075,13 +1074,14 @@ LITE_OS_SEC_TEXT UINT32 LOS_TaskDelay(UINT32 tick)
|
|||||||
if (!OsPreemptable()) {
|
if (!OsPreemptable()) {
|
||||||
return LOS_ERRNO_TSK_DELAY_IN_LOCK;
|
return LOS_ERRNO_TSK_DELAY_IN_LOCK;
|
||||||
}
|
}
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_TASK_DELAY, tick);
|
||||||
if (tick == 0) {
|
if (tick == 0) {
|
||||||
return LOS_TaskYield();
|
return LOS_TaskYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
OsSchedDelay(runTask, tick);
|
OsSchedDelay(runTask, tick);
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTODELAYEDLIST, runTask);
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ typedef struct ProcessCB {
|
|||||||
TimerIdMap timerIdMap;
|
TimerIdMap timerIdMap;
|
||||||
#endif
|
#endif
|
||||||
#ifdef LOSCFG_DRIVERS_TZDRIVER
|
#ifdef LOSCFG_DRIVERS_TZDRIVER
|
||||||
struct file *execFile; /**< Exec bin of the process */
|
struct Vnode *execVnode; /**< Exec bin of the process */
|
||||||
#endif
|
#endif
|
||||||
mode_t umask;
|
mode_t umask;
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
#ifdef LOSCFG_KERNEL_CPUP
|
||||||
@@ -408,6 +408,12 @@ STATIC INLINE User *OsCurrUserGet(VOID)
|
|||||||
* if this option is not specified.
|
* if this option is not specified.
|
||||||
*/
|
*/
|
||||||
#define LOS_WAIT_WUNTRACED (1 << 1U)
|
#define LOS_WAIT_WUNTRACED (1 << 1U)
|
||||||
|
#define LOS_WAIT_WSTOPPED (1 << 1U)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wait for exited processes
|
||||||
|
*/
|
||||||
|
#define LOS_WAIT_WEXITED (1 << 2U)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return if a stopped child has been resumed by delivery of SIGCONT.
|
* return if a stopped child has been resumed by delivery of SIGCONT.
|
||||||
@@ -415,6 +421,12 @@ STATIC INLINE User *OsCurrUserGet(VOID)
|
|||||||
*/
|
*/
|
||||||
#define LOS_WAIT_WCONTINUED (1 << 3U)
|
#define LOS_WAIT_WCONTINUED (1 << 3U)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Leave the child in a waitable state;
|
||||||
|
* a later wait call can be used to again retrieve the child status information.
|
||||||
|
*/
|
||||||
|
#define LOS_WAIT_WNOWAIT (1 << 24U)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Indicates that you are already in a wait state
|
* Indicates that you are already in a wait state
|
||||||
*/
|
*/
|
||||||
@@ -464,6 +476,8 @@ extern UINT32 OsGetKernelInitProcessID(VOID);
|
|||||||
extern VOID OsSetSigHandler(UINTPTR addr);
|
extern VOID OsSetSigHandler(UINTPTR addr);
|
||||||
extern UINTPTR OsGetSigHandler(VOID);
|
extern UINTPTR OsGetSigHandler(VOID);
|
||||||
extern VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID);
|
extern VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID);
|
||||||
|
extern INT32 OsSendSignalToProcessGroup(INT32 pid, siginfo_t *info, INT32 permission);
|
||||||
|
extern INT32 OsSendSignalToAllProcess(siginfo_t *info, INT32 permission);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|||||||
@@ -132,6 +132,11 @@ struct sq_queue_s {
|
|||||||
};
|
};
|
||||||
typedef struct sq_queue_s sq_queue_t;
|
typedef struct sq_queue_s sq_queue_t;
|
||||||
|
|
||||||
|
typedef struct SigInfoListNode {
|
||||||
|
struct SigInfoListNode *next;
|
||||||
|
siginfo_t info;
|
||||||
|
} SigInfoListNode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
sigset_t sigFlag;
|
sigset_t sigFlag;
|
||||||
sigset_t sigPendFlag;
|
sigset_t sigPendFlag;
|
||||||
@@ -140,6 +145,7 @@ typedef struct {
|
|||||||
LOS_DL_LIST waitList;
|
LOS_DL_LIST waitList;
|
||||||
sigset_t sigwaitmask; /* Waiting for pending signals */
|
sigset_t sigwaitmask; /* Waiting for pending signals */
|
||||||
siginfo_t sigunbinfo; /* Signal info when task unblocked */
|
siginfo_t sigunbinfo; /* Signal info when task unblocked */
|
||||||
|
SigInfoListNode *tmpInfoListHead; /* Signal info List */
|
||||||
unsigned int sigIntLock;
|
unsigned int sigIntLock;
|
||||||
void *sigContext;
|
void *sigContext;
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
@@ -167,6 +173,7 @@ int OsSigSuspend(const sigset_t *set);
|
|||||||
VOID OsSigIntLock(VOID);
|
VOID OsSigIntLock(VOID);
|
||||||
VOID OsSigIntUnlock(VOID);
|
VOID OsSigIntUnlock(VOID);
|
||||||
INT32 OsTaskKillUnsafe(UINT32 taskID, INT32 signo);
|
INT32 OsTaskKillUnsafe(UINT32 taskID, INT32 signo);
|
||||||
|
VOID OsClearSigInfoTmpList(sig_cb *sigcb);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
|
|||||||
@@ -45,10 +45,6 @@
|
|||||||
#include "los_cpup_pri.h"
|
#include "los_cpup_pri.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
#include "los_trace.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -505,24 +501,12 @@ STATIC INLINE VOID OsTaskWaitSetPendMask(UINT16 mask, UINTPTR lockID, UINT32 tim
|
|||||||
runTask->waitID = lockID;
|
runTask->waitID = lockID;
|
||||||
runTask->waitFlag = mask;
|
runTask->waitFlag = mask;
|
||||||
(VOID)timeout;
|
(VOID)timeout;
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
UINT16 status = OS_TASK_STATUS_PENDING;
|
|
||||||
if (timeout != LOS_WAIT_FOREVER) {
|
|
||||||
status |= OS_TASK_STATUS_PEND_TIME;
|
|
||||||
}
|
|
||||||
LOS_Trace(LOS_TRACE_TASK, runTask->taskEntry, status, mask, lockID);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE VOID OsTaskWakeClearPendMask(LosTaskCB *resumeTask)
|
STATIC INLINE VOID OsTaskWakeClearPendMask(LosTaskCB *resumeTask)
|
||||||
{
|
{
|
||||||
resumeTask->waitID = 0;
|
resumeTask->waitID = 0;
|
||||||
resumeTask->waitFlag = 0;
|
resumeTask->waitFlag = 0;
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
LosTaskCB *runTask = OsCurrTaskGet();
|
|
||||||
LOS_Trace(LOS_TRACE_TASK, resumeTask->taskEntry, (UINT16)OS_TASK_STATUS_READY,
|
|
||||||
runTask->taskStatus, runTask->taskEntry);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern UINT32 OsTaskSetDetachUnsafe(LosTaskCB *taskCB);
|
extern UINT32 OsTaskSetDetachUnsafe(LosTaskCB *taskCB);
|
||||||
@@ -559,23 +543,6 @@ extern VOID OsWriteResourceEvent(UINT32 events);
|
|||||||
extern VOID OsWriteResourceEventUnsafe(UINT32 events);
|
extern VOID OsWriteResourceEventUnsafe(UINT32 events);
|
||||||
extern UINT32 OsResourceFreeTaskCreate(VOID);
|
extern UINT32 OsResourceFreeTaskCreate(VOID);
|
||||||
|
|
||||||
#ifdef LOSCFG_DEBUG_VERSION
|
|
||||||
STATIC INLINE VOID OsTraceTaskSchedule(LosTaskCB *newTask, LosTaskCB *runTask)
|
|
||||||
{
|
|
||||||
(VOID)newTask;
|
|
||||||
(VOID)runTask;
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
LOS_Trace(LOS_TRACE_TASK, newTask->taskEntry, (UINT16)OS_TASK_STATUS_RUNNING,
|
|
||||||
runTask->taskStatus, runTask->taskEntry);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define OsTraceTaskSchedule(newTask, runTask)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ typedef struct ArchMmuInitMapping {
|
|||||||
const char *name;
|
const char *name;
|
||||||
} LosArchMmuInitMapping;
|
} LosArchMmuInitMapping;
|
||||||
|
|
||||||
|
extern LosArchMmuInitMapping g_archMmuInitMapping[];
|
||||||
|
|
||||||
extern UINTPTR g_vmBootMemBase;
|
extern UINTPTR g_vmBootMemBase;
|
||||||
extern BOOL g_kHeapInited;
|
extern BOOL g_kHeapInited;
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
#include "los_vm_zone.h"
|
#include "los_vm_zone.h"
|
||||||
#include "los_vm_common.h"
|
#include "los_vm_common.h"
|
||||||
|
|
||||||
|
struct Vnode;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#if __cplusplus
|
#if __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -91,8 +93,8 @@ struct VmMapRegion {
|
|||||||
UINT8 regionType; /**< vm region type: ANON, FILE, DEV */
|
UINT8 regionType; /**< vm region type: ANON, FILE, DEV */
|
||||||
union {
|
union {
|
||||||
struct VmRegionFile {
|
struct VmRegionFile {
|
||||||
unsigned int fileMagic;
|
int f_oflags;
|
||||||
struct file *file;
|
struct Vnode *vnode;
|
||||||
const LosVmFileOps *vmFOps;
|
const LosVmFileOps *vmFOps;
|
||||||
} rf;
|
} rf;
|
||||||
struct VmRegionAnon {
|
struct VmRegionAnon {
|
||||||
@@ -290,6 +292,8 @@ LosVmSpace *OsCreateUserVmSpace(VOID);
|
|||||||
STATUS_T LOS_VmSpaceClone(LosVmSpace *oldVmSpace, LosVmSpace *newVmSpace);
|
STATUS_T LOS_VmSpaceClone(LosVmSpace *oldVmSpace, LosVmSpace *newVmSpace);
|
||||||
LosMux *OsGVmSpaceMuxGet(VOID);
|
LosMux *OsGVmSpaceMuxGet(VOID);
|
||||||
STATUS_T OsUnMMap(LosVmSpace *space, VADDR_T addr, size_t size);
|
STATUS_T OsUnMMap(LosVmSpace *space, VADDR_T addr, size_t size);
|
||||||
|
STATUS_T OsVmSpaceRegionFree(LosVmSpace *space);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* thread safety
|
* thread safety
|
||||||
* it is used to malloc continuous virtual memory, no sure for continuous physical memory.
|
* it is used to malloc continuous virtual memory, no sure for continuous physical memory.
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "los_mp.h"
|
#include "los_mp.h"
|
||||||
#include "los_percpu_pri.h"
|
#include "los_percpu_pri.h"
|
||||||
#include "los_sched_pri.h"
|
#include "los_sched_pri.h"
|
||||||
|
#include "los_hook.h"
|
||||||
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
||||||
#include "los_exc.h"
|
#include "los_exc.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -51,6 +52,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_EventInit(PEVENT_CB_S eventCB)
|
|||||||
eventCB->uwEventID = 0;
|
eventCB->uwEventID = 0;
|
||||||
LOS_ListInit(&eventCB->stEventList);
|
LOS_ListInit(&eventCB->stEventList);
|
||||||
LOS_IntRestore(intSave);
|
LOS_IntRestore(intSave);
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_EVENT_INIT, eventCB);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +128,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 OsEventReadImp(PEVENT_CB_S eventCB, UINT32 eventM
|
|||||||
{
|
{
|
||||||
UINT32 ret = 0;
|
UINT32 ret = 0;
|
||||||
LosTaskCB *runTask = OsCurrTaskGet();
|
LosTaskCB *runTask = OsCurrTaskGet();
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_EVENT_READ, eventCB, eventMask, mode, timeout);
|
||||||
|
|
||||||
if (once == FALSE) {
|
if (once == FALSE) {
|
||||||
ret = OsEventPoll(&eventCB->uwEventID, eventMask, mode);
|
ret = OsEventPoll(&eventCB->uwEventID, eventMask, mode);
|
||||||
@@ -193,7 +196,7 @@ LITE_OS_SEC_TEXT VOID OsEventWriteUnsafe(PEVENT_CB_S eventCB, UINT32 events, BOO
|
|||||||
LosTaskCB *resumedTask = NULL;
|
LosTaskCB *resumedTask = NULL;
|
||||||
LosTaskCB *nextTask = NULL;
|
LosTaskCB *nextTask = NULL;
|
||||||
BOOL schedFlag = FALSE;
|
BOOL schedFlag = FALSE;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_EVENT_WRITE, eventCB, events);
|
||||||
eventCB->uwEventID |= events;
|
eventCB->uwEventID |= events;
|
||||||
if (!LOS_ListEmpty(&eventCB->stEventList)) {
|
if (!LOS_ListEmpty(&eventCB->stEventList)) {
|
||||||
for (resumedTask = LOS_DL_LIST_ENTRY((&eventCB->stEventList)->pstNext, LosTaskCB, pendList);
|
for (resumedTask = LOS_DL_LIST_ENTRY((&eventCB->stEventList)->pstNext, LosTaskCB, pendList);
|
||||||
@@ -292,7 +295,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_EventDestroy(PEVENT_CB_S eventCB)
|
|||||||
eventCB->uwEventID = 0;
|
eventCB->uwEventID = 0;
|
||||||
LOS_ListDelInit(&eventCB->stEventList);
|
LOS_ListDelInit(&eventCB->stEventList);
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_EVENT_DESTROY, eventCB);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,6 +306,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_EventClear(PEVENT_CB_S eventCB, UINT32 eventMa
|
|||||||
if (eventCB == NULL) {
|
if (eventCB == NULL) {
|
||||||
return LOS_ERRNO_EVENT_PTR_NULL;
|
return LOS_ERRNO_EVENT_PTR_NULL;
|
||||||
}
|
}
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_EVENT_CLEAR, eventCB, eventMask);
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
eventCB->uwEventID &= eventMask;
|
eventCB->uwEventID &= eventMask;
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "los_spinlock.h"
|
#include "los_spinlock.h"
|
||||||
#include "los_mp.h"
|
#include "los_mp.h"
|
||||||
#include "los_percpu_pri.h"
|
#include "los_percpu_pri.h"
|
||||||
|
#include "los_hook.h"
|
||||||
|
|
||||||
#ifdef LOSCFG_BASE_IPC_QUEUE
|
#ifdef LOSCFG_BASE_IPC_QUEUE
|
||||||
#if (LOSCFG_BASE_IPC_QUEUE_LIMIT <= 0)
|
#if (LOSCFG_BASE_IPC_QUEUE_LIMIT <= 0)
|
||||||
@@ -137,6 +137,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueCreate(CHAR *queueName, UINT16 len, UINT32
|
|||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
|
||||||
*queueID = queueCB->queueID;
|
*queueID = queueCB->queueID;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_QUEUE_CREATE, queueCB);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,6 +264,7 @@ UINT32 OsQueueOperate(UINT32 queueID, UINT32 operateType, VOID *bufferAddr, UINT
|
|||||||
UINT32 ret;
|
UINT32 ret;
|
||||||
UINT32 readWrite = OS_QUEUE_READ_WRITE_GET(operateType);
|
UINT32 readWrite = OS_QUEUE_READ_WRITE_GET(operateType);
|
||||||
UINT32 intSave;
|
UINT32 intSave;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_QUEUE_READ, (LosQueueCB *)GET_QUEUE_HANDLE(queueID), operateType, *bufferSize, timeout);
|
||||||
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
queueCB = (LosQueueCB *)GET_QUEUE_HANDLE(queueID);
|
queueCB = (LosQueueCB *)GET_QUEUE_HANDLE(queueID);
|
||||||
@@ -435,7 +437,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_QueueDelete(UINT32 queueID)
|
|||||||
|
|
||||||
LOS_ListTailInsert(&g_freeQueueList, &queueCB->readWriteList[OS_QUEUE_WRITE]);
|
LOS_ListTailInsert(&g_freeQueueList, &queueCB->readWriteList[OS_QUEUE_WRITE]);
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_QUEUE_DELETE, queueCB);
|
||||||
ret = LOS_MemFree(m_aucSysMem1, (VOID *)queue);
|
ret = LOS_MemFree(m_aucSysMem1, (VOID *)queue);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#include "los_spinlock.h"
|
#include "los_spinlock.h"
|
||||||
#include "los_mp.h"
|
#include "los_mp.h"
|
||||||
#include "los_percpu_pri.h"
|
#include "los_percpu_pri.h"
|
||||||
|
#include "los_hook.h"
|
||||||
|
|
||||||
#ifdef LOSCFG_BASE_IPC_SEM
|
#ifdef LOSCFG_BASE_IPC_SEM
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSemCreate(UINT16 count, UINT16 maxCount, UINT32 *
|
|||||||
semCreated->maxSemCount = maxCount;
|
semCreated->maxSemCount = maxCount;
|
||||||
LOS_ListInit(&semCreated->semList);
|
LOS_ListInit(&semCreated->semList);
|
||||||
*semHandle = semCreated->semID;
|
*semHandle = semCreated->semID;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SEM_CREATE, semCreated);
|
||||||
OsSemDbgUpdateHook(semCreated->semID, OsCurrTaskGet()->taskEntry, count);
|
OsSemDbgUpdateHook(semCreated->semID, OsCurrTaskGet()->taskEntry, count);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
|
|
||||||
@@ -165,6 +165,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_SemDelete(UINT32 semHandle)
|
|||||||
semDeleted->semStat = OS_SEM_UNUSED;
|
semDeleted->semStat = OS_SEM_UNUSED;
|
||||||
semDeleted->semID = SET_SEM_ID(GET_SEM_COUNT(semDeleted->semID) + 1, GET_SEM_INDEX(semDeleted->semID));
|
semDeleted->semID = SET_SEM_ID(GET_SEM_COUNT(semDeleted->semID) + 1, GET_SEM_INDEX(semDeleted->semID));
|
||||||
|
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SEM_DELETE, semDeleted);
|
||||||
OsSemDbgUpdateHook(semDeleted->semID, NULL, 0);
|
OsSemDbgUpdateHook(semDeleted->semID, NULL, 0);
|
||||||
|
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
@@ -203,12 +204,12 @@ LITE_OS_SEC_TEXT UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout)
|
|||||||
retErr = LOS_ERRNO_SEM_INVALID;
|
retErr = LOS_ERRNO_SEM_INVALID;
|
||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the operate time, no matter the actual Pend success or not */
|
/* Update the operate time, no matter the actual Pend success or not */
|
||||||
OsSemDbgTimeUpdateHook(semHandle);
|
OsSemDbgTimeUpdateHook(semHandle);
|
||||||
|
|
||||||
if (semPended->semCount > 0) {
|
if (semPended->semCount > 0) {
|
||||||
semPended->semCount--;
|
semPended->semCount--;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SEM_PEND, semPended, runTask, timeout);
|
||||||
goto OUT;
|
goto OUT;
|
||||||
} else if (!timeout) {
|
} else if (!timeout) {
|
||||||
retErr = LOS_ERRNO_SEM_UNAVAILABLE;
|
retErr = LOS_ERRNO_SEM_UNAVAILABLE;
|
||||||
@@ -222,6 +223,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SemPend(UINT32 semHandle, UINT32 timeout)
|
|||||||
goto OUT;
|
goto OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SEM_PEND, semPended, runTask, timeout);
|
||||||
OsTaskWaitSetPendMask(OS_TASK_WAIT_SEM, semPended->semID, timeout);
|
OsTaskWaitSetPendMask(OS_TASK_WAIT_SEM, semPended->semID, timeout);
|
||||||
retErr = OsSchedTaskWait(&semPended->semList, timeout, TRUE);
|
retErr = OsSchedTaskWait(&semPended->semList, timeout, TRUE);
|
||||||
if (retErr == LOS_ERRNO_TSK_TIMEOUT) {
|
if (retErr == LOS_ERRNO_TSK_TIMEOUT) {
|
||||||
@@ -259,7 +261,7 @@ LITE_OS_SEC_TEXT UINT32 OsSemPostUnsafe(UINT32 semHandle, BOOL *needSched)
|
|||||||
} else {
|
} else {
|
||||||
semPosted->semCount++;
|
semPosted->semCount++;
|
||||||
}
|
}
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_SEM_POST, semPosted, resumedTask);
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,11 +67,67 @@ int OsSigIsMember(const sigset_t *set, int signo)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo)
|
||||||
|
{
|
||||||
|
SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead;
|
||||||
|
SigInfoListNode **prevHook = &sigcb->tmpInfoListHead;
|
||||||
|
while (tmpInfoNode != NULL) {
|
||||||
|
if (tmpInfoNode->info.si_signo == signo) {
|
||||||
|
/* copy tmpinfo to unbinfo. */
|
||||||
|
(VOID)memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), &tmpInfoNode->info, sizeof(siginfo_t));
|
||||||
|
/* delete tmpinfo from tmpList. */
|
||||||
|
*prevHook = tmpInfoNode->next;
|
||||||
|
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
|
||||||
|
tmpInfoNode = *prevHook;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
prevHook = &tmpInfoNode->next;
|
||||||
|
tmpInfoNode = tmpInfoNode->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC INT32 OsAddSigInfoToTmpList(sig_cb *sigcb, siginfo_t *info)
|
||||||
|
{
|
||||||
|
/* try to find the old siginfo */
|
||||||
|
SigInfoListNode *tmp = sigcb->tmpInfoListHead;
|
||||||
|
while (tmp != NULL) {
|
||||||
|
if (tmp->info.si_signo == info->si_signo) {
|
||||||
|
/* found it, break. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tmp == NULL) {
|
||||||
|
/* none, alloc new one */
|
||||||
|
tmp = (SigInfoListNode *)LOS_MemAlloc(m_aucSysMem0, sizeof(SigInfoListNode));
|
||||||
|
if (tmp == NULL) {
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
tmp->next = sigcb->tmpInfoListHead;
|
||||||
|
sigcb->tmpInfoListHead = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
(VOID)memcpy_s(&tmp->info, sizeof(siginfo_t), info, sizeof(siginfo_t));
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID OsClearSigInfoTmpList(sig_cb *sigcb)
|
||||||
|
{
|
||||||
|
while (sigcb->tmpInfoListHead != NULL) {
|
||||||
|
SigInfoListNode *tmpInfoNode = sigcb->tmpInfoListHead;
|
||||||
|
sigcb->tmpInfoListHead = sigcb->tmpInfoListHead->next;
|
||||||
|
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
STATIC INLINE VOID OsSigWaitTaskWake(LosTaskCB *taskCB, INT32 signo)
|
STATIC INLINE VOID OsSigWaitTaskWake(LosTaskCB *taskCB, INT32 signo)
|
||||||
{
|
{
|
||||||
sig_cb *sigcb = &taskCB->sig;
|
sig_cb *sigcb = &taskCB->sig;
|
||||||
|
|
||||||
if (!LOS_ListEmpty(&sigcb->waitList) && OsSigIsMember(&sigcb->sigwaitmask, signo)) {
|
if (!LOS_ListEmpty(&sigcb->waitList) && OsSigIsMember(&sigcb->sigwaitmask, signo)) {
|
||||||
|
OsMoveTmpInfoToUnbInfo(sigcb, signo);
|
||||||
OsTaskWakeClearPendMask(taskCB);
|
OsTaskWakeClearPendMask(taskCB);
|
||||||
OsSchedTaskWake(taskCB);
|
OsSchedTaskWake(taskCB);
|
||||||
OsSigEmptySet(&sigcb->sigwaitmask);
|
OsSigEmptySet(&sigcb->sigwaitmask);
|
||||||
@@ -141,7 +197,10 @@ int OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info)
|
|||||||
/* unmasked signal actions */
|
/* unmasked signal actions */
|
||||||
OsSigAddSet(&sigcb->sigFlag, info->si_signo);
|
OsSigAddSet(&sigcb->sigFlag, info->si_signo);
|
||||||
}
|
}
|
||||||
(void) memcpy_s(&sigcb->sigunbinfo, sizeof(siginfo_t), info, sizeof(siginfo_t));
|
|
||||||
|
if (OsAddSigInfoToTmpList(sigcb, info) == LOS_NOK) {
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
return OsPendingTaskWake(stcb, info->si_signo);
|
return OsPendingTaskWake(stcb, info->si_signo);
|
||||||
}
|
}
|
||||||
@@ -159,28 +218,22 @@ void OsSigMaskSwitch(LosTaskCB * const rtcb, sigset_t set)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int OsSigprocMask(int how, const sigset_t_l *setl, sigset_t_l *oldset)
|
int OsSigprocMask(int how, const sigset_t_l *setl, sigset_t_l *oldsetl)
|
||||||
{
|
{
|
||||||
LosTaskCB *spcb = NULL;
|
LosTaskCB *spcb = NULL;
|
||||||
sigset_t oldSigprocmask;
|
|
||||||
int ret = LOS_OK;
|
int ret = LOS_OK;
|
||||||
unsigned int intSave;
|
unsigned int intSave;
|
||||||
sigset_t set;
|
sigset_t set;
|
||||||
int retVal;
|
|
||||||
|
|
||||||
if (setl != NULL) {
|
|
||||||
retVal = LOS_ArchCopyFromUser(&set, &(setl->sig[0]), sizeof(sigset_t));
|
|
||||||
if (retVal != 0) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SCHEDULER_LOCK(intSave);
|
SCHEDULER_LOCK(intSave);
|
||||||
spcb = OsCurrTaskGet();
|
spcb = OsCurrTaskGet();
|
||||||
/* If requested, copy the old mask to user. */
|
/* If requested, copy the old mask to user. */
|
||||||
oldSigprocmask = spcb->sig.sigprocmask;
|
if (oldsetl != NULL) {
|
||||||
|
*(sigset_t *)oldsetl = spcb->sig.sigprocmask;
|
||||||
|
}
|
||||||
/* If requested, modify the current signal mask. */
|
/* If requested, modify the current signal mask. */
|
||||||
if (setl != NULL) {
|
if (setl != NULL) {
|
||||||
|
set = *(sigset_t *)setl;
|
||||||
/* Okay, determine what we are supposed to do */
|
/* Okay, determine what we are supposed to do */
|
||||||
switch (how) {
|
switch (how) {
|
||||||
/* Set the union of the current set and the signal
|
/* Set the union of the current set and the signal
|
||||||
@@ -208,12 +261,6 @@ int OsSigprocMask(int how, const sigset_t_l *setl, sigset_t_l *oldset)
|
|||||||
}
|
}
|
||||||
SCHEDULER_UNLOCK(intSave);
|
SCHEDULER_UNLOCK(intSave);
|
||||||
|
|
||||||
if (oldset != NULL) {
|
|
||||||
retVal = LOS_ArchCopyToUser(&(oldset->sig[0]), &oldSigprocmask, sizeof(sigset_t));
|
|
||||||
if (retVal != 0) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,6 +398,10 @@ static int OsSignalPermissionToCheck(const LosProcessCB *spcb)
|
|||||||
|
|
||||||
int OsDispatch(pid_t pid, siginfo_t *info, int permission)
|
int OsDispatch(pid_t pid, siginfo_t *info, int permission)
|
||||||
{
|
{
|
||||||
|
if (OsProcessIDUserCheckInvalid(pid) || pid < 0) {
|
||||||
|
return -ESRCH;
|
||||||
|
}
|
||||||
|
|
||||||
LosProcessCB *spcb = OS_PCB_FROM_PID(pid);
|
LosProcessCB *spcb = OS_PCB_FROM_PID(pid);
|
||||||
if (OsProcessIsUnused(spcb)) {
|
if (OsProcessIsUnused(spcb)) {
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
@@ -382,20 +433,27 @@ int OsKill(pid_t pid, int sig, int permission)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Make sure that the para is valid */
|
/* Make sure that the para is valid */
|
||||||
if (!GOOD_SIGNO(sig) || pid < 0) {
|
if (!GOOD_SIGNO(sig)) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (OsProcessIDUserCheckInvalid(pid)) {
|
|
||||||
return -ESRCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create the siginfo structure */
|
/* Create the siginfo structure */
|
||||||
info.si_signo = sig;
|
info.si_signo = sig;
|
||||||
info.si_code = SI_USER;
|
info.si_code = SI_USER;
|
||||||
info.si_value.sival_ptr = NULL;
|
info.si_value.sival_ptr = NULL;
|
||||||
|
|
||||||
/* Send the signal */
|
if (pid > 0) {
|
||||||
ret = OsDispatch(pid, &info, permission);
|
/* Send the signal to the specify process */
|
||||||
|
ret = OsDispatch(pid, &info, permission);
|
||||||
|
} else if (pid == -1) {
|
||||||
|
/* Send SIG to all processes */
|
||||||
|
ret = OsSendSignalToAllProcess(&info, permission);
|
||||||
|
} else {
|
||||||
|
/* Send SIG to all processes in process group PGRP.
|
||||||
|
If PGRP is zero, send SIG to all processes in
|
||||||
|
the current process's process group. */
|
||||||
|
ret = OsSendSignalToProcessGroup(pid, &info, permission);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,6 +563,7 @@ int OsSigTimedWaitNoLock(sigset_t *set, siginfo_t *info, unsigned int timeout)
|
|||||||
if (clear) {
|
if (clear) {
|
||||||
sigcb->sigPendFlag ^= clear;
|
sigcb->sigPendFlag ^= clear;
|
||||||
ret = FindFirstSetedBit((UINT64)clear) + 1;
|
ret = FindFirstSetedBit((UINT64)clear) + 1;
|
||||||
|
OsMoveTmpInfoToUnbInfo(sigcb, ret);
|
||||||
} else {
|
} else {
|
||||||
OsSigAddSet(set, SIGKILL);
|
OsSigAddSet(set, SIGKILL);
|
||||||
OsSigAddSet(set, SIGSTOP);
|
OsSigAddSet(set, SIGSTOP);
|
||||||
@@ -518,7 +577,7 @@ int OsSigTimedWaitNoLock(sigset_t *set, siginfo_t *info, unsigned int timeout)
|
|||||||
sigcb->sigwaitmask = NULL_SIGNAL_SET;
|
sigcb->sigwaitmask = NULL_SIGNAL_SET;
|
||||||
}
|
}
|
||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
(void) memcpy_s(info, sizeof(siginfo_t), &sigcb->sigunbinfo, sizeof(siginfo_t));
|
(VOID)memcpy_s(info, sizeof(siginfo_t), &sigcb->sigunbinfo, sizeof(siginfo_t));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -646,6 +705,7 @@ VOID *OsSaveSignalContext(VOID *sp, VOID *newSp)
|
|||||||
sigcb->sigFlag |= process->sigShare;
|
sigcb->sigFlag |= process->sigShare;
|
||||||
UINT32 signo = (UINT32)FindFirstSetedBit(sigcb->sigFlag) + 1;
|
UINT32 signo = (UINT32)FindFirstSetedBit(sigcb->sigFlag) + 1;
|
||||||
UINT32 sigVal = (UINT32)(UINTPTR)(sigcb->sigunbinfo.si_value.sival_ptr);
|
UINT32 sigVal = (UINT32)(UINTPTR)(sigcb->sigunbinfo.si_value.sival_ptr);
|
||||||
|
OsMoveTmpInfoToUnbInfo(sigcb, signo);
|
||||||
OsProcessExitCodeSignalSet(process, signo);
|
OsProcessExitCodeSignalSet(process, signo);
|
||||||
sigcb->sigContext = sp;
|
sigcb->sigContext = sp;
|
||||||
|
|
||||||
|
|||||||
@@ -37,11 +37,7 @@
|
|||||||
#include "los_vm_boot.h"
|
#include "los_vm_boot.h"
|
||||||
#include "los_vm_filemap.h"
|
#include "los_vm_filemap.h"
|
||||||
#include "los_task_pri.h"
|
#include "los_task_pri.h"
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
#include "los_hook.h"
|
||||||
#include "los_trace_frame.h"
|
|
||||||
#include "los_trace.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Used to cut non-essential functions. */
|
/* Used to cut non-essential functions. */
|
||||||
#define OS_MEM_FREE_BY_TASKID 0
|
#define OS_MEM_FREE_BY_TASKID 0
|
||||||
@@ -865,11 +861,7 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
OsHookCall(LOS_HOOK_TYPE_MEM_INIT, pool, size);
|
||||||
LOS_TraceReg(LOS_TRACE_MEM_TIME, OsMemTimeTrace, LOS_TRACE_MEM_TIME_NAME, LOS_TRACE_ENABLE);
|
|
||||||
LOS_TraceReg(LOS_TRACE_MEM_INFO, OsMemInfoTrace, LOS_TRACE_MEM_INFO_NAME, LOS_TRACE_ENABLE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,11 +878,7 @@ UINT32 LOS_MemDeInit(VOID *pool)
|
|||||||
|
|
||||||
OsMemPoolDeinit(pool);
|
OsMemPoolDeinit(pool);
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
OsHookCall(LOS_HOOK_TYPE_MEM_DEINIT, pool);
|
||||||
LOS_TraceUnreg(LOS_TRACE_MEM_TIME);
|
|
||||||
LOS_TraceUnreg(LOS_TRACE_MEM_INFO);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return LOS_OK;
|
return LOS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -958,10 +946,6 @@ retry:
|
|||||||
|
|
||||||
VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
|
VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
|
||||||
{
|
{
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
UINT64 start = HalClockGetCycles();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((pool == NULL) || (size == 0)) {
|
if ((pool == NULL) || (size == 0)) {
|
||||||
return (size > 0) ? OsVmBootMemAlloc(size) : NULL;
|
return (size > 0) ? OsVmBootMemAlloc(size) : NULL;
|
||||||
}
|
}
|
||||||
@@ -983,28 +967,12 @@ VOID *LOS_MemAlloc(VOID *pool, UINT32 size)
|
|||||||
MEM_UNLOCK(poolHead, intSave);
|
MEM_UNLOCK(poolHead, intSave);
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
OsHookCall(LOS_HOOK_TYPE_MEM_ALLOC, pool, ptr, size);
|
||||||
UINT64 end = HalClockGetCycles();
|
|
||||||
UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
|
|
||||||
LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_MALLOC, timeUsed);
|
|
||||||
|
|
||||||
LOS_MEM_POOL_STATUS poolStatus = {0};
|
|
||||||
(VOID)LOS_MemInfoGet(pool, &poolStatus);
|
|
||||||
UINT8 fragment = 100 - poolStatus.maxFreeNodeSize * 100 / poolStatus.totalFreeSize; /* 100: percent denominator. */
|
|
||||||
UINT8 usage = LOS_MemTotalUsedGet(pool) * 100 / LOS_MemPoolSizeGet(pool); /* 100: percent denominator. */
|
|
||||||
LOS_Trace(LOS_TRACE_MEM_INFO, (UINTPTR)pool & MEM_POOL_ADDR_MASK, fragment, usage, poolStatus.totalFreeSize,
|
|
||||||
poolStatus.maxFreeNodeSize, poolStatus.usedNodeNum, poolStatus.freeNodeNum);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary)
|
VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary)
|
||||||
{
|
{
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
UINT64 start = HalClockGetCycles();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
UINT32 gapSize;
|
UINT32 gapSize;
|
||||||
|
|
||||||
if ((pool == NULL) || (size == 0) || (boundary == 0) || !OS_MEM_IS_POW_TWO(boundary) ||
|
if ((pool == NULL) || (size == 0) || (boundary == 0) || !OS_MEM_IS_POW_TWO(boundary) ||
|
||||||
@@ -1053,12 +1021,7 @@ VOID *LOS_MemAllocAlign(VOID *pool, UINT32 size, UINT32 boundary)
|
|||||||
ptr = alignedPtr;
|
ptr = alignedPtr;
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
OsHookCall(LOS_HOOK_TYPE_MEM_ALLOCALIGN, pool, ptr, size, boundary);
|
||||||
UINT64 end = HalClockGetCycles();
|
|
||||||
UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
|
|
||||||
LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_MEMALIGN, timeUsed);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,14 +1172,11 @@ STATIC INLINE UINT32 OsMemFree(struct OsMemPoolHead *pool, struct OsMemNodeHead
|
|||||||
|
|
||||||
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
|
UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
|
||||||
{
|
{
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
UINT64 start = HalClockGetCycles();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((pool == NULL) || (ptr == NULL) || !OS_MEM_IS_ALIGNED(pool, sizeof(VOID *)) ||
|
if ((pool == NULL) || (ptr == NULL) || !OS_MEM_IS_ALIGNED(pool, sizeof(VOID *)) ||
|
||||||
!OS_MEM_IS_ALIGNED(ptr, sizeof(VOID *))) {
|
!OS_MEM_IS_ALIGNED(ptr, sizeof(VOID *))) {
|
||||||
return LOS_NOK;
|
return LOS_NOK;
|
||||||
}
|
}
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_MEM_FREE, pool, ptr);
|
||||||
|
|
||||||
UINT32 ret = LOS_NOK;
|
UINT32 ret = LOS_NOK;
|
||||||
struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
|
struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
|
||||||
@@ -1245,12 +1205,6 @@ UINT32 LOS_MemFree(VOID *pool, VOID *ptr)
|
|||||||
MEM_UNLOCK(poolHead, intSave);
|
MEM_UNLOCK(poolHead, intSave);
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
UINT64 end = HalClockGetCycles();
|
|
||||||
UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
|
|
||||||
LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_FREE, timeUsed);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1345,14 +1299,10 @@ STATIC INLINE VOID *OsMemRealloc(struct OsMemPoolHead *pool, const VOID *ptr,
|
|||||||
|
|
||||||
VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size)
|
VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size)
|
||||||
{
|
{
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
UINT64 start = HalClockGetCycles();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((pool == NULL) || OS_MEM_NODE_GET_USED_FLAG(size) || OS_MEM_NODE_GET_ALIGNED_FLAG(size)) {
|
if ((pool == NULL) || OS_MEM_NODE_GET_USED_FLAG(size) || OS_MEM_NODE_GET_ALIGNED_FLAG(size)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_MEM_REALLOC, pool, ptr, size);
|
||||||
if (size < OS_MEM_MIN_ALLOC_SIZE) {
|
if (size < OS_MEM_MIN_ALLOC_SIZE) {
|
||||||
size = OS_MEM_MIN_ALLOC_SIZE;
|
size = OS_MEM_MIN_ALLOC_SIZE;
|
||||||
}
|
}
|
||||||
@@ -1387,12 +1337,6 @@ VOID *LOS_MemRealloc(VOID *pool, VOID *ptr, UINT32 size)
|
|||||||
} while (0);
|
} while (0);
|
||||||
MEM_UNLOCK(poolHead, intSave);
|
MEM_UNLOCK(poolHead, intSave);
|
||||||
|
|
||||||
#ifdef LOSCFG_KERNEL_TRACE
|
|
||||||
UINT64 end = HalClockGetCycles();
|
|
||||||
UINT32 timeUsed = MEM_TRACE_CYCLE_TO_US(end - start);
|
|
||||||
LOS_Trace(LOS_TRACE_MEM_TIME, (UINTPTR)pool & MEM_POOL_ADDR_MASK, MEM_TRACE_REALLOC, timeUsed);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return newPtr;
|
return newPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "los_task_pri.h"
|
#include "los_task_pri.h"
|
||||||
#include "los_process_pri.h"
|
#include "los_process_pri.h"
|
||||||
#include "los_arch_mmu.h"
|
#include "los_arch_mmu.h"
|
||||||
|
#include "los_hook.h"
|
||||||
#ifdef LOSCFG_KERNEL_CPUP
|
#ifdef LOSCFG_KERNEL_CPUP
|
||||||
#include "los_cpup_pri.h"
|
#include "los_cpup_pri.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -724,6 +725,7 @@ BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 policy, UINT16 priori
|
|||||||
}
|
}
|
||||||
|
|
||||||
taskCB->priority = priority;
|
taskCB->priority = priority;
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority);
|
||||||
if (taskCB->taskStatus & OS_TASK_STATUS_INIT) {
|
if (taskCB->taskStatus & OS_TASK_STATUS_INIT) {
|
||||||
OsSchedTaskEnQueue(taskCB);
|
OsSchedTaskEnQueue(taskCB);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -953,8 +955,7 @@ STATIC INLINE VOID OsSchedSwitchCheck(LosTaskCB *runTask, LosTaskCB *newTask)
|
|||||||
#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
|
#ifdef LOSCFG_BASE_CORE_TSK_MONITOR
|
||||||
OsTaskStackCheck(runTask, newTask);
|
OsTaskStackCheck(runTask, newTask);
|
||||||
#endif /* LOSCFG_BASE_CORE_TSK_MONITOR */
|
#endif /* LOSCFG_BASE_CORE_TSK_MONITOR */
|
||||||
|
OsHookCall(LOS_HOOK_TYPE_TASK_SWITCHEDIN, newTask, runTask);
|
||||||
OsTraceTaskSchedule(newTask, runTask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC INLINE VOID OsSchedSwitchProcess(LosProcessCB *runProcess, LosProcessCB *newProcess)
|
STATIC INLINE VOID OsSchedSwitchProcess(LosProcessCB *runProcess, LosProcessCB *newProcess)
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include "los_mmu_descriptor_v6.h"
|
#include "los_mmu_descriptor_v6.h"
|
||||||
#ifdef LOSCFG_FS_VFS
|
#ifdef LOSCFG_FS_VFS
|
||||||
#include "fs/file.h"
|
#include "fs/file.h"
|
||||||
|
#include "vnode.h"
|
||||||
#endif
|
#endif
|
||||||
#include "los_printf.h"
|
#include "los_printf.h"
|
||||||
#include "los_vm_page.h"
|
#include "los_vm_page.h"
|
||||||
@@ -55,13 +56,13 @@
|
|||||||
|
|
||||||
const CHAR *OsGetRegionNameOrFilePath(LosVmMapRegion *region)
|
const CHAR *OsGetRegionNameOrFilePath(LosVmMapRegion *region)
|
||||||
{
|
{
|
||||||
struct file *filep = NULL;
|
struct Vnode *vnode = NULL;
|
||||||
if (region == NULL) {
|
if (region == NULL) {
|
||||||
return "";
|
return "";
|
||||||
#ifdef LOSCFG_FS_VFS
|
#ifdef LOSCFG_FS_VFS
|
||||||
} else if (LOS_IsRegionFileValid(region)) {
|
} else if (LOS_IsRegionFileValid(region)) {
|
||||||
filep = region->unTypeData.rf.file;
|
vnode = region->unTypeData.rf.vnode;
|
||||||
return filep->f_path;
|
return vnode->filePath;
|
||||||
#endif
|
#endif
|
||||||
} else if (region->regionFlags & VM_MAP_REGION_FLAG_HEAP) {
|
} else if (region->regionFlags & VM_MAP_REGION_FLAG_HEAP) {
|
||||||
return "HEAP";
|
return "HEAP";
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user