summaryrefslogtreecommitdiff
path: root/boot/bootdev-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-01-17 20:47:33 +0300
committerTom Rini <trini@konsulko.com>2023-01-24 02:11:40 +0300
commitbd90b092882099afa3786829036c82d6a4241fc8 (patch)
tree062539871ab4506554a1c6251b1cfca9ebb6e6e5 /boot/bootdev-uclass.c
parent3722cc973f092a6fd1724ea06bd18b205e678ddf (diff)
downloadu-boot-bd90b092882099afa3786829036c82d6a4241fc8.tar.xz
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 'boot/bootdev-uclass.c')
-rw-r--r--boot/bootdev-uclass.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 0ef3daf24c..62eb0b617c 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -636,6 +636,37 @@ int bootdev_setup_iter_order(struct bootflow_iter *iter, struct udevice **devp)
return 0;
}
+void bootdev_list_hunters(struct bootstd_priv *std)
+{
+ struct bootdev_hunter *orig, *start;
+ int n_ent, i;
+
+ orig = ll_entry_start(struct bootdev_hunter, bootdev_hunter);
+ n_ent = ll_entry_count(struct bootdev_hunter, bootdev_hunter);
+
+ /*
+ * workaround for strange bug in clang-12 which sees all the below data
+ * as zeroes. Any access of start seems to fix it, such as
+ *
+ * printf("%p", start);
+ *
+ * Use memcpy() to force the correct behaviour.
+ */
+ memcpy(&start, &orig, sizeof(orig));
+ printf("%4s %4s %-15s %s\n", "Prio", "Used", "Uclass", "Hunter");
+ printf("%4s %4s %-15s %s\n", "----", "----", "---------------", "---------------");
+ for (i = 0; i < n_ent; i++) {
+ struct bootdev_hunter *info = start + i;
+
+ printf("%4d %4s %-15s %s\n", info->prio,
+ std->hunters_used & BIT(i) ? "*" : "",
+ uclass_get_name(info->uclass),
+ info->drv ? info->drv->name : "(none)");
+ }
+
+ printf("(total hunters: %d)\n", n_ent);
+}
+
static int bootdev_post_bind(struct udevice *dev)
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);