diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2008-11-09 15:33:47 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2008-11-09 15:33:47 -0500 |
commit | be19cdc4dce80711fad94e6db0ab428761f3170d (patch) | |
tree | 17e4d7ae41c11f268a735f00d69852b0bb701a0f /src/shadow.c | |
parent | ceea03c235f337062b3ded69cc658ea759e254f6 (diff) | |
download | seabios-be19cdc4dce80711fad94e6db0ab428761f3170d.tar.gz |
Overhaul PCI config functions.
Remove PCIDevice struct and replace with a "u16" with BDF -
Bus/Device/Function. This simplifies the code in several places.
Also, scan for and store the maximum PCI bus found during startup.
The previous config option CONFIG_PCI_BUS_COUNT is no longer
needed and has been removed.
Diffstat (limited to 'src/shadow.c')
-rw-r--r-- | src/shadow.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/shadow.c b/src/shadow.c index b99c139e..16319545 100644 --- a/src/shadow.c +++ b/src/shadow.c @@ -20,11 +20,11 @@ // Enable shadowing and copy bios. static void -copy_bios(PCIDevice d) +copy_bios(u16 bdf) { - int v = pci_config_readb(d, 0x59); + int v = pci_config_readb(bdf, 0x59); v |= 0x30; - pci_config_writeb(d, 0x59, v); + pci_config_writeb(bdf, 0x59, v); memcpy((void *)BUILD_BIOS_ADDR, (void *)BUILD_BIOS_TMP_ADDR , BUILD_BIOS_SIZE); } @@ -39,10 +39,8 @@ make_bios_writable() dprintf(3, "enabling shadow ram\n"); // Locate chip controlling ram shadowing. - PCIDevice d; - int ret = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441 - , 0, &d); - if (ret) { + int bdf = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, 0); + if (bdf < 0) { dprintf(1, "Unable to unlock ram - bridge not found\n"); return; } @@ -57,10 +55,10 @@ make_bios_writable() // temporary storage area so that memory does not change under // the executing code. u32 pos = (u32)copy_bios - BUILD_BIOS_ADDR + BUILD_BIOS_TMP_ADDR; - void (*func)(PCIDevice) = (void*)pos; - func(d); + void (*func)(u16 bdf) = (void*)pos; + func(bdf); } else { - copy_bios(d); + copy_bios(bdf); } // Clear the temporary area. @@ -76,16 +74,14 @@ make_bios_readonly() dprintf(3, "locking shadow ram\n"); - PCIDevice d; - int ret = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441 - , 0, &d); - if (ret) { + int bdf = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, 0); + if (bdf < 0) { dprintf(1, "Unable to lock ram - bridge not found\n"); return; } wbinvd(); - int v = pci_config_readb(d, 0x59); + int v = pci_config_readb(bdf, 0x59); v = (v & 0x0f) | (0x10); - pci_config_writeb(d, 0x59, v); + pci_config_writeb(bdf, 0x59, v); } |