host_bootdev.c 1.1 KB

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