[coreboot-gerrit] Change in coreboot[master]: lib/boot_device: Add API for getting boot device information

Furquan Shaikh (Code Review) gerrit at coreboot.org
Tue May 16 10:15:12 CEST 2017


Furquan Shaikh has uploaded a new change for review. ( https://review.coreboot.org/19701 )

Change subject: lib/boot_device: Add API for getting boot device information
......................................................................

lib/boot_device: Add API for getting boot device information

Add API boot_device_get_info that can be provided by boot device
implementations to return any information that can be useful for the
caller. Return value is void *, so each implementation can return a
pointer to any data structure that is required. By default, NULL is
returned by weak implementation indicating that no information is
available for use by the caller.

BUG=b:38330715

Change-Id: Ia35fc275a2aacf1cf8a3080d5f0da5dc19284206
---
M src/include/boot_device.h
M src/lib/boot_device.c
2 files changed, 24 insertions(+), 0 deletions(-)


  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/01/19701/1

diff --git a/src/include/boot_device.h b/src/include/boot_device.h
index cc70442..6079cc9 100644
--- a/src/include/boot_device.h
+++ b/src/include/boot_device.h
@@ -50,4 +50,19 @@
  **/
 void boot_device_init(void);
 
+/*
+ * Obtain information about boot device. This can be used by boot device
+ * implementations to return pointer to any structure that the users might find
+ * useful. e.g. In case of SPI flash boot device, pointer to struct spi_flash
+ * would be useful for filling in coreboot tables or performing operations on
+ * the boot device.
+ *
+ * Returns:
+ *  void * = Pointer to agreed-upon structure between boot device implementation
+ *           and the caller.
+ *  NULL   = No information provided by boot device implementation or boot
+ *           device init has failed.
+ */
+void *boot_device_get_info(void);
+
 #endif /* _BOOT_DEVICE_H_ */
diff --git a/src/lib/boot_device.c b/src/lib/boot_device.c
index e7968f4..b9c706a 100644
--- a/src/lib/boot_device.c
+++ b/src/lib/boot_device.c
@@ -15,6 +15,15 @@
 
 #include <boot_device.h>
 
+void *__attribute__((weak)) boot_device_get_info(void)
+{
+	/*
+	 * Default weak-implementation that returns NULL indicating no
+	 * information provided by boot device implementation.
+	 */
+	return NULL;
+}
+
 void __attribute__((weak)) boot_device_init(void)
 {
 	/* Provide weak do-nothing init. */

-- 
To view, visit https://review.coreboot.org/19701
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia35fc275a2aacf1cf8a3080d5f0da5dc19284206
Gerrit-PatchSet: 1
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Furquan Shaikh <furquan at google.com>



More information about the coreboot-gerrit mailing list