]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Ipf/ProcessorBind.h
Remove __APPLE__ usage in ProcessorBind.h files.
[mirror_edk2.git] / MdePkg / Include / Ipf / ProcessorBind.h
1 /** @file
2 Processor or Compiler specific defines and types for Intel Itanium(TM).
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 ///
20 /// Define the processor type so other code can make processor based choices
21 ///
22 #define MDE_CPU_IPF
23
24
25 //
26 // Make sure we are using the correct packing rules per EFI specification
27 //
28 #pragma pack()
29
30
31 #if defined(__INTEL_COMPILER)
32 //
33 // Disable ICC's remark #869: "Parameter" was never referenced warning.
34 // This is legal ANSI C code so we disable the remark that is turned on with -Wall
35 //
36 #pragma warning ( disable : 869 )
37
38 //
39 // Disable ICC's remark #1418: external function definition with no prior declaration.
40 // This is legal ANSI C code so we disable the remark that is turned on with /W4
41 //
42 #pragma warning ( disable : 1418 )
43
44 //
45 // Disable ICC's remark #1419: external declaration in primary source file
46 // This is legal ANSI C code so we disable the remark that is turned on with /W4
47 //
48 #pragma warning ( disable : 1419 )
49
50 #endif
51
52
53 #if defined(_MSC_EXTENSIONS)
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 // Disable warning on conversion from function pointer to a data pointer
77 //
78 #pragma warning ( disable : 4054 )
79
80 //
81 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
82 //
83 #pragma warning ( disable : 4127 )
84
85 //
86 // Can not cast a function pointer to a data pointer. We need to do this on
87 // IPF to get access to the PLABEL.
88 //
89 #pragma warning ( disable : 4514 )
90
91 //
92 // This warning is caused by functions defined but not used. For precompiled header only.
93 //
94 #pragma warning ( disable : 4505 )
95
96 //
97 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
98 //
99 #pragma warning ( disable : 4206 )
100
101 #endif
102
103
104 #if !defined (__STDC_VERSION__) || (__STDC_VERSION__) < 199901L
105 //
106 // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
107 //
108
109 #if defined(_MSC_EXTENSIONS)
110 //
111 // use Microsoft C complier dependent integer width types
112 //
113
114 ///
115 /// 8-byte unsigned value
116 ///
117 typedef unsigned __int64 UINT64;
118 ///
119 /// 8-byte signed value
120 ///
121 typedef __int64 INT64;
122 ///
123 /// 4-byte unsigned value
124 ///
125 typedef unsigned __int32 UINT32;
126 ///
127 /// 4-byte signed value
128 ///
129 typedef __int32 INT32;
130 ///
131 /// 2-byte unsigned value
132 ///
133 typedef unsigned short UINT16;
134 ///
135 /// 2-byte Character. Unless otherwise specified all strings are stored in the
136 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
137 ///
138 typedef unsigned short CHAR16;
139 ///
140 /// 2-byte signed value
141 ///
142 typedef short INT16;
143 ///
144 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
145 /// values are undefined.
146 ///
147 typedef unsigned char BOOLEAN;
148 ///
149 /// 1-byte unsigned value
150 ///
151 typedef unsigned char UINT8;
152 ///
153 /// 1-byte Character
154 ///
155 typedef char CHAR8;
156 ///
157 /// 1-byte signed value
158 ///
159 typedef char INT8;
160 #else
161 #if defined(_EFI_P64)
162 //
163 // P64 - pointers being 64-bit and longs and ints are 32-bits.
164 //
165
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 Character. Unless otherwise specified all strings are stored in the
184 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
185 ///
186 typedef unsigned short CHAR16;
187 ///
188 /// 2-byte unsigned value
189 ///
190 typedef unsigned short UINT16;
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 char INT8;
212 #else
213 //
214 // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.
215 //
216
217 ///
218 /// 8-byte unsigned value
219 ///
220 typedef unsigned long UINT64;
221 ///
222 /// 8-byte signed value
223 ///
224 typedef long INT64;
225 ///
226 /// 4-byte unsigned value
227 ///
228 typedef unsigned int UINT32;
229 ///
230 /// 4-byte signed value
231 ///
232 typedef int INT32;
233 ///
234 /// 2-byte unsigned value
235 ///
236 typedef unsigned short UINT16;
237 ///
238 /// 2-byte Character. Unless otherwise specified all strings are stored in the
239 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
240 ///
241 typedef unsigned short CHAR16;
242 ///
243 /// 2-byte signed value
244 ///
245 typedef short INT16;
246 ///
247 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
248 /// values are undefined.
249 ///
250 typedef unsigned char BOOLEAN;
251 ///
252 /// 1-byte unsigned value
253 ///
254 typedef unsigned char UINT8;
255 ///
256 /// 1-byte Character
257 ///
258 typedef char CHAR8;
259 ///
260 /// 1-byte signed value
261 ///
262 typedef char INT8;
263 #endif
264 #endif
265 #else
266 //
267 // Use ANSI C 2000 stdint.h integer width declarations
268 //
269 #include <stdint.h>
270
271 ///
272 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other
273 /// values are undefined.
274 ///
275 typedef uint8_t BOOLEAN;
276 ///
277 /// 1-byte signed value
278 ///
279 typedef int8_t INT8;
280 ///
281 /// 1-byte unsigned value
282 ///
283 typedef uint8_t UINT8;
284 ///
285 /// 2-byte signed value
286 ///
287 typedef int16_t INT16;
288 ///
289 /// 2-byte unsigned value
290 ///
291 typedef uint16_t UINT16;
292 ///
293 /// 4-byte signed value
294 ///
295 typedef int32_t INT32;
296 ///
297 /// 4-byte unsigned value
298 ///
299 typedef uint32_t UINT32;
300 ///
301 /// 8-byte signed value
302 ///
303 typedef int64_t INT64;
304 ///
305 /// 8-byte unsigned value
306 ///
307 typedef uint64_t UINT64;
308 ///
309 /// 1-byte Character
310 ///
311 typedef char CHAR8;
312 ///
313 /// 2-byte Character. Unless otherwise specified all strings are stored in the
314 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.
315 ///
316 typedef uint16_t CHAR16;
317
318 #endif
319
320 ///
321 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
322 /// 8 bytes on supported 64-bit processor instructions)
323 ///
324 typedef UINT64 UINTN;
325 ///
326 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
327 /// 8 bytes on supported 64-bit processor instructions)
328 ///
329 typedef INT64 INTN;
330
331
332 //
333 // Processor specific defines
334 //
335
336 ///
337 /// A value of native width with the highest bit set.
338 ///
339 #define MAX_BIT 0x8000000000000000ULL
340 ///
341 /// A value of native width with the two highest bits set.
342 ///
343 #define MAX_2_BITS 0xC000000000000000ULL
344
345 ///
346 /// Maximum legal Itanium-based address
347 ///
348 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
349
350 ///
351 /// Per the Itanium Software Conventions and Runtime Architecture Guide,
352 /// section 3.3.4, IPF stack must always be 16-byte aligned.
353 ///
354 #define CPU_STACK_ALIGNMENT 16
355
356 //
357 // Modifier to ensure that all protocol member functions and EFI intrinsics
358 // use the correct C calling convention. All protocol member functions and
359 // EFI intrinsics are required to modify their member functions with EFIAPI.
360 //
361 #ifdef EFIAPI
362 ///
363 /// If EFIAPI is already defined, then we use that definition.
364 ///
365 #elif defined(_MSC_EXTENSIONS)
366 ///
367 /// Microsoft* compiler specific method for EFIAPI calling convension
368 ///
369 #define EFIAPI __cdecl
370 #else
371 #define EFIAPI
372 #endif
373
374 //
375 // The Microsoft* C compiler can removed references to unreferenced data items
376 // if the /OPT:REF linker option is used. We defined a macro as this is a
377 // a non standard extension
378 //
379 #if defined(_MSC_EXTENSIONS)
380 ///
381 /// Remove global variable from the linked image if there are no references to
382 /// it after all compiler and linker optimizations have been performed.
383 ///
384 ///
385 #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)
386 #else
387 ///
388 /// Remove global variable from the linked image if there are no references to
389 /// it after all compiler and linker optimizations have been performed.
390 ///
391 ///
392 #define GLOBAL_REMOVE_IF_UNREFERENCED
393 #endif
394
395 ///
396 /// For GNU assembly code, .global or .globl can declare global symbols.
397 /// Define this macro to unify the usage.
398 ///
399 #define ASM_GLOBAL .globl
400
401 ///
402 /// A pointer to a function in IPF points to a plabel.
403 ///
404 typedef struct {
405 UINT64 EntryPoint;
406 UINT64 GP;
407 } EFI_PLABEL;
408
409 ///
410 /// PAL Call return structure.
411 ///
412 typedef struct {
413 UINT64 Status;
414 UINT64 r9;
415 UINT64 r10;
416 UINT64 r11;
417 } PAL_CALL_RETURN;
418
419 /**
420 Return the pointer to the first instruction of a function given a function pointer.
421 For Itanium CPUs, all function calls are made through a PLABEL, so a pointer to a function
422 is actually a pointer to a PLABEL. The pointer to the first instruction of the function
423 is contained within the PLABEL. This macro may be used to retrieve a pointer to the first
424 instruction of a function independent of the CPU architecture being used. This is very
425 useful when printing function addresses through DEBUG() macros.
426
427 @param FunctionPointer A pointer to a function.
428
429 @return The pointer to the first instruction of a function given a function pointer.
430
431 **/
432 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(((EFI_PLABEL *)(FunctionPointer))->EntryPoint)
433
434 #endif
435