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