Hi,
This patch series enables 64bit BAR support in seabios. It has a bit different approach for resources accounting, We did this because we wanted: a) Provide 64bit bar support for PCI BARs and bridges with 64bit memory window. b) Allow migration to 64bit bit ranges if we did not fit into 32bit range c) Keep implementation simple.
There are still have two main passes to enumerate resources and map devices, but structures are changed. We introduced two new structures: pci_region and pci_region_entry.
The pci_region structure includes a list of pci_region_entries. Each pci_region_entry could be a PCI bar or a downstream PCI region (bridge). Each entry has a set of attributes: type (IO, MEM, PREFMEM), is64bit (if address can be over 4GB), size, base address, PCI device owner, and a pointer to the pci_region it belongs to.
In the first pass we fill the pci_regions with entries and discover topology. In the second pass we try assigning memory addresses to pci_regions. If there is not enough space available the 64bit entries of root regions will be migrated to 64bit bit ranges and then we try assigning memory addresses again. Then each entry of each region will be mapped.
The patch series includes 6 patches. In the 1st patch we introduce new structures.
In the 2nd patch we introduce support functions for basic hlist operations, plus modify service functions to support 64bits address ranges. Note: I've seen similar hlist operations in post memory manager and stack location operations, it makes sense to move them to a header file.
In the 3rd patch a new function to fill pci_region structures with entries, and discover topology is added.
In the 4th patch we define address range for pci_region structure, migrate entries to 64bits address range if necessary, and program PCI BAR addresses and bridge regions.
In the 6th patch we clear old code.
And last patch is proposed by Michael Tsirkin, it contains changes in acpi-dsdt.dsl file those are necessary to support 64bit BARs in Windows.
src/acpi-dsdt.dsl | 7 + src/acpi-dsdt.hex | 72 ++++++-- src/config.h | 2 + src/pci.h | 6 - src/pciinit.c | 509 +++++++++++++++++++++++++++++----------------------- 5 files changed, 352 insertions(+), 244 deletions(-)
Note: At the moment there are three issues related to support of 64bit BARs in qemu (head of master branch). It's very likely they will be fixed in next qemu release.
The 1st one is described here (this issue causing problems if 64bit BAR is mapped below 4GB and Linux guest OS version is < 2.6.27): http://www.mail-archive.com/qemu-devel@nongnu.org/msg94522.html
The 2nd one is just a typo in i440fx init code (this issue is causing problems if somebody is going to access 64bit PCI memory - memory will be inaccessible): http://www.mail-archive.com/qemu-devel@nongnu.org/msg99423.html
The 3nd issue is related to a case of HUGE PCI bars when BAR size is 4GB and over. Qemu for some reasons reports zero size in this case. New seabios should handle huge bars well.
I've sent the patches for the first two issues. If they are all applied problems except the "huge BARs issue" should gone.