Using Mini-OS with GNU cross development chain and Red Hat Newlib
We have been doing some experiments using Mini-OS together with a GNU cross development toolchain to allow small applications to be layered on top of Red Hat Newlib and Mini-OS. The use of Red Hat Newlib and Mini-OS was inspired by the work John Ramsdell did. The additional contribution offered here is a set of patches to add a new target architecture to the GNU cross development toolchain, making application development easier, although at the cost of making building the toolchain more complex.
This patch contains:
-- patches to the GNU development chain in extras/devenv/patches:
binutils-2.16.1.patch gcc-4.1.0.patch gmp-4.2.1.patch newlib-1.14.0.patch
-- documentation explaining how to build the cross-development
toolchain in extras/devenv/docs/build-cross-dev-env
-- patches to Mini-OS needed for the cross development chain and Red
Hat Newlib port.
The changes to Mini-OS in detail are:
-- rename gettimeofday() to _xgettimeofday() because of clash with
function of same name but different signature in Newlib.
Files changed:
extras/mini-os/arch/ia64/time.c
extras/mini-os/arch/x86/time.c
extras/mini-os/include/time.h
extras/mini-os/sched.c
-- add very simple console input handling
Files changed:
extras/mini-os/console/console.c
extras/mini-os/include/console.h
-- Correct domain_config to fix wrong kernel name
Files changed:
extras/mini-os/domain_config
-- Add simple implementation of _xrealloc() for Newlib
Files changed:
extras/mini-os/lib/xmalloc.c
extras/mini-os/include/xmalloc.h
-- Modify kernel.c so the application is called main(), and comment
out the rest of the test code. This is needed so that autoconf etc. can compile and link small test programs without getting undefined symbols. It also makes it easier to port small applications.
Files changed:
extras/mini-os/kernel.c
-- When using Mini-OS to run an application in a lightweight domain,
if the application called by Mini-OS exits quickly, "xm create" fails. Is this a race? Has the Mini-OS domain exited before xm has time to see it? Adding a delay loop seems to get round the problem:
for (i = 0; i < 1000000000; i++)
;Files changed:
extras/mini-os/kernel.c
-- Add functions for sti and cli replacement -- thanks to John
Ramsdell.
File added:
extras/mini-os/sticli.c
Thanks are due to HP for permission to publish this work, and to the Open Trusted Computing project http://www.opentc.net/, of which this work was a part.
Regards,
Melvin Anderson.
extras/mini-os/arch/ia64/time.c +1 -1
@@ -178,7 +178,7 @@ monotonic_clock(void) }void -gettimeofday (struct timeval *tv) +_xgettimeofday (struct timeval *tv) {calculate_time (); tv->tv_sec = os_time.ts_sec;/* seconds */
extras/mini-os/arch/x86/time.c +2 -2
@@ -183,7 +183,7 @@ static void update_wallclock(void) } -void gettimeofday (struct timeval *tv) +void _xgettimeofday (struct timeval *tv) {u64 nsec =monotonic_clock (); nsec += shadow_ts.ts_nsec;
@@ -198,7 +198,7 @@ void block_domain(s_time_t until)void block_domain (s_time_t until) {struct timeval tv; -gettimeofday (&tv); +_xgettimeofday (&tv);if (monotonic_clock () < until) {HYPERVISOR_set_timer_op (until);
extras/mini-os/console/console.c +114 -8
137 lines not on this page · raw message
extras/mini-os/domain_config +1 -1
@@ -8,7 +8,7 @@ #---------------------------------------------------------------------------- # Kernel image file. -kernel = "mini-os.elf" +kernel = "mini-os.gz" # Initial memory allocation (in megabytes) for the new domain. memory = 32
extras/mini-os/include/console.h +4 -0
@@ -41,6 +41,10 @@ void printk(const char *fmt, ...);void printk (const char *fmt, ...);void xprintk (const char *fmt, ...); +long console_input (char *data,int leng); +/* read up to end of line, EOT or "leng" chars into buffer "data", +whichever comes first, and return number of chars read */ +void xencons_rx (char *buf,unsigned len,struct pt_regs *regs);void xencons_tx (void );
extras/mini-os/include/time.h +1 -1
@@ -59,7 +59,7 @@ s_time_t get_s_time(void);s_time_t get_s_time (void );s_time_t get_v_time (void );u64 monotonic_clock (void ); -void gettimeofday (struct timeval *tv); +void _xgettimeofday (struct timeval *tv);void block_domain (s_time_t until);#endif /* _TIME_H_ */
extras/mini-os/include/xmalloc.h +1 -0
@@ -15,6 +15,7 @@ extern void xfree(const void *);/* Underlying functions */ extern void *_xmalloc (size_t size,size_t align); +extern void *_xrealloc (const void *p,size_t size,size_t align);static inline void *_xmalloc_array (size_t size,size_t align,size_t num) {/* Check for overflow. */
extras/mini-os/kernel.c +44 -19
80 lines not on this page · raw message
extras/mini-os/lib/xmalloc.c +36 -0
@@ -223,3 +223,39 @@ void xfree(const void *p)/* spin_unlock_irqrestore(&freelist_lock, flags); */ } + +/* Very simple realloc() implementation -- doesn't try to extend in place */ + +#define min (x,y) ({ \ + typeof(x) tmpx = (x); \ + typeof(y) tmpy = (y); \ + tmpx < tmpy ? tmpx : tmpy; \ + }) + +static size_t +xsizeof (const void *p) +{ +struct xmalloc_hdr *hdr; + +if ( p ==NULL ) +return (0 ); + + hdr = (struct xmalloc_hdr *)p -1 ; + +return (hdr->size -sizeof (struct xmalloc_hdr )); +} + +void * +_xrealloc (const void *p,size_t size,size_t align) +{ +void *p2 =NULL ; + +if (size >0 ) + { + p2 =_xmalloc (size, align); +memcpy (p2, p,min (size,xsizeof (p))); + } + +xfree (p); +return (p2); +}
extras/mini-os/sched.c +2 -2
@@ -241,10 +241,10 @@ void th_f1(void *data)up (&mutex); -gettimeofday (&tv1); +_xgettimeofday (&tv1);for (;;) { -gettimeofday (&tv2); +_xgettimeofday (&tv2);if (tv2.tv_sec - tv1.tv_sec >2 )break ; }
extras/devenv/README new file +3 -0
@@ -0,0 +1,3 @@ +This directory contains patches and instructions for building a +development environment to support cross development for small +applications running in a separate domain under Mini-OS.
extras/devenv/docs/build-cross-dev-env/Makefile new file +31 -0
@@ -0,0 +1,31 @@ +# $Id: Makefile,v 1.1 2006/09/13 08:56:14 mja Exp $ +# + +SRC=build-cross-dev-env.tex bibliography.bib + +DIAG=app-overview.pdf dev-chain-overview.pdf + +# useful make targets +all: build-cross-dev-env.pdf + +pdf: build-cross-dev-env.pdf + +%.eps: %.fig + fig2dev -Leps -m0.65 $< $@ + +%.pdf: %.eps + epstopdf $< --outfile=$@ + +build-cross-dev-env.pdf: $(SRC) $(DIAG) + latex \\batchmode \\input build-cross-dev-env ; \ + bibtex build-cross-dev-env ; \ + thumbpdf build-cross-dev-env ; \ + while ( \ + latex \\batchmode \\input build-cross-dev-env ; \ + grep "Rerun" build-cross-dev-env.log > /dev/null ) do true ; \ + done + +clean: + rm -rf *.aux *.dvi *.lof *.log *.lot *.toc $(DIAG) *.bak *.eps *.bbl + rm -rf *.blg *.brf *.out *.tpt *~ +
extras/devenv/docs/build-cross-dev-env/app-overview.fig new file +67 -0
67 lines not on this page · raw message
extras/devenv/docs/build-cross-dev-env/bibliography.bib new file +240 -0
240 lines not on this page · raw message
extras/devenv/docs/build-cross-dev-env/build-cross-dev-env.tex new file +626 -0
626 lines not on this page · raw message
extras/devenv/docs/build-cross-dev-env/dev-chain-overview.fig new file +44 -0
44 lines not on this page · raw message
extras/devenv/patches/binutils-2.16.1.patch new file +1668 -0
1,664 lines not on this page · raw message
extras/devenv/patches/gcc-4.1.0.patch new file +79 -0
79 lines not on this page · raw message
extras/devenv/patches/gmp-4.2.1.patch new file +38 -0
Lines of this file are not shown. View the raw message.
extras/devenv/patches/newlib-1.14.0.patch new file +2191 -0
2,191 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Part of the diff is not shown here. View the raw message.
Quoted 8 lines · Melvin Anderson
We have been doing some experiments using Mini-OS together with a GNU cross development toolchain to allow small applications to be layered on top of Red Hat Newlib and Mini-OS. The use of Red Hat Newlib and Mini-OS was inspired by the work John Ramsdell did. The additional contribution offered here is a set of patches to add a new target architecture to the GNU cross development toolchain, making application development easier, although at the cost of making building the toolchain more complex.
I suggest breaking this up into logical subpatches where possible. For example, the console enhancements are useful independent of changes to the minios build system. Can you give some more motivation for why you'd want to change the tool chain to add a new build target? It doesn't seem a great place to add customisations and complexity!
-- Keir