vbe_simple.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Verified Boot for Embedded (VBE) vbe-simple common file
  4. *
  5. * Copyright 2022 Google LLC
  6. * Written by Simon Glass <sjg@chromium.org>
  7. */
  8. #ifndef __VBE_SIMPLE_H
  9. #define __VBE_SIMPLE_H
  10. enum {
  11. MAX_VERSION_LEN = 256,
  12. NVD_HDR_VER_SHIFT = 0,
  13. NVD_HDR_VER_MASK = 0xf,
  14. NVD_HDR_SIZE_SHIFT = 4,
  15. NVD_HDR_SIZE_MASK = 0xf << NVD_HDR_SIZE_SHIFT,
  16. /* Firmware key-version is in the top 16 bits of fw_ver */
  17. FWVER_KEY_SHIFT = 16,
  18. FWVER_FW_MASK = 0xffff,
  19. NVD_HDR_VER_CUR = 1, /* current version */
  20. };
  21. /** struct simple_priv - information read from the device tree */
  22. struct simple_priv {
  23. u32 area_start;
  24. u32 area_size;
  25. u32 skip_offset;
  26. u32 state_offset;
  27. u32 state_size;
  28. u32 version_offset;
  29. u32 version_size;
  30. const char *storage;
  31. };
  32. /** struct simple_state - state information read from media
  33. *
  34. * @fw_version: Firmware version string
  35. * @fw_vernum: Firmware version number
  36. */
  37. struct simple_state {
  38. char fw_version[MAX_VERSION_LEN];
  39. u32 fw_vernum;
  40. };
  41. /**
  42. * vbe_simple_read_fw_bootflow() - Read a bootflow for firmware
  43. *
  44. * Locates and loads the firmware image (FIT) needed for the next phase. The FIT
  45. * should ideally use external data, to reduce the amount of it that needs to be
  46. * read.
  47. *
  48. * @bdev: bootdev device containing the firmwre
  49. * @blow: Place to put the created bootflow, on success
  50. * @return 0 if OK, -ve on error
  51. */
  52. int vbe_simple_read_bootflow_fw(struct udevice *dev, struct bootflow *bflow);
  53. /**
  54. * vbe_simple_read_state() - Read the VBE simple state information
  55. *
  56. * @dev: VBE bootmeth
  57. * @state: Place to put the state
  58. * @return 0 if OK, -ve on error
  59. */
  60. int vbe_simple_read_state(struct udevice *dev, struct simple_state *state);
  61. #endif /* __VBE_SIMPLE_H */