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