MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bios_oem_strings

Function bios_oem_strings

freebsd/i386/i386/bios.c:443–519  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443int
444bios_oem_strings(struct bios_oem *oem, u_char *buffer, size_t maxlen)
445{
446 size_t idx = 0;
447 struct bios_oem_signature *sig;
448 u_int from, to;
449 u_char c, *s, *se, *str, *bios_str;
450 size_t i, off, len, tot;
451
452 if ( !oem || !buffer || maxlen<2 )
453 return(-1);
454
455 sig = oem->signature;
456 if (!sig)
457 return(-2);
458
459 from = oem->range.from;
460 to = oem->range.to;
461 if ( (to<=from) || (from<BIOS_START) || (to>(BIOS_START+BIOS_SIZE)) )
462 return(-3);
463
464 while (sig->anchor != NULL) {
465 str = sig->anchor;
466 len = strlen(str);
467 off = sig->offset;
468 tot = sig->totlen;
469 /* make sure offset doesn't go beyond bios area */
470 if ( (to+off)>(BIOS_START+BIOS_SIZE) ||
471 ((from+off)<BIOS_START) ) {
472 printf("sys/i386/i386/bios.c: sig '%s' "
473 "from 0x%0x to 0x%0x offset %d "
474 "out of BIOS bounds 0x%0x - 0x%0x\n",
475 str, from, to, off,
476 BIOS_START, BIOS_START+BIOS_SIZE);
477 return(-4);
478 }
479 /* make sure we don't overrun return buffer */
480 if (idx + tot > maxlen - 1) {
481 printf("sys/i386/i386/bios.c: sig '%s' "
482 "idx %d + tot %d = %d > maxlen-1 %d\n",
483 str, idx, tot, idx+tot, maxlen-1);
484 return(-5);
485 }
486 bios_str = NULL;
487 s = (u_char *)BIOS_PADDRTOVADDR(from);
488 se = (u_char *)BIOS_PADDRTOVADDR(to-len);
489 for (; s<se; s++) {
490 if (!bcmp(str, s, len)) {
491 bios_str = s;
492 break;
493 }
494 }
495 /*
496 * store pretty version of totlen bytes of bios string with
497 * given offset; 0x20 - 0x7E are printable; uniquify spaces
498 */
499 if (bios_str) {
500 for (i=0; i<tot; i++) {

Callers 2

elan_drvinitFunction · 0.85
geode_probeFunction · 0.85

Calls 1

printfFunction · 0.50

Tested by

no test coverage detected