112 lines
2.5 KiB
Plaintext
112 lines
2.5 KiB
Plaintext
|
|
boot_c_flags = [
|
||
|
|
"-ffreestanding",
|
||
|
|
"-Werror",
|
||
|
|
"-Wno-address-of-packed-member",
|
||
|
|
]
|
||
|
|
boot_asm_flags = []
|
||
|
|
boot_ld_flags = []
|
||
|
|
|
||
|
|
if (kernel_symbols) {
|
||
|
|
boot_c_flags += [ "-ggdb" ]
|
||
|
|
}
|
||
|
|
|
||
|
|
boot_c_flags += [
|
||
|
|
"-fno-builtin",
|
||
|
|
"-march=armv7-a",
|
||
|
|
"-mfpu=neon-vfpv4",
|
||
|
|
"-mfloat-abi=soft",
|
||
|
|
"-fno-pie",
|
||
|
|
]
|
||
|
|
boot_asm_flags += [
|
||
|
|
"-march=armv7-a",
|
||
|
|
"-mfpu=neon-vfpv4",
|
||
|
|
"-mfloat-abi=softfp",
|
||
|
|
"-mcpu=cortex-a15",
|
||
|
|
]
|
||
|
|
boot_ld_flags += [ "-nostdlib" ]
|
||
|
|
|
||
|
|
if (host == "gnu") {
|
||
|
|
boot_ld_flags += [
|
||
|
|
"-nostdinc",
|
||
|
|
"-nodefaultlibs",
|
||
|
|
"-nostartfiles",
|
||
|
|
"-lgcc",
|
||
|
|
]
|
||
|
|
}
|
||
|
|
|
||
|
|
if (host == "llvm") {
|
||
|
|
boot_ld_flags += [
|
||
|
|
"--oformat",
|
||
|
|
"elf32-littlearm",
|
||
|
|
"/usr/lib/llvm-18/lib/clang/18/lib/linux/libclang_rt.builtins-arm.a",
|
||
|
|
]
|
||
|
|
}
|
||
|
|
|
||
|
|
config("boot_flags") {
|
||
|
|
cflags = boot_c_flags
|
||
|
|
asmflags = boot_asm_flags
|
||
|
|
ldflags = boot_ld_flags
|
||
|
|
defines = [ "xOS_kernel" ]
|
||
|
|
}
|
||
|
|
|
||
|
|
linker_script =
|
||
|
|
rebase_path("//build/boot/$target_arch/boot_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
|
||
|
|
}
|
||
|
|
|
||
|
|
devtree_compile_script_args = [
|
||
|
|
rebase_path("//firmware/$target_arch/$target_board.odt", root_build_dir),
|
||
|
|
rebase_path("$root_out_dir/firmware/$target_board.obt", root_build_dir),
|
||
|
|
"$target_arch",
|
||
|
|
"$target_board",
|
||
|
|
"$host",
|
||
|
|
"$path_to_bins",
|
||
|
|
]
|
||
|
|
|
||
|
|
action("devtree_compile") {
|
||
|
|
script = "//build/kernel/devtree_compile.py"
|
||
|
|
inputs = [ "//firmware/$target_arch/$target_board.odt" ]
|
||
|
|
outputs = [
|
||
|
|
"$root_out_dir/firmware/$target_board.obt",
|
||
|
|
"$root_out_dir/firmware/$target_board.obto",
|
||
|
|
]
|
||
|
|
args = devtree_compile_script_args
|
||
|
|
}
|
||
|
|
|
||
|
|
executable("bootarm") {
|
||
|
|
deps = [ ":devtree_compile" ]
|
||
|
|
output_name = "bootarm.bin"
|
||
|
|
sources = [
|
||
|
|
"//boot/arm32/drivers/pl181.c",
|
||
|
|
"//boot/arm32/drivers/uart.c",
|
||
|
|
"//boot/arm32/entry.s",
|
||
|
|
"//boot/arm32/hw/ram.c",
|
||
|
|
"//boot/arm32/main.c",
|
||
|
|
"//boot/arm32/start_kernel.s",
|
||
|
|
"//boot/arm32/vmm/vmm.c",
|
||
|
|
"//boot/libboot/crypto/sha256.c",
|
||
|
|
"//boot/libboot/crypto/signature.c",
|
||
|
|
"//boot/libboot/crypto/uint2048.c",
|
||
|
|
"//boot/libboot/crypto/validate.c",
|
||
|
|
"//boot/libboot/devtree/devtree.c",
|
||
|
|
"//boot/libboot/elf/elf_lite.c",
|
||
|
|
"//boot/libboot/fs/ext2_lite.c",
|
||
|
|
"//boot/libboot/log/log.c",
|
||
|
|
"//boot/libboot/mem/alloc.c",
|
||
|
|
"//boot/libboot/mem/mem.c",
|
||
|
|
]
|
||
|
|
|
||
|
|
include_dirs = [ "//boot" ]
|
||
|
|
|
||
|
|
configs = [ ":boot_flags" ]
|
||
|
|
|
||
|
|
ldflags = [
|
||
|
|
rebase_path("$root_out_dir/firmware/$target_board.obto", root_build_dir),
|
||
|
|
"-T$linker_script",
|
||
|
|
]
|
||
|
|
}
|