efidef.h 5.3 KB

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