The goal of this assessment is to evaluate whether you briefly understand how applications and operating systems interact with devices. You will implement a simple character device driver to demonstrate this knowledge.
In this task, you will need to simply build a driver using the Makefile
. Even though you can type the following commands, I would recommend you look at the commands in the Makefile
to see how the compilation process works.
make
If you are not sure what is the kernel module, you can read more at https://sysprog21.github.io/lkmpg/.
Since your driver is a C module, you can use insmod
to load it as follows.
sudo insmod heartydev.ko
To verify, you can use the following commands.
cat /proc/modules | grep heartydev
cat /proc/devices | grep heartydev
Also, the heartydev_init
function will be executed. The output will be printed out in the /var/log/syslog
file. You can use the following commands to see.
tail /var/log/syslog
If you want to remove the module, you can use the following command.
sudo rmmod heartydev
You should follow a good coding convention. In this class, please stick with the CMU 15-213's Code Style.
https://www.cs.cmu.edu/afs/cs/academic/class/15213-f24/www/codeStyle.html
Since we do not have a real device, interacting with the device will be to read/write to the driver buffer instead.
Your task is to implement the heartydev_write
by copying the text from the user buffer (buf
) into the driver buffer. Note that you may need to create the driver buffer by yourself.
To verify, you should be able to call heartydev_write
through the following command.
echo 'hello, heartydev!' > /dev/heartydev
Your task is to implement the heartydev_read
by copying the text from the driver buffer into the user buffer. However, all the lowercase English letters must be capitalized.
To verify, you should be able to call heartydev_read
through the following command.
cat /dev/heartydev
You need to implement four ioctl
commands and show that user applications can call this driver command. The commands are listed as follows:
HEARTYDEV_READ_CNT
must show the current number of heartydev_read
function calls.
HEARTYDEV_WRITE_CNT
must show the current number of heartydev_write
function calls.
HEARTYDEV_BUF_LEN
must show the current length of the driver buffer. If there is nothing in the buffer, it should show 0
.
You will need to implement two more device modes using the prior knowledge you learned.
Your task is to implement the ioctl
command that changes the device's mode. There will be in total of three modes. The driver we previously implemented should be in the mode called UPPER
.
Your task is to implement the NORMAL
mode, where the driver should not capitalize the text while doing heartydev_read
.
Your task is to implement the LOWER
mode, where the driver should, instead of doing capitalization, change all capitalized English letters into lowercase letters while doing heartydev_read
.
- 20% - Task 1
- 30% - Task 2 (If task 1 is not complete, task 2 will not be graded.)
- 30% - Task 3 (If tasks 1 and 2 are not complete, task 3 will not be graded.)
- 20% - Code Style (If tasks 1, 2, and 3 are not complete, the code style will not be graded.)