Assignments For Device Drivers Programming in Linux
Assignments For Device Drivers Programming in Linux
Contents
Introduction to Module Programming and Device Drivers ......................................................................3
Lab Objectives ......................................................................................................................................3
Assignments..........................................................................................................................................3
Introduction to Character Drivers..............................................................................................................4
Lab Objectives.......................................................................................................................................4
Assignments..........................................................................................................................................4
Advanced Character Drivers......................................................................................................................5
Lab Objectives.......................................................................................................................................5
Assignments..........................................................................................................................................5
Concurrency & Race Conditions...............................................................................................................6
Lab Objectives.......................................................................................................................................6
Assignments..........................................................................................................................................6
Time, Delays and Deferred Execution.......................................................................................................8
Lab Objectives.......................................................................................................................................8
Assignments..........................................................................................................................................8
Communication with Hardware and Interrupt Handling...........................................................................9
Lab Objectives.......................................................................................................................................9
Assignments..........................................................................................................................................9
Additional Topics.....................................................................................................................................10
Debugging Techniques........................................................................................................................10
Kernel Linked Lists.............................................................................................................................10
Adding A system Call..........................................................................................................................10
Embedded Linux.................................................................................................................................10
USB Drivers........................................................................................................................................10
Ultimate Bonus.........................................................................................................................................11
8. For all the synchronization mechanisms you have learnt so far, write where each finds its
application in driver development.
Assignments
1. Implement a sleep function in the driver using the jiffies variable. The user space application
should call ioctl function with a command requesting a delay. The amount of delay in seconds
can be passed as command value to ioctl. The driver should use jiffies and provide this delay.
During the delay, the application may be put onto the wait queue and woken up after the delay
has expired. Print out the time difference in the user space application. Journal the result,
defining the logic used
2. Write a driver which returns the current time to the user space application when the ioctl
function is called.
3. Write a driver, which executes a function to print the time in the kernel, every second. The
function is initiated when read is called by application A1. When application A2 executes, the
periodicity of execution should be modified to 2 seconds. Application A3 will stop the function
from executing. Journal your results
4. Explore the tasklet API and write a driver which defers the execution of a function to a later
moment. Print the time difference between scheduling the tasklet and its actual execution.
Repeat this experiment using the high priority variant of the tasklet API and record the
differences. Journal your learnings.
Additional Topics
Debugging Techniques
1. Explore the Oops message and try to find out the error using the message?
2. Configure and Compile the UML (User Mode Linux) and try simple Driver programs in UML ?
3. Explore KDB, KGDB and set up a debugging environment for linux device drivers.
Kernel Linked Lists
1. Implement a Linked list inside the kernel and perform the following operations on th list
1. Add a entry to the list
2. Add a entry to the tail of the list
3. Delete a entry from the list
4. Removes a entry from a list and adds to another list
5. Removes a entry from a list and adds to the tail of another list
6. Traversing the list
Do the above program using the IOCTL commands for the user application?
Adding A system Call
1. Add your own system call to linux by defining a function to provide system time as a string
Embedded Linux
1. Configure and Compile the New Kernel for ARM processor and generate initrd for the same
run the system with the new compiled kernel and do all Device Drivers programs in that kernel.
USB Drivers
1. Explore the USB subsystem and write a driver to probe a device.
Ultimate Bonus
1. Write a driver for the Serial Port using data sheet, 16550. The driver should implement all the
mechanisms and constructs covered in the Device Drivers lectures and should communicate
with the hardware using Interrupts. Proper mechanisms for buffer management should be
performed in the driver and it should support concurrent access. If this is completed according
to required specifications, you will be exempt for appearing in the lab exam and will be
awarded highest marks. You may begin from the 2 nd week of the module and complete it within
5 working days. Partially completed drivers will not be accepted.