Skip to content

Commit

Permalink
14231 want support for SMBIOS 3.5
Browse files Browse the repository at this point in the history
14232 several smbios_info_* routines don't check for bad ids
14233 smbios_info_chassis calculates sku number incorrectly
14234 smbios chassis elements need work
Reviewed by: Yuri Pankov <ypankov@tintri.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Rich Lowe <richlowe@richlowe.net>
  • Loading branch information
rmustacc committed Nov 19, 2021
1 parent e43afc9 commit d53cdfa
Show file tree
Hide file tree
Showing 17 changed files with 2,592 additions and 149 deletions.
147 changes: 120 additions & 27 deletions usr/src/cmd/smbios/smbios.c
Expand Up @@ -480,7 +480,8 @@ static void
print_chassis(smbios_hdl_t *shp, id_t id, FILE *fp)
{
smbios_chassis_t c;
int elem_cnt;
smbios_chassis_entry_t *elts;
uint_t nelts, i;

(void) smbios_info_chassis(shp, id, &c);

Expand All @@ -504,35 +505,38 @@ print_chassis(smbios_hdl_t *shp, id_t id, FILE *fp)
oprintf(fp, " Chassis Height: %uu\n", c.smbc_uheight);
oprintf(fp, " Power Cords: %u\n", c.smbc_cords);

elem_cnt = c.smbc_elems;
oprintf(fp, " Element Records: %u\n", elem_cnt);
oprintf(fp, " Element Records: %u\n", c.smbc_elems);

if (elem_cnt > 0) {
id_t *elems;
uint8_t type;
int i, n, cnt;
if (c.smbc_elems == 0) {
return;
}

elems = alloca(c.smbc_elems * sizeof (id_t));
cnt = smbios_info_contains(shp, id, elem_cnt, elems);
if (cnt > SMB_CONT_MAX)
return;
n = MIN(elem_cnt, cnt);
if (smbios_info_chassis_elts(shp, id, &nelts, &elts) != 0) {
smbios_warn(shp, "failed to read chassis elements");
return;
}

oprintf(fp, "\n");
for (i = 0; i < n; i++) {
type = (uint8_t)elems[i];
if (type & 0x80) {
/* SMBIOS structrure Type */
desc_printf(smbios_type_name(type & 0x7f), fp,
" Contained SMBIOS structure Type: %u",
type & 0x80);
} else {
/* SMBIOS Base Board Type */
desc_printf(smbios_bboard_type_desc(type), fp,
" Contained SMBIOS Base Board Type: 0x%x",
type);
}
oprintf(fp, "\n");

for (i = 0; i < nelts; i++) {
switch (elts[i].smbce_type) {
case SMB_CELT_BBOARD:
desc_printf(smbios_bboard_type_desc(elts[i].smbce_elt),
fp, " Contained SMBIOS Base Board Type: 0x%x",
elts[i].smbce_elt);
break;
case SMB_CELT_SMBIOS:
desc_printf(smbios_type_name(elts[i].smbce_elt), fp,
" Contained SMBIOS structure Type: %u",
elts[i].smbce_elt);
break;
default:
oprintf(fp, " Unknown contained Type: %u/%u\n",
elts[i].smbce_type, elts[i].smbce_elt);
break;
}
oprintf(fp, " Minimum number: %u\n", elts[i].smbce_min);
oprintf(fp, " Maximum number: %u\n", elts[i].smbce_max);
}
}

Expand Down Expand Up @@ -782,6 +786,19 @@ print_slot(smbios_hdl_t *shp, id_t id, FILE *fp)
oprintf(fp, " Slot Pitch: %u.%u mm\n", s.smbl_pitch / 100,
s.smbl_pitch % 100);
}

/*
* The slot height was introduced in SMBIOS 3.5. However, a value of
* zero here does not mean that it is unknown, but rather that the
* concept is not applicable. Therefore we cannot use a standard check
* against zero for this and instead use the version.
*/
if (smbios_vergteq(&v, 3, 5)) {
desc_printf(smbios_slot_height_desc(s.smbl_height), fp,
" Height: 0x%x", s.smbl_height);
} else {
oprintf(fp, " Height: unknown\n");
}
}

