]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
a1b7065b | 3 | Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r |
f57387d5 | 4 | This program and the accompanying materials \r |
3eb9473e | 5 | are licensed and made available under the terms and conditions of the BSD License \r |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | EfiTypes.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | EFI defined types. Use these types when ever possible!\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #ifndef _EFI_TYPES_H_\r | |
23 | #define _EFI_TYPES_H_\r | |
24 | \r | |
25 | //\r | |
26 | // EFI Data Types based on ANSI C integer types in EfiBind.h\r | |
27 | //\r | |
28 | typedef uint8_t BOOLEAN;\r | |
29 | typedef intn_t INTN;\r | |
30 | typedef uintn_t UINTN;\r | |
31 | typedef int8_t INT8;\r | |
32 | typedef uint8_t UINT8;\r | |
33 | typedef int16_t INT16;\r | |
34 | typedef uint16_t UINT16;\r | |
35 | typedef int32_t INT32;\r | |
36 | typedef uint32_t UINT32;\r | |
37 | typedef int64_t INT64;\r | |
38 | typedef uint64_t UINT64;\r | |
ff8dd84a | 39 | typedef char CHAR8;\r |
3eb9473e | 40 | typedef uint16_t CHAR16;\r |
41 | typedef UINT64 EFI_LBA;\r | |
42 | \r | |
43 | //\r | |
44 | // Modifiers for EFI Data Types used to self document code.\r | |
45 | // Please see EFI coding convention for proper usage.\r | |
46 | //\r | |
47 | #ifndef IN\r | |
48 | //\r | |
49 | // Some other envirnments use this construct, so #ifndef to prevent\r | |
50 | // mulitple definition.\r | |
51 | //\r | |
52 | #define IN\r | |
53 | #define OUT\r | |
54 | #define OPTIONAL\r | |
55 | #endif\r | |
db13e3c0 | 56 | \r |
57 | #ifndef UNALIGNED\r | |
3eb9473e | 58 | #define UNALIGNED\r |
db13e3c0 | 59 | #endif\r |
3eb9473e | 60 | \r |
61 | //\r | |
62 | // Modifiers for EFI Runtime and Boot Services\r | |
63 | //\r | |
64 | #define EFI_RUNTIMESERVICE\r | |
65 | #define EFI_BOOTSERVICE\r | |
66 | \r | |
67 | //\r | |
68 | // Boot Service add in EFI 1.1\r | |
69 | //\r | |
70 | #define EFI_BOOTSERVICE11\r | |
71 | \r | |
72 | //\r | |
73 | // Modifiers to absract standard types to aid in debug of problems\r | |
74 | //\r | |
75 | #define CONST const\r | |
76 | #define STATIC static\r | |
77 | #define VOID void\r | |
78 | #define VOLATILE volatile\r | |
79 | \r | |
80 | //\r | |
81 | // Modifier to ensure that all protocol member functions and EFI intrinsics\r | |
82 | // use the correct C calling convention. All protocol member functions and\r | |
83 | // EFI intrinsics are required to modify thier member functions with EFIAPI.\r | |
84 | //\r | |
5a2bc714 | 85 | #ifndef EFIAPI\r |
86 | #define EFIAPI _EFIAPI\r | |
87 | #endif \r | |
3eb9473e | 88 | \r |
89 | //\r | |
90 | // EFI Constants. They may exist in other build structures, so #ifndef them.\r | |
91 | //\r | |
92 | #ifndef TRUE\r | |
3e99020d | 93 | #define TRUE ((BOOLEAN) (1 == 1))\r |
3eb9473e | 94 | #endif\r |
95 | \r | |
96 | #ifndef FALSE\r | |
3e99020d | 97 | #define FALSE ((BOOLEAN) (0 == 1))\r |
3eb9473e | 98 | #endif\r |
99 | \r | |
100 | #ifndef NULL\r | |
101 | #define NULL ((VOID *) 0)\r | |
102 | #endif\r | |
103 | //\r | |
104 | // EFI Data Types derived from other EFI data types.\r | |
105 | //\r | |
106 | typedef UINTN EFI_STATUS;\r | |
107 | \r | |
108 | typedef VOID *EFI_HANDLE;\r | |
109 | #define NULL_HANDLE ((VOID *) 0)\r | |
110 | \r | |
111 | typedef VOID *EFI_EVENT;\r | |
112 | typedef UINTN EFI_TPL;\r | |
113 | \r | |
114 | typedef struct {\r | |
115 | UINT32 Data1;\r | |
116 | UINT16 Data2;\r | |
117 | UINT16 Data3;\r | |
118 | UINT8 Data4[8];\r | |
119 | } EFI_GUID;\r | |
120 | \r | |
121 | typedef union {\r | |
122 | EFI_GUID Guid;\r | |
123 | UINT8 Raw[16];\r | |
124 | } EFI_GUID_UNION;\r | |
125 | \r | |
126 | //\r | |
127 | // EFI Time Abstraction:\r | |
128 | // Year: 2000 - 20XX\r | |
129 | // Month: 1 - 12\r | |
130 | // Day: 1 - 31\r | |
131 | // Hour: 0 - 23\r | |
132 | // Minute: 0 - 59\r | |
133 | // Second: 0 - 59\r | |
134 | // Nanosecond: 0 - 999,999,999\r | |
135 | // TimeZone: -1440 to 1440 or 2047\r | |
136 | //\r | |
137 | typedef struct {\r | |
138 | UINT16 Year;\r | |
139 | UINT8 Month;\r | |
140 | UINT8 Day;\r | |
141 | UINT8 Hour;\r | |
142 | UINT8 Minute;\r | |
143 | UINT8 Second;\r | |
144 | UINT8 Pad1;\r | |
145 | UINT32 Nanosecond;\r | |
146 | INT16 TimeZone;\r | |
147 | UINT8 Daylight;\r | |
148 | UINT8 Pad2;\r | |
149 | } EFI_TIME;\r | |
150 | \r | |
151 | //\r | |
152 | // Bit definitions for EFI_TIME.Daylight\r | |
153 | //\r | |
154 | #define EFI_TIME_ADJUST_DAYLIGHT 0x01\r | |
155 | #define EFI_TIME_IN_DAYLIGHT 0x02\r | |
156 | \r | |
157 | //\r | |
158 | // Value definition for EFI_TIME.TimeZone\r | |
159 | //\r | |
160 | #define EFI_UNSPECIFIED_TIMEZONE 0x07FF\r | |
161 | \r | |
162 | //\r | |
163 | // Networking\r | |
164 | //\r | |
165 | typedef struct {\r | |
166 | UINT8 Addr[4];\r | |
167 | } EFI_IPv4_ADDRESS;\r | |
168 | \r | |
169 | typedef struct {\r | |
170 | UINT8 Addr[16];\r | |
171 | } EFI_IPv6_ADDRESS;\r | |
172 | \r | |
173 | typedef struct {\r | |
174 | UINT8 Addr[32];\r | |
175 | } EFI_MAC_ADDRESS;\r | |
176 | \r | |
177 | typedef union {\r | |
178 | UINT32 Addr[4];\r | |
179 | EFI_IPv4_ADDRESS v4;\r | |
180 | EFI_IPv6_ADDRESS v6;\r | |
181 | } EFI_IP_ADDRESS;\r | |
182 | \r | |
183 | typedef enum {\r | |
184 | EfiReservedMemoryType,\r | |
185 | EfiLoaderCode,\r | |
186 | EfiLoaderData,\r | |
187 | EfiBootServicesCode,\r | |
188 | EfiBootServicesData,\r | |
189 | EfiRuntimeServicesCode,\r | |
190 | EfiRuntimeServicesData,\r | |
191 | EfiConventionalMemory,\r | |
192 | EfiUnusableMemory,\r | |
193 | EfiACPIReclaimMemory,\r | |
194 | EfiACPIMemoryNVS,\r | |
195 | EfiMemoryMappedIO,\r | |
196 | EfiMemoryMappedIOPortSpace,\r | |
197 | EfiPalCode,\r | |
a1b7065b | 198 | EfiPersistentMemory,\r |
3eb9473e | 199 | EfiMaxMemoryType\r |
200 | } EFI_MEMORY_TYPE;\r | |
201 | \r | |
202 | typedef enum {\r | |
203 | AllocateAnyPages,\r | |
204 | AllocateMaxAddress,\r | |
205 | AllocateAddress,\r | |
206 | MaxAllocateType\r | |
207 | } EFI_ALLOCATE_TYPE;\r | |
208 | \r | |
209 | typedef struct {\r | |
210 | UINT64 Signature;\r | |
211 | UINT32 Revision;\r | |
212 | UINT32 HeaderSize;\r | |
213 | UINT32 CRC32;\r | |
214 | UINT32 Reserved;\r | |
215 | } EFI_TABLE_HEADER;\r | |
216 | \r | |
217 | //\r | |
218 | // possible caching types for the memory range\r | |
219 | //\r | |
220 | #define EFI_MEMORY_UC 0x0000000000000001\r | |
221 | #define EFI_MEMORY_WC 0x0000000000000002\r | |
222 | #define EFI_MEMORY_WT 0x0000000000000004\r | |
223 | #define EFI_MEMORY_WB 0x0000000000000008\r | |
224 | #define EFI_MEMORY_UCE 0x0000000000000010\r | |
225 | \r | |
226 | //\r | |
227 | // physical memory protection on range\r | |
228 | //\r | |
229 | #define EFI_MEMORY_WP 0x0000000000001000\r | |
230 | #define EFI_MEMORY_RP 0x0000000000002000\r | |
231 | #define EFI_MEMORY_XP 0x0000000000004000\r | |
232 | \r | |
233 | //\r | |
234 | // range requires a runtime mapping\r | |
235 | //\r | |
36e90351 | 236 | #define EFI_MEMORY_RUNTIME 0x8000000000000000ULL\r |
3eb9473e | 237 | \r |
238 | typedef UINT64 EFI_PHYSICAL_ADDRESS;\r | |
239 | typedef UINT64 EFI_VIRTUAL_ADDRESS;\r | |
240 | \r | |
241 | #define EFI_MEMORY_DESCRIPTOR_VERSION 1\r | |
242 | typedef struct {\r | |
243 | UINT32 Type;\r | |
244 | UINT32 Pad;\r | |
245 | EFI_PHYSICAL_ADDRESS PhysicalStart;\r | |
246 | EFI_VIRTUAL_ADDRESS VirtualStart;\r | |
247 | UINT64 NumberOfPages;\r | |
248 | UINT64 Attribute;\r | |
249 | } EFI_MEMORY_DESCRIPTOR;\r | |
250 | \r | |
251 | //\r | |
252 | // The EFI memory allocation functions work in units of EFI_PAGEs that are\r | |
253 | // 4K. This should in no way be confused with the page size of the processor.\r | |
254 | // An EFI_PAGE is just the quanta of memory in EFI.\r | |
255 | //\r | |
256 | #define EFI_PAGE_SIZE 4096\r | |
257 | #define EFI_PAGE_MASK 0xFFF\r | |
258 | #define EFI_PAGE_SHIFT 12\r | |
259 | \r | |
260 | #define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))\r | |
261 | \r | |
262 | #define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)\r | |
263 | \r | |
264 | //\r | |
4fc0be87 | 265 | // ALIGN_POINTER - aligns a pointer to the lowest boundary\r |
3eb9473e | 266 | //\r |
267 | #define ALIGN_POINTER(p, s) ((VOID *) (p + ((s - ((UINTN) p)) & (s - 1))))\r | |
268 | \r | |
269 | //\r | |
4fc0be87 | 270 | // ALIGN_VARIABLE - aligns a variable up to the next natural boundary for int size of a processor\r |
3eb9473e | 271 | //\r |
272 | #define ALIGN_VARIABLE(Value, Adjustment) \\r | |
273 | (UINTN) Adjustment = 0; \\r | |
274 | if ((UINTN) Value % sizeof (UINTN)) { \\r | |
275 | (UINTN) Adjustment = sizeof (UINTN) - ((UINTN) Value % sizeof (UINTN)); \\r | |
276 | } \\r | |
277 | Value = (UINTN) Value + (UINTN) Adjustment\r | |
278 | \r | |
279 | //\r | |
280 | // EFI_FIELD_OFFSET - returns the byte offset to a field within a structure\r | |
281 | //\r | |
282 | #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))\r | |
283 | \r | |
284 | //\r | |
285 | // CONTAINING_RECORD - returns a pointer to the structure\r | |
286 | // from one of it's elements.\r | |
287 | //\r | |
288 | #define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r | |
289 | \r | |
290 | //\r | |
291 | // Define macros to build data structure signatures from characters.\r | |
292 | //\r | |
293 | #define EFI_SIGNATURE_16(A, B) ((A) | (B << 8))\r | |
294 | #define EFI_SIGNATURE_32(A, B, C, D) (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))\r | |
295 | #define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \\r | |
296 | (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))\r | |
297 | \r | |
298 | #endif\r |