Deleted Added
full compact
ata-all.c (45554) ata-all.c (45720)
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.5 1999/03/28 18:57:18 sos Exp $
28 * $Id: ata-all.c,v 1.6 1999/04/10 18:53:35 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>
37#include <sys/systm.h>
38#include <sys/kernel.h>
39#include <sys/interrupt.h>
40#include <sys/conf.h>
41#include <sys/buf.h>
42#include <sys/malloc.h>
43#include <sys/devicestat.h>
44#include <vm/vm.h>
45#include <vm/pmap.h>
46#include <machine/clock.h>
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>
37#include <sys/systm.h>
38#include <sys/kernel.h>
39#include <sys/interrupt.h>
40#include <sys/conf.h>
41#include <sys/buf.h>
42#include <sys/malloc.h>
43#include <sys/devicestat.h>
44#include <vm/vm.h>
45#include <vm/pmap.h>
46#include <machine/clock.h>
47#ifdef __i386__
47#include <machine/smp.h>
48#include <machine/smp.h>
49#endif
48#include <pci/pcivar.h>
49#include <pci/pcireg.h>
50#include <pci/pcivar.h>
51#include <pci/pcireg.h>
52#ifdef __i386__
50#include <i386/isa/icu.h>
51#include <i386/isa/isa.h>
52#include <i386/isa/isa_device.h>
53#include <i386/isa/icu.h>
54#include <i386/isa/isa.h>
55#include <i386/isa/isa_device.h>
56#else
57#include <isa/isareg.h>
58#endif
53#include <dev/ata/ata-all.h>
54#include <dev/ata/ata-disk.h>
55#include <dev/ata/atapi-all.h>
56
57/* misc defines */
58#define UNIT(dev) (dev>>3 & 0x1f) /* assume 8 minor # per unit */
59#define MIN(a,b) ((a)>(b)?(b):(a))
60#if NSMP == 0
61#define isa_apic_irq(x) x
62#endif
63
64/* prototypes */
59#include <dev/ata/ata-all.h>
60#include <dev/ata/ata-disk.h>
61#include <dev/ata/atapi-all.h>
62
63/* misc defines */
64#define UNIT(dev) (dev>>3 & 0x1f) /* assume 8 minor # per unit */
65#define MIN(a,b) ((a)>(b)?(b):(a))
66#if NSMP == 0
67#define isa_apic_irq(x) x
68#endif
69
70/* prototypes */
65#if NISA > 0
71#if NISA > 0 && defined(__i386__)
66static int32_t ata_isaprobe(struct isa_device *);
67static int32_t ata_isaattach(struct isa_device *);
68#endif
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];
72static int32_t ata_isaprobe(struct isa_device *);
73static int32_t ata_isaattach(struct isa_device *);
74#endif
75#if NPCI > 0
76static const char *ata_pciprobe(pcici_t, pcidi_t);
77static void ata_pciattach(pcici_t, int32_t);
78static void promise_intr(int32_t);
79#endif
80static int32_t ata_probe(int32_t, int32_t, int32_t, pcici_t, int32_t *);
81static void ataintr(int32_t);
82
83static int32_t atanlun = 0;
84struct ata_softc *atadevices[MAXATA];
85
86#if NISA > 0 && defined(__i386__)
79struct isa_driver atadriver = { ata_isaprobe, ata_isaattach, "ata" };
80
87struct isa_driver atadriver = { ata_isaprobe, ata_isaattach, "ata" };
88
81#if NISA > 0
82static int32_t
83ata_isaprobe(struct isa_device *devp)
84{
85 int32_t ctlr, res;
86
87 for (ctlr = 0; ctlr < atanlun; ctlr++) {
88 if (atadevices[ctlr]->ioaddr == devp->id_iobase) {
89 printf("ata-isa%d: already registered as ata%d\n",

--- 38 unchanged lines hidden (view full) ---

128 case 0x70108086:
129 return "Intel PIIX3 IDE controller";
130 case 0x71118086:
131 return "Intel PIIX4 IDE controller";
132 case 0x4d33105a:
133 return "Promise Ultra/33 IDE controller";
134 case 0x522910b9:
135 return "AcerLabs Aladdin IDE controller";
89static int32_t
90ata_isaprobe(struct isa_device *devp)
91{
92 int32_t ctlr, res;
93
94 for (ctlr = 0; ctlr < atanlun; ctlr++) {
95 if (atadevices[ctlr]->ioaddr == devp->id_iobase) {
96 printf("ata-isa%d: already registered as ata%d\n",

--- 38 unchanged lines hidden (view full) ---

135 case 0x70108086:
136 return "Intel PIIX3 IDE controller";
137 case 0x71118086:
138 return "Intel PIIX4 IDE controller";
139 case 0x4d33105a:
140 return "Promise Ultra/33 IDE controller";
141 case 0x522910b9:
142 return "AcerLabs Aladdin IDE controller";
143 case 0x06401095:
144 return "CMD 640 IDE controller";
145 case 0x06461095:
146 return "CMD 646 IDE controller";
136#if 0
137 case 0x05711106:
138 return "VIA Apollo IDE controller";
139 case 0x01021078:
140 return "Cyrix 5530 IDE controller";
141#endif
142 default:
143 return "Unknown PCI IDE controller";

--- 73 unchanged lines hidden (view full) ---

217 else
218 printf("ata-pci%d: Busmastering DMA not supported\n", unit);
219 }
220
221 /* now probe the addresse found for "real" ATA/ATAPI hardware */
222 lun = 0;
223 if (ata_probe(iobase_1, altiobase_1, bmaddr_1, tag, &lun)) {
224 if (iobase_1 == IO_WD1)
147#if 0
148 case 0x05711106:
149 return "VIA Apollo IDE controller";
150 case 0x01021078:
151 return "Cyrix 5530 IDE controller";
152#endif
153 default:
154 return "Unknown PCI IDE controller";

--- 73 unchanged lines hidden (view full) ---

228 else
229 printf("ata-pci%d: Busmastering DMA not supported\n", unit);
230 }
231
232 /* now probe the addresse found for "real" ATA/ATAPI hardware */
233 lun = 0;
234 if (ata_probe(iobase_1, altiobase_1, bmaddr_1, tag, &lun)) {
235 if (iobase_1 == IO_WD1)
236#ifdef __i386__
225 register_intr(irq1, (int)"", 0, (inthand2_t *)ataintr,
226 &bio_imask, lun);
237 register_intr(irq1, (int)"", 0, (inthand2_t *)ataintr,
238 &bio_imask, lun);
239#else
240 alpha_platform_setup_ide_intr(0, ataintr, (void *)(intptr_t)lun);
241#endif
227 else {
228 if (sysctrl)
229 pci_map_int(tag, (inthand2_t *)promise_intr,
242 else {
243 if (sysctrl)
244 pci_map_int(tag, (inthand2_t *)promise_intr,
230 (void *)lun, &bio_imask);
245 (void *)(intptr_t)lun, &bio_imask);
231 else
246 else
232 pci_map_int(tag, (inthand2_t *)ataintr, (void *)lun,&bio_imask);
247 pci_map_int(tag, (inthand2_t *)ataintr, (void *)(intptr_t)lun,&bio_imask);
233 }
234 printf("ata%d at 0x%04x irq %d on ata-pci%d\n",
235 lun, iobase_1, isa_apic_irq(irq1), unit);
236 }
237 lun = 1;
238 if (ata_probe(iobase_2, altiobase_2, bmaddr_2, tag, &lun)) {
239 if (iobase_2 == IO_WD2)
248 }
249 printf("ata%d at 0x%04x irq %d on ata-pci%d\n",
250 lun, iobase_1, isa_apic_irq(irq1), unit);
251 }
252 lun = 1;
253 if (ata_probe(iobase_2, altiobase_2, bmaddr_2, tag, &lun)) {
254 if (iobase_2 == IO_WD2)
255#ifdef __i386__
240 register_intr(irq2, (int)"", 0, (inthand2_t *)ataintr,
241 &bio_imask, lun);
256 register_intr(irq2, (int)"", 0, (inthand2_t *)ataintr,
257 &bio_imask, lun);
258#else
259 alpha_platform_setup_ide_intr(1, ataintr, (void *)(intptr_t)lun);
260#endif
242 else {
243 if (!sysctrl)
261 else {
262 if (!sysctrl)
244 pci_map_int(tag, (inthand2_t *)ataintr, (void *)lun,&bio_imask);
263 pci_map_int(tag, (inthand2_t *)ataintr, (void *)(intptr_t)lun,&bio_imask);
245 }
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)

--- 160 unchanged lines hidden (view full) ---

413 *unit = scp->lun;
414 scp->tag = tag;
415 if (bmaddr)
416 scp->bmaddr = bmaddr;
417 atadevices[scp->lun] = scp;
418#ifndef ATA_STATIC_ID
419 atanlun++;
420#endif
264 }
265 printf("ata%d at 0x%04x irq %d on ata-pci%d\n",
266 lun, iobase_2, isa_apic_irq(irq2), unit);
267 }
268}
269
270static void
271promise_intr(int32_t unit)

--- 160 unchanged lines hidden (view full) ---

432 *unit = scp->lun;
433 scp->tag = tag;
434 if (bmaddr)
435 scp->bmaddr = bmaddr;
436 atadevices[scp->lun] = scp;
437#ifndef ATA_STATIC_ID
438 atanlun++;
439#endif
440 outb(scp->ioaddr + ATA_DRIVE, ATA_D_IBM | ATA_MASTER);
421 return ATA_IOSIZE;
422}
423
424static void
425ataintr(int32_t unit)
426{
427 struct ata_softc *scp;
428 struct atapi_request *atapi_request;

--- 137 unchanged lines hidden (view full) ---

566 if (scp->active != ATA_IDLE && flags != ATA_IMMEDIATE)
567 printf("DANGER active=%d\n", scp->active);
568
569 switch (flags) {
570 case ATA_WAIT_INTR:
571 scp->active = ATA_WAIT_INTR;
572 outb(scp->ioaddr + ATA_CMD, command);
573 if (tsleep((caddr_t)scp, PRIBIO, "atacmd", 500)) {
441 return ATA_IOSIZE;
442}
443
444static void
445ataintr(int32_t unit)
446{
447 struct ata_softc *scp;
448 struct atapi_request *atapi_request;

--- 137 unchanged lines hidden (view full) ---

586 if (scp->active != ATA_IDLE && flags != ATA_IMMEDIATE)
587 printf("DANGER active=%d\n", scp->active);
588
589 switch (flags) {
590 case ATA_WAIT_INTR:
591 scp->active = ATA_WAIT_INTR;
592 outb(scp->ioaddr + ATA_CMD, command);
593 if (tsleep((caddr_t)scp, PRIBIO, "atacmd", 500)) {
574 printf("ata_command: timeout waiting for interrupt");
594 printf("ata_command: timeout waiting for interrupt\n");
575 scp->active = ATA_IDLE;
576 return -1;
577 }
578 break;
579
580 case ATA_IGNORE_INTR:
581 scp->active = ATA_IGNORE_INTR;
582 outb(scp->ioaddr + ATA_CMD, command);

--- 53 unchanged lines hidden ---
595 scp->active = ATA_IDLE;
596 return -1;
597 }
598 break;
599
600 case ATA_IGNORE_INTR:
601 scp->active = ATA_IGNORE_INTR;
602 outb(scp->ioaddr + ATA_CMD, command);

--- 53 unchanged lines hidden ---