Drivers
Current Linux kernels support a huge number of devices. Device drivers account for half of the size of the source tree (actually two-thirds if you exclude architecture-specific code that you are not using). They account for almost 1500 C-language files and more than 800 headers.
The drivers directory itself doesn’t host any
source file, only subdirectories (and, obviously, a makefile).
Structuring the huge amount of source code is not easy, and the
developers haven’t followed any strict rules. The original division
between drivers/char and
drivers/block is inefficient nowadays, and more
directories have been created according to several different
requirements. Still, the most generic char and block drivers are found
in drivers/char and
drivers/block, so we’ll start by visiting those
two.
drivers/char
The drivers/char directory is perhaps the most
important in the drivers hierarchy, because it
hosts a lot of driver-independent code.
The generic tty layer (as well as line disciplines, tty software
drivers, and similar features) is implemented in this directory.
console.c defines the linux
terminal type (by implementing its specific escape sequences and
keyboard encoding). vt.c defines the virtual
consoles, including code for switching from one virtual console to
another. Selection support (the cut-and-paste capability of the Linux
text console) is implemented by selection.c; the
default line discipline is implemented by
n_tty.c.
There are other files that, ...