1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
/* $OpenBSD: eisa.c,v 1.7 2000/04/14 03:29:01 smurph Exp $ */
/* $NetBSD: eisa.c,v 1.15 1996/10/21 22:31:01 thorpej Exp $ */
/*
* Copyright (c) 1995, 1996 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Christopher G. Demetriou
* for the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* EISA Bus device
*
* Makes sure an EISA bus is present, and finds and attaches devices
* living on it.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/bus.h>
#include <dev/eisa/eisareg.h>
#include <dev/eisa/eisavar.h>
#include <dev/eisa/eisadevs.h>
int eisamatch __P((struct device *, void *, void *));
void eisaattach __P((struct device *, struct device *, void *));
struct cfattach eisa_ca = {
sizeof(struct device), eisamatch, eisaattach
};
struct cfdriver eisa_cd = {
NULL, "eisa", DV_DULL
};
int eisasubmatch __P((struct device *, void *, void *));
int eisaprint __P((void *, const char *));
void eisa_devinfo __P((const char *, char *));
int
eisamatch(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct cfdata *cf = match;
struct eisabus_attach_args *eba = aux;
if (strcmp(eba->eba_busname, cf->cf_driver->cd_name))
return (0);
/* XXX check other indicators */
return (1);
}
int
eisaprint(aux, pnp)
void *aux;
const char *pnp;
{
register struct eisa_attach_args *ea = aux;
char devinfo[256];
if (pnp) {
eisa_devinfo(ea->ea_idstring, devinfo);
printf("%s at %s", devinfo, pnp);
}
printf(" slot %d", ea->ea_slot);
return (UNCONF);
}
int
eisasubmatch(parent, match, aux)
struct device *parent;
void *match, *aux;
{
struct cfdata *cf = match;
struct eisa_attach_args *ea = aux;
if (cf->eisacf_slot != EISA_UNKNOWN_SLOT &&
cf->eisacf_slot != ea->ea_slot)
return 0;
return ((*cf->cf_attach->ca_match)(parent, match, aux));
}
void
eisaattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct eisabus_attach_args *eba = aux;
bus_space_tag_t iot, memt;
eisa_chipset_tag_t ec;
int slot, maxnslots;
eisa_attach_hook(parent, self, eba);
printf("\n");
iot = eba->eba_iot;
memt = eba->eba_memt;
ec = eba->eba_ec;
/*
* Search for and attach subdevices.
*
* Slot 0 is the "motherboard" slot, and the code attaching
* the EISA bus should have already attached an ISA bus there.
*/
maxnslots = eisa_maxslots(ec);
for (slot = 1; slot < maxnslots; slot++) {
struct eisa_attach_args ea;
u_int slotaddr;
bus_space_handle_t slotioh;
int i;
ea.ea_dmat = eba->eba_dmat;
ea.ea_iot = iot;
ea.ea_memt = memt;
ea.ea_ec = ec;
ea.ea_slot = slot;
slotaddr = EISA_SLOT_ADDR(slot);
/*
* Get a mapping for the whole slot-specific address
* space. If we can't, assume nothing's there but warn
* about it.
*/
if (bus_space_map(iot, slotaddr, EISA_SLOT_SIZE, 0, &slotioh)) {
printf("%s: can't map I/O space for slot %d\n",
self->dv_xname, slot);
continue;
}
/* Get the vendor ID bytes */
for (i = 0; i < EISA_NVIDREGS; i++) {
#ifdef EISA_SLOTOFF_PRIMING
bus_space_write_1(iot, slotioh,
EISA_SLOTOFF_PRIMING, EISA_PRIMING_VID(i));
#endif
ea.ea_vid[i] = bus_space_read_1(iot, slotioh,
EISA_SLOTOFF_VID + i);
}
/* Check for device existence */
if (EISA_VENDID_NODEV(ea.ea_vid)) {
#if 0
printf("no device at %s slot %d\n", self->dv_xname,
slot);
printf("\t(0x%x, 0x%x)\n", ea.ea_vid[0],
ea.ea_vid[1]);
#endif
bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
continue;
}
/* And check that the firmware didn't biff something badly */
if (EISA_VENDID_IDDELAY(ea.ea_vid)) {
printf("%s slot %d not configured by BIOS?\n",
self->dv_xname, slot);
bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
continue;
}
/* Get the product ID bytes */
for (i = 0; i < EISA_NPIDREGS; i++) {
#ifdef EISA_SLOTOFF_PRIMING
bus_space_write_1(iot, slotioh,
EISA_SLOTOFF_PRIMING, EISA_PRIMING_PID(i));
#endif
ea.ea_pid[i] = bus_space_read_1(iot, slotioh,
EISA_SLOTOFF_PID + i);
}
/* Create the ID string from the vendor and product IDs */
ea.ea_idstring[0] = EISA_VENDID_0(ea.ea_vid);
ea.ea_idstring[1] = EISA_VENDID_1(ea.ea_vid);
ea.ea_idstring[2] = EISA_VENDID_2(ea.ea_vid);
ea.ea_idstring[3] = EISA_PRODID_0(ea.ea_pid);
ea.ea_idstring[4] = EISA_PRODID_1(ea.ea_pid);
ea.ea_idstring[5] = EISA_PRODID_2(ea.ea_pid);
ea.ea_idstring[6] = EISA_PRODID_3(ea.ea_pid);
ea.ea_idstring[7] = '\0'; /* sanity */
/* We no longer need the I/O handle; free it. */
bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
/* Attach matching device. */
config_found_sm(self, &ea, eisaprint, eisasubmatch);
}
}
#ifdef EISAVERBOSE
/*
* Descriptions of of known vendors and devices ("products").
*/
struct eisa_knowndev {
int flags;
const char *id, *name;
};
#define EISA_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
#include <dev/eisa/eisadevs_data.h>
#endif /* EISAVERBOSE */
void
eisa_devinfo(id, cp)
const char *id;
char *cp;
{
const char *name;
int onlyvendor;
#ifdef EISAVERBOSE
struct eisa_knowndev *edp;
int match;
const char *unmatched = "unknown ";
#else
const char *unmatched = "";
#endif
onlyvendor = 0;
name = NULL;
#ifdef EISAVERBOSE
/* find the device in the table, if possible. */
edp = eisa_knowndevs;
while (edp->id != NULL) {
/* check this entry for a match */
if ((edp->flags & EISA_KNOWNDEV_NOPROD) != 0)
match = !strncmp(edp->id, id, 3);
else
match = !strcmp(edp->id, id);
if (match) {
name = edp->name;
onlyvendor = (edp->flags & EISA_KNOWNDEV_NOPROD) != 0;
break;
}
edp++;
}
#endif
if (name == NULL)
cp += sprintf(cp, "%sdevice %s", unmatched, id);
else if (onlyvendor) /* never if not EISAVERBOSE */
cp += sprintf(cp, "unknown %s device %s", name, id);
else
cp += sprintf(cp, "%s", name);
}
|