summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-09-21 01:26:28 +0200
committerRichard Braun <rbraun@sceen.net>2017-09-21 01:26:28 +0200
commit4077ffe75fe9f2149cfac5b7046e73f21dc80312 (patch)
tree76be7f7076d908a395d2c15b4bf7cf4e0225004d /arch
parent9b1d0f9488c905decaac5269886b137bcd23f416 (diff)
parent1ff3666dc29c0eacf911c57d3e6b6a62bdc9cb78 (diff)
Merge branch 'xbuild'
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/Kconfig32
-rw-r--r--arch/x86/Makefile54
-rw-r--r--arch/x86/Makefrag.am79
-rw-r--r--arch/x86/configfrag.ac47
-rw-r--r--arch/x86/configs/amd64_defconfig0
-rw-r--r--arch/x86/configs/i386_defconfig1
-rw-r--r--arch/x86/machine/boot.c6
-rw-r--r--arch/x86/machine/pmap.c46
-rw-r--r--arch/x86/machine/pmap.h6
-rw-r--r--arch/x86/machine/pmem.h6
-rw-r--r--arch/x86/machine/types.h6
11 files changed, 122 insertions, 161 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
new file mode 100644
index 0000000..421deaa
--- /dev/null
+++ b/arch/x86/Kconfig
@@ -0,0 +1,32 @@
+menu "Architecture-specific options"
+
+config 64BITS
+ bool "64-bits kernel" if ARCH = "x86"
+ default ARCH != "i386"
+ ---help---
+ Build a 64-bits kernel.
+
+config X86_PAE
+ bool "Enable PAE (Physical Address Extension)"
+ depends on X86_32
+ ---help---
+ PAE allows addressing physical memory beyond 4 GiB at the cost
+ of more pagetable lookup and memory overhead.
+
+endmenu
+
+config X86_32
+ def_bool y
+ depends on !64BITS
+
+config X86_64
+ def_bool y
+ depends on 64BITS
+
+config X86
+ def_bool y
+
+config SUBARCH
+ string
+ default "i386" if X86_32
+ default "amd64" if X86_64
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
new file mode 100644
index 0000000..f0640f7
--- /dev/null
+++ b/arch/x86/Makefile
@@ -0,0 +1,54 @@
+ifeq ($(shell uname -m),x86_64)
+ KCONFIG_DEFCONFIG := amd64_defconfig
+else
+ KCONFIG_DEFCONFIG := i386_defconfig
+endif
+
+# Prevent GCC from generating any FP code by mistake.
+XBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow
+XBUILD_CFLAGS += $(call cc-option,-mno-avx,)
+
+# Store unwind information in .debug_frame instead of .eh_frame. Unwind
+# tables aren't used at runtime, so using a debug section reduces the kernel
+# code size.
+XBUILD_CFLAGS += -fno-asynchronous-unwind-tables
+
+# For now, use frame pointers for convenient stack tracing.
+XBUILD_CFLAGS += -fno-omit-frame-pointer
+
+XBUILD_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
+
+ifeq ($(CONFIG_X86_32),y)
+ biarch := $(call cc-option,-m32)
+ XBUILD_CPPFLAGS += -m32
+else
+ biarch := -m64
+ XBUILD_CPPFLAGS += -m64
+
+ XBUILD_CFLAGS += -mno-red-zone
+ XBUILD_CFLAGS += -mcmodel=kernel
+endif
+
+x15_SOURCES-y += \
+ arch/x86/machine/acpi.c \
+ arch/x86/machine/atcons.c \
+ arch/x86/machine/atkbd.c \
+ arch/x86/machine/biosmem.c \
+ arch/x86/machine/boot_asm.S \
+ arch/x86/machine/boot.c \
+ arch/x86/machine/cga.c \
+ arch/x86/machine/cpu_asm.S \
+ arch/x86/machine/cpu.c \
+ arch/x86/machine/ioapic.c \
+ arch/x86/machine/lapic.c \
+ arch/x86/machine/pic.c \
+ arch/x86/machine/pit.c \
+ arch/x86/machine/pmap.c \
+ arch/x86/machine/ssp.c \
+ arch/x86/machine/strace.c \
+ arch/x86/machine/string.c \
+ arch/x86/machine/tcb_asm.S \
+ arch/x86/machine/tcb.c \
+ arch/x86/machine/trap_asm.S \
+ arch/x86/machine/trap.c \
+ arch/x86/machine/uart.c
diff --git a/arch/x86/Makefrag.am b/arch/x86/Makefrag.am
deleted file mode 100644
index 016e31c..0000000
--- a/arch/x86/Makefrag.am
+++ /dev/null
@@ -1,79 +0,0 @@
-EXTRA_DIST += arch/x86/x15.lds.S
-
-if X86
-
-# Store unwind information in .debug_frame instead of .eh_frame. Unwind
-# tables aren't used at runtime, so using a debug section reduces the kernel
-# code size.
-AM_CFLAGS += -fno-asynchronous-unwind-tables
-
-# For now, use frame pointers for convenient stack tracing.
-AM_CFLAGS += -fno-omit-frame-pointer
-
-x15_LDFLAGS += -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
-
-if X86_64
-
-AM_CPPFLAGS += -m64
-AM_CFLAGS += -mcmodel=kernel -mno-red-zone
-x15_LDFLAGS += -m64
-
-else !X86_64
-
-AM_CPPFLAGS += -m32
-x15_LDFLAGS += -m32
-
-endif !X86_64
-
-x15_SOURCES += \
- arch/x86/machine/acpi.c \
- arch/x86/machine/acpi.h \
- arch/x86/machine/atcons.c \
- arch/x86/machine/atcons.h \
- arch/x86/machine/atkbd.c \
- arch/x86/machine/atkbd.h \
- arch/x86/machine/asm.h \
- arch/x86/machine/atomic.h \
- arch/x86/machine/biosmem.c \
- arch/x86/machine/biosmem.h \
- arch/x86/machine/boot_asm.S \
- arch/x86/machine/boot.c \
- arch/x86/machine/boot.h \
- arch/x86/machine/config.h \
- arch/x86/machine/cga.c \
- arch/x86/machine/cga.h \
- arch/x86/machine/cpu_asm.S \
- arch/x86/machine/cpu.c \
- arch/x86/machine/cpu.h \
- arch/x86/machine/elf.h \
- arch/x86/machine/io.h \
- arch/x86/machine/ioapic.c \
- arch/x86/machine/ioapic.h \
- arch/x86/machine/lapic.c \
- arch/x86/machine/lapic.h \
- arch/x86/machine/multiboot.h \
- arch/x86/machine/page.h \
- arch/x86/machine/pic.c \
- arch/x86/machine/pic.h \
- arch/x86/machine/pit.c \
- arch/x86/machine/pit.h \
- arch/x86/machine/pmap.c \
- arch/x86/machine/pmap.h \
- arch/x86/machine/pmem.h \
- arch/x86/machine/ssp.c \
- arch/x86/machine/ssp.h \
- arch/x86/machine/strace.c \
- arch/x86/machine/strace.h \
- arch/x86/machine/string.c \
- arch/x86/machine/string.h \
- arch/x86/machine/tcb_asm.S \
- arch/x86/machine/tcb.c \
- arch/x86/machine/tcb.h \
- arch/x86/machine/trap_asm.S \
- arch/x86/machine/trap.c \
- arch/x86/machine/trap.h \
- arch/x86/machine/types.h \
- arch/x86/machine/uart.c \
- arch/x86/machine/uart.h
-
-endif X86
diff --git a/arch/x86/configfrag.ac b/arch/x86/configfrag.ac
deleted file mode 100644
index 0857368..0000000
--- a/arch/x86/configfrag.ac
+++ /dev/null
@@ -1,47 +0,0 @@
-m4_define([x86_ENABLE_PAE],
- [AC_DEFINE([X15_X86_PAE], [1], [use PAE page translation])])
-
-m4_define([x86_SELECT_I386],
- [subarch=i386
- AS_IF([test x"$enable_x86_pae" = xyes], [x86_ENABLE_PAE])])
-
-m4_define([x86_SELECT_AMD64],
- [subarch=amd64
- AS_IF([test x"$enable_x86_pae" = xyes],
- [AC_MSG_WARN([pae option available for 32-bits builds only, ignoring])])])
-
-m4_define([x86_SELECT],
- [arch=x86
- AC_ARG_ENABLE([x86-pae],
- [AS_HELP_STRING([--enable-x86-pae],
- [enable physical address extension (32-bits only)])],
- [],
- [enable_x86_pae=no])
-
- AS_IF([test -z "$enable_64bits"],
- [AS_CASE(["$host_cpu"],
- [i?86], [enable_64bits=no],
- [x86_64], [enable_64bits=yes])])
-
- AS_IF([test x"$enable_64bits" = xyes], [x86_SELECT_AMD64], [x86_SELECT_I386])
-
- # Never generate instructions that are unhandled in kernel mode
- AX_APPEND_COMPILE_FLAGS([ \
- -mno-mmx \
- -mno-3dnow \
- -mno-sse \
- -mno-sse2 \
- -mno-avx])
-
- AC_DEFINE_UNQUOTED([X15_X86_SUBARCH], [$subarch], [subarch])
-
- AS_ECHO
- AC_MSG_NOTICE([target: $arch ($subarch)])
- AS_IF([test x"$subarch" = xi386],
- [AC_MSG_NOTICE([x86: physical address extension: $enable_x86_pae])])])
-
-AS_CASE(["$host_cpu"],
- [i?86|x86_64], [x86_SELECT])
-
-AM_CONDITIONAL([X86], [test x"$arch" = xx86])
-AM_CONDITIONAL([X86_64], [test x"$arch" = xx86 -a x"$enable_64bits" = xyes])
diff --git a/arch/x86/configs/amd64_defconfig b/arch/x86/configs/amd64_defconfig
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/arch/x86/configs/amd64_defconfig
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
new file mode 100644
index 0000000..7d843af
--- /dev/null
+++ b/arch/x86/configs/i386_defconfig
@@ -0,0 +1 @@
+# 64BITS is not set
diff --git a/arch/x86/machine/boot.c b/arch/x86/machine/boot.c
index 47055c8..afc41d7 100644
--- a/arch/x86/machine/boot.c
+++ b/arch/x86/machine/boot.c
@@ -353,10 +353,10 @@ boot_setup_paging(struct multiboot_raw_info *mbi, unsigned long eax)
void __init
boot_log_info(void)
{
- log_info(KERNEL_NAME "/" QUOTE(X15_X86_SUBARCH) " " KERNEL_VERSION
-#ifdef X15_X86_PAE
+ log_info(KERNEL_NAME "/" CONFIG_SUBARCH " " KERNEL_VERSION
+#ifdef CONFIG_X86_PAE
" PAE"
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
);
}
diff --git a/arch/x86/machine/pmap.c b/arch/x86/machine/pmap.c
index 07b8a70..0448d07 100644
--- a/arch/x86/machine/pmap.c
+++ b/arch/x86/machine/pmap.c
@@ -82,7 +82,7 @@ struct pmap_cpu_table {
};
struct pmap {
- struct pmap_cpu_table *cpu_tables[X15_MAX_CPUS];
+ struct pmap_cpu_table *cpu_tables[CONFIG_MAX_CPUS];
};
/*
@@ -98,13 +98,13 @@ typedef void (*pmap_walk_fn_t)(phys_addr_t pa, unsigned int index,
* that using a percpu variable would actually become ugly. This array
* is rather small anyway.
*/
-static struct pmap_cpu_table pmap_kernel_cpu_tables[X15_MAX_CPUS] __read_mostly;
+static struct pmap_cpu_table pmap_kernel_cpu_tables[CONFIG_MAX_CPUS] __read_mostly;
struct pmap pmap_kernel_pmap;
struct pmap *pmap_current_ptr __percpu;
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
/*
* Alignment required on page directory pointer tables.
@@ -115,9 +115,9 @@ struct pmap *pmap_current_ptr __percpu;
* "Hidden" kernel root page tables for PAE mode.
*/
static alignas(PMAP_PDPT_ALIGN) pmap_pte_t
- pmap_cpu_kpdpts[X15_MAX_CPUS][PMAP_L2_PTES_PER_PT] __read_mostly;
+ pmap_cpu_kpdpts[CONFIG_MAX_CPUS][PMAP_L2_PTES_PER_PT] __read_mostly;
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
/*
* Flags related to page protection.
@@ -260,7 +260,7 @@ struct pmap_update_request {
* on remote processors.
*/
struct pmap_update_request_array {
- struct pmap_update_request requests[X15_MAX_CPUS];
+ struct pmap_update_request requests[CONFIG_MAX_CPUS];
struct mutex lock;
};
@@ -270,10 +270,10 @@ static int pmap_do_remote_updates __read_mostly;
static struct kmem_cache pmap_cache;
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
static char pmap_panic_no_pae[] __bootdata
= "pmap: PAE not supported";
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
static char pmap_panic_inval_msg[] __bootdata
= "pmap: invalid physical address";
static char pmap_panic_directmap_msg[] __bootdata
@@ -369,17 +369,17 @@ out:
eax = 1;
cpu_cpuid(&eax, &ebx, &ecx, &edx);
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
if (!(edx & CPU_FEATURE2_PAE)) {
boot_panic(pmap_panic_no_pae);
}
return (1 << PMAP_L1_SKIP);
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
if (edx & CPU_FEATURE2_PSE) {
return (1 << PMAP_L1_SKIP);
}
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
out:
return PAGE_SIZE;
@@ -401,11 +401,11 @@ pmap_boot_enable_pgext(unsigned long pgsize)
*
* See the boot module.
*/
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
cpu_enable_pae();
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
cpu_enable_pse();
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
}
#endif /* __LP64__ */
@@ -428,11 +428,11 @@ pmap_setup_paging(void)
* direct physical mapping of physical memory.
*/
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
root_ptp = (void *)BOOT_VTOP((uintptr_t)pmap_cpu_kpdpts[0]);
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
root_ptp = biosmem_bootalloc(1);
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
va = vm_page_trunc((uintptr_t)&_boot);
pa = va;
@@ -496,11 +496,11 @@ pmap_ap_setup_paging(void)
pmap = (void *)BOOT_VTOP((uintptr_t)&pmap_kernel_pmap);
cpu_table = (void *)BOOT_VTOP((uintptr_t)pmap->cpu_tables[boot_ap_id]);
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
return (void *)(uint32_t)cpu_table->root_ptp_pa;
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
return (void *)cpu_table->root_ptp_pa;
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
}
/*
@@ -1004,10 +1004,10 @@ pmap_copy_cpu_table(unsigned int cpu)
kernel_pmap = pmap_get_kernel_pmap();
sptp = pmap_ptp_from_pa(kernel_pmap->cpu_tables[cpu_id()]->root_ptp_pa);
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
cpu_table->root_ptp_pa = BOOT_VTOP((uintptr_t)pmap_cpu_kpdpts[cpu]);
dptp = pmap_ptp_from_pa(cpu_table->root_ptp_pa);
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
struct vm_page *page;
page = vm_page_alloc(0, VM_PAGE_SEL_DIRECTMAP, VM_PAGE_PMAP);
@@ -1018,7 +1018,7 @@ pmap_copy_cpu_table(unsigned int cpu)
cpu_table->root_ptp_pa = vm_page_to_pa(page);
dptp = vm_page_direct_ptr(page);
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
pmap_copy_cpu_table_recursive(sptp, level, dptp, PMAP_START_ADDRESS);
}
diff --git a/arch/x86/machine/pmap.h b/arch/x86/machine/pmap.h
index d8c2455..369679f 100644
--- a/arch/x86/machine/pmap.h
+++ b/arch/x86/machine/pmap.h
@@ -132,7 +132,7 @@
#define PMAP_L2_MASK PMAP_L1_MASK
#define PMAP_L3_MASK PMAP_L1_MASK
#else /* __LP64__ */
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
#define PMAP_NR_LEVELS 3
#define PMAP_L0_BITS 9
#define PMAP_L1_BITS 9
@@ -140,13 +140,13 @@
#define PMAP_VA_MASK DECL_CONST(0xffffffff, UL)
#define PMAP_PA_MASK DECL_CONST(0x000ffffffffff000, ULL)
#define PMAP_L2_MASK PMAP_PAE_L2_MASK
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
#define PMAP_NR_LEVELS 2
#define PMAP_L0_BITS 10
#define PMAP_L1_BITS 10
#define PMAP_VA_MASK DECL_CONST(0xffffffff, UL)
#define PMAP_PA_MASK DECL_CONST(0xfffff000, UL)
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
#endif /* __LP64__ */
#define PMAP_L0_SKIP 12
diff --git a/arch/x86/machine/pmem.h b/arch/x86/machine/pmem.h
index b6c6db0..33006a7 100644
--- a/arch/x86/machine/pmem.h
+++ b/arch/x86/machine/pmem.h
@@ -39,13 +39,13 @@
#define PMEM_HIGHMEM_LIMIT DECL_CONST(0x10000000000000, UL)
#else /* __LP64__ */
#define PMEM_DIRECTMAP_LIMIT DECL_CONST(0x38000000, ULL)
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
#define PMEM_MAX_ZONES 3
#define PMEM_HIGHMEM_LIMIT DECL_CONST(0x10000000000000, ULL)
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
#define PMEM_MAX_ZONES 3
#define PMEM_HIGHMEM_LIMIT DECL_CONST(0xfffff000, UL)
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
#endif /* __LP64__ */
/*
diff --git a/arch/x86/machine/types.h b/arch/x86/machine/types.h
index fa41e91..cd82515 100644
--- a/arch/x86/machine/types.h
+++ b/arch/x86/machine/types.h
@@ -18,10 +18,10 @@
#ifndef _X86_TYPES_H
#define _X86_TYPES_H
-#ifdef X15_X86_PAE
+#ifdef CONFIG_X86_PAE
typedef unsigned long long phys_addr_t;
-#else /* X15_X86_PAE */
+#else /* CONFIG_X86_PAE */
typedef unsigned long phys_addr_t;
-#endif /* X15_X86_PAE */
+#endif /* CONFIG_X86_PAE */
#endif /* _X86_TYPES_H */