On 05/13/10 02:51 AM, 邓宁 wrote:
Hi all,

Forgive me of the naive questions about PCI device driver.

I am reading something about PCI device driver, as mentioned in the materials, the PCI device contains three memory space: i/o, configuration, and memory space.I know that the configuration memory space is located in the PCI device, which, is responsible for guiding the allocation of the other two memory spaces. However, I am puzzled if the two memory spaces(i/o, memory) are really physically existed in every PCI device, in the form of "an on-device memory"? Or, these spaces are only allocated at the booting stage and are actually exitsed in the physical memory range?

In a PCI device driver, I implemented the mmap() function to mmap the pci device into the user applications, then what's the memory space mapped? Is it only the "PCI memory space" in the PCI device? Or the three memory spaces together?

Generally the mmap logic would make just one space available... usually the system won't allocate contiguous regions to the BARs (base address registers).

These spaces are generally implemented by the device -- they may take the form of hardware registers (common), some internal memory mapping, or some other kind of logic. The PCI spec doesn't say that much about the details here.

Not every device will have every BAR, either. The only guarantee is that PCI compliant devices will have configuration space.

Configuration space may or may not be available via directly mapped memory. Most systems (maybe even all of them) that OpenSolaris supports use directly mapped memory, but I've seen other systems which use other mechanisms, such as a pair of indirection registers, to access PCI configuration space. So its important that you use the DDI provided for these kinds of access (pci_config_setup, etc.)

- Garrett

_______________________________________________
driver-discuss mailing list
driver-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to