[coreboot-gerrit] New patch to review for coreboot: pcengines/apu1: Fill serial number in SMBIOS
Kyösti Mälkki (kyosti.malkki@gmail.com)
gerrit at coreboot.org
Wed Oct 14 21:28:41 CEST 2015
Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11901
-gerrit
commit 9ed9deec914189fa3dcd75d65923d3ba0e2f2ce9
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date: Wed Oct 14 22:17:22 2015 +0300
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 at gmail.com>
---
src/mainboard/pcengines/apu1/mainboard.c | 33 ++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/mainboard/pcengines/apu1/mainboard.c b/src/mainboard/pcengines/apu1/mainboard.c
index 6bc94da7..b4d3f67 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 6 bytes that make up the NIC's MAC address. */
+ BAR18 = pci_read_config32(nic_dev, 0x18);
+ BAR18 &= 0xFFFFFC00;
+ for (i = 0; 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;
More information about the coreboot-gerrit
mailing list