]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Ia32/ProcessorBind.h
edf881b7ee5f13be57cc88583fdd9bf1c67406fb
[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 - 2009, Intel Corporation<BR>
5 All rights reserved. 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_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 #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 constructes so supress 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 #endif
91
92
93 #if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)
94 //
95 // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
96 //
97
98 #if defined(_MSC_EXTENSIONS)
99
100 //
101 // use Microsoft C complier dependent integer width types
102 //
103
104 ///
105 /// 8-byte unsigned value
106 ///
107 typedef unsigned __int64 UINT64;
108 ///
109 /// 8-byte signed value
110 ///
111 typedef __int64 INT64;
112 ///
113 /// 4-byte unsigned value
114 ///
115 typedef unsigned __int32 UINT32;
116 ///
117 /// 4-byte signed value
118 ///
119 typedef __int32 INT32;
120 ///
121 /// 2-byte unsigned value
122 ///
123 typedef unsigned short UINT16;
124 ///
125 /// 2-byte Character. Unless otherwise specified all strings are stored in the
126 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
127 ///
128 typedef unsigned short CHAR16;
129 ///
130 /// 2-byte signed value
131 ///
132 typedef short INT16;
133 ///
134 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
135 /// values are undefined.
136 ///
137 typedef unsigned char BOOLEAN;
138 ///
139 /// 1-byte unsigned value
140 ///
141 typedef unsigned char UINT8;
142 ///
143 /// 1-byte Character
144 ///
145 typedef char CHAR8;
146 ///
147 /// 1-byte signed value
148 ///
149 typedef char INT8;
150 #else
151
152 //
153 // Assume standard IA-32 alignment.
154 // Need to check portability of long long
155 //
156
157 ///
158 /// 8-byte unsigned value
159 ///
160 typedef unsigned long long UINT64;
161 ///
162 /// 8-byte signed value
163 ///
164 typedef long long INT64;
165 ///
166 /// 4-byte unsigned value
167 ///
168 typedef unsigned int UINT32;
169 ///
170 /// 4-byte signed value
171 ///
172 typedef int INT32;
173 ///
174 /// 2-byte unsigned value
175 ///
176 typedef unsigned short UINT16;
177 ///
178 /// 2-byte Character. Unless otherwise specified all strings are stored in the
179 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
180 ///
181 typedef unsigned short CHAR16;
182 ///
183 /// 2-byte signed value
184 ///
185 typedef short INT16;
186 ///
187 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
188 /// values are undefined.
189 ///
190 typedef unsigned char BOOLEAN;
191 ///
192 /// 1-byte unsigned value
193 ///
194 typedef unsigned char UINT8;
195 ///
196 /// 1-byte Character
197 ///
198 typedef char CHAR8;
199 ///
200 /// 1-byte signed value
201 ///
202 typedef char INT8;
203 #endif
204 #else
205 //
206 // Use ANSI C 2000 stdint.h integer width declarations
207 //
208 #include <stdint.h>
209
210 ///
211 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
212 /// values are undefined.
213 ///
214 typedef uint8_t BOOLEAN;
215 ///
216 /// 1-byte signed value
217 ///
218 typedef int8_t INT8;
219 ///
220 /// 1-byte unsigned value
221 ///
222 typedef uint8_t UINT8;
223 ///
224 /// 2-byte signed value
225 ///
226 typedef int16_t INT16;
227 ///
228 /// 2-byte unsigned value
229 ///
230 typedef uint16_t UINT16;
231 ///
232 /// 4-byte signed value
233 ///
234 typedef int32_t INT32;
235 ///
236 /// 4-byte unsigned value
237 ///
238 typedef uint32_t UINT32;
239 ///
240 /// 8-byte signed value
241 ///
242 typedef int64_t INT64;
243 ///
244 /// 8-byte unsigned value
245 ///
246 typedef uint64_t UINT64;
247 ///
248 /// 1-byte Character
249 ///
250 typedef char CHAR8;
251 ///
252 /// 2-byte Character. Unless otherwise specified all strings are stored in the
253 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
254 ///
255 typedef uint16_t CHAR16;
256
257 #endif
258
259 ///
260 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
261 /// 8 bytes on supported 64-bit processor instructions)
262 ///
263 typedef UINT32 UINTN;
264 ///
265 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
266 /// 8 bytes on supported 64-bit processor instructions)
267 ///
268 typedef INT32 INTN;
269
270 //
271 // Processor specific defines
272 //
273
274 ///
275 /// A value of native width with the highest bit set.
276 ///
277 #define MAX_BIT 0x80000000
278 ///
279 /// A value of native width with the two highest bits set.
280 ///
281 #define MAX_2_BITS 0xC0000000
282
283 ///
284 /// Maximum legal IA-32 address
285 ///
286 #define MAX_ADDRESS 0xFFFFFFFF
287
288 ///
289 /// The stack alignment required for IA-32
290 ///
291 #define CPU_STACK_ALIGNMENT sizeof(UINTN)
292
293 //
294 // Modifier to ensure that all protocol member functions and EFI intrinsics
295 // use the correct C calling convention. All protocol member functions and
296 // EFI intrinsics are required to modify their member functions with EFIAPI.
297 //
298 #ifdef EFIAPI
299 ///
300 /// If EFIAPI is already defined, then we use that definition.
301 ///
302 #elif defined(_MSC_EXTENSIONS)
303 ///
304 /// Microsoft* compiler specific method for EFIAPI calling convension
305 ///
306 #define EFIAPI __cdecl
307 #else
308 #if defined(__GNUC__)
309 ///
310 /// GCC specific method for EFIAPI calling convension
311 ///
312 #define EFIAPI __attribute__((cdecl))
313 #endif
314 #endif
315
316 //
317 // The Microsoft* C compiler can removed references to unreferenced data items
318 // if the /OPT:REF linker option is used. We defined a macro as this is a
319 // a non standard extension
320 //
321 #if defined(_MSC_EXTENSIONS)
322 ///
323 /// Remove global variable from the linked image if there are no references to
324 /// it after all compiler and linker optimizations have been performed.
325 ///
326 #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)
327 #else
328 ///
329 /// Remove global variable from the linked image if there are no references to
330 /// it after all compiler and linker optimizations have been performed.
331 ///
332 #define GLOBAL_REMOVE_IF_UNREFERENCED
333 #endif
334
335 //
336 // For symbol name in GNU assembly code, an extra "_" is necessary
337 //
338 #if defined(__GNUC__)
339 #if defined(linux)
340 #define ASM_PFX(name) name
341 #else
342 #define ASM_PFX(name) _##name
343 #endif
344 #endif
345
346 /**
347 Return the pointer to the first instruction of a function given a function pointer.
348 On IA-32 CPU architectures, these two pointer values are the same,
349 so the implementation of this macro is very simple.
350
351 @param FunctionPointer A pointer to a function.
352
353 @return The pointer to the first instruction of a function given a function pointer.
354
355 **/
356 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
357
358 #endif
359