xref: /DragonStub/inc/efidef.h (revision f412fd2a1a248b546b7085648dece8d908077fab)
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 //
95 // Time
96 //
97 
98 typedef struct {
99     UINT16      Year;       // 1998 - 20XX
100     UINT8       Month;      // 1 - 12
101     UINT8       Day;        // 1 - 31
102     UINT8       Hour;       // 0 - 23
103     UINT8       Minute;     // 0 - 59
104     UINT8       Second;     // 0 - 59
105     UINT8       Pad1;
106     UINT32      Nanosecond; // 0 - 999,999,999
107     INT16       TimeZone;   // -1440 to 1440 or 2047
108     UINT8       Daylight;
109     UINT8       Pad2;
110 } EFI_TIME;
111 
112 // Bit definitions for EFI_TIME.Daylight
113 #define EFI_TIME_ADJUST_DAYLIGHT    0x01
114 #define EFI_TIME_IN_DAYLIGHT        0x02
115 
116 // Value definition for EFI_TIME.TimeZone
117 #define EFI_UNSPECIFIED_TIMEZONE    0x07FF
118 
119 
120 
121 //
122 // Networking
123 //
124 
125 typedef struct {
126     UINT8                   Addr[4];
127 } EFI_IPv4_ADDRESS;
128 
129 typedef struct {
130     UINT8                   Addr[16];
131 } EFI_IPv6_ADDRESS;
132 
133 typedef struct {
134     UINT8                   Addr[32];
135 } EFI_MAC_ADDRESS;
136 
137 typedef struct {
138     UINT32 ReceivedQueueTimeoutValue;
139     UINT32 TransmitQueueTimeoutValue;
140     UINT16 ProtocolTypeFilter;
141     BOOLEAN EnableUnicastReceive;
142     BOOLEAN EnableMulticastReceive;
143     BOOLEAN EnableBroadcastReceive;
144     BOOLEAN EnablePromiscuousReceive;
145     BOOLEAN FlushQueuesOnReset;
146     BOOLEAN EnableReceiveTimestamps;
147     BOOLEAN DisableBackgroundPolling;
148 } EFI_MANAGED_NETWORK_CONFIG_DATA;
149 
150 //
151 // Memory
152 //
153 
154 typedef UINT64          EFI_PHYSICAL_ADDRESS;
155 typedef UINT64          EFI_VIRTUAL_ADDRESS;
156 
157 typedef enum {
158     AllocateAnyPages,
159     AllocateMaxAddress,
160     AllocateAddress,
161     MaxAllocateType
162 } EFI_ALLOCATE_TYPE;
163 
164 //Preseve the attr on any range supplied.
165 //ConventialMemory must have WB,SR,SW when supplied.
166 //When allocating from ConventialMemory always make it WB,SR,SW
167 //When returning to ConventialMemory always make it WB,SR,SW
168 //When getting the memory map, or on RT for runtime types
169 
170 
171 typedef enum {
172     EfiReservedMemoryType,
173     EfiLoaderCode,
174     EfiLoaderData,
175     EfiBootServicesCode,
176     EfiBootServicesData,
177     EfiRuntimeServicesCode,
178     EfiRuntimeServicesData,
179     EfiConventionalMemory,
180     EfiUnusableMemory,
181     EfiACPIReclaimMemory,
182     EfiACPIMemoryNVS,
183     EfiMemoryMappedIO,
184     EfiMemoryMappedIOPortSpace,
185     EfiPalCode,
186     EfiPersistentMemory,
187     EfiUnacceptedMemoryType,
188     EfiMaxMemoryType
189 } EFI_MEMORY_TYPE;
190 
191 
192 // Memory cacheability attribute
193 #define EFI_MEMORY_UC            0x0000000000000001
194 #define EFI_MEMORY_WC            0x0000000000000002
195 #define EFI_MEMORY_WT            0x0000000000000004
196 #define EFI_MEMORY_WB            0x0000000000000008
197 #define EFI_MEMORY_UCE           0x0000000000000010
198 
199 // Physical memory protection attribute
200 #define EFI_MEMORY_WP            0x0000000000001000
201 #define EFI_MEMORY_RP            0x0000000000002000
202 #define EFI_MEMORY_XP            0x0000000000004000
203 #define EFI_MEMORY_RO            0x0000000000020000
204 
205 // Runtime memory attribute
206 #define EFI_MEMORY_NV            0x0000000000008000
207 #define EFI_MEMORY_RUNTIME       0x8000000000000000
208 
209 // Other memory attribute
210 #define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000
211 #define EFI_MEMORY_SP            0x0000000000040000
212 #define EFI_MEMORY_CPU_CRYPTO    0x0000000000080000
213 #define EFI_MEMORY_ISA_VALID     0x4000000000000000
214 #define EFI_MEMORY_ISA_MASK      0x0FFFF00000000000
215 
216 
217 #define EFI_MEMORY_DESCRIPTOR_VERSION  1
218 typedef struct {
219     UINT32                          Type;           // Field size is 32 bits followed by 32 bit pad
220     UINT32                          Pad;
221     EFI_PHYSICAL_ADDRESS            PhysicalStart;  // Field size is 64 bits
222     EFI_VIRTUAL_ADDRESS             VirtualStart;   // Field size is 64 bits
223     UINT64                          NumberOfPages;  // Field size is 64 bits
224     UINT64                          Attribute;      // Field size is 64 bits
225 } EFI_MEMORY_DESCRIPTOR;
226 
227 //
228 // International Language
229 //
230 
231 typedef CHAR8 ISO_639_2;
232 #define ISO_639_2_ENTRY_SIZE    3
233 
234 //
235 //
236 //
237 
238 #define EFI_PAGE_SIZE   4096
239 #define EFI_PAGE_MASK   0xFFF
240 #define EFI_PAGE_SHIFT  12
241 
242 #define EFI_SIZE_TO_PAGES(a)  \
243     ( ((a) >> EFI_PAGE_SHIFT) + ((a) & EFI_PAGE_MASK ? 1 : 0) )
244 
245 #define EFI_OS_INDICATIONS_BOOT_TO_FW_UI        0x0000000000000001
246 #define EFI_OS_INDICATIONS_TIMESTAMP_REVOCATION 0x0000000000000002
247 #define EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED \
248                                                 0x0000000000000004
249 #define EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED \
250                                                 0x0000000000000008
251 #define EFI_OS_INDICATIONS_CAPSULE_RESULT_VAR_SUPPORTED \
252                                                 0x0000000000000010
253 #define EFI_OS_INDICATIONS_START_OS_RECOVERY    0x0000000000000020
254 #define EFI_OS_INDICATIONS_START_PLATFORM_RECOVERY \
255                                                 0x0000000000000040
256 #define EFI_OS_INDICATIONS_JSON_CONFIG_DATA_REFRESH \
257                                                 0x0000000000000080
258 
259 #endif
260