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 52303 1999-10-16 09:00:49Z dfr $
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 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 {
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 {
351 struct resource *irq;
352 int rid = 0;
353 void *ih;
354
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 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;
517 if ((scp->status = inb(scp->ioaddr + ATA_STATUS)) == ATA_S_BUSY) /*XXX SOS*/
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:
524 if (scp->running && (ad_interrupt(scp->running) == ATA_OP_CONTINUES))
525 return;
526 break;
527#endif
528#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0
529 case ATA_ACTIVE_ATAPI:
530 if (scp->running && (atapi_interrupt(scp->running) == ATA_OP_CONTINUES))
531 return;
532 break;
533#endif
534 case ATA_WAIT_INTR:
535 wakeup((caddr_t)scp);
536 break;
537
538 case ATA_REINITING:
539 return;
540
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)
783 printf("DANGER 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
793 case ATA_IGNORE_INTR:
794 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;
798 outb(scp->ioaddr + ATA_CMD, command);
799 break;
800
801 case ATA_IMMEDIATE:
802 outb(scp->ioaddr + ATA_CMD, command);
803 break;
804
805 default:
806 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");
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 ---