isapnpres.c revision 1.4 1 1.4 christos /* $NetBSD: isapnpres.c,v 1.4 1997/01/24 21:58:36 christos Exp $ */
2 1.1 christos
3 1.1 christos /*
4 1.1 christos * Copyright (c) 1996 Christos Zoulas. All rights reserved.
5 1.1 christos *
6 1.1 christos * Redistribution and use in source and binary forms, with or without
7 1.1 christos * modification, are permitted provided that the following conditions
8 1.1 christos * are met:
9 1.1 christos * 1. Redistributions of source code must retain the above copyright
10 1.1 christos * notice, this list of conditions and the following disclaimer.
11 1.1 christos * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 christos * notice, this list of conditions and the following disclaimer in the
13 1.1 christos * documentation and/or other materials provided with the distribution.
14 1.1 christos * 3. All advertising materials mentioning features or use of this software
15 1.1 christos * must display the following acknowledgement:
16 1.1 christos * This product includes software developed by Christos Zoulas.
17 1.1 christos * 4. The name of the author may not be used to endorse or promote products
18 1.1 christos * derived from this software without specific prior written permission.
19 1.1 christos *
20 1.1 christos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 christos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 christos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 christos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 christos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 christos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 christos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 christos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 christos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 christos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 christos */
31 1.1 christos
32 1.1 christos /*
33 1.1 christos * Resource parser for Plug and Play cards.
34 1.1 christos */
35 1.1 christos
36 1.1 christos #include <sys/param.h>
37 1.1 christos #include <sys/systm.h>
38 1.1 christos #include <sys/device.h>
39 1.1 christos #include <sys/malloc.h>
40 1.1 christos
41 1.1 christos #include <machine/bus.h>
42 1.1 christos
43 1.1 christos #include <dev/isa/isavar.h>
44 1.1 christos
45 1.1 christos #include <dev/isapnp/isapnpreg.h>
46 1.1 christos #include <dev/isapnp/isapnpvar.h>
47 1.1 christos
48 1.1 christos
49 1.1 christos static int isapnp_wait_status __P((struct isapnp_softc *));
50 1.4 christos static struct isapnp_attach_args *
51 1.4 christos isapnp_newdev __P((struct isapnp_attach_args *));
52 1.4 christos static struct isapnp_attach_args *
53 1.4 christos isapnp_newconf __P((struct isapnp_attach_args *));
54 1.4 christos static void isapnp_merge __P((struct isapnp_attach_args *,
55 1.4 christos struct isapnp_attach_args *));
56 1.4 christos static struct isapnp_attach_args *
57 1.4 christos isapnp_flatten __P((struct isapnp_attach_args *));
58 1.4 christos static int isapnp_process_tag __P((u_char, u_char, u_char *,
59 1.4 christos struct isapnp_attach_args **, struct isapnp_attach_args **,
60 1.4 christos struct isapnp_attach_args **));
61 1.1 christos
62 1.1 christos
63 1.1 christos /* isapnp_wait_status():
64 1.1 christos * Wait for the next byte of resource data to become available
65 1.1 christos */
66 1.1 christos static int
67 1.1 christos isapnp_wait_status(sc)
68 1.1 christos struct isapnp_softc *sc;
69 1.1 christos {
70 1.1 christos int i;
71 1.1 christos
72 1.1 christos for (i = 0; i < 10; i++) {
73 1.1 christos if (isapnp_read_reg(sc, ISAPNP_STATUS) & 1)
74 1.1 christos return 0;
75 1.3 veego DELAY(40);
76 1.1 christos }
77 1.1 christos return 1;
78 1.1 christos }
79 1.1 christos
80 1.4 christos
81 1.4 christos /* isapnp_newdev():
82 1.4 christos * Add a new logical device to the current card; expand the configuration
83 1.4 christos * resources of the current card if needed.
84 1.4 christos */
85 1.4 christos static struct isapnp_attach_args *
86 1.4 christos isapnp_newdev(card)
87 1.4 christos struct isapnp_attach_args *card;
88 1.4 christos {
89 1.4 christos struct isapnp_attach_args *ipa, *dev = ISAPNP_MALLOC(sizeof(*dev));
90 1.4 christos
91 1.4 christos memset(dev, 0, sizeof(*dev));
92 1.4 christos
93 1.4 christos dev->ipa_pref = ISAPNP_DEP_ACCEPTABLE;
94 1.4 christos memcpy(dev->ipa_devident, card->ipa_devident,
95 1.4 christos sizeof(card->ipa_devident));
96 1.4 christos
97 1.4 christos if (card->ipa_child == NULL)
98 1.4 christos card->ipa_child = dev;
99 1.4 christos else {
100 1.4 christos for (ipa = card->ipa_child; ipa->ipa_sibling != NULL;
101 1.4 christos ipa = ipa->ipa_sibling)
102 1.4 christos continue;
103 1.4 christos ipa->ipa_sibling = dev;
104 1.4 christos }
105 1.4 christos
106 1.4 christos
107 1.4 christos return dev;
108 1.4 christos }
109 1.4 christos
110 1.4 christos
111 1.4 christos /* isapnp_newconf():
112 1.4 christos * Add a new alternate configuration to a logical device
113 1.4 christos */
114 1.4 christos static struct isapnp_attach_args *
115 1.4 christos isapnp_newconf(dev)
116 1.4 christos struct isapnp_attach_args *dev;
117 1.4 christos {
118 1.4 christos struct isapnp_attach_args *ipa, *conf = ISAPNP_MALLOC(sizeof(*conf));
119 1.4 christos
120 1.4 christos memset(conf, 0, sizeof(*conf));
121 1.4 christos
122 1.4 christos memcpy(conf->ipa_devident, dev->ipa_devident,
123 1.4 christos sizeof(conf->ipa_devident));
124 1.4 christos memcpy(conf->ipa_devlogic, dev->ipa_devlogic,
125 1.4 christos sizeof(conf->ipa_devlogic));
126 1.4 christos memcpy(conf->ipa_devclass, dev->ipa_devclass,
127 1.4 christos sizeof(conf->ipa_devclass));
128 1.4 christos
129 1.4 christos if (dev->ipa_child == NULL)
130 1.4 christos dev->ipa_child = conf;
131 1.4 christos else {
132 1.4 christos for (ipa = dev->ipa_child; ipa->ipa_sibling;
133 1.4 christos ipa = ipa->ipa_sibling)
134 1.4 christos continue;
135 1.4 christos ipa->ipa_sibling = conf;
136 1.4 christos }
137 1.4 christos
138 1.4 christos return conf;
139 1.4 christos }
140 1.4 christos
141 1.4 christos
142 1.4 christos /* isapnp_merge():
143 1.4 christos * Merge the common device configurations to the subconfigurations
144 1.4 christos */
145 1.4 christos static void
146 1.4 christos isapnp_merge(d, c)
147 1.4 christos struct isapnp_attach_args *d, *c;
148 1.4 christos {
149 1.4 christos int i;
150 1.4 christos
151 1.4 christos for (i = 0; i < d->ipa_nio; i++)
152 1.4 christos c->ipa_io[c->ipa_nio++] = d->ipa_io[i];
153 1.4 christos
154 1.4 christos for (i = 0; i < d->ipa_nmem; i++)
155 1.4 christos c->ipa_mem[c->ipa_nmem++] = d->ipa_mem[i];
156 1.4 christos
157 1.4 christos for (i = 0; i < d->ipa_nmem32; i++)
158 1.4 christos c->ipa_mem32[c->ipa_nmem32++] = d->ipa_mem32[i];
159 1.4 christos
160 1.4 christos for (i = 0; i < d->ipa_nirq; i++)
161 1.4 christos c->ipa_irq[c->ipa_nirq++] = d->ipa_irq[i];
162 1.4 christos
163 1.4 christos for (i = 0; i < d->ipa_ndrq; i++)
164 1.4 christos c->ipa_drq[c->ipa_ndrq++] = d->ipa_drq[i];
165 1.4 christos }
166 1.4 christos
167 1.4 christos
168 1.4 christos /* isapnp_flatten():
169 1.4 christos * Flatten the tree to a list of config entries.
170 1.4 christos */
171 1.4 christos static struct isapnp_attach_args *
172 1.4 christos isapnp_flatten(card)
173 1.4 christos struct isapnp_attach_args *card;
174 1.4 christos {
175 1.4 christos struct isapnp_attach_args *dev, *conf, *d, *c, *pa;
176 1.4 christos
177 1.4 christos dev = card->ipa_child;
178 1.4 christos ISAPNP_FREE(card);
179 1.4 christos
180 1.4 christos for (conf = c = NULL, d = dev; d; d = dev) {
181 1.4 christos dev = d->ipa_sibling;
182 1.4 christos if (d->ipa_child == NULL) {
183 1.4 christos /*
184 1.4 christos * No subconfigurations; all configuration info
185 1.4 christos * is in the device node.
186 1.4 christos */
187 1.4 christos d->ipa_sibling = NULL;
188 1.4 christos pa = d;
189 1.4 christos }
190 1.4 christos else {
191 1.4 christos /*
192 1.4 christos * Push down device configuration info to the
193 1.4 christos * subconfigurations
194 1.4 christos */
195 1.4 christos for (pa = d->ipa_child; pa; pa = pa->ipa_sibling)
196 1.4 christos isapnp_merge(d, pa);
197 1.4 christos
198 1.4 christos pa = d->ipa_child;
199 1.4 christos ISAPNP_FREE(d);
200 1.4 christos }
201 1.4 christos
202 1.4 christos if (c == NULL)
203 1.4 christos c = conf = pa;
204 1.4 christos else
205 1.4 christos c->ipa_sibling = pa;
206 1.4 christos
207 1.4 christos while (c->ipa_sibling)
208 1.4 christos c = c->ipa_sibling;
209 1.4 christos }
210 1.4 christos return conf;
211 1.4 christos }
212 1.4 christos
213 1.4 christos
214 1.1 christos /* isapnp_process_tag():
215 1.1 christos * Process a resource tag
216 1.1 christos */
217 1.4 christos static int
218 1.4 christos isapnp_process_tag(tag, len, buf, card, dev, conf)
219 1.1 christos u_char tag, len, *buf;
220 1.4 christos struct isapnp_attach_args **card, **dev, **conf;
221 1.1 christos {
222 1.1 christos char str[64];
223 1.1 christos struct isapnp_region *r;
224 1.1 christos struct isapnp_pin *p;
225 1.4 christos struct isapnp_attach_args *pa;
226 1.1 christos
227 1.1 christos #define COPY(a, b) strncpy((a), (b), sizeof(a)), (a)[sizeof(a) - 1] = '\0'
228 1.1 christos
229 1.1 christos switch (tag) {
230 1.1 christos case ISAPNP_TAG_VERSION_NUM:
231 1.1 christos DPRINTF(("PnP version %d.%d, Vendor version %d.%d\n",
232 1.1 christos buf[0] >> 4, buf[0] & 0xf, buf[1] >> 4, buf[1] & 0xf));
233 1.4 christos return 0;
234 1.1 christos
235 1.1 christos case ISAPNP_TAG_LOGICAL_DEV_ID:
236 1.1 christos (void) isapnp_id_to_vendor(str, buf);
237 1.1 christos DPRINTF(("Logical device id %s\n", str));
238 1.4 christos
239 1.4 christos *dev = isapnp_newdev(*card);
240 1.4 christos COPY((*dev)->ipa_devlogic, str);
241 1.4 christos return 0;
242 1.1 christos
243 1.1 christos case ISAPNP_TAG_COMPAT_DEV_ID:
244 1.1 christos (void) isapnp_id_to_vendor(str, buf);
245 1.1 christos DPRINTF(("Compatible device id %s\n", str));
246 1.4 christos return 0;
247 1.4 christos
248 1.4 christos case ISAPNP_TAG_DEP_START:
249 1.4 christos if (len == 0)
250 1.4 christos buf[0] = ISAPNP_DEP_ACCEPTABLE;
251 1.4 christos
252 1.4 christos if (*dev == NULL)
253 1.4 christos return -1;
254 1.4 christos
255 1.4 christos *conf = isapnp_newconf(*dev);
256 1.4 christos (*conf)->ipa_pref = buf[0];
257 1.4 christos #ifdef DEBUG_ISAPNP
258 1.4 christos isapnp_print_dep_start(">>> Start dependent functions ",
259 1.4 christos (*conf)->ipa_pref);
260 1.4 christos #endif
261 1.4 christos return 0;
262 1.4 christos
263 1.4 christos case ISAPNP_TAG_DEP_END:
264 1.4 christos DPRINTF(("<<<End dependend functions\n"));
265 1.4 christos *conf = NULL;
266 1.4 christos return 0;
267 1.4 christos
268 1.4 christos case ISAPNP_TAG_ANSI_IDENT_STRING:
269 1.4 christos buf[len] = '\0';
270 1.4 christos DPRINTF(("ANSI Ident: %s\n", buf));
271 1.4 christos if (*dev == NULL)
272 1.4 christos COPY((*card)->ipa_devident, buf);
273 1.4 christos else
274 1.4 christos COPY((*dev)->ipa_devclass, buf);
275 1.4 christos return 0;
276 1.4 christos
277 1.4 christos case ISAPNP_TAG_END:
278 1.4 christos *dev = NULL;
279 1.4 christos return 0;
280 1.4 christos
281 1.4 christos default:
282 1.4 christos /* Handled below */
283 1.1 christos break;
284 1.4 christos }
285 1.4 christos
286 1.4 christos
287 1.4 christos /*
288 1.4 christos * Decide which configuration we add the tag to
289 1.4 christos */
290 1.4 christos if (*conf)
291 1.4 christos pa = *conf;
292 1.4 christos else if (*dev)
293 1.4 christos pa = *dev;
294 1.4 christos else
295 1.4 christos /* error */
296 1.4 christos return -1;
297 1.4 christos
298 1.4 christos switch (tag) {
299 1.1 christos case ISAPNP_TAG_IRQ_FORMAT:
300 1.1 christos if (len < 2)
301 1.1 christos break;
302 1.1 christos
303 1.1 christos if (len != 3)
304 1.1 christos buf[2] = ISAPNP_IRQTYPE_EDGE_PLUS;
305 1.1 christos
306 1.1 christos p = &pa->ipa_irq[pa->ipa_nirq++];
307 1.1 christos p->bits = buf[0] | (buf[1] << 8);
308 1.1 christos p->flags = buf[2];
309 1.1 christos #ifdef DEBUG_ISAPNP
310 1.1 christos isapnp_print_irq("", p);
311 1.1 christos #endif
312 1.1 christos break;
313 1.1 christos
314 1.1 christos case ISAPNP_TAG_DMA_FORMAT:
315 1.1 christos if (buf[0] == 0)
316 1.1 christos break;
317 1.1 christos
318 1.1 christos p = &pa->ipa_drq[pa->ipa_ndrq++];
319 1.1 christos p->bits = buf[0];
320 1.1 christos p->flags = buf[1];
321 1.1 christos #ifdef DEBUG_ISAPNP
322 1.1 christos isapnp_print_drq("", p);
323 1.1 christos #endif
324 1.1 christos break;
325 1.1 christos
326 1.1 christos
327 1.1 christos case ISAPNP_TAG_IO_PORT_DESC:
328 1.1 christos r = &pa->ipa_io[pa->ipa_nio++];
329 1.1 christos r->flags = buf[0];
330 1.1 christos r->minbase = (buf[2] << 8) | buf[1];
331 1.1 christos r->maxbase = (buf[4] << 8) | buf[3];
332 1.1 christos r->align = buf[5];
333 1.1 christos r->length = buf[6];
334 1.1 christos
335 1.1 christos #ifdef DEBUG_ISAPNP
336 1.1 christos isapnp_print_io("", r);
337 1.1 christos #endif
338 1.1 christos break;
339 1.1 christos
340 1.1 christos case ISAPNP_TAG_FIXED_IO_PORT_DESC:
341 1.1 christos r = &pa->ipa_io[pa->ipa_nio++];
342 1.1 christos r->flags = 0;
343 1.1 christos r->minbase = (buf[2] << 8) | buf[1];
344 1.1 christos r->maxbase = r->minbase;
345 1.1 christos r->align = 1;
346 1.1 christos r->length = buf[3];
347 1.1 christos
348 1.1 christos #ifdef DEBUG_ISAPNP
349 1.1 christos isapnp_print_io("FIXED", r);
350 1.1 christos #endif
351 1.1 christos break;
352 1.1 christos
353 1.1 christos case ISAPNP_TAG_RESERVED1:
354 1.1 christos case ISAPNP_TAG_RESERVED2:
355 1.1 christos case ISAPNP_TAG_RESERVED3:
356 1.1 christos case ISAPNP_TAG_RESERVED4:
357 1.1 christos break;
358 1.1 christos
359 1.1 christos case ISAPNP_TAG_VENDOR_DEF:
360 1.1 christos break;
361 1.1 christos
362 1.1 christos case ISAPNP_TAG_MEM_RANGE_DESC:
363 1.1 christos r = &pa->ipa_mem[pa->ipa_nmem++];
364 1.1 christos r->minbase = (buf[2] << 8) | buf[1];
365 1.1 christos r->maxbase = (buf[4] << 8) | buf[3];
366 1.1 christos r->align = (buf[6] << 8) | buf[5];
367 1.1 christos r->length = (buf[8] << 8) | buf[7];
368 1.1 christos #ifdef DEBUG_ISAPNP
369 1.1 christos isapnp_print_mem("16 bit", r);
370 1.1 christos #endif
371 1.1 christos break;
372 1.1 christos
373 1.1 christos
374 1.1 christos case ISAPNP_TAG_UNICODE_IDENT_STRING:
375 1.1 christos buf[len] = '\0';
376 1.1 christos DPRINTF(("Unicode Ident: %s\n", buf));
377 1.1 christos break;
378 1.1 christos
379 1.1 christos case ISAPNP_TAG_VENDOR_DEFINED:
380 1.1 christos break;
381 1.1 christos
382 1.1 christos case ISAPNP_TAG_MEM32_RANGE_DESC:
383 1.1 christos r = &pa->ipa_mem32[pa->ipa_nmem32++];
384 1.1 christos r->flags = buf[0];
385 1.1 christos r->minbase = (buf[4] << 24) | (buf[3] << 16) |
386 1.1 christos (buf[2] << 8) | buf[1];
387 1.1 christos r->maxbase = (buf[8] << 24) | (buf[7] << 16) |
388 1.1 christos (buf[6] << 8) | buf[5];
389 1.1 christos r->align = (buf[12] << 24) | (buf[11] << 16) |
390 1.1 christos (buf[10] << 8) | buf[9];
391 1.1 christos r->length = (buf[16] << 24) | (buf[15] << 16) |
392 1.1 christos (buf[14] << 8) | buf[13];
393 1.1 christos #ifdef DEBUG_ISAPNP
394 1.1 christos isapnp_print_mem("32 bit", r);
395 1.1 christos #endif
396 1.1 christos break;
397 1.1 christos
398 1.1 christos case ISAPNP_TAG_FIXED_MEM32_RANGE_DESC:
399 1.1 christos r = &pa->ipa_mem32[pa->ipa_nmem32++];
400 1.1 christos r->flags = buf[0];
401 1.1 christos r->minbase = (buf[4] << 24) | (buf[3] << 16) |
402 1.1 christos (buf[2] << 8) | buf[1];
403 1.1 christos r->maxbase = r->minbase;
404 1.1 christos r->align = 1;
405 1.1 christos r->length = (buf[8] << 24) | (buf[7] << 16) |
406 1.1 christos (buf[6] << 8) | buf[5];
407 1.1 christos #ifdef DEBUG_ISAPNP
408 1.1 christos isapnp_print_mem("FIXED 32 bit", r);
409 1.1 christos #endif
410 1.1 christos break;
411 1.1 christos
412 1.1 christos default:
413 1.1 christos #ifdef DEBUG_ISAPNP
414 1.1 christos {
415 1.1 christos int i;
416 1.1 christos printf("tag %.2x, len %d: ", tag, len);
417 1.1 christos for (i = 0; i < len; i++)
418 1.1 christos printf("%.2x ", buf[i]);
419 1.1 christos printf("\n");
420 1.1 christos }
421 1.1 christos #endif
422 1.1 christos break;
423 1.1 christos }
424 1.4 christos return 0;
425 1.1 christos }
426 1.1 christos
427 1.1 christos
428 1.1 christos /* isapnp_get_resource():
429 1.1 christos * Read the resources for card c
430 1.1 christos */
431 1.1 christos struct isapnp_attach_args *
432 1.1 christos isapnp_get_resource(sc, c)
433 1.1 christos struct isapnp_softc *sc;
434 1.1 christos int c;
435 1.1 christos {
436 1.1 christos u_char d, tag;
437 1.1 christos u_short len;
438 1.1 christos int i;
439 1.4 christos int warned = 0;
440 1.4 christos struct isapnp_attach_args *card, *dev = NULL, *conf = NULL;
441 1.4 christos u_char buf[ISAPNP_MAX_TAGSIZE], *p;
442 1.1 christos
443 1.4 christos memset(buf, 0, sizeof(buf));
444 1.4 christos
445 1.4 christos card = ISAPNP_MALLOC(sizeof(*card));
446 1.4 christos memset(card, 0, sizeof(*card));
447 1.4 christos
448 1.4 christos #define NEXT_BYTE \
449 1.4 christos if (isapnp_wait_status(sc)) \
450 1.4 christos goto bad; \
451 1.4 christos d = isapnp_read_reg(sc, ISAPNP_RESOURCE_DATA)
452 1.1 christos
453 1.1 christos for (i = 0; i < ISAPNP_SERIAL_SIZE; i++) {
454 1.4 christos NEXT_BYTE;
455 1.1 christos
456 1.1 christos if (d != sc->sc_id[c][i] && i != ISAPNP_SERIAL_SIZE - 1) {
457 1.4 christos if (!warned) {
458 1.4 christos printf("%s: card %d violates PnP spec; byte %d\n",
459 1.4 christos sc->sc_dev.dv_xname, c + 1, i);
460 1.4 christos warned++;
461 1.4 christos }
462 1.4 christos if (i == 0) {
463 1.4 christos /*
464 1.4 christos * Magic! If this is the first byte, we
465 1.4 christos * assume that the tag data begins here.
466 1.4 christos */
467 1.4 christos goto parse;
468 1.4 christos }
469 1.1 christos }
470 1.1 christos }
471 1.1 christos
472 1.1 christos do {
473 1.1 christos NEXT_BYTE;
474 1.4 christos parse:
475 1.1 christos
476 1.1 christos if (d & ISAPNP_LARGE_TAG) {
477 1.1 christos tag = d;
478 1.1 christos NEXT_BYTE;
479 1.1 christos buf[0] = d;
480 1.1 christos NEXT_BYTE;
481 1.1 christos buf[1] = d;
482 1.1 christos len = (buf[1] << 8) | buf[0];
483 1.1 christos }
484 1.1 christos else {
485 1.1 christos tag = (d >> 3) & 0xf;
486 1.1 christos len = d & 0x7;
487 1.1 christos }
488 1.1 christos
489 1.1 christos for (p = buf, i = 0; i < len; i++) {
490 1.1 christos NEXT_BYTE;
491 1.1 christos if (i < ISAPNP_MAX_TAGSIZE)
492 1.1 christos *p++ = d;
493 1.1 christos }
494 1.1 christos
495 1.1 christos if (len >= ISAPNP_MAX_TAGSIZE) {
496 1.4 christos printf("%s: Maximum tag size exceeded, card %d\n",
497 1.4 christos sc->sc_dev.dv_xname, c + 1);
498 1.1 christos len = ISAPNP_MAX_TAGSIZE;
499 1.4 christos if (++warned == 10)
500 1.4 christos goto bad;
501 1.1 christos }
502 1.1 christos
503 1.4 christos if (isapnp_process_tag(tag, len, buf, &card, &dev, &conf) == -1)
504 1.4 christos printf("%s: No current device for tag, card %d\n",
505 1.4 christos sc->sc_dev.dv_xname, c + 1);
506 1.1 christos }
507 1.1 christos while (tag != ISAPNP_TAG_END);
508 1.4 christos return isapnp_flatten(card);
509 1.4 christos
510 1.1 christos bad:
511 1.4 christos for (card = isapnp_flatten(card); card; ) {
512 1.4 christos dev = card->ipa_sibling;
513 1.4 christos ISAPNP_FREE(card);
514 1.4 christos card = dev;
515 1.1 christos }
516 1.4 christos printf("%s: %s, card %d\n", sc->sc_dev.dv_xname,
517 1.4 christos warned >= 10 ? "Too many tag errors" : "Resource timeout", c + 1);
518 1.1 christos return NULL;
519 1.1 christos }
520