[coreboot-gerrit] New patch to review for coreboot: device: include devicetree in bootblock stage

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Mon Jul 25 18:20:48 CEST 2016


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15837

-gerrit

commit c136fe413b18ffa9d6fc86433b6eb106d9075522
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Mon Jul 25 11:18:46 2016 -0500

    device: include devicetree in bootblock stage
    
    Allow bootblock to get access to the static device tree like
    other early stages. device_romstage.c was renamed to
    device_simple.c to better articulate the usage since it's not
    just being used in romstage.
    
    BUG=chrome-os-partner:55357
    
    Change-Id: I3d63d2754c737cc738c09a3e3b3b468362fb78d1
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 Makefile.inc                 |   1 +
 src/device/Makefile.inc      |   5 +-
 src/device/device_romstage.c | 120 -------------------------------------------
 src/device/device_simple.c   | 120 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 124 insertions(+), 122 deletions(-)

diff --git a/Makefile.inc b/Makefile.inc
index 69c8843..c1ad9cb 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -458,6 +458,7 @@ $(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/devi
 ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
 romstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
 verstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
+bootblock-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c
 
 $(objgenerated)/libverstage.a: $$(libverstage-objs)
 	rm -f $@
diff --git a/src/device/Makefile.inc b/src/device/Makefile.inc
index 261ed53..232a981 100644
--- a/src/device/Makefile.inc
+++ b/src/device/Makefile.inc
@@ -20,8 +20,9 @@ ifeq ($(CONFIG_AZALIA_PLUGIN_SUPPORT),y)
 ramstage-srcs += src/mainboard/$(MAINBOARDDIR)/hda_verb.c
 endif
 
-verstage-y += device_romstage.c
-romstage-y += device_romstage.c
+bootblock-y += device_simple.c
+verstage-y += device_simple.c
+romstage-y += device_simple.c
 romstage-$(CONFIG_PCI) += pci_early.c
 
 subdirs-y += oprom dram
diff --git a/src/device/device_romstage.c b/src/device/device_romstage.c
deleted file mode 100644
index 828e99b..0000000
--- a/src/device/device_romstage.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * This file is part of the coreboot project.
- *
- * Copyright (C) 2003-2004 Linux Networx
- * (Written by Eric Biederman <ebiederman at lnxi.com> for Linux Networx)
- * Copyright (C) 2003 Greg Watson <jarrah at users.sourceforge.net>
- * Copyright (C) 2004 Li-Ta Lo <ollie at lanl.gov>
- * Copyright (C) 2005-2006 Tyan
- * (Written by Yinghai Lu <yhlu at tyan.com> for Tyan)
- *
- * 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.
- */
-
-#include <device/device.h>
-#include <device/path.h>
-#include <device/pci.h>
-#include <device/resource.h>
-
-/** Linked list of ALL devices */
-ROMSTAGE_CONST struct device * ROMSTAGE_CONST all_devices = &dev_root;
-
-/**
- * Given a PCI bus and a devfn number, find the device structure.
- *
- * @param bus The bus number.
- * @param devfn A device/function number.
- * @return Pointer to the device structure (if found), 0 otherwise.
- */
-ROMSTAGE_CONST struct device *dev_find_slot(unsigned int bus,
-						unsigned int devfn)
-{
-	ROMSTAGE_CONST struct device *dev, *result;
-
-	result = 0;
-	for (dev = all_devices; dev; dev = dev->next) {
-		if ((dev->path.type == DEVICE_PATH_PCI) &&
-		    (dev->bus->secondary == bus) &&
-		    (dev->path.pci.devfn == devfn)) {
-			result = dev;
-			break;
-		}
-	}
-	return result;
-}
-
-/**
- * Given a device pointer, find the next PCI device.
- *
- * @param previous_dev A pointer to a PCI device structure.
- * @return Pointer to the next device structure (if found), 0 otherwise.
- */
-ROMSTAGE_CONST struct device *dev_find_next_pci_device(
-		ROMSTAGE_CONST struct device *previous_dev)
-{
-	ROMSTAGE_CONST struct device *dev, *result;
-
-	if (previous_dev == NULL)
-		previous_dev = all_devices;
-
-	result = 0;
-	for (dev = previous_dev->next; dev; dev = dev->next) {
-		if (dev->path.type == DEVICE_PATH_PCI) {
-			result = dev;
-			break;
-		}
-	}
-	return result;
-}
-
-/**
- * Given an SMBus bus and a device number, find the device structure.
- *
- * @param bus The bus number.
- * @param addr A device number.
- * @return Pointer to the device structure (if found), 0 otherwise.
- */
-ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
-							unsigned int addr)
-{
-	ROMSTAGE_CONST struct device *dev, *result;
-
-	result = 0;
-	for (dev = all_devices; dev; dev = dev->next) {
-		if ((dev->path.type == DEVICE_PATH_I2C) &&
-		    (dev->bus->secondary == bus) &&
-		    (dev->path.i2c.device == addr)) {
-			result = dev;
-			break;
-		}
-	}
-	return result;
-}
-
-/**
- * Given a PnP port and a device number, find the device structure.
- *
- * @param port The I/O port.
- * @param device Logical device number.
- * @return Pointer to the device structure (if found), 0 otherwise.
- */
-ROMSTAGE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device)
-{
-	ROMSTAGE_CONST struct device *dev;
-
-	for (dev = all_devices; dev; dev = dev->next) {
-		if ((dev->path.type == DEVICE_PATH_PNP) &&
-		    (dev->path.pnp.port == port) &&
-		    (dev->path.pnp.device == device)) {
-			return dev;
-		}
-	}
-	return 0;
-}
diff --git a/src/device/device_simple.c b/src/device/device_simple.c
new file mode 100644
index 0000000..828e99b
--- /dev/null
+++ b/src/device/device_simple.c
@@ -0,0 +1,120 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2003-2004 Linux Networx
+ * (Written by Eric Biederman <ebiederman at lnxi.com> for Linux Networx)
+ * Copyright (C) 2003 Greg Watson <jarrah at users.sourceforge.net>
+ * Copyright (C) 2004 Li-Ta Lo <ollie at lanl.gov>
+ * Copyright (C) 2005-2006 Tyan
+ * (Written by Yinghai Lu <yhlu at tyan.com> for Tyan)
+ *
+ * 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.
+ */
+
+#include <device/device.h>
+#include <device/path.h>
+#include <device/pci.h>
+#include <device/resource.h>
+
+/** Linked list of ALL devices */
+ROMSTAGE_CONST struct device * ROMSTAGE_CONST all_devices = &dev_root;
+
+/**
+ * Given a PCI bus and a devfn number, find the device structure.
+ *
+ * @param bus The bus number.
+ * @param devfn A device/function number.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_slot(unsigned int bus,
+						unsigned int devfn)
+{
+	ROMSTAGE_CONST struct device *dev, *result;
+
+	result = 0;
+	for (dev = all_devices; dev; dev = dev->next) {
+		if ((dev->path.type == DEVICE_PATH_PCI) &&
+		    (dev->bus->secondary == bus) &&
+		    (dev->path.pci.devfn == devfn)) {
+			result = dev;
+			break;
+		}
+	}
+	return result;
+}
+
+/**
+ * Given a device pointer, find the next PCI device.
+ *
+ * @param previous_dev A pointer to a PCI device structure.
+ * @return Pointer to the next device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_next_pci_device(
+		ROMSTAGE_CONST struct device *previous_dev)
+{
+	ROMSTAGE_CONST struct device *dev, *result;
+
+	if (previous_dev == NULL)
+		previous_dev = all_devices;
+
+	result = 0;
+	for (dev = previous_dev->next; dev; dev = dev->next) {
+		if (dev->path.type == DEVICE_PATH_PCI) {
+			result = dev;
+			break;
+		}
+	}
+	return result;
+}
+
+/**
+ * Given an SMBus bus and a device number, find the device structure.
+ *
+ * @param bus The bus number.
+ * @param addr A device number.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_slot_on_smbus(unsigned int bus,
+							unsigned int addr)
+{
+	ROMSTAGE_CONST struct device *dev, *result;
+
+	result = 0;
+	for (dev = all_devices; dev; dev = dev->next) {
+		if ((dev->path.type == DEVICE_PATH_I2C) &&
+		    (dev->bus->secondary == bus) &&
+		    (dev->path.i2c.device == addr)) {
+			result = dev;
+			break;
+		}
+	}
+	return result;
+}
+
+/**
+ * Given a PnP port and a device number, find the device structure.
+ *
+ * @param port The I/O port.
+ * @param device Logical device number.
+ * @return Pointer to the device structure (if found), 0 otherwise.
+ */
+ROMSTAGE_CONST struct device *dev_find_slot_pnp(u16 port, u16 device)
+{
+	ROMSTAGE_CONST struct device *dev;
+
+	for (dev = all_devices; dev; dev = dev->next) {
+		if ((dev->path.type == DEVICE_PATH_PNP) &&
+		    (dev->path.pnp.port == port) &&
+		    (dev->path.pnp.device == device)) {
+			return dev;
+		}
+	}
+	return 0;
+}



More information about the coreboot-gerrit mailing list