This is an old revision of the document!


Session 5: Character Device Drivers

Tasks

Download and unzip the tasks archive sesiune-05 on the virtual machine.

  1. Simple character device driver
    • Use the code in the archive to implement a simple device that has a text buffer that can be read and written.
      • The module will use major 42 and minor 0. Make use of this information when creating device node file
      • sudo mknod /dev/mydev c 42 0
      • All the code is implemented by commented out. Take each TODO and analyse the commented code and then uncomment it step by step.
  2. Double the work, same effort
    • Modify the code such as the device driver could handle more devices (NUM_MINORS devices)
      • These devices will have the same Major number, but different minor numbers.
      • Most code can be reused (such as the file operations), but each device needs it's own instance of the struct my_device_data and each cdev structure needs to be initiated.
      • Use a static array of my_device_data[NUM_MINORS]. Iterate from 0 to NUM_MINORS and initiate all needed structures.
sesiuni/kernel/day-5.1372885516.txt.gz · Last modified: 2013/07/04 00:05 by alexj