ata-all.c (45095) | ata-all.c (45554) |
---|---|
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 * $Id: ata-all.c,v 1.4 1999/03/07 21:49:14 sos Exp $ | 28 * $Id: ata-all.c,v 1.5 1999/03/28 18:57:18 sos 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 <sys/param.h> --- 32 unchanged lines hidden (view full) --- 69#if NPCI > 0 70static const char *ata_pciprobe(pcici_t, pcidi_t); 71static void ata_pciattach(pcici_t, int32_t); 72static void promise_intr(int32_t); 73#endif 74static int32_t ata_probe(int32_t, int32_t, int32_t, pcici_t, int32_t *); 75static void ataintr(int32_t); 76 | 29 */ 30 31#include "ata.h" 32#if NATA > 0 33#include "isa.h" 34#include "pci.h" 35#include "atadisk.h" 36#include <sys/param.h> --- 32 unchanged lines hidden (view full) --- 69#if NPCI > 0 70static const char *ata_pciprobe(pcici_t, pcidi_t); 71static void ata_pciattach(pcici_t, int32_t); 72static void promise_intr(int32_t); 73#endif 74static int32_t ata_probe(int32_t, int32_t, int32_t, pcici_t, int32_t *); 75static void ataintr(int32_t); 76 |
77static int32_t atanlun = 0, sysctrl = 0; | 77static int32_t atanlun = 0; |
78struct ata_softc *atadevices[MAXATA]; 79struct isa_driver atadriver = { ata_isaprobe, ata_isaattach, "ata" }; 80 81#if NISA > 0 82static int32_t 83ata_isaprobe(struct isa_device *devp) 84{ 85 int32_t ctlr, res; --- 60 unchanged lines hidden (view full) --- 146 return NULL; 147} 148 149static void 150ata_pciattach(pcici_t tag, int32_t unit) 151{ 152 pcidi_t type, class, cmd; 153 int32_t iobase_1, iobase_2, altiobase_1, altiobase_2; | 78struct ata_softc *atadevices[MAXATA]; 79struct isa_driver atadriver = { ata_isaprobe, ata_isaattach, "ata" }; 80 81#if NISA > 0 82static int32_t 83ata_isaprobe(struct isa_device *devp) 84{ 85 int32_t ctlr, res; --- 60 unchanged lines hidden (view full) --- 146 return NULL; 147} 148 149static void 150ata_pciattach(pcici_t tag, int32_t unit) 151{ 152 pcidi_t type, class, cmd; 153 int32_t iobase_1, iobase_2, altiobase_1, altiobase_2; |
154 int32_t bmaddr_1 = 0, bmaddr_2 = 0, irq1, irq2; | 154 int32_t bmaddr_1 = 0, bmaddr_2 = 0, sysctrl = 0, irq1, irq2; |
155 int32_t lun; 156 157 /* set up vendor-specific stuff */ 158 type = pci_conf_read(tag, PCI_ID_REG); 159 class = pci_conf_read(tag, PCI_CLASS_REG); 160 cmd = pci_conf_read(tag, PCI_COMMAND_STATUS_REG); 161 162#ifdef ATA_DEBUG 163 printf("ata%d: type=%08x class=%08x cmd=%08x\n", unit, type, class, cmd); 164#endif 165 | 155 int32_t lun; 156 157 /* set up vendor-specific stuff */ 158 type = pci_conf_read(tag, PCI_ID_REG); 159 class = pci_conf_read(tag, PCI_CLASS_REG); 160 cmd = pci_conf_read(tag, PCI_COMMAND_STATUS_REG); 161 162#ifdef ATA_DEBUG 163 printf("ata%d: type=%08x class=%08x cmd=%08x\n", unit, type, class, cmd); 164#endif 165 |
166 /* if this is at Promise controller handle it specially */ | 166 /* if this is a Promise controller handle it specially */ |
167 if (type == 0x4d33105a) { 168 iobase_1 = pci_conf_read(tag, 0x10) & 0xfffc; 169 altiobase_1 = pci_conf_read(tag, 0x14) & 0xfffc; 170 iobase_2 = pci_conf_read(tag, 0x18) & 0xfffc; 171 altiobase_2 = pci_conf_read(tag, 0x1c) & 0xfffc; 172 irq1 = irq2 = pci_conf_read(tag, PCI_INTERRUPT_REG) & 0xff; 173 bmaddr_1 = pci_conf_read(tag, 0x20) & 0xfffc; 174 bmaddr_2 = bmaddr_1 + ATA_BM_OFFSET1; 175 sysctrl = (pci_conf_read(tag, 0x20) & 0xfffc) + 0x1c; | 167 if (type == 0x4d33105a) { 168 iobase_1 = pci_conf_read(tag, 0x10) & 0xfffc; 169 altiobase_1 = pci_conf_read(tag, 0x14) & 0xfffc; 170 iobase_2 = pci_conf_read(tag, 0x18) & 0xfffc; 171 altiobase_2 = pci_conf_read(tag, 0x1c) & 0xfffc; 172 irq1 = irq2 = pci_conf_read(tag, PCI_INTERRUPT_REG) & 0xff; 173 bmaddr_1 = pci_conf_read(tag, 0x20) & 0xfffc; 174 bmaddr_2 = bmaddr_1 + ATA_BM_OFFSET1; 175 sysctrl = (pci_conf_read(tag, 0x20) & 0xfffc) + 0x1c; |
176 outb(bmaddr_1 + 0x1f, inb(bmaddr_1 + 0x1f) | 0x01); |
|
176 printf("ata-pci%d: Busmastering DMA supported\n", unit); 177 } 178 /* everybody else seems to do it this way */ 179 else { 180 if ((class & 0x100) == 0) { 181 iobase_1 = IO_WD1; 182 altiobase_1 = iobase_1 + ATA_ALTPORT; 183 irq1 = 14; --- 61 unchanged lines hidden (view full) --- 245 printf("ata%d at 0x%04x irq %d on ata-pci%d\n", 246 lun, iobase_2, isa_apic_irq(irq2), unit); 247 } 248} 249 250static void 251promise_intr(int32_t unit) 252{ | 177 printf("ata-pci%d: Busmastering DMA supported\n", unit); 178 } 179 /* everybody else seems to do it this way */ 180 else { 181 if ((class & 0x100) == 0) { 182 iobase_1 = IO_WD1; 183 altiobase_1 = iobase_1 + ATA_ALTPORT; 184 irq1 = 14; --- 61 unchanged lines hidden (view full) --- 246 printf("ata%d at 0x%04x irq %d on ata-pci%d\n", 247 lun, iobase_2, isa_apic_irq(irq2), unit); 248 } 249} 250 251static void 252promise_intr(int32_t unit) 253{ |
253 if (inl(sysctrl) & 0x00000400) | 254 struct ata_softc *scp = atadevices[unit]; 255 int32_t channel = inl((pci_conf_read(scp->tag, 0x20) & 0xfffc) + 0x1c); 256 257 if (channel & 0x00000400) |
254 ataintr(unit); | 258 ataintr(unit); |
255 if (inl(sysctrl) & 0x00004000) | 259 260 if (channel & 0x00004000) |
256 ataintr(unit+1); 257} 258#endif 259 260static int32_t | 261 ataintr(unit+1); 262} 263#endif 264 265static int32_t |
261ata_probe(int32_t ioaddr, int32_t altioaddr, int32_t bmaddr, | 266ata_probe(int32_t ioaddr, int32_t altioaddr, int32_t bmaddr, |
262 pcici_t tag, int32_t *unit) 263{ 264 struct ata_softc *scp = atadevices[atanlun]; 265 int32_t mask = 0; 266 int32_t timeout; 267 int32_t lun = atanlun; 268 u_int8_t status0, status1; 269 --- 147 unchanged lines hidden (view full) --- 417} 418 419static void 420ataintr(int32_t unit) 421{ 422 struct ata_softc *scp; 423 struct atapi_request *atapi_request; 424 struct buf *ata_request; | 267 pcici_t tag, int32_t *unit) 268{ 269 struct ata_softc *scp = atadevices[atanlun]; 270 int32_t mask = 0; 271 int32_t timeout; 272 int32_t lun = atanlun; 273 u_int8_t status0, status1; 274 --- 147 unchanged lines hidden (view full) --- 422} 423 424static void 425ataintr(int32_t unit) 426{ 427 struct ata_softc *scp; 428 struct atapi_request *atapi_request; 429 struct buf *ata_request; |
425 static int32_t intcount = 0; | 430 u_int8_t status; 431 static int32_t intr_count = 0; |
426 427 if (unit < 0 || unit > atanlun) { 428 printf("ataintr: unit %d unusable\n", unit); 429 return; 430 } 431 432 scp = atadevices[unit]; 433 --- 16 unchanged lines hidden (view full) --- 450 wakeup((caddr_t)scp); 451 break; 452 453 case ATA_IGNORE_INTR: 454 break; 455 456 default: 457 case ATA_IDLE: | 432 433 if (unit < 0 || unit > atanlun) { 434 printf("ataintr: unit %d unusable\n", unit); 435 return; 436 } 437 438 scp = atadevices[unit]; 439 --- 16 unchanged lines hidden (view full) --- 456 wakeup((caddr_t)scp); 457 break; 458 459 case ATA_IGNORE_INTR: 460 break; 461 462 default: 463 case ATA_IDLE: |
458 if (intcount++ < 10) 459 printf("ata%d: unwanted interrupt %d\n", unit, intcount); 460 inb(scp->ioaddr + ATA_STATUS); | 464 status = inb(scp->ioaddr + ATA_STATUS); 465 if (intr_count++ < 10) 466 printf("ata%d: unwanted interrupt %d status = %02x\n", 467 unit, intr_count, status); |
461 return; 462 } 463 scp->active = ATA_IDLE; 464 ata_start(scp); 465} 466 467void 468ata_start(struct ata_softc *scp) --- 160 unchanged lines hidden --- | 468 return; 469 } 470 scp->active = ATA_IDLE; 471 ata_start(scp); 472} 473 474void 475ata_start(struct ata_softc *scp) --- 160 unchanged lines hidden --- |