This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Newlib in Xen/Mini-OS


Mini-OS is a light-weight kernel that can be run by the Xen
hypervisor.  Mini-OS is in the Xen sources, in the directory
extras/mini-os.  Some Mini-OS applications require a more complete C
library than is currently provided by Mini-OS, hence the interest in
Newlib.

To write Mini-OS applications with Newlib, one must build the
components with a cross compiler that supports the target i386-elf.
The application must not perform floating point operations, as the
kernel does not preserve floating point registers, and the
implementation of setjmp and longjmp ignores them.

* Building the Mini-OS library

If the home directory of your cross compiler is ${COMP_HOME}, build
the Mini-OS library with:

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

Defining HAVE_LIBC causes Mini-OS's C library functions to be omitted
so they do not conflict with the ones provided by Newlib.

* Write your program

Place your program in a file called, say, app.c.  You must define
app_main with the following prototype:

int app_main(start_info_t *si);

* Build your program

If the home directory of your Mini-OS sources is ${MINIOS_HOME}, build
your program using the following parameters, taking other parameters
from the Mini-OS Makefile.

OBJS = $(MINIOS_HOME)/x86_32.o app.o newlib.o setjmp_x86_32.o
CROSS_COMPILE = $(COMP_HOME)/bin/
CPPFLAGS = -DHAVE_LIBC -I$(MINIOS_HOME)/include
LDLIBS = -L$(MINIOS_HOME) -lminios -lc -lnosys

Note the inclusion of libnosys.a in ${LDLIBS}.  This library provides
stubs for library calls that will always fail, such as the write
system call.

* Boot your VM.

You can use the domain configuration file that comes with the Mini-OS
sources to create your domain.

John

Attachment: newlib.c
Description: Newlib additions

Attachment: setjmp_x86_32.S
Description: setjmp/longjmp for Mini-OS


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]