Project 0

This project by Michael Hicks and Ashok Agrawala of the University of Maryland

 

Due Wednesday September 3rd.

 

Working on your own machine

This project should compile on Rosemary without any problems. In addition, you should be able to compile this project on any machine (Linux, Mac, Windows). I will give you some guidance for Ubuntu Linux. For Windows and Mac you are on your own. Here are the packages you need to install.

  • bochs This includes bochs, bochs-x, bochsbios, and vgabios. Bochs is an IA-32 Emulator.
  • nasm an assembler for IA-32
  • libc6-dev-i386. As mentioned above Bochs is an IA-32 emulator. If you have a 64 bit OS, you will need these 32 bit libraries.

You will also need to edit build/.bochsrc to match your local environment (instructions are in that file).

I am testing your code on 64 bit Ubuntu. If your code runs on Rosemary it will run on my machine. When I test I do the following:

% make clean
% make
% bochs

If your code does not work with these commands and if there is no readme.txt file with the submission that explains why it does not work you will receive a zero. You may resubmit for reduced credit.

Accessing Rosemary

If you are trying to access rosemary remotely use the -X option for ssh:

ssh -X username@rosemary.umw.edu

This opens a terminal on your local machine. From there you can run Bochs as usual.

The first step

You might want to try to run Bochs on an existing image. You can get images at http://bochs.sourceforge.net/diskimages.html. You may need to edit the boschsrc file. Make sure romimage points to the right place. On my Ubuntu install it is

romimage: file=/usr/share/bochs/BIOS-bochs-latest, address=0xf0000

Also make sure the vgarom image points to the right place. My setting is

vgaromimage: file=/usr/share/vgabios/vgabios.bin

If you get the error

Message: dlopen failed for module 'x': file not found

you will need to install the bochs-x module

Introduction

In this course we will implement a big project in subsequent phases. In each project we will be adding some new functionality to GeekOS. GeekOS is a tiny operating system kernel for x86 PCs. Its main purpose is to serve as a simple but realistic example of an OS kernel running on real hardware. To run our OS, we need to either use an actual machine (which must be an x86 machine) or the other (simpler) idea is to use an emulator; we will use Bochs

The purpose of this assignment (project0) is to get you familiar with the GeekOS development environment, including the BOCHS x86 simulator. The assignment is to write a simple kernel mode thread that does two things:

  • prints a message (your name)
  • reads keyboard input, echoing each key pressed to the terminal, until the user hits control-d.

Preparation

Compiling the Kernel

You should download the GeekOS kernel and unpack it into your account. (if you are using Ubuntu on your own machine you might prefer this kernel This will create a directory project0.

At this point, you can compile the kernel. Change the directory to project0/build/ and invoke GNU make to build the kernel.

Running your kernel on top of Bochs

Once you have the kernel built, it's the time to run Bochs and load your kernel into it. Assuming you have set your path properly as indicated above, just go to your project's build directory and run Bochs (choose option 5, which is the default).

    $ bochs 

For this to work, you need a proper .bochsrc in that directory. If you are running bochs at home, you will have to edit the file so that vgaromimage and romimage refer to the bochs installation on your machine.

The task

Your first task is to add code to the kernel to create a new kernel mode thread. The kernel mode thread should print out ``Hello from xxx'' where xxx is your class account name. To start a new kernel mode thread you use the Start_Kernel_Thread function. Look at the comments before the definition of this function in geekos/kthread.c.

Next, implement the thread to then call the keyboard input routine Wait_For_Key repeatedly, echoing each character entered, until the termination character (left control-d) is entered. You need only handle left control key when testing for termination character. The KeyCode returned by Wait_For_Key is 16 bits; you need to properly convert this to an 8-bit ASCII value before printing it to the screen.

Grading Criteria

  • readme.txt file included with submission - 8 points. this readme needs to include
    • the file names and line numbers indicating where you added code.
    • if your code does not run as spec'd an explanation of your problems.
    • any other additional information you would like to provide.
  • Unpack and compile correctly - 8 points
  • Printing out "Hello from XXX" from the newly created thread - 16 points
  • Echo characters (once or twice) - 18 points
  • Echo characters only once - 19 points
  • Stop echoing upon hitting ^D - 20 points
  • Elegance of solution - 11 points
  • TOTAL - 100 points

Submission Instructions

  1. make clean - to remove unnecessary files
  2. zip or gz your project0 directory (for example, on the command line zip -r zacharski.zip project0)
  3. email the zip to raz@umw.edu with the subject project0
  4. Remember I test by
    1. unzipping
    2. make clean
    3. make
    4. bochs