This source file includes following definitions.
- eisamatch
- eisaprint
- eisasubmatch
- eisaattach
- eisa_devinfo
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 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/device.h>
45
46 #include <machine/bus.h>
47
48 #include <dev/eisa/eisareg.h>
49 #include <dev/eisa/eisavar.h>
50 #include <dev/eisa/eisadevs.h>
51
52 int eisamatch(struct device *, void *, void *);
53 void eisaattach(struct device *, struct device *, void *);
54
55 struct cfattach eisa_ca = {
56 sizeof(struct device), eisamatch, eisaattach
57 };
58
59 struct cfdriver eisa_cd = {
60 NULL, "eisa", DV_DULL
61 };
62
63 int eisasubmatch(struct device *, void *, void *);
64 int eisaprint(void *, const char *);
65 void eisa_devinfo(const char *, char *, size_t);
66
67 int
68 eisamatch(parent, match, aux)
69 struct device *parent;
70 void *match, *aux;
71 {
72 struct cfdata *cf = match;
73 struct eisabus_attach_args *eba = aux;
74
75 if (strcmp(eba->eba_busname, cf->cf_driver->cd_name))
76 return (0);
77
78
79
80 return (1);
81 }
82
83 int
84 eisaprint(aux, pnp)
85 void *aux;
86 const char *pnp;
87 {
88 register struct eisa_attach_args *ea = aux;
89 char devinfo[256];
90
91 if (pnp) {
92 eisa_devinfo(ea->ea_idstring, devinfo, sizeof devinfo);
93 printf("%s at %s", devinfo, pnp);
94 }
95 printf(" slot %d", ea->ea_slot);
96 return (UNCONF);
97 }
98
99 int
100 eisasubmatch(parent, match, aux)
101 struct device *parent;
102 void *match, *aux;
103 {
104 struct cfdata *cf = match;
105 struct eisa_attach_args *ea = aux;
106
107 if (cf->eisacf_slot != EISA_UNKNOWN_SLOT &&
108 cf->eisacf_slot != ea->ea_slot)
109 return 0;
110 return ((*cf->cf_attach->ca_match)(parent, match, aux));
111 }
112
113 void
114 eisaattach(parent, self, aux)
115 struct device *parent, *self;
116 void *aux;
117 {
118 struct eisabus_attach_args *eba = aux;
119 bus_space_tag_t iot, memt;
120 eisa_chipset_tag_t ec;
121 int slot, maxnslots;
122
123 eisa_attach_hook(parent, self, eba);
124 printf("\n");
125
126 iot = eba->eba_iot;
127 memt = eba->eba_memt;
128 ec = eba->eba_ec;
129
130
131
132
133
134
135
136 maxnslots = eisa_maxslots(ec);
137 for (slot = 1; slot < maxnslots; slot++) {
138 struct eisa_attach_args ea;
139 u_int slotaddr;
140 bus_space_handle_t slotioh;
141 int i;
142
143 ea.ea_dmat = eba->eba_dmat;
144 ea.ea_iot = iot;
145 ea.ea_memt = memt;
146 ea.ea_ec = ec;
147 ea.ea_slot = slot;
148 slotaddr = EISA_SLOT_ADDR(slot);
149
150
151
152
153
154
155 if (bus_space_map(iot, slotaddr, EISA_SLOT_SIZE, 0, &slotioh)) {
156 printf("%s: can't map I/O space for slot %d\n",
157 self->dv_xname, slot);
158 continue;
159 }
160
161
162 for (i = 0; i < EISA_NVIDREGS; i++) {
163 #ifdef EISA_SLOTOFF_PRIMING
164 bus_space_write_1(iot, slotioh,
165 EISA_SLOTOFF_PRIMING, EISA_PRIMING_VID(i));
166 #endif
167 ea.ea_vid[i] = bus_space_read_1(iot, slotioh,
168 EISA_SLOTOFF_VID + i);
169 }
170
171
172 if (EISA_VENDID_NODEV(ea.ea_vid)) {
173 #if 0
174 printf("no device at %s slot %d\n", self->dv_xname,
175 slot);
176 printf("\t(0x%x, 0x%x)\n", ea.ea_vid[0],
177 ea.ea_vid[1]);
178 #endif
179 bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
180 continue;
181 }
182
183
184 if (EISA_VENDID_IDDELAY(ea.ea_vid)) {
185 printf("%s slot %d not configured by BIOS?\n",
186 self->dv_xname, slot);
187 bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
188 continue;
189 }
190
191
192 for (i = 0; i < EISA_NPIDREGS; i++) {
193 #ifdef EISA_SLOTOFF_PRIMING
194 bus_space_write_1(iot, slotioh,
195 EISA_SLOTOFF_PRIMING, EISA_PRIMING_PID(i));
196 #endif
197 ea.ea_pid[i] = bus_space_read_1(iot, slotioh,
198 EISA_SLOTOFF_PID + i);
199 }
200
201
202 ea.ea_idstring[0] = EISA_VENDID_0(ea.ea_vid);
203 ea.ea_idstring[1] = EISA_VENDID_1(ea.ea_vid);
204 ea.ea_idstring[2] = EISA_VENDID_2(ea.ea_vid);
205 ea.ea_idstring[3] = EISA_PRODID_0(ea.ea_pid);
206 ea.ea_idstring[4] = EISA_PRODID_1(ea.ea_pid);
207 ea.ea_idstring[5] = EISA_PRODID_2(ea.ea_pid);
208 ea.ea_idstring[6] = EISA_PRODID_3(ea.ea_pid);
209 ea.ea_idstring[7] = '\0';
210
211
212 bus_space_unmap(iot, slotioh, EISA_SLOT_SIZE);
213
214
215 config_found_sm(self, &ea, eisaprint, eisasubmatch);
216 }
217 }
218
219 #ifdef EISAVERBOSE
220
221
222
223 struct eisa_knowndev {
224 int flags;
225 char id[8];
226 const char *name;
227 };
228 #define EISA_KNOWNDEV_NOPROD 0x01
229
230 #include <dev/eisa/eisadevs_data.h>
231 #endif
232
233 void
234 eisa_devinfo(const char *id, char *cp, size_t cp_len)
235 {
236 const char *name;
237 int onlyvendor;
238 #ifdef EISAVERBOSE
239 const struct eisa_knowndev *edp;
240 int match;
241 const char *unmatched = "unknown ";
242 #else
243 const char *unmatched = "";
244 #endif
245
246 onlyvendor = 0;
247 name = NULL;
248
249 #ifdef EISAVERBOSE
250
251 edp = eisa_knowndevs;
252 while (edp->name != NULL) {
253
254 if ((edp->flags & EISA_KNOWNDEV_NOPROD) != 0)
255 match = !strncmp(edp->id, id, 3);
256 else
257 match = !strcmp(edp->id, id);
258 if (match) {
259 name = edp->name;
260 onlyvendor = (edp->flags & EISA_KNOWNDEV_NOPROD) != 0;
261 break;
262 }
263 edp++;
264 }
265 #endif
266
267 if (name == NULL)
268 snprintf(cp, cp_len, "%sdevice %s", unmatched, id);
269 else if (onlyvendor)
270 snprintf(cp, cp_len, "unknown %s device %s", name, id);
271 else
272 snprintf(cp, cp_len, "%s", name);
273 }