Using an Emulator with CS452

You don't have to use an emulator to do your assignments, but it may be extremely useful, especially in the early kernel assignments. You should also know that we will only test your submissions on the real machines in the lab, not on the emulator. Thus, if your submission works in the emulator, but does not work on the actual hardware, you will not receive any marks for it. In other words test everything on the actual hardware, and use the emulator only for debugging (and maybe when the lab is busy).

Currently, the Bochs emulator is set up for student use in the course. To use our installation of bochs, you need to have your environment variables set up correctly. To do this, run either
source ~cs452/public/env.csh if you're running tcsh or csh
or
source ~cs452/public/env.sh if you're running bash.

Before you can use the emulator some configuration files and a disk image will have to be set up. Simply run 452mkemu, and this will be done automatically for you. This script will set up a 10 MB disk image in the ~/cs452/emu/ directory.

Once you have a disk image set up, you can post to it by using the 452postemu script. This script takes exactly the same arguments as the regular posting script.

After you've posted a kernel to the disk image, you can start the simulator by running bochs. Press enter at the first prompt. You will now be in the bochs debugger. To start up the simulated PC, press c (for continue). You'll notice grub booting up, and you will be presented with a menu similar to the one you see when grub loads on the real machines. Pick your entry, press enter, and watch your kernel boot up.

Caveats

Tips

You don't have to stop and restart Bochs every time you recompile. Instead, do the recompilation and posting with 452postemu in a separate window, then press the "Reset" button in the Bochs UI. This should be much faster than rerunning Bochs from scratch

A convenient way to get into the bochs debugger at some point in your code is simply to include a hlt instruction. Then you can press Ctrl-C in the console where you ran bochs once the halt instruction has hit, and step through your code using the bochs debugger.

I've installed the bfe2 frontend to the bochs debugger for you. Simply type bfe2 to run it. You may or may not find this useful.

Links

-- Stefanus Du Toit, September 24 2004. Last updated October 2, 2004.