efidef.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. #ifndef _EFI_DEF_H
  2. #define _EFI_DEF_H
  3. #include <efibind.h>
  4. /*++
  5. Copyright (c) 1998 Intel Corporation
  6. Module Name:
  7. efidef.h
  8. Abstract:
  9. EFI definitions
  10. Revision History
  11. --*/
  12. #if !defined(__cplusplus)
  13. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  14. typedef _Bool BOOLEAN;
  15. #else
  16. typedef unsigned char BOOLEAN;
  17. #endif
  18. #else
  19. typedef bool BOOLEAN;
  20. #endif
  21. #ifndef CONST
  22. #define CONST const
  23. #endif
  24. #ifndef TRUE
  25. #if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
  26. #define TRUE true
  27. #define FALSE false
  28. #else
  29. #define TRUE ((BOOLEAN) 1)
  30. #define FALSE ((BOOLEAN) 0)
  31. #endif
  32. #endif
  33. #ifndef NULL
  34. #if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
  35. #define NULL nullptr
  36. #else
  37. #if !defined(__cplusplus)
  38. #define NULL ((VOID *) 0)
  39. #else
  40. #define NULL 0
  41. #endif
  42. #endif
  43. #endif
  44. typedef UINTN EFI_STATUS;
  45. typedef UINT64 EFI_LBA;
  46. typedef UINTN EFI_TPL;
  47. typedef VOID *EFI_HANDLE;
  48. typedef VOID *EFI_EVENT;
  49. //
  50. // Prototype argument decoration for EFI parameters to indicate
  51. // their direction
  52. //
  53. // IN - argument is passed into the function
  54. // OUT - argument (pointer) is returned from the function
  55. // OPTIONAL - argument is optional
  56. //
  57. #ifndef IN
  58. #define IN
  59. #define OUT
  60. #define OPTIONAL
  61. #endif
  62. //
  63. // A GUID
  64. //
  65. typedef struct {
  66. UINT32 Data1;
  67. UINT16 Data2;
  68. UINT16 Data3;
  69. UINT8 Data4[8];
  70. } EFI_GUID;
  71. //
  72. // Time
  73. //
  74. typedef struct {
  75. UINT16 Year; // 1998 - 20XX
  76. UINT8 Month; // 1 - 12
  77. UINT8 Day; // 1 - 31
  78. UINT8 Hour; // 0 - 23
  79. UINT8 Minute; // 0 - 59
  80. UINT8 Second; // 0 - 59
  81. UINT8 Pad1;
  82. UINT32 Nanosecond; // 0 - 999,999,999
  83. INT16 TimeZone; // -1440 to 1440 or 2047
  84. UINT8 Daylight;
  85. UINT8 Pad2;
  86. } EFI_TIME;
  87. // Bit definitions for EFI_TIME.Daylight
  88. #define EFI_TIME_ADJUST_DAYLIGHT 0x01
  89. #define EFI_TIME_IN_DAYLIGHT 0x02
  90. // Value definition for EFI_TIME.TimeZone
  91. #define EFI_UNSPECIFIED_TIMEZONE 0x07FF
  92. //
  93. // Networking
  94. //
  95. typedef struct {
  96. UINT8 Addr[4];
  97. } EFI_IPv4_ADDRESS;
  98. typedef struct {
  99. UINT8 Addr[16];
  100. } EFI_IPv6_ADDRESS;
  101. typedef struct {
  102. UINT8 Addr[32];
  103. } EFI_MAC_ADDRESS;
  104. typedef struct {
  105. UINT32 ReceivedQueueTimeoutValue;
  106. UINT32 TransmitQueueTimeoutValue;
  107. UINT16 ProtocolTypeFilter;
  108. BOOLEAN EnableUnicastReceive;
  109. BOOLEAN EnableMulticastReceive;
  110. BOOLEAN EnableBroadcastReceive;
  111. BOOLEAN EnablePromiscuousReceive;
  112. BOOLEAN FlushQueuesOnReset;
  113. BOOLEAN EnableReceiveTimestamps;
  114. BOOLEAN DisableBackgroundPolling;
  115. } EFI_MANAGED_NETWORK_CONFIG_DATA;
  116. //
  117. // Memory
  118. //
  119. typedef UINT64 EFI_PHYSICAL_ADDRESS;
  120. typedef UINT64 EFI_VIRTUAL_ADDRESS;
  121. typedef enum {
  122. AllocateAnyPages,
  123. AllocateMaxAddress,
  124. AllocateAddress,
  125. MaxAllocateType
  126. } EFI_ALLOCATE_TYPE;
  127. //Preseve the attr on any range supplied.
  128. //ConventialMemory must have WB,SR,SW when supplied.
  129. //When allocating from ConventialMemory always make it WB,SR,SW
  130. //When returning to ConventialMemory always make it WB,SR,SW
  131. //When getting the memory map, or on RT for runtime types
  132. typedef enum {
  133. EfiReservedMemoryType,
  134. EfiLoaderCode,
  135. EfiLoaderData,
  136. EfiBootServicesCode,
  137. EfiBootServicesData,
  138. EfiRuntimeServicesCode,
  139. EfiRuntimeServicesData,
  140. EfiConventionalMemory,
  141. EfiUnusableMemory,
  142. EfiACPIReclaimMemory,
  143. EfiACPIMemoryNVS,
  144. EfiMemoryMappedIO,
  145. EfiMemoryMappedIOPortSpace,
  146. EfiPalCode,
  147. EfiPersistentMemory,
  148. EfiUnacceptedMemoryType,
  149. EfiMaxMemoryType
  150. } EFI_MEMORY_TYPE;
  151. // Memory cacheability attribute
  152. #define EFI_MEMORY_UC 0x0000000000000001
  153. #define EFI_MEMORY_WC 0x0000000000000002
  154. #define EFI_MEMORY_WT 0x0000000000000004
  155. #define EFI_MEMORY_WB 0x0000000000000008
  156. #define EFI_MEMORY_UCE 0x0000000000000010
  157. // Physical memory protection attribute
  158. #define EFI_MEMORY_WP 0x0000000000001000
  159. #define EFI_MEMORY_RP 0x0000000000002000
  160. #define EFI_MEMORY_XP 0x0000000000004000
  161. #define EFI_MEMORY_RO 0x0000000000020000
  162. // Runtime memory attribute
  163. #define EFI_MEMORY_NV 0x0000000000008000
  164. #define EFI_MEMORY_RUNTIME 0x8000000000000000
  165. // Other memory attribute
  166. #define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000
  167. #define EFI_MEMORY_SP 0x0000000000040000
  168. #define EFI_MEMORY_CPU_CRYPTO 0x0000000000080000
  169. #define EFI_MEMORY_ISA_VALID 0x4000000000000000
  170. #define EFI_MEMORY_ISA_MASK 0x0FFFF00000000000
  171. #define EFI_MEMORY_DESCRIPTOR_VERSION 1
  172. typedef struct {
  173. UINT32 Type; // Field size is 32 bits followed by 32 bit pad
  174. UINT32 Pad;
  175. EFI_PHYSICAL_ADDRESS PhysicalStart; // Field size is 64 bits
  176. EFI_VIRTUAL_ADDRESS VirtualStart; // Field size is 64 bits
  177. UINT64 NumberOfPages; // Field size is 64 bits
  178. UINT64 Attribute; // Field size is 64 bits
  179. } EFI_MEMORY_DESCRIPTOR;
  180. //
  181. // International Language
  182. //
  183. typedef CHAR8 ISO_639_2;
  184. #define ISO_639_2_ENTRY_SIZE 3
  185. //
  186. //
  187. //
  188. #define EFI_PAGE_SIZE 4096
  189. #define EFI_PAGE_MASK 0xFFF
  190. #define EFI_PAGE_SHIFT 12
  191. #define EFI_SIZE_TO_PAGES(a) \
  192. ( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) )
  193. #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001
  194. #define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002
  195. #define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED \
  196. 0x0000000000000004
  197. #define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED \
  198. 0x0000000000000008
  199. #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED \
  200. 0x0000000000000010
  201. #define EFI_OS_INDICATIONS_START_OS_RECOVERY 0x0000000000000020
  202. #define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY \
  203. 0x0000000000000040
  204. #define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH \
  205. 0x0000000000000080
  206. #endif