iPXE
ProcessorBind.h
Go to the documentation of this file.
1/** @file
2 Processor or Compiler specific defines and types x64 (Intel 64, AMD64).
3
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#pragma once
10
11FILE_LICENCE ( BSD2_PATENT );
12FILE_SECBOOT ( PERMITTED );
13
14///
15/// Define the processor type so other code can make processor based choices
16///
17#define MDE_CPU_X64
18
19//
20// Make sure we are using the correct packing rules per EFI specification
21//
22#if !defined (__GNUC__)
23 #pragma pack()
24#endif
25
26#if defined (__INTEL_COMPILER)
27//
28// Disable ICC's remark #869: "Parameter" was never referenced warning.
29// This is legal ANSI C code so we disable the remark that is turned on with -Wall
30//
31 #pragma warning ( disable : 869 )
32
33//
34// Disable ICC's remark #1418: external function definition with no prior declaration.
35// This is legal ANSI C code so we disable the remark that is turned on with /W4
36//
37 #pragma warning ( disable : 1418 )
38
39//
40// Disable ICC's remark #1419: external declaration in primary source file
41// This is legal ANSI C code so we disable the remark that is turned on with /W4
42//
43 #pragma warning ( disable : 1419 )
44
45//
46// Disable ICC's remark #593: "Variable" was set but never used.
47// This is legal ANSI C code so we disable the remark that is turned on with /W4
48//
49 #pragma warning ( disable : 593 )
50
51#endif
52
53#if defined (_MSC_EXTENSIONS)
54
55//
56// Disable warning that make it impossible to compile at /W4
57// This only works for Microsoft* tools
58//
59
60//
61// Disabling bitfield type checking warnings.
62//
63 #pragma warning ( disable : 4214 )
64
65//
66// Disabling the unreferenced formal parameter warnings.
67//
68 #pragma warning ( disable : 4100 )
69
70//
71// Disable slightly different base types warning as CHAR8 * can not be set
72// to a constant string.
73//
74 #pragma warning ( disable : 4057 )
75
76//
77// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
78//
79 #pragma warning ( disable : 4127 )
80
81//
82// This warning is caused by functions defined but not used. For precompiled header only.
83//
84 #pragma warning ( disable : 4505 )
85
86//
87// This warning is caused by empty (after preprocessing) source file. For precompiled header only.
88//
89 #pragma warning ( disable : 4206 )
90
91 #if defined (_MSC_VER) && _MSC_VER >= 1800
92
93//
94// This warning is for potentially uninitialized local variable, and it may cause false
95// positive issues in VS2015 build
96//
97 #pragma warning ( disable : 4701 )
98
99//
100// This warning is for potentially uninitialized local pointer variable, and it may cause
101// false positive issues in VS2015 build
102//
103 #pragma warning ( disable : 4703 )
104
105 #endif
106
107#endif
108
109#if defined (_MSC_EXTENSIONS)
110//
111// use Microsoft C compiler dependent integer width types
112//
113
114///
115/// 8-byte unsigned value
116///
117typedef unsigned __int64 UINT64;
118///
119/// 8-byte signed value
120///
121typedef __int64 INT64;
122///
123/// 4-byte unsigned value
124///
125typedef unsigned __int32 UINT32;
126///
127/// 4-byte signed value
128///
129typedef __int32 INT32;
130///
131/// 2-byte unsigned value
132///
133typedef unsigned short UINT16;
134///
135/// 2-byte Character. Unless otherwise specified all strings are stored in the
136/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
137///
138typedef unsigned short CHAR16;
139///
140/// 2-byte signed value
141///
142typedef short INT16;
143///
144/// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
145/// values are undefined.
146///
147typedef unsigned char BOOLEAN;
148///
149/// 1-byte unsigned value
150///
151typedef unsigned char UINT8;
152///
153/// 1-byte Character
154///
155typedef char CHAR8;
156///
157/// 1-byte signed value
158///
159typedef signed char INT8;
160#else
161///
162/// 8-byte unsigned value
163///
164typedef unsigned long long UINT64;
165///
166/// 8-byte signed value
167///
168typedef long long INT64;
169///
170/// 4-byte unsigned value
171///
172typedef unsigned int UINT32;
173///
174/// 4-byte signed value
175///
176typedef int INT32;
177///
178/// 2-byte unsigned value
179///
180typedef unsigned short UINT16;
181///
182/// 2-byte Character. Unless otherwise specified all strings are stored in the
183/// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
184///
185typedef unsigned short CHAR16;
186///
187/// 2-byte signed value
188///
189typedef short INT16;
190///
191/// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
192/// values are undefined.
193///
194typedef unsigned char BOOLEAN;
195///
196/// 1-byte unsigned value
197///
198typedef unsigned char UINT8;
199///
200/// 1-byte Character
201///
202typedef char CHAR8;
203///
204/// 1-byte signed value
205///
206typedef signed char INT8;
207#endif
208
209///
210/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
211/// 8 bytes on supported 64-bit processor instructions)
212///
213typedef UINT64 UINTN;
214///
215/// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
216/// 8 bytes on supported 64-bit processor instructions)
217///
218typedef INT64 INTN;
219
220//
221// Processor specific defines
222//
223
224///
225/// A value of native width with the highest bit set.
226///
227#define MAX_BIT 0x8000000000000000ULL
228///
229/// A value of native width with the two highest bits set.
230///
231#define MAX_2_BITS 0xC000000000000000ULL
232
233///
234/// Maximum legal x64 address
235///
236#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
237
238///
239/// Maximum usable address at boot time
240///
241#define MAX_ALLOC_ADDRESS MAX_ADDRESS
242
243///
244/// Maximum legal x64 INTN and UINTN values.
245///
246#define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
247#define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
248
249///
250/// Minimum legal x64 INTN value.
251///
252#define MIN_INTN (((INTN)-9223372036854775807LL) - 1)
253
254///
255/// The stack alignment required for x64
256///
257#define CPU_STACK_ALIGNMENT 16
258
259///
260/// Page allocation granularity for x64
261///
262#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
263#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
264
265//
266// Modifier to ensure that all protocol member functions and EFI intrinsics
267// use the correct C calling convention. All protocol member functions and
268// EFI intrinsics are required to modify their member functions with EFIAPI.
269//
270#ifdef EFIAPI
271///
272/// If EFIAPI is already defined, then we use that definition.
273///
274#elif defined (_MSC_EXTENSIONS)
275///
276/// Microsoft* compiler specific method for EFIAPI calling convention.
277///
278#define EFIAPI __cdecl
279#elif defined (__GNUC__)
280///
281/// Define the standard calling convention regardless of optimization level.
282/// The GCC support assumes a GCC compiler that supports the EFI ABI. The EFI
283/// ABI is much closer to the x64 Microsoft* ABI than standard x64 (x86-64)
284/// GCC ABI. Thus a standard x64 (x86-64) GCC compiler can not be used for
285/// x64. Warning the assembly code in the MDE x64 does not follow the correct
286/// ABI for the standard x64 (x86-64) GCC.
287///
288#define EFIAPI
289#else
290///
291/// The default for a non Microsoft* or GCC compiler is to assume the EFI ABI
292/// is the standard.
293///
294#define EFIAPI
295#endif
296
297#if defined (__GNUC__) || defined (__clang__)
298///
299/// For GNU assembly code, .global or .globl can declare global symbols.
300/// Define this macro to unify the usage.
301///
302#define ASM_GLOBAL .globl
303#endif
304
305/**
306 Return the pointer to the first instruction of a function given a function pointer.
307 On x64 CPU architectures, these two pointer values are the same,
308 so the implementation of this macro is very simple.
309
310 @param FunctionPointer A pointer to a function.
311
312 @return The pointer to the first instruction of a function given a function pointer.
313
314**/
315#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
316
317#ifndef __USER_LABEL_PREFIX__
318#define __USER_LABEL_PREFIX__
319#endif
unsigned short UINT16
2-byte unsigned value.
unsigned char BOOLEAN
Logical Boolean.
char CHAR8
1-byte Character
UINT64 UINTN
Unsigned value of native width.
unsigned long long UINT64
8-byte unsigned value.
short INT16
2-byte signed value.
int INT32
4-byte signed value.
long long INT64
8-byte signed value.
unsigned short CHAR16
2-byte Character.
signed char INT8
1-byte signed value
INT64 INTN
Signed value of native width.
unsigned char UINT8
1-byte unsigned value.
unsigned int UINT32
4-byte unsigned value.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:921
#define FILE_SECBOOT(_status)
Declare a file's UEFI Secure Boot permission status.
Definition compiler.h:951