Simon Glass | 1b4bc15 | 2022-04-24 23:31:21 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
Simon Glass | 4157158 | 2023-07-12 09:04:32 -0600 | [diff] [blame] | 3 | * Bootdev for sandbox host |
Simon Glass | 1b4bc15 | 2022-04-24 23:31:21 -0600 | [diff] [blame] | 4 | * |
| 5 | * Copyright 2021 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
Simon Glass | 1b4bc15 | 2022-04-24 23:31:21 -0600 | [diff] [blame] | 9 | #include <bootdev.h> |
| 10 | #include <bootflow.h> |
| 11 | #include <bootmeth.h> |
| 12 | #include <dm.h> |
| 13 | #include <fs.h> |
| 14 | |
| 15 | static int host_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, |
| 16 | struct bootflow *bflow) |
| 17 | { |
| 18 | int ret; |
| 19 | |
| 20 | if (iter->part) |
| 21 | return log_msg_ret("max", -ESHUTDOWN); |
| 22 | |
| 23 | bflow->name = strdup(dev->name); |
| 24 | if (!bflow->name) |
| 25 | return log_msg_ret("name", -ENOMEM); |
| 26 | |
| 27 | ret = bootmeth_check(bflow->method, iter); |
| 28 | if (ret) |
| 29 | return log_msg_ret("check", ret); |
| 30 | |
| 31 | bflow->state = BOOTFLOWST_MEDIA; |
| 32 | bflow->fs_type = FS_TYPE_SANDBOX; |
| 33 | |
| 34 | ret = bootmeth_read_bootflow(bflow->method, bflow); |
| 35 | if (ret) |
| 36 | return log_msg_ret("method", ret); |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | struct bootdev_ops host_bootdev_ops = { |
| 42 | .get_bootflow = host_get_bootflow, |
| 43 | }; |
| 44 | |
| 45 | static const struct udevice_id host_bootdev_ids[] = { |
| 46 | { .compatible = "sandbox,bootdev-host" }, |
| 47 | { } |
| 48 | }; |
| 49 | |
| 50 | U_BOOT_DRIVER(host_bootdev) = { |
| 51 | .name = "host_bootdev", |
| 52 | .id = UCLASS_BOOTDEV, |
| 53 | .ops = &host_bootdev_ops, |
| 54 | .of_match = host_bootdev_ids, |
| 55 | }; |