Your browser is unsupported

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

3: device drivers for console and display

In this homework, we extend the existing console device driver to support colored text, and create a brand new device driver for graphics display. Provided are a couple of user-space programs that use the new (and as of yet non-existent) functionality to show stuff on the screen.

Getting started Heading link

Pull the latest from the class repository, and check out origin/hw3 to get started. After running “make qemu”, you will have two new binaries prettyprint and imshow. Try running them, neither program takes any parameters.

Console driver Heading link

prettyprint console output

With prettyprint a correct solution would display multi-colored text. Read prettyprint.c to see how it is intended to work.

Here, ioctl() (read “I/O control”) is a classic Unix system call that was added to xv6 for this assignment. The purpose of ioctl, is to support various configuration settings to I/O devices. In the Unix model, I/O devices are represented by device files, notably console and display in this assignment.

Hence, your job is to extend the functionality of the existing ioctl system call, to support the expected behavior of the prettyprint program. Remember the color configured by each call to ioctl, and make sure this color is used to print subsequent characters on the appropriate file descriptor. There is also a separate ioctl to change the “global” color, used when displaying input and cprintf output. Note that other output (say from cprintf, console input, or stderr), should not be affected by any color change to stdout, and vice versa.

Below is the expected output.

hint: store the file descriptor-specific color in the struct file. To output colored text, see the “white on black” comment in cgaputc(). Now to get the configured color out on the screen, it’s just a question of providing the color as an argument to cgaputc, and so on.

Graphics driver Heading link

With imshow, the by-now-familiar cover image should show up on the screen, change color, and disappear (return to text mode). For full points, make sure the original console text remains after the program finishes. (hint: switching video modes clears the corresponding buffer).

While console supports both reading and writing, display needs to support only writes. Look at how the console driver is implemented to figure out how to implement a display driver. Note that due to the virtual memory mapping, the virtual address 0xA0000 does not hold the video buffer – instead, you’ll find it at KERNBASE+0xA0000.

Create a flie display.c to hold the display driver code, except for “hooks” elsewhere. You’ll need to implement any driver initialization, writes to the display, and ioctls to change mode and modify palette colors. To change mode and palette colors, use the helper functions provided in vga.h

hint: the display device file is created for you upon startup, in init.c. For sys_ioctl and sys_write, try mirroring how the console device is implemented.

turn-in instructions Heading link

As in previous homeworks, commit your changes to your local repository, follow this invitation link, then add the hw3 turn-in repository remote.

Finally, push your solution to the hw3 turn-in repository. Don’t forget to double check that your turn-in was successful, by cloning the entire repo to somewhere else, building, and testing.