xref: /titanic_44/usr/src/common/smbios/smb_info.c (revision 4e901881a1e657e1cbf12d7ef9b476ec373e7939)
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 /*
23*4e901881SDale Ghent  * Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
2403f9f63dSTom Pothier  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2584ab085aSmws  * Use is subject to license terms.
2684ab085aSmws  */
2784ab085aSmws 
2884ab085aSmws /*
2984ab085aSmws  * SMBIOS Information Routines
3084ab085aSmws  *
3184ab085aSmws  * The routines in this file are used to convert from the SMBIOS data format to
3284ab085aSmws  * a more reasonable and stable set of structures offered as part of our ABI.
3384ab085aSmws  * These functions take the general form:
3484ab085aSmws  *
3584ab085aSmws  *	stp = smb_lookup_type(shp, foo);
3684ab085aSmws  *	smb_foo_t foo;
3784ab085aSmws  *
3884ab085aSmws  *	smb_info_bcopy(stp->smbst_hdr, &foo, sizeof (foo));
3984ab085aSmws  *      bzero(caller's struct);
4084ab085aSmws  *
4184ab085aSmws  *	copy/convert foo members into caller's struct
4284ab085aSmws  *
4384ab085aSmws  * We copy the internal structure on to an automatic variable so as to avoid
4484ab085aSmws  * checks everywhere for structures that the BIOS has improperly truncated, and
4584ab085aSmws  * also to automatically handle the case of a structure that has been extended.
4684ab085aSmws  * When necessary, this code can use smb_gteq() to determine whether the SMBIOS
4784ab085aSmws  * data is of a particular revision that is supposed to contain a new field.
4884ab085aSmws  */
4984ab085aSmws 
5084ab085aSmws #include <sys/smbios_impl.h>
5184ab085aSmws 
529c94f155SCheng Sean Ye #ifdef _KERNEL
539c94f155SCheng Sean Ye #include <sys/sunddi.h>
549c94f155SCheng Sean Ye #else
55c7c09f80SEric Schrock #include <fcntl.h>
56c7c09f80SEric Schrock #include <unistd.h>
579c94f155SCheng Sean Ye #include <string.h>
58c7c09f80SEric Schrock #endif
59c7c09f80SEric Schrock 
6084ab085aSmws /*
6184ab085aSmws  * A large number of SMBIOS structures contain a set of common strings used to
6284ab085aSmws  * describe a h/w component's serial number, manufacturer, etc.  These fields
6384ab085aSmws  * helpfully have different names and offsets and sometimes aren't consistent.
6484ab085aSmws  * To simplify life for our clients, we factor these common things out into
6584ab085aSmws  * smbios_info_t, which can be retrieved for any structure.  The following
6684ab085aSmws  * table describes the mapping from a given structure to the smbios_info_t.
67074bb90dSTom Pothier  * Multiple SMBIOS stuctures' contained objects are also handled here.
6884ab085aSmws  */
6984ab085aSmws static const struct smb_infospec {
7084ab085aSmws 	uint8_t is_type;		/* structure type */
7184ab085aSmws 	uint8_t is_manu;		/* manufacturer offset */
7284ab085aSmws 	uint8_t is_product;		/* product name offset */
7384ab085aSmws 	uint8_t is_version;		/* version offset */
7484ab085aSmws 	uint8_t is_serial;		/* serial number offset */
7584ab085aSmws 	uint8_t is_asset;		/* asset tag offset */
7684ab085aSmws 	uint8_t is_location;		/* location string offset */
7784ab085aSmws 	uint8_t is_part;		/* part number offset */
78074bb90dSTom Pothier 	uint8_t is_contc;		/* contained count */
79074bb90dSTom Pothier 	uint8_t is_contsz;		/* contained size */
80074bb90dSTom Pothier 	uint8_t is_contv;		/* contained objects */
8184ab085aSmws } _smb_infospecs[] = {
8284ab085aSmws 	{ SMB_TYPE_SYSTEM,
8384ab085aSmws 		offsetof(smb_system_t, smbsi_manufacturer),
8484ab085aSmws 		offsetof(smb_system_t, smbsi_product),
8584ab085aSmws 		offsetof(smb_system_t, smbsi_version),
8684ab085aSmws 		offsetof(smb_system_t, smbsi_serial),
8784ab085aSmws 		0,
8884ab085aSmws 		0,
89074bb90dSTom Pothier 		0,
90074bb90dSTom Pothier 		0,
91074bb90dSTom Pothier 		0,
9284ab085aSmws 		0 },
9384ab085aSmws 	{ SMB_TYPE_BASEBOARD,
9484ab085aSmws 		offsetof(smb_bboard_t, smbbb_manufacturer),
9584ab085aSmws 		offsetof(smb_bboard_t, smbbb_product),
9684ab085aSmws 		offsetof(smb_bboard_t, smbbb_version),
9784ab085aSmws 		offsetof(smb_bboard_t, smbbb_serial),
9884ab085aSmws 		offsetof(smb_bboard_t, smbbb_asset),
9984ab085aSmws 		offsetof(smb_bboard_t, smbbb_location),
100074bb90dSTom Pothier 		0,
101074bb90dSTom Pothier 		offsetof(smb_bboard_t, smbbb_cn),
102074bb90dSTom Pothier 		SMB_CONT_WORD,
103074bb90dSTom Pothier 		offsetof(smb_bboard_t, smbbb_cv) },
10484ab085aSmws 	{ SMB_TYPE_CHASSIS,
10584ab085aSmws 		offsetof(smb_chassis_t, smbch_manufacturer),
10684ab085aSmws 		0,
10784ab085aSmws 		offsetof(smb_chassis_t, smbch_version),
10884ab085aSmws 		offsetof(smb_chassis_t, smbch_serial),
10984ab085aSmws 		offsetof(smb_chassis_t, smbch_asset),
11084ab085aSmws 		0,
111074bb90dSTom Pothier 		0,
112074bb90dSTom Pothier 		offsetof(smb_chassis_t, smbch_cn),
113074bb90dSTom Pothier 		SMB_CONT_BYTE,
114074bb90dSTom Pothier 		offsetof(smb_chassis_t, smbch_cv) },
11584ab085aSmws 	{ SMB_TYPE_PROCESSOR,
11684ab085aSmws 		offsetof(smb_processor_t, smbpr_manufacturer),
11784ab085aSmws 		0,
11884ab085aSmws 		offsetof(smb_processor_t, smbpr_version),
11984ab085aSmws 		offsetof(smb_processor_t, smbpr_serial),
12084ab085aSmws 		offsetof(smb_processor_t, smbpr_asset),
12184ab085aSmws 		offsetof(smb_processor_t, smbpr_socket),
122074bb90dSTom Pothier 		offsetof(smb_processor_t, smbpr_part),
123074bb90dSTom Pothier 		0,
124074bb90dSTom Pothier 		0,
125074bb90dSTom Pothier 		0 },
12684ab085aSmws 	{ SMB_TYPE_CACHE,
12784ab085aSmws 		0,
12884ab085aSmws 		0,
12984ab085aSmws 		0,
13084ab085aSmws 		0,
13184ab085aSmws 		0,
13284ab085aSmws 		offsetof(smb_cache_t, smbca_socket),
133074bb90dSTom Pothier 		0,
134074bb90dSTom Pothier 		0,
135074bb90dSTom Pothier 		0,
13684ab085aSmws 		0 },
13784ab085aSmws 	{ SMB_TYPE_PORT,
13884ab085aSmws 		0,
13984ab085aSmws 		0,
14084ab085aSmws 		0,
14184ab085aSmws 		0,
14284ab085aSmws 		0,
14384ab085aSmws 		offsetof(smb_port_t, smbpo_iref),
144074bb90dSTom Pothier 		0,
145074bb90dSTom Pothier 		0,
146074bb90dSTom Pothier 		0,
14784ab085aSmws 		0 },
14884ab085aSmws 	{ SMB_TYPE_SLOT,
14984ab085aSmws 		0,
15084ab085aSmws 		0,
15184ab085aSmws 		0,
15284ab085aSmws 		0,
15384ab085aSmws 		0,
15484ab085aSmws 		offsetof(smb_slot_t, smbsl_name),
155074bb90dSTom Pothier 		0,
156074bb90dSTom Pothier 		0,
157074bb90dSTom Pothier 		0,
15884ab085aSmws 		0 },
15984ab085aSmws 	{ SMB_TYPE_MEMDEVICE,
16084ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_manufacturer),
16184ab085aSmws 		0,
16284ab085aSmws 		0,
16384ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_serial),
16484ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_asset),
16584ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_dloc),
166074bb90dSTom Pothier 		offsetof(smb_memdevice_t, smbmdev_part),
167074bb90dSTom Pothier 		0,
168074bb90dSTom Pothier 		0,
169074bb90dSTom Pothier 		0 },
17084ab085aSmws 	{ SMB_TYPE_POWERSUP,
17184ab085aSmws 		offsetof(smb_powersup_t, smbpsup_manufacturer),
17284ab085aSmws 		offsetof(smb_powersup_t, smbpsup_devname),
17384ab085aSmws 		offsetof(smb_powersup_t, smbpsup_rev),
17484ab085aSmws 		offsetof(smb_powersup_t, smbpsup_serial),
17584ab085aSmws 		offsetof(smb_powersup_t, smbpsup_asset),
17684ab085aSmws 		offsetof(smb_powersup_t, smbpsup_loc),
177074bb90dSTom Pothier 		offsetof(smb_powersup_t, smbpsup_part),
178074bb90dSTom Pothier 		0,
179074bb90dSTom Pothier 		0,
180074bb90dSTom Pothier 		0 },
18184ab085aSmws 	{ SMB_TYPE_EOT }
18284ab085aSmws };
18384ab085aSmws 
18484ab085aSmws static const char *
18584ab085aSmws smb_info_strptr(const smb_struct_t *stp, uint8_t off, int *n)
18684ab085aSmws {
18784ab085aSmws 	const uint8_t *sp = (const uint8_t *)(uintptr_t)stp->smbst_hdr;
18884ab085aSmws 
18984ab085aSmws 	if (off != 0 && sp + off < stp->smbst_end) {
19084ab085aSmws 		(*n)++; /* indicate success for caller */
19184ab085aSmws 		return (smb_strptr(stp, sp[off]));
19284ab085aSmws 	}
19384ab085aSmws 
19484ab085aSmws 	return (smb_strptr(stp, 0));
19584ab085aSmws }
19684ab085aSmws 
19784ab085aSmws static void
19884ab085aSmws smb_info_bcopy(const smb_header_t *hp, void *dst, size_t dstlen)
19984ab085aSmws {
20084ab085aSmws 	if (dstlen > hp->smbh_len) {
20184ab085aSmws 		bcopy(hp, dst, hp->smbh_len);
20284ab085aSmws 		bzero((char *)dst + hp->smbh_len, dstlen - hp->smbh_len);
20384ab085aSmws 	} else
20484ab085aSmws 		bcopy(hp, dst, dstlen);
20584ab085aSmws }
20684ab085aSmws 
20784ab085aSmws void
20884ab085aSmws smbios_info_smbios(smbios_hdl_t *shp, smbios_entry_t *ep)
20984ab085aSmws {
21084ab085aSmws 	bcopy(&shp->sh_ent, ep, sizeof (smbios_entry_t));
21184ab085aSmws }
21284ab085aSmws 
213c7c09f80SEric Schrock #ifndef _KERNEL
214c7c09f80SEric Schrock static char smbios_product_override[256];
215c7c09f80SEric Schrock static boolean_t smbios_product_checked;
216c7c09f80SEric Schrock #endif
217c7c09f80SEric Schrock 
21884ab085aSmws int
21984ab085aSmws smbios_info_common(smbios_hdl_t *shp, id_t id, smbios_info_t *ip)
22084ab085aSmws {
22184ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
22284ab085aSmws 	const struct smb_infospec *isp;
22384ab085aSmws 	int n = 0;
22484ab085aSmws 
22584ab085aSmws 	if (stp == NULL)
22684ab085aSmws 		return (-1); /* errno is set for us */
22784ab085aSmws 
22884ab085aSmws 	for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
22984ab085aSmws 		if (isp->is_type == stp->smbst_hdr->smbh_type)
23084ab085aSmws 			break;
23184ab085aSmws 	}
23284ab085aSmws 
23384ab085aSmws 	ip->smbi_manufacturer = smb_info_strptr(stp, isp->is_manu, &n);
23484ab085aSmws 	ip->smbi_product = smb_info_strptr(stp, isp->is_product, &n);
23584ab085aSmws 	ip->smbi_version = smb_info_strptr(stp, isp->is_version, &n);
23684ab085aSmws 	ip->smbi_serial = smb_info_strptr(stp, isp->is_serial, &n);
23784ab085aSmws 	ip->smbi_asset = smb_info_strptr(stp, isp->is_asset, &n);
23884ab085aSmws 	ip->smbi_location = smb_info_strptr(stp, isp->is_location, &n);
23984ab085aSmws 	ip->smbi_part = smb_info_strptr(stp, isp->is_part, &n);
24084ab085aSmws 
24184ab085aSmws 	/*
242c7c09f80SEric Schrock 	 * This private file allows developers to experiment with reporting
243c7c09f80SEric Schrock 	 * different platform strings from SMBIOS.  It is not a supported
244c7c09f80SEric Schrock 	 * mechanism in the long term, and does not work in the kernel.
245c7c09f80SEric Schrock 	 */
246c7c09f80SEric Schrock #ifndef _KERNEL
247c7c09f80SEric Schrock 	if (isp->is_type == SMB_TYPE_SYSTEM) {
248c7c09f80SEric Schrock 		if (!smbios_product_checked) {
249c7c09f80SEric Schrock 			int fd = open("/etc/smbios_product", O_RDONLY);
250c7c09f80SEric Schrock 			if (fd >= 0) {
251c7c09f80SEric Schrock 				(void) read(fd, smbios_product_override,
252c7c09f80SEric Schrock 				    sizeof (smbios_product_override) - 1);
253c7c09f80SEric Schrock 				(void) close(fd);
254c7c09f80SEric Schrock 			}
255c7c09f80SEric Schrock 			smbios_product_checked = B_TRUE;
256c7c09f80SEric Schrock 		}
257c7c09f80SEric Schrock 
258c7c09f80SEric Schrock 		if (smbios_product_override[0] != '\0')
259c7c09f80SEric Schrock 			ip->smbi_product = smbios_product_override;
260c7c09f80SEric Schrock 	}
261c7c09f80SEric Schrock #endif
262c7c09f80SEric Schrock 
263c7c09f80SEric Schrock 	/*
26484ab085aSmws 	 * If we have a port with an empty internal reference designator string
26584ab085aSmws 	 * try using the external reference designator string instead.
26684ab085aSmws 	 */
26784ab085aSmws 	if (isp->is_type == SMB_TYPE_PORT && ip->smbi_location[0] == '\0') {
26884ab085aSmws 		ip->smbi_location = smb_info_strptr(stp,
26984ab085aSmws 		    offsetof(smb_port_t, smbpo_eref), &n);
27084ab085aSmws 	}
27184ab085aSmws 
27284ab085aSmws 	return (n ? 0 : smb_set_errno(shp, ESMB_NOINFO));
27384ab085aSmws }
27484ab085aSmws 
275074bb90dSTom Pothier /*
276074bb90dSTom Pothier  * Returns the actual number of contained objects.
277074bb90dSTom Pothier  *
278074bb90dSTom Pothier  * idc - number of contained objects
279074bb90dSTom Pothier  * idv - returned array of contained objects
280074bb90dSTom Pothier  */
281074bb90dSTom Pothier int
282074bb90dSTom Pothier smbios_info_contains(smbios_hdl_t *shp, id_t id, uint_t idc, id_t *idv)
283074bb90dSTom Pothier {
284074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
285074bb90dSTom Pothier 	const struct smb_infospec *isp;
286074bb90dSTom Pothier 	id_t *cp;
287074bb90dSTom Pothier 	uint_t size;
288074bb90dSTom Pothier 	uint8_t cnt;
289074bb90dSTom Pothier 	int i, n;
290074bb90dSTom Pothier 
291074bb90dSTom Pothier 	if (stp == NULL) {
292074bb90dSTom Pothier 		return (-1); /* errno is set for us */
293074bb90dSTom Pothier 	}
294074bb90dSTom Pothier 
295074bb90dSTom Pothier 	for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
296074bb90dSTom Pothier 		if (isp->is_type == stp->smbst_hdr->smbh_type)
297074bb90dSTom Pothier 			break;
298074bb90dSTom Pothier 	}
299074bb90dSTom Pothier 	if (isp->is_type == SMB_TYPE_EOT)
300074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
301074bb90dSTom Pothier 
302074bb90dSTom Pothier 	size = isp->is_contsz;
303074bb90dSTom Pothier 	cnt = *((uint8_t *)(uintptr_t)stp->smbst_hdr + isp->is_contc);
304074bb90dSTom Pothier 	cp = (id_t *)((uintptr_t)stp->smbst_hdr + isp->is_contv);
305074bb90dSTom Pothier 
306074bb90dSTom Pothier 	n = MIN(cnt, idc);
307074bb90dSTom Pothier 	for (i = 0; i < n; i++) {
308074bb90dSTom Pothier 		if (size == SMB_CONT_WORD)
309074bb90dSTom Pothier 			idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 2));
310074bb90dSTom Pothier 		else if (size == SMB_CONT_BYTE)
311074bb90dSTom Pothier 			idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 3));
312074bb90dSTom Pothier 		else
313074bb90dSTom Pothier 			return (smb_set_errno(shp, ESMB_INVAL));
314074bb90dSTom Pothier 	}
315074bb90dSTom Pothier 
316074bb90dSTom Pothier 	return (cnt);
317074bb90dSTom Pothier }
318074bb90dSTom Pothier 
31984ab085aSmws id_t
32084ab085aSmws smbios_info_bios(smbios_hdl_t *shp, smbios_bios_t *bp)
32184ab085aSmws {
32284ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BIOS);
32384ab085aSmws 	const smb_bios_t *bip;
32484ab085aSmws 
32584ab085aSmws 	if (stp == NULL)
32684ab085aSmws 		return (-1); /* errno is set for us */
32784ab085aSmws 
32884ab085aSmws 	if (stp->smbst_hdr->smbh_len < sizeof (smb_bios_t) - sizeof (uint8_t))
32984ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
33084ab085aSmws 
33184ab085aSmws 	bip = (smb_bios_t *)(uintptr_t)stp->smbst_hdr;
33284ab085aSmws 	bzero(bp, sizeof (smbios_bios_t));
33384ab085aSmws 
33484ab085aSmws 	bp->smbb_vendor = smb_strptr(stp, bip->smbbi_vendor);
33584ab085aSmws 	bp->smbb_version = smb_strptr(stp, bip->smbbi_version);
33684ab085aSmws 	bp->smbb_segment = bip->smbbi_segment;
33784ab085aSmws 	bp->smbb_reldate = smb_strptr(stp, bip->smbbi_reldate);
33884ab085aSmws 	bp->smbb_romsize = 64 * 1024 * ((uint32_t)bip->smbbi_romsize + 1);
33984ab085aSmws 	bp->smbb_runsize = 16 * (0x10000 - (uint32_t)bip->smbbi_segment);
34084ab085aSmws 	bp->smbb_cflags = bip->smbbi_cflags;
34184ab085aSmws 
34284ab085aSmws 	/*
34384ab085aSmws 	 * If one or more extension bytes are present, reset smbb_xcflags to
34484ab085aSmws 	 * point to them.  Otherwise leave this member set to NULL.
34584ab085aSmws 	 */
34684ab085aSmws 	if (stp->smbst_hdr->smbh_len >= sizeof (smb_bios_t)) {
34784ab085aSmws 		bp->smbb_xcflags = bip->smbbi_xcflags;
34884ab085aSmws 		bp->smbb_nxcflags = stp->smbst_hdr->smbh_len -
34984ab085aSmws 		    sizeof (smb_bios_t) + 1;
35084ab085aSmws 
35184ab085aSmws 		if (bp->smbb_nxcflags > SMB_BIOSXB_ECFW_MIN &&
35284ab085aSmws 		    smb_gteq(shp, SMB_VERSION_24)) {
35384ab085aSmws 			bp->smbb_biosv.smbv_major =
35484ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MAJ];
35584ab085aSmws 			bp->smbb_biosv.smbv_minor =
35684ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MIN];
35784ab085aSmws 			bp->smbb_ecfwv.smbv_major =
35884ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MAJ];
35984ab085aSmws 			bp->smbb_ecfwv.smbv_minor =
36084ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MIN];
36184ab085aSmws 		}
36284ab085aSmws 	}
36384ab085aSmws 
36484ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
36584ab085aSmws }
36684ab085aSmws 
36784ab085aSmws id_t
36884ab085aSmws smbios_info_system(smbios_hdl_t *shp, smbios_system_t *sip)
36984ab085aSmws {
37084ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM);
37184ab085aSmws 	smb_system_t si;
37284ab085aSmws 
37384ab085aSmws 	if (stp == NULL)
37484ab085aSmws 		return (-1); /* errno is set for us */
37584ab085aSmws 
37684ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &si, sizeof (si));
37784ab085aSmws 	bzero(sip, sizeof (smbios_system_t));
37884ab085aSmws 
37984ab085aSmws 	sip->smbs_uuid = ((smb_system_t *)stp->smbst_hdr)->smbsi_uuid;
38084ab085aSmws 	sip->smbs_uuidlen = sizeof (si.smbsi_uuid);
38184ab085aSmws 	sip->smbs_wakeup = si.smbsi_wakeup;
38284ab085aSmws 	sip->smbs_sku = smb_strptr(stp, si.smbsi_sku);
38384ab085aSmws 	sip->smbs_family = smb_strptr(stp, si.smbsi_family);
38484ab085aSmws 
38584ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
38684ab085aSmws }
38784ab085aSmws 
38884ab085aSmws int
38984ab085aSmws smbios_info_bboard(smbios_hdl_t *shp, id_t id, smbios_bboard_t *bbp)
39084ab085aSmws {
39184ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
39284ab085aSmws 	smb_bboard_t bb;
39384ab085aSmws 
39484ab085aSmws 	if (stp == NULL)
39584ab085aSmws 		return (-1); /* errno is set for us */
39684ab085aSmws 
39784ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_BASEBOARD)
39884ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
39984ab085aSmws 
40084ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &bb, sizeof (bb));
40184ab085aSmws 	bzero(bbp, sizeof (smbios_bboard_t));
40284ab085aSmws 
40384ab085aSmws 	bbp->smbb_chassis = bb.smbbb_chassis;
40484ab085aSmws 	bbp->smbb_flags = bb.smbbb_flags;
40584ab085aSmws 	bbp->smbb_type = bb.smbbb_type;
406074bb90dSTom Pothier 	bbp->smbb_contn = bb.smbbb_cn;
40784ab085aSmws 
40884ab085aSmws 	return (0);
40984ab085aSmws }
41084ab085aSmws 
41184ab085aSmws int
41284ab085aSmws smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp)
41384ab085aSmws {
41484ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
415*4e901881SDale Ghent 	/* Length is measurable by one byte, so it'll be no more than 255. */
416*4e901881SDale Ghent 	uint8_t buf[256];
417*4e901881SDale Ghent 	smb_chassis_t *ch = (smb_chassis_t *)&buf[0];
41884ab085aSmws 
41984ab085aSmws 	if (stp == NULL)
42084ab085aSmws 		return (-1); /* errno is set for us */
42184ab085aSmws 
42284ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS)
42384ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
42484ab085aSmws 
425*4e901881SDale Ghent 	smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf));
42684ab085aSmws 	bzero(chp, sizeof (smbios_chassis_t));
42784ab085aSmws 
428*4e901881SDale Ghent 	chp->smbc_oemdata = ch->smbch_oemdata;
429*4e901881SDale Ghent 	chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0;
430*4e901881SDale Ghent 	chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK;
431*4e901881SDale Ghent 	chp->smbc_bustate = ch->smbch_bustate;
432*4e901881SDale Ghent 	chp->smbc_psstate = ch->smbch_psstate;
433*4e901881SDale Ghent 	chp->smbc_thstate = ch->smbch_thstate;
434*4e901881SDale Ghent 	chp->smbc_security = ch->smbch_security;
435*4e901881SDale Ghent 	chp->smbc_uheight = ch->smbch_uheight;
436*4e901881SDale Ghent 	chp->smbc_cords = ch->smbch_cords;
437*4e901881SDale Ghent 	chp->smbc_elems = ch->smbch_cn;
438*4e901881SDale Ghent 	chp->smbc_elemlen = ch->smbch_cm;
439*4e901881SDale Ghent 
440*4e901881SDale Ghent 	if (shp->sh_smbvers >= SMB_VERSION_27) {
441*4e901881SDale Ghent 		(void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch),
442*4e901881SDale Ghent 		    sizeof (chp->smbc_sku));
443*4e901881SDale Ghent 	}
44484ab085aSmws 
44584ab085aSmws 	return (0);
44684ab085aSmws }
44784ab085aSmws 
44884ab085aSmws int
44984ab085aSmws smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp)
45084ab085aSmws {
45184ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
45284ab085aSmws 	smb_processor_t p;
45384ab085aSmws 
45484ab085aSmws 	if (stp == NULL)
45584ab085aSmws 		return (-1); /* errno is set for us */
45684ab085aSmws 
45784ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_PROCESSOR)
45884ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
45984ab085aSmws 
46084ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
46184ab085aSmws 	bzero(pp, sizeof (smbios_processor_t));
46284ab085aSmws 
46384ab085aSmws 	pp->smbp_cpuid = p.smbpr_cpuid;
46484ab085aSmws 	pp->smbp_type = p.smbpr_type;
46584ab085aSmws 	pp->smbp_family = p.smbpr_family;
46684ab085aSmws 	pp->smbp_voltage = p.smbpr_voltage;
46784ab085aSmws 	pp->smbp_maxspeed = p.smbpr_maxspeed;
46884ab085aSmws 	pp->smbp_curspeed = p.smbpr_curspeed;
46984ab085aSmws 	pp->smbp_status = p.smbpr_status;
47084ab085aSmws 	pp->smbp_upgrade = p.smbpr_upgrade;
47184ab085aSmws 	pp->smbp_l1cache = p.smbpr_l1cache;
47284ab085aSmws 	pp->smbp_l2cache = p.smbpr_l2cache;
47384ab085aSmws 	pp->smbp_l3cache = p.smbpr_l3cache;
47484ab085aSmws 
475*4e901881SDale Ghent 	if (shp->sh_smbvers >= SMB_VERSION_25) {
476*4e901881SDale Ghent 		pp->smbp_corecount = p.smbpr_corecount;
477*4e901881SDale Ghent 		pp->smbp_coresenabled = p.smbpr_coresenabled;
478*4e901881SDale Ghent 		pp->smbp_threadcount = p.smbpr_threadcount;
479*4e901881SDale Ghent 		pp->smbp_cflags = p.smbpr_cflags;
480*4e901881SDale Ghent 	}
481*4e901881SDale Ghent 
482*4e901881SDale Ghent 	if (shp->sh_smbvers >= SMB_VERSION_26)
483*4e901881SDale Ghent 		pp->smbp_family2 = p.smbpr_family2;
484*4e901881SDale Ghent 
48584ab085aSmws 	return (0);
48684ab085aSmws }
48784ab085aSmws 
48884ab085aSmws int
48984ab085aSmws smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap)
49084ab085aSmws {
49184ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
49284ab085aSmws 	smb_cache_t c;
49384ab085aSmws 
49484ab085aSmws 	if (stp == NULL)
49584ab085aSmws 		return (-1); /* errno is set for us */
49684ab085aSmws 
49784ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_CACHE)
49884ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
49984ab085aSmws 
50084ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &c, sizeof (c));
50184ab085aSmws 	bzero(cap, sizeof (smbios_cache_t));
50284ab085aSmws 
50384ab085aSmws 	cap->smba_maxsize = SMB_CACHE_SIZE(c.smbca_maxsize);
50484ab085aSmws 	cap->smba_size = SMB_CACHE_SIZE(c.smbca_size);
50584ab085aSmws 	cap->smba_stype = c.smbca_stype;
50684ab085aSmws 	cap->smba_ctype = c.smbca_ctype;
50784ab085aSmws 	cap->smba_speed = c.smbca_speed;
50884ab085aSmws 	cap->smba_etype = c.smbca_etype;
50984ab085aSmws 	cap->smba_ltype = c.smbca_ltype;
51084ab085aSmws 	cap->smba_assoc = c.smbca_assoc;
51184ab085aSmws 	cap->smba_level = SMB_CACHE_CFG_LEVEL(c.smbca_config);
51284ab085aSmws 	cap->smba_mode = SMB_CACHE_CFG_MODE(c.smbca_config);
51384ab085aSmws 	cap->smba_location = SMB_CACHE_CFG_LOCATION(c.smbca_config);
51484ab085aSmws 
51584ab085aSmws 	if (SMB_CACHE_CFG_ENABLED(c.smbca_config))
51684ab085aSmws 		cap->smba_flags |= SMB_CAF_ENABLED;
51784ab085aSmws 
51884ab085aSmws 	if (SMB_CACHE_CFG_SOCKETED(c.smbca_config))
51984ab085aSmws 		cap->smba_flags |= SMB_CAF_SOCKETED;
52084ab085aSmws 
52184ab085aSmws 	return (0);
52284ab085aSmws }
52384ab085aSmws 
52484ab085aSmws int
52584ab085aSmws smbios_info_port(smbios_hdl_t *shp, id_t id, smbios_port_t *pop)
52684ab085aSmws {
52784ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
52884ab085aSmws 	smb_port_t p;
52984ab085aSmws 
53084ab085aSmws 	if (stp == NULL)
53184ab085aSmws 		return (-1); /* errno is set for us */
53284ab085aSmws 
53384ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_PORT)
53484ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
53584ab085aSmws 
53684ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
53784ab085aSmws 	bzero(pop, sizeof (smbios_port_t));
53884ab085aSmws 
53984ab085aSmws 	pop->smbo_iref = smb_strptr(stp, p.smbpo_iref);
54084ab085aSmws 	pop->smbo_eref = smb_strptr(stp, p.smbpo_eref);
54184ab085aSmws 
54284ab085aSmws 	pop->smbo_itype = p.smbpo_itype;
54384ab085aSmws 	pop->smbo_etype = p.smbpo_etype;
54484ab085aSmws 	pop->smbo_ptype = p.smbpo_ptype;
54584ab085aSmws 
54684ab085aSmws 	return (0);
54784ab085aSmws }
54884ab085aSmws 
54984ab085aSmws int
55084ab085aSmws smbios_info_slot(smbios_hdl_t *shp, id_t id, smbios_slot_t *sp)
55184ab085aSmws {
55284ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
55384ab085aSmws 	smb_slot_t s;
55484ab085aSmws 
55584ab085aSmws 	if (stp == NULL)
55684ab085aSmws 		return (-1); /* errno is set for us */
55784ab085aSmws 
55884ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT)
55984ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
56084ab085aSmws 
56184ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
56284ab085aSmws 	bzero(sp, sizeof (smbios_slot_t));
56384ab085aSmws 
56484ab085aSmws 	sp->smbl_name = smb_strptr(stp, s.smbsl_name);
56584ab085aSmws 	sp->smbl_type = s.smbsl_type;
56684ab085aSmws 	sp->smbl_width = s.smbsl_width;
56784ab085aSmws 	sp->smbl_usage = s.smbsl_usage;
56884ab085aSmws 	sp->smbl_length = s.smbsl_length;
56984ab085aSmws 	sp->smbl_id = s.smbsl_id;
57084ab085aSmws 	sp->smbl_ch1 = s.smbsl_ch1;
57184ab085aSmws 	sp->smbl_ch2 = s.smbsl_ch2;
57203f9f63dSTom Pothier 	sp->smbl_sg = s.smbsl_sg;
57303f9f63dSTom Pothier 	sp->smbl_bus = s.smbsl_bus;
57403f9f63dSTom Pothier 	sp->smbl_df = s.smbsl_df;
57503f9f63dSTom Pothier 
57603f9f63dSTom Pothier 	return (0);
57703f9f63dSTom Pothier }
57803f9f63dSTom Pothier 
57903f9f63dSTom Pothier int
58003f9f63dSTom Pothier smbios_info_obdevs_ext(smbios_hdl_t *shp, id_t id, smbios_obdev_ext_t *oep)
58103f9f63dSTom Pothier {
58203f9f63dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
58303f9f63dSTom Pothier 	smb_obdev_ext_t obe;
58403f9f63dSTom Pothier 
58503f9f63dSTom Pothier 	if (stp == NULL)
58603f9f63dSTom Pothier 		return (-1); /* errno is set for us */
58703f9f63dSTom Pothier 
58803f9f63dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVEXT)
58903f9f63dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
59003f9f63dSTom Pothier 
59103f9f63dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &obe, sizeof (obe));
59203f9f63dSTom Pothier 	bzero(oep, sizeof (smbios_obdev_ext_t));
59303f9f63dSTom Pothier 
59403f9f63dSTom Pothier 	oep->smboe_name = smb_strptr(stp, obe.smbobe_name);
59503f9f63dSTom Pothier 	oep->smboe_dtype = obe.smbobe_dtype;
59603f9f63dSTom Pothier 	oep->smboe_dti = obe.smbobe_dti;
59703f9f63dSTom Pothier 	oep->smboe_sg = obe.smbobe_sg;
59803f9f63dSTom Pothier 	oep->smboe_bus = obe.smbobe_bus;
59903f9f63dSTom Pothier 	oep->smboe_df = obe.smbobe_df;
60084ab085aSmws 
60184ab085aSmws 	return (0);
60284ab085aSmws }
60384ab085aSmws 
60484ab085aSmws int
60584ab085aSmws smbios_info_obdevs(smbios_hdl_t *shp, id_t id, int obc, smbios_obdev_t *obp)
60684ab085aSmws {
60784ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
60884ab085aSmws 	const smb_obdev_t *op;
60984ab085aSmws 	int i, m, n;
61084ab085aSmws 
61184ab085aSmws 	if (stp == NULL)
61284ab085aSmws 		return (-1); /* errno is set for us */
61384ab085aSmws 
61484ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVS)
61584ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
61684ab085aSmws 
61784ab085aSmws 	op = (smb_obdev_t *)((uintptr_t)stp->smbst_hdr + sizeof (smb_header_t));
61884ab085aSmws 	m = (stp->smbst_hdr->smbh_len - sizeof (smb_header_t)) / sizeof (*op);
61984ab085aSmws 	n = MIN(m, obc);
62084ab085aSmws 
62184ab085aSmws 	for (i = 0; i < n; i++, op++, obp++) {
62284ab085aSmws 		obp->smbd_name = smb_strptr(stp, op->smbob_name);
62384ab085aSmws 		obp->smbd_type = op->smbob_type & ~SMB_OBT_ENABLED;
62484ab085aSmws 		obp->smbd_enabled = (op->smbob_type & SMB_OBT_ENABLED) != 0;
62584ab085aSmws 	}
62684ab085aSmws 
62784ab085aSmws 	return (m);
62884ab085aSmws }
62984ab085aSmws 
63084ab085aSmws /*
63184ab085aSmws  * The implementation structures for OEMSTR, SYSCONFSTR, and LANG all use the
63284ab085aSmws  * first byte to indicate the size of a string table at the end of the record.
63384ab085aSmws  * Therefore, smbios_info_strtab() can be used to retrieve the table size and
63484ab085aSmws  * strings for any of these underlying record types.
63584ab085aSmws  */
63684ab085aSmws int
63784ab085aSmws smbios_info_strtab(smbios_hdl_t *shp, id_t id, int argc, const char *argv[])
63884ab085aSmws {
63984ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
64084ab085aSmws 	smb_strtab_t s;
64184ab085aSmws 	int i, n;
64284ab085aSmws 
64384ab085aSmws 	if (stp == NULL)
64484ab085aSmws 		return (-1); /* errno is set for us */
64584ab085aSmws 
64684ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR &&
64784ab085aSmws 	    stp->smbst_hdr->smbh_type != SMB_TYPE_SYSCONFSTR &&
64884ab085aSmws 	    stp->smbst_hdr->smbh_type != SMB_TYPE_LANG)
64984ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
65084ab085aSmws 
65184ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
65284ab085aSmws 	n = MIN(s.smbtb_count, argc);
65384ab085aSmws 
65484ab085aSmws 	for (i = 0; i < n; i++)
65584ab085aSmws 		argv[i] = smb_strptr(stp, i + 1);
65684ab085aSmws 
65784ab085aSmws 	return (s.smbtb_count);
65884ab085aSmws }
65984ab085aSmws 
66084ab085aSmws id_t
66184ab085aSmws smbios_info_lang(smbios_hdl_t *shp, smbios_lang_t *lp)
66284ab085aSmws {
66384ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_LANG);
66484ab085aSmws 	smb_lang_t l;
66584ab085aSmws 
66684ab085aSmws 	if (stp == NULL)
66784ab085aSmws 		return (-1); /* errno is set for us */
66884ab085aSmws 
66984ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &l, sizeof (l));
67084ab085aSmws 	bzero(lp, sizeof (smbios_lang_t));
67184ab085aSmws 
67284ab085aSmws 	lp->smbla_cur = smb_strptr(stp, l.smblang_cur);
67384ab085aSmws 	lp->smbla_fmt = l.smblang_flags & 1;
67484ab085aSmws 	lp->smbla_num = l.smblang_num;
67584ab085aSmws 
67684ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
67784ab085aSmws }
67884ab085aSmws 
67984ab085aSmws id_t
68084ab085aSmws smbios_info_eventlog(smbios_hdl_t *shp, smbios_evlog_t *evp)
68184ab085aSmws {
68284ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_EVENTLOG);
68384ab085aSmws 	const smb_sel_t *sel;
68484ab085aSmws 	size_t len;
68584ab085aSmws 
68684ab085aSmws 	if (stp == NULL)
68784ab085aSmws 		return (-1); /* errno is set for us */
68884ab085aSmws 
68984ab085aSmws 	if (stp->smbst_hdr->smbh_len < sizeof (smb_sel_t) - sizeof (uint8_t))
69084ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
69184ab085aSmws 
69284ab085aSmws 	sel = (smb_sel_t *)(uintptr_t)stp->smbst_hdr;
69384ab085aSmws 	len = stp->smbst_hdr->smbh_len - sizeof (smb_sel_t) + sizeof (uint8_t);
69484ab085aSmws 	bzero(evp, sizeof (smbios_evlog_t));
69584ab085aSmws 
69684ab085aSmws 	if (len < sel->smbsel_typec * sel->smbsel_typesz)
69784ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
69884ab085aSmws 
69984ab085aSmws 	evp->smbev_size = sel->smbsel_len;
70084ab085aSmws 	evp->smbev_hdr = sel->smbsel_hdroff;
70184ab085aSmws 	evp->smbev_data = sel->smbsel_dataoff;
70284ab085aSmws 	evp->smbev_method = sel->smbsel_method;
70384ab085aSmws 	evp->smbev_flags = sel->smbsel_status;
70484ab085aSmws 	evp->smbev_format = sel->smbsel_format;
70584ab085aSmws 	evp->smbev_token = sel->smbsel_token;
70684ab085aSmws 	evp->smbev_addr.eva_addr = sel->smbsel_addr;
70784ab085aSmws 
70884ab085aSmws 	if (sel->smbsel_typesz == sizeof (smbios_evtype_t)) {
70984ab085aSmws 		evp->smbev_typec = sel->smbsel_typec;
71084ab085aSmws 		evp->smbev_typev = (void *)(uintptr_t)sel->smbsel_typev;
71184ab085aSmws 	}
71284ab085aSmws 
71384ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
71484ab085aSmws }
71584ab085aSmws 
71684ab085aSmws int
71784ab085aSmws smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map)
71884ab085aSmws {
71984ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
72084ab085aSmws 	smb_memarray_t m;
72184ab085aSmws 
72284ab085aSmws 	if (stp == NULL)
72384ab085aSmws 		return (-1); /* errno is set for us */
72484ab085aSmws 
72584ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAY)
72684ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
72784ab085aSmws 
72884ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
72984ab085aSmws 	bzero(map, sizeof (smbios_memarray_t));
73084ab085aSmws 
73184ab085aSmws 	map->smbma_location = m.smbmarr_loc;
73284ab085aSmws 	map->smbma_use = m.smbmarr_use;
73384ab085aSmws 	map->smbma_ecc = m.smbmarr_ecc;
73484ab085aSmws 	map->smbma_ndevs = m.smbmarr_ndevs;
73584ab085aSmws 	map->smbma_err = m.smbmarr_err;
73684ab085aSmws 
73784ab085aSmws 	if (m.smbmarr_cap != 0x80000000)
73884ab085aSmws 		map->smbma_size = (uint64_t)m.smbmarr_cap * 1024;
739*4e901881SDale Ghent 	else if (m.smbmarr_extcap != 0)
740*4e901881SDale Ghent 		map->smbma_size = m.smbmarr_extcap;
74184ab085aSmws 	else
74284ab085aSmws 		map->smbma_size = 0; /* unknown */
74384ab085aSmws 
74484ab085aSmws 	return (0);
74584ab085aSmws }
74684ab085aSmws 
74784ab085aSmws int
74884ab085aSmws smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map)
74984ab085aSmws {
75084ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
75184ab085aSmws 	smb_memarrmap_t m;
75284ab085aSmws 
75384ab085aSmws 	if (stp == NULL)
75484ab085aSmws 		return (-1); /* errno is set for us */
75584ab085aSmws 
75684ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP)
75784ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
75884ab085aSmws 
75984ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
76084ab085aSmws 	bzero(map, sizeof (smbios_memarrmap_t));
76184ab085aSmws 
76284ab085aSmws 	map->smbmam_array = m.smbamap_array;
76384ab085aSmws 	map->smbmam_width = m.smbamap_width;
764*4e901881SDale Ghent 
765*4e901881SDale Ghent 	if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) {
76684ab085aSmws 		map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
76784ab085aSmws 		map->smbmam_size = (uint64_t)
76884ab085aSmws 		    (m.smbamap_end - m.smbamap_start + 1) * 1024;
769*4e901881SDale Ghent 	} else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) {
770*4e901881SDale Ghent 		map->smbmam_addr = m.smbamap_extstart;
771*4e901881SDale Ghent 		map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1;
772*4e901881SDale Ghent 	}
77384ab085aSmws 
77484ab085aSmws 	return (0);
77584ab085aSmws }
77684ab085aSmws 
77784ab085aSmws int
77884ab085aSmws smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp)
77984ab085aSmws {
78084ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
78184ab085aSmws 	smb_memdevice_t m;
78284ab085aSmws 
78384ab085aSmws 	if (stp == NULL)
78484ab085aSmws 		return (-1); /* errno is set for us */
78584ab085aSmws 
78684ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICE)
78784ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
78884ab085aSmws 
78984ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
79084ab085aSmws 	bzero(mdp, sizeof (smbios_memdevice_t));
79184ab085aSmws 
79284ab085aSmws 	mdp->smbmd_array = m.smbmdev_array;
79384ab085aSmws 	mdp->smbmd_error = m.smbmdev_error;
79484ab085aSmws 	mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth;
79584ab085aSmws 	mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth;
79684ab085aSmws 
797*4e901881SDale Ghent 	if (m.smbmdev_size == 0x7FFF) {
798*4e901881SDale Ghent 		mdp->smbmd_size = (uint64_t)m.smbmdev_extsize;
799*4e901881SDale Ghent 		mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */
800*4e901881SDale Ghent 	} else if (m.smbmdev_size != 0xFFFF) {
80184ab085aSmws 		mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES);
80284ab085aSmws 		if (m.smbmdev_size & SMB_MDS_KBYTES)
80384ab085aSmws 			mdp->smbmd_size *= 1024;
80484ab085aSmws 		else
80584ab085aSmws 			mdp->smbmd_size *= 1024 * 1024;
80684ab085aSmws 	} else
80784ab085aSmws 		mdp->smbmd_size = -1ULL; /* size unknown */
80884ab085aSmws 
80984ab085aSmws 	mdp->smbmd_form = m.smbmdev_form;
81084ab085aSmws 	mdp->smbmd_set = m.smbmdev_set;
81184ab085aSmws 	mdp->smbmd_type = m.smbmdev_type;
812*4e901881SDale Ghent 	mdp->smbmd_speed = m.smbmdev_speed;
81384ab085aSmws 	mdp->smbmd_flags = m.smbmdev_flags;
81484ab085aSmws 	mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc);
81584ab085aSmws 	mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc);
81684ab085aSmws 
817*4e901881SDale Ghent 	if (shp->sh_smbvers >= SMB_VERSION_26)
818*4e901881SDale Ghent 		mdp->smbmd_rank = m.smbmdev_attrs & 0x0F;
819*4e901881SDale Ghent 
820*4e901881SDale Ghent 	if (shp->sh_smbvers >= SMB_VERSION_27)
821*4e901881SDale Ghent 		mdp->smbmd_clkspeed = m.smbmdev_clkspeed;
822*4e901881SDale Ghent 
823*4e901881SDale Ghent 	if (shp->sh_smbvers >= SMB_VERSION_28) {
824*4e901881SDale Ghent 		mdp->smbmd_minvolt = m.smbmdev_minvolt;
825*4e901881SDale Ghent 		mdp->smbmd_maxvolt = m.smbmdev_maxvolt;
826*4e901881SDale Ghent 		mdp->smbmd_confvolt = m.smbmdev_confvolt;
827*4e901881SDale Ghent 	}
82884ab085aSmws 
82984ab085aSmws 	return (0);
83084ab085aSmws }
83184ab085aSmws 
83284ab085aSmws int
83384ab085aSmws smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp)
83484ab085aSmws {
83584ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
83684ab085aSmws 	smb_memdevmap_t m;
83784ab085aSmws 
83884ab085aSmws 	if (stp == NULL)
83984ab085aSmws 		return (-1); /* errno is set for us */
84084ab085aSmws 
84184ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP)
84284ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
84384ab085aSmws 
84484ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
84584ab085aSmws 	bzero(mdp, sizeof (smbios_memdevmap_t));
84684ab085aSmws 
84784ab085aSmws 	mdp->smbmdm_device = m.smbdmap_device;
84884ab085aSmws 	mdp->smbmdm_arrmap = m.smbdmap_array;
84984ab085aSmws 	mdp->smbmdm_rpos = m.smbdmap_rpos;
85084ab085aSmws 	mdp->smbmdm_ipos = m.smbdmap_ipos;
85184ab085aSmws 	mdp->smbmdm_idepth = m.smbdmap_idepth;
85284ab085aSmws 
853*4e901881SDale Ghent 	if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) {
854*4e901881SDale Ghent 		mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
855*4e901881SDale Ghent 		mdp->smbmdm_size = (uint64_t)
856*4e901881SDale Ghent 		    (m.smbdmap_end - m.smbdmap_start + 1) * 1024;
857*4e901881SDale Ghent 	} else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) {
858*4e901881SDale Ghent 		mdp->smbmdm_addr = m.smbdmap_extstart;
859*4e901881SDale Ghent 		mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1;
860*4e901881SDale Ghent 	}
861*4e901881SDale Ghent 
86284ab085aSmws 	return (0);
86384ab085aSmws }
86484ab085aSmws 
86584ab085aSmws id_t
86684ab085aSmws smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp)
86784ab085aSmws {
86884ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY);
86984ab085aSmws 	smb_hwsec_t hs;
87084ab085aSmws 
87184ab085aSmws 	if (stp == NULL)
87284ab085aSmws 		return (-1); /* errno is set for us */
87384ab085aSmws 
87484ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &hs, sizeof (hs));
87584ab085aSmws 	bzero(hsp, sizeof (smbios_hwsec_t));
87684ab085aSmws 
87784ab085aSmws 	hsp->smbh_pwr_ps = SMB_HWS_PWR_PS(hs.smbhs_settings);
87884ab085aSmws 	hsp->smbh_kbd_ps = SMB_HWS_KBD_PS(hs.smbhs_settings);
87984ab085aSmws 	hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings);
88084ab085aSmws 	hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings);
88184ab085aSmws 
88284ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
88384ab085aSmws }
88484ab085aSmws 
88584ab085aSmws id_t
88684ab085aSmws smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp)
88784ab085aSmws {
88884ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT);
88984ab085aSmws 	const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
89084ab085aSmws 
89184ab085aSmws 	if (stp == NULL)
89284ab085aSmws 		return (-1); /* errno is set for us */
89384ab085aSmws 
89484ab085aSmws 	bzero(bp, sizeof (smbios_boot_t));
89584ab085aSmws 
89684ab085aSmws 	bp->smbt_status = b->smbbo_status[0];
89784ab085aSmws 	bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t);
89884ab085aSmws 	bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL;
89984ab085aSmws 
90084ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
90184ab085aSmws }
90284ab085aSmws 
90384ab085aSmws id_t
90484ab085aSmws smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip)
90584ab085aSmws {
90684ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_IPMIDEV);
90784ab085aSmws 	smb_ipmi_t i;
90884ab085aSmws 
90984ab085aSmws 	if (stp == NULL)
91084ab085aSmws 		return (-1); /* errno is set for us */
91184ab085aSmws 
91284ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &i, sizeof (i));
91384ab085aSmws 	bzero(ip, sizeof (smbios_ipmi_t));
91484ab085aSmws 
91584ab085aSmws 	ip->smbip_type = i.smbipm_type;
91684ab085aSmws 	ip->smbip_vers.smbv_major = SMB_IPM_SPEC_MAJOR(i.smbipm_spec);
91784ab085aSmws 	ip->smbip_vers.smbv_minor = SMB_IPM_SPEC_MINOR(i.smbipm_spec);
91884ab085aSmws 	ip->smbip_i2c = i.smbipm_i2c;
91984ab085aSmws 	ip->smbip_addr = i.smbipm_addr & ~SMB_IPM_ADDR_IO;
92084ab085aSmws 	ip->smbip_intr = i.smbipm_intr;
92184ab085aSmws 
92284ab085aSmws 	if (i.smbipm_bus != (uint8_t)-1)
92384ab085aSmws 		ip->smbip_bus = i.smbipm_bus;
92484ab085aSmws 	else
92584ab085aSmws 		ip->smbip_bus = -1u;
92684ab085aSmws 
92784ab085aSmws 	if (SMB_IPM_INFO_LSB(i.smbipm_info))
92884ab085aSmws 		ip->smbip_addr |= 1; /* turn on least-significant bit of addr */
92984ab085aSmws 
93084ab085aSmws 	if (i.smbipm_addr & SMB_IPM_ADDR_IO) {
93184ab085aSmws 		switch (SMB_IPM_INFO_REGS(i.smbipm_info)) {
93284ab085aSmws 		case SMB_IPM_REGS_1B:
93384ab085aSmws 			ip->smbip_regspacing = 1;
93484ab085aSmws 			break;
93584ab085aSmws 		case SMB_IPM_REGS_4B:
93684ab085aSmws 			ip->smbip_regspacing = 4;
93784ab085aSmws 			break;
93884ab085aSmws 		case SMB_IPM_REGS_16B:
93984ab085aSmws 			ip->smbip_regspacing = 16;
94084ab085aSmws 			break;
94184ab085aSmws 		default:
94284ab085aSmws 			ip->smbip_regspacing = 1;
94384ab085aSmws 		}
94484ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_IOADDR;
94584ab085aSmws 	}
94684ab085aSmws 
94784ab085aSmws 	if (SMB_IPM_INFO_ISPEC(i.smbipm_info))
94884ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTRSPEC;
94984ab085aSmws 
95084ab085aSmws 	if (SMB_IPM_INFO_IPOL(i.smbipm_info) == SMB_IPM_IPOL_HI)
95184ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTRHIGH;
95284ab085aSmws 
95384ab085aSmws 	if (SMB_IPM_INFO_IMODE(i.smbipm_info) == SMB_IPM_IMODE_EDGE)
95484ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTREDGE;
95584ab085aSmws 
95684ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
95784ab085aSmws }
9589c94f155SCheng Sean Ye 
9599c94f155SCheng Sean Ye static boolean_t
9609c94f155SCheng Sean Ye smbios_has_oemstr(smbios_hdl_t *shp, const char *oemstr)
9619c94f155SCheng Sean Ye {
9629c94f155SCheng Sean Ye 	const smb_struct_t *stp = shp->sh_structs;
9639c94f155SCheng Sean Ye 	smb_strtab_t s;
9649c94f155SCheng Sean Ye 	int i, j;
9659c94f155SCheng Sean Ye 
9669c94f155SCheng Sean Ye 	for (i = 0; i < shp->sh_nstructs; i++, stp++) {
9679c94f155SCheng Sean Ye 		if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR)
9689c94f155SCheng Sean Ye 			continue;
9699c94f155SCheng Sean Ye 
9709c94f155SCheng Sean Ye 		smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
9719c94f155SCheng Sean Ye 		for (j = 0; j < s.smbtb_count; j++)
9729c94f155SCheng Sean Ye 			if (strcmp(smb_strptr(stp, j + 1), oemstr) == 0)
9739c94f155SCheng Sean Ye 				return (B_TRUE);
9749c94f155SCheng Sean Ye 	}
9759c94f155SCheng Sean Ye 
9769c94f155SCheng Sean Ye 	return (B_FALSE);
9779c94f155SCheng Sean Ye }
9789c94f155SCheng Sean Ye 
9799c94f155SCheng Sean Ye static const char *
9809c94f155SCheng Sean Ye smb_serial_valid(const char *serial)
9819c94f155SCheng Sean Ye {
9829c94f155SCheng Sean Ye 	char buf[MAXNAMELEN];
9839c94f155SCheng Sean Ye 	int i = 0;
9849c94f155SCheng Sean Ye 
9859c94f155SCheng Sean Ye 	if (serial == NULL)
9869c94f155SCheng Sean Ye 		return (NULL);
9879c94f155SCheng Sean Ye 
9889c94f155SCheng Sean Ye 	(void) strlcpy(buf, serial, sizeof (buf));
9899c94f155SCheng Sean Ye 
9909c94f155SCheng Sean Ye 	while (buf[i] != '\0' && buf[i] == ' ')
9919c94f155SCheng Sean Ye 		i++;
9929c94f155SCheng Sean Ye 
9939c94f155SCheng Sean Ye 	if (buf[i] == '\0' || strstr(buf, SMB_DEFAULT1) != NULL ||
9949c94f155SCheng Sean Ye 	    strstr(buf, SMB_DEFAULT2) != NULL)
9959c94f155SCheng Sean Ye 		return (NULL);
9969c94f155SCheng Sean Ye 
9979c94f155SCheng Sean Ye 	return (serial);
9989c94f155SCheng Sean Ye }
9999c94f155SCheng Sean Ye 
10009c94f155SCheng Sean Ye /*
10019c94f155SCheng Sean Ye  * Get chassis SN or product SN
10029c94f155SCheng Sean Ye  */
10039c94f155SCheng Sean Ye static int
10049c94f155SCheng Sean Ye smb_get_sn(smbios_hdl_t *shp, const char **psnp, const char **csnp)
10059c94f155SCheng Sean Ye {
10069c94f155SCheng Sean Ye 	const smb_struct_t *stp;
10079c94f155SCheng Sean Ye 	smbios_info_t s1, s3;
10089c94f155SCheng Sean Ye 
10099c94f155SCheng Sean Ye 	if (psnp == NULL || csnp == NULL)
10109c94f155SCheng Sean Ye 		return (smb_set_errno(shp, ESMB_INVAL));
10119c94f155SCheng Sean Ye 
10129c94f155SCheng Sean Ye 	*psnp = *csnp = NULL;
10139c94f155SCheng Sean Ye 
10149c94f155SCheng Sean Ye 	/*
10159c94f155SCheng Sean Ye 	 * If SMBIOS meets Sun's PRMS requirements, retrieve product SN
10169c94f155SCheng Sean Ye 	 * from type 1 structure, and chassis SN from type 3 structure.
10179c94f155SCheng Sean Ye 	 * Otherwise return SN in type 1 structure as chassis SN.
10189c94f155SCheng Sean Ye 	 */
10199c94f155SCheng Sean Ye 
10209c94f155SCheng Sean Ye 	/* Get type 1 SN */
10219c94f155SCheng Sean Ye 	if ((stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM)) == NULL ||
10229c94f155SCheng Sean Ye 	    smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s1) == SMB_ERR)
10239c94f155SCheng Sean Ye 		s1.smbi_serial = NULL;
10249c94f155SCheng Sean Ye 
10259c94f155SCheng Sean Ye 	/* Get type 3 SN */
10269c94f155SCheng Sean Ye 	if ((stp = smb_lookup_type(shp, SMB_TYPE_CHASSIS)) == NULL ||
10279c94f155SCheng Sean Ye 	    smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s3) == SMB_ERR)
10289c94f155SCheng Sean Ye 		s3.smbi_serial = NULL;
10299c94f155SCheng Sean Ye 
10309c94f155SCheng Sean Ye 	if (smbios_has_oemstr(shp, SMB_PRMS1)) {
10319c94f155SCheng Sean Ye 		*psnp = smb_serial_valid(s1.smbi_serial);
10329c94f155SCheng Sean Ye 		*csnp = smb_serial_valid(s3.smbi_serial);
10339c94f155SCheng Sean Ye 	} else {
10349c94f155SCheng Sean Ye 		*csnp = smb_serial_valid(s1.smbi_serial);
10359c94f155SCheng Sean Ye 	}
10369c94f155SCheng Sean Ye 
10379c94f155SCheng Sean Ye 	return (0);
10389c94f155SCheng Sean Ye }
10399c94f155SCheng Sean Ye 
10409c94f155SCheng Sean Ye const char *
10419c94f155SCheng Sean Ye smbios_psn(smbios_hdl_t *shp)
10429c94f155SCheng Sean Ye {
10439c94f155SCheng Sean Ye 	const char *psn, *csn;
10449c94f155SCheng Sean Ye 
10459c94f155SCheng Sean Ye 	return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : psn);
10469c94f155SCheng Sean Ye }
10479c94f155SCheng Sean Ye 
10489c94f155SCheng Sean Ye const char *
10499c94f155SCheng Sean Ye smbios_csn(smbios_hdl_t *shp)
10509c94f155SCheng Sean Ye {
10519c94f155SCheng Sean Ye 	const char *psn, *csn;
10529c94f155SCheng Sean Ye 
10539c94f155SCheng Sean Ye 	return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : csn);
10549c94f155SCheng Sean Ye }
1055074bb90dSTom Pothier 
1056074bb90dSTom Pothier int
1057074bb90dSTom Pothier smbios_info_extprocessor(smbios_hdl_t *shp, id_t id,
1058074bb90dSTom Pothier     smbios_processor_ext_t *epp)
1059074bb90dSTom Pothier {
1060074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1061074bb90dSTom Pothier 	smb_processor_ext_t *exp;
1062074bb90dSTom Pothier 
1063074bb90dSTom Pothier 	if (stp == NULL)
1064074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1065074bb90dSTom Pothier 
1066074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PROCESSOR)
1067074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1068074bb90dSTom Pothier 
1069074bb90dSTom Pothier 	exp = (smb_processor_ext_t *)(uintptr_t)stp->smbst_hdr;
1070074bb90dSTom Pothier 	bzero(epp, sizeof (smbios_processor_ext_t));
1071074bb90dSTom Pothier 
1072074bb90dSTom Pothier 	epp->smbpe_processor = exp->smbpre_processor;
1073074bb90dSTom Pothier 	epp->smbpe_fru = exp->smbpre_fru;
1074074bb90dSTom Pothier 	epp->smbpe_n = exp->smbpre_n;
1075074bb90dSTom Pothier 	epp->smbpe_apicid = exp->smbpre_apicid;
1076074bb90dSTom Pothier 
1077074bb90dSTom Pothier 	return (0);
1078074bb90dSTom Pothier }
1079074bb90dSTom Pothier 
1080074bb90dSTom Pothier int
108103f9f63dSTom Pothier smbios_info_extport(smbios_hdl_t *shp, id_t id, smbios_port_ext_t *eportp)
108203f9f63dSTom Pothier {
108303f9f63dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
108403f9f63dSTom Pothier 	smb_port_ext_t *ep;
108503f9f63dSTom Pothier 
108603f9f63dSTom Pothier 	if (stp == NULL)
108703f9f63dSTom Pothier 		return (-1); /* errno is set for us */
108803f9f63dSTom Pothier 
108903f9f63dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PORT)
109003f9f63dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
109103f9f63dSTom Pothier 
109203f9f63dSTom Pothier 	ep = (smb_port_ext_t *)(uintptr_t)stp->smbst_hdr;
109303f9f63dSTom Pothier 	bzero(eportp, sizeof (smbios_port_ext_t));
109403f9f63dSTom Pothier 
109503f9f63dSTom Pothier 	eportp->smbporte_chassis = ep->smbpoe_chassis;
109603f9f63dSTom Pothier 	eportp->smbporte_port = ep->smbpoe_port;
109703f9f63dSTom Pothier 	eportp->smbporte_dtype = ep->smbpoe_dtype;
109803f9f63dSTom Pothier 	eportp->smbporte_devhdl = ep->smbpoe_devhdl;
109903f9f63dSTom Pothier 	eportp->smbporte_phy = ep->smbpoe_phy;
110003f9f63dSTom Pothier 
110103f9f63dSTom Pothier 	return (0);
110203f9f63dSTom Pothier }
110303f9f63dSTom Pothier 
110403f9f63dSTom Pothier int
1105074bb90dSTom Pothier smbios_info_pciexrc(smbios_hdl_t *shp, id_t id,
1106074bb90dSTom Pothier     smbios_pciexrc_t *rcp)
1107074bb90dSTom Pothier {
1108074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1109074bb90dSTom Pothier 	smb_pciexrc_t rc;
1110074bb90dSTom Pothier 
1111074bb90dSTom Pothier 	if (stp == NULL)
1112074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1113074bb90dSTom Pothier 
1114074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_PCIEXRC)
1115074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1116074bb90dSTom Pothier 
1117074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &rc, sizeof (rc));
1118074bb90dSTom Pothier 	bzero(rcp, sizeof (smbios_pciexrc_t));
1119074bb90dSTom Pothier 
1120074bb90dSTom Pothier 	rcp->smbpcie_bb = rc.smbpciexrc_bboard;
1121074bb90dSTom Pothier 	rcp->smbpcie_bdf = rc.smbpciexrc_bdf;
1122074bb90dSTom Pothier 
1123074bb90dSTom Pothier 	return (0);
1124074bb90dSTom Pothier }
1125074bb90dSTom Pothier 
1126074bb90dSTom Pothier int
1127074bb90dSTom Pothier smbios_info_extmemarray(smbios_hdl_t *shp, id_t id, smbios_memarray_ext_t *emap)
1128074bb90dSTom Pothier {
1129074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1130074bb90dSTom Pothier 	smb_memarray_ext_t exma;
1131074bb90dSTom Pothier 
1132074bb90dSTom Pothier 	if (stp == NULL)
1133074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1134074bb90dSTom Pothier 
1135074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMARRAY)
1136074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1137074bb90dSTom Pothier 
1138074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &exma, sizeof (exma));
1139074bb90dSTom Pothier 	bzero(emap, sizeof (smbios_memarray_ext_t));
1140074bb90dSTom Pothier 
1141074bb90dSTom Pothier 	emap->smbmae_ma = exma.smbmarre_ma;
1142074bb90dSTom Pothier 	emap->smbmae_comp = exma.smbmarre_component;
1143074bb90dSTom Pothier 	emap->smbmae_bdf = exma.smbmarre_bdf;
1144074bb90dSTom Pothier 
1145074bb90dSTom Pothier 	return (0);
1146074bb90dSTom Pothier }
1147074bb90dSTom Pothier 
1148074bb90dSTom Pothier int
1149074bb90dSTom Pothier smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id,
1150074bb90dSTom Pothier     smbios_memdevice_ext_t *emdp)
1151074bb90dSTom Pothier {
1152074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1153074bb90dSTom Pothier 	smb_memdevice_ext_t exmd;
1154074bb90dSTom Pothier 
1155074bb90dSTom Pothier 	if (stp == NULL)
1156074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1157074bb90dSTom Pothier 
1158074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMDEVICE)
1159074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1160074bb90dSTom Pothier 
1161074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &exmd, sizeof (exmd));
1162074bb90dSTom Pothier 	bzero(emdp, sizeof (smbios_memdevice_ext_t));
1163074bb90dSTom Pothier 
1164074bb90dSTom Pothier 	emdp->smbmdeve_md = exmd.smbmdeve_mdev;
1165074bb90dSTom Pothier 	emdp->smbmdeve_drch = exmd.smbmdeve_dchan;
1166074bb90dSTom Pothier 	emdp->smbmdeve_ncs  = exmd.smbmdeve_ncs;
1167074bb90dSTom Pothier 	emdp->smbmdeve_cs = exmd.smbmdeve_cs;
1168074bb90dSTom Pothier 
1169074bb90dSTom Pothier 	return (0);
1170074bb90dSTom Pothier }
1171