static void
Expand All @@ -798,7 +815,7 @@ print_obdevs_ext(smbios_hdl_t *shp, id_t id, FILE *fp)
* are the actual device type.
*/
enabled = oe.smboe_dtype >> 7;
type = smbios_onboard_type_desc(oe.smboe_dtype & 0x7f);
type = smbios_onboard_ext_type_desc(oe.smboe_dtype & 0x7f);

str_print(fp, " Reference Designator", oe.smboe_name);
oprintf(fp, " Device Enabled: %s\n", enabled == B_TRUE ? "true" :
Expand Down Expand Up @@ -1685,6 +1702,74 @@ print_extmemdevice(smbios_hdl_t *shp, id_t id, FILE *fp)
}
}

static void
print_strprop_info(smbios_hdl_t *shp, id_t id, FILE *fp)
{
smbios_strprop_t prop;

if (smbios_info_strprop(shp, id, &prop) != 0) {
smbios_warn(shp, "failed to read string property information");
return;
}

desc_printf(smbios_strprop_id_desc(prop.smbsp_prop_id), fp,
" Property ID: %u", prop.smbsp_prop_id);
if (prop.smbsp_prop_val != NULL) {
str_print(fp, " Property Value", prop.smbsp_prop_val);
}
id_printf(fp, " Parent Handle: ", prop.smbsp_parent);
}

static void
print_fwinfo(smbios_hdl_t *shp, id_t id, FILE *fp)
{
smbios_fwinfo_t fw;
smbios_fwinfo_comp_t *comps;
uint_t ncomps, i;

if (smbios_info_fwinfo(shp, id, &fw) != 0) {
smbios_warn(shp, "failed to read firmware inventory");
return;
}

str_print(fp, " Component Name", fw.smbfw_name);
str_print(fp, " ID", fw.smbfw_id);
str_print(fp, " Release Date", fw.smbfw_reldate);
str_print(fp, " Lowest Supported Version", fw.smbfw_lsv);
desc_printf(smbios_fwinfo_vers_desc(fw.smbfw_vers_fmt), fp,
" Version Format: %u", fw.smbfw_vers_fmt);
desc_printf(smbios_fwinfo_id_desc(fw.smbfw_id_fmt), fp,
" ID Format: %u", fw.smbfw_id_fmt);
if (fw.smbfw_imgsz != UINT64_MAX) {
oprintf(fp, " Image Size: %" PRIu64 "\n", fw.smbfw_imgsz);
} else {
oprintf(fp, " Image Size: unknown\n");
}

flag_printf(fp, "Characteristics", fw.smbfw_chars,
sizeof (fw.smbfw_chars) * NBBY, smbios_fwinfo_ch_name,
smbios_fwinfo_ch_desc);

desc_printf(smbios_fwinfo_state_desc(fw.smbfw_state), fp, " State: %u",
fw.smbfw_state);
oprintf(fp, " Number of Associated Components: %u\n",
fw.smbfw_ncomps);

if (fw.smbfw_ncomps == 0)
return;

if (smbios_info_fwinfo_comps(shp, id, &ncomps, &comps) == -1) {
smbios_warn(shp, "failed to read firmware inventory "
"components");
return;
}

oprintf(fp, "\n Component Handles:\n");
for (i = 0; i < ncomps; i++) {
oprintf(fp, " %ld\n", comps[i]);
}
}

static int
print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp)
{
Expand Down Expand Up @@ -1841,6 +1926,14 @@ print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp)
oprintf(fp, "\n");
print_processor_info(shp, sp->smbstr_id, fp);
break;
case SMB_TYPE_STRPROP:
oprintf(fp, "\n");
print_strprop_info(shp, sp->smbstr_id, fp);
break;
case SMB_TYPE_FWINFO:
oprintf(fp, "\n");
print_fwinfo(shp, sp->smbstr_id, fp);
break;
case SUN_OEM_EXT_PROCESSOR:
oprintf(fp, "\n");
print_extprocessor(shp, sp->smbstr_id, fp);
Expand Down
13 changes: 11 additions & 2 deletions usr/src/common/smbios/mktables.sh
Expand Up @@ -23,6 +23,7 @@
#
# Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright (c) 2018, Joyent, Inc.
# Copyright 2021 Oxide Computer Company
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
Expand All @@ -47,6 +48,7 @@ SMB_BIOSXB2_ smbios_bios_xb2_name uint_t
SMB_CAT_ smbios_cache_ctype_name uint_t
SMB_CAF_ smbios_cache_flag_name uint_t
SMB_EVFL_ smbios_evlog_flag_name uint_t
SMB_FWC_ smbios_fwinfo_ch_name uint_t
SMB_IPMI_F_ smbios_ipmi_flag_name uint_t
SMB_POWERSUP_F_ smbios_powersup_flag_name uint_t
SMB_MOMC_ smbios_memdevice_op_capab_name uint_t
Expand Down Expand Up @@ -81,6 +83,10 @@ SMB_COOLDEV_T_ smbios_cooldev_type_desc uint_t
SMB_EVFL_ smbios_evlog_flag_desc uint_t
SMB_EVHF_ smbios_evlog_format_desc uint_t
SMB_EVM_ smbios_evlog_method_desc uint_t
SMB_FWC_ smbios_fwinfo_ch_desc uint_t
SMB_FWI_ smbios_fwinfo_id_desc uint_t
SMB_FWS_ smbios_fwinfo_state_desc uint_t
SMB_FWV_ smbios_fwinfo_vers_desc uint_t
SMB_HWSEC_PS_ smbios_hwsec_desc uint_t
SMB_IPMI_F_ smbios_ipmi_flag_desc uint_t
SMB_IPMI_T_ smbios_ipmi_type_desc uint_t
Expand All @@ -100,6 +106,7 @@ SMB_MDR_ smbios_memdevice_rank_desc uint_t
SMB_MTECH_ smbios_memdevice_memtech_desc uint_t
SMB_MOMC_ smbios_memdevice_op_capab_desc uint_t
SMB_OBT_ smbios_onboard_type_desc uint_t
SMB_OBET_ smbios_onboard_ext_type_desc uint_t
SMB_PDI_ smbios_pointdev_iface_desc uint_t
SMB_PDT_ smbios_pointdev_type_desc uint_t
SMB_POC_ smbios_port_conn_desc uint_t
Expand All @@ -115,10 +122,12 @@ SMB_RV_PRIV_ smbios_riscv_priv_desc uint_t
SMB_RV_WIDTH_ smbios_riscv_width_desc uint_t
SMB_SLCH1_ smbios_slot_ch1_desc uint_t
SMB_SLCH2_ smbios_slot_ch2_desc uint_t
SMB_SLHT_ smbios_slot_height_desc uint_t
SMB_SLL_ smbios_slot_length_desc uint_t
SMB_SLT_ smbios_slot_type_desc uint_t
SMB_SLU_ smbios_slot_usage_desc uint_t
SMB_SLW_ smbios_slot_width_desc uint_t
SMB_STRP_ smbios_strprop_id_desc uint_t
SMB_TPROBE_L_ smbios_tprobe_loc_desc uint_t
SMB_TPROBE_S_ smbios_tprobe_status_desc uint_t
SMB_TYPE_ smbios_type_desc uint_t
Expand All @@ -143,7 +152,7 @@ echo "\

echo "$name_funcs" | while read p name type; do
[ -z "$p" ] && continue
pattern="^#define[ ]\($p[A-Za-z0-9_]*\)[ ]*[A-Z0-9]*.*$"
pattern="^#define[ ]\(${p}[A-Za-z0-9_]*\)[ ]*[A-Z0-9]*.*\$"
replace=' case \1: return ("\1");'

echo "\nconst char *\n$name($type x)\n{\n\tswitch (x) {"
Expand All @@ -162,7 +171,7 @@ done
#
echo "$desc_funcs" | while read p name type; do
[ -z "$p" ] && continue
pattern="^#define[ ]\($p[A-Za-z0-9_]*\)[ ]*.*/\\* \(.*\) \\*/$"
pattern="^#define[ ]\(${p}[A-Za-z0-9_]*\)[ ]*.*/\\* \(.*\) \\*/\$"
replace=' case \1: return (\2);'

echo "\nconst char *\n$name($type x)\n{\n\tswitch (x) {"
Expand Down

0 comments on commit d53cdfa

Please sign in to comment.