]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
inmates: Refactor folder structure
authorJan Kiszka <jan.kiszka@siemens.com>
Wed, 16 Jul 2014 11:05:42 +0000 (13:05 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Mon, 21 Jul 2014 06:53:05 +0000 (08:53 +0200)
Move common code into inmates/lib and showcases into a inmates/demos to
prepare for a reusable and extensible inmates framework. Also split
along architecture dependencies, we will get code for non-x86 as well
one day.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
12 files changed:
inmates/Makefile
inmates/demos/arm/Makefile [new file with mode: 0644]
inmates/demos/x86/Makefile [new file with mode: 0644]
inmates/demos/x86/apic-demo.c [moved from inmates/apic-demo.c with 100% similarity]
inmates/demos/x86/tiny-demo.c [moved from inmates/tiny-demo.c with 100% similarity]
inmates/lib/x86/Makefile.lib [new file with mode: 0644]
inmates/lib/x86/header-32.S [moved from inmates/header-32.S with 100% similarity]
inmates/lib/x86/header.S [moved from inmates/header.S with 100% similarity]
inmates/lib/x86/inmate.h [moved from inmates/inmate.h with 100% similarity]
inmates/lib/x86/inmate.lds [moved from inmates/inmate.lds with 100% similarity]
inmates/lib/x86/pm-timer.c [moved from inmates/pm-timer.c with 100% similarity]
inmates/lib/x86/printk.c [moved from inmates/printk.c with 96% similarity]

index 98df5bfc88138567f681eb2db597ecb248454eaa..cf1d124f8bed777339cc7bd8852f66018821c860 100644 (file)
 # the COPYING file in the top-level directory.
 #
 
-LINUXINCLUDE := -I$(src)
+INMATES_LIB = $(src)/lib/$(SRCARCH)
+export INMATES_LIB
+
+INCLUDES := -I$(INMATES_LIB) \
+           -I$(src)/../hypervisor/arch/$(SRCARCH)/include \
+           -I$(src)/../hypervisor/include
+
+LINUXINCLUDE  :=
+KBUILD_AFLAGS += $(INCLUDES)
 KBUILD_CFLAGS := -g -Os -Wall -Wstrict-prototypes -Wtype-limits \
                 -Wmissing-declarations -Wmissing-prototypes \
                 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
-                -fno-common -fno-stack-protector -I. \
-                -I$(src)/../hypervisor/arch/$(SRCARCH)/include \
-                -I$(src)/../hypervisor/include
+                -fno-common -fno-stack-protector $(INCLUDES)
 ifneq ($(wildcard $(src)/../hypervisor/include/jailhouse/config.h),)
 KBUILD_CFLAGS += -include $(src)/../hypervisor/include/jailhouse/config.h
 endif
@@ -24,39 +30,4 @@ endif
 OBJCOPYFLAGS := -O binary
 LDFLAGS += -T
 
-
-ifeq ($(SRCARCH), x86)
-
-KBUILD_CFLAGS += -m64
-
-INMATES := tiny-demo.bin apic-demo.bin
-
-AFLAGS_header-32.o := -m32
-CFLAGS_printk-32.o := -m32
-
-$(obj)/printk-32.o: $(obj)/printk.c
-       $(call if_changed_rule,cc_o_c)
-
-endif
-
-tiny-demo-y := tiny-demo.o header.o printk.o pm-timer.o
-
-apic-demo-y := apic-demo.o header.o printk.o pm-timer.o
-
-
-always := $(INMATES)
-
-# $(NAME-y) NAME-linked.o NAME.bin
-targets += $(foreach t,$(INMATES:.bin=-y),$($t)) $(INMATES:.bin=-linked.o) \
-               $(INMATES)
-
-# prevent deleting intermediate files which would cause rebuilds
-.SECONDARY: $(addprefix $(obj)/,$(targets))
-
-# obj/NAME-linked.o: ... obj/$(NAME-y)
-.SECONDEXPANSION:
-$(obj)/%-linked.o: $(src)/inmate.lds $$(addprefix $$(obj)/,$$($$*-y))
-       $(call if_changed,ld)
-
-$(obj)/%.bin: $(obj)/%-linked.o
-       $(call if_changed,objcopy)
+subdir-y := demos/$(SRCARCH)
diff --git a/inmates/demos/arm/Makefile b/inmates/demos/arm/Makefile
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/inmates/demos/x86/Makefile b/inmates/demos/x86/Makefile
new file mode 100644 (file)
index 0000000..4cae9ee
--- /dev/null
@@ -0,0 +1,25 @@
+#
+# Jailhouse, a Linux-based partitioning hypervisor
+#
+# Copyright (c) Siemens AG, 2013, 2014
+#
+# Authors:
+#  Jan Kiszka <jan.kiszka@siemens.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+include $(INMATES_LIB)/Makefile.lib
+
+LIBDIR := ../../lib/x86
+
+INMATES := tiny-demo.bin apic-demo.bin
+
+tiny-demo-y := tiny-demo.o \
+       $(LIBDIR)/header.o $(LIBDIR)/printk.o $(LIBDIR)/pm-timer.o
+
+apic-demo-y := apic-demo.o \
+       $(LIBDIR)/header.o $(LIBDIR)/printk.o $(LIBDIR)/pm-timer.o
+
+$(eval $(call DECLARE_TARGETS,$(INMATES)))
diff --git a/inmates/lib/x86/Makefile.lib b/inmates/lib/x86/Makefile.lib
new file mode 100644 (file)
index 0000000..6088f97
--- /dev/null
@@ -0,0 +1,44 @@
+#
+# Jailhouse, a Linux-based partitioning hypervisor
+#
+# Copyright (c) Siemens AG, 2013, 2014
+#
+# Authors:
+#  Jan Kiszka <jan.kiszka@siemens.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+KBUILD_CFLAGS += -m64
+
+define DECLARE_TARGETS =
+ _TARGETS = $(1)
+ always := $$(_TARGETS)
+ # $(NAME-y) NAME-linked.o NAME.bin
+ targets += $$(foreach t,$$(_TARGETS:.bin=-y),$$($$t)) \
+            $$(_TARGETS:.bin=-linked.o) $$(_TARGETS)
+endef
+
+# prevent deleting intermediate files which would cause rebuilds
+.SECONDARY: $(addprefix $(obj)/,$(targets))
+
+# obj/NAME-linked.o: ... obj/$(NAME-y)
+.SECONDEXPANSION:
+$(obj)/%-linked.o: $(INMATES_LIB)/inmate.lds $$(addprefix $$(obj)/,$$($$*-y))
+       $(call if_changed,ld)
+
+$(obj)/%.bin: $(obj)/%-linked.o
+       $(call if_changed,objcopy)
+
+# 32-bit (i386) support
+define DECLARE_32_BIT =
+ CFLAGS_$(1).o := -m32
+ LDFLAGS_$(1)-linked.o := /dev/null -m elf_i386 -T
+endef
+
+AFLAGS_header-32.o := -m32
+
+$(obj)/%-32.o: c_flags += -m32
+$(obj)/%-32.o: $(obj)/%.c
+       $(call if_changed_rule,cc_o_c)
similarity index 100%
rename from inmates/header.S
rename to inmates/lib/x86/header.S
similarity index 100%
rename from inmates/inmate.h
rename to inmates/lib/x86/inmate.h
similarity index 96%
rename from inmates/printk.c
rename to inmates/lib/x86/printk.c
index 0264725a1b2ed42e2dd1e151152b3c688f7eeebb..4358476124d4e997e6ff9172fecd32d2774e8028 100644 (file)
@@ -39,7 +39,7 @@ static void uart_write(const char *msg)
 }
 
 #define console_write(msg)     uart_write(msg)
-#include "../hypervisor/printk-core.c"
+#include "../../../hypervisor/printk-core.c"
 
 void printk(const char *fmt, ...)
 {