blob: 855a184a0c44df2df3f638b6c1b2b64cbd8411f9 [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")
# 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" ]
configs = [
# <arch/aspace.h> has #include <bitmap/rle-bitmap.h>
"$zx/system/ulib/bitmap:headers.config",
# <arch/aspace.h> has #include <arch/x86/page_tables/constants.h>.
"page_tables:headers.config",
# <arch/x86/page_tables/page_tables.h> has #include <hwreg/bitfields.h>.
"$zx/system/ulib/hwreg:headers.config",
]
}
library("x86") {
kernel = true
sources = [
"acpi.S",
"amd.cpp",
"arch.cpp",
"asm.S",
"bootstrap16.cpp",
"cache.cpp",
"debugger.cpp",
"descriptor.cpp",
"exceptions.S",
"faults.cpp",
"feature.cpp",
"gdt.S",
"hwp.cpp",
"idt.cpp",
"intel.cpp",
"ioapic.cpp",
"ioport.cpp",
"lapic.cpp",
"mexec.S",
"mmu.cpp",
"mmu_mem_types.cpp",
"mp.cpp",
"msr.cpp",
"ops.S",
"perf_mon.cpp",
"proc_trace.cpp",
"pvclock.cpp",
"registers.cpp",
"smp.cpp",
"start.S",
"start16.S",
"system_topology.cpp",
"thread.cpp",
"timer_freq.cpp",
"tsc.cpp",
"user_copy.S",
"user_copy.cpp",
"uspace_entry.S",
]
deps = [
":syscall",
":tests",
"$zx/kernel/arch/x86/cpuid",
"$zx/kernel/dev/hw_rng",
"$zx/kernel/dev/iommu/dummy",
"$zx/kernel/dev/iommu/intel",
"$zx/kernel/lib/acpi_tables",
"$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/lib/perfmon",
"$zx/kernel/lib/topology",
"$zx/kernel/object",
"$zx/system/ulib/bitmap",
"cpuid",
]
public_deps = [
# arch/x86/system_topology.h has #include <arch/x86/cpuid.h>.
"$zx/kernel/arch/x86/cpuid: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",
# <arch/x86/ioport.h> has #include <bitmap/rle-bitmap.h>.
"$zx/system/ulib/bitmap:headers",
# <arch/x86/apic.h> has #include <dev/interrupt.h>.
"$zx/kernel/dev/interrupt:headers",
]
}
source_set("syscall") {
sources = [
"syscall.S",
]
deps = [
"$zx/kernel/syscalls:syscall-abi",
]
}
source_set("tests") {
sources = [
"mmu_tests.cpp",
"system_topology_test.cpp",
]
deps = [
":headers",
"$zx/kernel/lib/acpi_tables:headers",
"$zx/kernel/lib/topology:headers",
"$zx/kernel/lib/unittest",
]
}