efidef.h 5.6 KB

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