| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("$zx/kernel/params.gni") |
| import("$zx/public/gn/toolchain/environment.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. |
| environment("physmem") { |
| cpu = "arm64" |
| globals = { |
| is_kernel = true |
| } |
| configs += standard_fuchsia_configs + [ ":physmem_config" ] |
| tags = [ "standalone" ] |
| } |
| } else { |
| # This is the top config for the physmem environment. |
| config("physmem_config") { |
| configs = [ |
| "$zx/kernel:headers", |
| "$zx/kernel:standalone", |
| "$zx/kernel:warnings", |
| "$zx/public/gn/config: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(TC-237): cflags += [ "-mcmodel=tiny" ] |
| } |
| |
| include_dirs = [ "include" ] |
| } |
| |
| # This is used pervasively throughout the kernel on arm64. |
| config("kernel") { |
| if (!is_gcc) { |
| # Clang needs -mcmodel=kernel to tell it to use the right safe-stack |
| # ABI for the kernel. |
| cflags = [ "-mcmodel=kernel" ] |
| } |
| |
| defines = [ |
| "ARCH_ARM64", |
| "KERNEL_ASPACE_BASE=$kernel_aspace_base", |
| "KERNEL_ASPACE_SIZE=0x0001000000000000", |
| "USER_ASPACE_BASE=0x0000000001000000", |
| "USER_ASPACE_SIZE=0x0000fffffe000000", |
| ] |
| |
| # For #include <arch/foo.h>. |
| include_dirs = [ "include" ] |
| } |
| |
| source_set("arm64") { |
| sources = [ |
| "arch.cpp", |
| "asm.S", |
| "boot-mmu.cpp", |
| "cache-ops.S", |
| "debugger.cpp", |
| "exceptions.S", |
| "exceptions_c.cpp", |
| "feature.cpp", |
| "fpu.cpp", |
| "mexec.S", |
| "mmu.cpp", |
| "mp.cpp", |
| "perf_mon.cpp", |
| "periphmap.cpp", |
| "registers.cpp", |
| "smccc.S", |
| "spinlock.cpp", |
| "start.S", |
| "sysreg.cpp", |
| "thread.cpp", |
| "user_copy.S", |
| "user_copy_c.cpp", |
| "uspace_entry.S", |
| ] |
| deps = [ |
| "$zx/kernel/dev/interrupt/arm_gic/common", |
| "$zx/kernel/dev/iommu/dummy", |
| "$zx/kernel/lib/console", |
| "$zx/kernel/lib/counters", |
| "$zx/kernel/lib/crashlog", |
| "$zx/kernel/lib/perfmon", |
| "$zx/kernel/object", |
| "$zx/kernel/syscalls:syscall-abi", |
| "$zx/kernel/vm", |
| "$zx/system/ulib/bitmap", |
| ] |
| } |
| } |