184ab085aSmws /* 284ab085aSmws * CDDL HEADER START 384ab085aSmws * 484ab085aSmws * The contents of this file are subject to the terms of the 5c7c09f80SEric Schrock * Common Development and Distribution License (the "License"). 6c7c09f80SEric Schrock * You may not use this file except in compliance with the License. 784ab085aSmws * 884ab085aSmws * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 984ab085aSmws * or http://www.opensolaris.org/os/licensing. 1084ab085aSmws * See the License for the specific language governing permissions 1184ab085aSmws * and limitations under the License. 1284ab085aSmws * 1384ab085aSmws * When distributing Covered Code, include this CDDL HEADER in each 1484ab085aSmws * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1584ab085aSmws * If applicable, add the following below this CDDL HEADER, with the 1684ab085aSmws * fields enclosed by brackets "[]" replaced with your own identifying 1784ab085aSmws * information: Portions Copyright [yyyy] [name of copyright owner] 1884ab085aSmws * 1984ab085aSmws * CDDL HEADER END 2084ab085aSmws */ 2184ab085aSmws 2284ab085aSmws /* 234e901881SDale Ghent * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. 24*38d76b18SRobert Mustacchi * Copyright 2016 Joyent, Inc. 2503f9f63dSTom Pothier * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2684ab085aSmws * Use is subject to license terms. 2784ab085aSmws */ 2884ab085aSmws 2984ab085aSmws /* 3084ab085aSmws * SMBIOS Information Routines 3184ab085aSmws * 3284ab085aSmws * The routines in this file are used to convert from the SMBIOS data format to 3384ab085aSmws * a more reasonable and stable set of structures offered as part of our ABI. 3484ab085aSmws * These functions take the general form: 3584ab085aSmws * 3684ab085aSmws * stp = smb_lookup_type(shp, foo); 3784ab085aSmws * smb_foo_t foo; 3884ab085aSmws * 3984ab085aSmws * smb_info_bcopy(stp->smbst_hdr, &foo, sizeof (foo)); 4084ab085aSmws * bzero(caller's struct); 4184ab085aSmws * 4284ab085aSmws * copy/convert foo members into caller's struct 4384ab085aSmws * 4484ab085aSmws * We copy the internal structure on to an automatic variable so as to avoid 4584ab085aSmws * checks everywhere for structures that the BIOS has improperly truncated, and 4684ab085aSmws * also to automatically handle the case of a structure that has been extended. 4784ab085aSmws * When necessary, this code can use smb_gteq() to determine whether the SMBIOS 4884ab085aSmws * data is of a particular revision that is supposed to contain a new field. 496734c4b0SRobert Mustacchi * 506734c4b0SRobert Mustacchi * Note, when trying to bzero the caller's struct you have to be careful about 516734c4b0SRobert Mustacchi * versions. One can only bzero the initial version that existed in illumos. In 526734c4b0SRobert Mustacchi * other words, if someone passes an older library handle that doesn't support a 536734c4b0SRobert Mustacchi * version you cannot assume that their structures have those additional members 546734c4b0SRobert Mustacchi * in them. Instead, a 'base' version is introduced for such types that have 556734c4b0SRobert Mustacchi * differences and instead we only bzero out the base version and then handle 566734c4b0SRobert Mustacchi * the additional members. In general, because all additional members will be 576734c4b0SRobert Mustacchi * assigned, there's no reason to zero them out unless they are arrays that 586734c4b0SRobert Mustacchi * won't be entirely filled in. 596734c4b0SRobert Mustacchi * 606734c4b0SRobert Mustacchi * Due to history, anything added after the update from version 2.4, in other 616734c4b0SRobert Mustacchi * words additions from or after '5094 Update libsmbios with recent items' 626734c4b0SRobert Mustacchi * (4e901881) is currently being used for this. While we don't allow software 636734c4b0SRobert Mustacchi * compiling against this to get an older form, this was the first major update 646734c4b0SRobert Mustacchi * and a good starting point for us to enforce this behavior which is useful for 656734c4b0SRobert Mustacchi * moving forward to making this more public. 6684ab085aSmws */ 6784ab085aSmws 6884ab085aSmws #include <sys/smbios_impl.h> 69*38d76b18SRobert Mustacchi #include <sys/byteorder.h> 7084ab085aSmws 719c94f155SCheng Sean Ye #ifdef _KERNEL 729c94f155SCheng Sean Ye #include <sys/sunddi.h> 739c94f155SCheng Sean Ye #else 74c7c09f80SEric Schrock #include <fcntl.h> 75c7c09f80SEric Schrock #include <unistd.h> 769c94f155SCheng Sean Ye #include <string.h> 77c7c09f80SEric Schrock #endif 78c7c09f80SEric Schrock 7984ab085aSmws /* 8084ab085aSmws * A large number of SMBIOS structures contain a set of common strings used to 8184ab085aSmws * describe a h/w component's serial number, manufacturer, etc. These fields 8284ab085aSmws * helpfully have different names and offsets and sometimes aren't consistent. 8384ab085aSmws * To simplify life for our clients, we factor these common things out into 8484ab085aSmws * smbios_info_t, which can be retrieved for any structure. The following 8584ab085aSmws * table describes the mapping from a given structure to the smbios_info_t. 86074bb90dSTom Pothier * Multiple SMBIOS stuctures' contained objects are also handled here. 8784ab085aSmws */ 8884ab085aSmws static const struct smb_infospec { 8984ab085aSmws uint8_t is_type; /* structure type */ 9084ab085aSmws uint8_t is_manu; /* manufacturer offset */ 9184ab085aSmws uint8_t is_product; /* product name offset */ 9284ab085aSmws uint8_t is_version; /* version offset */ 9384ab085aSmws uint8_t is_serial; /* serial number offset */ 9484ab085aSmws uint8_t is_asset; /* asset tag offset */ 9584ab085aSmws uint8_t is_location; /* location string offset */ 9684ab085aSmws uint8_t is_part; /* part number offset */ 97074bb90dSTom Pothier uint8_t is_contc; /* contained count */ 98074bb90dSTom Pothier uint8_t is_contsz; /* contained size */ 99074bb90dSTom Pothier uint8_t is_contv; /* contained objects */ 10084ab085aSmws } _smb_infospecs[] = { 10184ab085aSmws { SMB_TYPE_SYSTEM, 10284ab085aSmws offsetof(smb_system_t, smbsi_manufacturer), 10384ab085aSmws offsetof(smb_system_t, smbsi_product), 10484ab085aSmws offsetof(smb_system_t, smbsi_version), 10584ab085aSmws offsetof(smb_system_t, smbsi_serial), 10684ab085aSmws 0, 10784ab085aSmws 0, 108074bb90dSTom Pothier 0, 109074bb90dSTom Pothier 0, 110074bb90dSTom Pothier 0, 11184ab085aSmws 0 }, 11284ab085aSmws { SMB_TYPE_BASEBOARD, 11384ab085aSmws offsetof(smb_bboard_t, smbbb_manufacturer), 11484ab085aSmws offsetof(smb_bboard_t, smbbb_product), 11584ab085aSmws offsetof(smb_bboard_t, smbbb_version), 11684ab085aSmws offsetof(smb_bboard_t, smbbb_serial), 11784ab085aSmws offsetof(smb_bboard_t, smbbb_asset), 11884ab085aSmws offsetof(smb_bboard_t, smbbb_location), 119074bb90dSTom Pothier 0, 120074bb90dSTom Pothier offsetof(smb_bboard_t, smbbb_cn), 121074bb90dSTom Pothier SMB_CONT_WORD, 122074bb90dSTom Pothier offsetof(smb_bboard_t, smbbb_cv) }, 12384ab085aSmws { SMB_TYPE_CHASSIS, 12484ab085aSmws offsetof(smb_chassis_t, smbch_manufacturer), 12584ab085aSmws 0, 12684ab085aSmws offsetof(smb_chassis_t, smbch_version), 12784ab085aSmws offsetof(smb_chassis_t, smbch_serial), 12884ab085aSmws offsetof(smb_chassis_t, smbch_asset), 12984ab085aSmws 0, 130074bb90dSTom Pothier 0, 131074bb90dSTom Pothier offsetof(smb_chassis_t, smbch_cn), 132074bb90dSTom Pothier SMB_CONT_BYTE, 133074bb90dSTom Pothier offsetof(smb_chassis_t, smbch_cv) }, 13484ab085aSmws { SMB_TYPE_PROCESSOR, 13584ab085aSmws offsetof(smb_processor_t, smbpr_manufacturer), 13684ab085aSmws 0, 13784ab085aSmws offsetof(smb_processor_t, smbpr_version), 13884ab085aSmws offsetof(smb_processor_t, smbpr_serial), 13984ab085aSmws offsetof(smb_processor_t, smbpr_asset), 14084ab085aSmws offsetof(smb_processor_t, smbpr_socket), 141074bb90dSTom Pothier offsetof(smb_processor_t, smbpr_part), 142074bb90dSTom Pothier 0, 143074bb90dSTom Pothier 0, 144074bb90dSTom Pothier 0 }, 14584ab085aSmws { SMB_TYPE_CACHE, 14684ab085aSmws 0, 14784ab085aSmws 0, 14884ab085aSmws 0, 14984ab085aSmws 0, 15084ab085aSmws 0, 15184ab085aSmws offsetof(smb_cache_t, smbca_socket), 152074bb90dSTom Pothier 0, 153074bb90dSTom Pothier 0, 154074bb90dSTom Pothier 0, 15584ab085aSmws 0 }, 15684ab085aSmws { SMB_TYPE_PORT, 15784ab085aSmws 0, 15884ab085aSmws 0, 15984ab085aSmws 0, 16084ab085aSmws 0, 16184ab085aSmws 0, 16284ab085aSmws offsetof(smb_port_t, smbpo_iref), 163074bb90dSTom Pothier 0, 164074bb90dSTom Pothier 0, 165074bb90dSTom Pothier 0, 16684ab085aSmws 0 }, 16784ab085aSmws { SMB_TYPE_SLOT, 16884ab085aSmws 0, 16984ab085aSmws 0, 17084ab085aSmws 0, 17184ab085aSmws 0, 17284ab085aSmws 0, 17384ab085aSmws offsetof(smb_slot_t, smbsl_name), 174074bb90dSTom Pothier 0, 175074bb90dSTom Pothier 0, 176074bb90dSTom Pothier 0, 17784ab085aSmws 0 }, 17884ab085aSmws { SMB_TYPE_MEMDEVICE, 17984ab085aSmws offsetof(smb_memdevice_t, smbmdev_manufacturer), 18084ab085aSmws 0, 18184ab085aSmws 0, 18284ab085aSmws offsetof(smb_memdevice_t, smbmdev_serial), 18384ab085aSmws offsetof(smb_memdevice_t, smbmdev_asset), 18484ab085aSmws offsetof(smb_memdevice_t, smbmdev_dloc), 185074bb90dSTom Pothier offsetof(smb_memdevice_t, smbmdev_part), 186074bb90dSTom Pothier 0, 187074bb90dSTom Pothier 0, 188074bb90dSTom Pothier 0 }, 18984ab085aSmws { SMB_TYPE_POWERSUP, 19084ab085aSmws offsetof(smb_powersup_t, smbpsup_manufacturer), 19184ab085aSmws offsetof(smb_powersup_t, smbpsup_devname), 19284ab085aSmws offsetof(smb_powersup_t, smbpsup_rev), 19384ab085aSmws offsetof(smb_powersup_t, smbpsup_serial), 19484ab085aSmws offsetof(smb_powersup_t, smbpsup_asset), 19584ab085aSmws offsetof(smb_powersup_t, smbpsup_loc), 196074bb90dSTom Pothier offsetof(smb_powersup_t, smbpsup_part), 197074bb90dSTom Pothier 0, 198074bb90dSTom Pothier 0, 199074bb90dSTom Pothier 0 }, 20084ab085aSmws { SMB_TYPE_EOT } 20184ab085aSmws }; 20284ab085aSmws 20384ab085aSmws static const char * 20484ab085aSmws smb_info_strptr(const smb_struct_t *stp, uint8_t off, int *n) 20584ab085aSmws { 20684ab085aSmws const uint8_t *sp = (const uint8_t *)(uintptr_t)stp->smbst_hdr; 20784ab085aSmws 20884ab085aSmws if (off != 0 && sp + off < stp->smbst_end) { 20984ab085aSmws (*n)++; /* indicate success for caller */ 21084ab085aSmws return (smb_strptr(stp, sp[off])); 21184ab085aSmws } 21284ab085aSmws 21384ab085aSmws return (smb_strptr(stp, 0)); 21484ab085aSmws } 21584ab085aSmws 21684ab085aSmws static void 21784ab085aSmws smb_info_bcopy(const smb_header_t *hp, void *dst, size_t dstlen) 21884ab085aSmws { 21984ab085aSmws if (dstlen > hp->smbh_len) { 22084ab085aSmws bcopy(hp, dst, hp->smbh_len); 22184ab085aSmws bzero((char *)dst + hp->smbh_len, dstlen - hp->smbh_len); 22284ab085aSmws } else 22384ab085aSmws bcopy(hp, dst, dstlen); 22484ab085aSmws } 22584ab085aSmws 22684ab085aSmws void 22784ab085aSmws smbios_info_smbios(smbios_hdl_t *shp, smbios_entry_t *ep) 22884ab085aSmws { 22984ab085aSmws bcopy(&shp->sh_ent, ep, sizeof (smbios_entry_t)); 23084ab085aSmws } 23184ab085aSmws 232c7c09f80SEric Schrock #ifndef _KERNEL 233c7c09f80SEric Schrock static char smbios_product_override[256]; 234c7c09f80SEric Schrock static boolean_t smbios_product_checked; 235c7c09f80SEric Schrock #endif 236c7c09f80SEric Schrock 23784ab085aSmws int 23884ab085aSmws smbios_info_common(smbios_hdl_t *shp, id_t id, smbios_info_t *ip) 23984ab085aSmws { 24084ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 24184ab085aSmws const struct smb_infospec *isp; 24284ab085aSmws int n = 0; 24384ab085aSmws 24484ab085aSmws if (stp == NULL) 24584ab085aSmws return (-1); /* errno is set for us */ 24684ab085aSmws 24784ab085aSmws for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) { 24884ab085aSmws if (isp->is_type == stp->smbst_hdr->smbh_type) 24984ab085aSmws break; 25084ab085aSmws } 25184ab085aSmws 25284ab085aSmws ip->smbi_manufacturer = smb_info_strptr(stp, isp->is_manu, &n); 25384ab085aSmws ip->smbi_product = smb_info_strptr(stp, isp->is_product, &n); 25484ab085aSmws ip->smbi_version = smb_info_strptr(stp, isp->is_version, &n); 25584ab085aSmws ip->smbi_serial = smb_info_strptr(stp, isp->is_serial, &n); 25684ab085aSmws ip->smbi_asset = smb_info_strptr(stp, isp->is_asset, &n); 25784ab085aSmws ip->smbi_location = smb_info_strptr(stp, isp->is_location, &n); 25884ab085aSmws ip->smbi_part = smb_info_strptr(stp, isp->is_part, &n); 25984ab085aSmws 26084ab085aSmws /* 261c7c09f80SEric Schrock * This private file allows developers to experiment with reporting 262c7c09f80SEric Schrock * different platform strings from SMBIOS. It is not a supported 263c7c09f80SEric Schrock * mechanism in the long term, and does not work in the kernel. 264c7c09f80SEric Schrock */ 265c7c09f80SEric Schrock #ifndef _KERNEL 266c7c09f80SEric Schrock if (isp->is_type == SMB_TYPE_SYSTEM) { 267c7c09f80SEric Schrock if (!smbios_product_checked) { 268c7c09f80SEric Schrock int fd = open("/etc/smbios_product", O_RDONLY); 269c7c09f80SEric Schrock if (fd >= 0) { 270c7c09f80SEric Schrock (void) read(fd, smbios_product_override, 271c7c09f80SEric Schrock sizeof (smbios_product_override) - 1); 272c7c09f80SEric Schrock (void) close(fd); 273c7c09f80SEric Schrock } 274c7c09f80SEric Schrock smbios_product_checked = B_TRUE; 275c7c09f80SEric Schrock } 276c7c09f80SEric Schrock 277c7c09f80SEric Schrock if (smbios_product_override[0] != '\0') 278c7c09f80SEric Schrock ip->smbi_product = smbios_product_override; 279c7c09f80SEric Schrock } 280c7c09f80SEric Schrock #endif 281c7c09f80SEric Schrock 282c7c09f80SEric Schrock /* 28384ab085aSmws * If we have a port with an empty internal reference designator string 28484ab085aSmws * try using the external reference designator string instead. 28584ab085aSmws */ 28684ab085aSmws if (isp->is_type == SMB_TYPE_PORT && ip->smbi_location[0] == '\0') { 28784ab085aSmws ip->smbi_location = smb_info_strptr(stp, 28884ab085aSmws offsetof(smb_port_t, smbpo_eref), &n); 28984ab085aSmws } 29084ab085aSmws 29184ab085aSmws return (n ? 0 : smb_set_errno(shp, ESMB_NOINFO)); 29284ab085aSmws } 29384ab085aSmws 294074bb90dSTom Pothier /* 295074bb90dSTom Pothier * Returns the actual number of contained objects. 296074bb90dSTom Pothier * 297074bb90dSTom Pothier * idc - number of contained objects 298074bb90dSTom Pothier * idv - returned array of contained objects 299074bb90dSTom Pothier */ 300074bb90dSTom Pothier int 301074bb90dSTom Pothier smbios_info_contains(smbios_hdl_t *shp, id_t id, uint_t idc, id_t *idv) 302074bb90dSTom Pothier { 303074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 304074bb90dSTom Pothier const struct smb_infospec *isp; 305074bb90dSTom Pothier id_t *cp; 306074bb90dSTom Pothier uint_t size; 307074bb90dSTom Pothier uint8_t cnt; 308074bb90dSTom Pothier int i, n; 309074bb90dSTom Pothier 310074bb90dSTom Pothier if (stp == NULL) { 311074bb90dSTom Pothier return (-1); /* errno is set for us */ 312074bb90dSTom Pothier } 313074bb90dSTom Pothier 314074bb90dSTom Pothier for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) { 315074bb90dSTom Pothier if (isp->is_type == stp->smbst_hdr->smbh_type) 316074bb90dSTom Pothier break; 317074bb90dSTom Pothier } 318074bb90dSTom Pothier if (isp->is_type == SMB_TYPE_EOT) 319074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 320074bb90dSTom Pothier 321074bb90dSTom Pothier size = isp->is_contsz; 322074bb90dSTom Pothier cnt = *((uint8_t *)(uintptr_t)stp->smbst_hdr + isp->is_contc); 323074bb90dSTom Pothier cp = (id_t *)((uintptr_t)stp->smbst_hdr + isp->is_contv); 324074bb90dSTom Pothier 325074bb90dSTom Pothier n = MIN(cnt, idc); 326074bb90dSTom Pothier for (i = 0; i < n; i++) { 327074bb90dSTom Pothier if (size == SMB_CONT_WORD) 328074bb90dSTom Pothier idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 2)); 329074bb90dSTom Pothier else if (size == SMB_CONT_BYTE) 330074bb90dSTom Pothier idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 3)); 331074bb90dSTom Pothier else 332074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_INVAL)); 333074bb90dSTom Pothier } 334074bb90dSTom Pothier 335074bb90dSTom Pothier return (cnt); 336074bb90dSTom Pothier } 337074bb90dSTom Pothier 33884ab085aSmws id_t 33984ab085aSmws smbios_info_bios(smbios_hdl_t *shp, smbios_bios_t *bp) 34084ab085aSmws { 34184ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BIOS); 34284ab085aSmws const smb_bios_t *bip; 34384ab085aSmws 34484ab085aSmws if (stp == NULL) 34584ab085aSmws return (-1); /* errno is set for us */ 34684ab085aSmws 34784ab085aSmws if (stp->smbst_hdr->smbh_len < sizeof (smb_bios_t) - sizeof (uint8_t)) 34884ab085aSmws return (smb_set_errno(shp, ESMB_CORRUPT)); 34984ab085aSmws 35084ab085aSmws bip = (smb_bios_t *)(uintptr_t)stp->smbst_hdr; 351*38d76b18SRobert Mustacchi bzero(bp, sizeof (smb_base_bios_t)); 352*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31)) { 353*38d76b18SRobert Mustacchi bp->smbb_extromsize = 0; 354*38d76b18SRobert Mustacchi } 35584ab085aSmws 35684ab085aSmws bp->smbb_vendor = smb_strptr(stp, bip->smbbi_vendor); 35784ab085aSmws bp->smbb_version = smb_strptr(stp, bip->smbbi_version); 35884ab085aSmws bp->smbb_segment = bip->smbbi_segment; 35984ab085aSmws bp->smbb_reldate = smb_strptr(stp, bip->smbbi_reldate); 36084ab085aSmws bp->smbb_romsize = 64 * 1024 * ((uint32_t)bip->smbbi_romsize + 1); 36184ab085aSmws bp->smbb_runsize = 16 * (0x10000 - (uint32_t)bip->smbbi_segment); 36284ab085aSmws bp->smbb_cflags = bip->smbbi_cflags; 36384ab085aSmws 36484ab085aSmws /* 36584ab085aSmws * If one or more extension bytes are present, reset smbb_xcflags to 36684ab085aSmws * point to them. Otherwise leave this member set to NULL. 36784ab085aSmws */ 36884ab085aSmws if (stp->smbst_hdr->smbh_len >= sizeof (smb_bios_t)) { 36984ab085aSmws bp->smbb_xcflags = bip->smbbi_xcflags; 37084ab085aSmws bp->smbb_nxcflags = stp->smbst_hdr->smbh_len - 37184ab085aSmws sizeof (smb_bios_t) + 1; 37284ab085aSmws 37384ab085aSmws if (bp->smbb_nxcflags > SMB_BIOSXB_ECFW_MIN && 37484ab085aSmws smb_gteq(shp, SMB_VERSION_24)) { 37584ab085aSmws bp->smbb_biosv.smbv_major = 37684ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MAJ]; 37784ab085aSmws bp->smbb_biosv.smbv_minor = 37884ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MIN]; 37984ab085aSmws bp->smbb_ecfwv.smbv_major = 38084ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MAJ]; 38184ab085aSmws bp->smbb_ecfwv.smbv_minor = 38284ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MIN]; 38384ab085aSmws } 384*38d76b18SRobert Mustacchi 385*38d76b18SRobert Mustacchi if (bp->smbb_nxcflags > SMB_BIOSXB_EXTROM + 1 && 386*38d76b18SRobert Mustacchi smb_gteq(shp, SMB_VERSION_31)) { 387*38d76b18SRobert Mustacchi uint16_t val; 388*38d76b18SRobert Mustacchi uint64_t rs; 389*38d76b18SRobert Mustacchi 390*38d76b18SRobert Mustacchi /* 391*38d76b18SRobert Mustacchi * Because of the fact that the extended size is a 392*38d76b18SRobert Mustacchi * uint16_t and we'd need to define an explicit 393*38d76b18SRobert Mustacchi * endian-aware way to access it, we don't include it in 394*38d76b18SRobert Mustacchi * the number of extended flags below and thus subtract 395*38d76b18SRobert Mustacchi * its size. 396*38d76b18SRobert Mustacchi */ 397*38d76b18SRobert Mustacchi bp->smbb_nxcflags -= sizeof (uint16_t); 398*38d76b18SRobert Mustacchi bcopy(&bip->smbbi_xcflags[SMB_BIOSXB_EXTROM], &val, 399*38d76b18SRobert Mustacchi sizeof (val)); 400*38d76b18SRobert Mustacchi val = LE_16(val); 401*38d76b18SRobert Mustacchi 402*38d76b18SRobert Mustacchi /* 403*38d76b18SRobert Mustacchi * The upper two bits of the extended rom size are used 404*38d76b18SRobert Mustacchi * to indicate whether the other 14 bits are in MB or 405*38d76b18SRobert Mustacchi * GB. 406*38d76b18SRobert Mustacchi */ 407*38d76b18SRobert Mustacchi rs = SMB_BIOS_EXTROM_VALUE_MASK(val); 408*38d76b18SRobert Mustacchi switch (SMB_BIOS_EXTROM_SHIFT_MASK(val)) { 409*38d76b18SRobert Mustacchi case 0: 410*38d76b18SRobert Mustacchi rs *= 1024ULL * 1024ULL; 411*38d76b18SRobert Mustacchi break; 412*38d76b18SRobert Mustacchi case 1: 413*38d76b18SRobert Mustacchi rs *= 1024ULL * 1024ULL * 1024ULL; 414*38d76b18SRobert Mustacchi break; 415*38d76b18SRobert Mustacchi default: 416*38d76b18SRobert Mustacchi rs = 0; 417*38d76b18SRobert Mustacchi break; 418*38d76b18SRobert Mustacchi } 419*38d76b18SRobert Mustacchi 420*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31)) { 421*38d76b18SRobert Mustacchi bp->smbb_extromsize = rs; 422*38d76b18SRobert Mustacchi } 423*38d76b18SRobert Mustacchi } 424*38d76b18SRobert Mustacchi } 425*38d76b18SRobert Mustacchi 426*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31) && bp->smbb_extromsize == 0) { 427*38d76b18SRobert Mustacchi bp->smbb_extromsize = bp->smbb_romsize; 42884ab085aSmws } 42984ab085aSmws 43084ab085aSmws return (stp->smbst_hdr->smbh_hdl); 43184ab085aSmws } 43284ab085aSmws 43384ab085aSmws id_t 43484ab085aSmws smbios_info_system(smbios_hdl_t *shp, smbios_system_t *sip) 43584ab085aSmws { 43684ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM); 43784ab085aSmws smb_system_t si; 43884ab085aSmws 43984ab085aSmws if (stp == NULL) 44084ab085aSmws return (-1); /* errno is set for us */ 44184ab085aSmws 44284ab085aSmws smb_info_bcopy(stp->smbst_hdr, &si, sizeof (si)); 44384ab085aSmws bzero(sip, sizeof (smbios_system_t)); 44484ab085aSmws 44584ab085aSmws sip->smbs_uuid = ((smb_system_t *)stp->smbst_hdr)->smbsi_uuid; 44684ab085aSmws sip->smbs_uuidlen = sizeof (si.smbsi_uuid); 44784ab085aSmws sip->smbs_wakeup = si.smbsi_wakeup; 44884ab085aSmws sip->smbs_sku = smb_strptr(stp, si.smbsi_sku); 44984ab085aSmws sip->smbs_family = smb_strptr(stp, si.smbsi_family); 45084ab085aSmws 45184ab085aSmws return (stp->smbst_hdr->smbh_hdl); 45284ab085aSmws } 45384ab085aSmws 45484ab085aSmws int 45584ab085aSmws smbios_info_bboard(smbios_hdl_t *shp, id_t id, smbios_bboard_t *bbp) 45684ab085aSmws { 45784ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 45884ab085aSmws smb_bboard_t bb; 45984ab085aSmws 46084ab085aSmws if (stp == NULL) 46184ab085aSmws return (-1); /* errno is set for us */ 46284ab085aSmws 46384ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_BASEBOARD) 46484ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 46584ab085aSmws 46684ab085aSmws smb_info_bcopy(stp->smbst_hdr, &bb, sizeof (bb)); 46784ab085aSmws bzero(bbp, sizeof (smbios_bboard_t)); 46884ab085aSmws 46984ab085aSmws bbp->smbb_chassis = bb.smbbb_chassis; 47084ab085aSmws bbp->smbb_flags = bb.smbbb_flags; 47184ab085aSmws bbp->smbb_type = bb.smbbb_type; 472074bb90dSTom Pothier bbp->smbb_contn = bb.smbbb_cn; 47384ab085aSmws 47484ab085aSmws return (0); 47584ab085aSmws } 47684ab085aSmws 47784ab085aSmws int 47884ab085aSmws smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp) 47984ab085aSmws { 48084ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 4814e901881SDale Ghent /* Length is measurable by one byte, so it'll be no more than 255. */ 4824e901881SDale Ghent uint8_t buf[256]; 4834e901881SDale Ghent smb_chassis_t *ch = (smb_chassis_t *)&buf[0]; 48484ab085aSmws 48584ab085aSmws if (stp == NULL) 48684ab085aSmws return (-1); /* errno is set for us */ 48784ab085aSmws 48884ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS) 48984ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 49084ab085aSmws 4914e901881SDale Ghent smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf)); 4926734c4b0SRobert Mustacchi bzero(chp, sizeof (smb_base_chassis_t)); 493*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_27)) { 4946734c4b0SRobert Mustacchi bzero(chp->smbc_sku, sizeof (chp->smbc_sku)); 4956734c4b0SRobert Mustacchi } 49684ab085aSmws 4974e901881SDale Ghent chp->smbc_oemdata = ch->smbch_oemdata; 4984e901881SDale Ghent chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0; 4994e901881SDale Ghent chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK; 5004e901881SDale Ghent chp->smbc_bustate = ch->smbch_bustate; 5014e901881SDale Ghent chp->smbc_psstate = ch->smbch_psstate; 5024e901881SDale Ghent chp->smbc_thstate = ch->smbch_thstate; 5034e901881SDale Ghent chp->smbc_security = ch->smbch_security; 5044e901881SDale Ghent chp->smbc_uheight = ch->smbch_uheight; 5054e901881SDale Ghent chp->smbc_cords = ch->smbch_cords; 5064e901881SDale Ghent chp->smbc_elems = ch->smbch_cn; 5074e901881SDale Ghent chp->smbc_elemlen = ch->smbch_cm; 5084e901881SDale Ghent 509*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_27)) { 5104e901881SDale Ghent (void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch), 5114e901881SDale Ghent sizeof (chp->smbc_sku)); 5124e901881SDale Ghent } 51384ab085aSmws 51484ab085aSmws return (0); 51584ab085aSmws } 51684ab085aSmws 51784ab085aSmws int 51884ab085aSmws smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp) 51984ab085aSmws { 52084ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 52184ab085aSmws smb_processor_t p; 52284ab085aSmws 52384ab085aSmws if (stp == NULL) 52484ab085aSmws return (-1); /* errno is set for us */ 52584ab085aSmws 52684ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_PROCESSOR) 52784ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 52884ab085aSmws 52984ab085aSmws smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p)); 5306734c4b0SRobert Mustacchi bzero(pp, sizeof (smb_base_processor_t)); 53184ab085aSmws 53284ab085aSmws pp->smbp_cpuid = p.smbpr_cpuid; 53384ab085aSmws pp->smbp_type = p.smbpr_type; 53484ab085aSmws pp->smbp_family = p.smbpr_family; 53584ab085aSmws pp->smbp_voltage = p.smbpr_voltage; 53684ab085aSmws pp->smbp_maxspeed = p.smbpr_maxspeed; 53784ab085aSmws pp->smbp_curspeed = p.smbpr_curspeed; 53884ab085aSmws pp->smbp_status = p.smbpr_status; 53984ab085aSmws pp->smbp_upgrade = p.smbpr_upgrade; 54084ab085aSmws pp->smbp_l1cache = p.smbpr_l1cache; 54184ab085aSmws pp->smbp_l2cache = p.smbpr_l2cache; 54284ab085aSmws pp->smbp_l3cache = p.smbpr_l3cache; 54384ab085aSmws 544*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_25)) { 5454e901881SDale Ghent pp->smbp_corecount = p.smbpr_corecount; 5464e901881SDale Ghent pp->smbp_coresenabled = p.smbpr_coresenabled; 5474e901881SDale Ghent pp->smbp_threadcount = p.smbpr_threadcount; 5484e901881SDale Ghent pp->smbp_cflags = p.smbpr_cflags; 5494e901881SDale Ghent } 5504e901881SDale Ghent 551*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_26)) { 5524e901881SDale Ghent pp->smbp_family2 = p.smbpr_family2; 553*38d76b18SRobert Mustacchi } 5544e901881SDale Ghent 555*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_30)) { 5566734c4b0SRobert Mustacchi pp->smbp_corecount2 = p.smbpr_corecount2; 5576734c4b0SRobert Mustacchi pp->smbp_coresenabled2 = p.smbpr_coresenabled2; 5586734c4b0SRobert Mustacchi pp->smbp_threadcount2 = p.smbpr_threadcount2; 5596734c4b0SRobert Mustacchi } 5606734c4b0SRobert Mustacchi 56184ab085aSmws return (0); 56284ab085aSmws } 56384ab085aSmws 56484ab085aSmws int 56584ab085aSmws smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap) 56684ab085aSmws { 56784ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 56884ab085aSmws smb_cache_t c; 56984ab085aSmws 57084ab085aSmws if (stp == NULL) 57184ab085aSmws return (-1); /* errno is set for us */ 57284ab085aSmws 57384ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_CACHE) 57484ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 57584ab085aSmws 57684ab085aSmws smb_info_bcopy(stp->smbst_hdr, &c, sizeof (c)); 577*38d76b18SRobert Mustacchi bzero(cap, sizeof (smb_base_cache_t)); 57884ab085aSmws 57984ab085aSmws cap->smba_maxsize = SMB_CACHE_SIZE(c.smbca_maxsize); 58084ab085aSmws cap->smba_size = SMB_CACHE_SIZE(c.smbca_size); 58184ab085aSmws cap->smba_stype = c.smbca_stype; 58284ab085aSmws cap->smba_ctype = c.smbca_ctype; 58384ab085aSmws cap->smba_speed = c.smbca_speed; 58484ab085aSmws cap->smba_etype = c.smbca_etype; 58584ab085aSmws cap->smba_ltype = c.smbca_ltype; 58684ab085aSmws cap->smba_assoc = c.smbca_assoc; 58784ab085aSmws cap->smba_level = SMB_CACHE_CFG_LEVEL(c.smbca_config); 58884ab085aSmws cap->smba_mode = SMB_CACHE_CFG_MODE(c.smbca_config); 58984ab085aSmws cap->smba_location = SMB_CACHE_CFG_LOCATION(c.smbca_config); 59084ab085aSmws 59184ab085aSmws if (SMB_CACHE_CFG_ENABLED(c.smbca_config)) 59284ab085aSmws cap->smba_flags |= SMB_CAF_ENABLED; 59384ab085aSmws 59484ab085aSmws if (SMB_CACHE_CFG_SOCKETED(c.smbca_config)) 59584ab085aSmws cap->smba_flags |= SMB_CAF_SOCKETED; 59684ab085aSmws 597*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31)) { 598*38d76b18SRobert Mustacchi if (smb_gteq(shp, SMB_VERSION_31)) { 599*38d76b18SRobert Mustacchi cap->smba_maxsize2 = 600*38d76b18SRobert Mustacchi SMB_CACHE_EXT_SIZE(c.smbca_maxsize2); 601*38d76b18SRobert Mustacchi cap->smba_size2 = SMB_CACHE_EXT_SIZE(c.smbca_size2); 602*38d76b18SRobert Mustacchi } else { 603*38d76b18SRobert Mustacchi cap->smba_maxsize2 = cap->smba_maxsize; 604*38d76b18SRobert Mustacchi cap->smba_size2 = cap->smba_size; 605*38d76b18SRobert Mustacchi } 606*38d76b18SRobert Mustacchi } 607*38d76b18SRobert Mustacchi 60884ab085aSmws return (0); 60984ab085aSmws } 61084ab085aSmws 61184ab085aSmws int 61284ab085aSmws smbios_info_port(smbios_hdl_t *shp, id_t id, smbios_port_t *pop) 61384ab085aSmws { 61484ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 61584ab085aSmws smb_port_t p; 61684ab085aSmws 61784ab085aSmws if (stp == NULL) 61884ab085aSmws return (-1); /* errno is set for us */ 61984ab085aSmws 62084ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_PORT) 62184ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 62284ab085aSmws 62384ab085aSmws smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p)); 62484ab085aSmws bzero(pop, sizeof (smbios_port_t)); 62584ab085aSmws 62684ab085aSmws pop->smbo_iref = smb_strptr(stp, p.smbpo_iref); 62784ab085aSmws pop->smbo_eref = smb_strptr(stp, p.smbpo_eref); 62884ab085aSmws 62984ab085aSmws pop->smbo_itype = p.smbpo_itype; 63084ab085aSmws pop->smbo_etype = p.smbpo_etype; 63184ab085aSmws pop->smbo_ptype = p.smbpo_ptype; 63284ab085aSmws 63384ab085aSmws return (0); 63484ab085aSmws } 63584ab085aSmws 63684ab085aSmws int 63784ab085aSmws smbios_info_slot(smbios_hdl_t *shp, id_t id, smbios_slot_t *sp) 63884ab085aSmws { 63984ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 64084ab085aSmws smb_slot_t s; 64184ab085aSmws 64284ab085aSmws if (stp == NULL) 64384ab085aSmws return (-1); /* errno is set for us */ 64484ab085aSmws 64584ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT) 64684ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 64784ab085aSmws 64884ab085aSmws smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 64984ab085aSmws bzero(sp, sizeof (smbios_slot_t)); 65084ab085aSmws 65184ab085aSmws sp->smbl_name = smb_strptr(stp, s.smbsl_name); 65284ab085aSmws sp->smbl_type = s.smbsl_type; 65384ab085aSmws sp->smbl_width = s.smbsl_width; 65484ab085aSmws sp->smbl_usage = s.smbsl_usage; 65584ab085aSmws sp->smbl_length = s.smbsl_length; 65684ab085aSmws sp->smbl_id = s.smbsl_id; 65784ab085aSmws sp->smbl_ch1 = s.smbsl_ch1; 65884ab085aSmws sp->smbl_ch2 = s.smbsl_ch2; 65903f9f63dSTom Pothier sp->smbl_sg = s.smbsl_sg; 66003f9f63dSTom Pothier sp->smbl_bus = s.smbsl_bus; 66103f9f63dSTom Pothier sp->smbl_df = s.smbsl_df; 66203f9f63dSTom Pothier 66303f9f63dSTom Pothier return (0); 66403f9f63dSTom Pothier } 66503f9f63dSTom Pothier 66603f9f63dSTom Pothier int 66703f9f63dSTom Pothier smbios_info_obdevs_ext(smbios_hdl_t *shp, id_t id, smbios_obdev_ext_t *oep) 66803f9f63dSTom Pothier { 66903f9f63dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 67003f9f63dSTom Pothier smb_obdev_ext_t obe; 67103f9f63dSTom Pothier 67203f9f63dSTom Pothier if (stp == NULL) 67303f9f63dSTom Pothier return (-1); /* errno is set for us */ 67403f9f63dSTom Pothier 67503f9f63dSTom Pothier if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVEXT) 67603f9f63dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 67703f9f63dSTom Pothier 67803f9f63dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &obe, sizeof (obe)); 67903f9f63dSTom Pothier bzero(oep, sizeof (smbios_obdev_ext_t)); 68003f9f63dSTom Pothier 68103f9f63dSTom Pothier oep->smboe_name = smb_strptr(stp, obe.smbobe_name); 68203f9f63dSTom Pothier oep->smboe_dtype = obe.smbobe_dtype; 68303f9f63dSTom Pothier oep->smboe_dti = obe.smbobe_dti; 68403f9f63dSTom Pothier oep->smboe_sg = obe.smbobe_sg; 68503f9f63dSTom Pothier oep->smboe_bus = obe.smbobe_bus; 68603f9f63dSTom Pothier oep->smboe_df = obe.smbobe_df; 68784ab085aSmws 68884ab085aSmws return (0); 68984ab085aSmws } 69084ab085aSmws 69184ab085aSmws int 69284ab085aSmws smbios_info_obdevs(smbios_hdl_t *shp, id_t id, int obc, smbios_obdev_t *obp) 69384ab085aSmws { 69484ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 69584ab085aSmws const smb_obdev_t *op; 69684ab085aSmws int i, m, n; 69784ab085aSmws 69884ab085aSmws if (stp == NULL) 69984ab085aSmws return (-1); /* errno is set for us */ 70084ab085aSmws 70184ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVS) 70284ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 70384ab085aSmws 70484ab085aSmws op = (smb_obdev_t *)((uintptr_t)stp->smbst_hdr + sizeof (smb_header_t)); 70584ab085aSmws m = (stp->smbst_hdr->smbh_len - sizeof (smb_header_t)) / sizeof (*op); 70684ab085aSmws n = MIN(m, obc); 70784ab085aSmws 70884ab085aSmws for (i = 0; i < n; i++, op++, obp++) { 70984ab085aSmws obp->smbd_name = smb_strptr(stp, op->smbob_name); 71084ab085aSmws obp->smbd_type = op->smbob_type & ~SMB_OBT_ENABLED; 71184ab085aSmws obp->smbd_enabled = (op->smbob_type & SMB_OBT_ENABLED) != 0; 71284ab085aSmws } 71384ab085aSmws 71484ab085aSmws return (m); 71584ab085aSmws } 71684ab085aSmws 71784ab085aSmws /* 71884ab085aSmws * The implementation structures for OEMSTR, SYSCONFSTR, and LANG all use the 71984ab085aSmws * first byte to indicate the size of a string table at the end of the record. 72084ab085aSmws * Therefore, smbios_info_strtab() can be used to retrieve the table size and 72184ab085aSmws * strings for any of these underlying record types. 72284ab085aSmws */ 72384ab085aSmws int 72484ab085aSmws smbios_info_strtab(smbios_hdl_t *shp, id_t id, int argc, const char *argv[]) 72584ab085aSmws { 72684ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 72784ab085aSmws smb_strtab_t s; 72884ab085aSmws int i, n; 72984ab085aSmws 73084ab085aSmws if (stp == NULL) 73184ab085aSmws return (-1); /* errno is set for us */ 73284ab085aSmws 73384ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR && 73484ab085aSmws stp->smbst_hdr->smbh_type != SMB_TYPE_SYSCONFSTR && 73584ab085aSmws stp->smbst_hdr->smbh_type != SMB_TYPE_LANG) 73684ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 73784ab085aSmws 73884ab085aSmws smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 73984ab085aSmws n = MIN(s.smbtb_count, argc); 74084ab085aSmws 74184ab085aSmws for (i = 0; i < n; i++) 74284ab085aSmws argv[i] = smb_strptr(stp, i + 1); 74384ab085aSmws 74484ab085aSmws return (s.smbtb_count); 74584ab085aSmws } 74684ab085aSmws 74784ab085aSmws id_t 74884ab085aSmws smbios_info_lang(smbios_hdl_t *shp, smbios_lang_t *lp) 74984ab085aSmws { 75084ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_LANG); 75184ab085aSmws smb_lang_t l; 75284ab085aSmws 75384ab085aSmws if (stp == NULL) 75484ab085aSmws return (-1); /* errno is set for us */ 75584ab085aSmws 75684ab085aSmws smb_info_bcopy(stp->smbst_hdr, &l, sizeof (l)); 75784ab085aSmws bzero(lp, sizeof (smbios_lang_t)); 75884ab085aSmws 75984ab085aSmws lp->smbla_cur = smb_strptr(stp, l.smblang_cur); 76084ab085aSmws lp->smbla_fmt = l.smblang_flags & 1; 76184ab085aSmws lp->smbla_num = l.smblang_num; 76284ab085aSmws 76384ab085aSmws return (stp->smbst_hdr->smbh_hdl); 76484ab085aSmws } 76584ab085aSmws 76684ab085aSmws id_t 76784ab085aSmws smbios_info_eventlog(smbios_hdl_t *shp, smbios_evlog_t *evp) 76884ab085aSmws { 76984ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_EVENTLOG); 77084ab085aSmws const smb_sel_t *sel; 77184ab085aSmws size_t len; 77284ab085aSmws 77384ab085aSmws if (stp == NULL) 77484ab085aSmws return (-1); /* errno is set for us */ 77584ab085aSmws 77684ab085aSmws if (stp->smbst_hdr->smbh_len < sizeof (smb_sel_t) - sizeof (uint8_t)) 77784ab085aSmws return (smb_set_errno(shp, ESMB_CORRUPT)); 77884ab085aSmws 77984ab085aSmws sel = (smb_sel_t *)(uintptr_t)stp->smbst_hdr; 78084ab085aSmws len = stp->smbst_hdr->smbh_len - sizeof (smb_sel_t) + sizeof (uint8_t); 78184ab085aSmws bzero(evp, sizeof (smbios_evlog_t)); 78284ab085aSmws 78384ab085aSmws if (len < sel->smbsel_typec * sel->smbsel_typesz) 78484ab085aSmws return (smb_set_errno(shp, ESMB_CORRUPT)); 78584ab085aSmws 78684ab085aSmws evp->smbev_size = sel->smbsel_len; 78784ab085aSmws evp->smbev_hdr = sel->smbsel_hdroff; 78884ab085aSmws evp->smbev_data = sel->smbsel_dataoff; 78984ab085aSmws evp->smbev_method = sel->smbsel_method; 79084ab085aSmws evp->smbev_flags = sel->smbsel_status; 79184ab085aSmws evp->smbev_format = sel->smbsel_format; 79284ab085aSmws evp->smbev_token = sel->smbsel_token; 79384ab085aSmws evp->smbev_addr.eva_addr = sel->smbsel_addr; 79484ab085aSmws 79584ab085aSmws if (sel->smbsel_typesz == sizeof (smbios_evtype_t)) { 79684ab085aSmws evp->smbev_typec = sel->smbsel_typec; 79784ab085aSmws evp->smbev_typev = (void *)(uintptr_t)sel->smbsel_typev; 79884ab085aSmws } 79984ab085aSmws 80084ab085aSmws return (stp->smbst_hdr->smbh_hdl); 80184ab085aSmws } 80284ab085aSmws 80384ab085aSmws int 80484ab085aSmws smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map) 80584ab085aSmws { 80684ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 80784ab085aSmws smb_memarray_t m; 80884ab085aSmws 80984ab085aSmws if (stp == NULL) 81084ab085aSmws return (-1); /* errno is set for us */ 81184ab085aSmws 81284ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAY) 81384ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 81484ab085aSmws 81584ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 81684ab085aSmws bzero(map, sizeof (smbios_memarray_t)); 81784ab085aSmws 81884ab085aSmws map->smbma_location = m.smbmarr_loc; 81984ab085aSmws map->smbma_use = m.smbmarr_use; 82084ab085aSmws map->smbma_ecc = m.smbmarr_ecc; 82184ab085aSmws map->smbma_ndevs = m.smbmarr_ndevs; 82284ab085aSmws map->smbma_err = m.smbmarr_err; 82384ab085aSmws 82484ab085aSmws if (m.smbmarr_cap != 0x80000000) 82584ab085aSmws map->smbma_size = (uint64_t)m.smbmarr_cap * 1024; 8264e901881SDale Ghent else if (m.smbmarr_extcap != 0) 8274e901881SDale Ghent map->smbma_size = m.smbmarr_extcap; 82884ab085aSmws else 82984ab085aSmws map->smbma_size = 0; /* unknown */ 83084ab085aSmws 83184ab085aSmws return (0); 83284ab085aSmws } 83384ab085aSmws 83484ab085aSmws int 83584ab085aSmws smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map) 83684ab085aSmws { 83784ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 83884ab085aSmws smb_memarrmap_t m; 83984ab085aSmws 84084ab085aSmws if (stp == NULL) 84184ab085aSmws return (-1); /* errno is set for us */ 84284ab085aSmws 84384ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP) 84484ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 84584ab085aSmws 84684ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 84784ab085aSmws bzero(map, sizeof (smbios_memarrmap_t)); 84884ab085aSmws 84984ab085aSmws map->smbmam_array = m.smbamap_array; 85084ab085aSmws map->smbmam_width = m.smbamap_width; 8514e901881SDale Ghent 8524e901881SDale Ghent if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) { 85384ab085aSmws map->smbmam_addr = (uint64_t)m.smbamap_start * 1024; 85484ab085aSmws map->smbmam_size = (uint64_t) 85584ab085aSmws (m.smbamap_end - m.smbamap_start + 1) * 1024; 8564e901881SDale Ghent } else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) { 8574e901881SDale Ghent map->smbmam_addr = m.smbamap_extstart; 8584e901881SDale Ghent map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1; 8594e901881SDale Ghent } 86084ab085aSmws 86184ab085aSmws return (0); 86284ab085aSmws } 86384ab085aSmws 86484ab085aSmws int 86584ab085aSmws smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp) 86684ab085aSmws { 86784ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 86884ab085aSmws smb_memdevice_t m; 86984ab085aSmws 87084ab085aSmws if (stp == NULL) 87184ab085aSmws return (-1); /* errno is set for us */ 87284ab085aSmws 87384ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICE) 87484ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 87584ab085aSmws 87684ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 8776734c4b0SRobert Mustacchi bzero(mdp, sizeof (smb_base_memdevice_t)); 87884ab085aSmws 87984ab085aSmws mdp->smbmd_array = m.smbmdev_array; 88084ab085aSmws mdp->smbmd_error = m.smbmdev_error; 88184ab085aSmws mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth; 88284ab085aSmws mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth; 88384ab085aSmws 8844e901881SDale Ghent if (m.smbmdev_size == 0x7FFF) { 8854e901881SDale Ghent mdp->smbmd_size = (uint64_t)m.smbmdev_extsize; 8864e901881SDale Ghent mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */ 8874e901881SDale Ghent } else if (m.smbmdev_size != 0xFFFF) { 88884ab085aSmws mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES); 88984ab085aSmws if (m.smbmdev_size & SMB_MDS_KBYTES) 89084ab085aSmws mdp->smbmd_size *= 1024; 89184ab085aSmws else 89284ab085aSmws mdp->smbmd_size *= 1024 * 1024; 89384ab085aSmws } else 89484ab085aSmws mdp->smbmd_size = -1ULL; /* size unknown */ 89584ab085aSmws 89684ab085aSmws mdp->smbmd_form = m.smbmdev_form; 89784ab085aSmws mdp->smbmd_set = m.smbmdev_set; 89884ab085aSmws mdp->smbmd_type = m.smbmdev_type; 8994e901881SDale Ghent mdp->smbmd_speed = m.smbmdev_speed; 90084ab085aSmws mdp->smbmd_flags = m.smbmdev_flags; 90184ab085aSmws mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc); 90284ab085aSmws mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc); 90384ab085aSmws 904*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_26)) { 9054e901881SDale Ghent mdp->smbmd_rank = m.smbmdev_attrs & 0x0F; 906*38d76b18SRobert Mustacchi } 9074e901881SDale Ghent 908*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_27)) { 9094e901881SDale Ghent mdp->smbmd_clkspeed = m.smbmdev_clkspeed; 910*38d76b18SRobert Mustacchi } 9114e901881SDale Ghent 912*38d76b18SRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_28)) { 9134e901881SDale Ghent mdp->smbmd_minvolt = m.smbmdev_minvolt; 9144e901881SDale Ghent mdp->smbmd_maxvolt = m.smbmdev_maxvolt; 9154e901881SDale Ghent mdp->smbmd_confvolt = m.smbmdev_confvolt; 9164e901881SDale Ghent } 91784ab085aSmws 91884ab085aSmws return (0); 91984ab085aSmws } 92084ab085aSmws 92184ab085aSmws int 92284ab085aSmws smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp) 92384ab085aSmws { 92484ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 92584ab085aSmws smb_memdevmap_t m; 92684ab085aSmws 92784ab085aSmws if (stp == NULL) 92884ab085aSmws return (-1); /* errno is set for us */ 92984ab085aSmws 93084ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP) 93184ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 93284ab085aSmws 93384ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 93484ab085aSmws bzero(mdp, sizeof (smbios_memdevmap_t)); 93584ab085aSmws 93684ab085aSmws mdp->smbmdm_device = m.smbdmap_device; 93784ab085aSmws mdp->smbmdm_arrmap = m.smbdmap_array; 93884ab085aSmws mdp->smbmdm_rpos = m.smbdmap_rpos; 93984ab085aSmws mdp->smbmdm_ipos = m.smbdmap_ipos; 94084ab085aSmws mdp->smbmdm_idepth = m.smbdmap_idepth; 94184ab085aSmws 9424e901881SDale Ghent if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) { 9434e901881SDale Ghent mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024; 9444e901881SDale Ghent mdp->smbmdm_size = (uint64_t) 9454e901881SDale Ghent (m.smbdmap_end - m.smbdmap_start + 1) * 1024; 9464e901881SDale Ghent } else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) { 9474e901881SDale Ghent mdp->smbmdm_addr = m.smbdmap_extstart; 9484e901881SDale Ghent mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1; 9494e901881SDale Ghent } 9504e901881SDale Ghent 95184ab085aSmws return (0); 95284ab085aSmws } 95384ab085aSmws 95484ab085aSmws id_t 95584ab085aSmws smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp) 95684ab085aSmws { 95784ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY); 95884ab085aSmws smb_hwsec_t hs; 95984ab085aSmws 96084ab085aSmws if (stp == NULL) 96184ab085aSmws return (-1); /* errno is set for us */ 96284ab085aSmws 96384ab085aSmws smb_info_bcopy(stp->smbst_hdr, &hs, sizeof (hs)); 96484ab085aSmws bzero(hsp, sizeof (smbios_hwsec_t)); 96584ab085aSmws 96684ab085aSmws hsp->smbh_pwr_ps = SMB_HWS_PWR_PS(hs.smbhs_settings); 96784ab085aSmws hsp->smbh_kbd_ps = SMB_HWS_KBD_PS(hs.smbhs_settings); 96884ab085aSmws hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings); 96984ab085aSmws hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings); 97084ab085aSmws 97184ab085aSmws return (stp->smbst_hdr->smbh_hdl); 97284ab085aSmws } 97384ab085aSmws 97484ab085aSmws id_t 97584ab085aSmws smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp) 97684ab085aSmws { 97784ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT); 97884ab085aSmws const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr; 97984ab085aSmws 98084ab085aSmws if (stp == NULL) 98184ab085aSmws return (-1); /* errno is set for us */ 98284ab085aSmws 98384ab085aSmws bzero(bp, sizeof (smbios_boot_t)); 98484ab085aSmws 98584ab085aSmws bp->smbt_status = b->smbbo_status[0]; 98684ab085aSmws bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t); 98784ab085aSmws bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL; 98884ab085aSmws 98984ab085aSmws return (stp->smbst_hdr->smbh_hdl); 99084ab085aSmws } 99184ab085aSmws 99284ab085aSmws id_t 99384ab085aSmws smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip) 99484ab085aSmws { 99584ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_IPMIDEV); 99684ab085aSmws smb_ipmi_t i; 99784ab085aSmws 99884ab085aSmws if (stp == NULL) 99984ab085aSmws return (-1); /* errno is set for us */ 100084ab085aSmws 100184ab085aSmws smb_info_bcopy(stp->smbst_hdr, &i, sizeof (i)); 100284ab085aSmws bzero(ip, sizeof (smbios_ipmi_t)); 100384ab085aSmws 100484ab085aSmws ip->smbip_type = i.smbipm_type; 100584ab085aSmws ip->smbip_vers.smbv_major = SMB_IPM_SPEC_MAJOR(i.smbipm_spec); 100684ab085aSmws ip->smbip_vers.smbv_minor = SMB_IPM_SPEC_MINOR(i.smbipm_spec); 100784ab085aSmws ip->smbip_i2c = i.smbipm_i2c; 100884ab085aSmws ip->smbip_addr = i.smbipm_addr & ~SMB_IPM_ADDR_IO; 100984ab085aSmws ip->smbip_intr = i.smbipm_intr; 101084ab085aSmws 101184ab085aSmws if (i.smbipm_bus != (uint8_t)-1) 101284ab085aSmws ip->smbip_bus = i.smbipm_bus; 101384ab085aSmws else 101484ab085aSmws ip->smbip_bus = -1u; 101584ab085aSmws 101684ab085aSmws if (SMB_IPM_INFO_LSB(i.smbipm_info)) 101784ab085aSmws ip->smbip_addr |= 1; /* turn on least-significant bit of addr */ 101884ab085aSmws 101984ab085aSmws if (i.smbipm_addr & SMB_IPM_ADDR_IO) { 102084ab085aSmws switch (SMB_IPM_INFO_REGS(i.smbipm_info)) { 102184ab085aSmws case SMB_IPM_REGS_1B: 102284ab085aSmws ip->smbip_regspacing = 1; 102384ab085aSmws break; 102484ab085aSmws case SMB_IPM_REGS_4B: 102584ab085aSmws ip->smbip_regspacing = 4; 102684ab085aSmws break; 102784ab085aSmws case SMB_IPM_REGS_16B: 102884ab085aSmws ip->smbip_regspacing = 16; 102984ab085aSmws break; 103084ab085aSmws default: 103184ab085aSmws ip->smbip_regspacing = 1; 103284ab085aSmws } 103384ab085aSmws ip->smbip_flags |= SMB_IPMI_F_IOADDR; 103484ab085aSmws } 103584ab085aSmws 103684ab085aSmws if (SMB_IPM_INFO_ISPEC(i.smbipm_info)) 103784ab085aSmws ip->smbip_flags |= SMB_IPMI_F_INTRSPEC; 103884ab085aSmws 103984ab085aSmws if (SMB_IPM_INFO_IPOL(i.smbipm_info) == SMB_IPM_IPOL_HI) 104084ab085aSmws ip->smbip_flags |= SMB_IPMI_F_INTRHIGH; 104184ab085aSmws 104284ab085aSmws if (SMB_IPM_INFO_IMODE(i.smbipm_info) == SMB_IPM_IMODE_EDGE) 104384ab085aSmws ip->smbip_flags |= SMB_IPMI_F_INTREDGE; 104484ab085aSmws 104584ab085aSmws return (stp->smbst_hdr->smbh_hdl); 104684ab085aSmws } 10479c94f155SCheng Sean Ye 10489c94f155SCheng Sean Ye static boolean_t 10499c94f155SCheng Sean Ye smbios_has_oemstr(smbios_hdl_t *shp, const char *oemstr) 10509c94f155SCheng Sean Ye { 10519c94f155SCheng Sean Ye const smb_struct_t *stp = shp->sh_structs; 10529c94f155SCheng Sean Ye smb_strtab_t s; 10539c94f155SCheng Sean Ye int i, j; 10549c94f155SCheng Sean Ye 10559c94f155SCheng Sean Ye for (i = 0; i < shp->sh_nstructs; i++, stp++) { 10569c94f155SCheng Sean Ye if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR) 10579c94f155SCheng Sean Ye continue; 10589c94f155SCheng Sean Ye 10599c94f155SCheng Sean Ye smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 10609c94f155SCheng Sean Ye for (j = 0; j < s.smbtb_count; j++) 10619c94f155SCheng Sean Ye if (strcmp(smb_strptr(stp, j + 1), oemstr) == 0) 10629c94f155SCheng Sean Ye return (B_TRUE); 10639c94f155SCheng Sean Ye } 10649c94f155SCheng Sean Ye 10659c94f155SCheng Sean Ye return (B_FALSE); 10669c94f155SCheng Sean Ye } 10679c94f155SCheng Sean Ye 10689c94f155SCheng Sean Ye static const char * 10699c94f155SCheng Sean Ye smb_serial_valid(const char *serial) 10709c94f155SCheng Sean Ye { 10719c94f155SCheng Sean Ye char buf[MAXNAMELEN]; 10729c94f155SCheng Sean Ye int i = 0; 10739c94f155SCheng Sean Ye 10749c94f155SCheng Sean Ye if (serial == NULL) 10759c94f155SCheng Sean Ye return (NULL); 10769c94f155SCheng Sean Ye 10779c94f155SCheng Sean Ye (void) strlcpy(buf, serial, sizeof (buf)); 10789c94f155SCheng Sean Ye 10799c94f155SCheng Sean Ye while (buf[i] != '\0' && buf[i] == ' ') 10809c94f155SCheng Sean Ye i++; 10819c94f155SCheng Sean Ye 10829c94f155SCheng Sean Ye if (buf[i] == '\0' || strstr(buf, SMB_DEFAULT1) != NULL || 10839c94f155SCheng Sean Ye strstr(buf, SMB_DEFAULT2) != NULL) 10849c94f155SCheng Sean Ye return (NULL); 10859c94f155SCheng Sean Ye 10869c94f155SCheng Sean Ye return (serial); 10879c94f155SCheng Sean Ye } 10889c94f155SCheng Sean Ye 10899c94f155SCheng Sean Ye /* 10909c94f155SCheng Sean Ye * Get chassis SN or product SN 10919c94f155SCheng Sean Ye */ 10929c94f155SCheng Sean Ye static int 10939c94f155SCheng Sean Ye smb_get_sn(smbios_hdl_t *shp, const char **psnp, const char **csnp) 10949c94f155SCheng Sean Ye { 10959c94f155SCheng Sean Ye const smb_struct_t *stp; 10969c94f155SCheng Sean Ye smbios_info_t s1, s3; 10979c94f155SCheng Sean Ye 10989c94f155SCheng Sean Ye if (psnp == NULL || csnp == NULL) 10999c94f155SCheng Sean Ye return (smb_set_errno(shp, ESMB_INVAL)); 11009c94f155SCheng Sean Ye 11019c94f155SCheng Sean Ye *psnp = *csnp = NULL; 11029c94f155SCheng Sean Ye 11039c94f155SCheng Sean Ye /* 11049c94f155SCheng Sean Ye * If SMBIOS meets Sun's PRMS requirements, retrieve product SN 11059c94f155SCheng Sean Ye * from type 1 structure, and chassis SN from type 3 structure. 11069c94f155SCheng Sean Ye * Otherwise return SN in type 1 structure as chassis SN. 11079c94f155SCheng Sean Ye */ 11089c94f155SCheng Sean Ye 11099c94f155SCheng Sean Ye /* Get type 1 SN */ 11109c94f155SCheng Sean Ye if ((stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM)) == NULL || 11119c94f155SCheng Sean Ye smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s1) == SMB_ERR) 11129c94f155SCheng Sean Ye s1.smbi_serial = NULL; 11139c94f155SCheng Sean Ye 11149c94f155SCheng Sean Ye /* Get type 3 SN */ 11159c94f155SCheng Sean Ye if ((stp = smb_lookup_type(shp, SMB_TYPE_CHASSIS)) == NULL || 11169c94f155SCheng Sean Ye smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s3) == SMB_ERR) 11179c94f155SCheng Sean Ye s3.smbi_serial = NULL; 11189c94f155SCheng Sean Ye 11199c94f155SCheng Sean Ye if (smbios_has_oemstr(shp, SMB_PRMS1)) { 11209c94f155SCheng Sean Ye *psnp = smb_serial_valid(s1.smbi_serial); 11219c94f155SCheng Sean Ye *csnp = smb_serial_valid(s3.smbi_serial); 11229c94f155SCheng Sean Ye } else { 11239c94f155SCheng Sean Ye *csnp = smb_serial_valid(s1.smbi_serial); 11249c94f155SCheng Sean Ye } 11259c94f155SCheng Sean Ye 11269c94f155SCheng Sean Ye return (0); 11279c94f155SCheng Sean Ye } 11289c94f155SCheng Sean Ye 11299c94f155SCheng Sean Ye const char * 11309c94f155SCheng Sean Ye smbios_psn(smbios_hdl_t *shp) 11319c94f155SCheng Sean Ye { 11329c94f155SCheng Sean Ye const char *psn, *csn; 11339c94f155SCheng Sean Ye 11349c94f155SCheng Sean Ye return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : psn); 11359c94f155SCheng Sean Ye } 11369c94f155SCheng Sean Ye 11379c94f155SCheng Sean Ye const char * 11389c94f155SCheng Sean Ye smbios_csn(smbios_hdl_t *shp) 11399c94f155SCheng Sean Ye { 11409c94f155SCheng Sean Ye const char *psn, *csn; 11419c94f155SCheng Sean Ye 11429c94f155SCheng Sean Ye return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : csn); 11439c94f155SCheng Sean Ye } 1144074bb90dSTom Pothier 1145074bb90dSTom Pothier int 1146074bb90dSTom Pothier smbios_info_extprocessor(smbios_hdl_t *shp, id_t id, 1147074bb90dSTom Pothier smbios_processor_ext_t *epp) 1148074bb90dSTom Pothier { 1149074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1150074bb90dSTom Pothier smb_processor_ext_t *exp; 1151074bb90dSTom Pothier 1152074bb90dSTom Pothier if (stp == NULL) 1153074bb90dSTom Pothier return (-1); /* errno is set for us */ 1154074bb90dSTom Pothier 1155074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PROCESSOR) 1156074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1157074bb90dSTom Pothier 1158074bb90dSTom Pothier exp = (smb_processor_ext_t *)(uintptr_t)stp->smbst_hdr; 1159074bb90dSTom Pothier bzero(epp, sizeof (smbios_processor_ext_t)); 1160074bb90dSTom Pothier 1161074bb90dSTom Pothier epp->smbpe_processor = exp->smbpre_processor; 1162074bb90dSTom Pothier epp->smbpe_fru = exp->smbpre_fru; 1163074bb90dSTom Pothier epp->smbpe_n = exp->smbpre_n; 1164074bb90dSTom Pothier epp->smbpe_apicid = exp->smbpre_apicid; 1165074bb90dSTom Pothier 1166074bb90dSTom Pothier return (0); 1167074bb90dSTom Pothier } 1168074bb90dSTom Pothier 1169074bb90dSTom Pothier int 117003f9f63dSTom Pothier smbios_info_extport(smbios_hdl_t *shp, id_t id, smbios_port_ext_t *eportp) 117103f9f63dSTom Pothier { 117203f9f63dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 117303f9f63dSTom Pothier smb_port_ext_t *ep; 117403f9f63dSTom Pothier 117503f9f63dSTom Pothier if (stp == NULL) 117603f9f63dSTom Pothier return (-1); /* errno is set for us */ 117703f9f63dSTom Pothier 117803f9f63dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PORT) 117903f9f63dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 118003f9f63dSTom Pothier 118103f9f63dSTom Pothier ep = (smb_port_ext_t *)(uintptr_t)stp->smbst_hdr; 118203f9f63dSTom Pothier bzero(eportp, sizeof (smbios_port_ext_t)); 118303f9f63dSTom Pothier 118403f9f63dSTom Pothier eportp->smbporte_chassis = ep->smbpoe_chassis; 118503f9f63dSTom Pothier eportp->smbporte_port = ep->smbpoe_port; 118603f9f63dSTom Pothier eportp->smbporte_dtype = ep->smbpoe_dtype; 118703f9f63dSTom Pothier eportp->smbporte_devhdl = ep->smbpoe_devhdl; 118803f9f63dSTom Pothier eportp->smbporte_phy = ep->smbpoe_phy; 118903f9f63dSTom Pothier 119003f9f63dSTom Pothier return (0); 119103f9f63dSTom Pothier } 119203f9f63dSTom Pothier 119303f9f63dSTom Pothier int 1194074bb90dSTom Pothier smbios_info_pciexrc(smbios_hdl_t *shp, id_t id, 1195074bb90dSTom Pothier smbios_pciexrc_t *rcp) 1196074bb90dSTom Pothier { 1197074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1198074bb90dSTom Pothier smb_pciexrc_t rc; 1199074bb90dSTom Pothier 1200074bb90dSTom Pothier if (stp == NULL) 1201074bb90dSTom Pothier return (-1); /* errno is set for us */ 1202074bb90dSTom Pothier 1203074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_PCIEXRC) 1204074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1205074bb90dSTom Pothier 1206074bb90dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &rc, sizeof (rc)); 1207074bb90dSTom Pothier bzero(rcp, sizeof (smbios_pciexrc_t)); 1208074bb90dSTom Pothier 1209074bb90dSTom Pothier rcp->smbpcie_bb = rc.smbpciexrc_bboard; 1210074bb90dSTom Pothier rcp->smbpcie_bdf = rc.smbpciexrc_bdf; 1211074bb90dSTom Pothier 1212074bb90dSTom Pothier return (0); 1213074bb90dSTom Pothier } 1214074bb90dSTom Pothier 1215074bb90dSTom Pothier int 1216074bb90dSTom Pothier smbios_info_extmemarray(smbios_hdl_t *shp, id_t id, smbios_memarray_ext_t *emap) 1217074bb90dSTom Pothier { 1218074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1219074bb90dSTom Pothier smb_memarray_ext_t exma; 1220074bb90dSTom Pothier 1221074bb90dSTom Pothier if (stp == NULL) 1222074bb90dSTom Pothier return (-1); /* errno is set for us */ 1223074bb90dSTom Pothier 1224074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMARRAY) 1225074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1226074bb90dSTom Pothier 1227074bb90dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &exma, sizeof (exma)); 1228074bb90dSTom Pothier bzero(emap, sizeof (smbios_memarray_ext_t)); 1229074bb90dSTom Pothier 1230074bb90dSTom Pothier emap->smbmae_ma = exma.smbmarre_ma; 1231074bb90dSTom Pothier emap->smbmae_comp = exma.smbmarre_component; 1232074bb90dSTom Pothier emap->smbmae_bdf = exma.smbmarre_bdf; 1233074bb90dSTom Pothier 1234074bb90dSTom Pothier return (0); 1235074bb90dSTom Pothier } 1236074bb90dSTom Pothier 1237074bb90dSTom Pothier int 1238074bb90dSTom Pothier smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id, 1239074bb90dSTom Pothier smbios_memdevice_ext_t *emdp) 1240074bb90dSTom Pothier { 1241074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1242074bb90dSTom Pothier smb_memdevice_ext_t exmd; 1243074bb90dSTom Pothier 1244074bb90dSTom Pothier if (stp == NULL) 1245074bb90dSTom Pothier return (-1); /* errno is set for us */ 1246074bb90dSTom Pothier 1247074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMDEVICE) 1248074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1249074bb90dSTom Pothier 1250074bb90dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &exmd, sizeof (exmd)); 1251074bb90dSTom Pothier bzero(emdp, sizeof (smbios_memdevice_ext_t)); 1252074bb90dSTom Pothier 1253074bb90dSTom Pothier emdp->smbmdeve_md = exmd.smbmdeve_mdev; 1254074bb90dSTom Pothier emdp->smbmdeve_drch = exmd.smbmdeve_dchan; 1255074bb90dSTom Pothier emdp->smbmdeve_ncs = exmd.smbmdeve_ncs; 1256074bb90dSTom Pothier emdp->smbmdeve_cs = exmd.smbmdeve_cs; 1257074bb90dSTom Pothier 1258074bb90dSTom Pothier return (0); 1259074bb90dSTom Pothier } 1260