aboutsummaryrefslogtreecommitdiff
path: root/include/bootdev.h
diff options
context:
space:
mode:
authorSimon Glass2023-01-17 10:47:33 -0700
committerTom Rini2023-01-23 18:11:40 -0500
commitbd90b092882099afa3786829036c82d6a4241fc8 (patch)
tree062539871ab4506554a1c6251b1cfca9ebb6e6e5 /include/bootdev.h
parent3722cc973f092a6fd1724ea06bd18b205e678ddf (diff)
bootstd: Add the concept of a bootdev hunter
Some bootdevs must be enumerated before they appear. For example, USB bootdevs are not visible until USB is enumerated. With standard boot this needs to happen automatically, since we only want to enumerate a bus if it is needed. Add a way to define bootdev 'hunters' which can be used to hunt for bootdevs of a given type. Track which ones have been used and add a command to list them. Include a clang work-around which seems to be needed. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/bootdev.h')
-rw-r--r--include/bootdev.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/bootdev.h b/include/bootdev.h
index 1e91d4130e7..cafb5285a28 100644
--- a/include/bootdev.h
+++ b/include/bootdev.h
@@ -11,6 +11,7 @@
struct bootflow;
struct bootflow_iter;
+struct bootstd_priv;
struct udevice;
/**
@@ -33,6 +34,53 @@ enum bootdev_prio_t {
BOOTDEVP_COUNT,
};
+struct bootdev_hunter;
+
+/**
+ * bootdev_hunter_func - function to probe for bootdevs of a given type
+ *
+ * This should hunt around for bootdevs of the given type, binding them as it
+ * finds them. This may involve bus enumeration, etc.
+ *
+ * @info: Info structure describing this hunter
+ * @show: true to show information from the hunter
+ * Returns: 0 if OK, -ve on error
+ */
+typedef int (*bootdev_hunter_func)(struct bootdev_hunter *info, bool show);
+
+/**
+ * struct bootdev_hunter - information about how to hunt for bootdevs
+ *
+ * @prio: Scanning priority of this hunter
+ * @uclass: Uclass ID for the media associated with this bootdev
+ * @drv: bootdev driver for the things found by this hunter
+ * @hunt: Function to call to hunt for bootdevs of this type (NULL if none)
+ *
+ * Some bootdevs are not visible until other devices are enumerated. For
+ * example, USB bootdevs only appear when the USB bus is enumerated.
+ *
+ * On the other hand, we don't always want to enumerate all the buses just to
+ * find the first valid bootdev. Ideally we want to work through them in
+ * priority order, so that the fastest bootdevs are discovered first.
+ *
+ * This struct holds information about the bootdev so we can determine the probe
+ * order and how to hunt for bootdevs of this type
+ */
+struct bootdev_hunter {
+ enum bootdev_prio_t prio;
+ enum uclass_id uclass;
+ struct driver *drv;
+ bootdev_hunter_func hunt;
+};
+
+/* declare a new bootdev hunter */
+#define BOOTDEV_HUNTER(__name) \
+ ll_entry_declare(struct bootdev_hunter, __name, bootdev_hunter)
+
+/* access a bootdev hunter by name */
+#define BOOTDEV_HUNTER_GET(__name) \
+ ll_entry_get(struct bootdev_hunter, __name, bootdev_hunter)
+
/**
* struct bootdev_uc_plat - uclass information about a bootdev
*
@@ -205,6 +253,16 @@ int bootdev_find_by_any(const char *name, struct udevice **devp);
*/
int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp);
+/**
+ * bootdev_list_hunters() - List the available bootdev hunters
+ *
+ * These provide a way to find new bootdevs by enumerating buses, etc. This
+ * function lists the available hunters
+ *
+ * @std: Pointer to bootstd private info
+ */
+void bootdev_list_hunters(struct bootstd_priv *std);
+
#if CONFIG_IS_ENABLED(BOOTSTD)
/**
* bootdev_setup_for_dev() - Bind a new bootdev device (deprecated)