summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2022-05-20 09:54:36 +0200
committerJean Delvare <jdelvare@suse.de>2022-05-20 09:54:36 +0200
commit1286fc98c4f621b608de2903e30be710123d1128 (patch)
tree73405a168bf1367b6ed37b2e8699fd40747a2f3c
parent9060fb8f9d262cca1d44c683c81af4a1ca4c384a (diff)
downloaddmidecode-git-1286fc98c4f621b608de2903e30be710123d1128.tar.gz
dmidecode: Save the CPUID format
In order to decode the information from HPE type 199 in a human-friendly way, we need to know how the CPUID data is encoded. This depends on the CPU brand and family, so save this information for later. Signed-off-by: Jean Delvare <jdelvare@suse.de>
-rw-r--r--dmidecode.c10
-rw-r--r--dmidecode.h2
2 files changed, 8 insertions, 4 deletions
diff --git a/dmidecode.c b/dmidecode.c
index 1a4ddae..73e455f 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -85,6 +85,8 @@
#define out_of_spec "<OUT OF SPEC>"
static const char *bad_index = "<BAD INDEX>";
+enum cpuid_type cpuid_type = cpuid_none;
+
#define SUPPORTED_SMBIOS_VER 0x030300
#define FLAG_NO_FILE_OFFSET (1 << 0)
@@ -5250,7 +5252,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
u8 *data;
int i = 0;
- /* First pass: Save the vendor so that so that we can decode OEM types */
+ /* First pass: Save specific values needed to decode OEM types */
data = buf;
while ((i < num || !num)
&& data + 4 <= buf + len) /* 4 is the length of an SMBIOS structure header */
@@ -5284,12 +5286,12 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
/* Assign vendor for vendor-specific decodes later */
if (h.type == 1 && h.length >= 6)
- {
dmi_set_vendor(_dmi_string(&h, data[0x04], 0),
_dmi_string(&h, data[0x05], 0));
- break;
- }
+ /* Remember CPUID type for HPE type 199 */
+ if (h.type == 4 && h.length >= 0x1A && cpuid_type == cpuid_none)
+ cpuid_type = dmi_get_cpuid_type(&h);
data = next;
}
diff --git a/dmidecode.h b/dmidecode.h
index f4022f9..318cdc6 100644
--- a/dmidecode.h
+++ b/dmidecode.h
@@ -42,6 +42,8 @@ enum cpuid_type
cpuid_x86_amd,
};
+extern enum cpuid_type cpuid_type;
+
int is_printable(const u8 *data, int len);
const char *dmi_string(const struct dmi_header *dm, u8 s);
void dmi_print_memory_size(const char *addr, u64 code, int shift);