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