wiki/notebook/linux.drivers.org
Gabriel Arazas b088086b06 Merge evergreen notes into the notebook
Now, it's all under the notebook umbrella. Seems to be appropriate as it
is just my notes after all.

I also updated some notes from there. I didn't keep track of what it is
this time. Something about more learning notes extracted from my
"Learning how to learn" course notes and then some. Lack of time and
hurriness just makes it difficult to track but it should be under
version control already.
2021-07-21 16:28:07 +08:00

2.4 KiB

Linux drivers

Linux drivers (also called as kernel modules) are software executed in the kernel. Usually, they are used to communicate between hardware and create an inteface with it, making them usable. Examples include the Linux Wacom project to make Wacom graphics tablet usable in Linux, those sort of stuff.

Liveoverflow's video summary:

  • A driver is just a compiled module (e.g., driver.o) that makes use of the code in the Linux header and does the communication from the associated device.
  • Each driver may have functions attached to an event (e.g., opening in module_open, closing in module_exit).
  • You can insert a driver with the insmod program and remove it with the rmmod program.
  • Each driver will appear on a special filesystem in /dev as a special type of file which you can view what type of file it is with ls -l.
  • You can print out events (i.e., printk) and view it in the system log (e.g., /var/log/syslog).
  • Essentially, a driver is basically a handler that does its magic whenever an associated system call (syscall) has been invoked by the kernel. The kernel provides an abstraction for the events associated with the syscall. For example, whenever the kernel invokes a syscall for writing in the device file, the associated code defined in module_write (or something equivalent) event will run.
  • NEEDS INVESTIGATION: Another interesting of note here is how the kernel does not immediately writes the bytes in the device file until closing it.
  • An overview from a student without prior experience
  • Creating a driver for a graphics tablet on Unix StackExchange
  • The de-facto reference on creating Linux drivers
  • How do Linux kernel drivers work? from LiveOverflow
  • Writing Linux kernel modules in safe Rust from the Linux Foundation
  • Linux device drivers, 3rd edition, the de-facto reference for kernel modules