the following patch was just integrated into master:
commit 2b80734811ee056f0447bab359ec5961e90101b7
Author: Patrick Georgi <pgeorgi(a)chromium.org>
Date: Tue Jun 28 20:45:34 2016 +0200
fmaptool: Accept hex values with uppercase letters
Due to a newer flex version with which the scanner was recreated, we
also have to make the compiler less strict on the generated code.
Change-Id: I3758c0dcb2f5661d072b54a30d6a4ebe094854e6
Signed-off-by: Patrick Georgi <pgeorgi(a)chromium.org>
Reviewed-on: https://review.coreboot.org/15482
Tested-by: build bot (Jenkins)
Reviewed-by: Werner Zeh <werner.zeh(a)siemens.com>
Reviewed-by: Paul Menzel <paulepanter(a)users.sourceforge.net>
See https://review.coreboot.org/15482 for details.
-gerrit
Nico Huber (nico.h(a)gmx.de) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15452
-gerrit
commit caedc8c84530d1b4052e44bead8b54121a66bc89
Author: Paul Kocialkowski <contact(a)paulk.fr>
Date: Fri Jun 17 21:41:00 2016 -0700
buildgcc: Never set GMP CFLAGS manually in order to get the right flags
When no CFLAGS are explicitly provided to it, the GMP configure script
will figure out the best optimization flags to use on its own. In
particular, it will setup the march, mfpu and mtune flags based on
hardware detection.
However, when CFLAGS are provided, they are used as-is and such
detection doesn't happen. When the march, mfpu and mtune flags are not
provided (which happens when GMP wasn't built already), not only will
related optimizations be disabled, but some code might not build because
of missing support. This happens with NEON instructions on ARMv7 hosts.
Thus, it is better not to set CFLAGS and leave it up to the GMP
configure script to get them right and still reuse those later.
Change-Id: I6ffcbac1298523d1b8ddf29a8bca1b00298828a7
Signed-off-by: Paul Kocialkowski <contact(a)paulk.fr>
---
util/crossgcc/buildgcc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc
index 1e761da..a4d83f0 100755
--- a/util/crossgcc/buildgcc
+++ b/util/crossgcc/buildgcc
@@ -416,8 +416,7 @@ set_hostcflags_from_gmp() {
}
build_GMP() {
- CC="$CC" CFLAGS="$HOSTCFLAGS" \
- ../${GMP_DIR}/configure --disable-shared --enable-fat \
+ CC="$CC" ../${GMP_DIR}/configure --disable-shared --enable-fat \
--prefix=$TARGETDIR $OPTIONS \
|| touch .failed
$MAKE $JOBS || touch .failed
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15516
-gerrit
commit dee2eace7faff7e4a85fef38578396c592666ae3
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Wed Jun 29 07:53:47 2016 +0200
intel/i210: Change API for function mainboard_get_mac_address()
The function mainboard_get_mac_address() is used to get a MAC address
for a given i210 PCI device. Instead of passing pure numbers for PCI
bus, device and function pass the device pointer to this function. In
this way the function can retrieve the needed values itself as well as
have the pointer to the device tree so that PCI path can be evaluated
there.
Change-Id: I2335d995651baa5e23a0448f5f32310dcd394f9b
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/drivers/intel/i210/Makefile.inc | 19 +++++++++++++++++--
src/drivers/intel/i210/i210.c | 8 +-------
src/drivers/intel/i210/i210.h | 8 ++++++++
src/mainboard/siemens/mc_tcu3/mainboard.c | 6 +++---
src/vendorcode/siemens/hwilib/hwilib.h | 4 ----
5 files changed, 29 insertions(+), 16 deletions(-)
diff --git a/src/drivers/intel/i210/Makefile.inc b/src/drivers/intel/i210/Makefile.inc
index a696022..c3dac65 100644
--- a/src/drivers/intel/i210/Makefile.inc
+++ b/src/drivers/intel/i210/Makefile.inc
@@ -1,5 +1,20 @@
-ifeq ($(CONFIG_DRIVER_INTEL_I210),y)
+##
+## This file is part of the coreboot project.
+##
+## Copyright 2016 Siemens AG
+##
+## 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.
+##
-ramstage-y += i210.c
+ramstage-$(CONFIG_DRIVER_INTEL_I210)+= i210.c
+ifeq ($(CONFIG_DRIVER_INTEL_I210),y)
+CFLAGS_x86_32 += -Isrc/drivers/intel/i210
endif
diff --git a/src/drivers/intel/i210/i210.c b/src/drivers/intel/i210/i210.c
index c5e0c4e..656e4f3 100644
--- a/src/drivers/intel/i210/i210.c
+++ b/src/drivers/intel/i210/i210.c
@@ -23,11 +23,6 @@
#include <types.h>
#include <delay.h>
-/* We need one function we can call to get a MAC address to use */
-/* This function can be coded somewhere else but must exist. */
-extern enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
- uint8_t mac[6]);
-
/* This is a private function to wait for a bit mask in a given register */
/* To avoid endless loops, a time-out is implemented here. */
static int wait_done(uint32_t* reg, uint32_t mask)
@@ -202,8 +197,7 @@ static void init(struct device *dev)
enum cb_err status;
/*Check first whether there is a valid MAC address available */
- status = mainboard_get_mac_address(dev->bus->subordinate,
- dev->path.pci.devfn, adr_to_set);
+ status = mainboard_get_mac_address(dev, adr_to_set);
if (status != CB_SUCCESS) {
printk(BIOS_ERR, "I210: No valid MAC address found\n");
return;
diff --git a/src/drivers/intel/i210/i210.h b/src/drivers/intel/i210/i210.h
index b19b584..e3179b7 100644
--- a/src/drivers/intel/i210/i210.h
+++ b/src/drivers/intel/i210/i210.h
@@ -16,6 +16,9 @@
#ifndef _INTEL_I210_H_
#define _INTEL_I210_H_
+#include <types.h>
+#include <device/device.h>
+
#define I210_PCI_MEM_BAR_OFFSET 0x10
#define I210_REG_EECTRL 0x12010 /* Offset for EEPROM control reg */
#define I210_FLUPD 0x800000 /* Start flash update bit */
@@ -38,4 +41,9 @@
#define I210_CHECKSUM_ERROR 0x00000010
#define I210_FLASH_UPDATE_ERROR 0x00000020
+/* We need one function we can call to get a MAC address to use */
+/* This function can be coded somewhere else but must exist. */
+extern enum cb_err mainboard_get_mac_address(struct device *dev,
+ uint8_t mac[6]);
+
#endif /* _INTEL_I210_H_ */
diff --git a/src/mainboard/siemens/mc_tcu3/mainboard.c b/src/mainboard/siemens/mc_tcu3/mainboard.c
index 009c34d..a11ff26 100644
--- a/src/mainboard/siemens/mc_tcu3/mainboard.c
+++ b/src/mainboard/siemens/mc_tcu3/mainboard.c
@@ -30,17 +30,17 @@
#include <arch/interrupt.h>
#include <boot/coreboot_tables.h>
#include <hwilib.h>
+#include <i210.h>
#include "lcd_panel.h"
/** \brief This function will search for a MAC address which can be assigned
* to a MACPHY.
- * @param pci_bdf Bus, device and function of the given PCI-device
+ * @param dev pointer to PCI device
* @param mac buffer where to store the MAC address
* @return cb_err CB_ERR or CB_SUCCESS
*/
-enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
- uint8_t mac[6])
+enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6])
{
uint8_t mac_adr[6];
uint32_t i;
diff --git a/src/vendorcode/siemens/hwilib/hwilib.h b/src/vendorcode/siemens/hwilib/hwilib.h
index d858091..fc083de 100644
--- a/src/vendorcode/siemens/hwilib/hwilib.h
+++ b/src/vendorcode/siemens/hwilib/hwilib.h
@@ -18,7 +18,6 @@
#include <types.h>
-
/* Declare all supported fields which can be get with hwilib. */
typedef enum {
HIB_VerID = 0,
@@ -135,7 +134,4 @@ enum cb_err hwilib_find_blocks (const char *hwi_filename);
*/
uint32_t hwilib_get_field (hwinfo_field_t field, uint8_t *data, uint32_t maxlen);
-/* This functions needs to be implemented for every mainboard that uses i210. */
-enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
- uint8_t mac[6]);
#endif /* SIEMENS_HWI_LIB_H_ */
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15517
-gerrit
commit 6015c8472af79ae59032bdb267297e9528fb669e
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Thu Jun 30 08:21:17 2016 +0200
siemens/mc_bdx1: Set up MAC address for available i210 MACs
Enable the usage of DRIVER_INTEL_I210 and provide a function to search
for a valid MAC address for all i210 devices using hwilib.
Change-Id: Ic0f4f1579364cf5b0111334a05a8a0926785318b
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/mainboard/siemens/mc_bdx1/Kconfig | 2 +
src/mainboard/siemens/mc_bdx1/mainboard.c | 77 ++++++++++++++++++++++++++++++-
2 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/src/mainboard/siemens/mc_bdx1/Kconfig b/src/mainboard/siemens/mc_bdx1/Kconfig
index e33b14a..f947f3d 100644
--- a/src/mainboard/siemens/mc_bdx1/Kconfig
+++ b/src/mainboard/siemens/mc_bdx1/Kconfig
@@ -9,6 +9,8 @@ config BOARD_SPECIFIC_OPTIONS
select TSC_MONOTONIC_TIMER
select HAVE_FSP_BIN if FSP_PACKAGE_DEFAULT
select CBFS_AUTOGEN_ATTRIBUTES
+ select USE_SIEMENS_HWILIB
+ select DRIVER_INTEL_I210
config MAINBOARD_DIR
string
diff --git a/src/mainboard/siemens/mc_bdx1/mainboard.c b/src/mainboard/siemens/mc_bdx1/mainboard.c
index 58da036..af886a9 100644
--- a/src/mainboard/siemens/mc_bdx1/mainboard.c
+++ b/src/mainboard/siemens/mc_bdx1/mainboard.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2009 coresystems GmbH
* Copyright (C) 2011 Google Inc.
+ * Copyright (C) 2016 Siemens AG
*
* 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
@@ -17,7 +18,6 @@
#include <types.h>
#include <string.h>
#include <device/device.h>
-#include <device/device.h>
#include <device/pci_def.h>
#include <device/pci_ops.h>
#include <console/console.h>
@@ -29,7 +29,11 @@
#include <arch/io.h>
#include <arch/interrupt.h>
#include <boot/coreboot_tables.h>
+#include <hwilib.h>
+#include <i210.h>
+#define MAX_PATH_DEPTH 12
+#define MAX_NUM_MAPPINGS 10
/*
* mainboard_enable is executed as first thing after enumerate_buses().
* This is the earliest point to add customization.
@@ -38,6 +42,77 @@ static void mainboard_enable(device_t dev)
{
}
+/** \brief This function can decide if a given MAC address is valid or not.
+ * Currently, addresses filled with 0xff or 0x00 are not valid.
+ * @param mac Buffer to the MAC address to check
+ * @return 0 if address is not valid, otherwise 1
+ */
+static uint8_t is_mac_adr_valid(uint8_t mac[6])
+{
+ uint8_t buf[6];
+
+ memset(buf, 0, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ memset(buf, 0xff, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ return 1;
+}
+ /** \brief This function will search for a MAC address which can be assigned
+ * to a MACPHY.
+ * @param dev pointer to PCI device
+ * @param mac buffer where to store the MAC address
+ * @return cb_err CB_ERR or CB_SUCCESS
+ */
+enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6])
+{
+ struct bus *parent = dev->bus;
+ uint8_t buf[16], mapping[16], i = 0, chain_len = 0;
+
+ memset(buf, 0, sizeof(buf));
+ memset(mapping, 0, sizeof(mapping));
+
+ /* The first entry in the tree is the device itself. */
+ buf[0] = dev->path.pci.devfn;
+ chain_len = 1;
+ for (i = 1; i < MAX_PATH_DEPTH && parent->dev->bus->subordinate; i++) {
+ buf[i] = parent->dev->path.pci.devfn;
+ chain_len++;
+ parent = parent->dev->bus;
+ }
+ if (i == MAX_PATH_DEPTH) {
+ /* The path is deeper than MAX_PATH_DEPTH devices, error. */
+ printk(BIOS_ERR, "Too many bridges for %s\n", dev_path(dev));
+ return CB_ERR;
+ }
+ /* Now construct the mapping based on the device chain starting from */
+ /* root bridge device to the device itself. */
+ mapping[0] = 1;
+ mapping[1] = chain_len;
+ for (i = 0; i < chain_len; i++)
+ mapping[i + 4] = buf[chain_len - i - 1];
+
+ /* Open main hwinfo block */
+ if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
+ return CB_ERR;
+ /* Now try to find a valid MAC address in hwinfo for this mapping.*/
+ for (i = 0; i < MAX_NUM_MAPPINGS; i++) {
+ if ((hwilib_get_field(XMac1Mapping + i, buf, 16) == 16) &&
+ !(memcmp(buf, mapping, chain_len + 4))) {
+ /* There is a matching mapping available, get MAC address. */
+ if ((hwilib_get_field(XMac1 + i, mac, 6) == 6) &&
+ (is_mac_adr_valid(mac))) {
+ return CB_SUCCESS;
+ } else {
+ return CB_ERR;
+ }
+ } else
+ continue;
+ }
+ /* No MAC address found for */
+ return CB_ERR;
+}
struct chip_operations mainboard_ops = {
.enable_dev = mainboard_enable,
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15516
-gerrit
commit 7ee4e42c12f08833fa921ae50f0026acf65e685b
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Wed Jun 29 07:53:47 2016 +0200
intel/i210: Change API for function mainboard_get_mac_address()
The function mainboard_get_mac_address() is used to get a MAC address
for a given i210 PCI device. Instead of passing pure numbers for PCI
bus, device and function pass the device pointer to this function. In
this way the function can retrieve the needed values itself as well as
have the pointer to the device tree so that PCI path can be evaluated
there.
Change-Id: I2335d995651baa5e23a0448f5f32310dcd394f9b
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/drivers/intel/i210/Makefile.inc | 19 +++++++++++++++++--
src/drivers/intel/i210/i210.c | 10 +---------
src/drivers/intel/i210/i210.h | 8 ++++++++
src/mainboard/siemens/mc_tcu3/mainboard.c | 6 +++---
src/vendorcode/siemens/hwilib/hwilib.h | 4 +---
5 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/src/drivers/intel/i210/Makefile.inc b/src/drivers/intel/i210/Makefile.inc
index a696022..c3dac65 100644
--- a/src/drivers/intel/i210/Makefile.inc
+++ b/src/drivers/intel/i210/Makefile.inc
@@ -1,5 +1,20 @@
-ifeq ($(CONFIG_DRIVER_INTEL_I210),y)
+##
+## This file is part of the coreboot project.
+##
+## Copyright 2016 Siemens AG
+##
+## 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.
+##
-ramstage-y += i210.c
+ramstage-$(CONFIG_DRIVER_INTEL_I210)+= i210.c
+ifeq ($(CONFIG_DRIVER_INTEL_I210),y)
+CFLAGS_x86_32 += -Isrc/drivers/intel/i210
endif
diff --git a/src/drivers/intel/i210/i210.c b/src/drivers/intel/i210/i210.c
index c5e0c4e..c55eecc 100644
--- a/src/drivers/intel/i210/i210.c
+++ b/src/drivers/intel/i210/i210.c
@@ -14,20 +14,13 @@
*/
#include "i210.h"
-#include <device/device.h>
#include <console/console.h>
#include <device/pci.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
#include <string.h>
-#include <types.h>
#include <delay.h>
-/* We need one function we can call to get a MAC address to use */
-/* This function can be coded somewhere else but must exist. */
-extern enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
- uint8_t mac[6]);
-
/* This is a private function to wait for a bit mask in a given register */
/* To avoid endless loops, a time-out is implemented here. */
static int wait_done(uint32_t* reg, uint32_t mask)
@@ -202,8 +195,7 @@ static void init(struct device *dev)
enum cb_err status;
/*Check first whether there is a valid MAC address available */
- status = mainboard_get_mac_address(dev->bus->subordinate,
- dev->path.pci.devfn, adr_to_set);
+ status = mainboard_get_mac_address(dev, adr_to_set);
if (status != CB_SUCCESS) {
printk(BIOS_ERR, "I210: No valid MAC address found\n");
return;
diff --git a/src/drivers/intel/i210/i210.h b/src/drivers/intel/i210/i210.h
index b19b584..e3179b7 100644
--- a/src/drivers/intel/i210/i210.h
+++ b/src/drivers/intel/i210/i210.h
@@ -16,6 +16,9 @@
#ifndef _INTEL_I210_H_
#define _INTEL_I210_H_
+#include <types.h>
+#include <device/device.h>
+
#define I210_PCI_MEM_BAR_OFFSET 0x10
#define I210_REG_EECTRL 0x12010 /* Offset for EEPROM control reg */
#define I210_FLUPD 0x800000 /* Start flash update bit */
@@ -38,4 +41,9 @@
#define I210_CHECKSUM_ERROR 0x00000010
#define I210_FLASH_UPDATE_ERROR 0x00000020
+/* We need one function we can call to get a MAC address to use */
+/* This function can be coded somewhere else but must exist. */
+extern enum cb_err mainboard_get_mac_address(struct device *dev,
+ uint8_t mac[6]);
+
#endif /* _INTEL_I210_H_ */
diff --git a/src/mainboard/siemens/mc_tcu3/mainboard.c b/src/mainboard/siemens/mc_tcu3/mainboard.c
index 009c34d..a11ff26 100644
--- a/src/mainboard/siemens/mc_tcu3/mainboard.c
+++ b/src/mainboard/siemens/mc_tcu3/mainboard.c
@@ -30,17 +30,17 @@
#include <arch/interrupt.h>
#include <boot/coreboot_tables.h>
#include <hwilib.h>
+#include <i210.h>
#include "lcd_panel.h"
/** \brief This function will search for a MAC address which can be assigned
* to a MACPHY.
- * @param pci_bdf Bus, device and function of the given PCI-device
+ * @param dev pointer to PCI device
* @param mac buffer where to store the MAC address
* @return cb_err CB_ERR or CB_SUCCESS
*/
-enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
- uint8_t mac[6])
+enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6])
{
uint8_t mac_adr[6];
uint32_t i;
diff --git a/src/vendorcode/siemens/hwilib/hwilib.h b/src/vendorcode/siemens/hwilib/hwilib.h
index d858091..c0ae733 100644
--- a/src/vendorcode/siemens/hwilib/hwilib.h
+++ b/src/vendorcode/siemens/hwilib/hwilib.h
@@ -17,6 +17,7 @@
#define SIEMENS_HWI_LIB_H_
#include <types.h>
+#include <device/device.h>
/* Declare all supported fields which can be get with hwilib. */
@@ -135,7 +136,4 @@ enum cb_err hwilib_find_blocks (const char *hwi_filename);
*/
uint32_t hwilib_get_field (hwinfo_field_t field, uint8_t *data, uint32_t maxlen);
-/* This functions needs to be implemented for every mainboard that uses i210. */
-enum cb_err mainboard_get_mac_address(uint16_t bus, uint8_t devfn,
- uint8_t mac[6]);
#endif /* SIEMENS_HWI_LIB_H_ */
Werner Zeh (werner.zeh(a)siemens.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15517
-gerrit
commit 5e14176d4628c9960efddeff670ddace2a041c8a
Author: Werner Zeh <werner.zeh(a)siemens.com>
Date: Thu Jun 30 08:21:17 2016 +0200
siemens/mc_bdx1: Set up MAC address for available i210 MACs
Enable the usage of DRIVER_INTEL_I210 and provide a function to search
for a valid MAC address for all i210 devices using hwilib.
Change-Id: Ic0f4f1579364cf5b0111334a05a8a0926785318b
Signed-off-by: Werner Zeh <werner.zeh(a)siemens.com>
---
src/mainboard/siemens/mc_bdx1/Kconfig | 2 +
src/mainboard/siemens/mc_bdx1/mainboard.c | 76 +++++++++++++++++++++++++++++++
2 files changed, 78 insertions(+)
diff --git a/src/mainboard/siemens/mc_bdx1/Kconfig b/src/mainboard/siemens/mc_bdx1/Kconfig
index e33b14a..f947f3d 100644
--- a/src/mainboard/siemens/mc_bdx1/Kconfig
+++ b/src/mainboard/siemens/mc_bdx1/Kconfig
@@ -9,6 +9,8 @@ config BOARD_SPECIFIC_OPTIONS
select TSC_MONOTONIC_TIMER
select HAVE_FSP_BIN if FSP_PACKAGE_DEFAULT
select CBFS_AUTOGEN_ATTRIBUTES
+ select USE_SIEMENS_HWILIB
+ select DRIVER_INTEL_I210
config MAINBOARD_DIR
string
diff --git a/src/mainboard/siemens/mc_bdx1/mainboard.c b/src/mainboard/siemens/mc_bdx1/mainboard.c
index 58da036..c933132 100644
--- a/src/mainboard/siemens/mc_bdx1/mainboard.c
+++ b/src/mainboard/siemens/mc_bdx1/mainboard.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2009 coresystems GmbH
* Copyright (C) 2011 Google Inc.
+ * Copyright (C) 2016 Siemens AG
*
* 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
@@ -29,7 +30,11 @@
#include <arch/io.h>
#include <arch/interrupt.h>
#include <boot/coreboot_tables.h>
+#include <hwilib.h>
+#include <i210.h>
+#define MAX_PATH_DEPTH 12
+#define MAX_NUM_MAPPINGS 10
/*
* mainboard_enable is executed as first thing after enumerate_buses().
* This is the earliest point to add customization.
@@ -38,6 +43,77 @@ static void mainboard_enable(device_t dev)
{
}
+/** \brief This function can decide if a given MAC address is valid or not.
+ * Currently, addresses filled with 0xff or 0x00 are not valid.
+ * @param mac Buffer to the MAC address to check
+ * @return 0 if address is not valid, otherwise 1
+ */
+static uint8_t is_mac_adr_valid(uint8_t mac[6])
+{
+ uint8_t buf[6];
+
+ memset(buf, 0, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ memset(buf, 0xff, sizeof(buf));
+ if (!memcmp(buf, mac, sizeof(buf)))
+ return 0;
+ return 1;
+}
+ /** \brief This function will search for a MAC address which can be assigned
+ * to a MACPHY.
+ * @param dev pointer to PCI device
+ * @param mac buffer where to store the MAC address
+ * @return cb_err CB_ERR or CB_SUCCESS
+ */
+enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6])
+{
+ struct bus *parent = dev->bus;
+ uint8_t buf[16], mapping[16], i = 0, chain_len = 0;
+
+ memset(buf, 0, sizeof(buf));
+ memset(mapping, 0, sizeof(mapping));
+
+ /* The first entry in the tree is the device itself. */
+ buf[0] = dev->path.pci.devfn;
+ chain_len = 1;
+ for (i = 1; i < MAX_PATH_DEPTH && parent->dev->bus->subordinate; i++) {
+ buf[i] = parent->dev->path.pci.devfn;
+ chain_len++;
+ parent = parent->dev->bus;
+ }
+ if (i == MAX_PATH_DEPTH) {
+ /* The path is deeper than MAX_PATH_DEPTH devices, error. */
+ printk(BIOS_ERR, "Too many bridges for %s\n", dev_path(dev));
+ return CB_ERR;
+ }
+ /* Now construct the mapping based on the device chain starting from */
+ /* root bridge device to the device itself. */
+ mapping[0] = 1;
+ mapping[1] = chain_len;
+ for (i = 0; i < chain_len; i++)
+ mapping[i + 4] = buf[chain_len - i - 1];
+
+ /* Open main hwinfo block */
+ if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS)
+ return CB_ERR;
+ /* Now try to find a valid MAC address in hwinfo for this mapping.*/
+ for (i = 0; i < MAX_NUM_MAPPINGS; i++) {
+ if ((hwilib_get_field(XMac1Mapping + i, buf, 16) == 16) &&
+ !(memcmp(buf, mapping, chain_len + 4))) {
+ /* There is a matching mapping available, get MAC address. */
+ if ((hwilib_get_field(XMac1 + i, mac, 6) == 6) &&
+ (is_mac_adr_valid(mac))) {
+ return CB_SUCCESS;
+ } else {
+ return CB_ERR;
+ }
+ } else
+ continue;
+ }
+ /* No MAC address found for */
+ return CB_ERR;
+}
struct chip_operations mainboard_ops = {
.enable_dev = mainboard_enable,