WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Allow linking of mini-os with application-specific objec

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Allow linking of mini-os with application-specific object code.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 May 2006 16:54:10 +0000
Delivery-date: Mon, 15 May 2006 10:34:41 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID dc213d745642690b4bbc34af951e57f0d04c2d04
# Parent  cb70d4f8d7182b0d1b5bcee7044f59fbe4dc9839
Allow linking of mini-os with application-specific object code.
From: Jacob Gorm Hansen
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 extras/mini-os/Makefile     |   29 +++++++++++++++++++----------
 extras/mini-os/include/mm.h |    7 ++-----
 extras/mini-os/kernel.c     |   11 ++++++++++-
 extras/mini-os/mm.c         |    1 -
 4 files changed, 31 insertions(+), 17 deletions(-)

diff -r cb70d4f8d718 -r dc213d745642 extras/mini-os/Makefile
--- a/extras/mini-os/Makefile   Mon May 15 07:51:07 2006 +0100
+++ b/extras/mini-os/Makefile   Mon May 15 16:32:09 2006 +0100
@@ -6,18 +6,23 @@ override TARGET_ARCH     := $(XEN_TARGET
 override TARGET_ARCH     := $(XEN_TARGET_ARCH)
 
 # NB. '-Wcast-qual' is nasty, so I omitted it.
-CFLAGS := -fno-builtin -Wall -Werror -Iinclude/ -Wredundant-decls -Wno-format
+CFLAGS := -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format
 CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline
+
+override CPPFLAGS := -Iinclude $(CPPFLAGS)
+ASFLAGS = -D__ASSEMBLY__
+
+LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
 
 ifeq ($(TARGET_ARCH),x86_32)
 CFLAGS += -m32 -march=i686
-LDFLAGS := -m elf_i386
+LDFLAGS += -m elf_i386
 endif
 
 ifeq ($(TARGET_ARCH),x86_64)
 CFLAGS += -m64 -mno-red-zone -fpic -fno-reorder-blocks
 CFLAGS += -fno-asynchronous-unwind-tables
-LDFLAGS := -m elf_x86_64
+LDFLAGS += -m elf_x86_64
 endif
 
 ifeq ($(debug),y)
@@ -28,12 +33,12 @@ endif
 
 TARGET := mini-os
 
-OBJS := $(TARGET_ARCH).o
-OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
+HEAD := $(TARGET_ARCH).o
+OBJS := $(patsubst %.c,%.o,$(wildcard *.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard console/*.c))
-                                                                               
   
+
 HDRS := $(wildcard include/*.h)
 HDRS += $(wildcard include/xen/*.h)
 
@@ -44,21 +49,25 @@ links:
 links:
        [ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
 
-$(TARGET): links $(OBJS)
-       $(LD) -N -T minios-$(TARGET_ARCH).lds $(OBJS) -o $@.elf
+libminios.a: $(OBJS) $(HEAD)
+       ar r libminios.a $(HEAD) $(OBJS)
+
+$(TARGET): links libminios.a $(HEAD)
+       $(LD) $(LDFLAGS) $(HEAD) -L. -lminios -o $@.elf
        gzip -f -9 -c $@.elf >$@.gz
 
 .PHONY: clean
 clean:
        find . -type f -name '*.o' | xargs rm -f
        rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
+       rm -f libminios.a
        find . -type l | xargs rm -f
 
 %.o: %.c $(HDRS) Makefile
-       $(CC) $(CFLAGS) -c $< -o $@
+       $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
 
 %.o: %.S $(HDRS) Makefile
-       $(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
+       $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@
 
 define all_sources
      ( find . -follow -name SCCS -prune -o -name '*.[chS]' -print )
diff -r cb70d4f8d718 -r dc213d745642 extras/mini-os/include/mm.h
--- a/extras/mini-os/include/mm.h       Mon May 15 07:51:07 2006 +0100
+++ b/extras/mini-os/include/mm.h       Mon May 15 16:32:09 2006 +0100
@@ -130,6 +130,7 @@
 #define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
 
 extern unsigned long *phys_to_machine_mapping;
+extern char _text, _etext, _edata, _end;
 #define pfn_to_mfn(_pfn) (phys_to_machine_mapping[(_pfn)])
 static __inline__ unsigned long phys_to_machine(unsigned long phys)
 {
@@ -147,11 +148,7 @@ static __inline__ unsigned long machine_
     return phys;
 }
 
-#if defined(__x86_64__)
-#define VIRT_START              0xFFFFFFFF80000000UL
-#elif defined(__i386__)
-#define VIRT_START              0xC0000000UL
-#endif
+#define VIRT_START                 ((unsigned long)&_text)
 
 #define to_phys(x)                 ((unsigned long)(x)-VIRT_START)
 #define to_virt(x)                 ((void *)((unsigned long)(x)+VIRT_START))
diff -r cb70d4f8d718 -r dc213d745642 extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c   Mon May 15 07:51:07 2006 +0100
+++ b/extras/mini-os/kernel.c   Mon May 15 16:32:09 2006 +0100
@@ -106,6 +106,12 @@ void setup_xen_features(void)
     }
 }
 
+/* This should be overridden by the application we are linked against. */
+__attribute__((weak)) int app_main(start_info_t *si)
+{
+    printk("Dummy main: start_info=%p\n", si);
+    return 0;
+}
 
 /*
  * INITIAL C ENTRY POINT.
@@ -165,11 +171,14 @@ void start_kernel(start_info_t *si)
     /* Init the console driver. */
     init_console();
  
-   /* Init scheduler. */
+    /* Init scheduler. */
     init_sched();
  
     /* Init XenBus from a separate thread */
     create_thread("init_xs", init_xs, NULL);
+
+    /* Call (possibly overridden) app_main() */
+    app_main(&start_info);
 
     /* Everything initialised, start idle thread */
     run_idle_thread();
diff -r cb70d4f8d718 -r dc213d745642 extras/mini-os/mm.c
--- a/extras/mini-os/mm.c       Mon May 15 07:51:07 2006 +0100
+++ b/extras/mini-os/mm.c       Mon May 15 16:32:09 2006 +0100
@@ -50,7 +50,6 @@
 
 unsigned long *phys_to_machine_mapping;
 extern char *stack;
-extern char _text, _etext, _edata, _end;
 extern void page_walk(unsigned long virt_addr);
 
 /*********************

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Allow linking of mini-os with application-specific object code., Xen patchbot-unstable <=