blob: d46dc50c17da96dd265725e950942516bafa069d [file] [log] [blame]
# 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" ]
exclude_variant_tags = [ "instrumented" ]
}
} 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.cc",
"asm.S",
"boot-mmu.cc",
"cache-ops.S",
"debugger.cc",
"exceptions.S",
"exceptions_c.cc",
"feature.cc",
"fpu.cc",
"mexec.S",
"mmu.cc",
"mp.cc",
"perf_mon.cc",
"periphmap.cc",
"registers.cc",
"smccc.S",
"spinlock.cc",
"start.S",
"sysreg.cc",
"thread.cc",
"user_copy.S",
"user_copy_c.cc",
"uspace_entry.S",
]
deps = [
"$zx/kernel/dev/interrupt/arm_gic/common",
"$zx/kernel/dev/iommu/dummy",
"$zx/kernel/lib/cmdline",
"$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",
]
}
}