From d7750592038e79a602c329a42a813fa098e5f6ad Mon Sep 17 00:00:00 2001 From: Burt P Date: Sun, 30 Jun 2019 15:01:10 -0500 Subject: Memory devices: try and get code bytes from DMI mfgr string Signed-off-by: Burt P --- modules/devices/dmi_memory.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'modules/devices') diff --git a/modules/devices/dmi_memory.c b/modules/devices/dmi_memory.c index ae016193..057a00b5 100644 --- a/modules/devices/dmi_memory.c +++ b/modules/devices/dmi_memory.c @@ -203,6 +203,7 @@ dmi_mem_socket *dmi_mem_socket_new(unsigned long h) { null_if_empty(&s->bank_locator); gchar *ah = dmidecode_match("Array Handle", &dtm, &h); + STR_IGNORE(ah, "Unknown"); if (ah) { s->array_handle = strtol(ah, NULL, 16); g_free(ah); @@ -281,6 +282,27 @@ dmi_mem_socket *dmi_mem_socket_new(unsigned long h) { } } + if (s->mfgr && !s->has_jedec_mfg_id && strlen(s->mfgr) == 4) { + /* Some BIOS put the code bytes into the mfgr string + * if they don't know the manufacturer. + * It's not always reliable, but what is lost + * by trying it? */ + if (isxdigit(s->mfgr[0]) + && isxdigit(s->mfgr[1]) + && isxdigit(s->mfgr[2]) + && isxdigit(s->mfgr[3]) ) { + int codes = strtol(s->mfgr, NULL, 16); + char *mstr = NULL; + decode_ddr34_manufacturer(codes >> 8, codes & 0xff, + &mstr, &s->mfgr_bank, &s->mfgr_index); + s->has_jedec_mfg_id = TRUE; + g_free(s->mfgr); + s->mfgr = NULL; + if (mstr) + s->mfgr = g_strdup(mstr); + } + } + s->vendor = vendor_match(s->mfgr, NULL); } return s; -- cgit v1.2.3