Deleted Added
full compact
ata-all.c (52303) ata-all.c (52918)
1/*-
2 * Copyright (c) 1998,1999 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 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 52303 1999-10-16 09:00:49Z dfr $
28 * $FreeBSD: head/sys/dev/ata/ata-all.c 52918 1999-11-06 16:50:21Z sos $
29 */
30
31#include "ata.h"
32#include "apm.h"
33#include "isa.h"
34#include "pci.h"
35#include "atadisk.h"
36#include "atapicd.h"

--- 201 unchanged lines hidden (view full) ---

238{
239 int unit = device_get_unit(dev);
240 struct ata_softc *scp;
241 u_int32_t type;
242 u_int8_t class, subclass;
243 u_int32_t cmd;
244 int32_t iobase_1, iobase_2, altiobase_1, altiobase_2;
245 int32_t bmaddr_1 = 0, bmaddr_2 = 0, irq1, irq2;
29 */
30
31#include "ata.h"
32#include "apm.h"
33#include "isa.h"
34#include "pci.h"
35#include "atadisk.h"
36#include "atapicd.h"

--- 201 unchanged lines hidden (view full) ---

238{
239 int unit = device_get_unit(dev);
240 struct ata_softc *scp;
241 u_int32_t type;
242 u_int8_t class, subclass;
243 u_int32_t cmd;
244 int32_t iobase_1, iobase_2, altiobase_1, altiobase_2;
245 int32_t bmaddr_1 = 0, bmaddr_2 = 0, irq1, irq2;
246 struct resource *irq = NULL;
246 int32_t lun;
247
248 /* set up vendor-specific stuff */
249 type = pci_get_devid(dev);
250 class = pci_get_class(dev);
251 subclass = pci_get_subclass(dev);
252 cmd = pci_read_config(dev, PCIR_COMMAND, 4);
253

--- 65 unchanged lines hidden (view full) ---

319#ifdef __i386__
320 inthand_add(device_get_nameunit(dev), irq1, ataintr, scp,
321 &bio_imask, INTR_EXCL);
322#endif
323#ifdef __alpha__
324 alpha_platform_setup_ide_intr(0, ataintr, scp);
325#endif
326 else {
247 int32_t lun;
248
249 /* set up vendor-specific stuff */
250 type = pci_get_devid(dev);
251 class = pci_get_class(dev);
252 subclass = pci_get_subclass(dev);
253 cmd = pci_read_config(dev, PCIR_COMMAND, 4);
254

--- 65 unchanged lines hidden (view full) ---

320#ifdef __i386__
321 inthand_add(device_get_nameunit(dev), irq1, ataintr, scp,
322 &bio_imask, INTR_EXCL);
323#endif
324#ifdef __alpha__
325 alpha_platform_setup_ide_intr(0, ataintr, scp);
326#endif
327 else {
327 struct resource *irq;
328 int rid = 0;
329 void *ih;
330
331 if (!(irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
332 RF_SHAREABLE | RF_ACTIVE)))
333 printf("ata_pciattach: Unable to alloc interrupt\n");
334 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih);
335 }

--- 7 unchanged lines hidden (view full) ---

343#ifdef __i386__
344 inthand_add(device_get_nameunit(dev), irq2, ataintr, scp,
345 &bio_imask, INTR_EXCL);
346#endif
347#ifdef __alpha__
348 alpha_platform_setup_ide_intr(1, ataintr, scp);
349#endif
350 else {
328 int rid = 0;
329 void *ih;
330
331 if (!(irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
332 RF_SHAREABLE | RF_ACTIVE)))
333 printf("ata_pciattach: Unable to alloc interrupt\n");
334 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih);
335 }

--- 7 unchanged lines hidden (view full) ---

343#ifdef __i386__
344 inthand_add(device_get_nameunit(dev), irq2, ataintr, scp,
345 &bio_imask, INTR_EXCL);
346#endif
347#ifdef __alpha__
348 alpha_platform_setup_ide_intr(1, ataintr, scp);
349#endif
350 else {
351 struct resource *irq;
352 int rid = 0;
353 void *ih;
354
351 int rid = 0;
352 void *ih;
353
355 if (!(irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
356 RF_SHAREABLE | RF_ACTIVE)))
357 printf("ata_pciattach: Unable to alloc interrupt\n");
354 if (irq1 != irq2 || irq == NULL) {
355 if (!(irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
356 RF_SHAREABLE | RF_ACTIVE)))
357 printf("ata_pciattach: Unable to alloc interrupt\n");
358 }
358 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih);
359 }
360 printf("ata%d at 0x%04x irq %d on ata-pci%d\n",
361 lun, iobase_2, isa_apic_irq(irq2), unit);
362 }
363 return 0;
364}
365

