CS 635 PROJECT 1 Due: 7:30pm Tuesday, 09/25/2007 The purpose of this project is to gain familiarity with the process of adapting an earlier character-mode device-driver for Linux so it uses the kernel's new 'cdev' interface functions. PROJECT STATEMENT Rewrite the LKM demo-module named 'cmosram.c' which was distributed in class, but using the new 'cdev' kernel-interface functions (described in our "Linux Device Drivers (3rd Ed)" textbook, pages 55-57) instead of the older-style 'register_chrdev()' and 'unregister_chrdev()' functions. As explained in LDD3, the "new" way requires your driver to include the header-file, and to allocate storage for an object of type 'struct cdev' which your driver must initialize and then 'register' by calling the 'cdev_add()' function, then later must 'unregister' using the 'cdev_del()' function. DRIVER ENHANCEMENTS After you have successfully upgraded the original 'cmosram.c' code, you may earn extra credit on this assignment by implementing one or more of the following driver enhancements: (1) Add code to your module's initialization function which creates the required '/dev/cmos' device-file allowing both read-and-write access to all users, and add code to your module's cleanup function to 'unlink' this device-file when your module is removed from the kernel. This will be more convenient for your module's users than requiring that they must ask their System Administrator to setup that device-file or else install a separate module which performs that step. (2) Add code to your module that will implement a pseudo-file named '/proc/cmos', in addition to the device-file named 'dev/cmos', so a user can use the Linux 'cat' command to quickly display the current values in the 128 cmos memory locations, using hexadecimal format, without needing to write a special application-program that performs the binary-to-ascii translations. (3) Identify the 'race conditions' that are present in the original 'cmosram.c' driver-code, and eliminate them from your revised driver, by using the 'rtc_cmos_read()' and 'rtc_cmos_write()' functions (prototyped in the header-file). WHAT TO SUBMIT Copy your revised 'cmosram.c' source-file, and compiled 'cmosram.ko' kernel-object, into your '/submit' subdirectory where the Instructor can access it for testing and grading. Also, in addition to these binaries, you need to turn in a paper printout of your 'cmosram.c' textfile. (You are asked to use the 'ljpages' utility-program from our class website to do your printing, to be sure that the output is appropriately formatted. Disregarding these guidelines WILL affect your project grade.) _______________________________________________________________________ (c) Allan B. Cruse University of San Francisco Fall 2007