93 lines
2.0 KiB
Plaintext
93 lines
2.0 KiB
Plaintext
|
|
prekernel_c_flags = [
|
||
|
|
"-ffreestanding",
|
||
|
|
"-Werror",
|
||
|
|
"-Wno-address-of-packed-member",
|
||
|
|
"-fno-builtin",
|
||
|
|
"-mno-80387",
|
||
|
|
"-mno-mmx",
|
||
|
|
"-mno-sse",
|
||
|
|
"-mno-sse2",
|
||
|
|
"-fpie",
|
||
|
|
"-mno-red-zone",
|
||
|
|
"-fno-omit-frame-pointer",
|
||
|
|
]
|
||
|
|
prekernel_asm_flags = [
|
||
|
|
"-w+all",
|
||
|
|
"-Werror",
|
||
|
|
"-f",
|
||
|
|
"elf64",
|
||
|
|
]
|
||
|
|
prekernel_ld_flags = [ "-nostdlib" ]
|
||
|
|
|
||
|
|
if (kernel_symbols) {
|
||
|
|
prekernel_c_flags += [ "-ggdb" ]
|
||
|
|
}
|
||
|
|
|
||
|
|
if (host == "llvm") {
|
||
|
|
prekernel_ld_flags += [
|
||
|
|
"--oformat",
|
||
|
|
"elf64",
|
||
|
|
]
|
||
|
|
}
|
||
|
|
|
||
|
|
config("prekernel_flags") {
|
||
|
|
cflags = prekernel_c_flags
|
||
|
|
asmflags = prekernel_asm_flags
|
||
|
|
ldflags = prekernel_ld_flags
|
||
|
|
defines = [ "xOS_prekernel" ]
|
||
|
|
}
|
||
|
|
|
||
|
|
linker_script =
|
||
|
|
rebase_path("//build/boot/$target_arch/prekernel/prekernel_link.ld",
|
||
|
|
root_build_dir)
|
||
|
|
|
||
|
|
# Use a strange __EMPTY_PATH_, empty string can't be passed as an arg.
|
||
|
|
path_to_bins = "__EMPTY_PATH_"
|
||
|
|
if (host == "llvm") {
|
||
|
|
path_to_bins = llvm_bin_path
|
||
|
|
}
|
||
|
|
|
||
|
|
embed_kernel_script_args = [
|
||
|
|
rebase_path("$root_build_dir/base/boot/kernel.bin", root_build_dir),
|
||
|
|
rebase_path("$root_build_dir/tmp/boot/kernel.o", root_build_dir),
|
||
|
|
"$target_arch",
|
||
|
|
"$target_board",
|
||
|
|
"$host",
|
||
|
|
"$path_to_bins",
|
||
|
|
]
|
||
|
|
|
||
|
|
action("embed_kernel") {
|
||
|
|
script = "embed_kernel.py"
|
||
|
|
sources = [ "$root_build_dir/base/boot/kernel.bin" ]
|
||
|
|
outputs = [ "$root_build_dir/tmp/boot/kernel.o" ]
|
||
|
|
args = embed_kernel_script_args
|
||
|
|
deps = [ "//build/kernel:kernel_build" ]
|
||
|
|
}
|
||
|
|
|
||
|
|
executable("prekernelx86_64") {
|
||
|
|
output_name = "prekernelx86_64.bin"
|
||
|
|
inputs = [ "$root_build_dir/tmp/boot/kernel.o" ]
|
||
|
|
sources = [
|
||
|
|
"//boot/libboot/elf/elf_lite.c",
|
||
|
|
"//boot/libboot/log/log.c",
|
||
|
|
"//boot/libboot/mem/alloc.c",
|
||
|
|
"//boot/libboot/mem/mem.c",
|
||
|
|
"//boot/x86_64/prekernel/drivers/uart.c",
|
||
|
|
"//boot/x86_64/prekernel/main.c",
|
||
|
|
"//boot/x86_64/prekernel/mboot1.S",
|
||
|
|
"//boot/x86_64/prekernel/vm.c",
|
||
|
|
]
|
||
|
|
|
||
|
|
deps = [ ":embed_kernel" ]
|
||
|
|
|
||
|
|
include_dirs = [ "//boot" ]
|
||
|
|
|
||
|
|
configs = [ ":prekernel_flags" ]
|
||
|
|
|
||
|
|
ldflags = [
|
||
|
|
# Embeding kernel elf file into rawimage.
|
||
|
|
rebase_path("$root_out_dir/tmp/boot/kernel.o", ""),
|
||
|
|
"-T$linker_script",
|
||
|
|
]
|
||
|
|
}
|