blob: 695386e7f205650e35b8424b315e06497d930127 [file]
# 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",
]
}
zx_library("x86") {
kernel = true
sources = [
"acpi.S",
"amd.cc",
"arch.cc",
"asm.S",
"bootstrap16.cc",
"cache.cc",
"debugger.cc",
"descriptor.cc",
"exceptions.S",
"faults.cc",
"feature.cc",
"gdt.S",
"hwp.cc",
"idle_states.cc",
"idt.cc",
"intel.cc",
"ioapic.cc",
"ioport.cc",
"lapic.cc",
"mexec.S",
"mmu.cc",
"mmu_mem_types.cc",
"mp.cc",
"msr.cc",
"ops.S",
"perf_mon.cc",
"proc_trace.cc",
"pvclock.cc",
"registers.cc",
"smp.cc",
"spinlock.cc",
"start.S",
"start16.S",
"system_topology.cc",
"thread.cc",
"timer_freq.cc",
"tsc.cc",
"user_copy.S",
"user_copy.cc",
"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/cmdline",
"$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/kernel/platform/pc",
"$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/hypervisor:headers",
# <arch/aspace.h> has #include <bitmap/rle-bitmap.h>.
"$zx/system/ulib/bitmap:headers",
# <arch/aspace.h> uses various fbl things
"$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",
]
public_configs = [ "$zx/public/gn/config:Wno-unused-function" ]
}
source_set("syscall") {
sources = [
"syscall.S",
]
deps = [
"$zx/kernel/lib/code_patching",
"$zx/kernel/syscalls:syscall-abi",
]
}
source_set("tests") {
sources = [
"idle_states_test.cc",
"mmu_tests.cc",
"platform_tests.cc",
"system_topology_test.cc",
]
deps = [
":headers",
"$zx/kernel/lib/acpi_tables:headers",
"$zx/kernel/lib/console:headers",
"$zx/kernel/lib/topology:headers",
"$zx/kernel/lib/unittest",
]
}