summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/boot/coreboot_tables.h6
-rw-r--r--src/lib/coreboot_table.c73
-rw-r--r--src/vendorcode/google/chromeos/Makefile.inc2
-rw-r--r--src/vendorcode/google/chromeos/vpd_mac.c93
4 files changed, 100 insertions, 74 deletions
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h
index 0efb8fdb41..db55adaa36 100644
--- a/src/include/boot/coreboot_tables.h
+++ b/src/include/boot/coreboot_tables.h
@@ -366,6 +366,12 @@ void lb_add_console(uint16_t consoletype, void *data);
/* Define this in mainboard.c to add board-specific table entries. */
void lb_board(struct lb_header *header);
+/*
+ * Function to retrieve MAC address(es) from the VPD and store them in the
+ * coreboot table.
+ */
+void lb_table_add_macs_from_vpd(struct lb_header *header);
+
struct lb_record *lb_new_record(struct lb_header *header);
#endif /* COREBOOT_TABLES_H */
diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c
index a8b5edf049..365283fffe 100644
--- a/src/lib/coreboot_table.c
+++ b/src/lib/coreboot_table.c
@@ -38,7 +38,6 @@
#endif
#include <vendorcode/google/chromeos/chromeos.h>
#include <vendorcode/google/chromeos/gnvs.h>
-#include <vendorcode/google/chromeos/cros_vpd.h>
#endif
#if CONFIG_ARCH_X86
#include <cpu/x86/mtrr.h>
@@ -158,75 +157,6 @@ void fill_lb_gpio(struct lb_gpio *gpio, int num,
}
#if CONFIG_CHROMEOS
-static void lb_macs(struct lb_header *header)
-{
- /*
- * In case there is one or more MAC addresses stored in the VPD, the
- * key is "ethernet_mac{0..9}", up to 10 values.
- */
- static const char mac_addr_key_base[] = "ethernet_mac0";
- char mac_addr_key[sizeof(mac_addr_key_base)];
- char mac_addr_str[13]; /* 12 symbols and the trailing zero. */
- int count;
- struct lb_macs *macs = NULL;
- const int index_of_index = sizeof(mac_addr_key) - 2;
-
- /*
- * MAC addresses are stored in the VPD as strings of hex numbers,
- * which need to be converted into binary for storing in the coreboot
- * table.
- */
- strcpy(mac_addr_key, mac_addr_key_base);
- count = 0;
- do {
- int i;
-
- if (!cros_vpd_gets(mac_addr_key, mac_addr_str,
- sizeof(mac_addr_str)))
- break; /* No more MAC addresses in VPD */
-
- if (!macs) {
- macs = (struct lb_macs *)lb_new_record(header);
- macs->tag = LB_TAG_MAC_ADDRS;
- }
-
- /* MAC address in symbolic form is in mac_addr_str. */
- for (i = 0; i < sizeof(macs->mac_addrs[0].mac_addr); i++) {
- int j;
- uint8_t n = 0;
-
- for (j = 0; j < 2; j++) {
- char c = mac_addr_str[i * 2 + j];
-
- if (isxdigit(c)) {
- if (isdigit(c))
- c -= '0';
- else
- c = tolower(c) - 'a' + 10;
- } else {
- printk(BIOS_ERR,
- "%s: non hexadecimal symbol "
- "%#2.2x in the VPD field %s\n",
- __func__, (uint8_t)c,
- mac_addr_key);
- c = 0;
- }
- n <<= 4;
- n |= c;
- }
- macs->mac_addrs[count].mac_addr[i] = n;
- }
- count++;
- mac_addr_key[index_of_index] = '0' + count;
- } while (count < 10);
-
- if (!count)
- return; /* No MAC addresses in the VPD. */
-
- macs->count = count;
- macs->size = sizeof(*macs) + count * sizeof(struct mac_address);
-}
-
static void lb_gpios(struct lb_header *header)
{
struct lb_gpios *gpios;
@@ -517,9 +447,6 @@ unsigned long write_coreboot_table(
/* pass along the vboot_handoff address. */
lb_vboot_handoff(head);
-
- /* Retrieve mac addresses from VPD, if any. */
- lb_macs(head);
#endif
/* Add board ID if available */
diff --git a/src/vendorcode/google/chromeos/Makefile.inc b/src/vendorcode/google/chromeos/Makefile.inc
index f43a87e9a3..da1db8bc4d 100644
--- a/src/vendorcode/google/chromeos/Makefile.inc
+++ b/src/vendorcode/google/chromeos/Makefile.inc
@@ -29,7 +29,7 @@ ramstage-y += fmap.c
ramstage-$(CONFIG_CHROMEOS_RAMOOPS) += ramoops.c
smm-y += fmap.c
romstage-y += vpd_decode.c cros_vpd.c
-ramstage-y += vpd_decode.c cros_vpd.c
+ramstage-y += vpd_decode.c cros_vpd.c vpd_mac.c
ifeq ($(MOCK_TPM),1)
CFLAGS_common += -DMOCK_TPM=1
diff --git a/src/vendorcode/google/chromeos/vpd_mac.c b/src/vendorcode/google/chromeos/vpd_mac.c
new file mode 100644
index 0000000000..ad4174c6bf
--- /dev/null
+++ b/src/vendorcode/google/chromeos/vpd_mac.c
@@ -0,0 +1,93 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <boot/coreboot_tables.h>
+#include <console/console.h>
+#include <string.h>
+
+#include <vendorcode/google/chromeos/cros_vpd.h>
+
+void lb_table_add_macs_from_vpd(struct lb_header *header)
+{
+ /*
+ * In case there is one or more MAC addresses stored in the VPD, the
+ * key is "ethernet_mac{0..9}", up to 10 values.
+ */
+ static const char mac_addr_key_base[] = "ethernet_mac0";
+ char mac_addr_key[sizeof(mac_addr_key_base)];
+ char mac_addr_str[13]; /* 12 symbols and the trailing zero. */
+ int count;
+ struct lb_macs *macs = NULL;
+ const int index_of_index = sizeof(mac_addr_key) - 2;
+
+ /*
+ * MAC addresses are stored in the VPD as strings of hex numbers,
+ * which need to be converted into binary for storing in the coreboot
+ * table.
+ */
+ strcpy(mac_addr_key, mac_addr_key_base);
+ count = 0;
+ do {
+ int i;
+
+ if (!cros_vpd_gets(mac_addr_key, mac_addr_str,
+ sizeof(mac_addr_str)))
+ break; /* No more MAC addresses in VPD */
+
+ if (!macs) {
+ macs = (struct lb_macs *)lb_new_record(header);
+ macs->tag = LB_TAG_MAC_ADDRS;
+ }
+
+ /* MAC address in symbolic form is in mac_addr_str. */
+ for (i = 0; i < sizeof(macs->mac_addrs[0].mac_addr); i++) {
+ int j;
+ uint8_t n = 0;
+
+ for (j = 0; j < 2; j++) {
+ char c = mac_addr_str[i * 2 + j];
+
+ if (isxdigit(c)) {
+ if (isdigit(c))
+ c -= '0';
+ else
+ c = tolower(c) - 'a' + 10;
+ } else {
+ printk(BIOS_ERR,
+ "%s: non hexadecimal symbol "
+ "%#2.2x in the VPD field %s\n",
+ __func__, (uint8_t)c,
+ mac_addr_key);
+ c = 0;
+ }
+ n <<= 4;
+ n |= c;
+ }
+ macs->mac_addrs[count].mac_addr[i] = n;
+ }
+ count++;
+ mac_addr_key[index_of_index] = '0' + count;
+ } while (count < 10);
+
+ if (!count)
+ return; /* No MAC addresses in the VPD. */
+
+ macs->count = count;
+ macs->size = sizeof(*macs) + count * sizeof(struct mac_address);
+}