1

Starting from Linux kernel 3.0, pci probing is automatic with: pci_register_driver(&pci_driver);

Linux kernel 2.6 and older, programmers had to create a character device, and walk through the PCI list, select appropriate PCI and doing work with it. Can you tell me how the steps of this procedure, why the initialization of a character device is need before working with the PCI driver and why it is unnecessary to register a character driver anymore.

4

1 回答 1

1

I think you refer to linux 2.4 or older. Current kernel device model with busses, devices and drivers has always been part of the 2.6 series.

What is your question exactly ?

A list of PCI devices is made at boot time. Then when a driver is registered, the pci_driver structure id_table field is used to match with the devices present on the bus. Then the pci_driver probe function is called with a pointer to the device structure that matched.

  • pci_driver is registered
  • for each device present on the bus, id element of the device(product id and vendor id) are compared to id element in the id_table provided by pci_driver
  • if there is a match, the pci_driver probe function is called, and in this probe function you can register a char device, or a block device etc ..

So it is not very different from 2.4, except all the probing, matching driver and devices, etc... is handled by the "device core" and not by the pci driver.

For a detailed explanation, see this PDF and this page

于 2012-08-28T07:29:34.833 回答