efi.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef BOOT_COMPRESSED_EFI_H
  3. #define BOOT_COMPRESSED_EFI_H
  4. #if defined(_LINUX_EFI_H) || defined(_ASM_X86_EFI_H)
  5. #error Please do not include kernel proper namespace headers
  6. #endif
  7. typedef guid_t efi_guid_t __aligned(__alignof__(u32));
  8. #define EFI_GUID(a, b, c, d...) (efi_guid_t){ { \
  9. (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
  10. (b) & 0xff, ((b) >> 8) & 0xff, \
  11. (c) & 0xff, ((c) >> 8) & 0xff, d } }
  12. #define ACPI_TABLE_GUID EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  13. #define ACPI_20_TABLE_GUID EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  14. #define EFI_CC_BLOB_GUID EFI_GUID(0x067b1f5f, 0xcf26, 0x44c5, 0x85, 0x54, 0x93, 0xd7, 0x77, 0x91, 0x2d, 0x42)
  15. #define EFI32_LOADER_SIGNATURE "EL32"
  16. #define EFI64_LOADER_SIGNATURE "EL64"
  17. /*
  18. * Generic EFI table header
  19. */
  20. typedef struct {
  21. u64 signature;
  22. u32 revision;
  23. u32 headersize;
  24. u32 crc32;
  25. u32 reserved;
  26. } efi_table_hdr_t;
  27. #define EFI_CONVENTIONAL_MEMORY 7
  28. #define EFI_MEMORY_MORE_RELIABLE \
  29. ((u64)0x0000000000010000ULL) /* higher reliability */
  30. #define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* soft reserved */
  31. #define EFI_PAGE_SHIFT 12
  32. typedef struct {
  33. u32 type;
  34. u32 pad;
  35. u64 phys_addr;
  36. u64 virt_addr;
  37. u64 num_pages;
  38. u64 attribute;
  39. } efi_memory_desc_t;
  40. #define efi_early_memdesc_ptr(map, desc_size, n) \
  41. (efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size)))
  42. typedef struct {
  43. efi_guid_t guid;
  44. u64 table;
  45. } efi_config_table_64_t;
  46. typedef struct {
  47. efi_guid_t guid;
  48. u32 table;
  49. } efi_config_table_32_t;
  50. typedef struct {
  51. efi_table_hdr_t hdr;
  52. u64 fw_vendor; /* physical addr of CHAR16 vendor string */
  53. u32 fw_revision;
  54. u32 __pad1;
  55. u64 con_in_handle;
  56. u64 con_in;
  57. u64 con_out_handle;
  58. u64 con_out;
  59. u64 stderr_handle;
  60. u64 stderr;
  61. u64 runtime;
  62. u64 boottime;
  63. u32 nr_tables;
  64. u32 __pad2;
  65. u64 tables;
  66. } efi_system_table_64_t;
  67. typedef struct {
  68. efi_table_hdr_t hdr;
  69. u32 fw_vendor; /* physical addr of CHAR16 vendor string */
  70. u32 fw_revision;
  71. u32 con_in_handle;
  72. u32 con_in;
  73. u32 con_out_handle;
  74. u32 con_out;
  75. u32 stderr_handle;
  76. u32 stderr;
  77. u32 runtime;
  78. u32 boottime;
  79. u32 nr_tables;
  80. u32 tables;
  81. } efi_system_table_32_t;
  82. /* kexec external ABI */
  83. struct efi_setup_data {
  84. u64 fw_vendor;
  85. u64 __unused;
  86. u64 tables;
  87. u64 smbios;
  88. u64 reserved[8];
  89. };
  90. static inline int efi_guidcmp (efi_guid_t left, efi_guid_t right)
  91. {
  92. return memcmp(&left, &right, sizeof (efi_guid_t));
  93. }
  94. #ifdef CONFIG_EFI
  95. bool __pure __efi_soft_reserve_enabled(void);
  96. static inline bool __pure efi_soft_reserve_enabled(void)
  97. {
  98. return IS_ENABLED(CONFIG_EFI_SOFT_RESERVE)
  99. && __efi_soft_reserve_enabled();
  100. }
  101. #else
  102. static inline bool efi_soft_reserve_enabled(void)
  103. {
  104. return false;
  105. }
  106. #endif /* CONFIG_EFI */
  107. #endif /* BOOT_COMPRESSED_EFI_H */