Deleted Added
full compact
28c28
< * $Id: ata-all.c,v 1.3 1999/03/05 09:43:30 sos Exp $
---
> * $Id: ata-all.c,v 1.4 1999/03/07 21:49:14 sos Exp $
43a44,45
> #include <vm/vm.h>
> #include <vm/pmap.h>
44a47
> #include <machine/smp.h>
55a59,62
> #define MIN(a,b) ((a)>(b)?(b):(a))
> #if NSMP == 0
> #define isa_apic_irq(x) x
> #endif
67c74
< static int32_t ata_probe(int32_t, int32_t, int32_t *);
---
> static int32_t ata_probe(int32_t, int32_t, int32_t, pcici_t, int32_t *);
87c94,95
< res=ata_probe(devp->id_iobase, devp->id_iobase+ATA_ALTPORT, &devp->id_unit);
---
> res = ata_probe(devp->id_iobase, devp->id_iobase + ATA_ALTPORT, 0, 0,
> &devp->id_unit);
118,121d125
< case 0x71118086:
< return "Intel PIIX4 IDE controller";
< case 0x70108086:
< return "Intel PIIX3 IDE controller";
123a128,131
> case 0x70108086:
> return "Intel PIIX3 IDE controller";
> case 0x71118086:
> return "Intel PIIX4 IDE controller";
125a134,136
> case 0x522910b9:
> return "AcerLabs Aladdin IDE controller";
> #if 0
130,131c141
< case 0x522910b9:
< return "Acer Aladdin IV/V IDE controller";
---
> #endif
143c153,154
< int32_t iobase_1, iobase_2, altiobase_1, altiobase_2, irq1, irq2;
---
> int32_t iobase_1, iobase_2, altiobase_1, altiobase_2;
> int32_t bmaddr_1 = 0, bmaddr_2 = 0, irq1, irq2;
152c163
< printf("ata: type=%08x class=%08x cmd=%08x\n", type, class, cmd);
---
> printf("ata%d: type=%08x class=%08x cmd=%08x\n", unit, type, class, cmd);
155,177c166,167
< switch (type) {
< case 0x71118086:
< case 0x70108086:
< case 0x12308086: /* Intel PIIX, PIIX3, PIIX4 */
< break;
<
< case 0x05711106: /* VIA Apollo chipset family */
< break;
<
< case 0x4d33105a: /* Promise controllers */
< break;
<
< case 0x01021078: /* Cyrix 5530 */
< break;
<
< case 0x522910B9: /* Acer Aladdin IV/V (M5229) */
< break;
< default:
< /* everybody else */
< break;
< }
<
< if (type == 0x4d33105a) { /* the Promise is special */
---
> /* if this is at Promise controller handle it specially */
> if (type == 0x4d33105a) {
182a173,174
> bmaddr_1 = pci_conf_read(tag, 0x20) & 0xfffc;
> bmaddr_2 = bmaddr_1 + ATA_BM_OFFSET1;
183a176
> printf("ata-pci%d: Busmastering DMA supported\n", unit);
184a178
> /* everybody else seems to do it this way */
205a200,217
>
> /* is this controller busmaster capable ? */
> if (pci_conf_read(tag, PCI_CLASS_REG) & 0x8000) {
> /* is busmastering support turned on ? */
> if ((pci_conf_read(tag, PCI_COMMAND_STATUS_REG) & 5) == 5) {
> /* is there a valid port range to connect to ? */
> if ((bmaddr_1 = pci_conf_read(tag, 0x20) & 0xfffc)) {
> bmaddr_2 = bmaddr_1 + ATA_BM_OFFSET1;
> printf("ata-pci%d: Busmastering DMA supported\n", unit);
> }
> else
> printf("ata-pci%d: Busmastering DMA not configured\n",unit);
> }
> else
> printf("ata-pci%d: Busmastering DMA not enabled\n", unit);
> }
> else
> printf("ata-pci%d: Busmastering DMA not supported\n", unit);
209c221,222
< if (ata_probe(iobase_1, altiobase_1, &lun)) {
---
> lun = 0;
> if (ata_probe(iobase_1, altiobase_1, bmaddr_1, tag, &lun)) {
211c224,225
< register_intr(irq1, 0, 0, (inthand2_t *)ataintr, &bio_imask, lun);
---
> register_intr(irq1, (int)"", 0, (inthand2_t *)ataintr,
> &bio_imask, lun);
220c234
< lun, iobase_1, irq1, unit);
---
> lun, iobase_1, isa_apic_irq(irq1), unit);
222c236,237
< if (ata_probe(iobase_2, altiobase_2, &lun)) {
---
> lun = 1;
> if (ata_probe(iobase_2, altiobase_2, bmaddr_2, tag, &lun)) {
224c239,240
< register_intr(irq2, 0, 0, (inthand2_t *)ataintr, &bio_imask, lun);
---
> register_intr(irq2, (int)"", 0, (inthand2_t *)ataintr,
> &bio_imask, lun);
230c246
< lun, iobase_2, irq2, unit);
---
> lun, iobase_2, isa_apic_irq(irq2), unit);
245c261,262
< ata_probe(int32_t ioaddr, int32_t altioaddr, int32_t *unit)
---
> ata_probe(int32_t ioaddr, int32_t altioaddr, int32_t bmaddr,
> pcici_t tag, int32_t *unit)
257c274
< printf("ata: unit of of range(%d)\n", lun);
---
> printf("ata: unit out of range(%d)\n", lun);
271c288,289
< scp->unit = lun;
---
> scp->unit = *unit;
> scp->lun = lun;
278c296
< scp->unit, scp->ioaddr, scp->altioaddr);
---
> scp->lun, scp->ioaddr, scp->altioaddr);
294c312
< scp->unit, mask, status0, status1);
---
> scp->lun, mask, status0, status1);
307a326
> DELAY(1);
336c355
< scp->unit, mask, status0, status1);
---
> scp->lun, mask, status0, status1);
381c400
< printf("ata%d: devices = 0x%x\n", scp->unit, scp->devices);
---
> printf("ata%d: devices = 0x%x\n", scp->lun, scp->devices);
383,384d401
< if (!(scp->devices & (ATA_ATA_MASTER|ATA_ATAPI_MASTER)))
< scp->flags |= ATA_F_SLAVE_ONLY;
391,392c408,412
< *unit = scp->unit;
< atadevices[scp->unit] = scp;
---
> *unit = scp->lun;
> scp->tag = tag;
> if (bmaddr)
> scp->bmaddr = bmaddr;
> atadevices[scp->lun] = scp;
405d424
<
408,410d426
< #ifdef ATA_DEBUG
< printf("ataintr: entered unit=%d\n", unit);
< #endif
442,443c458,460
< if (intcount++ < 5)
< printf("ata%d: unwanted interrupt\n", unit);
---
> if (intcount++ < 10)
> printf("ata%d: unwanted interrupt %d\n", unit, intcount);
> inb(scp->ioaddr + ATA_STATUS);
459c476
< if (scp->active) {
---
> if (scp->active != ATA_IDLE) {
463a481
> #if NATADISK > 0
467a486,489
> #ifdef ATA_DEBUG
> printf("ata_start: started ata, leaving\n");
> #endif
> return;
468a491
> #endif
473a497,500
> #ifdef ATA_DEBUG
> printf("ata_start: started atapi, leaving\n");
> #endif
> return;
478c505
< ata_wait(struct ata_softc *scp, u_int8_t mask)
---
> ata_wait(struct ata_softc *scp, int32_t device, u_int8_t mask)
483c510
< while (timeout++ <= 50000) { /* timeout 5 secs */
---
> while (timeout++ <= 500000) { /* timeout 5 secs */
485,486c512,517
< if ((status == 0xff) && (scp->flags & ATA_F_SLAVE_ONLY)) {
< outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE);
---
>
> /* if drive fails status, reselect the drive just to be sure */
> if (status == 0xff) {
> printf("ata%d: %s: no status, reselecting device\n",
> scp->lun, device?"slave":"master");
> outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device);
510c541
< u_int32_t count, int32_t flags)
---
> u_int32_t count, u_int32_t feature, int32_t flags)
511a543,546
> #ifdef ATA_DEBUG
> printf("ata_command: addr=%04x, device=%02x, cmd=%02x, c=%d, h=%d, s=%d, count=%d, flags=%02x\n", scp->ioaddr, device, command, cylinder, head, sector, count, flags);
> #endif
>
513,515c548,550
< if (ata_wait(scp, 0) < 0) {
< printf("ata_command: timeout waiting to give command");
< return -1;
---
> if (ata_wait(scp, device, 0) < 0) {
> printf("ata%d: %s: timeout waiting to give command s=%02x e=%02x\n",
> scp->lun, device?"slave":"master", scp->status, scp->error);
517,518c552
< outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device | head);
< outb(scp->ioaddr + ATA_PRECOMP, 0); /* no precompensation */
---
> outb(scp->ioaddr + ATA_FEATURE, feature);
520a555
> outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device | head);
524c559
< if (scp->active && flags != ATA_IMMEDIATE)
---
> if (scp->active != ATA_IDLE && flags != ATA_IMMEDIATE)
547a583,585
> #ifdef ATA_DEBUG
> printf("ata_command: leaving\n");
> #endif
590c628
< #endif
---
> #endif /* NATA > 0 */