xref: /titanic_50/usr/src/common/smbios/smb_info.c (revision 03f9f63d24f0494b7d47b927090ad9045e396402)
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*03f9f63dSTom Pothier  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
2484ab085aSmws  * Use is subject to license terms.
2584ab085aSmws  */
2684ab085aSmws 
2784ab085aSmws /*
2884ab085aSmws  * SMBIOS Information Routines
2984ab085aSmws  *
3084ab085aSmws  * The routines in this file are used to convert from the SMBIOS data format to
3184ab085aSmws  * a more reasonable and stable set of structures offered as part of our ABI.
3284ab085aSmws  * These functions take the general form:
3384ab085aSmws  *
3484ab085aSmws  *	stp = smb_lookup_type(shp, foo);
3584ab085aSmws  *	smb_foo_t foo;
3684ab085aSmws  *
3784ab085aSmws  *	smb_info_bcopy(stp->smbst_hdr, &foo, sizeof (foo));
3884ab085aSmws  *      bzero(caller's struct);
3984ab085aSmws  *
4084ab085aSmws  *	copy/convert foo members into caller's struct
4184ab085aSmws  *
4284ab085aSmws  * We copy the internal structure on to an automatic variable so as to avoid
4384ab085aSmws  * checks everywhere for structures that the BIOS has improperly truncated, and
4484ab085aSmws  * also to automatically handle the case of a structure that has been extended.
4584ab085aSmws  * When necessary, this code can use smb_gteq() to determine whether the SMBIOS
4684ab085aSmws  * data is of a particular revision that is supposed to contain a new field.
4784ab085aSmws  */
4884ab085aSmws 
4984ab085aSmws #include <sys/smbios_impl.h>
5084ab085aSmws 
519c94f155SCheng Sean Ye #ifdef _KERNEL
529c94f155SCheng Sean Ye #include <sys/sunddi.h>
539c94f155SCheng Sean Ye #else
54c7c09f80SEric Schrock #include <fcntl.h>
55c7c09f80SEric Schrock #include <unistd.h>
569c94f155SCheng Sean Ye #include <string.h>
57c7c09f80SEric Schrock #endif
58c7c09f80SEric Schrock 
5984ab085aSmws /*
6084ab085aSmws  * A large number of SMBIOS structures contain a set of common strings used to
6184ab085aSmws  * describe a h/w component's serial number, manufacturer, etc.  These fields
6284ab085aSmws  * helpfully have different names and offsets and sometimes aren't consistent.
6384ab085aSmws  * To simplify life for our clients, we factor these common things out into
6484ab085aSmws  * smbios_info_t, which can be retrieved for any structure.  The following
6584ab085aSmws  * table describes the mapping from a given structure to the smbios_info_t.
66074bb90dSTom Pothier  * Multiple SMBIOS stuctures' contained objects are also handled here.
6784ab085aSmws  */
6884ab085aSmws static const struct smb_infospec {
6984ab085aSmws 	uint8_t is_type;		/* structure type */
7084ab085aSmws 	uint8_t is_manu;		/* manufacturer offset */
7184ab085aSmws 	uint8_t is_product;		/* product name offset */
7284ab085aSmws 	uint8_t is_version;		/* version offset */
7384ab085aSmws 	uint8_t is_serial;		/* serial number offset */
7484ab085aSmws 	uint8_t is_asset;		/* asset tag offset */
7584ab085aSmws 	uint8_t is_location;		/* location string offset */
7684ab085aSmws 	uint8_t is_part;		/* part number offset */
77074bb90dSTom Pothier 	uint8_t is_contc;		/* contained count */
78074bb90dSTom Pothier 	uint8_t is_contsz;		/* contained size */
79074bb90dSTom Pothier 	uint8_t is_contv;		/* contained objects */
8084ab085aSmws } _smb_infospecs[] = {
8184ab085aSmws 	{ SMB_TYPE_SYSTEM,
8284ab085aSmws 		offsetof(smb_system_t, smbsi_manufacturer),
8384ab085aSmws 		offsetof(smb_system_t, smbsi_product),
8484ab085aSmws 		offsetof(smb_system_t, smbsi_version),
8584ab085aSmws 		offsetof(smb_system_t, smbsi_serial),
8684ab085aSmws 		0,
8784ab085aSmws 		0,
88074bb90dSTom Pothier 		0,
89074bb90dSTom Pothier 		0,
90074bb90dSTom Pothier 		0,
9184ab085aSmws 		0 },
9284ab085aSmws 	{ SMB_TYPE_BASEBOARD,
9384ab085aSmws 		offsetof(smb_bboard_t, smbbb_manufacturer),
9484ab085aSmws 		offsetof(smb_bboard_t, smbbb_product),
9584ab085aSmws 		offsetof(smb_bboard_t, smbbb_version),
9684ab085aSmws 		offsetof(smb_bboard_t, smbbb_serial),
9784ab085aSmws 		offsetof(smb_bboard_t, smbbb_asset),
9884ab085aSmws 		offsetof(smb_bboard_t, smbbb_location),
99074bb90dSTom Pothier 		0,
100074bb90dSTom Pothier 		offsetof(smb_bboard_t, smbbb_cn),
101074bb90dSTom Pothier 		SMB_CONT_WORD,
102074bb90dSTom Pothier 		offsetof(smb_bboard_t, smbbb_cv) },
10384ab085aSmws 	{ SMB_TYPE_CHASSIS,
10484ab085aSmws 		offsetof(smb_chassis_t, smbch_manufacturer),
10584ab085aSmws 		0,
10684ab085aSmws 		offsetof(smb_chassis_t, smbch_version),
10784ab085aSmws 		offsetof(smb_chassis_t, smbch_serial),
10884ab085aSmws 		offsetof(smb_chassis_t, smbch_asset),
10984ab085aSmws 		0,
110074bb90dSTom Pothier 		0,
111074bb90dSTom Pothier 		offsetof(smb_chassis_t, smbch_cn),
112074bb90dSTom Pothier 		SMB_CONT_BYTE,
113074bb90dSTom Pothier 		offsetof(smb_chassis_t, smbch_cv) },
11484ab085aSmws 	{ SMB_TYPE_PROCESSOR,
11584ab085aSmws 		offsetof(smb_processor_t, smbpr_manufacturer),
11684ab085aSmws 		0,
11784ab085aSmws 		offsetof(smb_processor_t, smbpr_version),
11884ab085aSmws 		offsetof(smb_processor_t, smbpr_serial),
11984ab085aSmws 		offsetof(smb_processor_t, smbpr_asset),
12084ab085aSmws 		offsetof(smb_processor_t, smbpr_socket),
121074bb90dSTom Pothier 		offsetof(smb_processor_t, smbpr_part),
122074bb90dSTom Pothier 		0,
123074bb90dSTom Pothier 		0,
124074bb90dSTom Pothier 		0 },
12584ab085aSmws 	{ SMB_TYPE_CACHE,
12684ab085aSmws 		0,
12784ab085aSmws 		0,
12884ab085aSmws 		0,
12984ab085aSmws 		0,
13084ab085aSmws 		0,
13184ab085aSmws 		offsetof(smb_cache_t, smbca_socket),
132074bb90dSTom Pothier 		0,
133074bb90dSTom Pothier 		0,
134074bb90dSTom Pothier 		0,
13584ab085aSmws 		0 },
13684ab085aSmws 	{ SMB_TYPE_PORT,
13784ab085aSmws 		0,
13884ab085aSmws 		0,
13984ab085aSmws 		0,
14084ab085aSmws 		0,
14184ab085aSmws 		0,
14284ab085aSmws 		offsetof(smb_port_t, smbpo_iref),
143074bb90dSTom Pothier 		0,
144074bb90dSTom Pothier 		0,
145074bb90dSTom Pothier 		0,
14684ab085aSmws 		0 },
14784ab085aSmws 	{ SMB_TYPE_SLOT,
14884ab085aSmws 		0,
14984ab085aSmws 		0,
15084ab085aSmws 		0,
15184ab085aSmws 		0,
15284ab085aSmws 		0,
15384ab085aSmws 		offsetof(smb_slot_t, smbsl_name),
154074bb90dSTom Pothier 		0,
155074bb90dSTom Pothier 		0,
156074bb90dSTom Pothier 		0,
15784ab085aSmws 		0 },
15884ab085aSmws 	{ SMB_TYPE_MEMDEVICE,
15984ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_manufacturer),
16084ab085aSmws 		0,
16184ab085aSmws 		0,
16284ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_serial),
16384ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_asset),
16484ab085aSmws 		offsetof(smb_memdevice_t, smbmdev_dloc),
165074bb90dSTom Pothier 		offsetof(smb_memdevice_t, smbmdev_part),
166074bb90dSTom Pothier 		0,
167074bb90dSTom Pothier 		0,
168074bb90dSTom Pothier 		0 },
16984ab085aSmws 	{ SMB_TYPE_POWERSUP,
17084ab085aSmws 		offsetof(smb_powersup_t, smbpsup_manufacturer),
17184ab085aSmws 		offsetof(smb_powersup_t, smbpsup_devname),
17284ab085aSmws 		offsetof(smb_powersup_t, smbpsup_rev),
17384ab085aSmws 		offsetof(smb_powersup_t, smbpsup_serial),
17484ab085aSmws 		offsetof(smb_powersup_t, smbpsup_asset),
17584ab085aSmws 		offsetof(smb_powersup_t, smbpsup_loc),
176074bb90dSTom Pothier 		offsetof(smb_powersup_t, smbpsup_part),
177074bb90dSTom Pothier 		0,
178074bb90dSTom Pothier 		0,
179074bb90dSTom Pothier 		0 },
18084ab085aSmws 	{ SMB_TYPE_EOT }
18184ab085aSmws };
18284ab085aSmws 
18384ab085aSmws static const char *
18484ab085aSmws smb_info_strptr(const smb_struct_t *stp, uint8_t off, int *n)
18584ab085aSmws {
18684ab085aSmws 	const uint8_t *sp = (const uint8_t *)(uintptr_t)stp->smbst_hdr;
18784ab085aSmws 
18884ab085aSmws 	if (off != 0 && sp + off < stp->smbst_end) {
18984ab085aSmws 		(*n)++; /* indicate success for caller */
19084ab085aSmws 		return (smb_strptr(stp, sp[off]));
19184ab085aSmws 	}
19284ab085aSmws 
19384ab085aSmws 	return (smb_strptr(stp, 0));
19484ab085aSmws }
19584ab085aSmws 
19684ab085aSmws static void
19784ab085aSmws smb_info_bcopy(const smb_header_t *hp, void *dst, size_t dstlen)
19884ab085aSmws {
19984ab085aSmws 	if (dstlen > hp->smbh_len) {
20084ab085aSmws 		bcopy(hp, dst, hp->smbh_len);
20184ab085aSmws 		bzero((char *)dst + hp->smbh_len, dstlen - hp->smbh_len);
20284ab085aSmws 	} else
20384ab085aSmws 		bcopy(hp, dst, dstlen);
20484ab085aSmws }
20584ab085aSmws 
20684ab085aSmws void
20784ab085aSmws smbios_info_smbios(smbios_hdl_t *shp, smbios_entry_t *ep)
20884ab085aSmws {
20984ab085aSmws 	bcopy(&shp->sh_ent, ep, sizeof (smbios_entry_t));
21084ab085aSmws }
21184ab085aSmws 
212c7c09f80SEric Schrock #ifndef _KERNEL
213c7c09f80SEric Schrock static char smbios_product_override[256];
214c7c09f80SEric Schrock static boolean_t smbios_product_checked;
215c7c09f80SEric Schrock #endif
216c7c09f80SEric Schrock 
21784ab085aSmws int
21884ab085aSmws smbios_info_common(smbios_hdl_t *shp, id_t id, smbios_info_t *ip)
21984ab085aSmws {
22084ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
22184ab085aSmws 	const struct smb_infospec *isp;
22284ab085aSmws 	int n = 0;
22384ab085aSmws 
22484ab085aSmws 	if (stp == NULL)
22584ab085aSmws 		return (-1); /* errno is set for us */
22684ab085aSmws 
22784ab085aSmws 	for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
22884ab085aSmws 		if (isp->is_type == stp->smbst_hdr->smbh_type)
22984ab085aSmws 			break;
23084ab085aSmws 	}
23184ab085aSmws 
23284ab085aSmws 	ip->smbi_manufacturer = smb_info_strptr(stp, isp->is_manu, &n);
23384ab085aSmws 	ip->smbi_product = smb_info_strptr(stp, isp->is_product, &n);
23484ab085aSmws 	ip->smbi_version = smb_info_strptr(stp, isp->is_version, &n);
23584ab085aSmws 	ip->smbi_serial = smb_info_strptr(stp, isp->is_serial, &n);
23684ab085aSmws 	ip->smbi_asset = smb_info_strptr(stp, isp->is_asset, &n);
23784ab085aSmws 	ip->smbi_location = smb_info_strptr(stp, isp->is_location, &n);
23884ab085aSmws 	ip->smbi_part = smb_info_strptr(stp, isp->is_part, &n);
23984ab085aSmws 
24084ab085aSmws 	/*
241c7c09f80SEric Schrock 	 * This private file allows developers to experiment with reporting
242c7c09f80SEric Schrock 	 * different platform strings from SMBIOS.  It is not a supported
243c7c09f80SEric Schrock 	 * mechanism in the long term, and does not work in the kernel.
244c7c09f80SEric Schrock 	 */
245c7c09f80SEric Schrock #ifndef _KERNEL
246c7c09f80SEric Schrock 	if (isp->is_type == SMB_TYPE_SYSTEM) {
247c7c09f80SEric Schrock 		if (!smbios_product_checked) {
248c7c09f80SEric Schrock 			int fd = open("/etc/smbios_product", O_RDONLY);
249c7c09f80SEric Schrock 			if (fd >= 0) {
250c7c09f80SEric Schrock 				(void) read(fd, smbios_product_override,
251c7c09f80SEric Schrock 				    sizeof (smbios_product_override) - 1);
252c7c09f80SEric Schrock 				(void) close(fd);
253c7c09f80SEric Schrock 			}
254c7c09f80SEric Schrock 			smbios_product_checked = B_TRUE;
255c7c09f80SEric Schrock 		}
256c7c09f80SEric Schrock 
257c7c09f80SEric Schrock 		if (smbios_product_override[0] != '\0')
258c7c09f80SEric Schrock 			ip->smbi_product = smbios_product_override;
259c7c09f80SEric Schrock 	}
260c7c09f80SEric Schrock #endif
261c7c09f80SEric Schrock 
262c7c09f80SEric Schrock 	/*
26384ab085aSmws 	 * If we have a port with an empty internal reference designator string
26484ab085aSmws 	 * try using the external reference designator string instead.
26584ab085aSmws 	 */
26684ab085aSmws 	if (isp->is_type == SMB_TYPE_PORT && ip->smbi_location[0] == '\0') {
26784ab085aSmws 		ip->smbi_location = smb_info_strptr(stp,
26884ab085aSmws 		    offsetof(smb_port_t, smbpo_eref), &n);
26984ab085aSmws 	}
27084ab085aSmws 
27184ab085aSmws 	return (n ? 0 : smb_set_errno(shp, ESMB_NOINFO));
27284ab085aSmws }
27384ab085aSmws 
274074bb90dSTom Pothier /*
275074bb90dSTom Pothier  * Returns the actual number of contained objects.
276074bb90dSTom Pothier  *
277074bb90dSTom Pothier  * idc - number of contained objects
278074bb90dSTom Pothier  * idv - returned array of contained objects
279074bb90dSTom Pothier  */
280074bb90dSTom Pothier int
281074bb90dSTom Pothier smbios_info_contains(smbios_hdl_t *shp, id_t id, uint_t idc, id_t *idv)
282074bb90dSTom Pothier {
283074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
284074bb90dSTom Pothier 	const struct smb_infospec *isp;
285074bb90dSTom Pothier 	id_t *cp;
286074bb90dSTom Pothier 	uint_t size;
287074bb90dSTom Pothier 	uint8_t cnt;
288074bb90dSTom Pothier 	int i, n;
289074bb90dSTom Pothier 
290074bb90dSTom Pothier 	if (stp == NULL) {
291074bb90dSTom Pothier 		return (-1); /* errno is set for us */
292074bb90dSTom Pothier 	}
293074bb90dSTom Pothier 
294074bb90dSTom Pothier 	for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
295074bb90dSTom Pothier 		if (isp->is_type == stp->smbst_hdr->smbh_type)
296074bb90dSTom Pothier 			break;
297074bb90dSTom Pothier 	}
298074bb90dSTom Pothier 	if (isp->is_type == SMB_TYPE_EOT)
299074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
300074bb90dSTom Pothier 
301074bb90dSTom Pothier 	size = isp->is_contsz;
302074bb90dSTom Pothier 	cnt = *((uint8_t *)(uintptr_t)stp->smbst_hdr + isp->is_contc);
303074bb90dSTom Pothier 	cp = (id_t *)((uintptr_t)stp->smbst_hdr + isp->is_contv);
304074bb90dSTom Pothier 
305074bb90dSTom Pothier 	n = MIN(cnt, idc);
306074bb90dSTom Pothier 	for (i = 0; i < n; i++) {
307074bb90dSTom Pothier 		if (size == SMB_CONT_WORD)
308074bb90dSTom Pothier 			idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 2));
309074bb90dSTom Pothier 		else if (size == SMB_CONT_BYTE)
310074bb90dSTom Pothier 			idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 3));
311074bb90dSTom Pothier 		else
312074bb90dSTom Pothier 			return (smb_set_errno(shp, ESMB_INVAL));
313074bb90dSTom Pothier 	}
314074bb90dSTom Pothier 
315074bb90dSTom Pothier 	return (cnt);
316074bb90dSTom Pothier }
317074bb90dSTom Pothier 
31884ab085aSmws id_t
31984ab085aSmws smbios_info_bios(smbios_hdl_t *shp, smbios_bios_t *bp)
32084ab085aSmws {
32184ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BIOS);
32284ab085aSmws 	const smb_bios_t *bip;
32384ab085aSmws 
32484ab085aSmws 	if (stp == NULL)
32584ab085aSmws 		return (-1); /* errno is set for us */
32684ab085aSmws 
32784ab085aSmws 	if (stp->smbst_hdr->smbh_len < sizeof (smb_bios_t) - sizeof (uint8_t))
32884ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
32984ab085aSmws 
33084ab085aSmws 	bip = (smb_bios_t *)(uintptr_t)stp->smbst_hdr;
33184ab085aSmws 	bzero(bp, sizeof (smbios_bios_t));
33284ab085aSmws 
33384ab085aSmws 	bp->smbb_vendor = smb_strptr(stp, bip->smbbi_vendor);
33484ab085aSmws 	bp->smbb_version = smb_strptr(stp, bip->smbbi_version);
33584ab085aSmws 	bp->smbb_segment = bip->smbbi_segment;
33684ab085aSmws 	bp->smbb_reldate = smb_strptr(stp, bip->smbbi_reldate);
33784ab085aSmws 	bp->smbb_romsize = 64 * 1024 * ((uint32_t)bip->smbbi_romsize + 1);
33884ab085aSmws 	bp->smbb_runsize = 16 * (0x10000 - (uint32_t)bip->smbbi_segment);
33984ab085aSmws 	bp->smbb_cflags = bip->smbbi_cflags;
34084ab085aSmws 
34184ab085aSmws 	/*
34284ab085aSmws 	 * If one or more extension bytes are present, reset smbb_xcflags to
34384ab085aSmws 	 * point to them.  Otherwise leave this member set to NULL.
34484ab085aSmws 	 */
34584ab085aSmws 	if (stp->smbst_hdr->smbh_len >= sizeof (smb_bios_t)) {
34684ab085aSmws 		bp->smbb_xcflags = bip->smbbi_xcflags;
34784ab085aSmws 		bp->smbb_nxcflags = stp->smbst_hdr->smbh_len -
34884ab085aSmws 		    sizeof (smb_bios_t) + 1;
34984ab085aSmws 
35084ab085aSmws 		if (bp->smbb_nxcflags > SMB_BIOSXB_ECFW_MIN &&
35184ab085aSmws 		    smb_gteq(shp, SMB_VERSION_24)) {
35284ab085aSmws 			bp->smbb_biosv.smbv_major =
35384ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MAJ];
35484ab085aSmws 			bp->smbb_biosv.smbv_minor =
35584ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MIN];
35684ab085aSmws 			bp->smbb_ecfwv.smbv_major =
35784ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MAJ];
35884ab085aSmws 			bp->smbb_ecfwv.smbv_minor =
35984ab085aSmws 			    bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MIN];
36084ab085aSmws 		}
36184ab085aSmws 	}
36284ab085aSmws 
36384ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
36484ab085aSmws }
36584ab085aSmws 
36684ab085aSmws id_t
36784ab085aSmws smbios_info_system(smbios_hdl_t *shp, smbios_system_t *sip)
36884ab085aSmws {
36984ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM);
37084ab085aSmws 	smb_system_t si;
37184ab085aSmws 
37284ab085aSmws 	if (stp == NULL)
37384ab085aSmws 		return (-1); /* errno is set for us */
37484ab085aSmws 
37584ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &si, sizeof (si));
37684ab085aSmws 	bzero(sip, sizeof (smbios_system_t));
37784ab085aSmws 
37884ab085aSmws 	sip->smbs_uuid = ((smb_system_t *)stp->smbst_hdr)->smbsi_uuid;
37984ab085aSmws 	sip->smbs_uuidlen = sizeof (si.smbsi_uuid);
38084ab085aSmws 	sip->smbs_wakeup = si.smbsi_wakeup;
38184ab085aSmws 	sip->smbs_sku = smb_strptr(stp, si.smbsi_sku);
38284ab085aSmws 	sip->smbs_family = smb_strptr(stp, si.smbsi_family);
38384ab085aSmws 
38484ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
38584ab085aSmws }
38684ab085aSmws 
38784ab085aSmws int
38884ab085aSmws smbios_info_bboard(smbios_hdl_t *shp, id_t id, smbios_bboard_t *bbp)
38984ab085aSmws {
39084ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
39184ab085aSmws 	smb_bboard_t bb;
39284ab085aSmws 
39384ab085aSmws 	if (stp == NULL)
39484ab085aSmws 		return (-1); /* errno is set for us */
39584ab085aSmws 
39684ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_BASEBOARD)
39784ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
39884ab085aSmws 
39984ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &bb, sizeof (bb));
40084ab085aSmws 	bzero(bbp, sizeof (smbios_bboard_t));
40184ab085aSmws 
40284ab085aSmws 	bbp->smbb_chassis = bb.smbbb_chassis;
40384ab085aSmws 	bbp->smbb_flags = bb.smbbb_flags;
40484ab085aSmws 	bbp->smbb_type = bb.smbbb_type;
405074bb90dSTom Pothier 	bbp->smbb_contn = bb.smbbb_cn;
40684ab085aSmws 
40784ab085aSmws 	return (0);
40884ab085aSmws }
40984ab085aSmws 
41084ab085aSmws int
41184ab085aSmws smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp)
41284ab085aSmws {
41384ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
41484ab085aSmws 	smb_chassis_t ch;
41584ab085aSmws 
41684ab085aSmws 	if (stp == NULL)
41784ab085aSmws 		return (-1); /* errno is set for us */
41884ab085aSmws 
41984ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS)
42084ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
42184ab085aSmws 
42284ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &ch, sizeof (ch));
42384ab085aSmws 	bzero(chp, sizeof (smbios_chassis_t));
42484ab085aSmws 
42584ab085aSmws 	chp->smbc_oemdata = ch.smbch_oemdata;
42684ab085aSmws 	chp->smbc_lock = (ch.smbch_type & SMB_CHT_LOCK) != 0;
42784ab085aSmws 	chp->smbc_type = ch.smbch_type & ~SMB_CHT_LOCK;
42884ab085aSmws 	chp->smbc_bustate = ch.smbch_bustate;
42984ab085aSmws 	chp->smbc_psstate = ch.smbch_psstate;
43084ab085aSmws 	chp->smbc_thstate = ch.smbch_thstate;
43184ab085aSmws 	chp->smbc_security = ch.smbch_security;
43284ab085aSmws 	chp->smbc_uheight = ch.smbch_uheight;
43384ab085aSmws 	chp->smbc_cords = ch.smbch_cords;
43484ab085aSmws 	chp->smbc_elems = ch.smbch_cn;
435074bb90dSTom Pothier 	chp->smbc_elemlen = ch.smbch_cm;
43684ab085aSmws 
43784ab085aSmws 	return (0);
43884ab085aSmws }
43984ab085aSmws 
44084ab085aSmws int
44184ab085aSmws smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp)
44284ab085aSmws {
44384ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
44484ab085aSmws 	smb_processor_t p;
44584ab085aSmws 
44684ab085aSmws 	if (stp == NULL)
44784ab085aSmws 		return (-1); /* errno is set for us */
44884ab085aSmws 
44984ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_PROCESSOR)
45084ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
45184ab085aSmws 
45284ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
45384ab085aSmws 	bzero(pp, sizeof (smbios_processor_t));
45484ab085aSmws 
45584ab085aSmws 	pp->smbp_cpuid = p.smbpr_cpuid;
45684ab085aSmws 	pp->smbp_type = p.smbpr_type;
45784ab085aSmws 	pp->smbp_family = p.smbpr_family;
45884ab085aSmws 	pp->smbp_voltage = p.smbpr_voltage;
45984ab085aSmws 	pp->smbp_maxspeed = p.smbpr_maxspeed;
46084ab085aSmws 	pp->smbp_curspeed = p.smbpr_curspeed;
46184ab085aSmws 	pp->smbp_status = p.smbpr_status;
46284ab085aSmws 	pp->smbp_upgrade = p.smbpr_upgrade;
46384ab085aSmws 	pp->smbp_l1cache = p.smbpr_l1cache;
46484ab085aSmws 	pp->smbp_l2cache = p.smbpr_l2cache;
46584ab085aSmws 	pp->smbp_l3cache = p.smbpr_l3cache;
46684ab085aSmws 
46784ab085aSmws 	return (0);
46884ab085aSmws }
46984ab085aSmws 
47084ab085aSmws int
47184ab085aSmws smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap)
47284ab085aSmws {
47384ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
47484ab085aSmws 	smb_cache_t c;
47584ab085aSmws 
47684ab085aSmws 	if (stp == NULL)
47784ab085aSmws 		return (-1); /* errno is set for us */
47884ab085aSmws 
47984ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_CACHE)
48084ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
48184ab085aSmws 
48284ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &c, sizeof (c));
48384ab085aSmws 	bzero(cap, sizeof (smbios_cache_t));
48484ab085aSmws 
48584ab085aSmws 	cap->smba_maxsize = SMB_CACHE_SIZE(c.smbca_maxsize);
48684ab085aSmws 	cap->smba_size = SMB_CACHE_SIZE(c.smbca_size);
48784ab085aSmws 	cap->smba_stype = c.smbca_stype;
48884ab085aSmws 	cap->smba_ctype = c.smbca_ctype;
48984ab085aSmws 	cap->smba_speed = c.smbca_speed;
49084ab085aSmws 	cap->smba_etype = c.smbca_etype;
49184ab085aSmws 	cap->smba_ltype = c.smbca_ltype;
49284ab085aSmws 	cap->smba_assoc = c.smbca_assoc;
49384ab085aSmws 	cap->smba_level = SMB_CACHE_CFG_LEVEL(c.smbca_config);
49484ab085aSmws 	cap->smba_mode = SMB_CACHE_CFG_MODE(c.smbca_config);
49584ab085aSmws 	cap->smba_location = SMB_CACHE_CFG_LOCATION(c.smbca_config);
49684ab085aSmws 
49784ab085aSmws 	if (SMB_CACHE_CFG_ENABLED(c.smbca_config))
49884ab085aSmws 		cap->smba_flags |= SMB_CAF_ENABLED;
49984ab085aSmws 
50084ab085aSmws 	if (SMB_CACHE_CFG_SOCKETED(c.smbca_config))
50184ab085aSmws 		cap->smba_flags |= SMB_CAF_SOCKETED;
50284ab085aSmws 
50384ab085aSmws 	return (0);
50484ab085aSmws }
50584ab085aSmws 
50684ab085aSmws int
50784ab085aSmws smbios_info_port(smbios_hdl_t *shp, id_t id, smbios_port_t *pop)
50884ab085aSmws {
50984ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
51084ab085aSmws 	smb_port_t p;
51184ab085aSmws 
51284ab085aSmws 	if (stp == NULL)
51384ab085aSmws 		return (-1); /* errno is set for us */
51484ab085aSmws 
51584ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_PORT)
51684ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
51784ab085aSmws 
51884ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
51984ab085aSmws 	bzero(pop, sizeof (smbios_port_t));
52084ab085aSmws 
52184ab085aSmws 	pop->smbo_iref = smb_strptr(stp, p.smbpo_iref);
52284ab085aSmws 	pop->smbo_eref = smb_strptr(stp, p.smbpo_eref);
52384ab085aSmws 
52484ab085aSmws 	pop->smbo_itype = p.smbpo_itype;
52584ab085aSmws 	pop->smbo_etype = p.smbpo_etype;
52684ab085aSmws 	pop->smbo_ptype = p.smbpo_ptype;
52784ab085aSmws 
52884ab085aSmws 	return (0);
52984ab085aSmws }
53084ab085aSmws 
53184ab085aSmws int
53284ab085aSmws smbios_info_slot(smbios_hdl_t *shp, id_t id, smbios_slot_t *sp)
53384ab085aSmws {
53484ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
53584ab085aSmws 	smb_slot_t s;
53684ab085aSmws 
53784ab085aSmws 	if (stp == NULL)
53884ab085aSmws 		return (-1); /* errno is set for us */
53984ab085aSmws 
54084ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT)
54184ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
54284ab085aSmws 
54384ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
54484ab085aSmws 	bzero(sp, sizeof (smbios_slot_t));
54584ab085aSmws 
54684ab085aSmws 	sp->smbl_name = smb_strptr(stp, s.smbsl_name);
54784ab085aSmws 	sp->smbl_type = s.smbsl_type;
54884ab085aSmws 	sp->smbl_width = s.smbsl_width;
54984ab085aSmws 	sp->smbl_usage = s.smbsl_usage;
55084ab085aSmws 	sp->smbl_length = s.smbsl_length;
55184ab085aSmws 	sp->smbl_id = s.smbsl_id;
55284ab085aSmws 	sp->smbl_ch1 = s.smbsl_ch1;
55384ab085aSmws 	sp->smbl_ch2 = s.smbsl_ch2;
554*03f9f63dSTom Pothier 	sp->smbl_sg = s.smbsl_sg;
555*03f9f63dSTom Pothier 	sp->smbl_bus = s.smbsl_bus;
556*03f9f63dSTom Pothier 	sp->smbl_df = s.smbsl_df;
557*03f9f63dSTom Pothier 
558*03f9f63dSTom Pothier 	return (0);
559*03f9f63dSTom Pothier }
560*03f9f63dSTom Pothier 
561*03f9f63dSTom Pothier int
562*03f9f63dSTom Pothier smbios_info_obdevs_ext(smbios_hdl_t *shp, id_t id, smbios_obdev_ext_t *oep)
563*03f9f63dSTom Pothier {
564*03f9f63dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
565*03f9f63dSTom Pothier 	smb_obdev_ext_t obe;
566*03f9f63dSTom Pothier 
567*03f9f63dSTom Pothier 	if (stp == NULL)
568*03f9f63dSTom Pothier 		return (-1); /* errno is set for us */
569*03f9f63dSTom Pothier 
570*03f9f63dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVEXT)
571*03f9f63dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
572*03f9f63dSTom Pothier 
573*03f9f63dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &obe, sizeof (obe));
574*03f9f63dSTom Pothier 	bzero(oep, sizeof (smbios_obdev_ext_t));
575*03f9f63dSTom Pothier 
576*03f9f63dSTom Pothier 	oep->smboe_name = smb_strptr(stp, obe.smbobe_name);
577*03f9f63dSTom Pothier 	oep->smboe_dtype = obe.smbobe_dtype;
578*03f9f63dSTom Pothier 	oep->smboe_dti = obe.smbobe_dti;
579*03f9f63dSTom Pothier 	oep->smboe_sg = obe.smbobe_sg;
580*03f9f63dSTom Pothier 	oep->smboe_bus = obe.smbobe_bus;
581*03f9f63dSTom Pothier 	oep->smboe_df = obe.smbobe_df;
58284ab085aSmws 
58384ab085aSmws 	return (0);
58484ab085aSmws }
58584ab085aSmws 
58684ab085aSmws int
58784ab085aSmws smbios_info_obdevs(smbios_hdl_t *shp, id_t id, int obc, smbios_obdev_t *obp)
58884ab085aSmws {
58984ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
59084ab085aSmws 	const smb_obdev_t *op;
59184ab085aSmws 	int i, m, n;
59284ab085aSmws 
59384ab085aSmws 	if (stp == NULL)
59484ab085aSmws 		return (-1); /* errno is set for us */
59584ab085aSmws 
59684ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVS)
59784ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
59884ab085aSmws 
59984ab085aSmws 	op = (smb_obdev_t *)((uintptr_t)stp->smbst_hdr + sizeof (smb_header_t));
60084ab085aSmws 	m = (stp->smbst_hdr->smbh_len - sizeof (smb_header_t)) / sizeof (*op);
60184ab085aSmws 	n = MIN(m, obc);
60284ab085aSmws 
60384ab085aSmws 	for (i = 0; i < n; i++, op++, obp++) {
60484ab085aSmws 		obp->smbd_name = smb_strptr(stp, op->smbob_name);
60584ab085aSmws 		obp->smbd_type = op->smbob_type & ~SMB_OBT_ENABLED;
60684ab085aSmws 		obp->smbd_enabled = (op->smbob_type & SMB_OBT_ENABLED) != 0;
60784ab085aSmws 	}
60884ab085aSmws 
60984ab085aSmws 	return (m);
61084ab085aSmws }
61184ab085aSmws 
61284ab085aSmws /*
61384ab085aSmws  * The implementation structures for OEMSTR, SYSCONFSTR, and LANG all use the
61484ab085aSmws  * first byte to indicate the size of a string table at the end of the record.
61584ab085aSmws  * Therefore, smbios_info_strtab() can be used to retrieve the table size and
61684ab085aSmws  * strings for any of these underlying record types.
61784ab085aSmws  */
61884ab085aSmws int
61984ab085aSmws smbios_info_strtab(smbios_hdl_t *shp, id_t id, int argc, const char *argv[])
62084ab085aSmws {
62184ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
62284ab085aSmws 	smb_strtab_t s;
62384ab085aSmws 	int i, n;
62484ab085aSmws 
62584ab085aSmws 	if (stp == NULL)
62684ab085aSmws 		return (-1); /* errno is set for us */
62784ab085aSmws 
62884ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR &&
62984ab085aSmws 	    stp->smbst_hdr->smbh_type != SMB_TYPE_SYSCONFSTR &&
63084ab085aSmws 	    stp->smbst_hdr->smbh_type != SMB_TYPE_LANG)
63184ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
63284ab085aSmws 
63384ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
63484ab085aSmws 	n = MIN(s.smbtb_count, argc);
63584ab085aSmws 
63684ab085aSmws 	for (i = 0; i < n; i++)
63784ab085aSmws 		argv[i] = smb_strptr(stp, i + 1);
63884ab085aSmws 
63984ab085aSmws 	return (s.smbtb_count);
64084ab085aSmws }
64184ab085aSmws 
64284ab085aSmws id_t
64384ab085aSmws smbios_info_lang(smbios_hdl_t *shp, smbios_lang_t *lp)
64484ab085aSmws {
64584ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_LANG);
64684ab085aSmws 	smb_lang_t l;
64784ab085aSmws 
64884ab085aSmws 	if (stp == NULL)
64984ab085aSmws 		return (-1); /* errno is set for us */
65084ab085aSmws 
65184ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &l, sizeof (l));
65284ab085aSmws 	bzero(lp, sizeof (smbios_lang_t));
65384ab085aSmws 
65484ab085aSmws 	lp->smbla_cur = smb_strptr(stp, l.smblang_cur);
65584ab085aSmws 	lp->smbla_fmt = l.smblang_flags & 1;
65684ab085aSmws 	lp->smbla_num = l.smblang_num;
65784ab085aSmws 
65884ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
65984ab085aSmws }
66084ab085aSmws 
66184ab085aSmws id_t
66284ab085aSmws smbios_info_eventlog(smbios_hdl_t *shp, smbios_evlog_t *evp)
66384ab085aSmws {
66484ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_EVENTLOG);
66584ab085aSmws 	const smb_sel_t *sel;
66684ab085aSmws 	size_t len;
66784ab085aSmws 
66884ab085aSmws 	if (stp == NULL)
66984ab085aSmws 		return (-1); /* errno is set for us */
67084ab085aSmws 
67184ab085aSmws 	if (stp->smbst_hdr->smbh_len < sizeof (smb_sel_t) - sizeof (uint8_t))
67284ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
67384ab085aSmws 
67484ab085aSmws 	sel = (smb_sel_t *)(uintptr_t)stp->smbst_hdr;
67584ab085aSmws 	len = stp->smbst_hdr->smbh_len - sizeof (smb_sel_t) + sizeof (uint8_t);
67684ab085aSmws 	bzero(evp, sizeof (smbios_evlog_t));
67784ab085aSmws 
67884ab085aSmws 	if (len < sel->smbsel_typec * sel->smbsel_typesz)
67984ab085aSmws 		return (smb_set_errno(shp, ESMB_CORRUPT));
68084ab085aSmws 
68184ab085aSmws 	evp->smbev_size = sel->smbsel_len;
68284ab085aSmws 	evp->smbev_hdr = sel->smbsel_hdroff;
68384ab085aSmws 	evp->smbev_data = sel->smbsel_dataoff;
68484ab085aSmws 	evp->smbev_method = sel->smbsel_method;
68584ab085aSmws 	evp->smbev_flags = sel->smbsel_status;
68684ab085aSmws 	evp->smbev_format = sel->smbsel_format;
68784ab085aSmws 	evp->smbev_token = sel->smbsel_token;
68884ab085aSmws 	evp->smbev_addr.eva_addr = sel->smbsel_addr;
68984ab085aSmws 
69084ab085aSmws 	if (sel->smbsel_typesz == sizeof (smbios_evtype_t)) {
69184ab085aSmws 		evp->smbev_typec = sel->smbsel_typec;
69284ab085aSmws 		evp->smbev_typev = (void *)(uintptr_t)sel->smbsel_typev;
69384ab085aSmws 	}
69484ab085aSmws 
69584ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
69684ab085aSmws }
69784ab085aSmws 
69884ab085aSmws int
69984ab085aSmws smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map)
70084ab085aSmws {
70184ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
70284ab085aSmws 	smb_memarray_t m;
70384ab085aSmws 
70484ab085aSmws 	if (stp == NULL)
70584ab085aSmws 		return (-1); /* errno is set for us */
70684ab085aSmws 
70784ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAY)
70884ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
70984ab085aSmws 
71084ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
71184ab085aSmws 	bzero(map, sizeof (smbios_memarray_t));
71284ab085aSmws 
71384ab085aSmws 	map->smbma_location = m.smbmarr_loc;
71484ab085aSmws 	map->smbma_use = m.smbmarr_use;
71584ab085aSmws 	map->smbma_ecc = m.smbmarr_ecc;
71684ab085aSmws 	map->smbma_ndevs = m.smbmarr_ndevs;
71784ab085aSmws 	map->smbma_err = m.smbmarr_err;
71884ab085aSmws 
71984ab085aSmws 	if (m.smbmarr_cap != 0x80000000)
72084ab085aSmws 		map->smbma_size = (uint64_t)m.smbmarr_cap * 1024;
72184ab085aSmws 	else
72284ab085aSmws 		map->smbma_size = 0; /* unknown */
72384ab085aSmws 
72484ab085aSmws 	return (0);
72584ab085aSmws }
72684ab085aSmws 
72784ab085aSmws int
72884ab085aSmws smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map)
72984ab085aSmws {
73084ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
73184ab085aSmws 	smb_memarrmap_t m;
73284ab085aSmws 
73384ab085aSmws 	if (stp == NULL)
73484ab085aSmws 		return (-1); /* errno is set for us */
73584ab085aSmws 
73684ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP)
73784ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
73884ab085aSmws 
73984ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
74084ab085aSmws 	bzero(map, sizeof (smbios_memarrmap_t));
74184ab085aSmws 
74284ab085aSmws 	map->smbmam_array = m.smbamap_array;
74384ab085aSmws 	map->smbmam_width = m.smbamap_width;
74484ab085aSmws 	map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
74584ab085aSmws 	map->smbmam_size = (uint64_t)
74684ab085aSmws 	    (m.smbamap_end - m.smbamap_start + 1) * 1024;
74784ab085aSmws 
74884ab085aSmws 	return (0);
74984ab085aSmws }
75084ab085aSmws 
75184ab085aSmws int
75284ab085aSmws smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp)
75384ab085aSmws {
75484ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
75584ab085aSmws 	smb_memdevice_t m;
75684ab085aSmws 
75784ab085aSmws 	if (stp == NULL)
75884ab085aSmws 		return (-1); /* errno is set for us */
75984ab085aSmws 
76084ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICE)
76184ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
76284ab085aSmws 
76384ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
76484ab085aSmws 	bzero(mdp, sizeof (smbios_memdevice_t));
76584ab085aSmws 
76684ab085aSmws 	mdp->smbmd_array = m.smbmdev_array;
76784ab085aSmws 	mdp->smbmd_error = m.smbmdev_error;
76884ab085aSmws 	mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth;
76984ab085aSmws 	mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth;
77084ab085aSmws 
77184ab085aSmws 	if (mdp->smbmd_size != 0xFFFF) {
77284ab085aSmws 		mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES);
77384ab085aSmws 		if (m.smbmdev_size & SMB_MDS_KBYTES)
77484ab085aSmws 			mdp->smbmd_size *= 1024;
77584ab085aSmws 		else
77684ab085aSmws 			mdp->smbmd_size *= 1024 * 1024;
77784ab085aSmws 	} else
77884ab085aSmws 		mdp->smbmd_size = -1ULL; /* size unknown */
77984ab085aSmws 
78084ab085aSmws 	mdp->smbmd_form = m.smbmdev_form;
78184ab085aSmws 	mdp->smbmd_set = m.smbmdev_set;
78284ab085aSmws 	mdp->smbmd_type = m.smbmdev_type;
78384ab085aSmws 	mdp->smbmd_flags = m.smbmdev_flags;
78484ab085aSmws 	mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc);
78584ab085aSmws 	mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc);
78684ab085aSmws 
78784ab085aSmws 	if (m.smbmdev_speed != 0)
78884ab085aSmws 		mdp->smbmd_speed = 1000 / m.smbmdev_speed; /* MHz -> nsec */
78984ab085aSmws 
79084ab085aSmws 	return (0);
79184ab085aSmws }
79284ab085aSmws 
79384ab085aSmws int
79484ab085aSmws smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp)
79584ab085aSmws {
79684ab085aSmws 	const smb_struct_t *stp = smb_lookup_id(shp, id);
79784ab085aSmws 	smb_memdevmap_t m;
79884ab085aSmws 
79984ab085aSmws 	if (stp == NULL)
80084ab085aSmws 		return (-1); /* errno is set for us */
80184ab085aSmws 
80284ab085aSmws 	if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP)
80384ab085aSmws 		return (smb_set_errno(shp, ESMB_TYPE));
80484ab085aSmws 
80584ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
80684ab085aSmws 	bzero(mdp, sizeof (smbios_memdevmap_t));
80784ab085aSmws 
80884ab085aSmws 	mdp->smbmdm_device = m.smbdmap_device;
80984ab085aSmws 	mdp->smbmdm_arrmap = m.smbdmap_array;
81084ab085aSmws 	mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
81184ab085aSmws 	mdp->smbmdm_size = (uint64_t)
81284ab085aSmws 	    (m.smbdmap_end - m.smbdmap_start + 1) * 1024;
81384ab085aSmws 	mdp->smbmdm_rpos = m.smbdmap_rpos;
81484ab085aSmws 	mdp->smbmdm_ipos = m.smbdmap_ipos;
81584ab085aSmws 	mdp->smbmdm_idepth = m.smbdmap_idepth;
81684ab085aSmws 
81784ab085aSmws 	return (0);
81884ab085aSmws }
81984ab085aSmws 
82084ab085aSmws id_t
82184ab085aSmws smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp)
82284ab085aSmws {
82384ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY);
82484ab085aSmws 	smb_hwsec_t hs;
82584ab085aSmws 
82684ab085aSmws 	if (stp == NULL)
82784ab085aSmws 		return (-1); /* errno is set for us */
82884ab085aSmws 
82984ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &hs, sizeof (hs));
83084ab085aSmws 	bzero(hsp, sizeof (smbios_hwsec_t));
83184ab085aSmws 
83284ab085aSmws 	hsp->smbh_pwr_ps = SMB_HWS_PWR_PS(hs.smbhs_settings);
83384ab085aSmws 	hsp->smbh_kbd_ps = SMB_HWS_KBD_PS(hs.smbhs_settings);
83484ab085aSmws 	hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings);
83584ab085aSmws 	hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings);
83684ab085aSmws 
83784ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
83884ab085aSmws }
83984ab085aSmws 
84084ab085aSmws id_t
84184ab085aSmws smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp)
84284ab085aSmws {
84384ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT);
84484ab085aSmws 	const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
84584ab085aSmws 
84684ab085aSmws 	if (stp == NULL)
84784ab085aSmws 		return (-1); /* errno is set for us */
84884ab085aSmws 
84984ab085aSmws 	bzero(bp, sizeof (smbios_boot_t));
85084ab085aSmws 
85184ab085aSmws 	bp->smbt_status = b->smbbo_status[0];
85284ab085aSmws 	bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t);
85384ab085aSmws 	bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL;
85484ab085aSmws 
85584ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
85684ab085aSmws }
85784ab085aSmws 
85884ab085aSmws id_t
85984ab085aSmws smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip)
86084ab085aSmws {
86184ab085aSmws 	const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_IPMIDEV);
86284ab085aSmws 	smb_ipmi_t i;
86384ab085aSmws 
86484ab085aSmws 	if (stp == NULL)
86584ab085aSmws 		return (-1); /* errno is set for us */
86684ab085aSmws 
86784ab085aSmws 	smb_info_bcopy(stp->smbst_hdr, &i, sizeof (i));
86884ab085aSmws 	bzero(ip, sizeof (smbios_ipmi_t));
86984ab085aSmws 
87084ab085aSmws 	ip->smbip_type = i.smbipm_type;
87184ab085aSmws 	ip->smbip_vers.smbv_major = SMB_IPM_SPEC_MAJOR(i.smbipm_spec);
87284ab085aSmws 	ip->smbip_vers.smbv_minor = SMB_IPM_SPEC_MINOR(i.smbipm_spec);
87384ab085aSmws 	ip->smbip_i2c = i.smbipm_i2c;
87484ab085aSmws 	ip->smbip_addr = i.smbipm_addr & ~SMB_IPM_ADDR_IO;
87584ab085aSmws 	ip->smbip_intr = i.smbipm_intr;
87684ab085aSmws 
87784ab085aSmws 	if (i.smbipm_bus != (uint8_t)-1)
87884ab085aSmws 		ip->smbip_bus = i.smbipm_bus;
87984ab085aSmws 	else
88084ab085aSmws 		ip->smbip_bus = -1u;
88184ab085aSmws 
88284ab085aSmws 	if (SMB_IPM_INFO_LSB(i.smbipm_info))
88384ab085aSmws 		ip->smbip_addr |= 1; /* turn on least-significant bit of addr */
88484ab085aSmws 
88584ab085aSmws 	if (i.smbipm_addr & SMB_IPM_ADDR_IO) {
88684ab085aSmws 		switch (SMB_IPM_INFO_REGS(i.smbipm_info)) {
88784ab085aSmws 		case SMB_IPM_REGS_1B:
88884ab085aSmws 			ip->smbip_regspacing = 1;
88984ab085aSmws 			break;
89084ab085aSmws 		case SMB_IPM_REGS_4B:
89184ab085aSmws 			ip->smbip_regspacing = 4;
89284ab085aSmws 			break;
89384ab085aSmws 		case SMB_IPM_REGS_16B:
89484ab085aSmws 			ip->smbip_regspacing = 16;
89584ab085aSmws 			break;
89684ab085aSmws 		default:
89784ab085aSmws 			ip->smbip_regspacing = 1;
89884ab085aSmws 		}
89984ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_IOADDR;
90084ab085aSmws 	}
90184ab085aSmws 
90284ab085aSmws 	if (SMB_IPM_INFO_ISPEC(i.smbipm_info))
90384ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTRSPEC;
90484ab085aSmws 
90584ab085aSmws 	if (SMB_IPM_INFO_IPOL(i.smbipm_info) == SMB_IPM_IPOL_HI)
90684ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTRHIGH;
90784ab085aSmws 
90884ab085aSmws 	if (SMB_IPM_INFO_IMODE(i.smbipm_info) == SMB_IPM_IMODE_EDGE)
90984ab085aSmws 		ip->smbip_flags |= SMB_IPMI_F_INTREDGE;
91084ab085aSmws 
91184ab085aSmws 	return (stp->smbst_hdr->smbh_hdl);
91284ab085aSmws }
9139c94f155SCheng Sean Ye 
9149c94f155SCheng Sean Ye static boolean_t
9159c94f155SCheng Sean Ye smbios_has_oemstr(smbios_hdl_t *shp, const char *oemstr)
9169c94f155SCheng Sean Ye {
9179c94f155SCheng Sean Ye 	const smb_struct_t *stp = shp->sh_structs;
9189c94f155SCheng Sean Ye 	smb_strtab_t s;
9199c94f155SCheng Sean Ye 	int i, j;
9209c94f155SCheng Sean Ye 
9219c94f155SCheng Sean Ye 	for (i = 0; i < shp->sh_nstructs; i++, stp++) {
9229c94f155SCheng Sean Ye 		if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR)
9239c94f155SCheng Sean Ye 			continue;
9249c94f155SCheng Sean Ye 
9259c94f155SCheng Sean Ye 		smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
9269c94f155SCheng Sean Ye 		for (j = 0; j < s.smbtb_count; j++)
9279c94f155SCheng Sean Ye 			if (strcmp(smb_strptr(stp, j + 1), oemstr) == 0)
9289c94f155SCheng Sean Ye 				return (B_TRUE);
9299c94f155SCheng Sean Ye 	}
9309c94f155SCheng Sean Ye 
9319c94f155SCheng Sean Ye 	return (B_FALSE);
9329c94f155SCheng Sean Ye }
9339c94f155SCheng Sean Ye 
9349c94f155SCheng Sean Ye static const char *
9359c94f155SCheng Sean Ye smb_serial_valid(const char *serial)
9369c94f155SCheng Sean Ye {
9379c94f155SCheng Sean Ye 	char buf[MAXNAMELEN];
9389c94f155SCheng Sean Ye 	int i = 0;
9399c94f155SCheng Sean Ye 
9409c94f155SCheng Sean Ye 	if (serial == NULL)
9419c94f155SCheng Sean Ye 		return (NULL);
9429c94f155SCheng Sean Ye 
9439c94f155SCheng Sean Ye 	(void) strlcpy(buf, serial, sizeof (buf));
9449c94f155SCheng Sean Ye 
9459c94f155SCheng Sean Ye 	while (buf[i] != '\0' && buf[i] == ' ')
9469c94f155SCheng Sean Ye 		i++;
9479c94f155SCheng Sean Ye 
9489c94f155SCheng Sean Ye 	if (buf[i] == '\0' || strstr(buf, SMB_DEFAULT1) != NULL ||
9499c94f155SCheng Sean Ye 	    strstr(buf, SMB_DEFAULT2) != NULL)
9509c94f155SCheng Sean Ye 		return (NULL);
9519c94f155SCheng Sean Ye 
9529c94f155SCheng Sean Ye 	return (serial);
9539c94f155SCheng Sean Ye }
9549c94f155SCheng Sean Ye 
9559c94f155SCheng Sean Ye /*
9569c94f155SCheng Sean Ye  * Get chassis SN or product SN
9579c94f155SCheng Sean Ye  */
9589c94f155SCheng Sean Ye static int
9599c94f155SCheng Sean Ye smb_get_sn(smbios_hdl_t *shp, const char **psnp, const char **csnp)
9609c94f155SCheng Sean Ye {
9619c94f155SCheng Sean Ye 	const smb_struct_t *stp;
9629c94f155SCheng Sean Ye 	smbios_info_t s1, s3;
9639c94f155SCheng Sean Ye 
9649c94f155SCheng Sean Ye 	if (psnp == NULL || csnp == NULL)
9659c94f155SCheng Sean Ye 		return (smb_set_errno(shp, ESMB_INVAL));
9669c94f155SCheng Sean Ye 
9679c94f155SCheng Sean Ye 	*psnp = *csnp = NULL;
9689c94f155SCheng Sean Ye 
9699c94f155SCheng Sean Ye 	/*
9709c94f155SCheng Sean Ye 	 * If SMBIOS meets Sun's PRMS requirements, retrieve product SN
9719c94f155SCheng Sean Ye 	 * from type 1 structure, and chassis SN from type 3 structure.
9729c94f155SCheng Sean Ye 	 * Otherwise return SN in type 1 structure as chassis SN.
9739c94f155SCheng Sean Ye 	 */
9749c94f155SCheng Sean Ye 
9759c94f155SCheng Sean Ye 	/* Get type 1 SN */
9769c94f155SCheng Sean Ye 	if ((stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM)) == NULL ||
9779c94f155SCheng Sean Ye 	    smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s1) == SMB_ERR)
9789c94f155SCheng Sean Ye 		s1.smbi_serial = NULL;
9799c94f155SCheng Sean Ye 
9809c94f155SCheng Sean Ye 	/* Get type 3 SN */
9819c94f155SCheng Sean Ye 	if ((stp = smb_lookup_type(shp, SMB_TYPE_CHASSIS)) == NULL ||
9829c94f155SCheng Sean Ye 	    smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s3) == SMB_ERR)
9839c94f155SCheng Sean Ye 		s3.smbi_serial = NULL;
9849c94f155SCheng Sean Ye 
9859c94f155SCheng Sean Ye 	if (smbios_has_oemstr(shp, SMB_PRMS1)) {
9869c94f155SCheng Sean Ye 		*psnp = smb_serial_valid(s1.smbi_serial);
9879c94f155SCheng Sean Ye 		*csnp = smb_serial_valid(s3.smbi_serial);
9889c94f155SCheng Sean Ye 	} else {
9899c94f155SCheng Sean Ye 		*csnp = smb_serial_valid(s1.smbi_serial);
9909c94f155SCheng Sean Ye 	}
9919c94f155SCheng Sean Ye 
9929c94f155SCheng Sean Ye 	return (0);
9939c94f155SCheng Sean Ye }
9949c94f155SCheng Sean Ye 
9959c94f155SCheng Sean Ye const char *
9969c94f155SCheng Sean Ye smbios_psn(smbios_hdl_t *shp)
9979c94f155SCheng Sean Ye {
9989c94f155SCheng Sean Ye 	const char *psn, *csn;
9999c94f155SCheng Sean Ye 
10009c94f155SCheng Sean Ye 	return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : psn);
10019c94f155SCheng Sean Ye }
10029c94f155SCheng Sean Ye 
10039c94f155SCheng Sean Ye const char *
10049c94f155SCheng Sean Ye smbios_csn(smbios_hdl_t *shp)
10059c94f155SCheng Sean Ye {
10069c94f155SCheng Sean Ye 	const char *psn, *csn;
10079c94f155SCheng Sean Ye 
10089c94f155SCheng Sean Ye 	return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : csn);
10099c94f155SCheng Sean Ye }
1010074bb90dSTom Pothier 
1011074bb90dSTom Pothier int
1012074bb90dSTom Pothier smbios_info_extprocessor(smbios_hdl_t *shp, id_t id,
1013074bb90dSTom Pothier     smbios_processor_ext_t *epp)
1014074bb90dSTom Pothier {
1015074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1016074bb90dSTom Pothier 	smb_processor_ext_t *exp;
1017074bb90dSTom Pothier 
1018074bb90dSTom Pothier 	if (stp == NULL)
1019074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1020074bb90dSTom Pothier 
1021074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PROCESSOR)
1022074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1023074bb90dSTom Pothier 
1024074bb90dSTom Pothier 	exp = (smb_processor_ext_t *)(uintptr_t)stp->smbst_hdr;
1025074bb90dSTom Pothier 	bzero(epp, sizeof (smbios_processor_ext_t));
1026074bb90dSTom Pothier 
1027074bb90dSTom Pothier 	epp->smbpe_processor = exp->smbpre_processor;
1028074bb90dSTom Pothier 	epp->smbpe_fru = exp->smbpre_fru;
1029074bb90dSTom Pothier 	epp->smbpe_n = exp->smbpre_n;
1030074bb90dSTom Pothier 	epp->smbpe_apicid = exp->smbpre_apicid;
1031074bb90dSTom Pothier 
1032074bb90dSTom Pothier 	return (0);
1033074bb90dSTom Pothier }
1034074bb90dSTom Pothier 
1035074bb90dSTom Pothier int
1036*03f9f63dSTom Pothier smbios_info_extport(smbios_hdl_t *shp, id_t id, smbios_port_ext_t *eportp)
1037*03f9f63dSTom Pothier {
1038*03f9f63dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1039*03f9f63dSTom Pothier 	smb_port_ext_t *ep;
1040*03f9f63dSTom Pothier 
1041*03f9f63dSTom Pothier 	if (stp == NULL)
1042*03f9f63dSTom Pothier 		return (-1); /* errno is set for us */
1043*03f9f63dSTom Pothier 
1044*03f9f63dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PORT)
1045*03f9f63dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1046*03f9f63dSTom Pothier 
1047*03f9f63dSTom Pothier 	ep = (smb_port_ext_t *)(uintptr_t)stp->smbst_hdr;
1048*03f9f63dSTom Pothier 	bzero(eportp, sizeof (smbios_port_ext_t));
1049*03f9f63dSTom Pothier 
1050*03f9f63dSTom Pothier 	eportp->smbporte_chassis = ep->smbpoe_chassis;
1051*03f9f63dSTom Pothier 	eportp->smbporte_port = ep->smbpoe_port;
1052*03f9f63dSTom Pothier 	eportp->smbporte_dtype = ep->smbpoe_dtype;
1053*03f9f63dSTom Pothier 	eportp->smbporte_devhdl = ep->smbpoe_devhdl;
1054*03f9f63dSTom Pothier 	eportp->smbporte_phy = ep->smbpoe_phy;
1055*03f9f63dSTom Pothier 
1056*03f9f63dSTom Pothier 	return (0);
1057*03f9f63dSTom Pothier }
1058*03f9f63dSTom Pothier 
1059*03f9f63dSTom Pothier int
1060074bb90dSTom Pothier smbios_info_pciexrc(smbios_hdl_t *shp, id_t id,
1061074bb90dSTom Pothier     smbios_pciexrc_t *rcp)
1062074bb90dSTom Pothier {
1063074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1064074bb90dSTom Pothier 	smb_pciexrc_t rc;
1065074bb90dSTom Pothier 
1066074bb90dSTom Pothier 	if (stp == NULL)
1067074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1068074bb90dSTom Pothier 
1069074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_PCIEXRC)
1070074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1071074bb90dSTom Pothier 
1072074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &rc, sizeof (rc));
1073074bb90dSTom Pothier 	bzero(rcp, sizeof (smbios_pciexrc_t));
1074074bb90dSTom Pothier 
1075074bb90dSTom Pothier 	rcp->smbpcie_bb = rc.smbpciexrc_bboard;
1076074bb90dSTom Pothier 	rcp->smbpcie_bdf = rc.smbpciexrc_bdf;
1077074bb90dSTom Pothier 
1078074bb90dSTom Pothier 	return (0);
1079074bb90dSTom Pothier }
1080074bb90dSTom Pothier 
1081074bb90dSTom Pothier int
1082074bb90dSTom Pothier smbios_info_extmemarray(smbios_hdl_t *shp, id_t id, smbios_memarray_ext_t *emap)
1083074bb90dSTom Pothier {
1084074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1085074bb90dSTom Pothier 	smb_memarray_ext_t exma;
1086074bb90dSTom Pothier 
1087074bb90dSTom Pothier 	if (stp == NULL)
1088074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1089074bb90dSTom Pothier 
1090074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMARRAY)
1091074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1092074bb90dSTom Pothier 
1093074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &exma, sizeof (exma));
1094074bb90dSTom Pothier 	bzero(emap, sizeof (smbios_memarray_ext_t));
1095074bb90dSTom Pothier 
1096074bb90dSTom Pothier 	emap->smbmae_ma = exma.smbmarre_ma;
1097074bb90dSTom Pothier 	emap->smbmae_comp = exma.smbmarre_component;
1098074bb90dSTom Pothier 	emap->smbmae_bdf = exma.smbmarre_bdf;
1099074bb90dSTom Pothier 
1100074bb90dSTom Pothier 	return (0);
1101074bb90dSTom Pothier }
1102074bb90dSTom Pothier 
1103074bb90dSTom Pothier int
1104074bb90dSTom Pothier smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id,
1105074bb90dSTom Pothier     smbios_memdevice_ext_t *emdp)
1106074bb90dSTom Pothier {
1107074bb90dSTom Pothier 	const smb_struct_t *stp = smb_lookup_id(shp, id);
1108074bb90dSTom Pothier 	smb_memdevice_ext_t exmd;
1109074bb90dSTom Pothier 
1110074bb90dSTom Pothier 	if (stp == NULL)
1111074bb90dSTom Pothier 		return (-1); /* errno is set for us */
1112074bb90dSTom Pothier 
1113074bb90dSTom Pothier 	if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMDEVICE)
1114074bb90dSTom Pothier 		return (smb_set_errno(shp, ESMB_TYPE));
1115074bb90dSTom Pothier 
1116074bb90dSTom Pothier 	smb_info_bcopy(stp->smbst_hdr, &exmd, sizeof (exmd));
1117074bb90dSTom Pothier 	bzero(emdp, sizeof (smbios_memdevice_ext_t));
1118074bb90dSTom Pothier 
1119074bb90dSTom Pothier 	emdp->smbmdeve_md = exmd.smbmdeve_mdev;
1120074bb90dSTom Pothier 	emdp->smbmdeve_drch = exmd.smbmdeve_dchan;
1121074bb90dSTom Pothier 	emdp->smbmdeve_ncs  = exmd.smbmdeve_ncs;
1122074bb90dSTom Pothier 	emdp->smbmdeve_cs = exmd.smbmdeve_cs;
1123074bb90dSTom Pothier 
1124074bb90dSTom Pothier 	return (0);
1125074bb90dSTom Pothier }
1126