MdePkg/ProcessorBind: add defines for page allocation granularity
[mirror_edk2.git] / MdePkg / Include / Ipf / ProcessorBind.h
CommitLineData
959ccb23 1/** @file\r
1a2f870c 2 Processor or Compiler specific defines and types for Intel Itanium(TM) processors.\r
959ccb23 3\r
068a82fc 4Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
809bd7b3 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
959ccb23 9\r
809bd7b3 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
959ccb23 12\r
959ccb23 13**/\r
14\r
15#ifndef __PROCESSOR_BIND_H__\r
16#define __PROCESSOR_BIND_H__\r
17\r
18\r
fb5148a0 19///\r
809bd7b3 20/// Define the processor type so other code can make processor-based choices.\r
fb5148a0 21///\r
959ccb23 22#define MDE_CPU_IPF\r
23\r
24\r
25//\r
3963c4bf 26// Make sure we are using the correct packing rules per EFI specification\r
959ccb23 27//\r
28#pragma pack()\r
29\r
30\r
5cfbd055 31#if defined(__INTEL_COMPILER)\r
1fb24cc4 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
46913d4d 38//\r
b483e395
A
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
46913d4d 41//\r
42#pragma warning ( disable : 1418 )\r
43\r
46913d4d 44//\r
b483e395
A
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
46913d4d 47//\r
48#pragma warning ( disable : 1419 )\r
49\r
8fe69f13 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
46913d4d 56#endif\r
57\r
b483e395 58\r
5cfbd055 59#if defined(_MSC_EXTENSIONS)\r
b483e395
A
60//\r
61// Disable warning that make it impossible to compile at /W4\r
f4ec40ab 62// This only works for Microsoft* tools\r
b483e395
A
63//\r
64\r
959ccb23 65//\r
66// Disabling bitfield type checking warnings.\r
67//\r
68#pragma warning ( disable : 4214 )\r
69\r
f4ec40ab 70//\r
959ccb23 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
00b7cc0f 87// ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning\r
959ccb23 88//\r
89#pragma warning ( disable : 4127 )\r
90\r
91//\r
bf3179d8 92// Can not cast a function pointer to a data pointer. We need to do this on\r
1a2f870c 93// Itanium processors to get access to the PLABEL.\r
959ccb23 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
3963c4bf 103// This warning is caused by empty (after preprocessing) source file. For precompiled header only.\r
959ccb23 104//\r
105#pragma warning ( disable : 4206 )\r
106\r
107#endif\r
108\r
52aa9e13 109#if defined(_MSC_EXTENSIONS)\r
959ccb23 110 //\r
52aa9e13 111 // use Microsoft C compiler dependent integer width types\r
959ccb23 112 //\r
f4ec40ab 113\r
52aa9e13 114 ///\r
809bd7b3 115 /// 8-byte unsigned value.\r
52aa9e13
EB
116 ///\r
117 typedef unsigned __int64 UINT64;\r
118 ///\r
809bd7b3 119 /// 8-byte signed value.\r
52aa9e13
EB
120 ///\r
121 typedef __int64 INT64;\r
122 ///\r
809bd7b3 123 /// 4-byte unsigned value.\r
52aa9e13
EB
124 ///\r
125 typedef unsigned __int32 UINT32;\r
126 ///\r
809bd7b3 127 /// 4-byte signed value.\r
52aa9e13
EB
128 ///\r
129 typedef __int32 INT32;\r
130 ///\r
809bd7b3 131 /// 2-byte unsigned value.\r
52aa9e13
EB
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
809bd7b3 140 /// 2-byte signed value.\r
52aa9e13
EB
141 ///\r
142 typedef short INT16;\r
f4ec40ab 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
52aa9e13
EB
147 typedef unsigned char BOOLEAN;\r
148 ///\r
809bd7b3 149 /// 1-byte unsigned value.\r
52aa9e13
EB
150 ///\r
151 typedef unsigned char UINT8;\r
152 ///\r
809bd7b3 153 /// 1-byte Character.\r
52aa9e13
EB
154 ///\r
155 typedef char CHAR8;\r
f4ec40ab 156 ///\r
809bd7b3 157 /// 1-byte signed value.\r
f4ec40ab 158 ///\r
d22ebbe3 159 typedef signed char INT8;\r
52aa9e13 160#else\r
f4ec40ab 161 ///\r
809bd7b3 162 /// 8-byte unsigned value.\r
f4ec40ab 163 ///\r
52aa9e13 164 typedef unsigned long long UINT64;\r
f4ec40ab 165 ///\r
809bd7b3 166 /// 8-byte signed value.\r
f4ec40ab 167 ///\r
52aa9e13 168 typedef long long INT64;\r
f4ec40ab 169 ///\r
809bd7b3 170 /// 4-byte unsigned value.\r
f4ec40ab 171 ///\r
52aa9e13 172 typedef unsigned int UINT32;\r
f4ec40ab 173 ///\r
809bd7b3 174 /// 4-byte signed value.\r
f4ec40ab 175 ///\r
52aa9e13 176 typedef int INT32;\r
f4ec40ab 177 ///\r
809bd7b3 178 /// 2-byte unsigned value.\r
f4ec40ab 179 ///\r
52aa9e13 180 typedef unsigned short UINT16;\r
f4ec40ab 181 ///\r
52aa9e13
EB
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
f4ec40ab 184 ///\r
52aa9e13 185 typedef unsigned short CHAR16;\r
f4ec40ab 186 ///\r
809bd7b3 187 /// 2-byte signed value.\r
52aa9e13
EB
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
f4ec40ab 193 ///\r
52aa9e13
EB
194 typedef unsigned char BOOLEAN;\r
195 ///\r
809bd7b3 196 /// 1-byte unsigned value.\r
52aa9e13
EB
197 ///\r
198 typedef unsigned char UINT8;\r
f4ec40ab 199 ///\r
809bd7b3 200 /// 1-byte Character.\r
f4ec40ab 201 ///\r
52aa9e13 202 typedef char CHAR8;\r
f4ec40ab 203 ///\r
809bd7b3 204 /// 1-byte signed value.\r
f4ec40ab 205 ///\r
d22ebbe3 206 typedef signed char INT8;\r
959ccb23 207#endif\r
208\r
f4ec40ab 209///\r
809bd7b3 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
f4ec40ab 212///\r
959ccb23 213typedef UINT64 UINTN;\r
f4ec40ab 214///\r
809bd7b3 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
f4ec40ab 217///\r
959ccb23 218typedef INT64 INTN;\r
219\r
220\r
221//\r
222// Processor specific defines\r
223//\r
f4ec40ab 224\r
225///\r
226/// A value of native width with the highest bit set.\r
227///\r
959ccb23 228#define MAX_BIT 0x8000000000000000ULL\r
f4ec40ab 229///\r
230/// A value of native width with the two highest bits set.\r
231///\r
959ccb23 232#define MAX_2_BITS 0xC000000000000000ULL\r
233\r
f4ec40ab 234///\r
809bd7b3 235/// The maximum legal Itanium-based address\r
f4ec40ab 236///\r
959ccb23 237#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL\r
238\r
068a82fc
LG
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
f4ec40ab 245///\r
246/// Per the Itanium Software Conventions and Runtime Architecture Guide,\r
247/// section 3.3.4, IPF stack must always be 16-byte aligned.\r
248///\r
959ccb23 249#define CPU_STACK_ALIGNMENT 16\r
250\r
08855193
AB
251///\r
252/// Page allocation granularity for Itanium\r
253///\r
254#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)\r
255#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x2000)\r
256\r
959ccb23 257//\r
258// Modifier to ensure that all protocol member functions and EFI intrinsics\r
259// use the correct C calling convention. All protocol member functions and\r
3963c4bf 260// EFI intrinsics are required to modify their member functions with EFIAPI.\r
959ccb23 261//\r
6149e6bb 262#ifdef EFIAPI\r
263 ///\r
264 /// If EFIAPI is already defined, then we use that definition.\r
265 ///\r
266#elif defined(_MSC_EXTENSIONS)\r
f4ec40ab 267 ///\r
809bd7b3 268 /// Microsoft* compiler-specific method for EFIAPI calling convention.\r
f4ec40ab 269 /// \r
bf3179d8 270 #define EFIAPI __cdecl\r
959ccb23 271#else\r
bf3179d8 272 #define EFIAPI\r
959ccb23 273#endif\r
274\r
68167fed 275///\r
276/// For GNU assembly code, .global or .globl can declare global symbols.\r
277/// Define this macro to unify the usage.\r
278///\r
279#define ASM_GLOBAL .globl\r
280\r
fb5148a0 281///\r
282/// A pointer to a function in IPF points to a plabel.\r
283///\r
959ccb23 284typedef struct {\r
285 UINT64 EntryPoint;\r
286 UINT64 GP;\r
287} EFI_PLABEL;\r
288\r
f4ec40ab 289///\r
290/// PAL Call return structure.\r
291///\r
842f5579
A
292typedef struct {\r
293 UINT64 Status;\r
294 UINT64 r9;\r
295 UINT64 r10;\r
296 UINT64 r11;\r
297} PAL_CALL_RETURN;\r
298\r
14996c96
LG
299/**\r
300 Return the pointer to the first instruction of a function given a function pointer.\r
1a2f870c 301 For Itanium processors, all function calls are made through a PLABEL, so a pointer to a function \r
14996c96
LG
302 is actually a pointer to a PLABEL. The pointer to the first instruction of the function \r
303 is contained within the PLABEL. This macro may be used to retrieve a pointer to the first \r
304 instruction of a function independent of the CPU architecture being used. This is very \r
305 useful when printing function addresses through DEBUG() macros.\r
306 \r
3963c4bf 307 @param FunctionPointer A pointer to a function.\r
14996c96
LG
308\r
309 @return The pointer to the first instruction of a function given a function pointer.\r
3963c4bf 310 \r
14996c96 311**/\r
9a1d00cb 312#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(((EFI_PLABEL *)(FunctionPointer))->EntryPoint)\r
24a7505c 313\r
02eef553
JJ
314#ifndef __USER_LABEL_PREFIX__\r
315#define __USER_LABEL_PREFIX__\r
316#endif\r
317\r
959ccb23 318#endif\r
319\r