Print this page
SKU fix for 5094
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/common/smbios/smb_info.c
+++ new/usr/src/common/smbios/smb_info.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
24 24 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 */
27 27
28 28 /*
29 29 * SMBIOS Information Routines
30 30 *
31 31 * The routines in this file are used to convert from the SMBIOS data format to
32 32 * a more reasonable and stable set of structures offered as part of our ABI.
33 33 * These functions take the general form:
34 34 *
35 35 * stp = smb_lookup_type(shp, foo);
36 36 * smb_foo_t foo;
37 37 *
38 38 * smb_info_bcopy(stp->smbst_hdr, &foo, sizeof (foo));
39 39 * bzero(caller's struct);
40 40 *
41 41 * copy/convert foo members into caller's struct
42 42 *
43 43 * We copy the internal structure on to an automatic variable so as to avoid
44 44 * checks everywhere for structures that the BIOS has improperly truncated, and
45 45 * also to automatically handle the case of a structure that has been extended.
46 46 * When necessary, this code can use smb_gteq() to determine whether the SMBIOS
47 47 * data is of a particular revision that is supposed to contain a new field.
48 48 */
49 49
50 50 #include <sys/smbios_impl.h>
51 51
52 52 #ifdef _KERNEL
53 53 #include <sys/sunddi.h>
54 54 #else
55 55 #include <fcntl.h>
56 56 #include <unistd.h>
57 57 #include <string.h>
58 58 #endif
59 59
60 60 /*
61 61 * A large number of SMBIOS structures contain a set of common strings used to
62 62 * describe a h/w component's serial number, manufacturer, etc. These fields
63 63 * helpfully have different names and offsets and sometimes aren't consistent.
64 64 * To simplify life for our clients, we factor these common things out into
65 65 * smbios_info_t, which can be retrieved for any structure. The following
66 66 * table describes the mapping from a given structure to the smbios_info_t.
67 67 * Multiple SMBIOS stuctures' contained objects are also handled here.
68 68 */
69 69 static const struct smb_infospec {
70 70 uint8_t is_type; /* structure type */
71 71 uint8_t is_manu; /* manufacturer offset */
72 72 uint8_t is_product; /* product name offset */
73 73 uint8_t is_version; /* version offset */
74 74 uint8_t is_serial; /* serial number offset */
75 75 uint8_t is_asset; /* asset tag offset */
76 76 uint8_t is_location; /* location string offset */
77 77 uint8_t is_part; /* part number offset */
78 78 uint8_t is_contc; /* contained count */
79 79 uint8_t is_contsz; /* contained size */
80 80 uint8_t is_contv; /* contained objects */
81 81 } _smb_infospecs[] = {
82 82 { SMB_TYPE_SYSTEM,
83 83 offsetof(smb_system_t, smbsi_manufacturer),
84 84 offsetof(smb_system_t, smbsi_product),
85 85 offsetof(smb_system_t, smbsi_version),
86 86 offsetof(smb_system_t, smbsi_serial),
87 87 0,
88 88 0,
89 89 0,
90 90 0,
91 91 0,
92 92 0 },
93 93 { SMB_TYPE_BASEBOARD,
94 94 offsetof(smb_bboard_t, smbbb_manufacturer),
95 95 offsetof(smb_bboard_t, smbbb_product),
96 96 offsetof(smb_bboard_t, smbbb_version),
97 97 offsetof(smb_bboard_t, smbbb_serial),
98 98 offsetof(smb_bboard_t, smbbb_asset),
99 99 offsetof(smb_bboard_t, smbbb_location),
100 100 0,
101 101 offsetof(smb_bboard_t, smbbb_cn),
102 102 SMB_CONT_WORD,
103 103 offsetof(smb_bboard_t, smbbb_cv) },
104 104 { SMB_TYPE_CHASSIS,
105 105 offsetof(smb_chassis_t, smbch_manufacturer),
106 106 0,
107 107 offsetof(smb_chassis_t, smbch_version),
108 108 offsetof(smb_chassis_t, smbch_serial),
109 109 offsetof(smb_chassis_t, smbch_asset),
110 110 0,
111 111 0,
112 112 offsetof(smb_chassis_t, smbch_cn),
113 113 SMB_CONT_BYTE,
114 114 offsetof(smb_chassis_t, smbch_cv) },
115 115 { SMB_TYPE_PROCESSOR,
116 116 offsetof(smb_processor_t, smbpr_manufacturer),
117 117 0,
118 118 offsetof(smb_processor_t, smbpr_version),
119 119 offsetof(smb_processor_t, smbpr_serial),
120 120 offsetof(smb_processor_t, smbpr_asset),
121 121 offsetof(smb_processor_t, smbpr_socket),
122 122 offsetof(smb_processor_t, smbpr_part),
123 123 0,
124 124 0,
125 125 0 },
126 126 { SMB_TYPE_CACHE,
127 127 0,
128 128 0,
129 129 0,
130 130 0,
131 131 0,
132 132 offsetof(smb_cache_t, smbca_socket),
133 133 0,
134 134 0,
135 135 0,
136 136 0 },
137 137 { SMB_TYPE_PORT,
138 138 0,
139 139 0,
140 140 0,
141 141 0,
142 142 0,
143 143 offsetof(smb_port_t, smbpo_iref),
144 144 0,
145 145 0,
146 146 0,
147 147 0 },
148 148 { SMB_TYPE_SLOT,
149 149 0,
150 150 0,
151 151 0,
152 152 0,
153 153 0,
154 154 offsetof(smb_slot_t, smbsl_name),
155 155 0,
156 156 0,
157 157 0,
158 158 0 },
159 159 { SMB_TYPE_MEMDEVICE,
160 160 offsetof(smb_memdevice_t, smbmdev_manufacturer),
161 161 0,
162 162 0,
163 163 offsetof(smb_memdevice_t, smbmdev_serial),
164 164 offsetof(smb_memdevice_t, smbmdev_asset),
165 165 offsetof(smb_memdevice_t, smbmdev_dloc),
166 166 offsetof(smb_memdevice_t, smbmdev_part),
167 167 0,
168 168 0,
169 169 0 },
170 170 { SMB_TYPE_POWERSUP,
171 171 offsetof(smb_powersup_t, smbpsup_manufacturer),
172 172 offsetof(smb_powersup_t, smbpsup_devname),
173 173 offsetof(smb_powersup_t, smbpsup_rev),
174 174 offsetof(smb_powersup_t, smbpsup_serial),
175 175 offsetof(smb_powersup_t, smbpsup_asset),
176 176 offsetof(smb_powersup_t, smbpsup_loc),
177 177 offsetof(smb_powersup_t, smbpsup_part),
178 178 0,
179 179 0,
180 180 0 },
181 181 { SMB_TYPE_EOT }
182 182 };
183 183
184 184 static const char *
185 185 smb_info_strptr(const smb_struct_t *stp, uint8_t off, int *n)
186 186 {
187 187 const uint8_t *sp = (const uint8_t *)(uintptr_t)stp->smbst_hdr;
188 188
189 189 if (off != 0 && sp + off < stp->smbst_end) {
190 190 (*n)++; /* indicate success for caller */
191 191 return (smb_strptr(stp, sp[off]));
192 192 }
193 193
194 194 return (smb_strptr(stp, 0));
195 195 }
196 196
197 197 static void
198 198 smb_info_bcopy(const smb_header_t *hp, void *dst, size_t dstlen)
199 199 {
200 200 if (dstlen > hp->smbh_len) {
201 201 bcopy(hp, dst, hp->smbh_len);
202 202 bzero((char *)dst + hp->smbh_len, dstlen - hp->smbh_len);
203 203 } else
204 204 bcopy(hp, dst, dstlen);
205 205 }
206 206
207 207 void
208 208 smbios_info_smbios(smbios_hdl_t *shp, smbios_entry_t *ep)
209 209 {
210 210 bcopy(&shp->sh_ent, ep, sizeof (smbios_entry_t));
211 211 }
212 212
213 213 #ifndef _KERNEL
214 214 static char smbios_product_override[256];
215 215 static boolean_t smbios_product_checked;
216 216 #endif
217 217
218 218 int
219 219 smbios_info_common(smbios_hdl_t *shp, id_t id, smbios_info_t *ip)
220 220 {
221 221 const smb_struct_t *stp = smb_lookup_id(shp, id);
222 222 const struct smb_infospec *isp;
223 223 int n = 0;
224 224
225 225 if (stp == NULL)
226 226 return (-1); /* errno is set for us */
227 227
228 228 for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
229 229 if (isp->is_type == stp->smbst_hdr->smbh_type)
230 230 break;
231 231 }
232 232
233 233 ip->smbi_manufacturer = smb_info_strptr(stp, isp->is_manu, &n);
234 234 ip->smbi_product = smb_info_strptr(stp, isp->is_product, &n);
235 235 ip->smbi_version = smb_info_strptr(stp, isp->is_version, &n);
236 236 ip->smbi_serial = smb_info_strptr(stp, isp->is_serial, &n);
237 237 ip->smbi_asset = smb_info_strptr(stp, isp->is_asset, &n);
238 238 ip->smbi_location = smb_info_strptr(stp, isp->is_location, &n);
239 239 ip->smbi_part = smb_info_strptr(stp, isp->is_part, &n);
240 240
241 241 /*
242 242 * This private file allows developers to experiment with reporting
243 243 * different platform strings from SMBIOS. It is not a supported
244 244 * mechanism in the long term, and does not work in the kernel.
245 245 */
246 246 #ifndef _KERNEL
247 247 if (isp->is_type == SMB_TYPE_SYSTEM) {
248 248 if (!smbios_product_checked) {
249 249 int fd = open("/etc/smbios_product", O_RDONLY);
250 250 if (fd >= 0) {
251 251 (void) read(fd, smbios_product_override,
252 252 sizeof (smbios_product_override) - 1);
253 253 (void) close(fd);
254 254 }
255 255 smbios_product_checked = B_TRUE;
256 256 }
257 257
258 258 if (smbios_product_override[0] != '\0')
259 259 ip->smbi_product = smbios_product_override;
260 260 }
261 261 #endif
262 262
263 263 /*
264 264 * If we have a port with an empty internal reference designator string
265 265 * try using the external reference designator string instead.
266 266 */
267 267 if (isp->is_type == SMB_TYPE_PORT && ip->smbi_location[0] == '\0') {
268 268 ip->smbi_location = smb_info_strptr(stp,
269 269 offsetof(smb_port_t, smbpo_eref), &n);
270 270 }
271 271
272 272 return (n ? 0 : smb_set_errno(shp, ESMB_NOINFO));
273 273 }
274 274
275 275 /*
276 276 * Returns the actual number of contained objects.
277 277 *
278 278 * idc - number of contained objects
279 279 * idv - returned array of contained objects
280 280 */
281 281 int
282 282 smbios_info_contains(smbios_hdl_t *shp, id_t id, uint_t idc, id_t *idv)
283 283 {
284 284 const smb_struct_t *stp = smb_lookup_id(shp, id);
285 285 const struct smb_infospec *isp;
286 286 id_t *cp;
287 287 uint_t size;
288 288 uint8_t cnt;
289 289 int i, n;
290 290
291 291 if (stp == NULL) {
292 292 return (-1); /* errno is set for us */
293 293 }
294 294
295 295 for (isp = _smb_infospecs; isp->is_type != SMB_TYPE_EOT; isp++) {
296 296 if (isp->is_type == stp->smbst_hdr->smbh_type)
297 297 break;
298 298 }
299 299 if (isp->is_type == SMB_TYPE_EOT)
300 300 return (smb_set_errno(shp, ESMB_TYPE));
301 301
302 302 size = isp->is_contsz;
303 303 cnt = *((uint8_t *)(uintptr_t)stp->smbst_hdr + isp->is_contc);
304 304 cp = (id_t *)((uintptr_t)stp->smbst_hdr + isp->is_contv);
305 305
306 306 n = MIN(cnt, idc);
307 307 for (i = 0; i < n; i++) {
308 308 if (size == SMB_CONT_WORD)
309 309 idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 2));
310 310 else if (size == SMB_CONT_BYTE)
311 311 idv[i] = *((uint8_t *)(uintptr_t)cp + (i * 3));
312 312 else
313 313 return (smb_set_errno(shp, ESMB_INVAL));
314 314 }
315 315
316 316 return (cnt);
317 317 }
318 318
319 319 id_t
320 320 smbios_info_bios(smbios_hdl_t *shp, smbios_bios_t *bp)
321 321 {
322 322 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BIOS);
323 323 const smb_bios_t *bip;
324 324
325 325 if (stp == NULL)
326 326 return (-1); /* errno is set for us */
327 327
328 328 if (stp->smbst_hdr->smbh_len < sizeof (smb_bios_t) - sizeof (uint8_t))
329 329 return (smb_set_errno(shp, ESMB_CORRUPT));
330 330
331 331 bip = (smb_bios_t *)(uintptr_t)stp->smbst_hdr;
332 332 bzero(bp, sizeof (smbios_bios_t));
333 333
334 334 bp->smbb_vendor = smb_strptr(stp, bip->smbbi_vendor);
335 335 bp->smbb_version = smb_strptr(stp, bip->smbbi_version);
336 336 bp->smbb_segment = bip->smbbi_segment;
337 337 bp->smbb_reldate = smb_strptr(stp, bip->smbbi_reldate);
338 338 bp->smbb_romsize = 64 * 1024 * ((uint32_t)bip->smbbi_romsize + 1);
339 339 bp->smbb_runsize = 16 * (0x10000 - (uint32_t)bip->smbbi_segment);
340 340 bp->smbb_cflags = bip->smbbi_cflags;
341 341
342 342 /*
343 343 * If one or more extension bytes are present, reset smbb_xcflags to
344 344 * point to them. Otherwise leave this member set to NULL.
345 345 */
346 346 if (stp->smbst_hdr->smbh_len >= sizeof (smb_bios_t)) {
347 347 bp->smbb_xcflags = bip->smbbi_xcflags;
348 348 bp->smbb_nxcflags = stp->smbst_hdr->smbh_len -
349 349 sizeof (smb_bios_t) + 1;
350 350
351 351 if (bp->smbb_nxcflags > SMB_BIOSXB_ECFW_MIN &&
352 352 smb_gteq(shp, SMB_VERSION_24)) {
353 353 bp->smbb_biosv.smbv_major =
354 354 bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MAJ];
355 355 bp->smbb_biosv.smbv_minor =
356 356 bip->smbbi_xcflags[SMB_BIOSXB_BIOS_MIN];
357 357 bp->smbb_ecfwv.smbv_major =
358 358 bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MAJ];
359 359 bp->smbb_ecfwv.smbv_minor =
360 360 bip->smbbi_xcflags[SMB_BIOSXB_ECFW_MIN];
361 361 }
362 362 }
363 363
364 364 return (stp->smbst_hdr->smbh_hdl);
365 365 }
366 366
367 367 id_t
368 368 smbios_info_system(smbios_hdl_t *shp, smbios_system_t *sip)
369 369 {
370 370 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM);
371 371 smb_system_t si;
372 372
373 373 if (stp == NULL)
374 374 return (-1); /* errno is set for us */
375 375
376 376 smb_info_bcopy(stp->smbst_hdr, &si, sizeof (si));
377 377 bzero(sip, sizeof (smbios_system_t));
378 378
379 379 sip->smbs_uuid = ((smb_system_t *)stp->smbst_hdr)->smbsi_uuid;
380 380 sip->smbs_uuidlen = sizeof (si.smbsi_uuid);
381 381 sip->smbs_wakeup = si.smbsi_wakeup;
382 382 sip->smbs_sku = smb_strptr(stp, si.smbsi_sku);
383 383 sip->smbs_family = smb_strptr(stp, si.smbsi_family);
384 384
385 385 return (stp->smbst_hdr->smbh_hdl);
386 386 }
387 387
388 388 int
389 389 smbios_info_bboard(smbios_hdl_t *shp, id_t id, smbios_bboard_t *bbp)
390 390 {
391 391 const smb_struct_t *stp = smb_lookup_id(shp, id);
392 392 smb_bboard_t bb;
393 393
394 394 if (stp == NULL)
395 395 return (-1); /* errno is set for us */
396 396
397 397 if (stp->smbst_hdr->smbh_type != SMB_TYPE_BASEBOARD)
398 398 return (smb_set_errno(shp, ESMB_TYPE));
399 399
400 400 smb_info_bcopy(stp->smbst_hdr, &bb, sizeof (bb));
401 401 bzero(bbp, sizeof (smbios_bboard_t));
402 402
403 403 bbp->smbb_chassis = bb.smbbb_chassis;
404 404 bbp->smbb_flags = bb.smbbb_flags;
|
↓ open down ↓ |
404 lines elided |
↑ open up ↑ |
405 405 bbp->smbb_type = bb.smbbb_type;
406 406 bbp->smbb_contn = bb.smbbb_cn;
407 407
408 408 return (0);
409 409 }
410 410
411 411 int
412 412 smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp)
413 413 {
414 414 const smb_struct_t *stp = smb_lookup_id(shp, id);
415 - smb_chassis_t ch;
415 + /* Length is measurable by one byte, so it'll be no more than 255. */
416 + uint8_t buf[256]
417 + smb_chassis_t *ch = (smb_chassis_t *)&(buf[0]);
416 418
417 419 if (stp == NULL)
418 420 return (-1); /* errno is set for us */
419 421
420 422 if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS)
421 423 return (smb_set_errno(shp, ESMB_TYPE));
422 424
423 - smb_info_bcopy(stp->smbst_hdr, &ch, sizeof (ch));
425 + smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf));
424 426 bzero(chp, sizeof (smbios_chassis_t));
425 427
426 - chp->smbc_oemdata = ch.smbch_oemdata;
427 - chp->smbc_lock = (ch.smbch_type & SMB_CHT_LOCK) != 0;
428 - chp->smbc_type = ch.smbch_type & ~SMB_CHT_LOCK;
429 - chp->smbc_bustate = ch.smbch_bustate;
430 - chp->smbc_psstate = ch.smbch_psstate;
431 - chp->smbc_thstate = ch.smbch_thstate;
432 - chp->smbc_security = ch.smbch_security;
433 - chp->smbc_uheight = ch.smbch_uheight;
434 - chp->smbc_cords = ch.smbch_cords;
435 - chp->smbc_elems = ch.smbch_cn;
436 - chp->smbc_elemlen = ch.smbch_cm;
428 + chp->smbc_oemdata = ch->smbch_oemdata;
429 + chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0;
430 + chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK;
431 + chp->smbc_bustate = ch->smbch_bustate;
432 + chp->smbc_psstate = ch->smbch_psstate;
433 + chp->smbc_thstate = ch->smbch_thstate;
434 + chp->smbc_security = ch->smbch_security;
435 + chp->smbc_uheight = ch->smbch_uheight;
436 + chp->smbc_cords = ch->smbch_cords;
437 + chp->smbc_elems = ch->smbch_cn;
438 + chp->smbc_elemlen = ch->smbch_cm;
437 439
438 - if (shp->sh_smbvers >= SMB_VERSION_27)
439 - chp->smbc_sku = smb_strptr(stp, ch.smbch_sku);
440 + if (shp->sh_smbvers >= SMB_VERSION_27) {
441 + (void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch),
442 + sizeof (chp->smbc_sku));
443 + }
440 444
441 445 return (0);
442 446 }
443 447
444 448 int
445 449 smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp)
446 450 {
447 451 const smb_struct_t *stp = smb_lookup_id(shp, id);
448 452 smb_processor_t p;
449 453
450 454 if (stp == NULL)
451 455 return (-1); /* errno is set for us */
452 456
453 457 if (stp->smbst_hdr->smbh_type != SMB_TYPE_PROCESSOR)
454 458 return (smb_set_errno(shp, ESMB_TYPE));
455 459
456 460 smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
457 461 bzero(pp, sizeof (smbios_processor_t));
458 462
459 463 pp->smbp_cpuid = p.smbpr_cpuid;
460 464 pp->smbp_type = p.smbpr_type;
461 465 pp->smbp_family = p.smbpr_family;
462 466 pp->smbp_voltage = p.smbpr_voltage;
463 467 pp->smbp_maxspeed = p.smbpr_maxspeed;
464 468 pp->smbp_curspeed = p.smbpr_curspeed;
465 469 pp->smbp_status = p.smbpr_status;
466 470 pp->smbp_upgrade = p.smbpr_upgrade;
467 471 pp->smbp_l1cache = p.smbpr_l1cache;
468 472 pp->smbp_l2cache = p.smbpr_l2cache;
469 473 pp->smbp_l3cache = p.smbpr_l3cache;
470 474
471 475 if (shp->sh_smbvers >= SMB_VERSION_25) {
472 476 pp->smbp_corecount = p.smbpr_corecount;
473 477 pp->smbp_coresenabled = p.smbpr_coresenabled;
474 478 pp->smbp_threadcount = p.smbpr_threadcount;
475 479 pp->smbp_cflags = p.smbpr_cflags;
476 480 }
477 481
478 482 if (shp->sh_smbvers >= SMB_VERSION_26)
479 483 pp->smbp_family2 = p.smbpr_family2;
480 484
481 485 return (0);
482 486 }
483 487
484 488 int
485 489 smbios_info_cache(smbios_hdl_t *shp, id_t id, smbios_cache_t *cap)
486 490 {
487 491 const smb_struct_t *stp = smb_lookup_id(shp, id);
488 492 smb_cache_t c;
489 493
490 494 if (stp == NULL)
491 495 return (-1); /* errno is set for us */
492 496
493 497 if (stp->smbst_hdr->smbh_type != SMB_TYPE_CACHE)
494 498 return (smb_set_errno(shp, ESMB_TYPE));
495 499
496 500 smb_info_bcopy(stp->smbst_hdr, &c, sizeof (c));
497 501 bzero(cap, sizeof (smbios_cache_t));
498 502
499 503 cap->smba_maxsize = SMB_CACHE_SIZE(c.smbca_maxsize);
500 504 cap->smba_size = SMB_CACHE_SIZE(c.smbca_size);
501 505 cap->smba_stype = c.smbca_stype;
502 506 cap->smba_ctype = c.smbca_ctype;
503 507 cap->smba_speed = c.smbca_speed;
504 508 cap->smba_etype = c.smbca_etype;
505 509 cap->smba_ltype = c.smbca_ltype;
506 510 cap->smba_assoc = c.smbca_assoc;
507 511 cap->smba_level = SMB_CACHE_CFG_LEVEL(c.smbca_config);
508 512 cap->smba_mode = SMB_CACHE_CFG_MODE(c.smbca_config);
509 513 cap->smba_location = SMB_CACHE_CFG_LOCATION(c.smbca_config);
510 514
511 515 if (SMB_CACHE_CFG_ENABLED(c.smbca_config))
512 516 cap->smba_flags |= SMB_CAF_ENABLED;
513 517
514 518 if (SMB_CACHE_CFG_SOCKETED(c.smbca_config))
515 519 cap->smba_flags |= SMB_CAF_SOCKETED;
516 520
517 521 return (0);
518 522 }
519 523
520 524 int
521 525 smbios_info_port(smbios_hdl_t *shp, id_t id, smbios_port_t *pop)
522 526 {
523 527 const smb_struct_t *stp = smb_lookup_id(shp, id);
524 528 smb_port_t p;
525 529
526 530 if (stp == NULL)
527 531 return (-1); /* errno is set for us */
528 532
529 533 if (stp->smbst_hdr->smbh_type != SMB_TYPE_PORT)
530 534 return (smb_set_errno(shp, ESMB_TYPE));
531 535
532 536 smb_info_bcopy(stp->smbst_hdr, &p, sizeof (p));
533 537 bzero(pop, sizeof (smbios_port_t));
534 538
535 539 pop->smbo_iref = smb_strptr(stp, p.smbpo_iref);
536 540 pop->smbo_eref = smb_strptr(stp, p.smbpo_eref);
537 541
538 542 pop->smbo_itype = p.smbpo_itype;
539 543 pop->smbo_etype = p.smbpo_etype;
540 544 pop->smbo_ptype = p.smbpo_ptype;
541 545
542 546 return (0);
543 547 }
544 548
545 549 int
546 550 smbios_info_slot(smbios_hdl_t *shp, id_t id, smbios_slot_t *sp)
547 551 {
548 552 const smb_struct_t *stp = smb_lookup_id(shp, id);
549 553 smb_slot_t s;
550 554
551 555 if (stp == NULL)
552 556 return (-1); /* errno is set for us */
553 557
554 558 if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT)
555 559 return (smb_set_errno(shp, ESMB_TYPE));
556 560
557 561 smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
558 562 bzero(sp, sizeof (smbios_slot_t));
559 563
560 564 sp->smbl_name = smb_strptr(stp, s.smbsl_name);
561 565 sp->smbl_type = s.smbsl_type;
562 566 sp->smbl_width = s.smbsl_width;
563 567 sp->smbl_usage = s.smbsl_usage;
564 568 sp->smbl_length = s.smbsl_length;
565 569 sp->smbl_id = s.smbsl_id;
566 570 sp->smbl_ch1 = s.smbsl_ch1;
567 571 sp->smbl_ch2 = s.smbsl_ch2;
568 572 sp->smbl_sg = s.smbsl_sg;
569 573 sp->smbl_bus = s.smbsl_bus;
570 574 sp->smbl_df = s.smbsl_df;
571 575
572 576 return (0);
573 577 }
574 578
575 579 int
576 580 smbios_info_obdevs_ext(smbios_hdl_t *shp, id_t id, smbios_obdev_ext_t *oep)
577 581 {
578 582 const smb_struct_t *stp = smb_lookup_id(shp, id);
579 583 smb_obdev_ext_t obe;
580 584
581 585 if (stp == NULL)
582 586 return (-1); /* errno is set for us */
583 587
584 588 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVEXT)
585 589 return (smb_set_errno(shp, ESMB_TYPE));
586 590
587 591 smb_info_bcopy(stp->smbst_hdr, &obe, sizeof (obe));
588 592 bzero(oep, sizeof (smbios_obdev_ext_t));
589 593
590 594 oep->smboe_name = smb_strptr(stp, obe.smbobe_name);
591 595 oep->smboe_dtype = obe.smbobe_dtype;
592 596 oep->smboe_dti = obe.smbobe_dti;
593 597 oep->smboe_sg = obe.smbobe_sg;
594 598 oep->smboe_bus = obe.smbobe_bus;
595 599 oep->smboe_df = obe.smbobe_df;
596 600
597 601 return (0);
598 602 }
599 603
600 604 int
601 605 smbios_info_obdevs(smbios_hdl_t *shp, id_t id, int obc, smbios_obdev_t *obp)
602 606 {
603 607 const smb_struct_t *stp = smb_lookup_id(shp, id);
604 608 const smb_obdev_t *op;
605 609 int i, m, n;
606 610
607 611 if (stp == NULL)
608 612 return (-1); /* errno is set for us */
609 613
610 614 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OBDEVS)
611 615 return (smb_set_errno(shp, ESMB_TYPE));
612 616
613 617 op = (smb_obdev_t *)((uintptr_t)stp->smbst_hdr + sizeof (smb_header_t));
614 618 m = (stp->smbst_hdr->smbh_len - sizeof (smb_header_t)) / sizeof (*op);
615 619 n = MIN(m, obc);
616 620
617 621 for (i = 0; i < n; i++, op++, obp++) {
618 622 obp->smbd_name = smb_strptr(stp, op->smbob_name);
619 623 obp->smbd_type = op->smbob_type & ~SMB_OBT_ENABLED;
620 624 obp->smbd_enabled = (op->smbob_type & SMB_OBT_ENABLED) != 0;
621 625 }
622 626
623 627 return (m);
624 628 }
625 629
626 630 /*
627 631 * The implementation structures for OEMSTR, SYSCONFSTR, and LANG all use the
628 632 * first byte to indicate the size of a string table at the end of the record.
629 633 * Therefore, smbios_info_strtab() can be used to retrieve the table size and
630 634 * strings for any of these underlying record types.
631 635 */
632 636 int
633 637 smbios_info_strtab(smbios_hdl_t *shp, id_t id, int argc, const char *argv[])
634 638 {
635 639 const smb_struct_t *stp = smb_lookup_id(shp, id);
636 640 smb_strtab_t s;
637 641 int i, n;
638 642
639 643 if (stp == NULL)
640 644 return (-1); /* errno is set for us */
641 645
642 646 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR &&
643 647 stp->smbst_hdr->smbh_type != SMB_TYPE_SYSCONFSTR &&
644 648 stp->smbst_hdr->smbh_type != SMB_TYPE_LANG)
645 649 return (smb_set_errno(shp, ESMB_TYPE));
646 650
647 651 smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
648 652 n = MIN(s.smbtb_count, argc);
649 653
650 654 for (i = 0; i < n; i++)
651 655 argv[i] = smb_strptr(stp, i + 1);
652 656
653 657 return (s.smbtb_count);
654 658 }
655 659
656 660 id_t
657 661 smbios_info_lang(smbios_hdl_t *shp, smbios_lang_t *lp)
658 662 {
659 663 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_LANG);
660 664 smb_lang_t l;
661 665
662 666 if (stp == NULL)
663 667 return (-1); /* errno is set for us */
664 668
665 669 smb_info_bcopy(stp->smbst_hdr, &l, sizeof (l));
666 670 bzero(lp, sizeof (smbios_lang_t));
667 671
668 672 lp->smbla_cur = smb_strptr(stp, l.smblang_cur);
669 673 lp->smbla_fmt = l.smblang_flags & 1;
670 674 lp->smbla_num = l.smblang_num;
671 675
672 676 return (stp->smbst_hdr->smbh_hdl);
673 677 }
674 678
675 679 id_t
676 680 smbios_info_eventlog(smbios_hdl_t *shp, smbios_evlog_t *evp)
677 681 {
678 682 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_EVENTLOG);
679 683 const smb_sel_t *sel;
680 684 size_t len;
681 685
682 686 if (stp == NULL)
683 687 return (-1); /* errno is set for us */
684 688
685 689 if (stp->smbst_hdr->smbh_len < sizeof (smb_sel_t) - sizeof (uint8_t))
686 690 return (smb_set_errno(shp, ESMB_CORRUPT));
687 691
688 692 sel = (smb_sel_t *)(uintptr_t)stp->smbst_hdr;
689 693 len = stp->smbst_hdr->smbh_len - sizeof (smb_sel_t) + sizeof (uint8_t);
690 694 bzero(evp, sizeof (smbios_evlog_t));
691 695
692 696 if (len < sel->smbsel_typec * sel->smbsel_typesz)
693 697 return (smb_set_errno(shp, ESMB_CORRUPT));
694 698
695 699 evp->smbev_size = sel->smbsel_len;
696 700 evp->smbev_hdr = sel->smbsel_hdroff;
697 701 evp->smbev_data = sel->smbsel_dataoff;
698 702 evp->smbev_method = sel->smbsel_method;
699 703 evp->smbev_flags = sel->smbsel_status;
700 704 evp->smbev_format = sel->smbsel_format;
701 705 evp->smbev_token = sel->smbsel_token;
702 706 evp->smbev_addr.eva_addr = sel->smbsel_addr;
703 707
704 708 if (sel->smbsel_typesz == sizeof (smbios_evtype_t)) {
705 709 evp->smbev_typec = sel->smbsel_typec;
706 710 evp->smbev_typev = (void *)(uintptr_t)sel->smbsel_typev;
707 711 }
708 712
709 713 return (stp->smbst_hdr->smbh_hdl);
710 714 }
711 715
712 716 int
713 717 smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map)
714 718 {
715 719 const smb_struct_t *stp = smb_lookup_id(shp, id);
716 720 smb_memarray_t m;
717 721
718 722 if (stp == NULL)
719 723 return (-1); /* errno is set for us */
720 724
721 725 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAY)
722 726 return (smb_set_errno(shp, ESMB_TYPE));
723 727
724 728 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
725 729 bzero(map, sizeof (smbios_memarray_t));
726 730
727 731 map->smbma_location = m.smbmarr_loc;
728 732 map->smbma_use = m.smbmarr_use;
729 733 map->smbma_ecc = m.smbmarr_ecc;
730 734 map->smbma_ndevs = m.smbmarr_ndevs;
731 735 map->smbma_err = m.smbmarr_err;
732 736
733 737 if (m.smbmarr_cap != 0x80000000)
734 738 map->smbma_size = (uint64_t)m.smbmarr_cap * 1024;
735 739 else if (m.smbmarr_extcap != 0)
736 740 map->smbma_size = m.smbmarr_extcap;
737 741 else
738 742 map->smbma_size = 0; /* unknown */
739 743
740 744 return (0);
741 745 }
742 746
743 747 int
744 748 smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map)
745 749 {
746 750 const smb_struct_t *stp = smb_lookup_id(shp, id);
747 751 smb_memarrmap_t m;
748 752
749 753 if (stp == NULL)
750 754 return (-1); /* errno is set for us */
751 755
752 756 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMARRAYMAP)
753 757 return (smb_set_errno(shp, ESMB_TYPE));
754 758
755 759 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
756 760 bzero(map, sizeof (smbios_memarrmap_t));
757 761
758 762 map->smbmam_array = m.smbamap_array;
759 763 map->smbmam_width = m.smbamap_width;
760 764
761 765 if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) {
762 766 map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
763 767 map->smbmam_size = (uint64_t)
764 768 (m.smbamap_end - m.smbamap_start + 1) * 1024;
765 769 } else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) {
766 770 map->smbmam_addr = m.smbamap_extstart;
767 771 map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1;
768 772 }
769 773
770 774 return (0);
771 775 }
772 776
773 777 int
774 778 smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp)
775 779 {
776 780 const smb_struct_t *stp = smb_lookup_id(shp, id);
777 781 smb_memdevice_t m;
778 782
779 783 if (stp == NULL)
780 784 return (-1); /* errno is set for us */
781 785
782 786 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICE)
783 787 return (smb_set_errno(shp, ESMB_TYPE));
784 788
785 789 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
786 790 bzero(mdp, sizeof (smbios_memdevice_t));
787 791
788 792 mdp->smbmd_array = m.smbmdev_array;
789 793 mdp->smbmd_error = m.smbmdev_error;
790 794 mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth;
791 795 mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth;
792 796
793 797 if (m.smbmdev_size == 0x7FFF) {
794 798 mdp->smbmd_size = (uint64_t)m.smbmdev_extsize;
795 799 mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */
796 800 } else if (m.smbmdev_size != 0xFFFF) {
797 801 mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES);
798 802 if (m.smbmdev_size & SMB_MDS_KBYTES)
799 803 mdp->smbmd_size *= 1024;
800 804 else
801 805 mdp->smbmd_size *= 1024 * 1024;
802 806 } else
803 807 mdp->smbmd_size = -1ULL; /* size unknown */
804 808
805 809 mdp->smbmd_form = m.smbmdev_form;
806 810 mdp->smbmd_set = m.smbmdev_set;
807 811 mdp->smbmd_type = m.smbmdev_type;
808 812 mdp->smbmd_speed = m.smbmdev_speed;
809 813 mdp->smbmd_flags = m.smbmdev_flags;
810 814 mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc);
811 815 mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc);
812 816
813 817 if (shp->sh_smbvers >= SMB_VERSION_26)
814 818 mdp->smbmd_rank = m.smbmdev_attrs & 0x0F;
815 819
816 820 if (shp->sh_smbvers >= SMB_VERSION_27)
817 821 mdp->smbmd_clkspeed = m.smbmdev_clkspeed;
818 822
819 823 if (shp->sh_smbvers >= SMB_VERSION_28) {
820 824 mdp->smbmd_minvolt = m.smbmdev_minvolt;
821 825 mdp->smbmd_maxvolt = m.smbmdev_maxvolt;
822 826 mdp->smbmd_confvolt = m.smbmdev_confvolt;
823 827 }
824 828
825 829 return (0);
826 830 }
827 831
828 832 int
829 833 smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp)
830 834 {
831 835 const smb_struct_t *stp = smb_lookup_id(shp, id);
832 836 smb_memdevmap_t m;
833 837
834 838 if (stp == NULL)
835 839 return (-1); /* errno is set for us */
836 840
837 841 if (stp->smbst_hdr->smbh_type != SMB_TYPE_MEMDEVICEMAP)
838 842 return (smb_set_errno(shp, ESMB_TYPE));
839 843
840 844 smb_info_bcopy(stp->smbst_hdr, &m, sizeof (m));
841 845 bzero(mdp, sizeof (smbios_memdevmap_t));
842 846
843 847 mdp->smbmdm_device = m.smbdmap_device;
844 848 mdp->smbmdm_arrmap = m.smbdmap_array;
845 849 mdp->smbmdm_rpos = m.smbdmap_rpos;
846 850 mdp->smbmdm_ipos = m.smbdmap_ipos;
847 851 mdp->smbmdm_idepth = m.smbdmap_idepth;
848 852
849 853 if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) {
850 854 mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
851 855 mdp->smbmdm_size = (uint64_t)
852 856 (m.smbdmap_end - m.smbdmap_start + 1) * 1024;
853 857 } else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) {
854 858 mdp->smbmdm_addr = m.smbdmap_extstart;
855 859 mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1;
856 860 }
857 861
858 862 return (0);
859 863 }
860 864
861 865 id_t
862 866 smbios_info_hwsec(smbios_hdl_t *shp, smbios_hwsec_t *hsp)
863 867 {
864 868 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_SECURITY);
865 869 smb_hwsec_t hs;
866 870
867 871 if (stp == NULL)
868 872 return (-1); /* errno is set for us */
869 873
870 874 smb_info_bcopy(stp->smbst_hdr, &hs, sizeof (hs));
871 875 bzero(hsp, sizeof (smbios_hwsec_t));
872 876
873 877 hsp->smbh_pwr_ps = SMB_HWS_PWR_PS(hs.smbhs_settings);
874 878 hsp->smbh_kbd_ps = SMB_HWS_KBD_PS(hs.smbhs_settings);
875 879 hsp->smbh_adm_ps = SMB_HWS_ADM_PS(hs.smbhs_settings);
876 880 hsp->smbh_pan_ps = SMB_HWS_PAN_PS(hs.smbhs_settings);
877 881
878 882 return (stp->smbst_hdr->smbh_hdl);
879 883 }
880 884
881 885 id_t
882 886 smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp)
883 887 {
884 888 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT);
885 889 const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr;
886 890
887 891 if (stp == NULL)
888 892 return (-1); /* errno is set for us */
889 893
890 894 bzero(bp, sizeof (smbios_boot_t));
891 895
892 896 bp->smbt_status = b->smbbo_status[0];
893 897 bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t);
894 898 bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL;
895 899
896 900 return (stp->smbst_hdr->smbh_hdl);
897 901 }
898 902
899 903 id_t
900 904 smbios_info_ipmi(smbios_hdl_t *shp, smbios_ipmi_t *ip)
901 905 {
902 906 const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_IPMIDEV);
903 907 smb_ipmi_t i;
904 908
905 909 if (stp == NULL)
906 910 return (-1); /* errno is set for us */
907 911
908 912 smb_info_bcopy(stp->smbst_hdr, &i, sizeof (i));
909 913 bzero(ip, sizeof (smbios_ipmi_t));
910 914
911 915 ip->smbip_type = i.smbipm_type;
912 916 ip->smbip_vers.smbv_major = SMB_IPM_SPEC_MAJOR(i.smbipm_spec);
913 917 ip->smbip_vers.smbv_minor = SMB_IPM_SPEC_MINOR(i.smbipm_spec);
914 918 ip->smbip_i2c = i.smbipm_i2c;
915 919 ip->smbip_addr = i.smbipm_addr & ~SMB_IPM_ADDR_IO;
916 920 ip->smbip_intr = i.smbipm_intr;
917 921
918 922 if (i.smbipm_bus != (uint8_t)-1)
919 923 ip->smbip_bus = i.smbipm_bus;
920 924 else
921 925 ip->smbip_bus = -1u;
922 926
923 927 if (SMB_IPM_INFO_LSB(i.smbipm_info))
924 928 ip->smbip_addr |= 1; /* turn on least-significant bit of addr */
925 929
926 930 if (i.smbipm_addr & SMB_IPM_ADDR_IO) {
927 931 switch (SMB_IPM_INFO_REGS(i.smbipm_info)) {
928 932 case SMB_IPM_REGS_1B:
929 933 ip->smbip_regspacing = 1;
930 934 break;
931 935 case SMB_IPM_REGS_4B:
932 936 ip->smbip_regspacing = 4;
933 937 break;
934 938 case SMB_IPM_REGS_16B:
935 939 ip->smbip_regspacing = 16;
936 940 break;
937 941 default:
938 942 ip->smbip_regspacing = 1;
939 943 }
940 944 ip->smbip_flags |= SMB_IPMI_F_IOADDR;
941 945 }
942 946
943 947 if (SMB_IPM_INFO_ISPEC(i.smbipm_info))
944 948 ip->smbip_flags |= SMB_IPMI_F_INTRSPEC;
945 949
946 950 if (SMB_IPM_INFO_IPOL(i.smbipm_info) == SMB_IPM_IPOL_HI)
947 951 ip->smbip_flags |= SMB_IPMI_F_INTRHIGH;
948 952
949 953 if (SMB_IPM_INFO_IMODE(i.smbipm_info) == SMB_IPM_IMODE_EDGE)
950 954 ip->smbip_flags |= SMB_IPMI_F_INTREDGE;
951 955
952 956 return (stp->smbst_hdr->smbh_hdl);
953 957 }
954 958
955 959 static boolean_t
956 960 smbios_has_oemstr(smbios_hdl_t *shp, const char *oemstr)
957 961 {
958 962 const smb_struct_t *stp = shp->sh_structs;
959 963 smb_strtab_t s;
960 964 int i, j;
961 965
962 966 for (i = 0; i < shp->sh_nstructs; i++, stp++) {
963 967 if (stp->smbst_hdr->smbh_type != SMB_TYPE_OEMSTR)
964 968 continue;
965 969
966 970 smb_info_bcopy(stp->smbst_hdr, &s, sizeof (s));
967 971 for (j = 0; j < s.smbtb_count; j++)
968 972 if (strcmp(smb_strptr(stp, j + 1), oemstr) == 0)
969 973 return (B_TRUE);
970 974 }
971 975
972 976 return (B_FALSE);
973 977 }
974 978
975 979 static const char *
976 980 smb_serial_valid(const char *serial)
977 981 {
978 982 char buf[MAXNAMELEN];
979 983 int i = 0;
980 984
981 985 if (serial == NULL)
982 986 return (NULL);
983 987
984 988 (void) strlcpy(buf, serial, sizeof (buf));
985 989
986 990 while (buf[i] != '\0' && buf[i] == ' ')
987 991 i++;
988 992
989 993 if (buf[i] == '\0' || strstr(buf, SMB_DEFAULT1) != NULL ||
990 994 strstr(buf, SMB_DEFAULT2) != NULL)
991 995 return (NULL);
992 996
993 997 return (serial);
994 998 }
995 999
996 1000 /*
997 1001 * Get chassis SN or product SN
998 1002 */
999 1003 static int
1000 1004 smb_get_sn(smbios_hdl_t *shp, const char **psnp, const char **csnp)
1001 1005 {
1002 1006 const smb_struct_t *stp;
1003 1007 smbios_info_t s1, s3;
1004 1008
1005 1009 if (psnp == NULL || csnp == NULL)
1006 1010 return (smb_set_errno(shp, ESMB_INVAL));
1007 1011
1008 1012 *psnp = *csnp = NULL;
1009 1013
1010 1014 /*
1011 1015 * If SMBIOS meets Sun's PRMS requirements, retrieve product SN
1012 1016 * from type 1 structure, and chassis SN from type 3 structure.
1013 1017 * Otherwise return SN in type 1 structure as chassis SN.
1014 1018 */
1015 1019
1016 1020 /* Get type 1 SN */
1017 1021 if ((stp = smb_lookup_type(shp, SMB_TYPE_SYSTEM)) == NULL ||
1018 1022 smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s1) == SMB_ERR)
1019 1023 s1.smbi_serial = NULL;
1020 1024
1021 1025 /* Get type 3 SN */
1022 1026 if ((stp = smb_lookup_type(shp, SMB_TYPE_CHASSIS)) == NULL ||
1023 1027 smbios_info_common(shp, stp->smbst_hdr->smbh_hdl, &s3) == SMB_ERR)
1024 1028 s3.smbi_serial = NULL;
1025 1029
1026 1030 if (smbios_has_oemstr(shp, SMB_PRMS1)) {
1027 1031 *psnp = smb_serial_valid(s1.smbi_serial);
1028 1032 *csnp = smb_serial_valid(s3.smbi_serial);
1029 1033 } else {
1030 1034 *csnp = smb_serial_valid(s1.smbi_serial);
1031 1035 }
1032 1036
1033 1037 return (0);
1034 1038 }
1035 1039
1036 1040 const char *
1037 1041 smbios_psn(smbios_hdl_t *shp)
1038 1042 {
1039 1043 const char *psn, *csn;
1040 1044
1041 1045 return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : psn);
1042 1046 }
1043 1047
1044 1048 const char *
1045 1049 smbios_csn(smbios_hdl_t *shp)
1046 1050 {
1047 1051 const char *psn, *csn;
1048 1052
1049 1053 return (smb_get_sn(shp, &psn, &csn) == SMB_ERR ? NULL : csn);
1050 1054 }
1051 1055
1052 1056 int
1053 1057 smbios_info_extprocessor(smbios_hdl_t *shp, id_t id,
1054 1058 smbios_processor_ext_t *epp)
1055 1059 {
1056 1060 const smb_struct_t *stp = smb_lookup_id(shp, id);
1057 1061 smb_processor_ext_t *exp;
1058 1062
1059 1063 if (stp == NULL)
1060 1064 return (-1); /* errno is set for us */
1061 1065
1062 1066 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PROCESSOR)
1063 1067 return (smb_set_errno(shp, ESMB_TYPE));
1064 1068
1065 1069 exp = (smb_processor_ext_t *)(uintptr_t)stp->smbst_hdr;
1066 1070 bzero(epp, sizeof (smbios_processor_ext_t));
1067 1071
1068 1072 epp->smbpe_processor = exp->smbpre_processor;
1069 1073 epp->smbpe_fru = exp->smbpre_fru;
1070 1074 epp->smbpe_n = exp->smbpre_n;
1071 1075 epp->smbpe_apicid = exp->smbpre_apicid;
1072 1076
1073 1077 return (0);
1074 1078 }
1075 1079
1076 1080 int
1077 1081 smbios_info_extport(smbios_hdl_t *shp, id_t id, smbios_port_ext_t *eportp)
1078 1082 {
1079 1083 const smb_struct_t *stp = smb_lookup_id(shp, id);
1080 1084 smb_port_ext_t *ep;
1081 1085
1082 1086 if (stp == NULL)
1083 1087 return (-1); /* errno is set for us */
1084 1088
1085 1089 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_PORT)
1086 1090 return (smb_set_errno(shp, ESMB_TYPE));
1087 1091
1088 1092 ep = (smb_port_ext_t *)(uintptr_t)stp->smbst_hdr;
1089 1093 bzero(eportp, sizeof (smbios_port_ext_t));
1090 1094
1091 1095 eportp->smbporte_chassis = ep->smbpoe_chassis;
1092 1096 eportp->smbporte_port = ep->smbpoe_port;
1093 1097 eportp->smbporte_dtype = ep->smbpoe_dtype;
1094 1098 eportp->smbporte_devhdl = ep->smbpoe_devhdl;
1095 1099 eportp->smbporte_phy = ep->smbpoe_phy;
1096 1100
1097 1101 return (0);
1098 1102 }
1099 1103
1100 1104 int
1101 1105 smbios_info_pciexrc(smbios_hdl_t *shp, id_t id,
1102 1106 smbios_pciexrc_t *rcp)
1103 1107 {
1104 1108 const smb_struct_t *stp = smb_lookup_id(shp, id);
1105 1109 smb_pciexrc_t rc;
1106 1110
1107 1111 if (stp == NULL)
1108 1112 return (-1); /* errno is set for us */
1109 1113
1110 1114 if (stp->smbst_hdr->smbh_type != SUN_OEM_PCIEXRC)
1111 1115 return (smb_set_errno(shp, ESMB_TYPE));
1112 1116
1113 1117 smb_info_bcopy(stp->smbst_hdr, &rc, sizeof (rc));
1114 1118 bzero(rcp, sizeof (smbios_pciexrc_t));
1115 1119
1116 1120 rcp->smbpcie_bb = rc.smbpciexrc_bboard;
1117 1121 rcp->smbpcie_bdf = rc.smbpciexrc_bdf;
1118 1122
1119 1123 return (0);
1120 1124 }
1121 1125
1122 1126 int
1123 1127 smbios_info_extmemarray(smbios_hdl_t *shp, id_t id, smbios_memarray_ext_t *emap)
1124 1128 {
1125 1129 const smb_struct_t *stp = smb_lookup_id(shp, id);
1126 1130 smb_memarray_ext_t exma;
1127 1131
1128 1132 if (stp == NULL)
1129 1133 return (-1); /* errno is set for us */
1130 1134
1131 1135 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMARRAY)
1132 1136 return (smb_set_errno(shp, ESMB_TYPE));
1133 1137
1134 1138 smb_info_bcopy(stp->smbst_hdr, &exma, sizeof (exma));
1135 1139 bzero(emap, sizeof (smbios_memarray_ext_t));
1136 1140
1137 1141 emap->smbmae_ma = exma.smbmarre_ma;
1138 1142 emap->smbmae_comp = exma.smbmarre_component;
1139 1143 emap->smbmae_bdf = exma.smbmarre_bdf;
1140 1144
1141 1145 return (0);
1142 1146 }
1143 1147
1144 1148 int
1145 1149 smbios_info_extmemdevice(smbios_hdl_t *shp, id_t id,
1146 1150 smbios_memdevice_ext_t *emdp)
1147 1151 {
1148 1152 const smb_struct_t *stp = smb_lookup_id(shp, id);
1149 1153 smb_memdevice_ext_t exmd;
1150 1154
1151 1155 if (stp == NULL)
1152 1156 return (-1); /* errno is set for us */
1153 1157
1154 1158 if (stp->smbst_hdr->smbh_type != SUN_OEM_EXT_MEMDEVICE)
1155 1159 return (smb_set_errno(shp, ESMB_TYPE));
1156 1160
1157 1161 smb_info_bcopy(stp->smbst_hdr, &exmd, sizeof (exmd));
1158 1162 bzero(emdp, sizeof (smbios_memdevice_ext_t));
1159 1163
1160 1164 emdp->smbmdeve_md = exmd.smbmdeve_mdev;
1161 1165 emdp->smbmdeve_drch = exmd.smbmdeve_dchan;
1162 1166 emdp->smbmdeve_ncs = exmd.smbmdeve_ncs;
1163 1167 emdp->smbmdeve_cs = exmd.smbmdeve_cs;
1164 1168
1165 1169 return (0);
1166 1170 }
|
↓ open down ↓ |
717 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX