1 /** @file
2   Processor or Compiler specific defines and types x64 (Intel(r) EM64T, AMD64).
3 
4   Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
5 
6   This program and the accompanying materials are licensed and made available
7   under the terms and conditions of the BSD License which accompanies this
8   distribution.  The full text of the license may be found at
9     http://opensource.org/licenses/bsd-license.php
10 
11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 
16 #ifndef __PROCESSOR_BIND_H__
17 #define __PROCESSOR_BIND_H__
18 
19 //
20 // Define the processor type so other code can make processor based choices
21 //
22 #define MDE_CPU_X64
23 
24 
25 //
26 // Make sure we are useing the correct packing rules per EFI specification
27 //
28 #ifndef __GNUC__
29 #pragma pack()
30 #endif
31 
32 
33 #if _MSC_EXTENSIONS
34 
35 //
36 // Disable warning that make it impossible to compile at /W4
37 // This only works for Microsoft* tools
38 //
39 
40 //
41 // Disabling bitfield type checking warnings.
42 //
43 #pragma warning ( disable : 4214 )
44 
45 //
46 // Disabling the unreferenced formal parameter warnings.
47 //
48 #pragma warning ( disable : 4100 )
49 
50 //
51 // Disable slightly different base types warning as CHAR8 * can not be set
52 // to a constant string.
53 //
54 #pragma warning ( disable : 4057 )
55 
56 //
57 // ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
58 //
59 #pragma warning ( disable : 4127 )
60 
61 
62 #endif
63 
64 
65 #if !defined(__GNUC__) && (__STDC_VERSION__ < 199901L)
66   //
67   // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
68   //
69 
70   #if _MSC_EXTENSIONS
71 
72 
73     //
74     // use Microsoft C complier dependent integer width types
75     //
76     typedef unsigned __int64    UINT64;
77     typedef __int64             INT64;
78     typedef unsigned __int32    UINT32;
79     typedef __int32             INT32;
80     typedef unsigned short      UINT16;
81     typedef unsigned short      CHAR16;
82     typedef short               INT16;
83     typedef unsigned char       BOOLEAN;
84     typedef unsigned char       UINT8;
85     typedef char                CHAR8;
86     typedef char                INT8;
87   #else
88     #ifdef _EFI_P64
89       //
90       // P64 - is Intel Itanium(TM) speak for pointers being 64-bit and longs and ints
91       //  are 32-bits
92       //
93       typedef unsigned long long  UINT64;
94       typedef long long           INT64;
95       typedef unsigned int        UINT32;
96       typedef int                 INT32;
97       typedef unsigned short      CHAR16;
98       typedef unsigned short      UINT16;
99       typedef short               INT16;
100       typedef unsigned char       BOOLEAN;
101       typedef unsigned char       UINT8;
102       typedef char                CHAR8;
103       typedef char                INT8;
104     #else
105       //
106       // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.
107       //
108       typedef unsigned long   UINT64;
109       typedef long            INT64;
110       typedef unsigned int    UINT32;
111       typedef int             INT32;
112       typedef unsigned short  UINT16;
113       typedef unsigned short  CHAR16;
114       typedef short           INT16;
115       typedef unsigned char   BOOLEAN;
116       typedef unsigned char   UINT8;
117       typedef char            CHAR8;
118       typedef char            INT8;
119     #endif
120   #endif
121 
122   #define UINT8_MAX 0xff
123 
124 #else
125   //
126   // Use ANSI C 2000 stdint.h integer width declarations
127   //
128   #include <stdint.h>
129   typedef uint8_t   BOOLEAN;
130   typedef int8_t    INT8;
131   typedef uint8_t   UINT8;
132   typedef int16_t   INT16;
133   typedef uint16_t  UINT16;
134   typedef int32_t   INT32;
135   typedef uint32_t  UINT32;
136   typedef int64_t   INT64;
137   typedef uint64_t  UINT64;
138   typedef char      CHAR8;
139   typedef uint16_t  CHAR16;
140 
141 #endif
142 
143 typedef UINT64  UINTN;
144 typedef INT64   INTN;
145 
146 
147 //
148 // Processor specific defines
149 //
150 #define MAX_BIT     0x8000000000000000ULL
151 #define MAX_2_BITS  0xC000000000000000ULL
152 
153 //
154 // Maximum legal Itanium-based address
155 //
156 #define MAX_ADDRESS   0xFFFFFFFFFFFFFFFFULL
157 
158 //
159 // Modifier to ensure that all protocol member functions and EFI intrinsics
160 // use the correct C calling convention. All protocol member functions and
161 // EFI intrinsics are required to modify thier member functions with EFIAPI.
162 //
163 #if _MSC_EXTENSIONS
164   ///
165   /// Define the standard calling convention reguardless of optimization level.
166   /// __cdecl is Microsoft* specific C extension.
167   ///
168   #define EFIAPI __cdecl
169 #elif __GNUC__
170   ///
171   /// Define the standard calling convention reguardless of optimization level.
172   /// efidecl is an extension to GCC that supports the differnece between x64
173   /// GCC ABI and x64 Microsoft* ABI. EFI is closer to the Microsoft* ABI and
174   /// EFIAPI makes sure the right ABI is used for public interfaces.
175   /// eficecl is a work in progress and we do not yet have the compiler
176   ///
177   #define EFIAPI
178 #else
179   #define EFIAPI
180 #endif
181 
182 //
183 // The Microsoft* C compiler can removed references to unreferenced data items
184 //  if the /OPT:REF linker option is used. We defined a macro as this is a
185 //  a non standard extension
186 //
187 #if _MSC_EXTENSIONS
188   #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)
189 #else
190   #define GLOBAL_REMOVE_IF_UNREFERENCED
191 #endif
192 
193 #endif
194 
195