Skip to content

Commit

Permalink
5094 Update libsmbios with recent items
Browse files Browse the repository at this point in the history
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
  • Loading branch information
Dale Ghent authored and Dan McDonald committed Mar 28, 2015
1 parent 4838646 commit 4e90188
Show file tree
Hide file tree
Showing 7 changed files with 382 additions and 79 deletions.
90 changes: 76 additions & 14 deletions usr/src/cmd/smbios/smbios.c
Expand Up @@ -20,6 +20,7 @@
*/

/*
* Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
Expand Down Expand Up @@ -337,6 +338,8 @@ print_chassis(smbios_hdl_t *shp, id_t id, FILE *fp)
(void) smbios_info_chassis(shp, id, &c);

oprintf(fp, " OEM Data: 0x%x\n", c.smbc_oemdata);
oprintf(fp, " SKU number: %s\n",
c.smbc_sku == NULL ? "<unknown>" : c.smbc_sku);
oprintf(fp, " Lock Present: %s\n", c.smbc_lock ? "Y" : "N");

desc_printf(smbios_chassis_type_desc(c.smbc_type),
Expand Down Expand Up @@ -398,6 +401,10 @@ print_processor(smbios_hdl_t *shp, id_t id, FILE *fp)
desc_printf(smbios_processor_family_desc(p.smbp_family),
fp, " Family: %u", p.smbp_family);

if (p.smbp_family2 != 0)
desc_printf(smbios_processor_family_desc(p.smbp_family2),
fp, " Family Ext: %u", p.smbp_family2);

oprintf(fp, " CPUID: 0x%llx\n", (u_longlong_t)p.smbp_cpuid);

desc_printf(smbios_processor_type_desc(p.smbp_type),
Expand Down Expand Up @@ -432,6 +439,28 @@ print_processor(smbios_hdl_t *shp, id_t id, FILE *fp)
(float)SMB_PRV_VOLTAGE(p.smbp_voltage) / 10);
}

if (p.smbp_corecount != 0)
oprintf(fp, " Core Count: %u\n", p.smbp_corecount);
else
oprintf(fp, " Core Count: Unknown\n");

if (p.smbp_coresenabled != 0)
oprintf(fp, " Cores Enabled: %u\n", p.smbp_coresenabled);
else
oprintf(fp, " Cores Enabled: Unknown\n");

if (p.smbp_threadcount != 0)
oprintf(fp, " Thread Count: %u\n", p.smbp_threadcount);
else
oprintf(fp, " Thread Count: Unknown\n");

if (p.smbp_cflags) {
flag_printf(fp, "Processor Characteristics",
p.smbp_cflags, sizeof (p.smbp_cflags) * NBBY,
smbios_processor_core_flag_name,
smbios_processor_core_flag_desc);
}

if (p.smbp_clkspeed != 0)
oprintf(fp, " External Clock Speed: %uMHz\n", p.smbp_clkspeed);
else
Expand All @@ -447,9 +476,9 @@ print_processor(smbios_hdl_t *shp, id_t id, FILE *fp)
else
oprintf(fp, " Current Speed: Unknown\n");

id_printf(fp, " L1 Cache: ", p.smbp_l1cache);
id_printf(fp, " L2 Cache: ", p.smbp_l2cache);
id_printf(fp, " L3 Cache: ", p.smbp_l3cache);
id_printf(fp, " L1 Cache: ", p.smbp_l1cache);
id_printf(fp, " L2 Cache: ", p.smbp_l2cache);
id_printf(fp, " L3 Cache: ", p.smbp_l3cache);
}

static void
Expand Down Expand Up @@ -675,11 +704,11 @@ print_bytes(const uint8_t *data, size_t size, FILE *fp)
char buf[17];
uint8_t x;

oprintf(fp, "\n offset: 0 1 2 3 4 5 6 7 8 9 a b c d e f "
oprintf(fp, "\n offset: 0 1 2 3 4 5 6 7 8 9 a b c d e f "
"0123456789abcdef\n");

for (row = 0; row < rows; row++) {
oprintf(fp, " %#4lx: ", (ulong_t)row * 16);
oprintf(fp, " %#4lx: ", (ulong_t)row * 16);
cols = MIN(size - row * 16, 16);

for (col = 0; col < cols; col++) {
Expand Down Expand Up @@ -721,7 +750,7 @@ print_memarray(smbios_hdl_t *shp, id_t id, FILE *fp)
fp, " ECC: %u", ma.smbma_ecc);

oprintf(fp, " Number of Slots/Sockets: %u\n", ma.smbma_ndevs);
id_printf(fp, " Memory Error Data: ", ma.smbma_err);
id_printf(fp, " Memory Error Data: ", ma.smbma_err);
oprintf(fp, " Max Capacity: %llu bytes\n",
(u_longlong_t)ma.smbma_size);
}
Expand All @@ -733,8 +762,8 @@ print_memdevice(smbios_hdl_t *shp, id_t id, FILE *fp)

(void) smbios_info_memdevice(shp, id, &md);

id_printf(fp, " Physical Memory Array: ", md.smbmd_array);
id_printf(fp, " Memory Error Data: ", md.smbmd_error);
id_printf(fp, " Physical Memory Array: ", md.smbmd_array);
id_printf(fp, " Memory Error Data: ", md.smbmd_error);

if (md.smbmd_twidth != -1u)
oprintf(fp, " Total Width: %u bits\n", md.smbmd_twidth);
Expand Down Expand Up @@ -768,19 +797,52 @@ print_memdevice(smbios_hdl_t *shp, id_t id, FILE *fp)
else
oprintf(fp, " Set: %u\n", md.smbmd_set);

if (md.smbmd_rank != 0) {
desc_printf(smbios_memdevice_rank_desc(md.smbmd_rank),
fp, " Rank: %u", md.smbmd_rank);
} else {
oprintf(fp, " Rank: Unknown\n");
}

desc_printf(smbios_memdevice_type_desc(md.smbmd_type),
fp, " Memory Type: %u", md.smbmd_type);

flag_printf(fp, "Flags", md.smbmd_flags, sizeof (md.smbmd_flags) * NBBY,
smbios_memdevice_flag_name, smbios_memdevice_flag_desc);

if (md.smbmd_speed != 0)
oprintf(fp, " Speed: %uns\n", md.smbmd_speed);
oprintf(fp, " Speed: %u MHz\n", md.smbmd_speed);
else
oprintf(fp, " Speed: Unknown\n");

if (md.smbmd_clkspeed != 0)
oprintf(fp, " Configured Speed: %u MHz\n", md.smbmd_clkspeed);
else
oprintf(fp, " Configured Speed: Unknown\n");

oprintf(fp, " Device Locator: %s\n", md.smbmd_dloc);
oprintf(fp, " Bank Locator: %s\n", md.smbmd_bloc);

if (md.smbmd_minvolt != 0) {
oprintf(fp, " Minimum Voltage: %.2fV\n",
md.smbmd_minvolt / 1000.0);
} else {
oprintf(fp, " Minimum Voltage: Unknown\n");
}

if (md.smbmd_maxvolt != 0) {
oprintf(fp, " Maximum Voltage: %.2fV\n",
md.smbmd_maxvolt / 1000.0);
} else {
oprintf(fp, " Maximum Voltage: Unknown\n");
}

if (md.smbmd_confvolt != 0) {
oprintf(fp, " Configured Voltage: %.2fV\n",
md.smbmd_confvolt / 1000.0);
} else {
oprintf(fp, " Configured Voltage: Unknown\n");
}
}

static void
Expand All @@ -790,7 +852,7 @@ print_memarrmap(smbios_hdl_t *shp, id_t id, FILE *fp)

(void) smbios_info_memarrmap(shp, id, &ma);

id_printf(fp, " Physical Memory Array: ", ma.smbmam_array);
id_printf(fp, " Physical Memory Array: ", ma.smbmam_array);
oprintf(fp, " Devices per Row: %u\n", ma.smbmam_width);

oprintf(fp, " Physical Address: 0x%llx\n Size: %llu bytes\n",
Expand All @@ -804,8 +866,8 @@ print_memdevmap(smbios_hdl_t *shp, id_t id, FILE *fp)

(void) smbios_info_memdevmap(shp, id, &md);

id_printf(fp, " Memory Device: ", md.smbmdm_device);
id_printf(fp, " Memory Array Mapped Address: ", md.smbmdm_arrmap);
id_printf(fp, " Memory Device: ", md.smbmdm_device);
id_printf(fp, " Memory Array Mapped Address: ", md.smbmdm_arrmap);

oprintf(fp, " Physical Address: 0x%llx\n Size: %llu bytes\n",
(u_longlong_t)md.smbmdm_addr, (u_longlong_t)md.smbmdm_size);
Expand Down Expand Up @@ -979,10 +1041,10 @@ print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp)
(uint_t)sp->smbstr_id, (ulong_t)sp->smbstr_size);

if ((s = smbios_type_name(sp->smbstr_type)) != NULL)
oprintf(fp, " %s", s);
oprintf(fp, " (%u) %s", sp->smbstr_type, s);
else if (sp->smbstr_type > SMB_TYPE_OEM_LO &&
sp->smbstr_type < SMB_TYPE_OEM_HI)
oprintf(fp, " %s+%u", "SMB_TYPE_OEM_LO",
oprintf(fp, " (%u) %s+%u", sp->smbstr_type, "SMB_TYPE_OEM_LO",
sp->smbstr_type - SMB_TYPE_OEM_LO);
else
oprintf(fp, " %u", sp->smbstr_type);
Expand Down
8 changes: 5 additions & 3 deletions usr/src/common/smbios/mktables.sh
Expand Up @@ -21,10 +21,10 @@
# CDDL HEADER END
#
#
# Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"

#
# The SMBIOS interfaces defined in <sys/smbios.h> include a set of integer-to-
Expand All @@ -48,6 +48,7 @@ SMB_CAF_ smbios_cache_flag_name uint_t
SMB_EVFL_ smbios_evlog_flag_name uint_t
SMB_IPMI_F_ smbios_ipmi_flag_name uint_t
SMB_MDF_ smbios_memdevice_flag_name uint_t
SMB_PRC_ smbios_processor_core_flag_name uint_t
SMB_TYPE_ smbios_type_name uint_t
SMB_SLCH1_ smbios_slot_ch1_name uint_t
SMB_SLCH2_ smbios_slot_ch2_name uint_t
Expand Down Expand Up @@ -81,8 +82,10 @@ SMB_MAE_ smbios_memarray_ecc_desc uint_t
SMB_MDF_ smbios_memdevice_flag_desc uint_t
SMB_MDFF_ smbios_memdevice_form_desc uint_t
SMB_MDT_ smbios_memdevice_type_desc uint_t
SMB_MDR_ smbios_memdevice_rank_desc uint_t
SMB_POC_ smbios_port_conn_desc uint_t
SMB_POT_ smbios_port_type_desc uint_t
SMB_PRC_ smbios_processor_core_flag_desc uint_t
SMB_PRF_ smbios_processor_family_desc uint_t
SMB_PRS_ smbios_processor_status_desc uint_t
SMB_PRT_ smbios_processor_type_desc uint_t
Expand All @@ -104,12 +107,11 @@ fi

echo "\
/*\n\
* Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.\n\
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.\n\
* Use is subject to license terms.\n\
*/\n\
\n\
#pragma ident\t\"%Z%%M%\t%I%\t%E% SMI\"\n\
\n\
#include <smbios.h>"

