Skip to contentSkip to conversation

Set RAM size in i440FX PCI configuration

PATCH New Ed Swierk 1 participant 1 message Sep 13, 2006

lore
Share & tools
lore

Ed Swierk

author
#0 lore raw

PATCH 1/1 Set RAM size in i440FX PCI configuration

Currently qemu's i440FX PCI bridge emulation code does not set the registers indicating the amount of RAM installed in each DIMM slot. LinuxBIOS relies on this information to properly set up RAM before booting Linux.

The attached patch sets a i440FX configuration register indicating the highest RAM address in all slots, in units of 8MB. Since this is an 8-bit value, the maximum is capped at 2040MB.

--Ed

hw/piix_pci.c +5 -1
@@ -42,7 +42,7 @@
 
 static void piix3_set_irq(PCIDevice *pci_dev, void *pic, int irq_num, int level);
 
-PCIBus *i440fx_init(void)
+PCIBus *i440fx_init(int ram_size)
 {
     PCIBus *b;
     PCIDevice *d;
@@ -73,6 +73,10 @@
     d->config[0x0a] = 0x00; // class_sub = host2pci
     d->config[0x0b] = 0x06; // class_base = PCI_bridge
     d->config[0x0e] = 0x00; // header_type
+    ram_size = ram_size / 8 / 1024 / 1024;
+    if (ram_size > 255)
+        ram_size = 255;
+    d->config[0x57] = ram_size;
     return b;
 }
 
hw/pc.c +1 -1
@@ -747,7 +749,7 @@
     }
 
     if (pci_enabled) {
-        pci_bus = i440fx_init();
+        pci_bus = i440fx_init(ram_size);
         piix3_devfn = piix3_init(pci_bus);
     } else {
         pci_bus = NULL;
vl.h +1 -1
@@ -695,7 +695,7 @@
 PCIBus *pci_vpb_init(void *pic);
 
 /* piix_pci.c */
-PCIBus *i440fx_init(void);
+PCIBus *i440fx_init(int ram_size);
 int piix3_init(PCIBus *bus);
 void pci_bios_init(void);