vbe.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Verified Boot for Embedded (VBE) support
  4. * See doc/develop/vbe.rst
  5. *
  6. * Copyright 2022 Google LLC
  7. * Written by Simon Glass <sjg@chromium.org>
  8. */
  9. #ifndef __VBE_H
  10. #define __VBE_H
  11. /**
  12. * enum vbe_phase_t - current phase of VBE
  13. *
  14. * VBE operates in two distinct phases. In VPL it has to choose which firmware
  15. * to run (SPL, U-Boot, OP-TEE, etc.). It then carries on running until it gets
  16. * to U-Boot, where it decides which OS to run
  17. *
  18. * @VBE_PHASE_FIRMWARE: Selecting the firmware to run
  19. * @VBE_PHASE_OS: Selecting the Operating System to run
  20. */
  21. enum vbe_phase_t {
  22. VBE_PHASE_FIRMWARE,
  23. VBE_PHASE_OS,
  24. };
  25. /**
  26. * struct vbe_handoff - information about VBE progress
  27. *
  28. * @phases: Indicates which phases used the VBE bootmeth (1 << PHASE_...)
  29. */
  30. struct vbe_handoff {
  31. u8 phases;
  32. };
  33. /**
  34. * vbe_phase() - get current VBE phase
  35. *
  36. * Returns: Current VBE phase
  37. */
  38. static inline enum vbe_phase_t vbe_phase(void)
  39. {
  40. if (IS_ENABLED(CONFIG_SPL_BUILD))
  41. return VBE_PHASE_FIRMWARE;
  42. return VBE_PHASE_OS;
  43. }
  44. /**
  45. * vbe_list() - List the VBE bootmeths
  46. *
  47. * This shows a list of the VBE bootmeth devices
  48. *
  49. * @return 0 (always)
  50. */
  51. int vbe_list(void);
  52. /**
  53. * vbe_find_by_any() - Find a VBE bootmeth by name or sequence
  54. *
  55. * @name: name (e.g. "vbe-simple"), or sequence ("2") to find
  56. * @devp: returns the device found, on success
  57. * Return: 0 if OK, -ve on error
  58. */
  59. int vbe_find_by_any(const char *name, struct udevice **devp);
  60. /**
  61. * vbe_find_first_device() - Find the first VBE bootmeth
  62. *
  63. * @devp: Returns first available VBE bootmeth, or NULL if none
  64. * Returns: 0 (always)
  65. */
  66. int vbe_find_first_device(struct udevice **devp);
  67. /**
  68. * vbe_find_next_device() - Find the next available VBE bootmeth
  69. *
  70. * @devp: Previous device to start from. Returns next available VBE bootmeth,
  71. * or NULL if none
  72. * Returns: 0 (always)
  73. */
  74. int vbe_find_next_device(struct udevice **devp);
  75. #endif