boot: sandbox: Provide a bootdev for the host uclass

Support standard boot on a host device by adding a bootdev. This allows
booting from disk images using sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-05-31 15:26:38 +01:00
parent 847d15cada
commit 8fdae6fe54

View File

@@ -10,6 +10,7 @@
#define LOG_CATEGORY UCLASS_HOST
#include <blk.h>
#include <bootdev.h>
#include <dm.h>
#include <malloc.h>
#include <part.h>
@@ -101,6 +102,31 @@ int host_attach_file(struct udevice *dev, const char *filename)
return ops->attach_file(dev, filename);
}
static int host_bootdev_bind(struct udevice *dev)
{
struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev);
ucp->prio = BOOTDEVP_2_INTERNAL_FAST;
return 0;
}
static struct bootdev_ops host_bootdev_ops = {
};
static const struct udevice_id host_bootdev_ids[] = {
{ .compatible = "u-boot,bootdev-host" },
{ }
};
U_BOOT_DRIVER(host_bootdev) = {
.name = "host_bootdev",
.id = UCLASS_BOOTDEV,
.ops = &host_bootdev_ops,
.bind = host_bootdev_bind,
.of_match = host_bootdev_ids,
};
int host_create_attach_file(const char *label, const char *filename,
bool removable, unsigned long blksz,
struct udevice **devp)