summaryrefslogtreecommitdiff
path: root/boot/bootmeth_sandbox.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-04-25 08:31:20 +0300
committerTom Rini <trini@konsulko.com>2022-04-25 17:00:04 +0300
commit126947b77321418127274f3102e7988225a780b7 (patch)
tree41b49e702f5c38c3b7f48b5dd1982f9d4d9c7836 /boot/bootmeth_sandbox.c
parent0b41525e8f5453220e8c78a763a5879e73e6b825 (diff)
downloadu-boot-126947b77321418127274f3102e7988225a780b7.tar.xz
bootstd: Add a sandbox bootmeth driver
Add a bootmeth driver for sandbox, used for testing. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'boot/bootmeth_sandbox.c')
-rw-r--r--boot/bootmeth_sandbox.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/boot/bootmeth_sandbox.c b/boot/bootmeth_sandbox.c
new file mode 100644
index 0000000000..13ec5e95e6
--- /dev/null
+++ b/boot/bootmeth_sandbox.c
@@ -0,0 +1,69 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootmethod for sandbox testing
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <dm.h>
+
+static int sandbox_check(struct udevice *dev, struct bootflow_iter *iter)
+{
+ return 0;
+}
+
+static int sandbox_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+{
+ /* pretend we are ready */
+ bflow->state = BOOTFLOWST_READY;
+
+ return 0;
+}
+
+static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr, ulong *sizep)
+{
+ return -ENOSYS;
+}
+
+static int sandbox_boot(struct udevice *dev, struct bootflow *bflow)
+{
+ /* always fail: see bootflow_iter_disable() */
+ return -ENOTSUPP;
+}
+
+static int sandbox_bootmeth_bind(struct udevice *dev)
+{
+ struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
+
+ plat->desc = "Sandbox boot for testing";
+
+ return 0;
+}
+
+static struct bootmeth_ops sandbox_bootmeth_ops = {
+ .check = sandbox_check,
+ .read_bootflow = sandbox_read_bootflow,
+ .read_file = sandbox_read_file,
+ .boot = sandbox_boot,
+};
+
+static const struct udevice_id sandbox_bootmeth_ids[] = {
+ { .compatible = "u-boot,sandbox-syslinux" },
+ { }
+};
+
+U_BOOT_DRIVER(bootmeth_sandbox) = {
+ .name = "bootmeth_sandbox",
+ .id = UCLASS_BOOTMETH,
+ .of_match = sandbox_bootmeth_ids,
+ .ops = &sandbox_bootmeth_ops,
+ .bind = sandbox_bootmeth_bind,
+};