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 * $Id: ata-all.c,v 1.12 1999/05/08 21:58:58 dfr Exp $ |
29 */ 30 31#include "ata.h" 32#if NATA > 0 33#include "isa.h" 34#include "pci.h" 35#include "atadisk.h" 36#include "opt_global.h" --- 12 unchanged lines hidden (view full) --- 49#include <machine/resource.h> 50#include <machine/bus.h> 51#include <sys/rman.h> 52#include <machine/clock.h> 53#ifdef __i386__ 54#include <machine/smp.h> 55#include <i386/isa/intr_machdep.h> 56#endif |
57#if NPCI > 0 |
58#include <pci/pcivar.h> 59#include <pci/pcireg.h> |
60#endif |
61#include <isa/isavar.h> 62#include <isa/isareg.h> 63#include <dev/ata/ata-all.h> 64#include <dev/ata/ata-disk.h> 65#include <dev/ata/atapi-all.h> 66 67/* misc defines */ 68#define UNIT(dev) (dev>>3 & 0x1f) /* assume 8 minor # per unit */ --- 151 unchanged lines hidden (view full) --- 220ata_pciattach(device_t dev) 221{ 222 int unit = device_get_unit(dev); 223 struct ata_softc *scp; 224 u_int32_t type; 225 u_int8_t class, subclass; 226 u_int32_t cmd; 227 int32_t iobase_1, iobase_2, altiobase_1, altiobase_2; |
228 int32_t bmaddr_1 = 0, bmaddr_2 = 0, irq1, irq2; |
229 int32_t lun; 230 231 /* set up vendor-specific stuff */ 232 type = pci_get_devid(dev); 233 class = pci_get_class(dev); 234 subclass = pci_get_subclass(dev); 235 cmd = pci_read_config(dev, PCIR_COMMAND, 4); 236 --- 6 unchanged lines hidden (view full) --- 243 if (type == 0x4d33105a) { 244 iobase_1 = pci_read_config(dev, 0x10, 4) & 0xfffc; 245 altiobase_1 = pci_read_config(dev, 0x14, 4) & 0xfffc; 246 iobase_2 = pci_read_config(dev, 0x18, 4) & 0xfffc; 247 altiobase_2 = pci_read_config(dev, 0x1c, 4) & 0xfffc; 248 irq1 = irq2 = pci_read_config(dev, PCI_INTERRUPT_REG, 4) & 0xff; 249 bmaddr_1 = pci_read_config(dev, 0x20, 4) & 0xfffc; 250 bmaddr_2 = bmaddr_1 + ATA_BM_OFFSET1; |
251 outb(bmaddr_1 + 0x1f, inb(bmaddr_1 + 0x1f) | 0x01); 252 printf("ata-pci%d: Busmastering DMA supported\n", unit); 253 } 254 /* everybody else seems to do it this way */ 255 else { 256 if ((unit == 0) && 257 (pci_get_progif(dev) & PCIP_STORAGE_IDE_MODEPRIM) == 0) { 258 iobase_1 = IO_WD1; --- 48 unchanged lines hidden (view full) --- 307#ifdef __alpha__ 308 alpha_platform_setup_ide_intr(0, ataintr, scp); 309#endif 310 else { 311 struct resource *irq; 312 int rid = 0; 313 void *ih; 314 |
315 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 316 RF_SHAREABLE | RF_ACTIVE); 317 if (!irq) 318 printf("ata_pciattach: Unable to alloc interrupt\n"); 319 320 if (type == 0x4d33105a) 321 bus_setup_intr(dev, irq, INTR_TYPE_BIO, promise_intr, scp, &ih); |
322 else |
323 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih); |
324 } 325 printf("ata%d at 0x%04x irq %d on ata-pci%d\n", 326 lun, iobase_1, isa_apic_irq(irq1), unit); 327 } 328 lun = 1; 329 if (ata_probe(iobase_2, altiobase_2, bmaddr_2, dev, &lun)) { 330 scp = atadevices[lun]; 331 if (iobase_2 == IO_WD2) --- 4 unchanged lines hidden (view full) --- 336#ifdef __alpha__ 337 alpha_platform_setup_ide_intr(1, ataintr, scp); 338#endif 339 else { 340 struct resource *irq; 341 int rid = 0; 342 void *ih; 343 |
344 if (type != 0x4d33105a) { 345 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, 346 RF_SHAREABLE | RF_ACTIVE); 347 if (!irq) 348 printf("ata_pciattach: Unable to alloc interrupt\n"); 349 |
350 bus_setup_intr(dev, irq, INTR_TYPE_BIO, ataintr, scp, &ih); |
351 } |
352 } 353 printf("ata%d at 0x%04x irq %d on ata-pci%d\n", 354 lun, iobase_2, isa_apic_irq(irq2), unit); 355 } 356 return 0; 357} 358 359static device_method_t ata_pci_methods[] = { --- 187 unchanged lines hidden (view full) --- 547static void 548ataintr(void *data) 549{ 550 struct ata_softc *scp; 551 struct atapi_request *atapi_request; 552 struct buf *ata_request; 553 u_int8_t status; 554 static int32_t intr_count = 0; |
555 556 scp = (struct ata_softc *)data; |
557 558 /* find & call the responsible driver to process this interrupt */ 559 switch (scp->active) { 560#if NATADISK > 0 561 case ATA_ACTIVE_ATA: 562 if ((ata_request = bufq_first(&scp->ata_queue))) 563 if (ad_interrupt(ata_request) == ATA_OP_CONTINUES) 564 return; --- 12 unchanged lines hidden (view full) --- 577 case ATA_IGNORE_INTR: 578 break; 579 580 default: 581 case ATA_IDLE: 582 status = inb(scp->ioaddr + ATA_STATUS); 583 if (intr_count++ < 10) 584 printf("ata%d: unwanted interrupt %d status = %02x\n", |
585 scp->lun, intr_count, status); |
586 return; 587 } 588 scp->active = ATA_IDLE; 589 ata_start(scp); 590} 591 592void 593ata_start(struct ata_softc *scp) --- 160 unchanged lines hidden --- |