Merge tag 'tpm-master-28012025' of https://source.denx.de/u-boot/custodians/u-boot-tpm
[u-boot.git] / boot / bootmeth_sandbox.c
blob92ba2e3f0509578f7cbb4d209b9f2ef7e29f522f
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Bootmethod for sandbox testing
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
9 #define LOG_CATEGORY UCLASS_BOOTSTD
11 #include <bootdev.h>
12 #include <bootflow.h>
13 #include <bootmeth.h>
14 #include <dm.h>
16 static int sandbox_check(struct udevice *dev, struct bootflow_iter *iter)
18 return 0;
21 static int sandbox_read_bootflow(struct udevice *dev, struct bootflow *bflow)
23 /* pretend we are ready */
24 bflow->state = BOOTFLOWST_READY;
26 return 0;
29 static int sandbox_read_file(struct udevice *dev, struct bootflow *bflow,
30 const char *file_path, ulong addr,
31 enum bootflow_img_t type, ulong *sizep)
33 return -ENOSYS;
36 static int sandbox_boot(struct udevice *dev, struct bootflow *bflow)
38 /* always fail: see bootflow_iter_disable() */
39 return -ENOTSUPP;
42 static int sandbox_bootmeth_bind(struct udevice *dev)
44 struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
46 plat->desc = "Sandbox boot for testing";
48 return 0;
51 static struct bootmeth_ops sandbox_bootmeth_ops = {
52 .check = sandbox_check,
53 .read_bootflow = sandbox_read_bootflow,
54 .read_file = sandbox_read_file,
55 .boot = sandbox_boot,
58 static const struct udevice_id sandbox_bootmeth_ids[] = {
59 { .compatible = "u-boot,sandbox-bootmeth" },
60 { }
63 U_BOOT_DRIVER(bootmeth_sandbox) = {
64 .name = "bootmeth_sandbox",
65 .id = UCLASS_BOOTMETH,
66 .of_match = sandbox_bootmeth_ids,
67 .ops = &sandbox_bootmeth_ops,
68 .bind = sandbox_bootmeth_bind,