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