On Tue, Nov 20, 2012 at 05:45:30PM +0100, Gerd Hoffmann wrote:
Add a piix4 memory setup function to make the control flow more clear.
[...]
static void pci_bios_map_devices(struct pci_bus *busses) { pcimem_start = RamSize;
- /* chipset specific memory setup */
- pci_find_init_device(pci_mem_addr_tbl, NULL);
I find setting the pcimem_start in the middle of the resource assignment to be a little confusing. How about just setting it up prior to the scan - something like the below?
-Kevin
diff --git a/src/pciinit.c b/src/pciinit.c index d61f0a8..a2ee86c 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -226,6 +226,35 @@ static void pci_bios_init_devices(void)
/**************************************************************** + * Platform device initialization + ****************************************************************/ + +void i440fx_mem_addr_init(struct pci_device *dev, void *arg) +{ + if (RamSize <= 0x80000000) + pcimem_start = 0x80000000; + else if (RamSize <= 0xc0000000) + pcimem_start = 0xc0000000; + + mtrr_base = pcimem_start; +} + +static const struct pci_device_id pci_platform_tbl[] = { + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, + i440fx_mem_addr_init), + PCI_DEVICE_END +}; + +static void pci_bios_init_platform(void) +{ + struct pci_device *pci; + foreachpci(pci) { + pci_init_device(pci_platform_tbl, pci, NULL); + } +} + + +/**************************************************************** * Bus initialization ****************************************************************/
@@ -583,8 +612,6 @@ static void pci_region_map_entries(struct pci_bus *busses, struct pci_region *r)
static void pci_bios_map_devices(struct pci_bus *busses) { - pcimem_start = RamSize; - if (pci_bios_init_root_regions(busses)) { struct pci_region r64_mem, r64_pref; r64_mem.list = NULL; @@ -647,6 +674,9 @@ pci_setup(void) dprintf(1, "=== PCI device probing ===\n"); pci_probe_devices();
+ pcimem_start = RamSize; + pci_bios_init_platform(); + dprintf(1, "=== PCI new allocation pass #1 ===\n"); struct pci_bus *busses = malloc_tmp(sizeof(*busses) * (MaxPCIBus + 1)); if (!busses) {