Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


Registering Device Drivers


After performing some sanity checks and initialization work,driver_registeremploys
bus_add_driverto add a new driver to a bus. Once more, the driver is first equipped with a
name and then registered in the generic data structure framework:

drivers/base/bus.c
int bus_add_driver(struct device_driver *drv)
{
struct bus_type * bus = bus_get(drv->bus);
int error = 0;
...
error = kobject_set_name(&drv->kobj, "%s", drv->name);
drv->kobj.kset = &bus->drivers;
error = kobject_register(&drv->kobj);
...

If the bus supports autoprobing,driver_attachis called. The function iterates over all devices on the
bus and checks if the driver feels responsible for any of them using the driver’smatchfunction. Finally,
the driver is added to the list of all drivers registered with the bus.

drivers/base/bus.
if (drv->bus->drivers_autoprobe)
error = driver_attach(drv);
...
klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
...
}

6.7.2 The PCI Bus


PCI is short forperipheral component interconnect, a standard bus developed by Intel that has quickly
established itself as a very popular bus among component manufacturers and architecture vendors, not
because of a skillful marketing strategy but on the basis of its technical merits. It was designed to combat
one of the worst plagues ever to affect the (programming) world — the ISA bus.^20 The following goals
were formulated to compensate for the deficiencies inherent in the ISA bus design once and for all:

❑ Support for high transfer bandwidths to cater to multimedia applications with large data
streams.
❑ Simple and easily automated configuration of attached peripherals.
❑ Platform independence; that is, not tied to a specific processor type or system platform.

Several versions of the PCI specification exist, as enhancements have been added to cover more recent
technical developments — for example, one of the last major ‘‘updates‘‘ relates to support for hotplug-
ging (the addition and removal of devices while the system is up and running).

(^20) ISA stands forindustrial standard architecture. This bus was developed by a large association of hardware vendors in response
to IBM’s attempts to suppress the manufacture of expansion devices through the introduction of the patented and proprietary
microchannel. The ISA bus system is of very simple design to facilitate the use of expansion cards; in fact, it is so simple that even
amateur electronics enthusiasts are able to develop suitable expansion hardware — something that is practically inconceivable with
today’s modern designs. It does, however, exhibit serious deficiencies in terms of bus programming and device driver addressing
that are due in part to the totally different computer technology situation of the time and in part to the bus design, which can by no
means be regarded as forward-looking.

Free download pdf