Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


The first section includes all elements that create links with other PCI data structures.nodeis a list ele-
ment used to keep all buses on the global list mentioned above.parentis a pointer to the data structure of
the higher-level bus. There may be just one parentbus. The subordinate or child buses must be managed
on a linked list withchildrenas the list head.

All attached devices are likewise managed in a linked list headed bydevices.

With the exception of bus 0, all system buses can be addressed only via a PCI bridge that functions like
a normal PCI device. Theselfelement provides each bus with a pointer to apci_devinstance that
describes the bridge.

Thesolepurposeoftheresourcearray is to hold the address areas occupied by the bus in virtual mem-
ory; each array element contains an instance of the aboveresourcestructure. Since the array contains
four entries, a bus can reserve just as many different address spaces to communicate with the rest of the
system (the array dimension does, of course, conform to the PCI standard). The first element contains the
address area for I/O ports. The second always holds the I/O memory area.

The second block first lists a large number of function pointers concentrated in theopselement. These
are a collection of functions invoked to access the configuration space, examined more closely below.
Thesysdataelement enables the bus structure to be associated with hardware-specific and therefore
driver-specific functions, although the kernel rarely makes use of this option. Finally,procdirprovides
an interface to theprocfilesystem so that/proc/bus/pcican be used to export information on the
individual buses to userspace.

The next block contains numeric information.numberis a consecutive number that uniquely identifies
the bus in the system.subordinateis the maximum number of subordinate buses that the particular bus
may have. Thenamefield holds a text name for the bus (e.g.,PCI Bus #01) but may also be left blank.

A list of all system buses is compiled when the PCI subsystem is initialized. The buses are linked together
in two different ways. The first involves a linear list starting with the above-mentionedroot_busesglobal
variable and including all the buses in the system. Thenodeelement acts as the list head.

The two-dimensional topology structure of the PCI buses in the form of a tree is facilitated by theparent
andchildrenstructure members.

Device Management


Thestruct pci_devdata structure described in this section is the key structure used to represent the
individual PCI devices in the system.

In this context, the kernel interprets the termdeviceto mean not only expansion
cards but also the PCI bridges used to connect buses to each other. There are not
only bridges to interlink PCI buses but also (on older systems) bridges to link PCI
buses with ISA buses.


struct pci_dev {
struct list_head global_list; /* node in list of all PCI devices */
struct list_head bus_list; /* node in per-bus list */
Free download pdf