diff options
-rw-r--r-- | usr/src/cmd/smbios/smbios.c | 52 | ||||
-rw-r--r-- | usr/src/common/smbios/mktables.sh | 1 | ||||
-rw-r--r-- | usr/src/common/smbios/smb_info.c | 70 | ||||
-rw-r--r-- | usr/src/lib/libsmbios/common/mapfile-vers | 2 | ||||
-rw-r--r-- | usr/src/uts/common/sys/smbios.h | 31 |
5 files changed, 156 insertions, 0 deletions
diff --git a/usr/src/cmd/smbios/smbios.c b/usr/src/cmd/smbios/smbios.c index 2c0c844674..0d3f110961 100644 --- a/usr/src/cmd/smbios/smbios.c +++ b/usr/src/cmd/smbios/smbios.c @@ -1467,6 +1467,54 @@ print_processor_info(smbios_hdl_t *shp, id_t id, FILE *fp) } static void +print_battery(smbios_hdl_t *shp, id_t id, FILE *fp) +{ + smbios_battery_t bat; + + if (smbios_info_battery(shp, id, &bat) != 0) { + smbios_warn(shp, "failed to read battery information"); + return; + } + + if (bat.smbb_date != NULL) { + oprintf(fp, " Manufacture Date: %s\n", bat.smbb_date); + } + + if (bat.smbb_serial != NULL) { + oprintf(fp, " Serial Number: %s\n", bat.smbb_serial); + } + + if (bat.smbb_chem != SMB_BDC_UNKNOWN) { + desc_printf(smbios_battery_chem_desc(bat.smbb_chem), + fp, " Battery Chemistry: 0x%x", bat.smbb_chem); + } + + if (bat.smbb_cap != 0) { + oprintf(fp, " Design Capacity: %u mWh\n", bat.smbb_cap); + } else { + oprintf(fp, " Design Capacity: unknown\n"); + } + + if (bat.smbb_volt != 0) { + oprintf(fp, " Design Voltage: %u mV\n", bat.smbb_volt); + } else { + oprintf(fp, " Design Voltage: unknown\n"); + } + + oprintf(fp, " SBDS Version Number: %s\n", bat.smbb_version); + if (bat.smbb_err != UINT8_MAX) { + oprintf(fp, " Maximum Error: %u\n", bat.smbb_err); + } else { + oprintf(fp, " Maximum Error: unknown\n", bat.smbb_err); + } + oprintf(fp, " SBDS Serial Number: %04x\n", bat.smbb_ssn); + oprintf(fp, " SBDS Manufacture Date: %u-%02u-%02u\n", bat.smbb_syear, + bat.smbb_smonth, bat.smbb_sday); + oprintf(fp, " SBDS Device Chemistry: %s\n", bat.smbb_schem); + oprintf(fp, " OEM-specific Information: 0x%08x\n", bat.smbb_oemdata); +} + +static void print_pointdev(smbios_hdl_t *shp, id_t id, FILE *fp) { smbios_pointdev_t pd; @@ -1678,6 +1726,10 @@ print_struct(smbios_hdl_t *shp, const smbios_struct_t *sp, void *fp) oprintf(fp, "\n"); print_memdevmap(shp, sp->smbstr_id, fp); break; + case SMB_TYPE_BATTERY: + oprintf(fp, "\n"); + print_battery(shp, sp->smbstr_id, fp); + break; case SMB_TYPE_POINTDEV: oprintf(fp, "\n"); print_pointdev(shp, sp->smbstr_id, fp); diff --git a/usr/src/common/smbios/mktables.sh b/usr/src/common/smbios/mktables.sh index bb6c077791..95bd9d6f8b 100644 --- a/usr/src/common/smbios/mktables.sh +++ b/usr/src/common/smbios/mktables.sh @@ -62,6 +62,7 @@ SMB_SLCH2_ smbios_slot_ch2_name uint_t desc_funcs=' SMB_BBFL_ smbios_bboard_flag_desc uint_t SMB_BBT_ smbios_bboard_type_desc uint_t +SMB_BDC_ smbios_battery_chem_desc uint_t SMB_BIOSFL_ smbios_bios_flag_desc uint64_t SMB_BIOSXB1_ smbios_bios_xb1_desc uint_t SMB_BIOSXB2_ smbios_bios_xb2_desc uint_t diff --git a/usr/src/common/smbios/smb_info.c b/usr/src/common/smbios/smb_info.c index c4376fd081..47c19e7fcb 100644 --- a/usr/src/common/smbios/smb_info.c +++ b/usr/src/common/smbios/smb_info.c @@ -198,6 +198,23 @@ static const struct smb_infospec { 0, 0, 0 }, + { SMB_TYPE_BATTERY, + offsetof(smb_battery_t, smbbat_manufacturer), + offsetof(smb_battery_t, smbbat_devname), + 0, + /* + * While the serial number is a part of the device, because of + * the fact that the battery has two different serial numbers, + * we don't include it here. + */ + 0, + 0, + offsetof(smb_battery_t, smbbat_loc), + 0, + 0, + 0, + 0 + }, { SMB_TYPE_EOT } }; @@ -1698,3 +1715,56 @@ smbios_info_pointdev(smbios_hdl_t *shp, id_t id, smbios_pointdev_t *pd) return (0); } + +int +smbios_info_battery(smbios_hdl_t *shp, id_t id, smbios_battery_t *bp) +{ + const smb_struct_t *stp = smb_lookup_id(shp, id); + smb_battery_t bat; + + if (stp->smbst_hdr->smbh_type != SMB_TYPE_BATTERY) { + return (smb_set_errno(shp, ESMB_TYPE)); + } + + if (stp->smbst_hdr->smbh_len < sizeof (bat)) { + return (smb_set_errno(shp, ESMB_SHORT)); + } + + bzero(bp, sizeof (*bp)); + smb_info_bcopy(stp->smbst_hdr, &bat, sizeof (bat)); + + /* + * This may be superseded by the SBDS data. + */ + if (bat.smbbat_date != 0) { + bp->smbb_date = smb_strptr(stp, bat.smbbat_date); + } else { + bp->smbb_date = NULL; + } + + /* + * This may be superseded by the SBDS data. + */ + if (bat.smbbat_serial != 0) { + bp->smbb_serial = smb_strptr(stp, bat.smbbat_serial); + } else { + bp->smbb_serial = NULL; + } + + bp->smbb_chem = bat.smbbat_chem; + bp->smbb_cap = bat.smbbat_cap; + if (bat.smbbat_mult > 0) { + bp->smbb_cap *= bat.smbbat_mult; + } + bp->smbb_volt = bat.smbbat_volt; + bp->smbb_version = smb_strptr(stp, bat.smbbat_version); + bp->smbb_err = bat.smbbat_err; + bp->smbb_ssn = bat.smbbat_ssn; + bp->smbb_syear = 1980 + (bat.smbbat_sdate >> 9); + bp->smbb_smonth = (bat.smbbat_sdate >> 5) & 0xf; + bp->smbb_sday = bat.smbbat_sdate & 0x1f; + bp->smbb_schem = smb_strptr(stp, bat.smbbat_schem); + bp->smbb_oemdata = bat.smbbat_oemdata; + + return (0); +} diff --git a/usr/src/lib/libsmbios/common/mapfile-vers b/usr/src/lib/libsmbios/common/mapfile-vers index dd09785fe3..1016220cd7 100644 --- a/usr/src/lib/libsmbios/common/mapfile-vers +++ b/usr/src/lib/libsmbios/common/mapfile-vers @@ -43,6 +43,7 @@ $mapfile_version 2 SYMBOL_VERSION SUNWprivate_1.1 { global: _smb_debug; + smbios_battery_chem_desc; smbios_bboard_flag_desc; smbios_bboard_flag_name; smbios_bboard_type_desc; @@ -80,6 +81,7 @@ SYMBOL_VERSION SUNWprivate_1.1 { smbios_evlog_method_desc; smbios_fdopen; smbios_hwsec_desc; + smbios_info_battery; smbios_info_bboard; smbios_info_bios; smbios_info_boot; diff --git a/usr/src/uts/common/sys/smbios.h b/usr/src/uts/common/sys/smbios.h index 82a81b5a28..34281898e0 100644 --- a/usr/src/uts/common/sys/smbios.h +++ b/usr/src/uts/common/sys/smbios.h @@ -1379,6 +1379,34 @@ typedef struct smbios_pointdev { #define SMB_PDI_BUSM_USB 0xA2 /* USB */ /* + * SMBIOS Portable Battery. See DSP0134 Section 7.23 for more information. + */ +typedef struct smbios_battery { + const char *smbb_date; /* Manufacture date */ + const char *smbb_serial; /* Serial number */ + uint8_t smbb_chem; /* Device Chemistry */ + uint32_t smbb_cap; /* Design Capacity */ + uint16_t smbb_volt; /* Design Voltage */ + const char *smbb_version; /* Smart Battery version */ + uint8_t smbb_err; /* Maximum error */ + uint16_t smbb_ssn; /* SBDS serial number */ + uint16_t smbb_syear; /* SBDS manufacture year */ + uint8_t smbb_smonth; /* SBDS manufacture month */ + uint8_t smbb_sday; /* SBDS manufacture day */ + const char *smbb_schem; /* SBDS chemistry */ + uint32_t smbb_oemdata; /* OEM data */ +} smbios_battery_t; + +#define SMB_BDC_OTHER 0x01 /* Other */ +#define SMB_BDC_UNKNOWN 0x02 /* Unknown */ +#define SMB_BDC_LEADACID 0x03 /* Lead Acid */ +#define SMB_BDC_NICD 0x04 /* Nickel Cadmium */ +#define SMB_BDC_NIMH 0x05 /* Nickel Metal hydride */ +#define SMB_BDC_LIB 0x06 /* Lithium-ion */ +#define SMB_BDC_ZINCAIR 0x07 /* Zinc air */ +#define SMB_BDC_LIPO 0x08 /* Lithium Polymer */ + +/* * SMBIOS Hardware Security Settings. See DSP0134 Section 7.25 for more * information. Only one such record will be present in the SMBIOS. */ @@ -1867,6 +1895,7 @@ extern int smbios_info_extprocessor(smbios_hdl_t *, id_t, smbios_processor_ext_t *); extern int smbios_info_cache(smbios_hdl_t *, id_t, smbios_cache_t *); extern int smbios_info_pointdev(smbios_hdl_t *, id_t, smbios_pointdev_t *); +extern int smbios_info_battery(smbios_hdl_t *, id_t, smbios_battery_t *); extern int smbios_info_port(smbios_hdl_t *, id_t, smbios_port_t *); extern int smbios_info_extport(smbios_hdl_t *, id_t, smbios_port_ext_t *); extern int smbios_info_slot(smbios_hdl_t *, id_t, smbios_slot_t *); @@ -1912,6 +1941,8 @@ extern const char *smbios_csn(smbios_hdl_t *); * functions return the comment string next to the #defines listed above, and * the _name functions return the appropriate #define identifier itself. */ +extern const char *smbios_battery_chem_desc(uint_t); + extern const char *smbios_bboard_flag_desc(uint_t); extern const char *smbios_bboard_flag_name(uint_t); extern const char *smbios_bboard_type_desc(uint_t); |