Tools Used in CS372H

Public CS Linux Machines

If you use the CS department machines that run Linux (run "cshosts publinux" to get a list), then all the software tools you will need for this course are installed. You just need to set up your paths and such to get convenient access to them.  The standard gnu compilers and tools (make, etc.) should already be in your path (in /usr/bin and /lusr/bin). Finally, Bochs has been installed in /p/graft/bochs-2.3/bochs  Depending on your setup, you may want to modify your .login, .cshrc, or other files. I added the following to my .login:

  setenv PATH /p/graft/bochs-2.3:$PATH

Bochs makes use ROM images stored in /p/graft/bochs-2.3/bios. You may also want to update your .login or .cshrc to set BXSHARE to refer to that directory:

  setenv BXSHARE /p/graft/bochs-2.3/bios

Also note that I have installed another copy of bochs, this one with gdb support turned on, in /p/graft/bochs-2.3-gdb/bochs, and added a symlink to it from at /p/graft/bochs-2.3/bochs-gdb, so if you set your paths as just described and run "bochs-gdb" you should see that version run.  Here is a description of how to use bochs with a remote GDB process.

Finally, depending on how your X environment is set up, Bochs may have trouble finding the font it wants for the console it displays. You may want to add the following to your .xinitrc
      xset fp+ /p/graft/bochs-2.3/font

Personal Machines

If you would like to compile and run the tools on your own machine, however, here is the information you need. Of course, we cannot guarantee that these tools will be portable to every possible machine you might want to run them on; they should at least compile easily on most recent versions of Linux. If you are on MacOS X or BSD or Solaris, it should also be possible to get the environment set up with a bit more work. If you run Windows, it should be possible to get this development environment running under windows with the help of Cygwin. Install cygwin, and be sure to install the flex and bison packages (they are under the development header).  Note that we will not be able to provide much additional help in setting up or debugging your home environment. Also note that all grading will be done on the CS Linux machines and it is your responsiblity to port and test your solutions in this environment before you turn in your code. "It works on my home machine" is not a factor we will consider in grading. 

Compiler Toolchain

First, if you are using a platform that is not a standard x86 linux or BSD, you will need the GNU C compiler toolchain, configured and built 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:

Once you've unpacked these archives, run the following commands as root:

$ cd binutils-2.15
$ ./configure --target=i386-jos-elf
$ make
$ make install
$ cd ../gcc-3.4.1
$ ./configure --target=i386-jos-elf
$ make
$ make install

If there are errors compiling gcc when it gets to libstdc++, don't worry about it.

Then you'll have in /usr/local/bin a bunch of binaries with names like i386-jos-elf-gcc. It will also be necessary to change the GNUMakefile used in the labs to use i386-jos-elf-gcc instead of gcc. There are instructions for how to do this inside of GNUMakefile.

Bochs Emulator

Bochs version 2.3 is set up on .cs for x86 machines. If you want to use the same version on your home machine, you can download, compile, and install bochs from the source archive. Note that 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.3, and it can be downloaded from the Bochs downoad page.

You may also want to run ./configure --help and look at the available options. The --prefix= option can be very useful.

tar xzvf bochs-2.3.tar.gz
cd bochs-2.3
./configure \ --enable-disasm \
--enable-debugger \
--enable-new-pit \
--enable-all-optimizations \
--enable-4meg-pages \
--enable-all-optimizations \
--with-x11 \
--with-nogui \
--enable-cpu-level=5

make
make install

If you wish to use a different UI than the default one, modify your .bochsrc file accordingly. See the bochsrc documentation..

If you are compiling on a non-x86 platform or on windows, it may be necessary to remove the --enable-all-optimizations flag and to add a flag saying which windowing system to use (you can try --with-all-libs, which tries to auto-detect what is available; if that fails, you will have to set this manually). If the make install step fails, it is probably possible to install it manually by copying ./bochs to /usr/bin/bochs and setting the environment variable BXSHARE to the path to the bochs-2.3 directory.

We have it on good authority that the following works on Mac OS X Tiger (but we have not tried it ourselves):

    ./configure --with-x11 --disable-cdrom --enable-disasm \
      --enable-debugger --enable-new-pit  --enable-all-optimizations \
      --enable-4meg-pages --enable-global-pages --enable-pae \
      --enable-all-optimizations --disable-reset-on-triple-fault --with-nogui

If you do build your own environment for your home machine, please report your experience (successes and difficulties) to the newsgroup so that others can benefit from your experience and vice versa.