xref: /titanic_50/usr/src/uts/common/sys/smbios_impl.h (revision 356f72340a69936724c69f2f87fffa6f5887f885)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2015 OmniTI Computer Consulting, Inc.  All rights reserved.
24  * Copyright 2016 Joyent, Inc.
25  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms.
27  */
28 
29 /*
30  * This header file defines the implementation structures for the SMBIOS access
31  * library, libsmbios, and an equivalent kernel module.  Clients should use
32  * the <smbios.h> or <sys/smbios.h> header files to access DMTF SMBIOS
33  * information, NOT these underlying implementation structures from the spec.
34  * In short, do not user this header file or these routines for any purpose.
35  */
36 
37 #ifndef	_SYS_SMBIOS_IMPL_H
38 #define	_SYS_SMBIOS_IMPL_H
39 
40 #include <sys/smbios.h>
41 #include <sys/sysmacros.h>
42 
43 #ifdef _KERNEL
44 #include <sys/systm.h>
45 #else
46 #include <strings.h>
47 #include <stddef.h>
48 #endif
49 
50 #ifdef	__cplusplus
51 extern "C" {
52 #endif
53 
54 /*
55  * Definitions required to interpret the BIOS type information.
56  */
57 #define	SMB_BIOSXB_EXTROM	6
58 
59 #define	SMB_BIOS_EXTROM_VALUE_MASK(x)	((x) & 0x3fff)
60 #define	SMB_BIOS_EXTROM_SHIFT_MASK(x)	(((x) & 0xc000) >> 14)
61 
62 #pragma pack(1)
63 
64 typedef struct smb_header {
65 	uint8_t smbh_type;		/* structure type (SMB_TYPE_* value) */
66 	uint8_t smbh_len;		/* length in bytes of formatted area */
67 	uint16_t smbh_hdl;		/* structure handle */
68 } smb_header_t;
69 
70 typedef struct smb_bios {
71 	smb_header_t smbbi_hdr;		/* structure header */
72 	uint8_t smbbi_vendor;		/* bios vendor string */
73 	uint8_t smbbi_version;		/* bios version string */
74 	uint16_t smbbi_segment;		/* segment location of bios address */
75 	uint8_t smbbi_reldate;		/* bios release date */
76 	uint8_t smbbi_romsize;		/* bios rom size (64k * (n + 1)) */
77 	uint64_t smbbi_cflags;		/* bios characteristics */
78 	uint8_t smbbi_xcflags[1];	/* bios characteristics extensions */
79 } smb_bios_t;
80 
81 typedef struct smb_system {
82 	smb_header_t smbsi_hdr;		/* structure header */
83 	uint8_t smbsi_manufacturer;	/* manufacturer */
84 	uint8_t smbsi_product;		/* product name */
85 	uint8_t smbsi_version;		/* version */
86 	uint8_t smbsi_serial;		/* serial number */
87 	uint8_t smbsi_uuid[16];		/* UUID */
88 	uint8_t smbsi_wakeup;		/* wake-up type */
89 	uint8_t smbsi_sku;		/* SKU number */
90 	uint8_t smbsi_family;		/* family */
91 } smb_system_t;
92 
93 typedef struct smb_bboard {
94 	smb_header_t smbbb_hdr;		/* structure header */
95 	uint8_t smbbb_manufacturer;	/* manufacturer */
96 	uint8_t smbbb_product;		/* product name */
97 	uint8_t smbbb_version;		/* version */
98 	uint8_t smbbb_serial;		/* serial number */
99 	uint8_t smbbb_asset;		/* asset tag */
100 	uint8_t smbbb_flags;		/* feature flags */
101 	uint8_t smbbb_location;		/* location in chassis */
102 	uint16_t smbbb_chassis;		/* chassis handle */
103 	uint8_t smbbb_type;		/* board type */
104 	uint8_t smbbb_cn;		/* number of contained handles */
105 	uint16_t smbbb_cv[1];		/* array of contained handles */
106 } smb_bboard_t;
107 
108 typedef struct smb_chassis {
109 	smb_header_t smbch_hdr;		/* structure header */
110 	uint8_t smbch_manufacturer;	/* manufacturer */
111 	uint8_t smbch_type;		/* type */
112 	uint8_t smbch_version;		/* version */
113 	uint8_t smbch_serial;		/* serial number */
114 	uint8_t smbch_asset;		/* asset tag */
115 	uint8_t smbch_bustate;		/* boot-up state */
116 	uint8_t smbch_psstate;		/* power supply state */
117 	uint8_t smbch_thstate;		/* thermal state */
118 	uint8_t smbch_security;		/* security state */
119 	uint32_t smbch_oemdata;		/* OEM-specific data */
120 	uint8_t smbch_uheight;		/* enclosure height */
121 	uint8_t smbch_cords;		/* number of power cords */
122 	uint8_t smbch_cn;		/* number of contained records */
123 	uint8_t smbch_cm;		/* size of contained records */
124 	uint8_t smbch_cv[1];		/* array of contained records */
125 } smb_chassis_t;
126 
127 /* WARNING: the argument is evaluated three times! */
128 #define	SMB_CH_SKU(smbcp) ((char *) \
129 	(smbcp)->smbch_cv + ((smbcp)->smbch_cn * (smbcp)->smbch_cm))
130 #define	SMB_CHT_LOCK	0x80		/* lock bit within smbch_type */
131 
132 typedef struct smb_processor {
133 	smb_header_t smbpr_hdr;		/* structure header */
134 	uint8_t smbpr_socket;		/* socket designation */
135 	uint8_t smbpr_type;		/* processor type (see <smbios.h>) */
136 	uint8_t smbpr_family;		/* processor family (see <smbios.h>) */
137 	uint8_t smbpr_manufacturer;	/* manufacturer */
138 	uint64_t smbpr_cpuid;		/* processor cpuid information */
139 	uint8_t smbpr_version;		/* version */
140 	uint8_t smbpr_voltage;		/* voltage */
141 	uint16_t smbpr_clkspeed;	/* external clock speed in MHz */
142 	uint16_t smbpr_maxspeed;	/* maximum speed in MHz */
143 	uint16_t smbpr_curspeed;	/* current speed in MHz */
144 	uint8_t smbpr_status;		/* status (see <smbios.h>) */
145 	uint8_t smbpr_upgrade;		/* upgrade */
146 	uint16_t smbpr_l1cache;		/* L1 cache handle (if any) */
147 	uint16_t smbpr_l2cache;		/* L2 cache handle (if any) */
148 	uint16_t smbpr_l3cache;		/* L3 cache handle (if any) */
149 	uint8_t smbpr_serial;		/* serial number */
150 	uint8_t smbpr_asset;		/* asset tag */
151 	uint8_t smbpr_part;		/* part number */
152 	uint8_t smbpr_corecount;	/* number of cores per socket */
153 	uint8_t smbpr_coresenabled;	/* number of enabled cores per socket */
154 	uint8_t smbpr_threadcount;	/* number of threads per socket */
155 	uint16_t smbpr_cflags;	/* cpu characteristics (see <smbios.h>) */
156 	uint16_t smbpr_family2;		/* processor family2 (see <smbios.h>) */
157 	uint16_t smbpr_corecount2;	/* second number of cores per socket */
158 	uint16_t smbpr_coresenabled2;	/* second number of enabled cores */
159 	uint16_t smbpr_threadcount2;	/* second number of enabled threads */
160 } smb_processor_t;
161 
162 typedef struct smb_cache {
163 	smb_header_t smbca_hdr;		/* structure header */
164 	uint8_t smbca_socket;		/* socket designation */
165 	uint16_t smbca_config;		/* cache configuration */
166 	uint16_t smbca_maxsize;		/* maximum installed size */
167 	uint16_t smbca_size;		/* installed size */
168 	uint16_t smbca_stype;		/* supported SRAM type */
169 	uint16_t smbca_ctype;		/* current SRAM type */
170 	uint8_t smbca_speed;		/* speed in nanoseconds */
171 	uint8_t smbca_etype;		/* error correction type */
172 	uint8_t smbca_ltype;		/* logical cache type */
173 	uint8_t smbca_assoc;		/* associativity */
174 	uint32_t smbca_maxsize2;	/* maximum installed size 2 */
175 	uint32_t smbca_size2;		/* installed size 2 */
176 } smb_cache_t;
177 
178 /*
179  * Convert encoded cache size to bytes: DSP0134 Section 7.8 explains the
180  * encoding.  The highest bit is 0 for 1k units, 1 for 64k units, and this
181  * macro decodes the value into bytes for exporting to our clients.
182  */
183 #define	SMB_CACHE_SIZE(s)	(((s) & 0x8000) ? \
184 	((uint32_t)((s) & 0x7FFF) * 64 * 1024) : ((uint32_t)(s) * 1024))
185 
186 #define	SMB_CACHE_EXT_SIZE(s)	(((s) & 0x80000000U) ? 	\
187 	((uint64_t)((s) & 0x7FFFFFFFULL) * 64ULL * 1024ULL) : 	\
188 	((uint64_t)(s) * 1024ULL))
189 
190 #define	SMB_CACHE_CFG_MODE(c)		(((c) >> 8) & 3)
191 #define	SMB_CACHE_CFG_ENABLED(c)	(((c) >> 7) & 1)
192 #define	SMB_CACHE_CFG_LOCATION(c)	(((c) >> 5) & 3)
193 #define	SMB_CACHE_CFG_SOCKETED(c)	(((c) >> 3) & 1)
194 #define	SMB_CACHE_CFG_LEVEL(c)		(((c) & 7) + 1)
195 
196 typedef struct smb_port {
197 	smb_header_t smbpo_hdr;		/* structure header */
198 	uint8_t smbpo_iref;		/* internal reference designator */
199 	uint8_t smbpo_itype;		/* internal connector type */
200 	uint8_t smbpo_eref;		/* external reference designator */
201 	uint8_t smbpo_etype;		/* external connector type */
202 	uint8_t smbpo_ptype;		/* port type */
203 } smb_port_t;
204 
205 typedef struct smb_slot {
206 	smb_header_t smbsl_hdr;		/* structure header */
207 	uint8_t smbsl_name;		/* reference designation */
208 	uint8_t smbsl_type;		/* slot type */
209 	uint8_t smbsl_width;		/* slot data bus width */
210 	uint8_t smbsl_usage;		/* current usage */
211 	uint8_t smbsl_length;		/* slot length */
212 	uint16_t smbsl_id;		/* slot ID */
213 	uint8_t smbsl_ch1;		/* slot characteristics 1 */
214 	uint8_t smbsl_ch2;		/* slot characteristics 2 */
215 	uint16_t smbsl_sg;		/* segment group number */
216 	uint8_t smbsl_bus;		/* bus number */
217 	uint8_t smbsl_df;		/* device/function number */
218 } smb_slot_t;
219 
220 typedef struct smb_obdev {
221 	uint8_t smbob_type;		/* encoded type and enable bit */
222 	uint8_t smbob_name;		/* description string */
223 } smb_obdev_t;
224 
225 #define	SMB_OBT_ENABLED		0x80	/* enable bit within smbob_type */
226 
227 typedef struct smb_strtab {
228 	smb_header_t smbtb_hdr;		/* structure header */
229 	uint8_t smbtb_count;		/* number of strings */
230 } smb_strtab_t;
231 
232 typedef struct smb_lang {
233 	smb_header_t smblang_hdr;	/* structure header */
234 	uint8_t smblang_num;		/* number of installed languages */
235 	uint8_t smblang_flags;		/* flags */
236 	uint8_t smblang_resv[15];	/* reserved for future use */
237 	uint8_t smblang_cur;		/* current language string */
238 } smb_lang_t;
239 
240 typedef struct smb_sel {
241 	smb_header_t smbsel_hdr;	/* structure header */
242 	uint16_t smbsel_len;		/* log area length */
243 	uint16_t smbsel_hdroff;		/* header offset */
244 	uint16_t smbsel_dataoff;	/* data offset */
245 	uint8_t smbsel_method;		/* access method */
246 	uint8_t smbsel_status;		/* status flags */
247 	uint32_t smbsel_token;		/* change token */
248 	uint32_t smbsel_addr;		/* access method address */
249 	uint8_t smbsel_format;		/* header format */
250 	uint8_t smbsel_typec;		/* number of type descriptors */
251 	uint8_t smbsel_typesz;		/* size of each type descriptor */
252 	uint8_t smbsel_typev[1];	/* array of type descriptors */
253 } smb_sel_t;
254 
255 typedef struct smb_memarray {
256 	smb_header_t smbmarr_hdr;	/* structure header */
257 	uint8_t smbmarr_loc;		/* location */
258 	uint8_t smbmarr_use;		/* use */
259 	uint8_t smbmarr_ecc;		/* error detect/correct mechanism */
260 	uint32_t smbmarr_cap;		/* maximum capacity */
261 	uint16_t smbmarr_err;		/* error handle */
262 	uint16_t smbmarr_ndevs;		/* number of slots or sockets */
263 	uint64_t smbmarr_extcap;	/* extended maximum capacity */
264 } smb_memarray_t;
265 
266 typedef struct smb_memarrmap {
267 	smb_header_t smbamap_hdr;	/* structure header */
268 	uint32_t smbamap_start;		/* starting address in kilobytes */
269 	uint32_t smbamap_end;		/* ending address in kilobytes */
270 	uint16_t smbamap_array;		/* physical memory array handle */
271 	uint8_t smbamap_width;		/* partition width */
272 	uint64_t smbamap_extstart;	/* extended starting address in bytes */
273 	uint64_t smbamap_extend;	/* extended ending address in bytes */
274 } smb_memarrmap_t;
275 
276 typedef struct smb_memdevice {
277 	smb_header_t smbmdev_hdr;	/* structure header */
278 	uint16_t smbmdev_array;		/* array handle */
279 	uint16_t smbmdev_error;		/* error handle */
280 	uint16_t smbmdev_twidth;	/* total width */
281 	uint16_t smbmdev_dwidth;	/* data width */
282 	uint16_t smbmdev_size;		/* size in either K or MB */
283 	uint8_t smbmdev_form;		/* form factor */
284 	uint8_t smbmdev_set;		/* device set */
285 	uint8_t smbmdev_dloc;		/* device locator */
286 	uint8_t smbmdev_bloc;		/* bank locator */
287 	uint8_t smbmdev_type;		/* memory type */
288 	uint16_t smbmdev_flags;		/* detail flags */
289 	uint16_t smbmdev_speed;		/* speed in MT/s */
290 	uint8_t smbmdev_manufacturer;	/* manufacturer */
291 	uint8_t smbmdev_serial;		/* serial number */
292 	uint8_t smbmdev_asset;		/* asset tag */
293 	uint8_t smbmdev_part;		/* part number */
294 	uint8_t smbmdev_attrs;		/* attributes */
295 	uint32_t smbmdev_extsize;	/* extended size */
296 	uint16_t smbmdev_clkspeed;	/* configured clock speed */
297 	uint16_t smbmdev_minvolt;	/* minimum voltage */
298 	uint16_t smbmdev_maxvolt;	/* maximum voltage */
299 	uint16_t smbmdev_confvolt;	/* configured voltage */
300 } smb_memdevice_t;
301 
302 #define	SMB_MDS_KBYTES		0x8000	/* size in specified in kilobytes */
303 
304 typedef struct smb_memdevmap {
305 	smb_header_t smbdmap_hdr;	/* structure header */
306 	uint32_t smbdmap_start;		/* starting address in kilobytes */
307 	uint32_t smbdmap_end;		/* ending address in kilobytes */
308 	uint16_t smbdmap_device;	/* memory device handle */
309 	uint16_t smbdmap_array;		/* memory array mapped address handle */
310 	uint8_t smbdmap_rpos;		/* row position */
311 	uint8_t smbdmap_ipos;		/* interleave position */
312 	uint8_t smbdmap_idepth;		/* interleave depth */
313 	uint64_t smbdmap_extstart;	/* extended starting address */
314 	uint64_t smbdmap_extend;	/* extended ending address */
315 } smb_memdevmap_t;
316 
317 typedef struct smb_battery {
318 	smb_header_t smbbat_hdr;	/* structure header */
319 	uint8_t smbbat_loc;		/* location */
320 	uint8_t smbbat_manufacturer;	/* manufacturer */
321 	uint8_t smbbat_date;		/* manufacture date */
322 	uint8_t smbbat_serial;		/* serial number */
323 	uint8_t smbbat_devname;		/* device name */
324 	uint8_t smbbat_chem;		/* device chemistry */
325 	uint16_t smbbat_cap;		/* design capacity in mW hours */
326 	uint16_t smbbat_volt;		/* design voltage in mV */
327 	uint8_t smbbat_version;		/* SBDS version string */
328 	uint8_t smbbat_err;		/* error percentage */
329 	uint16_t smbbat_ssn;		/* SBDS serial number */
330 	uint16_t smbbat_sdate;		/* SBDS manufacture date */
331 	uint8_t smbbat_schem;		/* SBDS chemistry string */
332 	uint8_t smbbat_mult;		/* design capacity multiplier */
333 	uint32_t smbbat_oemdata;	/* OEM-specific data */
334 } smb_battery_t;
335 
336 typedef struct smb_hwsec {
337 	smb_header_t smbhs_hdr;		/* structure header */
338 	uint8_t smbhs_settings;		/* settings byte */
339 } smb_hwsec_t;
340 
341 #define	SMB_HWS_PWR_PS(x)	(((x) & 0xC0) >> 6)
342 #define	SMB_HWS_KBD_PS(x)	(((x) & 0x30) >> 4)
343 #define	SMB_HWS_ADM_PS(x)	(((x) & 0x0C) >> 2)
344 #define	SMB_HWS_PAN_PS(x)	(((x) & 0x03) >> 0)
345 
346 typedef struct smb_boot {
347 	smb_header_t smbbo_hdr;		/* structure header */
348 	uint8_t smbbo_pad[6];		/* reserved for future use */
349 	uint8_t smbbo_status[1];	/* variable-length status buffer */
350 } smb_boot_t;
351 
352 typedef struct smb_ipmi {
353 	smb_header_t smbipm_hdr;	/* structure header */
354 	uint8_t smbipm_type;		/* interface type */
355 	uint8_t smbipm_spec;		/* specification revision */
356 	uint8_t smbipm_i2c;		/* i2C slave address */
357 	uint8_t smbipm_bus;		/* NV storage device bus ID */
358 	uint64_t smbipm_addr;		/* base address */
359 	uint8_t smbipm_info;		/* base address modifier/intr info */
360 	uint8_t smbipm_intr;		/* interrupt number */
361 } smb_ipmi_t;
362 
363 #define	SMB_IPM_SPEC_MAJOR(x)	(((x) & 0xF0) >> 4)
364 #define	SMB_IPM_SPEC_MINOR(x)	((x) & 0x0F)
365 
366 #define	SMB_IPM_ADDR_IO		1ULL
367 
368 #define	SMB_IPM_INFO_REGS(x)	(((x) & 0xC0) >> 6)
369 #define	SMB_IPM_INFO_LSB(x)	(((x) & 0x10) >> 4)
370 #define	SMB_IPM_INFO_ISPEC(x)	(((x) & 0x08) >> 3)
371 #define	SMB_IPM_INFO_IPOL(x)	(((x) & 0x02) >> 1)
372 #define	SMB_IPM_INFO_IMODE(x)	(((x) & 0x01) >> 0)
373 
374 #define	SMB_IPM_REGS_1B		0
375 #define	SMB_IPM_REGS_4B		1
376 #define	SMB_IPM_REGS_16B	2
377 
378 #define	SMB_IPM_IPOL_LO		0
379 #define	SMB_IPM_IPOL_HI		1
380 
381 #define	SMB_IPM_IMODE_EDGE	0
382 #define	SMB_IPM_IMODE_LEVEL	1
383 
384 typedef struct smb_powersup {
385 	smb_header_t smbpsup_hdr;	/* structure header */
386 	uint8_t smbpsup_group;		/* group id */
387 	uint8_t smbpsup_loc;		/* location tag */
388 	uint8_t smbpsup_devname;	/* device name */
389 	uint8_t smbpsup_manufacturer;	/* manufacturer */
390 	uint8_t smbpsup_serial;		/* serial number */
391 	uint8_t smbpsup_asset;		/* asset tag */
392 	uint8_t smbpsup_part;		/* part number */
393 	uint8_t smbpsup_rev;		/* revision string */
394 	uint16_t smbpsup_max;		/* max output in milliwatts */
395 	uint16_t smbpsup_char;		/* characteristics */
396 	uint16_t smbpsup_vprobe;	/* voltage probe handle */
397 	uint16_t smbpsup_cooldev;	/* cooling device handle */
398 	uint16_t smbpsup_iprobe;	/* current probe handle */
399 } smb_powersup_t;
400 
401 typedef struct smb_obdev_ext {
402 	smb_header_t smbobe_hdr;	/* structure header */
403 	uint8_t smbobe_name;		/* reference designation */
404 	uint8_t smbobe_dtype;		/* device type */
405 	uint8_t smbobe_dti;		/* device type instance */
406 	uint16_t smbobe_sg;		/* segment group number */
407 	uint8_t smbobe_bus;		/* bus number */
408 	uint8_t smbobe_df;		/* device/function number */
409 } smb_obdev_ext_t;
410 
411 typedef struct smb_processor_ext {
412 	smb_header_t smbpre_hdr;	/* structure header */
413 	uint16_t smbpre_processor;	/* processor handle */
414 	uint8_t smbpre_fru;		/* FRU indicator */
415 	uint8_t smbpre_n;		/* number of APIC IDs */
416 	uint16_t smbpre_apicid[1];	/* strand initial apic id */
417 } smb_processor_ext_t;
418 
419 typedef struct smb_port_ext {
420 	smb_header_t smbpoe_hdr;	/* structure header */
421 	uint16_t smbpoe_chassis;	/* chassis handle */
422 	uint16_t smbpoe_port;		/* port connector handle */
423 	uint8_t smbpoe_dtype;		/* device type */
424 	uint16_t smbpoe_devhdl;		/* device handle */
425 	uint8_t smbpoe_phy;		/* PHY number */
426 } smb_port_ext_t;
427 
428 typedef struct smb_pciexrc {
429 	smb_header_t smbpciexrc_hdr;	/* structure header */
430 	uint16_t smbpciexrc_bboard;	/* base board handle */
431 	uint16_t smbpciexrc_bdf;	/* PCI Bus/Dev/Func */
432 } smb_pciexrc_t;
433 
434 typedef struct smb_memarray_ext {
435 	smb_header_t smbmarre_hdr;	/* structure header */
436 	uint16_t smbmarre_ma;		/* memory array handle */
437 	uint16_t smbmarre_component;	/* component parent handle */
438 	uint16_t smbmarre_bdf;		/* PCI bus/dev/funct */
439 } smb_memarray_ext_t;
440 
441 typedef struct smb_memdevice_ext {
442 	smb_header_t smbmdeve_hdr;	/* structure header */
443 	uint16_t smbmdeve_mdev;		/* memory device handle */
444 	uint8_t smbmdeve_dchan;		/* DRAM channel */
445 	uint8_t smbmdeve_ncs;		/* number of chip select */
446 	uint8_t smbmdeve_cs[1];		/* chip selects */
447 } smb_memdevice_ext_t;
448 
449 #pragma pack()
450 
451 typedef struct smb_struct {
452 	const smb_header_t *smbst_hdr;	/* address of raw structure data */
453 	const uchar_t *smbst_str;	/* address of string data (if any) */
454 	const uchar_t *smbst_end;	/* address of 0x0000 ending tag */
455 	struct smb_struct *smbst_next; 	/* next structure in hash chain */
456 	uint16_t *smbst_strtab;		/* string index -> offset table */
457 	uint_t smbst_strtablen;		/* length of smbst_strtab */
458 } smb_struct_t;
459 
460 struct smbios_hdl {
461 	smbios_entry_point_t sh_ent_type; /* structure table entry point type */
462 	smbios_entry_t sh_ent;		/* structure table entry point */
463 	uint_t sh_ent_stnum;		/* number of structure table entries */
464 	const void *sh_buf;		/* structure table buffer */
465 	size_t sh_buflen;		/* size of structure table buffer */
466 	smb_struct_t *sh_structs;	/* array of structure descriptors */
467 	uint_t sh_nstructs;		/* number of active structures */
468 	smb_struct_t **sh_hash;		/* hash bucket array for descriptors */
469 	uint_t sh_hashlen;		/* hash bucket array length */
470 	int sh_err;			/* error code for smbios_errno() */
471 	int sh_libvers;			/* library client abi version */
472 	int sh_smbvers;			/* derived underlying format version */
473 	uint_t sh_flags;		/* miscellaneous flags (see below) */
474 };
475 
476 #define	SMB_FL_DEBUG	0x1		/* print debug messages for this hdl */
477 #define	SMB_FL_BUFALLOC	0x2		/* sh_buf was allocated by library */
478 #define	SMB_FL_TRUNC	0x4		/* smbios table is truncated */
479 
480 #define	SMB_BIOS_DEVICE		"/dev/xsvc"	/* device w/ BIOS physmem */
481 #define	SMB_SMBIOS_DEVICE	"/dev/smbios"	/* device w/ SMBIOS image */
482 
483 #define	SMB_RANGE_START	0xF0000		/* start of physical address range */
484 #define	SMB_RANGE_LIMIT	0xFFFFF		/* limit of physical address range */
485 #define	SMB_SCAN_STEP	16		/* stepping by paragraph */
486 
487 #define	SMB_MAJMIN(M, m)	((((M) & 0xFF) << 16) | ((m) & 0xFF))
488 #define	SMB_MAJOR(v)		(((v) & 0xFF00) >> 8)
489 #define	SMB_MINOR(v)		(((v) & 0x00FF))
490 
491 #define	ESMB_BASE	1000		/* base value for libsmbios errnos */
492 
493 enum {
494 	ESMB_NOTFOUND = ESMB_BASE,	/* SMBIOS table not found on system */
495 	ESMB_MAPDEV,			/* failed to map SMBIOS table */
496 	ESMB_NOENT,			/* failed to locate structure */
497 	ESMB_NOMEM,			/* failed to allocate memory */
498 	ESMB_NOHDR,			/* failed to read SMBIOS header */
499 	ESMB_NOSTAB,			/* failed to read SMBIOS struct table */
500 	ESMB_NOINFO,			/* no common info for structure */
501 	ESMB_SHORT,			/* buffer length doesn't match header */
502 	ESMB_CORRUPT,			/* buffer struct or len is corrupt */
503 	ESMB_VERSION,			/* version not supported by library */
504 	ESMB_NOTSUP,			/* feature not supported by provider */
505 	ESMB_HEADER,			/* SMBIOS header corrupt or invalid */
506 	ESMB_OLD,			/* SMBIOS version is too old for us */
507 	ESMB_NEW,			/* SMBIOS version is too new for us */
508 	ESMB_CKSUM,			/* SMBIOS header checksum mismatch */
509 	ESMB_INVAL,			/* invalid function call argument */
510 	ESMB_TYPE,			/* structure type mismatch */
511 	ESMB_UNKNOWN			/* unknown error (maximum value tag) */
512 };
513 
514 extern const smb_struct_t *smb_lookup_type(smbios_hdl_t *, uint_t);
515 extern const smb_struct_t *smb_lookup_id(smbios_hdl_t *, uint_t);
516 extern const char *smb_strptr(const smb_struct_t *, uint_t);
517 extern int smb_gteq(smbios_hdl_t *, int);
518 extern int smb_libgteq(smbios_hdl_t *, int);
519 
520 extern int smb_set_errno(smbios_hdl_t *, int);
521 extern smbios_hdl_t *smb_open_error(smbios_hdl_t *, int *, int);
522 extern const char *smb_strerror(int);
523 
524 extern void *smb_alloc(size_t);
525 extern void *smb_zalloc(size_t);
526 extern void smb_free(void *, size_t);
527 
528 extern void smb_dprintf(smbios_hdl_t *, const char *, ...);
529 
530 extern int _smb_debug;
531 
532 /*
533  * The following series of structures represent the base versions of public
534  * structures that are used inside by the smbios routines. This allows the
535  * common code to properly know how much it should or should not bzero and how
536  * to handle additions to the spec. Types should only be added here if we need
537  * to extend the public structures in sys/smbios.h due to a change in the spec.
538  *
539  * Types here have the name smb_base_%s which corresponds to smbios_%s.
540  */
541 typedef struct smb_base_chassis {
542 	uint32_t smbbc_oemdata;		/* OEM-specific data */
543 	uint8_t smbbc_lock;		/* lock present? */
544 	uint8_t smbbc_type;		/* type */
545 	uint8_t smbbc_bustate;		/* boot-up state */
546 	uint8_t smbbc_psstate;		/* power supply state */
547 	uint8_t smbbc_thstate;		/* thermal state */
548 	uint8_t smbbc_security;		/* security status */
549 	uint8_t smbbc_uheight;		/* enclosure height in U's */
550 	uint8_t smbbc_cords;		/* number of power cords */
551 	uint8_t smbbc_elems;		/* number of element records (n) */
552 	uint8_t smbbc_elemlen;		/* length of contained element (m) */
553 } smb_base_chassis_t;
554 
555 typedef struct smb_base_processor {
556 	uint64_t smbbp_cpuid;		/* processor cpuid information */
557 	uint32_t smbbp_family;		/* processor family */
558 	uint8_t smbbp_type;		/* processor type (SMB_PRT_*) */
559 	uint8_t smbbp_voltage;		/* voltage (SMB_PRV_*) */
560 	uint8_t smbbp_status;		/* status (SMB_PRS_*) */
561 	uint8_t smbbp_upgrade;		/* upgrade (SMB_PRU_*) */
562 	uint32_t smbbp_clkspeed;	/* external clock speed in MHz */
563 	uint32_t smbbp_maxspeed;	/* maximum speed in MHz */
564 	uint32_t smbbp_curspeed;	/* current speed in MHz */
565 	id_t smbbp_l1cache;		/* L1 cache handle */
566 	id_t smbbp_l2cache;		/* L2 cache handle */
567 	id_t smbbp_l3cache;		/* L3 cache handle */
568 } smb_base_processor_t;
569 
570 typedef struct smb_base_memdevice {
571 	id_t smbbmd_array;		/* handle of physical memory array */
572 	id_t smbbmd_error;		/* handle of memory error data */
573 	uint32_t smbbmd_twidth;		/* total width in bits including ecc */
574 	uint32_t smbbmd_dwidth;		/* data width in bits */
575 	uint64_t smbbmd_size;		/* size in bytes (see note above) */
576 	uint8_t smbbmd_form;		/* form factor */
577 	uint8_t smbbmd_set;		/* set (0x00=none, 0xFF=unknown) */
578 	uint8_t smbbmd_type;		/* memory type */
579 	uint8_t smbbmd_pad;		/* padding */
580 	uint32_t smbbmd_flags;		/* flags (see below) */
581 	uint32_t smbbmd_speed;		/* speed in MHz */
582 	const char *smbbmd_dloc;	/* physical device locator string */
583 	const char *smbbmd_bloc;	/* physical bank locator string */
584 	uint8_t smbbmd_rank;		/* rank */
585 } smb_base_memdevice_t;
586 
587 typedef struct smb_base_bios {
588 	const char *smbbb_vendor;	/* bios vendor string */
589 	const char *smbbb_version;	/* bios version string */
590 	const char *smbbb_reldate;	/* bios release date */
591 	uint32_t smbbb_segment;		/* bios address segment location */
592 	uint32_t smbbb_romsize;		/* bios rom size in bytes */
593 	uint32_t smbbb_runsize;		/* bios image size in bytes */
594 	uint64_t smbbb_cflags;		/* bios characteristics */
595 	const uint8_t *smbbb_xcflags;	/* bios characteristics extensions */
596 	size_t smbbb_nxcflags;		/* number of smbb_xcflags[] bytes */
597 	smbios_version_t smbbb_biosv;	/* bios version */
598 	smbios_version_t smbbb_ecfwv;	/* bios embedded ctrl f/w version */
599 } smb_base_bios_t;
600 
601 typedef struct smb_base_cache {
602 	uint32_t smbba_maxsize;		/* maximum installed size in bytes */
603 	uint32_t smbba_size;		/* installed size in bytes */
604 	uint16_t smbba_stype;		/* supported SRAM types (SMB_CAT_*) */
605 	uint16_t smbba_ctype;		/* current SRAM type (SMB_CAT_*) */
606 	uint8_t smbba_speed;		/* speed in nanoseconds */
607 	uint8_t smbba_etype;		/* error correction type (SMB_CAE_*) */
608 	uint8_t smbba_ltype;		/* logical cache type (SMB_CAG_*) */
609 	uint8_t smbba_assoc;		/* associativity (SMB_CAA_*) */
610 	uint8_t smbba_level;		/* cache level */
611 	uint8_t smbba_mode;		/* cache mode (SMB_CAM_*) */
612 	uint8_t smbba_location;		/* cache location (SMB_CAL_*) */
613 	uint8_t smbba_flags;		/* cache flags (SMB_CAF_*) */
614 } smb_base_cache_t;
615 
616 #ifdef	__cplusplus
617 }
618 #endif
619 
620 #endif	/* _SYS_SMBIOS_IMPL_H */
621