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. 2465fa020fSRobert Mustacchi * Copyright (c) 2017, 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. 4904cdb0e3SRobert Mustacchi * 5004cdb0e3SRobert Mustacchi * Note, when trying to bzero the caller's struct you have to be careful about 5104cdb0e3SRobert Mustacchi * versions. One can only bzero the initial version that existed in illumos. In 5204cdb0e3SRobert Mustacchi * other words, if someone passes an older library handle that doesn't support a 5304cdb0e3SRobert Mustacchi * version you cannot assume that their structures have those additional members 5404cdb0e3SRobert Mustacchi * in them. Instead, a 'base' version is introduced for such types that have 5504cdb0e3SRobert Mustacchi * differences and instead we only bzero out the base version and then handle 5604cdb0e3SRobert Mustacchi * the additional members. In general, because all additional members will be 5704cdb0e3SRobert Mustacchi * assigned, there's no reason to zero them out unless they are arrays that 5804cdb0e3SRobert Mustacchi * won't be entirely filled in. 5904cdb0e3SRobert Mustacchi * 6004cdb0e3SRobert Mustacchi * Due to history, anything added after the update from version 2.4, in other 6104cdb0e3SRobert Mustacchi * words additions from or after '5094 Update libsmbios with recent items' 6204cdb0e3SRobert Mustacchi * (4e901881) is currently being used for this. While we don't allow software 6304cdb0e3SRobert Mustacchi * compiling against this to get an older form, this was the first major update 6404cdb0e3SRobert Mustacchi * and a good starting point for us to enforce this behavior which is useful for 6504cdb0e3SRobert Mustacchi * moving forward to making this more public. 6684ab085aSmws */ 6784ab085aSmws 6884ab085aSmws #include <sys/smbios_impl.h> 691eb9e3eaSRobert 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 226af349cd6SToomas Soome smbios_entry_point_t 22784ab085aSmws smbios_info_smbios(smbios_hdl_t *shp, smbios_entry_t *ep) 22884ab085aSmws { 22984ab085aSmws bcopy(&shp->sh_ent, ep, sizeof (smbios_entry_t)); 230af349cd6SToomas Soome return (shp->sh_ent_type); 231af349cd6SToomas Soome } 232af349cd6SToomas Soome 233af349cd6SToomas Soome void 234af349cd6SToomas Soome smbios_info_smbios_version(smbios_hdl_t *shp, smbios_version_t *v) 235af349cd6SToomas Soome { 236af349cd6SToomas Soome v->smbv_major = SMB_MAJOR(shp->sh_smbvers); 237af349cd6SToomas Soome v->smbv_minor = SMB_MINOR(shp->sh_smbvers); 23884ab085aSmws } 23984ab085aSmws 240c7c09f80SEric Schrock #ifndef _KERNEL 241c7c09f80SEric Schrock static char smbios_product_override[256]; 242c7c09f80SEric Schrock static boolean_t smbios_product_checked; 243c7c09f80SEric Schrock #endif 244c7c09f80SEric Schrock 24584ab085aSmws int 24684ab085aSmws smbios_info_common(smbios_hdl_t *shp, id_t id, smbios_info_t *ip) 24784ab085aSmws { 24884ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 24984ab085aSmws const struct smb_infospec *isp; 25084ab085aSmws int n = 0; 25184ab085aSmws 25284ab085aSmws if (stp == NULL) 25384ab085aSmws return (-1); /* errno is set for us */ 25484ab085aSmws 25584ab085aSmws for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) { 25684ab085aSmws if (isp->is_type == stp->smbst_hdr->smbh_type) 25784ab085aSmws break; 25884ab085aSmws } 25984ab085aSmws 26084ab085aSmws ip->smbi_manufacturer = smb_info_strptr(stp, isp->is_manu, &n); 26184ab085aSmws ip->smbi_product = smb_info_strptr(stp, isp->is_product, &n); 26284ab085aSmws ip->smbi_version = smb_info_strptr(stp, isp->is_version, &n); 26384ab085aSmws ip->smbi_serial = smb_info_strptr(stp, isp->is_serial, &n); 26484ab085aSmws ip->smbi_asset = smb_info_strptr(stp, isp->is_asset, &n); 26584ab085aSmws ip->smbi_location = smb_info_strptr(stp, isp->is_location, &n); 26684ab085aSmws ip->smbi_part = smb_info_strptr(stp, isp->is_part, &n); 26784ab085aSmws 26884ab085aSmws /* 269c7c09f80SEric Schrock * This private file allows developers to experiment with reporting 270c7c09f80SEric Schrock * different platform strings from SMBIOS. It is not a supported 271c7c09f80SEric Schrock * mechanism in the long term, and does not work in the kernel. 272c7c09f80SEric Schrock */ 273c7c09f80SEric Schrock #ifndef _KERNEL 274c7c09f80SEric Schrock if (isp->is_type == SMB_TYPE_SYSTEM) { 275c7c09f80SEric Schrock if (!smbios_product_checked) { 276c7c09f80SEric Schrock int fd = open("/etc/smbios_product", O_RDONLY); 277c7c09f80SEric Schrock if (fd >= 0) { 278c7c09f80SEric Schrock (void) read(fd, smbios_product_override, 279c7c09f80SEric Schrock sizeof (smbios_product_override) - 1); 280c7c09f80SEric Schrock (void) close(fd); 281c7c09f80SEric Schrock } 282c7c09f80SEric Schrock smbios_product_checked = B_TRUE; 283c7c09f80SEric Schrock } 284c7c09f80SEric Schrock 285c7c09f80SEric Schrock if (smbios_product_override[0] != '\0') 286c7c09f80SEric Schrock ip->smbi_product = smbios_product_override; 287c7c09f80SEric Schrock } 288c7c09f80SEric Schrock #endif 289c7c09f80SEric Schrock 290c7c09f80SEric Schrock /* 29184ab085aSmws * If we have a port with an empty internal reference designator string 29284ab085aSmws * try using the external reference designator string instead. 29384ab085aSmws */ 29484ab085aSmws if (isp->is_type == SMB_TYPE_PORT && ip->smbi_location[0] == '\0') { 29584ab085aSmws ip->smbi_location = smb_info_strptr(stp, 29684ab085aSmws offsetof(smb_port_t, smbpo_eref), &n); 29784ab085aSmws } 29884ab085aSmws 29984ab085aSmws return (n ? 0 : smb_set_errno(shp, ESMB_NOINFO)); 30084ab085aSmws } 30184ab085aSmws 302074bb90dSTom Pothier /* 303074bb90dSTom Pothier * Returns the actual number of contained objects. 304074bb90dSTom Pothier * 305074bb90dSTom Pothier * idc - number of contained objects 306074bb90dSTom Pothier * idv - returned array of contained objects 307074bb90dSTom Pothier */ 308074bb90dSTom Pothier int 309074bb90dSTom Pothier smbios_info_contains(smbios_hdl_t *shp, id_t id, uint_t idc, id_t *idv) 310074bb90dSTom Pothier { 311074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 312074bb90dSTom Pothier const struct smb_infospec *isp; 313074bb90dSTom Pothier id_t *cp; 314074bb90dSTom Pothier uint_t size; 315074bb90dSTom Pothier uint8_t cnt; 316074bb90dSTom Pothier int i, n; 317074bb90dSTom Pothier 318074bb90dSTom Pothier if (stp == NULL) { 319074bb90dSTom Pothier return (-1); /* errno is set for us */ 320074bb90dSTom Pothier } 321074bb90dSTom Pothier 322074bb90dSTom Pothier for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) { 323074bb90dSTom Pothier if (isp->is_type == stp->smbst_hdr->smbh_type) 324074bb90dSTom Pothier break; 325074bb90dSTom Pothier } 326074bb90dSTom Pothier if (isp->is_type == SMB_TYPE_EOT) 327074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 328074bb90dSTom Pothier 329074bb90dSTom Pothier size = isp->is_contsz; 330074bb90dSTom Pothier cnt = *((uint8_t *)(uintptr_t)stp->smbst_hdr + isp->is_contc); 331074bb90dSTom Pothier cp = (id_t *)((uintptr_t)stp->smbst_hdr + isp->is_contv); 332074bb90dSTom Pothier 333074bb90dSTom Pothier n = MIN(cnt, idc); 334074bb90dSTom Pothier for (i = 0; i < n; i++) { 335074bb90dSTom Pothier if (size == SMB_CONT_WORD) 336074bb90dSTom Pothier idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 2)); 337074bb90dSTom Pothier else if (size == SMB_CONT_BYTE) 338074bb90dSTom Pothier idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 3)); 339074bb90dSTom Pothier else 340074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_INVAL)); 341074bb90dSTom Pothier } 342074bb90dSTom Pothier 343074bb90dSTom Pothier return (cnt); 344074bb90dSTom Pothier } 345074bb90dSTom Pothier 34684ab085aSmws id_t 34784ab085aSmws smbios_info_bios(smbios_hdl_t *shp, smbios_bios_t *bp) 34884ab085aSmws { 34984ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BIOS); 35084ab085aSmws const smb_bios_t *bip; 35184ab085aSmws 35284ab085aSmws if (stp == NULL) 35384ab085aSmws return (-1); /* errno is set for us */ 35484ab085aSmws 35584ab085aSmws if (stp->smbst_hdr->smbh_len < sizeof (smb_bios_t) - sizeof (uint8_t)) 35684ab085aSmws return (smb_set_errno(shp, ESMB_CORRUPT)); 35784ab085aSmws 35884ab085aSmws bip = (smb_bios_t *)(uintptr_t)stp->smbst_hdr; 3591eb9e3eaSRobert Mustacchi bzero(bp, sizeof (smb_base_bios_t)); 3601eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31)) { 3611eb9e3eaSRobert Mustacchi bp->smbb_extromsize = 0; 3621eb9e3eaSRobert Mustacchi } 36384ab085aSmws 36484ab085aSmws bp->smbb_vendor = smb_strptr(stp, bip->smbbi_vendor); 36584ab085aSmws bp->smbb_version = smb_strptr(stp, bip->smbbi_version); 36684ab085aSmws bp->smbb_segment = bip->smbbi_segment; 36784ab085aSmws bp->smbb_reldate = smb_strptr(stp, bip->smbbi_reldate); 36884ab085aSmws bp->smbb_romsize = 64 * 1024 * ((uint32_t)bip->smbbi_romsize + 1); 36984ab085aSmws bp->smbb_runsize = 16 * (0x10000 - (uint32_t)bip->smbbi_segment); 37084ab085aSmws bp->smbb_cflags = bip->smbbi_cflags; 37184ab085aSmws 37284ab085aSmws /* 37384ab085aSmws * If one or more extension bytes are present, reset smbb_xcflags to 37484ab085aSmws * point to them. Otherwise leave this member set to NULL. 37584ab085aSmws */ 37684ab085aSmws if (stp->smbst_hdr->smbh_len >= sizeof (smb_bios_t)) { 37784ab085aSmws bp->smbb_xcflags = bip->smbbi_xcflags; 37884ab085aSmws bp->smbb_nxcflags = stp->smbst_hdr->smbh_len - 37984ab085aSmws sizeof (smb_bios_t) + 1; 38084ab085aSmws 38184ab085aSmws if (bp->smbb_nxcflags > SMB_BIOSXB_ECFW_MIN && 38284ab085aSmws smb_gteq(shp, SMB_VERSION_24)) { 38384ab085aSmws bp->smbb_biosv.smbv_major = 38484ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MAJ]; 38584ab085aSmws bp->smbb_biosv.smbv_minor = 38684ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MIN]; 38784ab085aSmws bp->smbb_ecfwv.smbv_major = 38884ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MAJ]; 38984ab085aSmws bp->smbb_ecfwv.smbv_minor = 39084ab085aSmws bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MIN]; 39184ab085aSmws } 3921eb9e3eaSRobert Mustacchi 3931eb9e3eaSRobert Mustacchi if (bp->smbb_nxcflags > SMB_BIOSXB_EXTROM + 1 && 3941eb9e3eaSRobert Mustacchi smb_gteq(shp, SMB_VERSION_31)) { 3951eb9e3eaSRobert Mustacchi uint16_t val; 3961eb9e3eaSRobert Mustacchi uint64_t rs; 3971eb9e3eaSRobert Mustacchi 3981eb9e3eaSRobert Mustacchi /* 3991eb9e3eaSRobert Mustacchi * Because of the fact that the extended size is a 4001eb9e3eaSRobert Mustacchi * uint16_t and we'd need to define an explicit 4011eb9e3eaSRobert Mustacchi * endian-aware way to access it, we don't include it in 4021eb9e3eaSRobert Mustacchi * the number of extended flags below and thus subtract 4031eb9e3eaSRobert Mustacchi * its size. 4041eb9e3eaSRobert Mustacchi */ 4051eb9e3eaSRobert Mustacchi bp->smbb_nxcflags -= sizeof (uint16_t); 4061eb9e3eaSRobert Mustacchi bcopy(&bip->smbbi_xcflags[SMB_BIOSXB_EXTROM], &val, 4071eb9e3eaSRobert Mustacchi sizeof (val)); 4081eb9e3eaSRobert Mustacchi val = LE_16(val); 4091eb9e3eaSRobert Mustacchi 4101eb9e3eaSRobert Mustacchi /* 4111eb9e3eaSRobert Mustacchi * The upper two bits of the extended rom size are used 4121eb9e3eaSRobert Mustacchi * to indicate whether the other 14 bits are in MB or 4131eb9e3eaSRobert Mustacchi * GB. 4141eb9e3eaSRobert Mustacchi */ 4151eb9e3eaSRobert Mustacchi rs = SMB_BIOS_EXTROM_VALUE_MASK(val); 4161eb9e3eaSRobert Mustacchi switch (SMB_BIOS_EXTROM_SHIFT_MASK(val)) { 4171eb9e3eaSRobert Mustacchi case 0: 4181eb9e3eaSRobert Mustacchi rs *= 1024ULL * 1024ULL; 4191eb9e3eaSRobert Mustacchi break; 4201eb9e3eaSRobert Mustacchi case 1: 4211eb9e3eaSRobert Mustacchi rs *= 1024ULL * 1024ULL * 1024ULL; 4221eb9e3eaSRobert Mustacchi break; 4231eb9e3eaSRobert Mustacchi default: 4241eb9e3eaSRobert Mustacchi rs = 0; 4251eb9e3eaSRobert Mustacchi break; 4261eb9e3eaSRobert Mustacchi } 4271eb9e3eaSRobert Mustacchi 4281eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31)) { 4291eb9e3eaSRobert Mustacchi bp->smbb_extromsize = rs; 4301eb9e3eaSRobert Mustacchi } 4311eb9e3eaSRobert Mustacchi } 4321eb9e3eaSRobert Mustacchi } 4331eb9e3eaSRobert Mustacchi 4341eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31) && bp->smbb_extromsize == 0) { 4351eb9e3eaSRobert Mustacchi bp->smbb_extromsize = bp->smbb_romsize; 43684ab085aSmws } 43784ab085aSmws 43884ab085aSmws return (stp->smbst_hdr->smbh_hdl); 43984ab085aSmws } 44084ab085aSmws 44184ab085aSmws id_t 44284ab085aSmws smbios_info_system(smbios_hdl_t *shp, smbios_system_t *sip) 44384ab085aSmws { 44484ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM); 44584ab085aSmws smb_system_t si; 44684ab085aSmws 44784ab085aSmws if (stp == NULL) 44884ab085aSmws return (-1); /* errno is set for us */ 44984ab085aSmws 45084ab085aSmws smb_info_bcopy(stp->smbst_hdr, &si, sizeof (si)); 45184ab085aSmws bzero(sip, sizeof (smbios_system_t)); 45284ab085aSmws 45384ab085aSmws sip->smbs_uuid = ((smb_system_t *)stp->smbst_hdr)->smbsi_uuid; 45484ab085aSmws sip->smbs_uuidlen = sizeof (si.smbsi_uuid); 45584ab085aSmws sip->smbs_wakeup = si.smbsi_wakeup; 45684ab085aSmws sip->smbs_sku = smb_strptr(stp, si.smbsi_sku); 45784ab085aSmws sip->smbs_family = smb_strptr(stp, si.smbsi_family); 45884ab085aSmws 45984ab085aSmws return (stp->smbst_hdr->smbh_hdl); 46084ab085aSmws } 46184ab085aSmws 46284ab085aSmws int 46384ab085aSmws smbios_info_bboard(smbios_hdl_t *shp, id_t id, smbios_bboard_t *bbp) 46484ab085aSmws { 46584ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 46684ab085aSmws smb_bboard_t bb; 46784ab085aSmws 46884ab085aSmws if (stp == NULL) 46984ab085aSmws return (-1); /* errno is set for us */ 47084ab085aSmws 47184ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_BASEBOARD) 47284ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 47384ab085aSmws 47484ab085aSmws smb_info_bcopy(stp->smbst_hdr, &bb, sizeof (bb)); 47584ab085aSmws bzero(bbp, sizeof (smbios_bboard_t)); 47684ab085aSmws 47784ab085aSmws bbp->smbb_chassis = bb.smbbb_chassis; 47884ab085aSmws bbp->smbb_flags = bb.smbbb_flags; 47984ab085aSmws bbp->smbb_type = bb.smbbb_type; 480074bb90dSTom Pothier bbp->smbb_contn = bb.smbbb_cn; 48184ab085aSmws 48284ab085aSmws return (0); 48384ab085aSmws } 48484ab085aSmws 48584ab085aSmws int 48684ab085aSmws smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp) 48784ab085aSmws { 48884ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 4894e901881SDale Ghent /* Length is measurable by one byte, so it'll be no more than 255. */ 4904e901881SDale Ghent uint8_t buf[256]; 4914e901881SDale Ghent smb_chassis_t *ch = (smb_chassis_t *)&buf[0]; 49284ab085aSmws 49384ab085aSmws if (stp == NULL) 49484ab085aSmws return (-1); /* errno is set for us */ 49584ab085aSmws 49684ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS) 49784ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 49884ab085aSmws 4994e901881SDale Ghent smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf)); 50004cdb0e3SRobert Mustacchi bzero(chp, sizeof (smb_base_chassis_t)); 5011eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_27)) { 50204cdb0e3SRobert Mustacchi bzero(chp->smbc_sku, sizeof (chp->smbc_sku)); 50304cdb0e3SRobert Mustacchi } 50484ab085aSmws 5054e901881SDale Ghent chp->smbc_oemdata = ch->smbch_oemdata; 5064e901881SDale Ghent chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0; 5074e901881SDale Ghent chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK; 5084e901881SDale Ghent chp->smbc_bustate = ch->smbch_bustate; 5094e901881SDale Ghent chp->smbc_psstate = ch->smbch_psstate; 5104e901881SDale Ghent chp->smbc_thstate = ch->smbch_thstate; 5114e901881SDale Ghent chp->smbc_security = ch->smbch_security; 5124e901881SDale Ghent chp->smbc_uheight = ch->smbch_uheight; 5134e901881SDale Ghent chp->smbc_cords = ch->smbch_cords; 5144e901881SDale Ghent chp->smbc_elems = ch->smbch_cn; 5154e901881SDale Ghent chp->smbc_elemlen = ch->smbch_cm; 5164e901881SDale Ghent 5171eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_27)) { 5184e901881SDale Ghent (void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch), 5194e901881SDale Ghent sizeof (chp->smbc_sku)); 5204e901881SDale Ghent } 52184ab085aSmws 52284ab085aSmws return (0); 52384ab085aSmws } 52484ab085aSmws 52584ab085aSmws int 52684ab085aSmws smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp) 52784ab085aSmws { 52884ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 52984ab085aSmws smb_processor_t p; 53084ab085aSmws 53184ab085aSmws if (stp == NULL) 53284ab085aSmws return (-1); /* errno is set for us */ 53384ab085aSmws 53484ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_PROCESSOR) 53584ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 53684ab085aSmws 53784ab085aSmws smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p)); 53804cdb0e3SRobert Mustacchi bzero(pp, sizeof (smb_base_processor_t)); 53984ab085aSmws 54084ab085aSmws pp->smbp_cpuid = p.smbpr_cpuid; 54184ab085aSmws pp->smbp_type = p.smbpr_type; 54284ab085aSmws pp->smbp_family = p.smbpr_family; 54384ab085aSmws pp->smbp_voltage = p.smbpr_voltage; 54484ab085aSmws pp->smbp_maxspeed = p.smbpr_maxspeed; 54584ab085aSmws pp->smbp_curspeed = p.smbpr_curspeed; 54684ab085aSmws pp->smbp_status = p.smbpr_status; 54784ab085aSmws pp->smbp_upgrade = p.smbpr_upgrade; 54884ab085aSmws pp->smbp_l1cache = p.smbpr_l1cache; 54984ab085aSmws pp->smbp_l2cache = p.smbpr_l2cache; 55084ab085aSmws pp->smbp_l3cache = p.smbpr_l3cache; 55184ab085aSmws 5521eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_25)) { 5534e901881SDale Ghent pp->smbp_corecount = p.smbpr_corecount; 5544e901881SDale Ghent pp->smbp_coresenabled = p.smbpr_coresenabled; 5554e901881SDale Ghent pp->smbp_threadcount = p.smbpr_threadcount; 5564e901881SDale Ghent pp->smbp_cflags = p.smbpr_cflags; 5574e901881SDale Ghent } 5584e901881SDale Ghent 5591eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_26)) { 5604e901881SDale Ghent pp->smbp_family2 = p.smbpr_family2; 5611eb9e3eaSRobert Mustacchi } 5624e901881SDale Ghent 5631eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_30)) { 56404cdb0e3SRobert Mustacchi pp->smbp_corecount2 = p.smbpr_corecount2; 56504cdb0e3SRobert Mustacchi pp->smbp_coresenabled2 = p.smbpr_coresenabled2; 56604cdb0e3SRobert Mustacchi pp->smbp_threadcount2 = p.smbpr_threadcount2; 56704cdb0e3SRobert Mustacchi } 56804cdb0e3SRobert Mustacchi 56984ab085aSmws return (0); 57084ab085aSmws } 57184ab085aSmws 57284ab085aSmws int 57384ab085aSmws smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap) 57484ab085aSmws { 57584ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 57684ab085aSmws smb_cache_t c; 57784ab085aSmws 57884ab085aSmws if (stp == NULL) 57984ab085aSmws return (-1); /* errno is set for us */ 58084ab085aSmws 58184ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_CACHE) 58284ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 58384ab085aSmws 58484ab085aSmws smb_info_bcopy(stp->smbst_hdr, &c, sizeof (c)); 5851eb9e3eaSRobert Mustacchi bzero(cap, sizeof (smb_base_cache_t)); 58684ab085aSmws 58784ab085aSmws cap->smba_maxsize = SMB_CACHE_SIZE(c.smbca_maxsize); 58884ab085aSmws cap->smba_size = SMB_CACHE_SIZE(c.smbca_size); 58984ab085aSmws cap->smba_stype = c.smbca_stype; 59084ab085aSmws cap->smba_ctype = c.smbca_ctype; 59184ab085aSmws cap->smba_speed = c.smbca_speed; 59284ab085aSmws cap->smba_etype = c.smbca_etype; 59384ab085aSmws cap->smba_ltype = c.smbca_ltype; 59484ab085aSmws cap->smba_assoc = c.smbca_assoc; 59584ab085aSmws cap->smba_level = SMB_CACHE_CFG_LEVEL(c.smbca_config); 59684ab085aSmws cap->smba_mode = SMB_CACHE_CFG_MODE(c.smbca_config); 59784ab085aSmws cap->smba_location = SMB_CACHE_CFG_LOCATION(c.smbca_config); 59884ab085aSmws 59984ab085aSmws if (SMB_CACHE_CFG_ENABLED(c.smbca_config)) 60084ab085aSmws cap->smba_flags |= SMB_CAF_ENABLED; 60184ab085aSmws 60284ab085aSmws if (SMB_CACHE_CFG_SOCKETED(c.smbca_config)) 60384ab085aSmws cap->smba_flags |= SMB_CAF_SOCKETED; 60484ab085aSmws 6051eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_31)) { 6061eb9e3eaSRobert Mustacchi if (smb_gteq(shp, SMB_VERSION_31)) { 6071eb9e3eaSRobert Mustacchi cap->smba_maxsize2 = 6081eb9e3eaSRobert Mustacchi SMB_CACHE_EXT_SIZE(c.smbca_maxsize2); 6091eb9e3eaSRobert Mustacchi cap->smba_size2 = SMB_CACHE_EXT_SIZE(c.smbca_size2); 6101eb9e3eaSRobert Mustacchi } else { 6111eb9e3eaSRobert Mustacchi cap->smba_maxsize2 = cap->smba_maxsize; 6121eb9e3eaSRobert Mustacchi cap->smba_size2 = cap->smba_size; 6131eb9e3eaSRobert Mustacchi } 6141eb9e3eaSRobert Mustacchi } 6151eb9e3eaSRobert Mustacchi 61684ab085aSmws return (0); 61784ab085aSmws } 61884ab085aSmws 61984ab085aSmws int 62084ab085aSmws smbios_info_port(smbios_hdl_t *shp, id_t id, smbios_port_t *pop) 62184ab085aSmws { 62284ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 62384ab085aSmws smb_port_t p; 62484ab085aSmws 62584ab085aSmws if (stp == NULL) 62684ab085aSmws return (-1); /* errno is set for us */ 62784ab085aSmws 62884ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_PORT) 62984ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 63084ab085aSmws 63184ab085aSmws smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p)); 63284ab085aSmws bzero(pop, sizeof (smbios_port_t)); 63384ab085aSmws 63484ab085aSmws pop->smbo_iref = smb_strptr(stp, p.smbpo_iref); 63584ab085aSmws pop->smbo_eref = smb_strptr(stp, p.smbpo_eref); 63684ab085aSmws 63784ab085aSmws pop->smbo_itype = p.smbpo_itype; 63884ab085aSmws pop->smbo_etype = p.smbpo_etype; 63984ab085aSmws pop->smbo_ptype = p.smbpo_ptype; 64084ab085aSmws 64184ab085aSmws return (0); 64284ab085aSmws } 64384ab085aSmws 64484ab085aSmws int 64584ab085aSmws smbios_info_slot(smbios_hdl_t *shp, id_t id, smbios_slot_t *sp) 64684ab085aSmws { 64784ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 64884ab085aSmws smb_slot_t s; 64984ab085aSmws 65084ab085aSmws if (stp == NULL) 65184ab085aSmws return (-1); /* errno is set for us */ 65284ab085aSmws 65384ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT) 65484ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 65584ab085aSmws 65684ab085aSmws smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 65784ab085aSmws bzero(sp, sizeof (smbios_slot_t)); 65884ab085aSmws 65984ab085aSmws sp->smbl_name = smb_strptr(stp, s.smbsl_name); 66084ab085aSmws sp->smbl_type = s.smbsl_type; 66184ab085aSmws sp->smbl_width = s.smbsl_width; 66284ab085aSmws sp->smbl_usage = s.smbsl_usage; 66384ab085aSmws sp->smbl_length = s.smbsl_length; 66484ab085aSmws sp->smbl_id = s.smbsl_id; 66584ab085aSmws sp->smbl_ch1 = s.smbsl_ch1; 66684ab085aSmws sp->smbl_ch2 = s.smbsl_ch2; 66703f9f63dSTom Pothier sp->smbl_sg = s.smbsl_sg; 66803f9f63dSTom Pothier sp->smbl_bus = s.smbsl_bus; 66903f9f63dSTom Pothier sp->smbl_df = s.smbsl_df; 67003f9f63dSTom Pothier 67103f9f63dSTom Pothier return (0); 67203f9f63dSTom Pothier } 67303f9f63dSTom Pothier 67403f9f63dSTom Pothier int 67503f9f63dSTom Pothier smbios_info_obdevs_ext(smbios_hdl_t *shp, id_t id, smbios_obdev_ext_t *oep) 67603f9f63dSTom Pothier { 67703f9f63dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 67803f9f63dSTom Pothier smb_obdev_ext_t obe; 67903f9f63dSTom Pothier 68003f9f63dSTom Pothier if (stp == NULL) 68103f9f63dSTom Pothier return (-1); /* errno is set for us */ 68203f9f63dSTom Pothier 68303f9f63dSTom Pothier if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVEXT) 68403f9f63dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 68503f9f63dSTom Pothier 68603f9f63dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &obe, sizeof (obe)); 68703f9f63dSTom Pothier bzero(oep, sizeof (smbios_obdev_ext_t)); 68803f9f63dSTom Pothier 68903f9f63dSTom Pothier oep->smboe_name = smb_strptr(stp, obe.smbobe_name); 69003f9f63dSTom Pothier oep->smboe_dtype = obe.smbobe_dtype; 69103f9f63dSTom Pothier oep->smboe_dti = obe.smbobe_dti; 69203f9f63dSTom Pothier oep->smboe_sg = obe.smbobe_sg; 69303f9f63dSTom Pothier oep->smboe_bus = obe.smbobe_bus; 69403f9f63dSTom Pothier oep->smboe_df = obe.smbobe_df; 69584ab085aSmws 69684ab085aSmws return (0); 69784ab085aSmws } 69884ab085aSmws 69984ab085aSmws int 70084ab085aSmws smbios_info_obdevs(smbios_hdl_t *shp, id_t id, int obc, smbios_obdev_t *obp) 70184ab085aSmws { 70284ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 70384ab085aSmws const smb_obdev_t *op; 70484ab085aSmws int i, m, n; 70584ab085aSmws 70684ab085aSmws if (stp == NULL) 70784ab085aSmws return (-1); /* errno is set for us */ 70884ab085aSmws 70984ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVS) 71084ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 71184ab085aSmws 71284ab085aSmws op = (smb_obdev_t *)((uintptr_t)stp->smbst_hdr + sizeof (smb_header_t)); 71384ab085aSmws m = (stp->smbst_hdr->smbh_len - sizeof (smb_header_t)) / sizeof (*op); 71484ab085aSmws n = MIN(m, obc); 71584ab085aSmws 71684ab085aSmws for (i = 0; i < n; i++, op++, obp++) { 71784ab085aSmws obp->smbd_name = smb_strptr(stp, op->smbob_name); 71884ab085aSmws obp->smbd_type = op->smbob_type & ~SMB_OBT_ENABLED; 71984ab085aSmws obp->smbd_enabled = (op->smbob_type & SMB_OBT_ENABLED) != 0; 72084ab085aSmws } 72184ab085aSmws 72284ab085aSmws return (m); 72384ab085aSmws } 72484ab085aSmws 72584ab085aSmws /* 72684ab085aSmws * The implementation structures for OEMSTR, SYSCONFSTR, and LANG all use the 72784ab085aSmws * first byte to indicate the size of a string table at the end of the record. 72884ab085aSmws * Therefore, smbios_info_strtab() can be used to retrieve the table size and 72984ab085aSmws * strings for any of these underlying record types. 73084ab085aSmws */ 73184ab085aSmws int 73284ab085aSmws smbios_info_strtab(smbios_hdl_t *shp, id_t id, int argc, const char *argv[]) 73384ab085aSmws { 73484ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 73584ab085aSmws smb_strtab_t s; 73684ab085aSmws int i, n; 73784ab085aSmws 73884ab085aSmws if (stp == NULL) 73984ab085aSmws return (-1); /* errno is set for us */ 74084ab085aSmws 74184ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR && 74284ab085aSmws stp->smbst_hdr->smbh_type != SMB_TYPE_SYSCONFSTR && 74384ab085aSmws stp->smbst_hdr->smbh_type != SMB_TYPE_LANG) 74484ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 74584ab085aSmws 74684ab085aSmws smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 74784ab085aSmws n = MIN(s.smbtb_count, argc); 74884ab085aSmws 74984ab085aSmws for (i = 0; i < n; i++) 75084ab085aSmws argv[i] = smb_strptr(stp, i + 1); 75184ab085aSmws 75284ab085aSmws return (s.smbtb_count); 75384ab085aSmws } 75484ab085aSmws 75584ab085aSmws id_t 75684ab085aSmws smbios_info_lang(smbios_hdl_t *shp, smbios_lang_t *lp) 75784ab085aSmws { 75884ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_LANG); 75984ab085aSmws smb_lang_t l; 76084ab085aSmws 76184ab085aSmws if (stp == NULL) 76284ab085aSmws return (-1); /* errno is set for us */ 76384ab085aSmws 76484ab085aSmws smb_info_bcopy(stp->smbst_hdr, &l, sizeof (l)); 76584ab085aSmws bzero(lp, sizeof (smbios_lang_t)); 76684ab085aSmws 76784ab085aSmws lp->smbla_cur = smb_strptr(stp, l.smblang_cur); 76884ab085aSmws lp->smbla_fmt = l.smblang_flags & 1; 76984ab085aSmws lp->smbla_num = l.smblang_num; 77084ab085aSmws 77184ab085aSmws return (stp->smbst_hdr->smbh_hdl); 77284ab085aSmws } 77384ab085aSmws 77484ab085aSmws id_t 77584ab085aSmws smbios_info_eventlog(smbios_hdl_t *shp, smbios_evlog_t *evp) 77684ab085aSmws { 77784ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_EVENTLOG); 77884ab085aSmws const smb_sel_t *sel; 77984ab085aSmws size_t len; 78084ab085aSmws 78184ab085aSmws if (stp == NULL) 78284ab085aSmws return (-1); /* errno is set for us */ 78384ab085aSmws 78484ab085aSmws if (stp->smbst_hdr->smbh_len < sizeof (smb_sel_t) - sizeof (uint8_t)) 78584ab085aSmws return (smb_set_errno(shp, ESMB_CORRUPT)); 78684ab085aSmws 78784ab085aSmws sel = (smb_sel_t *)(uintptr_t)stp->smbst_hdr; 78884ab085aSmws len = stp->smbst_hdr->smbh_len - sizeof (smb_sel_t) + sizeof (uint8_t); 78984ab085aSmws bzero(evp, sizeof (smbios_evlog_t)); 79084ab085aSmws 79184ab085aSmws if (len < sel->smbsel_typec * sel->smbsel_typesz) 79284ab085aSmws return (smb_set_errno(shp, ESMB_CORRUPT)); 79384ab085aSmws 79484ab085aSmws evp->smbev_size = sel->smbsel_len; 79584ab085aSmws evp->smbev_hdr = sel->smbsel_hdroff; 79684ab085aSmws evp->smbev_data = sel->smbsel_dataoff; 79784ab085aSmws evp->smbev_method = sel->smbsel_method; 79884ab085aSmws evp->smbev_flags = sel->smbsel_status; 79984ab085aSmws evp->smbev_format = sel->smbsel_format; 80084ab085aSmws evp->smbev_token = sel->smbsel_token; 80184ab085aSmws evp->smbev_addr.eva_addr = sel->smbsel_addr; 80284ab085aSmws 80384ab085aSmws if (sel->smbsel_typesz == sizeof (smbios_evtype_t)) { 80484ab085aSmws evp->smbev_typec = sel->smbsel_typec; 80584ab085aSmws evp->smbev_typev = (void *)(uintptr_t)sel->smbsel_typev; 80684ab085aSmws } 80784ab085aSmws 80884ab085aSmws return (stp->smbst_hdr->smbh_hdl); 80984ab085aSmws } 81084ab085aSmws 81184ab085aSmws int 81284ab085aSmws smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map) 81384ab085aSmws { 81484ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 81584ab085aSmws smb_memarray_t m; 81684ab085aSmws 81784ab085aSmws if (stp == NULL) 81884ab085aSmws return (-1); /* errno is set for us */ 81984ab085aSmws 82084ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAY) 82184ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 82284ab085aSmws 82384ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 82484ab085aSmws bzero(map, sizeof (smbios_memarray_t)); 82584ab085aSmws 82684ab085aSmws map->smbma_location = m.smbmarr_loc; 82784ab085aSmws map->smbma_use = m.smbmarr_use; 82884ab085aSmws map->smbma_ecc = m.smbmarr_ecc; 82984ab085aSmws map->smbma_ndevs = m.smbmarr_ndevs; 83084ab085aSmws map->smbma_err = m.smbmarr_err; 83184ab085aSmws 83284ab085aSmws if (m.smbmarr_cap != 0x80000000) 83384ab085aSmws map->smbma_size = (uint64_t)m.smbmarr_cap * 1024; 8344e901881SDale Ghent else if (m.smbmarr_extcap != 0) 8354e901881SDale Ghent map->smbma_size = m.smbmarr_extcap; 83684ab085aSmws else 83784ab085aSmws map->smbma_size = 0; /* unknown */ 83884ab085aSmws 83984ab085aSmws return (0); 84084ab085aSmws } 84184ab085aSmws 84284ab085aSmws int 84384ab085aSmws smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map) 84484ab085aSmws { 84584ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 84684ab085aSmws smb_memarrmap_t m; 84784ab085aSmws 84884ab085aSmws if (stp == NULL) 84984ab085aSmws return (-1); /* errno is set for us */ 85084ab085aSmws 85184ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP) 85284ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 85384ab085aSmws 85484ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 85584ab085aSmws bzero(map, sizeof (smbios_memarrmap_t)); 85684ab085aSmws 85784ab085aSmws map->smbmam_array = m.smbamap_array; 85884ab085aSmws map->smbmam_width = m.smbamap_width; 8594e901881SDale Ghent 8604e901881SDale Ghent if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) { 86184ab085aSmws map->smbmam_addr = (uint64_t)m.smbamap_start * 1024; 86284ab085aSmws map->smbmam_size = (uint64_t) 86384ab085aSmws (m.smbamap_end - m.smbamap_start + 1) * 1024; 8644e901881SDale Ghent } else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) { 8654e901881SDale Ghent map->smbmam_addr = m.smbamap_extstart; 8664e901881SDale Ghent map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1; 8674e901881SDale Ghent } 86884ab085aSmws 86984ab085aSmws return (0); 87084ab085aSmws } 87184ab085aSmws 87284ab085aSmws int 87384ab085aSmws smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp) 87484ab085aSmws { 87584ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 87684ab085aSmws smb_memdevice_t m; 87784ab085aSmws 87884ab085aSmws if (stp == NULL) 87984ab085aSmws return (-1); /* errno is set for us */ 88084ab085aSmws 88184ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICE) 88284ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 88384ab085aSmws 88484ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 88504cdb0e3SRobert Mustacchi bzero(mdp, sizeof (smb_base_memdevice_t)); 88684ab085aSmws 88784ab085aSmws mdp->smbmd_array = m.smbmdev_array; 88884ab085aSmws mdp->smbmd_error = m.smbmdev_error; 88984ab085aSmws mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth; 89084ab085aSmws mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth; 89184ab085aSmws 8924e901881SDale Ghent if (m.smbmdev_size == 0x7FFF) { 8934e901881SDale Ghent mdp->smbmd_size = (uint64_t)m.smbmdev_extsize; 8944e901881SDale Ghent mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */ 8954e901881SDale Ghent } else if (m.smbmdev_size != 0xFFFF) { 89684ab085aSmws mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES); 89784ab085aSmws if (m.smbmdev_size & SMB_MDS_KBYTES) 89884ab085aSmws mdp->smbmd_size *= 1024; 89984ab085aSmws else 90084ab085aSmws mdp->smbmd_size *= 1024 * 1024; 90184ab085aSmws } else 90284ab085aSmws mdp->smbmd_size = -1ULL; /* size unknown */ 90384ab085aSmws 90484ab085aSmws mdp->smbmd_form = m.smbmdev_form; 90584ab085aSmws mdp->smbmd_set = m.smbmdev_set; 90684ab085aSmws mdp->smbmd_type = m.smbmdev_type; 9074e901881SDale Ghent mdp->smbmd_speed = m.smbmdev_speed; 90884ab085aSmws mdp->smbmd_flags = m.smbmdev_flags; 90984ab085aSmws mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc); 91084ab085aSmws mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc); 91184ab085aSmws 9121eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_26)) { 9134e901881SDale Ghent mdp->smbmd_rank = m.smbmdev_attrs & 0x0F; 9141eb9e3eaSRobert Mustacchi } 9154e901881SDale Ghent 9161eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_27)) { 9174e901881SDale Ghent mdp->smbmd_clkspeed = m.smbmdev_clkspeed; 9181eb9e3eaSRobert Mustacchi } 9194e901881SDale Ghent 9201eb9e3eaSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_28)) { 9214e901881SDale Ghent mdp->smbmd_minvolt = m.smbmdev_minvolt; 9224e901881SDale Ghent mdp->smbmd_maxvolt = m.smbmdev_maxvolt; 9234e901881SDale Ghent mdp->smbmd_confvolt = m.smbmdev_confvolt; 9244e901881SDale Ghent } 92584ab085aSmws 92684ab085aSmws return (0); 92784ab085aSmws } 92884ab085aSmws 92984ab085aSmws int 93084ab085aSmws smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp) 93184ab085aSmws { 93284ab085aSmws const smb_struct_t *stp = smb_lookup_id(shp, id); 93384ab085aSmws smb_memdevmap_t m; 93484ab085aSmws 93584ab085aSmws if (stp == NULL) 93684ab085aSmws return (-1); /* errno is set for us */ 93784ab085aSmws 93884ab085aSmws if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP) 93984ab085aSmws return (smb_set_errno(shp, ESMB_TYPE)); 94084ab085aSmws 94184ab085aSmws smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m)); 94284ab085aSmws bzero(mdp, sizeof (smbios_memdevmap_t)); 94384ab085aSmws 94484ab085aSmws mdp->smbmdm_device = m.smbdmap_device; 94584ab085aSmws mdp->smbmdm_arrmap = m.smbdmap_array; 94684ab085aSmws mdp->smbmdm_rpos = m.smbdmap_rpos; 94784ab085aSmws mdp->smbmdm_ipos = m.smbdmap_ipos; 94884ab085aSmws mdp->smbmdm_idepth = m.smbdmap_idepth; 94984ab085aSmws 9504e901881SDale Ghent if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) { 9514e901881SDale Ghent mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024; 9524e901881SDale Ghent mdp->smbmdm_size = (uint64_t) 9534e901881SDale Ghent (m.smbdmap_end - m.smbdmap_start + 1) * 1024; 9544e901881SDale Ghent } else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) { 9554e901881SDale Ghent mdp->smbmdm_addr = m.smbdmap_extstart; 9564e901881SDale Ghent mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1; 9574e901881SDale Ghent } 9584e901881SDale Ghent 95984ab085aSmws return (0); 96084ab085aSmws } 96184ab085aSmws 96284ab085aSmws id_t 96384ab085aSmws smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp) 96484ab085aSmws { 96584ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY); 96684ab085aSmws smb_hwsec_t hs; 96784ab085aSmws 96884ab085aSmws if (stp == NULL) 96984ab085aSmws return (-1); /* errno is set for us */ 97084ab085aSmws 97184ab085aSmws smb_info_bcopy(stp->smbst_hdr, &hs, sizeof (hs)); 97284ab085aSmws bzero(hsp, sizeof (smbios_hwsec_t)); 97384ab085aSmws 97484ab085aSmws hsp->smbh_pwr_ps = SMB_HWS_PWR_PS(hs.smbhs_settings); 97584ab085aSmws hsp->smbh_kbd_ps = SMB_HWS_KBD_PS(hs.smbhs_settings); 97684ab085aSmws hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings); 97784ab085aSmws hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings); 97884ab085aSmws 97984ab085aSmws return (stp->smbst_hdr->smbh_hdl); 98084ab085aSmws } 98184ab085aSmws 98284ab085aSmws id_t 98384ab085aSmws smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp) 98484ab085aSmws { 98584ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT); 98684ab085aSmws const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr; 98784ab085aSmws 98884ab085aSmws if (stp == NULL) 98984ab085aSmws return (-1); /* errno is set for us */ 99084ab085aSmws 99184ab085aSmws bzero(bp, sizeof (smbios_boot_t)); 99284ab085aSmws 99384ab085aSmws bp->smbt_status = b->smbbo_status[0]; 99484ab085aSmws bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t); 99584ab085aSmws bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL; 99684ab085aSmws 99784ab085aSmws return (stp->smbst_hdr->smbh_hdl); 99884ab085aSmws } 99984ab085aSmws 100084ab085aSmws id_t 100184ab085aSmws smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip) 100284ab085aSmws { 100384ab085aSmws const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_IPMIDEV); 100484ab085aSmws smb_ipmi_t i; 100584ab085aSmws 100684ab085aSmws if (stp == NULL) 100784ab085aSmws return (-1); /* errno is set for us */ 100884ab085aSmws 100984ab085aSmws smb_info_bcopy(stp->smbst_hdr, &i, sizeof (i)); 101084ab085aSmws bzero(ip, sizeof (smbios_ipmi_t)); 101184ab085aSmws 101284ab085aSmws ip->smbip_type = i.smbipm_type; 101384ab085aSmws ip->smbip_vers.smbv_major = SMB_IPM_SPEC_MAJOR(i.smbipm_spec); 101484ab085aSmws ip->smbip_vers.smbv_minor = SMB_IPM_SPEC_MINOR(i.smbipm_spec); 101584ab085aSmws ip->smbip_i2c = i.smbipm_i2c; 101684ab085aSmws ip->smbip_addr = i.smbipm_addr & ~SMB_IPM_ADDR_IO; 101784ab085aSmws ip->smbip_intr = i.smbipm_intr; 101884ab085aSmws 101984ab085aSmws if (i.smbipm_bus != (uint8_t)-1) 102084ab085aSmws ip->smbip_bus = i.smbipm_bus; 102184ab085aSmws else 102284ab085aSmws ip->smbip_bus = -1u; 102384ab085aSmws 102484ab085aSmws if (SMB_IPM_INFO_LSB(i.smbipm_info)) 102584ab085aSmws ip->smbip_addr |= 1; /* turn on least-significant bit of addr */ 102684ab085aSmws 102784ab085aSmws if (i.smbipm_addr & SMB_IPM_ADDR_IO) { 102884ab085aSmws switch (SMB_IPM_INFO_REGS(i.smbipm_info)) { 102984ab085aSmws case SMB_IPM_REGS_1B: 103084ab085aSmws ip->smbip_regspacing = 1; 103184ab085aSmws break; 103284ab085aSmws case SMB_IPM_REGS_4B: 103384ab085aSmws ip->smbip_regspacing = 4; 103484ab085aSmws break; 103584ab085aSmws case SMB_IPM_REGS_16B: 103684ab085aSmws ip->smbip_regspacing = 16; 103784ab085aSmws break; 103884ab085aSmws default: 103984ab085aSmws ip->smbip_regspacing = 1; 104084ab085aSmws } 104184ab085aSmws ip->smbip_flags |= SMB_IPMI_F_IOADDR; 104284ab085aSmws } 104384ab085aSmws 104484ab085aSmws if (SMB_IPM_INFO_ISPEC(i.smbipm_info)) 104584ab085aSmws ip->smbip_flags |= SMB_IPMI_F_INTRSPEC; 104684ab085aSmws 104784ab085aSmws if (SMB_IPM_INFO_IPOL(i.smbipm_info) == SMB_IPM_IPOL_HI) 104884ab085aSmws ip->smbip_flags |= SMB_IPMI_F_INTRHIGH; 104984ab085aSmws 105084ab085aSmws if (SMB_IPM_INFO_IMODE(i.smbipm_info) == SMB_IPM_IMODE_EDGE) 105184ab085aSmws ip->smbip_flags |= SMB_IPMI_F_INTREDGE; 105284ab085aSmws 105384ab085aSmws return (stp->smbst_hdr->smbh_hdl); 105484ab085aSmws } 10559c94f155SCheng Sean Ye 10569c94f155SCheng Sean Ye static boolean_t 10579c94f155SCheng Sean Ye smbios_has_oemstr(smbios_hdl_t *shp, const char *oemstr) 10589c94f155SCheng Sean Ye { 10599c94f155SCheng Sean Ye const smb_struct_t *stp = shp->sh_structs; 10609c94f155SCheng Sean Ye smb_strtab_t s; 10619c94f155SCheng Sean Ye int i, j; 10629c94f155SCheng Sean Ye 10639c94f155SCheng Sean Ye for (i = 0; i < shp->sh_nstructs; i++, stp++) { 10649c94f155SCheng Sean Ye if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR) 10659c94f155SCheng Sean Ye continue; 10669c94f155SCheng Sean Ye 10679c94f155SCheng Sean Ye smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s)); 10689c94f155SCheng Sean Ye for (j = 0; j < s.smbtb_count; j++) 10699c94f155SCheng Sean Ye if (strcmp(smb_strptr(stp, j + 1), oemstr) == 0) 10709c94f155SCheng Sean Ye return (B_TRUE); 10719c94f155SCheng Sean Ye } 10729c94f155SCheng Sean Ye 10739c94f155SCheng Sean Ye return (B_FALSE); 10749c94f155SCheng Sean Ye } 10759c94f155SCheng Sean Ye 10769c94f155SCheng Sean Ye static const char * 10779c94f155SCheng Sean Ye smb_serial_valid(const char *serial) 10789c94f155SCheng Sean Ye { 10799c94f155SCheng Sean Ye char buf[MAXNAMELEN]; 10809c94f155SCheng Sean Ye int i = 0; 10819c94f155SCheng Sean Ye 10829c94f155SCheng Sean Ye if (serial == NULL) 10839c94f155SCheng Sean Ye return (NULL); 10849c94f155SCheng Sean Ye 10859c94f155SCheng Sean Ye (void) strlcpy(buf, serial, sizeof (buf)); 10869c94f155SCheng Sean Ye 10879c94f155SCheng Sean Ye while (buf[i] != '\0' && buf[i] == ' ') 10889c94f155SCheng Sean Ye i++; 10899c94f155SCheng Sean Ye 10909c94f155SCheng Sean Ye if (buf[i] == '\0' || strstr(buf, SMB_DEFAULT1) != NULL || 10919c94f155SCheng Sean Ye strstr(buf, SMB_DEFAULT2) != NULL) 10929c94f155SCheng Sean Ye return (NULL); 10939c94f155SCheng Sean Ye 10949c94f155SCheng Sean Ye return (serial); 10959c94f155SCheng Sean Ye } 10969c94f155SCheng Sean Ye 10979c94f155SCheng Sean Ye /* 10989c94f155SCheng Sean Ye * Get chassis SN or product SN 10999c94f155SCheng Sean Ye */ 11009c94f155SCheng Sean Ye static int 11019c94f155SCheng Sean Ye smb_get_sn(smbios_hdl_t *shp, const char **psnp, const char **csnp) 11029c94f155SCheng Sean Ye { 11039c94f155SCheng Sean Ye const smb_struct_t *stp; 11049c94f155SCheng Sean Ye smbios_info_t s1, s3; 11059c94f155SCheng Sean Ye 11069c94f155SCheng Sean Ye if (psnp == NULL || csnp == NULL) 11079c94f155SCheng Sean Ye return (smb_set_errno(shp, ESMB_INVAL)); 11089c94f155SCheng Sean Ye 11099c94f155SCheng Sean Ye *psnp = *csnp = NULL; 11109c94f155SCheng Sean Ye 11119c94f155SCheng Sean Ye /* 11129c94f155SCheng Sean Ye * If SMBIOS meets Sun's PRMS requirements, retrieve product SN 11139c94f155SCheng Sean Ye * from type 1 structure, and chassis SN from type 3 structure. 11149c94f155SCheng Sean Ye * Otherwise return SN in type 1 structure as chassis SN. 11159c94f155SCheng Sean Ye */ 11169c94f155SCheng Sean Ye 11179c94f155SCheng Sean Ye /* Get type 1 SN */ 11189c94f155SCheng Sean Ye if ((stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM)) == NULL || 11199c94f155SCheng Sean Ye smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s1) == SMB_ERR) 11209c94f155SCheng Sean Ye s1.smbi_serial = NULL; 11219c94f155SCheng Sean Ye 11229c94f155SCheng Sean Ye /* Get type 3 SN */ 11239c94f155SCheng Sean Ye if ((stp = smb_lookup_type(shp, SMB_TYPE_CHASSIS)) == NULL || 11249c94f155SCheng Sean Ye smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s3) == SMB_ERR) 11259c94f155SCheng Sean Ye s3.smbi_serial = NULL; 11269c94f155SCheng Sean Ye 11279c94f155SCheng Sean Ye if (smbios_has_oemstr(shp, SMB_PRMS1)) { 11289c94f155SCheng Sean Ye *psnp = smb_serial_valid(s1.smbi_serial); 11299c94f155SCheng Sean Ye *csnp = smb_serial_valid(s3.smbi_serial); 11309c94f155SCheng Sean Ye } else { 11319c94f155SCheng Sean Ye *csnp = smb_serial_valid(s1.smbi_serial); 11329c94f155SCheng Sean Ye } 11339c94f155SCheng Sean Ye 11349c94f155SCheng Sean Ye return (0); 11359c94f155SCheng Sean Ye } 11369c94f155SCheng Sean Ye 11379c94f155SCheng Sean Ye const char * 11389c94f155SCheng Sean Ye smbios_psn(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 : psn); 11439c94f155SCheng Sean Ye } 11449c94f155SCheng Sean Ye 11459c94f155SCheng Sean Ye const char * 11469c94f155SCheng Sean Ye smbios_csn(smbios_hdl_t *shp) 11479c94f155SCheng Sean Ye { 11489c94f155SCheng Sean Ye const char *psn, *csn; 11499c94f155SCheng Sean Ye 11509c94f155SCheng Sean Ye return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : csn); 11519c94f155SCheng Sean Ye } 1152074bb90dSTom Pothier 1153074bb90dSTom Pothier int 1154074bb90dSTom Pothier smbios_info_extprocessor(smbios_hdl_t *shp, id_t id, 1155074bb90dSTom Pothier smbios_processor_ext_t *epp) 1156074bb90dSTom Pothier { 1157074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1158074bb90dSTom Pothier smb_processor_ext_t *exp; 1159074bb90dSTom Pothier 1160074bb90dSTom Pothier if (stp == NULL) 1161074bb90dSTom Pothier return (-1); /* errno is set for us */ 1162074bb90dSTom Pothier 1163074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PROCESSOR) 1164074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1165074bb90dSTom Pothier 1166074bb90dSTom Pothier exp = (smb_processor_ext_t *)(uintptr_t)stp->smbst_hdr; 1167074bb90dSTom Pothier bzero(epp, sizeof (smbios_processor_ext_t)); 1168074bb90dSTom Pothier 1169074bb90dSTom Pothier epp->smbpe_processor = exp->smbpre_processor; 1170074bb90dSTom Pothier epp->smbpe_fru = exp->smbpre_fru; 1171074bb90dSTom Pothier epp->smbpe_n = exp->smbpre_n; 1172074bb90dSTom Pothier epp->smbpe_apicid = exp->smbpre_apicid; 1173074bb90dSTom Pothier 1174074bb90dSTom Pothier return (0); 1175074bb90dSTom Pothier } 1176074bb90dSTom Pothier 1177074bb90dSTom Pothier int 117803f9f63dSTom Pothier smbios_info_extport(smbios_hdl_t *shp, id_t id, smbios_port_ext_t *eportp) 117903f9f63dSTom Pothier { 118003f9f63dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 118103f9f63dSTom Pothier smb_port_ext_t *ep; 118203f9f63dSTom Pothier 118303f9f63dSTom Pothier if (stp == NULL) 118403f9f63dSTom Pothier return (-1); /* errno is set for us */ 118503f9f63dSTom Pothier 118603f9f63dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PORT) 118703f9f63dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 118803f9f63dSTom Pothier 118903f9f63dSTom Pothier ep = (smb_port_ext_t *)(uintptr_t)stp->smbst_hdr; 119003f9f63dSTom Pothier bzero(eportp, sizeof (smbios_port_ext_t)); 119103f9f63dSTom Pothier 119203f9f63dSTom Pothier eportp->smbporte_chassis = ep->smbpoe_chassis; 119303f9f63dSTom Pothier eportp->smbporte_port = ep->smbpoe_port; 119403f9f63dSTom Pothier eportp->smbporte_dtype = ep->smbpoe_dtype; 119503f9f63dSTom Pothier eportp->smbporte_devhdl = ep->smbpoe_devhdl; 119603f9f63dSTom Pothier eportp->smbporte_phy = ep->smbpoe_phy; 119703f9f63dSTom Pothier 119803f9f63dSTom Pothier return (0); 119903f9f63dSTom Pothier } 120003f9f63dSTom Pothier 120103f9f63dSTom Pothier int 1202074bb90dSTom Pothier smbios_info_pciexrc(smbios_hdl_t *shp, id_t id, 1203074bb90dSTom Pothier smbios_pciexrc_t *rcp) 1204074bb90dSTom Pothier { 1205074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1206074bb90dSTom Pothier smb_pciexrc_t rc; 1207074bb90dSTom Pothier 1208074bb90dSTom Pothier if (stp == NULL) 1209074bb90dSTom Pothier return (-1); /* errno is set for us */ 1210074bb90dSTom Pothier 1211074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_PCIEXRC) 1212074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1213074bb90dSTom Pothier 1214074bb90dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &rc, sizeof (rc)); 1215074bb90dSTom Pothier bzero(rcp, sizeof (smbios_pciexrc_t)); 1216074bb90dSTom Pothier 1217074bb90dSTom Pothier rcp->smbpcie_bb = rc.smbpciexrc_bboard; 1218074bb90dSTom Pothier rcp->smbpcie_bdf = rc.smbpciexrc_bdf; 1219074bb90dSTom Pothier 1220074bb90dSTom Pothier return (0); 1221074bb90dSTom Pothier } 1222074bb90dSTom Pothier 1223074bb90dSTom Pothier int 1224074bb90dSTom Pothier smbios_info_extmemarray(smbios_hdl_t *shp, id_t id, smbios_memarray_ext_t *emap) 1225074bb90dSTom Pothier { 1226074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1227074bb90dSTom Pothier smb_memarray_ext_t exma; 1228074bb90dSTom Pothier 1229074bb90dSTom Pothier if (stp == NULL) 1230074bb90dSTom Pothier return (-1); /* errno is set for us */ 1231074bb90dSTom Pothier 1232074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMARRAY) 1233074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1234074bb90dSTom Pothier 1235074bb90dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &exma, sizeof (exma)); 1236074bb90dSTom Pothier bzero(emap, sizeof (smbios_memarray_ext_t)); 1237074bb90dSTom Pothier 1238074bb90dSTom Pothier emap->smbmae_ma = exma.smbmarre_ma; 1239074bb90dSTom Pothier emap->smbmae_comp = exma.smbmarre_component; 1240074bb90dSTom Pothier emap->smbmae_bdf = exma.smbmarre_bdf; 1241074bb90dSTom Pothier 1242074bb90dSTom Pothier return (0); 1243074bb90dSTom Pothier } 1244074bb90dSTom Pothier 1245074bb90dSTom Pothier int 1246074bb90dSTom Pothier smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id, 1247074bb90dSTom Pothier smbios_memdevice_ext_t *emdp) 1248074bb90dSTom Pothier { 1249074bb90dSTom Pothier const smb_struct_t *stp = smb_lookup_id(shp, id); 1250074bb90dSTom Pothier smb_memdevice_ext_t exmd; 1251074bb90dSTom Pothier 1252074bb90dSTom Pothier if (stp == NULL) 1253074bb90dSTom Pothier return (-1); /* errno is set for us */ 1254074bb90dSTom Pothier 1255074bb90dSTom Pothier if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMDEVICE) 1256074bb90dSTom Pothier return (smb_set_errno(shp, ESMB_TYPE)); 1257074bb90dSTom Pothier 1258074bb90dSTom Pothier smb_info_bcopy(stp->smbst_hdr, &exmd, sizeof (exmd)); 1259074bb90dSTom Pothier bzero(emdp, sizeof (smbios_memdevice_ext_t)); 1260074bb90dSTom Pothier 1261074bb90dSTom Pothier emdp->smbmdeve_md = exmd.smbmdeve_mdev; 1262074bb90dSTom Pothier emdp->smbmdeve_drch = exmd.smbmdeve_dchan; 1263074bb90dSTom Pothier emdp->smbmdeve_ncs = exmd.smbmdeve_ncs; 1264074bb90dSTom Pothier emdp->smbmdeve_cs = exmd.smbmdeve_cs; 1265074bb90dSTom Pothier 1266074bb90dSTom Pothier return (0); 1267074bb90dSTom Pothier } 126865fa020fSRobert Mustacchi 126965fa020fSRobert Mustacchi int 127065fa020fSRobert Mustacchi smbios_info_powersup(smbios_hdl_t *shp, id_t id, smbios_powersup_t *psup) 127165fa020fSRobert Mustacchi { 127265fa020fSRobert Mustacchi const smb_struct_t *stp = smb_lookup_id(shp, id); 127365fa020fSRobert Mustacchi smb_powersup_t psu; 127465fa020fSRobert Mustacchi 127565fa020fSRobert Mustacchi if (stp == NULL) 127665fa020fSRobert Mustacchi return (-1); /* errno is set for us */ 127765fa020fSRobert Mustacchi 127865fa020fSRobert Mustacchi if (stp->smbst_hdr->smbh_type != SMB_TYPE_POWERSUP) 127965fa020fSRobert Mustacchi return (smb_set_errno(shp, ESMB_TYPE)); 128065fa020fSRobert Mustacchi 128165fa020fSRobert Mustacchi /* The minimum length required by the spec is 0x10. */ 128265fa020fSRobert Mustacchi if (stp->smbst_hdr->smbh_len < 0x10) 128365fa020fSRobert Mustacchi return (smb_set_errno(shp, ESMB_SHORT)); 128465fa020fSRobert Mustacchi 128565fa020fSRobert Mustacchi bzero(psup, sizeof (*psup)); 128665fa020fSRobert Mustacchi smb_info_bcopy(stp->smbst_hdr, &psu, sizeof (psu)); 128765fa020fSRobert Mustacchi psup->smbps_group = psu.smbpsup_group; 128865fa020fSRobert Mustacchi psup->smbps_maxout = psu.smbpsup_max; 128965fa020fSRobert Mustacchi 129065fa020fSRobert Mustacchi if (SMB_PSU_CHARS_ISHOT(psu.smbpsup_char)) 129165fa020fSRobert Mustacchi psup->smbps_flags |= SMB_POWERSUP_F_HOT; 129265fa020fSRobert Mustacchi if (SMB_PSU_CHARS_ISPRES(psu.smbpsup_char)) 129365fa020fSRobert Mustacchi psup->smbps_flags |= SMB_POWERSUP_F_PRESENT; 129465fa020fSRobert Mustacchi if (SMB_PSU_CHARS_ISUNPLUG(psu.smbpsup_char)) 129565fa020fSRobert Mustacchi psup->smbps_flags |= SMB_POWERSUP_F_UNPLUG; 129665fa020fSRobert Mustacchi 129765fa020fSRobert Mustacchi psup->smbps_ivrs = SMB_PSU_CHARS_IVRS(psu.smbpsup_char); 129865fa020fSRobert Mustacchi psup->smbps_status = SMB_PSU_CHARS_STATUS(psu.smbpsup_char); 129965fa020fSRobert Mustacchi psup->smbps_pstype = SMB_PSU_CHARS_TYPE(psu.smbpsup_char); 130065fa020fSRobert Mustacchi 130165fa020fSRobert Mustacchi if (stp->smbst_hdr->smbh_len >= 0x12) { 130265fa020fSRobert Mustacchi psup->smbps_vprobe = psu.smbpsup_vprobe; 130365fa020fSRobert Mustacchi } else { 130465fa020fSRobert Mustacchi psup->smbps_vprobe = 0xffff; 130565fa020fSRobert Mustacchi } 130665fa020fSRobert Mustacchi 130765fa020fSRobert Mustacchi if (stp->smbst_hdr->smbh_len >= 0x14) { 130865fa020fSRobert Mustacchi psup->smbps_cooldev = psu.smbpsup_cooldev; 130965fa020fSRobert Mustacchi } else { 131065fa020fSRobert Mustacchi psup->smbps_cooldev = 0xffff; 131165fa020fSRobert Mustacchi } 131265fa020fSRobert Mustacchi 131365fa020fSRobert Mustacchi if (stp->smbst_hdr->smbh_len >= 0x16) { 131465fa020fSRobert Mustacchi psup->smbps_iprobe = psu.smbpsup_iprobe; 131565fa020fSRobert Mustacchi } else { 131665fa020fSRobert Mustacchi psup->smbps_iprobe = 0xffff; 131765fa020fSRobert Mustacchi } 131865fa020fSRobert Mustacchi 131965fa020fSRobert Mustacchi return (0); 132065fa020fSRobert Mustacchi } 1321*a448814aSRobert Mustacchi 1322*a448814aSRobert Mustacchi int 1323*a448814aSRobert Mustacchi smbios_info_vprobe(smbios_hdl_t *shp, id_t id, smbios_vprobe_t *vprobe) 1324*a448814aSRobert Mustacchi { 1325*a448814aSRobert Mustacchi const smb_struct_t *stp = smb_lookup_id(shp, id); 1326*a448814aSRobert Mustacchi smb_vprobe_t vp; 1327*a448814aSRobert Mustacchi 1328*a448814aSRobert Mustacchi if (stp == NULL) 1329*a448814aSRobert Mustacchi return (-1); /* errno is set for us */ 1330*a448814aSRobert Mustacchi 1331*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_type != SMB_TYPE_VPROBE) 1332*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_TYPE)); 1333*a448814aSRobert Mustacchi 1334*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_len < SMB_VPROBE_MINLEN) 1335*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_SHORT)); 1336*a448814aSRobert Mustacchi 1337*a448814aSRobert Mustacchi bzero(vprobe, sizeof (*vprobe)); 1338*a448814aSRobert Mustacchi smb_info_bcopy(stp->smbst_hdr, &vp, sizeof (vp)); 1339*a448814aSRobert Mustacchi vprobe->smbvp_description = smb_strptr(stp, vp.smbvpr_descr); 1340*a448814aSRobert Mustacchi vprobe->smbvp_location = SMB_VPROBE_LOCATION(vp.smbvpr_locstat); 1341*a448814aSRobert Mustacchi vprobe->smbvp_status = SMB_VPROBE_STATUS(vp.smbvpr_locstat); 1342*a448814aSRobert Mustacchi vprobe->smbvp_maxval = vp.smbvpr_maxval; 1343*a448814aSRobert Mustacchi vprobe->smbvp_minval = vp.smbvpr_minval; 1344*a448814aSRobert Mustacchi vprobe->smbvp_resolution = vp.smbvpr_resolution; 1345*a448814aSRobert Mustacchi vprobe->smbvp_tolerance = vp.smbvpr_tolerance; 1346*a448814aSRobert Mustacchi vprobe->smbvp_accuracy = vp.smbvpr_accuracy; 1347*a448814aSRobert Mustacchi 1348*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_len >= SMB_VPROBE_NOMINAL_MINLEN) { 1349*a448814aSRobert Mustacchi vprobe->smbvp_nominal = vp.smbvpr_nominal; 1350*a448814aSRobert Mustacchi } else { 1351*a448814aSRobert Mustacchi vprobe->smbvp_nominal = SMB_PROBE_UNKNOWN_VALUE; 1352*a448814aSRobert Mustacchi } 1353*a448814aSRobert Mustacchi 1354*a448814aSRobert Mustacchi return (0); 1355*a448814aSRobert Mustacchi } 1356*a448814aSRobert Mustacchi 1357*a448814aSRobert Mustacchi int 1358*a448814aSRobert Mustacchi smbios_info_cooldev(smbios_hdl_t *shp, id_t id, smbios_cooldev_t *cooldev) 1359*a448814aSRobert Mustacchi { 1360*a448814aSRobert Mustacchi const smb_struct_t *stp = smb_lookup_id(shp, id); 1361*a448814aSRobert Mustacchi smb_cooldev_t cd; 1362*a448814aSRobert Mustacchi 1363*a448814aSRobert Mustacchi if (stp == NULL) 1364*a448814aSRobert Mustacchi return (-1); /* errno is set for us */ 1365*a448814aSRobert Mustacchi 1366*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_type != SMB_TYPE_COOLDEV) 1367*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_TYPE)); 1368*a448814aSRobert Mustacchi 1369*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_len < SMB_COOLDEV_MINLEN) 1370*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_SHORT)); 1371*a448814aSRobert Mustacchi 1372*a448814aSRobert Mustacchi bzero(cooldev, sizeof (*cooldev)); 1373*a448814aSRobert Mustacchi smb_info_bcopy(stp->smbst_hdr, &cd, sizeof (cd)); 1374*a448814aSRobert Mustacchi cooldev->smbcd_tprobe = cd.smbcdev_tprobe; 1375*a448814aSRobert Mustacchi cooldev->smbcd_type = SMB_COOLDEV_TYPE(cd.smbcdev_typstat); 1376*a448814aSRobert Mustacchi cooldev->smbcd_status = SMB_COOLDEV_STATUS(cd.smbcdev_typstat); 1377*a448814aSRobert Mustacchi cooldev->smbcd_group = cd.smbcdev_group; 1378*a448814aSRobert Mustacchi cooldev->smbcd_oem = cd.smbcdev_oem; 1379*a448814aSRobert Mustacchi 1380*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_len >= SMB_COOLDEV_NOMINAL_MINLEN) { 1381*a448814aSRobert Mustacchi cooldev->smbcd_nominal = cd.smbcdev_nominal; 1382*a448814aSRobert Mustacchi } else { 1383*a448814aSRobert Mustacchi cooldev->smbcd_nominal = SMB_PROBE_UNKNOWN_VALUE; 1384*a448814aSRobert Mustacchi } 1385*a448814aSRobert Mustacchi 1386*a448814aSRobert Mustacchi /* 1387*a448814aSRobert Mustacchi * The description field was added in SMBIOS version 2.7. The 1388*a448814aSRobert Mustacchi * SMB_TYPE_COOLDEV support was only added after all of the 2.7+ fields 1389*a448814aSRobert Mustacchi * were added in the spec. So while a user may request an older version, 1390*a448814aSRobert Mustacchi * we don't have to worry about old structures and just simply skip it 1391*a448814aSRobert Mustacchi * if they're not asking for it. 1392*a448814aSRobert Mustacchi */ 1393*a448814aSRobert Mustacchi if (smb_libgteq(shp, SMB_VERSION_27) && 1394*a448814aSRobert Mustacchi smb_gteq(shp, SMB_VERSION_27) && 1395*a448814aSRobert Mustacchi stp->smbst_hdr->smbh_len >= SMB_COOLDEV_DESCR_MINLEN) { 1396*a448814aSRobert Mustacchi cooldev->smbcd_descr = smb_strptr(stp, cd.smbcdev_descr); 1397*a448814aSRobert Mustacchi } else { 1398*a448814aSRobert Mustacchi cooldev->smbcd_descr = NULL; 1399*a448814aSRobert Mustacchi } 1400*a448814aSRobert Mustacchi 1401*a448814aSRobert Mustacchi return (0); 1402*a448814aSRobert Mustacchi } 1403*a448814aSRobert Mustacchi 1404*a448814aSRobert Mustacchi int 1405*a448814aSRobert Mustacchi smbios_info_tprobe(smbios_hdl_t *shp, id_t id, smbios_tprobe_t *tprobe) 1406*a448814aSRobert Mustacchi { 1407*a448814aSRobert Mustacchi const smb_struct_t *stp = smb_lookup_id(shp, id); 1408*a448814aSRobert Mustacchi smb_tprobe_t tp; 1409*a448814aSRobert Mustacchi 1410*a448814aSRobert Mustacchi if (stp == NULL) 1411*a448814aSRobert Mustacchi return (-1); /* errno is set for us */ 1412*a448814aSRobert Mustacchi 1413*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_type != SMB_TYPE_TPROBE) 1414*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_TYPE)); 1415*a448814aSRobert Mustacchi 1416*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_len < SMB_TPROBE_MINLEN) 1417*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_SHORT)); 1418*a448814aSRobert Mustacchi 1419*a448814aSRobert Mustacchi bzero(tprobe, sizeof (*tprobe)); 1420*a448814aSRobert Mustacchi smb_info_bcopy(stp->smbst_hdr, &tp, sizeof (tp)); 1421*a448814aSRobert Mustacchi tprobe->smbtp_description = smb_strptr(stp, tp.smbtpr_descr); 1422*a448814aSRobert Mustacchi tprobe->smbtp_location = SMB_TPROBE_LOCATION(tp.smbtpr_locstat); 1423*a448814aSRobert Mustacchi tprobe->smbtp_status = SMB_TPROBE_STATUS(tp.smbtpr_locstat); 1424*a448814aSRobert Mustacchi tprobe->smbtp_maxval = tp.smbtpr_maxval; 1425*a448814aSRobert Mustacchi tprobe->smbtp_minval = tp.smbtpr_minval; 1426*a448814aSRobert Mustacchi tprobe->smbtp_resolution = tp.smbtpr_resolution; 1427*a448814aSRobert Mustacchi tprobe->smbtp_tolerance = tp.smbtpr_tolerance; 1428*a448814aSRobert Mustacchi tprobe->smbtp_accuracy = tp.smbtpr_accuracy; 1429*a448814aSRobert Mustacchi 1430*a448814aSRobert Mustacchi if (stp->smbst_hdr->smbh_len >= SMB_TPROBE_NOMINAL_MINLEN) { 1431*a448814aSRobert Mustacchi tprobe->smbtp_nominal = tp.smbtpr_nominal; 1432*a448814aSRobert Mustacchi } else { 1433*a448814aSRobert Mustacchi tprobe->smbtp_nominal = SMB_PROBE_UNKNOWN_VALUE; 1434*a448814aSRobert Mustacchi } 1435*a448814aSRobert Mustacchi 1436*a448814aSRobert Mustacchi return (0); 1437*a448814aSRobert Mustacchi } 1438*a448814aSRobert Mustacchi 1439*a448814aSRobert Mustacchi int 1440*a448814aSRobert Mustacchi smbios_info_iprobe(smbios_hdl_t *shp, id_t id, smbios_iprobe_t *iprobe) 1441*a448814aSRobert Mustacchi { 1442*a448814aSRobert Mustacchi const smb_struct_t *sip = smb_lookup_id(shp, id); 1443*a448814aSRobert Mustacchi smb_iprobe_t ip; 1444*a448814aSRobert Mustacchi 1445*a448814aSRobert Mustacchi if (sip == NULL) 1446*a448814aSRobert Mustacchi return (-1); /* errno is set for us */ 1447*a448814aSRobert Mustacchi 1448*a448814aSRobert Mustacchi if (sip->smbst_hdr->smbh_type != SMB_TYPE_IPROBE) 1449*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_TYPE)); 1450*a448814aSRobert Mustacchi 1451*a448814aSRobert Mustacchi if (sip->smbst_hdr->smbh_len < SMB_IPROBE_MINLEN) 1452*a448814aSRobert Mustacchi return (smb_set_errno(shp, ESMB_SHORT)); 1453*a448814aSRobert Mustacchi 1454*a448814aSRobert Mustacchi bzero(iprobe, sizeof (*iprobe)); 1455*a448814aSRobert Mustacchi smb_info_bcopy(sip->smbst_hdr, &ip, sizeof (ip)); 1456*a448814aSRobert Mustacchi iprobe->smbip_description = smb_strptr(sip, ip.smbipr_descr); 1457*a448814aSRobert Mustacchi iprobe->smbip_location = SMB_IPROBE_LOCATION(ip.smbipr_locstat); 1458*a448814aSRobert Mustacchi iprobe->smbip_status = SMB_IPROBE_STATUS(ip.smbipr_locstat); 1459*a448814aSRobert Mustacchi iprobe->smbip_maxval = ip.smbipr_maxval; 1460*a448814aSRobert Mustacchi iprobe->smbip_minval = ip.smbipr_minval; 1461*a448814aSRobert Mustacchi iprobe->smbip_resolution = ip.smbipr_resolution; 1462*a448814aSRobert Mustacchi iprobe->smbip_tolerance = ip.smbipr_tolerance; 1463*a448814aSRobert Mustacchi iprobe->smbip_accuracy = ip.smbipr_accuracy; 1464*a448814aSRobert Mustacchi 1465*a448814aSRobert Mustacchi if (sip->smbst_hdr->smbh_len >= SMB_IPROBE_NOMINAL_MINLEN) { 1466*a448814aSRobert Mustacchi iprobe->smbip_nominal = ip.smbipr_nominal; 1467*a448814aSRobert Mustacchi } else { 1468*a448814aSRobert Mustacchi iprobe->smbip_nominal = SMB_PROBE_UNKNOWN_VALUE; 1469*a448814aSRobert Mustacchi } 1470*a448814aSRobert Mustacchi 1471*a448814aSRobert Mustacchi return (0); 1472*a448814aSRobert Mustacchi } 1473