--- 143 unchanged lines hidden (view full) ---

509ataintr(void *data)
510{
511 struct ata_softc *scp =(struct ata_softc *)data;
512
513 /* is this interrupt really for this channel */
514 if (scp->flags & ATA_DMA_ACTIVE)
515 if (!(ata_dmastatus(scp) & ATA_BMSTAT_INTERRUPT))
516 return;
359 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih);
360 }
361 printf("ata%d at 0x%04x irq %d on ata-pci%d\n",
362 lun, iobase_2, isa_apic_irq(irq2), unit);
363 }
364 return 0;
365}
366

--- 143 unchanged lines hidden (view full) ---

510ataintr(void *data)
511{
512 struct ata_softc *scp =(struct ata_softc *)data;
513
514 /* is this interrupt really for this channel */
515 if (scp->flags & ATA_DMA_ACTIVE)
516 if (!(ata_dmastatus(scp) & ATA_BMSTAT_INTERRUPT))
517 return;
517 if ((scp->status = inb(scp->ioaddr + ATA_STATUS)) == ATA_S_BUSY) /*XXX SOS*/
518 if ((scp->status = inb(scp->ioaddr + ATA_STATUS)) == ATA_S_BUSY)
518 return;
519
520 /* find & call the responsible driver to process this interrupt */
521 switch (scp->active) {
522#if NATADISK > 0
523 case ATA_ACTIVE_ATA:
519 return;
520
521 /* find & call the responsible driver to process this interrupt */
522 switch (scp->active) {
523#if NATADISK > 0
524 case ATA_ACTIVE_ATA:
524 if (scp->running && (ad_interrupt(scp->running) == ATA_OP_CONTINUES))
525 return;
525 if (!scp->running)
526 return;
527 if (ad_interrupt(scp->running) == ATA_OP_CONTINUES)
528 return;
526 break;
527#endif
528#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
529 case ATA_ACTIVE_ATAPI:
529 break;
530#endif
531#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
532 case ATA_ACTIVE_ATAPI:
530 if (scp->running && (atapi_interrupt(scp->running) == ATA_OP_CONTINUES))
531 return;
533 if (!scp->running)
534 return;
535 if (atapi_interrupt(scp->running) == ATA_OP_CONTINUES)
536 return;
532 break;
533#endif
534 case ATA_WAIT_INTR:
535 wakeup((caddr_t)scp);
536 break;
537
537 break;
538#endif
539 case ATA_WAIT_INTR:
540 wakeup((caddr_t)scp);
541 break;
542
543 case ATA_WAIT_READY:
544 break;
545
538 case ATA_REINITING:
539 return;
540
546 case ATA_REINITING:
547 return;
548
541 case ATA_IGNORE_INTR:
542 break;
543
544 default:
545 case ATA_IDLE:
546#ifdef ATA_DEBUG
547 {
548 static int32_t intr_count = 0;
549 if (intr_count++ < 10)
550 printf("ata%d: unwanted interrupt %d status = %02x\n",
551 scp->lun, intr_count, scp->status);

--- 223 unchanged lines hidden (view full) ---

775 outb(scp->ioaddr + ATA_CYL_MSB, cylinder >> 8);
776 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device | head);
777 outb(scp->ioaddr + ATA_SECTOR, sector);
778 outb(scp->ioaddr + ATA_COUNT, count);
779
780 switch (flags) {
781 case ATA_WAIT_INTR:
782 if (scp->active != ATA_IDLE)
549 default:
550 case ATA_IDLE:
551#ifdef ATA_DEBUG
552 {
553 static int32_t intr_count = 0;
554 if (intr_count++ < 10)
555 printf("ata%d: unwanted interrupt %d status = %02x\n",
556 scp->lun, intr_count, scp->status);

--- 223 unchanged lines hidden (view full) ---

780 outb(scp->ioaddr + ATA_CYL_MSB, cylinder >> 8);
781 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | device | head);
782 outb(scp->ioaddr + ATA_SECTOR, sector);
783 outb(scp->ioaddr + ATA_COUNT, count);
784
785 switch (flags) {
786 case ATA_WAIT_INTR:
787 if (scp->active != ATA_IDLE)
783 printf("DANGER wait_intr active=%s\n", active2str(scp->active));
788 printf("WARNING: WAIT_INTR active=%s\n", active2str(scp->active));
784 scp->active = ATA_WAIT_INTR;
785 outb(scp->ioaddr + ATA_CMD, command);
786 if (tsleep((caddr_t)scp, PRIBIO, "atacmd", 500)) {
787 printf("ata_command: timeout waiting for interrupt\n");
788 scp->active = ATA_IDLE;
789 return -1;
790 }
791 break;
792
789 scp->active = ATA_WAIT_INTR;
790 outb(scp->ioaddr + ATA_CMD, command);
791 if (tsleep((caddr_t)scp, PRIBIO, "atacmd", 500)) {
792 printf("ata_command: timeout waiting for interrupt\n");
793 scp->active = ATA_IDLE;
794 return -1;
795 }
796 break;
797
793 case ATA_IGNORE_INTR:
798 case ATA_WAIT_READY:
794 if (scp->active != ATA_IDLE && scp->active != ATA_REINITING)
799 if (scp->active != ATA_IDLE && scp->active != ATA_REINITING)
795 printf("DANGER ignore_intr active=%s\n", active2str(scp->active));
796 if (scp->active != ATA_REINITING)
797 scp->active = ATA_IGNORE_INTR;
800 printf("WARNING: WAIT_READY active=%s\n", active2str(scp->active));
801 scp->active = ATA_WAIT_READY;
798 outb(scp->ioaddr + ATA_CMD, command);
802 outb(scp->ioaddr + ATA_CMD, command);
803 if (ata_wait(scp, device, ATA_S_READY) < 0) {
804 printf("ata%d-%s: timeout waiting for command=%02x s=%02x e=%02x\n",
805 scp->lun, device ? "slave" : "master", command,
806 scp->status, scp->error);
807 return -1;
808 }
799 break;
800
801 case ATA_IMMEDIATE:
802 outb(scp->ioaddr + ATA_CMD, command);
803 break;
804
805 default:
809 break;
810
811 case ATA_IMMEDIATE:
812 outb(scp->ioaddr + ATA_CMD, command);
813 break;
814
815 default:
806 printf("DANGER illegal interrupt flag=%s\n", active2str(flags));
816 printf("DANGER: illegal interrupt flag=%s\n", active2str(flags));
807 }
808#ifdef ATA_DEBUG
809 printf("ata_command: leaving\n");
810#endif
811 return 0;
812}
813
814int8_t *

--- 18 unchanged lines hidden (view full) ---

833static int8_t *
834active2str(int32_t active)
835{
836 switch (active) {
837 case ATA_IDLE:
838 return("ATA_IDLE");
839 case ATA_WAIT_INTR:
840 return("ATA_WAIT_INTR");
817 }
818#ifdef ATA_DEBUG
819 printf("ata_command: leaving\n");
820#endif
821 return 0;
822}
823
824int8_t *

--- 18 unchanged lines hidden (view full) ---

843static int8_t *
844active2str(int32_t active)
845{
846 switch (active) {
847 case ATA_IDLE:
848 return("ATA_IDLE");
849 case ATA_WAIT_INTR:
850 return("ATA_WAIT_INTR");
841 case ATA_IGNORE_INTR:
842 return("ATA_IGNORE_INTR");
843 case ATA_ACTIVE_ATA:
844 return("ATA_ACTIVE_ATA");
845 case ATA_ACTIVE_ATAPI:
846 return("ATA_ACTIVE_ATAPI");
847 case ATA_REINITING:
848 return("ATA_REINITING");
849 default:
850 return("UNKNOWN");

--- 45 unchanged lines hidden ---
851 case ATA_ACTIVE_ATA:
852 return("ATA_ACTIVE_ATA");
853 case ATA_ACTIVE_ATAPI:
854 return("ATA_ACTIVE_ATAPI");
855 case ATA_REINITING:
856 return("ATA_REINITING");
857 default:
858 return("UNKNOWN");

--- 45 unchanged lines hidden ---