Your browser is unsupported

We recommend using the latest version of IE11, Edge, Chrome, Firefox or Safari.

2: a splash-screen boot sector

due at start of class Sept 12, 2017

In this homework, we use BIOS services to create a "splash screen" boot sector. This requires:

  • creating a "disk" that contains the boot sector and the picture to be shown,
  • waiting for the user to press a key, and outputting text on the console.
  • changing the video mode and palette settings,
  • reading an image from disk into memory,
  • (bonus points) produce a nice-looking, alternative picture to display, in the right format.

Getting started Heading link

A skeleton boot sector is provided in bootskel.S in the xv6 folder. This was recently updated; to access it, first

git pull

the latest updates from the class repository, then

git checkout -b hw2 origin/hw2

to create a new branch called hw2, based on the hw2 branch at the course repository.

The default image is provided in the same folder, as cover.raw and cover.bmp respectively. The raw version is in the correct format for video mode 13h.

For turn-in, you will need to accept this invitation to create your hw2 turn-in repository.

Creating the disk Heading link

Use the program dd twice to create your disk. First to copy the boot sector to the first block of the disk, then to append the image after the boot sector. Handy ‘dd’ parameters to use are ifofcountbs for block size, skip (jump past input blocks) and seek (start writing this many blocks into the output file). Copy the bootskel.img Makefile target to make a now bootsplash.img target with the necessary commands, rather than type things on the command line over and over. Chances are you’ll be doing it many many times.

Try your finished disk by running

qemu-system-i386 bootsplash.img.

You should see a single character H appear on the screen.

Writing text to the screen and waiting for keypress Heading link

When in text mode, use Int 10h, AH=0Eh to write a single character at a time to the screen.

Update the boot sector code to say “Welcome to xv6 @ UIC. Press any key… ” instead of “H”. Then wait for a keypress before continuing. Use Int 16h, AH=00 to wait for a keypress.

Changing video mode Heading link

BIOS interrupt 10h lets you set the video mode using function ah=00h. Use video mode 13h for this homework. WikiPedia on Int 10h.

You should notice the screen going blank (and perhaps the emulator window changing shape) upon success.

Writing graphics to the screen Heading link

Once in video mode, the screen will show whatever is in memory starting at address 0xA0000. However, not that the video buffer is cleared by switching modes.

Once you put something other than zeroes in 0xA0000, you should notice something on the screen once you are in video mode 13h.

Then put the image from the disk onto the screen, as per below.

Reading from disk using BIOS services Heading link

Int 13h, function AH=42h reads from disk. Fill in a disk address packet struct, specifying the buffer address, start sector, number of sectors to read etc, and call the interrupt to get the buffer filled in. Int 13h, ah=42h documentation. Note that the “transfer buffer” address is a 32-bit field, in offset:segment form. Also, pay attention to byte order.

To see if you succeeded, start qemu with the flags “-s -S” to have it wait for gdb. Start gdb in a separate Linux window, and type target remote 127.0.0.1:1234 if running qemu in Linux. If running outside Linux, replace 127.0.0.1 with the IP address of your host machine.

Now you can inspect your memory. For example, x/100uwx 0x7c00 prints out 100 unsigned words in hexadecimal, starting at 0x7c00. This should show your boot sector binary.

Manipulate palette settings Heading link

Int 10h, function AH=10h, lets you configure the palette. function listingAssembler for Dummies: Graphics II – palette.

To complete this part, wait for another key press after displaying the initial image. Then change some of the colors in the image and wait for another key press.

Customize the image (bonus points) Heading link

For bonus points (20% extra), add a “flame” icon in 2-3 colors to the standard image, cycle the flame colors through red/orange/yellow to simulate a burning fire after loading the image, instead of waiting for a key press. If you do this part, please email the TA separately to mention this.

To update the image, start with the .bmp picture. Edit it with a drawing program, making sure to use only a few colors. The last 64,000 bytes in the is the actual image, although as you’ll find out, the bytes are in a different order (flipped/reversed). For the full score, make sure the image looks correct.