aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2013-03-08 19:31:14 -0500
committerKevin O'Connor <kevin@koconnor.net>2013-03-08 19:55:26 -0500
commit96d4c438656b01927a2cb97d395f5e286d6195cf (patch)
treedcc2363d77bcfb31900bf2987b6081aef0503955
parentdc15c8d5d3ab012e4c5b27e7703aca59c4c19ef1 (diff)
downloadseabios-96d4c438656b01927a2cb97d395f5e286d6195cf.tar.gz
shadow: Don't use PCIDevices list in make_bios_readonly().
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>
-rw-r--r--src/shadow.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/shadow.c b/src/shadow.c
index e971fe9..967eb8e 100644
--- a/src/shadow.c
+++ b/src/shadow.c
@@ -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