summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2022-07-30 15:52:19 -0600
committerTom Rini <[email protected]>2022-08-12 08:14:24 -0400
commit988cacaeedae920c13741c9ab2fc580f63a06c3a (patch)
tree5b2d7bc4a9a821179fd89658252469405f0cc747 /boot
parent10d16faa436c9f06bbcdeb6da35871a1b329b6b0 (diff)
bootstd: Provide a bootmeth method to obtain state info
Some bootmeths can provide information about what is available to boot. For example, VBE simple provides access to the firmware state. Add a new method for this, along with a sandbox test. Signed-off-by: Simon Glass <[email protected]>
Diffstat (limited to 'boot')
-rw-r--r--boot/bootmeth-uclass.c10
-rw-r--r--boot/bootmeth_distro.c14
2 files changed, 24 insertions, 0 deletions
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index b8ba4eca7ab..1e276c0f26b 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -20,6 +20,16 @@
DECLARE_GLOBAL_DATA_PTR;
+int bootmeth_get_state_desc(struct udevice *dev, char *buf, int maxsize)
+{
+ const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
+
+ if (!ops->get_state_desc)
+ return -ENOSYS;
+
+ return ops->get_state_desc(dev, buf, maxsize);
+}
+
int bootmeth_check(struct udevice *dev, struct bootflow_iter *iter)
{
const struct bootmeth_ops *ops = bootmeth_get_ops(dev);
diff --git a/boot/bootmeth_distro.c b/boot/bootmeth_distro.c
index 2b41e654ade..fea09b2c2fb 100644
--- a/boot/bootmeth_distro.c
+++ b/boot/bootmeth_distro.c
@@ -22,6 +22,19 @@
#include <mmc.h>
#include <pxe_utils.h>
+static int distro_get_state_desc(struct udevice *dev, char *buf, int maxsize)
+{
+ if (IS_ENABLED(CONFIG_SANDBOX)) {
+ int len;
+
+ len = snprintf(buf, maxsize, "OK");
+
+ return len + 1 < maxsize ? 0 : -ENOSPC;
+ }
+
+ return 0;
+}
+
static int disto_getfile(struct pxe_context *ctx, const char *file_path,
char *file_addr, ulong *sizep)
{
@@ -123,6 +136,7 @@ static int distro_bootmeth_bind(struct udevice *dev)
}
static struct bootmeth_ops distro_bootmeth_ops = {
+ .get_state_desc = distro_get_state_desc,
.check = distro_check,
.read_bootflow = distro_read_bootflow,
.read_file = bootmeth_common_read_file,