TWiki> CS385fall14 Web>Homeworks>Homework2 (revision 4)EditAttach

Homework 2: A splash screen boot sector

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

A skeleton boot sector is provided in bootskel.S in the xv6 folder. This was recently added, 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.

Creating the disk

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 if, of, count, bs 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 A appear on the screen.

Writing text to the screen

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 "A". Then wait for a keypress before continuing. Use Int 16h, AH=1 to wait for a keypress.

Reading from disk using BIOS services

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.

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 if running qemu in Linux. If running outside Linux, replace 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.

Changing video mode

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

Once in video mode, the screen will show whatever is in memory starting at address 0xA0000. Assuming you put something other than zeroes in 0xA0000, you should notice something on the screen after switching to video mode 13h.

Put the image from the disk onto the screen.

Manipulate palette settings

Int 10h, function AH=10h, lets you configure the palette. function listing. Assembler 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)

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 Sepideh 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.

Make a UIC/xv6-themed image that looks good with standard VGA palette. (major cred with instructor)

Face it. The current image isn't a great boot loader splash screen.

Edit | Attach | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r4 - 2014-09-02 - 23:07:01 - Main.jakob
Copyright 2016 The Board of Trustees
of the University of
Helping Women Faculty Advance
Funded by NSF