echo "$name_funcs" | while read p name type; do
Expand Down
89 changes: 67 additions & 22 deletions usr/src/common/smbios/smb_info.c
Expand Up @@ -20,6 +20,7 @@
*/

/*
* Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
Expand Down Expand Up @@ -411,28 +412,35 @@ int
smbios_info_chassis(smbios_hdl_t *shp, id_t id, smbios_chassis_t *chp)
{
const smb_struct_t *stp = smb_lookup_id(shp, id);
smb_chassis_t ch;
/* Length is measurable by one byte, so it'll be no more than 255. */
uint8_t buf[256];
smb_chassis_t *ch = (smb_chassis_t *)&buf[0];

if (stp == NULL)
return (-1); /* errno is set for us */

if (stp->smbst_hdr->smbh_type != SMB_TYPE_CHASSIS)
return (smb_set_errno(shp, ESMB_TYPE));

smb_info_bcopy(stp->smbst_hdr, &ch, sizeof (ch));
smb_info_bcopy(stp->smbst_hdr, ch, sizeof (buf));
bzero(chp, sizeof (smbios_chassis_t));

chp->smbc_oemdata = ch.smbch_oemdata;
chp->smbc_lock = (ch.smbch_type & SMB_CHT_LOCK) != 0;
chp->smbc_type = ch.smbch_type & ~SMB_CHT_LOCK;
chp->smbc_bustate = ch.smbch_bustate;
chp->smbc_psstate = ch.smbch_psstate;
chp->smbc_thstate = ch.smbch_thstate;
chp->smbc_security = ch.smbch_security;
chp->smbc_uheight = ch.smbch_uheight;
chp->smbc_cords = ch.smbch_cords;
chp->smbc_elems = ch.smbch_cn;
chp->smbc_elemlen = ch.smbch_cm;
chp->smbc_oemdata = ch->smbch_oemdata;
chp->smbc_lock = (ch->smbch_type & SMB_CHT_LOCK) != 0;
chp->smbc_type = ch->smbch_type & ~SMB_CHT_LOCK;
chp->smbc_bustate = ch->smbch_bustate;
chp->smbc_psstate = ch->smbch_psstate;
chp->smbc_thstate = ch->smbch_thstate;
chp->smbc_security = ch->smbch_security;
chp->smbc_uheight = ch->smbch_uheight;
chp->smbc_cords = ch->smbch_cords;
chp->smbc_elems = ch->smbch_cn;
chp->smbc_elemlen = ch->smbch_cm;

