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