Drivers

There is little to say at this point about the Linux drivers directory. The source files in this directory have been referenced throughout the book; that’s why I left them until last in this walk through the source tree.

Char, Block, and Network Drivers

Although most of the drivers in these directories are specific to a particular hardware device, a few of the files play a more general role in the system’s setup.

As far as drivers/char is concerned, code that implements the N_TTY line discipline is implemented there. N_TTY is the default line discipline for system ttys, and it is defined in n_tty.c. Another device-independent file in drivers/char is misc.c, which provides support for ``misc'' devices. A ``misc'' device is a simplified char driver that has a single minor number.

This directory also includes console support for PCs and some other architecture-dependent drivers; it actually contains a miscellaneous assortment of files that didn’t fit elsewhere.

drivers/block is much cleaner. It includes single-file drivers for most block devices and the full-featured IDE driver, which is split into multiple files. Several files in this directory provide general-purpose support; genhd.c handles partition tables and ll_rw_block.c is in charge of the low-level mechanism for data transfer to and from the physical device. The request structure is the main player in ll_rw_block.c.

drivers/net contains a long list of drivers for PC network cards, plus a few for other architectures (e.g., sunlance.c for the interface found on most Sparc computers). Some drivers may be more complicated than it appeared when they were introduced in Chapter 14. The driver ppp.c, for example, declares its own line discipline.

The general-purpose source files in drivers/net are Space.c and net_init.c. Space.c consists primarily of a table of available network devices. This table contains a long list of #ifdef entries that are checked at system boot to detect and initialize the network devices. net_init.c contains ether_setup, tr_setup, and similar general-purpose functions.

SCSI Drivers

As suggested in Chapter 1, the SCSI drivers in Linux are not included in the common char and block classes. This happens because the SCSI interface bus has its own standard. Therefore, by distinguishing SCSI devices from other drivers, the developers isolated and shared common code.

Most of the files in drivers/scsi are low-level drivers for specific SCSI controllers. The general-purpose SCSI implementation is defined in the scsi_*.c files, with the addition of sd.c for disk support, sr.c for CD-ROM support, st.c to support SCSI tapes, and sg.c for generic SCSI support. This last source file defines general-purpose support for devices that talk the SCSI protocol. Scanners and other generic devices can be controlled by user-space programs using the /dev/sg* device nodes.

Other Subdirectories

Other hardware drivers have their own subdirectories. drivers/cdrom contains drivers for CD-ROM drives that are neither IDE nor SCSI. These are conventional block drivers, which have their own major numbers.

drivers/isdn is (as the name indicates) an ISDN implementation for Linux; drivers/sound is a collection of sound drivers for the most common PC sound boards. drivers/pci contains a single file, which in turn contains the list of all known PCI devices (vendor/ID pairs). The actual PCI functions are not defined here, but rather within architecture-specific directories.

Finally, sbus includes a char subdirectory and has the console code for the Sparc architecture. This directory is quickly growing, as 2.1 development continues.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.213.209