[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 10/23] mini-os: create app-specific configuration



Instead of using CONFIG_QEMU and CONFIG_GRUB to enable or disable minios
code, create CONFIG_ items for features and use application-specific
configuration files to enable or disable the features.

The configuration flags are currently added to the compiler command
line; as the number of flags grows this may need to move to a header.

Signed-off-by: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
---
 extras/mini-os/Makefile  |   52 ++++++++++++++++++++++++++++++++++++++++-----
 extras/mini-os/main.c    |   16 +++++++-------
 extras/mini-os/minios.mk |    4 +-
 stubdom/Makefile         |    8 +++---
 stubdom/grub/minios.cfg  |    2 +
 stubdom/ioemu-minios.cfg |    1 +
 6 files changed, 63 insertions(+), 20 deletions(-)
 create mode 100644 stubdom/c/minios.cfg
 create mode 100644 stubdom/caml/minios.cfg
 create mode 100644 stubdom/grub/minios.cfg
 create mode 100644 stubdom/ioemu-minios.cfg

diff --git a/extras/mini-os/Makefile b/extras/mini-os/Makefile
index c2ee062..be38170 100644
--- a/extras/mini-os/Makefile
+++ b/extras/mini-os/Makefile
@@ -8,10 +8,25 @@ export XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/Config.mk
 OBJ_DIR ?= $(CURDIR)
 
-ifneq ($(stubdom),y)
+ifeq ($(MINIOS_CONFIG),)
 include Config.mk
+else
+EXTRA_DEPS += $(MINIOS_CONFIG)
+include $(MINIOS_CONFIG)
 endif
 
+# Configuration defaults
+CONFIG_START_NETWORK ?= y
+CONFIG_SPARSE_BSS ?= y
+CONFIG_QEMU_XS_ARGS ?= n
+
+# Export config items as compiler directives
+flags-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK
+flags-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS
+flags-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS
+
+DEF_CFLAGS += $(flags-y)
+
 # Include common mini-os makerules.
 include minios.mk
 
@@ -34,13 +49,38 @@ TARGET := mini-os
 # Subdirectories common to mini-os
 SUBDIRS := lib xenbus console
 
+src-y += blkfront.c
+src-y += daytime.c
+src-y += events.c
+src-y += fbfront.c
+src-y += gntmap.c
+src-y += gnttab.c
+src-y += hypervisor.c
+src-y += kernel.c
+src-y += lock.c
+src-y += main.c
+src-y += mm.c
+src-y += netfront.c
+src-y += pcifront.c
+src-y += sched.c
+
+src-y += lib/ctype.c
+src-y += lib/math.c
+src-y += lib/printf.c
+src-y += lib/stack_chk_fail.c
+src-y += lib/string.c
+src-y += lib/sys.c
+src-y += lib/xmalloc.c
+src-y += lib/xs.c
+
+src-y += xenbus/xenbus.c
+
+src-y += console/console.c
+src-y += console/xencons_ring.c
+
 # The common mini-os objects to build.
 APP_OBJS :=
-OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard *.c))
-OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard lib/*.c))
-OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard xenbus/*.c))
-OBJS += $(patsubst %.c,$(OBJ_DIR)/%.o,$(wildcard console/*.c))
-
+OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(src-y))
 
 .PHONY: default
 default: $(OBJ_DIR)/$(TARGET)
diff --git a/extras/mini-os/main.c b/extras/mini-os/main.c
index b95b889..aeda548 100644
--- a/extras/mini-os/main.c
+++ b/extras/mini-os/main.c
@@ -43,13 +43,13 @@ extern char __app_bss_start, __app_bss_end;
 static void call_main(void *p)
 {
     char *c, quote;
-#ifdef CONFIG_QEMU
+#ifdef CONFIG_QEMU_XS_ARGS
     char *domargs, *msg;
 #endif
     int argc;
     char **argv;
     char *envp[] = { NULL };
-#ifdef CONFIG_QEMU
+#ifdef CONFIG_QEMU_XS_ARGS
     char *vm;
     char path[128];
     int domid;
@@ -60,15 +60,15 @@ static void call_main(void *p)
      * crashing. */
     //sleep(1);
 
