[Kernel, courtesy IowaFarmer.com CornCam]

Advanced Operating Systems, Fall 2004


You'll use two sets of tools in this class: an x86 emulator, Bochs, for running your kernel; and a compiler toolchain, including assembler, linker, C compiler, and so forth, for compiling your kernel. Here's the information you'll need to use the versions on SEASnet, or to download and install your own copies. This class assumes familiarity with Unix commands throughout.

Using SEASnet

Add the directory /u/cs/class/cs239/cbin/bin to your PATH, and /u/cs/class/cs239/cbin/man to your MANPATH. If you ssh in to a SEASnet machine, use ssh -X: Bochs puts up an X window.

Downloading Your Own Copies

The process is pretty easy if you have access to a Unix or Mac OS X machine. It should be possible under Windows, too, with the help of Cygwin. Install cygwin, and be sure to install the flex and bison packages (they are under the development header).

First, choose a prefix, or directory, you'll use for storing the tools. Good choices include /usr/local, $HOME (your home directory), and /usr/local/aos. Call your prefix PFX; then executables will be stored in PFX/bin, libraries in PFX/lib, shared files in PFX/share, and so forth.

Before you go any further, make sure that your PATH environment variable includes PFX/bin! Without this, GCC will fail to build. You may want to change your MANPATH environment variable while you're at it.

The class tools are pretty large. You'll need around 500 MB of space to compile all the tools, but after deleting the sources, the installed executables and libraries take up less than 100 MB. Your mileage may vary.

Compiler Toolchain

First, check whether you need to build a GNU C compiler toolchain. If your native GNU binutils and GCC compiler build for an i386 ELF target (like most standard Linux and BSD systems), and your GCC is version 3.0 or higher, you should be able to use the native compiler. To check, run objdump -i. If the second line is elf32-i386, and gcc -v reports a high enough version, you're all set, and can skip the rest of this section.

Otherwise, configure and build the GNU C compiler toolchain as a cross-compiler for the target 'i386-jos-elf'. You can download the specific versions we used via these links, although more recent versions of gcc and binutils should work too:

Unpack these archives, using "gzcat FILE | tar xf -" for .tar.gz files and "bzcat FILE | tar xf -" for .tar.bz2 files. Then run the following commands. (Supply your prefix for PFX.)

cd binutils-2.15
./configure --target=i386-jos-elf --prefix=PFX
make install
cd ../gcc-3.4.2
./configure --target=i386-jos-elf --enable-languages=c --prefix=PFX
make install

Depending on the prefix, you may need to be root to run 'make install'. Then you'll have in PFX/bin a bunch of binaries with names like i386-jos-elf-gcc. As long as PFX/bin is in your PATH, the labs should automatically find and use the i386-jos-elf- binaries.

You can also download and configure the full gcc-3.4.2 release, which has support for C++ and Java as well as C. The C++ standard library does not support JOS, however, so you'll need to change GCC's ./configure script to disable it. Edit ./configure, search for the line that says 'case "${target}" in', and add the following text immediately after that line:

    noconfigdirs="$noconfigdirs target-libstdc++-v3"

Bochs Emulator

Next, download, compile, and install Bochs from the source archive. This is the only option if you want to run Bochs under a different OS or on a different architecture; if you download a prebuilt version of Bochs, it will not be compiled with the same options as we use for the class.

The latest stable version of Bochs is 2.1.1, which can be downloaded from the Bochs downoad page. However, this version has some issues where triple faults will cause Bochs to hang. We're currently using a CVS snapshot instead. If you choose to use the CVS snapshot on your home machine, you will need to update the instructions accordingly.

You may also want to run ./configure --help and look at the available options.

tar xzvf bochs-2.1.1.tar.gz
cd bochs-2.1.1
./configure --enable-disasm \
            --enable-debugger \
            --enable-new-pit \
            --enable-all-optimizations \
            --enable-4meg-pages \
            --enable-global-pages \
            --enable-pae \
            --disable-reset-on-triple-fault \
            --with-all-libs \
make install
Mac OS X note: You may want to run "make install_unix" instead of "make install"; the default make install creates and installs a "bundle" rather than a shell application. If you do this and Bochs fails to run, complaining about a file named BIOS-bochs-latest, follow up with the following commands:
ln -sf PFX/share/bochs/BIOS-bochs-latest PFX
ln -sf PFX/share/bochs/VGABIOS-lgpl-latest PFX

Other ./configure flags: Some of our challenge problems may require adding other flags to Bochs's ./configure line, such as --enable-x86-debugger. To add VGA support, configure with --enable-vbe.

If you wish to use a different UI than the default one, modify your .bochsrc file accordingly. See the bochsrc documentation. It should also be possible to just run man bochsrc.

If you are compiling on a non-x86 platform or on windows, it may be necessary to remove the --enable-all-optimizations flag.

Back to Advanced Operating Systems, Fall 2004