isa.c revision 1.75 1 /* $NetBSD: isa.c,v 1.75 1995/12/24 02:31:37 mycroft Exp $ */
2
3 /*-
4 * Copyright (c) 1993, 1994 Charles Hannum. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Charles Hannum.
17 * 4. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/kernel.h>
35 #include <sys/conf.h>
36 #include <sys/malloc.h>
37 #include <sys/device.h>
38
39 #include <dev/isa/isareg.h>
40 #include <dev/isa/isavar.h>
41
42 int
43 isaprint(aux, isa)
44 void *aux;
45 char *isa;
46 {
47 struct isa_attach_args *ia = aux;
48
49 if (ia->ia_iosize)
50 printf(" port 0x%x", ia->ia_iobase);
51 if (ia->ia_iosize > 1)
52 printf("-0x%x", ia->ia_iobase + ia->ia_iosize - 1);
53 if (ia->ia_msize)
54 printf(" iomem 0x%x", ia->ia_maddr);
55 if (ia->ia_msize > 1)
56 printf("-0x%x", ia->ia_maddr + ia->ia_msize - 1);
57 if (ia->ia_irq != IRQUNK)
58 printf(" irq %d", ia->ia_irq);
59 if (ia->ia_drq != DRQUNK)
60 printf(" drq %d", ia->ia_drq);
61 return (UNCONF);
62 }
63
64 void
65 isascan(parent, match)
66 struct device *parent;
67 void *match;
68 {
69 struct device *dev = match;
70 struct cfdata *cf = dev->dv_cfdata;
71 struct isa_attach_args ia;
72
73 if (cf->cf_fstate == FSTATE_STAR)
74 panic("not bloody likely");
75
76 ia.ia_iobase = cf->cf_loc[0];
77 ia.ia_iosize = 0x666;
78 ia.ia_maddr = cf->cf_loc[2];
79 ia.ia_msize = cf->cf_loc[3];
80 ia.ia_irq = cf->cf_loc[4] == 2 ? 9 : cf->cf_loc[4];
81 ia.ia_drq = cf->cf_loc[5];
82
83 if ((*cf->cf_driver->cd_match)(parent, dev, &ia) > 0)
84 config_attach(parent, dev, &ia, isaprint);
85 else
86 free(dev, M_DEVBUF);
87 }
88
89 char *
90 isa_intr_typename(type)
91 int type;
92 {
93
94 switch (type) {
95 case IST_NONE :
96 return ("none");
97 case IST_PULSE:
98 return ("pulsed");
99 case IST_EDGE:
100 return ("edge-triggered");
101 case IST_LEVEL:
102 return ("level-triggered");
103 default:
104 panic("isa_intr_typename: invalid type %d", type);
105 }
106 }
107