blob: dff70c38ab441a3029159e714e2c52fa980132ee [file] [log] [blame]
# Copyright 2019 The Fuchsia Authors
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT
import("$zx/public/gn/toolchain/c_utils.gni")
import("$zx/public/gn/toolchain/select_toolchain.gni")
assert(current_cpu == "arm64")
# The boot shims need to be compiled in the special environment for running
# in physical memory with the MMU disabled.
if (toolchain.environment == "physmem") {
source_set("common") {
visibility = [ ":*" ]
sources = [
"boot-shim.S",
"debug.c",
"devicetree.c",
"util.c",
]
deps = [
"$zx/kernel/lib/libc/string",
]
public_deps = [
"$zx/system/ulib/ddk:headers",
"$zx/system/ulib/libzbi",
]
}
}
template("boot_shim") {
board = target_name
if (toolchain.environment == "physmem") {
executable("${board}-boot-shim") {
output_extension = "elf"
deps = [
":common",
]
sources = [
"${board}-uart.c",
"boot-shim.c",
]
defines = [ "KERNEL_ALIGN=0x10000" ]
# TODO(mcgrathr): Move these to ./$board-config.h and use a -D.
include_dirs = [ "$zx/kernel/target/arm64/board/$board" ]
inputs = [
"boot-shim.ld",
]
ldflags = [
"-Wl,-T," + rebase_path("boot-shim.ld", root_build_dir),
"-Wl,-defsym," + defines[0],
]
}
image_binary(board) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
deps = [
":${board}-boot-shim",
]
outputs = [
"$root_out_dir/${board}-boot-shim.bin",
]
sources = [
"$target_out_dir/${board}-boot-shim.elf",
]
metadata = {
images = [
{
name = "${board}-boot-shim"
path = rebase_path(outputs[0], root_build_dir)
type = "bin" # TODO(mcgrathr): ???
},
]
if (board == "qemu") {
images += [
{
name = "qemu-kernel"
type = "kernel"
path = rebase_path(outputs[0], root_build_dir)
},
]
}
# TODO: later
bootimage_inputs = outputs
bootimage_script = [ invoker.script ]
bootimage_args = invoker.args + rebase_path(outputs, root_build_dir)
}
}
} else {
select_toolchain(board) {
environment_label = "$zx/kernel/arch/arm64:physmem"
deps = [
":$board",
]
}
not_needed(invoker, "*")
}
}
boot_shim("hikey960") {
script = "..." # TODO: cat $1 $2 | gzip -9n > $3
args = []
}
boot_shim("imx8mevk") {
script = "..." # TODO: avb, mkbootimg
args = []
}
boot_shim("imx8mmevk") {
script = "..." # TODO: avb, mkbootimg
args = []
}
boot_shim("mt8167s_ref") {
script = "..." # TODO: avb, append
args = []
}
boot_shim("qemu") {
# The "image" for the QEMU "board" is just a response file pointing to
# the shim, which acts as QEMU's kernel, with the ZBI as initrd.
script = "..." # TODO: echo "-kernel $1 -initrd $2" > $3
args = []
}
boot_shim("sherlock") {
script = "..." # TODO: kdtb
args = []
}