xref: /titanic_50/usr/src/common/smbios/smb_info.c (revision 6734c4b0468cc77a7871a5dd5c23a5562557d64c)
184ab085aSmws /*
284ab085aSmws  * CDDL HEADER START
384ab085aSmws  *
484ab085aSmws  * The contents of this file are subject to the terms of the
5c7c09f80SEric Schrock  * Common Development and Distribution License (the "License").
6c7c09f80SEric Schrock  * You may not use this file except in compliance with the License.
784ab085aSmws  *
884ab085aSmws  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
984ab085aSmws  * or http://www.opensolaris.org/os/licensing.
1084ab085aSmws  * See the License for the specific language governing permissions
1184ab085aSmws  * and limitations under the License.
1284ab085aSmws  *
1384ab085aSmws  * When distributing Covered Code, include this CDDL HEADER in each
1484ab085aSmws  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1584ab085aSmws  * If applicable, add the following below this CDDL HEADER, with the
1684ab085aSmws  * fields enclosed by brackets "[]" replaced with your own identifying
1784ab085aSmws  * information: Portions Copyright [yyyy] [name of copyright owner]
1884ab085aSmws  *
1984ab085aSmws  * CDDL HEADER END
2084ab085aSmws  */
2184ab085aSmws 
2284ab085aSmws /*
234e901881SDale Ghent  * Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
24*6734c4b0SRobert Mustacchi  * Copyright 2015 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.
49*6734c4b0SRobert Mustacchi  *
50*6734c4b0SRobert Mustacchi  * Note, when trying to bzero the caller's struct you have to be careful about
51*6734c4b0SRobert Mustacchi  * versions. One can only bzero the initial version that existed in illumos. In
52*6734c4b0SRobert Mustacchi  * other words, if someone passes an older library handle that doesn't support a
53*6734c4b0SRobert Mustacchi  * version you cannot assume that their structures have those additional members
54*6734c4b0SRobert Mustacchi  * in them. Instead, a 'base' version is introduced for such types that have
55*6734c4b0SRobert Mustacchi  * differences and instead we only bzero out the base version and then handle
56*6734c4b0SRobert Mustacchi  * the additional members. In general, because all additional members will be
57*6734c4b0SRobert Mustacchi  * assigned, there's no reason to zero them out unless they are arrays that
58*6734c4b0SRobert Mustacchi  * won't be entirely filled in.
59*6734c4b0SRobert Mustacchi  *
60*6734c4b0SRobert Mustacchi  * Due to history, anything added after the update from version 2.4, in other
61*6734c4b0SRobert Mustacchi  * words additions from or after '5094 Update libsmbios with recent items'
62*6734c4b0SRobert Mustacchi  * (4e901881) is currently being used for this. While we don't allow software
63*6734c4b0SRobert Mustacchi  * compiling against this to get an older form, this was the first major update
64*6734c4b0SRobert Mustacchi  * and a good starting point for us to enforce this behavior which is useful for
65*6734c4b0SRobert Mustacchi  * moving forward to making this more public.
6684ab085aSmws  */
6784ab085aSmws 
6884ab085aSmws #include <sys/smbios_impl.h>
6984ab085aSmws 
709c94f155SCheng Sean Ye #ifdef _KERNEL
719c94f155SCheng Sean Ye #include <sys/sunddi.h>
729c94f155SCheng Sean Ye #else
73c7c09f80SEric Schrock #include <fcntl.h>
74c7c09f80SEric Schrock #include <unistd.h>
759c94f155SCheng Sean Ye #include <string.h>
76c7c09f80SEric Schrock #endif
77c7c09f80SEric Schrock 
7884ab085aSmws /*
7984ab085aSmws  * A large number of SMBIOS structures contain a set of common strings used to
8084ab085aSmws  * describe a h/w component's serial number, manufacturer, etc.  These fields
8184ab085aSmws  * helpfully have different names and offsets and sometimes aren't consistent.
8284ab085aSmws  * To simplify life for our clients, we factor these common things out into
8384ab085aSmws  * smbios_info_t, which can be retrieved for any structure.  The following
8484ab085aSmws  * table describes the mapping from a given structure to the smbios_info_t.
85074bb90dSTom Pothier  * Multiple SMBIOS stuctures' contained objects are also handled here.
8684ab085aSmws  */
8784ab085aSmws static const struct smb_infospec {
8884ab085aSmws 	uint8_t is_type;		/* structure type */
8984ab085aSmws 	uint8_t is_manu;		/* manufacturer offset */
9084ab085aSmws 	uint8_t is_product;		/* product name offset */
9184ab085aSmws 	uint8_t is_version;		/* version offset */
9284ab085aSmws 	uint8_t is_serial;		/* serial number offset */
9384ab085aSmws 	uint8_t is_asset;		/* asset tag offset */
9484ab085aSmws 	uint8_t is_location;		/* location string offset */
9584ab085aSmws 	uint8_t is_part;		/* part number offset */
96074bb90dSTom Pothier 	uint8_t is_contc;		/* contained count */
97074bb90dSTom Pothier 	uint8_t is_contsz;		/* contained size */
98074bb90dSTom Pothier 	uint8_t is_contv;		/* contained objects */
9984ab085aSmws } _smb_infospecs[] = {
10084ab085aSmws 	{ SMB_TYPE_SYSTEM,
10184ab085aSmws 		offsetof(smb_system_t, smbsi_manufacturer),
10284ab085aSmws 		offsetof(smb_system_t, smbsi_product),
10384ab085aSmws 		offsetof(smb_system_t, smbsi_version),
10484ab085aSmws 		offsetof(smb_system_t, smbsi_serial),
10584ab085aSmws 		0,
10684ab085aSmws 		0,
107074bb90dSTom Pothier 		0,
108074bb90dSTom Pothier 		0,
109074bb90dSTom Pothier 		0,
11084ab085aSmws 		0 },
11184ab085aSmws 	{ SMB_TYPE_BASEBOARD,
11284ab085aSmws 		offsetof(smb_bboard_t, smbbb_manufacturer),
11384ab085aSmws 		offsetof(smb_bboard_t, smbbb_product),
11484ab085aSmws 		offsetof(smb_bboard_t, smbbb_version),
11584ab085aSmws 		offsetof(smb_bboard_t, smbbb_serial),
11684ab085aSmws 		offsetof(smb_bboard_t, smbbb_asset),
11784ab085aSmws 		offsetof(smb_bboard_t, smbbb_location),
118074bb90dSTom Pothier 		0,
119074bb90dSTom Pothier 		offsetof(smb_bboard_t, smbbb_cn),
120074bb90dSTom Pothier 		SMB_CONT_WORD,
121074bb90dSTom Pothier 		offsetof(smb_bboard_t, smbbb_cv) },
12284ab085aSmws 	{ SMB_TYPE_CHASSIS,
12384ab085aSmws 		offsetof(smb_chassis_t, smbch_manufacturer),
12484ab085aSmws 		0,
12584ab085aSmws 		offsetof(smb_chassis_t, smbch_version),
12684ab085aSmws 		offsetof(smb_chassis_t, smbch_serial),
12784ab085aSmws 		offsetof(smb_chassis_t, smbch_asset),
12884ab085aSmws 		0,
129074bb90dSTom Pothier 		0,
130074bb90dSTom Pothier 		offsetof(smb_chassis_t, smbch_cn),
131074bb90dSTom Pothier 		SMB_CONT_BYTE,
132074bb90dSTom Pothier 		offsetof(smb_chassis_t, smbch_cv) },
13384ab085aSmws 	{ SMB_TYPE_PROCESSOR,
13484ab085aSmws 		offsetof(smb_processor_t, smbpr_manufacturer),
13584ab085aSmws 		0,
13684ab085aSmws 		offsetof(smb_processor_t, smbpr_version),
13784ab085aSmws 		offsetof(smb_processor_t, smbpr_serial),
13884ab085aSmws 		offsetof(smb_processor_t, smbpr_asset),
13984ab085aSmws 		offsetof(smb_processor_t, smbpr_socket),
140074bb90dSTom Pothier 		offsetof(smb_processor_t, smbpr_part),
141074bb90dSTom Pothier 		0,
142074bb90dSTom Pothier 		0,
143074bb90dSTom Pothier 		0 },
14484ab085aSmws 	{ SMB_TYPE_CACHE,
14584ab085aSmws 		0,
14684ab085aSmws 		0,
14784ab085aSmws 		0,
14884ab085aSmws 		0,
14984ab085aSmws 		0,
15084ab085aSmws 		offsetof(smb_cache_t, smbca_socket),
151074bb90dSTom Pothier 		0,
152074bb90dSTom Pothier 		0,
153074bb90dSTom Pothier 		0,
15484ab085aSmws 		0 },
15584ab085aSmws 	{ SMB_TYPE_PORT,
15684ab085aSmws 		0,
15784ab085aSmws 		0,
15884ab085aSmws 		0,
15984ab085aSmws 		0,
16084ab085aSmws 		0,
16184ab085aSmws 		offsetof(smb_port_t, smbpo_iref),
162074bb90dSTom Pothier 		0,
163074bb90dSTom Pothier 		0,
164074bb90dSTom Pothier 		0,
16584ab085aSmws 		0 },
16684ab085aSmws 	{ SMB_TYPE_SLOT,
16784ab085aSmws 		0,
16884ab085aSmws 		0,
16984ab085aSmws 		0,
17084ab085aSmws 		0,
17184ab085aSmws 		0,
17284ab085aSmws 		offsetof(smb_slot_t, smbsl_name),
173074bb90dSTom Pothier 		0,
174074bb90dSTom Pothier 		0,
175074bb90dSTom Pothier 		0,
17684ab085aSmws 		0 },
17784ab085aSmws 	{ SMB_TYPE_MEMDEVICE,
17884ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_manufacturer),
17984ab085aSmws 		0,
18084ab085aSmws 		0,
18184ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_serial),
18284ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_asset),
18384ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_dloc),
184074bb90dSTom Pothier 		offsetof(smb_memdevice_t, smbmdev_part),
185074bb90dSTom Pothier 		0,
186074bb90dSTom Pothier 		0,
187074bb90dSTom Pothier 		0 },
18884ab085aSmws 	{ SMB_TYPE_POWERSUP,
18984ab085aSmws 		offsetof(smb_powersup_t, smbpsup_manufacturer),
19084ab085aSmws 		offsetof(smb_powersup_t, smbpsup_devname),
19184ab085aSmws 		offsetof(smb_powersup_t, smbpsup_rev),
19284ab085aSmws 		offsetof(smb_powersup_t, smbpsup_serial),
19384ab085aSmws 		offsetof(smb_powersup_t, smbpsup_asset),
19484ab085aSmws 		offsetof(smb_powersup_t, smbpsup_loc),
195074bb90dSTom Pothier 		offsetof(smb_powersup_t, smbpsup_part),
196074bb90dSTom Pothier 		0,
197074bb90dSTom Pothier 		0,
198074bb90dSTom Pothier 		0 },
19984ab085aSmws 	{ SMB_TYPE_EOT }
20084ab085aSmws };
20184ab085aSmws 
20284ab085aSmws static const char *
20384ab085aSmws smb_info_strptr(const smb_struct_t *stp, uint8_t off, int *n)
20484ab085aSmws {
20584ab085aSmws 	const uint8_t *sp = (const uint8_t *)(uintptr_t)stp->smbst_hdr;
20684ab085aSmws 
20784ab085aSmws 	if (off != 0 && sp + off < stp->smbst_end) {
20884ab085aSmws 		(*n)++; /* indicate success for caller */
20984ab085aSmws 		return (smb_strptr(stp, sp[off]));
21084ab085aSmws 	}
21184ab085aSmws 
21284ab085aSmws 	return (smb_strptr(stp, 0));
21384ab085aSmws }
21484ab085aSmws 
21584ab085aSmws static void
21684ab085aSmws smb_info_bcopy(const smb_header_t *hp, void *dst, size_t dstlen)
21784ab085aSmws {
21884ab085aSmws 	if (dstlen > hp->smbh_len) {
21984ab085aSmws 		bcopy(hp, dst, hp->smbh_len);
22084ab085aSmws 		bzero((char *)dst + hp->smbh_len, dstlen - hp->smbh_len);
22184ab085aSmws 	} else
22284ab085aSmws 		bcopy(hp, dst, dstlen);
22384ab085aSmws }
22484ab085aSmws 
22584ab085aSmws void
22684ab085aSmws smbios_info_smbios(smbios_hdl_t *shp, smbios_entry_t *ep)
22784ab085aSmws {
22884ab085aSmws 	bcopy(&shp->sh_ent, ep, sizeof (smbios_entry_t));
22984ab085aSmws }
23084ab085aSmws 
231c7c09f80SEric Schrock #ifndef _KERNEL
232c7c09f80SEric Schrock static char smbios_product_override[256];
233c7c09f80SEric Schrock static boolean_t smbios_product_checked;
234c7c09f80SEric Schrock #endif
235c7c09f80SEric Schrock 
23684ab085aSmws int
23784ab085aSmws smbios_info_common(smbios_hdl_t *shp, id_t id, smbios_info_t *ip)
23884ab085aSmws {
23984ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
24084ab085aSmws 	const struct smb_infospec *isp;
24184ab085aSmws 	int n = 0;
24284ab085aSmws 
24384ab085aSmws 	if (stp == NULL)
24484ab085aSmws 		return (-1); /* errno is set for us */
24584ab085aSmws 
24684ab085aSmws 	for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
24784ab085aSmws 		if (isp->is_type == stp->smbst_hdr->smbh_type)
24884ab085aSmws 			break;
24984ab085aSmws 	}
25084ab085aSmws 
25184ab085aSmws 	ip->smbi_manufacturer = smb_info_strptr(stp, isp->is_manu, &n);
25284ab085aSmws 	ip->smbi_product = smb_info_strptr(stp, isp->is_product, &n);
25384ab085aSmws 	ip->smbi_version = smb_info_strptr(stp, isp->is_version, &n);
25484ab085aSmws 	ip->smbi_serial = smb_info_strptr(stp, isp->is_serial, &n);
25584ab085aSmws 	ip->smbi_asset = smb_info_strptr(stp, isp->is_asset, &n);
25684ab085aSmws 	ip->smbi_location = smb_info_strptr(stp, isp->is_location, &n);
25784ab085aSmws 	ip->smbi_part = smb_info_strptr(stp, isp->is_part, &n);
25884ab085aSmws 
25984ab085aSmws 	/*
260c7c09f80SEric Schrock 	 * This private file allows developers to experiment with reporting
261c7c09f80SEric Schrock 	 * different platform strings from SMBIOS.  It is not a supported
262c7c09f80SEric Schrock 	 * mechanism in the long term, and does not work in the kernel.
263c7c09f80SEric Schrock 	 */
264c7c09f80SEric Schrock #ifndef _KERNEL
265c7c09f80SEric Schrock 	if (isp->is_type == SMB_TYPE_SYSTEM) {
266c7c09f80SEric Schrock 		if (!smbios_product_checked) {
267c7c09f80SEric Schrock 			int fd = open("/etc/smbios_product", O_RDONLY);
268c7c09f80SEric Schrock 			if (fd >= 0) {
269c7c09f80SEric Schrock 				(void) read(fd, smbios_product_override,
270c7c09f80SEric Schrock 				    sizeof (smbios_product_override) - 1);
271c7c09f80SEric Schrock 				(void) close(fd);
272c7c09f80SEric Schrock 			}
273c7c09f80SEric Schrock 			smbios_product_checked = B_TRUE;
274c7c09f80SEric Schrock 		}
275c7c09f80SEric Schrock 
276c7c09f80SEric Schrock 		if (smbios_product_override[0] != '\0')
277c7c09f80SEric Schrock 			ip->smbi_product = smbios_product_override;
278c7c09f80SEric Schrock 	}
279c7c09f80SEric Schrock #endif
280c7c09f80SEric Schrock 
281c7c09f80SEric Schrock 	/*
28284ab085aSmws 	 * If we have a port with an empty internal reference designator string
28384ab085aSmws 	 * try using the external reference designator string instead.
28484ab085aSmws 	 */
28584ab085aSmws 	if (isp->is_type == SMB_TYPE_PORT && ip->smbi_location[0] == '\0') {
28684ab085aSmws 		ip->smbi_location = smb_info_strptr(stp,
28784ab085aSmws 		    offsetof(smb_port_t, smbpo_eref), &n);
28884ab085aSmws 	}
28984ab085aSmws 
29084ab085aSmws 	return (n ? 0 : smb_set_errno(shp, ESMB_NOINFO));
29184ab085aSmws }
29284ab085aSmws 
293074bb90dSTom Pothier /*
294074bb90dSTom Pothier  * Returns the actual number of contained objects.
295074bb90dSTom Pothier  *
296074bb90dSTom Pothier  * idc - number of contained objects
297074bb90dSTom Pothier  * idv - returned array of contained objects
298074bb90dSTom Pothier  */
299074bb90dSTom Pothier int
300074bb90dSTom Pothier smbios_info_contains(smbios_hdl_t *shp, id_t id, uint_t idc, id_t *idv)
301074bb90dSTom Pothier {
302074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
303074bb90dSTom Pothier 	const struct smb_infospec *isp;
304074bb90dSTom Pothier 	id_t *cp;
305074bb90dSTom Pothier 	uint_t size;
306074bb90dSTom Pothier 	uint8_t cnt;
307074bb90dSTom Pothier 	int i, n;
308074bb90dSTom Pothier 
309074bb90dSTom Pothier 	if (stp == NULL) {
310074bb90dSTom Pothier 		return (-1); /* errno is set for us */
311074bb90dSTom Pothier 	}
312074bb90dSTom Pothier 
313074bb90dSTom Pothier 	for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
314074bb90dSTom Pothier 		if (isp->is_type == stp->smbst_hdr->smbh_type)
315074bb90dSTom Pothier 			break;
316074bb90dSTom Pothier 	}
317074bb90dSTom Pothier 	if (isp->is_type == SMB_TYPE_EOT)
318074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
319074bb90dSTom Pothier 
320074bb90dSTom Pothier 	size = isp->is_contsz;
321074bb90dSTom Pothier 	cnt = *((uint8_t *)(uintptr_t)stp->smbst_hdr + isp->is_contc);
322074bb90dSTom Pothier 	cp = (id_t *)((uintptr_t)stp->smbst_hdr + isp->is_contv);
323074bb90dSTom Pothier 
324074bb90dSTom Pothier 	n = MIN(cnt, idc);
325074bb90dSTom Pothier 	for (i = 0; i < n; i++) {
326074bb90dSTom Pothier 		if (size == SMB_CONT_WORD)
327074bb90dSTom Pothier 			idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 2));
328074bb90dSTom Pothier 		else if (size == SMB_CONT_BYTE)
329074bb90dSTom Pothier 			idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 3));
330074bb90dSTom Pothier 		else
331074bb90dSTom Pothier 			return (smb_set_errno(shp, ESMB_INVAL));
332074bb90dSTom Pothier 	}
333074bb90dSTom Pothier 
334074bb90dSTom Pothier 	return (cnt);
335074bb90dSTom Pothier }
336074bb90dSTom Pothier 
33784ab085aSmws id_t
33884ab085aSmws smbios_info_bios(smbios_hdl_t *shp, smbios_bios_t *bp)
33984ab085aSmws {
34084ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BIOS);
34184ab085aSmws 	const smb_bios_t *bip;
34284ab085aSmws 
34384ab085aSmws 	if (stp == NULL)
34484ab085aSmws 		return (-1); /* errno is set for us */
34584ab085aSmws 
34684ab085aSmws 	if (stp->smbst_hdr->smbh_len < sizeof (smb_bios_t) - sizeof (uint8_t))
34784ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
34884ab085aSmws 
34984ab085aSmws 	bip = (smb_bios_t *)(uintptr_t)stp->smbst_hdr;
35084ab085aSmws 	bzero(bp, sizeof (smbios_bios_t));
35184ab085aSmws 
35284ab085aSmws 	bp->smbb_vendor = smb_strptr(stp, bip->smbbi_vendor);
35384ab085aSmws 	bp->smbb_version = smb_strptr(stp, bip->smbbi_version);
35484ab085aSmws 	bp->smbb_segment = bip->smbbi_segment;
35584ab085aSmws 	bp->smbb_reldate = smb_strptr(stp, bip->smbbi_reldate);
35684ab085aSmws 	bp->smbb_romsize = 64 * 1024 * ((uint32_t)bip->smbbi_romsize + 1);
35784ab085aSmws 	bp->smbb_runsize = 16 * (0x10000 - (uint32_t)bip->smbbi_segment);
35884ab085aSmws 	bp->smbb_cflags = bip->smbbi_cflags;
35984ab085aSmws 
36084ab085aSmws 	/*
36184ab085aSmws 	 * If one or more extension bytes are present, reset smbb_xcflags to
36284ab085aSmws 	 * point to them.  Otherwise leave this member set to NULL.
36384ab085aSmws 	 */
36484ab085aSmws 	if (stp->smbst_hdr->smbh_len >= sizeof (smb_bios_t)) {
36584ab085aSmws 		bp->smbb_xcflags = bip->smbbi_xcflags;
36684ab085aSmws 		bp->smbb_nxcflags = stp->smbst_hdr->smbh_len -
36784ab085aSmws 		    sizeof (smb_bios_t) + 1;
36884ab085aSmws 
36984ab085aSmws 		if (bp->smbb_nxcflags > SMB_BIOSXB_ECFW_MIN &&
37084ab085aSmws 		    smb_gteq(shp, SMB_VERSION_24)) {
37184ab085aSmws 			bp->smbb_biosv.smbv_major =
37284ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MAJ];
37384ab085aSmws 			bp->smbb_biosv.smbv_minor =
37484ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MIN];
37584ab085aSmws 			bp->smbb_ecfwv.smbv_major =
37684ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MAJ];
37784ab085aSmws 			bp->smbb_ecfwv.smbv_minor =
37884ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MIN];
37984ab085aSmws 		}
38084ab085aSmws 	}
38184ab085aSmws 
38284ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
38384ab085aSmws }
38484ab085aSmws 
38584ab085aSmws id_t
38684ab085aSmws smbios_info_system(smbios_hdl_t *shp, smbios_system_t *sip)
38784ab085aSmws {
38884ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM);
38984ab085aSmws 	smb_system_t si;
39084ab085aSmws 
39184ab085aSmws 	if (stp == NULL)
39284ab085aSmws 		return (-1); /* errno is set for us */
39384ab085aSmws 
39484ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &si, sizeof (si));
39584ab085aSmws 	bzero(sip, sizeof (smbios_system_t));
39684ab085aSmws 
39784ab085aSmws 	sip->smbs_uuid = ((smb_system_t *)stp->smbst_hdr)->smbsi_uuid;
39884ab085aSmws 	sip->smbs_uuidlen = sizeof (si.smbsi_uuid);
39984ab085aSmws 	sip->smbs_wakeup = si.smbsi_wakeup;
40084ab085aSmws 	sip->smbs_sku = smb_strptr(stp, si.smbsi_sku);
40184ab085aSmws 	sip->smbs_family = smb_strptr(stp, si.smbsi_family);
40284ab085aSmws 
40384ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
40484ab085aSmws }
40584ab085aSmws 
40684ab085aSmws int
40784ab085aSmws smbios_info_bboard(smbios_hdl_t *shp, id_t id, smbios_bboard_t *bbp)
40884ab085aSmws {
40984ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
41084ab085aSmws 	smb_bboard_t bb;
41184ab085aSmws 
41284ab085aSmws 	if (stp == NULL)
41384ab085aSmws 		return (-1); /* errno is set for us */
41484ab085aSmws 
41584ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_BASEBOARD)
41684ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
41784ab085aSmws 
41884ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &bb, sizeof (bb));
41984ab085aSmws 	bzero(bbp, sizeof (smbios_bboard_t));
42084ab085aSmws 
42184ab085aSmws 	bbp->smbb_chassis = bb.smbbb_chassis;
42284ab085aSmws 	bbp->smbb_flags = bb.smbbb_flags;
42384ab085aSmws 	bbp->smbb_type = bb.smbbb_type;
424074bb90dSTom Pothier 	bbp->smbb_contn = bb.smbbb_cn;
42584ab085aSmws 
42684ab085aSmws 	return (0);
42784ab085aSmws }
42884ab085aSmws 
42984ab085aSmws int
43084ab085aSmws smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp)
43184ab085aSmws {
43284ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
4334e901881SDale Ghent 	/* Length is measurable by one byte, so it'll be no more than 255. */
4344e901881SDale Ghent 	uint8_t buf[256];
4354e901881SDale Ghent 	smb_chassis_t *ch = (smb_chassis_t *)&buf[0];
43684ab085aSmws 
43784ab085aSmws 	if (stp == NULL)
43884ab085aSmws 		return (-1); /* errno is set for us */
43984ab085aSmws 
44084ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS)
44184ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
44284ab085aSmws 
4434e901881SDale Ghent 	smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf));
444*6734c4b0SRobert Mustacchi 	bzero(chp, sizeof (smb_base_chassis_t));
445*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_27) {
446*6734c4b0SRobert Mustacchi 		bzero(chp->smbc_sku, sizeof (chp->smbc_sku));
447*6734c4b0SRobert Mustacchi 	}
44884ab085aSmws 
4494e901881SDale Ghent 	chp->smbc_oemdata = ch->smbch_oemdata;
4504e901881SDale Ghent 	chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0;
4514e901881SDale Ghent 	chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK;
4524e901881SDale Ghent 	chp->smbc_bustate = ch->smbch_bustate;
4534e901881SDale Ghent 	chp->smbc_psstate = ch->smbch_psstate;
4544e901881SDale Ghent 	chp->smbc_thstate = ch->smbch_thstate;
4554e901881SDale Ghent 	chp->smbc_security = ch->smbch_security;
4564e901881SDale Ghent 	chp->smbc_uheight = ch->smbch_uheight;
4574e901881SDale Ghent 	chp->smbc_cords = ch->smbch_cords;
4584e901881SDale Ghent 	chp->smbc_elems = ch->smbch_cn;
4594e901881SDale Ghent 	chp->smbc_elemlen = ch->smbch_cm;
4604e901881SDale Ghent 
461*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_27) {
4624e901881SDale Ghent 		(void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch),
4634e901881SDale Ghent 		    sizeof (chp->smbc_sku));
4644e901881SDale Ghent 	}
46584ab085aSmws 
46684ab085aSmws 	return (0);
46784ab085aSmws }
46884ab085aSmws 
46984ab085aSmws int
47084ab085aSmws smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp)
47184ab085aSmws {
47284ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
47384ab085aSmws 	smb_processor_t p;
47484ab085aSmws 
47584ab085aSmws 	if (stp == NULL)
47684ab085aSmws 		return (-1); /* errno is set for us */
47784ab085aSmws 
47884ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_PROCESSOR)
47984ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
48084ab085aSmws 
48184ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
482*6734c4b0SRobert Mustacchi 	bzero(pp, sizeof (smb_base_processor_t));
48384ab085aSmws 
48484ab085aSmws 	pp->smbp_cpuid = p.smbpr_cpuid;
48584ab085aSmws 	pp->smbp_type = p.smbpr_type;
48684ab085aSmws 	pp->smbp_family = p.smbpr_family;
48784ab085aSmws 	pp->smbp_voltage = p.smbpr_voltage;
48884ab085aSmws 	pp->smbp_maxspeed = p.smbpr_maxspeed;
48984ab085aSmws 	pp->smbp_curspeed = p.smbpr_curspeed;
49084ab085aSmws 	pp->smbp_status = p.smbpr_status;
49184ab085aSmws 	pp->smbp_upgrade = p.smbpr_upgrade;
49284ab085aSmws 	pp->smbp_l1cache = p.smbpr_l1cache;
49384ab085aSmws 	pp->smbp_l2cache = p.smbpr_l2cache;
49484ab085aSmws 	pp->smbp_l3cache = p.smbpr_l3cache;
49584ab085aSmws 
496*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_25) {
4974e901881SDale Ghent 		pp->smbp_corecount = p.smbpr_corecount;
4984e901881SDale Ghent 		pp->smbp_coresenabled = p.smbpr_coresenabled;
4994e901881SDale Ghent 		pp->smbp_threadcount = p.smbpr_threadcount;
5004e901881SDale Ghent 		pp->smbp_cflags = p.smbpr_cflags;
5014e901881SDale Ghent 	}
5024e901881SDale Ghent 
503*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_26)
5044e901881SDale Ghent 		pp->smbp_family2 = p.smbpr_family2;
5054e901881SDale Ghent 
506*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_30) {
507*6734c4b0SRobert Mustacchi 		pp->smbp_corecount2 = p.smbpr_corecount2;
508*6734c4b0SRobert Mustacchi 		pp->smbp_coresenabled2 = p.smbpr_coresenabled2;
509*6734c4b0SRobert Mustacchi 		pp->smbp_threadcount2 = p.smbpr_threadcount2;
510*6734c4b0SRobert Mustacchi 	}
511*6734c4b0SRobert Mustacchi 
51284ab085aSmws 	return (0);
51384ab085aSmws }
51484ab085aSmws 
51584ab085aSmws int
51684ab085aSmws smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap)
51784ab085aSmws {
51884ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
51984ab085aSmws 	smb_cache_t c;
52084ab085aSmws 
52184ab085aSmws 	if (stp == NULL)
52284ab085aSmws 		return (-1); /* errno is set for us */
52384ab085aSmws 
52484ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_CACHE)
52584ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
52684ab085aSmws 
52784ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &c, sizeof (c));
52884ab085aSmws 	bzero(cap, sizeof (smbios_cache_t));
52984ab085aSmws 
53084ab085aSmws 	cap->smba_maxsize = SMB_CACHE_SIZE(c.smbca_maxsize);
53184ab085aSmws 	cap->smba_size = SMB_CACHE_SIZE(c.smbca_size);
53284ab085aSmws 	cap->smba_stype = c.smbca_stype;
53384ab085aSmws 	cap->smba_ctype = c.smbca_ctype;
53484ab085aSmws 	cap->smba_speed = c.smbca_speed;
53584ab085aSmws 	cap->smba_etype = c.smbca_etype;
53684ab085aSmws 	cap->smba_ltype = c.smbca_ltype;
53784ab085aSmws 	cap->smba_assoc = c.smbca_assoc;
53884ab085aSmws 	cap->smba_level = SMB_CACHE_CFG_LEVEL(c.smbca_config);
53984ab085aSmws 	cap->smba_mode = SMB_CACHE_CFG_MODE(c.smbca_config);
54084ab085aSmws 	cap->smba_location = SMB_CACHE_CFG_LOCATION(c.smbca_config);
54184ab085aSmws 
54284ab085aSmws 	if (SMB_CACHE_CFG_ENABLED(c.smbca_config))
54384ab085aSmws 		cap->smba_flags |= SMB_CAF_ENABLED;
54484ab085aSmws 
54584ab085aSmws 	if (SMB_CACHE_CFG_SOCKETED(c.smbca_config))
54684ab085aSmws 		cap->smba_flags |= SMB_CAF_SOCKETED;
54784ab085aSmws 
54884ab085aSmws 	return (0);
54984ab085aSmws }
55084ab085aSmws 
55184ab085aSmws int
55284ab085aSmws smbios_info_port(smbios_hdl_t *shp, id_t id, smbios_port_t *pop)
55384ab085aSmws {
55484ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
55584ab085aSmws 	smb_port_t p;
55684ab085aSmws 
55784ab085aSmws 	if (stp == NULL)
55884ab085aSmws 		return (-1); /* errno is set for us */
55984ab085aSmws 
56084ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_PORT)
56184ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
56284ab085aSmws 
56384ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
56484ab085aSmws 	bzero(pop, sizeof (smbios_port_t));
56584ab085aSmws 
56684ab085aSmws 	pop->smbo_iref = smb_strptr(stp, p.smbpo_iref);
56784ab085aSmws 	pop->smbo_eref = smb_strptr(stp, p.smbpo_eref);
56884ab085aSmws 
56984ab085aSmws 	pop->smbo_itype = p.smbpo_itype;
57084ab085aSmws 	pop->smbo_etype = p.smbpo_etype;
57184ab085aSmws 	pop->smbo_ptype = p.smbpo_ptype;
57284ab085aSmws 
57384ab085aSmws 	return (0);
57484ab085aSmws }
57584ab085aSmws 
57684ab085aSmws int
57784ab085aSmws smbios_info_slot(smbios_hdl_t *shp, id_t id, smbios_slot_t *sp)
57884ab085aSmws {
57984ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
58084ab085aSmws 	smb_slot_t s;
58184ab085aSmws 
58284ab085aSmws 	if (stp == NULL)
58384ab085aSmws 		return (-1); /* errno is set for us */
58484ab085aSmws 
58584ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT)
58684ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
58784ab085aSmws 
58884ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
58984ab085aSmws 	bzero(sp, sizeof (smbios_slot_t));
59084ab085aSmws 
59184ab085aSmws 	sp->smbl_name = smb_strptr(stp, s.smbsl_name);
59284ab085aSmws 	sp->smbl_type = s.smbsl_type;
59384ab085aSmws 	sp->smbl_width = s.smbsl_width;
59484ab085aSmws 	sp->smbl_usage = s.smbsl_usage;
59584ab085aSmws 	sp->smbl_length = s.smbsl_length;
59684ab085aSmws 	sp->smbl_id = s.smbsl_id;
59784ab085aSmws 	sp->smbl_ch1 = s.smbsl_ch1;
59884ab085aSmws 	sp->smbl_ch2 = s.smbsl_ch2;
59903f9f63dSTom Pothier 	sp->smbl_sg = s.smbsl_sg;
60003f9f63dSTom Pothier 	sp->smbl_bus = s.smbsl_bus;
60103f9f63dSTom Pothier 	sp->smbl_df = s.smbsl_df;
60203f9f63dSTom Pothier 
60303f9f63dSTom Pothier 	return (0);
60403f9f63dSTom Pothier }
60503f9f63dSTom Pothier 
60603f9f63dSTom Pothier int
60703f9f63dSTom Pothier smbios_info_obdevs_ext(smbios_hdl_t *shp, id_t id, smbios_obdev_ext_t *oep)
60803f9f63dSTom Pothier {
60903f9f63dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
61003f9f63dSTom Pothier 	smb_obdev_ext_t obe;
61103f9f63dSTom Pothier 
61203f9f63dSTom Pothier 	if (stp == NULL)
61303f9f63dSTom Pothier 		return (-1); /* errno is set for us */
61403f9f63dSTom Pothier 
61503f9f63dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVEXT)
61603f9f63dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
61703f9f63dSTom Pothier 
61803f9f63dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &obe, sizeof (obe));
61903f9f63dSTom Pothier 	bzero(oep, sizeof (smbios_obdev_ext_t));
62003f9f63dSTom Pothier 
62103f9f63dSTom Pothier 	oep->smboe_name = smb_strptr(stp, obe.smbobe_name);
62203f9f63dSTom Pothier 	oep->smboe_dtype = obe.smbobe_dtype;
62303f9f63dSTom Pothier 	oep->smboe_dti = obe.smbobe_dti;
62403f9f63dSTom Pothier 	oep->smboe_sg = obe.smbobe_sg;
62503f9f63dSTom Pothier 	oep->smboe_bus = obe.smbobe_bus;
62603f9f63dSTom Pothier 	oep->smboe_df = obe.smbobe_df;
62784ab085aSmws 
62884ab085aSmws 	return (0);
62984ab085aSmws }
63084ab085aSmws 
63184ab085aSmws int
63284ab085aSmws smbios_info_obdevs(smbios_hdl_t *shp, id_t id, int obc, smbios_obdev_t *obp)
63384ab085aSmws {
63484ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
63584ab085aSmws 	const smb_obdev_t *op;
63684ab085aSmws 	int i, m, n;
63784ab085aSmws 
63884ab085aSmws 	if (stp == NULL)
63984ab085aSmws 		return (-1); /* errno is set for us */
64084ab085aSmws 
64184ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVS)
64284ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
64384ab085aSmws 
64484ab085aSmws 	op = (smb_obdev_t *)((uintptr_t)stp->smbst_hdr + sizeof (smb_header_t));
64584ab085aSmws 	m = (stp->smbst_hdr->smbh_len - sizeof (smb_header_t)) / sizeof (*op);
64684ab085aSmws 	n = MIN(m, obc);
64784ab085aSmws 
64884ab085aSmws 	for (i = 0; i < n; i++, op++, obp++) {
64984ab085aSmws 		obp->smbd_name = smb_strptr(stp, op->smbob_name);
65084ab085aSmws 		obp->smbd_type = op->smbob_type & ~SMB_OBT_ENABLED;
65184ab085aSmws 		obp->smbd_enabled = (op->smbob_type & SMB_OBT_ENABLED) != 0;
65284ab085aSmws 	}
65384ab085aSmws 
65484ab085aSmws 	return (m);
65584ab085aSmws }
65684ab085aSmws 
65784ab085aSmws /*
65884ab085aSmws  * The implementation structures for OEMSTR, SYSCONFSTR, and LANG all use the
65984ab085aSmws  * first byte to indicate the size of a string table at the end of the record.
66084ab085aSmws  * Therefore, smbios_info_strtab() can be used to retrieve the table size and
66184ab085aSmws  * strings for any of these underlying record types.
66284ab085aSmws  */
66384ab085aSmws int
66484ab085aSmws smbios_info_strtab(smbios_hdl_t *shp, id_t id, int argc, const char *argv[])
66584ab085aSmws {
66684ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
66784ab085aSmws 	smb_strtab_t s;
66884ab085aSmws 	int i, n;
66984ab085aSmws 
67084ab085aSmws 	if (stp == NULL)
67184ab085aSmws 		return (-1); /* errno is set for us */
67284ab085aSmws 
67384ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR &&
67484ab085aSmws 	    stp->smbst_hdr->smbh_type != SMB_TYPE_SYSCONFSTR &&
67584ab085aSmws 	    stp->smbst_hdr->smbh_type != SMB_TYPE_LANG)
67684ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
67784ab085aSmws 
67884ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
67984ab085aSmws 	n = MIN(s.smbtb_count, argc);
68084ab085aSmws 
68184ab085aSmws 	for (i = 0; i < n; i++)
68284ab085aSmws 		argv[i] = smb_strptr(stp, i + 1);
68384ab085aSmws 
68484ab085aSmws 	return (s.smbtb_count);
68584ab085aSmws }
68684ab085aSmws 
68784ab085aSmws id_t
68884ab085aSmws smbios_info_lang(smbios_hdl_t *shp, smbios_lang_t *lp)
68984ab085aSmws {
69084ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_LANG);
69184ab085aSmws 	smb_lang_t l;
69284ab085aSmws 
69384ab085aSmws 	if (stp == NULL)
69484ab085aSmws 		return (-1); /* errno is set for us */
69584ab085aSmws 
69684ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &l, sizeof (l));
69784ab085aSmws 	bzero(lp, sizeof (smbios_lang_t));
69884ab085aSmws 
69984ab085aSmws 	lp->smbla_cur = smb_strptr(stp, l.smblang_cur);
70084ab085aSmws 	lp->smbla_fmt = l.smblang_flags & 1;
70184ab085aSmws 	lp->smbla_num = l.smblang_num;
70284ab085aSmws 
70384ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
70484ab085aSmws }
70584ab085aSmws 
70684ab085aSmws id_t
70784ab085aSmws smbios_info_eventlog(smbios_hdl_t *shp, smbios_evlog_t *evp)
70884ab085aSmws {
70984ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_EVENTLOG);
71084ab085aSmws 	const smb_sel_t *sel;
71184ab085aSmws 	size_t len;
71284ab085aSmws 
71384ab085aSmws 	if (stp == NULL)
71484ab085aSmws 		return (-1); /* errno is set for us */
71584ab085aSmws 
71684ab085aSmws 	if (stp->smbst_hdr->smbh_len < sizeof (smb_sel_t) - sizeof (uint8_t))
71784ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
71884ab085aSmws 
71984ab085aSmws 	sel = (smb_sel_t *)(uintptr_t)stp->smbst_hdr;
72084ab085aSmws 	len = stp->smbst_hdr->smbh_len - sizeof (smb_sel_t) + sizeof (uint8_t);
72184ab085aSmws 	bzero(evp, sizeof (smbios_evlog_t));
72284ab085aSmws 
72384ab085aSmws 	if (len < sel->smbsel_typec * sel->smbsel_typesz)
72484ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
72584ab085aSmws 
72684ab085aSmws 	evp->smbev_size = sel->smbsel_len;
72784ab085aSmws 	evp->smbev_hdr = sel->smbsel_hdroff;
72884ab085aSmws 	evp->smbev_data = sel->smbsel_dataoff;
72984ab085aSmws 	evp->smbev_method = sel->smbsel_method;
73084ab085aSmws 	evp->smbev_flags = sel->smbsel_status;
73184ab085aSmws 	evp->smbev_format = sel->smbsel_format;
73284ab085aSmws 	evp->smbev_token = sel->smbsel_token;
73384ab085aSmws 	evp->smbev_addr.eva_addr = sel->smbsel_addr;
73484ab085aSmws 
73584ab085aSmws 	if (sel->smbsel_typesz == sizeof (smbios_evtype_t)) {
73684ab085aSmws 		evp->smbev_typec = sel->smbsel_typec;
73784ab085aSmws 		evp->smbev_typev = (void *)(uintptr_t)sel->smbsel_typev;
73884ab085aSmws 	}
73984ab085aSmws 
74084ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
74184ab085aSmws }
74284ab085aSmws 
74384ab085aSmws int
74484ab085aSmws smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map)
74584ab085aSmws {
74684ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
74784ab085aSmws 	smb_memarray_t m;
74884ab085aSmws 
74984ab085aSmws 	if (stp == NULL)
75084ab085aSmws 		return (-1); /* errno is set for us */
75184ab085aSmws 
75284ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAY)
75384ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
75484ab085aSmws 
75584ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
75684ab085aSmws 	bzero(map, sizeof (smbios_memarray_t));
75784ab085aSmws 
75884ab085aSmws 	map->smbma_location = m.smbmarr_loc;
75984ab085aSmws 	map->smbma_use = m.smbmarr_use;
76084ab085aSmws 	map->smbma_ecc = m.smbmarr_ecc;
76184ab085aSmws 	map->smbma_ndevs = m.smbmarr_ndevs;
76284ab085aSmws 	map->smbma_err = m.smbmarr_err;
76384ab085aSmws 
76484ab085aSmws 	if (m.smbmarr_cap != 0x80000000)
76584ab085aSmws 		map->smbma_size = (uint64_t)m.smbmarr_cap * 1024;
7664e901881SDale Ghent 	else if (m.smbmarr_extcap != 0)
7674e901881SDale Ghent 		map->smbma_size = m.smbmarr_extcap;
76884ab085aSmws 	else
76984ab085aSmws 		map->smbma_size = 0; /* unknown */
77084ab085aSmws 
77184ab085aSmws 	return (0);
77284ab085aSmws }
77384ab085aSmws 
77484ab085aSmws int
77584ab085aSmws smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map)
77684ab085aSmws {
77784ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
77884ab085aSmws 	smb_memarrmap_t m;
77984ab085aSmws 
78084ab085aSmws 	if (stp == NULL)
78184ab085aSmws 		return (-1); /* errno is set for us */
78284ab085aSmws 
78384ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP)
78484ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
78584ab085aSmws 
78684ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
78784ab085aSmws 	bzero(map, sizeof (smbios_memarrmap_t));
78884ab085aSmws 
78984ab085aSmws 	map->smbmam_array = m.smbamap_array;
79084ab085aSmws 	map->smbmam_width = m.smbamap_width;
7914e901881SDale Ghent 
7924e901881SDale Ghent 	if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) {
79384ab085aSmws 		map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
79484ab085aSmws 		map->smbmam_size = (uint64_t)
79584ab085aSmws 		    (m.smbamap_end - m.smbamap_start + 1) * 1024;
7964e901881SDale Ghent 	} else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) {
7974e901881SDale Ghent 		map->smbmam_addr = m.smbamap_extstart;
7984e901881SDale Ghent 		map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1;
7994e901881SDale Ghent 	}
80084ab085aSmws 
80184ab085aSmws 	return (0);
80284ab085aSmws }
80384ab085aSmws 
80484ab085aSmws int
80584ab085aSmws smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp)
80684ab085aSmws {
80784ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
80884ab085aSmws 	smb_memdevice_t m;
80984ab085aSmws 
81084ab085aSmws 	if (stp == NULL)
81184ab085aSmws 		return (-1); /* errno is set for us */
81284ab085aSmws 
81384ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICE)
81484ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
81584ab085aSmws 
81684ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
817*6734c4b0SRobert Mustacchi 	bzero(mdp, sizeof (smb_base_memdevice_t));
81884ab085aSmws 
81984ab085aSmws 	mdp->smbmd_array = m.smbmdev_array;
82084ab085aSmws 	mdp->smbmd_error = m.smbmdev_error;
82184ab085aSmws 	mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth;
82284ab085aSmws 	mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth;
82384ab085aSmws 
8244e901881SDale Ghent 	if (m.smbmdev_size == 0x7FFF) {
8254e901881SDale Ghent 		mdp->smbmd_size = (uint64_t)m.smbmdev_extsize;
8264e901881SDale Ghent 		mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */
8274e901881SDale Ghent 	} else if (m.smbmdev_size != 0xFFFF) {
82884ab085aSmws 		mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES);
82984ab085aSmws 		if (m.smbmdev_size & SMB_MDS_KBYTES)
83084ab085aSmws 			mdp->smbmd_size *= 1024;
83184ab085aSmws 		else
83284ab085aSmws 			mdp->smbmd_size *= 1024 * 1024;
83384ab085aSmws 	} else
83484ab085aSmws 		mdp->smbmd_size = -1ULL; /* size unknown */
83584ab085aSmws 
83684ab085aSmws 	mdp->smbmd_form = m.smbmdev_form;
83784ab085aSmws 	mdp->smbmd_set = m.smbmdev_set;
83884ab085aSmws 	mdp->smbmd_type = m.smbmdev_type;
8394e901881SDale Ghent 	mdp->smbmd_speed = m.smbmdev_speed;
84084ab085aSmws 	mdp->smbmd_flags = m.smbmdev_flags;
84184ab085aSmws 	mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc);
84284ab085aSmws 	mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc);
84384ab085aSmws 
844*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_26)
8454e901881SDale Ghent 		mdp->smbmd_rank = m.smbmdev_attrs & 0x0F;
8464e901881SDale Ghent 
847*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_27)
8484e901881SDale Ghent 		mdp->smbmd_clkspeed = m.smbmdev_clkspeed;
8494e901881SDale Ghent 
850*6734c4b0SRobert Mustacchi 	if (shp->sh_libvers >= SMB_VERSION_28) {
8514e901881SDale Ghent 		mdp->smbmd_minvolt = m.smbmdev_minvolt;
8524e901881SDale Ghent 		mdp->smbmd_maxvolt = m.smbmdev_maxvolt;
8534e901881SDale Ghent 		mdp->smbmd_confvolt = m.smbmdev_confvolt;
8544e901881SDale Ghent 	}
85584ab085aSmws 
85684ab085aSmws 	return (0);
85784ab085aSmws }
85884ab085aSmws 
85984ab085aSmws int
86084ab085aSmws smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp)
86184ab085aSmws {
86284ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
86384ab085aSmws 	smb_memdevmap_t m;
86484ab085aSmws 
86584ab085aSmws 	if (stp == NULL)
86684ab085aSmws 		return (-1); /* errno is set for us */
86784ab085aSmws 
86884ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP)
86984ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
87084ab085aSmws 
87184ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
87284ab085aSmws 	bzero(mdp, sizeof (smbios_memdevmap_t));
87384ab085aSmws 
87484ab085aSmws 	mdp->smbmdm_device = m.smbdmap_device;
87584ab085aSmws 	mdp->smbmdm_arrmap = m.smbdmap_array;
87684ab085aSmws 	mdp->smbmdm_rpos = m.smbdmap_rpos;
87784ab085aSmws 	mdp->smbmdm_ipos = m.smbdmap_ipos;
87884ab085aSmws 	mdp->smbmdm_idepth = m.smbdmap_idepth;
87984ab085aSmws 
8804e901881SDale Ghent 	if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) {
8814e901881SDale Ghent 		mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
8824e901881SDale Ghent 		mdp->smbmdm_size = (uint64_t)
8834e901881SDale Ghent 		    (m.smbdmap_end - m.smbdmap_start + 1) * 1024;
8844e901881SDale Ghent 	} else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) {
8854e901881SDale Ghent 		mdp->smbmdm_addr = m.smbdmap_extstart;
8864e901881SDale Ghent 		mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1;
8874e901881SDale Ghent 	}
8884e901881SDale Ghent 
88984ab085aSmws 	return (0);
89084ab085aSmws }
89184ab085aSmws 
89284ab085aSmws id_t
89384ab085aSmws smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp)
89484ab085aSmws {
89584ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY);
89684ab085aSmws 	smb_hwsec_t hs;
89784ab085aSmws 
89884ab085aSmws 	if (stp == NULL)
89984ab085aSmws 		return (-1); /* errno is set for us */
90084ab085aSmws 
90184ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &hs, sizeof (hs));
90284ab085aSmws 	bzero(hsp, sizeof (smbios_hwsec_t));
90384ab085aSmws 
90484ab085aSmws 	hsp->smbh_pwr_ps = SMB_HWS_PWR_PS(hs.smbhs_settings);
90584ab085aSmws 	hsp->smbh_kbd_ps = SMB_HWS_KBD_PS(hs.smbhs_settings);
90684ab085aSmws 	hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings);
90784ab085aSmws 	hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings);
90884ab085aSmws 
90984ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
91084ab085aSmws }
91184ab085aSmws 
91284ab085aSmws id_t
91384ab085aSmws smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp)
91484ab085aSmws {
91584ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT);
91684ab085aSmws 	const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
91784ab085aSmws 
91884ab085aSmws 	if (stp == NULL)
91984ab085aSmws 		return (-1); /* errno is set for us */
92084ab085aSmws 
92184ab085aSmws 	bzero(bp, sizeof (smbios_boot_t));
92284ab085aSmws 
92384ab085aSmws 	bp->smbt_status = b->smbbo_status[0];
92484ab085aSmws 	bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t);
92584ab085aSmws 	bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL;
92684ab085aSmws 
92784ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
92884ab085aSmws }
92984ab085aSmws 
93084ab085aSmws id_t
93184ab085aSmws smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip)
93284ab085aSmws {
93384ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_IPMIDEV);
93484ab085aSmws 	smb_ipmi_t i;
93584ab085aSmws 
93684ab085aSmws 	if (stp == NULL)
93784ab085aSmws 		return (-1); /* errno is set for us */
93884ab085aSmws 
93984ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &i, sizeof (i));
94084ab085aSmws 	bzero(ip, sizeof (smbios_ipmi_t));
94184ab085aSmws 
94284ab085aSmws 	ip->smbip_type = i.smbipm_type;
94384ab085aSmws 	ip->smbip_vers.smbv_major = SMB_IPM_SPEC_MAJOR(i.smbipm_spec);
94484ab085aSmws 	ip->smbip_vers.smbv_minor = SMB_IPM_SPEC_MINOR(i.smbipm_spec);
94584ab085aSmws 	ip->smbip_i2c = i.smbipm_i2c;
94684ab085aSmws 	ip->smbip_addr = i.smbipm_addr & ~SMB_IPM_ADDR_IO;
94784ab085aSmws 	ip->smbip_intr = i.smbipm_intr;
94884ab085aSmws 
94984ab085aSmws 	if (i.smbipm_bus != (uint8_t)-1)
95084ab085aSmws 		ip->smbip_bus = i.smbipm_bus;
95184ab085aSmws 	else
95284ab085aSmws 		ip->smbip_bus = -1u;
95384ab085aSmws 
95484ab085aSmws 	if (SMB_IPM_INFO_LSB(i.smbipm_info))
95584ab085aSmws 		ip->smbip_addr |= 1; /* turn on least-significant bit of addr */
95684ab085aSmws 
95784ab085aSmws 	if (i.smbipm_addr & SMB_IPM_ADDR_IO) {
95884ab085aSmws 		switch (SMB_IPM_INFO_REGS(i.smbipm_info)) {
95984ab085aSmws 		case SMB_IPM_REGS_1B:
96084ab085aSmws 			ip->smbip_regspacing = 1;
96184ab085aSmws 			break;
96284ab085aSmws 		case SMB_IPM_REGS_4B:
96384ab085aSmws 			ip->smbip_regspacing = 4;
96484ab085aSmws 			break;
96584ab085aSmws 		case SMB_IPM_REGS_16B:
96684ab085aSmws 			ip->smbip_regspacing = 16;
96784ab085aSmws 			break;
96884ab085aSmws 		default:
96984ab085aSmws 			ip->smbip_regspacing = 1;
97084ab085aSmws 		}
97184ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_IOADDR;
97284ab085aSmws 	}
97384ab085aSmws 
97484ab085aSmws 	if (SMB_IPM_INFO_ISPEC(i.smbipm_info))
97584ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTRSPEC;
97684ab085aSmws 
97784ab085aSmws 	if (SMB_IPM_INFO_IPOL(i.smbipm_info) == SMB_IPM_IPOL_HI)
97884ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTRHIGH;
97984ab085aSmws 
98084ab085aSmws 	if (SMB_IPM_INFO_IMODE(i.smbipm_info) == SMB_IPM_IMODE_EDGE)
98184ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTREDGE;
98284ab085aSmws 
98384ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
98484ab085aSmws }
9859c94f155SCheng Sean Ye 
9869c94f155SCheng Sean Ye static boolean_t
9879c94f155SCheng Sean Ye smbios_has_oemstr(smbios_hdl_t *shp, const char *oemstr)
9889c94f155SCheng Sean Ye {
9899c94f155SCheng Sean Ye 	const smb_struct_t *stp = shp->sh_structs;
9909c94f155SCheng Sean Ye 	smb_strtab_t s;
9919c94f155SCheng Sean Ye 	int i, j;
9929c94f155SCheng Sean Ye 
9939c94f155SCheng Sean Ye 	for (i = 0; i < shp->sh_nstructs; i++, stp++) {
9949c94f155SCheng Sean Ye 		if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR)
9959c94f155SCheng Sean Ye 			continue;
9969c94f155SCheng Sean Ye 
9979c94f155SCheng Sean Ye 		smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
9989c94f155SCheng Sean Ye 		for (j = 0; j < s.smbtb_count; j++)
9999c94f155SCheng Sean Ye 			if (strcmp(smb_strptr(stp, j + 1), oemstr) == 0)
10009c94f155SCheng Sean Ye 				return (B_TRUE);
10019c94f155SCheng Sean Ye 	}
10029c94f155SCheng Sean Ye 
10039c94f155SCheng Sean Ye 	return (B_FALSE);
10049c94f155SCheng Sean Ye }
10059c94f155SCheng Sean Ye 
10069c94f155SCheng Sean Ye static const char *
10079c94f155SCheng Sean Ye smb_serial_valid(const char *serial)
10089c94f155SCheng Sean Ye {
10099c94f155SCheng Sean Ye 	char buf[MAXNAMELEN];
10109c94f155SCheng Sean Ye 	int i = 0;
10119c94f155SCheng Sean Ye 
10129c94f155SCheng Sean Ye 	if (serial == NULL)
10139c94f155SCheng Sean Ye 		return (NULL);
10149c94f155SCheng Sean Ye 
10159c94f155SCheng Sean Ye 	(void) strlcpy(buf, serial, sizeof (buf));
10169c94f155SCheng Sean Ye 
10179c94f155SCheng Sean Ye 	while (buf[i] != '\0' && buf[i] == ' ')
10189c94f155SCheng Sean Ye 		i++;
10199c94f155SCheng Sean Ye 
10209c94f155SCheng Sean Ye 	if (buf[i] == '\0' || strstr(buf, SMB_DEFAULT1) != NULL ||
10219c94f155SCheng Sean Ye 	    strstr(buf, SMB_DEFAULT2) != NULL)
10229c94f155SCheng Sean Ye 		return (NULL);
10239c94f155SCheng Sean Ye 
10249c94f155SCheng Sean Ye 	return (serial);
10259c94f155SCheng Sean Ye }
10269c94f155SCheng Sean Ye 
10279c94f155SCheng Sean Ye /*
10289c94f155SCheng Sean Ye  * Get chassis SN or product SN
10299c94f155SCheng Sean Ye  */
10309c94f155SCheng Sean Ye static int
10319c94f155SCheng Sean Ye smb_get_sn(smbios_hdl_t *shp, const char **psnp, const char **csnp)
10329c94f155SCheng Sean Ye {
10339c94f155SCheng Sean Ye 	const smb_struct_t *stp;
10349c94f155SCheng Sean Ye 	smbios_info_t s1, s3;
10359c94f155SCheng Sean Ye 
10369c94f155SCheng Sean Ye 	if (psnp == NULL || csnp == NULL)
10379c94f155SCheng Sean Ye 		return (smb_set_errno(shp, ESMB_INVAL));
10389c94f155SCheng Sean Ye 
10399c94f155SCheng Sean Ye 	*psnp = *csnp = NULL;
10409c94f155SCheng Sean Ye 
10419c94f155SCheng Sean Ye 	/*
10429c94f155SCheng Sean Ye 	 * If SMBIOS meets Sun's PRMS requirements, retrieve product SN
10439c94f155SCheng Sean Ye 	 * from type 1 structure, and chassis SN from type 3 structure.
10449c94f155SCheng Sean Ye 	 * Otherwise return SN in type 1 structure as chassis SN.
10459c94f155SCheng Sean Ye 	 */
10469c94f155SCheng Sean Ye 
10479c94f155SCheng Sean Ye 	/* Get type 1 SN */
10489c94f155SCheng Sean Ye 	if ((stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM)) == NULL ||
10499c94f155SCheng Sean Ye 	    smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s1) == SMB_ERR)
10509c94f155SCheng Sean Ye 		s1.smbi_serial = NULL;
10519c94f155SCheng Sean Ye 
10529c94f155SCheng Sean Ye 	/* Get type 3 SN */
10539c94f155SCheng Sean Ye 	if ((stp = smb_lookup_type(shp, SMB_TYPE_CHASSIS)) == NULL ||
10549c94f155SCheng Sean Ye 	    smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s3) == SMB_ERR)
10559c94f155SCheng Sean Ye 		s3.smbi_serial = NULL;
10569c94f155SCheng Sean Ye 
10579c94f155SCheng Sean Ye 	if (smbios_has_oemstr(shp, SMB_PRMS1)) {
10589c94f155SCheng Sean Ye 		*psnp = smb_serial_valid(s1.smbi_serial);
10599c94f155SCheng Sean Ye 		*csnp = smb_serial_valid(s3.smbi_serial);
10609c94f155SCheng Sean Ye 	} else {
10619c94f155SCheng Sean Ye 		*csnp = smb_serial_valid(s1.smbi_serial);
10629c94f155SCheng Sean Ye 	}
10639c94f155SCheng Sean Ye 
10649c94f155SCheng Sean Ye 	return (0);
10659c94f155SCheng Sean Ye }
10669c94f155SCheng Sean Ye 
10679c94f155SCheng Sean Ye const char *
10689c94f155SCheng Sean Ye smbios_psn(smbios_hdl_t *shp)
10699c94f155SCheng Sean Ye {
10709c94f155SCheng Sean Ye 	const char *psn, *csn;
10719c94f155SCheng Sean Ye 
10729c94f155SCheng Sean Ye 	return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : psn);
10739c94f155SCheng Sean Ye }
10749c94f155SCheng Sean Ye 
10759c94f155SCheng Sean Ye const char *
10769c94f155SCheng Sean Ye smbios_csn(smbios_hdl_t *shp)
10779c94f155SCheng Sean Ye {
10789c94f155SCheng Sean Ye 	const char *psn, *csn;
10799c94f155SCheng Sean Ye 
10809c94f155SCheng Sean Ye 	return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : csn);
10819c94f155SCheng Sean Ye }
1082074bb90dSTom Pothier 
1083074bb90dSTom Pothier int
1084074bb90dSTom Pothier smbios_info_extprocessor(smbios_hdl_t *shp, id_t id,
1085074bb90dSTom Pothier     smbios_processor_ext_t *epp)
1086074bb90dSTom Pothier {
1087074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1088074bb90dSTom Pothier 	smb_processor_ext_t *exp;
1089074bb90dSTom Pothier 
1090074bb90dSTom Pothier 	if (stp == NULL)
1091074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1092074bb90dSTom Pothier 
1093074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PROCESSOR)
1094074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1095074bb90dSTom Pothier 
1096074bb90dSTom Pothier 	exp = (smb_processor_ext_t *)(uintptr_t)stp->smbst_hdr;
1097074bb90dSTom Pothier 	bzero(epp, sizeof (smbios_processor_ext_t));
1098074bb90dSTom Pothier 
1099074bb90dSTom Pothier 	epp->smbpe_processor = exp->smbpre_processor;
1100074bb90dSTom Pothier 	epp->smbpe_fru = exp->smbpre_fru;
1101074bb90dSTom Pothier 	epp->smbpe_n = exp->smbpre_n;
1102074bb90dSTom Pothier 	epp->smbpe_apicid = exp->smbpre_apicid;
1103074bb90dSTom Pothier 
1104074bb90dSTom Pothier 	return (0);
1105074bb90dSTom Pothier }
1106074bb90dSTom Pothier 
1107074bb90dSTom Pothier int
110803f9f63dSTom Pothier smbios_info_extport(smbios_hdl_t *shp, id_t id, smbios_port_ext_t *eportp)
110903f9f63dSTom Pothier {
111003f9f63dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
111103f9f63dSTom Pothier 	smb_port_ext_t *ep;
111203f9f63dSTom Pothier 
111303f9f63dSTom Pothier 	if (stp == NULL)
111403f9f63dSTom Pothier 		return (-1); /* errno is set for us */
111503f9f63dSTom Pothier 
111603f9f63dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PORT)
111703f9f63dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
111803f9f63dSTom Pothier 
111903f9f63dSTom Pothier 	ep = (smb_port_ext_t *)(uintptr_t)stp->smbst_hdr;
112003f9f63dSTom Pothier 	bzero(eportp, sizeof (smbios_port_ext_t));
112103f9f63dSTom Pothier 
112203f9f63dSTom Pothier 	eportp->smbporte_chassis = ep->smbpoe_chassis;
112303f9f63dSTom Pothier 	eportp->smbporte_port = ep->smbpoe_port;
112403f9f63dSTom Pothier 	eportp->smbporte_dtype = ep->smbpoe_dtype;
112503f9f63dSTom Pothier 	eportp->smbporte_devhdl = ep->smbpoe_devhdl;
112603f9f63dSTom Pothier 	eportp->smbporte_phy = ep->smbpoe_phy;
112703f9f63dSTom Pothier 
112803f9f63dSTom Pothier 	return (0);
112903f9f63dSTom Pothier }
113003f9f63dSTom Pothier 
113103f9f63dSTom Pothier int
1132074bb90dSTom Pothier smbios_info_pciexrc(smbios_hdl_t *shp, id_t id,
1133074bb90dSTom Pothier     smbios_pciexrc_t *rcp)
1134074bb90dSTom Pothier {
1135074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1136074bb90dSTom Pothier 	smb_pciexrc_t rc;
1137074bb90dSTom Pothier 
1138074bb90dSTom Pothier 	if (stp == NULL)
1139074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1140074bb90dSTom Pothier 
1141074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_PCIEXRC)
1142074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1143074bb90dSTom Pothier 
1144074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &rc, sizeof (rc));
1145074bb90dSTom Pothier 	bzero(rcp, sizeof (smbios_pciexrc_t));
1146074bb90dSTom Pothier 
1147074bb90dSTom Pothier 	rcp->smbpcie_bb = rc.smbpciexrc_bboard;
1148074bb90dSTom Pothier 	rcp->smbpcie_bdf = rc.smbpciexrc_bdf;
1149074bb90dSTom Pothier 
1150074bb90dSTom Pothier 	return (0);
1151074bb90dSTom Pothier }
1152074bb90dSTom Pothier 
1153074bb90dSTom Pothier int
1154074bb90dSTom Pothier smbios_info_extmemarray(smbios_hdl_t *shp, id_t id, smbios_memarray_ext_t *emap)
1155074bb90dSTom Pothier {
1156074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1157074bb90dSTom Pothier 	smb_memarray_ext_t exma;
1158074bb90dSTom Pothier 
1159074bb90dSTom Pothier 	if (stp == NULL)
1160074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1161074bb90dSTom Pothier 
1162074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMARRAY)
1163074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1164074bb90dSTom Pothier 
1165074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &exma, sizeof (exma));
1166074bb90dSTom Pothier 	bzero(emap, sizeof (smbios_memarray_ext_t));
1167074bb90dSTom Pothier 
1168074bb90dSTom Pothier 	emap->smbmae_ma = exma.smbmarre_ma;
1169074bb90dSTom Pothier 	emap->smbmae_comp = exma.smbmarre_component;
1170074bb90dSTom Pothier 	emap->smbmae_bdf = exma.smbmarre_bdf;
1171074bb90dSTom Pothier 
1172074bb90dSTom Pothier 	return (0);
1173074bb90dSTom Pothier }
1174074bb90dSTom Pothier 
1175074bb90dSTom Pothier int
1176074bb90dSTom Pothier smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id,
1177074bb90dSTom Pothier     smbios_memdevice_ext_t *emdp)
1178074bb90dSTom Pothier {
1179074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1180074bb90dSTom Pothier 	smb_memdevice_ext_t exmd;
1181074bb90dSTom Pothier 
1182074bb90dSTom Pothier 	if (stp == NULL)
1183074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1184074bb90dSTom Pothier 
1185074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMDEVICE)
1186074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1187074bb90dSTom Pothier 
1188074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &exmd, sizeof (exmd));
1189074bb90dSTom Pothier 	bzero(emdp, sizeof (smbios_memdevice_ext_t));
1190074bb90dSTom Pothier 
1191074bb90dSTom Pothier 	emdp->smbmdeve_md = exmd.smbmdeve_mdev;
1192074bb90dSTom Pothier 	emdp->smbmdeve_drch = exmd.smbmdeve_dchan;
1193074bb90dSTom Pothier 	emdp->smbmdeve_ncs  = exmd.smbmdeve_ncs;
1194074bb90dSTom Pothier 	emdp->smbmdeve_cs = exmd.smbmdeve_cs;
1195074bb90dSTom Pothier 
1196074bb90dSTom Pothier 	return (0);
1197074bb90dSTom Pothier }
1198