1 // SPDX-License-Identifier: GPL-2.0
3 * Verified Boot for Embedded (VBE) access functions
5 * Copyright 2022 Google LLC
14 #include <dm/uclass-internal.h>
17 * is_vbe() - Check if a device is a VBE method
19 * @dev: Device to check
20 * @return true if this is a VBE bootmth device, else false
22 static bool is_vbe(struct udevice *dev)
24 return !strncmp("vbe", dev->driver->name, 3);
27 int vbe_find_next_device(struct udevice **devp)
29 for (uclass_find_next_device(devp);
31 uclass_find_next_device(devp)) {
39 int vbe_find_first_device(struct udevice **devp)
41 uclass_find_first_device(UCLASS_BOOTMETH, devp);
42 if (!*devp || is_vbe(*devp))
45 return vbe_find_next_device(devp);
50 struct bootstd_priv *std;
54 ret = bootstd_get_priv(&std);
58 printf("%3s %-3s %-15s %-15s %s\n", "#", "Sel", "Device", "Driver",
60 printf("%3s %-3s %-15s %-15s %s\n", "---", "---", "--------------",
61 "--------------", "-----------");
62 for (ret = vbe_find_first_device(&dev); dev;
63 ret = vbe_find_next_device(&dev)) {
64 const struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
66 printf("%3d %-3s %-15s %-15s %s\n", dev_seq(dev),
67 std->vbe_bootmeth == dev ? "*" : "", dev->name,
68 dev->driver->name, plat->desc);
70 printf("%3s %-3s %-15s %-15s %s\n", "---", "---", "--------------",
71 "--------------", "-----------");
76 int vbe_select(struct udevice *dev)
78 struct bootstd_priv *std;
81 ret = bootstd_get_priv(&std);
84 std->vbe_bootmeth = dev;
89 int vbe_find_by_any(const char *name, struct udevice **devp)
95 seq = simple_strtol(name, &endp, 16);
99 ret = uclass_get_device_by_name(UCLASS_BOOTMETH, name, &dev);
101 printf("Cannot probe VBE bootmeth '%s' (err=%d)\n", name,
106 /* select by number */
108 ret = uclass_get_device_by_seq(UCLASS_BOOTMETH, seq, &dev);
110 printf("Cannot find '%s' (err=%d)\n", name, ret);