]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdePkg/Include/Ipf/ProcessorBind.h
MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance
[mirror_edk2.git] / MdePkg / Include / Ipf / ProcessorBind.h
... / ...
CommitLineData
1/** @file\r
2 Processor or Compiler specific defines and types for Intel Itanium(TM) processors.\r
3\r
4Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials are licensed and made available \r
6under the terms and conditions of the BSD License which accompanies this\r
7distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php.\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __PROCESSOR_BIND_H__\r
16#define __PROCESSOR_BIND_H__\r
17\r
18\r
19///\r
20/// Define the processor type so other code can make processor-based choices.\r
21///\r
22#define MDE_CPU_IPF\r
23\r
24\r
25//\r
26// Make sure we are using the correct packing rules per EFI specification\r
27//\r
28#pragma pack()\r
29\r
30\r
31#if defined(__INTEL_COMPILER)\r
32//\r
33// Disable ICC's remark #869: "Parameter" was never referenced warning.\r
34// This is legal ANSI C code so we disable the remark that is turned on with -Wall\r
35//\r
36#pragma warning ( disable : 869 )\r
37\r
38//\r
39// Disable ICC's remark #1418: external function definition with no prior declaration.\r
40// This is legal ANSI C code so we disable the remark that is turned on with /W4\r
41//\r
42#pragma warning ( disable : 1418 )\r
43\r
44//\r
45// Disable ICC's remark #1419: external declaration in primary source file\r
46// This is legal ANSI C code so we disable the remark that is turned on with /W4\r
47//\r
48#pragma warning ( disable : 1419 )\r
49\r
50//\r
51// Disable ICC's remark #593: "Variable" was set but never used.\r
52// This is legal ANSI C code so we disable the remark that is turned on with /W4\r
53//\r
54#pragma warning ( disable : 593 )\r
55\r
56#endif\r
57\r
58\r
59#if defined(_MSC_EXTENSIONS)\r
60//\r
61// Disable warning that make it impossible to compile at /W4\r
62// This only works for Microsoft* tools\r
63//\r
64\r
65//\r
66// Disabling bitfield type checking warnings.\r
67//\r
68#pragma warning ( disable : 4214 )\r
69\r
70//\r
71// Disabling the unreferenced formal parameter warnings.\r
72//\r
73#pragma warning ( disable : 4100 )\r
74\r
75//\r
76// Disable slightly different base types warning as CHAR8 * can not be set\r
77// to a constant string.\r
78//\r
79#pragma warning ( disable : 4057 )\r
80\r
81//\r
82// Disable warning on conversion from function pointer to a data pointer\r
83//\r
84#pragma warning ( disable : 4054 )\r
85\r
86//\r
87// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning\r
88//\r
89#pragma warning ( disable : 4127 )\r
90\r
91//\r
92// Can not cast a function pointer to a data pointer. We need to do this on\r
93// Itanium processors to get access to the PLABEL.\r
94//\r
95#pragma warning ( disable : 4514 )\r
96\r
97//\r
98// This warning is caused by functions defined but not used. For precompiled header only.\r
99//\r
100#pragma warning ( disable : 4505 )\r
101\r
102//\r
103// This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r
104//\r
105#pragma warning ( disable : 4206 )\r
106\r
107#endif\r
108\r
109#if defined(_MSC_EXTENSIONS)\r
110 //\r
111 // use Microsoft C compiler dependent integer width types\r
112 //\r
113\r
114 ///\r
115 /// 8-byte unsigned value.\r
116 ///\r
117 typedef unsigned __int64 UINT64;\r
118 ///\r
119 /// 8-byte signed value.\r
120 ///\r
121 typedef __int64 INT64;\r
122 ///\r
123 /// 4-byte unsigned value.\r
124 ///\r
125 typedef unsigned __int32 UINT32;\r
126 ///\r
127 /// 4-byte signed value.\r
128 ///\r
129 typedef __int32 INT32;\r
130 ///\r
131 /// 2-byte unsigned value.\r
132 ///\r
133 typedef unsigned short UINT16;\r
134 ///\r
135 /// 2-byte Character. Unless otherwise specified all strings are stored in the\r
136 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
137 ///\r
138 typedef unsigned short CHAR16;\r
139 ///\r
140 /// 2-byte signed value.\r
141 ///\r
142 typedef short INT16;\r
143 ///\r
144 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r
145 /// values are undefined.\r
146 ///\r
147 typedef unsigned char BOOLEAN;\r
148 ///\r
149 /// 1-byte unsigned value.\r
150 ///\r
151 typedef unsigned char UINT8;\r
152 ///\r
153 /// 1-byte Character.\r
154 ///\r
155 typedef char CHAR8;\r
156 ///\r
157 /// 1-byte signed value.\r
158 ///\r
159 typedef signed char INT8;\r
160#else\r
161 ///\r
162 /// 8-byte unsigned value.\r
163 ///\r
164 typedef unsigned long long UINT64;\r
165 ///\r
166 /// 8-byte signed value.\r
167 ///\r
168 typedef long long INT64;\r
169 ///\r
170 /// 4-byte unsigned value.\r
171 ///\r
172 typedef unsigned int UINT32;\r
173 ///\r
174 /// 4-byte signed value.\r
175 ///\r
176 typedef int INT32;\r
177 ///\r
178 /// 2-byte unsigned value.\r
179 ///\r
180 typedef unsigned short UINT16;\r
181 ///\r
182 /// 2-byte Character. Unless otherwise specified all strings are stored in the\r
183 /// UTF-16 encoding format as defined by Unicode 2.1 and ISO/IEC 10646 standards.\r
184 ///\r
185 typedef unsigned short CHAR16;\r
186 ///\r
187 /// 2-byte signed value.\r
188 ///\r
189 typedef short INT16;\r
190 ///\r
191 /// Logical Boolean. 1-byte value containing 0 for FALSE or a 1 for TRUE. Other\r
192 /// values are undefined.\r
193 ///\r
194 typedef unsigned char BOOLEAN;\r
195 ///\r
196 /// 1-byte unsigned value.\r
197 ///\r
198 typedef unsigned char UINT8;\r
199 ///\r
200 /// 1-byte Character.\r
201 ///\r
202 typedef char CHAR8;\r
203 ///\r
204 /// 1-byte signed value.\r
205 ///\r
206 typedef signed char INT8;\r
207#endif\r
208\r
209///\r
210/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions;\r
211/// 8 bytes on supported 64-bit processor instructions.)\r
212///\r
213typedef UINT64 UINTN;\r
214///\r
215/// Signed value of native width. (4 bytes on supported 32-bit processor instructions;\r
216/// 8 bytes on supported 64-bit processor instructions.)\r
217///\r
218typedef INT64 INTN;\r
219\r
220\r
221//\r
222// Processor specific defines\r
223//\r
224\r
225///\r
226/// A value of native width with the highest bit set.\r
227///\r
228#define MAX_BIT 0x8000000000000000ULL\r
229///\r
230/// A value of native width with the two highest bits set.\r
231///\r
232#define MAX_2_BITS 0xC000000000000000ULL\r
233\r
234///\r
235/// The maximum legal Itanium-based address\r
236///\r
237#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r
238\r
239///\r
240/// Maximum legal Itanium-based INTN and UINTN values.\r
241///\r
242#define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)\r
243#define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)\r
244\r
245///\r
246/// Minimum legal Itanium-based INTN value.\r
247///\r
248#define MIN_INTN (((INTN)-9223372036854775807LL) - 1)\r
249\r
250///\r
251/// Per the Itanium Software Conventions and Runtime Architecture Guide,\r
252/// section 3.3.4, IPF stack must always be 16-byte aligned.\r
253///\r
254#define CPU_STACK_ALIGNMENT 16\r
255\r
256///\r
257/// Page allocation granularity for Itanium\r
258///\r
259#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)\r
260#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x2000)\r
261\r
262//\r
263// Modifier to ensure that all protocol member functions and EFI intrinsics\r
264// use the correct C calling convention. All protocol member functions and\r
265// EFI intrinsics are required to modify their member functions with EFIAPI.\r
266//\r
267#ifdef EFIAPI\r
268 ///\r
269 /// If EFIAPI is already defined, then we use that definition.\r
270 ///\r
271#elif defined(_MSC_EXTENSIONS)\r
272 ///\r
273 /// Microsoft* compiler-specific method for EFIAPI calling convention.\r
274 /// \r
275 #define EFIAPI __cdecl\r
276#else\r
277 #define EFIAPI\r
278#endif\r
279\r
280///\r
281/// For GNU assembly code, .global or .globl can declare global symbols.\r
282/// Define this macro to unify the usage.\r
283///\r
284#define ASM_GLOBAL .globl\r
285\r
286///\r
287/// A pointer to a function in IPF points to a plabel.\r
288///\r
289typedef struct {\r
290 UINT64 EntryPoint;\r
291 UINT64 GP;\r
292} EFI_PLABEL;\r
293\r
294///\r
295/// PAL Call return structure.\r
296///\r
297typedef struct {\r
298 UINT64 Status;\r
299 UINT64 r9;\r
300 UINT64 r10;\r
301 UINT64 r11;\r
302} PAL_CALL_RETURN;\r
303\r
304/**\r
305 Return the pointer to the first instruction of a function given a function pointer.\r
306 For Itanium processors, all function calls are made through a PLABEL, so a pointer to a function \r
307 is actually a pointer to a PLABEL. The pointer to the first instruction of the function \r
308 is contained within the PLABEL. This macro may be used to retrieve a pointer to the first \r
309 instruction of a function independent of the CPU architecture being used. This is very \r
310 useful when printing function addresses through DEBUG() macros.\r
311 \r
312 @param FunctionPointer A pointer to a function.\r
313\r
314 @return The pointer to the first instruction of a function given a function pointer.\r
315 \r
316**/\r
317#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(((EFI_PLABEL *)(FunctionPointer))->EntryPoint)\r
318\r
319#ifndef __USER_LABEL_PREFIX__\r
320#define __USER_LABEL_PREFIX__\r
321#endif\r
322\r
323#endif\r
324\r