Martin Roth has submitted this change. ( https://review.coreboot.org/c/coreboot/+/67275 )
Change subject: mb/prodrive/hermes: Factor out serial reading logic ......................................................................
mb/prodrive/hermes: Factor out serial reading logic
Add the `eeprom_read_serial()` function to read serials from the EEPROM. Note that there's only one buffer now: this means only one serial can be accessed at the same time, and the buffer needs to be cleared so that it does not contain old data from other serials. Given that the serials are copied one at a time into SMBIOS tables, having one shared buffer is not a problem.
Change-Id: I5c9781e4e599043be756514cfd6dd86dedcf580c Signed-off-by: Angel Pons th3fanbus@gmail.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/67275 Reviewed-by: Lean Sheng Tan sheng.tan@9elements.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/mainboard/prodrive/hermes/eeprom.c M src/mainboard/prodrive/hermes/eeprom.h M src/mainboard/prodrive/hermes/smbios.c 3 files changed, 35 insertions(+), 12 deletions(-)
Approvals: build bot (Jenkins): Verified Lean Sheng Tan: Looks good to me, approved
diff --git a/src/mainboard/prodrive/hermes/eeprom.c b/src/mainboard/prodrive/hermes/eeprom.c index 7a92fe3..54e0e11 100644 --- a/src/mainboard/prodrive/hermes/eeprom.c +++ b/src/mainboard/prodrive/hermes/eeprom.c @@ -7,6 +7,7 @@ #include <device/pci_ops.h> #include <device/smbus_host.h> #include <soc/intel/common/block/smbus/smbuslib.h> +#include <string.h> #include <types.h>
#include "eeprom.h" @@ -88,6 +89,17 @@ return &bmc_cfg; }
+const char *eeprom_read_serial(const size_t offset, const char *const fallback) +{ + static char serial_no[HERMES_SERIAL_NUMBER_LENGTH] = { 0 }; + memset(serial_no, 0, sizeof(serial_no)); + + if (eeprom_read_buffer(serial_no, offset, sizeof(serial_no)) == 0) + return serial_no; + else + return fallback; +} + uint8_t get_bmc_hsi(void) { uint8_t hsi = 0; diff --git a/src/mainboard/prodrive/hermes/eeprom.h b/src/mainboard/prodrive/hermes/eeprom.h index 2f7eac7..63e84af 100644 --- a/src/mainboard/prodrive/hermes/eeprom.h +++ b/src/mainboard/prodrive/hermes/eeprom.h @@ -105,6 +105,7 @@ int check_signature(const size_t offset, const uint64_t signature); struct eeprom_board_settings *get_board_settings(void); struct eeprom_bmc_settings *get_bmc_settings(void); +const char *eeprom_read_serial(size_t offset, const char *fallback); uint8_t get_bmc_hsi(void); void report_eeprom_error(const size_t off); bool write_board_settings(const struct eeprom_board_layout *new_layout); diff --git a/src/mainboard/prodrive/hermes/smbios.c b/src/mainboard/prodrive/hermes/smbios.c index c1325d4..923ce81 100644 --- a/src/mainboard/prodrive/hermes/smbios.c +++ b/src/mainboard/prodrive/hermes/smbios.c @@ -9,23 +9,13 @@ const char *smbios_system_serial_number(void) { const size_t offset = offsetof(struct eeprom_layout, system_serial_number); - static char serial_no[HERMES_SERIAL_NUMBER_LENGTH] = { 0 }; - - if (eeprom_read_buffer(serial_no, offset, sizeof(serial_no)) == 0) - return serial_no; - else - return CONFIG_MAINBOARD_SERIAL_NUMBER; + return eeprom_read_serial(offset, CONFIG_MAINBOARD_SERIAL_NUMBER); }
const char *smbios_mainboard_serial_number(void) { const size_t offset = offsetof(struct eeprom_layout, board_serial_number); - static char serial_no[HERMES_SERIAL_NUMBER_LENGTH] = { 0 }; - - if (eeprom_read_buffer(serial_no, offset, sizeof(serial_no)) == 0) - return serial_no; - else - return CONFIG_MAINBOARD_SERIAL_NUMBER; + return eeprom_read_serial(offset, CONFIG_MAINBOARD_SERIAL_NUMBER); }
const char *smbios_mainboard_version(void)