1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. 24 * Copyright 2015 Joyent, Inc. 25 * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 26 * Use is subject to license terms. 27 */ 28 29 /* 30 * SMBIOS Information Routines 31 * 32 * The routines in this file are used to convert from the SMBIOS data format to 33 * a more reasonable and stable set of structures offered as part of our ABI. 34 * These functions take the general form: 35 * 36 * stp = smb_lookup_type(shp, foo); 37 * smb_foo_t foo; 38 * 39 * smb_info_bcopy(stp->smbst_hdr, &foo, sizeof (foo)); 40 * bzero(caller's struct); 41 * 42 * copy/convert foo members into caller's struct 43 * 44 * We copy the internal structure on to an automatic variable so as to avoid 45 * checks everywhere for structures that the BIOS has improperly truncated, and 46 * also to automatically handle the case of a structure that has been extended. 47 * When necessary, this code can use smb_gteq() to determine whether the SMBIOS 48 * data is of a particular revision that is supposed to contain a new field. 49 * 50 * Note, when trying to bzero the caller's struct you have to be careful about 51 * versions. One can only bzero the initial version that existed in illumos. In 52 * other words, if someone passes an older library handle that doesn't support a 53 * version you cannot assume that their structures have those additional members 54 * in them. Instead, a 'base' version is introduced for such types that have 55 * differences and instead we only bzero out the base version and then handle 56 * the additional members. In general, because all additional members will be 57 * assigned, there's no reason to zero them out unless they are arrays that 58 * won't be entirely filled in. 59 * 60 * Due to history, anything added after the update from version 2.4, in other 61 * words additions from or after '5094 Update libsmbios with recent items' 62 * (4e901881) is currently being used for this. While we don't allow software 63 * compiling against this to get an older form, this was the first major update 64 * and a good starting point for us to enforce this behavior which is useful for 65 * moving forward to making this more public. 66 */ 67 68 #include <sys/smbios_impl.h> 69 70 #ifdef _KERNEL 71 #include <sys/sunddi.h> 72 #else 73 #include <fcntl.h> 74 #include <unistd.h> 75 #include <string.h> 76 #endif 77 78 /* 79 * A large number of SMBIOS structures contain a set of common strings used to 80 * describe a h/w component's serial number, manufacturer, etc. These fields 81 * helpfully have different names and offsets and sometimes aren't consistent. 82 * To simplify life for our clients, we factor these common things out into 83 * smbios_info_t, which can be retrieved for any structure. The following 84 * table describes the mapping from a given structure to the smbios_info_t. 85 * Multiple SMBIOS stuctures' contained objects are also handled here. 86 */ 87 static const struct smb_infospec { 88 uint8_t is_type; /* structure type */ 89 uint8_t is_manu; /* manufacturer offset */ 90 uint8_t is_product; /* product name offset */ 91 uint8_t is_version; /* version offset */ 92 uint8_t is_serial; /* serial number offset */ 93 uint8_t is_asset; /* asset tag offset */ 94 uint8_t is_location; /* location string offset */ 95 uint8_t is_part; /* part number offset */ 96 uint8_t is_contc; /* contained count */ 97 uint8_t is_contsz; /* contained size */ 98 uint8_t is_contv; /* contained objects */ 99 } _smb_infospecs[] = { 100 { SMB_TYPE_SYSTEM, 101 offsetof(smb_system_t, smbsi_manufacturer), 102 offsetof(smb_system_t, smbsi_product), 103 offsetof(smb_system_t, smbsi_version), 104 offsetof(smb_system_t, smbsi_serial), 105 0, 106 0, 107 0, 108 0, 109 0, 110 0 }, 111 { SMB_TYPE_BASEBOARD, 112 offsetof(smb_bboard_t, smbbb_manufacturer), 113 offsetof(smb_bboard_t, smbbb_product), 114 offsetof(smb_bboard_t, smbbb_version), 115 offsetof(smb_bboard_t, smbbb_serial), 116 offsetof(smb_bboard_t, smbbb_asset), 117 offsetof(smb_bboard_t, smbbb_location), 118 0, 119 offsetof(smb_bboard_t, smbbb_cn), 120 SMB_CONT_WORD, 121 offsetof(smb_bboard_t, smbbb_cv) }, 122 { SMB_TYPE_CHASSIS, 123 offsetof(smb_chassis_t, smbch_manufacturer), 124 0, 125 offsetof(smb_chassis_t, smbch_version), 126 offsetof(smb_chassis_t, smbch_serial), 127 offsetof(smb_chassis_t, smbch_asset), 128 0, 129 0, 130 offsetof(smb_chassis_t, smbch_cn), 131 SMB_CONT_BYTE, 132 offsetof(smb_chassis_t, smbch_cv) }, 133 { SMB_TYPE_PROCESSOR, 134 offsetof(smb_processor_t, smbpr_manufacturer), 135 0, 136 offsetof(smb_processor_t, smbpr_version), 137 offsetof(smb_processor_t, smbpr_serial), 138 offsetof(smb_processor_t, smbpr_asset), 139 offsetof(smb_processor_t, smbpr_socket), 140 offsetof(smb_processor_t, smbpr_part), 141 0, 142 0, 143 0 }, 144 { SMB_TYPE_CACHE, 145 0, 146 0, 147 0, 148 0, 149 0, 150 offsetof(smb_cache_t, smbca_socket), 151 0, 152 0, 153 0, 154 0 }, 155 { SMB_TYPE_PORT, 156 0, 157 0, 158 0, 159 0, 160 0, 161 offsetof(smb_port_t, smbpo_iref), 162 0, 163 0, 164 0, 165 0 }, 166 { SMB_TYPE_SLOT, 167 0, 168 0, 169 0, 170 0, 171 0, 172 offsetof(smb_slot_t, smbsl_name), 173 0, 174 0, 175 0, 176 0 }, 177 { SMB_TYPE_MEMDEVICE, 178 offsetof(smb_memdevice_t, smbmdev_manufacturer), 179 0, 180 0, 181 offsetof(smb_memdevice_t, smbmdev_serial), 182 offsetof(smb_memdevice_t, smbmdev_asset), 183 offsetof(smb_memdevice_t, smbmdev_dloc), 184 offsetof(smb_memdevice_t, smbmdev_part), 185 0, 186 0, 187 0 }, 188 { SMB_TYPE_POWERSUP, 189 offsetof(smb_powersup_t, smbpsup_manufacturer), 190 offsetof(smb_powersup_t, smbpsup_devname), 191 offsetof(smb_powersup_t, smbpsup_rev), 192 offsetof(smb_powersup_t, smbpsup_serial), 193 offsetof(smb_powersup_t, smbpsup_asset), 194 offsetof(smb_powersup_t, smbpsup_loc), 195 offsetof(smb_powersup_t, smbpsup_part), 196 0, 197 0, 198 0 }, 199 { SMB_TYPE_EOT } 200 }; 201 202 static const char * 203 smb_info_strptr(const smb_struct_t *stp, uint8_t off, int *n) 204 { 205 const uint8_t *sp = (const uint8_t *)(uintptr_t)stp->smbst_hdr; 206 207 if (off != 0 && sp + off < stp->smbst_end) { 208 (*n)++; /* indicate success for caller */ 209 return (smb_strptr(stp, sp[off])); 210 } 211 212 return (smb_strptr(stp, 0)); 213 } 214 215 static void 216 smb_info_bcopy(const smb_header_t *hp, void *dst, size_t dstlen) 217 { 218 if (dstlen > hp->smbh_len) { 219 bcopy(hp, dst, hp->smbh_len); 220 bzero((char *)dst + hp->smbh_len, dstlen - hp->smbh_len); 221 } else 222 bcopy(hp, dst, dstlen); 223 } 224 225 void 226 smbios_info_smbios(smbios_hdl_t *shp, smbios_entry_t *ep) 227 { 228 bcopy(&shp->sh_ent, ep, sizeof (smbios_entry_t)); 229 } 230 231 #ifndef _KERNEL 232 static char smbios_product_override[256]; 233 static boolean_t smbios_product_checked; 234 #endif 235 236 int 237 smbios_info_common(smbios_hdl_t *shp, id_t id, smbios_info_t *ip) 238 { 239 const smb_struct_t *stp = smb_lookup_id(shp, id); 240 const struct smb_infospec *isp; 241 int n = 0; 242 243 if (stp == NULL) 244 return (-1); /* errno is set for us */ 245 246 for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) { 247 if (isp->is_type == stp->smbst_hdr->smbh_type) 248 break; 249 } 250 251 ip->smbi_manufacturer = smb_info_strptr(stp, isp->is_manu, &n); 252 ip->smbi_product = smb_info_strptr(stp, isp->is_product, &n); 253 ip->smbi_version = smb_info_strptr(stp, isp->is_version, &n); 254 ip->smbi_serial = smb_info_strptr(stp, isp->is_serial, &n); 255 ip->smbi_asset = smb_info_strptr(stp, isp->is_asset, &n); 256 ip->smbi_location = smb_info_strptr(stp, isp->is_location, &n); 257 ip->smbi_part = smb_info_strptr(stp, isp->is_part, &n); 258 259 /* 260 * This private file allows developers to experiment with reporting 261 * different platform strings from SMBIOS. It is not a supported 262 * mechanism in the long term, and does not work in the kernel. 263 */ 264 #ifndef _KERNEL 265 if (isp->is_type == SMB_TYPE_SYSTEM) { 266 if (!smbios_product_checked) { 267 int fd = open("/etc/smbios_product", O_RDONLY); 268 if (fd >= 0) { 269 (void) read(fd, smbios_product_override, 270 sizeof (smbios_product_override) - 1); 271 (void) close(fd); 272 } 273 smbios_product_checked = B_TRUE; 274 } 275 276 if (smbios_product_override[0] != '\0') 277 ip->smbi_product = smbios_product_override; 278 } 279 #endif 280 281 /* 282 * If we have a port with an empty internal reference designator string 283 * try using the external reference designator string instead. 284 */ 285 if (isp->is_type == SMB_TYPE_PORT && ip->smbi_location[0] == '\0') { 286 ip->smbi_location = smb_info_strptr(stp, 287 offsetof(smb_port_t, smbpo_eref), &n); 288 } 289 290 return (n ? 0 : smb_set_errno(shp, ESMB_NOINFO)); 291 } 292 293 /* 294 * Returns the actual number of contained objects. 295 * 296 * idc - number of contained objects 297 * idv - returned array of contained objects 298 */ 299 int 300 smbios_info_contains(smbios_hdl_t *shp, id_t id, uint_t idc, id_t *idv) 301 { 302 const smb_struct_t *stp = smb_lookup_id(shp, id); 303 const struct smb_infospec *isp; 304 id_t *cp; 305 uint_t size; 306 uint8_t cnt; 307 int i, n; 308 309 if (stp == NULL) { 310 return (-1); /* errno is set for us */ 311 } 312 313 for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) { 314 if (isp->is_type == stp->smbst_hdr->smbh_type) 315 break; 316 } 317 if (isp->is_type == SMB_TYPE_EOT) 318 return (smb_set_errno(shp, ESMB_TYPE)); 319 320 size = isp->is_contsz; 321 cnt = *((uint8_t *)(uintptr_t)stp->smbst_hdr + isp->is_contc); 322 cp = (id_t *)((uintptr_t)stp->smbst_hdr + isp->is_contv); 323 324 n = MIN(cnt, idc); 325 for (i = 0; i < n; i++) { 326 if (size == SMB_CONT_WORD) 327 idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 2)); 328 else if (size == SMB_CONT_BYTE) 329 idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 3)); 330 else 331 return (smb_set_errno(shp, ESMB_INVAL)); 332 } 333 334 return (cnt); 335 } 336 337 id_t 338 smbios_info_bios(smbios_hdl_t *shp, smbios_bios_t *bp) 339 { 340 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BIOS); 341 const smb_bios_t *bip; 342 343 if (stp == NULL) 344 return (-1); /* errno is set for us */ 345 346 if (stp->smbst_hdr->smbh_len < sizeof (smb_bios_t) - sizeof (uint8_t)) 347 return (smb_set_errno(shp, ESMB_CORRUPT)); 348 349 bip = (smb_bios_t *)(uintptr_t)stp->smbst_hdr; 350 bzero(bp, sizeof (smbios_bios_t)); 351 352 bp->smbb_vendor = smb_strptr(stp, bip->smbbi_vendor); 353 bp->smbb_version = smb_strptr(stp, bip->smbbi_version); 354 bp->smbb_segment = bip->smbbi_segment; 355 bp->smbb_reldate = smb_strptr(stp, bip->smbbi_reldate); 356 bp->smbb_romsize = 64 * 1024 * ((uint32_t)bip->smbbi_romsize + 1); 357 bp->smbb_runsize = 16 * (0x10000 - (uint32_t)bip->smbbi_segment); 358 bp->smbb_cflags = bip->smbbi_cflags; 359 360 /* 361 * If one or more extension bytes are present, reset smbb_xcflags to 362 * point to them. Otherwise leave this member set to NULL. 363 */ 364 if (stp->smbst_hdr->smbh_len >= sizeof (smb_bios_t)) { 365 bp->smbb_xcflags = bip->smbbi_xcflags; 366 bp->smbb_nxcflags = stp->smbst_hdr->smbh_len - 367 sizeof (smb_bios_t) + 1; 368 369 if (bp->smbb_nxcflags > SMB_BIOSXB_ECFW_MIN && 370 smb_gteq(shp, SMB_VERSION_24)) { 371 bp->smbb_biosv.smbv_major = 372 bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MAJ]; 373 bp->smbb_biosv.smbv_minor = 374 bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MIN]; 375 bp->smbb_ecfwv.smbv_major = 376 bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MAJ]; 377 bp->smbb_ecfwv.smbv_minor = 378 bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MIN]; 379 } 380 } 381 382 return (stp->smbst_hdr->smbh_hdl); 383 } 384 385 id_t 386 smbios_info_system(smbios_hdl_t *shp, smbios_system_t *sip) 387 { 388 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM); 389 smb_system_t si; 390 391 if (stp == NULL) 392 return (-1); /* errno is set for us */ 393 394 smb_info_bcopy(stp->smbst_hdr, &si, sizeof (si)); 395 bzero(sip, sizeof (smbios_system_t)); 396 397 sip->smbs_uuid = ((smb_system_t *)stp->smbst_hdr)->smbsi_uuid; 398 sip->smbs_uuidlen = sizeof (si.smbsi_uuid); 399 sip->smbs_wakeup = si.smbsi_wakeup; 400 sip->smbs_sku = smb_strptr(stp, si.smbsi_sku); 401 sip->smbs_family = smb_strptr(stp, si.smbsi_family); 402 403 return (stp->smbst_hdr->smbh_hdl); 404 } 405 406 int 407 smbios_info_bboard(smbios_hdl_t *shp, id_t id, smbios_bboard_t *bbp) 408 { 409 const smb_struct_t *stp = smb_lookup_id(shp, id); 410 smb_bboard_t bb; 411 412 if (stp == NULL) 413 return (-1); /* errno is set for us */ 414 415 if (stp->smbst_hdr->smbh_type != SMB_TYPE_BASEBOARD) 416 return (smb_set_errno(shp, ESMB_TYPE)); 417 418 smb_info_bcopy(stp->smbst_hdr, &bb, sizeof (bb)); 419 bzero(bbp, sizeof (smbios_bboard_t)); 420 421 bbp->smbb_chassis = bb.smbbb_chassis; 422 bbp->smbb_flags = bb.smbbb_flags; 423 bbp->smbb_type = bb.smbbb_type; 424 bbp->smbb_contn = bb.smbbb_cn; 425 426 return (0); 427 } 428 429 int 430 smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp) 431 { 432 const smb_struct_t *stp = smb_lookup_id(shp, id); 433 /* Length is measurable by one byte, so it'll be no more than 255. */ 434 uint8_t buf[256]; 435 smb_chassis_t *ch = (smb_chassis_t *)&buf[0]; 436 437 if (stp == NULL) 438 return (-1); /* errno is set for us */ 439 440 if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS) 441 return (smb_set_errno(shp, ESMB_TYPE)); 442 443 smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf)); 444 bzero(chp, sizeof (smb_base_chassis_t)); 445 if (shp->sh_libvers >= SMB_VERSION_27) { 446 bzero(chp->smbc_sku, sizeof (chp->smbc_sku)); 447 } 448 449 chp->smbc_oemdata = ch->smbch_oemdata; 450 chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0; 451 chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK; 452 chp->smbc_bustate = ch->smbch_bustate; 453 chp->smbc_psstate = ch->smbch_psstate; 454 chp->smbc_thstate = ch->smbch_thstate; 455 chp->smbc_security = ch->smbch_security; 456 chp->smbc_uheight = ch->smbch_uheight; 457 chp->smbc_cords = ch->smbch_cords; 458 chp->smbc_elems = ch->smbch_cn; 459 chp->smbc_elemlen = ch->smbch_cm; 460 461 if (shp->sh_libvers >= SMB_VERSION_27) { 462 (void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch), 463 sizeof (chp->smbc_sku)); 464 } 465 466 return (0); 467 } 468 469 int 470 smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp) 471 { 472 const smb_struct_t *stp = smb_lookup_id(shp, id); 473 smb_processor_t p; 474 475 if (stp == NULL) 476 return (-1); /* errno is set for us */ 477 478 if (stp->smbst_hdr->smbh_type != SMB_TYPE_PROCESSOR) 479 return (smb_set_errno(shp, ESMB_TYPE)); 480 481 smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p)); 482 bzero(pp, sizeof (smb_base_processor_t)); 483 484 pp->smbp_cpuid = p.smbpr_cpuid; 485 pp->smbp_type = p.smbpr_type; 486 pp->smbp_family = p.smbpr_family; 487 pp->smbp_voltage = p.smbpr_voltage; 488 pp->smbp_maxspeed = p.smbpr_maxspeed; 489 pp->smbp_curspeed = p.smbpr_curspeed; 490 pp->smbp_status = p.smbpr_status; 491 pp->smbp_upgrade = p.smbpr_upgrade; 492 pp->smbp_l1cache = p.smbpr_l1cache; 493 pp->smbp_l2cache = p.smbpr_l2cache; 494 pp->smbp_l3cache = p.smbpr_l3cache; 495 496 if (shp->sh_libvers >= SMB_VERSION_25) { 497 pp->smbp_corecount = p.smbpr_corecount; 498 pp->smbp_coresenabled = p.smbpr_coresenabled; 499 pp->smbp_threadcount = p.smbpr_threadcount; 500 pp->smbp_cflags = p.smbpr_cflags; 501 } 502 503 if (shp->sh_libvers >= SMB_VERSION_26) 504 pp->smbp_family2 = p.smbpr_family2; 505 506 if (shp->sh_libvers >= SMB_VERSION_30) { 507 pp->smbp_corecount2 = p.smbpr_corecount2; 508 pp->smbp_coresenabled2 = p.smbpr_coresenabled2; 509 pp->smbp_threadcount2 = p.smbpr_threadcount2; 510 } 511 512 return (0); 513 } 514 515 int 516 smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap) 517 { 518 const smb_struct_t *stp = smb_lookup_id(shp, id); 519 smb_cache_t c; 520 521 if (stp == NULL) 522 return (-1); /* errno is set for us */ 523 524 if (stp->smbst_hdr->smbh_type != SMB_TYPE_CACHE) 525 return (smb_set_errno(shp, ESMB_TYPE)); 526 527 smb_info_bcopy(stp->smbst_hdr, &c, sizeof (c)); 528 bzero(cap, sizeof (smbios_cache_t)); 529 530 cap->smba_maxsize = SMB_CACHE_SIZE(c.smbca_maxsize); 531 cap->smba_size = SMB_CACHE_SIZE(c.smbca_size); 532 cap->smba_stype = c.smbca_stype; 533 cap->smba_ctype = c.smbca_ctype; 534 cap->smba_speed = c.smbca_speed; 535 cap->smba_etype = c.smbca_etype; 536 cap->smba_ltype = c.smbca_ltype; 537 cap->smba_assoc = c.smbca_assoc; 538 cap->smba_level = SMB_CACHE_CFG_LEVEL(c.smbca_config); 539 cap->smba_mode = SMB_CACHE_CFG_MODE(c.smbca_config); 540 cap->smba_location = SMB_CACHE_CFG_LOCATION(c.smbca_config); 541 542 if (SMB_CACHE_CFG_ENABLED(c.smbca_config)) 543 cap->smba_flags |= SMB_CAF_ENABLED; 544 545 if (SMB_CACHE_CFG_SOCKETED(c.smbca_config)) 546 cap->smba_flags |= SMB_CAF_SOCKETED; 547 548 return (0); 549 } 550 551 int 552 smbios_info_port(smbios_hdl_t *shp, id_t id, smbios_port_t *pop) 553 { 554 const smb_struct_t *stp = smb_lookup_id(shp, id); 555 smb_port_t p; 556 557 if (stp == NULL) 558 return (-1); /* errno is set for us */ 559 560 if (stp->smbst_hdr->smbh_type != SMB_TYPE_PORT) 561 return (smb_set_errno(shp, ESMB_TYPE)); 562 563 smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p)); 564 bzero(pop, sizeof (smbios_port_t)); 565 566 pop->smbo_iref = smb_strptr(stp, p.smbpo_iref); 567 pop->smbo_eref = smb_strptr(stp, p.smbpo_eref); 568 569 pop->smbo_itype = p.smbpo_itype; 570 pop->smbo_etype = p.smbpo_etype; 571 pop->smbo_ptype = p.smbpo_ptype; 572 573 return (0); 574 } 575 576 int 577 smbios_info_slot(smbios_hdl_t *shp, id_t id, smbios_slot_t *sp) 578 { 579 const smb_struct_t *stp = smb_lookup_id(shp, id); 580 smb_slot_t s; 581 582 if (stp == NULL) 583 return (-1); /* errno is set for us */ 584 585 if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT) 586 return (smb_set_errno(shp, ESMB_TYPE)); 587 588 smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 589 bzero(sp, sizeof (smbios_slot_t)); 590 591 sp->smbl_name = smb_strptr(stp, s.smbsl_name); 592 sp->smbl_type = s.smbsl_type; 593 sp->smbl_width = s.smbsl_width; 594 sp->smbl_usage = s.smbsl_usage; 595 sp->smbl_length = s.smbsl_length; 596 sp->smbl_id = s.smbsl_id; 597 sp->smbl_ch1 = s.smbsl_ch1; 598 sp->smbl_ch2 = s.smbsl_ch2; 599 sp->smbl_sg = s.smbsl_sg; 600 sp->smbl_bus = s.smbsl_bus; 601 sp->smbl_df = s.smbsl_df; 602 603 return (0); 604 } 605 606 int 607 smbios_info_obdevs_ext(smbios_hdl_t *shp, id_t id, smbios_obdev_ext_t *oep) 608 { 609 const smb_struct_t *stp = smb_lookup_id(shp, id); 610 smb_obdev_ext_t obe; 611 612 if (stp == NULL) 613 return (-1); /* errno is set for us */ 614 615 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVEXT) 616 return (smb_set_errno(shp, ESMB_TYPE)); 617 618 smb_info_bcopy(stp->smbst_hdr, &obe, sizeof (obe)); 619 bzero(oep, sizeof (smbios_obdev_ext_t)); 620 621 oep->smboe_name = smb_strptr(stp, obe.smbobe_name); 622 oep->smboe_dtype = obe.smbobe_dtype; 623 oep->smboe_dti = obe.smbobe_dti; 624 oep->smboe_sg = obe.smbobe_sg; 625 oep->smboe_bus = obe.smbobe_bus; 626 oep->smboe_df = obe.smbobe_df; 627 628 return (0); 629 } 630 631 int 632 smbios_info_obdevs(smbios_hdl_t *shp, id_t id, int obc, smbios_obdev_t *obp) 633 { 634 const smb_struct_t *stp = smb_lookup_id(shp, id); 635 const smb_obdev_t *op; 636 int i, m, n; 637 638 if (stp == NULL) 639 return (-1); /* errno is set for us */ 640 641 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVS) 642 return (smb_set_errno(shp, ESMB_TYPE)); 643 644 op = (smb_obdev_t *)((uintptr_t)stp->smbst_hdr + sizeof (smb_header_t)); 645 m = (stp->smbst_hdr->smbh_len - sizeof (smb_header_t)) / sizeof (*op); 646 n = MIN(m, obc); 647 648 for (i = 0; i < n; i++, op++, obp++) { 649 obp->smbd_name = smb_strptr(stp, op->smbob_name); 650 obp->smbd_type = op->smbob_type & ~SMB_OBT_ENABLED; 651 obp->smbd_enabled = (op->smbob_type & SMB_OBT_ENABLED) != 0; 652 } 653 654 return (m); 655 } 656 657 /* 658 * The implementation structures for OEMSTR, SYSCONFSTR, and LANG all use the 659 * first byte to indicate the size of a string table at the end of the record. 660 * Therefore, smbios_info_strtab() can be used to retrieve the table size and 661 * strings for any of these underlying record types. 662 */ 663 int 664 smbios_info_strtab(smbios_hdl_t *shp, id_t id, int argc, const char *argv[]) 665 { 666 const smb_struct_t *stp = smb_lookup_id(shp, id); 667 smb_strtab_t s; 668 int i, n; 669 670 if (stp == NULL) 671 return (-1); /* errno is set for us */ 672 673 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR && 674 stp->smbst_hdr->smbh_type != SMB_TYPE_SYSCONFSTR && 675 stp->smbst_hdr->smbh_type != SMB_TYPE_LANG) 676 return (smb_set_errno(shp, ESMB_TYPE)); 677 678 smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 679 n = MIN(s.smbtb_count, argc); 680 681 for (i = 0; i < n; i++) 682 argv[i] = smb_strptr(stp, i + 1); 683 684 return (s.smbtb_count); 685 } 686 687 id_t 688 smbios_info_lang(smbios_hdl_t *shp, smbios_lang_t *lp) 689 { 690 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_LANG); 691 smb_lang_t l; 692 693 if (stp == NULL) 694 return (-1); /* errno is set for us */ 695 696 smb_info_bcopy(stp->smbst_hdr, &l, sizeof (l)); 697 bzero(lp, sizeof (smbios_lang_t)); 698 699 lp->smbla_cur = smb_strptr(stp, l.smblang_cur); 700 lp->smbla_fmt = l.smblang_flags & 1; 701 lp->smbla_num = l.smblang_num; 702 703 return (stp->smbst_hdr->smbh_hdl); 704 } 705 706 id_t 707 smbios_info_eventlog(smbios_hdl_t *shp, smbios_evlog_t *evp) 708 { 709 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_EVENTLOG); 710 const smb_sel_t *sel; 711 size_t len; 712 713 if (stp == NULL) 714 return (-1); /* errno is set for us */ 715 716 if (stp->smbst_hdr->smbh_len < sizeof (smb_sel_t) - sizeof (uint8_t)) 717 return (smb_set_errno(shp, ESMB_CORRUPT)); 718 719 sel = (smb_sel_t *)(uintptr_t)stp->smbst_hdr; 720 len = stp->smbst_hdr->smbh_len - sizeof (smb_sel_t) + sizeof (uint8_t); 721 bzero(evp, sizeof (smbios_evlog_t)); 722 723 if (len < sel->smbsel_typec * sel->smbsel_typesz) 724 return (smb_set_errno(shp, ESMB_CORRUPT)); 725 726 evp->smbev_size = sel->smbsel_len; 727 evp->smbev_hdr = sel->smbsel_hdroff; 728 evp->smbev_data = sel->smbsel_dataoff; 729 evp->smbev_method = sel->smbsel_method; 730 evp->smbev_flags = sel->smbsel_status; 731 evp->smbev_format = sel->smbsel_format; 732 evp->smbev_token = sel->smbsel_token; 733 evp->smbev_addr.eva_addr = sel->smbsel_addr; 734 735 if (sel->smbsel_typesz == sizeof (smbios_evtype_t)) { 736 evp->smbev_typec = sel->smbsel_typec; 737 evp->smbev_typev = (void *)(uintptr_t)sel->smbsel_typev; 738 } 739 740 return (stp->smbst_hdr->smbh_hdl); 741 } 742 743 int 744 smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map) 745 { 746 const smb_struct_t *stp = smb_lookup_id(shp, id); 747 smb_memarray_t m; 748 749 if (stp == NULL) 750 return (-1); /* errno is set for us */ 751 752 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAY) 753 return (smb_set_errno(shp, ESMB_TYPE)); 754 755 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 756 bzero(map, sizeof (smbios_memarray_t)); 757 758 map->smbma_location = m.smbmarr_loc; 759 map->smbma_use = m.smbmarr_use; 760 map->smbma_ecc = m.smbmarr_ecc; 761 map->smbma_ndevs = m.smbmarr_ndevs; 762 map->smbma_err = m.smbmarr_err; 763 764 if (m.smbmarr_cap != 0x80000000) 765 map->smbma_size = (uint64_t)m.smbmarr_cap * 1024; 766 else if (m.smbmarr_extcap != 0) 767 map->smbma_size = m.smbmarr_extcap; 768 else 769 map->smbma_size = 0; /* unknown */ 770 771 return (0); 772 } 773 774 int 775 smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map) 776 { 777 const smb_struct_t *stp = smb_lookup_id(shp, id); 778 smb_memarrmap_t m; 779 780 if (stp == NULL) 781 return (-1); /* errno is set for us */ 782 783 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP) 784 return (smb_set_errno(shp, ESMB_TYPE)); 785 786 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 787 bzero(map, sizeof (smbios_memarrmap_t)); 788 789 map->smbmam_array = m.smbamap_array; 790 map->smbmam_width = m.smbamap_width; 791 792 if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) { 793 map->smbmam_addr = (uint64_t)m.smbamap_start * 1024; 794 map->smbmam_size = (uint64_t) 795 (m.smbamap_end - m.smbamap_start + 1) * 1024; 796 } else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) { 797 map->smbmam_addr = m.smbamap_extstart; 798 map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1; 799 } 800 801 return (0); 802 } 803 804 int 805 smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp) 806 { 807 const smb_struct_t *stp = smb_lookup_id(shp, id); 808 smb_memdevice_t m; 809 810 if (stp == NULL) 811 return (-1); /* errno is set for us */ 812 813 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICE) 814 return (smb_set_errno(shp, ESMB_TYPE)); 815 816 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 817 bzero(mdp, sizeof (smb_base_memdevice_t)); 818 819 mdp->smbmd_array = m.smbmdev_array; 820 mdp->smbmd_error = m.smbmdev_error; 821 mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth; 822 mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth; 823 824 if (m.smbmdev_size == 0x7FFF) { 825 mdp->smbmd_size = (uint64_t)m.smbmdev_extsize; 826 mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */ 827 } else if (m.smbmdev_size != 0xFFFF) { 828 mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES); 829 if (m.smbmdev_size & SMB_MDS_KBYTES) 830 mdp->smbmd_size *= 1024; 831 else 832 mdp->smbmd_size *= 1024 * 1024; 833 } else 834 mdp->smbmd_size = -1ULL; /* size unknown */ 835 836 mdp->smbmd_form = m.smbmdev_form; 837 mdp->smbmd_set = m.smbmdev_set; 838 mdp->smbmd_type = m.smbmdev_type; 839 mdp->smbmd_speed = m.smbmdev_speed; 840 mdp->smbmd_flags = m.smbmdev_flags; 841 mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc); 842 mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc); 843 844 if (shp->sh_libvers >= SMB_VERSION_26) 845 mdp->smbmd_rank = m.smbmdev_attrs & 0x0F; 846 847 if (shp->sh_libvers >= SMB_VERSION_27) 848 mdp->smbmd_clkspeed = m.smbmdev_clkspeed; 849 850 if (shp->sh_libvers >= SMB_VERSION_28) { 851 mdp->smbmd_minvolt = m.smbmdev_minvolt; 852 mdp->smbmd_maxvolt = m.smbmdev_maxvolt; 853 mdp->smbmd_confvolt = m.smbmdev_confvolt; 854 } 855 856 return (0); 857 } 858 859 int 860 smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp) 861 { 862 const smb_struct_t *stp = smb_lookup_id(shp, id); 863 smb_memdevmap_t m; 864 865 if (stp == NULL) 866 return (-1); /* errno is set for us */ 867 868 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP) 869 return (smb_set_errno(shp, ESMB_TYPE)); 870 871 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 872 bzero(mdp, sizeof (smbios_memdevmap_t)); 873 874 mdp->smbmdm_device = m.smbdmap_device; 875 mdp->smbmdm_arrmap = m.smbdmap_array; 876 mdp->smbmdm_rpos = m.smbdmap_rpos; 877 mdp->smbmdm_ipos = m.smbdmap_ipos; 878 mdp->smbmdm_idepth = m.smbdmap_idepth; 879 880 if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) { 881 mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024; 882 mdp->smbmdm_size = (uint64_t) 883 (m.smbdmap_end - m.smbdmap_start + 1) * 1024; 884 } else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) { 885 mdp->smbmdm_addr = m.smbdmap_extstart; 886 mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1; 887 } 888 889 return (0); 890 } 891 892 id_t 893 smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp) 894 { 895 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY); 896 smb_hwsec_t hs; 897 898 if (stp == NULL) 899 return (-1); /* errno is set for us */ 900 901 smb_info_bcopy(stp->smbst_hdr, &hs, sizeof (hs)); 902 bzero(hsp, sizeof (smbios_hwsec_t)); 903 904 hsp->smbh_pwr_ps = SMB_HWS_PWR_PS(hs.smbhs_settings); 905 hsp->smbh_kbd_ps = SMB_HWS_KBD_PS(hs.smbhs_settings); 906 hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings); 907 hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings); 908 909 return (stp->smbst_hdr->smbh_hdl); 910 } 911 912 id_t 913 smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp) 914 { 915 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT); 916 const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr; 917 918 if (stp == NULL) 919 return (-1); /* errno is set for us */ 920 921 bzero(bp, sizeof (smbios_boot_t)); 922 923 bp->smbt_status = b->smbbo_status[0]; 924 bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t); 925 bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL; 926 927 return (stp->smbst_hdr->smbh_hdl); 928 } 929 930 id_t 931 smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip) 932 { 933 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_IPMIDEV); 934 smb_ipmi_t i; 935 936 if (stp == NULL) 937 return (-1); /* errno is set for us */ 938 939 smb_info_bcopy(stp->smbst_hdr, &i, sizeof (i)); 940 bzero(ip, sizeof (smbios_ipmi_t)); 941 942 ip->smbip_type = i.smbipm_type; 943 ip->smbip_vers.smbv_major = SMB_IPM_SPEC_MAJOR(i.smbipm_spec); 944 ip->smbip_vers.smbv_minor = SMB_IPM_SPEC_MINOR(i.smbipm_spec); 945 ip->smbip_i2c = i.smbipm_i2c; 946 ip->smbip_addr = i.smbipm_addr & ~SMB_IPM_ADDR_IO; 947 ip->smbip_intr = i.smbipm_intr; 948 949 if (i.smbipm_bus != (uint8_t)-1) 950 ip->smbip_bus = i.smbipm_bus; 951 else 952 ip->smbip_bus = -1u; 953 954 if (SMB_IPM_INFO_LSB(i.smbipm_info)) 955 ip->smbip_addr |= 1; /* turn on least-significant bit of addr */ 956 957 if (i.smbipm_addr & SMB_IPM_ADDR_IO) { 958 switch (SMB_IPM_INFO_REGS(i.smbipm_info)) { 959 case SMB_IPM_REGS_1B: 960 ip->smbip_regspacing = 1; 961 break; 962 case SMB_IPM_REGS_4B: 963 ip->smbip_regspacing = 4; 964 break; 965 case SMB_IPM_REGS_16B: 966 ip->smbip_regspacing = 16; 967 break; 968 default: 969 ip->smbip_regspacing = 1; 970 } 971 ip->smbip_flags |= SMB_IPMI_F_IOADDR; 972 } 973 974 if (SMB_IPM_INFO_ISPEC(i.smbipm_info)) 975 ip->smbip_flags |= SMB_IPMI_F_INTRSPEC; 976 977 if (SMB_IPM_INFO_IPOL(i.smbipm_info) == SMB_IPM_IPOL_HI) 978 ip->smbip_flags |= SMB_IPMI_F_INTRHIGH; 979 980 if (SMB_IPM_INFO_IMODE(i.smbipm_info) == SMB_IPM_IMODE_EDGE) 981 ip->smbip_flags |= SMB_IPMI_F_INTREDGE; 982 983 return (stp->smbst_hdr->smbh_hdl); 984 } 985 986 static boolean_t 987 smbios_has_oemstr(smbios_hdl_t *shp, const char *oemstr) 988 { 989 const smb_struct_t *stp = shp->sh_structs; 990 smb_strtab_t s; 991 int i, j; 992 993 for (i = 0; i < shp->sh_nstructs; i++, stp++) { 994 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR) 995 continue; 996 997 smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 998 for (j = 0; j < s.smbtb_count; j++) 999 if (strcmp(smb_strptr(stp, j + 1), oemstr) == 0) 1000 return (B_TRUE); 1001 } 1002 1003 return (B_FALSE); 1004 } 1005 1006 static const char * 1007 smb_serial_valid(const char *serial) 1008 { 1009 char buf[MAXNAMELEN]; 1010 int i = 0; 1011 1012 if (serial == NULL) 1013 return (NULL); 1014 1015 (void) strlcpy(buf, serial, sizeof (buf)); 1016 1017 while (buf[i] != '\0' && buf[i] == ' ') 1018 i++; 1019 1020 if (buf[i] == '\0' || strstr(buf, SMB_DEFAULT1) != NULL || 1021 strstr(buf, SMB_DEFAULT2) != NULL) 1022 return (NULL); 1023 1024 return (serial); 1025 } 1026 1027 /* 1028 * Get chassis SN or product SN 1029 */ 1030 static int 1031 smb_get_sn(smbios_hdl_t *shp, const char **psnp, const char **csnp) 1032 { 1033 const smb_struct_t *stp; 1034 smbios_info_t s1, s3; 1035 1036 if (psnp == NULL || csnp == NULL) 1037 return (smb_set_errno(shp, ESMB_INVAL)); 1038 1039 *psnp = *csnp = NULL; 1040 1041 /* 1042 * If SMBIOS meets Sun's PRMS requirements, retrieve product SN 1043 * from type 1 structure, and chassis SN from type 3 structure. 1044 * Otherwise return SN in type 1 structure as chassis SN. 1045 */ 1046 1047 /* Get type 1 SN */ 1048 if ((stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM)) == NULL || 1049 smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s1) == SMB_ERR) 1050 s1.smbi_serial = NULL; 1051 1052 /* Get type 3 SN */ 1053 if ((stp = smb_lookup_type(shp, SMB_TYPE_CHASSIS)) == NULL || 1054 smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s3) == SMB_ERR) 1055 s3.smbi_serial = NULL; 1056 1057 if (smbios_has_oemstr(shp, SMB_PRMS1)) { 1058 *psnp = smb_serial_valid(s1.smbi_serial); 1059 *csnp = smb_serial_valid(s3.smbi_serial); 1060 } else { 1061 *csnp = smb_serial_valid(s1.smbi_serial); 1062 } 1063 1064 return (0); 1065 } 1066 1067 const char * 1068 smbios_psn(smbios_hdl_t *shp) 1069 { 1070 const char *psn, *csn; 1071 1072 return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : psn); 1073 } 1074 1075 const char * 1076 smbios_csn(smbios_hdl_t *shp) 1077 { 1078 const char *psn, *csn; 1079 1080 return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : csn); 1081 } 1082 1083 int 1084 smbios_info_extprocessor(smbios_hdl_t *shp, id_t id, 1085 smbios_processor_ext_t *epp) 1086 { 1087 const smb_struct_t *stp = smb_lookup_id(shp, id); 1088 smb_processor_ext_t *exp; 1089 1090 if (stp == NULL) 1091 return (-1); /* errno is set for us */ 1092 1093 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PROCESSOR) 1094 return (smb_set_errno(shp, ESMB_TYPE)); 1095 1096 exp = (smb_processor_ext_t *)(uintptr_t)stp->smbst_hdr; 1097 bzero(epp, sizeof (smbios_processor_ext_t)); 1098 1099 epp->smbpe_processor = exp->smbpre_processor; 1100 epp->smbpe_fru = exp->smbpre_fru; 1101 epp->smbpe_n = exp->smbpre_n; 1102 epp->smbpe_apicid = exp->smbpre_apicid; 1103 1104 return (0); 1105 } 1106 1107 int 1108 smbios_info_extport(smbios_hdl_t *shp, id_t id, smbios_port_ext_t *eportp) 1109 { 1110 const smb_struct_t *stp = smb_lookup_id(shp, id); 1111 smb_port_ext_t *ep; 1112 1113 if (stp == NULL) 1114 return (-1); /* errno is set for us */ 1115 1116 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PORT) 1117 return (smb_set_errno(shp, ESMB_TYPE)); 1118 1119 ep = (smb_port_ext_t *)(uintptr_t)stp->smbst_hdr; 1120 bzero(eportp, sizeof (smbios_port_ext_t)); 1121 1122 eportp->smbporte_chassis = ep->smbpoe_chassis; 1123 eportp->smbporte_port = ep->smbpoe_port; 1124 eportp->smbporte_dtype = ep->smbpoe_dtype; 1125 eportp->smbporte_devhdl = ep->smbpoe_devhdl; 1126 eportp->smbporte_phy = ep->smbpoe_phy; 1127 1128 return (0); 1129 } 1130 1131 int 1132 smbios_info_pciexrc(smbios_hdl_t *shp, id_t id, 1133 smbios_pciexrc_t *rcp) 1134 { 1135 const smb_struct_t *stp = smb_lookup_id(shp, id); 1136 smb_pciexrc_t rc; 1137 1138 if (stp == NULL) 1139 return (-1); /* errno is set for us */ 1140 1141 if (stp->smbst_hdr->smbh_type != SUN_OEM_PCIEXRC) 1142 return (smb_set_errno(shp, ESMB_TYPE)); 1143 1144 smb_info_bcopy(stp->smbst_hdr, &rc, sizeof (rc)); 1145 bzero(rcp, sizeof (smbios_pciexrc_t)); 1146 1147 rcp->smbpcie_bb = rc.smbpciexrc_bboard; 1148 rcp->smbpcie_bdf = rc.smbpciexrc_bdf; 1149 1150 return (0); 1151 } 1152 1153 int 1154 smbios_info_extmemarray(smbios_hdl_t *shp, id_t id, smbios_memarray_ext_t *emap) 1155 { 1156 const smb_struct_t *stp = smb_lookup_id(shp, id); 1157 smb_memarray_ext_t exma; 1158 1159 if (stp == NULL) 1160 return (-1); /* errno is set for us */ 1161 1162 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMARRAY) 1163 return (smb_set_errno(shp, ESMB_TYPE)); 1164 1165 smb_info_bcopy(stp->smbst_hdr, &exma, sizeof (exma)); 1166 bzero(emap, sizeof (smbios_memarray_ext_t)); 1167 1168 emap->smbmae_ma = exma.smbmarre_ma; 1169 emap->smbmae_comp = exma.smbmarre_component; 1170 emap->smbmae_bdf = exma.smbmarre_bdf; 1171 1172 return (0); 1173 } 1174 1175 int 1176 smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id, 1177 smbios_memdevice_ext_t *emdp) 1178 { 1179 const smb_struct_t *stp = smb_lookup_id(shp, id); 1180 smb_memdevice_ext_t exmd; 1181 1182 if (stp == NULL) 1183 return (-1); /* errno is set for us */ 1184 1185 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMDEVICE) 1186 return (smb_set_errno(shp, ESMB_TYPE)); 1187 1188 smb_info_bcopy(stp->smbst_hdr, &exmd, sizeof (exmd)); 1189 bzero(emdp, sizeof (smbios_memdevice_ext_t)); 1190 1191 emdp->smbmdeve_md = exmd.smbmdeve_mdev; 1192 emdp->smbmdeve_drch = exmd.smbmdeve_dchan; 1193 emdp->smbmdeve_ncs = exmd.smbmdeve_ncs; 1194 emdp->smbmdeve_cs = exmd.smbmdeve_cs; 1195 1196 return (0); 1197 } 1198