Deleted Added
sdiff udiff text old ( 52303 ) new ( 52918 )
full compact
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 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;
246 struct resource *irq = NULL;
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 {
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 int rid = 0;
352 void *ih;
353
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 }
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;
518 if ((scp->status = inb(scp->ioaddr + ATA_STATUS)) == ATA_S_BUSY)
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:
525 if (!scp->running)
526 return;
527 if (ad_interrupt(scp->running) == ATA_OP_CONTINUES)
528 return;
529 break;
530#endif
531#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
532 case ATA_ACTIVE_ATAPI:
533 if (!scp->running)
534 return;
535 if (atapi_interrupt(scp->running) == ATA_OP_CONTINUES)
536 return;
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
546 case ATA_REINITING:
547 return;
548
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)
788 printf("WARNING: WAIT_INTR active=%s\n", active2str(scp->active));
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
798 case ATA_WAIT_READY:
799 if (scp->active != ATA_IDLE && scp->active != ATA_REINITING)
800 printf("WARNING: WAIT_READY active=%s\n", active2str(scp->active));
801 scp->active = ATA_WAIT_READY;
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 }
809 break;
810
811 case ATA_IMMEDIATE:
812 outb(scp->ioaddr + ATA_CMD, command);
813 break;
814
815 default:
816 printf("DANGER: illegal interrupt flag=%s\n", active2str(flags));
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");
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 ---