Sync EDKII BaseTools to BaseTools project r1928
[mirror_edk2.git] / MdePkg / Include / Uefi / UefiBaseType.h
CommitLineData
c311f86b 1/** @file\r
959ccb23 2 Defines data types and constants introduced in UEFI.\r
3\r
e189264e 4 Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
8992ce06 5 Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>\r
c311f86b 6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10 \r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
959ccb23 13\r
14**/\r
15\r
16#ifndef __UEFI_BASETYPE_H__\r
17#define __UEFI_BASETYPE_H__\r
18\r
a0f1b047 19#include <Base.h>\r
959ccb23 20\r
e0c047a0 21//\r
eaad1319 22// Basic data type definitions introduced in UEFI.\r
e0c047a0 23//\r
24\r
25///\r
26/// 128-bit buffer containing a unique identifier value.\r
8b13229b 27///\r
00edb218 28typedef GUID EFI_GUID;\r
3f748e52 29///\r
30/// Function return status for EFI API\r
31///\r
00edb218 32typedef RETURN_STATUS EFI_STATUS;\r
e0c047a0 33///\r
34/// A collection of related interfaces.\r
35///\r
00edb218 36typedef VOID *EFI_HANDLE;\r
e0c047a0 37///\r
38/// Handle to an event structure.\r
39///\r
00edb218 40typedef VOID *EFI_EVENT;\r
e0c047a0 41///\r
42/// Task priority level.\r
43///\r
00edb218 44typedef UINTN EFI_TPL;\r
e0c047a0 45///\r
46/// Logical block address.\r
47///\r
00edb218 48typedef UINT64 EFI_LBA;\r
6617fcc2 49\r
50///\r
51/// 64-bit physical memory address.\r
52///\r
00edb218 53typedef UINT64 EFI_PHYSICAL_ADDRESS;\r
6617fcc2 54\r
55///\r
56/// 64-bit virtual memory address.\r
57///\r
00edb218 58typedef UINT64 EFI_VIRTUAL_ADDRESS;\r
959ccb23 59\r
fb5148a0 60///\r
61/// EFI Time Abstraction:\r
e189264e 62/// Year: 1900 - 9999\r
fb5148a0 63/// Month: 1 - 12\r
64/// Day: 1 - 31\r
65/// Hour: 0 - 23\r
66/// Minute: 0 - 59\r
67/// Second: 0 - 59\r
68/// Nanosecond: 0 - 999,999,999\r
69/// TimeZone: -1440 to 1440 or 2047\r
70///\r
959ccb23 71typedef struct {\r
72 UINT16 Year;\r
73 UINT8 Month;\r
74 UINT8 Day;\r
75 UINT8 Hour;\r
76 UINT8 Minute;\r
77 UINT8 Second;\r
78 UINT8 Pad1;\r
79 UINT32 Nanosecond;\r
80 INT16 TimeZone;\r
81 UINT8 Daylight;\r
82 UINT8 Pad2;\r
83} EFI_TIME;\r
84\r
d1f95000 85\r
e0c047a0 86///\r
87/// 4-byte buffer. An IPv4 internet protocol address.\r
88///\r
d1f95000 89typedef struct {\r
90 UINT8 Addr[4];\r
91} EFI_IPv4_ADDRESS;\r
92\r
e0c047a0 93///\r
94/// 16-byte buffer. An IPv6 internet protocol address\r
95///\r
d1f95000 96typedef struct {\r
97 UINT8 Addr[16];\r
98} EFI_IPv6_ADDRESS;\r
99\r
e0c047a0 100///\r
101/// 32-byte buffer containing a network Media Access Control address.\r
102///\r
d1f95000 103typedef struct {\r
104 UINT8 Addr[32];\r
105} EFI_MAC_ADDRESS;\r
106\r
e0c047a0 107///\r
108/// 16-byte buffer aligned on a 4-byte boundary.\r
109/// An IPv4 or IPv6 internet protocol address.\r
110///\r
d1f95000 111typedef union {\r
112 UINT32 Addr[4];\r
113 EFI_IPv4_ADDRESS v4;\r
114 EFI_IPv6_ADDRESS v6;\r
115} EFI_IP_ADDRESS;\r
116\r
117\r
d674ed53 118///\r
119/// Enumeration of EFI_STATUS.\r
120///@{ \r
959ccb23 121#define EFI_SUCCESS RETURN_SUCCESS \r
122#define EFI_LOAD_ERROR RETURN_LOAD_ERROR \r
123#define EFI_INVALID_PARAMETER RETURN_INVALID_PARAMETER \r
124#define EFI_UNSUPPORTED RETURN_UNSUPPORTED \r
125#define EFI_BAD_BUFFER_SIZE RETURN_BAD_BUFFER_SIZE \r
126#define EFI_BUFFER_TOO_SMALL RETURN_BUFFER_TOO_SMALL \r
127#define EFI_NOT_READY RETURN_NOT_READY \r
128#define EFI_DEVICE_ERROR RETURN_DEVICE_ERROR \r
129#define EFI_WRITE_PROTECTED RETURN_WRITE_PROTECTED \r
130#define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES \r
131#define EFI_VOLUME_CORRUPTED RETURN_VOLUME_CORRUPTED \r
132#define EFI_VOLUME_FULL RETURN_VOLUME_FULL \r
133#define EFI_NO_MEDIA RETURN_NO_MEDIA \r
134#define EFI_MEDIA_CHANGED RETURN_MEDIA_CHANGED \r
135#define EFI_NOT_FOUND RETURN_NOT_FOUND \r
136#define EFI_ACCESS_DENIED RETURN_ACCESS_DENIED \r
137#define EFI_NO_RESPONSE RETURN_NO_RESPONSE \r
138#define EFI_NO_MAPPING RETURN_NO_MAPPING \r
139#define EFI_TIMEOUT RETURN_TIMEOUT \r
140#define EFI_NOT_STARTED RETURN_NOT_STARTED \r
141#define EFI_ALREADY_STARTED RETURN_ALREADY_STARTED \r
142#define EFI_ABORTED RETURN_ABORTED \r
143#define EFI_ICMP_ERROR RETURN_ICMP_ERROR \r
144#define EFI_TFTP_ERROR RETURN_TFTP_ERROR \r
145#define EFI_PROTOCOL_ERROR RETURN_PROTOCOL_ERROR \r
146#define EFI_INCOMPATIBLE_VERSION RETURN_INCOMPATIBLE_VERSION \r
147#define EFI_SECURITY_VIOLATION RETURN_SECURITY_VIOLATION \r
148#define EFI_CRC_ERROR RETURN_CRC_ERROR \r
149#define EFI_END_OF_MEDIA RETURN_END_OF_MEDIA\r
150#define EFI_END_OF_FILE RETURN_END_OF_FILE\r
54cf8780 151#define EFI_INVALID_LANGUAGE RETURN_INVALID_LANGUAGE\r
959ccb23 152\r
153#define EFI_WARN_UNKNOWN_GLYPH RETURN_WARN_UNKNOWN_GLYPH \r
154#define EFI_WARN_DELETE_FAILURE RETURN_WARN_DELETE_FAILURE \r
155#define EFI_WARN_WRITE_FAILURE RETURN_WARN_WRITE_FAILURE \r
156#define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL\r
d674ed53 157///@}\r
959ccb23 158\r
d674ed53 159///\r
160/// Define macro to encode the status code.\r
161/// \r
00edb218 162#define EFIERR(_a) ENCODE_ERROR(_a)\r
959ccb23 163\r
164#define EFI_ERROR(A) RETURN_ERROR(A)\r
165\r
d674ed53 166///\r
167/// ICMP error definitions\r
168///@{\r
169#define EFI_NETWORK_UNREACHABLE EFIERR(100)\r
170#define EFI_HOST_UNREACHABLE EFIERR(101) \r
171#define EFI_PROTOCOL_UNREACHABLE EFIERR(102)\r
172#define EFI_PORT_UNREACHABLE EFIERR(103)\r
173///@}\r
959ccb23 174\r
d674ed53 175///\r
176/// Tcp connection status definitions\r
177///@{\r
178#define EFI_CONNECTION_FIN EFIERR(104)\r
179#define EFI_CONNECTION_RESET EFIERR(105)\r
180#define EFI_CONNECTION_REFUSED EFIERR(106)\r
181///@}\r
959ccb23 182\r
183//\r
184// The EFI memory allocation functions work in units of EFI_PAGEs that are\r
185// 4K. This should in no way be confused with the page size of the processor.\r
186// An EFI_PAGE is just the quanta of memory in EFI.\r
187//\r
00edb218
A
188#define EFI_PAGE_SIZE 0x1000\r
189#define EFI_PAGE_MASK 0xFFF\r
190#define EFI_PAGE_SHIFT 12\r
959ccb23 191\r
833bd94e 192#define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))\r
193\r
194#define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)\r
959ccb23 195\r
4ab0dff3 196///\r
197/// PE32+ Machine type for IA32 UEFI images\r
198///\r
97f8b30c 199#define EFI_IMAGE_MACHINE_IA32 0x014C\r
4ab0dff3 200\r
201///\r
202/// PE32+ Machine type for IA64 UEFI images\r
203///\r
97f8b30c 204#define EFI_IMAGE_MACHINE_IA64 0x0200\r
4ab0dff3 205\r
206///\r
207/// PE32+ Machine type for EBC UEFI images\r
208///\r
97f8b30c 209#define EFI_IMAGE_MACHINE_EBC 0x0EBC\r
4ab0dff3 210\r
211///\r
212/// PE32+ Machine type for X64 UEFI images\r
213///\r
97f8b30c 214#define EFI_IMAGE_MACHINE_X64 0x8664\r
4ab0dff3 215\r
ebd04fc2 216///\r
217/// PE32+ Machine type for ARM mixed ARM and Thumb/Thumb2 images\r
218///\r
219#define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2\r
220\r
4ab0dff3 221\r
222#if defined (MDE_CPU_IA32)\r
223\r
224#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
225 (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
226\r
227#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64) \r
228\r
229#elif defined (MDE_CPU_IPF)\r
230\r
231#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
232 (((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
233\r
234#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) \r
235\r
236#elif defined (MDE_CPU_X64)\r
237\r
238#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
239 (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
240\r
241#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32) \r
242\r
ebd04fc2 243#elif defined (MDE_CPU_ARM)\r
244\r
245#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
246 (((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
247\r
248#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) \r
249\r
4ab0dff3 250#elif defined (MDE_CPU_EBC)\r
251\r
252///\r
eaad1319 253/// This is just to make sure you can cross compile with the EBC compiler.\r
8992ce06 254/// It does not make sense to have a PE loader coded in EBC. \r
4ab0dff3 255///\r
256#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
257\r
258#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) \r
259\r
260#else\r
261#error Unknown Processor Type\r
262#endif\r
f4e8509b 263\r
959ccb23 264#endif\r