blob: 0ae2ca69d3aa9c22bedb66cf04b09956849df5d4 [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("$zx/kernel/params.gni")
# This is used pervasively throughout the kernel on x86.
config("kernel") {
cflags = [
"-mno-red-zone",
# Hard disable floating point in the kernel.
"-msoft-float",
"-mno-mmx",
"-mno-sse",
"-mno-sse2",
"-mno-3dnow",
"-mno-avx",
"-mno-avx2",
]
if (is_gcc) {
cflags += [
"-falign-jumps=1",
"-falign-loops=1",
"-falign-functions=4",
# Optimization: Since FPU is disabled, do not pass flag in %rax to
# varargs routines that floating point args are in use.
"-mskip-rax-setup",
]
} else {
# Clang needs -mcmodel=kernel to tell it to use the right safe-stack
# ABI for the kernel.
cflags += [ "-mcmodel=kernel" ]
}
defines = [
"ARCH_X86",
"KERNEL_ASPACE_BASE=$kernel_aspace_base",
"KERNEL_ASPACE_SIZE=0x0000008000000000UL",
"USER_ASPACE_BASE=0x0000000001000000UL", # 16MB
# We set the top of user address space to be (1 << 47) - 4k. See
# docs/sysret_problem.md for why we subtract 4k here. Subtracting
# USER_ASPACE_BASE from that value gives the value for USER_ASPACE_SIZE
# below.
"USER_ASPACE_SIZE=0x00007ffffefff000UL",
"KERNEL_LOAD_OFFSET=0x00100000", # 1MB
]
# For #include <arch/foo.h>.
include_dirs = [ "include" ]
public_deps = [
# <arch/aspace.h> has #include <arch/x86/ioport.h>.
":headers",
]
}
library("x86") {
kernel = true
sources = [
"acpi.S",
"arch.cpp",
"asm.S",
"bootstrap16.cpp",
"cache.cpp",
"cpu_topology.cpp",
"debugger.cpp",
"descriptor.cpp",
"exceptions.S",
"faults.cpp",
"feature.cpp",
"gdt.S",
"hwp.cpp",
"idt.cpp",
"ioapic.cpp",
"ioport.cpp",
"lapic.cpp",
"mexec.S",
"mmu.cpp",
"mmu_mem_types.cpp",
"mp.cpp",
"ops.S",
"perf_mon.cpp",
"proc_trace.cpp",
"pvclock.cpp",
"registers.cpp",
"smp.cpp",
"start.S",
"start16.S",
"thread.cpp",
"timer_freq.cpp",
"tsc.cpp",
"user_copy.S",
"user_copy.cpp",
"uspace_entry.S",
]
deps = [
":syscall",
":tests",
"$zx/kernel/dev/hw_rng",
"$zx/kernel/dev/iommu/dummy",
"$zx/kernel/dev/iommu/intel",
"$zx/kernel/lib/code_patching",
"$zx/kernel/lib/console",
"$zx/kernel/lib/counters",
"$zx/kernel/lib/crashlog",
"$zx/kernel/lib/fbl",
"$zx/kernel/lib/pci",
"$zx/kernel/object",
"$zx/system/ulib/bitmap",
]
public_deps = [
"page_tables:headers",
# arch/x86/apic.h has #include <dev/interrupt.h>.
"$zx/kernel/dev/interrupt:headers",
# arch/x86/hypervisor.h has #include <hypervisor/guest_physical_address_space.h>.
"$zx/kernel/lib/hypervisor:headers",
# <arch/aspace.h> has #include <bitmap/rle-bitmap.h>.
"$zx/system/ulib/bitmap:headers",
# <arch/aspace.h> has #include <fbl/unique_ptr.h>.
"$zx/system/ulib/fbl:headers",
# <arch/x86/acpi.h> has #include <acpica/acpi.h>.
"$zx/third_party/lib/acpica:headers",
]
}
source_set("syscall") {
sources = [
"syscall.S",
]
deps = [
"$zx/kernel/syscalls:syscall-abi",
]
}
source_set("tests") {
sources = [
"mmu_tests.cpp",
]
deps = [
"$zx/kernel/lib/unittest",
]
}