From cd32da425c8e7498bb8f5f68e6655d40f7a60325 Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Wed, 14 Oct 2015 22:17:22 +0300 Subject: pcengines/apu1: Fill serial number in SMBIOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Serial number is derived from the MAC address of first NIC. Change-Id: I91e5555b462cca87d48fb56c83aedd1eb02eba62 Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/11901 Reviewed-by: Patrick Georgi Tested-by: build bot (Jenkins) --- src/mainboard/pcengines/apu1/mainboard.c | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/mainboard/pcengines') diff --git a/src/mainboard/pcengines/apu1/mainboard.c b/src/mainboard/pcengines/apu1/mainboard.c index 6bc94da77b..7d50c6600d 100644 --- a/src/mainboard/pcengines/apu1/mainboard.c +++ b/src/mainboard/pcengines/apu1/mainboard.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include "SBPLATFORM.h" #include #include @@ -189,6 +191,37 @@ static void mainboard_enable(device_t dev) pirq_setup(); } +/* + * We will stuff a modified version of the first NICs (BDF 1:0.0) MAC address + * into the smbios serial number location. + */ +const char *smbios_mainboard_serial_number(void) +{ + static char serial[10]; + device_t nic_dev; + uintptr_t bar18; + u32 mac_addr = 0; + int i; + + nic_dev = dev_find_slot(1, PCI_DEVFN(0, 0)); + if ((serial[0] != 0) || !nic_dev) + return serial; + + /* Read in the last 3 bytes of NIC's MAC address. */ + bar18 = pci_read_config32(nic_dev, 0x18); + bar18 &= 0xFFFFFC00; + for (i = 3; i < 6; i++) { + mac_addr <<= 8; + mac_addr |= read8((u8 *)bar18 + i); + } + mac_addr &= 0x00FFFFFF; + mac_addr /= 4; + mac_addr -= 64; + + snprintf(serial, sizeof(serial), "%d", mac_addr); + return serial; +} + static void mainboard_final(void *chip_info) { u32 mmio_base; -- cgit v1.2.3