how drivers and devices are linked to each other ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

This is in reference to my previous post on plug and play:

I still don't understand few things and would be very glad if any one can help me.

Lets look at the PCI example as stated in LDD book.

So, when system starts up it is said in the book that BIOS reads the configuration space and allocates the memory and I/O regions, writes back to configuration space, which can be used by the driver to access the device.

Now I don't understand, how firmware knows which devices are present and how to access their configuration space ?

Book also says there is 4 bytes of configuration space which holds the unique function ID in each device so that driver can identify its device (geographical addressing) but later it says that there are three registers (device ID, vendor ID and class) which driver can use to identify the device. Isn't its contradictory? Where is this unique function ID ? Can any one make the idea of geographical addressing clear ?

Then it talks of id tables which drivers uses to tell what devices it can handle, which I understand is for hot plugging because then system has the list and if later by some means system able to figure out that there is new device attached to it, it can refer to this table to find the appropriate driver.

Then it talks of registering the driver.. which when I looked in to the code goes like this

pci_register_driver -> device_register -> bus_add_driver -> driver_attach (match this driver against every device on that bus) -> driver_probe_device -> pci_device_probe -> ultimately calls driver probe.. and if everything goes well driver will get configure to device.

So what I understood is, if you add new driver and if (somehow, I dont understand how) system has list of devices attach to that bus, we can match the driver and the device. Does it mean that while system boots up it calls all  functions with label "__init" (implying every driver registers itself) ?

Then book talks about the kernel functions to access the configuration space.

Now, after reading this, I still dont understand how the system maintains the list of devices it has on a particular bus ?

Similar to driver register function there is device register function which takes device as an argument, which when I looked goes like this

device_register -> device_add -> bus_add_device -> device_attach

Now, what is the use of this and who calls this ? how is this linked to PCI ?

Can any one please please make the things clear ?

Thank you very much
Regards
--
Kamal Kant Gupta

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux