From: "Jacob Gorm Hansen" Subject: Re: [PATCH] Integrating applications into Mini-OS Date: Mon, 15 May 2006 14:18:54 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_53706_19097706.1147695534234" 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 List-Id: xen-devel@lists.xenproject.org ------=_Part_53706_19097706.1147695534234 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 11 May 2006 12:34:49 -0400, John D. Ramsdell wrote: > I'd like to make it so that there is no need to modify any Mini-OS > source files when extending it with an application. All that is > required is a change to Makefile, and a small change to kernel.c, > printf.c, and string.c. I have enclosed the patch. > > With this patch, one could write an application in a file called, say, > app.c, and add it to the Mini-OS directory along with newlib.c and > setjmp_x86_32.S, the two files I use to adapt newlib to the Mini-OS > environment. One would compile and link it with newlib, with the > command: hi, I think it would be more elegant to link the mini-os C files as a 'libminios.a' lib, and then you can replace main() with your own by linking libminios.a from a separate Makefile somewhere else in you tree. I have attached a small patch to mini-os which changes the mini-os Makefile and adds a dummy main function which you can override by linking with your own main() first, as in: OBJS :=3D mymain.o myapp: $(OBJS) $(LD) -N -T myapp.lds ../mini-os/x86_32.o $(OBJS) -o myapp.elf -lminios -L../mini-os regards, Jacob ------=_Part_53706_19097706.1147695534234 Content-Type: application/octet-stream; name=miniosappsupport Content-Transfer-Encoding: 7bit X-Attachment-Id: f_en8s3et2 Content-Disposition: attachment; filename="miniosappsupport" diff -r 61d87e0b0ea7 extras/mini-os/Makefile --- a/extras/mini-os/Makefile Sun May 14 16:33:10 2006 +0200 +++ b/extras/mini-os/Makefile Mon May 15 14:08:46 2006 +0200 @@ -28,7 +28,7 @@ endif TARGET := mini-os -OBJS := $(TARGET_ARCH).o +HEAD := $(TARGET_ARCH).o OBJS += $(patsubst %.c,%.o,$(wildcard *.c)) OBJS += $(patsubst %.c,%.o,$(wildcard lib/*.c)) OBJS += $(patsubst %.c,%.o,$(wildcard xenbus/*.c)) @@ -42,13 +42,17 @@ 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) + ar r libminios.a $(HEAD) $(OBJS) + +$(TARGET): links libminios.a $(HEAD) + $(LD) -N -T minios-$(TARGET_ARCH).lds $(HEAD) -L. -lminios -o $@.elf gzip -f -9 -c $@.elf >$@.gz 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 diff -r 61d87e0b0ea7 extras/mini-os/kernel.c --- a/extras/mini-os/kernel.c Sun May 14 16:33:10 2006 +0200 +++ b/extras/mini-os/kernel.c Mon May 15 14:08:46 2006 +0200 @@ -88,6 +88,7 @@ static void init_xs(void *ign) /* * INITIAL C ENTRY POINT. */ +extern int main(void); void start_kernel(start_info_t *si) { static char hello[] = "Bootstrapping...\n"; @@ -146,6 +147,8 @@ void start_kernel(start_info_t *si) /* Init XenBus from a separate thread */ create_thread("init_xs", init_xs, NULL); + + main(); /* Everything initialised, start idle thread */ run_idle_thread(); diff -r 61d87e0b0ea7 extras/mini-os/dummymain.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extras/mini-os/dummymain.c Mon May 15 14:08:46 2006 +0200 @@ -0,0 +1,8 @@ +#include +#include + +int main(void) +{ + printk("using dummy main.\n"); + return 0; +} ------=_Part_53706_19097706.1147695534234 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_53706_19097706.1147695534234--