aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2011-06-20 22:20:43 -0400
committerKevin O'Connor <kevin@koconnor.net>2011-06-20 23:52:16 -0400
commit3f3e58d29f0cbf1f084aedf4e69d19ac2b9ff6b8 (patch)
treef531851c291e17a2e46bd58dc8dfd5eb9ab1a2ef
parent862d5fb01190464711e3a91244a0309a398b0f59 (diff)
downloadseabios-3f3e58d29f0cbf1f084aedf4e69d19ac2b9ff6b8.zip
seabios-3f3e58d29f0cbf1f084aedf4e69d19ac2b9ff6b8.tar.gz
seabios-3f3e58d29f0cbf1f084aedf4e69d19ac2b9ff6b8.tar.bz2
Convert ATA detection code to use struct pci_device.
-rw-r--r--src/ata.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ata.c b/src/ata.c
index 2630431..e07aabe 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -11,7 +11,7 @@
#include "cmos.h" // inb_cmos
#include "pic.h" // enable_hwirq
#include "biosvar.h" // GET_EBDA
-#include "pci.h" // foreachbdf
+#include "pci.h" // foreachpci
#include "pci_ids.h" // PCI_CLASS_STORAGE_OTHER
#include "pci_regs.h" // PCI_INTERRUPT_LINE
#include "boot.h" // boot_add_hd
@@ -1032,21 +1032,20 @@ static const struct pci_device_id pci_ata_tbl[] = {
static void
ata_init(void)
{
- // Scan PCI bus for ATA adapters
- int pcicount=0;
- int bdf, max;
- foreachbdf(bdf, max) {
- pcicount++;
- pci_init_device(pci_ata_tbl, bdf, NULL);
- }
-
- if (!CONFIG_COREBOOT && !pcicount) {
+ if (!CONFIG_COREBOOT && !PCIDevices) {
// No PCI devices found - probably a QEMU "-M isapc" machine.
// Try using ISA ports for ATA controllers.
init_controller(-1, IRQ_ATA1
, PORT_ATA1_CMD_BASE, PORT_ATA1_CTRL_BASE, 0);
init_controller(-1, IRQ_ATA2
, PORT_ATA2_CMD_BASE, PORT_ATA2_CTRL_BASE, 0);
+ return;
+ }
+
+ // Scan PCI bus for ATA adapters
+ struct pci_device *pci;
+ foreachpci(pci) {
+ pci_init_device(pci_ata_tbl, pci->bdf, NULL);
}
}