Deleted Added
sdiff udiff text old ( 45095 ) new ( 45554 )
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 * $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
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;
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
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;
176 outb(bmaddr_1 + 0x1f, inb(bmaddr_1 + 0x1f) | 0x01);
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{
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)
258 ataintr(unit);
259
260 if (channel & 0x00004000)
261 ataintr(unit+1);
262}
263#endif
264
265static int32_t
266ata_probe(int32_t ioaddr, int32_t altioaddr, int32_t bmaddr,
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;
430 u_int8_t status;
431 static int32_t intr_count = 0;
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:
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);
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 ---