mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 07:57:57 +00:00
2.5 KiB
Executable File
2.5 KiB
Executable File
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.
- 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 inmodule_exit
). - You can insert a driver with the
insmod
program and remove it with thermmod
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 withls -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