diff --git a/src/hw/ata.c b/src/hw/ata.c index d805706..84e747d 100644 --- a/src/hw/ata.c +++ b/src/hw/ata.c @@ -739,7 +739,8 @@ init_drive_atapi(struct atadrive_s *dummy, u16 *buffer) u8 iscd = ((buffer[0] >> 8) & 0x1f) == 0x05; char model[MAXMODEL+1]; char *desc = znprintf(MAXDESCSIZE - , "DVD/CD [ata%d-%d: %s ATAPI-%d %s]" + , "ATA@%04x:%u-%u: %s ATAPI-%d %s" + , adrive->chan_gf->pci_bdf , adrive->chan_gf->chanid, adrive->slave , ata_extract_model(model, MAXMODEL, buffer) , ata_extract_version(buffer) @@ -791,7 +792,8 @@ init_drive_ata(struct atadrive_s *dummy, u16 *buffer) } char model[MAXMODEL+1]; char *desc = znprintf(MAXDESCSIZE - , "ata%d-%d: %s ATA-%d Hard-Disk (%u %ciBytes)" + , "ATA@%04x:%u-%u: %s ATA-%d Hard-Disk (%u %ciBytes)" + , adrive->chan_gf->pci_bdf , adrive->chan_gf->chanid, adrive->slave , ata_extract_model(model, MAXMODEL, buffer) , ata_extract_version(buffer) @@ -865,8 +867,8 @@ ata_detect(void *data) outb(0xaa, iobase1+ATA_CB_SN); u8 sc = inb(iobase1+ATA_CB_SC); u8 sn = inb(iobase1+ATA_CB_SN); - dprintf(6, "ata_detect ata%d-%d: sc=%x sn=%x dh=%x\n" - , chan_gf->chanid, slave, sc, sn, dh); + dprintf(6, "ata_detect ATA@%04x:%u-%u: sc=%x sn=%x dh=%x\n" + , chan_gf->pci_bdf, chan_gf->chanid, slave, sc, sn, dh); if (sc != 0x55 || sn != 0xaa || dh != newdh) continue; @@ -913,24 +915,23 @@ ata_detect(void *data) // Initialize an ata controller and detect its drives. static void -init_controller(struct pci_device *pci, int irq +init_controller(struct pci_device *pci, int irq, u32 chan , u32 port1, u32 port2, u32 master) { - static int chanid = 0; struct ata_channel_s *chan_gf = malloc_fseg(sizeof(*chan_gf)); if (!chan_gf) { warn_noalloc(); return; } - chan_gf->chanid = chanid++; + chan_gf->chanid = chan; chan_gf->irq = irq; chan_gf->pci_bdf = pci ? pci->bdf : -1; chan_gf->pci_tmp = pci; chan_gf->iobase1 = port1; chan_gf->iobase2 = port2; chan_gf->iomaster = master; - dprintf(1, "ATA controller %d at %x/%x/%x (irq %d dev %x)\n" - , chanid, port1, port2, master, irq, chan_gf->pci_bdf); + dprintf(1, "ATA controller ATA@%04x:%u (io %x/%x/%x irq %d)\n" + , chan_gf->pci_bdf, chan, port1, port2, master, irq); run_thread(ata_detect, chan_gf); } @@ -966,7 +967,7 @@ init_pciata(struct pci_device *pci, u8 prog_if) port2 = PORT_ATA1_CTRL_BASE; irq = IRQ_ATA1; } - init_controller(pci, irq, port1, port2, master); + init_controller(pci, irq, 0, port1, port2, master); if (prog_if & 4) { port1 = (pci_config_readl(bdf, PCI_BASE_ADDRESS_2) @@ -979,7 +980,7 @@ init_pciata(struct pci_device *pci, u8 prog_if) port2 = PORT_ATA2_CTRL_BASE; irq = IRQ_ATA2; } - init_controller(pci, irq, port1, port2, master ? master + 8 : 0); + init_controller(pci, irq, 1, port1, port2, master ? master + 8 : 0); } static void @@ -1011,9 +1012,9 @@ ata_scan(void) if (CONFIG_QEMU && hlist_empty(&PCIDevices)) { // No PCI devices found - probably a QEMU "-M isapc" machine. // Try using ISA ports for ATA controllers. - init_controller(NULL, IRQ_ATA1 + init_controller(NULL, IRQ_ATA1, 0 , PORT_ATA1_CMD_BASE, PORT_ATA1_CTRL_BASE, 0); - init_controller(NULL, IRQ_ATA2 + init_controller(NULL, IRQ_ATA2, 1 , PORT_ATA2_CMD_BASE, PORT_ATA2_CTRL_BASE, 0); return; }