From: "Jacob Gorm Hansen" Subject: Re: [PATCH] Integrating applications into Mini-OS Date: Mon, 15 May 2006 16:40:06 +0200 Message-ID: References: <1147697197.11888.12.camel@localhost.localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_56174_25697771.1147704006836" Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "John D. Ramsdell" Cc: xen-devel@lists.xensource.com, Ian Campbell List-Id: xen-devel@lists.xenproject.org ------=_Part_56174_25697771.1147704006836 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 15 May 2006 09:57:16 -0400, John D. Ramsdell wrote: > I didn't want to say this on the list, but another feature about the > patch I submitted is I cleaned up various problems with the Makefile. > It adds CPPFLAGS and ASFLAGS, for example, and its use of LDFLAGS is > broken. Please apply my patch to the base Makefile, and then make > your changes. Submit the combined patch to the list. Let's use this > opportunity to fix many problems at once. Gregor will appreciate a > well thought out change. New version incorporating most of your changes to the Makefile attached. Jacob ------=_Part_56174_25697771.1147704006836 Content-Type: application/octet-stream; name=miniosappsupport-unstable Content-Transfer-Encoding: 7bit X-Attachment-Id: f_en8xbjf8 Content-Disposition: attachment; filename="miniosappsupport-unstable" diff -r cb70d4f8d718 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:38:40 2006 +0200 @@ -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 := $(patsubst %.S,%.o,$(wildcard *$(TARGET_ARCH).S)) +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 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:38:40 2006 +0200 @@ -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 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:38:40 2006 +0200 @@ -110,6 +110,7 @@ void setup_xen_features(void) /* * INITIAL C ENTRY POINT. */ +extern int app_main(start_info_t *); void start_kernel(start_info_t *si) { static char hello[] = "Bootstrapping...\n"; @@ -171,6 +172,10 @@ void start_kernel(start_info_t *si) /* Init XenBus from a separate thread */ create_thread("init_xs", init_xs, NULL); + /* Call (possibly overridden) main() */ + + app_main(&start_info); + /* Everything initialised, start idle thread */ run_idle_thread(); } diff -r cb70d4f8d718 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:38:40 2006 +0200 @@ -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); /********************* diff -r cb70d4f8d718 extras/mini-os/dummymain.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extras/mini-os/dummymain.c Mon May 15 16:38:40 2006 +0200 @@ -0,0 +1,8 @@ +#include +#include + +__attribute__((weak)) int app_main(void) +{ + printk("using dummy main.\n"); + return 0; +} ------=_Part_56174_25697771.1147704006836 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ------=_Part_56174_25697771.1147704006836--