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