With each project, I will give you a new version of the virtual machine, where each version provides the capabilities needed for that project. This page will only describe obtaining and using v1.1 of the virtual platform (VP), which is needed for Project 1.
The source code is available on sirius in my public directory for CS 39. Follow these steps to create a copy of the source in your directory:
Login to sirius and open a shell.
The code is the form of a tarball: single files that contain, in compressed and archived form, a directory of files. Type the following command to decompress and un-archive the tarball.
tar -xjvpf ~sfkaplan/public/cs39/VP-v1.1.tar.bz2
You should now have a new directory named VP-v1.1 that contains the source code. Change into this directory to see the source code and other files that come with the package.
In order to compile the virtual platform, you must be in the directory that contains the source code. Then follow these directions to compile and use the virtual platform.
At the command line, simply type the following command:
make
You should see the compilation of each of the modules, and then the linking of those modules into a single executable named virtual-platform.
If you would like to change some of the compilation options, do so by editing the file Makefile. This file is the one that make reads for rules on how to compile the modules, and then how to link the modules to form the executable. For more information on using this utility, see the GNU make documentation.
Assuming things compile well (if they do not, see the section below), you may now try to use the virtual platform to run one of the programs that have been written for it. A few of these small and simple programs have been placed in the directory VM-executables/. To run the virtual platform, you must select one such virtual machine executable (.vmx) file. Note that the assembly code (.vma files) for each executable file is there as well.
To run your chosen .vmx, you must run the VP program like so:
./virtual-platform 16 VM-executables/do-nothing.vmx
Notice that the VP expects two arguments. The first is the memory size, in kilobytes. The second argument is the name of the executable you expect the kernel to load and run once the virtual machine boots.
If all goes well, you should see a bunch of output fly by. The virtual machine should start, the kernel should boot (that is, take control of the virtual machine), and then you should see instructions from the executable being processed.
Note that you can reduce the amount of output. In each module, there is a variable declared at the top of the code (.cc) file named debug. If you set it to be false, then many of the messages will no longer be emitted while the virtual platform runs. For example, you may not want to see the virtual machine (VM, which is the simulated CPU) output, thus seeing only the kernel output.
It will be important to understand how the VM and the existing kernel operate. I recommend that you begin at the main() function, contained in main.cc, and follow the execution flow from that entry point. You will see how the kernel boots, how an executable is loaded and scheduled on the CPU, and how the CPU then begins to execute that code.
You should particularly focus on kernel.cc where the trap table is created and configured, and where system call interrupts are handled. Your assignment will begin by responding to more interrupts, thus providing new entry points into the kernel from the VM.