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