From e2fe74f86b4ed43eb8a3c9d99055afc5d6fb7b78 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Mon, 22 Sep 2014 19:36:28 -0700 Subject: [PATCH] libpayload: cros: include mac addresses in coreboot table Pass MAC addresses found in coreboot table into lib_sysinfo. BUG=chrome-os-partner:32152 TEST=with all changes in place MAC addresses are properly inserted into the kernel device tree. Change-Id: I1d0bd437fb27fabd14b9ba1fb5415586cd8847bb Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/219444 Reviewed-by: Aaron Durbin --- payloads/libpayload/include/coreboot_tables.h | 12 ++++++++++++ payloads/libpayload/include/sysinfo.h | 5 +++++ payloads/libpayload/libc/coreboot.c | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 86e3cd63ee..3cc5614519 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -224,6 +224,18 @@ struct cb_x86_rom_mtrr { uint32_t index; }; +#define CB_TAG_MAC_ADDRS 0x0026 +struct mac_address { + uint8_t mac_addr[6]; + uint8_t pad[2]; /* Pad it to 8 bytes to keep it simple. */ +}; + +struct cb_macs { + uint32_t tag; + uint32_t size; + uint32_t count; + struct mac_address mac_addrs[0]; +}; #define CB_TAG_CMOS_OPTION_TABLE 0x00c8 struct cb_cmos_option_table { diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h index f4f47b755f..b90a8bdf23 100644 --- a/payloads/libpayload/include/sysinfo.h +++ b/payloads/libpayload/include/sysinfo.h @@ -35,6 +35,9 @@ /* Allow a maximum of 8 GPIOs */ #define SYSINFO_MAX_GPIOS 8 +/* Up to 10 MAC addresses */ +#define SYSINFO_MAX_MACS 10 + #include struct cb_serial; @@ -86,6 +89,8 @@ struct sysinfo_t { #ifdef CONFIG_LP_CHROMEOS int num_gpios; struct cb_gpio gpios[SYSINFO_MAX_GPIOS]; + int num_macs; + struct mac_address macs[SYSINFO_MAX_MACS]; #endif unsigned long *mbtable; /** Pointer to the multiboot table */ diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index 1563d4a583..8bd118e8df 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -114,6 +114,20 @@ static void cb_parse_vdat(unsigned char *ptr, struct sysinfo_t *info) info->vdat_addr = phys_to_virt(vdat->range_start); info->vdat_size = vdat->range_size; } + +static void cb_parse_mac_addresses(unsigned char *ptr, + struct sysinfo_t *info) +{ + struct cb_macs *macs = (struct cb_macs *)ptr; + int i; + + info->num_macs = (macs->count < ARRAY_SIZE(info->macs)) ? + macs->count : ARRAY_SIZE(info->macs); + + for (i = 0; i < info->num_macs; i++) + info->macs[i] = macs->mac_addrs[i]; +} + #endif static void cb_parse_tstamp(unsigned char *ptr, struct sysinfo_t *info) @@ -291,6 +305,9 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info) case CB_TAG_VBOOT_HANDOFF: cb_parse_vboot_handoff(ptr, info); break; + case CB_TAG_MAC_ADDRS: + cb_parse_mac_addresses(ptr, info); + break; #endif case CB_TAG_TIMESTAMPS: cb_parse_tstamp(ptr, info);