1 // SPDX-License-Identifier: GPL-2.0
3 * Verified Boot for Embedded (VBE) access functions
5 * Copyright 2022 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
15 #include <dm/uclass-internal.h>
18 * is_vbe() - Check if a device is a VBE method
20 * @dev: Device to check
21 * @return true if this is a VBE bootmth device, else false
23 static bool is_vbe(struct udevice *dev)
25 return !strncmp("vbe", dev->driver->name, 3);
28 int vbe_find_next_device(struct udevice **devp)
30 for (uclass_find_next_device(devp);
32 uclass_find_next_device(devp)) {
40 int vbe_find_first_device(struct udevice **devp)
42 uclass_find_first_device(UCLASS_BOOTMETH, devp);
43 if (!*devp || is_vbe(*devp))
46 return vbe_find_next_device(devp);
51 struct bootstd_priv *std;
55 ret = bootstd_get_priv(&std);
59 printf("%3s %-3s %-15s %-15s %s\n", "#", "Sel", "Device", "Driver",
61 printf("%3s %-3s %-15s %-15s %s\n", "---", "---", "--------------",
62 "--------------", "-----------");
63 for (ret = vbe_find_first_device(&dev); dev;
64 ret = vbe_find_next_device(&dev)) {
65 const struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
67 printf("%3d %-3s %-15s %-15s %s\n", dev_seq(dev),
68 std->vbe_bootmeth == dev ? "*" : "", dev->name,
69 dev->driver->name, plat->desc);
71 printf("%3s %-3s %-15s %-15s %s\n", "---", "---", "--------------",
72 "--------------", "-----------");
77 int vbe_select(struct udevice *dev)
79 struct bootstd_priv *std;
82 ret = bootstd_get_priv(&std);
85 std->vbe_bootmeth = dev;
90 int vbe_find_by_any(const char *name, struct udevice **devp)
96 seq = simple_strtol(name, &endp, 16);
100 ret = uclass_get_device_by_name(UCLASS_BOOTMETH, name, &dev);
102 printf("Cannot probe VBE bootmeth '%s' (err=%d)\n", name,
107 /* select by number */
109 ret = uclass_get_device_by_seq(UCLASS_BOOTMETH, seq, &dev);
111 printf("Cannot find '%s' (err=%d)\n", name, ret);