]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h
edk2/EdkCompatibilityPkg/Foundation/Efi/Include/EfiTypes.h:
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Efi / Include / EfiTypes.h
CommitLineData
3eb9473e 1/*++\r
2\r
3Copyright (c) 2004, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
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
85#define EFIAPI _EFIAPI\r
86\r
87//\r
88// EFI Constants. They may exist in other build structures, so #ifndef them.\r
89//\r
90#ifndef TRUE\r
91#define TRUE ((BOOLEAN) 1 == 1)\r
92#endif\r
93\r
94#ifndef FALSE\r
95#define FALSE ((BOOLEAN) 0 == 1)\r
96#endif\r
97\r
98#ifndef NULL\r
99#define NULL ((VOID *) 0)\r
100#endif\r
101//\r
102// EFI Data Types derived from other EFI data types.\r
103//\r
104typedef UINTN EFI_STATUS;\r
105\r
106typedef VOID *EFI_HANDLE;\r
107#define NULL_HANDLE ((VOID *) 0)\r
108\r
109typedef VOID *EFI_EVENT;\r
110typedef UINTN EFI_TPL;\r
111\r
112typedef struct {\r
113 UINT32 Data1;\r
114 UINT16 Data2;\r
115 UINT16 Data3;\r
116 UINT8 Data4[8];\r
117} EFI_GUID;\r
118\r
119typedef union {\r
120 EFI_GUID Guid;\r
121 UINT8 Raw[16];\r
122} EFI_GUID_UNION;\r
123\r
124//\r
125// EFI Time Abstraction:\r
126// Year: 2000 - 20XX\r
127// Month: 1 - 12\r
128// Day: 1 - 31\r
129// Hour: 0 - 23\r
130// Minute: 0 - 59\r
131// Second: 0 - 59\r
132// Nanosecond: 0 - 999,999,999\r
133// TimeZone: -1440 to 1440 or 2047\r
134//\r
135typedef struct {\r
136 UINT16 Year;\r
137 UINT8 Month;\r
138 UINT8 Day;\r
139 UINT8 Hour;\r
140 UINT8 Minute;\r
141 UINT8 Second;\r
142 UINT8 Pad1;\r
143 UINT32 Nanosecond;\r
144 INT16 TimeZone;\r
145 UINT8 Daylight;\r
146 UINT8 Pad2;\r
147} EFI_TIME;\r
148\r
149//\r
150// Bit definitions for EFI_TIME.Daylight\r
151//\r
152#define EFI_TIME_ADJUST_DAYLIGHT 0x01\r
153#define EFI_TIME_IN_DAYLIGHT 0x02\r
154\r
155//\r
156// Value definition for EFI_TIME.TimeZone\r
157//\r
158#define EFI_UNSPECIFIED_TIMEZONE 0x07FF\r
159\r
160//\r
161// Networking\r
162//\r
163typedef struct {\r
164 UINT8 Addr[4];\r
165} EFI_IPv4_ADDRESS;\r
166\r
167typedef struct {\r
168 UINT8 Addr[16];\r
169} EFI_IPv6_ADDRESS;\r
170\r
171typedef struct {\r
172 UINT8 Addr[32];\r
173} EFI_MAC_ADDRESS;\r
174\r
175typedef union {\r
176 UINT32 Addr[4];\r
177 EFI_IPv4_ADDRESS v4;\r
178 EFI_IPv6_ADDRESS v6;\r
179} EFI_IP_ADDRESS;\r
180\r
181typedef enum {\r
182 EfiReservedMemoryType,\r
183 EfiLoaderCode,\r
184 EfiLoaderData,\r
185 EfiBootServicesCode,\r
186 EfiBootServicesData,\r
187 EfiRuntimeServicesCode,\r
188 EfiRuntimeServicesData,\r
189 EfiConventionalMemory,\r
190 EfiUnusableMemory,\r
191 EfiACPIReclaimMemory,\r
192 EfiACPIMemoryNVS,\r
193 EfiMemoryMappedIO,\r
194 EfiMemoryMappedIOPortSpace,\r
195 EfiPalCode,\r
196 EfiMaxMemoryType\r
197} EFI_MEMORY_TYPE;\r
198\r
199typedef enum {\r
200 AllocateAnyPages,\r
201 AllocateMaxAddress,\r
202 AllocateAddress,\r
203 MaxAllocateType\r
204} EFI_ALLOCATE_TYPE;\r
205\r
206typedef struct {\r
207 UINT64 Signature;\r
208 UINT32 Revision;\r
209 UINT32 HeaderSize;\r
210 UINT32 CRC32;\r
211 UINT32 Reserved;\r
212} EFI_TABLE_HEADER;\r
213\r
214//\r
215// possible caching types for the memory range\r
216//\r
217#define EFI_MEMORY_UC 0x0000000000000001\r
218#define EFI_MEMORY_WC 0x0000000000000002\r
219#define EFI_MEMORY_WT 0x0000000000000004\r
220#define EFI_MEMORY_WB 0x0000000000000008\r
221#define EFI_MEMORY_UCE 0x0000000000000010\r
222\r
223//\r
224// physical memory protection on range\r
225//\r
226#define EFI_MEMORY_WP 0x0000000000001000\r
227#define EFI_MEMORY_RP 0x0000000000002000\r
228#define EFI_MEMORY_XP 0x0000000000004000\r
229\r
230//\r
231// range requires a runtime mapping\r
232//\r
233#define EFI_MEMORY_RUNTIME 0x8000000000000000\r
234\r
235typedef UINT64 EFI_PHYSICAL_ADDRESS;\r
236typedef UINT64 EFI_VIRTUAL_ADDRESS;\r
237\r
238#define EFI_MEMORY_DESCRIPTOR_VERSION 1\r
239typedef struct {\r
240 UINT32 Type;\r
241 UINT32 Pad;\r
242 EFI_PHYSICAL_ADDRESS PhysicalStart;\r
243 EFI_VIRTUAL_ADDRESS VirtualStart;\r
244 UINT64 NumberOfPages;\r
245 UINT64 Attribute;\r
246} EFI_MEMORY_DESCRIPTOR;\r
247\r
248//\r
249// The EFI memory allocation functions work in units of EFI_PAGEs that are\r
250// 4K. This should in no way be confused with the page size of the processor.\r
251// An EFI_PAGE is just the quanta of memory in EFI.\r
252//\r
253#define EFI_PAGE_SIZE 4096\r
254#define EFI_PAGE_MASK 0xFFF\r
255#define EFI_PAGE_SHIFT 12\r
256\r
257#define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))\r
258\r
259#define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)\r
260\r
261//\r
262// ALIGN_POINTER - aligns a pointer to the lowest boundry\r
263//\r
264#define ALIGN_POINTER(p, s) ((VOID *) (p + ((s - ((UINTN) p)) & (s - 1))))\r
265\r
266//\r
267// ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor\r
268//\r
269#define ALIGN_VARIABLE(Value, Adjustment) \\r
270 (UINTN) Adjustment = 0; \\r
271 if ((UINTN) Value % sizeof (UINTN)) { \\r
272 (UINTN) Adjustment = sizeof (UINTN) - ((UINTN) Value % sizeof (UINTN)); \\r
273 } \\r
274 Value = (UINTN) Value + (UINTN) Adjustment\r
275\r
276//\r
277// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure\r
278//\r
279#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))\r
280\r
281//\r
282// CONTAINING_RECORD - returns a pointer to the structure\r
283// from one of it's elements.\r
284//\r
285#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))\r
286\r
287//\r
288// Define macros to build data structure signatures from characters.\r
289//\r
290#define EFI_SIGNATURE_16(A, B) ((A) | (B << 8))\r
291#define EFI_SIGNATURE_32(A, B, C, D) (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))\r
292#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
293 (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))\r
294\r
295#endif\r