Use memory to access PCIe space under Linux

Source: Internet
Author: User

Test environment: Ubuntu 14.04LTS

Under Windows, we can easily see all of the PCIe config space with rw everything, but we recently wanted to dump PCIe config space under Linux, first we tried to use IO read,

That is, usually we will use CF8 and CFC way, but unfortunately this way can only read out 256 bytes, then the back of the 0x100~0x1ff how to read, is the following we have to solve the problem.

1, first we need to get PCIe in memory of the mapping address, we look at the ACPI manual, will find that there is a mcfg thing, the official explanation is as follows:

"Mcfg" PCI Express memory mapped configuration space base address Description table
PCI Firmware specification, Revision 3.0
See the ACPI Link Document under the heading "PCI Sig".

In other words, Mcfg contains the base address of the store PCIe, this method can be used acpidump this tool, if not, need to install first

sudo apt-get install Acpidump

After success, we type Acpidump, will dump out many register values, slowly pull down we will find the following


From the PCI Firmware Specification Revision 3.0 above you can see the definition of mcfg:


See the Sleep configuration space base address allocation structure, offset is 44, that is, 0x2c, and then refer to table4-3:


Back to Acpidump read out the base address of the Mcfg,pcie is F0000000, this value is not fixed, on the other machine will be different.

2, in order to verify that the base address above is PCIe, we need to write a simple program, try it.

[Email protected]:/mnt/hgfs/linuxtools/pcitools/pci_dump$ sudo./pci_dump-m
The offset address value is 0xf0000000
The value at 0xf0000000 is 0x71908086

Okay, let's read it. Memory address f0000000 's low 2 bytes is 8086, so the base site is definitely not a problem, then can be based on the PCIe spec protocol, the combination of PCIe Bus,device, The value of the function and register to get the value of the corresponding address.

If you do not rest assured that the above verification, can also be lspci this tool to read the bus 0, device 0,funtion 0,register 0 value, further verification.






Use memory to access PCIe space under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.