smbios.c (074bb90d80fdbeb2d04a8450a55ecbc96de28785) | smbios.c (03f9f63d24f0494b7d47b927090ad9045e396402) |
---|---|
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 --- 6 unchanged lines hidden (view full) --- 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/* | 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 --- 6 unchanged lines hidden (view full) --- 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 2009 Sun Microsystems, Inc. All rights reserved. | 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> --- 102 unchanged lines hidden (view full) --- 134 case SMB_ID_NOTSUP: 135 oprintf(fp, "%sNot Supported\n", s); 136 break; 137 default: 138 oprintf(fp, "%s%u\n", s, (uint_t)id); 139 } 140} 141 | 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> --- 102 unchanged lines hidden (view full) --- 134 case SMB_ID_NOTSUP: 135 oprintf(fp, "%sNot Supported\n", s); 136 break; 137 default: 138 oprintf(fp, "%s%u\n", s, (uint_t)id); 139 } 140} 141 |
142static int 143check_oem(smbios_hdl_t *shp) 144{ 145 int i; 146 int cnt; 147 int rv; 148 id_t oem_id; 149 smbios_struct_t s; 150 const char **oem_str; 151 152 rv = smbios_lookup_type(shp, SMB_TYPE_OEMSTR, &s); 153 if (rv != 0) { 154 return (-1); 155 } 156 157 oem_id = s.smbstr_id; 158 159 cnt = smbios_info_strtab(shp, oem_id, 0, NULL); 160 if (cnt > 0) { 161 oem_str = alloca(sizeof (char *) * cnt); 162 (void) smbios_info_strtab(shp, oem_id, cnt, oem_str); 163 164 for (i = 0; i < cnt; i++) { 165 if (strncmp(oem_str[i], SMB_PRMS1, 166 strlen(SMB_PRMS1) + 1) == 0) { 167 return (0); 168 } 169 } 170 } 171 172 return (-1); 173} 174 |
|
142static void 143print_smbios(smbios_hdl_t *shp, FILE *fp) 144{ 145 smbios_entry_t ep; 146 int i; 147 148 smbios_info_smbios(shp, &ep); 149 --- 334 unchanged lines hidden (view full) --- 484 desc_printf(smbios_port_type_desc(p.smbo_ptype), 485 fp, " Port Type: %u", p.smbo_ptype); 486} 487 488static void 489print_slot(smbios_hdl_t *shp, id_t id, FILE *fp) 490{ 491 smbios_slot_t s; | 175static void 176print_smbios(smbios_hdl_t *shp, FILE *fp) 177{ 178 smbios_entry_t ep; 179 int i; 180 181 smbios_info_smbios(shp, &ep); 182 --- 334 unchanged lines hidden (view full) --- 517 desc_printf(smbios_port_type_desc(p.smbo_ptype), 518 fp, " Port Type: %u", p.smbo_ptype); 519} 520 521static void 522print_slot(smbios_hdl_t *shp, id_t id, FILE *fp) 523{ 524 smbios_slot_t s; |
525 smbios_entry_t e; |
|
492 493 (void) smbios_info_slot(shp, id, &s); | 526 527 (void) smbios_info_slot(shp, id, &s); |
528 (void) smbios_info_smbios(shp, &e); |
|
494 495 oprintf(fp, " Reference Designator: %s\n", s.smbl_name); 496 oprintf(fp, " Slot ID: 0x%x\n", s.smbl_id); 497 498 desc_printf(smbios_slot_type_desc(s.smbl_type), 499 fp, " Type: 0x%x", s.smbl_type); 500 501 desc_printf(smbios_slot_width_desc(s.smbl_width), --- 7 unchanged lines hidden (view full) --- 509 510 flag_printf(fp, "Slot Characteristics 1", 511 s.smbl_ch1, sizeof (s.smbl_ch1) * NBBY, 512 smbios_slot_ch1_name, smbios_slot_ch1_desc); 513 514 flag_printf(fp, "Slot Characteristics 2", 515 s.smbl_ch2, sizeof (s.smbl_ch2) * NBBY, 516 smbios_slot_ch2_name, smbios_slot_ch2_desc); | 529 530 oprintf(fp, " Reference Designator: %s\n", s.smbl_name); 531 oprintf(fp, " Slot ID: 0x%x\n", s.smbl_id); 532 533 desc_printf(smbios_slot_type_desc(s.smbl_type), 534 fp, " Type: 0x%x", s.smbl_type); 535 536 desc_printf(smbios_slot_width_desc(s.smbl_width), --- 7 unchanged lines hidden (view full) --- 544 545 flag_printf(fp, "Slot Characteristics 1", 546 s.smbl_ch1, sizeof (s.smbl_ch1) * NBBY, 547 smbios_slot_ch1_name, smbios_slot_ch1_desc); 548 549 flag_printf(fp, "Slot Characteristics 2", 550 s.smbl_ch2, sizeof (s.smbl_ch2) * NBBY, 551 smbios_slot_ch2_name, smbios_slot_ch2_desc); |
552 553 if (check_oem(shp) != 0 && (e.smbe_major < 2 || e.smbe_minor < 6)) 554 return; 555 556 oprintf(fp, " Segment Group: %u\n", s.smbl_sg); 557 oprintf(fp, " Bus Number: %u\n", s.smbl_bus); 558 oprintf(fp, " Device/Function Number: %u\n", s.smbl_df); |
|
517} 518 519static void | 559} 560 561static void |
562print_obdevs_ext(smbios_hdl_t *shp, id_t id, FILE *fp) 563{ 564 smbios_obdev_ext_t oe; 565 566 (void) smbios_info_obdevs_ext(shp, id, &oe); 567 568 oprintf(fp, " Reference Designator: %s\n", oe.smboe_name); 569 oprintf(fp, " Device Type: %u\n", oe.smboe_dtype); 570 oprintf(fp, " Device Type Instance: %u\n", oe.smboe_dti); 571 oprintf(fp, " Segment Group Number: %u\n", oe.smboe_sg); 572 oprintf(fp, " Bus Number: %u\n", oe.smboe_bus); 573 oprintf(fp, " Device/Function Number: %u\n", oe.smboe_df); 574} 575 576static void |
|
520print_obdevs(smbios_hdl_t *shp, id_t id, FILE *fp) 521{ 522 smbios_obdev_t *argv; 523 int i, argc; 524 525 if ((argc = smbios_info_obdevs(shp, id, 0, NULL)) > 0) { 526 argv = alloca(sizeof (smbios_obdev_t) * argc); 527 (void) smbios_info_obdevs(shp, id, argc, argv); --- 281 unchanged lines hidden (view full) --- 809 oprintf(fp, " BMC Base Address: 0x%llx\n", (u_longlong_t)i.smbip_addr); 810 oprintf(fp, " Interrupt Number: %u\n", i.smbip_intr); 811 oprintf(fp, " Register Spacing: %u\n", i.smbip_regspacing); 812 813 flag_printf(fp, "Flags", i.smbip_flags, sizeof (i.smbip_flags) * NBBY, 814 smbios_ipmi_flag_name, smbios_ipmi_flag_desc); 815} 816 | 577print_obdevs(smbios_hdl_t *shp, id_t id, FILE *fp) 578{ 579 smbios_obdev_t *argv; 580 int i, argc; 581 582 if ((argc = smbios_info_obdevs(shp, id, 0, NULL)) > 0) { 583 argv = alloca(sizeof (smbios_obdev_t) * argc); 584 (void) smbios_info_obdevs(shp, id, argc, argv); --- 281 unchanged lines hidden (view full) --- 866 oprintf(fp, " BMC Base Address: 0x%llx\n", (u_longlong_t)i.smbip_addr); 867 oprintf(fp, " Interrupt Number: %u\n", i.smbip_intr); 868 oprintf(fp, " Register Spacing: %u\n", i.smbip_regspacing); 869 870 flag_printf(fp, "Flags", i.smbip_flags, sizeof (i.smbip_flags) * NBBY, 871 smbios_ipmi_flag_name, smbios_ipmi_flag_desc); 872} 873 |
817static int 818check_oem(smbios_hdl_t *shp) 819{ 820 int i; 821 int cnt; 822 int rv; 823 id_t oem_id; 824 smbios_struct_t s; 825 const char **oem_str; 826 827 rv = smbios_lookup_type(shp, SMB_TYPE_OEMSTR, &s); 828 if (rv != 0) { 829 return (-1); 830 } 831 832 oem_id = s.smbstr_id; 833 834 cnt = smbios_info_strtab(shp, oem_id, 0, NULL); 835 if (cnt > 0) { 836 oem_str = alloca(sizeof (char *) * cnt); 837 (void) smbios_info_strtab(shp, oem_id, cnt, oem_str); 838 839 for (i = 0; i < cnt; i++) { 840 if (strncmp(oem_str[i], SMB_PRMS1, 841 strlen(SMB_PRMS1) + 1) == 0) { 842 return (0); 843 } 844 } 845 } 846 847 return (-1); 848} 849 | |
850static void 851print_extprocessor(smbios_hdl_t *shp, id_t id, FILE *fp) 852{ 853 int i; 854 smbios_processor_ext_t ep; 855 856 if (check_oem(shp) != 0) 857 return; --- 6 unchanged lines hidden (view full) --- 864 865 for (i = 0; i < ep.smbpe_n; i++) { 866 oprintf(fp, " Logical Strand %u: Initial APIC ID: %u\n", i, 867 ep.smbpe_apicid[i]); 868 } 869} 870 871static void | 874static void 875print_extprocessor(smbios_hdl_t *shp, id_t id, FILE *fp) 876{ 877 int i; 878 smbios_processor_ext_t ep; 879 880 if (check_oem(shp) != 0) 881 return; --- 6 unchanged lines hidden (view full) --- 888 889 for (i = 0; i < ep.smbpe_n; i++) { 890 oprintf(fp, " Logical Strand %u: Initial APIC ID: %u\n", i, 891 ep.smbpe_apicid[i]); 892 } 893} 894 895static void |
896print_extport(smbios_hdl_t *shp, id_t id, FILE *fp) 897{ 898 smbios_port_ext_t epo; 899 900 if (check_oem(shp) != 0) 901 return; 902 903 (void) smbios_info_extport(shp, id, &epo); 904 905 oprintf(fp, " Chassis Handle: %u\n", epo.smbporte_chassis); 906 oprintf(fp, " Port Connector Handle: %u\n", epo.smbporte_port); 907 oprintf(fp, " Device Type: %u\n", epo.smbporte_dtype); 908 oprintf(fp, " Device Handle: %u\n", epo.smbporte_devhdl); 909 oprintf(fp, " PHY: %u\n", epo.smbporte_phy); 910} 911 912static void |
|
872print_pciexrc(smbios_hdl_t *shp, id_t id, FILE *fp) 873{ 874 smbios_pciexrc_t pcie; 875 876 if (check_oem(shp) != 0) 877 return; 878 879 (void) smbios_info_pciexrc(shp, id, &pcie); --- 152 unchanged lines hidden (view full) --- 1032 case SMB_TYPE_BOOT: 1033 oprintf(fp, "\n"); 1034 print_boot(shp, fp); 1035 break; 1036 case SMB_TYPE_IPMIDEV: 1037 oprintf(fp, "\n"); 1038 print_ipmi(shp, fp); 1039 break; | 913print_pciexrc(smbios_hdl_t *shp, id_t id, FILE *fp) 914{ 915 smbios_pciexrc_t pcie; 916 917 if (check_oem(shp) != 0) 918 return; 919 920 (void) smbios_info_pciexrc(shp, id, &pcie); --- 152 unchanged lines hidden (view full) --- 1073 case SMB_TYPE_BOOT: 1074 oprintf(fp, "\n"); 1075 print_boot(shp, fp); 1076 break; 1077 case SMB_TYPE_IPMIDEV: 1078 oprintf(fp, "\n"); 1079 print_ipmi(shp, fp); 1080 break; |
1081 case SMB_TYPE_OBDEVEXT: 1082 oprintf(fp, "\n"); 1083 print_obdevs_ext(shp, sp->smbstr_id, fp); 1084 break; |
|
1040 case SUN_OEM_EXT_PROCESSOR: 1041 oprintf(fp, "\n"); 1042 print_extprocessor(shp, sp->smbstr_id, fp); 1043 break; | 1085 case SUN_OEM_EXT_PROCESSOR: 1086 oprintf(fp, "\n"); 1087 print_extprocessor(shp, sp->smbstr_id, fp); 1088 break; |
1089 case SUN_OEM_EXT_PORT: 1090 oprintf(fp, "\n"); 1091 print_extport(shp, sp->smbstr_id, fp); 1092 break; |
|
1044 case SUN_OEM_PCIEXRC: 1045 oprintf(fp, "\n"); 1046 print_pciexrc(shp, sp->smbstr_id, fp); 1047 break; 1048 case SUN_OEM_EXT_MEMARRAY: 1049 oprintf(fp, "\n"); 1050 print_extmemarray(shp, sp->smbstr_id, fp); 1051 break; --- 183 unchanged lines hidden --- | 1093 case SUN_OEM_PCIEXRC: 1094 oprintf(fp, "\n"); 1095 print_pciexrc(shp, sp->smbstr_id, fp); 1096 break; 1097 case SUN_OEM_EXT_MEMARRAY: 1098 oprintf(fp, "\n"); 1099 print_extmemarray(shp, sp->smbstr_id, fp); 1100 break; --- 183 unchanged lines hidden --- |