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 53029 1999-11-08 21:36:00Z 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" --- 32 unchanged lines hidden (view full) --- 69#include <dev/ata/ata-all.h> 70#include <dev/ata/ata-disk.h> 71#include <dev/ata/atapi-all.h> 72 73/* misc defines */ 74#if SMP == 0 75#define isa_apic_irq(x) x 76#endif |
77#define IOMASK 0xfffffffc /* XXX SOS 0xfffc */ |
78 79/* prototypes */ 80static int32_t ata_probe(int32_t, int32_t, int32_t, device_t, int32_t *); 81static void ataintr(void *); 82static int8_t *active2str(int32_t); 83 84/* local vars */ 85static int32_t atanlun = 2; --- 173 unchanged lines hidden (view full) --- 259#endif 260 261 if (pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) { 262 iobase_1 = IO_WD1; 263 altiobase_1 = iobase_1 + ATA_ALTPORT; 264 irq1 = 14; 265 } 266 else { |
267 iobase_1 = pci_read_config(dev, 0x10, 4) & IOMASK; 268 altiobase_1 = pci_read_config(dev, 0x14, 4) & IOMASK; 269 bmaddr_1 = pci_read_config(dev, 0x20, 4) & IOMASK; |
270 irq1 = pci_read_config(dev, PCI_INTERRUPT_REG, 4) & 0xff; 271 } 272 273 if (pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) { 274 iobase_2 = IO_WD2; 275 altiobase_2 = iobase_2 + ATA_ALTPORT; 276 irq2 = 15; 277 } 278 else { |
279 iobase_2 = pci_read_config(dev, 0x18, 4) & IOMASK; 280 altiobase_2 = pci_read_config(dev, 0x1c, 4) & IOMASK; 281 bmaddr_2 = (pci_read_config(dev, 0x20, 4) & IOMASK) + ATA_BM_OFFSET1; |
282 irq2 = pci_read_config(dev, PCI_INTERRUPT_REG, 4) & 0xff; 283 } 284 285 /* is this controller busmaster DMA capable ? */ 286 if (pci_get_progif(dev) & PCIP_STORAGE_IDE_MASTERDEV) { 287 /* is busmastering support turned on ? */ 288 if ((pci_read_config(dev, PCI_COMMAND_STATUS_REG, 4) & 5) == 5) { 289 /* is there a valid port range to connect to ? */ |
290 if ((bmaddr_1 = pci_read_config(dev, 0x20, 4) & IOMASK)) { |
291 bmaddr_2 = bmaddr_1 + ATA_BM_OFFSET1; 292 printf("ata-pci%d: Busmastering DMA supported\n", unit); 293 } 294 else 295 printf("ata-pci%d: Busmastering DMA not configured\n", unit); 296 } 297 else 298 printf("ata-pci%d: Busmastering DMA not enabled\n", unit); 299 } 300 else { |
301 if (type == 0x4d33105a || type == 0x4d38105a || type == 0x00041103) { 302 /* Promise and HPT366 controllers support busmastering DMA */ |
303 printf("ata-pci%d: Busmastering DMA supported\n", unit); |
304 } |
305 else { |
306 /* we dont know this controller, disable busmastering DMA */ |
307 bmaddr_1 = bmaddr_2 = 0; 308 printf("ata-pci%d: Busmastering DMA not supported\n", unit); 309 } 310 } |
311 312 /* on the Aladdin activate the ATAPI FIFO */ 313 if (type == 0x522910b9) { 314 pci_write_config(dev, 0x53, 315 (pci_read_config(dev, 0x53, 1) & ~0x01) | 0x02, 1); 316 } 317 318 /* the Promise controllers needs burst mode to be turned on explicitly */ 319 if (type == 0x4d33105a || type == 0x4d38105a) 320 outb(bmaddr_1 + 0x1f, inb(bmaddr_1 + 0x1f) | 0x01); |
321 322 /* now probe the addresse found for "real" ATA/ATAPI hardware */ 323 lun = 0; 324 if (iobase_1 && ata_probe(iobase_1, altiobase_1, bmaddr_1, dev, &lun)) { 325 scp = atadevices[lun]; 326 if (iobase_1 == IO_WD1) 327#ifdef __i386__ 328 inthand_add(device_get_nameunit(dev), irq1, ataintr, scp, --- 185 unchanged lines hidden (view full) --- 514} 515 516static void 517ataintr(void *data) 518{ 519 struct ata_softc *scp =(struct ata_softc *)data; 520 521 /* is this interrupt really for this channel */ |
522 if ((scp->flags & ATA_DMA_ACTIVE) && 523 !(ata_dmastatus(scp) & ATA_BMSTAT_INTERRUPT)) |
524 return; 525 |
526 if (((scp->status = inb(scp->ioaddr+ATA_STATUS)) & ATA_S_BUSY)==ATA_S_BUSY) 527 return; 528 |
529 /* find & call the responsible driver to process this interrupt */ 530 switch (scp->active) { 531#if NATADISK > 0 532 case ATA_ACTIVE_ATA: 533 if (!scp->running) 534 return; 535 if (ad_interrupt(scp->running) == ATA_OP_CONTINUES) 536 return; 537 break; 538#endif 539#if NATAPICD > 0 || NATAPIFD > 0 || NATAPIST > 0 540 case ATA_ACTIVE_ATAPI: |
541 if (!scp->running) |
542 return; 543 if (atapi_interrupt(scp->running) == ATA_OP_CONTINUES) 544 return; 545 break; 546#endif 547 case ATA_WAIT_INTR: 548 wakeup((caddr_t)scp); 549 break; --- 362 unchanged lines hidden --- |