![]() |
|
Home | UNX511 | Help Notes | Contact |
FIRST: See labs.html for information on labs.
Copy the lab 5 sample code from https://github.com/jsellens/unx511_samples/tree/main/lab_5 (or clone/update the unx511_samples repository).
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 is in lab_5/kernel in the files Makefile hardwareDevice.c and hardwareDevice.h
Scripts to load the module into the kernal and unload the module from the kernel are in load.sh and unload.sh
A script that unloads, builds and loads the kernel module all in one is in build.sh
Make sure there is execute permission on the scripts. You might need to: $ chmod 755 *.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 in the lab_5/userapp directory. in the files 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.
See the lab 5 submission instructions in labs.html