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