1 /*- 2 * Copyright (c) 1997 Michael Smith 3 * Copyright (c) 1998 Jonathan Lemon 4 * 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 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 */ 27 28 #include <sys/cdefs.h> 29 __FBSDID("$FreeBSD$"); 30 31 /* 32 * Code for dealing with the BIOS in x86 PC systems. 33 */ 34 35 #include "opt_isa.h" 36 37 #include <sys/param.h> 38 #include <sys/systm.h> 39 #include <sys/kernel.h> 40 #include <sys/malloc.h> 41 #include <sys/module.h> 42 #include <sys/bus.h> 43 #include <sys/pcpu.h> 44 #include <vm/vm.h> 45 #include <vm/pmap.h> 46 #include <machine/md_var.h> 47 #include <machine/segments.h> 48 #include <machine/stdarg.h> 49 #include <machine/vmparam.h> 50 #include <machine/pc/bios.h> 51 #ifdef DEV_ISA 52 #include <isa/isavar.h> 53 #include <isa/pnpreg.h> 54 #include <isa/pnpvar.h> 55 #endif 56 57 #define BIOS_START 0xe0000 58 #define BIOS_SIZE 0x20000 59 60 /* exported lookup results */ 61 struct bios32_SDentry PCIbios; 62 63 static struct PnPBIOS_table *PnPBIOStable; 64 65 static u_int bios32_SDCI; 66 67 /* start fairly early */ 68 static void bios32_init(void *junk); 69 SYSINIT(bios32, SI_SUB_CPU, SI_ORDER_ANY, bios32_init, NULL); 70 71 /* 72 * bios32_init 73 * 74 * Locate various bios32 entities. 75 */ 76 static void 77 bios32_init(void *junk) 78 { 79 u_long sigaddr; 80 struct bios32_SDheader *sdh; 81 struct PnPBIOS_table *pt; 82 u_int8_t ck, *cv; 83 int i; 84 char *p; 85 86 /* 87 * BIOS32 Service Directory, PCI BIOS 88 */ 89 90 /* look for the signature */ 91 if ((sigaddr = bios_sigsearch(0, "_32_", 4, 16, 0)) != 0) { 92 93 /* get a virtual pointer to the structure */ 94 sdh = (struct bios32_SDheader *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr); 95 for (cv = (u_int8_t *)sdh, ck = 0, i = 0; i < (sdh->len * 16); i++) { 96 ck += cv[i]; 97 } 98 /* If checksum is OK, enable use of the entrypoint */ 99 if ((ck == 0) && (BIOS_START <= sdh->entry ) && 100 (sdh->entry < (BIOS_START + BIOS_SIZE))) { 101 bios32_SDCI = BIOS_PADDRTOVADDR(sdh->entry); 102 if (bootverbose) { 103 printf("bios32: Found BIOS32 Service Directory header at %p\n", sdh); 104 printf("bios32: Entry = 0x%x (%x) Rev = %d Len = %d\n", 105 sdh->entry, bios32_SDCI, sdh->revision, sdh->len); 106 } 107 108 /* Allow user override of PCI BIOS search */ 109 if (((p = getenv("machdep.bios.pci")) == NULL) || strcmp(p, "disable")) { 110 111 /* See if there's a PCI BIOS entrypoint here */ 112 PCIbios.ident.id = 0x49435024; /* PCI systems should have this */ 113 if (!bios32_SDlookup(&PCIbios) && bootverbose) 114 printf("pcibios: PCI BIOS entry at 0x%x+0x%x\n", PCIbios.base, PCIbios.entry); 115 } 116 if (p != NULL) 117 freeenv(p); 118 } else { 119 printf("bios32: Bad BIOS32 Service Directory\n"); 120 } 121 } 122 123 /* 124 * PnP BIOS 125 * 126 * Allow user override of PnP BIOS search 127 */ 128 if ((((p = getenv("machdep.bios.pnp")) == NULL) || strcmp(p, "disable")) && 129 ((sigaddr = bios_sigsearch(0, "$PnP", 4, 16, 0)) != 0)) { 130 131 /* get a virtual pointer to the structure */ 132 pt = (struct PnPBIOS_table *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr); 133 for (cv = (u_int8_t *)pt, ck = 0, i = 0; i < pt->len; i++) { 134 ck += cv[i]; 135 } 136 /* If checksum is OK, enable use of the entrypoint */ 137 if (ck == 0) { 138 PnPBIOStable = pt; 139 if (bootverbose) { 140 printf("pnpbios: Found PnP BIOS data at %p\n", pt); 141 printf("pnpbios: Entry = %x:%x Rev = %d.%d\n", 142 pt->pmentrybase, pt->pmentryoffset, pt->version >> 4, pt->version & 0xf); 143 if ((pt->control & 0x3) == 0x01) 144 printf("pnpbios: Event flag at %x\n", pt->evflagaddr); 145 if (pt->oemdevid != 0) 146 printf("pnpbios: OEM ID %x\n", pt->oemdevid); 147 148 } 149 } else { 150 printf("pnpbios: Bad PnP BIOS data checksum\n"); 151 } 152 } 153 if (p != NULL) 154 freeenv(p); 155 if (bootverbose) { 156 /* look for other know signatures */ 157 printf("Other BIOS signatures found:\n"); 158 } 159 } 160 161 /* 162 * bios32_SDlookup 163 * 164 * Query the BIOS32 Service Directory for the service named in (ent), 165 * returns nonzero if the lookup fails. The caller must fill in 166 * (ent->ident), the remainder are populated on a successful lookup. 167 */ 168 int 169 bios32_SDlookup(struct bios32_SDentry *ent) 170 { 171 struct bios_regs args; 172 173 if (bios32_SDCI == 0) 174 return (1); 175 176 args.eax = ent->ident.id; /* set up arguments */ 177 args.ebx = args.ecx = args.edx = 0; 178 bios32(&args, bios32_SDCI, GSEL(GCODE_SEL, SEL_KPL)); 179 if ((args.eax & 0xff) == 0) { /* success? */ 180 ent->base = args.ebx; 181 ent->len = args.ecx; 182 ent->entry = args.edx; 183 ent->ventry = BIOS_PADDRTOVADDR(ent->base + ent->entry); 184 return (0); /* all OK */ 185 } 186 return (1); /* failed */ 187 } 188 189 190 /* 191 * bios_sigsearch 192 * 193 * Search some or all of the BIOS region for a signature string. 194 * 195 * (start) Optional offset returned from this function 196 * (for searching for multiple matches), or NULL 197 * to start the search from the base of the BIOS. 198 * Note that this will be a _physical_ address in 199 * the range 0xe0000 - 0xfffff. 200 * (sig) is a pointer to the byte(s) of the signature. 201 * (siglen) number of bytes in the signature. 202 * (paralen) signature paragraph (alignment) size. 203 * (sigofs) offset of the signature within the paragraph. 204 * 205 * Returns the _physical_ address of the found signature, 0 if the 206 * signature was not found. 207 */ 208 209 u_int32_t 210 bios_sigsearch(u_int32_t start, u_char *sig, int siglen, int paralen, int sigofs) 211 { 212 u_char *sp, *end; 213 214 /* compute the starting address */ 215 if ((start >= BIOS_START) && (start <= (BIOS_START + BIOS_SIZE))) { 216 sp = (char *)BIOS_PADDRTOVADDR(start); 217 } else if (start == 0) { 218 sp = (char *)BIOS_PADDRTOVADDR(BIOS_START); 219 } else { 220 return 0; /* bogus start address */ 221 } 222 223 /* compute the end address */ 224 end = (u_char *)BIOS_PADDRTOVADDR(BIOS_START + BIOS_SIZE); 225 226 /* loop searching */ 227 while ((sp + sigofs + siglen) < end) { 228 229 /* compare here */ 230 if (!bcmp(sp + sigofs, sig, siglen)) { 231 /* convert back to physical address */ 232 return((u_int32_t)BIOS_VADDRTOPADDR(sp)); 233 } 234 sp += paralen; 235 } 236 return(0); 237 } 238 239 /* 240 * do not staticize, used by bioscall.s 241 */ 242 union { 243 struct { 244 u_short offset; 245 u_short segment; 246 } vec16; 247 struct { 248 u_int offset; 249 u_short segment; 250 } vec32; 251 } bioscall_vector; /* bios jump vector */ 252 253 void 254 set_bios_selectors(struct bios_segments *seg, int flags) 255 { 256 struct soft_segment_descriptor ssd = { 257 0, /* segment base address (overwritten) */ 258 0, /* length (overwritten) */ 259 SDT_MEMERA, /* segment type (overwritten) */ 260 0, /* priority level */ 261 1, /* descriptor present */ 262 0, 0, 263 1, /* descriptor size (overwritten) */ 264 0 /* granularity == byte units */ 265 }; 266 union descriptor *p_gdt; 267 268 #ifdef SMP 269 p_gdt = &gdt[PCPU_GET(cpuid) * NGDT]; 270 #else 271 p_gdt = gdt; 272 #endif 273 274 ssd.ssd_base = seg->code32.base; 275 ssd.ssd_limit = seg->code32.limit; 276 ssdtosd(&ssd, &p_gdt[GBIOSCODE32_SEL].sd); 277 278 ssd.ssd_def32 = 0; 279 if (flags & BIOSCODE_FLAG) { 280 ssd.ssd_base = seg->code16.base; 281 ssd.ssd_limit = seg->code16.limit; 282 ssdtosd(&ssd, &p_gdt[GBIOSCODE16_SEL].sd); 283 } 284 285 ssd.ssd_type = SDT_MEMRWA; 286 if (flags & BIOSDATA_FLAG) { 287 ssd.ssd_base = seg->data.base; 288 ssd.ssd_limit = seg->data.limit; 289 ssdtosd(&ssd, &p_gdt[GBIOSDATA_SEL].sd); 290 } 291 292 if (flags & BIOSUTIL_FLAG) { 293 ssd.ssd_base = seg->util.base; 294 ssd.ssd_limit = seg->util.limit; 295 ssdtosd(&ssd, &p_gdt[GBIOSUTIL_SEL].sd); 296 } 297 298 if (flags & BIOSARGS_FLAG) { 299 ssd.ssd_base = seg->args.base; 300 ssd.ssd_limit = seg->args.limit; 301 ssdtosd(&ssd, &p_gdt[GBIOSARGS_SEL].sd); 302 } 303 } 304 305 extern int vm86pa; 306 extern void bios16_jmp(void); 307 308 /* 309 * this routine is really greedy with selectors, and uses 5: 310 * 311 * 32-bit code selector: to return to kernel 312 * 16-bit code selector: for running code 313 * data selector: for 16-bit data 314 * util selector: extra utility selector 315 * args selector: to handle pointers 316 * 317 * the util selector is set from the util16 entry in bios16_args, if a 318 * "U" specifier is seen. 319 * 320 * See <machine/pc/bios.h> for description of format specifiers 321 */ 322 int 323 bios16(struct bios_args *args, char *fmt, ...) 324 { 325 char *p, *stack, *stack_top; 326 va_list ap; 327 int flags = BIOSCODE_FLAG | BIOSDATA_FLAG; 328 u_int i, arg_start, arg_end; 329 pt_entry_t *pte; 330 pd_entry_t *ptd; 331 332 arg_start = 0xffffffff; 333 arg_end = 0; 334 335 /* 336 * Some BIOS entrypoints attempt to copy the largest-case 337 * argument frame (in order to generalise handling for 338 * different entry types). If our argument frame is 339 * smaller than this, the BIOS will reach off the top of 340 * our constructed stack segment. Pad the top of the stack 341 * with some garbage to avoid this. 342 */ 343 stack = (caddr_t)PAGE_SIZE - 32; 344 345 va_start(ap, fmt); 346 for (p = fmt; p && *p; p++) { 347 switch (*p) { 348 case 'p': /* 32-bit pointer */ 349 i = va_arg(ap, u_int); 350 arg_start = min(arg_start, i); 351 arg_end = max(arg_end, i); 352 flags |= BIOSARGS_FLAG; 353 stack -= 4; 354 break; 355 356 case 'i': /* 32-bit integer */ 357 i = va_arg(ap, u_int); 358 stack -= 4; 359 break; 360 361 case 'U': /* 16-bit selector */ 362 flags |= BIOSUTIL_FLAG; 363 /* FALLTHROUGH */ 364 case 'D': /* 16-bit selector */ 365 case 'C': /* 16-bit selector */ 366 stack -= 2; 367 break; 368 369 case 's': /* 16-bit integer passed as an int */ 370 i = va_arg(ap, int); 371 stack -= 2; 372 break; 373 374 default: 375 return (EINVAL); 376 } 377 } 378 379 if (flags & BIOSARGS_FLAG) { 380 if (arg_end - arg_start > ctob(16)) 381 return (EACCES); 382 args->seg.args.base = arg_start; 383 args->seg.args.limit = 0xffff; 384 } 385 386 args->seg.code32.base = (u_int)&bios16_jmp & PG_FRAME; 387 args->seg.code32.limit = 0xffff; 388 389 ptd = (pd_entry_t *)rcr3(); 390 #ifdef PAE 391 if (ptd == IdlePDPT) 392 #else 393 if (ptd == IdlePTD) 394 #endif 395 { 396 /* 397 * no page table, so create one and install it. 398 */ 399 pte = (pt_entry_t *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK); 400 ptd = (pd_entry_t *)((u_int)IdlePTD + KERNBASE); 401 *pte = (vm86pa - PAGE_SIZE) | PG_RW | PG_V; 402 *ptd = vtophys(pte) | PG_RW | PG_V; 403 } else { 404 /* 405 * this is a user-level page table 406 */ 407 pte = PTmap; 408 *pte = (vm86pa - PAGE_SIZE) | PG_RW | PG_V; 409 } 410 pmap_invalidate_all(kernel_pmap); /* XXX insurance for now */ 411 412 stack_top = stack; 413 va_start(ap, fmt); 414 for (p = fmt; p && *p; p++) { 415 switch (*p) { 416 case 'p': /* 32-bit pointer */ 417 i = va_arg(ap, u_int); 418 *(u_int *)stack = (i - arg_start) | 419 (GSEL(GBIOSARGS_SEL, SEL_KPL) << 16); 420 stack += 4; 421 break; 422 423 case 'i': /* 32-bit integer */ 424 i = va_arg(ap, u_int); 425 *(u_int *)stack = i; 426 stack += 4; 427 break; 428 429 case 'U': /* 16-bit selector */ 430 *(u_short *)stack = GSEL(GBIOSUTIL_SEL, SEL_KPL); 431 stack += 2; 432 break; 433 434 case 'D': /* 16-bit selector */ 435 *(u_short *)stack = GSEL(GBIOSDATA_SEL, SEL_KPL); 436 stack += 2; 437 break; 438 439 case 'C': /* 16-bit selector */ 440 *(u_short *)stack = GSEL(GBIOSCODE16_SEL, SEL_KPL); 441 stack += 2; 442 break; 443 444 case 's': /* 16-bit integer passed as an int */ 445 i = va_arg(ap, int); 446 *(u_short *)stack = i; 447 stack += 2; 448 break; 449 450 default: 451 return (EINVAL); 452 } 453 } 454 455 set_bios_selectors(&args->seg, flags); 456 bioscall_vector.vec16.offset = (u_short)args->entry; 457 bioscall_vector.vec16.segment = GSEL(GBIOSCODE16_SEL, SEL_KPL); 458 459 i = bios16_call(&args->r, stack_top); 460 461 if (pte == PTmap) { 462 *pte = 0; /* remove entry */ 463 /* 464 * XXX only needs to be invlpg(0) but that doesn't work on the 386 465 */ 466 pmap_invalidate_all(kernel_pmap); 467 } else { 468 *ptd = 0; /* remove page table */ 469 /* 470 * XXX only needs to be invlpg(0) but that doesn't work on the 386 471 */ 472 pmap_invalidate_all(kernel_pmap); 473 free(pte, M_TEMP); /* ... and free it */ 474 } 475 return (i); 476 } 477 478 const u_char * 479 bios_string(u_int from, u_int to, const u_char *string, int len) 480 { 481 const char *t, *te; 482 483 if (len == 0) 484 len = strlen(string); 485 t = (const char *)(KERNBASE + from); 486 te = (const char *)(KERNBASE + to); 487 for (; t <= te; t++) 488 if (!memcmp(string, t, len)) 489 return (t); 490 return (NULL); 491 } 492 493 #ifdef DEV_ISA 494 /* 495 * PnP BIOS interface; enumerate devices only known to the system 496 * BIOS and save information about them for later use. 497 */ 498 499 struct pnp_sysdev 500 { 501 u_int16_t size; 502 u_int8_t handle; 503 u_int32_t devid; 504 u_int8_t type[3]; 505 u_int16_t attrib; 506 #define PNPATTR_NODISABLE (1<<0) /* can't be disabled */ 507 #define PNPATTR_NOCONFIG (1<<1) /* can't be configured */ 508 #define PNPATTR_OUTPUT (1<<2) /* can be primary output */ 509 #define PNPATTR_INPUT (1<<3) /* can be primary input */ 510 #define PNPATTR_BOOTABLE (1<<4) /* can be booted from */ 511 #define PNPATTR_DOCK (1<<5) /* is a docking station */ 512 #define PNPATTR_REMOVEABLE (1<<6) /* device is removeable */ 513 #define PNPATTR_CONFIG_STATIC (0) 514 #define PNPATTR_CONFIG_DYNAMIC (1) 515 #define PNPATTR_CONFIG_DYNONLY (3) 516 #define PNPATTR_CONFIG(a) (((a) >> 7) & 0x3) 517 /* device-specific data comes here */ 518 u_int8_t devdata[0]; 519 } __packed; 520 521 /* We have to cluster arguments within a 64k range for the bios16 call */ 522 struct pnp_sysdevargs 523 { 524 u_int16_t next; 525 struct pnp_sysdev node; 526 }; 527 528 /* 529 * This function is called after the bus has assigned resource 530 * locations for a logical device. 531 */ 532 static void 533 pnpbios_set_config(void *arg, struct isa_config *config, int enable) 534 { 535 } 536 537 /* 538 * Quiz the PnP BIOS, build a list of PNP IDs and resource data. 539 */ 540 static void 541 pnpbios_identify(driver_t *driver, device_t parent) 542 { 543 struct PnPBIOS_table *pt = PnPBIOStable; 544 struct bios_args args; 545 struct pnp_sysdev *pd; 546 struct pnp_sysdevargs *pda; 547 u_int16_t ndevs, bigdev; 548 int error, currdev; 549 u_int8_t *devnodebuf, tag; 550 u_int32_t *devid, *compid; 551 int idx, left; 552 device_t dev; 553 554 /* no PnP BIOS information */ 555 if (pt == NULL) 556 return; 557 558 /* Check to see if ACPI is already active. */ 559 dev = devclass_get_device(devclass_find("acpi"), 0); 560 if (dev != NULL && device_is_attached(dev)) 561 return; 562 563 /* get count of PnP devices */ 564 bzero(&args, sizeof(args)); 565 args.seg.code16.base = BIOS_PADDRTOVADDR(pt->pmentrybase); 566 args.seg.code16.limit = 0xffff; /* XXX ? */ 567 args.seg.data.base = BIOS_PADDRTOVADDR(pt->pmdataseg); 568 args.seg.data.limit = 0xffff; 569 args.entry = pt->pmentryoffset; 570 571 if ((error = bios16(&args, PNP_COUNT_DEVNODES, &ndevs, &bigdev)) || (args.r.eax & 0xff)) 572 printf("pnpbios: error %d/%x getting device count/size limit\n", error, args.r.eax); 573 ndevs &= 0xff; /* clear high byte garbage */ 574 if (bootverbose) 575 printf("pnpbios: %d devices, largest %d bytes\n", ndevs, bigdev); 576 577 devnodebuf = malloc(bigdev + (sizeof(struct pnp_sysdevargs) - sizeof(struct pnp_sysdev)), 578 M_DEVBUF, M_NOWAIT); 579 pda = (struct pnp_sysdevargs *)devnodebuf; 580 pd = &pda->node; 581 582 for (currdev = 0, left = ndevs; (currdev != 0xff) && (left > 0); left--) { 583 584 bzero(pd, bigdev); 585 pda->next = currdev; 586 /* get current configuration */ 587 if ((error = bios16(&args, PNP_GET_DEVNODE, &pda->next, &pda->node, 1))) { 588 printf("pnpbios: error %d making BIOS16 call\n", error); 589 break; 590 } 591 if ((error = (args.r.eax & 0xff))) { 592 if (bootverbose) 593 printf("pnpbios: %s 0x%x fetching node %d\n", error & 0x80 ? "error" : "warning", error, currdev); 594 if (error & 0x80) 595 break; 596 } 597 currdev = pda->next; 598 if (pd->size < sizeof(struct pnp_sysdev)) { 599 printf("pnpbios: bogus system node data, aborting scan\n"); 600 break; 601 } 602 603 /* 604 * Ignore PICs so that we don't have to worry about the PICs 605 * claiming IRQs to prevent their use. The PIC drivers 606 * already ensure that invalid IRQs are not used. 607 */ 608 if (!strcmp(pnp_eisaformat(pd->devid), "PNP0000")) /* ISA PIC */ 609 continue; 610 if (!strcmp(pnp_eisaformat(pd->devid), "PNP0003")) /* APIC */ 611 continue; 612 613 /* Add the device and parse its resources */ 614 dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNP, NULL, -1); 615 isa_set_vendorid(dev, pd->devid); 616 isa_set_logicalid(dev, pd->devid); 617 /* 618 * It appears that some PnP BIOS doesn't allow us to re-enable 619 * the embedded system device once it is disabled. We shall 620 * mark all system device nodes as "cannot be disabled", regardless 621 * of actual settings in the device attribute byte. 622 * XXX 623 isa_set_configattr(dev, 624 ((pd->attrib & PNPATTR_NODISABLE) ? 0 : ISACFGATTR_CANDISABLE) | 625 ((!(pd->attrib & PNPATTR_NOCONFIG) && 626 PNPATTR_CONFIG(pd->attrib) != PNPATTR_CONFIG_STATIC) 627 ? ISACFGATTR_DYNAMIC : 0)); 628 */ 629 isa_set_configattr(dev, 630 (!(pd->attrib & PNPATTR_NOCONFIG) && 631 PNPATTR_CONFIG(pd->attrib) != PNPATTR_CONFIG_STATIC) 632 ? ISACFGATTR_DYNAMIC : 0); 633 ISA_SET_CONFIG_CALLBACK(parent, dev, pnpbios_set_config, 0); 634 pnp_parse_resources(dev, &pd->devdata[0], 635 pd->size - sizeof(struct pnp_sysdev), 0); 636 if (!device_get_desc(dev)) 637 device_set_desc_copy(dev, pnp_eisaformat(pd->devid)); 638 639 /* Find device IDs */ 640 devid = &pd->devid; 641 compid = NULL; 642 643 /* look for a compatible device ID too */ 644 left = pd->size - sizeof(struct pnp_sysdev); 645 idx = 0; 646 while (idx < left) { 647 tag = pd->devdata[idx++]; 648 if (PNP_RES_TYPE(tag) == 0) { 649 /* Small resource */ 650 switch (PNP_SRES_NUM(tag)) { 651 case PNP_TAG_COMPAT_DEVICE: 652 compid = (u_int32_t *)(pd->devdata + idx); 653 if (bootverbose) 654 printf("pnpbios: node %d compat ID 0x%08x\n", pd->handle, *compid); 655 /* FALLTHROUGH */ 656 case PNP_TAG_END: 657 idx = left; 658 break; 659 default: 660 idx += PNP_SRES_LEN(tag); 661 break; 662 } 663 } else 664 /* Large resource, skip it */ 665 idx += *(u_int16_t *)(pd->devdata + idx) + 2; 666 } 667 if (bootverbose) { 668 printf("pnpbios: handle %d device ID %s (%08x)", 669 pd->handle, pnp_eisaformat(*devid), *devid); 670 if (compid != NULL) 671 printf(" compat ID %s (%08x)", 672 pnp_eisaformat(*compid), *compid); 673 printf("\n"); 674 } 675 } 676 } 677 678 static device_method_t pnpbios_methods[] = { 679 /* Device interface */ 680 DEVMETHOD(device_identify, pnpbios_identify), 681 682 { 0, 0 } 683 }; 684 685 static driver_t pnpbios_driver = { 686 "pnpbios", 687 pnpbios_methods, 688 1, /* no softc */ 689 }; 690 691 static devclass_t pnpbios_devclass; 692 693 DRIVER_MODULE(pnpbios, isa, pnpbios_driver, pnpbios_devclass, 0, 0); 694 #endif /* DEV_ISA */ 695