L4 Darwin HOWTO

This document describes how to get started with working on the L4Darwin project.

Contents

Toolchains

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.

binutils

  1. 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

  2. Unpack the binutils source:
    $ tar zxvf binutils-2.14.tar.gz

  3. Change into the binutils source directory:
    $ cd binutils-2.14

  4. 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

  5. Execute 'make'
    $ make

  6. Execute 'make install'
    $ make install

gcc

  1. Ensure binutils has been installed in your installation directory; gcc will use elements of binutils.

  2. 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

  3. Unpack the gcc source:
    $ tar zxvf gcc-3.3.1.tar.gz

  4. Create a gcc build directory.
    $ mkdir gcc-ppc-build

  5. Change into gcc build directory.
    $ cd gcc-ppc-build

  6. 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.

  7. Edit the Makefile:

    • Remove all subdirs from the TARGET_CONFIGDIRS rule.
    • Disable the install-info: rule (you can disable it be renaming it).
  8. 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}

  9. Run 'make'
    $ make

  10. Get a cup of coffee
  11. Run 'make install'
    $ make install

psim

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.

  1. 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

  2. Unpack the gdb source:
    $ tar zxvf gdb-5.3.tar.gz

  3. Change into the gdb source directory:
    $ cd gdb-5.3

  4. Configure gdb:
    $ ./configure --enable-sim-powerpc --target=powerpc-unknown-eabi --prefix=${YOUR_INSTALL_DIR}

  5. 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);
        }
    
  6. Execute 'make'
    $ make

  7. Execute 'make install'
    $ make install

L4::Pistachio

Build the kernel

  1. Download the pistachio source. Get this from CVS or get a copy from me.

  2. Change into the kernel subdir in the pistachio source tree.
    $ cd pistachio/kernel

  3. Create a build directory:
    $ make BUILDDIR=${PISTACHIO_SOURCE_DIR}/build/pistachio-powerpc

  4. Change into the build directory:
    $ cd ${PISTACHIO_SOURCE_DIR}/build/pistachio-powerpc

  5. Run make menuconfig to configure the kernel. You will want the following options:

    • Under the Hardware menu, select PowerPC as your Basic Architecture.
    • For the Processor Type choose the IBM750.
    • Enable the kernel debugger.
    • Under the Code Generator Options enable SYSV_ABI.
  6. Build the kernel
    $ make

Build user libraries and loader

  1. Create your user-level application build directory:
    mkdir ${PISTACHIO_SOURCE_DIR}/build/pistachio-user-powerpc

  2. Change into your build directory.
    $ cd ${PISTACHIO_SOURCE_DIR}/build/pistachio-user-powerpc

  3. Configure the user level build:
    $ ../../user/configure --host=powerpc

  4. Build the user-level libraries and boot loader by executing:
    $ make

L4/Darwin

Now that you have toolchains, the simulator, and pistachio built, you can finally build L4/Darwin.

  1. Obtain the source from cvs.
    $ cvs -d /home/disy/cvs_root co l4darwin

  2. Edit the Makefile so that XCCPREFIX is set to ${YOUR_INSTALLATION_DIRECTORY}/bin/powerpc-elf-.

  3. Edit the Makefile so that L4ROOT is set to ${PISTACHIO_SOURCE_DIR.

  4. 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.

  5. Build the kernel:
    $ make

  6. To run on the simulator:
    $ make sulima

  7. 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.)