if (shp->sh_smbvers >= SMB_VERSION_27) {
(void) strlcpy(chp->smbc_sku, SMB_CH_SKU(ch),
sizeof (chp->smbc_sku));
}

return (0);
}
Expand Down Expand Up @@ -464,6 +472,16 @@ smbios_info_processor(smbios_hdl_t *shp, id_t id, smbios_processor_t *pp)
pp->smbp_l2cache = p.smbpr_l2cache;
pp->smbp_l3cache = p.smbpr_l3cache;

if (shp->sh_smbvers >= SMB_VERSION_25) {
pp->smbp_corecount = p.smbpr_corecount;
pp->smbp_coresenabled = p.smbpr_coresenabled;
pp->smbp_threadcount = p.smbpr_threadcount;
pp->smbp_cflags = p.smbpr_cflags;
}

if (shp->sh_smbvers >= SMB_VERSION_26)
pp->smbp_family2 = p.smbpr_family2;

return (0);
}

Expand Down Expand Up @@ -718,6 +736,8 @@ smbios_info_memarray(smbios_hdl_t *shp, id_t id, smbios_memarray_t *map)

if (m.smbmarr_cap != 0x80000000)
map->smbma_size = (uint64_t)m.smbmarr_cap * 1024;
else if (m.smbmarr_extcap != 0)
map->smbma_size = m.smbmarr_extcap;
else
map->smbma_size = 0; /* unknown */

