diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2017-01-16 19:50:28 +0200 |
---|---|---|
committer | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2017-01-21 08:52:23 +0100 |
commit | 01bf599ea86abb360b0a57b892484dbb9c3ba387 (patch) | |
tree | b0b9598494732527bb976a40a069a7d7f73ea569 /src | |
parent | 104074994d741646016e431a30b8966b3fdfe439 (diff) | |
download | coreboot-01bf599ea86abb360b0a57b892484dbb9c3ba387.tar.xz |
pcengines/apu2: Add serial number in SMBIOS
Change-Id: Ic8149b1dd19d70935e00881cffa7ead0960d1c78
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/18154
Tested-by: build bot (Jenkins)
Reviewed-by: Piotr Król <piotr.krol@3mdeb.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainboard/pcengines/apu2/mainboard.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/mainboard/pcengines/apu2/mainboard.c b/src/mainboard/pcengines/apu2/mainboard.c index 742135571a..d2ab63822b 100644 --- a/src/mainboard/pcengines/apu2/mainboard.c +++ b/src/mainboard/pcengines/apu2/mainboard.c @@ -191,6 +191,38 @@ static void mainboard_enable(device_t dev) } /* + * 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 bar10; + 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. */ + bar10 = pci_read_config32(nic_dev, 0x10); + bar10 &= 0xFFFE0000; + bar10 += 0x5400; + for (i = 3; i < 6; i++) { + mac_addr <<= 8; + mac_addr |= read8((u8 *)bar10 + i); + } + mac_addr &= 0x00FFFFFF; + mac_addr /= 4; + mac_addr -= 64; + + snprintf(serial, sizeof(serial), "%d", mac_addr); + return serial; +} + +/* * We will stuff the memory size into the smbios sku location. */ const char *smbios_mainboard_sku(void) |