Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


As a result of the processor-independent nature of the PCI specification, the bus is used not only on IA-32
systems (and their more or less direct successors IA-64 and AMD64) but also on other complementary
architectures such as PowerPC, Alpha, or SPARC — justified by the need to enjoy the benefits of the
numerous inexpensive expansion cards produced for the bus.

Layoutof a PCI System


Before discussing how PCI is implemented in the kernel, let us examine the major principles on which
the bus is based. Readers who require more detailed descriptions are referred to the many textbooks on
hardware technology (e.g., [BH01]).

Identification of Devices


Each device on one of the PCI buses of the system is identified by a set of three numbers.

❑ Thebus numberis the number of the bus to which the device is assigned; numbering starts at 0 as
usual. The PCI specification permits a maximum of 255 buses per system.
❑ Thedevice numberis a unique identifying number within a bus. A maximum of 32 devices can be
attached to a bus. Devices on different buses may have the same device number.
❑ Thefunction numberis used to implement devices with more than one expansion device (in the
classical sense) on a single plug-in card. For example, two network cards can be housed on a
plug-in card for reasons of space, in which case the individual interfaces are designated by dif-
ferent function numbers. Much used in laptops are multifunction chipsets, which are attached
to the PCI and integrate a whole range of expansions (IDE controller, USB controller, modem,
network, etc.) in a minimum of space; these expansions must also be kept apart by means of the
function number. The PCI standard defines the maximum number of function units on a device
as eight.

Each device is uniquely identified by a 16-bit number, where 8 bits are reserved for the bus number, 5 for
the device number, and 3 for the function number. Drivers need not bother with this extremely compact
notation because the kernel builds a network of data structures that contains the same information but is
much easier to handle from a C point of view.

Address Spaces


ThreeaddressspacessupportcommunicationwithPCIdevices.

❑ The I/O space is described by 32 bits and therefore provides a maximum of 4 GB for the port
addresses used to communicate with the device.
❑ Depending on processor type, either 32 or 64 bytes are available for data space; of course, the
latter is supported only on CPUs with a corresponding word length. The devices present in the
system are split over the two memory areas and therefore have unique addresses.
❑ The configuration space contains detailed information on the type and characteristics of the indi-
vidual devices in order to dispense with the need for dangerous autoprobing.^21

The address spaces are mapped to different locations in the system’s virtual memory according to pro-
cessor type so that the kernel and the device drivers are able to access the corresponding resources.

(^21) Autoprobing is the ‘‘automatic detection‘‘ of devices by sending data to various addresses and waiting for the system to respond
in order to recognize the cards present in the system. This was one of the many evils of the ISA bus.

Free download pdf