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>
This commit is contained in:
parent
a39a812e40
commit
b9af5133dd
|
@ -7,6 +7,7 @@
|
||||||
#include <device/pci_ops.h>
|
#include <device/pci_ops.h>
|
||||||
#include <device/smbus_host.h>
|
#include <device/smbus_host.h>
|
||||||
#include <soc/intel/common/block/smbus/smbuslib.h>
|
#include <soc/intel/common/block/smbus/smbuslib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <types.h>
|
#include <types.h>
|
||||||
|
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
|
@ -88,6 +89,17 @@ struct eeprom_bmc_settings *get_bmc_settings(void)
|
||||||
return &bmc_cfg;
|
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 get_bmc_hsi(void)
|
||||||
{
|
{
|
||||||
uint8_t hsi = 0;
|
uint8_t hsi = 0;
|
||||||
|
|
|
@ -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);
|
int check_signature(const size_t offset, const uint64_t signature);
|
||||||
struct eeprom_board_settings *get_board_settings(void);
|
struct eeprom_board_settings *get_board_settings(void);
|
||||||
struct eeprom_bmc_settings *get_bmc_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);
|
uint8_t get_bmc_hsi(void);
|
||||||
void report_eeprom_error(const size_t off);
|
void report_eeprom_error(const size_t off);
|
||||||
bool write_board_settings(const struct eeprom_board_layout *new_layout);
|
bool write_board_settings(const struct eeprom_board_layout *new_layout);
|
||||||
|
|
|
@ -9,23 +9,13 @@
|
||||||
const char *smbios_system_serial_number(void)
|
const char *smbios_system_serial_number(void)
|
||||||
{
|
{
|
||||||
const size_t offset = offsetof(struct eeprom_layout, system_serial_number);
|
const size_t offset = offsetof(struct eeprom_layout, system_serial_number);
|
||||||
static char serial_no[HERMES_SERIAL_NUMBER_LENGTH] = { 0 };
|
return eeprom_read_serial(offset, CONFIG_MAINBOARD_SERIAL_NUMBER);
|
||||||
|
|
||||||
if (eeprom_read_buffer(serial_no, offset, sizeof(serial_no)) == 0)
|
|
||||||
return serial_no;
|
|
||||||
else
|
|
||||||
return CONFIG_MAINBOARD_SERIAL_NUMBER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *smbios_mainboard_serial_number(void)
|
const char *smbios_mainboard_serial_number(void)
|
||||||
{
|
{
|
||||||
const size_t offset = offsetof(struct eeprom_layout, board_serial_number);
|
const size_t offset = offsetof(struct eeprom_layout, board_serial_number);
|
||||||
static char serial_no[HERMES_SERIAL_NUMBER_LENGTH] = { 0 };
|
return eeprom_read_serial(offset, CONFIG_MAINBOARD_SERIAL_NUMBER);
|
||||||
|
|
||||||
if (eeprom_read_buffer(serial_no, offset, sizeof(serial_no)) == 0)
|
|
||||||
return serial_no;
|
|
||||||
else
|
|
||||||
return CONFIG_MAINBOARD_SERIAL_NUMBER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *smbios_mainboard_version(void)
|
const char *smbios_mainboard_version(void)
|
||||||
|
|
Loading…
Reference in New Issue