In this lab you will complete the missing sections of a hardware device driver. Most of the code is given to you. You have to implement the read and ioctl functions of the device driver. See the TODO sections inside the driver.
The source code for the hardware device driver can be found at
Makefile,
hardwareDevice.h, and
hardwareDevice.c.
Scripts to load the module into the kernal and unload the module from the kernel can be found at
load.sh and
unload.sh.
A script that unloads, builds and loads the kernel module all in one can be found at
build.sh.
You might have to change the permissions of your shell scripts: $ chmod 777 *.sh
The hardware device driver is simply a buffer running in a thread that is updated once per second. You have to implement the read function so a program from user-space can read the contents of the buffer. You also have to implement the ioctl function with two ioctl commands: HARDWARE_DEVICE_HALT and HARDWARE_DEVICE_RESUME. The command HARDWARE_DEVICE_HALT will halt the buffer from updating, and the command HARDWARE_DEVICE_RESUME will resume the updating of the buffer once per second. Details for HARDWARE_DEVICE_HALT and HARDWARE_DEVICE_RESUME can be found in the header file hardwareDevice.h.
A user-space program has been provided to test your work. This code can be found at
Makefile and
userHardware.cpp.
This program simply reads the buffer from kernel space three times once every three seconds, issues an ioctl command to halt, reads the buffer three times once every three seconds again,
then issues an ioctl command to resume, then reads the buffer three times once every three seconds then finishes.
Please note the directory structure. The Makefile for userHardware.cpp has to include the kernel header file hardwareDevice.h. It expects hardwareDevice.h to reside
in a directory whose relative path is ../kernel.
Email me your completed hardwareDevice.c to: miguel.watler@senecapolytechnic.ca
NB: My last name is Watler, not Walter.