xref: /titanic_51/usr/src/uts/common/sys/smbios_impl.h (revision ccdeb6b6d71f3c9aa7e78b688f7b34fff109a817)
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 (c) 2018, 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 /*
71  * SMBIOS implementation structure for SMB_TYPE_BIOS.
72  */
73 typedef struct smb_bios {
74 	smb_header_t smbbi_hdr;		/* structure header */
75 	uint8_t smbbi_vendor;		/* bios vendor string */
76 	uint8_t smbbi_version;		/* bios version string */
77 	uint16_t smbbi_segment;		/* segment location of bios address */
78 	uint8_t smbbi_reldate;		/* bios release date */
79 	uint8_t smbbi_romsize;		/* bios rom size (64k * (n + 1)) */
80 	uint64_t smbbi_cflags;		/* bios characteristics */
81 	uint8_t smbbi_xcflags[1];	/* bios characteristics extensions */
82 } smb_bios_t;
83 
84 /*
85  * SMBIOS implementation structure for SMB_TYPE_SYSTEM.
86  */
87 typedef struct smb_system {
88 	smb_header_t smbsi_hdr;		/* structure header */
89 	uint8_t smbsi_manufacturer;	/* manufacturer */
90 	uint8_t smbsi_product;		/* product name */
91 	uint8_t smbsi_version;		/* version */
92 	uint8_t smbsi_serial;		/* serial number */
93 	uint8_t smbsi_uuid[16];		/* UUID */
94 	uint8_t smbsi_wakeup;		/* wake-up type */
95 	uint8_t smbsi_sku;		/* SKU number */
96 	uint8_t smbsi_family;		/* family */
97 } smb_system_t;
98 
99 /*
100  * SMBIOS implementation structure for SMB_TYPE_BASEBOARD.
101  */
102 typedef struct smb_bboard {
103 	smb_header_t smbbb_hdr;		/* structure header */
104 	uint8_t smbbb_manufacturer;	/* manufacturer */
105 	uint8_t smbbb_product;		/* product name */
106 	uint8_t smbbb_version;		/* version */
107 	uint8_t smbbb_serial;		/* serial number */
108 	uint8_t smbbb_asset;		/* asset tag */
109 	uint8_t smbbb_flags;		/* feature flags */
110 	uint8_t smbbb_location;		/* location in chassis */
111 	uint16_t smbbb_chassis;		/* chassis handle */
112 	uint8_t smbbb_type;		/* board type */
113 	uint8_t smbbb_cn;		/* number of contained handles */
114 	uint16_t smbbb_cv[1];		/* array of contained handles */
115 } smb_bboard_t;
116 
117 /*
118  * SMBIOS implementation structure for SMB_TYPE_CHASSIS.
119  */
120 typedef struct smb_chassis {
121 	smb_header_t smbch_hdr;		/* structure header */
122 	uint8_t smbch_manufacturer;	/* manufacturer */
123 	uint8_t smbch_type;		/* type */
124 	uint8_t smbch_version;		/* version */
125 	uint8_t smbch_serial;		/* serial number */
126 	uint8_t smbch_asset;		/* asset tag */
127 	uint8_t smbch_bustate;		/* boot-up state */
128 	uint8_t smbch_psstate;		/* power supply state */
129 	uint8_t smbch_thstate;		/* thermal state */
130 	uint8_t smbch_security;		/* security state */
131 	uint32_t smbch_oemdata;		/* OEM-specific data */
132 	uint8_t smbch_uheight;		/* enclosure height */
133 	uint8_t smbch_cords;		/* number of power cords */
134 	uint8_t smbch_cn;		/* number of contained records */
135 	uint8_t smbch_cm;		/* size of contained records */
136 	uint8_t smbch_cv[1];		/* array of contained records */
137 } smb_chassis_t;
138 
139 /* WARNING: the argument is evaluated three times! */
140 #define	SMB_CH_SKU(smbcp) ((char *) \
141 	(smbcp)->smbch_cv + ((smbcp)->smbch_cn * (smbcp)->smbch_cm))
142 #define	SMB_CHT_LOCK	0x80		/* lock bit within smbch_type */
143 
144 /*
145  * SMBIOS implementation structure for SMB_TYPE_PROCESSOR.
146  */
147 typedef struct smb_processor {
148 	smb_header_t smbpr_hdr;		/* structure header */
149 	uint8_t smbpr_socket;		/* socket designation */
150 	uint8_t smbpr_type;		/* processor type (see <smbios.h>) */
151 	uint8_t smbpr_family;		/* processor family (see <smbios.h>) */
152 	uint8_t smbpr_manufacturer;	/* manufacturer */
153 	uint64_t smbpr_cpuid;		/* processor cpuid information */
154 	uint8_t smbpr_version;		/* version */
155 	uint8_t smbpr_voltage;		/* voltage */
156 	uint16_t smbpr_clkspeed;	/* external clock speed in MHz */
157 	uint16_t smbpr_maxspeed;	/* maximum speed in MHz */
158 	uint16_t smbpr_curspeed;	/* current speed in MHz */
159 	uint8_t smbpr_status;		/* status (see <smbios.h>) */
160 	uint8_t smbpr_upgrade;		/* upgrade */
161 	uint16_t smbpr_l1cache;		/* L1 cache handle (if any) */
162 	uint16_t smbpr_l2cache;		/* L2 cache handle (if any) */
163 	uint16_t smbpr_l3cache;		/* L3 cache handle (if any) */
164 	uint8_t smbpr_serial;		/* serial number */
165 	uint8_t smbpr_asset;		/* asset tag */
166 	uint8_t smbpr_part;		/* part number */
167 	uint8_t smbpr_corecount;	/* number of cores per socket */
168 	uint8_t smbpr_coresenabled;	/* number of enabled cores per socket */
169 	uint8_t smbpr_threadcount;	/* number of threads per socket */
170 	uint16_t smbpr_cflags;	/* cpu characteristics (see <smbios.h>) */
171 	uint16_t smbpr_family2;		/* processor family2 (see <smbios.h>) */
172 	uint16_t smbpr_corecount2;	/* second number of cores per socket */
173 	uint16_t smbpr_coresenabled2;	/* second number of enabled cores */
174 	uint16_t smbpr_threadcount2;	/* second number of enabled threads */
175 } smb_processor_t;
176 
177 /*
178  * SMBIOS implementation structure for SMB_TYPE_CACHE.
179  */
180 typedef struct smb_cache {
181 	smb_header_t smbca_hdr;		/* structure header */
182 	uint8_t smbca_socket;		/* socket designation */
183 	uint16_t smbca_config;		/* cache configuration */
184 	uint16_t smbca_maxsize;		/* maximum installed size */
185 	uint16_t smbca_size;		/* installed size */
186 	uint16_t smbca_stype;		/* supported SRAM type */
187 	uint16_t smbca_ctype;		/* current SRAM type */
188 	uint8_t smbca_speed;		/* speed in nanoseconds */
189 	uint8_t smbca_etype;		/* error correction type */
190 	uint8_t smbca_ltype;		/* logical cache type */
191 	uint8_t smbca_assoc;		/* associativity */
192 	uint32_t smbca_maxsize2;	/* maximum installed size 2 */
193 	uint32_t smbca_size2;		/* installed size 2 */
194 } smb_cache_t;
195 
196 /*
197  * Convert encoded cache size to bytes: DSP0134 Section 7.8 explains the
198  * encoding.  The highest bit is 0 for 1k units, 1 for 64k units, and this
199  * macro decodes the value into bytes for exporting to our clients.
200  */
201 #define	SMB_CACHE_SIZE(s)	(((s) & 0x8000) ? \
202 	((uint32_t)((s) & 0x7FFF) * 64 * 1024) : ((uint32_t)(s) * 1024))
203 
204 #define	SMB_CACHE_EXT_SIZE(s)	(((s) & 0x80000000U) ?	\
205 	((uint64_t)((s) & 0x7FFFFFFFULL) * 64ULL * 1024ULL) :	\
206 	((uint64_t)(s) * 1024ULL))
207 
208 #define	SMB_CACHE_CFG_MODE(c)		(((c) >> 8) & 3)
209 #define	SMB_CACHE_CFG_ENABLED(c)	(((c) >> 7) & 1)
210 #define	SMB_CACHE_CFG_LOCATION(c)	(((c) >> 5) & 3)
211 #define	SMB_CACHE_CFG_SOCKETED(c)	(((c) >> 3) & 1)
212 #define	SMB_CACHE_CFG_LEVEL(c)		(((c) & 7) + 1)
213 
214 /*
215  * SMBIOS implementation structure for SMB_TYPE_PORT.
216  */
217 typedef struct smb_port {
218 	smb_header_t smbpo_hdr;		/* structure header */
219 	uint8_t smbpo_iref;		/* internal reference designator */
220 	uint8_t smbpo_itype;		/* internal connector type */
221 	uint8_t smbpo_eref;		/* external reference designator */
222 	uint8_t smbpo_etype;		/* external connector type */
223 	uint8_t smbpo_ptype;		/* port type */
224 } smb_port_t;
225 
226 /*
227  * SMBIOS implementation structure for SMB_TYPE_SLOT.
228  */
229 typedef struct smb_slot_peer {
230 	uint16_t smbspb_group_no;	/* segment group number */
231 	uint8_t smbspb_bus;		/* bus number */
232 	uint8_t smbspb_df;		/* device/function number */
233 	uint8_t smbspb_width;		/* electrical width */
234 } smb_slot_peer_t;
235 
236 typedef struct smb_slot {
237 	smb_header_t smbsl_hdr;		/* structure header */
238 	uint8_t smbsl_name;		/* reference designation */
239 	uint8_t smbsl_type;		/* slot type */
240 	uint8_t smbsl_width;		/* slot data bus width */
241 	uint8_t smbsl_usage;		/* current usage */
242 	uint8_t smbsl_length;		/* slot length */
243 	uint16_t smbsl_id;		/* slot ID */
244 	uint8_t smbsl_ch1;		/* slot characteristics 1 */
245 	uint8_t smbsl_ch2;		/* slot characteristics 2 */
246 	uint16_t smbsl_sg;		/* segment group number */
247 	uint8_t smbsl_bus;		/* bus number */
248 	uint8_t smbsl_df;		/* device/function number */
249 	/* Added in SMBIOS 3.2+ */
250 	uint8_t	smbsl_dbw;		/* Data bus width */
251 	uint8_t	smbsl_npeers;		/* Peer bdf groups */
252 	smb_slot_peer_t smbsl_peers[];	/* bifurcation peers */
253 } smb_slot_t;
254 
255 /*
256  * SMBIOS implementation structure for SMB_TYPE_OBDEVS.
257  */
258 typedef struct smb_obdev {
259 	uint8_t smbob_type;		/* encoded type and enable bit */
260 	uint8_t smbob_name;		/* description string */
261 } smb_obdev_t;
262 
263 #define	SMB_OBT_ENABLED		0x80	/* enable bit within smbob_type */
264 
265 /*
266  * SMBIOS implementation structure for SMB_TYPE_OEMSTR, SMB_TYPE_SYSCONFSTR,
267  * and SMB_TYPE_LANG.
268  */
269 typedef struct smb_strtab {
270 	smb_header_t smbtb_hdr;		/* structure header */
271 	uint8_t smbtb_count;		/* number of strings */
272 } smb_strtab_t;
273 
274 /*
275  * SMBIOS implementation structure for SMB_TYPE_LANG.
276  */
277 typedef struct smb_lang {
278 	smb_header_t smblang_hdr;	/* structure header */
279 	uint8_t smblang_num;		/* number of installed languages */
280 	uint8_t smblang_flags;		/* flags */
281 	uint8_t smblang_resv[15];	/* reserved for future use */
282 	uint8_t smblang_cur;		/* current language string */
283 } smb_lang_t;
284 
285 /*
286  * SMBIOS implementation structure for SMB_TYPE_EVENTLOG.
287  */
288 typedef struct smb_sel {
289 	smb_header_t smbsel_hdr;	/* structure header */
290 	uint16_t smbsel_len;		/* log area length */
291 	uint16_t smbsel_hdroff;		/* header offset */
292 	uint16_t smbsel_dataoff;	/* data offset */
293 	uint8_t smbsel_method;		/* access method */
294 	uint8_t smbsel_status;		/* status flags */
295 	uint32_t smbsel_token;		/* change token */
296 	uint32_t smbsel_addr;		/* access method address */
297 	uint8_t smbsel_format;		/* header format */
298 	uint8_t smbsel_typec;		/* number of type descriptors */
299 	uint8_t smbsel_typesz;		/* size of each type descriptor */
300 	uint8_t smbsel_typev[1];	/* array of type descriptors */
301 } smb_sel_t;
302 
303 /*
304  * SMBIOS implementation structure for SMB_TYPE_MEMARRAY.
305  */
306 typedef struct smb_memarray {
307 	smb_header_t smbmarr_hdr;	/* structure header */
308 	uint8_t smbmarr_loc;		/* location */
309 	uint8_t smbmarr_use;		/* use */
310 	uint8_t smbmarr_ecc;		/* error detect/correct mechanism */
311 	uint32_t smbmarr_cap;		/* maximum capacity */
312 	uint16_t smbmarr_err;		/* error handle */
313 	uint16_t smbmarr_ndevs;		/* number of slots or sockets */
314 	uint64_t smbmarr_extcap;	/* extended maximum capacity */
315 } smb_memarray_t;
316 
317 /*
318  * SMBIOS implementation structure for SMB_TYPE_MEMARRAYMAP.
319  */
320 typedef struct smb_memarrmap {
321 	smb_header_t smbamap_hdr;	/* structure header */
322 	uint32_t smbamap_start;		/* starting address in kilobytes */
323 	uint32_t smbamap_end;		/* ending address in kilobytes */
324 	uint16_t smbamap_array;		/* physical memory array handle */
325 	uint8_t smbamap_width;		/* partition width */
326 	uint64_t smbamap_extstart;	/* extended starting address in bytes */
327 	uint64_t smbamap_extend;	/* extended ending address in bytes */
328 } smb_memarrmap_t;
329 
330 /*
331  * SMBIOS implementation structure for SMB_TYPE_MEMDEVICE.
332  */
333 typedef struct smb_memdevice {
334 	smb_header_t smbmdev_hdr;	/* structure header */
335 	uint16_t smbmdev_array;		/* array handle */
336 	uint16_t smbmdev_error;		/* error handle */
337 	uint16_t smbmdev_twidth;	/* total width */
338 	uint16_t smbmdev_dwidth;	/* data width */
339 	uint16_t smbmdev_size;		/* size in either K or MB */
340 	uint8_t smbmdev_form;		/* form factor */
341 	uint8_t smbmdev_set;		/* device set */
342 	uint8_t smbmdev_dloc;		/* device locator */
343 	uint8_t smbmdev_bloc;		/* bank locator */
344 	uint8_t smbmdev_type;		/* memory type */
345 	uint16_t smbmdev_flags;		/* detail flags */
346 	uint16_t smbmdev_speed;		/* speed in MT/s */
347 	uint8_t smbmdev_manufacturer;	/* manufacturer */
348 	uint8_t smbmdev_serial;		/* serial number */
349 	uint8_t smbmdev_asset;		/* asset tag */
350 	uint8_t smbmdev_part;		/* part number */
351 	uint8_t smbmdev_attrs;		/* attributes */
352 	uint32_t smbmdev_extsize;	/* extended size */
353 	uint16_t smbmdev_clkspeed;	/* configured clock speed */
354 	uint16_t smbmdev_minvolt;	/* minimum voltage */
355 	uint16_t smbmdev_maxvolt;	/* maximum voltage */
356 	uint16_t smbmdev_confvolt;	/* configured voltage */
357 	/* Added in SMBIOS 3.2 */
358 	uint8_t smbmdev_memtech;	/* memory technology */
359 	uint16_t smbmdev_opmode;	/* memory operating mode capability */
360 	uint8_t smbmdev_fwver;		/* firmware version */
361 	uint16_t smbmdev_modulemfgid;	/* module manufacturer ID */
362 	uint16_t smbmdev_moduleprodid;	/* module product ID */
363 	uint16_t smbmdev_memsysmfgid;	/* memory controller manufacturer id */
364 	uint16_t smbmdev_memsysprodid;	/* memory controller product id */
365 	uint64_t smbmdev_nvsize;	/* non-volatile memory size */
366 	uint64_t smbmdev_volsize;	/* volatile memory size */
367 	uint64_t smbmdev_cachesize;	/* cache size */
368 	uint64_t smbmdev_logicalsize;	/* logical size */
369 } smb_memdevice_t;
370 
371 #define	SMB_MDS_KBYTES		0x8000	/* size in specified in kilobytes */
372 
373 /*
374  * SMBIOS implementation structure for SMB_TYPE_MEMDEVICEMAP.
375  */
376 typedef struct smb_memdevmap {
377 	smb_header_t smbdmap_hdr;	/* structure header */
378 	uint32_t smbdmap_start;		/* starting address in kilobytes */
379 	uint32_t smbdmap_end;		/* ending address in kilobytes */
380 	uint16_t smbdmap_device;	/* memory device handle */
381 	uint16_t smbdmap_array;		/* memory array mapped address handle */
382 	uint8_t smbdmap_rpos;		/* row position */
383 	uint8_t smbdmap_ipos;		/* interleave position */
384 	uint8_t smbdmap_idepth;		/* interleave depth */
385 	uint64_t smbdmap_extstart;	/* extended starting address */
386 	uint64_t smbdmap_extend;	/* extended ending address */
387 } smb_memdevmap_t;
388 
389 /*
390  * SMBIOS implementation structure for SMB_TYPE_BATTERY.
391  */
392 typedef struct smb_battery {
393 	smb_header_t smbbat_hdr;	/* structure header */
394 	uint8_t smbbat_loc;		/* location */
395 	uint8_t smbbat_manufacturer;	/* manufacturer */
396 	uint8_t smbbat_date;		/* manufacture date */
397 	uint8_t smbbat_serial;		/* serial number */
398 	uint8_t smbbat_devname;		/* device name */
399 	uint8_t smbbat_chem;		/* device chemistry */
400 	uint16_t smbbat_cap;		/* design capacity in mW hours */
401 	uint16_t smbbat_volt;		/* design voltage in mV */
402 	uint8_t smbbat_version;		/* SBDS version string */
403 	uint8_t smbbat_err;		/* error percentage */
404 	uint16_t smbbat_ssn;		/* SBDS serial number */
405 	uint16_t smbbat_sdate;		/* SBDS manufacture date */
406 	uint8_t smbbat_schem;		/* SBDS chemistry string */
407 	uint8_t smbbat_mult;		/* design capacity multiplier */
408 	uint32_t smbbat_oemdata;	/* OEM-specific data */
409 } smb_battery_t;
410 
411 /*
412  * SMBIOS implementation structure for SMB_TYPE_SECURITY.
413  */
414 typedef struct smb_hwsec {
415 	smb_header_t smbhs_hdr;		/* structure header */
416 	uint8_t smbhs_settings;		/* settings byte */
417 } smb_hwsec_t;
418 
419 #define	SMB_HWS_PWR_PS(x)	(((x) & 0xC0) >> 6)
420 #define	SMB_HWS_KBD_PS(x)	(((x) & 0x30) >> 4)
421 #define	SMB_HWS_ADM_PS(x)	(((x) & 0x0C) >> 2)
422 #define	SMB_HWS_PAN_PS(x)	(((x) & 0x03) >> 0)
423 
424 /*
425  * SMBIOS implementation structure for SMB_TYPE_VPROBE.
426  */
427 typedef struct smb_vprobe {
428 	smb_header_t smbvpr_hdr;	/* structure header */
429 	uint8_t smbvpr_descr;		/* description string */
430 	uint8_t smbvpr_locstat;		/* location and status */
431 	uint16_t smbvpr_maxval;		/* maximum voltage */
432 	uint16_t smbvpr_minval;		/* minimum voltage */
433 	uint16_t smbvpr_resolution;	/* probe resolution */
434 	uint16_t smbvpr_tolerance;	/* probe tolerance */
435 	uint16_t smbvpr_accuracy;	/* probe accuracy */
436 	uint32_t smbvpr_oem;		/* vendor-specific data */
437 	uint16_t smbvpr_nominal;	/* nominal value */
438 } smb_vprobe_t;
439 
440 #define	SMB_VPROBE_MINLEN		0x14
441 #define	SMB_VPROBE_NOMINAL_MINLEN	0x16
442 
443 #define	SMB_VPROBE_LOCATION(x)	((x) & 0x1f)
444 #define	SMB_VPROBE_STATUS(x)	(((x) >> 5) & 0x7)
445 
446 /*
447  * SMBIOS implementation structure for SMB_TYPE_COOLDEV.
448  */
449 typedef struct smb_cooldev {
450 	smb_header_t smbcdev_hdr;	/* structure header */
451 	uint16_t smbcdev_tprobe;	/* temperature probe */
452 	uint8_t smbcdev_typstat;	/* type and status */
453 	uint8_t smbcdev_group;		/* group identifier */
454 	uint32_t smbcdev_oem;		/* vendor-specific data */
455 	uint16_t smbcdev_nominal;	/* nominal value */
456 	uint8_t smbcdev_descr;		/* description string */
457 } smb_cooldev_t;
458 
459 #define	SMB_COOLDEV_MINLEN		0x0c
460 #define	SMB_COOLDEV_NOMINAL_MINLEN	0x0e
461 #define	SMB_COOLDEV_DESCR_MINLEN	0x0f
462 
463 #define	SMB_COOLDEV_TYPE(x)	((x) & 0x1f)
464 #define	SMB_COOLDEV_STATUS(x)	(((x) >> 5) & 0x7)
465 
466 /*
467  * SMBIOS implementation structure for SMB_TYPE_TPROBE.
468  */
469 typedef struct smb_tprobe {
470 	smb_header_t smbtpr_hdr;	/* structure header */
471 	uint8_t smbtpr_descr;		/* description string */
472 	uint8_t smbtpr_locstat;		/* location and status */
473 	uint16_t smbtpr_maxval;		/* maximum temperature */
474 	uint16_t smbtpr_minval;		/* minimum temperature */
475 	uint16_t smbtpr_resolution;	/* probe resolution */
476 	uint16_t smbtpr_tolerance;	/* probe tolerance */
477 	uint16_t smbtpr_accuracy;	/* probe accuracy */
478 	uint32_t smbtpr_oem;		/* vendor-specific data */
479 	uint16_t smbtpr_nominal;	/* nominal value */
480 } smb_tprobe_t;
481 
482 #define	SMB_TPROBE_MINLEN		0x14
483 #define	SMB_TPROBE_NOMINAL_MINLEN	0x16
484 
485 #define	SMB_TPROBE_LOCATION(x)	((x) & 0x1f)
486 #define	SMB_TPROBE_STATUS(x)	(((x) >> 5) & 0x7)
487 
488 /*
489  * SMBIOS implementation structure for SMB_TYPE_IPROBE.
490  */
491 typedef struct smb_iprobe {
492 	smb_header_t smbipr_hdr;	/* structure header */
493 	uint8_t smbipr_descr;		/* description string */
494 	uint8_t smbipr_locstat;		/* location and status */
495 	uint16_t smbipr_maxval;		/* maximum current */
496 	uint16_t smbipr_minval;		/* minimum current */
497 	uint16_t smbipr_resolution;	/* probe resolution */
498 	uint16_t smbipr_tolerance;	/* probe tolerance */
499 	uint16_t smbipr_accuracy;	/* probe accuracy */
500 	uint32_t smbipr_oem;		/* vendor-specific data */
501 	uint16_t smbipr_nominal;	/* nominal value */
502 } smb_iprobe_t;
503 
504 #define	SMB_IPROBE_MINLEN		0x14
505 #define	SMB_IPROBE_NOMINAL_MINLEN	0x16
506 
507 #define	SMB_IPROBE_LOCATION(x)	((x) & 0x1f)
508 #define	SMB_IPROBE_STATUS(x)	(((x) >> 5) & 0x7)
509 
510 /*
511  * SMBIOS implementation structure for SMB_TYPE_BOOT.
512  */
513 typedef struct smb_boot {
514 	smb_header_t smbbo_hdr;		/* structure header */
515 	uint8_t smbbo_pad[6];		/* reserved for future use */
516 	uint8_t smbbo_status[1];	/* variable-length status buffer */
517 } smb_boot_t;
518 
519 /*
520  * SMBIOS implementation structure for SMB_TYPE_IPMIDEV.
521  */
522 typedef struct smb_ipmi {
523 	smb_header_t smbipm_hdr;	/* structure header */
524 	uint8_t smbipm_type;		/* interface type */
525 	uint8_t smbipm_spec;		/* specification revision */
526 	uint8_t smbipm_i2c;		/* i2C slave address */
527 	uint8_t smbipm_bus;		/* NV storage device bus ID */
528 	uint64_t smbipm_addr;		/* base address */
529 	uint8_t smbipm_info;		/* base address modifier/intr info */
530 	uint8_t smbipm_intr;		/* interrupt number */
531 } smb_ipmi_t;
532 
533 #define	SMB_IPM_SPEC_MAJOR(x)	(((x) & 0xF0) >> 4)
534 #define	SMB_IPM_SPEC_MINOR(x)	((x) & 0x0F)
535 
536 #define	SMB_IPM_ADDR_IO		1ULL
537 
538 #define	SMB_IPM_INFO_REGS(x)	(((x) & 0xC0) >> 6)
539 #define	SMB_IPM_INFO_LSB(x)	(((x) & 0x10) >> 4)
540 #define	SMB_IPM_INFO_ISPEC(x)	(((x) & 0x08) >> 3)
541 #define	SMB_IPM_INFO_IPOL(x)	(((x) & 0x02) >> 1)
542 #define	SMB_IPM_INFO_IMODE(x)	(((x) & 0x01) >> 0)
543 
544 #define	SMB_IPM_REGS_1B		0
545 #define	SMB_IPM_REGS_4B		1
546 #define	SMB_IPM_REGS_16B	2
547 
548 #define	SMB_IPM_IPOL_LO		0
549 #define	SMB_IPM_IPOL_HI		1
550 
551 #define	SMB_IPM_IMODE_EDGE	0
552 #define	SMB_IPM_IMODE_LEVEL	1
553 
554 /*
555  * SMBIOS implementation structure for SMB_TYPE_POWERSUP.
556  */
557 typedef struct smb_powersup {
558 	smb_header_t smbpsup_hdr;	/* structure header */
559 	uint8_t smbpsup_group;		/* group id */
560 	uint8_t smbpsup_loc;		/* location tag */
561 	uint8_t smbpsup_devname;	/* device name */
562 	uint8_t smbpsup_manufacturer;	/* manufacturer */
563 	uint8_t smbpsup_serial;		/* serial number */
564 	uint8_t smbpsup_asset;		/* asset tag */
565 	uint8_t smbpsup_part;		/* part number */
566 	uint8_t smbpsup_rev;		/* revision string */
567 	uint16_t smbpsup_max;		/* max output in milliwatts */
568 	uint16_t smbpsup_char;		/* characteristics */
569 	uint16_t smbpsup_vprobe;	/* voltage probe handle */
570 	uint16_t smbpsup_cooldev;	/* cooling device handle */
571 	uint16_t smbpsup_iprobe;	/* current probe handle */
572 } smb_powersup_t;
573 
574 #define	SMB_PSU_CHARS_ISHOT(x)		((x) & 0x01)
575 #define	SMB_PSU_CHARS_ISPRES(x)		((x) & 0x02)
576 #define	SMB_PSU_CHARS_ISUNPLUG(x)	((x) & 0x04)
577 #define	SMB_PSU_CHARS_IVRS(x)		(((x) >> 3) & 0xf)
578 #define	SMB_PSU_CHARS_STATUS(x)		(((x) >> 7) & 0x7)
579 #define	SMB_PSU_CHARS_TYPE(x)		(((x) >> 10) & 0xf)
580 
581 /*
582  * SMBIOS implementation structure for SMB_TYPE_OBDEVEXT.
583  */
584 typedef struct smb_obdev_ext {
585 	smb_header_t smbobe_hdr;	/* structure header */
586 	uint8_t smbobe_name;		/* reference designation */
587 	uint8_t smbobe_dtype;		/* device type */
588 	uint8_t smbobe_dti;		/* device type instance */
589 	uint16_t smbobe_sg;		/* segment group number */
590 	uint8_t smbobe_bus;		/* bus number */
591 	uint8_t smbobe_df;		/* device/function number */
592 } smb_obdev_ext_t;
593 
594 /*
595  * SMBIOS implementation structure for SUN_OEM_EXT_PROCESSOR.
596  */
597 typedef struct smb_processor_ext {
598 	smb_header_t smbpre_hdr;	/* structure header */
599 	uint16_t smbpre_processor;	/* processor handle */
600 	uint8_t smbpre_fru;		/* FRU indicator */
601 	uint8_t smbpre_n;		/* number of APIC IDs */
602 	uint16_t smbpre_apicid[1];	/* strand initial apic id */
603 } smb_processor_ext_t;
604 
605 /*
606  * SMBIOS implementation structure for SUN_OEM_EXT_PORT.
607  */
608 typedef struct smb_port_ext {
609 	smb_header_t smbpoe_hdr;	/* structure header */
610 	uint16_t smbpoe_chassis;	/* chassis handle */
611 	uint16_t smbpoe_port;		/* port connector handle */
612 	uint8_t smbpoe_dtype;		/* device type */
613 	uint16_t smbpoe_devhdl;		/* device handle */
614 	uint8_t smbpoe_phy;		/* PHY number */
615 } smb_port_ext_t;
616 
617 /*
618  * SMBIOS implementation structure for SUN_OEM_PCIEXRC.
619  */
620 typedef struct smb_pciexrc {
621 	smb_header_t smbpciexrc_hdr;	/* structure header */
622 	uint16_t smbpciexrc_bboard;	/* base board handle */
623 	uint16_t smbpciexrc_bdf;	/* PCI Bus/Dev/Func */
624 } smb_pciexrc_t;
625 
626 /*
627  * SMBIOS implementation structure for SUN_OEM_EXT_MEMARRAY.
628  */
629 typedef struct smb_memarray_ext {
630 	smb_header_t smbmarre_hdr;	/* structure header */
631 	uint16_t smbmarre_ma;		/* memory array handle */
632 	uint16_t smbmarre_component;	/* component parent handle */
633 	uint16_t smbmarre_bdf;		/* PCI bus/dev/funct */
634 } smb_memarray_ext_t;
635 
636 /*
637  * SMBIOS implementation structure for SUN_OEM_EXT_MEMDEVICE.
638  */
639 typedef struct smb_memdevice_ext {
640 	smb_header_t smbmdeve_hdr;	/* structure header */
641 	uint16_t smbmdeve_mdev;		/* memory device handle */
642 	uint8_t smbmdeve_dchan;		/* DRAM channel */
643 	uint8_t smbmdeve_ncs;		/* number of chip select */
644 	uint8_t smbmdeve_cs[1];		/* chip selects */
645 } smb_memdevice_ext_t;
646 
647 #pragma pack()
648 
649 typedef struct smb_struct {
650 	const smb_header_t *smbst_hdr;	/* address of raw structure data */
651 	const uchar_t *smbst_str;	/* address of string data (if any) */
652 	const uchar_t *smbst_end;	/* address of 0x0000 ending tag */
653 	struct smb_struct *smbst_next;	/* next structure in hash chain */
654 	uint16_t *smbst_strtab;		/* string index -> offset table */
655 	uint_t smbst_strtablen;		/* length of smbst_strtab */
656 } smb_struct_t;
657 
658 struct smbios_hdl {
659 	smbios_entry_point_t sh_ent_type; /* structure table entry point type */
660 	smbios_entry_t sh_ent;		/* structure table entry point */
661 	uint_t sh_ent_stnum;		/* number of structure table entries */
662 	const void *sh_buf;		/* structure table buffer */
663 	size_t sh_buflen;		/* size of structure table buffer */
664 	smb_struct_t *sh_structs;	/* array of structure descriptors */
665 	uint_t sh_nstructs;		/* number of active structures */
666 	smb_struct_t **sh_hash;		/* hash bucket array for descriptors */
667 	uint_t sh_hashlen;		/* hash bucket array length */
668 	int sh_err;			/* error code for smbios_errno() */
669 	int sh_libvers;			/* library client abi version */
670 	int sh_smbvers;			/* derived underlying format version */
671 	uint_t sh_flags;		/* miscellaneous flags (see below) */
672 };
673 
674 #define	SMB_FL_DEBUG	0x1		/* print debug messages for this hdl */
675 #define	SMB_FL_BUFALLOC	0x2		/* sh_buf was allocated by library */
676 #define	SMB_FL_TRUNC	0x4		/* smbios table is truncated */
677 
678 #define	SMB_BIOS_DEVICE		"/dev/xsvc"	/* device w/ BIOS physmem */
679 #define	SMB_SMBIOS_DEVICE	"/dev/smbios"	/* device w/ SMBIOS image */
680 
681 #define	SMB_RANGE_START	0xF0000		/* start of physical address range */
682 #define	SMB_RANGE_LIMIT	0xFFFFF		/* limit of physical address range */
683 #define	SMB_SCAN_STEP	16		/* stepping by paragraph */
684 
685 #define	SMB_MAJMIN(M, m)	((((M) & 0xFF) << 8) | ((m) & 0xFF))
686 #define	SMB_MAJOR(v)		(((v) & 0xFF00) >> 8)
687 #define	SMB_MINOR(v)		(((v) & 0x00FF))
688 
689 #define	ESMB_BASE	1000		/* base value for libsmbios errnos */
690 
691 enum {
692 	ESMB_NOTFOUND = ESMB_BASE,	/* SMBIOS table not found on system */
693 	ESMB_MAPDEV,			/* failed to map SMBIOS table */
694 	ESMB_NOENT,			/* failed to locate structure */
695 	ESMB_NOMEM,			/* failed to allocate memory */
696 	ESMB_NOHDR,			/* failed to read SMBIOS header */
697 	ESMB_NOSTAB,			/* failed to read SMBIOS struct table */
698 	ESMB_NOINFO,			/* no common info for structure */
699 	ESMB_SHORT,			/* buffer length doesn't match header */
700 	ESMB_CORRUPT,			/* buffer struct or len is corrupt */
701 	ESMB_VERSION,			/* version not supported by library */
702 	ESMB_NOTSUP,			/* feature not supported by provider */
703 	ESMB_HEADER,			/* SMBIOS header corrupt or invalid */
704 	ESMB_OLD,			/* SMBIOS version is too old for us */
705 	ESMB_NEW,			/* SMBIOS version is too new for us */
706 	ESMB_CKSUM,			/* SMBIOS header checksum mismatch */
707 	ESMB_INVAL,			/* invalid function call argument */
708 	ESMB_TYPE,			/* structure type mismatch */
709 	ESMB_UNKNOWN			/* unknown error (maximum value tag) */
710 };
711 
712 extern const smb_struct_t *smb_lookup_type(smbios_hdl_t *, uint_t);
713 extern const smb_struct_t *smb_lookup_id(smbios_hdl_t *, uint_t);
714 extern const char *smb_strptr(const smb_struct_t *, uint_t);
715 extern int smb_gteq(smbios_hdl_t *, int);
716 extern int smb_libgteq(smbios_hdl_t *, int);
717 
718 extern int smb_set_errno(smbios_hdl_t *, int);
719 extern smbios_hdl_t *smb_open_error(smbios_hdl_t *, int *, int);
720 extern const char *smb_strerror(int);
721 
722 extern void *smb_alloc(size_t);
723 extern void *smb_zalloc(size_t);
724 extern void smb_free(void *, size_t);
725 
726 extern void smb_dprintf(smbios_hdl_t *, const char *, ...);
727 
728 extern int _smb_debug;
729 
730 /*
731  * The following series of structures represent the base versions of public
732  * structures that are used inside by the smbios routines. This allows the
733  * common code to properly know how much it should or should not bzero and how
734  * to handle additions to the spec. Types should only be added here if we need
735  * to extend the public structures in sys/smbios.h due to a change in the spec.
736  *
737  * Types here have the name smb_base_%s which corresponds to smbios_%s.
738  */
739 typedef struct smb_base_chassis {
740 	uint32_t smbbc_oemdata;		/* OEM-specific data */
741 	uint8_t smbbc_lock;		/* lock present? */
742 	uint8_t smbbc_type;		/* type */
743 	uint8_t smbbc_bustate;		/* boot-up state */
744 	uint8_t smbbc_psstate;		/* power supply state */
745 	uint8_t smbbc_thstate;		/* thermal state */
746 	uint8_t smbbc_security;		/* security status */
747 	uint8_t smbbc_uheight;		/* enclosure height in U's */
748 	uint8_t smbbc_cords;		/* number of power cords */
749 	uint8_t smbbc_elems;		/* number of element records (n) */
750 	uint8_t smbbc_elemlen;		/* length of contained element (m) */
751 } smb_base_chassis_t;
752 
753 typedef struct smb_base_processor {
754 	uint64_t smbbp_cpuid;		/* processor cpuid information */
755 	uint32_t smbbp_family;		/* processor family */
756 	uint8_t smbbp_type;		/* processor type (SMB_PRT_*) */
757 	uint8_t smbbp_voltage;		/* voltage (SMB_PRV_*) */
758 	uint8_t smbbp_status;		/* status (SMB_PRS_*) */
759 	uint8_t smbbp_upgrade;		/* upgrade (SMB_PRU_*) */
760 	uint32_t smbbp_clkspeed;	/* external clock speed in MHz */
761 	uint32_t smbbp_maxspeed;	/* maximum speed in MHz */
762 	uint32_t smbbp_curspeed;	/* current speed in MHz */
763 	id_t smbbp_l1cache;		/* L1 cache handle */
764 	id_t smbbp_l2cache;		/* L2 cache handle */
765 	id_t smbbp_l3cache;		/* L3 cache handle */
766 } smb_base_processor_t;
767 
768 typedef struct smb_base_memdevice {
769 	id_t smbbmd_array;		/* handle of physical memory array */
770 	id_t smbbmd_error;		/* handle of memory error data */
771 	uint32_t smbbmd_twidth;		/* total width in bits including ecc */
772 	uint32_t smbbmd_dwidth;		/* data width in bits */
773 	uint64_t smbbmd_size;		/* size in bytes (see note above) */
774 	uint8_t smbbmd_form;		/* form factor */
775 	uint8_t smbbmd_set;		/* set (0x00=none, 0xFF=unknown) */
776 	uint8_t smbbmd_type;		/* memory type */
777 	uint8_t smbbmd_pad;		/* padding */
778 	uint32_t smbbmd_flags;		/* flags (see below) */
779 	uint32_t smbbmd_speed;		/* speed in MHz */
780 	const char *smbbmd_dloc;	/* physical device locator string */
781 	const char *smbbmd_bloc;	/* physical bank locator string */
782 	uint8_t smbbmd_rank;		/* rank */
783 } smb_base_memdevice_t;
784 
785 typedef struct smb_base_bios {
786 	const char *smbbb_vendor;	/* bios vendor string */
787 	const char *smbbb_version;	/* bios version string */
788 	const char *smbbb_reldate;	/* bios release date */
789 	uint32_t smbbb_segment;		/* bios address segment location */
790 	uint32_t smbbb_romsize;		/* bios rom size in bytes */
791 	uint32_t smbbb_runsize;		/* bios image size in bytes */
792 	uint64_t smbbb_cflags;		/* bios characteristics */
793 	const uint8_t *smbbb_xcflags;	/* bios characteristics extensions */
794 	size_t smbbb_nxcflags;		/* number of smbb_xcflags[] bytes */
795 	smbios_version_t smbbb_biosv;	/* bios version */
796 	smbios_version_t smbbb_ecfwv;	/* bios embedded ctrl f/w version */
797 } smb_base_bios_t;
798 
799 typedef struct smb_base_cache {
800 	uint32_t smbba_maxsize;		/* maximum installed size in bytes */
801 	uint32_t smbba_size;		/* installed size in bytes */
802 	uint16_t smbba_stype;		/* supported SRAM types (SMB_CAT_*) */
803 	uint16_t smbba_ctype;		/* current SRAM type (SMB_CAT_*) */
804 	uint8_t smbba_speed;		/* speed in nanoseconds */
805 	uint8_t smbba_etype;		/* error correction type (SMB_CAE_*) */
806 	uint8_t smbba_ltype;		/* logical cache type (SMB_CAG_*) */
807 	uint8_t smbba_assoc;		/* associativity (SMB_CAA_*) */
808 	uint8_t smbba_level;		/* cache level */
809 	uint8_t smbba_mode;		/* cache mode (SMB_CAM_*) */
810 	uint8_t smbba_location;		/* cache location (SMB_CAL_*) */
811 	uint8_t smbba_flags;		/* cache flags (SMB_CAF_*) */
812 } smb_base_cache_t;
813 
814 typedef struct smb_base_slot {
815 	const char *smbbl_name;		/* reference designation */
816 	uint8_t smbbl_type;		/* slot type */
817 	uint8_t smbbl_width;		/* slot data bus width */
818 	uint8_t smbbl_usage;		/* current usage */
819 	uint8_t smbbl_length;		/* slot length */
820 	uint16_t smbbl_id;		/* slot ID */
821 	uint8_t smbbl_ch1;		/* slot characteristics 1 */
822 	uint8_t smbbl_ch2;		/* slot characteristics 2 */
823 	uint16_t smbbl_sg;		/* segment group number */
824 	uint8_t smbbl_bus;		/* bus number */
825 	uint8_t smbbl_df;		/* device/function number */
826 } smb_base_slot_t;
827 
828 #ifdef	__cplusplus
829 }
830 #endif
831 
832 #endif	/* _SYS_SMBIOS_IMPL_H */
833