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