Skip to content

Commit

Permalink
Integrate Mini-OS build with mirage-xen
Browse files Browse the repository at this point in the history
Instead of installing the various individual object files to ocamlfind,
we now produce a libminios.a with the core kernel.

libminios.a is built using make and the original (almost unmodified)
Mini-OS build system, rather then with ocamlbuild.

The actual OCaml main is missing, so running one of these images just
produces the Mini-OS self-test output.
  • Loading branch information
talex5 committed May 13, 2014
1 parent a1f37dc commit 53e2675
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
1 change: 1 addition & 0 deletions cmd
Expand Up @@ -54,6 +54,7 @@ configure() {
# invoke native code and byte code compiler targets
compile() {
# build bytecode files and C bindings always
make -C runtime/kernel libminios.a
${OCAMLBUILD} ${OCAMLBUILD_FLAGS} ${NAME}.all
}

Expand Down
2 changes: 1 addition & 1 deletion xen/Makefile
Expand Up @@ -2,7 +2,7 @@

OCAML_VERSION=$(shell readlink runtime/ocaml)

EXTRA=runtime/dietlibc/libdiet.a runtime/libm/libm.a runtime/kernel/libxen.a runtime/kernel/libxencaml.a runtime/$(OCAML_VERSION)/libocaml.a runtime/kernel/x86_64.o runtime/kernel/longjmp.o runtime/kernel/mirage-x86_64.lds
EXTRA=runtime/dietlibc/libdiet.a runtime/libm/libm.a runtime/kernel/libminios.a runtime/$(OCAML_VERSION)/libocaml.a runtime/kernel/arch/x86/minios-x86_64.lds

OCAMLFIND ?= ocamlfind

Expand Down
11 changes: 9 additions & 2 deletions xen/runtime/kernel/Config.mk
@@ -1,6 +1,13 @@
# Set mini-os root path, used in mini-os.mk.
MINI-OS_ROOT=$(XEN_ROOT)/extras/mini-os
export MINI-OS_ROOT

OBJCOPY = $(CROSS_COMPILE)objcopy

XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \
-e s/i86pc/x86_32/ -e s/amd64/x86_64/ \
-e s/armv7.*/arm32/ -e s/armv8.*/arm64/ \
-e s/aarch64/arm64/)

XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH)

libc = $(stubdom)

Expand Down
18 changes: 6 additions & 12 deletions xen/runtime/kernel/Makefile
Expand Up @@ -4,8 +4,9 @@
# Makefile and a arch.mk.
#

export XEN_ROOT = $(CURDIR)/../..
include $(XEN_ROOT)/Config.mk
MINI-OS_ROOT=$(CURDIR)
export MINI-OS_ROOT

OBJ_DIR ?= $(CURDIR)

ifeq ($(MINIOS_CONFIG),)
Expand Down Expand Up @@ -140,14 +141,6 @@ $(ARCH_LINKS):
$(arch_links)
endif

include/mini-os/list.h: $(XEN_ROOT)/tools/include/xen-external/bsd-sys-queue-h-seddery $(XEN_ROOT)/tools/include/xen-external/bsd-sys-queue.h
perl $^ --prefix=minios >$@.new
$(call move-if-changed,$@.new,$@)

.PHONY: links
links: include/mini-os/list.h $(ARCH_LINKS)
[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen

.PHONY: arch_lib
arch_lib:
$(MAKE) --directory=$(TARGET_ARCH_DIR) OBJ_DIR=$(OBJ_DIR)/$(TARGET_ARCH_DIR) || exit 1;
Expand Down Expand Up @@ -202,6 +195,9 @@ else
gzip -f -9 -c $@ >$@.gz
endif

libminios.a: $(HEAD_OBJ) $(APP_O) $(OBJS) arch_lib
ar rcs $@ $(HEAD_OBJ) $(APP_O) $(OBJS) $(wildcard $(OBJ_DIR)/$(TARGET_ARCH_DIR)/*.o)

.PHONY: clean arch_clean

arch_clean:
Expand All @@ -211,9 +207,7 @@ clean: arch_clean
for dir in $(addprefix $(OBJ_DIR)/,$(SUBDIRS)); do \
rm -f $$dir/*.o; \
done
rm -f include/mini-os/list.h
rm -f $(OBJ_DIR)/*.o *~ $(OBJ_DIR)/core $(OBJ_DIR)/$(TARGET).elf $(OBJ_DIR)/$(TARGET).raw $(OBJ_DIR)/$(TARGET) $(OBJ_DIR)/$(TARGET).gz
find . $(OBJ_DIR) -type l | xargs rm -f
$(RM) $(OBJ_DIR)/lwip.a $(LWO)
rm -f tags TAGS

Expand Down
1 change: 1 addition & 0 deletions xen/runtime/kernel/_tags
@@ -0,0 +1 @@
true: not_hygienic
5 changes: 3 additions & 2 deletions xen/runtime/kernel/arch/x86/Makefile
Expand Up @@ -3,8 +3,9 @@
# It's is used for x86_32, x86_32y and x86_64
#

XEN_ROOT = $(CURDIR)/../../../..
include $(XEN_ROOT)/Config.mk
MINI-OS_ROOT=$(CURDIR)/../..
export MINI-OS_ROOT

include ../../Config.mk

# include arch.mk has to be before mini-os.mk!
Expand Down
1 change: 1 addition & 0 deletions xen/runtime/kernel/include/xen

0 comments on commit 53e2675

Please sign in to comment.