Skip to contentSkip to conversation

Allow use of a C library in Mini-OS

PATCH New John D. Ramsdell 1 participant 1 message May 19, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): E1Fh7Rx-00087F-4v@host-192-168-0-1-bcn-london

#1 lore raw

PATCH 1/1 Allow use of a C library in Mini-OS

I noticed many improvements have been made to Mini-OS, and one can now easily integrate an application into Mini-OS as long as the application does not depend on a C library. My thanks go to those responsible.

I'd like to make it so that the following command builds libminios.a using a cross-compiler that provides a full C library.

$ $PATH=${COMP_HOME}/bin:$PATH make CPPFLAGS=-DHAVE_LIBC libminios.a

The enclosed patch makes small changes to three files. The Makefile is changed so that the libminios.a target depends on the links target, and lib/printf.c and lib/string.c are changed so their content is omitted when HAVE_LIBC is defined.

John

Only in xen-unstable/extras/mini-os/console: console.o Only in xen-unstable/extras/mini-os/console: xencons_ring.o Only in xen-unstable/extras/mini-os: events.o
Only in xen-unstable/extras/mini-os: hypervisor.o Only in xen-unstable/extras/mini-os/include: xen Only in xen-unstable/extras/mini-os: kernel.o
Only in xen-unstable/extras/mini-os/lib: math.o

extras/mini-os/lib/printf.c +3 -1
diff -ur oxen-unstable/extras/mini-os/lib/printf.c xen-unstable/extras/mini-os/lib/printf.c
@@ -54,6 +54,8 @@
  * $FreeBSD: src/sys/libkern/divdi3.c,v 1.6 1999/08/28 00:46:31 peter Exp $
  */
 
+#if !defined HAVE_LIBC
+
 #include <os.h>
 #include <types.h>
 #include <hypervisor.h>
@@ -789,4 +791,4 @@
 	return i;
 }
 
-
+#endif

Only in xen-unstable/extras/mini-os/lib: printf.c~ Only in xen-unstable/extras/mini-os/lib: printf.o

extras/mini-os/lib/string.c +4 -0
diff -ur oxen-unstable/extras/mini-os/lib/string.c xen-unstable/extras/mini-os/lib/string.c
@@ -18,6 +18,8 @@
  ****************************************************************************
  */
 
+#if !defined HAVE_LIBC
+
 #include <os.h>
 #include <types.h>
 #include <lib.h>
@@ -153,3 +155,5 @@
         }
         return NULL;
 }
+
+#endif

Only in xen-unstable/extras/mini-os/lib: string.c~ Only in xen-unstable/extras/mini-os/lib: string.o Only in xen-unstable/extras/mini-os/lib: xmalloc.o Only in xen-unstable/extras/mini-os: libminios.a

extras/mini-os/Makefile +3 -2
diff -ur oxen-unstable/extras/mini-os/Makefile xen-unstable/extras/mini-os/Makefile
@@ -12,6 +12,7 @@
 override CPPFLAGS := -Iinclude $(CPPFLAGS)
 ASFLAGS = -D__ASSEMBLY__
 
+LDLIBS =  -L. -lminios
 LDFLAGS := -N -T minios-$(TARGET_ARCH).lds
 
 ifeq ($(TARGET_ARCH),x86_32)
@@ -49,11 +50,11 @@
 links:
 	[ -e include/xen ] || ln -sf ../../../xen/include/public include/xen
 
-libminios.a: $(OBJS) $(HEAD)
+libminios.a: links $(OBJS) $(HEAD)
 	ar r libminios.a $(HEAD) $(OBJS)
 
 $(TARGET): links libminios.a $(HEAD)
-	$(LD) $(LDFLAGS) $(HEAD) -L. -lminios -o [email protected]
+	$(LD) $(LDFLAGS) $(HEAD) $(LDLIBS) -o [email protected]
 	gzip -f -9 -c [email protected] >[email protected]
 
 .PHONY: clean

Only in xen-unstable/extras/mini-os: mm.o Only in xen-unstable/extras/mini-os: sched.o Only in xen-unstable/extras/mini-os: time.o Only in xen-unstable/extras/mini-os: traps.o Only in xen-unstable/extras/mini-os: x86_32.o Only in xen-unstable/extras/mini-os/xenbus: xenbus.o

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel