What information does the resource file under /sys/bus/pci/device/0000:xx:xx.x/resource contain?

lokesharo picture lokesharo · May 15, 2014 · Viewed 8.2k times · Source

I am doing a project to read the registers of the device from the pci configuration space and for that I need to mmap the space, for this I have to read the resource file. But what data this file contains. By looking at it, it looks to save some sort of addresses. I searched and read somewhere these are BAR's but there are only max of 6 BAR's so what are the other fields? The file contents are :

0x000000000000fc00 0x000000000000fcff 0x0000000000020101
0x00000000dcff0000 0x00000000dcffffff 0x0000000000120204
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000dcf80000 0x00000000dcfbffff 0x0000000000120204
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000dc000000 0x00000000dc0fffff 0x0000000000027200
0x00000000dc500000 0x00000000dc5fffff 0x0000000000120204
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000dc100000 0x00000000dc4fffff 0x0000000000120204
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000

Answer

Grapsus picture Grapsus · May 15, 2014

These special files are documented in Documentation/filesystems/sysfs-pci.txt.

The resource file contains host addresses of PCI resources. Then you have resource1, resource2 etc. files with each region's contents. Those can be mmaped.