summaryrefslogtreecommitdiff
path: root/src/mainboard
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2015-10-14 22:17:22 +0300
committerKyösti Mälkki <kyosti.malkki@gmail.com>2015-10-15 12:11:05 +0000
commitcd32da425c8e7498bb8f5f68e6655d40f7a60325 (patch)
treedea3776007636f1bd536c7bb6cf721b7a62c6dfc /src/mainboard
parent164dbd6a5c43355dbbe373efea739ba8834cce07 (diff)
downloadcoreboot-cd32da425c8e7498bb8f5f68e6655d40f7a60325.tar.xz
pcengines/apu1: Fill serial number in SMBIOS
Serial number is derived from the MAC address of first NIC. Change-Id: I91e5555b462cca87d48fb56c83aedd1eb02eba62 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/11901 Reviewed-by: Patrick Georgi <pgeorgi@google.com> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/mainboard')
-rw-r--r--src/mainboard/pcengines/apu1/mainboard.c33
1 files changed, 33 insertions, 0 deletions
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 <northbridge/amd/agesa/BiosCallOuts.h>
#include <cpu/amd/agesa/s3_resume.h>
#include <cpu/amd/mtrr.h>
+#include <smbios.h>
+#include <string.h>
#include "SBPLATFORM.h"
#include <southbridge/amd/cimx/sb800/pci_devs.h>
#include <northbridge/amd/agesa/family14/pci_devs.h>
@@ -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;