]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
bootstd: sandbox: Add a hostfs bootdev
authorSimon Glass <sjg@chromium.org>
Mon, 25 Apr 2022 05:31:21 +0000 (23:31 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 25 Apr 2022 14:00:04 +0000 (10:00 -0400)
It is helpful to be able to try out bootstd on sandbox, using host files.
This is easier than using a block device, which must have a filesystem,
partition table, etc.

Add a new driver which provides this feature. For now it is not used in
tests, but it is likely to be useful.

Add notes in the devicetree also, but don't disturb the tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/sandbox.dts
arch/sandbox/dts/sandbox.dtsi
fs/Kconfig
fs/sandbox/Kconfig [new file with mode: 0644]
fs/sandbox/Makefile
fs/sandbox/host_bootdev.c [new file with mode: 0644]

index 127f168f022bd4f5c3ad34a98a854052bcfff01b..18fde1c8c6f071f464c3a96543a4429117514d0b 100644 (file)
                fake-host-hwaddr = [00 00 66 44 22 00];
        };
 
+       host-fs {
+               compatible = "sandbox,bootdev-host";
+       };
+
        i2c_0: i2c@0 {
                #address-cells = <1>;
                #size-cells = <0>;
index 826db26fc2b56b47865b1d76c5a9287d74926f12..29306ac04da988698f16fa1bba29149af9ade075 100644 (file)
                #sound-dai-cells = <1>;
        };
 
+       bootstd {
+               compatible = "u-boot,boot-std";
+               filename-prefixes = "./";
+       };
+
        buttons {
                compatible = "gpio-keys";
 
index cda9f66cc93a3831ae479c57433c2b610bb0a9b2..aa13d4faa7717bc32daf15a18db7c3d1e4b18a49 100644 (file)
@@ -16,6 +16,8 @@ source "fs/fat/Kconfig"
 
 source "fs/jffs2/Kconfig"
 
+source "fs/sandbox/Kconfig"
+
 source "fs/ubifs/Kconfig"
 
 source "fs/cramfs/Kconfig"
diff --git a/fs/sandbox/Kconfig b/fs/sandbox/Kconfig
new file mode 100644 (file)
index 0000000..b2af848
--- /dev/null
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
index 06090519bf4457f41ea4d6c54d7b344daa71e96d..880d59dd6930abd183ff14a7639d0e1fc8c059c4 100644 (file)
@@ -9,3 +9,4 @@
 # Pavel Bartusek, Sysgo Real-Time Solutions AG, pba@sysgo.de
 
 obj-y := sandboxfs.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += host_bootdev.o
diff --git a/fs/sandbox/host_bootdev.c b/fs/sandbox/host_bootdev.c
new file mode 100644 (file)
index 0000000..0d12ee4
--- /dev/null
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Bootdevice for MMC
+ *
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <dm.h>
+#include <fs.h>
+
+static int host_get_bootflow(struct udevice *dev, struct bootflow_iter *iter,
+                            struct bootflow *bflow)
+{
+       int ret;
+
+       if (iter->part)
+               return log_msg_ret("max", -ESHUTDOWN);
+
+       bflow->name = strdup(dev->name);
+       if (!bflow->name)
+               return log_msg_ret("name", -ENOMEM);
+
+       ret = bootmeth_check(bflow->method, iter);
+       if (ret)
+               return log_msg_ret("check", ret);
+
+       bflow->state = BOOTFLOWST_MEDIA;
+       bflow->fs_type = FS_TYPE_SANDBOX;
+
+       ret = bootmeth_read_bootflow(bflow->method, bflow);
+       if (ret)
+               return log_msg_ret("method", ret);
+
+       return 0;
+}
+
+struct bootdev_ops host_bootdev_ops = {
+       .get_bootflow   = host_get_bootflow,
+};
+
+static const struct udevice_id host_bootdev_ids[] = {
+       { .compatible = "sandbox,bootdev-host" },
+       { }
+};
+
+U_BOOT_DRIVER(host_bootdev) = {
+       .name           = "host_bootdev",
+       .id             = UCLASS_BOOTDEV,
+       .ops            = &host_bootdev_ops,
+       .of_match       = host_bootdev_ids,
+};