ata-all.c (72096) | ata-all.c (72106) |
---|---|
1/*- 2 * Copyright (c) 1998,1999,2000,2001 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 1998,1999,2000,2001 S�ren Schmidt 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/sys/dev/ata/ata-all.c 72096 2001-02-06 12:49:33Z sos $ | 28 * $FreeBSD: head/sys/dev/ata/ata-all.c 72106 2001-02-06 16:44:25Z sos $ |
29 */ 30 31#include "card.h" 32#include "pci.h" 33#include "opt_global.h" 34#include "opt_isa.h" 35#include "opt_ata.h" 36#include <sys/param.h> --- 23 unchanged lines hidden (view full) --- 60#include <dev/ata/ata-disk.h> 61#include <dev/ata/atapi-all.h> 62 63/* misc defines */ 64#define IOMASK 0xfffffffc 65#define ATA_IOADDR_RID 0 66#define ATA_ALTADDR_RID 1 67#define ATA_BMADDR_RID 2 | 29 */ 30 31#include "card.h" 32#include "pci.h" 33#include "opt_global.h" 34#include "opt_isa.h" 35#include "opt_ata.h" 36#include <sys/param.h> --- 23 unchanged lines hidden (view full) --- 60#include <dev/ata/ata-disk.h> 61#include <dev/ata/atapi-all.h> 62 63/* misc defines */ 64#define IOMASK 0xfffffffc 65#define ATA_IOADDR_RID 0 66#define ATA_ALTADDR_RID 1 67#define ATA_BMADDR_RID 2 |
68#if NPCI > 0 | 68#define ATA_IRQ_RID 0 |
69#define ATA_MASTERDEV(dev) ((pci_get_progif(dev) & 0x80) && \ 70 (pci_get_progif(dev) & 0x05) != 0x05) | 69#define ATA_MASTERDEV(dev) ((pci_get_progif(dev) & 0x80) && \ 70 (pci_get_progif(dev) & 0x05) != 0x05) |
71#else 72#define ATA_MASTERDEV(dev) (1) 73#endif | |
74 75/* prototypes */ 76static int ata_probe(device_t); 77static int ata_attach(device_t); 78static int ata_detach(device_t); 79static int ata_resume(device_t); 80static void ata_boot_attach(void); 81static void ata_intr(void *); --- 19 unchanged lines hidden (view full) --- 101 {0x0306d041, "Generic ATA"}, /* PNP0603 */ 102 {0} 103}; 104 105static int 106ata_isa_probe(device_t dev) 107{ 108 struct ata_softc *scp = device_get_softc(dev); | 71 72/* prototypes */ 73static int ata_probe(device_t); 74static int ata_attach(device_t); 75static int ata_detach(device_t); 76static int ata_resume(device_t); 77static void ata_boot_attach(void); 78static void ata_intr(void *); --- 19 unchanged lines hidden (view full) --- 98 {0x0306d041, "Generic ATA"}, /* PNP0603 */ 99 {0} 100}; 101 102static int 103ata_isa_probe(device_t dev) 104{ 105 struct ata_softc *scp = device_get_softc(dev); |
109 struct resource *port; | 106 struct resource *io; |
110 int rid; 111 u_long tmp; 112 113 /* check isapnp ids */ 114 if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO) 115 return ENXIO; 116 | 107 int rid; 108 u_long tmp; 109 110 /* check isapnp ids */ 111 if (ISA_PNP_PROBE(device_get_parent(dev), dev, ata_ids) == ENXIO) 112 return ENXIO; 113 |
117 /* allocate the port range */ | 114 /* allocate the io port range to get the start address */ |
118 rid = ATA_IOADDR_RID; | 115 rid = ATA_IOADDR_RID; |
119 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 120 ATA_IOSIZE, RF_ACTIVE); 121 if (!port) | 116 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 117 ATA_IOSIZE, RF_ACTIVE); 118 if (!io) |
122 return ENOMEM; 123 | 119 return ENOMEM; 120 |
124 /* alloctate the altport range */ 125 if (bus_get_resource(dev, SYS_RES_IOPORT, 1, &tmp, &tmp)) { 126 bus_set_resource(dev, SYS_RES_IOPORT, 1, 127 rman_get_start(port) + ATA_ALTOFFSET, 128 ATA_ALTIOSIZE); | 121 /* set the altport range */ 122 if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, &tmp, &tmp)) { 123 bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, 124 rman_get_start(io) + ATA_ALTOFFSET, ATA_ALTIOSIZE); |
129 } | 125 } |
130 bus_release_resource(dev, SYS_RES_IOPORT, 0, port); | 126 127 bus_release_resource(dev, SYS_RES_IOPORT, rid, io); |
131 scp->channel = 0; 132 scp->flags |= ATA_USE_16BIT; 133 return ata_probe(dev); 134} 135 136static device_method_t ata_isa_methods[] = { 137 /* device interface */ 138 DEVMETHOD(device_probe, ata_isa_probe), --- 11 unchanged lines hidden (view full) --- 150DRIVER_MODULE(ata, isa, ata_isa_driver, ata_devclass, 0, 0); 151#endif 152 153#if NCARD > 0 154static int 155ata_pccard_probe(device_t dev) 156{ 157 struct ata_softc *scp = device_get_softc(dev); | 128 scp->channel = 0; 129 scp->flags |= ATA_USE_16BIT; 130 return ata_probe(dev); 131} 132 133static device_method_t ata_isa_methods[] = { 134 /* device interface */ 135 DEVMETHOD(device_probe, ata_isa_probe), --- 11 unchanged lines hidden (view full) --- 147DRIVER_MODULE(ata, isa, ata_isa_driver, ata_devclass, 0, 0); 148#endif 149 150#if NCARD > 0 151static int 152ata_pccard_probe(device_t dev) 153{ 154 struct ata_softc *scp = device_get_softc(dev); |
158 struct resource *port; 159 int rid, len; | 155 struct resource *io; 156 int rid, len, start, end; 157 u_long tmp; |
160 | 158 |
161 /* allocate the port range */ | 159 /* allocate the io range to get start and length */ |
162 rid = ATA_IOADDR_RID; 163 len = bus_get_resource_count(dev, SYS_RES_IOPORT, rid); | 160 rid = ATA_IOADDR_RID; 161 len = bus_get_resource_count(dev, SYS_RES_IOPORT, rid); |
164 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, len, RF_ACTIVE); 165 if (!port) | 162 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 163 ATA_IOSIZE, RF_ACTIVE); 164 if (!io) |
166 return ENOMEM; 167 | 165 return ENOMEM; 166 |
167 /* reallocate the io address to only cover the io ports */ 168 start = rman_get_start(io); 169 end = start + ATA_IOSIZE - 1; 170 bus_release_resource(dev, SYS_RES_IOPORT, rid, io); 171 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 172 start, end, ATA_IOSIZE, RF_ACTIVE); 173 bus_release_resource(dev, SYS_RES_IOPORT, rid, io); 174 |
|
168 /* 169 * if we got more than the default ATA_IOSIZE ports, this is likely | 175 /* 176 * if we got more than the default ATA_IOSIZE ports, this is likely |
170 * a pccard system where the altio ports are located just after the 171 * normal io ports, so no need to allocate them. | 177 * a pccard system where the altio ports are located at offset 14 178 * otherwise its the normal altio offset |
172 */ | 179 */ |
173 if (len <= ATA_IOSIZE) { 174 bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, 175 rman_get_start(port) + ATA_ALTOFFSET, ATA_ALTIOSIZE); | 180 if (bus_get_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, &tmp, &tmp)) { 181 if (len > ATA_IOSIZE) { 182 bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, 183 start + ATA_PCCARD_ALTOFFSET, ATA_ALTIOSIZE); 184 } 185 else { 186 bus_set_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, 187 start + ATA_ALTOFFSET, ATA_ALTIOSIZE); 188 } |
176 } | 189 } |
177 bus_release_resource(dev, SYS_RES_IOPORT, 0, port); | 190 else 191 return ENOMEM; 192 |
178 scp->channel = 0; 179 scp->flags |= (ATA_USE_16BIT | ATA_NO_SLAVE); 180 return ata_probe(dev); 181} 182 183static device_method_t ata_pccard_methods[] = { 184 /* device interface */ 185 DEVMETHOD(device_probe, ata_pccard_probe), --- 9 unchanged lines hidden (view full) --- 195}; 196 197DRIVER_MODULE(ata, pccard, ata_pccard_driver, ata_devclass, 0, 0); 198#endif 199 200#if NPCI > 0 201struct ata_pci_softc { 202 struct resource *bmio; | 193 scp->channel = 0; 194 scp->flags |= (ATA_USE_16BIT | ATA_NO_SLAVE); 195 return ata_probe(dev); 196} 197 198static device_method_t ata_pccard_methods[] = { 199 /* device interface */ 200 DEVMETHOD(device_probe, ata_pccard_probe), --- 9 unchanged lines hidden (view full) --- 210}; 211 212DRIVER_MODULE(ata, pccard, ata_pccard_driver, ata_devclass, 0, 0); 213#endif 214 215#if NPCI > 0 216struct ata_pci_softc { 217 struct resource *bmio; |
203 struct resource bmio_1; 204 struct resource bmio_2; | 218 int bmaddr; |
205 struct resource *irq; 206 int irqcnt; 207}; 208 209int 210ata_find_dev(device_t dev, u_int32_t type, u_int32_t revid) 211{ 212 device_t *children, child; --- 194 unchanged lines hidden (view full) --- 407 case 0x522910b9: /* Aladdin need to activate the ATAPI FIFO */ 408 pci_write_config(dev, 0x53, 409 (pci_read_config(dev, 0x53, 1) & ~0x01) | 0x02, 1); 410 break; 411 412 case 0x4d38105a: /* Promise 66 & 100 need their clock changed */ 413 case 0x4d30105a: 414 case 0x0d30105a: | 219 struct resource *irq; 220 int irqcnt; 221}; 222 223int 224ata_find_dev(device_t dev, u_int32_t type, u_int32_t revid) 225{ 226 device_t *children, child; --- 194 unchanged lines hidden (view full) --- 421 case 0x522910b9: /* Aladdin need to activate the ATAPI FIFO */ 422 pci_write_config(dev, 0x53, 423 (pci_read_config(dev, 0x53, 1) & ~0x01) | 0x02, 1); 424 break; 425 426 case 0x4d38105a: /* Promise 66 & 100 need their clock changed */ 427 case 0x4d30105a: 428 case 0x0d30105a: |
415 outb(rman_get_start(sc->bmio) + 0x11, 416 inb(rman_get_start(sc->bmio) + 0x11) | 0x0a); | 429 ATA_OUTB(sc->bmio, 0x11, ATA_INB(sc->bmio, 0x11) | 0x0a); |
417 /* FALLTHROUGH */ 418 419 case 0x4d33105a: /* Promise (all) need burst mode to be turned on */ | 430 /* FALLTHROUGH */ 431 432 case 0x4d33105a: /* Promise (all) need burst mode to be turned on */ |
420 outb(rman_get_start(sc->bmio) + 0x1f, 421 inb(rman_get_start(sc->bmio) + 0x1f) | 0x01); | 433 ATA_OUTB(sc->bmio, 0x1f, ATA_INB(sc->bmio, 0x1f) | 0x01); |
422 break; 423 424 case 0x00041103: /* HighPoint */ 425 switch (pci_get_revid(dev)) { 426 case 0x00: 427 case 0x01: 428 /* turn off interrupt prediction */ 429 pci_write_config(dev, 0x51, --- 42 unchanged lines hidden (view full) --- 472 pci_write_config(dev, 0x50, 473 pci_read_config(dev, 0x50, 4) | 0x070f070f, 4); 474 } 475 break; 476 477 case 0x10001042: /* RZ 100? known bad, no DMA */ 478 case 0x10011042: 479 case 0x06401095: /* CMD 640 known bad, no DMA */ | 434 break; 435 436 case 0x00041103: /* HighPoint */ 437 switch (pci_get_revid(dev)) { 438 case 0x00: 439 case 0x01: 440 /* turn off interrupt prediction */ 441 pci_write_config(dev, 0x51, --- 42 unchanged lines hidden (view full) --- 484 pci_write_config(dev, 0x50, 485 pci_read_config(dev, 0x50, 4) | 0x070f070f, 4); 486 } 487 break; 488 489 case 0x10001042: /* RZ 100? known bad, no DMA */ 490 case 0x10011042: 491 case 0x06401095: /* CMD 640 known bad, no DMA */ |
480 sc->bmio = 0x0; | 492 sc->bmio = NULL; |
481 device_printf(dev, "Busmastering DMA disabled\n"); 482 } 483 | 493 device_printf(dev, "Busmastering DMA disabled\n"); 494 } 495 |
496 if (sc->bmio) { 497 sc->bmaddr = rman_get_start(sc->bmio); 498 BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, 499 SYS_RES_IOPORT, rid, sc->bmio); 500 sc->bmio = NULL; 501 } 502 |
|
484 /* 485 * the Cypress chip is a mess, it contains two ATA functions, but 486 * both channels are visible on the first one. 487 * simply ignore the second function for now, as the right 488 * solution (ignoring the second channel on the first function) 489 * doesn't work with the crappy ATA interrupt setup on the alpha. 490 */ 491 if (pci_get_devid(dev) == 0xc6931080 && pci_get_function(dev) > 1) --- 9 unchanged lines hidden (view full) --- 501 502static int 503ata_pci_print_child(device_t dev, device_t child) 504{ 505 struct ata_softc *scp = device_get_softc(child); 506 int retval = 0; 507 508 retval += bus_print_child_header(dev, child); | 503 /* 504 * the Cypress chip is a mess, it contains two ATA functions, but 505 * both channels are visible on the first one. 506 * simply ignore the second function for now, as the right 507 * solution (ignoring the second channel on the first function) 508 * doesn't work with the crappy ATA interrupt setup on the alpha. 509 */ 510 if (pci_get_devid(dev) == 0xc6931080 && pci_get_function(dev) > 1) --- 9 unchanged lines hidden (view full) --- 520 521static int 522ata_pci_print_child(device_t dev, device_t child) 523{ 524 struct ata_softc *scp = device_get_softc(child); 525 int retval = 0; 526 527 retval += bus_print_child_header(dev, child); |
509 retval += printf(": at 0x%x", scp->ioaddr); | 528 retval += printf(": at 0x%lx", rman_get_start(scp->r_io)); |
510 511 if (ATA_MASTERDEV(dev)) 512 retval += printf(" irq %d", 14 + scp->channel); 513 514 retval += bus_print_child_footer(dev, child); 515 516 return retval; 517} 518 519static struct resource * 520ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, 521 u_long start, u_long end, u_long count, u_int flags) 522{ 523 struct ata_pci_softc *sc = device_get_softc(dev); | 529 530 if (ATA_MASTERDEV(dev)) 531 retval += printf(" irq %d", 14 + scp->channel); 532 533 retval += bus_print_child_footer(dev, child); 534 535 return retval; 536} 537 538static struct resource * 539ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, 540 u_long start, u_long end, u_long count, u_int flags) 541{ 542 struct ata_pci_softc *sc = device_get_softc(dev); |
543 struct resource *res = NULL; |
|
524 int channel = ((struct ata_softc *)device_get_softc(child))->channel; 525 int myrid; 526 527 if (type == SYS_RES_IOPORT) { 528 switch (*rid) { 529 case ATA_IOADDR_RID: 530 if (ATA_MASTERDEV(dev)) { 531 myrid = 0; 532 start = (channel == 0 ? IO_WD1 : IO_WD2); 533 end = start + ATA_IOSIZE - 1; 534 count = ATA_IOSIZE; | 544 int channel = ((struct ata_softc *)device_get_softc(child))->channel; 545 int myrid; 546 547 if (type == SYS_RES_IOPORT) { 548 switch (*rid) { 549 case ATA_IOADDR_RID: 550 if (ATA_MASTERDEV(dev)) { 551 myrid = 0; 552 start = (channel == 0 ? IO_WD1 : IO_WD2); 553 end = start + ATA_IOSIZE - 1; 554 count = ATA_IOSIZE; |
555 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 556 SYS_RES_IOPORT, &myrid, 557 start, end, count, flags); |
|
535 } | 558 } |
536 else | 559 else { |
537 myrid = 0x10 + 8 * channel; | 560 myrid = 0x10 + 8 * channel; |
561 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, 562 SYS_RES_IOPORT, &myrid, 563 start, end, count, flags); 564 } |
|
538 break; 539 540 case ATA_ALTADDR_RID: 541 if (ATA_MASTERDEV(dev)) { 542 myrid = 0; 543 start = (channel == 0 ? IO_WD1 : IO_WD2) + ATA_ALTOFFSET; 544 end = start + ATA_ALTIOSIZE - 1; 545 count = ATA_ALTIOSIZE; | 565 break; 566 567 case ATA_ALTADDR_RID: 568 if (ATA_MASTERDEV(dev)) { 569 myrid = 0; 570 start = (channel == 0 ? IO_WD1 : IO_WD2) + ATA_ALTOFFSET; 571 end = start + ATA_ALTIOSIZE - 1; 572 count = ATA_ALTIOSIZE; |
573 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 574 SYS_RES_IOPORT, &myrid, 575 start, end, count, flags); |
|
546 } | 576 } |
547 else | 577 else { |
548 myrid = 0x14 + 8 * channel; | 578 myrid = 0x14 + 8 * channel; |
579 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, 580 SYS_RES_IOPORT, &myrid, 581 start, end, count, flags); 582 if (res) { 583 start = rman_get_start(res) + 2; 584 end = start + ATA_ALTIOSIZE - 1; 585 count = ATA_ALTIOSIZE; 586 BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, 587 SYS_RES_IOPORT, myrid, res); 588 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, 589 SYS_RES_IOPORT, &myrid, 590 start, end, count, flags); 591 } 592 } |
|
549 break; 550 551 case ATA_BMADDR_RID: | 593 break; 594 595 case ATA_BMADDR_RID: |
552 /* the busmaster resource is shared between the two channels */ 553 if (sc->bmio) { 554 if (channel == 0) { 555 sc->bmio_1 = *sc->bmio; 556 sc->bmio_1.r_end = sc->bmio->r_start + ATA_BM_OFFSET1; 557 return &sc->bmio_1; 558 } else { 559 sc->bmio_2 = *sc->bmio; 560 sc->bmio_2.r_start = sc->bmio->r_start + ATA_BM_OFFSET1; 561 sc->bmio_2.r_end = sc->bmio_2.r_start + ATA_BM_OFFSET1; 562 return &sc->bmio_2; 563 } | 596 if (sc->bmaddr) { 597 myrid = 0x20; 598 start = (channel == 0 ? sc->bmaddr : sc->bmaddr + ATA_BMIOSIZE); 599 end = start + ATA_BMIOSIZE - 1; 600 count = ATA_BMIOSIZE; 601 res = BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 602 SYS_RES_IOPORT, &myrid, 603 start, end, count, flags); |
564 } | 604 } |
565 return 0; 566 567 default: 568 return 0; | |
569 } | 605 } |
570 571 if (ATA_MASTERDEV(dev)) 572 /* make the parent just pass through the allocation. */ 573 return BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 574 SYS_RES_IOPORT, &myrid, 575 start, end, count, flags); 576 else 577 /* we are using the parent resource directly. */ 578 return BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, 579 SYS_RES_IOPORT, &myrid, 580 start, end, count, flags); | 606 return res; |
581 } 582 | 607 } 608 |
583 if (type == SYS_RES_IRQ) { 584 if (*rid != 0) 585 return 0; 586 | 609 if (type == SYS_RES_IRQ && *rid == ATA_IRQ_RID) { |
587 if (ATA_MASTERDEV(dev)) { 588#ifdef __alpha__ 589 return alpha_platform_alloc_ide_intr(channel); 590#else 591 int irq = (channel == 0 ? 14 : 15); 592 593 return BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 594 SYS_RES_IRQ, rid, 595 irq, irq, 1, flags & ~RF_SHAREABLE); 596#endif | 610 if (ATA_MASTERDEV(dev)) { 611#ifdef __alpha__ 612 return alpha_platform_alloc_ide_intr(channel); 613#else 614 int irq = (channel == 0 ? 14 : 15); 615 616 return BUS_ALLOC_RESOURCE(device_get_parent(dev), child, 617 SYS_RES_IRQ, rid, 618 irq, irq, 1, flags & ~RF_SHAREABLE); 619#endif |
597 } else { | 620 } 621 else { |
598 /* primary and secondary channels share the same interrupt */ 599 sc->irqcnt++; 600 if (!sc->irq) 601 sc->irq = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, 602 SYS_RES_IRQ, rid, 0, ~0, 1, flags); 603 return sc->irq; 604 } 605 } --- 20 unchanged lines hidden (view full) --- 626 case ATA_ALTADDR_RID: 627 if (ATA_MASTERDEV(dev)) 628 myrid = 0; 629 else 630 myrid = 0x14 + 8 * channel; 631 break; 632 633 case ATA_BMADDR_RID: | 622 /* primary and secondary channels share the same interrupt */ 623 sc->irqcnt++; 624 if (!sc->irq) 625 sc->irq = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, 626 SYS_RES_IRQ, rid, 0, ~0, 1, flags); 627 return sc->irq; 628 } 629 } --- 20 unchanged lines hidden (view full) --- 650 case ATA_ALTADDR_RID: 651 if (ATA_MASTERDEV(dev)) 652 myrid = 0; 653 else 654 myrid = 0x14 + 8 * channel; 655 break; 656 657 case ATA_BMADDR_RID: |
634 return 0; | 658 myrid = 0x20; 659 break; |
635 636 default: 637 return ENOENT; 638 } 639 640 if (ATA_MASTERDEV(dev)) 641 /* make the parent just pass through the allocation. */ 642 return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, 643 SYS_RES_IOPORT, myrid, r); 644 else 645 /* we are using the parent resource directly. */ 646 return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, 647 SYS_RES_IOPORT, myrid, r); 648 } 649 if (type == SYS_RES_IRQ) { | 660 661 default: 662 return ENOENT; 663 } 664 665 if (ATA_MASTERDEV(dev)) 666 /* make the parent just pass through the allocation. */ 667 return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, 668 SYS_RES_IOPORT, myrid, r); 669 else 670 /* we are using the parent resource directly. */ 671 return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, 672 SYS_RES_IOPORT, myrid, r); 673 } 674 if (type == SYS_RES_IRQ) { |
650 if (rid != 0) | 675 if (rid != ATA_IRQ_RID) |
651 return ENOENT; 652 653 if (ATA_MASTERDEV(dev)) { 654#ifdef __alpha__ 655 return alpha_platform_release_ide_intr(channel, r); 656#else 657 return BUS_RELEASE_RESOURCE(device_get_parent(dev), 658 child, SYS_RES_IRQ, rid, r); --- 106 unchanged lines hidden (view full) --- 765 766DRIVER_MODULE(ata, atapci, ata_pcisub_driver, ata_devclass, 0, 0); 767#endif 768 769static int 770ata_probe(device_t dev) 771{ 772 struct ata_softc *scp = device_get_softc(dev); | 676 return ENOENT; 677 678 if (ATA_MASTERDEV(dev)) { 679#ifdef __alpha__ 680 return alpha_platform_release_ide_intr(channel, r); 681#else 682 return BUS_RELEASE_RESOURCE(device_get_parent(dev), 683 child, SYS_RES_IRQ, rid, r); --- 106 unchanged lines hidden (view full) --- 790 791DRIVER_MODULE(ata, atapci, ata_pcisub_driver, ata_devclass, 0, 0); 792#endif 793 794static int 795ata_probe(device_t dev) 796{ 797 struct ata_softc *scp = device_get_softc(dev); |
773 struct resource *io = 0; 774 struct resource *altio = 0; 775 struct resource *bmio = 0; | |
776 int rid; | 798 int rid; |
777 u_int32_t ioaddr, altioaddr, bmaddr; | |
778 int mask = 0; 779 u_int8_t status0, status1; 780 781 if (!scp || scp->flags & ATA_ATTACHED) 782 return ENXIO; 783 784 /* initialize the softc basics */ 785 scp->active = ATA_IDLE; 786 scp->dev = dev; 787 scp->devices = 0; 788 789 rid = ATA_IOADDR_RID; | 799 int mask = 0; 800 u_int8_t status0, status1; 801 802 if (!scp || scp->flags & ATA_ATTACHED) 803 return ENXIO; 804 805 /* initialize the softc basics */ 806 scp->active = ATA_IDLE; 807 scp->dev = dev; 808 scp->devices = 0; 809 810 rid = ATA_IOADDR_RID; |
790 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 791 ATA_IOSIZE, RF_ACTIVE); 792 if (!io) | 811 scp->r_io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 812 ATA_IOSIZE, RF_ACTIVE); 813 if (!scp->r_io) |
793 goto failure; | 814 goto failure; |
794 ioaddr = rman_get_start(io); | |
795 796 rid = ATA_ALTADDR_RID; | 815 816 rid = ATA_ALTADDR_RID; |
797 altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 798 ATA_ALTIOSIZE, RF_ACTIVE); 799 if (altio) { 800 if (scp->flags & ATA_USE_16BIT || ATA_MASTERDEV(device_get_parent(dev))) 801 altioaddr = rman_get_start(altio); 802 else 803 altioaddr = rman_get_start(altio) + 0x02; 804 } 805 else 806 altioaddr = ioaddr + ATA_PCCARD_ALTOFFSET; | 817 scp->r_altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 818 ATA_ALTIOSIZE, RF_ACTIVE); 819 if (!scp->r_altio) 820 goto failure; |
807 808 rid = ATA_BMADDR_RID; | 821 822 rid = ATA_BMADDR_RID; |
809 bmio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); 810 bmaddr = bmio ? rman_get_start(bmio) : 0; | 823 scp->r_bmio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 824 ATA_BMIOSIZE, RF_ACTIVE); |
811 | 825 |
812 /* store the IO resources for eventual later release */ 813 scp->r_io = io; 814 scp->r_altio = altio; 815 scp->r_bmio = bmio; 816 817 /* store the physical IO addresse for easy access */ 818 scp->ioaddr = ioaddr; 819 scp->altioaddr = altioaddr; 820 scp->bmaddr = bmaddr; 821 | |
822 if (bootverbose) 823 ata_printf(scp, -1, "iobase=0x%04x altiobase=0x%04x bmaddr=0x%04x\n", | 826 if (bootverbose) 827 ata_printf(scp, -1, "iobase=0x%04x altiobase=0x%04x bmaddr=0x%04x\n", |
824 scp->ioaddr, scp->altioaddr, scp->bmaddr); | 828 (int)rman_get_start(scp->r_io), 829 (int)rman_get_start(scp->r_altio), 830 (scp->r_bmio) ? (int)rman_get_start(scp->r_bmio) : 0); |
825 826 /* do we have any signs of ATA/ATAPI HW being present ? */ | 831 832 /* do we have any signs of ATA/ATAPI HW being present ? */ |
827 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); | 833 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); |
828 DELAY(1); | 834 DELAY(1); |
829 status0 = inb(scp->ioaddr + ATA_STATUS); | 835 status0 = ATA_INB(scp->r_io, ATA_STATUS); |
830 if ((status0 & 0xf8) != 0xf8 && status0 != 0xa5) 831 mask |= 0x01; | 836 if ((status0 & 0xf8) != 0xf8 && status0 != 0xa5) 837 mask |= 0x01; |
832 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); | 838 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); |
833 DELAY(1); | 839 DELAY(1); |
834 status1 = inb(scp->ioaddr + ATA_STATUS); | 840 status1 = ATA_INB(scp->r_io, ATA_STATUS); |
835 if ((status1 & 0xf8) != 0xf8 && status1 != 0xa5) 836 mask |= 0x02; 837 838 if (bootverbose) 839 ata_printf(scp, -1, "mask=%02x status0=%02x status1=%02x\n", 840 mask, status0, status1); 841 if (!mask) 842 goto failure; 843 844 ata_reset(scp, &mask); 845 846 if (!mask) 847 goto failure; 848 849 TAILQ_INIT(&scp->ata_queue); 850 TAILQ_INIT(&scp->atapi_queue); 851 return 0; 852 853failure: | 841 if ((status1 & 0xf8) != 0xf8 && status1 != 0xa5) 842 mask |= 0x02; 843 844 if (bootverbose) 845 ata_printf(scp, -1, "mask=%02x status0=%02x status1=%02x\n", 846 mask, status0, status1); 847 if (!mask) 848 goto failure; 849 850 ata_reset(scp, &mask); 851 852 if (!mask) 853 goto failure; 854 855 TAILQ_INIT(&scp->ata_queue); 856 TAILQ_INIT(&scp->atapi_queue); 857 return 0; 858 859failure: |
854 if (io) 855 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io); 856 if (altio) 857 bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, altio); 858 if (bmio) 859 bus_release_resource(dev, SYS_RES_IOPORT, ATA_BMADDR_RID, bmio); | 860 if (scp->r_io) 861 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, scp->r_io); 862 if (scp->r_altio) 863 bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID,scp->r_altio); 864 if (scp->r_bmio) 865 bus_release_resource(dev, SYS_RES_IOPORT, ATA_BMADDR_RID, scp->r_bmio); |
860 if (bootverbose) 861 ata_printf(scp, -1, "probe allocation failed\n"); 862 return ENXIO; 863} 864 865static int 866ata_attach(device_t dev) 867{ 868 struct ata_softc *scp = device_get_softc(dev); | 866 if (bootverbose) 867 ata_printf(scp, -1, "probe allocation failed\n"); 868 return ENXIO; 869} 870 871static int 872ata_attach(device_t dev) 873{ 874 struct ata_softc *scp = device_get_softc(dev); |
869 int error, rid = 0; | 875 int error, rid; |
870 871 if (!scp || scp->flags & ATA_ATTACHED) 872 return ENXIO; 873 | 876 877 if (!scp || scp->flags & ATA_ATTACHED) 878 return ENXIO; 879 |
880 rid = ATA_IRQ_RID; |
|
874 scp->r_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 875 RF_SHAREABLE | RF_ACTIVE); 876 if (!scp->r_irq) { 877 ata_printf(scp, -1, "unable to allocate interrupt\n"); 878 return ENXIO; 879 } 880 if ((error = bus_setup_intr(dev, scp->r_irq, INTR_TYPE_BIO, ata_intr, 881 scp, &scp->ih))) --- 37 unchanged lines hidden (view full) --- 919static int 920ata_detach(device_t dev) 921{ 922 struct ata_softc *scp = device_get_softc(dev); 923 924 if (!scp || !(scp->flags & ATA_ATTACHED)) 925 return ENXIO; 926 | 881 scp->r_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 882 RF_SHAREABLE | RF_ACTIVE); 883 if (!scp->r_irq) { 884 ata_printf(scp, -1, "unable to allocate interrupt\n"); 885 return ENXIO; 886 } 887 if ((error = bus_setup_intr(dev, scp->r_irq, INTR_TYPE_BIO, ata_intr, 888 scp, &scp->ih))) --- 37 unchanged lines hidden (view full) --- 926static int 927ata_detach(device_t dev) 928{ 929 struct ata_softc *scp = device_get_softc(dev); 930 931 if (!scp || !(scp->flags & ATA_ATTACHED)) 932 return ENXIO; 933 |
934 /* disable interrupts on devices */ 935 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); 936 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_IDS | ATA_A_4BIT); 937 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); 938 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_IDS | ATA_A_4BIT); 939 |
|
927#ifdef DEV_ATADISK 928 if (scp->devices & ATA_ATA_MASTER) 929 ad_detach(scp->dev_softc[0]); 930 if (scp->devices & ATA_ATA_SLAVE) 931 ad_detach(scp->dev_softc[1]); 932#endif 933#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) 934 if (scp->devices & ATA_ATAPI_MASTER) 935 atapi_detach(scp->dev_softc[0]); 936 if (scp->devices & ATA_ATAPI_SLAVE) 937 atapi_detach(scp->dev_softc[1]); 938#endif | 940#ifdef DEV_ATADISK 941 if (scp->devices & ATA_ATA_MASTER) 942 ad_detach(scp->dev_softc[0]); 943 if (scp->devices & ATA_ATA_SLAVE) 944 ad_detach(scp->dev_softc[1]); 945#endif 946#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) 947 if (scp->devices & ATA_ATAPI_MASTER) 948 atapi_detach(scp->dev_softc[0]); 949 if (scp->devices & ATA_ATAPI_SLAVE) 950 atapi_detach(scp->dev_softc[1]); 951#endif |
952 |
|
939 if (scp->dev_param[ATA_DEV(ATA_MASTER)]) { 940 free(scp->dev_param[ATA_DEV(ATA_MASTER)], M_ATA); 941 scp->dev_param[ATA_DEV(ATA_MASTER)] = NULL; 942 } 943 if (scp->dev_param[ATA_DEV(ATA_SLAVE)]) { 944 free(scp->dev_param[ATA_DEV(ATA_SLAVE)], M_ATA); 945 scp->dev_param[ATA_DEV(ATA_SLAVE)] = NULL; 946 } 947 scp->dev_softc[ATA_DEV(ATA_MASTER)] = NULL; 948 scp->dev_softc[ATA_DEV(ATA_SLAVE)] = NULL; 949 scp->mode[ATA_DEV(ATA_MASTER)] = ATA_PIO; 950 scp->mode[ATA_DEV(ATA_SLAVE)] = ATA_PIO; | 953 if (scp->dev_param[ATA_DEV(ATA_MASTER)]) { 954 free(scp->dev_param[ATA_DEV(ATA_MASTER)], M_ATA); 955 scp->dev_param[ATA_DEV(ATA_MASTER)] = NULL; 956 } 957 if (scp->dev_param[ATA_DEV(ATA_SLAVE)]) { 958 free(scp->dev_param[ATA_DEV(ATA_SLAVE)], M_ATA); 959 scp->dev_param[ATA_DEV(ATA_SLAVE)] = NULL; 960 } 961 scp->dev_softc[ATA_DEV(ATA_MASTER)] = NULL; 962 scp->dev_softc[ATA_DEV(ATA_SLAVE)] = NULL; 963 scp->mode[ATA_DEV(ATA_MASTER)] = ATA_PIO; 964 scp->mode[ATA_DEV(ATA_SLAVE)] = ATA_PIO; |
965 |
|
951 bus_teardown_intr(dev, scp->r_irq, scp->ih); | 966 bus_teardown_intr(dev, scp->r_irq, scp->ih); |
952 bus_release_resource(dev, SYS_RES_IRQ, 0, scp->r_irq); | 967 bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, scp->r_irq); |
953 if (scp->r_bmio) 954 bus_release_resource(dev, SYS_RES_IOPORT, ATA_BMADDR_RID, scp->r_bmio); | 968 if (scp->r_bmio) 969 bus_release_resource(dev, SYS_RES_IOPORT, ATA_BMADDR_RID, scp->r_bmio); |
955 if (scp->r_altio) 956 bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID,scp->r_altio); | 970 bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, scp->r_altio); |
957 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, scp->r_io); 958 scp->flags &= ~ATA_ATTACHED; 959 return 0; 960} 961 962static int 963ata_resume(device_t dev) 964{ --- 6 unchanged lines hidden (view full) --- 971static int 972ata_getparam(struct ata_softc *scp, int device, u_int8_t command) 973{ 974 struct ata_params *ata_parm; 975 int8_t buffer[DEV_BSIZE]; 976 int retry = 0; 977 978 /* select drive */ | 971 bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, scp->r_io); 972 scp->flags &= ~ATA_ATTACHED; 973 return 0; 974} 975 976static int 977ata_resume(device_t dev) 978{ --- 6 unchanged lines hidden (view full) --- 985static int 986ata_getparam(struct ata_softc *scp, int device, u_int8_t command) 987{ 988 struct ata_params *ata_parm; 989 int8_t buffer[DEV_BSIZE]; 990 int retry = 0; 991 992 /* select drive */ |
979 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device); | 993 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | device); |
980 DELAY(1); 981 982 /* enable interrupt */ | 994 DELAY(1); 995 996 /* enable interrupt */ |
983 outb(scp->altioaddr, ATA_A_4BIT); | 997 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_4BIT); |
984 DELAY(1); 985 986 /* apparently some devices needs this repeated */ 987 do { 988 if (ata_command(scp, device, command, 0, 0, 0, 0, 0, ATA_WAIT_INTR)) { 989 ata_printf(scp, device, "identify failed\n"); 990 return -1; 991 } 992 if (retry++ > 4) { 993 ata_printf(scp, device, "identify retries exceeded\n"); 994 return -1; 995 } 996 } while (ata_wait(scp, device, 997 ((command == ATA_C_ATAPI_IDENTIFY) ? 998 ATA_S_DRQ : (ATA_S_READY | ATA_S_DSC | ATA_S_DRQ)))); 999 | 998 DELAY(1); 999 1000 /* apparently some devices needs this repeated */ 1001 do { 1002 if (ata_command(scp, device, command, 0, 0, 0, 0, 0, ATA_WAIT_INTR)) { 1003 ata_printf(scp, device, "identify failed\n"); 1004 return -1; 1005 } 1006 if (retry++ > 4) { 1007 ata_printf(scp, device, "identify retries exceeded\n"); 1008 return -1; 1009 } 1010 } while (ata_wait(scp, device, 1011 ((command == ATA_C_ATAPI_IDENTIFY) ? 1012 ATA_S_DRQ : (ATA_S_READY | ATA_S_DSC | ATA_S_DRQ)))); 1013 |
1000 insw(scp->ioaddr + ATA_DATA, buffer, sizeof(buffer)/sizeof(int16_t)); | 1014 ATA_INSW(scp->r_io, ATA_DATA, (int16_t *)buffer, 1015 sizeof(buffer)/sizeof(int16_t)); |
1001 ata_parm = malloc(sizeof(struct ata_params), M_ATA, M_NOWAIT); 1002 if (!ata_parm) { 1003 ata_printf(scp, device, "malloc for identify data failed\n"); 1004 return -1; 1005 } 1006 bcopy(buffer, ata_parm, sizeof(struct ata_params)); 1007 if (command == ATA_C_ATA_IDENTIFY || 1008 !((ata_parm->model[0] == 'N' && ata_parm->model[1] == 'E') || --- 64 unchanged lines hidden (view full) --- 1073 ata_delayed_attach = NULL; 1074 } 1075} 1076 1077static void 1078ata_intr(void *data) 1079{ 1080 struct ata_softc *scp = (struct ata_softc *)data; | 1016 ata_parm = malloc(sizeof(struct ata_params), M_ATA, M_NOWAIT); 1017 if (!ata_parm) { 1018 ata_printf(scp, device, "malloc for identify data failed\n"); 1019 return -1; 1020 } 1021 bcopy(buffer, ata_parm, sizeof(struct ata_params)); 1022 if (command == ATA_C_ATA_IDENTIFY || 1023 !((ata_parm->model[0] == 'N' && ata_parm->model[1] == 'E') || --- 64 unchanged lines hidden (view full) --- 1088 ata_delayed_attach = NULL; 1089 } 1090} 1091 1092static void 1093ata_intr(void *data) 1094{ 1095 struct ata_softc *scp = (struct ata_softc *)data; |
1081 struct ata_pci_softc *sc = device_get_softc(device_get_parent(scp->dev)); | |
1082 u_int8_t dmastat = 0; 1083 1084 /* 1085 * since we might share the IRQ with another device, and in some 1086 * cases with our twin channel, we only want to process interrupts 1087 * that we know this channel generated. 1088 */ 1089 switch (scp->chiptype) { 1090#if NPCI > 0 1091 case 0x00041103: /* HighPoint HPT366/368/370 */ 1092 if (((dmastat = ata_dmastatus(scp)) & 1093 (ATA_BMSTAT_ACTIVE | ATA_BMSTAT_INTERRUPT)) != ATA_BMSTAT_INTERRUPT) 1094 return; | 1096 u_int8_t dmastat = 0; 1097 1098 /* 1099 * since we might share the IRQ with another device, and in some 1100 * cases with our twin channel, we only want to process interrupts 1101 * that we know this channel generated. 1102 */ 1103 switch (scp->chiptype) { 1104#if NPCI > 0 1105 case 0x00041103: /* HighPoint HPT366/368/370 */ 1106 if (((dmastat = ata_dmastatus(scp)) & 1107 (ATA_BMSTAT_ACTIVE | ATA_BMSTAT_INTERRUPT)) != ATA_BMSTAT_INTERRUPT) 1108 return; |
1095 outb(scp->bmaddr + ATA_BMSTAT_PORT, dmastat | ATA_BMSTAT_INTERRUPT); | 1109 ATA_OUTB(scp->r_bmio, ATA_BMSTAT_PORT, dmastat | ATA_BMSTAT_INTERRUPT); |
1096 break; 1097 1098 case 0x06481095: /* CMD 648 */ 1099 case 0x06491095: /* CMD 649 */ 1100 if (!(pci_read_config(device_get_parent(scp->dev), 0x71, 1) & 1101 (scp->channel ? 0x08 : 0x04))) 1102 return; 1103 goto out; 1104 1105 case 0x4d33105a: /* Promise Ultra/Fasttrak 33 */ 1106 case 0x4d38105a: /* Promise Ultra/Fasttrak 66 */ 1107 case 0x4d30105a: /* Promise Ultra/Fasttrak 100 */ 1108 case 0x0d30105a: /* Promise OEM ATA100 */ | 1110 break; 1111 1112 case 0x06481095: /* CMD 648 */ 1113 case 0x06491095: /* CMD 649 */ 1114 if (!(pci_read_config(device_get_parent(scp->dev), 0x71, 1) & 1115 (scp->channel ? 0x08 : 0x04))) 1116 return; 1117 goto out; 1118 1119 case 0x4d33105a: /* Promise Ultra/Fasttrak 33 */ 1120 case 0x4d38105a: /* Promise Ultra/Fasttrak 66 */ 1121 case 0x4d30105a: /* Promise Ultra/Fasttrak 100 */ 1122 case 0x0d30105a: /* Promise OEM ATA100 */ |
1109 if (!(inl(rman_get_start(sc->bmio) + 0x1c) & | 1123 if (!(ATA_INL(scp->r_bmio, (scp->channel ? 0x14 : 0x1c)) & |
1110 (scp->channel ? 0x00004000 : 0x00000400))) 1111 return; 1112 /* FALLTHROUGH */ 1113out: 1114#endif 1115 default: 1116 if (scp->flags & ATA_DMA_ACTIVE) { 1117 if (!((dmastat = ata_dmastatus(scp)) & ATA_BMSTAT_INTERRUPT)) 1118 return; | 1124 (scp->channel ? 0x00004000 : 0x00000400))) 1125 return; 1126 /* FALLTHROUGH */ 1127out: 1128#endif 1129 default: 1130 if (scp->flags & ATA_DMA_ACTIVE) { 1131 if (!((dmastat = ata_dmastatus(scp)) & ATA_BMSTAT_INTERRUPT)) 1132 return; |
1119 outb(scp->bmaddr + ATA_BMSTAT_PORT, dmastat | ATA_BMSTAT_INTERRUPT); | 1133 ATA_OUTB(scp->r_bmio, ATA_BMSTAT_PORT, 1134 dmastat | ATA_BMSTAT_INTERRUPT); |
1120 } 1121 } 1122 DELAY(1); 1123 1124 /* if drive is busy it didn't interrupt */ | 1135 } 1136 } 1137 DELAY(1); 1138 1139 /* if drive is busy it didn't interrupt */ |
1125 if (inb(scp->altioaddr) & ATA_S_BUSY) | 1140 if (ATA_INB(scp->r_altio, ATA_ALTSTAT) & ATA_S_BUSY) |
1126 return; 1127 1128 /* clear interrupt and get status */ | 1141 return; 1142 1143 /* clear interrupt and get status */ |
1129 scp->status = inb(scp->ioaddr + ATA_STATUS); | 1144 scp->status = ATA_INB(scp->r_io, ATA_STATUS); |
1130 1131 if (scp->status & ATA_S_ERROR) | 1145 1146 if (scp->status & ATA_S_ERROR) |
1132 scp->error = inb(scp->ioaddr + ATA_ERROR); | 1147 scp->error = ATA_INB(scp->r_io, ATA_ERROR); |
1133 1134 /* find & call the responsible driver to process this interrupt */ 1135 switch (scp->active) { 1136#ifdef DEV_ATADISK 1137 case ATA_ACTIVE_ATA: 1138 if (!scp->running || ad_interrupt(scp->running) == ATA_OP_CONTINUES) 1139 return; 1140 break; --- 91 unchanged lines hidden (view full) --- 1232void 1233ata_reset(struct ata_softc *scp, int *mask) 1234{ 1235 int timeout; 1236 u_int8_t a, b, ostat0, ostat1; 1237 u_int8_t status0 = ATA_S_BUSY, status1 = ATA_S_BUSY; 1238 1239 /* get the current status of the devices */ | 1148 1149 /* find & call the responsible driver to process this interrupt */ 1150 switch (scp->active) { 1151#ifdef DEV_ATADISK 1152 case ATA_ACTIVE_ATA: 1153 if (!scp->running || ad_interrupt(scp->running) == ATA_OP_CONTINUES) 1154 return; 1155 break; --- 91 unchanged lines hidden (view full) --- 1247void 1248ata_reset(struct ata_softc *scp, int *mask) 1249{ 1250 int timeout; 1251 u_int8_t a, b, ostat0, ostat1; 1252 u_int8_t status0 = ATA_S_BUSY, status1 = ATA_S_BUSY; 1253 1254 /* get the current status of the devices */ |
1240 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); | 1255 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); |
1241 DELAY(10); | 1256 DELAY(10); |
1242 ostat1 = inb(scp->ioaddr + ATA_STATUS); 1243 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); | 1257 ostat1 = ATA_INB(scp->r_io, ATA_STATUS); 1258 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); |
1244 DELAY(10); | 1259 DELAY(10); |
1245 ostat0 = inb(scp->ioaddr + ATA_STATUS); | 1260 ostat0 = ATA_INB(scp->r_io, ATA_STATUS); |
1246 1247 /* in some setups we dont want to test for a slave */ 1248 if (scp->flags & ATA_NO_SLAVE) 1249 *mask &= ~0x02; 1250 1251 if (bootverbose) 1252 ata_printf(scp, -1, "mask=%02x ostat0=%02x ostat2=%02x\n", 1253 *mask, ostat0, ostat1); 1254 1255 /* reset channel */ | 1261 1262 /* in some setups we dont want to test for a slave */ 1263 if (scp->flags & ATA_NO_SLAVE) 1264 *mask &= ~0x02; 1265 1266 if (bootverbose) 1267 ata_printf(scp, -1, "mask=%02x ostat0=%02x ostat2=%02x\n", 1268 *mask, ostat0, ostat1); 1269 1270 /* reset channel */ |
1256 outb(scp->altioaddr, ATA_A_IDS | ATA_A_RESET); | 1271 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_IDS | ATA_A_RESET); |
1257 DELAY(10000); | 1272 DELAY(10000); |
1258 outb(scp->altioaddr, ATA_A_IDS); | 1273 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_IDS); |
1259 DELAY(100000); | 1274 DELAY(100000); |
1260 inb(scp->ioaddr + ATA_ERROR); | 1275 ATA_INB(scp->r_io, ATA_ERROR); |
1261 scp->devices = 0; 1262 1263 /* wait for BUSY to go inactive */ 1264 for (timeout = 0; timeout < 310000; timeout++) { 1265 if (status0 & ATA_S_BUSY) { | 1276 scp->devices = 0; 1277 1278 /* wait for BUSY to go inactive */ 1279 for (timeout = 0; timeout < 310000; timeout++) { 1280 if (status0 & ATA_S_BUSY) { |
1266 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); | 1281 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); |
1267 DELAY(10); | 1282 DELAY(10); |
1268 status0 = inb(scp->ioaddr + ATA_STATUS); | 1283 status0 = ATA_INB(scp->r_io, ATA_STATUS); |
1269 if (!(status0 & ATA_S_BUSY)) { 1270 /* check for ATAPI signature while its still there */ | 1284 if (!(status0 & ATA_S_BUSY)) { 1285 /* check for ATAPI signature while its still there */ |
1271 a = inb(scp->ioaddr + ATA_CYL_LSB); 1272 b = inb(scp->ioaddr + ATA_CYL_MSB); | 1286 a = ATA_INB(scp->r_io, ATA_CYL_LSB); 1287 b = ATA_INB(scp->r_io, ATA_CYL_MSB); |
1273 if (bootverbose) 1274 ata_printf(scp, ATA_MASTER, 1275 "ATAPI probe a=%02x b=%02x\n", a, b); 1276 if (a == ATAPI_MAGIC_LSB && b == ATAPI_MAGIC_MSB) 1277 scp->devices |= ATA_ATAPI_MASTER; 1278 } 1279 } 1280 if (status1 & ATA_S_BUSY) { | 1288 if (bootverbose) 1289 ata_printf(scp, ATA_MASTER, 1290 "ATAPI probe a=%02x b=%02x\n", a, b); 1291 if (a == ATAPI_MAGIC_LSB && b == ATAPI_MAGIC_MSB) 1292 scp->devices |= ATA_ATAPI_MASTER; 1293 } 1294 } 1295 if (status1 & ATA_S_BUSY) { |
1281 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); | 1296 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); |
1282 DELAY(10); | 1297 DELAY(10); |
1283 status1 = inb(scp->ioaddr + ATA_STATUS); | 1298 status1 = ATA_INB(scp->r_io, ATA_STATUS); |
1284 if (!(status1 & ATA_S_BUSY)) { 1285 /* check for ATAPI signature while its still there */ | 1299 if (!(status1 & ATA_S_BUSY)) { 1300 /* check for ATAPI signature while its still there */ |
1286 a = inb(scp->ioaddr + ATA_CYL_LSB); 1287 b = inb(scp->ioaddr + ATA_CYL_MSB); | 1301 a = ATA_INB(scp->r_io, ATA_CYL_LSB); 1302 b = ATA_INB(scp->r_io, ATA_CYL_MSB); |
1288 if (bootverbose) 1289 ata_printf(scp, ATA_SLAVE, 1290 "ATAPI probe a=%02x b=%02x\n", a, b); 1291 if (a == ATAPI_MAGIC_LSB && b == ATAPI_MAGIC_MSB) 1292 scp->devices |= ATA_ATAPI_SLAVE; 1293 } 1294 } 1295 if (*mask == 0x01) /* wait for master only */ 1296 if (!(status0 & ATA_S_BUSY)) 1297 break; 1298 if (*mask == 0x02) /* wait for slave only */ 1299 if (!(status1 & ATA_S_BUSY)) 1300 break; 1301 if (*mask == 0x03) /* wait for both master & slave */ 1302 if (!(status0 & ATA_S_BUSY) && !(status1 & ATA_S_BUSY)) 1303 break; 1304 DELAY(100); 1305 } 1306 DELAY(10); | 1303 if (bootverbose) 1304 ata_printf(scp, ATA_SLAVE, 1305 "ATAPI probe a=%02x b=%02x\n", a, b); 1306 if (a == ATAPI_MAGIC_LSB && b == ATAPI_MAGIC_MSB) 1307 scp->devices |= ATA_ATAPI_SLAVE; 1308 } 1309 } 1310 if (*mask == 0x01) /* wait for master only */ 1311 if (!(status0 & ATA_S_BUSY)) 1312 break; 1313 if (*mask == 0x02) /* wait for slave only */ 1314 if (!(status1 & ATA_S_BUSY)) 1315 break; 1316 if (*mask == 0x03) /* wait for both master & slave */ 1317 if (!(status0 & ATA_S_BUSY) && !(status1 & ATA_S_BUSY)) 1318 break; 1319 DELAY(100); 1320 } 1321 DELAY(10); |
1307 outb(scp->altioaddr, ATA_A_4BIT); | 1322 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_4BIT); |
1308 1309 if (status0 & ATA_S_BUSY) 1310 *mask &= ~0x01; 1311 if (status1 & ATA_S_BUSY) 1312 *mask &= ~0x02; 1313 if (bootverbose) 1314 ata_printf(scp, -1, "mask=%02x status0=%02x status1=%02x\n", 1315 *mask, status0, status1); 1316 if (!*mask) 1317 return; 1318 1319 if (*mask & 0x01 && ostat0 != 0x00 && !(scp->devices & ATA_ATAPI_MASTER)) { | 1323 1324 if (status0 & ATA_S_BUSY) 1325 *mask &= ~0x01; 1326 if (status1 & ATA_S_BUSY) 1327 *mask &= ~0x02; 1328 if (bootverbose) 1329 ata_printf(scp, -1, "mask=%02x status0=%02x status1=%02x\n", 1330 *mask, status0, status1); 1331 if (!*mask) 1332 return; 1333 1334 if (*mask & 0x01 && ostat0 != 0x00 && !(scp->devices & ATA_ATAPI_MASTER)) { |
1320 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER); | 1335 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER); |
1321 DELAY(10); | 1336 DELAY(10); |
1322 outb(scp->ioaddr + ATA_ERROR, 0x58); 1323 outb(scp->ioaddr + ATA_CYL_LSB, 0xa5); 1324 a = inb(scp->ioaddr + ATA_ERROR); 1325 b = inb(scp->ioaddr + ATA_CYL_LSB); | 1337 ATA_OUTB(scp->r_io, ATA_ERROR, 0x58); 1338 ATA_OUTB(scp->r_io, ATA_CYL_LSB, 0xa5); 1339 a = ATA_INB(scp->r_io, ATA_ERROR); 1340 b = ATA_INB(scp->r_io, ATA_CYL_LSB); |
1326 if (bootverbose) 1327 ata_printf(scp, ATA_MASTER, "ATA probe a=%02x b=%02x\n", a, b); 1328 if (a != 0x58 && b == 0xa5) 1329 scp->devices |= ATA_ATA_MASTER; 1330 } 1331 if (*mask & 0x02 && ostat1 != 0x00 && !(scp->devices & ATA_ATAPI_SLAVE)) { | 1341 if (bootverbose) 1342 ata_printf(scp, ATA_MASTER, "ATA probe a=%02x b=%02x\n", a, b); 1343 if (a != 0x58 && b == 0xa5) 1344 scp->devices |= ATA_ATA_MASTER; 1345 } 1346 if (*mask & 0x02 && ostat1 != 0x00 && !(scp->devices & ATA_ATAPI_SLAVE)) { |
1332 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); | 1347 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE); |
1333 DELAY(10); | 1348 DELAY(10); |
1334 outb(scp->ioaddr + ATA_ERROR, 0x58); 1335 outb(scp->ioaddr + ATA_CYL_LSB, 0xa5); 1336 a = inb(scp->ioaddr + ATA_ERROR); 1337 b = inb(scp->ioaddr + ATA_CYL_LSB); | 1349 ATA_OUTB(scp->r_io, ATA_ERROR, 0x58); 1350 ATA_OUTB(scp->r_io, ATA_CYL_LSB, 0xa5); 1351 a = ATA_INB(scp->r_io, ATA_ERROR); 1352 b = ATA_INB(scp->r_io, ATA_CYL_LSB); |
1338 if (bootverbose) 1339 ata_printf(scp, ATA_SLAVE, "ATA probe a=%02x b=%02x\n", a, b); 1340 if (a != 0x58 && b == 0xa5) 1341 scp->devices |= ATA_ATA_SLAVE; 1342 } 1343 if (bootverbose) 1344 ata_printf(scp, -1, "devices=%02x\n", scp->devices); 1345} --- 35 unchanged lines hidden (view full) --- 1381 return 0; 1382} 1383 1384static int 1385ata_service(struct ata_softc *scp) 1386{ 1387 /* do we have a SERVICE request from the drive ? */ 1388 if ((scp->status & (ATA_S_SERVICE|ATA_S_ERROR|ATA_S_DRQ)) == ATA_S_SERVICE){ | 1353 if (bootverbose) 1354 ata_printf(scp, ATA_SLAVE, "ATA probe a=%02x b=%02x\n", a, b); 1355 if (a != 0x58 && b == 0xa5) 1356 scp->devices |= ATA_ATA_SLAVE; 1357 } 1358 if (bootverbose) 1359 ata_printf(scp, -1, "devices=%02x\n", scp->devices); 1360} --- 35 unchanged lines hidden (view full) --- 1396 return 0; 1397} 1398 1399static int 1400ata_service(struct ata_softc *scp) 1401{ 1402 /* do we have a SERVICE request from the drive ? */ 1403 if ((scp->status & (ATA_S_SERVICE|ATA_S_ERROR|ATA_S_DRQ)) == ATA_S_SERVICE){ |
1389 outb(scp->bmaddr + ATA_BMSTAT_PORT, ata_dmastatus(scp) | ATA_BMSTAT_INTERRUPT); | 1404 ATA_OUTB(scp->r_bmio, ATA_BMSTAT_PORT, 1405 ata_dmastatus(scp) | ATA_BMSTAT_INTERRUPT); |
1390#ifdef DEV_ATADISK | 1406#ifdef DEV_ATADISK |
1391 if ((inb(scp->ioaddr + ATA_DRIVE) & ATA_SLAVE) == ATA_MASTER) { | 1407 if ((ATA_INB(scp->r_io, ATA_DRIVE) & ATA_SLAVE) == ATA_MASTER) { |
1392 if ((scp->devices & ATA_ATA_MASTER) && scp->dev_softc[0]) 1393 return ad_service((struct ad_softc *)scp->dev_softc[0], 0); 1394 } 1395 else { 1396 if ((scp->devices & ATA_ATA_SLAVE) && scp->dev_softc[1]) 1397 return ad_service((struct ad_softc *)scp->dev_softc[1], 0); 1398 } 1399#endif 1400 } 1401 return ATA_OP_FINISHED; 1402} 1403 1404int 1405ata_wait(struct ata_softc *scp, int device, u_int8_t mask) 1406{ 1407 int timeout = 0; | 1408 if ((scp->devices & ATA_ATA_MASTER) && scp->dev_softc[0]) 1409 return ad_service((struct ad_softc *)scp->dev_softc[0], 0); 1410 } 1411 else { 1412 if ((scp->devices & ATA_ATA_SLAVE) && scp->dev_softc[1]) 1413 return ad_service((struct ad_softc *)scp->dev_softc[1], 0); 1414 } 1415#endif 1416 } 1417 return ATA_OP_FINISHED; 1418} 1419 1420int 1421ata_wait(struct ata_softc *scp, int device, u_int8_t mask) 1422{ 1423 int timeout = 0; |
1408 int statio = scp->ioaddr + ATA_STATUS; | |
1409 1410 DELAY(1); 1411 while (timeout < 5000000) { /* timeout 5 secs */ | 1424 1425 DELAY(1); 1426 while (timeout < 5000000) { /* timeout 5 secs */ |
1412 scp->status = inb(statio); | 1427 scp->status = ATA_INB(scp->r_io, ATA_STATUS); |
1413 1414 /* if drive fails status, reselect the drive just to be sure */ 1415 if (scp->status == 0xff) { 1416 ata_printf(scp, device, "no status, reselecting device\n"); | 1428 1429 /* if drive fails status, reselect the drive just to be sure */ 1430 if (scp->status == 0xff) { 1431 ata_printf(scp, device, "no status, reselecting device\n"); |
1417 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device); | 1432 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | device); |
1418 DELAY(1); | 1433 DELAY(1); |
1419 scp->status = inb(statio); | 1434 scp->status = ATA_INB(scp->r_io, ATA_STATUS); |
1420 } 1421 1422 /* are we done ? */ 1423 if (!(scp->status & ATA_S_BUSY)) 1424 break; 1425 1426 if (timeout > 1000) { 1427 timeout += 1000; 1428 DELAY(1000); 1429 } 1430 else { 1431 timeout += 10; 1432 DELAY(10); 1433 } 1434 } 1435 if (scp->status & ATA_S_ERROR) | 1435 } 1436 1437 /* are we done ? */ 1438 if (!(scp->status & ATA_S_BUSY)) 1439 break; 1440 1441 if (timeout > 1000) { 1442 timeout += 1000; 1443 DELAY(1000); 1444 } 1445 else { 1446 timeout += 10; 1447 DELAY(10); 1448 } 1449 } 1450 if (scp->status & ATA_S_ERROR) |
1436 scp->error = inb(scp->ioaddr + ATA_ERROR); | 1451 scp->error = ATA_INB(scp->r_io, ATA_ERROR); |
1437 if (timeout >= 5000000) 1438 return -1; 1439 if (!mask) 1440 return (scp->status & ATA_S_ERROR); 1441 1442 /* Wait 50 msec for bits wanted. */ 1443 timeout = 5000; 1444 while (timeout--) { | 1452 if (timeout >= 5000000) 1453 return -1; 1454 if (!mask) 1455 return (scp->status & ATA_S_ERROR); 1456 1457 /* Wait 50 msec for bits wanted. */ 1458 timeout = 5000; 1459 while (timeout--) { |
1445 scp->status = inb(statio); | 1460 scp->status = ATA_INB(scp->r_io, ATA_STATUS); |
1446 if ((scp->status & mask) == mask) { 1447 if (scp->status & ATA_S_ERROR) | 1461 if ((scp->status & mask) == mask) { 1462 if (scp->status & ATA_S_ERROR) |
1448 scp->error = inb(scp->ioaddr + ATA_ERROR); | 1463 scp->error = ATA_INB(scp->r_io, ATA_ERROR); |
1449 return (scp->status & ATA_S_ERROR); 1450 } 1451 DELAY (10); 1452 } 1453 return -1; 1454} 1455 1456int 1457ata_command(struct ata_softc *scp, int device, u_int8_t command, 1458 u_int16_t cylinder, u_int8_t head, u_int8_t sector, 1459 u_int8_t count, u_int8_t feature, int flags) 1460{ 1461 int error = 0; 1462#ifdef ATA_DEBUG 1463 ata_printf(scp, device, "ata_command: addr=%04x, cmd=%02x, " 1464 "c=%d, h=%d, s=%d, count=%d, feature=%d, flags=%02x\n", | 1464 return (scp->status & ATA_S_ERROR); 1465 } 1466 DELAY (10); 1467 } 1468 return -1; 1469} 1470 1471int 1472ata_command(struct ata_softc *scp, int device, u_int8_t command, 1473 u_int16_t cylinder, u_int8_t head, u_int8_t sector, 1474 u_int8_t count, u_int8_t feature, int flags) 1475{ 1476 int error = 0; 1477#ifdef ATA_DEBUG 1478 ata_printf(scp, device, "ata_command: addr=%04x, cmd=%02x, " 1479 "c=%d, h=%d, s=%d, count=%d, feature=%d, flags=%02x\n", |
1465 scp->ioaddr, command, cylinder, head, sector, | 1480 rman_get_start(scp->r_io), command, cylinder, head, sector, |
1466 count, feature, flags); 1467#endif 1468 1469 /* disable interrupt from device */ 1470 if (scp->flags & ATA_QUEUED) | 1481 count, feature, flags); 1482#endif 1483 1484 /* disable interrupt from device */ 1485 if (scp->flags & ATA_QUEUED) |
1471 outb(scp->altioaddr, ATA_A_IDS | ATA_A_4BIT); | 1486 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_IDS | ATA_A_4BIT); |
1472 1473 /* select device */ | 1487 1488 /* select device */ |
1474 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device); | 1489 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | device); |
1475 1476 /* ready to issue command ? */ 1477 if (ata_wait(scp, device, 0) < 0) { 1478 ata_printf(scp, device, 1479 "timeout waiting to give command=%02x s=%02x e=%02x\n", 1480 command, scp->status, scp->error); 1481 return -1; 1482 } 1483 | 1490 1491 /* ready to issue command ? */ 1492 if (ata_wait(scp, device, 0) < 0) { 1493 ata_printf(scp, device, 1494 "timeout waiting to give command=%02x s=%02x e=%02x\n", 1495 command, scp->status, scp->error); 1496 return -1; 1497 } 1498 |
1484 outb(scp->ioaddr + ATA_FEATURE, feature); 1485 outb(scp->ioaddr + ATA_COUNT, count); 1486 outb(scp->ioaddr + ATA_SECTOR, sector); 1487 outb(scp->ioaddr + ATA_CYL_MSB, cylinder >> 8); 1488 outb(scp->ioaddr + ATA_CYL_LSB, cylinder); 1489 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device | head); | 1499 ATA_OUTB(scp->r_io, ATA_FEATURE, feature); 1500 ATA_OUTB(scp->r_io, ATA_COUNT, count); 1501 ATA_OUTB(scp->r_io, ATA_SECTOR, sector); 1502 ATA_OUTB(scp->r_io, ATA_CYL_MSB, cylinder >> 8); 1503 ATA_OUTB(scp->r_io, ATA_CYL_LSB, cylinder); 1504 ATA_OUTB(scp->r_io, ATA_DRIVE, ATA_D_IBM | device | head); |
1490 1491 switch (flags) { 1492 case ATA_WAIT_INTR: 1493 scp->active = ATA_WAIT_INTR; 1494 asleep((caddr_t)scp, PRIBIO, "atacmd", 10 * hz); | 1505 1506 switch (flags) { 1507 case ATA_WAIT_INTR: 1508 scp->active = ATA_WAIT_INTR; 1509 asleep((caddr_t)scp, PRIBIO, "atacmd", 10 * hz); |
1495 outb(scp->ioaddr + ATA_CMD, command); | 1510 ATA_OUTB(scp->r_io, ATA_CMD, command); |
1496 1497 /* enable interrupt */ 1498 if (scp->flags & ATA_QUEUED) | 1511 1512 /* enable interrupt */ 1513 if (scp->flags & ATA_QUEUED) |
1499 outb(scp->altioaddr, ATA_A_4BIT); | 1514 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_4BIT); |
1500 1501 if (await(PRIBIO, 10 * hz)) { 1502 ata_printf(scp, device, "ata_command: timeout waiting for intr\n"); 1503 scp->active = ATA_IDLE; 1504 error = -1; 1505 } 1506 break; 1507 1508 case ATA_WAIT_READY: 1509 if (scp->active != ATA_REINITING) 1510 scp->active = ATA_WAIT_READY; | 1515 1516 if (await(PRIBIO, 10 * hz)) { 1517 ata_printf(scp, device, "ata_command: timeout waiting for intr\n"); 1518 scp->active = ATA_IDLE; 1519 error = -1; 1520 } 1521 break; 1522 1523 case ATA_WAIT_READY: 1524 if (scp->active != ATA_REINITING) 1525 scp->active = ATA_WAIT_READY; |
1511 outb(scp->ioaddr + ATA_CMD, command); | 1526 ATA_OUTB(scp->r_io, ATA_CMD, command); |
1512 if (ata_wait(scp, device, ATA_S_READY) < 0) { 1513 ata_printf(scp, device, 1514 "timeout waiting for command=%02x s=%02x e=%02x\n", 1515 command, scp->status, scp->error); 1516 error = -1; 1517 } 1518 if (scp->active != ATA_REINITING) 1519 scp->active = ATA_IDLE; 1520 break; 1521 1522 case ATA_IMMEDIATE: | 1527 if (ata_wait(scp, device, ATA_S_READY) < 0) { 1528 ata_printf(scp, device, 1529 "timeout waiting for command=%02x s=%02x e=%02x\n", 1530 command, scp->status, scp->error); 1531 error = -1; 1532 } 1533 if (scp->active != ATA_REINITING) 1534 scp->active = ATA_IDLE; 1535 break; 1536 1537 case ATA_IMMEDIATE: |
1523 outb(scp->ioaddr + ATA_CMD, command); | 1538 ATA_OUTB(scp->r_io, ATA_CMD, command); |
1524 break; 1525 1526 default: 1527 ata_printf(scp, device, "DANGER: illegal interrupt flag=%s\n", 1528 active2str(flags)); 1529 } 1530 /* enable interrupt */ 1531 if (scp->flags & ATA_QUEUED) | 1539 break; 1540 1541 default: 1542 ata_printf(scp, device, "DANGER: illegal interrupt flag=%s\n", 1543 active2str(flags)); 1544 } 1545 /* enable interrupt */ 1546 if (scp->flags & ATA_QUEUED) |
1532 outb(scp->altioaddr, ATA_A_4BIT); | 1547 ATA_OUTB(scp->r_altio, ATA_ALTSTAT, ATA_A_4BIT); |
1533 return error; 1534} 1535 1536int 1537ata_get_lun(u_int32_t *map) 1538{ 1539 int lun = ffs(~*map) - 1; 1540 --- 271 unchanged lines hidden --- | 1548 return error; 1549} 1550 1551int 1552ata_get_lun(u_int32_t *map) 1553{ 1554 int lun = ffs(~*map) - 1; 1555 --- 271 unchanged lines hidden --- |