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