MdePkg/ProcessorBind: add defines for page allocation granularity
[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
ab4de5c8 4Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
10a3840f 5Portions copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.<BR>\r
b4319afb 6\r
af2dc6a7 7This program and the accompanying materials are licensed and made available under \r
8the terms and conditions of the BSD License that accompanies this distribution. \r
9The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php. \r
11 \r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
959ccb23 14\r
15**/\r
16\r
17#ifndef __UEFI_BASETYPE_H__\r
18#define __UEFI_BASETYPE_H__\r
19\r
a0f1b047 20#include <Base.h>\r
959ccb23 21\r
e0c047a0 22//\r
eaad1319 23// Basic data type definitions introduced in UEFI.\r
e0c047a0 24//\r
25\r
26///\r
27/// 128-bit buffer containing a unique identifier value.\r
8b13229b 28///\r
00edb218 29typedef GUID EFI_GUID;\r
3f748e52 30///\r
af2dc6a7 31/// Function return status for EFI API.\r
3f748e52 32///\r
00edb218 33typedef RETURN_STATUS EFI_STATUS;\r
e0c047a0 34///\r
35/// A collection of related interfaces.\r
36///\r
00edb218 37typedef VOID *EFI_HANDLE;\r
e0c047a0 38///\r
39/// Handle to an event structure.\r
40///\r
00edb218 41typedef VOID *EFI_EVENT;\r
e0c047a0 42///\r
43/// Task priority level.\r
44///\r
00edb218 45typedef UINTN EFI_TPL;\r
e0c047a0 46///\r
47/// Logical block address.\r
48///\r
00edb218 49typedef UINT64 EFI_LBA;\r
6617fcc2 50\r
51///\r
52/// 64-bit physical memory address.\r
53///\r
00edb218 54typedef UINT64 EFI_PHYSICAL_ADDRESS;\r
6617fcc2 55\r
56///\r
57/// 64-bit virtual memory address.\r
58///\r
00edb218 59typedef UINT64 EFI_VIRTUAL_ADDRESS;\r
959ccb23 60\r
fb5148a0 61///\r
62/// EFI Time Abstraction:\r
e189264e 63/// Year: 1900 - 9999\r
fb5148a0 64/// Month: 1 - 12\r
65/// Day: 1 - 31\r
66/// Hour: 0 - 23\r
67/// Minute: 0 - 59\r
68/// Second: 0 - 59\r
69/// Nanosecond: 0 - 999,999,999\r
70/// TimeZone: -1440 to 1440 or 2047\r
71///\r
959ccb23 72typedef struct {\r
73 UINT16 Year;\r
74 UINT8 Month;\r
75 UINT8 Day;\r
76 UINT8 Hour;\r
77 UINT8 Minute;\r
78 UINT8 Second;\r
79 UINT8 Pad1;\r
80 UINT32 Nanosecond;\r
81 INT16 TimeZone;\r
82 UINT8 Daylight;\r
83 UINT8 Pad2;\r
84} EFI_TIME;\r
85\r
d1f95000 86\r
e0c047a0 87///\r
88/// 4-byte buffer. An IPv4 internet protocol address.\r
89///\r
ab4de5c8 90typedef IPv4_ADDRESS EFI_IPv4_ADDRESS;\r
d1f95000 91\r
e0c047a0 92///\r
af2dc6a7 93/// 16-byte buffer. An IPv6 internet protocol address.\r
e0c047a0 94///\r
ab4de5c8 95typedef IPv6_ADDRESS EFI_IPv6_ADDRESS;\r
d1f95000 96\r
e0c047a0 97///\r
98/// 32-byte buffer containing a network Media Access Control address.\r
99///\r
d1f95000 100typedef struct {\r
101 UINT8 Addr[32];\r
102} EFI_MAC_ADDRESS;\r
103\r
e0c047a0 104///\r
105/// 16-byte buffer aligned on a 4-byte boundary.\r
106/// An IPv4 or IPv6 internet protocol address.\r
107///\r
d1f95000 108typedef union {\r
109 UINT32 Addr[4];\r
110 EFI_IPv4_ADDRESS v4;\r
111 EFI_IPv6_ADDRESS v6;\r
112} EFI_IP_ADDRESS;\r
113\r
114\r
d674ed53 115///\r
116/// Enumeration of EFI_STATUS.\r
117///@{ \r
959ccb23 118#define EFI_SUCCESS RETURN_SUCCESS \r
119#define EFI_LOAD_ERROR RETURN_LOAD_ERROR \r
120#define EFI_INVALID_PARAMETER RETURN_INVALID_PARAMETER \r
121#define EFI_UNSUPPORTED RETURN_UNSUPPORTED \r
122#define EFI_BAD_BUFFER_SIZE RETURN_BAD_BUFFER_SIZE \r
123#define EFI_BUFFER_TOO_SMALL RETURN_BUFFER_TOO_SMALL \r
124#define EFI_NOT_READY RETURN_NOT_READY \r
125#define EFI_DEVICE_ERROR RETURN_DEVICE_ERROR \r
126#define EFI_WRITE_PROTECTED RETURN_WRITE_PROTECTED \r
127#define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES \r
128#define EFI_VOLUME_CORRUPTED RETURN_VOLUME_CORRUPTED \r
129#define EFI_VOLUME_FULL RETURN_VOLUME_FULL \r
130#define EFI_NO_MEDIA RETURN_NO_MEDIA \r
131#define EFI_MEDIA_CHANGED RETURN_MEDIA_CHANGED \r
132#define EFI_NOT_FOUND RETURN_NOT_FOUND \r
133#define EFI_ACCESS_DENIED RETURN_ACCESS_DENIED \r
134#define EFI_NO_RESPONSE RETURN_NO_RESPONSE \r
135#define EFI_NO_MAPPING RETURN_NO_MAPPING \r
136#define EFI_TIMEOUT RETURN_TIMEOUT \r
137#define EFI_NOT_STARTED RETURN_NOT_STARTED \r
138#define EFI_ALREADY_STARTED RETURN_ALREADY_STARTED \r
139#define EFI_ABORTED RETURN_ABORTED \r
140#define EFI_ICMP_ERROR RETURN_ICMP_ERROR \r
141#define EFI_TFTP_ERROR RETURN_TFTP_ERROR \r
142#define EFI_PROTOCOL_ERROR RETURN_PROTOCOL_ERROR \r
143#define EFI_INCOMPATIBLE_VERSION RETURN_INCOMPATIBLE_VERSION \r
144#define EFI_SECURITY_VIOLATION RETURN_SECURITY_VIOLATION \r
145#define EFI_CRC_ERROR RETURN_CRC_ERROR \r
146#define EFI_END_OF_MEDIA RETURN_END_OF_MEDIA\r
147#define EFI_END_OF_FILE RETURN_END_OF_FILE\r
54cf8780 148#define EFI_INVALID_LANGUAGE RETURN_INVALID_LANGUAGE\r
76336e4e 149#define EFI_COMPROMISED_DATA RETURN_COMPROMISED_DATA\r
10a3840f 150#define EFI_HTTP_ERROR RETURN_HTTP_ERROR\r
959ccb23 151\r
152#define EFI_WARN_UNKNOWN_GLYPH RETURN_WARN_UNKNOWN_GLYPH \r
153#define EFI_WARN_DELETE_FAILURE RETURN_WARN_DELETE_FAILURE \r
154#define EFI_WARN_WRITE_FAILURE RETURN_WARN_WRITE_FAILURE \r
155#define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL\r
76336e4e 156#define EFI_WARN_STALE_DATA RETURN_WARN_STALE_DATA\r
fed5f447 157#define EFI_WARN_FILE_SYSTEM RETURN_WARN_FILE_SYSTEM\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
b4319afb
HL
244///\r
245/// PE32+ Machine type for AARCH64 A64 images.\r
246///\r
247#define EFI_IMAGE_MACHINE_AARCH64 0xAA64\r
248\r
4ab0dff3 249\r
250#if defined (MDE_CPU_IA32)\r
251\r
252#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
253 (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
254\r
255#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64) \r
256\r
257#elif defined (MDE_CPU_IPF)\r
258\r
259#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
260 (((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
261\r
262#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) \r
263\r
264#elif defined (MDE_CPU_X64)\r
265\r
266#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
267 (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
268\r
269#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32) \r
270\r
ebd04fc2 271#elif defined (MDE_CPU_ARM)\r
272\r
273#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
274 (((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
275\r
276#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) \r
277\r
b4319afb
HL
278#elif defined (MDE_CPU_AARCH64)\r
279\r
280#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \\r
281 (((Machine) == EFI_IMAGE_MACHINE_AARCH64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))\r
282\r
283#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)\r
284\r
4ab0dff3 285#elif defined (MDE_CPU_EBC)\r
286\r
287///\r
eaad1319 288/// This is just to make sure you can cross compile with the EBC compiler.\r
8992ce06 289/// It does not make sense to have a PE loader coded in EBC. \r
4ab0dff3 290///\r
291#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)\r
292\r
293#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE) \r
294\r
295#else\r
296#error Unknown Processor Type\r
297#endif\r
f4e8509b 298\r
959ccb23 299#endif\r