Program 3: Char Driver (scull)

CS 3210 Design of Operating Systems
Spring 2000 * Hutto
Georgia Tech College of Computing

DUE: 1:35 pm (class time) Tuesday 22 February 2000

For your third programming assignment, you will implement the scull simple character driver as described in Rubini chapters 3 and 5. There have been some changes between the 2.0 kernel described in Rubini and the 2.2 kernel we are using. Most of the code in Rubini will not work as is. Your challenge for this assignment is to use your initiative to figure out how to update the Rubini example and get it to work under Linux 2.2. We have several good resources available. Alan Cox has written a couple of terse articles (part 1, part 2) about porting device drivers from Linux 2.0 to 2.2. In addition, the recent WROX book "Beginning Linux Programming" by Stone and Matthew has a good chapter on device driver development that has code examples that work under 2.2. By "triangulating" these various sources you should be able to get the basic Rubini driver described in ch 3 working. For extra credit, you can implement some of the advanced scull features described in chapter 5. The Rubini examples are mostly written as kernel modules so you will need to develop some familiarity with the kernel module concept. We will spend a week later in the semester looking at how kernel modules are supported in Linux. We will review the old kerneld user-space implementation and then briefly look at the new kmod kernel-space version of module support.

Scull

Scull is a memory-based character "device driver". It supports a variety of operations and allows you to read and write. The basic version dynamically allocates kernel memory using kmalloc as data is written to the device. The device memory is "kernel persistent". If you open scull, write, close and then re-open and read, you will see the previously written data. This only works, of course, if you haven't rebooted. Rubini describes a variety of extensions showing how to view the device as a pipe and how to enforce various access restrictions on the device. The piping and access restricted versions of scull are described in Rubini Chapter 5 Enhanced Char Driver Operations.

I will not provided detailed step-by-step instructions on this assignment. Let's work on this one together. Please share your problems and discoveries via the newsgroup. I will add detail to this web page as we clarify aspects of scull.

Resources

Feel free to use any resources you can to help you with this assignment! Internet newsgroups, Linux gurus, whatever it takes!

Gzipped tarballs of the source code files are available for the examples in Rubini (rubini.tar.gz) and in the WROX book (wrox.tar.gz). The Rubini file is about 150K. The WROX file contains source for the entire book and is about 450K.

Good luck!