diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/x86/smbios.c | 21 | ||||
-rw-r--r-- | src/include/memory_info.h | 8 | ||||
-rw-r--r-- | src/soc/amd/common/block/pi/amd_late_init.c | 26 |
3 files changed, 24 insertions, 31 deletions
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 7e776373c4..bb4bc1abd1 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -254,6 +254,19 @@ static void smbios_fill_dimm_part_number(const char *part_number, } } +/* Encodes the SPD serial number into hex */ +static void smbios_fill_dimm_serial_number(const struct dimm_info *dimm, + struct smbios_type17 *t) +{ + char serial[9]; + + snprintf(serial, sizeof(serial), "%02hhx%02hhx%02hhx%02hhx", + dimm->serial[0], dimm->serial[1], dimm->serial[2], + dimm->serial[3]); + + t->serial_number = smbios_add_string(t->eos, serial); +} + static int create_smbios_type17_for_dimm(struct dimm_info *dimm, unsigned long *current, int *handle) { @@ -293,13 +306,7 @@ static int create_smbios_type17_for_dimm(struct dimm_info *dimm, } smbios_fill_dimm_manufacturer_from_id(dimm->mod_id, t); - /* put '\0' in the end of data */ - dimm->serial[DIMM_INFO_SERIAL_SIZE - 1] = '\0'; - if (dimm->serial[0] == 0) - t->serial_number = smbios_add_string(t->eos, "None"); - else - t->serial_number = smbios_add_string(t->eos, - (const char *)dimm->serial); + smbios_fill_dimm_serial_number(dimm, t); snprintf(locator, sizeof(locator), "Channel-%d-DIMM-%d", dimm->channel_num, dimm->dimm_num); diff --git a/src/include/memory_info.h b/src/include/memory_info.h index 4613015d75..d26d7890bd 100644 --- a/src/include/memory_info.h +++ b/src/include/memory_info.h @@ -19,7 +19,7 @@ #include <stdint.h> #include <compiler.h> -#define DIMM_INFO_SERIAL_SIZE 5 +#define DIMM_INFO_SERIAL_SIZE 4 #define DIMM_INFO_PART_NUMBER_SIZE 19 #define DIMM_INFO_TOTAL 8 /* Maximum num of dimm is 8 */ @@ -46,11 +46,7 @@ struct dimm_info { uint8_t dimm_num; uint8_t bank_locator; /* - * The last byte is '\0' for the end of string. - * - * Even though the SPD spec defines this field as a byte array the value - * is passed directly to SMBIOS as a string, and thus must be printable - * ASCII. + * SPD serial number. */ uint8_t serial[DIMM_INFO_SERIAL_SIZE]; /* diff --git a/src/soc/amd/common/block/pi/amd_late_init.c b/src/soc/amd/common/block/pi/amd_late_init.c index b0064a2f40..b410602694 100644 --- a/src/soc/amd/common/block/pi/amd_late_init.c +++ b/src/soc/amd/common/block/pi/amd_late_init.c @@ -22,6 +22,7 @@ #include <device/pci_ops.h> #include <dimm_info_util.h> #include <memory_info.h> +#include <lib.h> #include <amdblocks/agesawrapper.h> #include <amdblocks/agesawrapper_call.h> @@ -29,23 +30,10 @@ /** * Populate dimm_info using AGESA TYPE17_DMI_INFO. */ -static void transfer_memory_info(const TYPE17_DMI_INFO *dmi17, +static void transfer_memory_info(TYPE17_DMI_INFO *dmi17, struct dimm_info *dimm) { - size_t len, destlen; - uint32_t offset; - - - len = strnlen(dmi17->SerialNumber, sizeof(dmi17->SerialNumber)) + 1; - destlen = sizeof(dimm->serial); - - if (len > destlen) { - offset = len - destlen; - len = destlen; - } else - offset = 0; - - strncpy((char *)dimm->serial, &dmi17->SerialNumber[offset], len); + hexstrtobin(dmi17->SerialNumber, dimm->serial, sizeof(dimm->serial)); dimm->dimm_size = smbios_memory_size_to_mib(dmi17->MemorySize, dmi17->ExtSize); @@ -90,7 +78,7 @@ static void print_dimm_info(const struct dimm_info *dimm) " mod_id: %hu\n" " mod_type: 0x%hhx\n" " bus_width: %hhu\n" - " serial(%zu): %s\n" + " serial: %02hhx%02hhx%02hhx%02hhx\n" " module_part_number(%zu): %s\n", dimm->dimm_size, dimm->ddr_type, @@ -102,8 +90,10 @@ static void print_dimm_info(const struct dimm_info *dimm) dimm->mod_id, dimm->mod_type, dimm->bus_width, - strlen((char *) dimm->serial), - (char *) dimm->serial, + dimm->serial[0], + dimm->serial[1], + dimm->serial[2], + dimm->serial[3], strlen((char *) dimm->module_part_number), (char *) dimm->module_part_number ); |