efidef.h 5.4 KB

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