essential linux device drivers ch10

Accessing PCI Regions

PCI devices contain three addressable regions: configuration space, I/O ports, and device memory

Configuration Space

pci_read_config_[byte|word|dword](struct pci_dev *pdev, int offset, int *value);

and

pci_write_config_[byte|word|dword](struct pci_dev *pdev, int offset, int value);

 

Only the first 64 bytes of the configuration space are standardized. The device manufacturer defines desired semantics to the rest.

 

I/O and Memory

PCI cards have up to six I/O or memory regions. I/O regions contain registers, and memory regions hold data. Video cards, for example, have I/O spaces that accommodate control registers and memory regions that map to frame buffers.

 

unsigned long pci_resource_[start|len|end|flags] (struct pci_dev *pdev, int bar);

1. Get the I/O base address from the appropriate base address register (bar) in the configuration space:

unsigned long io_base = pci_resource_start(pdev, bar);

posted on 2011-06-24 22:53  katago  阅读(226)  评论(0编辑  收藏  举报