| # 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/sanitizers: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(https://fxbug.dev/42101476): 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) { |
| cflags += [ |
| # Use the right thread-pointer ABI for the kernel. |
| "-mtp=el1", |
| |
| # 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 |
| } |
| |
| # This is used pervasively throughout the kernel on arm64. |
| config("kernel") { |
| 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", |
| ] |
| |
| # Don't use the outline atomics since we don't have the helper functions. |
| # TODO(mcgrathr): use code-patching to define the outcalls for the kernel |
| configs += [ "//build/config/arm64:no-outline-atomics" ] |
| } |
| |
| source_set("arm64") { |
| sources = [ |
| "arch.cc", |
| "asid_allocator.cc", |
| "asm.S", |
| "cache-ops.S", |
| "coresight.cc", |
| "crashlog.cc", |
| "dap.cc", |
| "debugger.cc", |
| "exceptions.S", |
| "exceptions_c.cc", |
| "feature.cc", |
| "fpu.cc", |
| "mexec.S", |
| "mmu.cc", |
| "mmu_tests.cc", |
| "mp.cc", |
| "perf_mon.cc", |
| "periphmap.cc", |
| "registers.cc", |
| "restricted.cc", |
| "smccc.S", |
| "spinlock.cc", |
| "start.S", |
| "sysreg.cc", |
| "thread.cc", |
| "uarch.cc", |
| "uspace_entry.S", |
| ] |
| deps = [ |
| ":boot-mmu", |
| ":tests", |
| "user-copy", |
| "//sdk/lib/fit", |
| "//zircon/kernel/dev/coresight", |
| "//zircon/kernel/dev/interrupt/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/heap", |
| "//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/lib/userabi:headers", |
| "//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/zx", |
| ] |
| } |
| |
| # This is linked into the ZBI kernel, but not the PIE (ELF) kernel. |
| source_set("zbi-kernel-image") { |
| sources = [ "zbi-start.S" ] |
| deps = [ "//zircon/kernel/lib/arch" ] |
| } |
| |
| 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/sanitizers:no_sanitizers" ] |
| } |
| |
| source_set("tests") { |
| sources = [ "cache_test.cc" ] |
| deps = [ |
| "//zircon/kernel/lib/arch", |
| "//zircon/kernel/lib/ktl", |
| "//zircon/kernel/lib/unittest", |
| "//zircon/kernel/vm", |
| ] |
| } |
| } |