1 #ifndef _EFI_DEF_H 2 #define _EFI_DEF_H 3 4 /*++ 5 6 Copyright (c) 1998 Intel Corporation 7 8 Module Name: 9 10 efidef.h 11 12 Abstract: 13 14 EFI definitions 15 16 17 18 19 Revision History 20 21 --*/ 22 23 #if !defined(__cplusplus) 24 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 25 typedef _Bool BOOLEAN; 26 #else 27 typedef unsigned char BOOLEAN; 28 #endif 29 #else 30 typedef bool BOOLEAN; 31 #endif 32 33 #ifndef CONST 34 #define CONST const 35 #endif 36 #ifndef TRUE 37 #if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) 38 #define TRUE true 39 #define FALSE false 40 #else 41 #define TRUE ((BOOLEAN) 1) 42 #define FALSE ((BOOLEAN) 0) 43 #endif 44 #endif 45 46 #ifndef NULL 47 #if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) 48 #define NULL nullptr 49 #else 50 #if !defined(__cplusplus) 51 #define NULL ((VOID *) 0) 52 #else 53 #define NULL 0 54 #endif 55 #endif 56 #endif 57 58 typedef UINTN EFI_STATUS; 59 typedef UINT64 EFI_LBA; 60 typedef UINTN EFI_TPL; 61 typedef VOID *EFI_HANDLE; 62 typedef VOID *EFI_EVENT; 63 64 65 // 66 // Prototype argument decoration for EFI parameters to indicate 67 // their direction 68 // 69 // IN - argument is passed into the function 70 // OUT - argument (pointer) is returned from the function 71 // OPTIONAL - argument is optional 72 // 73 74 #ifndef IN 75 #define IN 76 #define OUT 77 #define OPTIONAL 78 #endif 79 80 81 // 82 // A GUID 83 // 84 85 typedef struct { 86 UINT32 Data1; 87 UINT16 Data2; 88 UINT16 Data3; 89 UINT8 Data4[8]; 90 } EFI_GUID; 91 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 EfiMaxMemoryType 186 } EFI_MEMORY_TYPE; 187 188 // possible caching types for the memory range 189 #define EFI_MEMORY_UC 0x0000000000000001 190 #define EFI_MEMORY_WC 0x0000000000000002 191 #define EFI_MEMORY_WT 0x0000000000000004 192 #define EFI_MEMORY_WB 0x0000000000000008 193 #define EFI_MEMORY_UCE 0x0000000000000010 194 195 // physical memory protection on range 196 #define EFI_MEMORY_WP 0x0000000000001000 197 #define EFI_MEMORY_RP 0x0000000000002000 198 #define EFI_MEMORY_XP 0x0000000000004000 199 200 // range requires a runtime mapping 201 #define EFI_MEMORY_RUNTIME 0x8000000000000000 202 203 #define EFI_MEMORY_DESCRIPTOR_VERSION 1 204 typedef struct { 205 UINT32 Type; // Field size is 32 bits followed by 32 bit pad 206 UINT32 Pad; 207 EFI_PHYSICAL_ADDRESS PhysicalStart; // Field size is 64 bits 208 EFI_VIRTUAL_ADDRESS VirtualStart; // Field size is 64 bits 209 UINT64 NumberOfPages; // Field size is 64 bits 210 UINT64 Attribute; // Field size is 64 bits 211 } EFI_MEMORY_DESCRIPTOR; 212 213 // 214 // International Language 215 // 216 217 typedef CHAR8 ISO_639_2; 218 #define ISO_639_2_ENTRY_SIZE 3 219 220 // 221 // 222 // 223 224 #define EFI_PAGE_SIZE 4096 225 #define EFI_PAGE_MASK 0xFFF 226 #define EFI_PAGE_SHIFT 12 227 228 #define EFI_SIZE_TO_PAGES(a) \ 229 ( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) ) 230 231 #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI 0x0000000000000001 232 #define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002 233 #define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED \ 234 0x0000000000000004 235 #define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED \ 236 0x0000000000000008 237 #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED \ 238 0x0000000000000010 239 240 #endif 241