A few PCI/PCIe questions

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
8infy
Member
Member
Posts: 185
Joined: Sun Apr 05, 2020 1:01 pm

A few PCI/PCIe questions

Post by 8infy »

Hi, I have a few questions about PCI once again:
1. Can I access PCIe configuration space with 8/16/64 bit reads/writes?
2. Can I access PCIe devices bars with 8/16/64 bit reads/writes?
3. When I try to read the amount of address space required for a BAR for an AHCI controller, I get back 0x1000 after all conversions.
However, I know that an AHCI HBA memory space takes up to 0x1100 if all ports are present. Am I reading the value wrong or is that
intended? (I get 0x1000 on both VMWare and QEMU)

Thanks :)
wxwisiasdf
Member
Member
Posts: 34
Joined: Sat Sep 07, 2019 5:17 pm
Libera.chat IRC: Superleaf1995

Re: A few PCI/PCIe questions

Post by wxwisiasdf »

8infy wrote:Hi, I have a few questions about PCI once again:
1. Can I access PCIe configuration space with 8/16/64 bit reads/writes?
2. Can I access PCIe devices bars with 8/16/64 bit reads/writes?
3. When I try to read the amount of address space required for a BAR for an AHCI controller, I get back 0x1000 after all conversions.
However, I know that an AHCI HBA memory space takes up to 0x1100 if all ports are present. Am I reading the value wrong or is that
intended? (I get 0x1000 on both VMWare and QEMU)

Thanks :)
1. yes
2. yes
3. probably intended

edit: take in account that PCI is Little Endian
:-)
User avatar
thomtl
Member
Member
Posts: 66
Joined: Mon Sep 03, 2018 2:25 am

Re: A few PCI/PCIe questions

Post by thomtl »

1. No, you can only access PCI(e) config space with 8/16/32 bit read/writes, not 64bit ones.
2. Yes, although this is per device and per register, in general you should never access MMIO with unaligned accesses.
3. Probably intended, AHCI is not required to implement all 32 ports, which I don't think QEMU or VMWare do, so they have no use for such a large MMIO space.
8infy
Member
Member
Posts: 185
Joined: Sun Apr 05, 2020 1:01 pm

Re: A few PCI/PCIe questions

Post by 8infy »

thanks guys
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: A few PCI/PCIe questions

Post by Octocontrabass »

8infy wrote:1. Can I access PCIe configuration space with 8/16/64 bit reads/writes?
The PCI and PCIe configuration space allows 8/16/32-bit reads and writes that do not cross 32-bit boundaries.
8infy wrote:2. Can I access PCIe devices bars with 8/16/64 bit reads/writes?
You can access BARs with 8/16/32-bit reads and writes that do not cross 32-bit boundaries. (But BARs are 32-bit registers, so why wouldn't you use 32-bit accesses?)
8infy wrote:3. When I try to read the amount of address space required for a BAR for an AHCI controller, I get back 0x1000 after all conversions. [...] Am I reading the value wrong or is that intended?
It's intended. AHCI controllers are allowed to request different amounts of space depending on how many registers are implemented.
Post Reply