The Big Picture
Let's put together what we saw in the previous sections and see what happens at boot time in a system with a PCI bus and a few PCI devices.[*]
When the system boots, it creates a sort of database that associates each bus to a
list of detected devices that use the bus. For example, the descriptor for the PCI bus
includes, among other parameters, a list of detected PCI devices. As we saw in the section
"Registering a PCI NIC Device Driver,"
each PCI device is uniquely identified by a large collection of fields in the structure
pci_device_id, although only a few are usually
necessary. We also saw how PCI device drivers define an instance of pci_driver and register with the PCI layer with pci_register_driver (or its alias, pci_module_init). By the time device drivers are loaded, the kernel has
already built its database:[†] let's then take the example of Figure 6-1(a) with three PCI devices and see what happens when device drivers A and B are
loaded.
When device driver A is loaded, it registers with the PCI layer by calling pci_register_driver and providing its instance of pci_driver. The pci_driver
structure includes a vector with the IDs of those PCI devices it can drive. The PCI layer
then uses that table to see what devices match in its list of detected PCI devices. It
thus creates the driver's device list shown in Figure 6-1(b). In addition, for each matching device, the PCI layer invokes the
probe function provided by the matching driver in its
pci_driver structure. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access