]> xenbits.xensource.com Git - seabios.git/commitdiff
shadow: Don't use PCIDevices list in make_bios_readonly().
authorKevin O'Connor <kevin@koconnor.net>
Sat, 9 Mar 2013 00:31:14 +0000 (19:31 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 9 Mar 2013 00:55:26 +0000 (19:55 -0500)
The make_bios_readonly() call is invoked from resume.  The PCIDevices
list is only valid during POST.  Cache the necessary PCI BDF ids so
that PCIDevices isn't needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/shadow.c

index e971fe96189ae5b139537b7c8871d50e3ef286a8..967eb8e70f339f6835d36e03a162badf5e353eaa 100644 (file)
@@ -97,23 +97,7 @@ make_bios_readonly_intel(u16 bdf, u32 pam0)
     pci_config_writeb(bdf, pam0, 0x10);
 }
 
-static void i440fx_bios_make_readonly(struct pci_device *pci, void *arg)
-{
-    make_bios_readonly_intel(pci->bdf, I440FX_PAM0);
-}
-
-void mch_bios_make_readonly(struct pci_device *pci, void *arg)
-{
-    make_bios_readonly_intel(pci->bdf, Q35_HOST_BRIDGE_PAM0);
-}
-
-static const struct pci_device_id dram_controller_make_readonly_tbl[] = {
-    PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441,
-               i440fx_bios_make_readonly),
-    PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_Q35_MCH,
-               mch_bios_make_readonly),
-    PCI_DEVICE_END
-};
+static int ShadowBDF = -1;
 
 // Make the 0xc0000-0x100000 area read/writable.
 void
@@ -133,11 +117,13 @@ make_bios_writable(void)
         if (vendor == PCI_VENDOR_ID_INTEL
             && device == PCI_DEVICE_ID_INTEL_82441) {
             make_bios_writable_intel(bdf, I440FX_PAM0);
+            ShadowBDF = bdf;
             return;
         }
         if (vendor == PCI_VENDOR_ID_INTEL
             && device == PCI_DEVICE_ID_INTEL_Q35_MCH) {
             make_bios_writable_intel(bdf, Q35_HOST_BRIDGE_PAM0);
+            ShadowBDF = bdf;
             return;
         }
     }
@@ -150,12 +136,18 @@ make_bios_readonly(void)
 {
     if (!CONFIG_QEMU || runningOnXen())
         return;
-
     dprintf(3, "locking shadow ram\n");
-    struct pci_device *pci = pci_find_init_device(
-        dram_controller_make_readonly_tbl, NULL);
-    if (!pci)
+
+    if (ShadowBDF < 0) {
         dprintf(1, "Unable to lock ram - bridge not found\n");
+        return;
+    }
+
+    u16 device = pci_config_readw(ShadowBDF, PCI_DEVICE_ID);
+    if (device == PCI_DEVICE_ID_INTEL_82441)
+        make_bios_readonly_intel(ShadowBDF, I440FX_PAM0);
+    else
+        make_bios_readonly_intel(ShadowBDF, Q35_HOST_BRIDGE_PAM0);
 }
 
 void