On 04/07/10 06:57, 邓宁 wrote:

I am new in PCI driver writing, can anyone tell me if the PCI memory space
specified by the BAR(Base Address Register) in PCI configuration space is
capable of being allocated by the user program or by the device driver?


the "physical memory" for a device's ConfigSpace (CS) resides on the device
and is mapped into the OS via geographically addressing a specific PCI Bus,
Device, and Function (eg, "BDF").

a pci driver hopefully leverages the OS to access CS.  in solaris, one can
use a function like pci_config_get16(9f).

sr1-uaus-04: man -s9f intro|grep -i pci_config
     pci_config_get16                  Solaris DDI
     pci_config_get32                  Solaris DDI
     pci_config_get64                  Solaris DDI
     pci_config_get8                   Solaris DDI
     pci_config_getb                   Solaris DDI
...

CS is *geographically addressed*, not numerically addressed (eg, 0xfff01dd00).
the OS and system-bus bridge chip needs to know how to take a geo-address
that uses a BDF and turn it into a specific byte-address within a device's
CS.  the PCI standard allocs 256 bytes for CS; PCI-Express allows for 4096
bytes; it's up to the device to respond to a <Bus, dev, func, offset> geo-addr
and return what is specified in the PCI spec.

/andrew

_______________________________________________
driver-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to