Expand All @@ -741,9 +761,15 @@ smbios_info_memarrmap(smbios_hdl_t *shp, id_t id, smbios_memarrmap_t *map)

map->smbmam_array = m.smbamap_array;
map->smbmam_width = m.smbamap_width;
map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
map->smbmam_size = (uint64_t)
(m.smbamap_end - m.smbamap_start + 1) * 1024;

if (m.smbamap_start != 0xFFFFFFFF && m.smbamap_end != 0xFFFFFFFF) {
map->smbmam_addr = (uint64_t)m.smbamap_start * 1024;
map->smbmam_size = (uint64_t)
(m.smbamap_end - m.smbamap_start + 1) * 1024;
} else if (m.smbamap_extstart != 0 && m.smbamap_extend != 0) {
map->smbmam_addr = m.smbamap_extstart;
map->smbmam_size = m.smbamap_extend - m.smbamap_extstart + 1;
}

return (0);
}
Expand All @@ -768,7 +794,10 @@ smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp)
mdp->smbmd_twidth = m.smbmdev_twidth == 0xFFFF ? -1U : m.smbmdev_twidth;
mdp->smbmd_dwidth = m.smbmdev_dwidth == 0xFFFF ? -1U : m.smbmdev_dwidth;

if (mdp->smbmd_size != 0xFFFF) {
if (m.smbmdev_size == 0x7FFF) {
mdp->smbmd_size = (uint64_t)m.smbmdev_extsize;
mdp->smbmd_size *= 1024 * 1024; /* convert MB to bytes */
} else if (m.smbmdev_size != 0xFFFF) {
mdp->smbmd_size = (uint64_t)(m.smbmdev_size & ~SMB_MDS_KBYTES);
if (m.smbmdev_size & SMB_MDS_KBYTES)
mdp->smbmd_size *= 1024;
Expand All @@ -780,12 +809,22 @@ smbios_info_memdevice(smbios_hdl_t *shp, id_t id, smbios_memdevice_t *mdp)
mdp->smbmd_form = m.smbmdev_form;
mdp->smbmd_set = m.smbmdev_set;
mdp->smbmd_type = m.smbmdev_type;
mdp->smbmd_speed = m.smbmdev_speed;
mdp->smbmd_flags = m.smbmdev_flags;
mdp->smbmd_dloc = smb_strptr(stp, m.smbmdev_dloc);
mdp->smbmd_bloc = smb_strptr(stp, m.smbmdev_bloc);

if (m.smbmdev_speed != 0)
mdp->smbmd_speed = 1000 / m.smbmdev_speed; /* MHz -> nsec */
if (shp->sh_smbvers >= SMB_VERSION_26)
mdp->smbmd_rank = m.smbmdev_attrs & 0x0F;

if (shp->sh_smbvers >= SMB_VERSION_27)
mdp->smbmd_clkspeed = m.smbmdev_clkspeed;

if (shp->sh_smbvers >= SMB_VERSION_28) {
mdp->smbmd_minvolt = m.smbmdev_minvolt;
mdp->smbmd_maxvolt = m.smbmdev_maxvolt;
mdp->smbmd_confvolt = m.smbmdev_confvolt;
}

return (0);
}
Expand All @@ -807,13 +846,19 @@ smbios_info_memdevmap(smbios_hdl_t *shp, id_t id, smbios_memdevmap_t *mdp)

mdp->smbmdm_device = m.smbdmap_device;
mdp->smbmdm_arrmap = m.smbdmap_array;
mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
mdp->smbmdm_size = (uint64_t)
(m.smbdmap_end - m.smbdmap_start + 1) * 1024;
mdp->smbmdm_rpos = m.smbdmap_rpos;
mdp->smbmdm_ipos = m.smbdmap_ipos;
mdp->smbmdm_idepth = m.smbdmap_idepth;

if (m.smbdmap_start != 0xFFFFFFFF && m.smbdmap_end != 0xFFFFFFFF) {
mdp->smbmdm_addr = (uint64_t)m.smbdmap_start * 1024;
mdp->smbmdm_size = (uint64_t)
(m.smbdmap_end - m.smbdmap_start + 1) * 1024;
} else if (m.smbdmap_extstart != 0 && m.smbdmap_extend != 0) {
mdp->smbmdm_addr = m.smbdmap_extstart;
mdp->smbmdm_size = m.smbdmap_extend - m.smbdmap_extstart + 1;
}

return (0);
}

Expand Down

0 comments on commit 4e90188

Please sign in to comment.