blob: 73eceeef22e02c038da866b32eddd648f03c4215 [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("//build/toolchain/toolchain_environment.gni")
import("//build/toolchain/zircon/zircon_toolchain_suite.gni")
if (current_toolchain == default_toolchain) {
# Define a special environment for building code that runs in physical
# memory with the MMU disabled, at early boot.
zircon_toolchain_suite("physmem_arm64") {
cpu = "arm64"
os = "fuchsia"
environment = "physmem"
with_shared = false
configs = [ "//zircon/kernel/arch/arm64:physmem_config" ]
toolchain_tags = [
"kernel",
"strict-align",
]
exclude_variant_tags = [ "instrumented" ]
}
}
if (toolchain_environment == "physmem") {
# This is the top config for the physmem environment.
config("physmem_config") {
configs = [
"//zircon/kernel:headers",
"//zircon/kernel:standalone",
"//zircon/kernel:warnings",
"//build/config/zircon:no_sanitizers",
]
cflags = [
"-fpie",
# With the MMU disabled, alignment checking is always enabled. So make
# sure the compiler doesn't use any unaligned memory accesses.
"-mstrict-align",
]
if (!is_gcc) {
# TODO(fxbug.dev/26997): cflags += [ "-mcmodel=tiny" ]
}
include_dirs = [ "include" ]
}
group("physmem_config_deps") {
}
}
if (toolchain_environment == "physmem" ||
toolchain_environment == "kernel.phys" ||
toolchain_environment == "kernel") {
# These set the ABI contract between C++ and assembly code.
# This is kept consistent between the kernel proper and phys
# so (pure PIC) code should be callable from the kernel proper.
config("abi") {
# x20 is reserved so we can use it to point at the per-CPU structure.
cflags = [ "-ffixed-x20" ]
if (!is_gcc) {
# Use the right thread-pointer ABI for the kernel.
cflags += [ "-mtp=el1" ]
}
}
# This is used pervasively throughout the kernel on arm64.
config("kernel") {
cflags = []
if (!is_gcc) {
cflags += [
# Use shadow-call-stack rather than safe-stack for the kernel,
# regardless of the compiler's default.
"-fno-sanitize=safe-stack",
"-fsanitize=shadow-call-stack",
]
}
# Assembly code needs to use `#if __has_feature(...)` so make sure
# it always sees all the same `-fsanitize=...` flags and the like.
asmflags = cflags
ldflags = cflags
defines = [ "ARCH_ARM64" ]
# For #include <arch/foo.h>.
include_dirs = [ "include" ]
configs = [
# <arch/current_thread.h> has #include <lib/arch/intrin.h>.
"//zircon/kernel/lib/arch/arm64:headers.config",
]
# Align the kernel's segments to 64k so it can use "combined pages" to
# reduce the TLB load.
ldflags += [ "-Wl,-z,max-page-size=65536" ]
}
source_set("arm64") {
sources = [
"arch.cc",
"asid_allocator.cc",
"asm.S",
"cache-ops.S",
"coresight.cc",
"dap.cc",
"debugger.cc",
"exceptions.S",
"exceptions_c.cc",
"feature.cc",
"fpu.cc",
"mexec.S",
"mexec.cc",
"mmu.cc",
"mmu_tests.cc",
"mp.cc",
"perf_mon.cc",
"periphmap.cc",
"registers.cc",
"smccc.S",
"spinlock.cc",
"start.S",
"sysreg.cc",
"thread.cc",
"uarch.cc",
"user_copy.S",
"user_copy_c.cc",
"uspace_entry.S",
]
deps = [
":boot-mmu",
":dev-init",
":tests",
"code-patches:headers",
"//sdk/lib/fit",
"//zircon/kernel/dev/coresight",
"//zircon/kernel/dev/interrupt/arm_gic/common",
"//zircon/kernel/dev/iommu/dummy",
"//zircon/kernel/dev/psci",
"//zircon/kernel/lib/arch",
"//zircon/kernel/lib/boot-options",
"//zircon/kernel/lib/code-patching",
"//zircon/kernel/lib/console",
"//zircon/kernel/lib/counters",
"//zircon/kernel/lib/crashlog",
"//zircon/kernel/lib/init",
"//zircon/kernel/lib/instrumentation",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/perfmon",
"//zircon/kernel/lib/syscalls",
"//zircon/kernel/lib/unittest",
"//zircon/kernel/object",
"//zircon/kernel/phys:handoff",
"//zircon/kernel/vm",
"//zircon/system/ulib/bitmap",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/zbitl",
"//zircon/system/ulib/zxc",
]
}
source_set("boot-mmu") {
visibility = [ ":*" ]
sources = [ "boot-mmu.cc" ]
deps = [ "//zircon/kernel/vm" ]
# Everything in this file runs too early to use the full ABI. Per-function
# attribute suppression of sanitizer modes doesn't work for C++ lambda.
configs += [ "//build/config/zircon:no_sanitizers" ]
}
source_set("dev-init") {
visibility = [ ":*" ]
sources = [ "dev-init.cc" ]
deps = [
"//zircon/kernel/dev/hdcp/amlogic_s912",
"//zircon/kernel/dev/hw_rng/amlogic_rng",
"//zircon/kernel/dev/hw_watchdog/generic32",
"//zircon/kernel/dev/psci",
"//zircon/kernel/dev/timer/arm_generic",
"//zircon/kernel/dev/uart/amlogic_s905",
"//zircon/kernel/dev/uart/dw8250",
"//zircon/kernel/dev/uart/motmot",
"//zircon/kernel/dev/uart/pl011",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/phys:handoff",
"//zircon/system/ulib/uart",
]
}
source_set("tests") {
sources = [ "cache_test.cc" ]
deps = [
"//zircon/kernel/lib/arch",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/unittest",
"//zircon/kernel/vm",
]
}
}