Build: platform configuration files.
Change-Id: I934f36bc2cdb670f900a850a2b5889ea2e177d12
diff --git a/Makefile b/Makefile
index 8817e03..6a6736f 100644
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,27 @@
GN ?= ../gn/out/gn
NINJA ?= ninja
+# Configure the build arguments
+GCC ?= false
+ARCH ?= aarch64
+PLATFORM ?= qemu
+
all: $(OUT)/build.ninja
@$(NINJA) -C $(OUT)
-out/build.ninja: $(GN)
+$(OUT)/build.ninja: $(GN) $(OUT)/args.gn
@$(GN) gen $(OUT)
+# Configure the build by loading the configuration arguments for the
+# architecture and platform
+$(OUT)/args.gn: build/arch/$(ARCH)/$(PLATFORM).args
+ @echo Copying config for $(ARCH) on $(PLATFORM)
+ @mkdir -p $(OUT)
+ @echo "arch = \"$(ARCH)\"" >> $@
+ @echo "use_gcc = $(GCC)" >> $@
+ @echo >> $@
+ @cat $< >> $@
+
$(GN):
git clone https://gn.googlesource.com/gn ../gn
cd ../gn && python build/gen.py
diff --git a/build/BUILD.gn b/build/BUILD.gn
index 9a0bb6e..73c58b4 100644
--- a/build/BUILD.gn
+++ b/build/BUILD.gn
@@ -1,4 +1,5 @@
-import("//build/arch/${arch}/${arch_platform}.gni")
+import("//build/arch/common.gni")
+import("//build/arch/aarch64.gni") # TODO: remove when no dependency on arch_aarch64_pl011_base_address
config("compiler_defaults") {
cflags = [
@@ -53,9 +54,9 @@
# TODO: this should be arch specific but it is currenly used by the
# platform generic code to map the memory
- if (use_pl011) {
+ if (arch_aarch64_use_pl011) {
defines += [
- "PL011_BASE=${pl011_base_address}",
+ "PL011_BASE=${arch_aarch64_pl011_base_address}",
]
}
}
diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn
index 677544e..b330ffb 100644
--- a/build/BUILDCONFIG.gn
+++ b/build/BUILDCONFIG.gn
@@ -21,10 +21,7 @@
use_gcc = false
# The architecture to build the bare metal images for.
- arch = "aarch64"
-
- # The platform to build the bare metal images for.
- arch_platform = "qemu"
+ arch = ""
# Set by arch toolchain. Prefix for binutils tools.
arch_tool_prefix = ""
diff --git a/build/arch/aarch64.gni b/build/arch/aarch64.gni
new file mode 100644
index 0000000..5b8e3d2
--- /dev/null
+++ b/build/arch/aarch64.gni
@@ -0,0 +1,10 @@
+declare_args() {
+ # Whether to include the PrimeCell UART (PL011) driver.
+ arch_aarch64_use_pl011 = false
+
+ # The base address of the PrimeCell UART (PL011) device.
+ arch_aarch64_pl011_base_address = ""
+}
+
+assert(!arch_aarch64_use_pl011 || arch_aarch64_pl011_base_address != "",
+ "Must provide the PL011 base address as \"arch_aarch64_pl011_base_address\".")
diff --git a/build/arch/aarch64/hikey.args b/build/arch/aarch64/hikey.args
new file mode 100644
index 0000000..68261e1
--- /dev/null
+++ b/build/arch/aarch64/hikey.args
@@ -0,0 +1,5 @@
+arch_cpu = "cortex-a57+nofp"
+arch_hypervisor_load_address = "0x01000000"
+
+arch_aarch64_use_pl011 = true
+arch_aarch64_pl011_base_address = "0xf8015000"
diff --git a/build/arch/aarch64/hikey.gni b/build/arch/aarch64/hikey.gni
deleted file mode 100644
index f870611..0000000
--- a/build/arch/aarch64/hikey.gni
+++ /dev/null
@@ -1,13 +0,0 @@
-declare_args() {
- # The specific CPU that runs the architecture.
- arch_cpu = "cortex-a57+nofp"
-
- # The load address of the hypervisor
- hypervisor_load_address = "0x01000000"
-
- # Whether to include the PrimeCell UART (PL011) driver.
- use_pl011 = true
-
- # The base address of the PrimeCell UART (PL011) device.
- pl011_base_address = "0xf8015000"
-}
diff --git a/build/arch/aarch64/qemu.args b/build/arch/aarch64/qemu.args
new file mode 100644
index 0000000..16d47f2
--- /dev/null
+++ b/build/arch/aarch64/qemu.args
@@ -0,0 +1,5 @@
+arch_cpu = "cortex-a57+nofp"
+arch_hypervisor_load_address = "0x40001000"
+
+arch_aarch64_use_pl011 = true
+arch_aarch64_pl011_base_address = "0x09000000"
diff --git a/build/arch/aarch64/qemu.gni b/build/arch/aarch64/qemu.gni
deleted file mode 100644
index 4962ab8..0000000
--- a/build/arch/aarch64/qemu.gni
+++ /dev/null
@@ -1,13 +0,0 @@
-declare_args() {
- # The specific CPU that runs the architecture.
- arch_cpu = "cortex-a57+nofp"
-
- # The load address of the hypervisor
- hypervisor_load_address = "0x40001000"
-
- # Whether to include the PrimeCell UART (PL011) driver.
- use_pl011 = true
-
- # The base address of the PrimeCell UART (PL011) device.
- pl011_base_address = "0x09000000"
-}
diff --git a/build/arch/common.gni b/build/arch/common.gni
new file mode 100644
index 0000000..0eb4dc2
--- /dev/null
+++ b/build/arch/common.gni
@@ -0,0 +1,12 @@
+declare_args() {
+ # The specific CPU that runs the architecture.
+ arch_cpu = ""
+
+ # The load address of the hypervisor
+ arch_hypervisor_load_address = ""
+}
+
+assert(arch_cpu != "", "Must provide the CPU to build for as \"arch_cpu\".")
+assert(
+ arch_hypervisor_load_address != "",
+ "Must provide the load address of the hypervisor \"arch_hypervisor_load_address\".")
diff --git a/build/image/hypervisor.gni b/build/image/hypervisor.gni
index a2bd03e..2a2a02a 100644
--- a/build/image/hypervisor.gni
+++ b/build/image/hypervisor.gni
@@ -1,4 +1,4 @@
-import("//build/arch/${arch}/${arch_platform}.gni")
+import("//build/arch/common.gni")
# Helper to build a hypervisor image
template("hypervisor") {
@@ -19,7 +19,7 @@
"-pie",
"-T",
rebase_path("//build/image/hypervisor.ld"),
- "--defsym=PREFERRED_LOAD_ADDRESS=${hypervisor_load_address}",
+ "--defsym=PREFERRED_LOAD_ADDRESS=${arch_hypervisor_load_address}",
]
visibility = [ ":${invoker.target_name}" ]
}
diff --git a/src/arch/aarch64/BUILD.gn b/src/arch/aarch64/BUILD.gn
index 046778c..8506372 100644
--- a/src/arch/aarch64/BUILD.gn
+++ b/src/arch/aarch64/BUILD.gn
@@ -1,4 +1,4 @@
-import("//build/arch/${arch}/${arch_platform}.gni")
+import("//build/arch/aarch64.gni")
import("//build/image/generate_offsets.gni")
source_set("aarch64") {
@@ -11,7 +11,7 @@
"params.c",
]
- if (use_pl011) {
+ if (arch_aarch64_use_pl011) {
sources += [
"pl011.c",
]