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