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