This document describes how to get started with working on the L4Darwin project.
Before anything else you must get a working toolchain setup and installed. This part can be quite painful. Be careful to follow the instructions exactly. A lot of this info is taken from Josh LeVassuer's ppc-built.txt and the powerpc build instructions
FIXME: Create debian packages for the toolchains.
Get the binutils source from you local mirror. I reccommend
you get at least version 2.14:
$ wget ftp://mirror.cse.unsw.edu.au/pub/gnu/binutils/binutils-2.14.tar.gz
Unpack the binutils source:
$ tar zxvf binutils-2.14.tar.gz
Change into the binutils source directory:
$ cd binutils-2.14
Configure binutils to install its binaries in your chosen install
directory, and to support the PowerPC processor:
$ ./configure --prefix=${YOUR_INSTALL_DIR} --target=powerpc-elf
Execute 'make'
$ make
Execute 'make install'
$ make install
Ensure binutils has been installed in your installation directory; gcc will use elements of binutils.
Download the gcc source. You will need at least gcc-3.3.1:
$ wget ftp://mirror.cse.unsw.edu.au/pub/gnu/gcc/gcc-3.3.1.tar.gz
Unpack the gcc source:
$ tar zxvf gcc-3.3.1.tar.gz
Create a gcc build directory.
$ mkdir gcc-ppc-build
Change into gcc build directory.
$ cd gcc-ppc-build
Configure your gcc build:
$ ${YOUR_GCC_SOURCE_DIR}/configure --target=powerpc-elf --enable-languages="c,c++,objc" --with-gnu-as --with-gnu-ld --prefix=${YOUR_INSTALL_DIR}
The install directory must be same install directory as used for
the binutils install.
Edit the Makefile:
Add the bin dir of your installation directory to your path, so that
the build process can execute tools from your binutils.
$ export PATH=$PATH:${YOUR_INSTALL_DIR}
Run 'make'
$ make
Run 'make install'
$ make install
psim is the powerpc simulator. It is a great way to get a basic L4Darwinup and running. psim is an integral component of gdb. psim requires gdb to be built for the target powerpc-unknown-eabi.
Download the gdb source. You need at least version 5.3:
$ wget ftp://mirror.cse.unsw.edu.au/pub/gnu/gdb/gdb-5.3.tar.gz
Unpack the gdb source:
$ tar zxvf gdb-5.3.tar.gz
Change into the gdb source directory:
$ cd gdb-5.3
Configure gdb:
$ ./configure --enable-sim-powerpc --target=powerpc-unknown-eabi --prefix=${YOUR_INSTALL_DIR}
The default psim has an interrupt delivery bug. I submitted a patch to the gdb maintainers. But as of gdb 5.3, psim still has the bug. You must patch psim's interrupt delivery mechanism to support SMP and/or device simulation. The culprit file is sim/ppc/interrupts.c and the function is external_interrupt() located at the bottom of the file. Replace that function with:
INLINE_INTERRUPTS\ (void) external_interrupt(cpu *processor, int is_asserted) { interrupts *ints = cpu_interrupts(processor); if (is_asserted) { ints->pending_interrupts |= external_interrupt_pending; if (cpu_registers(processor)->msr & msr_external_interrupt_enable) schedule_hardware_interrupt_delivery(processor); } else ints->pending_interrupts &= ~external_interrupt_pending; }
Another bug lurks in psim, related to OpenFirmware emulation. For the kernel to boot, you must fix the function chirp_emul_nextprop() in the file sim/ppc/emul_chirp.c.
Look for the statement:
next_prop = device_next_property(prev_prop);
Change to:
if( *previous == '\0' ) next_prop = prev_prop; /* Return the first property! */ else next_prop = device_next_property(prev_prop);
And yet another bug in psim, regarding Open Firmware page hash initialization. In file sim/ppc/hw_htab.c, function htab_decode_hash_table(), look for:
if ((htab_ra & INSERTED32(*htabmask, 7, 15)) != 0) { device_error(parent, "htaborg 0x%lx not aligned to htabmask 0x%lx", (unsigned long)*htaborg, (unsigned long)*htabmask); }
and change to:
if ((htab_ra & (htab_nr_bytes-1)) != 0) { device_error(parent, "htaborg 0x%lx not aligned to htabmask 0x%lx", (unsigned long)*htaborg, (unsigned long)*htabmask); }
Execute 'make'
$ make
Execute 'make install'
$ make install
Download the pistachio source. Get this from CVS or get a copy from me.
Change into the kernel subdir in the pistachio source tree.
$ cd pistachio/kernel
Create a build directory:
$ make BUILDDIR=${PISTACHIO_SOURCE_DIR}/build/pistachio-powerpc
Change into the build directory:
$ cd ${PISTACHIO_SOURCE_DIR}/build/pistachio-powerpc
Run make menuconfig
to configure the kernel. You will
want the following options:
Build the kernel
$ make
Create your user-level application build directory:
mkdir ${PISTACHIO_SOURCE_DIR}/build/pistachio-user-powerpc
Change into your build directory.
$ cd ${PISTACHIO_SOURCE_DIR}/build/pistachio-user-powerpc
Configure the user level build:
$ ../../user/configure --host=powerpc
Build the user-level libraries and boot loader by executing:
$ make
Now that you have toolchains, the simulator, and pistachio built, you can finally build L4/Darwin.
Obtain the source from cvs.
$ cvs -d /home/disy/cvs_root co l4darwin
Edit the Makefile so that XCCPREFIX
is set to
${YOUR_INSTALLATION_DIRECTORY}/bin/powerpc-elf-
.
Edit the Makefile so that L4ROOT
is set to
${PISTACHIO_SOURCE_DIR
.
You also need to change the L4 build process so that the boot loader
knows about L4Darwin. Edit ${PISTACHIO_SOURCE_DIR}/build/pistachio-user-powerpc/util/piggybacker/ofppc/Makefile.locat so that ROOT_TASK
points to
${YOUR_L4DARWIN_DIR}/bsd_app
. Note that after chaning this Makefile.local you may need to delete all the .bin and .mod files in the directory util/piggyback/ofppc due to broken dependency detection.
Build the kernel:
$ make
To run on the simulator:
$ make sulima
Hopefully at this stage L4Darwin should run. But chances are you have stuffed up something in the previous steps. (Or, just as likely, I have mistyped something in these instructions.)