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