xref: /onnv-gate/usr/src/uts/common/sys/smbios_impl.h (revision 11859:f06d538b0f01)
1437Smws /*
2437Smws  * CDDL HEADER START
3437Smws  *
4437Smws  * The contents of this file are subject to the terms of the
510942STom.Pothier@Sun.COM  * Common Development and Distribution License (the "License").
610942STom.Pothier@Sun.COM  * You may not use this file except in compliance with the License.
7437Smws  *
8437Smws  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9437Smws  * or http://www.opensolaris.org/os/licensing.
10437Smws  * See the License for the specific language governing permissions
11437Smws  * and limitations under the License.
12437Smws  *
13437Smws  * When distributing Covered Code, include this CDDL HEADER in each
14437Smws  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15437Smws  * If applicable, add the following below this CDDL HEADER, with the
16437Smws  * fields enclosed by brackets "[]" replaced with your own identifying
17437Smws  * information: Portions Copyright [yyyy] [name of copyright owner]
18437Smws  *
19437Smws  * CDDL HEADER END
20437Smws  */
21437Smws 
22437Smws /*
23*11859STom.Pothier@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24437Smws  * Use is subject to license terms.
25437Smws  */
26437Smws 
27437Smws /*
28437Smws  * This header file defines the implementation structures for the SMBIOS access
29437Smws  * library, libsmbios, and an equivalent kernel module.  Clients should use
30437Smws  * the <smbios.h> or <sys/smbios.h> header files to access DMTF SMBIOS
31437Smws  * information, NOT these underlying implementation structures from the spec.
32437Smws  * In short, do not user this header file or these routines for any purpose.
33437Smws  */
34437Smws 
35437Smws #ifndef	_SYS_SMBIOS_IMPL_H
36437Smws #define	_SYS_SMBIOS_IMPL_H
37437Smws 
38437Smws #include <sys/smbios.h>
39437Smws #include <sys/sysmacros.h>
40437Smws 
41437Smws #ifdef _KERNEL
42437Smws #include <sys/systm.h>
43437Smws #else
44437Smws #include <strings.h>
45437Smws #include <stddef.h>
46437Smws #endif
47437Smws 
48437Smws #ifdef	__cplusplus
49437Smws extern "C" {
50437Smws #endif
51437Smws 
52437Smws #pragma pack(1)
53437Smws 
54437Smws typedef struct smb_header {
55437Smws 	uint8_t smbh_type;		/* structure type (SMB_TYPE_* value) */
56437Smws 	uint8_t smbh_len;		/* length in bytes of formatted area */
57437Smws 	uint16_t smbh_hdl;		/* structure handle */
58437Smws } smb_header_t;
59437Smws 
60437Smws typedef struct smb_bios {
61437Smws 	smb_header_t smbbi_hdr;		/* structure header */
62437Smws 	uint8_t smbbi_vendor;		/* bios vendor string */
63437Smws 	uint8_t smbbi_version;		/* bios version string */
64437Smws 	uint16_t smbbi_segment;		/* segment location of bios address */
65437Smws 	uint8_t smbbi_reldate;		/* bios release date */
66437Smws 	uint8_t smbbi_romsize;		/* bios rom size (64k * (n + 1)) */
67437Smws 	uint64_t smbbi_cflags;		/* bios characteristics */
68437Smws 	uint8_t smbbi_xcflags[1];	/* bios characteristics extensions */
69437Smws } smb_bios_t;
70437Smws 
71437Smws typedef struct smb_system {
72437Smws 	smb_header_t smbsi_hdr;		/* structure header */
73437Smws 	uint8_t smbsi_manufacturer;	/* manufacturer */
74437Smws 	uint8_t smbsi_product;		/* product name */
75437Smws 	uint8_t smbsi_version;		/* version */
76437Smws 	uint8_t smbsi_serial;		/* serial number */
77437Smws 	uint8_t smbsi_uuid[16];		/* UUID */
78437Smws 	uint8_t smbsi_wakeup;		/* wake-up type */
79437Smws 	uint8_t smbsi_sku;		/* SKU number */
80437Smws 	uint8_t smbsi_family;		/* family */
81437Smws } smb_system_t;
82437Smws 
83437Smws typedef struct smb_bboard {
84437Smws 	smb_header_t smbbb_hdr;		/* structure header */
85437Smws 	uint8_t smbbb_manufacturer;	/* manufacturer */
86437Smws 	uint8_t smbbb_product;		/* product name */
87437Smws 	uint8_t smbbb_version;		/* version */
88437Smws 	uint8_t smbbb_serial;		/* serial number */
89437Smws 	uint8_t smbbb_asset;		/* asset tag */
90437Smws 	uint8_t smbbb_flags;		/* feature flags */
91437Smws 	uint8_t smbbb_location;		/* location in chassis */
92437Smws 	uint16_t smbbb_chassis;		/* chassis handle */
93437Smws 	uint8_t smbbb_type;		/* board type */
94437Smws 	uint8_t smbbb_cn;		/* number of contained handles */
95437Smws 	uint16_t smbbb_cv[1];		/* array of contained handles */
96437Smws } smb_bboard_t;
97437Smws 
98437Smws typedef struct smb_chassis {
99437Smws 	smb_header_t smbch_hdr;		/* structure header */
100437Smws 	uint8_t smbch_manufacturer;	/* manufacturer */
101437Smws 	uint8_t smbch_type;		/* type */
102437Smws 	uint8_t smbch_version;		/* version */
103437Smws 	uint8_t smbch_serial;		/* serial number */
104437Smws 	uint8_t smbch_asset;		/* asset tag */
105437Smws 	uint8_t smbch_bustate;		/* boot-up state */
106437Smws 	uint8_t smbch_psstate;		/* power supply state */
107437Smws 	uint8_t smbch_thstate;		/* thermal state */
108437Smws 	uint8_t smbch_security;		/* security state */
109437Smws 	uint32_t smbch_oemdata;		/* OEM-specific data */
110437Smws 	uint8_t smbch_uheight;		/* enclosure height */
111437Smws 	uint8_t smbch_cords;		/* number of power cords */
112437Smws 	uint8_t smbch_cn;		/* number of contained records */
113437Smws 	uint8_t smbch_cm;		/* size of contained records */
114437Smws 	uint8_t smbch_cv[1];		/* array of contained records */
115437Smws } smb_chassis_t;
116437Smws 
117437Smws #define	SMB_CHT_LOCK	0x80		/* lock bit within smbch_type */
118437Smws 
119437Smws typedef struct smb_processor {
120437Smws 	smb_header_t smbpr_hdr;		/* structure header */
121437Smws 	uint8_t smbpr_socket;		/* socket designation */
122437Smws 	uint8_t smbpr_type;		/* processor type (see <smbios.h>) */
123437Smws 	uint8_t smbpr_family;		/* processor family (see <smbios.h>) */
124437Smws 	uint8_t smbpr_manufacturer;	/* manufacturer */
125437Smws 	uint64_t smbpr_cpuid;		/* processor cpuid information */
126437Smws 	uint8_t smbpr_version;		/* version */
127437Smws 	uint8_t smbpr_voltage;		/* voltage */
128437Smws 	uint16_t smbpr_clkspeed;	/* external clock speed in MHz */
129437Smws 	uint16_t smbpr_maxspeed;	/* maximum speed in MHz */
130437Smws 	uint16_t smbpr_curspeed;	/* current speed in MHz */
131437Smws 	uint8_t smbpr_status;		/* status (see <smbios.h>) */
132437Smws 	uint8_t smbpr_upgrade;		/* upgrade */
133437Smws 	uint16_t smbpr_l1cache;		/* L1 cache handle (if any) */
134437Smws 	uint16_t smbpr_l2cache;		/* L2 cache handle (if any) */
135437Smws 	uint16_t smbpr_l3cache;		/* L3 cache handle (if any) */
136437Smws 	uint8_t smbpr_serial;		/* serial number */
137437Smws 	uint8_t smbpr_asset;		/* asset tag */
138437Smws 	uint8_t smbpr_part;		/* part number */
139437Smws } smb_processor_t;
140437Smws 
141437Smws typedef struct smb_cache {
142437Smws 	smb_header_t smbca_hdr;		/* structure header */
143437Smws 	uint8_t smbca_socket;		/* socket designation */
144437Smws 	uint16_t smbca_config;		/* cache configuration */
145437Smws 	uint16_t smbca_maxsize;		/* maximum installed size */
146437Smws 	uint16_t smbca_size;		/* installed size */
147437Smws 	uint16_t smbca_stype;		/* supported SRAM type */
148437Smws 	uint16_t smbca_ctype;		/* current SRAM type */
149437Smws 	uint8_t smbca_speed;		/* speed in nanoseconds */
150437Smws 	uint8_t smbca_etype;		/* error correction type */
151437Smws 	uint8_t smbca_ltype;		/* logical cache type */
152437Smws 	uint8_t smbca_assoc;		/* associativity */
153437Smws } smb_cache_t;
154437Smws 
1551222Smws /*
1561222Smws  * Convert encoded cache size to bytes: DSP0134 Section 3.3.8 explains the
1571222Smws  * encoding.  The highest bit is 0 for 1k units, 1 for 64k units, and this
1581222Smws  * macro decodes the value into bytes for exporting to our clients.
1591222Smws  */
1601222Smws #define	SMB_CACHE_SIZE(s)	(((s) & 0x8000) ? \
1611222Smws 	((uint32_t)((s) & 0x7FFF) * 64 * 1024) : ((uint32_t)(s) * 1024))
162437Smws 
163437Smws #define	SMB_CACHE_CFG_MODE(c)		(((c) >> 8) & 3)
164437Smws #define	SMB_CACHE_CFG_ENABLED(c)	(((c) >> 7) & 1)
165437Smws #define	SMB_CACHE_CFG_LOCATION(c)	(((c) >> 5) & 3)
166437Smws #define	SMB_CACHE_CFG_SOCKETED(c)	(((c) >> 3) & 1)
167437Smws #define	SMB_CACHE_CFG_LEVEL(c)		(((c) & 7) + 1)
168437Smws 
169437Smws typedef struct smb_port {
170437Smws 	smb_header_t smbpo_hdr;		/* structure header */
171437Smws 	uint8_t smbpo_iref;		/* internal reference designator */
172437Smws 	uint8_t smbpo_itype;		/* internal connector type */
173437Smws 	uint8_t smbpo_eref;		/* external reference designator */
174437Smws 	uint8_t smbpo_etype;		/* external connector type */
175437Smws 	uint8_t smbpo_ptype;		/* port type */
176437Smws } smb_port_t;
177437Smws 
178437Smws typedef struct smb_slot {
179437Smws 	smb_header_t smbsl_hdr;		/* structure header */
180437Smws 	uint8_t smbsl_name;		/* reference designation */
181437Smws 	uint8_t smbsl_type;		/* slot type */
182437Smws 	uint8_t smbsl_width;		/* slot data bus width */
183437Smws 	uint8_t smbsl_usage;		/* current usage */
184437Smws 	uint8_t smbsl_length;		/* slot length */
185437Smws 	uint16_t smbsl_id;		/* slot ID */
186437Smws 	uint8_t smbsl_ch1;		/* slot characteristics 1 */
187437Smws 	uint8_t smbsl_ch2;		/* slot characteristics 2 */
188*11859STom.Pothier@Sun.COM 	uint16_t smbsl_sg;		/* segment group number */
189*11859STom.Pothier@Sun.COM 	uint8_t smbsl_bus;		/* bus number */
190*11859STom.Pothier@Sun.COM 	uint8_t smbsl_df;		/* device/function number */
191437Smws } smb_slot_t;
192437Smws 
193437Smws typedef struct smb_obdev {
194437Smws 	uint8_t smbob_type;		/* encoded type and enable bit */
195437Smws 	uint8_t smbob_name;		/* descriptiong string */
196437Smws } smb_obdev_t;
197437Smws 
198437Smws #define	SMB_OBT_ENABLED		0x80	/* enable bit within smbob_type */
199437Smws 
200437Smws typedef struct smb_strtab {
201437Smws 	smb_header_t smbtb_hdr;		/* structure header */
202437Smws 	uint8_t smbtb_count;		/* number of strings */
203437Smws } smb_strtab_t;
204437Smws 
205437Smws typedef struct smb_lang {
206437Smws 	smb_header_t smblang_hdr;	/* structure header */
207437Smws 	uint8_t smblang_num;		/* number of installed languages */
208437Smws 	uint8_t smblang_flags;		/* flags */
209437Smws 	uint8_t smblang_resv[15];	/* reserved for future use */
210437Smws 	uint8_t smblang_cur;		/* current language string */
211437Smws } smb_lang_t;
212437Smws 
213437Smws typedef struct smb_sel {
214437Smws 	smb_header_t smbsel_hdr;	/* structure header */
215437Smws 	uint16_t smbsel_len;		/* log area length */
216437Smws 	uint16_t smbsel_hdroff;		/* header offset */
217437Smws 	uint16_t smbsel_dataoff;	/* data offset */
218437Smws 	uint8_t smbsel_method;		/* access method */
219437Smws 	uint8_t smbsel_status;		/* status flags */
220437Smws 	uint32_t smbsel_token;		/* change token */
221437Smws 	uint32_t smbsel_addr;		/* access method address */
222437Smws 	uint8_t smbsel_format;		/* header format */
223437Smws 	uint8_t smbsel_typec;		/* number of type descriptors */
224437Smws 	uint8_t smbsel_typesz;		/* size of each type descriptor */
225437Smws 	uint8_t smbsel_typev[1];	/* array of type descriptors */
226437Smws } smb_sel_t;
227437Smws 
228437Smws typedef struct smb_memarray {
229437Smws 	smb_header_t smbmarr_hdr;	/* structure header */
230437Smws 	uint8_t smbmarr_loc;		/* location */
231437Smws 	uint8_t smbmarr_use;		/* use */
232437Smws 	uint8_t smbmarr_ecc;		/* error detect/correct mechanism */
233437Smws 	uint32_t smbmarr_cap;		/* maximum capacity */
234437Smws 	uint16_t smbmarr_err;		/* error handle */
235437Smws 	uint16_t smbmarr_ndevs;		/* number of slots or sockets */
236437Smws } smb_memarray_t;
237437Smws 
238437Smws typedef struct smb_memarrmap {
239437Smws 	smb_header_t smbamap_hdr;	/* structure header */
240437Smws 	uint32_t smbamap_start;		/* starting address in kilobytes */
241437Smws 	uint32_t smbamap_end;		/* ending address in kilobytes */
242437Smws 	uint16_t smbamap_array;		/* physical memory array handle */
243437Smws 	uint8_t smbamap_width;		/* partition width */
244437Smws } smb_memarrmap_t;
245437Smws 
246437Smws typedef struct smb_memdevice {
247437Smws 	smb_header_t smbmdev_hdr;	/* structure header */
248437Smws 	uint16_t smbmdev_array;		/* array handle */
249437Smws 	uint16_t smbmdev_error;		/* error handle */
250437Smws 	uint16_t smbmdev_twidth;	/* total width */
251437Smws 	uint16_t smbmdev_dwidth;	/* data width */
252437Smws 	uint16_t smbmdev_size;		/* size in either K or MB */
253437Smws 	uint8_t smbmdev_form;		/* form factor */
254437Smws 	uint8_t smbmdev_set;		/* device set */
255437Smws 	uint8_t smbmdev_dloc;		/* device locator */
256437Smws 	uint8_t smbmdev_bloc;		/* bank locator */
257437Smws 	uint8_t smbmdev_type;		/* memory type */
258437Smws 	uint16_t smbmdev_flags;		/* detail flags */
259437Smws 	uint16_t smbmdev_speed;		/* speed in MHz */
260437Smws 	uint8_t smbmdev_manufacturer;	/* manufacturer */
261437Smws 	uint8_t smbmdev_serial;		/* serial number */
262437Smws 	uint8_t smbmdev_asset;		/* asset tag */
263437Smws 	uint8_t smbmdev_part;		/* part number */
264437Smws } smb_memdevice_t;
265437Smws 
266437Smws #define	SMB_MDS_KBYTES		0x8000	/* size in specified in kilobytes */
267437Smws 
268437Smws typedef struct smb_memdevmap {
269437Smws 	smb_header_t smbdmap_hdr;	/* structure header */
270437Smws 	uint32_t smbdmap_start;		/* starting address in kilobytes */
271437Smws 	uint32_t smbdmap_end;		/* ending address in kilobytes */
272437Smws 	uint16_t smbdmap_device;	/* memory device handle */
273437Smws 	uint16_t smbdmap_array;		/* memory array mapped address handle */
274437Smws 	uint8_t smbdmap_rpos;		/* row position */
275437Smws 	uint8_t smbdmap_ipos;		/* interleave position */
276437Smws 	uint8_t smbdmap_idepth;		/* interleave depth */
277437Smws } smb_memdevmap_t;
278437Smws 
279437Smws typedef struct smb_battery {
280437Smws 	smb_header_t smbbat_hdr;	/* structure header */
281437Smws 	uint8_t smbbat_loc;		/* location */
282437Smws 	uint8_t smbbat_manufacturer;	/* manufacturer */
283437Smws 	uint8_t smbbat_date;		/* manufacture date */
284437Smws 	uint8_t smbbat_serial;		/* serial number */
285437Smws 	uint8_t smbbat_devname;		/* device name */
286437Smws 	uint8_t smbbat_chem;		/* device chemistry */
287437Smws 	uint16_t smbbat_cap;		/* design capacity in mW hours */
288437Smws 	uint16_t smbbat_volt;		/* design voltage in mV */
289437Smws 	uint8_t smbbat_version;		/* SBDS version string */
290437Smws 	uint8_t smbbat_err;		/* error percentage */
291437Smws 	uint16_t smbbat_ssn;		/* SBDS serial number */
292437Smws 	uint16_t smbbat_sdate;		/* SBDS manufacture date */
293437Smws 	uint8_t smbbat_schem;		/* SBDS chemistry string */
294437Smws 	uint8_t smbbat_mult;		/* design capacity multiplier */
295437Smws 	uint32_t smbbat_oemdata;	/* OEM-specific data */
296437Smws } smb_battery_t;
297437Smws 
298437Smws typedef struct smb_hwsec {
299437Smws 	smb_header_t smbhs_hdr;		/* structure header */
300437Smws 	uint8_t smbhs_settings;		/* settings byte */
301437Smws } smb_hwsec_t;
302437Smws 
303437Smws #define	SMB_HWS_PWR_PS(x)	(((x) & 0xC0) >> 6)
304437Smws #define	SMB_HWS_KBD_PS(x)	(((x) & 0x30) >> 4)
305437Smws #define	SMB_HWS_ADM_PS(x)	(((x) & 0x0C) >> 2)
306437Smws #define	SMB_HWS_PAN_PS(x)	(((x) & 0x03) >> 0)
307437Smws 
308437Smws typedef struct smb_boot {
309437Smws 	smb_header_t smbbo_hdr;		/* structure header */
310437Smws 	uint8_t smbbo_pad[6];		/* reserved for future use */
311437Smws 	uint8_t smbbo_status[1];	/* variable-length status buffer */
312437Smws } smb_boot_t;
313437Smws 
314437Smws typedef struct smb_ipmi {
315437Smws 	smb_header_t smbipm_hdr;	/* structure header */
316437Smws 	uint8_t smbipm_type;		/* interface type */
317437Smws 	uint8_t smbipm_spec;		/* specification revision */
318437Smws 	uint8_t smbipm_i2c;		/* i2C slave address */
319437Smws 	uint8_t smbipm_bus;		/* NV storage device bus ID */
320437Smws 	uint64_t smbipm_addr;		/* base address */
321437Smws 	uint8_t smbipm_info;		/* base address modifier/intr info */
322437Smws 	uint8_t smbipm_intr;		/* interrupt number */
323437Smws } smb_ipmi_t;
324437Smws 
325437Smws #define	SMB_IPM_SPEC_MAJOR(x)	(((x) & 0xF0) >> 4)
326437Smws #define	SMB_IPM_SPEC_MINOR(x)	((x) & 0x0F)
327437Smws 
328437Smws #define	SMB_IPM_ADDR_IO		1ULL
329437Smws 
330437Smws #define	SMB_IPM_INFO_REGS(x)	(((x) & 0xC0) >> 6)
331437Smws #define	SMB_IPM_INFO_LSB(x)	(((x) & 0x10) >> 4)
332437Smws #define	SMB_IPM_INFO_ISPEC(x)	(((x) & 0x08) >> 3)
333437Smws #define	SMB_IPM_INFO_IPOL(x)	(((x) & 0x02) >> 1)
334437Smws #define	SMB_IPM_INFO_IMODE(x)	(((x) & 0x01) >> 0)
335437Smws 
336437Smws #define	SMB_IPM_REGS_1B		0
337437Smws #define	SMB_IPM_REGS_4B		1
338437Smws #define	SMB_IPM_REGS_16B	2
339437Smws 
340437Smws #define	SMB_IPM_IPOL_LO		0
341437Smws #define	SMB_IPM_IPOL_HI		1
342437Smws 
343437Smws #define	SMB_IPM_IMODE_EDGE	0
344437Smws #define	SMB_IPM_IMODE_LEVEL	1
345437Smws 
346437Smws typedef struct smb_powersup {
347437Smws 	smb_header_t smbpsup_hdr;	/* structure header */
348437Smws 	uint8_t smbpsup_group;		/* group id */
349437Smws 	uint8_t smbpsup_loc;		/* location tag */
350437Smws 	uint8_t smbpsup_devname;	/* device name */
351437Smws 	uint8_t smbpsup_manufacturer;	/* manufacturer */
352437Smws 	uint8_t smbpsup_serial;		/* serial number */
353437Smws 	uint8_t smbpsup_asset;		/* asset tag */
354437Smws 	uint8_t smbpsup_part;		/* part number */
355437Smws 	uint8_t smbpsup_rev;		/* revision string */
356437Smws 	uint16_t smbpsup_max;		/* max output in milliwatts */
357437Smws 	uint16_t smbpsup_char;		/* characteristics */
358437Smws 	uint16_t smbpsup_vprobe;	/* voltage probe handle */
359437Smws 	uint16_t smbpsup_cooldev;	/* cooling device handle */
360437Smws 	uint16_t smbpsup_iprobe;	/* current probe handle */
361437Smws } smb_powersup_t;
362437Smws 
363*11859STom.Pothier@Sun.COM typedef struct smb_obdev_ext {
364*11859STom.Pothier@Sun.COM 	smb_header_t smbobe_hdr;	/* structure header */
365*11859STom.Pothier@Sun.COM 	uint8_t smbobe_name;		/* reference designation */
366*11859STom.Pothier@Sun.COM 	uint8_t smbobe_dtype;		/* device type */
367*11859STom.Pothier@Sun.COM 	uint8_t smbobe_dti;		/* device type instance */
368*11859STom.Pothier@Sun.COM 	uint16_t smbobe_sg;		/* segment group number */
369*11859STom.Pothier@Sun.COM 	uint8_t smbobe_bus;		/* bus number */
370*11859STom.Pothier@Sun.COM 	uint8_t smbobe_df;		/* device/function number */
371*11859STom.Pothier@Sun.COM } smb_obdev_ext_t;
372*11859STom.Pothier@Sun.COM 
37310942STom.Pothier@Sun.COM typedef struct smb_processor_ext {
37410942STom.Pothier@Sun.COM 	smb_header_t smbpre_hdr;	/* structure header */
37510942STom.Pothier@Sun.COM 	uint16_t smbpre_processor;	/* processor handle */
37610942STom.Pothier@Sun.COM 	uint8_t smbpre_fru;		/* FRU indicator */
37710942STom.Pothier@Sun.COM 	uint8_t smbpre_n;		/* number of APIC IDs */
37810942STom.Pothier@Sun.COM 	uint16_t smbpre_apicid[1];	/* strand initial apic id */
37910942STom.Pothier@Sun.COM } smb_processor_ext_t;
38010942STom.Pothier@Sun.COM 
381*11859STom.Pothier@Sun.COM typedef struct smb_port_ext {
382*11859STom.Pothier@Sun.COM 	smb_header_t smbpoe_hdr;	/* structure header */
383*11859STom.Pothier@Sun.COM 	uint16_t smbpoe_chassis;	/* chassis handle */
384*11859STom.Pothier@Sun.COM 	uint16_t smbpoe_port;		/* port connector handle */
385*11859STom.Pothier@Sun.COM 	uint8_t smbpoe_dtype;		/* device type */
386*11859STom.Pothier@Sun.COM 	uint16_t smbpoe_devhdl;		/* device handle */
387*11859STom.Pothier@Sun.COM 	uint8_t smbpoe_phy;		/* PHY number */
388*11859STom.Pothier@Sun.COM } smb_port_ext_t;
389*11859STom.Pothier@Sun.COM 
39010942STom.Pothier@Sun.COM typedef struct smb_pciexrc {
39110942STom.Pothier@Sun.COM 	smb_header_t smbpciexrc_hdr;	/* structure header */
39210942STom.Pothier@Sun.COM 	uint16_t smbpciexrc_bboard;	/* base board handle */
39310942STom.Pothier@Sun.COM 	uint16_t smbpciexrc_bdf;	/* PCI Bus/Dev/Func */
39410942STom.Pothier@Sun.COM } smb_pciexrc_t;
39510942STom.Pothier@Sun.COM 
39610942STom.Pothier@Sun.COM typedef struct smb_memarray_ext {
39710942STom.Pothier@Sun.COM 	smb_header_t smbmarre_hdr;	/* structure header */
39810942STom.Pothier@Sun.COM 	uint16_t smbmarre_ma;		/* memory array handle */
39910942STom.Pothier@Sun.COM 	uint16_t smbmarre_component;	/* component parent handle */
40010942STom.Pothier@Sun.COM 	uint16_t smbmarre_bdf;		/* PCI bus/dev/funct */
40110942STom.Pothier@Sun.COM } smb_memarray_ext_t;
40210942STom.Pothier@Sun.COM 
40310942STom.Pothier@Sun.COM typedef struct smb_memdevice_ext {
40410942STom.Pothier@Sun.COM 	smb_header_t smbmdeve_hdr;	/* structure header */
40510942STom.Pothier@Sun.COM 	uint16_t smbmdeve_mdev;		/* memory device handle */
40610942STom.Pothier@Sun.COM 	uint8_t smbmdeve_dchan;		/* DRAM channel */
40710942STom.Pothier@Sun.COM 	uint8_t smbmdeve_ncs;		/* number of chip select */
40810942STom.Pothier@Sun.COM 	uint8_t smbmdeve_cs[1];		/* chip selects */
40910942STom.Pothier@Sun.COM } smb_memdevice_ext_t;
41010942STom.Pothier@Sun.COM 
411437Smws #pragma pack()
412437Smws 
413437Smws typedef struct smb_struct {
414437Smws 	const smb_header_t *smbst_hdr;	/* address of raw structure data */
415437Smws 	const uchar_t *smbst_str;	/* address of string data (if any) */
416437Smws 	const uchar_t *smbst_end;	/* address of 0x0000 ending tag */
417437Smws 	struct smb_struct *smbst_next; 	/* next structure in hash chain */
418437Smws 	uint16_t *smbst_strtab;		/* string index -> offset table */
419437Smws 	uint_t smbst_strtablen;		/* length of smbst_strtab */
420437Smws } smb_struct_t;
421437Smws 
422437Smws struct smbios_hdl {
423437Smws 	smbios_entry_t sh_ent;		/* structure table entry point */
424437Smws 	const void *sh_buf;		/* structure table buffer */
425437Smws 	size_t sh_buflen;		/* size of structure table buffer */
426437Smws 	smb_struct_t *sh_structs;	/* array of structure descriptors */
427437Smws 	uint_t sh_nstructs;		/* number of active structures */
428437Smws 	smb_struct_t **sh_hash;		/* hash bucket array for descriptors */
429437Smws 	uint_t sh_hashlen;		/* hash bucket array length */
430437Smws 	int sh_err;			/* error code for smbios_errno() */
431437Smws 	int sh_libvers;			/* library client abi version */
432437Smws 	int sh_smbvers;			/* derived underlying format version */
433437Smws 	uint_t sh_flags;		/* miscellaneous flags (see below) */
434437Smws };
435437Smws 
436437Smws #define	SMB_FL_DEBUG	0x1		/* print debug messages for this hdl */
437437Smws #define	SMB_FL_BUFALLOC	0x2		/* sh_buf was allocated by library */
438437Smws 
439437Smws #define	SMB_BIOS_DEVICE		"/dev/xsvc"	/* device w/ BIOS physmem */
440437Smws #define	SMB_SMBIOS_DEVICE	"/dev/smbios"	/* device w/ SMBIOS image */
441437Smws 
442437Smws #define	SMB_RANGE_START	0xF0000		/* start of physical address range */
443437Smws #define	SMB_RANGE_LIMIT	0xFFFFF		/* limit of physical address range */
444437Smws 
445437Smws #define	SMB_MAJMIN(M, m)	((((M) & 0xFF) << 16) | ((m) & 0xFF))
446437Smws #define	SMB_MAJOR(v)		(((v) & 0xFF00) >> 8)
447437Smws #define	SMB_MINOR(v)		(((v) & 0x00FF))
448437Smws 
449437Smws #define	ESMB_BASE	1000		/* base value for libsmbios errnos */
450437Smws 
451437Smws enum {
452437Smws 	ESMB_NOTFOUND = ESMB_BASE,	/* SMBIOS table not found on system */
453437Smws 	ESMB_MAPDEV,			/* failed to map SMBIOS table */
454437Smws 	ESMB_NOENT,			/* failed to locate structure */
455437Smws 	ESMB_NOMEM,			/* failed to allocate memory */
456437Smws 	ESMB_NOHDR,			/* failed to read SMBIOS header */
457437Smws 	ESMB_NOSTAB,			/* failed to read SMBIOS struct table */
458437Smws 	ESMB_NOINFO,			/* no common info for structure */
459437Smws 	ESMB_SHORT,			/* buffer length doesn't match header */
460437Smws 	ESMB_CORRUPT,			/* buffer struct or len is corrupt */
461437Smws 	ESMB_VERSION,			/* version not supported by library */
462437Smws 	ESMB_NOTSUP,			/* feature not supported by provider */
463437Smws 	ESMB_HEADER,			/* SMBIOS header corrupt or invalid */
464437Smws 	ESMB_OLD,			/* SMBIOS version is too old for us */
465437Smws 	ESMB_NEW,			/* SMBIOS version is too new for us */
466437Smws 	ESMB_CKSUM,			/* SMBIOS header checksum mismatch */
467437Smws 	ESMB_INVAL,			/* invalid function call argument */
468437Smws 	ESMB_TYPE,			/* structure type mismatch */
469437Smws 	ESMB_UNKNOWN			/* unknown error (maximum value tag) */
470437Smws };
471437Smws 
472437Smws extern const smb_struct_t *smb_lookup_type(smbios_hdl_t *, uint_t);
473437Smws extern const smb_struct_t *smb_lookup_id(smbios_hdl_t *, uint_t);
474437Smws extern const char *smb_strptr(const smb_struct_t *, uint_t);
475437Smws extern int smb_gteq(smbios_hdl_t *, int);
476437Smws 
477437Smws extern int smb_set_errno(smbios_hdl_t *, int);
478437Smws extern smbios_hdl_t *smb_open_error(smbios_hdl_t *, int *, int);
479437Smws extern const char *smb_strerror(int);
480437Smws 
481437Smws extern void *smb_alloc(size_t);
482437Smws extern void *smb_zalloc(size_t);
483437Smws extern void smb_free(void *, size_t);
484437Smws 
485437Smws extern void smb_dprintf(smbios_hdl_t *, const char *, ...);
486437Smws 
487437Smws extern int _smb_debug;
488437Smws 
489437Smws #ifdef	__cplusplus
490437Smws }
491437Smws #endif
492437Smws 
493437Smws #endif	/* _SYS_SMBIOS_IMPL_H */
494