]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h
Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Efi / Include / EfiTypes.h
CommitLineData
3eb9473e 1/*++\r
2\r
3e99020d 3Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>\r
f57387d5 4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 EfiTypes.h\r
15\r
16Abstract:\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
28typedef uint8_t BOOLEAN;\r
29typedef intn_t INTN;\r
30typedef uintn_t UINTN;\r
31typedef int8_t INT8;\r
32typedef uint8_t UINT8;\r
33typedef int16_t INT16;\r
34typedef uint16_t UINT16;\r
35typedef int32_t INT32;\r
36typedef uint32_t UINT32;\r
37typedef int64_t INT64;\r
38typedef uint64_t UINT64;\r
ff8dd84a 39typedef char CHAR8;\r
3eb9473e 40typedef uint16_t CHAR16;\r
41typedef 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
106typedef UINTN EFI_STATUS;\r
107\r
108typedef VOID *EFI_HANDLE;\r
109#define NULL_HANDLE ((VOID *) 0)\r
110\r
111typedef VOID *EFI_EVENT;\r
112typedef UINTN EFI_TPL;\r
113\r
114typedef 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
121typedef 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
137typedef 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
165typedef struct {\r
166 UINT8 Addr[4];\r
167} EFI_IPv4_ADDRESS;\r
168\r
169typedef struct {\r
170 UINT8 Addr[16];\r
171} EFI_IPv6_ADDRESS;\r
172\r
173typedef struct {\r
174 UINT8 Addr[32];\r
175} EFI_MAC_ADDRESS;\r
176\r
177typedef 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
183typedef 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
198 EfiMaxMemoryType\r
199} EFI_MEMORY_TYPE;\r
200\r
201typedef enum {\r
202 AllocateAnyPages,\r
203 AllocateMaxAddress,\r
204 AllocateAddress,\r
205 MaxAllocateType\r
206} EFI_ALLOCATE_TYPE;\r
207\r
208typedef struct {\r
209 UINT64 Signature;\r
210 UINT32 Revision;\r
211 UINT32 HeaderSize;\r
212 UINT32 CRC32;\r
213 UINT32 Reserved;\r
214} EFI_TABLE_HEADER;\r
215\r
216//\r
217// possible caching types for the memory range\r
218//\r
219#define EFI_MEMORY_UC 0x0000000000000001\r
220#define EFI_MEMORY_WC 0x0000000000000002\r
221#define EFI_MEMORY_WT 0x0000000000000004\r
222#define EFI_MEMORY_WB 0x0000000000000008\r
223#define EFI_MEMORY_UCE 0x0000000000000010\r
224\r
225//\r
226// physical memory protection on range\r
227//\r
228#define EFI_MEMORY_WP 0x0000000000001000\r
229#define EFI_MEMORY_RP 0x0000000000002000\r
230#define EFI_MEMORY_XP 0x0000000000004000\r
231\r
232//\r
233// range requires a runtime mapping\r
234//\r
36e90351 235#define EFI_MEMORY_RUNTIME 0x8000000000000000ULL\r
3eb9473e 236\r
237typedef UINT64 EFI_PHYSICAL_ADDRESS;\r
238typedef UINT64 EFI_VIRTUAL_ADDRESS;\r
239\r
240#define EFI_MEMORY_DESCRIPTOR_VERSION 1\r
241typedef struct {\r
242 UINT32 Type;\r
243 UINT32 Pad;\r
244 EFI_PHYSICAL_ADDRESS PhysicalStart;\r
245 EFI_VIRTUAL_ADDRESS VirtualStart;\r
246 UINT64 NumberOfPages;\r
247 UINT64 Attribute;\r
248} EFI_MEMORY_DESCRIPTOR;\r
249\r
250//\r
251// The EFI memory allocation functions work in units of EFI_PAGEs that are\r
252// 4K. This should in no way be confused with the page size of the processor.\r
253// An EFI_PAGE is just the quanta of memory in EFI.\r
254//\r
255#define EFI_PAGE_SIZE 4096\r
256#define EFI_PAGE_MASK 0xFFF\r
257#define EFI_PAGE_SHIFT 12\r
258\r
259#define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))\r
260\r
261#define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)\r
262\r
263//\r
264// ALIGN_POINTER - aligns a pointer to the lowest boundry\r
265//\r
266#define ALIGN_POINTER(p, s) ((VOID *) (p + ((s - ((UINTN) p)) & (s - 1))))\r
267\r
268//\r
269// ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor\r
270//\r
271#define ALIGN_VARIABLE(Value, Adjustment) \\r
272 (UINTN) Adjustment = 0; \\r
273 if ((UINTN) Value % sizeof (UINTN)) { \\r
274 (UINTN) Adjustment = sizeof (UINTN) - ((UINTN) Value % sizeof (UINTN)); \\r
275 } \\r
276 Value = (UINTN) Value + (UINTN) Adjustment\r
277\r
278//\r
279// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure\r
280//\r
281#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))\r
282\r
283//\r
284// CONTAINING_RECORD - returns a pointer to the structure\r
285// from one of it's elements.\r
286//\r
287#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r
288\r
289//\r
290// Define macros to build data structure signatures from characters.\r
291//\r
292#define EFI_SIGNATURE_16(A, B) ((A) | (B << 8))\r
293#define EFI_SIGNATURE_32(A, B, C, D) (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))\r
294#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
295 (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))\r
296\r
297#endif\r