blob: 195b355b5c0a02588d9cf9d6fdc8dee3b89c9c77 [file] [edit]
# 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/cpp/library_headers.gni")
import("//build/toolchain/toolchain_environment.gni")
import("//build/toolchain/zircon/zircon_toolchain_suite.gni")
if (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") {
cflags = [
# x20 is reserved so we can use it to point at the per-CPU structure.
"-ffixed-x20",
# Use the right thread-pointer ABI for the kernel.
"-mtp=el1",
]
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
}
# 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") {
public_deps = [ ":headers" ]
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",
"handoff.cc",
"mexec.S",
"mmu.cc",
"mmu_tests.cc",
"mp.cc",
"perf_mon.cc",
"periphmap.cc",
"registers.cc",
"restricted.cc",
"secondary.S",
"smccc.S",
"spinlock.cc",
"sysreg.cc",
"thread.cc",
"uarch.cc",
"uspace_entry.S",
]
deps = [
":tests",
"user-copy",
"//sdk/lib/fit",
"//zircon/kernel/dev/coresight",
"//zircon/kernel/dev/interrupt/gic/common",
"//zircon/kernel/dev/iommu/stub",
"//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/page",
"//zircon/kernel/lib/perfmon",
"//zircon/kernel/lib/syscalls",
"//zircon/kernel/lib/thread-stack",
"//zircon/kernel/lib/unittest",
"//zircon/kernel/lib/userabi:headers",
"//zircon/kernel/object",
"//zircon/kernel/phys:handoff",
"//zircon/kernel/platform:headers",
"//zircon/kernel/vm",
"//zircon/system/ulib/bitmap",
"//zircon/system/ulib/fbl",
"//zircon/system/ulib/lazy_init",
"//zircon/system/ulib/pretty",
"//zircon/system/ulib/zx",
]
}
library_headers("headers") {
headers = [
# <arch/arm64/hypervisor.h> has #include <lib/id_allocator.h>.
"//zircon/kernel/lib/id_allocator:headers",
# <arch/arm64/hypervisor/el2_state.h> has #include <lib/page/size.h>
"//zircon/kernel/lib/page:headers",
]
}
source_set("tests") {
sources = [ "cache_test.cc" ]
deps = [
"//zircon/kernel/lib/arch",
"//zircon/kernel/lib/ktl",
"//zircon/kernel/lib/unittest",
"//zircon/kernel/vm",
]
}
}