diff options
author | Angel Pons <th3fanbus@gmail.com> | 2022-09-01 15:21:34 +0200 |
---|---|---|
committer | Martin Roth <martin.roth@amd.corp-partner.google.com> | 2022-10-07 22:08:11 +0000 |
commit | b9af5133dd2d1be972b9157e8a6860eedd13a766 (patch) | |
tree | d3a6fe24884ed75fd435ed6b76f520a842c0f3b3 /src/mainboard | |
parent | a39a812e407e1749c0177e229902883f5237ade1 (diff) |
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>
Diffstat (limited to 'src/mainboard')
-rw-r--r-- | src/mainboard/prodrive/hermes/eeprom.c | 12 | ||||
-rw-r--r-- | src/mainboard/prodrive/hermes/eeprom.h | 1 | ||||
-rw-r--r-- | src/mainboard/prodrive/hermes/smbios.c | 14 |
3 files changed, 15 insertions, 12 deletions
diff --git a/src/mainboard/prodrive/hermes/eeprom.c b/src/mainboard/prodrive/hermes/eeprom.c index 7a92fe3757..54e0e11ec7 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 @@ struct eeprom_bmc_settings *get_bmc_settings(void) 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 2f7eac7253..63e84afb6d 100644 --- a/src/mainboard/prodrive/hermes/eeprom.h +++ b/src/mainboard/prodrive/hermes/eeprom.h @@ -105,6 +105,7 @@ bool eeprom_read_buffer(void *blob, size_t read_offset, size_t size); 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 c1325d4771..923ce8170c 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) |