eficapsule.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2021 Linaro Limited
  4. * Author: AKASHI Takahiro
  5. *
  6. * derived from efi.h and efi_api.h to make the file POSIX-compliant
  7. */
  8. #ifndef _EFI_CAPSULE_H
  9. #define _EFI_CAPSULE_H
  10. #include <stdint.h>
  11. /*
  12. * Gcc's predefined attributes are not recognized by clang.
  13. */
  14. #ifndef __packed
  15. #define __packed __attribute__((__packed__))
  16. #endif
  17. #ifndef __aligned
  18. #define __aligned(x) __attribute__((__aligned__(x)))
  19. #endif
  20. typedef struct {
  21. uint8_t b[16];
  22. } efi_guid_t __aligned(8);
  23. #define EFI_GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
  24. {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, \
  25. ((a) >> 24) & 0xff, \
  26. (b) & 0xff, ((b) >> 8) & 0xff, \
  27. (c) & 0xff, ((c) >> 8) & 0xff, \
  28. (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) } }
  29. #define EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID \
  30. EFI_GUID(0x6dcbd5ed, 0xe82d, 0x4c44, 0xbd, 0xa1, \
  31. 0x71, 0x94, 0x19, 0x9a, 0xd9, 0x2a)
  32. #define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID \
  33. EFI_GUID(0xae13ff2d, 0x9ad4, 0x4e25, 0x9a, 0xc8, \
  34. 0x6d, 0x80, 0xb3, 0xb2, 0x21, 0x47)
  35. #define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID \
  36. EFI_GUID(0xe2bb9c06, 0x70e9, 0x4b14, 0x97, 0xa3, \
  37. 0x5a, 0x79, 0x13, 0x17, 0x6e, 0x3f)
  38. #define EFI_CERT_TYPE_PKCS7_GUID \
  39. EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \
  40. 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
  41. /* flags */
  42. #define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
  43. struct efi_capsule_header {
  44. efi_guid_t capsule_guid;
  45. uint32_t header_size;
  46. uint32_t flags;
  47. uint32_t capsule_image_size;
  48. } __packed;
  49. struct efi_firmware_management_capsule_header {
  50. uint32_t version;
  51. uint16_t embedded_driver_count;
  52. uint16_t payload_item_count;
  53. uint32_t item_offset_list[];
  54. } __packed;
  55. /* image_capsule_support */
  56. #define CAPSULE_SUPPORT_AUTHENTICATION 0x0000000000000001
  57. struct efi_firmware_management_capsule_image_header {
  58. uint32_t version;
  59. efi_guid_t update_image_type_id;
  60. uint8_t update_image_index;
  61. uint8_t reserved[3];
  62. uint32_t update_image_size;
  63. uint32_t update_vendor_code_size;
  64. uint64_t update_hardware_instance;
  65. uint64_t image_capsule_support;
  66. } __packed;
  67. /**
  68. * win_certificate_uefi_guid - A certificate that encapsulates
  69. * a GUID-specific signature
  70. *
  71. * @hdr: Windows certificate header, cf. WIN_CERTIFICATE
  72. * @cert_type: Certificate type
  73. */
  74. struct win_certificate_uefi_guid {
  75. struct {
  76. uint32_t dwLength;
  77. uint16_t wRevision;
  78. uint16_t wCertificateType;
  79. } hdr;
  80. efi_guid_t cert_type;
  81. } __packed;
  82. /**
  83. * efi_firmware_image_authentication - Capsule authentication method
  84. * descriptor
  85. *
  86. * This structure describes an authentication information for
  87. * a capsule with IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED set
  88. * and should be included as part of the capsule.
  89. * Only EFI_CERT_TYPE_PKCS7_GUID is accepted.
  90. *
  91. * @monotonic_count: Count to prevent replay
  92. * @auth_info: Authentication info
  93. */
  94. struct efi_firmware_image_authentication {
  95. uint64_t monotonic_count;
  96. struct win_certificate_uefi_guid auth_info;
  97. } __packed;
  98. #endif /* _EFI_CAPSULE_H */