-#ifndef CONFIG_GRUB
+#ifdef CONFIG_SPARSE_BSS
     sparse((unsigned long) &__app_bss_start, &__app_bss_end - 
&__app_bss_start);
-#if defined(HAVE_LWIP) && !defined(CONFIG_QEMU)
-    start_networking();
 #endif
+#if defined(HAVE_LWIP) && defined(CONFIG_START_NETWORK)
+    start_networking();
 #endif
     create_thread("pcifront", pcifront_watches, NULL);
 
-#ifdef CONFIG_QEMU
+#ifdef CONFIG_QEMU_XS_ARGS
     /* Fetch argc, argv from XenStore */
     domid = xenbus_read_integer("target");
     if (domid == -1) {
@@ -132,7 +132,7 @@ static void call_main(void *p)
 #define PARSE_ARGS_STORE(ARGS) PARSE_ARGS(ARGS, argv[argc++] = c, memmove(c, c 
+ 1, strlen(c + 1) + 1), *c++ = 0)
 
     PARSE_ARGS_COUNT((char*)start_info.cmd_line);
-#ifdef CONFIG_QEMU
+#ifdef CONFIG_QEMU_XS_ARGS
     PARSE_ARGS_COUNT(domargs);
 #endif
 
@@ -141,7 +141,7 @@ static void call_main(void *p)
     argc = 1;
 
     PARSE_ARGS_STORE((char*)start_info.cmd_line)
-#ifdef CONFIG_QEMU
+#ifdef CONFIG_QEMU_XS_ARGS
     PARSE_ARGS_STORE(domargs)
 #endif
 
diff --git a/extras/mini-os/minios.mk b/extras/mini-os/minios.mk
index 698648a..48ed768 100644
--- a/extras/mini-os/minios.mk
+++ b/extras/mini-os/minios.mk
@@ -39,8 +39,8 @@ LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS)
 
 # Special build dependencies.
 # Rebuild all after touching this/these file(s)
-EXTRA_DEPS = $(MINI-OS_ROOT)/minios.mk \
-               $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk
+EXTRA_DEPS += $(MINI-OS_ROOT)/minios.mk
+EXTRA_DEPS += $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk
 
 # Find all header files for checking dependencies.
 HDRS := $(wildcard $(MINI-OS_ROOT)/include/*.h)
diff --git a/stubdom/Makefile b/stubdom/Makefile
index e9dbf02..d4da2bb 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -341,19 +341,19 @@ grub: grub-upstream $(CROSS_ROOT)
 .PHONY: ioemu-stubdom
 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a 
$(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
 ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc 
ioemu
-       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU 
$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) 
OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) 
APP_OBJS="$(APP_OBJS)"
+       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" 
DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/ioemu-minios.cfg" 
$(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(APP_OBJS)"
 
 .PHONY: caml-stubdom
 caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc 
cross-ocaml caml
-       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML 
$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) 
OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) 
APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o 
$(CAMLLIB)/libasmrun.a"
+       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" 
DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/caml/minios.cfg" 
$(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(CURDIR)/caml/main-caml.o 
$(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
 
 .PHONY: c-stubdom
 c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
-       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C 
$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) 
OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) 
APP_OBJS=$(CURDIR)/c/main.a
+       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" 
DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/c/minios.cfg" 
$(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/c/main.a
 
 .PHONY: pv-grub
 pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
-       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB 
$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) 
OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
+       DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" 
DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/grub/minios.cfg" 
$(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< 
APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
 
 #########
 # install
diff --git a/stubdom/c/minios.cfg b/stubdom/c/minios.cfg
new file mode 100644
index 0000000..e69de29
diff --git a/stubdom/caml/minios.cfg b/stubdom/caml/minios.cfg
new file mode 100644
index 0000000..e69de29
diff --git a/stubdom/grub/minios.cfg b/stubdom/grub/minios.cfg
new file mode 100644
index 0000000..40cfa68
--- /dev/null
+++ b/stubdom/grub/minios.cfg
@@ -0,0 +1,2 @@
+CONFIG_START_NETWORK=n
+CONFIG_SPARSE_BSS=n
diff --git a/stubdom/ioemu-minios.cfg b/stubdom/ioemu-minios.cfg
new file mode 100644
index 0000000..7ea1d2f
--- /dev/null
+++ b/stubdom/ioemu-minios.cfg
@@ -0,0 +1 @@
+CONFIG_QEMU_XS_ARGS=y
-- 
1.7.7.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.