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 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #include <sys/sysmacros.h>
28 #include <sys/param.h>
29
30 #include <smbios.h>
31 #include <alloca.h>
32 #include <limits.h>
33 #include <unistd.h>
34 #include <strings.h>
35 #include <stdlib.h>
36 #include <stdarg.h>
37 #include <stdio.h>
38 #include <fcntl.h>
39 #include <errno.h>
40 #include <ctype.h>
41
42 #define SMBIOS_SUCCESS 0
320 return;
321 n = MIN(chdl_cnt, cnt);
322
323 oprintf(fp, "\n");
324 for (i = 0; i < n; i++) {
325 hdl = (uint16_t)chdl[i];
326 oprintf(fp, " Contained Handle: %u\n", hdl);
327 }
328 }
329 }
330
331 static void
332 print_chassis(smbios_hdl_t *shp, id_t id, FILE *fp)
333 {
334 smbios_chassis_t c;
335 int elem_cnt;
336
337 (void) smbios_info_chassis(shp, id, &c);
338
339 oprintf(fp, " OEM Data: 0x%x\n", c.smbc_oemdata);
340 oprintf(fp, " Lock Present: %s\n", c.smbc_lock ? "Y" : "N");
341
342 desc_printf(smbios_chassis_type_desc(c.smbc_type),
343 fp, " Chassis Type: 0x%x", c.smbc_type);
344
345 desc_printf(smbios_chassis_state_desc(c.smbc_bustate),
346 fp, " Boot-Up State: 0x%x", c.smbc_bustate);
347
348 desc_printf(smbios_chassis_state_desc(c.smbc_psstate),
349 fp, " Power Supply State: 0x%x", c.smbc_psstate);
350
351 desc_printf(smbios_chassis_state_desc(c.smbc_thstate),
352 fp, " Thermal State: 0x%x", c.smbc_thstate);
353
354 oprintf(fp, " Chassis Height: %uu\n", c.smbc_uheight);
355 oprintf(fp, " Power Cords: %u\n", c.smbc_cords);
356
357 elem_cnt = c.smbc_elems;
358 oprintf(fp, " Element Records: %u\n", elem_cnt);
359
381 desc_printf(smbios_bboard_type_desc(type), fp,
382 " Contained SMBIOS Base Board Type: 0x%x",
383 type);
384 }
385 }
386 }
387 }
388
389 static void
390 print_processor(smbios_hdl_t *shp, id_t id, FILE *fp)
391 {
392 smbios_processor_t p;
393 uint_t status;
394
395 (void) smbios_info_processor(shp, id, &p);
396 status = SMB_PRSTATUS_STATUS(p.smbp_status);
397
398 desc_printf(smbios_processor_family_desc(p.smbp_family),
399 fp, " Family: %u", p.smbp_family);
400
401 oprintf(fp, " CPUID: 0x%llx\n", (u_longlong_t)p.smbp_cpuid);
402
403 desc_printf(smbios_processor_type_desc(p.smbp_type),
404 fp, " Type: %u", p.smbp_type);
405
406 desc_printf(smbios_processor_upgrade_desc(p.smbp_upgrade),
407 fp, " Socket Upgrade: %u", p.smbp_upgrade);
408
409 oprintf(fp, " Socket Status: %s\n",
410 SMB_PRSTATUS_PRESENT(p.smbp_status) ?
411 "Populated" : "Not Populated");
412
413 desc_printf(smbios_processor_status_desc(status),
414 fp, " Processor Status: %u", status);
415
416 if (SMB_PRV_LEGACY(p.smbp_voltage)) {
417 oprintf(fp, " Supported Voltages:");
418 switch (p.smbp_voltage) {
419 case SMB_PRV_5V:
420 oprintf(fp, " 5.0V");
421 break;
422 case SMB_PRV_33V:
423 oprintf(fp, " 3.3V");
424 break;
425 case SMB_PRV_29V:
426 oprintf(fp, " 2.9V");
427 break;
428 }
429 oprintf(fp, "\n");
430 } else {
431 oprintf(fp, " Supported Voltages: %.1fV\n",
432 (float)SMB_PRV_VOLTAGE(p.smbp_voltage) / 10);
433 }
434
435 if (p.smbp_clkspeed != 0)
436 oprintf(fp, " External Clock Speed: %uMHz\n", p.smbp_clkspeed);
437 else
438 oprintf(fp, " External Clock Speed: Unknown\n");
439
440 if (p.smbp_maxspeed != 0)
441 oprintf(fp, " Maximum Speed: %uMHz\n", p.smbp_maxspeed);
442 else
443 oprintf(fp, " Maximum Speed: Unknown\n");
444
445 if (p.smbp_curspeed != 0)
446 oprintf(fp, " Current Speed: %uMHz\n", p.smbp_curspeed);
447 else
448 oprintf(fp, " Current Speed: Unknown\n");
449
450 id_printf(fp, " L1 Cache: ", p.smbp_l1cache);
451 id_printf(fp, " L2 Cache: ", p.smbp_l2cache);
452 id_printf(fp, " L3 Cache: ", p.smbp_l3cache);
453 }
454
751 oprintf(fp, " Size: Unknown\n");
752 break;
753 case 0:
754 oprintf(fp, " Size: Not Populated\n");
755 break;
756 default:
757 oprintf(fp, " Size: %llu bytes\n",
758 (u_longlong_t)md.smbmd_size);
759 }
760
761 desc_printf(smbios_memdevice_form_desc(md.smbmd_form),
762 fp, " Form Factor: %u", md.smbmd_form);
763
764 if (md.smbmd_set == 0)
765 oprintf(fp, " Set: None\n");
766 else if (md.smbmd_set == (uint8_t)-1u)
767 oprintf(fp, " Set: Unknown\n");
768 else
769 oprintf(fp, " Set: %u\n", md.smbmd_set);
770
771 desc_printf(smbios_memdevice_type_desc(md.smbmd_type),
772 fp, " Memory Type: %u", md.smbmd_type);
773
774 flag_printf(fp, "Flags", md.smbmd_flags, sizeof (md.smbmd_flags) * NBBY,
775 smbios_memdevice_flag_name, smbios_memdevice_flag_desc);
776
777 if (md.smbmd_speed != 0)
778 oprintf(fp, " Speed: %uns\n", md.smbmd_speed);
779 else
780 oprintf(fp, " Speed: Unknown\n");
781
782 oprintf(fp, " Device Locator: %s\n", md.smbmd_dloc);
783 oprintf(fp, " Bank Locator: %s\n", md.smbmd_bloc);
784 }
785
786 static void
787 print_memarrmap(smbios_hdl_t *shp, id_t id, FILE *fp)
788 {
789 smbios_memarrmap_t ma;
790
791 (void) smbios_info_memarrmap(shp, id, &ma);
792
793 id_printf(fp, " Physical Memory Array: ", ma.smbmam_array);
794 oprintf(fp, " Devices per Row: %u\n", ma.smbmam_width);
795
796 oprintf(fp, " Physical Address: 0x%llx\n Size: %llu bytes\n",
797 (u_longlong_t)ma.smbmam_addr, (u_longlong_t)ma.smbmam_size);
798 }
799
800 static void
801 print_memdevmap(smbios_hdl_t *shp, id_t id, FILE *fp)
802 {
803 smbios_memdevmap_t md;
962 print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp)
963 {
964 smbios_info_t info;
965 int hex = opt_x;
966 const char *s;
967
968 if (opt_t != -1 && opt_t != sp->smbstr_type)
969 return (0); /* skip struct if type doesn't match -t */
970
971 if (!opt_O && (sp->smbstr_type == SMB_TYPE_MEMCTL ||
972 sp->smbstr_type == SMB_TYPE_MEMMOD))
973 return (0); /* skip struct if type is obsolete */
974
975 if (g_hdr++ == 0 || !opt_s)
976 oprintf(fp, "%-5s %-4s %s\n", "ID", "SIZE", "TYPE");
977
978 oprintf(fp, "%-5u %-4lu",
979 (uint_t)sp->smbstr_id, (ulong_t)sp->smbstr_size);
980
981 if ((s = smbios_type_name(sp->smbstr_type)) != NULL)
982 oprintf(fp, " %s", s);
983 else if (sp->smbstr_type > SMB_TYPE_OEM_LO &&
984 sp->smbstr_type < SMB_TYPE_OEM_HI)
985 oprintf(fp, " %s+%u", "SMB_TYPE_OEM_LO",
986 sp->smbstr_type - SMB_TYPE_OEM_LO);
987 else
988 oprintf(fp, " %u", sp->smbstr_type);
989
990 if ((s = smbios_type_desc(sp->smbstr_type)) != NULL)
991 oprintf(fp, " (%s)\n", s);
992 else
993 oprintf(fp, "\n");
994
995 if (opt_s)
996 return (0); /* only print header line if -s specified */
997
998 if (smbios_info_common(shp, sp->smbstr_id, &info) == 0) {
999 oprintf(fp, "\n");
1000 print_common(&info, fp);
1001 }
1002
1003 switch (sp->smbstr_type) {
1004 case SMB_TYPE_BIOS:
1005 oprintf(fp, "\n");
|
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 2010 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28 #include <sys/sysmacros.h>
29 #include <sys/param.h>
30
31 #include <smbios.h>
32 #include <alloca.h>
33 #include <limits.h>
34 #include <unistd.h>
35 #include <strings.h>
36 #include <stdlib.h>
37 #include <stdarg.h>
38 #include <stdio.h>
39 #include <fcntl.h>
40 #include <errno.h>
41 #include <ctype.h>
42
43 #define SMBIOS_SUCCESS 0
321 return;
322 n = MIN(chdl_cnt, cnt);
323
324 oprintf(fp, "\n");
325 for (i = 0; i < n; i++) {
326 hdl = (uint16_t)chdl[i];
327 oprintf(fp, " Contained Handle: %u\n", hdl);
328 }
329 }
330 }
331
332 static void
333 print_chassis(smbios_hdl_t *shp, id_t id, FILE *fp)
334 {
335 smbios_chassis_t c;
336 int elem_cnt;
337
338 (void) smbios_info_chassis(shp, id, &c);
339
340 oprintf(fp, " OEM Data: 0x%x\n", c.smbc_oemdata);
341 oprintf(fp, " SKU number: %s\n",
342 c.smbc_sku == NULL ? "<unknown>" : c.smbc_sku);
343 oprintf(fp, " Lock Present: %s\n", c.smbc_lock ? "Y" : "N");
344
345 desc_printf(smbios_chassis_type_desc(c.smbc_type),
346 fp, " Chassis Type: 0x%x", c.smbc_type);
347
348 desc_printf(smbios_chassis_state_desc(c.smbc_bustate),
349 fp, " Boot-Up State: 0x%x", c.smbc_bustate);
350
351 desc_printf(smbios_chassis_state_desc(c.smbc_psstate),
352 fp, " Power Supply State: 0x%x", c.smbc_psstate);
353
354 desc_printf(smbios_chassis_state_desc(c.smbc_thstate),
355 fp, " Thermal State: 0x%x", c.smbc_thstate);
356
357 oprintf(fp, " Chassis Height: %uu\n", c.smbc_uheight);
358 oprintf(fp, " Power Cords: %u\n", c.smbc_cords);
359
360 elem_cnt = c.smbc_elems;
361 oprintf(fp, " Element Records: %u\n", elem_cnt);
362
384 desc_printf(smbios_bboard_type_desc(type), fp,
385 " Contained SMBIOS Base Board Type: 0x%x",
386 type);
387 }
388 }
389 }
390 }
391
392 static void
393 print_processor(smbios_hdl_t *shp, id_t id, FILE *fp)
394 {
395 smbios_processor_t p;
396 uint_t status;
397
398 (void) smbios_info_processor(shp, id, &p);
399 status = SMB_PRSTATUS_STATUS(p.smbp_status);
400
401 desc_printf(smbios_processor_family_desc(p.smbp_family),
402 fp, " Family: %u", p.smbp_family);
403
404 if (p.smbp_family2 != 0)
405 desc_printf(smbios_processor_family_desc(p.smbp_family2),
406 fp, " Family Ext: %u", p.smbp_family2);
407
408 oprintf(fp, " CPUID: 0x%llx\n", (u_longlong_t)p.smbp_cpuid);
409
410 desc_printf(smbios_processor_type_desc(p.smbp_type),
411 fp, " Type: %u", p.smbp_type);
412
413 desc_printf(smbios_processor_upgrade_desc(p.smbp_upgrade),
414 fp, " Socket Upgrade: %u", p.smbp_upgrade);
415
416 oprintf(fp, " Socket Status: %s\n",
417 SMB_PRSTATUS_PRESENT(p.smbp_status) ?
418 "Populated" : "Not Populated");
419
420 desc_printf(smbios_processor_status_desc(status),
421 fp, " Processor Status: %u", status);
422
423 if (SMB_PRV_LEGACY(p.smbp_voltage)) {
424 oprintf(fp, " Supported Voltages:");
425 switch (p.smbp_voltage) {
426 case SMB_PRV_5V:
427 oprintf(fp, " 5.0V");
428 break;
429 case SMB_PRV_33V:
430 oprintf(fp, " 3.3V");
431 break;
432 case SMB_PRV_29V:
433 oprintf(fp, " 2.9V");
434 break;
435 }
436 oprintf(fp, "\n");
437 } else {
438 oprintf(fp, " Supported Voltages: %.1fV\n",
439 (float)SMB_PRV_VOLTAGE(p.smbp_voltage) / 10);
440 }
441
442 if (p.smbp_corecount != 0)
443 oprintf(fp, " Core Count: %u\n", p.smbp_corecount);
444 else
445 oprintf(fp, " Core Count: Unknown\n");
446
447 if (p.smbp_coresenabled != 0)
448 oprintf(fp, " Cores Enabled: %u\n", p.smbp_coresenabled);
449 else
450 oprintf(fp, " Cores Enabled: Unknown\n");
451
452 if (p.smbp_threadcount != 0)
453 oprintf(fp, " Thread Count: %u\n", p.smbp_threadcount);
454 else
455 oprintf(fp, " Thread Count: Unknown\n");
456
457 if (p.smbp_cflags) {
458 flag_printf(fp, "Processor Characteristics",
459 p.smbp_cflags, sizeof (p.smbp_cflags) * NBBY,
460 smbios_processor_core_flag_name,
461 smbios_processor_core_flag_desc);
462 }
463
464 if (p.smbp_clkspeed != 0)
465 oprintf(fp, " External Clock Speed: %uMHz\n", p.smbp_clkspeed);
466 else
467 oprintf(fp, " External Clock Speed: Unknown\n");
468
469 if (p.smbp_maxspeed != 0)
470 oprintf(fp, " Maximum Speed: %uMHz\n", p.smbp_maxspeed);
471 else
472 oprintf(fp, " Maximum Speed: Unknown\n");
473
474 if (p.smbp_curspeed != 0)
475 oprintf(fp, " Current Speed: %uMHz\n", p.smbp_curspeed);
476 else
477 oprintf(fp, " Current Speed: Unknown\n");
478
479 id_printf(fp, " L1 Cache: ", p.smbp_l1cache);
480 id_printf(fp, " L2 Cache: ", p.smbp_l2cache);
481 id_printf(fp, " L3 Cache: ", p.smbp_l3cache);
482 }
483
780 oprintf(fp, " Size: Unknown\n");
781 break;
782 case 0:
783 oprintf(fp, " Size: Not Populated\n");
784 break;
785 default:
786 oprintf(fp, " Size: %llu bytes\n",
787 (u_longlong_t)md.smbmd_size);
788 }
789
790 desc_printf(smbios_memdevice_form_desc(md.smbmd_form),
791 fp, " Form Factor: %u", md.smbmd_form);
792
793 if (md.smbmd_set == 0)
794 oprintf(fp, " Set: None\n");
795 else if (md.smbmd_set == (uint8_t)-1u)
796 oprintf(fp, " Set: Unknown\n");
797 else
798 oprintf(fp, " Set: %u\n", md.smbmd_set);
799
800 if (md.smbmd_rank != 0) {
801 desc_printf(smbios_memdevice_rank_desc(md.smbmd_rank),
802 fp, " Rank: %u", md.smbmd_rank);
803 } else {
804 oprintf(fp, " Rank: Unknown\n");
805 }
806
807 desc_printf(smbios_memdevice_type_desc(md.smbmd_type),
808 fp, " Memory Type: %u", md.smbmd_type);
809
810 flag_printf(fp, "Flags", md.smbmd_flags, sizeof (md.smbmd_flags) * NBBY,
811 smbios_memdevice_flag_name, smbios_memdevice_flag_desc);
812
813 if (md.smbmd_speed != 0)
814 oprintf(fp, " Speed: %u MHz\n", md.smbmd_speed);
815 else
816 oprintf(fp, " Speed: Unknown\n");
817
818 if (md.smbmd_clkspeed != 0)
819 oprintf(fp, " Configured Speed: %u MHz\n", md.smbmd_clkspeed);
820 else
821 oprintf(fp, " Configured Speed: Unknown\n");
822
823 oprintf(fp, " Device Locator: %s\n", md.smbmd_dloc);
824 oprintf(fp, " Bank Locator: %s\n", md.smbmd_bloc);
825
826 if (md.smbmd_minvolt != 0) {
827 oprintf(fp, " Minimum Voltage: %.2fV\n",
828 md.smbmd_minvolt / 1000.0);
829 } else {
830 oprintf(fp, " Minimum Voltage: Unknown\n");
831 }
832
833 if (md.smbmd_maxvolt != 0) {
834 oprintf(fp, " Maximum Voltage: %.2fV\n",
835 md.smbmd_maxvolt / 1000.0);
836 } else {
837 oprintf(fp, " Maximum Voltage: Unknown\n");
838 }
839
840 if (md.smbmd_confvolt != 0) {
841 oprintf(fp, " Configured Voltage: %.2fV\n",
842 md.smbmd_confvolt / 1000.0);
843 } else {
844 oprintf(fp, " Configured Voltage: Unknown\n");
845 }
846 }
847
848 static void
849 print_memarrmap(smbios_hdl_t *shp, id_t id, FILE *fp)
850 {
851 smbios_memarrmap_t ma;
852
853 (void) smbios_info_memarrmap(shp, id, &ma);
854
855 id_printf(fp, " Physical Memory Array: ", ma.smbmam_array);
856 oprintf(fp, " Devices per Row: %u\n", ma.smbmam_width);
857
858 oprintf(fp, " Physical Address: 0x%llx\n Size: %llu bytes\n",
859 (u_longlong_t)ma.smbmam_addr, (u_longlong_t)ma.smbmam_size);
860 }
861
862 static void
863 print_memdevmap(smbios_hdl_t *shp, id_t id, FILE *fp)
864 {
865 smbios_memdevmap_t md;
1024 print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp)
1025 {
1026 smbios_info_t info;
1027 int hex = opt_x;
1028 const char *s;
1029
1030 if (opt_t != -1 && opt_t != sp->smbstr_type)
1031 return (0); /* skip struct if type doesn't match -t */
1032
1033 if (!opt_O && (sp->smbstr_type == SMB_TYPE_MEMCTL ||
1034 sp->smbstr_type == SMB_TYPE_MEMMOD))
1035 return (0); /* skip struct if type is obsolete */
1036
1037 if (g_hdr++ == 0 || !opt_s)
1038 oprintf(fp, "%-5s %-4s %s\n", "ID", "SIZE", "TYPE");
1039
1040 oprintf(fp, "%-5u %-4lu",
1041 (uint_t)sp->smbstr_id, (ulong_t)sp->smbstr_size);
1042
1043 if ((s = smbios_type_name(sp->smbstr_type)) != NULL)
1044 oprintf(fp, " (%u) %s", sp->smbstr_type, s);
1045 else if (sp->smbstr_type > SMB_TYPE_OEM_LO &&
1046 sp->smbstr_type < SMB_TYPE_OEM_HI)
1047 oprintf(fp, " (%u) %s+%u", sp->smbstr_type, "SMB_TYPE_OEM_LO",
1048 sp->smbstr_type - SMB_TYPE_OEM_LO);
1049 else
1050 oprintf(fp, " %u", sp->smbstr_type);
1051
1052 if ((s = smbios_type_desc(sp->smbstr_type)) != NULL)
1053 oprintf(fp, " (%s)\n", s);
1054 else
1055 oprintf(fp, "\n");
1056
1057 if (opt_s)
1058 return (0); /* only print header line if -s specified */
1059
1060 if (smbios_info_common(shp, sp->smbstr_id, &info) == 0) {
1061 oprintf(fp, "\n");
1062 print_common(&info, fp);
1063 }
1064
1065 switch (sp->smbstr_type) {
1066 case SMB_TYPE_BIOS:
1067 oprintf(fp, "\n");
|