Compare commits
344 Commits
OpenHarmon
...
OpenHarmon
| 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 | ||
|
|
36cfc68a54 | ||
|
|
4dc059f207 | ||
|
|
f4409babd4 | ||
|
|
e1b9a6b185 | ||
|
|
b5528e1d17 | ||
|
|
2db80ecb38 | ||
|
|
ec366df863 | ||
|
|
e1472b494f | ||
|
|
67ac8c4c58 | ||
|
|
555e0681be | ||
|
|
fb5df47b6c | ||
|
|
339e937a6a | ||
|
|
5910c9ab8d | ||
|
|
9fa8d27c6c | ||
|
|
7bc68f454f | ||
|
|
dc3cc094a7 | ||
|
|
1aa9f98858 | ||
|
|
42a3a6c51b | ||
|
|
bbdb977b5e | ||
|
|
87c2d4f7e4 | ||
|
|
0f4d5a4b0c | ||
|
|
dd91c5c772 | ||
|
|
da43449939 | ||
|
|
d6e0d3ee7d | ||
|
|
27dca4d857 | ||
|
|
70a8901c72 | ||
|
|
2f214bf4de | ||
|
|
76507c05a8 | ||
|
|
9b24cc4915 | ||
|
|
e64ee0f4e6 | ||
|
|
e13cb3bcc4 | ||
|
|
51da89a3fb | ||
|
|
42f374dd7a | ||
|
|
689c2e90cf | ||
|
|
cdf96fef0c | ||
|
|
26ee8b836e | ||
|
|
6917e08431 | ||
|
|
4c57aa26ad | ||
|
|
007c75eb18 | ||
|
|
8118408123 | ||
|
|
8df3e8c965 | ||
|
|
5edd78e756 | ||
|
|
ba16cd34d4 | ||
|
|
77dcef4bc0 | ||
|
|
024a8f2771 | ||
|
|
3bfa995a9d | ||
|
|
6549fd8be6 | ||
|
|
9ec208a273 | ||
|
|
53ced1a85e | ||
|
|
2b9c55fd90 | ||
|
|
7a98cad11a | ||
|
|
827e060606 | ||
|
|
78e8d86611 | ||
|
|
30b7d34eb4 | ||
|
|
a23b491f8c | ||
|
|
72734a335c | ||
|
|
626b6600c0 | ||
|
|
e8037dc56a | ||
|
|
4c8a86ece7 | ||
|
|
3cc09763f2 | ||
|
|
3bb3173604 | ||
|
|
d2fe0e788b | ||
|
|
6a5a0326d2 | ||
|
|
c3245b3ce3 | ||
|
|
e425187d17 | ||
|
|
a6c02e29c1 | ||
|
|
d169cad6b4 | ||
|
|
4875707b37 | ||
|
|
9b4fd13c3c | ||
|
|
343b92661d | ||
|
|
79982895ec | ||
|
|
7f7eb8374f | ||
|
|
1c8f3b98c9 | ||
|
|
8de96bba65 | ||
|
|
c66681a1f9 | ||
|
|
8696e1c6cb | ||
|
|
4dc421e3de | ||
|
|
ce66a234fc | ||
|
|
f85c27de59 | ||
|
|
9c291a4361 | ||
|
|
1722aaa80d | ||
|
|
88358ab302 | ||
|
|
1e5d01360b | ||
|
|
a7a25bb0a3 | ||
|
|
1394b3be26 | ||
|
|
590c7b4e22 | ||
|
|
698756d1e6 | ||
|
|
7819d15b36 | ||
|
|
11a9b00d43 | ||
|
|
2ad176e587 | ||
|
|
c54bfa16e3 | ||
|
|
187884937c | ||
|
|
2d8e59ccf3 | ||
|
|
85b4cb7a67 | ||
|
|
66764e48fb | ||
|
|
def22d3fd1 | ||
|
|
08878bd99f | ||
|
|
468c47b6b1 | ||
|
|
f3beb4b273 | ||
|
|
c71ec9d7e8 | ||
|
|
787fae2eec | ||
|
|
875c46290b | ||
|
|
09d5bcc22d | ||
|
|
abf4d8fb25 | ||
|
|
0dc79479ff | ||
|
|
0dfa58ca5a | ||
|
|
4427142d73 | ||
|
|
a531bcf389 | ||
|
|
9458de9ac6 | ||
|
|
76f45b3fb2 | ||
|
|
aaa9018acf | ||
|
|
3b5268f02a | ||
|
|
fa056ce246 | ||
|
|
0ad91713f6 | ||
|
|
9e9c7b28d4 | ||
|
|
8f6a1dd33c | ||
|
|
77270dd783 | ||
|
|
8755dc9d35 | ||
|
|
a8805a65aa | ||
|
|
4adc15e630 | ||
|
|
d9774e016e | ||
|
|
c610578d73 | ||
|
|
3b9e3f8471 | ||
|
|
58d4366e1d | ||
|
|
650d2b91cd | ||
|
|
35a2f3af33 | ||
|
|
2ff44c4938 | ||
|
|
7b7d64cc87 | ||
|
|
70c18b4a75 | ||
|
|
14bd753aa8 | ||
|
|
8729f6ee57 | ||
|
|
51a50c95b4 | ||
|
|
9d3e872454 | ||
|
|
80473f0975 | ||
|
|
7a6e4c8155 | ||
|
|
c40e1464b9 | ||
|
|
700c3415c4 | ||
|
|
0973004870 | ||
|
|
c9d69e2d1b | ||
|
|
d79fd50693 | ||
|
|
9547133e64 | ||
|
|
2d31aed27b | ||
|
|
d9ed4b4bf6 | ||
|
|
60bf2fc517 | ||
|
|
cb17fa50ed | ||
|
|
09c491ca1f | ||
|
|
a531da901d | ||
|
|
a195aac9fb | ||
|
|
1157c4a289 | ||
|
|
0056b4ade5 | ||
|
|
78a50aff99 | ||
|
|
7240fe3bd4 | ||
|
|
e7c4b1963a | ||
|
|
fd6f91bc9f | ||
|
|
33f5c70e6c | ||
|
|
ec977a1c7e | ||
|
|
92d7672b19 | ||
|
|
390159f58a | ||
|
|
d8be8aad65 | ||
|
|
6d948a42bb | ||
|
|
72d9aa1bcb | ||
|
|
8390738de5 | ||
|
|
40f239a7d4 | ||
|
|
cacb4f0103 | ||
|
|
ee54cd8b7e | ||
|
|
f523d7a98c | ||
|
|
d7387508e3 | ||
|
|
e4ff04586f | ||
|
|
8784694686 | ||
|
|
b29d9d88ab | ||
|
|
d8263b1e91 | ||
|
|
9304a683ad | ||
|
|
78906f4a6c | ||
|
|
ee7eb89354 | ||
|
|
55e5e29005 | ||
|
|
ac8c2c6d5b | ||
|
|
feae60c8fe | ||
|
|
425975e481 | ||
|
|
cc731d1e69 | ||
|
|
56a95b9ec9 | ||
|
|
3e7622ca78 | ||
|
|
b1b4ddcc7d | ||
|
|
e567a10d02 | ||
|
|
23fd4e55a3 | ||
|
|
e57dc7762b | ||
|
|
003810284c | ||
|
|
379d602ab6 | ||
|
|
bf7b2c0a3e | ||
|
|
4e4f2d6d7e | ||
|
|
d7672d47f2 | ||
|
|
abbeca1cb2 | ||
|
|
50c8abc521 | ||
|
|
0469e5b849 | ||
|
|
dfea902a08 | ||
|
|
339c467e71 | ||
|
|
455e42e5b9 | ||
|
|
6f6dc4f24c | ||
|
|
9e45086d19 | ||
|
|
9515d53dcc | ||
|
|
e0a27badde | ||
|
|
49856dc1e0 | ||
|
|
43bdf2f1d3 | ||
|
|
eb1900d4db | ||
|
|
7de43bb004 | ||
|
|
1d952a254a | ||
|
|
9db3407589 | ||
|
|
bb6abd8c6b | ||
|
|
3cddcb9f66 | ||
|
|
bfd27e78b2 | ||
|
|
a8384b5db2 | ||
|
|
5db839acef | ||
|
|
f4626985fd | ||
|
|
68da7aefc5 | ||
|
|
f1b4c87bc4 | ||
|
|
1348809807 | ||
|
|
eb72f78cf1 | ||
|
|
12577eade5 | ||
|
|
de6db86df3 | ||
|
|
56b8ecaf17 | ||
|
|
1e345f18b3 | ||
|
|
f793dc1097 | ||
|
|
112cdebe41 | ||
|
|
a28dcc38c9 | ||
|
|
3d1cf683f3 | ||
|
|
a9fc1e0e5d | ||
|
|
2e2b14205f | ||
|
|
b8e18ffdf1 | ||
|
|
21d8ac8752 | ||
|
|
008fa8660d | ||
|
|
6860246cfa | ||
|
|
8a3d188240 | ||
|
|
8f0d25225e | ||
|
|
8fe0cc7770 | ||
|
|
ee4cf83121 | ||
|
|
702d8d9dde | ||
|
|
290a3c6f92 | ||
|
|
600dded31e | ||
|
|
67806596a3 | ||
|
|
88fe4eb3e1 | ||
|
|
ca40c79761 | ||
|
|
231cb6be27 | ||
|
|
7f484dfa09 | ||
|
|
1fa6ba3389 | ||
|
|
b7f2df0350 | ||
|
|
8bb4538de1 | ||
|
|
99d7072332 | ||
|
|
30f5ab89b7 | ||
|
|
fd3f4072b5 | ||
|
|
143efc0fab | ||
|
|
2f3d7efc24 | ||
|
|
e76c0046f7 | ||
|
|
b3120b5498 | ||
|
|
53c6d96c6f | ||
|
|
3f84ed5075 | ||
|
|
e9ad6b71c3 | ||
|
|
fbfd71dfe3 | ||
|
|
e4b6ba56b9 | ||
|
|
6e95771303 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -16,10 +16,9 @@ cscope*
|
||||
tags
|
||||
|
||||
# Menuconfig temp files
|
||||
/include/config
|
||||
/include/generated
|
||||
.config*
|
||||
/config.h
|
||||
/.config
|
||||
/.config.old
|
||||
|
||||
# Build temp files
|
||||
/platform/board.ld
|
||||
/out
|
||||
|
||||
375
BUILD.gn
375
BUILD.gn
@@ -28,56 +28,361 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//build/lite/config/subsystem/lite_subsystem.gni")
|
||||
|
||||
declare_args() {
|
||||
tee_enable = false
|
||||
liteos_name = "OHOS_Image"
|
||||
liteos_skip_make = false
|
||||
}
|
||||
|
||||
cmd = "if [ -f $device_path/BUILD.gn ]; then echo true; else echo false; fi"
|
||||
HAVE_DEVICE_SDK = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value")
|
||||
|
||||
LITEOS_MENUCONFIG_H = rebase_path("$root_out_dir/config.h")
|
||||
|
||||
tee = ""
|
||||
if (tee_enable) {
|
||||
tee = "_tee"
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
liteos_config_file = "${ohos_build_type}${tee}.config"
|
||||
}
|
||||
|
||||
liteos_config_file = rebase_path(liteos_config_file, "", "$product_path/kernel_configs")
|
||||
print("liteos_config_file:", liteos_config_file)
|
||||
|
||||
exec_script("//build/lite/run_shell_cmd.py",
|
||||
[
|
||||
"env" +
|
||||
" CONFIG_=LOSCFG_" +
|
||||
" KCONFIG_CONFIG_HEADER='y=true'" +
|
||||
" KCONFIG_CONFIG=$liteos_config_file" +
|
||||
" DEVICE_PATH=$device_path" +
|
||||
" srctree=" + rebase_path(".") +
|
||||
" genconfig" +
|
||||
" --header-path $LITEOS_MENUCONFIG_H" +
|
||||
" --file-list kconfig_files.txt" +
|
||||
" --env-list kconfig_env.txt" +
|
||||
" --config-out config.gni",
|
||||
], "", [ liteos_config_file ])
|
||||
|
||||
import("liteos.gni")
|
||||
|
||||
assert(ARCH != "", "ARCH not set!")
|
||||
assert(ARCH == arch, "ARCH not match! details: $ARCH != $arch")
|
||||
assert(tee_enable == defined(LOSCFG_TEE_ENABLE), "TEE switch not match!")
|
||||
|
||||
generate_notice_file("kernel_notice_file") {
|
||||
module_name = "kernel"
|
||||
module_source_dir_list = [
|
||||
"//third_party/FreeBSD",
|
||||
"//third_party/musl",
|
||||
"//third_party/zlib",
|
||||
"//third_party/FatFs",
|
||||
"//third_party/Linux_Kernel",
|
||||
"//third_party/lwip",
|
||||
"//third_party/NuttX",
|
||||
"//third_party/mtd-utils",
|
||||
"$LITEOSTHIRDPARTY/FreeBSD",
|
||||
"$LITEOSTHIRDPARTY/musl",
|
||||
"$LITEOSTHIRDPARTY/zlib",
|
||||
"$LITEOSTHIRDPARTY/FatFs",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel",
|
||||
"$LITEOSTHIRDPARTY/lwip",
|
||||
"$LITEOSTHIRDPARTY/NuttX",
|
||||
"$LITEOSTHIRDPARTY/mtd-utils",
|
||||
]
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
enable_ohos_kernel_liteos_a_ext_build = true
|
||||
LOSCFG_TEST_APPS = false
|
||||
tee_enable = ""
|
||||
liteos_arch_cflags = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
mcpu = LOSCFG_ARCH_CPU
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH64) && defined(LOSCFG_ARCH_FPU_DISABLE)) {
|
||||
mcpu += "+nofp"
|
||||
}
|
||||
liteos_arch_cflags += [ "-mcpu=$mcpu" ]
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
liteos_arch_cflags += [
|
||||
"-mfloat-abi=softfp",
|
||||
"-mfpu=$LOSCFG_ARCH_FPU",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
lite_subsystem("kernel") {
|
||||
subsystem_components = []
|
||||
cc = "$ohos_current_cc_command " + string_join(" ", liteos_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
cc += " --target=$target_triple"
|
||||
}
|
||||
|
||||
if (enable_ohos_kernel_liteos_a_ext_build == false) {
|
||||
subsystem_components += [
|
||||
"//kernel/liteos_a/kernel",
|
||||
"//kernel/liteos_a/net",
|
||||
"//kernel/liteos_a/lib",
|
||||
"//kernel/liteos_a/compat",
|
||||
"//kernel/liteos_a/fs",
|
||||
"//kernel/liteos_a/arch:platform_cpu",
|
||||
]
|
||||
if (LOSCFG_SHELL) {
|
||||
subsystem_components += [ "//kernel/liteos_a/shell" ]
|
||||
config("arch_config") {
|
||||
cflags = liteos_arch_cflags
|
||||
asmflags = cflags
|
||||
ldflags = cflags
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += ["-mthumb-interwork"]
|
||||
}
|
||||
} else {
|
||||
deps = [ ":make" ]
|
||||
deps += [ "//kernel/liteos_a/testsuites/unittest:unittest" ]
|
||||
}
|
||||
if (defined(LOSCFG_THUMB)) {
|
||||
cflags += [ "-mthumb" ]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-mimplicit-it=thumb" ]
|
||||
} else {
|
||||
cflags += [ "-Wa,-mimplicit-it=thumb" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config("stdinc_config") {
|
||||
std_include = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-file-name=include" ], "trim string")
|
||||
cflags = [
|
||||
"-isystem",
|
||||
std_include,
|
||||
]
|
||||
cflags += [ "-nostdinc" ]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("ssp_config") {
|
||||
cflags = []
|
||||
if (defined(LOSCFG_CC_STACKPROTECTOR_ALL)) {
|
||||
cflags += [ "-fstack-protector-all" ]
|
||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR_STRONG)) {
|
||||
cflags += [ "-fstack-protector-strong" ]
|
||||
} else if (defined(LOSCFG_CC_STACKPROTECTOR)) {
|
||||
cflags += [
|
||||
"-fstack-protector",
|
||||
"--param",
|
||||
"ssp-buffer-size=4",
|
||||
]
|
||||
} else {
|
||||
cflags += [ "-fno-stack-protector" ]
|
||||
}
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("optimize_config") {
|
||||
cflags = []
|
||||
if (defined(LOSCFG_COMPILE_DEBUG)) {
|
||||
cflags += [
|
||||
"-g",
|
||||
"-gdwarf-2",
|
||||
]
|
||||
optimization_cflag = "-O0"
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
|
||||
optimization_cflag = "-O2"
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE_SIZE)) {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
optimization_cflag = "-Oz"
|
||||
} else {
|
||||
optimization_cflag = "-Os"
|
||||
}
|
||||
}
|
||||
if (defined(LOSCFG_COMPILE_LTO)) {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-flto=thin" ]
|
||||
} else {
|
||||
cflags += [ "-flto" ]
|
||||
}
|
||||
}
|
||||
cflags += [ optimization_cflag ]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("kconfig_config") {
|
||||
cflags = [
|
||||
"-imacros",
|
||||
"$LITEOS_MENUCONFIG_H",
|
||||
]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("warn_config") {
|
||||
cflags = [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wpointer-arith",
|
||||
"-Wstrict-prototypes",
|
||||
"-Winvalid-pch",
|
||||
"-Wno-address-of-packed-member",
|
||||
]
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("dialect_config") {
|
||||
cflags_c = [ "-std=c99" ]
|
||||
cflags_cc = [ "-std=c++11" ]
|
||||
}
|
||||
|
||||
config("misc_config") {
|
||||
defines = [ "__LITEOS__" ]
|
||||
if (!defined(LOSCFG_DEBUG_VERSION)) {
|
||||
defines += [ "NDEBUG" ]
|
||||
}
|
||||
|
||||
cflags = [
|
||||
"-fno-pic",
|
||||
"-fno-builtin",
|
||||
"-fms-extensions",
|
||||
"-fno-strict-aliasing",
|
||||
"-fno-common",
|
||||
"-fsigned-char",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-fno-exceptions",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-fno-short-enums",
|
||||
"-mno-unaligned-access",
|
||||
]
|
||||
|
||||
if (!defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-fno-aggressive-loop-optimizations" ]
|
||||
}
|
||||
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
config("los_config") {
|
||||
configs = [
|
||||
":arch_config",
|
||||
":kconfig_config",
|
||||
":stdinc_config",
|
||||
":dialect_config",
|
||||
":optimize_config",
|
||||
":ssp_config",
|
||||
":warn_config",
|
||||
":misc_config",
|
||||
]
|
||||
}
|
||||
|
||||
executable("liteos") {
|
||||
configs = [] # clear default configs
|
||||
configs += [ ":arch_config" ]
|
||||
configs += [ ":public" ]
|
||||
|
||||
ldflags = [
|
||||
"-static",
|
||||
"-nostdlib",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-Map=$liteos_name.map",
|
||||
"-Wl,--no-eh-frame-hdr",
|
||||
]
|
||||
|
||||
libgcc = exec_script("//build/lite/run_shell_cmd.py", [ "$cc -print-libgcc-file-name" ], "trim string")
|
||||
libs = [ libgcc ]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos_llvm.ld", root_build_dir) ]
|
||||
inputs = [ "tools/build/liteos_llvm.ld" ]
|
||||
} else {
|
||||
ldflags += [ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
||||
ldflags += [ "-Wl,-nostartfiles" ]
|
||||
inputs = [ "tools/build/liteos.ld" ]
|
||||
}
|
||||
|
||||
inputs += [ "$root_out_dir/board.ld" ]
|
||||
|
||||
output_dir = target_out_dir
|
||||
|
||||
deps = [
|
||||
"platform:copy_board.ld",
|
||||
":modules",
|
||||
]
|
||||
}
|
||||
|
||||
copy("copy_liteos") {
|
||||
deps = [ ":liteos" ]
|
||||
sources = [ "$target_out_dir/unstripped/bin/liteos" ]
|
||||
outputs = [ "$root_out_dir/$liteos_name" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_kernel_image") {
|
||||
deps = [ ":copy_liteos" ]
|
||||
exec_path = rebase_path(root_out_dir)
|
||||
|
||||
objcopy = "${compile_prefix}objcopy$toolchain_cmd_suffix"
|
||||
objdump = "${compile_prefix}objdump$toolchain_cmd_suffix"
|
||||
|
||||
command = "$objcopy -O binary $liteos_name $liteos_name.bin"
|
||||
command += " && sh -c '$objdump -t $liteos_name | sort >$liteos_name.sym.sorted'"
|
||||
command += " && sh -c '$objdump -d $liteos_name >$liteos_name.asm'"
|
||||
}
|
||||
|
||||
config("public") {
|
||||
configs = [
|
||||
"arch:public",
|
||||
"platform:public",
|
||||
"kernel:public",
|
||||
"compat:public",
|
||||
"bsd:public",
|
||||
"fs:public",
|
||||
"drivers:public",
|
||||
"security:public",
|
||||
"net:public",
|
||||
"shell:public",
|
||||
"lib:public",
|
||||
]
|
||||
|
||||
configs += [
|
||||
"$HDFTOPDIR:public",
|
||||
"//drivers/liteos:public",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
configs += [ "$device_path:public" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("modules") {
|
||||
deps = [
|
||||
"arch",
|
||||
"bsd",
|
||||
"compat",
|
||||
"drivers",
|
||||
"fs",
|
||||
"kernel",
|
||||
"lib",
|
||||
"net",
|
||||
"platform",
|
||||
"security",
|
||||
"shell",
|
||||
"syscall",
|
||||
]
|
||||
|
||||
deps += [
|
||||
HDFTOPDIR,
|
||||
"//drivers/liteos",
|
||||
]
|
||||
|
||||
if (HAVE_DEVICE_SDK) {
|
||||
deps += [ device_path ]
|
||||
}
|
||||
}
|
||||
|
||||
group("apps") {
|
||||
deps = [ "apps" ]
|
||||
}
|
||||
|
||||
group("tests") {
|
||||
deps = [ "testsuites" ]
|
||||
}
|
||||
|
||||
group("kernel") {
|
||||
deps = [ ":build_kernel_image" ]
|
||||
}
|
||||
|
||||
group("liteos_a") {
|
||||
deps = [
|
||||
":apps",
|
||||
":kernel",
|
||||
":tests",
|
||||
]
|
||||
}
|
||||
|
||||
build_ext_component("make") {
|
||||
exec_path = rebase_path(".", root_build_dir)
|
||||
tee_enable = "false"
|
||||
if (board_name == "hi3516dv300" && enable_tee_ree) {
|
||||
tee_enable = "tee"
|
||||
outdir = rebase_path("$target_out_dir/${target_name}_out")
|
||||
sysroot_path = rebase_path(ohos_current_sysroot)
|
||||
arch_cflags = string_join(" ", target_arch_cflags)
|
||||
command = "./build.sh \"$board_name\" \"$ohos_build_compiler\" \"$root_build_dir\" \"$ohos_build_type\" \"$tee_enable\""
|
||||
command += " \"$device_company\" \"$product_path\" \"$outdir\" \"$ohos_version\" \"$sysroot_path\" \"$arch_cflags\""
|
||||
command += " \"$device_path\" \"$compile_prefix\" \"$liteos_config_file\""
|
||||
if (liteos_skip_make) {
|
||||
print("build_ext_component \"$target_name\" skipped:", command)
|
||||
command = "true"
|
||||
}
|
||||
prebuilts = "sh build.sh ${board_name} ${ohos_build_compiler} ${root_build_dir} ${ohos_build_type} ${tee_enable} \"${device_company}\" \"${product_path}\""
|
||||
outdir = rebase_path(get_path_info(".", "out_dir"))
|
||||
command = "make clean OUTDIR=$outdir && make rootfs VERSION=\"${ohos_version}\" -j 16 OUTDIR=$outdir"
|
||||
}
|
||||
|
||||
125
Kconfig
125
Kconfig
@@ -26,41 +26,82 @@
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see extra/config/Kconfig-language.txt
|
||||
#
|
||||
|
||||
mainmenu "Huawei LiteOS Configuration"
|
||||
|
||||
menu "Compiler"
|
||||
choice
|
||||
prompt "LiteOS_Compiler_Type"
|
||||
prompt "Compiler type"
|
||||
default COMPILER_CLANG_LLVM
|
||||
help
|
||||
Enable arm-himix100 or aarch64-himix100 or compiler.
|
||||
Choose compiler type.
|
||||
|
||||
config COMPILER_HIMIX_32
|
||||
bool "arm-linux-ohoseabi"
|
||||
config COMPILER_GCC
|
||||
bool "GCC"
|
||||
|
||||
config CROSS_COMPILE
|
||||
string "GCC cross-compile toolchain prefix"
|
||||
depends on COMPILER_GCC
|
||||
default "arm-linux-ohoseabi-" if ARCH_ARM_AARCH32
|
||||
|
||||
config COMPILER_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
|
||||
|
||||
config COMPILE_DEBUG
|
||||
bool "Enable debug options"
|
||||
default n
|
||||
help
|
||||
Answer Y to add -g option in compile command.
|
||||
|
||||
config COMPILE_OPTIMIZE
|
||||
bool "Enable code optimization options"
|
||||
default y
|
||||
help
|
||||
Answer Y to add optimization options for efficient code.
|
||||
The final binary size will be smaller and execute faster.
|
||||
But the debugging experience may be worst somehow.
|
||||
|
||||
config COMPILE_OPTIMIZE_SIZE
|
||||
bool "Enable code size optimization options" if COMPILE_OPTIMIZE
|
||||
default y
|
||||
help
|
||||
Answer Y to add optimization options for small code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be a bit longer.
|
||||
|
||||
config COMPILE_LTO
|
||||
bool "Enable link time optimization (LTO)" if COMPILE_OPTIMIZE_SIZE
|
||||
default y
|
||||
help
|
||||
Answer Y to add lto options for more smaller code size.
|
||||
The final binary size will be smaller.
|
||||
But the compile time may be much longer.
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Platform"
|
||||
|
||||
######################### config options of bsp #####################
|
||||
source "../../kernel/liteos_a/platform/Kconfig"
|
||||
source "platform/Kconfig"
|
||||
|
||||
######################### config options of cpu arch ################
|
||||
source "../../kernel/liteos_a/arch/Kconfig"
|
||||
source "arch/Kconfig"
|
||||
|
||||
######################### config options of rootfs #####################
|
||||
source "../../kernel/liteos_a/kernel/common/Kconfig"
|
||||
source "kernel/common/rootfs/Kconfig"
|
||||
######################### config options of patchfs #####################
|
||||
source "../../kernel/liteos_a/kernel/common/patchfs/Kconfig"
|
||||
source "kernel/common/patchfs/Kconfig"
|
||||
######################### config options of blackbox #####################
|
||||
source "kernel/common/blackbox/Kconfig"
|
||||
######################### config options of hidumper #####################
|
||||
source "kernel/common/hidumper/Kconfig"
|
||||
|
||||
config QUICK_START
|
||||
bool "Enable QUICK_START"
|
||||
@@ -71,27 +112,25 @@ config QUICK_START
|
||||
endmenu
|
||||
|
||||
######################### config options of kernel #####################
|
||||
source "../../kernel/liteos_a/kernel/Kconfig"
|
||||
source "kernel/Kconfig"
|
||||
######################### config options of lib ########################
|
||||
source "../../kernel/liteos_a/lib/Kconfig"
|
||||
source "lib/Kconfig"
|
||||
######################### config options of compatibility ##############
|
||||
menu "Compat"
|
||||
source "../../kernel/liteos_a/compat/posix/Kconfig"
|
||||
source "../../kernel/liteos_a/bsd/Kconfig"
|
||||
source "compat/posix/Kconfig"
|
||||
source "bsd/Kconfig"
|
||||
endmenu
|
||||
|
||||
######################### config options of framework ##################
|
||||
#source "../../frameworks/m2mcomm/Kconfig"
|
||||
|
||||
######################## config options of filesystem ##################
|
||||
menu "FileSystem"
|
||||
source "../../kernel/liteos_a/fs/vfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/fat/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/ramfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/romfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/nfs/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/proc/Kconfig"
|
||||
source "../../kernel/liteos_a/fs/jffs2/Kconfig"
|
||||
source "fs/vfs/Kconfig"
|
||||
source "fs/fat/Kconfig"
|
||||
source "fs/ramfs/Kconfig"
|
||||
source "fs/romfs/Kconfig"
|
||||
source "fs/nfs/Kconfig"
|
||||
source "fs/proc/Kconfig"
|
||||
source "fs/jffs2/Kconfig"
|
||||
source "fs/zpfs/Kconfig"
|
||||
config ENABLE_READ_BUFFER
|
||||
bool "Enable read buffer Option"
|
||||
default n
|
||||
@@ -117,15 +156,15 @@ config MAX_PATH_CACHE_SIZE
|
||||
endmenu
|
||||
|
||||
######################## config options of net ############################
|
||||
source "../../kernel/liteos_a/net/Kconfig"
|
||||
source "net/Kconfig"
|
||||
|
||||
######################## config options of debug ########################
|
||||
menu "Debug"
|
||||
config COMPILE_DEBUG
|
||||
bool "Enable GCC -g Option"
|
||||
config GDB
|
||||
bool "Enable gdb functions"
|
||||
default n
|
||||
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
|
||||
bool "Enable Os_adapt"
|
||||
@@ -162,6 +201,7 @@ config ENABLE_MAGICKEY
|
||||
config THUMB
|
||||
bool "Enable Thumb"
|
||||
default n
|
||||
depends on ARCH_ARM
|
||||
help
|
||||
Answer Y to build thumb version. This will make LiteOS smaller.
|
||||
|
||||
@@ -184,8 +224,8 @@ config DEBUG_VERSION
|
||||
default n
|
||||
help
|
||||
If you do not select this option that means you enable a release version for LiteOS.
|
||||
It also means you do not want to use debug modules, like shell,telnet,tftp,
|
||||
,nfs,ramfs proc and memory check.
|
||||
It also means you do not want to use debug modules, like shell,telnet,tftp,nfs and
|
||||
memory check, etc.
|
||||
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.
|
||||
|
||||
@@ -219,14 +259,14 @@ config DEBUG_SEMAPHORE
|
||||
help
|
||||
Answer Y to enable debug semaphore.
|
||||
|
||||
source "../../kernel/liteos_a/shell/Kconfig"
|
||||
source "shell/Kconfig"
|
||||
config NET_LWIP_SACK_TFTP
|
||||
bool "Enable Tftp"
|
||||
default y
|
||||
depends on SHELL && NET_LWIP_SACK && DEBUG_VERSION
|
||||
help
|
||||
Answer Y to enable LiteOS support tftp cmd and tftp tool.
|
||||
source "../../kernel/liteos_a/net/telnet/Kconfig"
|
||||
source "net/telnet/Kconfig"
|
||||
config SCHED_DEBUG
|
||||
bool "Enable sched debug Feature"
|
||||
default n
|
||||
@@ -265,7 +305,7 @@ config MEM_LEAKCHECK
|
||||
help
|
||||
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
|
||||
config BASE_MEM_NODE_INTEGRITY_CHECK
|
||||
bool "Enable integrity check or not "
|
||||
bool "Enable integrity check or not"
|
||||
default n
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
config MEM_WATERLINE
|
||||
@@ -290,20 +330,25 @@ config DRIVERS
|
||||
help
|
||||
Answer Y to enable LiteOS support driver.
|
||||
|
||||
source "../../kernel/liteos_a/bsd/dev/usb/Kconfig"
|
||||
source "bsd/dev/usb/Kconfig"
|
||||
source "../../drivers/adapter/khdf/liteos/Kconfig"
|
||||
|
||||
# Device driver Kconfig import
|
||||
source "$(DEVICE_PATH)/drivers/Kconfig"
|
||||
|
||||
source "drivers/char/mem/Kconfig"
|
||||
source "drivers/char/quickstart/Kconfig"
|
||||
source "drivers/char/random/Kconfig"
|
||||
source "../../drivers/liteos/tzdriver/Kconfig"
|
||||
source "drivers/char/video/Kconfig"
|
||||
source "drivers/char/trace/Kconfig"
|
||||
|
||||
source "../../drivers/liteos/tzdriver/Kconfig"
|
||||
source "../../drivers/liteos/hievent/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
||||
menu "Security"
|
||||
source "../../kernel/liteos_a/security/Kconfig"
|
||||
source "security/Kconfig"
|
||||
endmenu
|
||||
|
||||
menu "Test"
|
||||
|
||||
270
Makefile
270
Makefile
@@ -27,44 +27,57 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LITEOSTOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
|
||||
export OS=$(shell uname -s)
|
||||
ifneq ($(OS), Linux)
|
||||
LITEOSTOPDIR := $(shell dirname $(subst \,/,$(LITEOSTOPDIR))/./)
|
||||
endif
|
||||
|
||||
LITEOSTHIRDPARTY := $(LITEOSTOPDIR)/../../third_party
|
||||
|
||||
LITEOSTOPDIR := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
export LITEOSTOPDIR
|
||||
export LITEOSTHIRDPARTY
|
||||
|
||||
RM = -rm -rf
|
||||
MAKE = make
|
||||
__LIBS = libs
|
||||
APPS = apps
|
||||
ROOTFSDIR = rootfsdir
|
||||
ROOTFS = rootfs
|
||||
|
||||
LITEOS_TARGET = liteos
|
||||
LITEOS_LIBS_TARGET = libs_target
|
||||
LITEOS_MENUCONFIG_H = $(LITEOSTOPDIR)/include/generated/autoconf.h
|
||||
LITEOS_PLATFORM_BASE = $(LITEOSTOPDIR)/platform
|
||||
LITEOS_LIBS_TARGET = libs
|
||||
KCONFIG_CMDS := $(notdir $(wildcard $(dir $(shell which menuconfig))*config))
|
||||
|
||||
export CONFIG_=LOSCFG_
|
||||
MENUCONFIG_PATH = $(LITEOSTOPDIR)/tools/menuconfig
|
||||
KCONFIG_FILE_PATH = $(LITEOSTOPDIR)/Kconfig
|
||||
|
||||
ifeq ($(OS), Linux)
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/mconf
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/conf
|
||||
else
|
||||
MENUCONFIG_MCONF := $(MENUCONFIG_PATH)/kconfig-mconf.exe
|
||||
MENUCONFIG_CONF := $(MENUCONFIG_PATH)/kconfig-conf.exe
|
||||
ohos_kernel ?= liteos_a
|
||||
$(foreach line,$(shell hb env | sed 's/\[OHOS INFO\]/ohos/g;s/ /_/g;s/:_/=/g' || true),$(eval $(line)))
|
||||
ifneq ($(ohos_kernel),liteos_a)
|
||||
$(error The selected product ($(ohos_product)) is not a liteos_a kernel type product)
|
||||
endif
|
||||
|
||||
$(shell env CONFIG_=$(CONFIG_) $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH))
|
||||
ifeq ($(PRODUCT_PATH),)
|
||||
PRODUCT_PATH:=$(ohos_product_path)
|
||||
endif
|
||||
|
||||
-include $(LITEOSTOPDIR)/tools/build/config.mk
|
||||
ifeq ($(DEVICE_PATH),)
|
||||
DEVICE_PATH:=$(ohos_device_path)
|
||||
endif
|
||||
|
||||
ifeq ($(TEE:1=y),y)
|
||||
tee = _tee
|
||||
endif
|
||||
ifeq ($(RELEASE:1=y),y)
|
||||
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/release$(tee).config
|
||||
else
|
||||
CONFIG ?= $(PRODUCT_PATH)/kernel_configs/debug$(tee).config
|
||||
endif
|
||||
|
||||
KCONFIG_CONFIG ?= $(CONFIG)
|
||||
SYSROOT_PATH ?= $(OUT)/sysroot
|
||||
LITEOS_MENUCONFIG_H ?= $(LITEOSTOPDIR)/config.h
|
||||
LITEOS_CONFIG_FILE ?= $(LITEOSTOPDIR)/.config
|
||||
|
||||
# export los_config.mk related environment variables
|
||||
export LITEOS_MENUCONFIG_H
|
||||
export LITEOS_CONFIG_FILE
|
||||
|
||||
# export subdir Makefile related environment variables
|
||||
export SYSROOT_PATH
|
||||
export PRODUCT_PATH
|
||||
export DEVICE_PATH
|
||||
|
||||
# export kconfig related environment variables
|
||||
export CONFIG_=LOSCFG_
|
||||
export srctree=$(LITEOSTOPDIR)
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(LOSCFG_STORAGE_SPINOR), y)
|
||||
FSTYPE = jffs2
|
||||
@@ -80,141 +93,118 @@ FSTYPE = jffs2
|
||||
endif
|
||||
ROOTFS_DIR = $(OUT)/rootfs
|
||||
ROOTFS_ZIP = $(OUT)/rootfs.zip
|
||||
VERSION =
|
||||
|
||||
all: $(OUT) $(BUILD) $(LITEOS_TARGET) $(APPS)
|
||||
lib: $(OUT) $(BUILD) $(LITEOS_LIBS_TARGET)
|
||||
define HELP =
|
||||
Usage: make [TARGET]... [PARAMETER=VALUE]...
|
||||
|
||||
Targets:
|
||||
help: display this help and exit
|
||||
clean: clean compiled objects
|
||||
cleanall: clean all build outputs
|
||||
all: make liteos kernel image and rootfs image (Default target)
|
||||
$(APPS): build all apps
|
||||
$(ROOTFS): make a original rootfs image
|
||||
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
|
||||
$(LITEOS_TARGET): make liteos kernel image
|
||||
update_config: update product kernel config (use menuconfig)
|
||||
xxconfig: invoke xxconfig command of kconfiglib (xxconfig is one of $(KCONFIG_CMDS))
|
||||
|
||||
Parameters:
|
||||
FSTYPE: value should be one of (jffs2 vfat yaffs2)
|
||||
TEE: boolean value(1 or y for true), enable tee
|
||||
RELEASE: boolean value(1 or y for true), build release version
|
||||
CONFIG: kernel config file to be use
|
||||
args: arguments for xxconfig command
|
||||
endef
|
||||
export HELP
|
||||
|
||||
all: $(LITEOS_TARGET) $(ROOTFS)
|
||||
|
||||
help:
|
||||
$(HIDE)echo "-------------------------------------------------------"
|
||||
$(HIDE)echo "1.====make help: get help infomation of make"
|
||||
$(HIDE)echo "2.====make: make a debug version based the .config"
|
||||
$(HIDE)echo "3.====make debug: make a debug version based the .config"
|
||||
$(HIDE)echo "4.====make release: make a release version for all platform"
|
||||
$(HIDE)echo "5.====make release PLATFORM=xxx: make a release version only for platform xxx"
|
||||
$(HIDE)echo "6.====make rootfsdir: make a original rootfs dir"
|
||||
$(HIDE)echo "7.====make rootfs FSTYPE=***: make a original rootfs img"
|
||||
$(HIDE)echo "8.====make test: make the testsuits_app and put it into the rootfs dir"
|
||||
$(HIDE)echo "9.====make test_apps FSTYPE=***: make a rootfs img with the testsuits_app in it"
|
||||
$(HIDE)echo "xxx should be one of (hi3516cv300 hi3516ev200 hi3556av100/cortex-a53_aarch32 hi3559av100/cortex-a53_aarch64)"
|
||||
$(HIDE)echo "*** should be one of (jffs2)"
|
||||
$(HIDE)echo "-------------------------------------------------------"
|
||||
$(HIDE)echo "$$HELP"
|
||||
|
||||
debug:
|
||||
$(HIDE)echo "=============== make a debug version ==============="
|
||||
$(HIDE) $(MAKE) all
|
||||
|
||||
release:
|
||||
ifneq ($(PLATFORM),)
|
||||
$(HIDE)echo "=============== make a release version for platform $(PLATFORM) ==============="
|
||||
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh $(PLATFORM)
|
||||
else
|
||||
$(HIDE)echo "================make a release version for all platform ==============="
|
||||
$(HIDE)$(SCRIPTS_PATH)/mklibversion.sh
|
||||
sysroot:
|
||||
$(HIDE)echo "sysroot:" $(abspath $(SYSROOT_PATH))
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
ifeq ($(origin SYSROOT_PATH),file)
|
||||
$(HIDE)mkdir -p $(SYSROOT_PATH)/build && cd $(SYSROOT_PATH)/build && \
|
||||
ln -snf $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/build/Makefile && \
|
||||
$(MAKE) TARGETS=liteos_a_user \
|
||||
ARCH=$(ARCH) \
|
||||
TARGET=$(LOSCFG_LLVM_TARGET) \
|
||||
ARCH_CFLAGS="$(LITEOS_CORE_COPTS) -w" \
|
||||
TOPDIR="$(LITEOSTOPDIR)/../.." \
|
||||
SYSROOTDIR="$(SYSROOT_PATH)" \
|
||||
CLANG="$(LITEOS_COMPILER_PATH)clang" \
|
||||
BUILD_ALL_MULTILIB=false \
|
||||
BUILD_DEBUG=$(if $(patsubst y,,$(or $(RELEASE:1=y),n)),true,false)
|
||||
endif
|
||||
endif
|
||||
|
||||
##### make dynload #####
|
||||
-include $(LITEOS_MK_PATH)/dynload.mk
|
||||
$(filter-out menuconfig,$(KCONFIG_CMDS)):
|
||||
$(HIDE)$@ $(args)
|
||||
|
||||
#-----need move when make version-----#
|
||||
##### make lib #####
|
||||
$(__LIBS): $(OUT) $(CXX_INCLUDE)
|
||||
$(LITEOS_CONFIG_FILE): $(KCONFIG_CONFIG)
|
||||
$(HIDE)env KCONFIG_CONFIG=$< genconfig --config-out $@ --header-path $(LITEOS_MENUCONFIG_H)
|
||||
|
||||
$(OUT): $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)mkdir -p $(OUT)/lib
|
||||
$(HIDE)$(CC) -I$(LITEOSTOPDIR)/kernel/base/include -I$(LITEOSTOPDIR)/../../$(LOSCFG_BOARD_CONFIG_PATH) \
|
||||
-I$(LITEOS_PLATFORM_BASE)/include -imacros $< -E $(LITEOS_PLATFORM_BASE)/board.ld.S \
|
||||
-o $(LITEOS_PLATFORM_BASE)/board.ld -P
|
||||
update_config menuconfig:
|
||||
$(HIDE)test -f "$(CONFIG)" && cp -v "$(CONFIG)" .config && menuconfig $(args) && savedefconfig --out "$(CONFIG)"
|
||||
|
||||
$(BUILD):
|
||||
$(HIDE)mkdir -p $(BUILD)
|
||||
$(LITEOS_LIBS_TARGET): sysroot
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
|
||||
|
||||
$(LITEOS_LIBS_TARGET): $(__LIBS)
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir all || exit 1; \
|
||||
done
|
||||
$(HIDE)echo "=============== make lib done ==============="
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET)
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).map
|
||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).objsize
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).bin
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).sym.sorted
|
||||
$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).asm
|
||||
#$(LITEOS_TARGET): $(OUT)/$(LITEOS_TARGET).size
|
||||
|
||||
##### make menuconfig #####
|
||||
menuconfig:$(MENUCONFIG_MCONF)
|
||||
$< $(KCONFIG_FILE_PATH)
|
||||
$(OUT)/$(LITEOS_TARGET): $(LITEOS_LIBS_TARGET)
|
||||
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) -Map=$@.map -o $@ --start-group $(LITEOS_LIBDEP) --end-group
|
||||
$(OUT)/$(LITEOS_TARGET).map: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OUT)/$(LITEOS_TARGET).objsize: $(LITEOS_LIBS_TARGET)
|
||||
$(SIZE) -t --common $(OUT)/lib/*.a >$@
|
||||
$(OUT)/$(LITEOS_TARGET).bin: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJCOPY) -O binary $< $@
|
||||
$(OUT)/$(LITEOS_TARGET).sym.sorted: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJDUMP) -t $< |sort >$@
|
||||
$(OUT)/$(LITEOS_TARGET).asm: $(OUT)/$(LITEOS_TARGET)
|
||||
$(OBJDUMP) -d $< >$@
|
||||
$(OUT)/$(LITEOS_TARGET).size: $(OUT)/$(LITEOS_TARGET)
|
||||
$(NM) -S --size-sort $< >$@
|
||||
|
||||
genconfig:$(MENUCONFIG_CONF)
|
||||
$(HIDE)mkdir -p include/config include/generated
|
||||
$< --olddefconfig $(KCONFIG_FILE_PATH)
|
||||
$< --silentoldconfig $(KCONFIG_FILE_PATH)
|
||||
##### menuconfig end #######
|
||||
|
||||
$(LITEOS_MENUCONFIG_H): .config
|
||||
$(HIDE)$(MAKE) genconfig
|
||||
|
||||
$(LITEOS_TARGET): $(__LIBS)
|
||||
$(HIDE)touch $(LOSCFG_ENTRY_SRC)
|
||||
|
||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir all || exit 1; \
|
||||
done
|
||||
|
||||
$(LD) $(LITEOS_LDFLAGS) $(LITEOS_TABLES_LDFLAGS) $(LITEOS_DYNLDFLAGS) -Map=$(OUT)/$@.map -o $(OUT)/$@ --start-group $(LITEOS_LIBDEP) --end-group
|
||||
# $(SIZE) -t --common $(OUT)/lib/*.a >$(OUT)/$@.objsize
|
||||
$(OBJCOPY) -O binary $(OUT)/$@ $(LITEOS_TARGET_DIR)/$@.bin
|
||||
$(OBJDUMP) -t $(OUT)/$@ |sort >$(OUT)/$@.sym.sorted
|
||||
$(OBJDUMP) -d $(OUT)/$@ >$(OUT)/$@.asm
|
||||
# $(NM) -S --size-sort $(OUT)/$@ >$(OUT)/$@.size
|
||||
|
||||
$(APPS): $(LITEOS_TARGET)
|
||||
$(APPS): sysroot
|
||||
$(HIDE)$(MAKE) -C apps all
|
||||
|
||||
prepare:
|
||||
$(ROOTFS): $(APPS)
|
||||
$(HIDE)mkdir -p $(OUT)/musl
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
$(HIDE)cp -f $(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/usr/lib/$(LLVM_TARGET)/a7_softfp_neon-vfpv4/libc.so $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/lib/$(LLVM_TARGET)/c++/a7_softfp_neon-vfpv4/libc++.so $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(CC) $(LITEOS_CFLAGS) -print-file-name=libc.so) $(OUT)/musl
|
||||
$(HIDE)cp -fp $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libc++.so) $(OUT)/musl
|
||||
else
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/target/usr/lib/libc.so $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libstdc++.so.6 $(OUT)/musl
|
||||
$(HIDE)cp -f $(LITEOS_COMPILER_PATH)/arm-linux-musleabi/lib/libgcc_s.so.1 $(OUT)/musl
|
||||
$(STRIP) $(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 $$($(GPP) $(LITEOS_CXXFLAGS) -print-file-name=libstdc++.so.6) $(OUT)/musl
|
||||
endif
|
||||
|
||||
$(ROOTFSDIR): prepare $(APPS)
|
||||
$(HIDE)$(MAKE) clean -C apps
|
||||
$(HIDE)$(LITEOSTOPDIR)/tools/scripts/make_rootfs/rootfsdir.sh $(OUT)/bin $(OUT)/musl $(ROOTFS_DIR) $(LITEOS_TARGET_DIR)
|
||||
$(HIDE)$(LITEOS_SCRIPTPATH)/make_rootfs/rootfsdir.sh $(OUT) $(ROOTFS_DIR)
|
||||
$(HIDE)shopt -s nullglob && $(STRIP) $(ROOTFS_DIR)/bin/* $(ROOTFS_DIR)/lib/*
|
||||
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
|
||||
|
||||
$(ROOTFS): $(ROOTFSDIR)
|
||||
$(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)
|
||||
|
||||
clean:
|
||||
$(HIDE)for dir in $(LITEOS_SUBDIRS); \
|
||||
do $(MAKE) -C $$dir clean|| exit 1; \
|
||||
done
|
||||
$(HIDE)$(MAKE) -C apps clean
|
||||
$(HIDE)$(RM) $(__OBJS) $(LITEOS_TARGET) $(BUILD) $(LITEOS_MENUCONFIG_H) *.bak *~
|
||||
$(HIDE)$(RM) include/config include/generated
|
||||
$(HIDE)$(MAKE) cleanrootfs
|
||||
$(HIDE)echo "clean $(LITEOS_PLATFORM) finish"
|
||||
$(HIDE)if [ -d $(SYSROOT_PATH)/build ]; then $(MAKE) -C $(SYSROOT_PATH)/build clean; fi
|
||||
$(HIDE)for dir in $(LIB_SUBDIRS) apps; do $(MAKE) -C $$dir clean || exit 1; done
|
||||
$(HIDE)$(RM) $(LITEOS_MENUCONFIG_H)
|
||||
$(HIDE)echo "clean $(LOSCFG_PLATFORM) finish"
|
||||
|
||||
cleanall: clean
|
||||
$(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_PLATFORM_BASE)/board.ld
|
||||
$(HIDE)$(RM) $(LITEOSTOPDIR)/out $(LITEOS_CONFIG_FILE)
|
||||
$(HIDE)echo "clean all done"
|
||||
|
||||
cleanrootfs:
|
||||
$(HIDE)$(RM) $(OUT)/rootfs
|
||||
$(HIDE)$(RM) $(OUT)/rootfs.zip
|
||||
$(HIDE)$(RM) $(OUT)/rootfs.img
|
||||
|
||||
update_all_config:
|
||||
$(HIDE)shopt -s globstar && for f in tools/build/config/**/*.config ; \
|
||||
do \
|
||||
echo updating $$f; \
|
||||
test -f $$f && cp $$f .config && $(MENUCONFIG_CONF) -s --olddefconfig $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig $$f $(KCONFIG_FILE_PATH); \
|
||||
done
|
||||
|
||||
%.config:
|
||||
$(HIDE)test -f tools/build/config/$@ && cp tools/build/config/$@ .config && $(MENUCONFIG_MCONF) $(KCONFIG_FILE_PATH) && $(MENUCONFIG_CONF) --savedefconfig tools/build/config/$@ $(KCONFIG_FILE_PATH)
|
||||
|
||||
.PHONY: all lib clean cleanall $(LITEOS_TARGET) debug release help update_all_config
|
||||
.PHONY: all clean cleanall sysroot help update_config
|
||||
.PHONY: $(LITEOS_TARGET) $(ROOTFS) $(APPS) $(KCONFIG_CMDS) $(LITEOS_LIBS_TARGET) $(KCONFIG_CONFIG)
|
||||
|
||||
83
OAT.xml
Normal file
83
OAT.xml
Normal file
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
|
||||
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
|
||||
</policy>
|
||||
</policylist>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="文件属于FreeBSD仓库软连接,本仓库屏蔽告警,在FreeBSD仓库进行处理">
|
||||
<filteritem type="filepath" name="bsd/.*" desc="文件属于FreeBSD仓库软连接,本仓库屏蔽告警,在FreeBSD仓库进行处理"/>
|
||||
<filteritem type="filepath" name="kernel/extended" desc="文件属于Nuttx仓库软连接,本仓库屏蔽告警,在Nuttx仓库进行处理"/>
|
||||
<filteritem type="filepath" name="fs/include/fs" desc="文件属于Nuttx仓库软连接,本仓库屏蔽告警,在Nuttx仓库进行处理"/>
|
||||
</filefilter>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="copyrightPolicyFilter" desc="Filters for copyright header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="licenseFileNamePolicyFilter" desc="Filters for LICENSE file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeFileNamePolicyFilter" desc="Filters for README file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="readmeOpenSourcefileNamePolicyFilter" desc="Filters for README.OpenSource file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="binaryFileTypePolicyFilter" desc="Filters for binary file policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
|
||||
</filefilterlist>
|
||||
<licensematcherlist>
|
||||
<!--licensematcher name="uvwxyz License" desc="If the scanning result is InvalidLicense, you can define matching rules here. Note that quotation marks must be escaped.">
|
||||
<licensetext name="
|
||||
uvwxyz license textA xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
<licensetext name="
|
||||
uvwxyz license textB xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
" desc=""/>
|
||||
</licensematcher-->
|
||||
</licensematcherlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
||||
13
README.md
13
README.md
@@ -67,26 +67,27 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
|
||||
|
||||
## Usage<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3518-development-board.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/introduction-to-the-hi3516-development-board.md). You can develop and run your applications based on both development boards.
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on both development boards.
|
||||
|
||||
### Preparations<a name="section1579912573329"></a>
|
||||
|
||||
You need to set up the compilation environment on Linux.
|
||||
|
||||
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3518-development-environment.md).
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/setting-up-the-hi3516-development-environment.md).
|
||||
- [Compilation environment on Linux](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-lin.md)
|
||||
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-setting.md).
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-setting.md).
|
||||
|
||||
### Source Code Acquisition<a name="section11443189655"></a>
|
||||
|
||||
Download and decompress a set of source code on a Linux server to acquire the [source code](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz). For more acquisition methods, see [Source Code Acquisition](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/source-code-acquisition.md).
|
||||
Download and decompress a set of source code on a Linux server to acquire the [source code](https://gitee.com/openharmony/docs/blob/master/en/device-dev/get-code/sourcecode-acquire.md).
|
||||
|
||||
### Compilation and Building<a name="section2081013992812"></a>
|
||||
|
||||
For details about how to develop the first application, see:
|
||||
|
||||
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3518.md)
|
||||
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-running.md)
|
||||
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/developing-the-first-example-program-running-on-hi3516.md)
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-running.md)
|
||||
|
||||
## Repositories Involved<a name="section1371113476307"></a>
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代內核,Huawei LiteOS是面向IoT領域構建的輕量級物聯網操作系統。在IoT產業高速發展的潮流中,OpenHarmony LiteOS-A內核能夠帶給用戶小體積、低功耗、高性能的體驗以及統一開放的生態系統能力,新增了豐富的內核機制、更加全面的POSIX標準接口以及統一驅動框架**HDF**(OpenHarmony Driver Foundation)等,為設備廠商提供了更統一的接入方式,為OpenHarmony的應用開發者提供了更友好的開發體驗。圖1為OpenHarmony LiteOS-A內核架構圖:
|
||||
|
||||
**圖 1** OpenHarmony LiteOS-A內核架構圖<a name="fig27311582210"></a>
|
||||

|
||||
|
||||

|
||||
|
||||
## 目錄<a name="section161941989596"></a>
|
||||
|
||||
@@ -67,31 +68,32 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
|
||||
|
||||
## 使用說明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5% 8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))、Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh- cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
|
||||
OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md))、Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
|
||||
|
||||
### 準備<a name="section1579912573329"></a>
|
||||
|
||||
開發者需要在Linux上搭建編譯環境:
|
||||
|
||||
- Hi3518EV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E6%90%AD%E5%BB% BA%E7%8E%AF%E5%A2%83.md);
|
||||
- Hi3516DV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E6%90%AD%E5%BB %BA%E7%8E%AF%E5%A2%83.md)。
|
||||
- [Ubuntu編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- Hi3516DV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
|
||||
### 獲取源碼<a name="section11443189655"></a>
|
||||
|
||||
在Linux服務器上下載並解壓一套源代碼,獲取源碼([下載鏈結](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz))。更多源碼獲取方式,參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0 %81%E8%8E%B7%E5%8F%96.md)。
|
||||
在Linux服務器上下載並解壓一套源代碼,源碼獲取方式參考[源碼獲取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||
|
||||
### 編譯構建<a name="section2081013992812"></a>
|
||||
|
||||
開發者開發第一個應用程序可參考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3518%E7% AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B%E7%A8%8B%E5%BA%8F.md);
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E5%BC%80%E5%8F%91Hi3516%E7% AC%AC%E4%B8%80%E4%B8%AA%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%A4%BA%E4%BE% 8B.md)。
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||
|
||||
## 相關倉<a name="section1371113476307"></a>
|
||||
|
||||
[內核子系統](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3 %BB%E7%BB%9F.md)
|
||||
[內核子系統](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E5%86%85%E6%A0%B8%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
|
||||
|
||||
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
|
||||
|
||||
**kernel\_liteos\_a**
|
||||
**kernel\_liteos\_a**
|
||||
|
||||
13
README_zh.md
13
README_zh.md
@@ -67,26 +67,27 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
|
||||
|
||||
## 使用说明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF%E4%BB%8B%E7%BB%8D.md))单板,开发者可基于两种单板开发运行自己的应用程序。
|
||||
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))单板,开发者可基于两种单板开发运行自己的应用程序。
|
||||
|
||||
### 准备<a name="section1579912573329"></a>
|
||||
|
||||
开发者需要在Linux上搭建编译环境:
|
||||
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3518%E5%BC%80%E5%8F%91%E6%9D%BF.md);
|
||||
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Hi3516%E5%BC%80%E5%8F%91%E6%9D%BF.md)。
|
||||
- [Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
|
||||
### 获取源码<a name="section11443189655"></a>
|
||||
|
||||
在Linux服务器上下载并解压一套源代码,获取源码([下载链接](https://repo.huaweicloud.com/harmonyos/os/1.0.1/code-1.0.1.tar.gz))。更多源码获取方式,参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/%E6%BA%90%E7%A0%81%E8%8E%B7%E5%8F%96.md)。
|
||||
在Linux服务器上下载并解压一套源代码,源码获取方式参考[源码获取](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md)。
|
||||
|
||||
### 编译构建<a name="section2081013992812"></a>
|
||||
|
||||
开发者开发第一个应用程序可参考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E8%BF%90%E8%A1%8CHello-OHOS-4.md);
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/%E8%BF%90%E8%A1%8CHello-OHOS.md)。
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||
|
||||
## 相关仓<a name="section1371113476307"></a>
|
||||
|
||||
|
||||
61
TODOList.md
61
TODOList.md
@@ -1,61 +0,0 @@
|
||||
- liteos_m易用性
|
||||
- [ ] liteos_m开发者手册
|
||||
- [ ] 低功耗框架及实现(含投票机制)
|
||||
- [ ] dump增强(配套解析工具)
|
||||
- [ ] 全内存dump(配套解析工具)
|
||||
- [ ] 实现完整L0 OHOS的qemu仿真
|
||||
- [ ] Shell + AT
|
||||
|
||||
- liteos_m能力增强
|
||||
- [ ] liteos_m支持elf动态加载
|
||||
- [ ] 基于MPU/PMP的多任务简化隔离
|
||||
- [ ] 基于MPU/PMP的多BIN隔离及灌段隔离
|
||||
- [ ] 扩展支持中断嵌套
|
||||
- [ ] 支持arm9架构
|
||||
- [ ] 支持xtensa架构
|
||||
|
||||
- 文件系统增强
|
||||
- [ ] 提供一种好用且开源的NandFlash文件系统
|
||||
- [ ] 面向fat32、jffs2持续性能优化,做到极致
|
||||
- [ ] fat32支持fast seek(现有fast seek限制文件扩展,需要改造)
|
||||
- [ ] 支持软链接
|
||||
- [ ] 头文件引用关系整理
|
||||
- [ ] 接口层去nuttx
|
||||
- [ ] 文件系统去大锁
|
||||
|
||||
- liteos_a支持三方芯片易移植性
|
||||
- [ ] 启动框架重构
|
||||
- [ ] musl库归一化
|
||||
- [ ] 去C库预编译
|
||||
- [ ] 宏配置依赖关系整理
|
||||
- [ ] 典型商用配置场景整理并导入门禁(1V1映射,去缺页,去隔离,单进程等等)
|
||||
- [ ] 编译框架整合到gn
|
||||
- [ ] 实现基于python的kconfig可视化配置
|
||||
|
||||
- liteos_a易用性
|
||||
- [ ] 实现L1 LiteOS-A及上层鸿蒙组件的qemu仿真
|
||||
- [ ] liteos_a开发者手册
|
||||
- [ ] mksh移植
|
||||
- [ ] toybox命令集
|
||||
- [ ] trace、backtrace、dump解析工具等
|
||||
- procfs适配
|
||||
- [ ] ifconfig、fd、free等
|
||||
|
||||
- liteos_a能力增强
|
||||
- [ ] 单链表整改(SMP多核性能)
|
||||
- [ ] 快启
|
||||
- [ ] 典型高频函数C库性能优化
|
||||
- [ ] rwlock
|
||||
|
||||
- liteos_a三方库移植
|
||||
- [ ] libuv、dlna、benchmark、iperf、perf、tcpdump 等等
|
||||
- C库能力补全
|
||||
- [ ] epoll实现
|
||||
|
||||
- 测试验证
|
||||
- [ ] syzkaller、difuze等
|
||||
|
||||
- 探索性课题
|
||||
- [ ] 基于rust重写liteos_m基础内核
|
||||
- [ ] 用户态驱动(对比业界并增强)
|
||||
- [ ] 用户态文件系统
|
||||
54
apps/BUILD.gn
Normal file
54
apps/BUILD.gn
Normal file
@@ -0,0 +1,54 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("apps") {
|
||||
deps = []
|
||||
|
||||
if (defined(LOSCFG_SHELL)) {
|
||||
deps += [
|
||||
"shell",
|
||||
"mksh",
|
||||
"toybox",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_USER_INIT_DEBUG)) {
|
||||
deps += [ "init" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_NET_LWIP_SACK_TFTP)) {
|
||||
deps += [ "tftp" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_TRACE)) {
|
||||
deps += [ "trace" ]
|
||||
}
|
||||
}
|
||||
@@ -27,26 +27,21 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
LITEOSTOPDIR = $(shell pwd)/../
|
||||
APPSTOPDIR := $(shell pwd)
|
||||
LITEOSTOPDIR ?= $(APPSTOPDIR)/..
|
||||
export LITEOSTOPDIR
|
||||
export APPSTOPDIR
|
||||
|
||||
include $(LITEOSTOPDIR)/.config
|
||||
include ./config.mk
|
||||
include ./module.mk
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
HIDE := @
|
||||
APPS := app
|
||||
|
||||
all: $(APPS)
|
||||
|
||||
# Make
|
||||
$(APPS):
|
||||
all:
|
||||
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
|
||||
|
||||
clean:
|
||||
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
|
||||
|
||||
.PHONY: all $(APPS) clean
|
||||
.PHONY: all clean
|
||||
|
||||
114
apps/app.mk
Normal file
114
apps/app.mk
Normal file
@@ -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 :=
|
||||
@@ -27,30 +27,18 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# common dir config
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
# output dir config
|
||||
OBJOUT := $(APPSTOPDIR)/out
|
||||
APPSOUT := $(OBJOUT)/apps
|
||||
LIBSOUT := $(OBJOUT)/libs
|
||||
IMGOUT := $(OUT)
|
||||
|
||||
# common flags config
|
||||
BASE_OPTS := -ffunction-sections -fdata-sections -fno-omit-frame-pointer -fno-common -fno-strict-aliasing -D_GNU_SOURCE \
|
||||
$(LITEOS_SSP) $(LITEOS_CORE_COPTS) $(WARNING_AS_ERROR) $(LLVM_EXTRA_OPTS) $(LITEOS_GCOV_OPTS)
|
||||
BASE_OPTS := -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE $(LITEOS_GCOV_OPTS)
|
||||
|
||||
CFLAGS := -std=c99 -fno-exceptions $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
CXXFLAGS := -std=c++11 -fexceptions -fpermissive -frtti $(BASE_OPTS) $(LITEOS_COPTS_OPTMIZE)
|
||||
LDCFLAGS := -lc
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LLVM_SYSROOT := --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
||||
LDCXXFLGS := -lc++ -lc++abi -lc
|
||||
else
|
||||
BASE_OPTS += -Wl,-z,relro,-z,now
|
||||
LDCXXFLGS := -lstdc++ -lsupc++ -lc
|
||||
endif
|
||||
COMMON_INCLUDE := -I $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
||||
ASFLAGS :=
|
||||
CFLAGS := $(LITEOS_COPTS) $(BASE_OPTS) -fPIE
|
||||
CXXFLAGS := $(LITEOS_CXXOPTS) $(BASE_OPTS) -fPIE
|
||||
LDFLAGS := $(LITEOS_CORE_COPTS) -pie -Wl,-z,relro,-z,now -O2
|
||||
|
||||
CFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib,$(CFLAGS))
|
||||
CXXFLAGS := $(filter-out -fno-pic -fno-builtin -nostdinc -nostdlib -nostdinc++,$(CXXFLAGS))
|
||||
|
||||
# alias variable config
|
||||
HIDE := @
|
||||
@@ -58,3 +46,35 @@ MAKE := make
|
||||
RM := rm -rf
|
||||
CP := cp -rf
|
||||
MV := mv -f
|
||||
|
||||
APP := $(APPSTOPDIR)/app.mk
|
||||
|
||||
##build modules config##
|
||||
APP_SUBDIRS :=
|
||||
|
||||
ifeq ($(LOSCFG_SHELL), y)
|
||||
APP_SUBDIRS += shell
|
||||
APP_SUBDIRS += mksh
|
||||
APP_SUBDIRS += toybox
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
||||
APP_SUBDIRS += init
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
|
||||
APP_SUBDIRS += tftp
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_TRACE), y)
|
||||
APP_SUBDIRS += trace
|
||||
endif
|
||||
|
||||
# clear all local variables
|
||||
LOCAL_FLAGS :=
|
||||
LOCAL_CFLAGS :=
|
||||
LOCAL_CPPFLAGS :=
|
||||
LOCAL_ASFLAGS :=
|
||||
LOCAL_SRCS :=
|
||||
LOCAL_CHS :=
|
||||
LOCAL_CPPHS :=
|
||||
|
||||
20
tools/scripts/make_rootfs/rootfs.sh → apps/init/BUILD.gn
Executable file → Normal file
20
tools/scripts/make_rootfs/rootfs.sh → apps/init/BUILD.gn
Executable file → Normal file
@@ -1,5 +1,3 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
@@ -28,12 +26,14 @@
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
set -e
|
||||
|
||||
BIN_DIR=$1
|
||||
LIB_DIR=$2
|
||||
ROOTFS_DIR=$3
|
||||
FSTYPE=$4
|
||||
CUR_DIR=$(dirname $(readlink -f "$0"))
|
||||
. ${CUR_DIR}/rootfsdir.sh ${BIN_DIR} ${LIB_DIR} ${ROOTFS_DIR}
|
||||
. ${CUR_DIR}/rootfsimg.sh ${ROOTFS_DIR} ${FSTYPE}
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("init") {
|
||||
sources = [ "src/init.c" ]
|
||||
|
||||
if (defined(LOSCFG_QUICK_START)) {
|
||||
ldflags = [ "--static" ]
|
||||
defines = [ "LOSCFG_QUICK_START" ]
|
||||
}
|
||||
}
|
||||
@@ -27,43 +27,15 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
INIT_DIR := $(dir $(shell pwd))/init/
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(INIT_DIR)/../config.mk
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
LOCAL_SRCS := src/init.c
|
||||
LOCAL_OBJ := src/init.o
|
||||
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses -Wnonnull $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_QUICK_START), y)
|
||||
LDCFLAGS += --static
|
||||
LDFLAGS += --static
|
||||
CFLAGS += -DLOSCFG_QUICK_START
|
||||
endif
|
||||
|
||||
INITNAME := init
|
||||
|
||||
all: $(INITNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(CFLAGS) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(INITNAME):$(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(INITNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(INITNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(INITNAME)
|
||||
|
||||
.PHONY: all $(INITNAME) clean
|
||||
include $(APP)
|
||||
|
||||
99
apps/mksh/BUILD.gn
Normal file
99
apps/mksh/BUILD.gn
Normal file
@@ -0,0 +1,99 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("mksh") {
|
||||
deps = [ ":build_mksh" ]
|
||||
}
|
||||
|
||||
copy("copy_mksh_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/mksh" ]
|
||||
outputs = [ "$target_out_dir/mksh_build" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_mksh") {
|
||||
deps = [ ":copy_mksh_src" ]
|
||||
deps += [ "//prebuilts/lite/sysroot" ]
|
||||
exec_path = rebase_path("$target_out_dir/mksh_build")
|
||||
|
||||
cflags = [
|
||||
"-flto",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fstack-protector-strong",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
"-DMKSH_DISABLE_TTY_WARNING",
|
||||
"-DMKSH_SMALL=1",
|
||||
"-DMKSH_ASSUME_UTF8=1",
|
||||
"-DMKSH_SMALL_BUT_FAST=0",
|
||||
"-DMKSH_S_NOVI=1",
|
||||
"-DHAVE_CAN_FSTACKPROTECTORSTRONG=1",
|
||||
"-DMKSH_LESS_CMDLINE_EDITING",
|
||||
"-DMKSH_LESS_BUILDINS",
|
||||
"-DMKSH_NO_INITCOMS",
|
||||
"-DADAPT_FOR_LITEOS_A",
|
||||
]
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags += [ "-Oz" ]
|
||||
} else {
|
||||
cflags += [ "-O2" ]
|
||||
}
|
||||
cflags = string_join(" ", cflags)
|
||||
|
||||
extra_flags = string_join(" ", target_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
extra_flags += " --target=$target_triple"
|
||||
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
|
||||
}
|
||||
|
||||
command = "rm -rf .git && env"
|
||||
command += " CC=\"$ohos_current_cc_command\""
|
||||
command += " TARGET_OS=OpenHarmony"
|
||||
command += " CFLAGS=\"$cflags $extra_flags\""
|
||||
command += " LDFLAGS=\"-Wl,--gc-sections -flto -O2\""
|
||||
command += " sh ./Build.sh -r"
|
||||
|
||||
# copy mksh and .mkshrc to out dir
|
||||
command += " && mkdir -p "
|
||||
command += rebase_path("$root_out_dir/bin", exec_path)
|
||||
command += " && install -D mksh "
|
||||
command += rebase_path("$root_out_dir/unstripped/bin/mksh", exec_path)
|
||||
command += " && $ohos_current_strip_command mksh -o "
|
||||
command += rebase_path("$root_out_dir/bin/mksh", exec_path)
|
||||
command += " && install -D .mkshrc "
|
||||
command += rebase_path("$root_out_dir/etc/.mkshrc", exec_path)
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/unstripped/bin/mksh",
|
||||
"$root_out_dir/bin/mksh",
|
||||
"$root_out_dir/etc/.mkshrc",
|
||||
]
|
||||
}
|
||||
@@ -27,42 +27,30 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
MKSH := mksh
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
MKSH_DIR := $(shell pwd)/
|
||||
LITEOSTOPDIR = $(MKSH_DIR)/../../
|
||||
include $(MKSH_DIR)/../config.mk
|
||||
BUILD_DIR := $(OUT)/mksh_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
BUILD_DIR := $(MKSH_DIR)/build
|
||||
BUILD_LOG := $(MKSH_DIR)/build.log
|
||||
TARGET_OS := OpenHarmony
|
||||
CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
||||
CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
CFLAGS += -Wno-error
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
LOCAL_CFLAGS := -flto -fdata-sections -ffunction-sections -Oz -fstack-protector-strong -D_FORTIFY_SOURCE=2 -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4
|
||||
LOCAL_CFLAGS += --target=arm-liteos --sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/
|
||||
LOCAL_CFLAGS += -DMKSH_DISABLE_TTY_WARNING -DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=1 -DMKSH_SMALL_BUT_FAST=0 -DMKSH_S_NOVI=1 -DHAVE_CAN_FSTACKPROTECTORSTRONG=1
|
||||
LOCAL_CFLAGS += -DMKSH_LESS_CMDLINE_EDITING -DMKSH_LESS_BUILDINS -DMKSH_NO_INITCOMS -DADAPT_FOR_LITEOS_A
|
||||
LOCAL_LDFLAGS := -Wl,--gc-sections -flto -O2
|
||||
|
||||
all:$(MKSH)
|
||||
|
||||
$(MKSH):
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)/Rebuild.sh),)
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Rebuild.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
$(HIDE)cd $(BUILD_DIR) && sh ./Rebuild.sh > $(BUILD_LOG) 2>&1
|
||||
else
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(MKSH)/. $(BUILD_DIR)
|
||||
$(HIDE)chmod +x $(BUILD_DIR)/Build.sh
|
||||
$(HIDE)cd $(BUILD_DIR) && CC=$(CC) TARGET_OS=$(TARGET_OS) CFLAGS="$(LOCAL_CFLAGS)" LDFLAGS="$(LOCAL_LDFLAGS)" ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/mksh/. $(BUILD_DIR)
|
||||
$(HIDE)cd $(BUILD_DIR) && CC="$(CC)" TARGET_OS=OpenHarmony CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" sh ./Build.sh -r > $(BUILD_LOG) 2>&1
|
||||
endif
|
||||
$(HIDE)$(CP) -rf $(BUILD_DIR)/$(MKSH) .
|
||||
$(HIDE)$(STRIP) $(MKSH)
|
||||
$(HIDE)mkdir -p $(APPS_OUT)
|
||||
$(HIDE)$(CP) $(MKSH) $(APPS_OUT)
|
||||
$(HIDE)mkdir -p $(OUT)/bin/ $(OUT)/etc/
|
||||
$(HIDE)$(STRIP) $(BUILD_DIR)/mksh -o $(OUT)/bin/mksh
|
||||
$(HIDE)$(CP) $(BUILD_DIR)/.mkshrc $(OUT)/etc/
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(MKSH) $(BUILD_DIR) $(BUILD_LOG)
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
.PHONY: all $(MKSH) clean
|
||||
.PHONY: all clean
|
||||
|
||||
44
apps/shell/BUILD.gn
Normal file
44
apps/shell/BUILD.gn
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("shell") {
|
||||
sources = [
|
||||
"builtin/cd.c",
|
||||
"src/main.c",
|
||||
"src/shcmd.c",
|
||||
"src/shcmdparse.c",
|
||||
"src/shmsg.c",
|
||||
]
|
||||
|
||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -27,52 +27,19 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
SHELL_DIR := $(dir $(shell pwd))/shell/
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(SHELL_DIR)/../config.mk
|
||||
APPS_OUT := $(OUT)/bin
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
SECUREC_INCLUDE := $(LITEOSTHIRDPARTY)/bounds_checking_function/include
|
||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||
|
||||
LOCAL_SRCS = $(wildcard src/main.c)\
|
||||
$(wildcard src/shcmd.c)\
|
||||
$(wildcard src/shmsg.c)\
|
||||
$(wildcard src/shcmdparse.c)\
|
||||
$(wildcard builtin/cd.c)
|
||||
LOCAL_SRCS += $(wildcard $(LITEOSTHIRDPARTY)/bounds_checking_function/src/*.c)
|
||||
LOCAL_OBJ := $(LOCAL_SRCS:.c=.o)
|
||||
LOCAL_SRCS = $(wildcard src/*.c builtin/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(SHELL_DIR)/include/ \
|
||||
-I $(SECUREC_INCLUDE)\
|
||||
-I include \
|
||||
-I $(SECUREC_DIR)/include
|
||||
|
||||
LOCAL_FLAGS += $(CFLAGS)
|
||||
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||
|
||||
LDPATH := -L$(SHELL_DIR)/
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
SHELLNAME := shell
|
||||
|
||||
all: $(SHELLNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(SHELLNAME): $(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(SHELLNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(SHELLNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(SHELLNAME)
|
||||
|
||||
.PHONY: all $(SHELLNAME) clean
|
||||
include $(APP)
|
||||
|
||||
@@ -42,10 +42,10 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern char *OsShellGetWorkingDirtectory();
|
||||
extern unsigned int OsShellInit();
|
||||
extern char *OsShellGetWorkingDirtectory(void);
|
||||
extern unsigned int OsShellInit(void);
|
||||
extern int OsShellDeinit(ShellCB *shellCB);
|
||||
extern ShellCB *OsGetShellCb();
|
||||
extern ShellCB *OsGetShellCb(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "semaphore.h"
|
||||
#include "securec.h"
|
||||
#include "unistd.h"
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
ShellCB *g_shellCB = NULL;
|
||||
|
||||
@@ -88,11 +88,44 @@ OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main()
|
||||
static int DoShellExec(char **argv)
|
||||
{
|
||||
int i, j;
|
||||
int len = 0;
|
||||
int ret = SH_NOK;
|
||||
char *cmdLine = NULL;
|
||||
|
||||
for (i = 0; argv[i]; i++) {
|
||||
len += strlen(argv[i]);
|
||||
}
|
||||
len += i + 1;
|
||||
cmdLine = (char *)malloc(len);
|
||||
if (!cmdLine) {
|
||||
return ret;
|
||||
}
|
||||
memset_s(cmdLine, len, 0, len);
|
||||
|
||||
for(j = 0; j < i; j++) {
|
||||
strcat_s(cmdLine, len, argv[j]);
|
||||
strcat_s(cmdLine, len, " ");
|
||||
}
|
||||
|
||||
cmdLine[len - 2] = '\0';
|
||||
ret = syscall(__NR_shellexec, argv[0], cmdLine);
|
||||
free(cmdLine);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = SH_NOK;
|
||||
ShellCB *shellCB = NULL;
|
||||
|
||||
if (!strcmp(argv[0], "shell") && argv[1]) {
|
||||
ret = DoShellExec(argv + 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
|
||||
|
||||
41
apps/tftp/BUILD.gn
Normal file
41
apps/tftp/BUILD.gn
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("tftp") {
|
||||
sources = [
|
||||
"src/main.c",
|
||||
"src/tftpc.c",
|
||||
]
|
||||
|
||||
deps = [ "$LITEOSTHIRDPARTY/bounds_checking_function:libsec_static" ]
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -27,51 +27,19 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
ROOT_DIR := $(dir $(shell pwd))/tftp/
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
ifeq ($(APPSTOPDIR), )
|
||||
APPSTOPDIR := $(shell pwd)/../
|
||||
LITEOSTOPDIR = $(APPSTOPDIR)/../
|
||||
endif
|
||||
include $(ROOT_DIR)/../config.mk
|
||||
APPS_OUT := $(OUT)/bin
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
SECUREC_DIR := $(LITEOSTHIRDPARTY)/bounds_checking_function
|
||||
|
||||
LOCAL_SRCS = $(wildcard src/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncpy_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memcpy_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/memset_s.c)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/strncat_s.c)
|
||||
LOCAL_OBJ := $(LOCAL_SRCS:.c=.o)
|
||||
LOCAL_SRCS += $(wildcard $(SECUREC_DIR)/src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(ROOT_DIR)/include/ \
|
||||
-I $(SECUREC_DIR)/include/\
|
||||
-I include \
|
||||
-I $(SECUREC_DIR)/include
|
||||
|
||||
LOCAL_FLAGS += $(CFLAGS)
|
||||
LOCAL_FLAGS += $(LOCAL_INCLUDE)
|
||||
|
||||
LDPATH := -L$(ROOT_DIR)/
|
||||
ifeq ($(LOSCFG_COMPILER_CLANG_LLVM), y)
|
||||
LOCAL_FLAGS += -Wno-shift-op-parentheses -Wno-bitwise-op-parentheses $(LLVM_SYSROOT)
|
||||
LDCFLAGS += $(LLVM_EXTRA_LD_OPTS) $(LLVM_SYSROOT)
|
||||
endif
|
||||
|
||||
TARGETNAME := tftp
|
||||
|
||||
all: $(TARGETNAME)
|
||||
|
||||
$(LOCAL_OBJ): %.o : %.c
|
||||
$(HIDE) $(CC) $(LOCAL_FLAGS) -fPIE $(LOCAL_INCLUDE) -c $< -o $@
|
||||
|
||||
$(TARGETNAME): $(LOCAL_OBJ)
|
||||
$(HIDE) $(CC) -pie -s $(LDPATH) $(BASE_OPTS) -o $(TARGETNAME) $^ $(LDCFLAGS)
|
||||
$(HIDE) mkdir -p $(APPS_OUT)
|
||||
$(HIDE) $(MV) $(TARGETNAME) $(APPS_OUT)
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
|
||||
clean:
|
||||
$(HIDE) $(RM) $(LOCAL_OBJ)
|
||||
$(HIDE) $(RM) $(TARGETNAME)
|
||||
|
||||
.PHONY: all $(TARGETNAME) clean
|
||||
include $(APP)
|
||||
|
||||
80
apps/toybox/BUILD.gn
Normal file
80
apps/toybox/BUILD.gn
Normal file
@@ -0,0 +1,80 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("toybox") {
|
||||
deps = [ ":build_toybox" ]
|
||||
}
|
||||
|
||||
copy("copy_toybox_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/toybox" ]
|
||||
outputs = [ "$target_out_dir/toybox_build" ]
|
||||
}
|
||||
|
||||
copy("copy_toybox_config") {
|
||||
deps = [ ":copy_toybox_src" ]
|
||||
sources = [ "liteos_a_custom.config" ]
|
||||
outputs = [ "$target_out_dir/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
build_ext_component("build_toybox") {
|
||||
deps = [ ":copy_toybox_src", ":copy_toybox_config" ]
|
||||
deps += [ "//prebuilts/lite/sysroot" ]
|
||||
exec_path = rebase_path("$target_out_dir/toybox_build")
|
||||
|
||||
cflags = [
|
||||
"-fstack-protector-strong",
|
||||
"-D_FORTIFY_SOURCE=2",
|
||||
]
|
||||
cflags = string_join(" ", cflags)
|
||||
|
||||
extra_flags = string_join(" ", target_arch_cflags)
|
||||
if (ohos_build_compiler == "clang") {
|
||||
extra_flags += " --target=$target_triple"
|
||||
extra_flags += " --sysroot=" + rebase_path(ohos_current_sysroot)
|
||||
}
|
||||
|
||||
command = "rm -rf .git && cp -rfp porting/liteos_a/. . && env"
|
||||
command += " CC=\"$ohos_current_cc_command\""
|
||||
command += " STRIP=\"$ohos_current_strip_command\""
|
||||
command += " OUTNAME=toybox"
|
||||
command += " CFLAGS=\"$cflags $extra_flags\""
|
||||
command += " make toybox"
|
||||
command += " && install -D toybox "
|
||||
command += rebase_path("$root_out_dir/bin/toybox", exec_path)
|
||||
command += " && install -D generated/unstripped/toybox "
|
||||
command += rebase_path("$root_out_dir/unstripped/bin/toybox", exec_path)
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/unstripped/bin/toybox",
|
||||
"$root_out_dir/bin/toybox",
|
||||
]
|
||||
}
|
||||
@@ -27,34 +27,27 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
TOYBOX:= toybox
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
TOYBOX_DIR := $(shell pwd)
|
||||
LITEOSTOPDIR = $(TOYBOX_DIR)/../../
|
||||
include $(TOYBOX_DIR)/../config.mk
|
||||
BUILD_DIR := $(OUT)/toybox_build
|
||||
BUILD_LOG := $(BUILD_DIR)/build.log
|
||||
|
||||
APPS_OUT := $(OUT)/bin
|
||||
BUILD_DIR := $(TOYBOX_DIR)/build
|
||||
BUILD_LOG := $(TOYBOX_DIR)/build.log
|
||||
OUTNAME := $(TOYBOX)
|
||||
CFLAGS += -Wno-error
|
||||
|
||||
$(TOYBOX):
|
||||
all:
|
||||
ifneq ($(wildcard $(BUILD_DIR)),)
|
||||
$(HIDE)echo "not clean, rebuilding now";
|
||||
$(HIDE)echo "not clean, rebuilding now"
|
||||
else
|
||||
$(HIDE)mkdir $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/$(TOYBOX)/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) -p $(LITEOSTHIRDPARTY)/$(TOYBOX)/porting/liteos_a/. $(BUILD_DIR)
|
||||
$(HIDE)mkdir -p $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) $(LITEOSTHIRDPARTY)/toybox/porting/liteos_a/. $(BUILD_DIR)
|
||||
$(HIDE)$(CP) liteos_a_custom.config $(BUILD_DIR)/../
|
||||
endif
|
||||
$(HIDE)CFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-strong --target=arm-liteos \
|
||||
--sysroot=$(LITEOSTOPDIR)/../../prebuilts/lite/sysroot/" CC="$(CC)" OUTNAME=$(OUTNAME) \
|
||||
$(HIDE)unset KCONFIG_CONFIG CROSS_COMPILE && \
|
||||
env CC="$(CC)" OUTNAME="$(OUT)/bin/toybox" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" STRIP="$(STRIP)" \
|
||||
make -C $(BUILD_DIR) toybox -j> $(BUILD_LOG) 2>&1
|
||||
$(HIDE)$(CP) $(BUILD_DIR)/$(TOYBOX) .
|
||||
$(HIDE)$(STRIP) $(TOYBOX)
|
||||
$(HIDE)mkdir -p $(APPS_OUT)
|
||||
$(HIDE)$(CP) $(TOYBOX) $(APPS_OUT)
|
||||
|
||||
clean:
|
||||
$(HIDE)$(RM) $(TOYBOX) $(BUILD_DIR) $(BUILD_LOG)
|
||||
$(HIDE)$(RM) $(BUILD_DIR)
|
||||
|
||||
.PHONY: all $(TOYBOX) clean
|
||||
.PHONY: all clean
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
CONFIG_GETTY=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_MDEV_CONF=y
|
||||
# CONFIG_BASENAME is not set
|
||||
# CONFIG_CAL is not set
|
||||
# CONFIG_CAT is not set
|
||||
# CONFIG_CATV is not set
|
||||
# CONFIG_CKSUM is not set
|
||||
# CONFIG_CRC32 is not set
|
||||
@@ -13,6 +12,7 @@ CONFIG_MDEV_CONF=y
|
||||
# CONFIG_CUT is not set
|
||||
# CONFIG_DF is not set
|
||||
# CONFIG_DIRNAME is not set
|
||||
# CONFIG_ECHO is not set
|
||||
# CONFIG_ENV is not set
|
||||
# CONFIG_EXPAND is not set
|
||||
# CONFIG_FALSE is not set
|
||||
@@ -128,7 +128,6 @@ CONFIG_MDEV_CONF=y
|
||||
# CONFIG_READAHEAD is not set
|
||||
# CONFIG_READLINK is not set
|
||||
# CONFIG_REALPATH is not set
|
||||
# CONFIG_REBOOT is not set
|
||||
# CONFIG_RESET is not set
|
||||
# CONFIG_REV is not set
|
||||
# CONFIG_RMMOD is not set
|
||||
@@ -179,3 +178,9 @@ CONFIG_MDEV_CONF=y
|
||||
# CONFIG_SEQ is not set
|
||||
# CONFIG_SU is not set
|
||||
# CONFIG_SYNC is not set
|
||||
#
|
||||
# pending (see toys/pending/README)
|
||||
#
|
||||
# CONFIG_GETTY is not set
|
||||
# CONFIG_MDEV is not set
|
||||
# CONFIG_MDEV_CONF is not set
|
||||
|
||||
8
tools/fsimage/MakeVersion.sh → apps/trace/BUILD.gn
Executable file → Normal file
8
tools/fsimage/MakeVersion.sh → apps/trace/BUILD.gn
Executable file → Normal file
@@ -1,5 +1,3 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
@@ -29,4 +27,8 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
./mkfs.jffs2 -s 0x1000 -e 0x10000 -p 0x100000 -d rootfs/ -o rootfs_64k.jffs2
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
executable("trace") {
|
||||
sources = [ "src/trace.c" ]
|
||||
}
|
||||
@@ -1,34 +1,36 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
DYNLOADTESTDIR := $(LITEOSTOPDIR)/test/kernel/sample/kernel_extend/dynload
|
||||
export DYNLOADTESTDIR
|
||||
|
||||
##### command to test dynload #####
|
||||
-include $(DYNLOADTESTDIR)/test_dynload.mk
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(APPSTOPDIR)/config.mk
|
||||
|
||||
APP_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := src/trace.c
|
||||
|
||||
include $(APP)
|
||||
135
apps/trace/src/trace.c
Normal file
135
apps/trace/src/trace.c
Normal file
@@ -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;
|
||||
}
|
||||
@@ -27,24 +27,18 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
APP_SUBDIRS :=
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
##build modules config##
|
||||
group("arch") {
|
||||
deps = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
deps += [ "arm" ]
|
||||
}
|
||||
}
|
||||
|
||||
ifeq ($(LOSCFG_SHELL), y)
|
||||
APP_SUBDIRS += shell
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_USER_INIT_DEBUG), y)
|
||||
APP_SUBDIRS += init
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_NET_LWIP_SACK_TFTP), y)
|
||||
APP_SUBDIRS += tftp
|
||||
endif
|
||||
|
||||
#only enable for qemu now
|
||||
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
||||
APP_SUBDIRS += mksh
|
||||
APP_SUBDIRS += toybox
|
||||
endif
|
||||
config("public") {
|
||||
configs = []
|
||||
if (defined(LOSCFG_ARCH_ARM)) {
|
||||
configs += [ "arm:public" ]
|
||||
}
|
||||
}
|
||||
40
arch/arm/BUILD.gn
Normal file
40
arch/arm/BUILD.gn
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("arm") {
|
||||
deps = [ "gic" ]
|
||||
deps += [ ARCH ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
configs = [ "$ARCH:public" ]
|
||||
}
|
||||
@@ -36,15 +36,15 @@ LOSCFG_ARCH_FPU_STRIP := $(subst $\",,$(LOSCFG_ARCH_FPU))
|
||||
LOSCFG_ARCH_FPU = $(LOSCFG_ARCH_FPU_STRIP)
|
||||
|
||||
ifeq ($(LOSCFG_ARCH_ARM_AARCH32), y)
|
||||
LITEOS_ARCH_ARM := arm
|
||||
ARCH := arm
|
||||
else ifeq ($(LOSCFG_ARCH_ARM_AARCH64), y)
|
||||
LITEOS_ARCH_ARM :=
|
||||
ARCH := aarch64
|
||||
endif
|
||||
|
||||
LITEOS_BASELIB += -l$(LOSCFG_ARCH_CPU)
|
||||
LITEOS_BASELIB += -lgic
|
||||
|
||||
LIB_SUBDIRS += arch/arm/$(LITEOS_ARCH_ARM)
|
||||
LIB_SUBDIRS += arch/arm/$(ARCH)
|
||||
LIB_SUBDIRS += arch/arm/gic
|
||||
|
||||
# CPU compile options
|
||||
@@ -65,18 +65,15 @@ LITEOS_FPU_OPTS := -mfpu=$(LOSCFG_ARCH_FPU)
|
||||
LITEOS_GCCLIB := $(subst cortex-,,$(LOSCFG_ARCH_CPU))_softfp_$(LOSCFG_ARCH_FPU)
|
||||
endif
|
||||
|
||||
LITEOS_CORE_COPTS = $(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS)
|
||||
LITEOS_INTERWORK += $(LITEOS_CORE_COPTS)
|
||||
LITEOS_NODEBUG += $(LITEOS_CORE_COPTS)
|
||||
LITEOS_CORE_COPTS = $(or $(ARCH_CFLAGS),$(LITEOS_CPU_OPTS) $(LITEOS_FLOAT_OPTS) $(LITEOS_FPU_OPTS))
|
||||
LITEOS_ASOPTS += $(LITEOS_CPU_OPTS)
|
||||
LITEOS_CXXOPTS_BASE += $(LITEOS_CORE_COPTS)
|
||||
|
||||
ARCH_INCLUDE := -I $(LITEOSTOPDIR)/arch/arm/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(LITEOS_ARCH_ARM)/src/include
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/include \
|
||||
-I $(LITEOSTOPDIR)/arch/arm/$(ARCH)/src/include
|
||||
|
||||
LITEOS_PLATFORM_INCLUDE += $(ARCH_INCLUDE)
|
||||
LITEOS_CXXINCLUDE += $(ARCH_INCLUDE)
|
||||
|
||||
# expose FPU info to assembly code
|
||||
ifeq ($(LOSCFG_ARCH_FPU_DISABLE), y)
|
||||
@@ -86,17 +83,3 @@ else ifeq ($(LOSCFG_ARCH_FPU_VFP_D16), y)
|
||||
else ifeq ($(LOSCFG_ARCH_FPU_VFP_D32), y)
|
||||
LITEOS_CMACRO += -DLOSCFG_ARCH_FPU_VFP_D32
|
||||
endif
|
||||
|
||||
# extra definition for other module
|
||||
LITEOS_CPU_TYPE = $(LOSCFG_ARCH_CPU)
|
||||
LITEOS_ARM_ARCH := -march=$(subst $\",,$(LOSCFG_ARCH_ARM_VER))
|
||||
|
||||
# linux style macros
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7M) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8A) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8R) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8M) = -D__LINUX_ARM_ARCH__=8
|
||||
|
||||
AS_OBJS_LIBC_FLAGS += $(LINUX_ARCH_y)
|
||||
|
||||
@@ -27,34 +27,64 @@
|
||||
# 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
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
TOP_LD_PATH = $(LITEOSTOPDIR)
|
||||
SCRIPTS_PATH = $(LITEOS_SCRIPTPATH)
|
||||
LITEOS_MK_PATH = $(MK_PATH)
|
||||
LITEOS_SUBDIRS = $(LIB_SUBDIRS)
|
||||
LIB_BIGODIR = $(LITEOS_LIB_BIGODIR)
|
||||
module_name = LOSCFG_ARCH_CPU
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/arm_generic_timer.c",
|
||||
"src/clear_user.S",
|
||||
"src/hw_user_get.S",
|
||||
"src/hw_user_put.S",
|
||||
"src/jmp.S",
|
||||
"src/los_arch_mmu.c",
|
||||
"src/los_asid.c",
|
||||
"src/los_dispatch.S",
|
||||
"src/los_exc.c",
|
||||
"src/los_hw.c",
|
||||
"src/los_hw_exc.S",
|
||||
"src/los_hw_runstop.S",
|
||||
"src/los_hw_tick.c",
|
||||
"src/los_hwi.c",
|
||||
"src/strncpy_from_user.c",
|
||||
"src/strnlen_user.c",
|
||||
"src/user_copy.c",
|
||||
"src/smp.c",
|
||||
]
|
||||
|
||||
##### liteos tables -u ldflags #####
|
||||
-include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk
|
||||
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
|
||||
sources += [ "src/armv7a/cache.S" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_KERNEL_SMP)) {
|
||||
sources += [ "src/startup/reset_vector_mp.S" ]
|
||||
} else {
|
||||
sources += [ "src/startup/reset_vector_up.S" ]
|
||||
}
|
||||
|
||||
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_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)
|
||||
include_dirs = [ "src/include" ]
|
||||
|
||||
if (defined(LOSCFG_GDB)) {
|
||||
configs += [ ":as_objs_libc_flags" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"src/include",
|
||||
]
|
||||
}
|
||||
|
||||
config("as_objs_libc_flags") {
|
||||
defines = [ "__ASSEMBLY__" ]
|
||||
|
||||
# linux style macros
|
||||
if (defined(LOSCFG_ARCH_ARM_V7A) || defined(LOSCFG_ARCH_ARM_V7R) || defined(LOSCFG_ARCH_ARM_V7M)) {
|
||||
defines += [ "__LINUX_ARM_ARCH__=7" ]
|
||||
} else if (defined(LOSCFG_ARCH_ARM_V8A) || defined(LOSCFG_ARCH_ARM_V8R) || defined(LOSCFG_ARCH_ARM_V8M)) {
|
||||
defines += [ "__LINUX_ARM_ARCH__=8" ]
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/kernel/extended/dynload/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)
|
||||
endif
|
||||
|
||||
@@ -50,6 +50,16 @@ endif
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
AS_OBJS_LIBC_FLAGS = -D__ASSEMBLY__
|
||||
# linux style macros
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7A) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7R) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V7M) = -D__LINUX_ARM_ARCH__=7
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8A) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8R) = -D__LINUX_ARM_ARCH__=8
|
||||
LINUX_ARCH_$(LOSCFG_ARCH_ARM_V8M) = -D__LINUX_ARM_ARCH__=8
|
||||
AS_OBJS_LIBC_FLAGS += $(LINUX_ARCH_y)
|
||||
|
||||
ifeq ($(LOSCFG_GDB), y)
|
||||
LOCAL_FLAGS += $(AS_OBJS_LIBC_FLAGS)
|
||||
endif
|
||||
|
||||
50
arch/arm/arm/include/arm_user_clear.h
Normal file
50
arch/arm/arm/include/arm_user_clear.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_USER_CLEAR_H
|
||||
#define _ARM_USER_CLEAR_H
|
||||
|
||||
#include "los_typedef.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
size_t _arm_clear_user(void *addr, size_t bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _ARM_USER_CLEAR_H */
|
||||
@@ -53,6 +53,8 @@ extern "C" {
|
||||
#define ISB __asm__ volatile("isb" ::: "memory")
|
||||
#define WFI __asm__ volatile("wfi" ::: "memory")
|
||||
#define BARRIER __asm__ volatile("":::"memory")
|
||||
#define WFE __asm__ volatile("wfe" ::: "memory")
|
||||
#define SEV __asm__ volatile("sev" ::: "memory")
|
||||
|
||||
#define ARM_SYSREG_READ(REG) \
|
||||
({ \
|
||||
@@ -145,7 +147,7 @@ STATIC INLINE VOID ArchCurrUserTaskSet(UINTPTR val)
|
||||
|
||||
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
return ARM_SYSREG_READ(MPIDR) & MPIDR_CPUID_MASK;
|
||||
#else
|
||||
return 0;
|
||||
|
||||
@@ -29,12 +29,10 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LOS_TRACE_PRI_H
|
||||
#define LOS_TRACE_PRI_H
|
||||
#ifndef _ARCH_SMP_H
|
||||
#define _ARCH_SMP_H
|
||||
|
||||
#include "los_trace.h"
|
||||
#include "los_spinlock.h"
|
||||
#include "los_seq_buf.h"
|
||||
#include "los_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -42,25 +40,13 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct {
|
||||
TraceSwitch onOff;
|
||||
WriteHook inputHook;
|
||||
const CHAR *typeStr;
|
||||
} TraceHook;
|
||||
struct SmpOps {
|
||||
INT32 (*SmpCpuOn)(UINT32 cpuNum, UINTPTR startEntry); /* The startEntry is physical addr. */
|
||||
};
|
||||
|
||||
/*
|
||||
* |1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0|
|
||||
* | |
|
||||
* readIndex writeIndex
|
||||
*/
|
||||
typedef VOID (*ArchCpuStartFunc)(VOID *arg);
|
||||
|
||||
typedef struct {
|
||||
UINT8 *dataBuf;
|
||||
UINT32 bufLen;
|
||||
TraceSwitch onOff;
|
||||
UINT32 writeIndex;
|
||||
UINT32 readIndex;
|
||||
} TraceBufferCtl;
|
||||
VOID HalArchCpuOn(UINT32 cpuNum, ArchCpuStartFunc func, struct SmpOps *ops, VOID *arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -68,4 +54,5 @@ typedef struct {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* LOS_TRACE_PRI_H */
|
||||
#endif /* _ARCH_SMP_H */
|
||||
|
||||
100
arch/arm/arm/src/clear_user.S
Normal file
100
arch/arm/arm/src/clear_user.S
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "asm.h"
|
||||
|
||||
.syntax unified
|
||||
.arm
|
||||
|
||||
// size_t _arm_clear_user(void *addr, size_t bytes)
|
||||
FUNCTION(_arm_clear_user)
|
||||
push {r0-r6, lr}
|
||||
cmp r1, #0
|
||||
beq .Lclear_user_return
|
||||
tst r0, #7
|
||||
beq .Lclear_user_aligned
|
||||
|
||||
.Lclear_user_byte:
|
||||
mov r2, #0
|
||||
0: strb r2, [r0], #1
|
||||
subs r1, r1, #1
|
||||
beq .Lclear_user_return
|
||||
tst r0, #7
|
||||
bne 0b
|
||||
|
||||
.Lclear_user_aligned:
|
||||
eor r3, r3
|
||||
eor r4, r4
|
||||
bics r2, r1, #15
|
||||
bne .Lclear_user_16bytes
|
||||
bics r2, r1, #7
|
||||
bne .Lclear_user_8bytes
|
||||
b .Lclear_user_remaining
|
||||
|
||||
.Lclear_user_16bytes:
|
||||
eor r5, r5
|
||||
eor r6, r6
|
||||
1: stmia r0!, {r3, r4, r5, r6}
|
||||
subs r2, r2, #16
|
||||
bne 1b
|
||||
ands r1, r1, #15
|
||||
beq .Lclear_user_return
|
||||
bics r2, r1, #7
|
||||
beq .Lclear_user_remaining
|
||||
|
||||
.Lclear_user_8bytes:
|
||||
2: stmia r0!, {r3, r4}
|
||||
ands r1, r1, #7
|
||||
beq .Lclear_user_return
|
||||
|
||||
.Lclear_user_remaining:
|
||||
mov r2, #0
|
||||
3: strb r2, [r0], #1
|
||||
subs r1, r1, #1
|
||||
bne 3b
|
||||
|
||||
.Lclear_user_return:
|
||||
pop {r0-r6, lr}
|
||||
mov r0, #0
|
||||
bx lr
|
||||
|
||||
.Lclear_user_err:
|
||||
pop {r0, r1}
|
||||
sub r0, r2, r0
|
||||
sub r0, r1, r0
|
||||
pop {r2-r6, lr}
|
||||
bx lr
|
||||
|
||||
.pushsection __exc_table, "a"
|
||||
.long 0b, .Lclear_user_err
|
||||
.long 1b, .Lclear_user_err
|
||||
.long 2b, .Lclear_user_err
|
||||
.long 3b, .Lclear_user_err
|
||||
.popsection
|
||||
@@ -51,7 +51,7 @@
|
||||
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
|
||||
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
|
||||
g_firstPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
__attribute__((aligned(MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS))) \
|
||||
__attribute__((section(".bss.prebss.translation_table"))) UINT8 \
|
||||
g_tempPageTable[MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS];
|
||||
@@ -218,7 +218,7 @@ STATIC UINT32 OsCvtSecCacheFlagsToMMUFlags(UINT32 flags)
|
||||
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
|
||||
case VM_MAP_REGION_FLAG_CACHED:
|
||||
mmuFlags |= MMU_DESCRIPTOR_L1_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
mmuFlags |= MMU_DESCRIPTOR_L1_SECTION_SHAREABLE;
|
||||
#endif
|
||||
break;
|
||||
@@ -544,7 +544,7 @@ STATIC UINT32 OsCvtPte2CacheFlagsToMMUFlags(UINT32 flags)
|
||||
|
||||
switch (flags & VM_MAP_REGION_FLAG_CACHE_MASK) {
|
||||
case VM_MAP_REGION_FLAG_CACHED:
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
mmuFlags |= MMU_DESCRIPTOR_L2_SHAREABLE;
|
||||
#endif
|
||||
mmuFlags |= MMU_DESCRIPTOR_L2_TYPE_NORMAL_WRITE_BACK_ALLOCATE;
|
||||
@@ -790,7 +790,7 @@ STATUS_T LOS_ArchMmuDestroy(LosArchMmu *archMmu)
|
||||
LOS_PhysPageFree(page);
|
||||
}
|
||||
|
||||
OsArmWriteTlbiasid(archMmu->asid);
|
||||
OsArmWriteTlbiasidis(archMmu->asid);
|
||||
OsFreeAsid(archMmu->asid);
|
||||
#endif
|
||||
(VOID)LOS_MuxDestroy(&archMmu->mtx);
|
||||
@@ -871,7 +871,7 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
kSpace->archMmu.virtTtb = (PTE_T *)g_firstPageTable;
|
||||
kSpace->archMmu.physTtb = LOS_PaddrQuery(kSpace->archMmu.virtTtb);
|
||||
status = LOS_ArchMmuUnmap(&kSpace->archMmu, virtAddr,
|
||||
(bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
(bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT);
|
||||
if (status != ((bssEndBoundary - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("unmap failed, status: %d", status);
|
||||
return;
|
||||
@@ -882,8 +882,8 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
flags |= VM_MAP_REGION_FLAG_UNCACHED;
|
||||
}
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, virtAddr, SYS_MEM_BASE,
|
||||
(textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
(textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
if (status != ((textStart - virtAddr) >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("mmap failed, status: %d", status);
|
||||
return;
|
||||
@@ -910,9 +910,9 @@ STATIC VOID OsSetKSectionAttr(UINTPTR virtAddr, BOOL uncached)
|
||||
flags |= VM_MAP_REGION_FLAG_UNCACHED;
|
||||
}
|
||||
status = LOS_ArchMmuMap(&kSpace->archMmu, bssEndBoundary,
|
||||
SYS_MEM_BASE + bssEndBoundary - virtAddr,
|
||||
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
SYS_MEM_BASE + bssEndBoundary - virtAddr,
|
||||
kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT,
|
||||
flags);
|
||||
if (status != (kmallocLength >> MMU_DESCRIPTOR_L2_SMALL_SHIFT)) {
|
||||
VM_ERR("mmap failed, status: %d", status);
|
||||
return;
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#include "los_excinfo_pri.h"
|
||||
#endif
|
||||
#include "los_sys_stack_pri.h"
|
||||
#include "los_stackinfo_pri.h"
|
||||
#ifdef LOSCFG_COREDUMP
|
||||
#include "los_coredump.h"
|
||||
#endif
|
||||
@@ -62,6 +61,9 @@
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "console.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
#include "los_blackbox.h"
|
||||
#endif
|
||||
|
||||
|
||||
#define INVALID_CPUID 0xFFFF
|
||||
@@ -75,7 +77,7 @@ VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr);
|
||||
UINT32 g_curNestCount[LOSCFG_KERNEL_CORE_NUM] = { 0 };
|
||||
BOOL g_excFromUserMode[LOSCFG_KERNEL_CORE_NUM];
|
||||
STATIC EXC_PROC_FUNC g_excHook = (EXC_PROC_FUNC)OsExcHook;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
STATIC SPIN_LOCK_INIT(g_excSerializerSpin);
|
||||
STATIC UINT32 g_currHandleExcPID = OS_INVALID_VALUE;
|
||||
STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
|
||||
@@ -226,7 +228,8 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = LOS_ERRNO_VM_NOT_FOUND;
|
||||
OsArmWriteTlbimvaais(ROUNDDOWN(far, PAGE_SIZE));
|
||||
ret = LOS_OK;
|
||||
break;
|
||||
}
|
||||
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
|
||||
@@ -274,8 +277,8 @@ STATIC const CHAR *g_excTypeString[] = {
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProcess)
|
||||
{
|
||||
struct file *curFilep = NULL;
|
||||
struct file *lastFilep = NULL;
|
||||
struct Vnode *curVnode = NULL;
|
||||
struct Vnode *lastVnode = NULL;
|
||||
LosVmMapRegion *curRegion = NULL;
|
||||
LosVmMapRegion *lastRegion = NULL;
|
||||
|
||||
@@ -294,9 +297,9 @@ STATIC VADDR_T OsGetTextRegionBase(LosVmMapRegion *region, LosProcessCB *runProc
|
||||
if ((lastRegion == NULL) || !LOS_IsRegionFileValid(lastRegion)) {
|
||||
goto DONE;
|
||||
}
|
||||
curFilep = curRegion->unTypeData.rf.file;
|
||||
lastFilep = lastRegion->unTypeData.rf.file;
|
||||
} while (!strcmp(curFilep->f_path, lastFilep->f_path));
|
||||
curVnode = curRegion->unTypeData.rf.vnode;
|
||||
lastVnode = lastRegion->unTypeData.rf.vnode;
|
||||
} while (curVnode == lastVnode);
|
||||
|
||||
DONE:
|
||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||
@@ -531,7 +534,7 @@ STATIC VOID OsExcRestore(VOID)
|
||||
g_excFromUserMode[currCpuID] = FALSE;
|
||||
g_intCount[currCpuID] = 0;
|
||||
g_curNestCount[currCpuID] = 0;
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsPercpuGet()->excFlag = CPU_RUNNING;
|
||||
#endif
|
||||
OsPercpuGet()->taskLockCnt = 0;
|
||||
@@ -548,7 +551,7 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
return;
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
if (g_nextExcWaitCpu != INVALID_CPUID) {
|
||||
g_currHandleExcCpuID = g_nextExcWaitCpu;
|
||||
@@ -563,12 +566,15 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
#endif
|
||||
runProcess->processStatus &= ~OS_PROCESS_FLAG_EXIT;
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
OsWakeConsoleSendTask();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
BBoxNotifyError("USER_CRASH", MODULE_SYSTEM, "Crash in user", 0);
|
||||
#endif
|
||||
SCHEDULER_LOCK(intSave);
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
OsProcessExitCodeCoreDumpSet(runProcess);
|
||||
@@ -716,14 +722,14 @@ VOID BackTraceSub(UINTPTR regFP)
|
||||
while (IsValidFP(backFP, stackStart, stackEnd, &kvaddr) == TRUE) {
|
||||
tmpFP = backFP;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
backFP = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
if (IsValidFP(tmpFP + POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback backLR check failed, backLP: 0x%x\n", tmpFP + POINTER_SIZE);
|
||||
return;
|
||||
}
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
#else
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
backLR = *(UINTPTR *)(UINTPTR)kvaddr;
|
||||
if (IsValidFP(tmpFP - POINTER_SIZE, stackStart, stackEnd, &kvaddr) == FALSE) {
|
||||
PrintExcInfo("traceback backFP check failed, backFP: 0x%x\n", tmpFP - POINTER_SIZE);
|
||||
return;
|
||||
@@ -909,7 +915,7 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
|
||||
#endif /* __LINUX_ARM_ARCH__ */
|
||||
#endif /* LOSCFG_GDB */
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#define EXC_WAIT_INTER 50U
|
||||
#define EXC_WAIT_TIME 2000U
|
||||
|
||||
@@ -989,10 +995,12 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
g_currHandleExcPID = OsCurrProcessGet()->processID;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
if (g_excFromUserMode[currCpuID] == FALSE) {
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
||||
}
|
||||
#endif
|
||||
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
||||
/* Both cores raise exceptions, and the current core is a user-mode exception.
|
||||
* Both cores are abnormal and come from the same process
|
||||
@@ -1007,7 +1015,7 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
|
||||
OsWaitOtherCoresHandleExcEnd(currCpuID);
|
||||
} else {
|
||||
if (g_excFromUserMode[g_currHandleExcCpuID] == TRUE) {
|
||||
if ((g_currHandleExcCpuID < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuID] == TRUE)) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
@@ -1017,17 +1025,18 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
while (1) {}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
/* use halt ipi to stop other active cores */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
||||
WaitAllCpuStop(currCpuID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID OsCheckCpuStatus(VOID)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsCheckAllCpuStatus();
|
||||
#else
|
||||
g_currHandleExcCpuID = ArchCurrCpuid();
|
||||
@@ -1048,7 +1057,7 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
|
||||
OsCheckCpuStatus();
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
/* Wait for the end of the Console task to avoid multicore printing code */
|
||||
OsWaitConsoleSendTaskPend(OsCurrTaskGet()->taskID);
|
||||
@@ -1058,6 +1067,11 @@ LITE_OS_SEC_TEXT VOID STATIC OsExcPriorDisposal(ExcContext *excBufAddr)
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
|
||||
{
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
SetExcInfoIndex(0);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
/* You are not allowed to add any other print information before this exception information */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
@@ -1113,7 +1127,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
|
||||
OsPrintExcHead(far);
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsAllCpuStatusOutput();
|
||||
#endif
|
||||
|
||||
@@ -1125,7 +1139,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
if (g_curNestCount[ArchCurrCpuid()] == 1) {
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
if (func != NULL) {
|
||||
#ifndef LOSCFG_BLACKBOX
|
||||
SetExcInfoIndex(0);
|
||||
#endif
|
||||
OsSysStateSave(&intCount, &lockCount);
|
||||
OsRecordExcInfoTime();
|
||||
OsSysStateRestore(intCount, lockCount);
|
||||
@@ -1154,6 +1170,9 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_BLACKBOX
|
||||
BBoxNotifyError(EVENT_PANIC, MODULE_SYSTEM, "Crash in kernel", 1);
|
||||
#endif
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
@@ -1168,7 +1187,7 @@ __attribute__((noinline)) VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
}
|
||||
|
||||
/* stack protector */
|
||||
UINT32 __stack_chk_guard = 0xd00a0dff;
|
||||
USED UINT32 __stack_chk_guard = 0xd00a0dff;
|
||||
|
||||
VOID __stack_chk_fail(VOID)
|
||||
{
|
||||
@@ -1200,7 +1219,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
framePtr = Get_Fp();
|
||||
while ((framePtr > stackStart) && (framePtr < stackEnd) && IS_ALIGNED(framePtr, sizeof(CHAR *))) {
|
||||
tmpFramePtr = framePtr;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
linkReg = *(UINTPTR *)(tmpFramePtr + sizeof(UINTPTR));
|
||||
#else
|
||||
linkReg = *(UINTPTR *)framePtr;
|
||||
#endif
|
||||
if (index >= jumpCount) {
|
||||
LR[count++] = linkReg;
|
||||
if (count == recordCount) {
|
||||
@@ -1208,7 +1231,11 @@ VOID LOS_RecordLR(UINTPTR *LR, UINT32 LRSize, UINT32 recordCount, UINT32 jumpCou
|
||||
}
|
||||
}
|
||||
index++;
|
||||
#ifdef LOSCFG_COMPILER_CLANG_LLVM
|
||||
framePtr = *(UINTPTR *)framePtr;
|
||||
#else
|
||||
framePtr = *(UINTPTR *)(tmpFramePtr - sizeof(UINTPTR));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* if linkReg is not enough,clean up the last of the effective LR as the end. */
|
||||
|
||||
@@ -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->R0 = taskID; /* R0 */
|
||||
|
||||
#ifdef LOSCFG_INTERWORK_THUMB
|
||||
#ifdef LOSCFG_THUMB
|
||||
taskContext->regCPSR = PSR_MODE_SVC_THUMB; /* CPSR (Enable IRQ and FIQ interrupts, THUMNB-mode) */
|
||||
#else
|
||||
taskContext->regCPSR = PSR_MODE_SVC_ARM; /* CPSR (Enable IRQ and FIQ interrupts, ARM-mode) */
|
||||
@@ -105,7 +105,15 @@ LITE_OS_SEC_TEXT_INIT VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOI
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStack, UINT32 parentStackSize)
|
||||
{
|
||||
VOID *cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
|
||||
LosTaskCB *task = OsCurrTaskGet();
|
||||
sig_cb *sigcb = &task->sig;
|
||||
VOID *cloneStack = NULL;
|
||||
|
||||
if (sigcb->sigContext != NULL) {
|
||||
cloneStack = (VOID *)((UINTPTR)sigcb->sigContext - sizeof(TaskContext));
|
||||
} else {
|
||||
cloneStack = (VOID *)(((UINTPTR)parentTopOfStack + parentStackSize) - sizeof(TaskContext));
|
||||
}
|
||||
|
||||
(VOID)memcpy_s(childStack, sizeof(TaskContext), cloneStack, sizeof(TaskContext));
|
||||
((TaskContext *)childStack)->R0 = 0;
|
||||
@@ -115,7 +123,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsUserTaskStackInit(TaskContext *context, UINTPTR tas
|
||||
{
|
||||
LOS_ASSERT(context != NULL);
|
||||
|
||||
#ifdef LOSCFG_INTERWORK_THUMB
|
||||
#ifdef LOSCFG_THUMB
|
||||
context->regCPSR = PSR_MODE_USR_THUMB;
|
||||
#else
|
||||
context->regCPSR = PSR_MODE_USR_ARM;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#include "los_hook.h"
|
||||
|
||||
/* spinlock for hwi module, only available on SMP mode */
|
||||
LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
|
||||
@@ -84,7 +84,7 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqStart();
|
||||
#endif
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum);
|
||||
hwiForm = (&g_hwiForm[intNum]);
|
||||
#ifndef LOSCFG_NO_SHARED_IRQ
|
||||
while (hwiForm->pstNext != NULL) {
|
||||
@@ -107,6 +107,7 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
#endif
|
||||
++g_hwiFormCnt[intNum];
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum);
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqEnd(intNum);
|
||||
#endif
|
||||
|
||||
106
arch/arm/arm/src/smp.c
Normal file
106
arch/arm/arm/src/smp.c
Normal file
@@ -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
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define ASSEMBLY
|
||||
#include "arch_config.h"
|
||||
#include "los_vm_boot.h"
|
||||
@@ -54,6 +55,8 @@
|
||||
.extern __stack_chk_guard_setup
|
||||
.extern g_firstPageTable
|
||||
.extern g_mmuJumpPageTable
|
||||
.extern g_archMmuInitMapping
|
||||
.extern HalSecondaryCpuStart
|
||||
|
||||
.equ MPIDR_CPUID_MASK, 0xffU
|
||||
|
||||
@@ -77,14 +80,6 @@
|
||||
bl excstack_magic
|
||||
.endm
|
||||
|
||||
/* param0 is physical address, param1 virtual address, param2 is sizes, param3 is flag */
|
||||
.macro PAGE_TABLE_SET param0, param1, param2, param3
|
||||
ldr r6, =\param0
|
||||
ldr r7, =\param1
|
||||
ldr r8, =\param2
|
||||
ldr r10, =\param3
|
||||
bl page_table_build
|
||||
.endm
|
||||
.code 32
|
||||
.section ".vectors","ax"
|
||||
|
||||
@@ -184,12 +179,15 @@ reloc_img_to_bottom_done:
|
||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
||||
|
||||
ldr r5, =g_archMmuInitMapping
|
||||
add r5, r5, r11
|
||||
init_mmu_loop:
|
||||
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||
cmp r8, 0 /* if size = 0, the mmu init done */
|
||||
beq init_mmu_done
|
||||
bl page_table_build
|
||||
b init_mmu_loop
|
||||
init_mmu_done:
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||
add r4, r4, r11
|
||||
@@ -205,9 +203,7 @@ reloc_img_to_bottom_done:
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[paIndex] = pt entry */
|
||||
rsb r7, r11, r6, lsl #20 /* r7: va */
|
||||
str r12, [r4, r7, lsr #(20 - 2)] /* jumpTable[vaIndex] = pt entry */
|
||||
#endif
|
||||
bl _bootaddr_setup
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
|
||||
bl mmu_setup /* set up the mmu */
|
||||
#endif
|
||||
/* clear out the interrupt and exception stack and set magic num to check the overflow */
|
||||
@@ -317,6 +313,7 @@ reset_platform:
|
||||
mov r0, #0
|
||||
mov pc, r0 // Jump to reset vector
|
||||
#endif
|
||||
|
||||
cpu_start:
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
ldr r4, =g_firstPageTable /* r4 = physical address of translation table and clear it */
|
||||
@@ -330,7 +327,8 @@ cpu_start:
|
||||
|
||||
bl mmu_setup
|
||||
#endif
|
||||
bl secondary_cpu_start
|
||||
|
||||
bl HalSecondaryCpuStart
|
||||
b .
|
||||
|
||||
secondary_cpu_init:
|
||||
@@ -370,9 +368,9 @@ sp_set:
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r9
|
||||
mov r10, r6
|
||||
bfc r10, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r10
|
||||
add r8, r8, #(1 << 20)
|
||||
sub r8, r8, #1
|
||||
lsr r6, #20 /* r6 = physical address / MB */
|
||||
@@ -380,7 +378,7 @@ page_table_build:
|
||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||
|
||||
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 */
|
||||
add r6, #1 /* physAddr+ */
|
||||
add r7, #1 /* l1Index++ */
|
||||
@@ -422,24 +420,6 @@ excstack_magic_loop:
|
||||
blt excstack_magic_loop
|
||||
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
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
.extern __stack_chk_guard_setup
|
||||
.extern g_firstPageTable
|
||||
.extern g_mmuJumpPageTable
|
||||
.extern g_archMmuInitMapping
|
||||
|
||||
.equ MPIDR_CPUID_MASK, 0xffU
|
||||
|
||||
@@ -77,14 +78,6 @@
|
||||
bl excstack_magic
|
||||
.endm
|
||||
|
||||
/* param0 is physical address, param1 virtual address, param2 is sizes, param3 is flag */
|
||||
.macro PAGE_TABLE_SET param0, param1, param2, param3
|
||||
ldr r6, =\param0
|
||||
ldr r7, =\param1
|
||||
ldr r8, =\param2
|
||||
ldr r10, =\param3
|
||||
bl page_table_build
|
||||
.endm
|
||||
.code 32
|
||||
.section ".vectors","ax"
|
||||
|
||||
@@ -161,12 +154,15 @@ reloc_img_to_bottom_done:
|
||||
mov r2, #MMU_DESCRIPTOR_L1_SMALL_ENTRY_NUMBERS
|
||||
bl memset_optimized /* optimized memset since r0 is 64-byte aligned */
|
||||
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, KERNEL_VMM_BASE, KERNEL_VMM_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET SYS_MEM_BASE, UNCACHED_VMM_BASE, UNCACHED_VMM_SIZE, MMU_INITIAL_MAP_NORMAL_NOCACHE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_DEVICE_BASE, PERIPH_DEVICE_SIZE, MMU_INITIAL_MAP_DEVICE
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_CACHED_BASE, PERIPH_CACHED_SIZE, MMU_DESCRIPTOR_KERNEL_L1_PTE_FLAGS
|
||||
PAGE_TABLE_SET PERIPH_PMM_BASE, PERIPH_UNCACHED_BASE, PERIPH_UNCACHED_SIZE, MMU_INITIAL_MAP_STRONGLY_ORDERED
|
||||
|
||||
ldr r5, =g_archMmuInitMapping
|
||||
add r5, r5, r11
|
||||
init_mmu_loop:
|
||||
ldmia r5!, {r6-r10} /* r6 = phys, r7 = virt, r8 = size, r9 = mmu_flags, r10 = name */
|
||||
cmp r8, 0 /* if size = 0, the mmu init done */
|
||||
beq init_mmu_done
|
||||
bl page_table_build
|
||||
b init_mmu_loop
|
||||
init_mmu_done:
|
||||
orr r8, r4, #MMU_TTBRx_FLAGS /* r8 = r4 and set cacheable attributes on translation walk */
|
||||
ldr r4, =g_mmuJumpPageTable /* r4: jump pagetable vaddr */
|
||||
add r4, r4, r11
|
||||
@@ -231,9 +227,6 @@ warm_reset:
|
||||
LDR r0, =__exception_handlers
|
||||
MCR p15, 0, r0, c12, c0, 0
|
||||
|
||||
cmp r11, #0
|
||||
bne cpu_start
|
||||
|
||||
clear_bss:
|
||||
ldr r0, =__bss_start
|
||||
ldr r2, =__bss_end
|
||||
@@ -310,11 +303,6 @@ reset_platform:
|
||||
mov r0, #0
|
||||
mov pc, r0 // Jump to reset vector
|
||||
#endif
|
||||
cpu_start:
|
||||
bl secondary_cpu_start
|
||||
b .
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* set sp for current cpu
|
||||
@@ -336,9 +324,9 @@ sp_set:
|
||||
*/
|
||||
#ifdef LOSCFG_KERNEL_MMU
|
||||
page_table_build:
|
||||
mov r9, r6
|
||||
bfc r9, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r9
|
||||
mov r10, r6
|
||||
bfc r10, #20, #12 /* r9: pa % MB */
|
||||
add r8, r8, r10
|
||||
add r8, r8, #(1 << 20)
|
||||
sub r8, r8, #1
|
||||
lsr r6, #20 /* r6 = physical address / MB */
|
||||
@@ -346,7 +334,7 @@ page_table_build:
|
||||
lsr r8, #20 /* r8 = roundup(size, MB) */
|
||||
|
||||
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 */
|
||||
add r6, #1 /* physAddr+ */
|
||||
add r7, #1 /* l1Index++ */
|
||||
@@ -388,24 +376,6 @@ excstack_magic_loop:
|
||||
blt excstack_magic_loop
|
||||
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
|
||||
memset_optimized:
|
||||
mov r3, r0
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "user_copy.h"
|
||||
#include "arm_user_copy.h"
|
||||
#include "arm_user_clear.h"
|
||||
#include "securec.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_vm_map.h"
|
||||
@@ -96,15 +97,9 @@ INT32 LOS_UserMemClear(unsigned char *buf, UINT32 len)
|
||||
if (!LOS_IsUserAddressRange((vaddr_t)(UINTPTR)buf, len)) {
|
||||
(VOID)memset_s(buf, len, 0, len);
|
||||
} else {
|
||||
unsigned char *tmp = (unsigned char *)LOS_MemAlloc(OS_SYS_MEM_ADDR, len);
|
||||
if (tmp == NULL) {
|
||||
return -ENOMEM;
|
||||
if (_arm_clear_user(buf, len)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
(VOID)memset_s(tmp, len, 0, len);
|
||||
if (_arm_user_copy(buf, tmp, len) != 0) {
|
||||
ret = -EFAULT;
|
||||
}
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, tmp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
41
arch/arm/gic/BUILD.gn
Normal file
41
arch/arm/gic/BUILD.gn
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = []
|
||||
|
||||
if (defined(LOSCFG_ARCH_GIC_V2)) {
|
||||
sources += [ "gic_v2.c" ]
|
||||
} else if (defined(LOSCFG_ARCH_GIC_V3)) {
|
||||
sources += [ "gic_v3.c" ]
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ STATIC_ASSERT(OS_USER_HWI_MAX <= 1020, "hwi max is too large!");
|
||||
|
||||
STATIC UINT32 g_curIrqNum = 0;
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/*
|
||||
* filter description
|
||||
* 0b00: forward to the cpu interfaces specified in cpu_mask
|
||||
@@ -144,7 +144,7 @@ VOID HalIrqInit(VOID)
|
||||
/* enable gic distributor control */
|
||||
GIC_REG_32(GICD_CTLR) = 1;
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/* register inter-processor interrupt */
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
|
||||
(VOID)LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
|
||||
|
||||
@@ -48,7 +48,7 @@ STATIC INLINE UINT64 MpidrToAffinity(UINT64 mpidr)
|
||||
(MPIDR_AFF_LEVEL(mpidr, 0)));
|
||||
}
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
|
||||
STATIC UINT32 NextCpu(UINT32 cpu, UINT32 cpuMask)
|
||||
{
|
||||
@@ -399,7 +399,7 @@ VOID HalIrqInit(VOID)
|
||||
|
||||
HalIrqInitPercpu();
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/* register inter-processor interrupt */
|
||||
LOS_HwiCreate(LOS_MP_IPI_WAKEUP, 0xa0, 0, OsMpWakeHandler, 0);
|
||||
LOS_HwiCreate(LOS_MP_IPI_SCHEDULE, 0xa0, 0, OsMpScheduleHandler, 0);
|
||||
|
||||
@@ -49,7 +49,7 @@ extern VOID HalIrqClear(UINT32 vector);
|
||||
extern CHAR *HalIrqVersion(VOID);
|
||||
extern UINT32 HalCurIrqGet(VOID);
|
||||
extern UINT32 HalIrqSetPrio(UINT32 vector, UINT8 priority);
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
extern VOID HalIrqSendIpi(UINT32 target, UINT32 ipi);
|
||||
extern VOID HalIrqSetAffinity(UINT32 vector, UINT32 cpuMask);
|
||||
#endif
|
||||
|
||||
86
bsd/BUILD.gn
Normal file
86
bsd/BUILD.gn
Normal file
@@ -0,0 +1,86 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_COMPAT_BSD)
|
||||
module_name = "libbsd"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"kern/bus_if.c",
|
||||
"kern/device_if.c",
|
||||
"kern/kern_condvar.c",
|
||||
"kern/kern_timeout.c",
|
||||
"kern/subr_bus.c",
|
||||
"kern/subr_kobj.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
sources += [
|
||||
"arm/autoconf.c",
|
||||
"arm/hw_user_copy.S",
|
||||
"arm/in_cksum.c",
|
||||
"arm/in_cksum_arm.S",
|
||||
"arm/nexus.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_RANDOM)) {
|
||||
sources += [
|
||||
"crypto/rijndael/rijndael-alg-fst.c",
|
||||
"crypto/rijndael/rijndael-api-fst.c",
|
||||
"crypto/sha2/sha256c.c",
|
||||
"dev/random/hash.c",
|
||||
"dev/random/yarrow.c",
|
||||
"libkern/explicit_bzero.c",
|
||||
]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
group("bsd") {
|
||||
public_deps = [ ":$module_name" ]
|
||||
|
||||
deps = [
|
||||
"compat/linuxkpi",
|
||||
"dev/usb",
|
||||
]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
".",
|
||||
"kern",
|
||||
]
|
||||
configs = [
|
||||
"compat/linuxkpi:public",
|
||||
"dev/usb:public",
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,14 @@
|
||||
config COMPAT_BSD
|
||||
bool "Enable FreeBSD"
|
||||
default y
|
||||
select COMPAT_LINUXKPI
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support FreeBSD.
|
||||
|
||||
config COMPAT_LINUXKPI
|
||||
bool "Enable linuxkpi" if COMPAT_BSD
|
||||
default y
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support compatible layer for linuxkpi.
|
||||
|
||||
@@ -33,8 +33,8 @@ MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard kern/*.c)
|
||||
|
||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(LITEOS_ARCH_ARM)/*.S)
|
||||
LOCAL_SRCS += $(wildcard $(ARCH)/*.c)
|
||||
LOCAL_SRCS += $(wildcard $(ARCH)/*.S)
|
||||
|
||||
ifeq ($(LOSCFG_DRIVERS_RANDOM), y)
|
||||
LOCAL_SRCS += $(wildcard crypto/rijndael/*.c) \
|
||||
|
||||
57
bsd/compat/linuxkpi/BUILD.gn
Normal file
57
bsd/compat/linuxkpi/BUILD.gn
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_COMPAT_BSD)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/adp.c",
|
||||
"src/linux_completion.c",
|
||||
"src/linux_interrupt.c",
|
||||
"src/linux_sched.c",
|
||||
"src/linux_semaphore.c",
|
||||
"src/linux_timer.c",
|
||||
"src/linux_wakelock.c",
|
||||
"src/linux_workqueue.c",
|
||||
"src/prctl.c",
|
||||
"src/tzdst.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_HRTIMER_ENABLE)) {
|
||||
sources += [ "src/linux_hrtimer.c" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd.h
|
||||
@@ -1 +0,0 @@
|
||||
../../../../../../../../third_party/Linux_Kernel/fs/jffs2/mtd_list.h
|
||||
150
bsd/dev/usb/BUILD.gn
Normal file
150
bsd/dev/usb/BUILD.gn
Normal file
@@ -0,0 +1,150 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_USB)
|
||||
module_name = "usb_base"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"implementation/bsd_busspace.c",
|
||||
"implementation/bsd_kernel.c",
|
||||
"implementation/usb_btree.c",
|
||||
"implementation/usb_busdma_loader.c",
|
||||
"implementation/usb_init.c",
|
||||
"implementation/usb_version.c",
|
||||
"usb_debug.c",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB)) {
|
||||
sources += [
|
||||
"controller/usb_controller.c",
|
||||
"quirk/usb_quirk.c",
|
||||
"usb_dev.c",
|
||||
"usb_device.c",
|
||||
"usb_dynamic.c",
|
||||
"usb_error.c",
|
||||
"usb_generic.c",
|
||||
"usb_handle_request.c",
|
||||
"usb_hub.c",
|
||||
"usb_if.c",
|
||||
"usb_lookup.c",
|
||||
"usb_mbuf.c",
|
||||
"usb_parse.c",
|
||||
"usb_process.c",
|
||||
"usb_request.c",
|
||||
"usb_transfer.c",
|
||||
"usb_util.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM)) {
|
||||
sources += [ "net/if_cdce.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_ETHERNET)) {
|
||||
sources += [
|
||||
"net/if_axe.c",
|
||||
"net/if_axge.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
|
||||
sources += [ "net/if_urndis.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
|
||||
defined(LOSCFG_DRIVERS_USB_ETHERNET) ||
|
||||
defined(LOSCFG_DRIVERS_USB_RNDIS_HOST)) {
|
||||
sources += [
|
||||
"net/usb_eth_drv.c",
|
||||
"net/usb_ethernet.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_4G_MODEM) ||
|
||||
defined(LOSCFG_DRIVERS_USB_SERIAL)) {
|
||||
sources += [
|
||||
"serial/u3g.c",
|
||||
"serial/usb_serial.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HOST_EHCI)) {
|
||||
sources += [
|
||||
"controller/ehci.c",
|
||||
"controller/ehci_pci.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HOST_XHCI) ||
|
||||
defined(LOSCFG_DRIVERS_USB_HOST_XHCI_FOR_PORT2)) {
|
||||
sources += [
|
||||
"controller/xhci.c",
|
||||
"controller/xhci_pci.c",
|
||||
]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_WIRELESS)) {
|
||||
sources += [ "linux_usb.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_MASS_STORAGE)) {
|
||||
sources += [ "storage/umass.c" ]
|
||||
}
|
||||
|
||||
if (defined(LOSCFG_DRIVERS_USB_HID_CLASS) &&
|
||||
defined(LOSCFG_DRIVERS_HDF_INPUT)) {
|
||||
sources += [
|
||||
"input/uhid.c",
|
||||
"usb_hid.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"//drivers/framework/model/input/driver",
|
||||
"//drivers/framework/include/core",
|
||||
"//drivers/framework/core/common/include/host",
|
||||
"//drivers/framework/utils",
|
||||
"//drivers/framework/osal",
|
||||
"//drivers/framework/ability/sbuf/include",
|
||||
"//drivers/framework/include/osal",
|
||||
]
|
||||
}
|
||||
|
||||
configs += [
|
||||
"$HDFTOPDIR:hdf_config"
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
include_dirs += [ "$LITEOSTHIRDPARTY/FreeBSD/sys/dev/evdev" ]
|
||||
}
|
||||
@@ -15,7 +15,7 @@ config DRIVERS_USB_HOST_DRIVER
|
||||
choice
|
||||
depends on DRIVERS_USB_HOST_DRIVER
|
||||
prompt "USB HCD"
|
||||
default y
|
||||
default DRIVERS_USB_HOST_EHCI
|
||||
help
|
||||
Enable EHCI for USB 2.0.
|
||||
Enable XHCI for USB 3.0
|
||||
|
||||
74
build.sh
74
build.sh
@@ -30,44 +30,40 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
set -e
|
||||
|
||||
echo "sh param:$1,$2,$3,$4,$5,$6,$7"
|
||||
destination=".config"
|
||||
config_file=""
|
||||
tee=""
|
||||
outdir="../..$3/test_info/gen/kernel/test"
|
||||
if [ "$5" = "tee" ]; then
|
||||
tee="_tee"
|
||||
fi
|
||||
product_name="$(basename $7)"
|
||||
source="tools/build/config/${product_name}_release.config"
|
||||
if [ "$2" = "clang" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${product_name}_$2$tee.config"
|
||||
source="tools/build/config/debug/$config_file"
|
||||
else
|
||||
config_file="${product_name}_$2_release$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
fi
|
||||
elif [ "$2" = "gcc" ]; then
|
||||
if [ "$4" = "debug" ]; then
|
||||
config_file="${product_name}_debug_shell$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
else
|
||||
config_file="${product_name}_release$tee.config"
|
||||
source="tools/build/config/$config_file"
|
||||
fi
|
||||
fi
|
||||
if [ -d "./out" ]; then
|
||||
rm -rf ./out
|
||||
fi
|
||||
if [ -f "$destination" ]; then
|
||||
rm -rf $destination
|
||||
fi
|
||||
if [ ! -f "$source" ]; then
|
||||
source="$7/config/sys/$config_file"
|
||||
fi
|
||||
cp $source $destination
|
||||
board_name=${1}
|
||||
ohos_build_compiler=${2}
|
||||
root_build_dir=${3}
|
||||
ohos_build_type=${4}
|
||||
tee_enable=${5}
|
||||
device_company=${6}
|
||||
product_path=${7}
|
||||
outdir=${8}
|
||||
ohos_version=${9}
|
||||
sysroot_path=${10}
|
||||
arch_cflags=${11}
|
||||
device_path=${12}
|
||||
compile_prefix=${13}
|
||||
liteos_config_file=${14}
|
||||
|
||||
mkdir -p $outdir
|
||||
cp kernel_test.sources $outdir
|
||||
echo "sh param:" "$@"
|
||||
|
||||
if [ "x" != "x${sysroot_path}" ]; then
|
||||
export SYSROOT_PATH=${sysroot_path}
|
||||
fi
|
||||
|
||||
if [ "x" != "x${arch_cflags}" ]; then
|
||||
export ARCH_CFLAGS="${arch_cflags}"
|
||||
fi
|
||||
|
||||
export PRODUCT_PATH="${product_path}"
|
||||
export DEVICE_PATH="${device_path}"
|
||||
|
||||
export OUTDIR="${outdir}"
|
||||
export KCONFIG_CONFIG="${liteos_config_file}"
|
||||
export LITEOS_MENUCONFIG_H="${outdir}/config.h"
|
||||
export LITEOS_CONFIG_FILE="${outdir}/.config"
|
||||
export LITEOS_COMPILER_PATH="${compile_prefix%/*}/"
|
||||
export CROSS_COMPILE="${compile_prefix##*/}"
|
||||
|
||||
mkdir -p "${outdir}"
|
||||
make -j all VERSION="${ohos_version}"
|
||||
|
||||
38
compat/BUILD.gn
Normal file
38
compat/BUILD.gn
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("compat") {
|
||||
deps = [ "posix" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
configs = [ "posix:public" ]
|
||||
}
|
||||
59
compat/posix/BUILD.gn
Normal file
59
compat/posix/BUILD.gn
Normal file
@@ -0,0 +1,59 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_COMPAT_POSIX)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/errno.c",
|
||||
"src/malloc.c",
|
||||
"src/map_error.c",
|
||||
"src/misc.c",
|
||||
"src/mqueue.c",
|
||||
"src/posix_memalign.c",
|
||||
"src/pthread.c",
|
||||
"src/pthread_attr.c",
|
||||
"src/pthread_cond.c",
|
||||
"src/pthread_mutex.c",
|
||||
"src/sched.c",
|
||||
"src/semaphore.c",
|
||||
"src/socket.c",
|
||||
"src/stdio.c",
|
||||
"src/stdlib.c",
|
||||
"src/time.c",
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -81,6 +81,11 @@ typedef union send_receive_t {
|
||||
short data;
|
||||
} mode_s;
|
||||
|
||||
struct mqnotify {
|
||||
pid_t pid;
|
||||
struct sigevent notify;
|
||||
};
|
||||
|
||||
/* TYPE DEFINITIONS */
|
||||
struct mqarray {
|
||||
UINT32 mq_id : 31;
|
||||
@@ -90,7 +95,7 @@ struct mqarray {
|
||||
mode_s mode_data; /* mode data of mqueue */
|
||||
uid_t euid; /* euid of mqueue */
|
||||
gid_t egid; /* egid of mqueue */
|
||||
fd_set mq_fdset; /* mqueue sysFd bit map */
|
||||
struct mqnotify mq_notify;
|
||||
LosQueueCB *mqcb;
|
||||
struct mqpersonal *mq_personal;
|
||||
};
|
||||
@@ -417,7 +422,8 @@ extern int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen,
|
||||
extern ssize_t mq_timedreceive(mqd_t personal, char *msg, size_t msgLen,
|
||||
unsigned int *msgPrio, const struct timespec *absTimeout);
|
||||
|
||||
extern void mqueue_refer(int sysFd);
|
||||
extern void MqueueRefer(int sysFd);
|
||||
extern int OsMqNotify(mqd_t personal, const struct sigevent *sigev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
51
compat/posix/src/errno.c
Normal file
51
compat/posix/src/errno.c
Normal file
@@ -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")));
|
||||
145
compat/posix/src/malloc.c
Normal file
145
compat/posix/src/malloc.c
Normal file
@@ -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);
|
||||
}
|
||||
@@ -30,13 +30,15 @@
|
||||
*/
|
||||
|
||||
#include "sys/types.h"
|
||||
#include "sys/resource.h"
|
||||
#include "unistd.h"
|
||||
#include "stdio.h"
|
||||
#include "pthread.h"
|
||||
#include "sys/utsname.h"
|
||||
#include "mqueue.h"
|
||||
#include "semaphore.h"
|
||||
|
||||
#include "los_process_pri.h"
|
||||
#include "los_hw.h"
|
||||
|
||||
/*
|
||||
* Supply some suitable values for constants that may not be present
|
||||
@@ -52,17 +54,27 @@
|
||||
int uname(struct utsname *name)
|
||||
{
|
||||
INT32 ret;
|
||||
const char *cpuInfo = NULL;
|
||||
|
||||
if (name == NULL) {
|
||||
return -EFAULT;
|
||||
}
|
||||
(VOID)strncpy_s(name->sysname, sizeof(name->sysname), KERNEL_NAME, strlen(KERNEL_NAME) + 1);
|
||||
(VOID)strncpy_s(name->nodename, sizeof(name->nodename), "hisilicon", strlen("hisilicon") + 1);
|
||||
ret = snprintf_s(name->version, sizeof(name->version), sizeof(name->version) - 1, "%s %u.%u.%u.%u %s %s\n",
|
||||
(VOID)strcpy_s(name->sysname, sizeof(name->sysname), KERNEL_NAME);
|
||||
(VOID)strcpy_s(name->nodename, sizeof(name->nodename), "hisilicon");
|
||||
ret = sprintf_s(name->version, sizeof(name->version), "%s %u.%u.%u.%u %s %s",
|
||||
KERNEL_NAME, KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE, __DATE__, __TIME__);
|
||||
if (ret < 0) {
|
||||
return -EIO;
|
||||
}
|
||||
name->machine[0] = '\0';
|
||||
|
||||
cpuInfo = LOS_CpuInfo();
|
||||
(VOID)strcpy_s(name->machine, sizeof(name->machine), cpuInfo);
|
||||
ret = sprintf_s(name->release, sizeof(name->release), "%u.%u.%u.%u",
|
||||
KERNEL_MAJOR, KERNEL_MINOR, KERNEL_PATCH, KERNEL_ITRE);
|
||||
if (ret < 0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
name->domainname[0] = '\0';
|
||||
return 0;
|
||||
}
|
||||
@@ -140,3 +152,50 @@ pid_t getpid(void)
|
||||
return ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
|
||||
}
|
||||
|
||||
int getrlimit(int resource, struct rlimit *rlim)
|
||||
{
|
||||
LosProcessCB *pcb = OsCurrProcessGet();
|
||||
|
||||
switch (resource) {
|
||||
case RLIMIT_NOFILE:
|
||||
case RLIMIT_FSIZE:
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
rlim->rlim_cur = pcb->pl_rlimit[resource].rlim_cur;
|
||||
rlim->rlim_max = pcb->pl_rlimit[resource].rlim_max;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define FSIZE_RLIMIT 0XFFFFFFFF
|
||||
#ifndef NR_OPEN_DEFAULT
|
||||
#define NR_OPEN_DEFAULT 1024
|
||||
#endif
|
||||
int setrlimit(int resource, const struct rlimit *rlim)
|
||||
{
|
||||
LosProcessCB *pcb = OsCurrProcessGet();
|
||||
|
||||
if (rlim->rlim_cur > rlim->rlim_max) {
|
||||
return -EINVAL;
|
||||
}
|
||||
switch (resource) {
|
||||
case RLIMIT_NOFILE:
|
||||
if (rlim->rlim_max > NR_OPEN_DEFAULT) {
|
||||
return -EPERM;
|
||||
}
|
||||
break;
|
||||
case RLIMIT_FSIZE:
|
||||
if (rlim->rlim_max > FSIZE_RLIMIT) {
|
||||
return -EPERM;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
pcb->pl_rlimit[resource].rlim_cur = rlim->rlim_cur;
|
||||
pcb->pl_rlimit[resource].rlim_max = rlim->rlim_max;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -49,6 +49,7 @@
|
||||
#endif
|
||||
|
||||
/* GLOBALS */
|
||||
STATIC fd_set g_queueFdSet;
|
||||
STATIC struct mqarray g_queueTable[LOSCFG_BASE_IPC_QUEUE_LIMIT];
|
||||
STATIC pthread_mutex_t g_mqueueMutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
|
||||
STATIC struct mqpersonal *g_mqPrivBuf[MAX_MQ_FD];
|
||||
@@ -120,6 +121,7 @@ STATIC INT32 DoMqueueDelete(struct mqarray *mqueueCB)
|
||||
mqueueCB->mode_data.data = 0;
|
||||
mqueueCB->euid = -1;
|
||||
mqueueCB->egid = -1;
|
||||
mqueueCB->mq_notify.pid = 0;
|
||||
|
||||
ret = LOS_QueueDelete(mqueueCB->mq_id);
|
||||
switch (ret) {
|
||||
@@ -204,6 +206,7 @@ STATIC struct mqpersonal *DoMqueueCreate(const struct mq_attr *attr, const CHAR
|
||||
mqueueCB->mq_personal->mq_flags = (INT32)((UINT32)openFlag | ((UINT32)attr->mq_flags & (UINT32)FNONBLOCK));
|
||||
mqueueCB->mq_personal->mq_mode = mode;
|
||||
mqueueCB->mq_personal->mq_refcount = 0;
|
||||
mqueueCB->mq_notify.pid = 0;
|
||||
|
||||
return mqueueCB->mq_personal;
|
||||
ERROUT:
|
||||
@@ -245,6 +248,44 @@ ERROUT:
|
||||
return (struct mqpersonal *)-1;
|
||||
}
|
||||
|
||||
STATIC INT32 DoMqueueClose(struct mqpersonal *privateMqPersonal)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *tmp = NULL;
|
||||
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
if (mqueueCB == NULL || mqueueCB->mq_personal == NULL) {
|
||||
errno = EBADF;
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
/* find the personal and remove */
|
||||
if (mqueueCB->mq_personal == privateMqPersonal) {
|
||||
mqueueCB->mq_personal = privateMqPersonal->mq_next;
|
||||
} else {
|
||||
for (tmp = mqueueCB->mq_personal; tmp->mq_next != NULL; tmp = tmp->mq_next) {
|
||||
if (tmp->mq_next == privateMqPersonal) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmp->mq_next == NULL) {
|
||||
errno = EBADF;
|
||||
return LOS_NOK;
|
||||
}
|
||||
tmp->mq_next = privateMqPersonal->mq_next;
|
||||
}
|
||||
/* flag no use */
|
||||
privateMqPersonal->mq_status = 0;
|
||||
|
||||
/* free the personal */
|
||||
(VOID)LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
|
||||
|
||||
if ((mqueueCB->unlinkflag == TRUE) && (mqueueCB->mq_personal == NULL)) {
|
||||
return DoMqueueDelete(mqueueCB);
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/* Translate a sysFd into privateMqPersonal */
|
||||
STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
|
||||
{
|
||||
@@ -270,29 +311,24 @@ STATIC struct mqpersonal *MqGetPrivDataBuff(mqd_t personal)
|
||||
STATIC INT32 MqAllocSysFd(int maxfdp, struct mqpersonal *privateMqPersonal)
|
||||
{
|
||||
INT32 i;
|
||||
struct mqarray *mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
fd_set *fdset = &mqueueCB->mq_fdset;
|
||||
fd_set *fdset = &g_queueFdSet;
|
||||
for (i = 0; i < maxfdp; i++) {
|
||||
/* sysFd: used bit setting, and get the index of swtmrID buffer */
|
||||
if (!(fdset && FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
|
||||
if (fdset && !(FD_ISSET(i + MQUEUE_FD_OFFSET, fdset))) {
|
||||
FD_SET(i + MQUEUE_FD_OFFSET, fdset);
|
||||
if (!g_mqPrivBuf[i]) {
|
||||
g_mqPrivBuf[i] = mqueueCB->mq_personal;
|
||||
g_mqPrivBuf[i] = privateMqPersonal;
|
||||
return i + MQUEUE_FD_OFFSET;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* there are no more mq sysFd to use, free the personal */
|
||||
LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
|
||||
privateMqPersonal = NULL;
|
||||
mqueueCB->mq_personal = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
STATIC VOID MqFreeSysFd(struct mqarray *mqueueCB, mqd_t personal)
|
||||
STATIC VOID MqFreeSysFd(mqd_t personal)
|
||||
{
|
||||
INT32 sysFd = (INT32)personal;
|
||||
fd_set *fdset = &mqueueCB->mq_fdset;
|
||||
fd_set *fdset = &g_queueFdSet;
|
||||
if (fdset && FD_ISSET(sysFd, fdset)) {
|
||||
FD_CLR(sysFd, fdset);
|
||||
g_mqPrivBuf[sysFd - MQUEUE_FD_OFFSET] = NULL;
|
||||
@@ -300,7 +336,7 @@ STATIC VOID MqFreeSysFd(struct mqarray *mqueueCB, mqd_t personal)
|
||||
}
|
||||
|
||||
/* Mqueue fd reference count */
|
||||
void mqueue_refer(int sysFd)
|
||||
void MqueueRefer(int sysFd)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
@@ -315,10 +351,11 @@ void mqueue_refer(int sysFd)
|
||||
if (mqueueCB == NULL) {
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
|
||||
privateMqPersonal->mq_refcount++;
|
||||
mqueueCB->unlink_ref++;
|
||||
OUT_UNLOCK:
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC INT32 MqTryClose(struct mqpersonal *privateMqPersonal)
|
||||
@@ -337,15 +374,6 @@ STATIC INT32 MqTryClose(struct mqpersonal *privateMqPersonal)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INT32 MqTryUnlink(struct mqarray *mqueueCB)
|
||||
{
|
||||
if (mqueueCB->unlink_ref == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
mqueueCB->unlink_ref--;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Set the mode data bit,for consumer's mode comparing. */
|
||||
STATIC INT32 MqueueModeAnalysisSet(struct mqpersonal *privateMqPersonal)
|
||||
{
|
||||
@@ -492,6 +520,9 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
|
||||
}
|
||||
/* Set mode data bit ,just for the first node */
|
||||
if (MqueueModeAnalysisSet(privateMqPersonal)) {
|
||||
if ((INT32)(UINTPTR)privateMqPersonal > 0) {
|
||||
(VOID)DoMqueueClose(privateMqPersonal);
|
||||
}
|
||||
goto OUT;
|
||||
}
|
||||
} else {
|
||||
@@ -500,15 +531,18 @@ mqd_t mq_open(const char *mqName, int openFlag, ...)
|
||||
}
|
||||
privateMqPersonal = DoMqueueOpen(mqueueCB, openFlag);
|
||||
}
|
||||
OUT:
|
||||
|
||||
if ((INT32)(UINTPTR)privateMqPersonal > 0) {
|
||||
/* alloc sysFd */
|
||||
sysFd = MqAllocSysFd(MAX_MQ_FD, privateMqPersonal);
|
||||
if (sysFd == -1) {
|
||||
/* there are no more mq sysFd to use, close the personal */
|
||||
(VOID)DoMqueueClose(privateMqPersonal);
|
||||
errno = ENFILE;
|
||||
}
|
||||
mqFd = (mqd_t)sysFd;
|
||||
}
|
||||
OUT:
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
return mqFd;
|
||||
}
|
||||
@@ -516,9 +550,7 @@ OUT:
|
||||
int mq_close(mqd_t personal)
|
||||
{
|
||||
INT32 ret = -1;
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
struct mqpersonal *tmp = NULL;
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
|
||||
@@ -532,47 +564,18 @@ int mq_close(mqd_t personal)
|
||||
errno = EBADF;
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
/* there have other thread used the fd */
|
||||
|
||||
if (!MqTryClose(privateMqPersonal)) {
|
||||
ret = 0;
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
if (mqueueCB->mq_personal == NULL) {
|
||||
errno = EBADF;
|
||||
|
||||
ret = DoMqueueClose(privateMqPersonal);
|
||||
if (ret < 0) {
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
MqFreeSysFd(personal);
|
||||
|
||||
/* find the personal and remove */
|
||||
if (mqueueCB->mq_personal == privateMqPersonal) {
|
||||
mqueueCB->mq_personal = privateMqPersonal->mq_next;
|
||||
} else {
|
||||
for (tmp = mqueueCB->mq_personal; tmp->mq_next != NULL; tmp = tmp->mq_next) {
|
||||
if (tmp->mq_next == privateMqPersonal) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tmp->mq_next == NULL) {
|
||||
errno = EBADF;
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
tmp->mq_next = privateMqPersonal->mq_next;
|
||||
}
|
||||
/* flag no use */
|
||||
privateMqPersonal->mq_status = 0;
|
||||
MqFreeSysFd(mqueueCB, personal);
|
||||
|
||||
/* free the personal */
|
||||
ret = LOS_MemFree(OS_SYS_MEM_ADDR, privateMqPersonal);
|
||||
if (ret != LOS_OK) {
|
||||
errno = EFAULT;
|
||||
ret = -1;
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
|
||||
if ((mqueueCB->unlinkflag == TRUE) && (mqueueCB->mq_personal == NULL)) {
|
||||
ret = DoMqueueDelete(mqueueCB);
|
||||
}
|
||||
OUT_UNLOCK:
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
return ret;
|
||||
@@ -665,10 +668,7 @@ int mq_unlink(const char *mqName)
|
||||
errno = ENOENT;
|
||||
goto ERROUT_UNLOCK;
|
||||
}
|
||||
if (!MqTryUnlink(mqueueCB)) {
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mqueueCB->mq_personal != NULL) {
|
||||
mqueueCB->unlinkflag = TRUE;
|
||||
} else if (mqueueCB->unlink_ref == 0) {
|
||||
@@ -717,6 +717,35 @@ STATIC INLINE BOOL MqParamCheck(mqd_t personal, const char *msg, size_t msgLen)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Send realtime a signal to process which registered itself
|
||||
* successfully by mq_notify.
|
||||
*/
|
||||
static void MqSendNotify(struct mqarray *mqueueCB)
|
||||
{
|
||||
struct mqnotify *mqnotify = &mqueueCB->mq_notify;
|
||||
|
||||
if ((mqnotify->pid) && (mqueueCB->mqcb->readWriteableCnt[OS_QUEUE_READ] == 0)) {
|
||||
siginfo_t info;
|
||||
|
||||
switch (mqnotify->notify.sigev_notify) {
|
||||
case SIGEV_SIGNAL:
|
||||
/* sends signal */
|
||||
/* Create the siginfo structure */
|
||||
info.si_signo = mqnotify->notify.sigev_signo;
|
||||
info.si_code = SI_MESGQ;
|
||||
info.si_value = mqnotify->notify.sigev_value;
|
||||
OsDispatch(mqnotify->pid, &info, OS_USER_KILL_PERMISSION);
|
||||
break;
|
||||
case SIGEV_NONE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* after notification unregisters process */
|
||||
mqnotify->pid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#define OS_MQ_GOTO_ERROUT_UNLOCK_IF(expr, errcode) \
|
||||
if (expr) { \
|
||||
errno = errcode; \
|
||||
@@ -754,6 +783,10 @@ int mq_timedsend(mqd_t personal, const char *msg, size_t msgLen, unsigned int ms
|
||||
mqueueID = mqueueCB->mq_id;
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
|
||||
if (LOS_ListEmpty(&mqueueCB->mqcb->readWriteList[OS_QUEUE_READ])) {
|
||||
MqSendNotify(mqueueCB);
|
||||
}
|
||||
|
||||
err = LOS_QueueWriteCopy(mqueueID, (VOID *)msg, (UINT32)msgLen, (UINT32)absTicks);
|
||||
if (map_errno(err) != ENOERR) {
|
||||
goto ERROUT;
|
||||
@@ -832,4 +865,82 @@ ssize_t mq_receive(mqd_t personal, char *msg_ptr, size_t msg_len, unsigned int *
|
||||
return mq_timedreceive(personal, msg_ptr, msg_len, msg_prio, NULL);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL MqNotifyParamCheck(mqd_t personal, const struct sigevent *sigev)
|
||||
{
|
||||
if (personal < 0) {
|
||||
errno = EBADF;
|
||||
goto ERROUT;
|
||||
}
|
||||
|
||||
if (sigev != NULL) {
|
||||
if (sigev->sigev_notify != SIGEV_NONE && sigev->sigev_notify != SIGEV_SIGNAL) {
|
||||
errno = EINVAL;
|
||||
goto ERROUT;
|
||||
}
|
||||
if (sigev->sigev_notify == SIGEV_SIGNAL && !GOOD_SIGNO(sigev->sigev_signo)) {
|
||||
errno = EINVAL;
|
||||
goto ERROUT;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
ERROUT:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int OsMqNotify(mqd_t personal, const struct sigevent *sigev)
|
||||
{
|
||||
struct mqarray *mqueueCB = NULL;
|
||||
struct mqnotify *mqnotify = NULL;
|
||||
struct mqpersonal *privateMqPersonal = NULL;
|
||||
|
||||
if (!MqNotifyParamCheck(personal, sigev)) {
|
||||
goto ERROUT;
|
||||
}
|
||||
|
||||
(VOID)pthread_mutex_lock(&g_mqueueMutex);
|
||||
privateMqPersonal = MqGetPrivDataBuff(personal);
|
||||
if (privateMqPersonal == NULL) {
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
|
||||
if (privateMqPersonal->mq_status != MQ_USE_MAGIC) {
|
||||
errno = EBADF;
|
||||
goto OUT_UNLOCK;
|
||||
}
|
||||
|
||||
mqueueCB = privateMqPersonal->mq_posixdes;
|
||||
mqnotify = &mqueueCB->mq_notify;
|
||||
|
||||
if (sigev == NULL) {
|
||||
if (mqnotify->pid == LOS_GetCurrProcessID()) {
|
||||
mqnotify->pid = 0;
|
||||
}
|
||||
} else if (mqnotify->pid != 0) {
|
||||
errno = EBUSY;
|
||||
goto OUT_UNLOCK;
|
||||
} else {
|
||||
switch (sigev->sigev_notify) {
|
||||
case SIGEV_NONE:
|
||||
mqnotify->notify.sigev_notify = SIGEV_NONE;
|
||||
break;
|
||||
case SIGEV_SIGNAL:
|
||||
mqnotify->notify.sigev_signo = sigev->sigev_signo;
|
||||
mqnotify->notify.sigev_value = sigev->sigev_value;
|
||||
mqnotify->notify.sigev_notify = SIGEV_SIGNAL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
mqnotify->pid = LOS_GetCurrProcessID();
|
||||
}
|
||||
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
return 0;
|
||||
OUT_UNLOCK:
|
||||
(VOID)pthread_mutex_unlock(&g_mqueueMutex);
|
||||
ERROUT:
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -204,7 +204,7 @@ STATIC UINT32 InitPthreadData(pthread_t threadID, pthread_attr_t *userAttr,
|
||||
PRINT_ERR("%s: %d, err: %d\n", __FUNCTION__, __LINE__, err);
|
||||
return LOS_NOK;
|
||||
}
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if (userAttr->cpuset.__bits[0] > 0) {
|
||||
taskCB->cpuAffiMask = (UINT16)userAttr->cpuset.__bits[0];
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ int pthread_attr_init(pthread_attr_t *attr)
|
||||
attr->stacksize_set = 1;
|
||||
attr->stacksize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
attr->cpuset.__bits[0] = 0;
|
||||
#endif
|
||||
|
||||
@@ -239,7 +239,7 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stackSize)
|
||||
*/
|
||||
int pthread_attr_setaffinity_np(pthread_attr_t* attr, size_t cpusetsize, const cpu_set_t* cpuset)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if (attr == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -264,7 +264,7 @@ int pthread_attr_setaffinity_np(pthread_attr_t* attr, size_t cpusetsize, const c
|
||||
*/
|
||||
int pthread_attr_getaffinity_np(const pthread_attr_t* attr, size_t cpusetsize, cpu_set_t* cpuset)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if ((attr == NULL) || (cpuset == NULL) || (cpusetsize != sizeof(cpu_set_t))) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ int sched_get_priority_max(int policy)
|
||||
*/
|
||||
int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT32 taskID = (UINT32)pid;
|
||||
UINT32 ret;
|
||||
|
||||
@@ -93,7 +93,7 @@ int sched_setaffinity(pid_t pid, size_t set_size, const cpu_set_t* set)
|
||||
*/
|
||||
int sched_getaffinity(pid_t pid, size_t set_size, cpu_set_t* set)
|
||||
{
|
||||
#if (LOSCFG_KERNEL_SMP == YES)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT32 taskID = (UINT32)pid;
|
||||
UINT16 cpuAffiMask;
|
||||
|
||||
@@ -138,3 +138,8 @@ int __sched_cpucount(size_t set_size, const cpu_set_t* set)
|
||||
return count;
|
||||
}
|
||||
|
||||
int sched_yield()
|
||||
{
|
||||
(void)LOS_TaskYield();
|
||||
return 0;
|
||||
}
|
||||
|
||||
121
compat/posix/src/stdio.c
Normal file
121
compat/posix/src/stdio.c
Normal file
@@ -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.
|
||||
*/
|
||||
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/mount.h>
|
||||
#include "proc_fs.h"
|
||||
#include "los_trace.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include "los_printf.h"
|
||||
#include "los_exc.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_TRACE
|
||||
static int KernelTraceProcFill(struct SeqBuf *m, void *v)
|
||||
char *getenv(const char *name)
|
||||
{
|
||||
(void)v;
|
||||
if (m == NULL) {
|
||||
return -LOS_EPERM;
|
||||
}
|
||||
|
||||
if (m->buf == NULL) {
|
||||
m->buf = (char *)LOS_TraceBufDataGet(&(m->size), &(m->count));
|
||||
}
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const struct ProcFileOperations KERNEL_TRACE_PROC_FOPS = {
|
||||
.read = KernelTraceProcFill,
|
||||
};
|
||||
#endif
|
||||
|
||||
void ProcKernelTraceInit(void)
|
||||
void srand(unsigned s)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_TRACE
|
||||
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
|
||||
return srandom(s);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -452,11 +452,25 @@ int clock_settime(clockid_t clockID, const struct timespec *tp)
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
inline UINT32 GetTidFromClockID(clockid_t clockID)
|
||||
{
|
||||
// In musl/src/thread/pthread_getcpuclockid.c, we know 'clockid = (-tid - 1) * 8 + 6'
|
||||
UINT32 tid = -(clockID - 6) / 8 - 1; // 6 8 1 inverse operation from clockID to tid
|
||||
return tid;
|
||||
}
|
||||
|
||||
inline const pid_t GetPidFromClockID(clockid_t clockID)
|
||||
{
|
||||
// In musl/src/time/clock_getcpuclockid.c, we know 'clockid = (-pid - 1) * 8 + 2'
|
||||
const pid_t pid = -(clockID - 2) / 8 - 1; // 2 8 1 inverse operation from clockID to pid
|
||||
return pid;
|
||||
}
|
||||
|
||||
static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
|
||||
{
|
||||
uint64_t runtime;
|
||||
UINT32 intSave;
|
||||
UINT32 tid = ((UINT32) ~((clockID) >> CPUCLOCK_ID_OFFSET));
|
||||
UINT32 tid = GetTidFromClockID(clockID);
|
||||
|
||||
if (OS_TID_CHECK_INVALID(tid)) {
|
||||
return -EINVAL;
|
||||
@@ -482,7 +496,7 @@ static int ProcessGetCputime(clockid_t clockID, struct timespec *ats)
|
||||
{
|
||||
UINT64 runtime;
|
||||
UINT32 intSave;
|
||||
const pid_t pid = ((pid_t) ~((clockID) >> CPUCLOCK_ID_OFFSET));
|
||||
const pid_t pid = GetPidFromClockID(clockID);
|
||||
LosProcessCB *spcb = NULL;
|
||||
|
||||
if (OsProcessIDUserCheckInvalid(pid) || pid < 0) {
|
||||
@@ -524,7 +538,7 @@ static int GetCputime(clockid_t clockID, struct timespec *tp)
|
||||
static int CheckClock(const clockid_t clockID)
|
||||
{
|
||||
int error = 0;
|
||||
const pid_t pid = ((pid_t) ~((clockID) >> CPUCLOCK_ID_OFFSET));
|
||||
const pid_t pid = GetPidFromClockID(clockID);
|
||||
|
||||
if (!((UINT32)clockID & CPUCLOCK_PERTHREAD_MASK)) {
|
||||
LosProcessCB *spcb = NULL;
|
||||
@@ -950,11 +964,11 @@ int timer_getoverrun(timer_t timerID)
|
||||
return (overRun > DELAYTIMER_MAX) ? DELAYTIMER_MAX : overRun;
|
||||
}
|
||||
|
||||
STATIC INT32 DoNanoSleep(UINT64 useconds)
|
||||
STATIC INT32 DoNanoSleep(UINT64 nanoseconds)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ret = LOS_TaskDelay(OsUS2Tick(useconds));
|
||||
ret = LOS_TaskDelay(OsNS2Tick(nanoseconds));
|
||||
if (ret == LOS_OK || ret == LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK) {
|
||||
return 0;
|
||||
}
|
||||
@@ -963,12 +977,12 @@ STATIC INT32 DoNanoSleep(UINT64 useconds)
|
||||
|
||||
int usleep(unsigned useconds)
|
||||
{
|
||||
return DoNanoSleep((UINT64)useconds);
|
||||
return DoNanoSleep((UINT64)useconds * OS_SYS_NS_PER_US);
|
||||
}
|
||||
|
||||
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
{
|
||||
UINT64 useconds;
|
||||
UINT64 nanoseconds;
|
||||
INT32 ret = -1;
|
||||
|
||||
(VOID)rmtp;
|
||||
@@ -979,14 +993,14 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
useconds = (UINT64)rqtp->tv_sec * OS_SYS_US_PER_SECOND + rqtp->tv_nsec / OS_SYS_NS_PER_US;
|
||||
nanoseconds = (UINT64)rqtp->tv_sec * OS_SYS_NS_PER_SECOND + rqtp->tv_nsec;
|
||||
|
||||
return DoNanoSleep(useconds);
|
||||
return DoNanoSleep(nanoseconds);
|
||||
}
|
||||
|
||||
unsigned int sleep(unsigned int seconds)
|
||||
{
|
||||
return DoNanoSleep((UINT64)seconds * OS_SYS_US_PER_SECOND);
|
||||
return DoNanoSleep((UINT64)seconds * OS_SYS_NS_PER_SECOND);
|
||||
}
|
||||
|
||||
double difftime(time_t time2, time_t time1)
|
||||
@@ -1121,3 +1135,19 @@ VOID OsVdsoTimeGet(VdsoDataPage *vdsoDataPage)
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
18
config.mk
18
config.mk
@@ -29,16 +29,8 @@
|
||||
|
||||
############### this is a makefile that you can config it ###############
|
||||
-include $(LITEOSTOPDIR)/tools/build/mk/los_config.mk
|
||||
|
||||
TOP_LD_PATH = $(LITEOSTOPDIR)
|
||||
SCRIPTS_PATH = $(LITEOS_SCRIPTPATH)
|
||||
LITEOS_MK_PATH = $(MK_PATH)
|
||||
LITEOS_SUBDIRS = $(LIB_SUBDIRS)
|
||||
LIB_BIGODIR = $(LITEOS_LIB_BIGODIR)
|
||||
|
||||
##### liteos tables -u ldflags #####
|
||||
-include $(LITEOS_MK_PATH)/liteos_tables_ldflags.mk
|
||||
|
||||
-include $(LITEOSTOPDIR)/tools/build/mk/liteos_tables_ldflags.mk
|
||||
|
||||
LITEOS_COPTS := $(LITEOS_COPTS_DEBUG) $(LITEOS_COPTS_BASE) \
|
||||
$(LITEOS_COPTS_EXTRA) $(LITEOS_CORE_COPTS)
|
||||
@@ -59,3 +51,11 @@ LITEOS_CXXFLAGS := $(LITEOS_CXXOPTS) $(LITEOS_CXXMACRO) \
|
||||
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 :=
|
||||
|
||||
56
drivers/BUILD.gn
Normal file
56
drivers/BUILD.gn
Normal file
@@ -0,0 +1,56 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("drivers") {
|
||||
deps = [
|
||||
"block/disk",
|
||||
"char/bch",
|
||||
"char/mem",
|
||||
"char/quickstart",
|
||||
"char/random",
|
||||
"char/trace",
|
||||
"char/video",
|
||||
"mtd/multi_partition",
|
||||
]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
configs = [
|
||||
"block/disk:public",
|
||||
"char/bch:public",
|
||||
"char/mem:public",
|
||||
"char/quickstart:public",
|
||||
"char/random:public",
|
||||
"char/video:public",
|
||||
"char/trace:public",
|
||||
"mtd/multi_partition:public",
|
||||
]
|
||||
}
|
||||
45
drivers/block/disk/BUILD.gn
Normal file
45
drivers/block/disk/BUILD.gn
Normal file
@@ -0,0 +1,45 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_FAT_DISK)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/disk.c",
|
||||
"src/disk_shellcmd.c",
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -725,6 +725,9 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName);
|
||||
*/
|
||||
INT32 los_get_diskid_byname(const CHAR *diskName);
|
||||
|
||||
|
||||
los_disk *los_get_mmcdisk_bytype(UINT8 type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -187,6 +187,22 @@ INT32 los_get_diskid_byname(const CHAR *diskName)
|
||||
return diskID;
|
||||
}
|
||||
|
||||
los_disk *los_get_mmcdisk_bytype(UINT8 type)
|
||||
{
|
||||
const CHAR *mmcDevHead = "/dev/mmcblk";
|
||||
|
||||
for (INT32 diskId = 0; diskId < SYS_MAX_DISK; diskId++) {
|
||||
los_disk *disk = get_disk(diskId);
|
||||
if (disk == NULL) {
|
||||
continue;
|
||||
} else if ((disk->type == type) && (strncmp(disk->disk_name, mmcDevHead, strlen(mmcDevHead)) == 0)) {
|
||||
return disk;
|
||||
}
|
||||
}
|
||||
PRINT_ERR("Cannot find the mmc disk!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID OsSetUsbStatus(UINT32 diskID)
|
||||
{
|
||||
if (diskID < SYS_MAX_DISK) {
|
||||
@@ -328,11 +344,7 @@ static INT32 DiskAddPart(los_disk *disk, UINT64 sectorStart, UINT64 sectorCount,
|
||||
|
||||
VnodeHold();
|
||||
VnodeLookup(devName, &partDev, 0);
|
||||
if (ret < 0) {
|
||||
VnodeDrop();
|
||||
PRINT_ERR("DiskAddPart : find %s fail!\n", devName);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
part = DiskPartAllocate(partDev, sectorStart, sectorCount);
|
||||
VnodeDrop();
|
||||
if (part == NULL) {
|
||||
@@ -1410,10 +1422,13 @@ DISK_FIND_ERROR:
|
||||
|
||||
INT32 los_disk_deinit(INT32 diskID)
|
||||
{
|
||||
int ret;
|
||||
los_disk *disk = get_disk(diskID);
|
||||
if (disk == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
ret = ForceUmountDev(disk->dev);
|
||||
PRINTK("warning: %s lost, force umount ret = %d\n", disk->disk_name, ret);
|
||||
|
||||
DISK_LOCK(&disk->disk_mutex);
|
||||
|
||||
|
||||
52
drivers/char/bch/BUILD.gn
Normal file
52
drivers/char/bch/BUILD.gn
Normal file
@@ -0,0 +1,52 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS_BLOCK_DEVICE)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_driver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_register.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_unregister.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_cache.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_read.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_sem.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_setup.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_teardown.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_write.c",
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
42
drivers/char/mem/BUILD.gn
Normal file
42
drivers/char/mem/BUILD.gn
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_MEM)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "src/mem.c" ]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
42
drivers/char/quickstart/BUILD.gn
Normal file
42
drivers/char/quickstart/BUILD.gn
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_QUICKSTART)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "src/quickstart.c" ]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
46
drivers/char/random/BUILD.gn
Normal file
46
drivers/char/random/BUILD.gn
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_RANDOM)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "src/random.c" ]
|
||||
|
||||
if (defined(LOSCFG_HW_RANDOM_ENABLE)) {
|
||||
sources += [ "src/random_hw.c" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -65,7 +65,7 @@ static int RandomHwClose(struct file *filep)
|
||||
|
||||
static int RandomHwIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
int ret;
|
||||
int ret = -1;
|
||||
|
||||
switch (cmd) {
|
||||
default:
|
||||
@@ -77,7 +77,7 @@ static int RandomHwIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
static ssize_t RandomHwRead(struct file *filep, char *buffer, size_t buflen)
|
||||
{
|
||||
int ret;
|
||||
int ret = -1;
|
||||
|
||||
if (g_randomOp.read != NULL) {
|
||||
ret = g_randomOp.read(buffer, buflen);
|
||||
|
||||
42
drivers/char/trace/BUILD.gn
Normal file
42
drivers/char/trace/BUILD.gn
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_TRACE)
|
||||
module_name = "trace_dev"
|
||||
kernel_module(module_name) {
|
||||
sources = [ "src/trace.c" ]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
6
drivers/char/trace/Kconfig
Normal file
6
drivers/char/trace/Kconfig
Normal file
@@ -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.
|
||||
40
drivers/char/trace/Makefile
Normal file
40
drivers/char/trace/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
MODULE_NAME := trace_dev
|
||||
|
||||
LOCAL_SRCS := $(wildcard src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := -I $(LITEOSTOPDIR)/drivers/char/trace/include
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
include $(MODULE)
|
||||
49
drivers/char/trace/include/los_dev_trace.h
Normal file
49
drivers/char/trace/include/los_dev_trace.h
Normal file
@@ -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
|
||||
160
drivers/char/trace/src/trace.c
Normal file
160
drivers/char/trace/src/trace.c
Normal file
@@ -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);
|
||||
42
drivers/char/video/BUILD.gn
Normal file
42
drivers/char/video/BUILD.gn
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_VIDEO)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "$LITEOSTHIRDPARTY/NuttX/drivers/video/fb.c" ]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "$LITEOSTHIRDPARTY/NuttX/include/nuttx/video" ]
|
||||
}
|
||||
51
drivers/mtd/multi_partition/BUILD.gn
Normal file
51
drivers/mtd/multi_partition/BUILD.gn
Normal file
@@ -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.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/mtd_partition.c",
|
||||
"src/mtd_shellcmd.c",
|
||||
]
|
||||
|
||||
include_dirs = [ "$LITEOSTOPDIR/fs/jffs2/include" ]
|
||||
|
||||
if (defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7)) {
|
||||
include_dirs += [ "//device/qemu/drivers/cfiflash" ]
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -35,11 +35,11 @@ LOCAL_SRCS := $(wildcard src/*.c)
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/fs/jffs2/include \
|
||||
-I $(LITEOSTOPDIR)/drivers/mtd/multi_partition/include \
|
||||
-I $(LITEOSTOPDIR)/../../device/hisilicon/drivers/include/mtd/common/include
|
||||
-I $(LITEOSTOPDIR)/../../drivers/framework/model/storage/include \
|
||||
-I $(LITEOSTOPDIR)/../../drivers/adapter/khdf/liteos/model/storage/include
|
||||
|
||||
ifeq ($(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7), y)
|
||||
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/arm_virt/config/cfiflash
|
||||
LOCAL_INCLUDE += -I $(LITEOSTOPDIR)/../../device/qemu/drivers/cfiflash
|
||||
endif
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "los_config.h"
|
||||
#include "los_mux.h"
|
||||
#include "fs/driver.h"
|
||||
#include "mtd_common.h"
|
||||
#include "mtd_legacy_lite.h"
|
||||
|
||||
#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7
|
||||
#include "cfiflash.h"
|
||||
|
||||
56
fs/BUILD.gn
Normal file
56
fs/BUILD.gn
Normal file
@@ -0,0 +1,56 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
group("fs") {
|
||||
deps = [
|
||||
"fat",
|
||||
"fat/virpart",
|
||||
"jffs2",
|
||||
"nfs",
|
||||
"proc",
|
||||
"ramfs",
|
||||
"romfs",
|
||||
"vfs",
|
||||
"vfs/bcache",
|
||||
"zpfs",
|
||||
]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
configs = [
|
||||
"vfs:public",
|
||||
"vfs/bcache:public",
|
||||
"fat:public",
|
||||
"fat/virpart:public",
|
||||
"proc:public",
|
||||
]
|
||||
}
|
||||
55
fs/fat/BUILD.gn
Normal file
55
fs/fat/BUILD.gn
Normal file
@@ -0,0 +1,55 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_FAT)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"os_adapt/fat_shellcmd.c",
|
||||
"os_adapt/fatfs.c",
|
||||
"os_adapt/format.c",
|
||||
]
|
||||
|
||||
sources += [
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/diskio.c",
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/ff.c",
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/ffsystem.c",
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/ffunicode.c",
|
||||
]
|
||||
|
||||
include_dirs = [ "os_adapt" ]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "$LITEOSTHIRDPARTY/FatFs/source" ]
|
||||
}
|
||||
@@ -39,7 +39,6 @@ LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/fs/fat/os_adapt \
|
||||
-I $(LITEOSTOPDIR)/fs/fat/virpart/include \
|
||||
-I $(LITEOSTOPDIR)/fs/vfs \
|
||||
-I $(LITEOSTHIRDPARTY)/NuttX/include
|
||||
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE) $(LITEOS_GCOV_OPTS)
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
#include "los_tables.h"
|
||||
#include "user_copy.h"
|
||||
#include "los_vm_filemap.h"
|
||||
#include "los_hash.h"
|
||||
#include "los_vm_common.h"
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
@@ -53,7 +55,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include "los_hash.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
struct VnodeOps fatfs_vops; /* forward define */
|
||||
@@ -190,7 +192,7 @@ static int fatfs_sync(unsigned long mountflags, FATFS *fs)
|
||||
{
|
||||
#ifdef LOSCFG_FS_FAT_CACHE
|
||||
los_part *part = NULL;
|
||||
if (mountflags != MS_NOSYNC) {
|
||||
if (!(mountflags & (MS_NOSYNC | MS_RDONLY))) {
|
||||
part = get_part((INT)fs->pdrv);
|
||||
if (part == NULL) {
|
||||
return -ENODEV;
|
||||
@@ -238,7 +240,8 @@ static mode_t fatfs_get_mode(BYTE attribute, mode_t fs_mode)
|
||||
return fs_mode;
|
||||
}
|
||||
|
||||
static enum VnodeType fatfstype_2_vnodetype(BYTE type) {
|
||||
static enum VnodeType fatfstype_2_vnodetype(BYTE type)
|
||||
{
|
||||
switch (type) {
|
||||
case AM_ARC:
|
||||
return VNODE_TYPE_REG;
|
||||
@@ -251,11 +254,13 @@ static enum VnodeType fatfstype_2_vnodetype(BYTE type) {
|
||||
}
|
||||
}
|
||||
|
||||
static FRESULT init_cluster(DIR *dp_new, FATFS *fs, int type, const char *target, DWORD *clust)
|
||||
#define DIR_SIZE 32
|
||||
static FRESULT init_cluster(DIR_FILE *pdfp, DIR *dp_new, FATFS *fs, int type, const char *target, DWORD *clust)
|
||||
{
|
||||
FRESULT result;
|
||||
BYTE *dir = NULL;
|
||||
QWORD sect;
|
||||
DWORD pclust;
|
||||
UINT n;
|
||||
|
||||
/* Allocate a new cluster */
|
||||
@@ -284,24 +289,53 @@ static FRESULT init_cluster(DIR *dp_new, FATFS *fs, int type, const char *target
|
||||
mem_set(dir, 0, SS(fs));
|
||||
if (type == AM_LNK && target) {
|
||||
/* Write target to symlink */
|
||||
strcpy_s((char *)dir, SS(fs), target);
|
||||
}
|
||||
for (n = fs->csize; n > 0; n--) {
|
||||
#ifndef LOSCFG_FS_FAT_VIRTUAL_PARTITION
|
||||
fs->winsect = sect++;
|
||||
fs->wflag = 1;
|
||||
#else
|
||||
PARENTFS(fs)->winsect = sect++;
|
||||
PARENTFS(fs)->wflag = 1;
|
||||
#endif
|
||||
result = sync_window(fs);
|
||||
if (result != FR_OK) {
|
||||
remove_chain(&(dp_new->obj), *clust, 0);
|
||||
return result;
|
||||
(void)strcpy_s((char *)dir, SS(fs), target);
|
||||
} else {
|
||||
/* Write the dir cluster */
|
||||
mem_set(dir, 0, SS(fs));
|
||||
/* 11, the The max length of of the short file name, Create "." entry */
|
||||
mem_set(dir + DIR_Name, ' ', 11);
|
||||
dir[DIR_Name] = '.';
|
||||
dir[DIR_Attr] = AM_DIR;
|
||||
st_clust(fs, dir, *clust);
|
||||
mem_cpy(dir + DIR_SIZE, dir, DIR_SIZE); /* Create ".." entry */
|
||||
dir[DIR_SIZE + 1] = '.'; /* Add extra "." */
|
||||
pclust = pdfp->fno.sclst;
|
||||
if (fs->fs_type == FS_FAT32 && pclust == fs->dirbase) {
|
||||
pclust = 0;
|
||||
}
|
||||
if (type == AM_LNK) {
|
||||
/* No need to clean the rest sectors of the cluster for symlink */
|
||||
break;
|
||||
st_clust(fs, dir + DIR_SIZE, pclust);
|
||||
}
|
||||
|
||||
#ifndef LOSCFG_FS_FAT_VIRTUAL_PARTITION
|
||||
fs->winsect = sect++;
|
||||
fs->wflag = 1;
|
||||
#else
|
||||
PARENTFS(fs)->winsect = sect++;
|
||||
PARENTFS(fs)->wflag = 1;
|
||||
#endif
|
||||
result = sync_window(fs);
|
||||
if (result != FR_OK) {
|
||||
remove_chain(&(dp_new->obj), *clust, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Rest of directory cluster should set to be zero */
|
||||
if (type == AM_DIR) {
|
||||
mem_set(dir, 0, SS(fs));
|
||||
for (n = fs->csize - 1; n > 0; n--) {
|
||||
#ifndef LOSCFG_FS_FAT_VIRTUAL_PARTITION
|
||||
fs->winsect = sect++;
|
||||
fs->wflag = 1;
|
||||
#else
|
||||
PARENTFS(fs)->winsect = sect++;
|
||||
PARENTFS(fs)->wflag = 1;
|
||||
#endif
|
||||
result = sync_window(fs);
|
||||
if (result != FR_OK) {
|
||||
remove_chain(&(dp_new->obj), *clust, 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +400,7 @@ static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, st
|
||||
}
|
||||
|
||||
if (type == AM_DIR || type == AM_LNK) {
|
||||
result = init_cluster(dp_new, fs, type, target, &clust);
|
||||
result = init_cluster(dfp, dp_new, fs, type, target, &clust);
|
||||
if (result != FR_OK) {
|
||||
goto ERROR_UNLOCK;
|
||||
}
|
||||
@@ -416,6 +450,8 @@ static int fatfs_create_obj(struct Vnode *parent, const char *name, int mode, st
|
||||
dp_new->obj.objsize = 0;
|
||||
} else if (type == AM_LNK) {
|
||||
dp_new->obj.objsize = strlen(target);
|
||||
} else {
|
||||
finfo_new->fsize = fs->csize * SS(fs);
|
||||
}
|
||||
|
||||
ret = VnodeAlloc(&fatfs_vops, &vp);
|
||||
@@ -525,6 +561,7 @@ int fatfs_lookup(struct Vnode *parent, const char *path, int len, struct Vnode *
|
||||
vp->mode = fatfs_get_mode(finfo->fattrib, fs->fs_mode);
|
||||
if (finfo->fattrib & AM_DIR) {
|
||||
vp->type = VNODE_TYPE_DIR;
|
||||
finfo->fsize = fs->csize * SS(fs);
|
||||
} else {
|
||||
vp->type = VNODE_TYPE_REG;
|
||||
}
|
||||
@@ -576,7 +613,7 @@ int fatfs_open(struct file *filep)
|
||||
ret = lock_fs(fs);
|
||||
if (ret == FALSE) {
|
||||
ret = EBUSY;
|
||||
goto ERROR_EXIT;
|
||||
goto ERROR_FREE;
|
||||
}
|
||||
|
||||
fp->dir_sect = dp->sect;
|
||||
@@ -595,7 +632,7 @@ int fatfs_open(struct file *filep)
|
||||
fp->buf = (BYTE*) ff_memalloc(SS(fs));
|
||||
if (fp->buf == NULL) {
|
||||
ret = ENOMEM;
|
||||
goto ERROR_FREE;
|
||||
goto ERROR_UNLOCK;
|
||||
}
|
||||
LOS_ListAdd(&finfo->fp_list, &fp->fp_entry);
|
||||
unlock_fs(fs, FR_OK);
|
||||
@@ -603,8 +640,9 @@ int fatfs_open(struct file *filep)
|
||||
filep->f_priv = fp;
|
||||
return fatfs_sync(vp->originMount->mountFlags, fs);
|
||||
|
||||
ERROR_FREE:
|
||||
ERROR_UNLOCK:
|
||||
unlock_fs(fs, FR_OK);
|
||||
ERROR_FREE:
|
||||
free(fp);
|
||||
ERROR_EXIT:
|
||||
return -ret;
|
||||
@@ -704,6 +742,7 @@ off64_t fatfs_lseek64(struct file *filep, off64_t offset, int whence)
|
||||
struct Vnode *vp = filep->f_vnode;
|
||||
DIR_FILE *dfp = (DIR_FILE *)vp->data;
|
||||
FILINFO *finfo = &(dfp->fno);
|
||||
struct Mount *mount = vp->originMount;
|
||||
FSIZE_t fpos;
|
||||
FRESULT result;
|
||||
int ret;
|
||||
@@ -741,6 +780,17 @@ off64_t fatfs_lseek64(struct file *filep, off64_t offset, int whence)
|
||||
if (ret == FALSE) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
if (fpos > finfo->fsize) {
|
||||
if ((filep->f_oflags & O_ACCMODE) == O_RDONLY) {
|
||||
result = FR_DENIED;
|
||||
goto ERROR_EXIT;
|
||||
}
|
||||
if (mount->mountFlags & MS_RDONLY) {
|
||||
result = FR_WRITE_PROTECTED;
|
||||
goto ERROR_EXIT;
|
||||
}
|
||||
}
|
||||
fp->obj.sclust = finfo->sclst;
|
||||
fp->obj.objsize = finfo->fsize;
|
||||
|
||||
@@ -872,11 +922,13 @@ int fatfs_fallocate64(struct file *filep, int mode, off64_t offset, off64_t len)
|
||||
return -EBUSY;
|
||||
}
|
||||
result = f_expand(fp, (FSIZE_t)offset, (FSIZE_t)len, 1);
|
||||
if (result == FR_OK && finfo->sclst == 0) {
|
||||
finfo->sclst = fp->obj.sclust;
|
||||
if (result == FR_OK) {
|
||||
if (finfo->sclst == 0) {
|
||||
finfo->sclst = fp->obj.sclust;
|
||||
}
|
||||
result = f_sync(fp);
|
||||
}
|
||||
result = f_sync(fp);
|
||||
unlock_fs(fs, FR_OK);
|
||||
unlock_fs(fs, result);
|
||||
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
@@ -1134,6 +1186,7 @@ int fatfs_mount(struct Mount *mnt, struct Vnode *blk_device, const void *data)
|
||||
dfp->fno.ftime = 0;
|
||||
dfp->fno.fattrib = AM_DIR;
|
||||
dfp->fno.sclst = 0;
|
||||
dfp->fno.fsize = fs->csize * SS(fs);
|
||||
dfp->fno.fname[0] = '/'; /* Mark as root dir */
|
||||
dfp->fno.fname[1] = '\0';
|
||||
LOS_ListInit(&(dfp->fno.fp_list));
|
||||
@@ -1365,10 +1418,17 @@ int fatfs_stat(struct Vnode *vp, struct stat* sp)
|
||||
sp->st_gid = fs->fs_gid;
|
||||
sp->st_size = finfo->fsize;
|
||||
sp->st_blksize = fs->csize * SS(fs);
|
||||
sp->st_blocks = finfo->fsize ? ((finfo->fsize - 1) / SS(fs) / fs->csize + 1) : 0;
|
||||
if (finfo->fattrib & AM_ARC) {
|
||||
sp->st_blocks = finfo->fsize ? ((finfo->fsize - 1) / SS(fs) / fs->csize + 1) : 0;
|
||||
} else {
|
||||
sp->st_blocks = fs->csize;
|
||||
}
|
||||
time = fattime_transfer(finfo->fdate, finfo->ftime);
|
||||
sp->st_mtime = time;
|
||||
|
||||
/* Adapt to kstat member "long tv_sec" */
|
||||
sp->__st_mtim32.tv_sec = (long)time;
|
||||
|
||||
unlock_fs(fs, FR_OK);
|
||||
return 0;
|
||||
}
|
||||
@@ -1745,6 +1805,45 @@ static int fatfs_set_part_info(los_part *part)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FRESULT fatfs_setlabel(los_part *part)
|
||||
{
|
||||
QWORD start_sector = 0;
|
||||
BYTE fmt = 0;
|
||||
FATFS fs;
|
||||
FRESULT result;
|
||||
|
||||
#ifdef LOSCFG_FS_FAT_VIRTUAL_PARTITION
|
||||
fs.vir_flag = FS_PARENT;
|
||||
fs.parent_fs = &fs;
|
||||
fs.vir_amount = DISK_ERROR;
|
||||
fs.vir_avail = FS_VIRDISABLE;
|
||||
#endif
|
||||
if (disk_ioctl(fs.pdrv, GET_SECTOR_SIZE, &(fs.ssize)) != RES_OK) {
|
||||
return -EIO;
|
||||
}
|
||||
fs.win = (BYTE *)ff_memalloc(fs.ssize);
|
||||
if (fs.win == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
result = find_fat_partition(&fs, part, &fmt, &start_sector);
|
||||
if (result != FR_OK) {
|
||||
free(fs.win);
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
result = init_fatobj(&fs, fmt, start_sector);
|
||||
if (result != FR_OK) {
|
||||
free(fs.win);
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
result = set_volumn_label(&fs, FatLabel);
|
||||
free(fs.win);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int fatfs_mkfs (struct Vnode *device, int sectors, int option)
|
||||
{
|
||||
BYTE *work_buff = NULL;
|
||||
@@ -1780,19 +1879,22 @@ int fatfs_mkfs (struct Vnode *device, int sectors, int option)
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
result = fatfs_setlabel(part);
|
||||
if (result == FR_OK) {
|
||||
#ifdef LOSCFG_FS_FAT_CACHE
|
||||
ret = OsSdSync(part->disk_id);
|
||||
if (ret != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
ret = OsSdSync(part->disk_id);
|
||||
if (ret != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ret = fatfs_set_part_info(part);
|
||||
if (ret != 0) {
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return -fatfs_2_vfs(result);
|
||||
}
|
||||
|
||||
int fatfs_mkdir(struct Vnode *parent, const char *name, mode_t mode, struct Vnode **vpp)
|
||||
@@ -2079,6 +2181,207 @@ ERROUT:
|
||||
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 = {
|
||||
/* file ops */
|
||||
.Getattr = fatfs_stat,
|
||||
@@ -2086,6 +2389,8 @@ struct VnodeOps fatfs_vops = {
|
||||
.Lookup = fatfs_lookup,
|
||||
.Rename = fatfs_rename,
|
||||
.Create = fatfs_create,
|
||||
.ReadPage = fatfs_readpage,
|
||||
.WritePage = fatfs_writepage,
|
||||
.Unlink = fatfs_unlink,
|
||||
.Reclaim = fatfs_reclaim,
|
||||
.Truncate = fatfs_truncate,
|
||||
|
||||
@@ -113,6 +113,8 @@ extern "C" {
|
||||
#define FMT_ANY 0x07
|
||||
#define FMT_ERASE 0x08
|
||||
|
||||
extern char FatLabel[LABEL_LEN];
|
||||
|
||||
int fatfs_2_vfs(int result);
|
||||
int fatfs_lookup(struct Vnode *parent, const char *name, int len, struct Vnode **vpp);
|
||||
int fatfs_create(struct Vnode *parent, const char *name, int mode, struct Vnode **vpp);
|
||||
|
||||
47
fs/fat/virpart/BUILD.gn
Normal file
47
fs/fat/virpart/BUILD.gn
Normal file
@@ -0,0 +1,47 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_FAT_VIRTUAL_PARTITION)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/virpart.c",
|
||||
"src/virpartff.c",
|
||||
]
|
||||
|
||||
include_dirs = [ "../os_adapt" ]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
@@ -37,12 +37,11 @@
|
||||
|
||||
#define _MAX_ENTRYLENGTH 16 /* MAX virtual partition name length */
|
||||
#define _MAX_VIRVOLUMES 5 /* MAX virtual partition number */
|
||||
typedef struct virtual_partition_info
|
||||
{
|
||||
char *devpartpath; /* need set virtual partition, e.g. /dev/mmcblk0p0 */
|
||||
int virpartnum; /* virtual partition numbers, MAX number is 5 */
|
||||
double virpartpercent[_MAX_VIRVOLUMES]; /* every virtual partition percent,e.g 0.6,0.3,0.1 */
|
||||
char virpartname[_MAX_VIRVOLUMES][_MAX_ENTRYLENGTH + 1]; /* every virtual partition name, MAX length is 16 */
|
||||
typedef struct virtual_partition_info {
|
||||
char *devpartpath; /* need set virtual partition, e.g. /dev/mmcblk0p0 */
|
||||
int virpartnum; /* virtual partition numbers, MAX number is 5 */
|
||||
double virpartpercent[_MAX_VIRVOLUMES]; /* every virtual partition percent,e.g 0.6,0.3,0.1 */
|
||||
char virpartname[_MAX_VIRVOLUMES][_MAX_ENTRYLENGTH + 1]; /* every virtual partition name, MAX length is 16 */
|
||||
} virpartinfo;
|
||||
|
||||
extern char g_devPartName[DISK_NAME + 1];
|
||||
|
||||
@@ -1,298 +0,0 @@
|
||||
/****************************************************************************
|
||||
* include/fs/fs.h
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2013, 2015-2018 Gregory Nutt. All rights
|
||||
* reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _FS_DRIVER_H_
|
||||
#define _FS_DRIVER_H_
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include "vnode.h"
|
||||
#include "fs/file.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* This structure provides information about the state of a block driver */
|
||||
|
||||
struct geometry
|
||||
{
|
||||
bool geo_available; /* true: The device is available */
|
||||
bool geo_mediachanged; /* true: The media has changed since last query */
|
||||
bool geo_writeenabled; /* true: It is okay to write to this device */
|
||||
unsigned long long geo_nsectors; /* Number of sectors on the device */
|
||||
size_t geo_sectorsize; /* Size of one sector */
|
||||
};
|
||||
|
||||
/* This structure is provided by block devices when they register with the
|
||||
* system. It is used by file systems to perform filesystem transfers. It
|
||||
* differs from the normal driver vtable in several ways -- most notably in
|
||||
* that it deals in struct Vnode vs. struct filep.
|
||||
*/
|
||||
|
||||
struct block_operations
|
||||
{
|
||||
int (*open)(struct Vnode *vnode);
|
||||
int (*close)(struct Vnode *vnode);
|
||||
ssize_t (*read)(struct Vnode *vnode, unsigned char *buffer,
|
||||
unsigned long long start_sector, unsigned int nsectors);
|
||||
ssize_t (*write)(struct Vnode *vnode, const unsigned char *buffer,
|
||||
unsigned long long start_sector, unsigned int nsectors);
|
||||
int (*geometry)(struct Vnode *vnode, struct geometry *geometry);
|
||||
int (*ioctl)(struct Vnode *vnode, int cmd, unsigned long arg);
|
||||
int (*unlink)(struct Vnode *vnode);
|
||||
};
|
||||
|
||||
struct drv_data
|
||||
{
|
||||
const void *ops;
|
||||
mode_t mode;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Name: register_driver
|
||||
*
|
||||
* Description:
|
||||
* Register a character driver vnode the pseudo file system.
|
||||
*
|
||||
* Input Parameters:
|
||||
* path - The path to the vnode to create
|
||||
* fops - The file operations structure
|
||||
* mode - Access privileges (not used)
|
||||
* priv - Private, user data that will be associated with the vnode.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success (with the vnode point in 'vnode'); A negated errno
|
||||
* value is returned on a failure (all error values returned by
|
||||
* vnode_reserve):
|
||||
*
|
||||
* EINVAL - 'path' is invalid for this operation
|
||||
* EEXIST - An vnode already exists at 'path'
|
||||
* ENOMEM - Failed to allocate in-memory resources for the operation
|
||||
*
|
||||
* Attention:
|
||||
* This function should be called after los_vfs_init has been called.
|
||||
* The parameter path must point a valid string, which end with the terminating null byte.
|
||||
* The total length of parameter path must less than the value defined by PATH_MAX.
|
||||
* The prefix of the parameter path must be /dev/.
|
||||
* The fops must pointed the right functions, otherwise the system will crash when the device is being operated.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int register_driver(const char *path,
|
||||
const struct file_operations_vfs *fops, mode_t mode,
|
||||
void *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: register_blockdriver
|
||||
*
|
||||
* Description:
|
||||
* Register a block driver vnode the pseudo file system.
|
||||
*
|
||||
* Attention:
|
||||
* This function should be called after los_vfs_init has been called.
|
||||
* The parameter path must point a valid string, which end with the terminating null byte.
|
||||
* The length of parameter path must be less than the value defined by PATH_MAX.
|
||||
* The prefix of the parameter path must be '/dev/'.
|
||||
* The bops must pointed the right functions, otherwise the system will crash when the device is being operated.
|
||||
*
|
||||
* Input Parameters:
|
||||
* path - The path to the vnode to create
|
||||
* bops - The block driver operations structure
|
||||
* mode - Access privileges (not used)
|
||||
* priv - Private, user data that will be associated with the vnode.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success (with the vnode point in 'vnode'); A negated errno
|
||||
* value is returned on a failure (all error values returned by
|
||||
* vnode_reserve):
|
||||
*
|
||||
* EINVAL - 'path' is invalid for this operation
|
||||
* EEXIST - An vnode already exists at 'path'
|
||||
* ENOMEM - Failed to allocate in-memory resources for the operation
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int register_blockdriver(const char *path,
|
||||
const struct block_operations *bops,
|
||||
mode_t mode, void *priv);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: unregister_driver
|
||||
*
|
||||
* Description:
|
||||
* Remove the character driver vnode at 'path' from the pseudo-file system
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success (with the vnode point in 'vnode'); A negated errno
|
||||
* value is returned on a failure (all error values returned by
|
||||
* vnode_reserve):
|
||||
*
|
||||
* EBUSY - Resource is busy ,not permit for this operation.
|
||||
* ENOENT - 'path' is invalid for this operation.
|
||||
*
|
||||
* Attention:
|
||||
* This function should be called after register_blockdriver has been called.
|
||||
* The parameter path must point a valid string, which end with the terminating null byte.
|
||||
* The total length of parameter path must less than the value defined by PATH_MAX.
|
||||
* The block device node referred by parameter path must be really exist.
|
||||
****************************************************************************/
|
||||
|
||||
int unregister_driver(const char *path);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: unregister_blockdriver
|
||||
*
|
||||
* Description:
|
||||
* Remove the block driver vnode at 'path' from the pseudo-file system
|
||||
*
|
||||
* Input Parameters:
|
||||
* path - The path that the vnode to be destroyed.
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero on success (with the vnode point in 'vnode'); A negated errno
|
||||
* value is returned on a failure (all error values returned by
|
||||
* vnode_reserve):
|
||||
*
|
||||
* EBUSY - Resource is busy ,not permit for this operation.
|
||||
* ENOENT - 'path' is invalid for this operation.
|
||||
*
|
||||
* Attention:
|
||||
* This function should be called after register_blockdriver has been called.
|
||||
* The parameter path must point a valid string, which end with the terminating null byte.
|
||||
* The total length of parameter path must less than the value defined by PATH_MAX.
|
||||
* The block device node referred by parameter path must be really exist.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int unregister_blockdriver(const char *path);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: open_blockdriver
|
||||
*
|
||||
* Description:
|
||||
* Return the vnode of the block driver specified by 'pathname'
|
||||
*
|
||||
* Input Parameters:
|
||||
* pathname - the full path to the block driver to be opened
|
||||
* mountflags - if MS_RDONLY is not set, then driver must support write
|
||||
* operations (see include/sys/mount.h)
|
||||
* ppvnode - address of the location to return the vnode reference
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns zero on success or a negated errno on failure:
|
||||
*
|
||||
* EINVAL - pathname or pvnode is NULL
|
||||
* ENOENT - No block driver of this name is registered
|
||||
* ENOTBLK - The vnode associated with the pathname is not a block driver
|
||||
* EACCESS - The MS_RDONLY option was not set but this driver does not
|
||||
* support write access
|
||||
*
|
||||
* Aattention:
|
||||
* The parameter path must point a valid string, which end with the terminating null byte.
|
||||
* The total length of parameter path must less than the value defined by PATH_MAX.
|
||||
* The parameter ppvnode must point a valid memory, which size must be enough for storing struct Vnode.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
int open_blockdriver(const char *pathname, int mountflags,
|
||||
struct Vnode **ppvnode);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: find_blockdriver
|
||||
*
|
||||
* Description:
|
||||
* Return the inode of the block driver specified by 'pathname'
|
||||
*
|
||||
* Input Parameters:
|
||||
* pathname - The full path to the block driver to be located
|
||||
* mountflags - If MS_RDONLY is not set, then driver must support write
|
||||
* operations (see include/sys/mount.h)
|
||||
* ppinode - Address of the location to return the inode reference
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns zero on success or a negated errno on failure:
|
||||
*
|
||||
* ENOENT - No block driver of this name is registered
|
||||
* ENOTBLK - The inode associated with the pathname is not a block driver
|
||||
* EACCESS - The MS_RDONLY option was not set but this driver does not
|
||||
* support write access
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int find_blockdriver(const char *pathname, int mountflags,
|
||||
struct Vnode **vpp);
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Name: close_blockdriver
|
||||
*
|
||||
* Description:
|
||||
* Call the close method and release the vnode
|
||||
*
|
||||
* Input Parameters:
|
||||
* vnode - reference to the vnode of a block driver opened by open_blockdriver
|
||||
*
|
||||
* Returned Value:
|
||||
* Returns zero on success or a negated errno on failure:
|
||||
*
|
||||
* EINVAL - vnode is NULL
|
||||
* ENOTBLK - The vnode is not a block driver
|
||||
*
|
||||
* Attention:
|
||||
* This function should be called after open_blockdriver has been called.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_NFILE_DESCRIPTORS > 0
|
||||
int close_blockdriver(struct Vnode *vnode);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* _FS_DRIVER_H_ */
|
||||
1
fs/include/fs/driver.h
Symbolic link
1
fs/include/fs/driver.h
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../../../third_party/NuttX/fs/vfs/include/driver.h
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user