summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-09-21 01:23:37 +0200
committerRichard Braun <rbraun@sceen.net>2017-09-21 01:26:09 +0200
commitb0b860e6cd8949c05da380dbe64b7c7c6ec75e7c (patch)
treea1c7d98eb2a370975bd82c6d3dc16349636ddddf
parent833316f34266a5fab2668f34c03e45db64d0ce76 (diff)
New build system
The new build system, called xbuild, is a minimalistic kbuild-like make-based build system, also using kconfig for scalable configurations.
-rw-r--r--.gitignore6
-rw-r--r--Kconfig51
-rw-r--r--Makefile333
-rw-r--r--arch/x86/Kconfig32
-rw-r--r--arch/x86/Makefile54
-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
-rw-r--r--doc/Makefile73
-rw-r--r--kern/Kconfig83
-rw-r--r--kern/Makefile42
-rw-r--r--kern/clock.h2
-rw-r--r--kern/cpumap.h28
-rw-r--r--kern/kernel.c4
-rw-r--r--kern/kernel.h4
-rw-r--r--kern/kmem.c4
-rw-r--r--kern/kmem_i.h2
-rw-r--r--kern/log.c4
-rw-r--r--kern/mutex.h6
-rw-r--r--kern/mutex_types.h6
-rw-r--r--kern/percpu.c4
-rw-r--r--kern/percpu.h4
-rw-r--r--kern/shell.h6
-rw-r--r--kern/shutdown.c4
-rw-r--r--kern/spinlock.c2
-rw-r--r--kern/syscnt.c4
-rw-r--r--kern/task.c4
-rw-r--r--kern/thread.c22
-rw-r--r--kern/thread.h3
-rw-r--r--kern/work.c2
-rw-r--r--kern/xcall.c2
-rw-r--r--test/Kconfig41
-rw-r--r--test/Makefile9
-rw-r--r--test/test_mutex.c6
-rw-r--r--tools/kconfig/Makefile269
-rw-r--r--tools/kconfig/gconf.c2
-rw-r--r--vm/Makefile5
-rw-r--r--vm/vm_map.c4
-rw-r--r--vm/vm_page.c6
43 files changed, 959 insertions, 245 deletions
diff --git a/.gitignore b/.gitignore
index 61d2f516..2dfdd966 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,10 @@
+.*
*.o
-cscope.out
+*.d
tags
+cscope.out
x15.lds
+/include/generated
/x15
-/x15.sorted_init_ops
/doc/*\.[1-9]
/doc/*\.[1-9]\.html
diff --git a/Kconfig b/Kconfig
new file mode 100644
index 00000000..cf42e9f2
--- /dev/null
+++ b/Kconfig
@@ -0,0 +1,51 @@
+#
+# For a description of the syntax of this configuration file,
+# see doc/kbuild/kconfig-language.txt.
+#
+mainmenu "X15/$ARCH $VERSION Kernel Configuration"
+
+config ARCH
+ string
+ option env="ARCH"
+
+config VERSION
+ string
+ option env="VERSION"
+
+config KERNEL_VERSION
+ string
+ default VERSION
+
+config CC
+ string
+ option env="CC"
+
+config CFLAGS
+ string
+ option env="CFLAGS"
+
+menu "Build options"
+
+config CC_EXE
+ string "Compiler executable"
+ default CC
+ ---help---
+ Name of the compiler executable
+
+config CC_OPTIONS
+ string "Compilation options"
+ default CFLAGS
+ ---help---
+ Raw options passed to the compiler.
+
+config ASSERT
+ bool "Assertions"
+ default y
+ ---help---
+ Enable assert() code generation.
+
+endmenu
+
+source "arch/$ARCH/Kconfig"
+source "kern/Kconfig"
+source "test/Kconfig"
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..33e8c140
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,333 @@
+SHELL := /bin/sh
+
+MAKEFLAGS += -rR
+MAKEFLAGS += --no-print-directory
+
+.PHONY: all
+all: x15 docs
+
+VERSION = 0.1
+export VERSION
+
+ifndef V
+V := 0
+endif
+
+# Use callable variables so that commands can be split into multiple
+# lines, but produce a single line when echoed. This makes copying
+# commands easy. It also makes them somewhat self-describing.
+
+ifeq ($(V),0)
+Q := @
+
+# $(call xbuild_action_print,<action_short_name>,<target>)
+define xbuild_action_print
+@printf " %-7s %s\n" $(1) $(2)
+@
+endef
+else ifneq ($(V),1)
+$(error invalid value for V)
+endif
+
+export Q
+
+# $(call xbuild_action_mkdir,<target>)
+define xbuild_action_mkdir
+ $(Q)mkdir -p $(dir $(1))
+endef
+
+# $(call xbuild_action,<action>,<target>)
+define xbuild_action
+ $(call xbuild_action_mkdir,$(2))
+ $(call xbuild_action_print,$(1),$(2))
+endef
+
+define xbuild_kconfig_invoke
+ $(Q)$(MAKE) -f $(SRCDIR)/$(KCONFIG_PATH)/Makefile $@
+endef
+
+define xbuild_gen_autoconf_h
+ $(call xbuild_action,GEN,$@)cat $< \
+ | sed -e 's/^\([^#]\)/#define CONFIG_\1/g' \
+ -e 's/=/ /' \
+ | grep '^#define' > $@
+endef
+
+define xbuild_gen_autoconf_mk
+ $(call xbuild_action,GEN,$@)cat $< \
+ | sed -e 's/^\([^#]\)/CONFIG_\1/g' > $@
+endef
+
+# $(call xbuild_check_cc_option,<option>)
+define xbuild_check_cc_option
+$(shell printf "int main(void){ return 0; }\n" \
+ | $(CC) -Wall -Werror -x c $(1) -c - -o /dev/null 2> /dev/null \
+ && printf -- "%s" $(1))
+endef
+
+# $(call xbuild_replace_source_suffix,<suffix>,<file_names>)
+define xbuild_replace_source_suffix
+$(sort $(patsubst %.c,%.$(1),$(filter %.c,$(2))) \
+ $(patsubst %.S,%.$(1),$(filter %.S,$(2))))
+endef
+
+define xbuild_compile
+ $(call xbuild_action,CC,$@) \
+ $(COMPILE) -MMD -MP -c -o $@ $<
+endef
+
+define xbuild_gen_linker_script
+ $(call xbuild_action,LDS,$@) \
+ $(CPP) $(XBUILD_CPPFLAGS) -P -o $@ $<
+endef
+
+# $(call xbuild_link,<objects>)
+define xbuild_link
+ $(call xbuild_action,LD,$@) \
+ $(COMPILE) -o $@ $(1) $(XBUILD_LDFLAGS)
+endef
+
+define xbuild_clean
+ $(Q)rm -f x15 \
+ $(x15_OBJDEPS) \
+ $(x15_OBJECTS) \
+ $(x15_LDS)
+endef
+
+define xbuild_distclean
+ $(clean)
+ $(Q)rm -f .config \
+ .config.old \
+ include/generated/autoconf.h \
+ include/generated/autoconf.mk
+endef
+
+ARCH ?= $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ )
+export ARCH
+
+SRCDIR := $(realpath $(dir $(realpath $(firstword $(MAKEFILE_LIST)))))
+VPATH := $(SRCDIR)
+export SRCDIR VPATH
+
+PREFIX ?= /usr/local
+DATAROOTDIR ?= share
+
+# Do not use MAKEFILE_LIST as its value is updated only on inclusion,
+# which makes it unsuitable as a rule dependency in most of the file.
+#
+# These additional Makefiles are included in order.
+MAKEFILE_INCLUDES := \
+ $(SRCDIR)/arch/$(ARCH)/Makefile \
+ $(SRCDIR)/doc/Makefile \
+ $(SRCDIR)/kern/Makefile \
+ $(SRCDIR)/test/Makefile \
+ $(SRCDIR)/vm/Makefile
+ALL_MAKEFILES := $(MAKEFILE_LIST) $(MAKEFILE_INCLUDES)
+
+ifeq ($(words $(MAKECMDGOALS)),0)
+else ifeq ($(words $(MAKECMDGOALS)),1)
+else
+$(error up to one target may be given)
+endif
+
+KCONFIG_PATH := tools/kconfig
+
+# Export to Kconfig
+export KCONFIG_PATH
+
+HOSTCC := $(if $(shell type gcc 2>/dev/null),gcc,cc)
+HOSTCXX = g++
+HOSTCFLAGS := -g
+HOSTCXXFLAGS := -g
+
+# Export to Kconfig
+export HOSTCC HOSTCXX HOSTCFLAGS HOSTCXXFLAGS
+
+BOARDS := $(wildcard $(SRCDIR)/arch/$(ARCH)/configs/*_defconfig)
+BOARDS := $(sort $(notdir $(BOARDS)))
+
+.PHONY: help
+help:
+ @printf 'Configuration targets:\n'
+ @$(Q)$(MAKE) -f $(SRCDIR)/$(KCONFIG_PATH)/Makefile $@
+ @printf '\n'
+ @printf 'Cleaning targets:\n'
+ @printf ' clean - Remove most generated files but keep configuration\n'
+ @printf ' distclean - Remove all generated files\n'
+ @printf '\n'
+ @printf 'Build targets:\n'
+ @printf ' all - Build all targets marked with [*]\n'
+ @printf '* x15 - Build the kernel ELF image\n'
+ @printf '\n'
+ $(DOC_HELP)
+ @printf 'Installation targets:\n'
+ @printf ' install - Install the kernel and documentation\n'
+ @printf ' install-strip - Same as install but also strip the kernel\n'
+ @printf '\n'
+ @printf 'Architecture specific targets ($(ARCH)):\n'
+ @$(if $(BOARDS), \
+ $(foreach b, $(BOARDS), \
+ printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));))
+ @printf '\n'
+ @printf 'Options:\n'
+ @printf ' make V=0 - Quiet build\n'
+ @printf ' make V=1 - Verbose build\n'
+ @printf '\n'
+ @printf 'Notes:\n'
+ @printf '- One target at most may be specified.\n'
+ @printf '- The compiler program and flags may be given at configuration time\n'
+ @printf ' through the CC and CFLAGS variables respectively.\n'
+ @printf '- Out-of-tree builds are performed with the following command:\n'
+ @printf ' make -f path/to/src/Makefile [options] [target]\n'
+ @printf '- The source directory must be completely clean for reliable out-of-tree builds.\n'
+ @printf '- Use the DESTDIR and PREFIX variables to control installation, e.g.:\n'
+ @printf ' make DESTDIR=/stagingroot PREFIX=/usr install\n'
+ @printf '\n'
+ @printf 'See README for more information.\n'
+
+# Don't create a %config pattern rule as it would conflict with .config
+KCONFIG_TARGETS := config nconfig menuconfig xconfig gconfig \
+ allnoconfig allyesconfig alldefconfig randconfig \
+ oldconfig defconfig savedefconfig listnewconfig
+
+.PHONY: $(KCONFIG_TARGETS)
+$(KCONFIG_TARGETS):
+ $(call xbuild_kconfig_invoke)
+
+%_defconfig:
+ $(call xbuild_kconfig_invoke)
+
+include/generated/autoconf.h: .config $(ALL_MAKEFILES)
+ $(call xbuild_gen_autoconf_h)
+
+include/generated/autoconf.mk: .config $(ALL_MAKEFILES)
+ $(call xbuild_gen_autoconf_mk)
+
+ifneq ($(MAKECMDGOALS),help)
+-include include/generated/autoconf.mk
+endif
+
+ifdef CONFIG_CC_EXE
+# Use printf to remove quotes
+CC := $(shell printf -- $(CONFIG_CC_EXE))
+else
+CC := gcc
+endif
+
+# Export to CONFIG_CC
+export CC
+
+CPP = $(CC) -E
+
+CFLAGS ?= -O2 -g
+
+# Export to CONFIG_CFLAGS
+export CFLAGS
+
+XBUILD_CPPFLAGS :=
+XBUILD_CFLAGS :=
+
+XBUILD_CPPFLAGS += -pipe
+
+# Do not include headers from the hosted environment, but
+# do include headers from the compiler.
+XBUILD_CPPFLAGS += -nostdinc
+XBUILD_CPPFLAGS += -isystem $(shell $(CC) -print-file-name=include)
+
+XBUILD_CPPFLAGS += -std=gnu11
+XBUILD_CPPFLAGS += -ffreestanding
+XBUILD_CPPFLAGS += -include $(SRCDIR)/kern/config.h
+XBUILD_CPPFLAGS += -include include/generated/autoconf.h
+XBUILD_CPPFLAGS += -I$(SRCDIR)
+XBUILD_CPPFLAGS += -I$(SRCDIR)/include
+XBUILD_CPPFLAGS += -I$(SRCDIR)/arch/$(ARCH)
+
+ifndef CONFIG_ASSERT
+XBUILD_CPPFLAGS += -DNDEBUG
+endif
+
+XBUILD_CFLAGS += -fsigned-char
+XBUILD_CFLAGS += -fno-common
+
+XBUILD_CFLAGS += -Wall
+XBUILD_CFLAGS += -Wextra
+XBUILD_CFLAGS += -Wshadow
+XBUILD_CFLAGS += -Wmissing-prototypes
+XBUILD_CFLAGS += -Wstrict-prototypes
+
+XBUILD_CFLAGS += $(call xbuild_check_cc_option,-fno-PIE)
+XBUILD_CFLAGS += $(call xbuild_check_cc_option,-Qunused-arguments)
+
+XBUILD_LDFLAGS += -static -nostdlib -lgcc
+
+x15_SOURCES-y :=
+x15_LDS_S := arch/$(ARCH)/x15.lds.S
+
+# Include the additional Makefiles here, as they may augment the build
+# variables.
+include $(MAKEFILE_INCLUDES)
+
+# Export to Kconfig.
+# Must be defined by the architecture-specific Makefile.
+export KCONFIG_DEFCONFIG
+
+ifdef CONFIG_CC_OPTIONS
+# Use printf to remove quotes
+XBUILD_CFLAGS += $(shell printf -- $(CONFIG_CC_OPTIONS))
+endif
+
+COMPILE := $(CC) $(XBUILD_CPPFLAGS) $(XBUILD_CFLAGS)
+
+# Don't change preprocessor and compiler flags from this point
+
+x15_SOURCES := $(x15_SOURCES-y)
+x15_OBJDEPS := $(call xbuild_replace_source_suffix,d,$(x15_SOURCES))
+x15_OBJECTS := $(call xbuild_replace_source_suffix,o,$(x15_SOURCES))
+x15_LDS := $(basename $(x15_LDS_S))
+
+XBUILD_LDFLAGS += -Xlinker -T $(x15_LDS)
+
+define gen_sorted_init_ops
+ $(call xbuild_action,GEN,$@) \
+ $(SRCDIR)/tools/tsort_init_ops.sh "$(COMPILE)" "$@" $^
+endef
+
+.INTERMEDIATE: .x15.sorted_init_ops
+.x15.sorted_init_ops: $(filter %.c,$(x15_SOURCES))
+ $(call gen_sorted_init_ops)
+
+x15_DEPS := $(x15_LDS) .x15.sorted_init_ops
+
+# Compiling produces dependency rules as a side-effect. When the dependency
+# rules file doesn't exist, the main source file is enough to trigger a
+# rebuild. Afterwards, the dependency rules file is included here and the
+# rules provide correct incremental compilation.
+-include $(x15_OBJDEPS)
+
+%.o: %.c include/generated/autoconf.h
+ $(xbuild_compile)
+
+%.o: %.S include/generated/autoconf.h
+ $(xbuild_compile)
+
+%.lds: %.lds.S include/generated/autoconf.h
+ $(xbuild_gen_linker_script)
+
+x15: $(x15_OBJECTS) $(x15_DEPS)
+ $(call xbuild_link,$(x15_OBJECTS))
+
+.PHONY: install install-strip
+install: docs_install
+ install -D -m 644 x15 $(DESTDIR)/boot/x15
+
+install-strip: docs_install
+ install -s -D -m 644 x15 $(DESTDIR)/boot/x15
+
+.PHONY: clean distclean
+clean: docs_clean
+ $(Q)$(MAKE) -f $(SRCDIR)/$(KCONFIG_PATH)/Makefile $@
+ $(call xbuild_clean)
+
+distclean: clean docs_distclean
+ $(Q)$(MAKE) -f $(SRCDIR)/$(KCONFIG_PATH)/Makefile $@
+ $(call xbuild_distclean)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
new file mode 100644
index 00000000..421deaa4
--- /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 00000000..f0640f77
--- /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/configs/amd64_defconfig b/arch/x86/configs/amd64_defconfig
new file mode 100644
index 00000000..e69de29b
--- /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 00000000..7d843afd
--- /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 47055c87..afc41d70 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 07b8a707..0448d07d 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 d8c2455b..369679fd 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 b6c6db0c..33006a7e 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 fa41e910..cd825154 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 */
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 00000000..2d49dd1f
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,73 @@
+ASCIIDOC := asciidoc
+A2X := a2x
+
+ASCIIDOC_FLAGS := -a toc -d manpage -a revnumber=$(VERSION)
+A2X_FLAGS := -d manpage -a revnumber=$(VERSION)
+
+ASCIIDOC_SOURCES := \
+ doc/cenv.9.txt \
+ doc/init.9.txt \
+ doc/intro.9.txt \
+ doc/style.9.txt
+
+ASCIIDOC_MANDOCS := $(patsubst %.9.txt,%.9,$(ASCIIDOC_SOURCES))
+ASCIIDOC_HTMLDOCS := $(patsubst %.9.txt,%.9.html,$(ASCIIDOC_SOURCES))
+
+define DOC_HELP
+ @printf 'Documentation targets:\n'
+ @printf ' docs - Build all documentation\n'
+ @printf ' mandocs - Build man pages\n'
+ @printf ' htmldocs - Build HTML man pages\n'
+ @printf '\n'
+endef
+
+# Expose intermediate DocBook files for correct parallel builds.
+%.9.xml: %.9.txt doc/asciidoc.conf $(ALL_MAKEFILES)
+ $(call xbuild_action_mkdir,$@)
+ $(Q)$(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -o $@ $<
+
+%.9: %.9.xml doc/asciidoc.conf $(ALL_MAKEFILES)
+ $(call xbuild_action,MAN,$@) \
+ $(A2X) $(A2X_FLAGS) -f manpage $<
+
+%.9.html: %.9.txt doc/asciidoc.conf $(ALL_MAKEFILES)
+ $(call xbuild_action,HTML,$@) \
+ $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b html5 -o $@ $<
+
+.PHONY: mandocs
+mandocs: $(ASCIIDOC_MANDOCS)
+
+.PHONY: htmldocs
+htmldocs: $(ASCIIDOC_HTMLDOCS)
+
+.PHONY: docs
+docs: mandocs htmldocs
+
+define mandocs_install_targets
+ $(foreach manpage,$(notdir $(ASCIIDOC_MANDOCS)),$(manpage)_man_install)
+endef
+
+%_man_install: doc/%
+ install -D -m 644 $< $(DESTDIR)$(PREFIX)/$(DATAROOTDIR)/man/man9/$*
+
+define htmldocs_install_targets
+ $(foreach htmlpage,$(notdir $(ASCIIDOC_HTMLDOCS)),$(htmlpage)_html_install)
+endef
+
+%_html_install: doc/%
+ install -D -m 644 $< $(DESTDIR)$(PREFIX)/$(DATAROOTDIR)/doc/x15/$*
+
+.PHONY: docs_install
+docs_install: $(mandocs_install_targets) $(htmldocs_install_targets)
+
+define docs_clean
+ $(Q)rm -f $(ASCIIDOC_MANDOCS) \
+ $(ASCIIDOC_HTMLDOCS)
+endef
+
+.PHONY: docs_clean
+docs_clean:
+ $(call docs_clean)
+
+.PHONY: docs_distclean
+docs_distclean:
diff --git a/kern/Kconfig b/kern/Kconfig
new file mode 100644
index 00000000..df0cbacb
--- /dev/null
+++ b/kern/Kconfig
@@ -0,0 +1,83 @@
+menu "General setup"
+
+config MULTIPROCESSOR
+ bool "Multiprocessor support"
+ default y
+ ---help---
+ Enable support for machines with multiple processors.
+
+config MAX_CPUS
+ int "Maximum number of supported CPUs" if MULTIPROCESSOR
+ range 2 512 if MULTIPROCESSOR
+ default "1" if !MULTIPROCESSOR
+ default "128" if MULTIPROCESSOR
+ ---help---
+ Maximum number of supported processors.
+
+config CLOCK_FREQ
+ int "Low resolution clock frequency"
+ range 100 1000
+ default 200
+ ---help---
+ The low resolution clock frequency determines how often low
+ resolution clocks interrupt processors. These clocks drive
+ the timer system. Low values increase throughput and latencies,
+ whereas high values reduce throughput and latencies.
+
+ The value must be usable as an integer divisor for 1000, with
+ no remainder.
+
+ Recommended values are 100 for throughput, 1000 for low
+ latencies, and 200 or 250 for a good balance between throughput
+ and latencies.
+
+choice
+ prompt "Mutex implementation"
+ default MUTEX_PLAIN
+ ---help---
+ A mutex is a sleeping synchronization object used throughout the
+ kernel and available to kernel applications. As a result, this
+ option affects all mutex users.
+
+ If in doubt, choose the plain implementation.
+
+config MUTEX_ADAPTIVE
+ bool "Adaptive spinning mutex"
+ ---help---
+ Adaptive spinning mutex, spinning instead of sleeping if the owner
+ is running, in the hope the critical section is short and the mutex
+ will be unlocked soon, to avoid expensive sleep/wakeup operations.
+ This implementation should improve overall performance at the cost
+ of increased latencies.
+
+config MUTEX_PI
+ bool "Mutex with priority inheritance"
+ ---help---
+ Real-time mutex with priority inheritance. This implementation
+ should improve latencies at the cost of overall performance.
+
+config MUTEX_PLAIN
+ bool "Plain mutex"
+ ---help---
+ Default implementation, immediately sleeping on contention.
+
+endchoice
+
+config SHELL
+ bool "Embedded shell"
+ default n
+ ---help---
+ Enable the embedded shell.
+
+ The embedded shell is mostly used for diagnostics.
+
+config THREAD_STACK_GUARD
+ bool "Thread stack guard pages"
+ ---help---
+ Enable the use of guard pages around kernel thread stacks to catch
+ overflows. Note that this feature wastes precious kernel virtual
+ memory and has some overhead during thread creation and destruction.
+
+ If unsure, disable.
+
+endmenu
diff --git a/kern/Makefile b/kern/Makefile
new file mode 100644
index 00000000..0aa96fc3
--- /dev/null
+++ b/kern/Makefile
@@ -0,0 +1,42 @@
+x15_SOURCES-y += \
+ kern/arg.c \
+ kern/bitmap.c \
+ kern/cbuf.c \
+ kern/clock.c \
+ kern/condition.c \
+ kern/console.c \
+ kern/cpumap.c \
+ kern/error.c \
+ kern/fmt.c \
+ kern/init.c \
+ kern/intr.c \
+ kern/kernel.c \
+ kern/kmem.c \
+ kern/llsync.c \
+ kern/log.c \
+ kern/mutex.c \
+ kern/panic.c \
+ kern/percpu.c \
+ kern/plist.c \
+ kern/printf.c \
+ kern/rbtree.c \
+ kern/rdxtree.c \
+ kern/rtmutex.c \
+ kern/semaphore.c \
+ kern/shutdown.c \
+ kern/sleepq.c \
+ kern/spinlock.c \
+ kern/sref.c \
+ kern/string.c \
+ kern/syscnt.c \
+ kern/task.c \
+ kern/thread.c \
+ kern/timer.c \
+ kern/turnstile.c \
+ kern/work.c \
+ kern/xcall.c
+
+x15_SOURCES-$(CONFIG_SHELL) += kern/shell.c
+
+x15_SOURCES-$(CONFIG_MUTEX_ADAPTIVE) += kern/mutex/mutex_adaptive.c
+x15_SOURCES-$(CONFIG_MUTEX_PLAIN) += kern/mutex/mutex_plain.c
diff --git a/kern/clock.h b/kern/clock.h
index fa48a477..854c146f 100644
--- a/kern/clock.h
+++ b/kern/clock.h
@@ -32,7 +32,7 @@
/*
* Clock frequency.
*/
-#define CLOCK_FREQ X15_CLOCK_FREQ
+#define CLOCK_FREQ CONFIG_CLOCK_FREQ
#if (CLOCK_FREQ < 100) || (CLOCK_FREQ > 1000) || (1000 % CLOCK_FREQ) != 0
#error "invalid clock frequency"
diff --git a/kern/cpumap.h b/kern/cpumap.h
index fd07afc1..89873b52 100644
--- a/kern/cpumap.h
+++ b/kern/cpumap.h
@@ -30,31 +30,31 @@
#include <kern/init.h>
struct cpumap {
- BITMAP_DECLARE(cpus, X15_MAX_CPUS);
+ BITMAP_DECLARE(cpus, CONFIG_MAX_CPUS);
};
static inline void
cpumap_zero(struct cpumap *cpumap)
{
- bitmap_zero(cpumap->cpus, X15_MAX_CPUS);
+ bitmap_zero(cpumap->cpus, CONFIG_MAX_CPUS);
}
static inline void
cpumap_fill(struct cpumap *cpumap)
{
- bitmap_fill(cpumap->cpus, X15_MAX_CPUS);
+ bitmap_fill(cpumap->cpus, CONFIG_MAX_CPUS);
}
static inline void
cpumap_copy(struct cpumap *dest, const struct cpumap *src)
{
- bitmap_copy(dest->cpus, src->cpus, X15_MAX_CPUS);
+ bitmap_copy(dest->cpus, src->cpus, CONFIG_MAX_CPUS);
}
static inline int
cpumap_cmp(const struct cpumap *a, const struct cpumap *b)
{
- return bitmap_cmp(a->cpus, b->cpus, X15_MAX_CPUS);
+ return bitmap_cmp(a->cpus, b->cpus, CONFIG_MAX_CPUS);
}
static inline void
@@ -90,50 +90,50 @@ cpumap_test(const struct cpumap *cpumap, int index)
static inline void
cpumap_and(struct cpumap *a, const struct cpumap *b)
{
- bitmap_and(a->cpus, b->cpus, X15_MAX_CPUS);
+ bitmap_and(a->cpus, b->cpus, CONFIG_MAX_CPUS);
}
static inline void
cpumap_or(struct cpumap *a, const struct cpumap *b)
{
- bitmap_or(a->cpus, b->cpus, X15_MAX_CPUS);
+ bitmap_or(a->cpus, b->cpus, CONFIG_MAX_CPUS);
}
static inline void
cpumap_xor(struct cpumap *a, const struct cpumap *b)
{
- bitmap_xor(a->cpus, b->cpus, X15_MAX_CPUS);
+ bitmap_xor(a->cpus, b->cpus, CONFIG_MAX_CPUS);
}
static inline int
cpumap_find_next(const struct cpumap *cpumap, int index)
{
- return bitmap_find_next(cpumap->cpus, X15_MAX_CPUS, index);
+ return bitmap_find_next(cpumap->cpus, CONFIG_MAX_CPUS, index);
}
static inline int
cpumap_find_first(const struct cpumap *cpumap)
{
- return bitmap_find_first(cpumap->cpus, X15_MAX_CPUS);
+ return bitmap_find_first(cpumap->cpus, CONFIG_MAX_CPUS);
}
static inline int
cpumap_find_next_zero(const struct cpumap *cpumap, int index)
{
- return bitmap_find_next_zero(cpumap->cpus, X15_MAX_CPUS, index);
+ return bitmap_find_next_zero(cpumap->cpus, CONFIG_MAX_CPUS, index);
}
static inline int
cpumap_find_first_zero(const struct cpumap *cpumap)
{
- return bitmap_find_first_zero(cpumap->cpus, X15_MAX_CPUS);
+ return bitmap_find_first_zero(cpumap->cpus, CONFIG_MAX_CPUS);
}
#define cpumap_for_each(cpumap, index) \
- bitmap_for_each((cpumap)->cpus, X15_MAX_CPUS, index)
+ bitmap_for_each((cpumap)->cpus, CONFIG_MAX_CPUS, index)
#define cpumap_for_each_zero(cpumap, index) \
- bitmap_for_each_zero((cpumap)->cpus, X15_MAX_CPUS, index)
+ bitmap_for_each_zero((cpumap)->cpus, CONFIG_MAX_CPUS, index)
/*
* Return a cpumap representing all active processors.
diff --git a/kern/kernel.c b/kern/kernel.c
index 755f42e6..418793d7 100644
--- a/kern/kernel.c
+++ b/kern/kernel.c
@@ -30,9 +30,9 @@ kernel_main(void)
init_setup();
vm_page_log_info();
-#ifdef X15_RUN_TEST_MODULE
+#ifdef CONFIG_TEST_MODULE
test_setup();
-#endif /* X15_RUN_TEST_MODULE */
+#endif /* CONFIG_TEST_MODULE */
/*
* Enabling application processors is done late in the boot process for
diff --git a/kern/kernel.h b/kern/kernel.h
index 22cae43b..f14b95b5 100644
--- a/kern/kernel.h
+++ b/kern/kernel.h
@@ -23,8 +23,8 @@
/*
* Kernel properties.
*/
-#define KERNEL_NAME PACKAGE_NAME
-#define KERNEL_VERSION PACKAGE_VERSION
+#define KERNEL_NAME "x15"
+#define KERNEL_VERSION CONFIG_KERNEL_VERSION
/*
* Machine-independent entry point.
diff --git a/kern/kmem.c b/kern/kmem.c
index ab33a86a..99664fc1 100644
--- a/kern/kmem.c
+++ b/kern/kmem.c
@@ -1123,7 +1123,7 @@ kmem_cache_info(struct kmem_cache *cache)
mutex_unlock(&cache->lock);
}
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
static struct kmem_cache *
kmem_lookup_cache(const char *name)
@@ -1184,7 +1184,7 @@ INIT_OP_DEFINE(kmem_setup_shell,
INIT_OP_DEP(shell_setup, true),
INIT_OP_DEP(thread_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static int __init
kmem_bootstrap(void)
diff --git a/kern/kmem_i.h b/kern/kmem_i.h
index beae6c45..0c0afd30 100644
--- a/kern/kmem_i.h
+++ b/kern/kmem_i.h
@@ -170,7 +170,7 @@ struct kmem_slab {
*/
struct kmem_cache {
/* CPU pool layer */
- struct kmem_cpu_pool cpu_pools[X15_MAX_CPUS];
+ struct kmem_cpu_pool cpu_pools[CONFIG_MAX_CPUS];
struct kmem_cpu_pool_type *cpu_pool_type;
/* Slab layer */
diff --git a/kern/log.c b/kern/log.c
index 83562206..3b1336e3 100644
--- a/kern/log.c
+++ b/kern/log.c
@@ -334,7 +334,7 @@ log_run(void *arg)
}
}
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
static void
log_dump(unsigned int level)
@@ -412,7 +412,7 @@ INIT_OP_DEFINE(log_setup_shell,
INIT_OP_DEP(log_setup, true),
INIT_OP_DEP(shell_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static int __init
log_setup(void)
diff --git a/kern/mutex.h b/kern/mutex.h
index c0a2c6e5..f152d317 100644
--- a/kern/mutex.h
+++ b/kern/mutex.h
@@ -25,11 +25,11 @@
#include <stdint.h>
-#if defined(X15_USE_MUTEX_ADAPTIVE)
+#if defined(CONFIG_MUTEX_ADAPTIVE)
#include <kern/mutex/mutex_adaptive_i.h>
-#elif defined(X15_USE_MUTEX_PI)
+#elif defined(CONFIG_MUTEX_PI)
#include <kern/mutex/mutex_pi_i.h>
-#elif defined(X15_USE_MUTEX_PLAIN)
+#elif defined(CONFIG_MUTEX_PLAIN)
#include <kern/mutex/mutex_plain_i.h>
#else
#error "unknown mutex implementation"
diff --git a/kern/mutex_types.h b/kern/mutex_types.h
index f0f8240c..574f4759 100644
--- a/kern/mutex_types.h
+++ b/kern/mutex_types.h
@@ -21,11 +21,11 @@
#ifndef _KERN_MUTEX_TYPES_H
#define _KERN_MUTEX_TYPES_H
-#if defined(X15_USE_MUTEX_ADAPTIVE)
+#if defined(CONFIG_MUTEX_ADAPTIVE)
#include <kern/mutex/mutex_adaptive_types.h>
-#elif defined(X15_USE_MUTEX_PI)
+#elif defined(CONFIG_MUTEX_PI)
#include <kern/mutex/mutex_pi_types.h>
-#elif defined(X15_USE_MUTEX_PLAIN)
+#elif defined(CONFIG_MUTEX_PLAIN)
#include <kern/mutex/mutex_plain_types.h>
#else
#error "unknown mutex implementation"
diff --git a/kern/percpu.c b/kern/percpu.c
index 7621bb29..62c3d22e 100644
--- a/kern/percpu.c
+++ b/kern/percpu.c
@@ -30,7 +30,7 @@
#include <vm/vm_kmem.h>
#include <vm/vm_page.h>
-void *percpu_areas[X15_MAX_CPUS] __read_mostly;
+void *percpu_areas[CONFIG_MAX_CPUS] __read_mostly;
static void *percpu_area_content __initdata;
static size_t percpu_area_size __initdata;
@@ -52,7 +52,7 @@ percpu_setup(void)
unsigned int order;
percpu_area_size = &_percpu_end - &_percpu;
- log_info("percpu: max_cpus: %u, section size: %zuk", X15_MAX_CPUS,
+ log_info("percpu: max_cpus: %u, section size: %zuk", CONFIG_MAX_CPUS,
percpu_area_size >> 10);
assert(vm_page_aligned(percpu_area_size));
diff --git a/kern/percpu.h b/kern/percpu.h
index 385930a1..87d14703 100644
--- a/kern/percpu.h
+++ b/kern/percpu.h
@@ -86,10 +86,10 @@ extern char _percpu_end;
static inline void *
percpu_area(unsigned int cpu)
{
- extern void *percpu_areas[X15_MAX_CPUS];
+ extern void *percpu_areas[CONFIG_MAX_CPUS];
void *area;
- assert(cpu < X15_MAX_CPUS);
+ assert(cpu < CONFIG_MAX_CPUS);
area = percpu_areas[cpu];
assert(area != NULL);
return area;
diff --git a/kern/shell.h b/kern/shell.h
index f6377f07..ee56856e 100644
--- a/kern/shell.h
+++ b/kern/shell.h
@@ -25,7 +25,7 @@
#include <kern/error.h>
#include <kern/macros.h>
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
#define SHELL_REGISTER_CMDS(cmds) \
MACRO_BEGIN \
@@ -81,11 +81,11 @@ void shell_start(void);
*/
int shell_cmd_register(struct shell_cmd *cmd);
-#else /* X15_ENABLE_SHELL */
+#else /* CONFIG_SHELL */
#define SHELL_REGISTER_CMDS(cmds)
#define shell_setup()
#define shell_start()
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
/*
* This init operation provides :
diff --git a/kern/shutdown.c b/kern/shutdown.c
index b85cb1cb..510911fe 100644
--- a/kern/shutdown.c
+++ b/kern/shutdown.c
@@ -26,7 +26,7 @@
static struct plist shutdown_ops_list;
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
static void
shutdown_shell_halt(int argc, char **argv)
@@ -66,7 +66,7 @@ INIT_OP_DEFINE(shutdown_setup_shell,
INIT_OP_DEP(shell_setup, true),
INIT_OP_DEP(shutdown_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static int __init
shutdown_bootstrap(void)
diff --git a/kern/spinlock.c b/kern/spinlock.c
index fcb7c7b6..a591c61d 100644
--- a/kern/spinlock.c
+++ b/kern/spinlock.c
@@ -106,7 +106,7 @@
#error "spinlock qid too large"
#endif
-#if X15_MAX_CPUS > (1 << SPINLOCK_QID_CPU_BITS)
+#if CONFIG_MAX_CPUS > (1 << SPINLOCK_QID_CPU_BITS)
#error "maximum number of supported processors too large"
#endif
diff --git a/kern/syscnt.c b/kern/syscnt.c
index f1cc95a9..cd13a398 100644
--- a/kern/syscnt.c
+++ b/kern/syscnt.c
@@ -33,7 +33,7 @@
static struct list syscnt_list;
static struct mutex syscnt_lock;
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
static void
syscnt_shell_info(int argc, char **argv)
@@ -61,7 +61,7 @@ INIT_OP_DEFINE(syscnt_setup_shell,
INIT_OP_DEP(shell_setup, true),
INIT_OP_DEP(syscnt_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static int __init
syscnt_setup(void)
diff --git a/kern/task.c b/kern/task.c
index 35220d3e..7039b426 100644
--- a/kern/task.c
+++ b/kern/task.c
@@ -59,7 +59,7 @@ task_init(struct task *task, const char *name, struct vm_map *map)
strlcpy(task->name, name, sizeof(task->name));
}
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
static void
task_shell_info(int argc, char *argv[])
@@ -107,7 +107,7 @@ INIT_OP_DEFINE(task_setup_shell,
INIT_OP_DEP(task_setup, true),
INIT_OP_DEP(thread_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static int __init
task_setup(void)
diff --git a/kern/thread.c b/kern/thread.c
index f9c22742..21736cd0 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -285,13 +285,13 @@ static struct thread_runq thread_runq __percpu;
* Statically allocated fake threads that provide thread context to processors
* during bootstrap.
*/
-static struct thread thread_booters[X15_MAX_CPUS] __initdata;
+static struct thread thread_booters[CONFIG_MAX_CPUS] __initdata;
static struct kmem_cache thread_cache;
-#ifndef X15_ENABLE_THREAD_STACK_GUARD
+#ifndef CONFIG_THREAD_STACK_GUARD
static struct kmem_cache thread_stack_cache;
-#endif /* X15_ENABLE_THREAD_STACK_GUARD */
+#endif /* CONFIG_THREAD_STACK_GUARD */
static const unsigned char thread_policy_table[THREAD_NR_SCHED_POLICIES] = {
[THREAD_SCHED_POLICY_FIFO] = THREAD_SCHED_CLASS_RT,
@@ -1877,7 +1877,7 @@ thread_unlock_runq(struct thread_runq *runq, unsigned long flags)
spinlock_unlock_intr_restore(&runq->lock, flags);
}
-#ifdef X15_ENABLE_THREAD_STACK_GUARD
+#ifdef CONFIG_THREAD_STACK_GUARD
#include <machine/pmap.h>
#include <vm/vm_kmem.h>
@@ -1939,7 +1939,7 @@ thread_free_stack(void *stack)
vm_kmem_free(va, (PAGE_SIZE * 2) + stack_size);
}
-#else /* X15_ENABLE_THREAD_STACK_GUARD */
+#else /* CONFIG_THREAD_STACK_GUARD */
static void *
thread_alloc_stack(void)
@@ -1953,7 +1953,7 @@ thread_free_stack(void *stack)
kmem_cache_free(&thread_stack_cache, stack);
}
-#endif /* X15_ENABLE_THREAD_STACK_GUARD */
+#endif /* CONFIG_THREAD_STACK_GUARD */
static void
thread_destroy(struct thread *thread)
@@ -2190,7 +2190,7 @@ thread_setup_runq(struct thread_runq *runq)
thread_setup_idler(runq);
}
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
/*
* This function is meant for debugging only. As a result, it uses a weak
@@ -2266,7 +2266,7 @@ INIT_OP_DEFINE(thread_setup_shell,
INIT_OP_DEP(task_setup, true),
INIT_OP_DEP(thread_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static void __init
thread_setup_common(unsigned int cpu)
@@ -2288,10 +2288,10 @@ thread_setup(void)
kmem_cache_init(&thread_cache, "thread", sizeof(struct thread),
CPU_L1_SIZE, NULL, 0);
-#ifndef X15_ENABLE_THREAD_STACK_GUARD
+#ifndef CONFIG_THREAD_STACK_GUARD
kmem_cache_init(&thread_stack_cache, "thread_stack", TCB_STACK_SIZE,
CPU_DATA_ALIGN, NULL, 0);
-#endif /* X15_ENABLE_THREAD_STACK_GUARD */
+#endif /* CONFIG_THREAD_STACK_GUARD */
cpumap_for_each(&thread_active_runqs, cpu) {
thread_setup_runq(percpu_ptr(thread_runq, cpu));
@@ -2308,7 +2308,7 @@ INIT_OP_DEFINE(thread_setup,
INIT_OP_DEP(task_setup, true),
INIT_OP_DEP(thread_bootstrap, true),
INIT_OP_DEP(turnstile_setup, true),
-#ifdef X15_ENABLE_THREAD_STACK_GUARD
+#ifdef CONFIG_THREAD_STACK_GUARD
INIT_OP_DEP(vm_kmem_setup, true),
INIT_OP_DEP(vm_map_setup, true),
INIT_OP_DEP(vm_page_setup, true),
diff --git a/kern/thread.h b/kern/thread.h
index 164eed79..29c2dfe5 100644
--- a/kern/thread.h
+++ b/kern/thread.h
@@ -43,6 +43,7 @@
#include <kern/init.h>
#include <kern/condition.h>
#include <kern/cpumap.h>
+#include <kern/kernel.h>
#include <kern/macros.h>
#include <kern/spinlock_types.h>
#include <kern/turnstile_types.h>
@@ -72,7 +73,7 @@ struct thread_sched_data {
#include <kern/thread_i.h>
-#define THREAD_KERNEL_PREFIX PACKAGE "_"
+#define THREAD_KERNEL_PREFIX KERNEL_NAME "_"
/*
* Scheduling policies.
diff --git a/kern/work.c b/kern/work.c
index ea3eb1f4..365ca30d 100644
--- a/kern/work.c
+++ b/kern/work.c
@@ -52,7 +52,7 @@
*/
#define WORK_THREADS_RATIO 4
#define WORK_THREADS_THRESHOLD 512
-#define WORK_MAX_THREADS MAX(X15_MAX_CPUS, WORK_THREADS_THRESHOLD)
+#define WORK_MAX_THREADS MAX(CONFIG_MAX_CPUS, WORK_THREADS_THRESHOLD)
/*
* Work pool flags.
diff --git a/kern/xcall.c b/kern/xcall.c
index 1251f28c..5a431b2f 100644
--- a/kern/xcall.c
+++ b/kern/xcall.c
@@ -50,7 +50,7 @@ struct xcall {
* between multiple cross-calls.
*/
struct xcall_cpu_data {
- alignas(CPU_L1_SIZE) struct xcall send_calls[X15_MAX_CPUS];
+ alignas(CPU_L1_SIZE) struct xcall send_calls[CONFIG_MAX_CPUS];
struct xcall *recv_call;
struct spinlock lock;
diff --git a/test/Kconfig b/test/Kconfig
new file mode 100644
index 00000000..7a71f4fb
--- /dev/null
+++ b/test/Kconfig
@@ -0,0 +1,41 @@
+menuconfig TEST_MODULE
+ bool "Test module"
+ default n
+ ---help---
+ Run a test module instead of booting the system.
+
+if TEST_MODULE
+
+choice
+ prompt "Select test module"
+
+config TEST_MODULE_LLSYNC_DEFER
+ bool "llsync_defer"
+
+config TEST_MODULE_MUTEX
+ bool "mutex"
+
+config TEST_MODULE_MUTEX_PI
+ bool "mutex_pi"
+
+config TEST_MODULE_PMAP_UPDATE_MP
+ bool "pmap_update_mp"
+
+config TEST_MODULE_SREF_DIRTY_ZEROES
+ bool "sref_dirty_zeroes"
+
+config TEST_MODULE_SREF_NOREF
+ bool "sref_noref"
+
+config TEST_MODULE_SREF_WEAKREF
+ bool "sref_weakref"
+
+config TEST_MODULE_VM_PAGE_FILL
+ bool "vm_page_fill"
+
+config TEST_MODULE_XCALL
+ bool "xcall"
+
+endchoice
+
+endif
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 00000000..098cecbd
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,9 @@
+x15_SOURCES-$(CONFIG_TEST_MODULE_LLSYNC_DEFER) += test/test_llsync_defer.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_MUTEX) += test/test_mutex.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_MUTEX_PI) += test/test_mutex_pi.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_PMAP_UPDATE_MP) += test/test_pmap_update_mp.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_SREF_DIRTY_ZEROES) += test/test_sref_dirty_zeroes.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_SREF_NOREF) += test/test_sref_noref.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_SREF_WEAKREF) += test/test_sref_weakref.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_VM_PAGE_FILL) += test/test_vm_page_fill.c
+x15_SOURCES-$(CONFIG_TEST_MODULE_XCALL) += test/test_xcall.c
diff --git a/test/test_mutex.c b/test/test_mutex.c
index 9e28c78a..d5cc5d13 100644
--- a/test/test_mutex.c
+++ b/test/test_mutex.c
@@ -151,11 +151,11 @@ test_report_syscnt(struct timer *timer)
{
uint64_t time;
-#ifdef X15_MUTEX_PI
+#ifdef CONFIG_MUTEX_PI
syscnt_info("rtmutex");
-#else /* X15_MUTEX_PI */
+#else /* CONFIG_MUTEX_PI */
syscnt_info("mutex");
-#endif /* X15_MUTEX_PI */
+#endif /* CONFIG_MUTEX_PI */
time = timer_get_time(timer) + clock_ticks_from_ms(TEST_REPORT_INTERVAL);
timer_schedule(timer, time);
diff --git a/tools/kconfig/Makefile b/tools/kconfig/Makefile
index eb814464..11b54644 100644
--- a/tools/kconfig/Makefile
+++ b/tools/kconfig/Makefile
@@ -2,166 +2,86 @@
# Kernel configuration targets
# These targets are used from top-level makefile
-PHONY += xconfig gconfig menuconfig config silentoldconfig update-po-config \
- localmodconfig localyesconfig
+PHONY += xconfig gconfig menuconfig config
-ifdef KBUILD_KCONFIG
-Kconfig := $(KBUILD_KCONFIG)
-else
-Kconfig := Kconfig
-endif
+# We need this, in case the user has it in its environment
+unexport CONFIG_
-ifeq ($(quiet),silent_)
-silent := -s
+ifneq ($(Q),)
+# $(call kconfig_action,<action>,<target>)
+define kconfig_action
+@printf " %-7s %s\n" $(1) $(2)
+@
+endef
endif
-# We need this, in case the user has it in its environment
-unexport CONFIG_
+srctree := $(SRCDIR)
+obj := $(KCONFIG_PATH)
+src := $(obj)
+kecho := echo
+
+# This environment variable is used by the conf tools to locate Kconfig files.
+export srctree
+
+Kconfig := $(srctree)/Kconfig
xconfig: $(obj)/qconf
- $< $(silent) $(Kconfig)
+ $< $(Kconfig)
gconfig: $(obj)/gconf
- $< $(silent) $(Kconfig)
+ $< $(Kconfig)
menuconfig: $(obj)/mconf
- $< $(silent) $(Kconfig)
+ $< $(Kconfig)
config: $(obj)/conf
- $< $(silent) --oldaskconfig $(Kconfig)
+ $< --oldaskconfig $(Kconfig)
nconfig: $(obj)/nconf
- $< $(silent) $(Kconfig)
-
-silentoldconfig: $(obj)/conf
- $(Q)mkdir -p include/config include/generated
- $(Q)test -e include/generated/autoksyms.h || \
- touch include/generated/autoksyms.h
- $< $(silent) --$@ $(Kconfig)
-
-localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
- $(Q)mkdir -p include/config include/generated
- $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
- $(Q)if [ -f .config ]; then \
- cmp -s .tmp.config .config || \
- (mv -f .config .config.old.1; \
- mv -f .tmp.config .config; \
- $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
- mv -f .config.old.1 .config.old) \
- else \
- mv -f .tmp.config .config; \
- $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
- fi
- $(Q)rm -f .tmp.config
-
-# Create new linux.pot file
-# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
-update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
- $(Q)$(kecho) " GEN config.pot"
- $(Q)xgettext --default-domain=linux \
- --add-comments --keyword=_ --keyword=N_ \
- --from-code=UTF-8 \
- --files-from=$(srctree)/scripts/kconfig/POTFILES.in \
- --directory=$(srctree) --directory=$(objtree) \
- --output $(obj)/config.pot
- $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
- $(Q)(for i in `ls $(srctree)/arch/*/Kconfig \
- $(srctree)/arch/*/um/Kconfig`; \
- do \
- $(kecho) " GEN $$i"; \
- $(obj)/kxgettext $$i \
- >> $(obj)/config.pot; \
- done )
- $(Q)$(kecho) " GEN linux.pot"
- $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
- --output $(obj)/linux.pot
- $(Q)rm -f $(obj)/config.pot
+ $< $(Kconfig)
# These targets map 1:1 to the commandline options of 'conf'
-simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
- alldefconfig randconfig listnewconfig olddefconfig
+simple-targets := oldconfig allnoconfig allyesconfig \
+ alldefconfig randconfig listnewconfig
PHONY += $(simple-targets)
$(simple-targets): $(obj)/conf
- $< $(silent) --$@ $(Kconfig)
-
-PHONY += oldnoconfig savedefconfig defconfig
+ $< --$@ $(Kconfig)
-# oldnoconfig is an alias of olddefconfig, because people already are dependent
-# on its behavior (sets new symbols to their default value but not 'n') with the
-# counter-intuitive name.
-oldnoconfig: olddefconfig
+PHONY += savedefconfig defconfig
savedefconfig: $(obj)/conf
- $< $(silent) --$@=defconfig $(Kconfig)
+ $< --$@=defconfig $(Kconfig)
defconfig: $(obj)/conf
-ifeq ($(KBUILD_DEFCONFIG),)
- $< $(silent) --defconfig $(Kconfig)
-else
-ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),)
- @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'"
- $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig)
-else
- @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'"
- $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG)
-endif
-endif
+ @$(kecho) "*** Default configuration is based on '$(KCONFIG_DEFCONFIG)'"
+ $(Q)$< --defconfig=arch/$(ARCH)/configs/$(KCONFIG_DEFCONFIG) $(Kconfig)
%_defconfig: $(obj)/conf
- $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
-
-configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@)
-
-%.config: $(obj)/conf
- $(if $(call configfiles),, $(error No configuration exists for this target on this architecture))
- $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles)
- +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig
-
-PHONY += kvmconfig
-kvmconfig: kvm_guest.config
- @:
-
-PHONY += xenconfig
-xenconfig: xen.config
- @:
-
-PHONY += tinyconfig
-tinyconfig:
- $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
+ $(Q)$< --defconfig=arch/$(ARCH)/configs/$@ $(Kconfig)
# Help text used by make help
help:
- @echo ' config - Update current config utilising a line-oriented program'
- @echo ' nconfig - Update current config utilising a ncurses menu based'
- @echo ' program'
- @echo ' menuconfig - Update current config utilising a menu based program'
- @echo ' xconfig - Update current config utilising a Qt based front-end'
- @echo ' gconfig - Update current config utilising a GTK+ based front-end'
- @echo ' oldconfig - Update current config utilising a provided .config as base'
- @echo ' localmodconfig - Update current config disabling modules not loaded'
- @echo ' localyesconfig - Update current config converting local mods to core'
- @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
- @echo ' defconfig - New config with default from ARCH supplied defconfig'
- @echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
- @echo ' allnoconfig - New config where all options are answered with no'
- @echo ' allyesconfig - New config where all options are accepted with yes'
- @echo ' allmodconfig - New config selecting modules when possible'
- @echo ' alldefconfig - New config with all symbols set to default'
- @echo ' randconfig - New config with random answer to all options'
- @echo ' listnewconfig - List new options'
- @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their'
- @echo ' default value'
- @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
- @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
- @echo ' tinyconfig - Configure the tiniest possible kernel'
+ @echo ' config - Set configuration - line-oriented program'
+ @echo ' nconfig - Set configuration - ncurses menu based program'
+ @echo ' menuconfig - Set configuration - menu based program'
+ @echo ' xconfig - Set configuration - Qt based front-end'
+ @echo ' gconfig - Set configuration - GTK+ based front-end'
+ @echo ' allnoconfig - New configuration - all options disabled'
+ @echo ' allyesconfig - New configuration - all options enabled'
+ @echo ' alldefconfig - New configuration - default values'
+ @echo ' randconfig - New configuration - random values'
+ @echo ' oldconfig - Reuse existing .config for configuration'
+ @echo ' defconfig - Default architecture-specific configuration'
+ @echo ' savedefconfig - Save configuration as ./defconfig (minimal config)'
+ @echo ' listnewconfig - List new options'
# lxdialog stuff
check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
# Use recursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
-HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \
+HOST_EXTRACFLAGS += $(shell $(CONFIG_HOST_SHELL) $(check-lxdialog) -ccflags) \
-DLOCALE
# ===========================================================================
@@ -183,31 +103,51 @@ lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o $(lxdialog)
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
-kxgettext-objs := kxgettext.o zconf.tab.o
qconf-cxxobjs := qconf.o
qconf-objs := zconf.tab.o
gconf-objs := gconf.o zconf.tab.o
-hostprogs-y := conf nconf mconf kxgettext qconf gconf
+hostprogs-y := conf
+
+ifeq ($(MAKECMDGOALS),nconfig)
+ hostprogs-y += nconf
+endif
+
+ifeq ($(MAKECMDGOALS),menuconfig)
+ hostprogs-y += mconf
+endif
+
+ifeq ($(MAKECMDGOALS),xconfig)
+ qconf-target := 1
+endif
+ifeq ($(MAKECMDGOALS),gconfig)
+ gconf-target := 1
+endif
+
+ifeq ($(qconf-target),1)
+ hostprogs-y += qconf
+endif
+
+ifeq ($(gconf-target),1)
+ hostprogs-y += gconf
+endif
clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
clean-files += config.pot linux.pot
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
-PHONY += $(obj)/dochecklxdialog
-$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog
-$(obj)/dochecklxdialog:
- $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
-
-always := dochecklxdialog
+$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/.dochecklxdialog
+$(obj)/.dochecklxdialog:
+ $(Q)$(CONFIG_HOST_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
+ $(Q)touch $@
# Add environment specific flags
-HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
+HOST_EXTRACFLAGS += $(shell $(CONFIG_HOST_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
# generated files seem to need this to find local include files
-HOSTCFLAGS_zconf.lex.o := -I$(src)
-HOSTCFLAGS_zconf.tab.o := -I$(src)
+HOSTCFLAGS_zconf.lex.o := -I$(srctree)/$(src)
+HOSTCFLAGS_zconf.tab.o := -I$(srctree)/$(src)
LEX_PREFIX_zconf := zconf
YACC_PREFIX_zconf := zconf
@@ -219,7 +159,7 @@ HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
-Wno-missing-prototypes
-HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
+HOSTLOADLIBES_mconf = $(shell $(CONFIG_HOST_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
HOSTLOADLIBES_nconf = $(shell \
pkg-config --libs menuw panelw ncursesw 2>/dev/null \
@@ -284,13 +224,60 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
$(obj)/qconf.o: $(obj)/qconf.moc
-quiet_cmd_moc = MOC $@
- cmd_moc = $(KC_QT_MOC) -i $< -o $@
-
$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck
- $(call cmd,moc)
+ $(call kconfig_action,MOC,$@,)$(KC_QT_MOC) -i $< -o $@
# Extract gconf menu items for i18n support
$(obj)/gconf.glade.h: $(obj)/gconf.glade
$(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \
$(obj)/gconf.glade
+
+-include $(obj)/.depend
+$(obj)/.depend: $(wildcard *.h *.c)
+ $(Q)mkdir -p $(@D)
+ $(Q)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > $@ 2>/dev/null || :
+
+__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
+host-csingle := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))))
+host-cmulti := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),\
+ $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))))
+host-cxxmulti := $(addprefix $(obj)/,$(foreach m,$(__hostprogs),\
+ $(if $($(m)-cxxobjs),$(m),$(if $($(m)-objs),))))
+host-cobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-objs))))
+host-cxxobjs := $(addprefix $(obj)/,$(sort $(foreach m,$(__hostprogs),$($(m)-cxxobjs))))
+
+HOST_EXTRACFLAGS += -I$(obj) -DCONFIG_=\"\"
+
+$(host-csingle): %: %.c
+ $(Q)mkdir -p $(@D)
+ $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $< -o $@
+
+$(host-cmulti): %: $(host-cobjs) $(host-cshlib)
+ $(Q)mkdir -p $(@D)
+ $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) $(addprefix $(obj)/,$($(@F)-objs)) $(HOSTLOADLIBES_$(@F)) -o $@
+
+$(host-cxxmulti): %: $(host-cxxobjs) $(host-cobjs) $(host-cshlib)
+ $(Q)mkdir -p $(@D)
+ $(call kconfig_action,CXX,$@)$(HOSTCXX) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) $(addprefix $(obj)/,$($(@F)-objs) $($(@F)-cxxobjs)) $(HOSTLOADLIBES_$(@F)) -o $@
+
+$(obj)/%.o: $(obj)/%.c
+ $(Q)mkdir -p $(@D)
+ $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F)) -c $< -o $@
+
+$(obj)/%.o: $(obj)/%.cc
+ $(Q)mkdir -p $(@D)
+ $(call kconfig_action,CC,$@)$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) $(HOSTCXXFLAGS_$(@F)) -c $< -o $@
+
+$(obj)/%:: $(src)/%_shipped
+ $(Q)mkdir -p $(@D)
+ $(Q)cat $< > $@
+
+clean:
+ $(Q)rm -f $(addprefix $(obj)/,$(clean-files))
+
+distclean: clean
+ $(Q)rm -f $(addprefix $(obj)/,$(lxdialog) $(conf-objs) $(mconf-objs) \
+ $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \
+ conf nconf mconf qconf gconf .depend .dochecklxdialog)
+
+.PHONY: clean distclean $(PHONY)
diff --git a/tools/kconfig/gconf.c b/tools/kconfig/gconf.c
index cfddddb9..ab047aaf 100644
--- a/tools/kconfig/gconf.c
+++ b/tools/kconfig/gconf.c
@@ -1462,7 +1462,7 @@ int main(int ac, char *av[])
/* Determine GUI path */
env = getenv(SRCTREE);
if (env)
- glade_file = g_strconcat(env, "/scripts/kconfig/gconf.glade", NULL);
+ glade_file = g_strconcat(env, "/tools/kconfig/gconf.glade", NULL);
else if (av[0][0] == '/')
glade_file = g_strconcat(av[0], ".glade", NULL);
else
diff --git a/vm/Makefile b/vm/Makefile
new file mode 100644
index 00000000..a42fe244
--- /dev/null
+++ b/vm/Makefile
@@ -0,0 +1,5 @@
+x15_SOURCES-y += \
+ vm/vm_kmem.c \
+ vm/vm_map.c \
+ vm/vm_object.c \
+ vm/vm_page.c
diff --git a/vm/vm_map.c b/vm/vm_map.c
index 713d92f0..c0e9e116 100644
--- a/vm/vm_map.c
+++ b/vm/vm_map.c
@@ -699,7 +699,7 @@ vm_map_init(struct vm_map *map, struct pmap *pmap,
map->pmap = pmap;
}
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
static void
vm_map_shell_info(int argc, char **argv)
@@ -744,7 +744,7 @@ INIT_OP_DEFINE(vm_map_setup_shell,
INIT_OP_DEP(task_setup, true),
INIT_OP_DEP(vm_map_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static int __init
vm_map_bootstrap(void)
diff --git a/vm/vm_page.c b/vm/vm_page.c
index cc6963fc..7f419b97 100644
--- a/vm/vm_page.c
+++ b/vm/vm_page.c
@@ -107,7 +107,7 @@ struct vm_page_free_list {
* Zone of contiguous memory.
*/
struct vm_page_zone {
- struct vm_page_cpu_pool cpu_pools[X15_MAX_CPUS];
+ struct vm_page_cpu_pool cpu_pools[CONFIG_MAX_CPUS];
phys_addr_t start;
phys_addr_t end;
@@ -657,7 +657,7 @@ vm_page_info_common(int (*print_fn)(const char *format, ...))
}
}
-#ifdef X15_ENABLE_SHELL
+#ifdef CONFIG_SHELL
static void
vm_page_info(void)
@@ -691,7 +691,7 @@ INIT_OP_DEFINE(vm_page_setup_shell,
INIT_OP_DEP(shell_setup, true),
INIT_OP_DEP(vm_page_setup, true));
-#endif /* X15_ENABLE_SHELL */
+#endif /* CONFIG_SHELL */
static int __init
vm_page_setup(void)