aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-04-24 23:31:21 -0600
committerTom Rini <trini@konsulko.com>2022-04-25 10:00:04 -0400
commit7d0478d241703b50e88736f3774deb5472418b58 (patch)
treef068eb27d2e817d15f611255e6ba8362899ce1d4
parent126947b77321418127274f3102e7988225a780b7 (diff)
downloadu-boot-7d0478d241703b50e88736f3774deb5472418b58.zip
u-boot-7d0478d241703b50e88736f3774deb5472418b58.tar.gz
u-boot-7d0478d241703b50e88736f3774deb5472418b58.tar.bz2
bootstd: sandbox: Add a hostfs bootdev
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>
-rw-r--r--arch/sandbox/dts/sandbox.dts4
-rw-r--r--arch/sandbox/dts/sandbox.dtsi5
-rw-r--r--fs/Kconfig2
-rw-r--r--fs/sandbox/Kconfig2
-rw-r--r--fs/sandbox/Makefile1
-rw-r--r--fs/sandbox/host_bootdev.c56
6 files changed, 70 insertions, 0 deletions
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
index 127f168..18fde1c 100644
--- a/arch/sandbox/dts/sandbox.dts
+++ b/arch/sandbox/dts/sandbox.dts
@@ -66,6 +66,10 @@
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>;
diff --git a/arch/sandbox/dts/sandbox.dtsi b/arch/sandbox/dts/sandbox.dtsi
index 826db26..29306ac 100644
--- a/arch/sandbox/dts/sandbox.dtsi
+++ b/arch/sandbox/dts/sandbox.dtsi
@@ -19,6 +19,11 @@
#sound-dai-cells = <1>;
};
+ bootstd {
+ compatible = "u-boot,boot-std";
+ filename-prefixes = "./";
+ };
+
buttons {
compatible = "gpio-keys";
diff --git a/fs/Kconfig b/fs/Kconfig
index cda9f66..aa13d4f 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -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
index 0000000..b2af848
--- /dev/null
+++ b/fs/sandbox/Kconfig
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
diff --git a/fs/sandbox/Makefile b/fs/sandbox/Makefile
index 0609051..880d59d 100644
--- a/fs/sandbox/Makefile
+++ b/fs/sandbox/Makefile
@@ -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
index 0000000..0d12ee4
--- /dev/null
+++ b/fs/sandbox/host_bootdev.c
@@ -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,
+};