summaryrefslogtreecommitdiff
path: root/src/mainboard/prodrive/hermes/smbios.c
blob: c1325d477162b38bee1c637250e235ff02c0ea25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* SPDX-License-Identifier: GPL-2.0-only */

#include <smbios.h>
#include <string.h>
#include <types.h>

#include "eeprom.h"

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;
}

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;
}

const char *smbios_mainboard_version(void)
{
	static char version_str[8] = { 0 };

	snprintf(version_str, sizeof(version_str), "HSI %u", get_bmc_hsi());

	return version_str;
}