|
|
fc71ac |
From 5893721859b73354a935135b4aee297bd41a5b1a Mon Sep 17 00:00:00 2001
|
|
|
fc71ac |
From: Jean Delvare <jdelvare@suse.de>
|
|
|
fc71ac |
Date: Wed, 1 Apr 2020 09:57:56 +0200
|
|
|
fc71ac |
Subject: [PATCH 15/23] dmidecode: Add helper functions pr_list_start/item/end
|
|
|
fc71ac |
|
|
|
fc71ac |
Print lists through helper functions. pr_list_start() starts the
|
|
|
fc71ac |
list, with an optional value. pr_list_item() prints a single item.
|
|
|
fc71ac |
pr_list_end() is a no-op for plain text output, but is in place in
|
|
|
fc71ac |
anticipation of supporting other output formats such as HTML.
|
|
|
fc71ac |
|
|
|
fc71ac |
Signed-off-by: Jean Delvare <jdelvare@suse.de>
|
|
|
fc71ac |
---
|
|
|
fc71ac |
dmidecode.c | 260 +++++++++++++++++++++++++++++-----------------------
|
|
|
fc71ac |
dmioutput.c | 35 +++++++
|
|
|
fc71ac |
dmioutput.h | 3 +
|
|
|
fc71ac |
3 files changed, 184 insertions(+), 114 deletions(-)
|
|
|
fc71ac |
|
|
|
fc71ac |
diff --git a/dmidecode.c b/dmidecode.c
|
|
|
fc71ac |
index 7ab058b61ef0..5a5299ed13ba 100644
|
|
|
fc71ac |
--- a/dmidecode.c
|
|
|
fc71ac |
+++ b/dmidecode.c
|
|
|
fc71ac |
@@ -340,7 +340,7 @@ static void dmi_bios_rom_size(u8 code1, u16 code2)
|
|
|
fc71ac |
pr_attr("ROM Size", "%u %s", code2 & 0x3FFF, unit[code2 >> 14]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_bios_characteristics(u64 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_bios_characteristics(u64 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.1.1 */
|
|
|
fc71ac |
static const char *characteristics[] = {
|
|
|
fc71ac |
@@ -381,18 +381,16 @@ static void dmi_bios_characteristics(u64 code, const char *prefix)
|
|
|
fc71ac |
*/
|
|
|
fc71ac |
if (code.l & (1 << 3))
|
|
|
fc71ac |
{
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, characteristics[0]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics[0]);
|
|
|
fc71ac |
return;
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
for (i = 4; i <= 31; i++)
|
|
|
fc71ac |
if (code.l & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, characteristics[i - 3]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics[i - 3]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_bios_characteristics_x1(u8 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_bios_characteristics_x1(u8 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.1.2.1 */
|
|
|
fc71ac |
static const char *characteristics[] = {
|
|
|
fc71ac |
@@ -409,11 +407,10 @@ static void dmi_bios_characteristics_x1(u8 code, const char *prefix)
|
|
|
fc71ac |
|
|
|
fc71ac |
for (i = 0; i <= 7; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, characteristics[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics[i]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_bios_characteristics_x2(u8 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_bios_characteristics_x2(u8 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 37.1.2.2 */
|
|
|
fc71ac |
static const char *characteristics[] = {
|
|
|
fc71ac |
@@ -427,8 +424,7 @@ static void dmi_bios_characteristics_x2(u8 code, const char *prefix)
|
|
|
fc71ac |
|
|
|
fc71ac |
for (i = 0; i <= 4; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, characteristics[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics[i]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
/*
|
|
|
fc71ac |
@@ -521,7 +517,7 @@ static const char *dmi_system_wake_up_type(u8 code)
|
|
|
fc71ac |
* 7.3 Base Board Information (Type 2)
|
|
|
fc71ac |
*/
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_base_board_features(u8 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_base_board_features(u8 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.3.1 */
|
|
|
fc71ac |
static const char *features[] = {
|
|
|
fc71ac |
@@ -533,17 +529,17 @@ static void dmi_base_board_features(u8 code, const char *prefix)
|
|
|
fc71ac |
};
|
|
|
fc71ac |
|
|
|
fc71ac |
if ((code & 0x1F) == 0)
|
|
|
fc71ac |
- printf(" None\n");
|
|
|
fc71ac |
+ pr_list_start("Features", "%s", "None");
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ pr_list_start("Features", NULL);
|
|
|
fc71ac |
for (i = 0; i <= 4; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, features[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", features[i]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
static const char *dmi_base_board_type(u8 code)
|
|
|
fc71ac |
@@ -570,15 +566,14 @@ static const char *dmi_base_board_type(u8 code)
|
|
|
fc71ac |
return out_of_spec;
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_base_board_handles(u8 count, const u8 *p, const char *prefix)
|
|
|
fc71ac |
+static void dmi_base_board_handles(u8 count, const u8 *p)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("%sContained Object Handles: %u\n",
|
|
|
fc71ac |
- prefix, count);
|
|
|
fc71ac |
+ pr_list_start("Contained Object Handles", "%u", count);
|
|
|
fc71ac |
for (i = 0; i < count; i++)
|
|
|
fc71ac |
- printf("%s\t0x%04X\n",
|
|
|
fc71ac |
- prefix, WORD(p + sizeof(u16) * i));
|
|
|
fc71ac |
+ pr_list_item("0x%04X", WORD(p + sizeof(u16) * i));
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
/*
|
|
|
fc71ac |
@@ -693,27 +688,29 @@ static void dmi_chassis_power_cords(u8 code)
|
|
|
fc71ac |
pr_attr("Number Of Power Cords", "%u", code);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_chassis_elements(u8 count, u8 len, const u8 *p, const char *prefix)
|
|
|
fc71ac |
+static void dmi_chassis_elements(u8 count, u8 len, const u8 *p)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("%sContained Elements: %u\n",
|
|
|
fc71ac |
- prefix, count);
|
|
|
fc71ac |
+ pr_list_start("Contained Elements", "%u", count);
|
|
|
fc71ac |
for (i = 0; i < count; i++)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
if (len >= 0x03)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
- printf("%s\t%s (",
|
|
|
fc71ac |
- prefix, p[i * len] & 0x80 ?
|
|
|
fc71ac |
+ const char *type;
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+ type = (p[i * len] & 0x80) ?
|
|
|
fc71ac |
dmi_smbios_structure_type(p[i * len] & 0x7F) :
|
|
|
fc71ac |
- dmi_base_board_type(p[i * len] & 0x7F));
|
|
|
fc71ac |
+ dmi_base_board_type(p[i * len] & 0x7F);
|
|
|
fc71ac |
+
|
|
|
fc71ac |
if (p[1 + i * len] == p[2 + i * len])
|
|
|
fc71ac |
- printf("%u", p[1 + i * len]);
|
|
|
fc71ac |
+ pr_list_item("%s (%u)", type, p[1 + i * len]);
|
|
|
fc71ac |
else
|
|
|
fc71ac |
- printf("%u-%u", p[1 + i * len], p[2 + i * len]);
|
|
|
fc71ac |
- printf(")\n");
|
|
|
fc71ac |
+ pr_list_item("%s (%u-%u)", type, p[1 + i * len],
|
|
|
fc71ac |
+ p[2 + i * len]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
/*
|
|
|
fc71ac |
@@ -1033,7 +1030,7 @@ static const char *dmi_processor_family(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_processor_id(const struct dmi_header *h, const char *prefix)
|
|
|
fc71ac |
+static void dmi_processor_id(const struct dmi_header *h)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* Intel AP-485 revision 36, table 2-4 */
|
|
|
fc71ac |
static const char *flags[32] = {
|
|
|
fc71ac |
@@ -1203,18 +1200,18 @@ static void dmi_processor_id(const struct dmi_header *h, const char *prefix)
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
edx = DWORD(p + 4);
|
|
|
fc71ac |
- printf("%sFlags:", prefix);
|
|
|
fc71ac |
if ((edx & 0xBFEFFBFF) == 0)
|
|
|
fc71ac |
- printf(" None\n");
|
|
|
fc71ac |
+ pr_list_start("Flags", "None");
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ pr_list_start("Flags", NULL);
|
|
|
fc71ac |
for (i = 0; i <= 31; i++)
|
|
|
fc71ac |
if (flags[i] != NULL && edx & (1 << i))
|
|
|
fc71ac |
- printf("%s\t%s\n", prefix, flags[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", flags[i]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
static void dmi_processor_voltage(const char *attr, u8 code)
|
|
|
fc71ac |
@@ -1373,7 +1370,7 @@ static void dmi_processor_cache(const char *attr, u16 code, const char *level,
|
|
|
fc71ac |
pr_attr(attr, "0x%04X", code);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_processor_characteristics(u16 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_processor_characteristics(const char *attr, u16 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.5.9 */
|
|
|
fc71ac |
static const char *characteristics[] = {
|
|
|
fc71ac |
@@ -1386,15 +1383,16 @@ static void dmi_processor_characteristics(u16 code, const char *prefix)
|
|
|
fc71ac |
};
|
|
|
fc71ac |
|
|
|
fc71ac |
if ((code & 0x00FC) == 0)
|
|
|
fc71ac |
- printf(" None\n");
|
|
|
fc71ac |
+ pr_attr(attr, "None");
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ pr_list_start(attr, NULL);
|
|
|
fc71ac |
for (i = 2; i <= 7; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n", prefix, characteristics[i - 2]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics[i - 2]);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
@@ -1421,7 +1419,7 @@ static const char *dmi_memory_controller_ed_method(u8 code)
|
|
|
fc71ac |
return out_of_spec;
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_memory_controller_ec_capabilities(u8 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_memory_controller_ec_capabilities(const char *attr, u8 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.6.2 */
|
|
|
fc71ac |
static const char *capabilities[] = {
|
|
|
fc71ac |
@@ -1434,15 +1432,16 @@ static void dmi_memory_controller_ec_capabilities(u8 code, const char *prefix)
|
|
|
fc71ac |
};
|
|
|
fc71ac |
|
|
|
fc71ac |
if ((code & 0x3F) == 0)
|
|
|
fc71ac |
- printf(" None\n");
|
|
|
fc71ac |
+ pr_attr(attr, "None");
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ pr_list_start(attr, NULL);
|
|
|
fc71ac |
for (i = 0; i <= 5; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n", prefix, capabilities[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", capabilities[i]);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
@@ -1464,7 +1463,7 @@ static const char *dmi_memory_controller_interleave(u8 code)
|
|
|
fc71ac |
return out_of_spec;
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_memory_controller_speeds(u16 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_memory_controller_speeds(const char *attr, u16 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.6.4 */
|
|
|
fc71ac |
const char *speeds[] = {
|
|
|
fc71ac |
@@ -1476,34 +1475,34 @@ static void dmi_memory_controller_speeds(u16 code, const char *prefix)
|
|
|
fc71ac |
};
|
|
|
fc71ac |
|
|
|
fc71ac |
if ((code & 0x001F) == 0)
|
|
|
fc71ac |
- printf(" None\n");
|
|
|
fc71ac |
+ pr_attr(attr, "None");
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ pr_list_start(attr, NULL);
|
|
|
fc71ac |
for (i = 0; i <= 4; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n", prefix, speeds[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", speeds[i]);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_memory_controller_slots(u8 count, const u8 *p, const char *prefix)
|
|
|
fc71ac |
+static void dmi_memory_controller_slots(u8 count, const u8 *p)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("%sAssociated Memory Slots: %u\n",
|
|
|
fc71ac |
- prefix, count);
|
|
|
fc71ac |
+ pr_list_start("Associated Memory Slots", "%u", count);
|
|
|
fc71ac |
for (i = 0; i < count; i++)
|
|
|
fc71ac |
- printf("%s\t0x%04X\n",
|
|
|
fc71ac |
- prefix, WORD(p + sizeof(u16) * i));
|
|
|
fc71ac |
+ pr_list_item("0x%04X", WORD(p + sizeof(u16) * i));
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
/*
|
|
|
fc71ac |
* 7.7 Memory Module Information (Type 6)
|
|
|
fc71ac |
*/
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_memory_module_types(u16 code, const char *sep)
|
|
|
fc71ac |
+static void dmi_memory_module_types(const char *attr, u16 code, int flat)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.7.1 */
|
|
|
fc71ac |
static const char *types[] = {
|
|
|
fc71ac |
@@ -1521,14 +1520,34 @@ static void dmi_memory_module_types(u16 code, const char *sep)
|
|
|
fc71ac |
};
|
|
|
fc71ac |
|
|
|
fc71ac |
if ((code & 0x07FF) == 0)
|
|
|
fc71ac |
- printf(" None");
|
|
|
fc71ac |
+ pr_attr(attr, "None");
|
|
|
fc71ac |
+ else if (flat)
|
|
|
fc71ac |
+ {
|
|
|
fc71ac |
+ char type_str[68];
|
|
|
fc71ac |
+ int i, off = 0;
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+ for (i = 0; i <= 10; i++)
|
|
|
fc71ac |
+ {
|
|
|
fc71ac |
+ if (code & (1 << i))
|
|
|
fc71ac |
+ {
|
|
|
fc71ac |
+ /* Insert space if not the first value */
|
|
|
fc71ac |
+ off += sprintf(type_str + off,
|
|
|
fc71ac |
+ off ? " %s" :"%s",
|
|
|
fc71ac |
+ types[i]);
|
|
|
fc71ac |
+ }
|
|
|
fc71ac |
+ }
|
|
|
fc71ac |
+ if (off)
|
|
|
fc71ac |
+ pr_attr(attr, type_str);
|
|
|
fc71ac |
+ }
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
+ pr_list_start(attr, NULL);
|
|
|
fc71ac |
for (i = 0; i <= 10; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s", sep, types[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", types[i]);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
@@ -1649,7 +1668,7 @@ static void dmi_cache_size(const char *attr, u16 code)
|
|
|
fc71ac |
(((u32)code & 0x8000LU) << 16) | (code & 0x7FFFLU));
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_cache_types(u16 code, const char *sep)
|
|
|
fc71ac |
+static void dmi_cache_types(const char *attr, u16 code, int flat)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.8.2 */
|
|
|
fc71ac |
static const char *types[] = {
|
|
|
fc71ac |
@@ -1663,14 +1682,34 @@ static void dmi_cache_types(u16 code, const char *sep)
|
|
|
fc71ac |
};
|
|
|
fc71ac |
|
|
|
fc71ac |
if ((code & 0x007F) == 0)
|
|
|
fc71ac |
- printf(" None");
|
|
|
fc71ac |
+ pr_attr(attr, "None");
|
|
|
fc71ac |
+ else if (flat)
|
|
|
fc71ac |
+ {
|
|
|
fc71ac |
+ char type_str[70];
|
|
|
fc71ac |
+ int i, off = 0;
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+ for (i = 0; i <= 6; i++)
|
|
|
fc71ac |
+ {
|
|
|
fc71ac |
+ if (code & (1 << i))
|
|
|
fc71ac |
+ {
|
|
|
fc71ac |
+ /* Insert space if not the first value */
|
|
|
fc71ac |
+ off += sprintf(type_str + off,
|
|
|
fc71ac |
+ off ? " %s" :"%s",
|
|
|
fc71ac |
+ types[i]);
|
|
|
fc71ac |
+ }
|
|
|
fc71ac |
+ }
|
|
|
fc71ac |
+ if (off)
|
|
|
fc71ac |
+ pr_attr(attr, type_str);
|
|
|
fc71ac |
+ }
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
+ pr_list_start(attr, NULL);
|
|
|
fc71ac |
for (i = 0; i <= 6; i++)
|
|
|
fc71ac |
if (code & (1 << i))
|
|
|
fc71ac |
- printf("%s%s", sep, types[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", types[i]);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
@@ -2053,7 +2092,7 @@ static void dmi_slot_id(u8 code1, u8 code2, u8 type)
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix)
|
|
|
fc71ac |
+static void dmi_slot_characteristics(const char *attr, u8 code1, u8 code2)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.10.6 */
|
|
|
fc71ac |
static const char *characteristics1[] = {
|
|
|
fc71ac |
@@ -2074,20 +2113,21 @@ static void dmi_slot_characteristics(u8 code1, u8 code2, const char *prefix)
|
|
|
fc71ac |
};
|
|
|
fc71ac |
|
|
|
fc71ac |
if (code1 & (1 << 0))
|
|
|
fc71ac |
- printf(" Unknown\n");
|
|
|
fc71ac |
+ pr_attr(attr, "Unknown");
|
|
|
fc71ac |
else if ((code1 & 0xFE) == 0 && (code2 & 0x07) == 0)
|
|
|
fc71ac |
- printf(" None\n");
|
|
|
fc71ac |
+ pr_attr(attr, "None");
|
|
|
fc71ac |
else
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ pr_list_start(attr, NULL);
|
|
|
fc71ac |
for (i = 1; i <= 7; i++)
|
|
|
fc71ac |
if (code1 & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n", prefix, characteristics1[i - 1]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics1[i - 1]);
|
|
|
fc71ac |
for (i = 0; i <= 3; i++)
|
|
|
fc71ac |
if (code2 & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n", prefix, characteristics2[i]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics2[i]);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
@@ -2199,15 +2239,14 @@ static void dmi_system_configuration_options(const struct dmi_header *h)
|
|
|
fc71ac |
* 7.14 BIOS Language Information (Type 13)
|
|
|
fc71ac |
*/
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_bios_languages(const struct dmi_header *h, const char *prefix)
|
|
|
fc71ac |
+static void dmi_bios_languages(const struct dmi_header *h)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
u8 *p = h->data + 4;
|
|
|
fc71ac |
u8 count = p[0x00];
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
for (i = 1; i <= count; i++)
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, dmi_string(h, i));
|
|
|
fc71ac |
+ pr_list_item("%s", dmi_string(h, i));
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
static const char *dmi_bios_language_format(u8 code)
|
|
|
fc71ac |
@@ -2222,14 +2261,14 @@ static const char *dmi_bios_language_format(u8 code)
|
|
|
fc71ac |
* 7.15 Group Associations (Type 14)
|
|
|
fc71ac |
*/
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_group_associations_items(u8 count, const u8 *p, const char *prefix)
|
|
|
fc71ac |
+static void dmi_group_associations_items(u8 count, const u8 *p)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
int i;
|
|
|
fc71ac |
|
|
|
fc71ac |
for (i = 0; i < count; i++)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
- printf("%s0x%04X (%s)\n",
|
|
|
fc71ac |
- prefix, WORD(p + 3 * i + 1),
|
|
|
fc71ac |
+ pr_list_item("0x%04X (%s)",
|
|
|
fc71ac |
+ WORD(p + 3 * i + 1),
|
|
|
fc71ac |
dmi_smbios_structure_type(p[3 * i]));
|
|
|
fc71ac |
}
|
|
|
fc71ac |
}
|
|
|
fc71ac |
@@ -3936,7 +3975,7 @@ static void dmi_tpm_vendor_id(const u8 *p)
|
|
|
fc71ac |
pr_attr("Vendor ID", "%s", vendor_id);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
-static void dmi_tpm_characteristics(u64 code, const char *prefix)
|
|
|
fc71ac |
+static void dmi_tpm_characteristics(u64 code)
|
|
|
fc71ac |
{
|
|
|
fc71ac |
/* 7.1.1 */
|
|
|
fc71ac |
static const char *characteristics[] = {
|
|
|
fc71ac |
@@ -3952,15 +3991,13 @@ static void dmi_tpm_characteristics(u64 code, const char *prefix)
|
|
|
fc71ac |
*/
|
|
|
fc71ac |
if (code.l & (1 << 2))
|
|
|
fc71ac |
{
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, characteristics[0]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics[0]);
|
|
|
fc71ac |
return;
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
for (i = 3; i <= 5; i++)
|
|
|
fc71ac |
if (code.l & (1 << i))
|
|
|
fc71ac |
- printf("%s%s\n",
|
|
|
fc71ac |
- prefix, characteristics[i - 2]);
|
|
|
fc71ac |
+ pr_list_item("%s", characteristics[i - 2]);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
|
|
|
fc71ac |
/*
|
|
|
fc71ac |
@@ -3997,12 +4034,13 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
dmi_bios_runtime_size((0x10000 - WORD(data + 0x06)) << 4);
|
|
|
fc71ac |
}
|
|
|
fc71ac |
dmi_bios_rom_size(data[0x09], h->length < 0x1A ? 16 : WORD(data + 0x18));
|
|
|
fc71ac |
- printf("\tCharacteristics:\n");
|
|
|
fc71ac |
- dmi_bios_characteristics(QWORD(data + 0x0A), "\t\t");
|
|
|
fc71ac |
+ pr_list_start("Characteristics", NULL);
|
|
|
fc71ac |
+ dmi_bios_characteristics(QWORD(data + 0x0A));
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
if (h->length < 0x13) break;
|
|
|
fc71ac |
- dmi_bios_characteristics_x1(data[0x12], "\t\t");
|
|
|
fc71ac |
+ dmi_bios_characteristics_x1(data[0x12]);
|
|
|
fc71ac |
if (h->length < 0x14) break;
|
|
|
fc71ac |
- dmi_bios_characteristics_x2(data[0x13], "\t\t");
|
|
|
fc71ac |
+ dmi_bios_characteristics_x2(data[0x13]);
|
|
|
fc71ac |
if (h->length < 0x18) break;
|
|
|
fc71ac |
if (data[0x14] != 0xFF && data[0x15] != 0xFF)
|
|
|
fc71ac |
pr_attr("BIOS Revision", "%u.%u",
|
|
|
fc71ac |
@@ -4049,8 +4087,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
pr_attr("Asset Tag", "%s",
|
|
|
fc71ac |
dmi_string(h, data[0x08]));
|
|
|
fc71ac |
if (h->length < 0x0A) break;
|
|
|
fc71ac |
- printf("\tFeatures:");
|
|
|
fc71ac |
- dmi_base_board_features(data[0x09], "\t\t");
|
|
|
fc71ac |
+ dmi_base_board_features(data[0x09]);
|
|
|
fc71ac |
if (h->length < 0x0E) break;
|
|
|
fc71ac |
pr_attr("Location In Chassis", "%s",
|
|
|
fc71ac |
dmi_string(h, data[0x0A]));
|
|
|
fc71ac |
@@ -4062,7 +4099,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
if (h->length < 0x0F) break;
|
|
|
fc71ac |
if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break;
|
|
|
fc71ac |
if (!(opt.flags & FLAG_QUIET))
|
|
|
fc71ac |
- dmi_base_board_handles(data[0x0E], data + 0x0F, "\t");
|
|
|
fc71ac |
+ dmi_base_board_handles(data[0x0E], data + 0x0F);
|
|
|
fc71ac |
break;
|
|
|
fc71ac |
|
|
|
fc71ac |
case 3: /* 7.4 Chassis Information */
|
|
|
fc71ac |
@@ -4097,7 +4134,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
dmi_chassis_power_cords(data[0x12]);
|
|
|
fc71ac |
if (h->length < 0x15) break;
|
|
|
fc71ac |
if (h->length < 0x15 + data[0x13] * data[0x14]) break;
|
|
|
fc71ac |
- dmi_chassis_elements(data[0x13], data[0x14], data + 0x15, "\t");
|
|
|
fc71ac |
+ dmi_chassis_elements(data[0x13], data[0x14], data + 0x15);
|
|
|
fc71ac |
if (h->length < 0x16 + data[0x13] * data[0x14]) break;
|
|
|
fc71ac |
pr_attr("SKU Number", "%s",
|
|
|
fc71ac |
dmi_string(h, data[0x15 + data[0x13] * data[0x14]]));
|
|
|
fc71ac |
@@ -4114,7 +4151,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
dmi_processor_family(h, ver));
|
|
|
fc71ac |
pr_attr("Manufacturer", "%s",
|
|
|
fc71ac |
dmi_string(h, data[0x07]));
|
|
|
fc71ac |
- dmi_processor_id(h, "\t");
|
|
|
fc71ac |
+ dmi_processor_id(h);
|
|
|
fc71ac |
pr_attr("Version", "%s",
|
|
|
fc71ac |
dmi_string(h, data[0x10]));
|
|
|
fc71ac |
dmi_processor_voltage("Voltage", data[0x11]);
|
|
|
fc71ac |
@@ -4158,8 +4195,8 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
pr_attr("Thread Count", "%u",
|
|
|
fc71ac |
h->length >= 0x30 && data[0x25] == 0xFF ?
|
|
|
fc71ac |
WORD(data + 0x2E) : data[0x25]);
|
|
|
fc71ac |
- printf("\tCharacteristics:");
|
|
|
fc71ac |
- dmi_processor_characteristics(WORD(data + 0x26), "\t\t");
|
|
|
fc71ac |
+ dmi_processor_characteristics("Characteristics",
|
|
|
fc71ac |
+ WORD(data + 0x26));
|
|
|
fc71ac |
break;
|
|
|
fc71ac |
|
|
|
fc71ac |
case 5: /* 7.6 Memory Controller Information */
|
|
|
fc71ac |
@@ -4167,8 +4204,8 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
if (h->length < 0x0F) break;
|
|
|
fc71ac |
pr_attr("Error Detecting Method", "%s",
|
|
|
fc71ac |
dmi_memory_controller_ed_method(data[0x04]));
|
|
|
fc71ac |
- printf("\tError Correcting Capabilities:");
|
|
|
fc71ac |
- dmi_memory_controller_ec_capabilities(data[0x05], "\t\t");
|
|
|
fc71ac |
+ dmi_memory_controller_ec_capabilities("Error Correcting Capabilities",
|
|
|
fc71ac |
+ data[0x05]);
|
|
|
fc71ac |
pr_attr("Supported Interleave", "%s",
|
|
|
fc71ac |
dmi_memory_controller_interleave(data[0x06]));
|
|
|
fc71ac |
pr_attr("Current Interleave", "%s",
|
|
|
fc71ac |
@@ -4177,17 +4214,16 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
1 << data[0x08]);
|
|
|
fc71ac |
pr_attr("Maximum Total Memory Size", "%u MB",
|
|
|
fc71ac |
data[0x0E] * (1 << data[0x08]));
|
|
|
fc71ac |
- printf("\tSupported Speeds:");
|
|
|
fc71ac |
- dmi_memory_controller_speeds(WORD(data + 0x09), "\t\t");
|
|
|
fc71ac |
- printf("\tSupported Memory Types:");
|
|
|
fc71ac |
- dmi_memory_module_types(WORD(data + 0x0B), "\n\t\t");
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ dmi_memory_controller_speeds("Supported Speeds",
|
|
|
fc71ac |
+ WORD(data + 0x09));
|
|
|
fc71ac |
+ dmi_memory_module_types("Supported Memory Types",
|
|
|
fc71ac |
+ WORD(data + 0x0B), 0);
|
|
|
fc71ac |
dmi_processor_voltage("Memory Module Voltage", data[0x0D]);
|
|
|
fc71ac |
if (h->length < 0x0F + data[0x0E] * sizeof(u16)) break;
|
|
|
fc71ac |
- dmi_memory_controller_slots(data[0x0E], data + 0x0F, "\t");
|
|
|
fc71ac |
+ dmi_memory_controller_slots(data[0x0E], data + 0x0F);
|
|
|
fc71ac |
if (h->length < 0x10 + data[0x0E] * sizeof(u16)) break;
|
|
|
fc71ac |
- printf("\tEnabled Error Correcting Capabilities:");
|
|
|
fc71ac |
- dmi_memory_controller_ec_capabilities(data[0x0F + data[0x0E] * sizeof(u16)], "\t\t");
|
|
|
fc71ac |
+ dmi_memory_controller_ec_capabilities("Enabled Error Correcting Capabilities",
|
|
|
fc71ac |
+ data[0x0F + data[0x0E] * sizeof(u16)]);
|
|
|
fc71ac |
break;
|
|
|
fc71ac |
|
|
|
fc71ac |
case 6: /* 7.7 Memory Module Information */
|
|
|
fc71ac |
@@ -4197,9 +4233,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
dmi_string(h, data[0x04]));
|
|
|
fc71ac |
dmi_memory_module_connections(data[0x05]);
|
|
|
fc71ac |
dmi_memory_module_speed("Current Speed", data[0x06]);
|
|
|
fc71ac |
- printf("\tType:");
|
|
|
fc71ac |
- dmi_memory_module_types(WORD(data + 0x07), " ");
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ dmi_memory_module_types("Type", WORD(data + 0x07), 1);
|
|
|
fc71ac |
dmi_memory_module_size("Installed Size", data[0x09]);
|
|
|
fc71ac |
dmi_memory_module_size("Enabled Size", data[0x0A]);
|
|
|
fc71ac |
dmi_memory_module_error(data[0x0B]);
|
|
|
fc71ac |
@@ -4226,12 +4260,8 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
dmi_cache_size_2("Maximum Size", DWORD(data + 0x13));
|
|
|
fc71ac |
else
|
|
|
fc71ac |
dmi_cache_size("Maximum Size", WORD(data + 0x07));
|
|
|
fc71ac |
- printf("\tSupported SRAM Types:");
|
|
|
fc71ac |
- dmi_cache_types(WORD(data + 0x0B), "\n\t\t");
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
- printf("\tInstalled SRAM Type:");
|
|
|
fc71ac |
- dmi_cache_types(WORD(data + 0x0D), " ");
|
|
|
fc71ac |
- printf("\n");
|
|
|
fc71ac |
+ dmi_cache_types("Supported SRAM Types", WORD(data + 0x0B), 0);
|
|
|
fc71ac |
+ dmi_cache_types("Installed SRAM Type", WORD(data + 0x0D), 1);
|
|
|
fc71ac |
if (h->length < 0x13) break;
|
|
|
fc71ac |
dmi_memory_module_speed("Speed", data[0x0F]);
|
|
|
fc71ac |
pr_attr("Error Correction Type", "%s",
|
|
|
fc71ac |
@@ -4270,11 +4300,10 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
pr_attr("Length", "%s",
|
|
|
fc71ac |
dmi_slot_length(data[0x08]));
|
|
|
fc71ac |
dmi_slot_id(data[0x09], data[0x0A], data[0x05]);
|
|
|
fc71ac |
- printf("\tCharacteristics:");
|
|
|
fc71ac |
if (h->length < 0x0D)
|
|
|
fc71ac |
- dmi_slot_characteristics(data[0x0B], 0x00, "\t\t");
|
|
|
fc71ac |
+ dmi_slot_characteristics("Characteristics", data[0x0B], 0x00);
|
|
|
fc71ac |
else
|
|
|
fc71ac |
- dmi_slot_characteristics(data[0x0B], data[0x0C], "\t\t");
|
|
|
fc71ac |
+ dmi_slot_characteristics("Characteristics", data[0x0B], data[0x0C]);
|
|
|
fc71ac |
if (h->length < 0x11) break;
|
|
|
fc71ac |
dmi_slot_segment_bus_func(WORD(data + 0x0D), data[0x0F], data[0x10]);
|
|
|
fc71ac |
if (h->length < 0x13) break;
|
|
|
fc71ac |
@@ -4308,8 +4337,9 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
pr_attr("Language Description Format", "%s",
|
|
|
fc71ac |
dmi_bios_language_format(data[0x05]));
|
|
|
fc71ac |
}
|
|
|
fc71ac |
- printf("\tInstallable Languages: %u\n", data[0x04]);
|
|
|
fc71ac |
- dmi_bios_languages(h, "\t\t");
|
|
|
fc71ac |
+ pr_list_start("Installable Languages", "%u", data[0x04]);
|
|
|
fc71ac |
+ dmi_bios_languages(h);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
pr_attr("Currently Installed Language", "%s",
|
|
|
fc71ac |
dmi_string(h, data[0x15]));
|
|
|
fc71ac |
break;
|
|
|
fc71ac |
@@ -4319,9 +4349,10 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
if (h->length < 0x05) break;
|
|
|
fc71ac |
pr_attr("Name", "%s",
|
|
|
fc71ac |
dmi_string(h, data[0x04]));
|
|
|
fc71ac |
- printf("\tItems: %u\n",
|
|
|
fc71ac |
+ pr_list_start("Items", "%u",
|
|
|
fc71ac |
(h->length - 0x05) / 3);
|
|
|
fc71ac |
- dmi_group_associations_items((h->length - 0x05) / 3, data + 0x05, "\t\t");
|
|
|
fc71ac |
+ dmi_group_associations_items((h->length - 0x05) / 3, data + 0x05);
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
break;
|
|
|
fc71ac |
|
|
|
fc71ac |
case 15: /* 7.16 System Event Log */
|
|
|
fc71ac |
@@ -5002,8 +5033,9 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
|
|
|
fc71ac |
break;
|
|
|
fc71ac |
}
|
|
|
fc71ac |
pr_attr("Description", "%s", dmi_string(h, data[0x12]));
|
|
|
fc71ac |
- printf("\tCharacteristics:\n");
|
|
|
fc71ac |
- dmi_tpm_characteristics(QWORD(data + 0x13), "\t\t");
|
|
|
fc71ac |
+ pr_list_start("Characteristics", NULL);
|
|
|
fc71ac |
+ dmi_tpm_characteristics(QWORD(data + 0x13));
|
|
|
fc71ac |
+ pr_list_end();
|
|
|
fc71ac |
if (h->length < 0x1F) break;
|
|
|
fc71ac |
pr_attr("OEM-specific Information", "0x%08X",
|
|
|
fc71ac |
DWORD(data + 0x1B));
|
|
|
fc71ac |
diff --git a/dmioutput.c b/dmioutput.c
|
|
|
fc71ac |
index 2330b65755c9..4c8a32a3569a 100644
|
|
|
fc71ac |
--- a/dmioutput.c
|
|
|
fc71ac |
+++ b/dmioutput.c
|
|
|
fc71ac |
@@ -71,3 +71,38 @@ void pr_attr(const char *name, const char *format, ...)
|
|
|
fc71ac |
va_end(args);
|
|
|
fc71ac |
printf("\n");
|
|
|
fc71ac |
}
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+void pr_list_start(const char *name, const char *format, ...)
|
|
|
fc71ac |
+{
|
|
|
fc71ac |
+ va_list args;
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+ printf("\t%s:", name);
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+ /* format is optional, skip value if not provided */
|
|
|
fc71ac |
+ if (format)
|
|
|
fc71ac |
+ {
|
|
|
fc71ac |
+ printf(" ");
|
|
|
fc71ac |
+ va_start(args, format);
|
|
|
fc71ac |
+ vprintf(format, args);
|
|
|
fc71ac |
+ va_end(args);
|
|
|
fc71ac |
+ }
|
|
|
fc71ac |
+ printf("\n");
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+}
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+void pr_list_item(const char *format, ...)
|
|
|
fc71ac |
+{
|
|
|
fc71ac |
+ va_list args;
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+ printf("\t\t");
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+ va_start(args, format);
|
|
|
fc71ac |
+ vprintf(format, args);
|
|
|
fc71ac |
+ va_end(args);
|
|
|
fc71ac |
+ printf("\n");
|
|
|
fc71ac |
+}
|
|
|
fc71ac |
+
|
|
|
fc71ac |
+void pr_list_end(void)
|
|
|
fc71ac |
+{
|
|
|
fc71ac |
+ /* a no-op for text output */
|
|
|
fc71ac |
+}
|
|
|
fc71ac |
diff --git a/dmioutput.h b/dmioutput.h
|
|
|
fc71ac |
index 981dcb45f26a..33f09c4452bb 100644
|
|
|
fc71ac |
--- a/dmioutput.h
|
|
|
fc71ac |
+++ b/dmioutput.h
|
|
|
fc71ac |
@@ -26,3 +26,6 @@ void pr_info(const char *format, ...);
|
|
|
fc71ac |
void pr_handle(const struct dmi_header *h);
|
|
|
fc71ac |
void pr_handle_name(const char *format, ...);
|
|
|
fc71ac |
void pr_attr(const char *name, const char *format, ...);
|
|
|
fc71ac |
+void pr_list_start(const char *name, const char *format, ...);
|
|
|
fc71ac |
+void pr_list_item(const char *format, ...);
|
|
|
fc71ac |
+void pr_list_end(void);
|
|
|
fc71ac |
--
|
|
|
fc71ac |
2.17.1
|
|
|
fc71ac |
|