1 /*- 2 * Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27 #include <sys/cdefs.h> 28 #include <stand.h> 29 #include <sys/endian.h> 30 31 #define PTOV(x) ptov(x) 32 33 /* Only enable 64-bit entry point if it makes sense */ 34 #if __SIZEOF_POINTER__ > 4 35 #define HAS_SMBV3 1 36 #endif 37 38 /* 39 * Detect SMBIOS and export information about the SMBIOS into the 40 * environment. 41 * 42 * System Management BIOS Reference Specification, v2.6 Final 43 * http://www.dmtf.org/standards/published_documents/DSP0134_2.6.0.pdf 44 * 45 * System Management BIOS (SMBIOS) Reference Specification, 3.6.0 46 * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.6.0.pdf 47 */ 48 49 /* 50 * The first quoted paragraph below can also be found in section 2.1.1 SMBIOS 51 * Structure Table Entry Point of System Management BIOS Reference 52 * Specification, v2.6 Final 53 * 54 * (From System Management BIOS (SMBIOS) Reference Specification, 3.6.0) 55 * 5.2.1 SMBIOS 2.1 (32-bit) Entry Point 56 * 57 * "On non-UEFI systems, the 32-bit SMBIOS Entry Point structure, can be 58 * located by application software by searching for the anchor-string on 59 * paragraph (16-byte) boundaries within the physical memory address 60 * range 000F0000h to 000FFFFFh. This entry point encapsulates an intermediate 61 * anchor string that is used by some existing DMI browsers. 62 * 63 * On UEFI-based systems, the SMBIOS Entry Point structure can be located by 64 * looking in the EFI Configuration Table for the SMBIOS GUID 65 * (SMBIOS_TABLE_GUID, {EB9D2D31-2D88-11D3-9A16-0090273FC14D}) and using the 66 * associated pointer. See section 4.6 of the UEFI Specification for details. 67 * See section 2.3 of the UEFI Specification for how to report the containing 68 * memory type. 69 * 70 * NOTE While the SMBIOS Major and Minor Versions (offsets 06h and 07h) 71 * currently duplicate the information that is present in the SMBIOS BCD 72 * Revision (offset 1Eh), they provide a path for future growth in this 73 * specification. The BCD Revision, for example, provides only a single digit 74 * for each of the major and minor version numbers." 75 * 76 * 5.2.2 SMBIOS 860 3.0 (64-bit) Entry Point 77 * 78 * "On non-UEFI systems, the 64-bit SMBIOS Entry Point structure can be located 79 * by application software by searching for the anchor-string on paragraph 80 * (16-byte) boundaries within the physical memory address range 000F0000h to 81 * 000FFFFFh. 82 * 83 * On UEFI-based systems, the SMBIOS Entry Point structure can be located by 84 * looking in the EFI Configuration Table for the SMBIOS 3.x GUID 85 * (SMBIOS3_TABLE_GUID, {F2FD1544-9794-4A2C-992E-E5BBCF20E394}) and using the 86 * associated pointer. See section 4.6 of the UEFI Specification for details. 87 * See section 2.3 of the UEFI Specification for how to report the containing 88 * memory type." 89 */ 90 #define SMBIOS_START 0xf0000 91 #define SMBIOS_LENGTH 0x10000 92 #define SMBIOS_STEP 0x10 93 #define SMBIOS_SIG "_SM_" 94 #define SMBIOS3_SIG "_SM3_" 95 #define SMBIOS_DMI_SIG "_DMI_" 96 97 /* 98 * 5.1 General 99 *... 100 * NOTE The Entry Point Structure and all SMBIOS structures assume a 101 * little-endian ordering convention... 102 * ... 103 * 104 * We use memcpy to avoid unaligned access to memory. To normal memory, this is 105 * fine, but the memory we are using might be mmap'd /dev/mem which under Linux 106 * on aarch64 doesn't allow unaligned access. leXdec and friends can't be used 107 * because those can optimize to an unaligned load (which often is fine, but not 108 * for mmap'd /dev/mem which has special memory attributes). 109 */ 110 static inline uint8_t SMBIOS_GET8(const caddr_t base, int off) { return (base[off]); } 111 112 static inline uint16_t 113 SMBIOS_GET16(const caddr_t base, int off) 114 { 115 uint16_t v; 116 117 memcpy(&v, base + off, sizeof(v)); 118 return (le16toh(v)); 119 } 120 121 static inline uint32_t 122 SMBIOS_GET32(const caddr_t base, int off) 123 { 124 uint32_t v; 125 126 memcpy(&v, base + off, sizeof(v)); 127 return (le32toh(v)); 128 } 129 130 static inline uint64_t 131 SMBIOS_GET64(const caddr_t base, int off) 132 { 133 uint64_t v; 134 135 memcpy(&v, base + off, sizeof(v)); 136 return (le64toh(v)); 137 } 138 139 #define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01) 140 #define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base)) 141 142 struct smbios_attr { 143 int probed; 144 caddr_t addr; 145 size_t length; 146 size_t count; 147 int major; 148 int minor; 149 int ver; 150 const char* bios_vendor; 151 const char* maker; 152 const char* product; 153 uint32_t enabled_memory; 154 uint32_t old_enabled_memory; 155 uint8_t enabled_sockets; 156 uint8_t populated_sockets; 157 }; 158 159 static struct smbios_attr smbios; 160 #ifdef HAS_SMBV3 161 static int isv3; 162 #endif 163 164 static uint8_t 165 smbios_checksum(const caddr_t addr, const uint8_t len) 166 { 167 uint8_t sum; 168 int i; 169 170 for (sum = 0, i = 0; i < len; i++) 171 sum += SMBIOS_GET8(addr, i); 172 return (sum); 173 } 174 175 static caddr_t 176 smbios_sigsearch(const caddr_t addr, const uint32_t len) 177 { 178 caddr_t cp; 179 180 /* Search on 16-byte boundaries. */ 181 for (cp = addr; cp < addr + len; cp += SMBIOS_STEP) { 182 /* v2.1, 32-bit Entry point */ 183 if (strncmp(cp, SMBIOS_SIG, sizeof(SMBIOS_SIG) - 1) == 0 && 184 smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 && 185 strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 && 186 smbios_checksum(cp + 0x10, 0x0f) == 0) 187 return (cp); 188 189 #ifdef HAS_SMBV3 190 /* v3.0, 64-bit Entry point */ 191 if (strncmp(cp, SMBIOS3_SIG, sizeof(SMBIOS3_SIG) - 1) == 0 && 192 smbios_checksum(cp, SMBIOS_GET8(cp, 0x06)) == 0) { 193 isv3 = 1; 194 return (cp); 195 } 196 #endif 197 } 198 return (NULL); 199 } 200 201 static const char* 202 smbios_getstring(caddr_t addr, const int offset) 203 { 204 caddr_t cp; 205 int i, idx; 206 207 idx = SMBIOS_GET8(addr, offset); 208 if (idx != 0) { 209 cp = SMBIOS_GETSTR(addr); 210 for (i = 1; i < idx; i++) 211 cp += strlen(cp) + 1; 212 return cp; 213 } 214 return (NULL); 215 } 216 217 static void 218 smbios_setenv(const char *name, caddr_t addr, const int offset) 219 { 220 const char* val; 221 222 val = smbios_getstring(addr, offset); 223 if (val != NULL) 224 setenv(name, val, 1); 225 } 226 227 #ifdef SMBIOS_SERIAL_NUMBERS 228 229 #define UUID_SIZE 16 230 #define UUID_TYPE uint32_t 231 #define UUID_STEP sizeof(UUID_TYPE) 232 #define UUID_ALL_BITS (UUID_SIZE / UUID_STEP) 233 #define UUID_GET(base, off) SMBIOS_GET32(base, off) 234 235 static void 236 smbios_setuuid(const char *name, const caddr_t addr, const int ver __unused) 237 { 238 char uuid[37]; 239 int byteorder, i, ones, zeros; 240 UUID_TYPE n; 241 uint32_t f1; 242 uint16_t f2, f3; 243 244 for (i = 0, ones = 0, zeros = 0; i < UUID_SIZE; i += UUID_STEP) { 245 n = UUID_GET(addr, i) + 1; 246 if (zeros == 0 && n == 0) 247 ones++; 248 else if (ones == 0 && n == 1) 249 zeros++; 250 else 251 break; 252 } 253 254 if (ones != UUID_ALL_BITS && zeros != UUID_ALL_BITS) { 255 /* 256 * 3.3.2.1 System UUID 257 * 258 * "Although RFC 4122 recommends network byte order for all 259 * fields, the PC industry (including the ACPI, UEFI, and 260 * Microsoft specifications) has consistently used 261 * little-endian byte encoding for the first three fields: 262 * time_low, time_mid, time_hi_and_version. The same encoding, 263 * also known as wire format, should also be used for the 264 * SMBIOS representation of the UUID." 265 * 266 * Note: We use network byte order for backward compatibility 267 * unless SMBIOS version is 2.6+ or little-endian is forced. 268 */ 269 #if defined(SMBIOS_LITTLE_ENDIAN_UUID) 270 byteorder = LITTLE_ENDIAN; 271 #elif defined(SMBIOS_NETWORK_ENDIAN_UUID) 272 byteorder = BIG_ENDIAN; 273 #else 274 byteorder = ver < 0x0206 ? BIG_ENDIAN : LITTLE_ENDIAN; 275 #endif 276 if (byteorder != LITTLE_ENDIAN) { 277 f1 = ntohl(SMBIOS_GET32(addr, 0)); 278 f2 = ntohs(SMBIOS_GET16(addr, 4)); 279 f3 = ntohs(SMBIOS_GET16(addr, 6)); 280 } else { 281 f1 = le32toh(SMBIOS_GET32(addr, 0)); 282 f2 = le16toh(SMBIOS_GET16(addr, 4)); 283 f3 = le16toh(SMBIOS_GET16(addr, 6)); 284 } 285 sprintf(uuid, 286 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", 287 f1, f2, f3, SMBIOS_GET8(addr, 8), SMBIOS_GET8(addr, 9), 288 SMBIOS_GET8(addr, 10), SMBIOS_GET8(addr, 11), 289 SMBIOS_GET8(addr, 12), SMBIOS_GET8(addr, 13), 290 SMBIOS_GET8(addr, 14), SMBIOS_GET8(addr, 15)); 291 setenv(name, uuid, 1); 292 } 293 } 294 295 #undef UUID_SIZE 296 #undef UUID_TYPE 297 #undef UUID_STEP 298 #undef UUID_ALL_BITS 299 #undef UUID_GET 300 301 #endif 302 303 static const char * 304 smbios_parse_chassis_type(caddr_t addr) 305 { 306 int type; 307 308 type = SMBIOS_GET8(addr, 0x5); 309 switch (type) { 310 case 0x1: 311 return ("Other"); 312 case 0x2: 313 return ("Unknown"); 314 case 0x3: 315 return ("Desktop"); 316 case 0x4: 317 return ("Low Profile Desktop"); 318 case 0x5: 319 return ("Pizza Box"); 320 case 0x6: 321 return ("Mini Tower"); 322 case 0x7: 323 return ("Tower"); 324 case 0x8: 325 return ("Portable"); 326 case 0x9: 327 return ("Laptop"); 328 case 0xA: 329 return ("Notebook"); 330 case 0xB: 331 return ("Hand Held"); 332 case 0xC: 333 return ("Docking Station"); 334 case 0xD: 335 return ("All in One"); 336 case 0xE: 337 return ("Sub Notebook"); 338 case 0xF: 339 return ("Lunch Box"); 340 case 0x10: 341 return ("Space-saving"); 342 case 0x11: 343 return ("Main Server Chassis"); 344 case 0x12: 345 return ("Expansion Chassis"); 346 case 0x13: 347 return ("SubChassis"); 348 case 0x14: 349 return ("Bus Expansion Chassis"); 350 case 0x15: 351 return ("Peripheral Chassis"); 352 case 0x16: 353 return ("RAID Chassis"); 354 case 0x17: 355 return ("Rack Mount Chassis"); 356 case 0x18: 357 return ("Sealed-case PC"); 358 case 0x19: 359 return ("Multi-system chassis"); 360 case 0x1A: 361 return ("Compact PCI"); 362 case 0x1B: 363 return ("Advanced TCA"); 364 case 0x1C: 365 return ("Blade"); 366 case 0x1D: 367 return ("Blade Enclosure"); 368 case 0x1E: 369 return ("Tablet"); 370 case 0x1F: 371 return ("Convertible"); 372 case 0x20: 373 return ("Detachable"); 374 case 0x21: 375 return ("IoT Gateway"); 376 case 0x22: 377 return ("Embedded PC"); 378 case 0x23: 379 return ("Mini PC"); 380 case 0x24: 381 return ("Stick PC"); 382 } 383 384 return ("Undefined"); 385 } 386 387 static caddr_t 388 smbios_parse_table(const caddr_t addr) 389 { 390 caddr_t cp; 391 int proc, size, osize, type; 392 uint8_t bios_minor, bios_major; 393 char buf[16]; 394 395 type = SMBIOS_GET8(addr, 0); /* 3.1.2 Structure Header Format */ 396 switch(type) { 397 case 0: /* 3.3.1 BIOS Information (Type 0) */ 398 smbios_setenv("smbios.bios.vendor", addr, 0x04); 399 smbios_setenv("smbios.bios.version", addr, 0x05); 400 smbios_setenv("smbios.bios.reldate", addr, 0x08); 401 bios_major = SMBIOS_GET8(addr, 0x14); 402 bios_minor = SMBIOS_GET8(addr, 0x15); 403 if (bios_minor != 0xFF && bios_major != 0xFF) { 404 snprintf(buf, sizeof(buf), "%u.%u", 405 bios_major, bios_minor); 406 setenv("smbios.bios.revision", buf, 1); 407 } 408 break; 409 410 case 1: /* 3.3.2 System Information (Type 1) */ 411 smbios_setenv("smbios.system.maker", addr, 0x04); 412 smbios_setenv("smbios.system.product", addr, 0x05); 413 smbios_setenv("smbios.system.version", addr, 0x06); 414 #ifdef SMBIOS_SERIAL_NUMBERS 415 smbios_setenv("smbios.system.serial", addr, 0x07); 416 smbios_setuuid("smbios.system.uuid", addr + 0x08, smbios.ver); 417 #endif 418 if (smbios.major > 2 || 419 (smbios.major == 2 && smbios.minor >= 4)) { 420 smbios_setenv("smbios.system.sku", addr, 0x19); 421 smbios_setenv("smbios.system.family", addr, 0x1a); 422 } 423 break; 424 425 case 2: /* 3.3.3 Base Board (or Module) Information (Type 2) */ 426 smbios_setenv("smbios.planar.maker", addr, 0x04); 427 smbios_setenv("smbios.planar.product", addr, 0x05); 428 smbios_setenv("smbios.planar.version", addr, 0x06); 429 #ifdef SMBIOS_SERIAL_NUMBERS 430 smbios_setenv("smbios.planar.serial", addr, 0x07); 431 smbios_setenv("smbios.planar.tag", addr, 0x08); 432 #endif 433 smbios_setenv("smbios.planar.location", addr, 0x0a); 434 break; 435 436 case 3: /* 3.3.4 System Enclosure or Chassis (Type 3) */ 437 smbios_setenv("smbios.chassis.maker", addr, 0x04); 438 setenv("smbios.chassis.type", smbios_parse_chassis_type(addr), 1); 439 smbios_setenv("smbios.chassis.version", addr, 0x06); 440 #ifdef SMBIOS_SERIAL_NUMBERS 441 smbios_setenv("smbios.chassis.serial", addr, 0x07); 442 smbios_setenv("smbios.chassis.tag", addr, 0x08); 443 #endif 444 break; 445 446 case 4: /* 3.3.5 Processor Information (Type 4) */ 447 /* 448 * Offset 18h: Processor Status 449 * 450 * Bit 7 Reserved, must be 0 451 * Bit 6 CPU Socket Populated 452 * 1 - CPU Socket Populated 453 * 0 - CPU Socket Unpopulated 454 * Bit 5:3 Reserved, must be zero 455 * Bit 2:0 CPU Status 456 * 0h - Unknown 457 * 1h - CPU Enabled 458 * 2h - CPU Disabled by User via BIOS Setup 459 * 3h - CPU Disabled by BIOS (POST Error) 460 * 4h - CPU is Idle, waiting to be enabled 461 * 5-6h - Reserved 462 * 7h - Other 463 */ 464 proc = SMBIOS_GET8(addr, 0x18); 465 if ((proc & 0x07) == 1) 466 smbios.enabled_sockets++; 467 if ((proc & 0x40) != 0) 468 smbios.populated_sockets++; 469 break; 470 471 case 6: /* 3.3.7 Memory Module Information (Type 6, Obsolete) */ 472 /* 473 * Offset 0Ah: Enabled Size 474 * 475 * Bit 7 Bank connection 476 * 1 - Double-bank connection 477 * 0 - Single-bank connection 478 * Bit 6:0 Size (n), where 2**n is the size in MB 479 * 7Dh - Not determinable (Installed Size only) 480 * 7Eh - Module is installed, but no memory 481 * has been enabled 482 * 7Fh - Not installed 483 */ 484 osize = SMBIOS_GET8(addr, 0x0a) & 0x7f; 485 if (osize > 0 && osize < 22) 486 smbios.old_enabled_memory += 1 << (osize + 10); 487 break; 488 489 case 17: /* 3.3.18 Memory Device (Type 17) */ 490 /* 491 * Offset 0Ch: Size 492 * 493 * Bit 15 Granularity 494 * 1 - Value is in kilobytes units 495 * 0 - Value is in megabytes units 496 * Bit 14:0 Size 497 */ 498 size = SMBIOS_GET16(addr, 0x0c); 499 if (size != 0 && size != 0xffff) 500 smbios.enabled_memory += (size & 0x8000) != 0 ? 501 (size & 0x7fff) : (size << 10); 502 break; 503 504 default: /* skip other types */ 505 break; 506 } 507 508 /* Find structure terminator. */ 509 cp = SMBIOS_GETSTR(addr); 510 while (SMBIOS_GET16(cp, 0) != 0) 511 cp++; 512 513 return (cp + 2); 514 } 515 516 static caddr_t 517 smbios_find_struct(int type) 518 { 519 caddr_t dmi; 520 size_t i; 521 caddr_t ep; 522 523 if (smbios.addr == NULL) 524 return (NULL); 525 526 ep = smbios.addr + smbios.length; 527 for (dmi = smbios.addr, i = 0; 528 dmi < ep && i < smbios.count; i++) { 529 if (SMBIOS_GET8(dmi, 0) == type) { 530 return dmi; 531 } 532 /* Find structure terminator. */ 533 dmi = SMBIOS_GETSTR(dmi); 534 while (SMBIOS_GET16(dmi, 0) != 0 && dmi < ep) { 535 dmi++; 536 } 537 dmi += 2; /* For checksum */ 538 } 539 540 return (NULL); 541 } 542 543 static void 544 smbios_probe(const caddr_t addr) 545 { 546 caddr_t saddr, info; 547 uintptr_t paddr; 548 int maj_off; 549 int min_off; 550 551 if (smbios.probed) 552 return; 553 smbios.probed = 1; 554 555 /* Search signatures and validate checksums. */ 556 saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START), 557 SMBIOS_LENGTH); 558 if (saddr == NULL) 559 return; 560 561 #ifdef HAS_SMBV3 562 if (isv3) { 563 smbios.length = SMBIOS_GET32(saddr, 0x0c); /* Structure Table Length */ 564 paddr = SMBIOS_GET64(saddr, 0x10); /* Structure Table Address */ 565 smbios.count = -1; /* not present in V3 */ 566 smbios.ver = 0; /* not present in V3 */ 567 maj_off = 0x07; 568 min_off = 0x08; 569 } else 570 #endif 571 { 572 smbios.length = SMBIOS_GET16(saddr, 0x16); /* Structure Table Length */ 573 paddr = SMBIOS_GET32(saddr, 0x18); /* Structure Table Address */ 574 smbios.count = SMBIOS_GET16(saddr, 0x1c); /* No of SMBIOS Structures */ 575 smbios.ver = SMBIOS_GET8(saddr, 0x1e); /* SMBIOS BCD Revision */ 576 maj_off = 0x06; 577 min_off = 0x07; 578 } 579 580 581 if (smbios.ver != 0) { 582 smbios.major = smbios.ver >> 4; 583 smbios.minor = smbios.ver & 0x0f; 584 if (smbios.major > 9 || smbios.minor > 9) 585 smbios.ver = 0; 586 } 587 if (smbios.ver == 0) { 588 smbios.major = SMBIOS_GET8(saddr, maj_off);/* SMBIOS Major Version */ 589 smbios.minor = SMBIOS_GET8(saddr, min_off);/* SMBIOS Minor Version */ 590 } 591 smbios.ver = (smbios.major << 8) | smbios.minor; 592 smbios.addr = PTOV(paddr); 593 594 /* Get system information from SMBIOS */ 595 info = smbios_find_struct(0x00); 596 if (info != NULL) { 597 smbios.bios_vendor = smbios_getstring(info, 0x04); 598 } 599 info = smbios_find_struct(0x01); 600 if (info != NULL) { 601 smbios.maker = smbios_getstring(info, 0x04); 602 smbios.product = smbios_getstring(info, 0x05); 603 } 604 } 605 606 void 607 smbios_detect(const caddr_t addr) 608 { 609 char buf[16]; 610 caddr_t dmi; 611 size_t i; 612 613 smbios_probe(addr); 614 if (smbios.addr == NULL) 615 return; 616 617 for (dmi = smbios.addr, i = 0; 618 dmi < smbios.addr + smbios.length && i < smbios.count; i++) 619 dmi = smbios_parse_table(dmi); 620 621 sprintf(buf, "%d.%d", smbios.major, smbios.minor); 622 setenv("smbios.version", buf, 1); 623 if (smbios.enabled_memory > 0 || smbios.old_enabled_memory > 0) { 624 sprintf(buf, "%u", smbios.enabled_memory > 0 ? 625 smbios.enabled_memory : smbios.old_enabled_memory); 626 setenv("smbios.memory.enabled", buf, 1); 627 } 628 if (smbios.enabled_sockets > 0) { 629 sprintf(buf, "%u", smbios.enabled_sockets); 630 setenv("smbios.socket.enabled", buf, 1); 631 } 632 if (smbios.populated_sockets > 0) { 633 sprintf(buf, "%u", smbios.populated_sockets); 634 setenv("smbios.socket.populated", buf, 1); 635 } 636 } 637 638 static int 639 smbios_match_str(const char* s1, const char* s2) 640 { 641 return (s1 == NULL || (s2 != NULL && !strcmp(s1, s2))); 642 } 643 644 int 645 smbios_match(const char* bios_vendor, const char* maker, 646 const char* product) 647 { 648 /* XXXRP currently, only called from non-EFI. */ 649 smbios_probe(NULL); 650 return (smbios_match_str(bios_vendor, smbios.bios_vendor) && 651 smbios_match_str(maker, smbios.maker) && 652 smbios_match_str(product, smbios.product)); 653 } 654