MdePkg/ProcessorBind: add defines for page allocation granularity
[mirror_edk2.git] / MdePkg / Include / Arm / ProcessorBind.h
CommitLineData
ebd04fc2 1/** @file\r
2 Processor or Compiler specific defines and types for ARM.\r
3\r
068a82fc 4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
9df063a0
HT
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
6 This program and the accompanying materials \r
ebd04fc2 7 are licensed and made available under the terms and conditions of the BSD License \r
8 which accompanies this distribution. The full text of the license may be found at \r
9 http://opensource.org/licenses/bsd-license.php \r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
13\r
14**/\r
15\r
16#ifndef __PROCESSOR_BIND_H__\r
17#define __PROCESSOR_BIND_H__\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_ARM\r
23\r
24//\r
ea3c1b3a 25// Make sure we are using the correct packing rules per EFI specification\r
ebd04fc2 26//\r
27#ifndef __GNUC__\r
28#pragma pack()\r
29#endif\r
30\r
82df6187
AB
31//\r
32// RVCT does not support the __builtin_unreachable() macro\r
33//\r
34#ifdef __ARMCC_VERSION\r
35#define UNREACHABLE()\r
36#endif\r
37\r
ebd04fc2 38#if _MSC_EXTENSIONS \r
39 //\r
00b7cc0f 40 // use Microsoft* C compiler dependent integer width types\r
ebd04fc2 41 //\r
42 typedef unsigned __int64 UINT64;\r
43 typedef __int64 INT64;\r
44 typedef unsigned __int32 UINT32;\r
45 typedef __int32 INT32;\r
46 typedef unsigned short UINT16;\r
47 typedef unsigned short CHAR16;\r
48 typedef short INT16;\r
49 typedef unsigned char BOOLEAN;\r
50 typedef unsigned char UINT8;\r
51 typedef char CHAR8;\r
d22ebbe3 52 typedef signed char INT8;\r
ebd04fc2 53#else\r
54 //\r
55 // Assume standard ARM alignment. \r
56 // Need to check portability of long long\r
57 //\r
58 typedef unsigned long long UINT64;\r
59 typedef long long INT64;\r
60 typedef unsigned int UINT32;\r
61 typedef int INT32;\r
62 typedef unsigned short UINT16;\r
63 typedef unsigned short CHAR16;\r
64 typedef short INT16;\r
65 typedef unsigned char BOOLEAN;\r
66 typedef unsigned char UINT8;\r
67 typedef char CHAR8;\r
d22ebbe3 68 typedef signed char INT8;\r
ebd04fc2 69#endif\r
70\r
4e094cba 71///\r
72/// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,\r
73/// 8 bytes on supported 64-bit processor instructions)\r
74///\r
ebd04fc2 75typedef UINT32 UINTN;\r
76\r
4e094cba 77///\r
78/// Signed value of native width. (4 bytes on supported 32-bit processor instructions,\r
79/// 8 bytes on supported 64-bit processor instructions)\r
80///\r
ebd04fc2 81typedef INT32 INTN;\r
82\r
83//\r
84// Processor specific defines\r
85//\r
4e094cba 86\r
87///\r
88/// A value of native width with the highest bit set.\r
89///\r
ebd04fc2 90#define MAX_BIT 0x80000000\r
91\r
4e094cba 92///\r
93/// A value of native width with the two highest bits set.\r
94///\r
ebd04fc2 95#define MAX_2_BITS 0xC0000000\r
96\r
97///\r
98/// Maximum legal ARM address\r
99///\r
100#define MAX_ADDRESS 0xFFFFFFFF\r
101\r
068a82fc
LG
102///\r
103/// Maximum legal ARM INTN and UINTN values.\r
104///\r
105#define MAX_INTN ((INTN)0x7FFFFFFF)\r
106#define MAX_UINTN ((UINTN)0xFFFFFFFF)\r
107\r
ebd04fc2 108///\r
109/// The stack alignment required for ARM\r
110///\r
111#define CPU_STACK_ALIGNMENT sizeof(UINT64)\r
112\r
08855193
AB
113///\r
114/// Page allocation granularity for ARM\r
115///\r
116#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)\r
117#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)\r
118\r
ebd04fc2 119//\r
120// Modifier to ensure that all protocol member functions and EFI intrinsics\r
121// use the correct C calling convention. All protocol member functions and\r
ea3c1b3a 122// EFI intrinsics are required to modify their member functions with EFIAPI.\r
ebd04fc2 123//\r
124#define EFIAPI \r
125\r
ba0a34f1
OM
126// When compiling with Clang, we still use GNU as for the assembler, so we still\r
127// need to define the GCC_ASM* macros.\r
128#if defined(__GNUC__) || defined(__clang__)\r
ebd04fc2 129 ///\r
130 /// For GNU assembly code, .global or .globl can declare global symbols.\r
131 /// Define this macro to unify the usage.\r
132 ///\r
133 #define ASM_GLOBAL .globl\r
e7cb469e 134\r
135 #if !defined(__APPLE__)\r
136 ///\r
137 /// ARM EABI defines that the linker should not manipulate call relocations\r
138 /// (do bl/blx conversion) unless the target symbol has function type.\r
139 /// CodeSourcery 2010.09 started requiring the .type to function properly\r
140 ///\r
141 #define INTERWORK_FUNC(func__) .type ASM_PFX(func__), %function\r
4c8a6e06 142\r
143 #define GCC_ASM_EXPORT(func__) \\r
144 .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\\r
145 .type ASM_PFX(func__), %function \r
146\r
147 #define GCC_ASM_IMPORT(func__) \\r
148 .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)\r
149 \r
e7cb469e 150 #else\r
151 //\r
152 // .type not supported by Apple Xcode tools \r
153 //\r
4c8a6e06 154 #define INTERWORK_FUNC(func__) \r
155\r
156 #define GCC_ASM_EXPORT(func__) \\r
157 .globl _CONCATENATE (__USER_LABEL_PREFIX__, func__) \\r
158 \r
6ced2e11 159 #define GCC_ASM_IMPORT(name) \r
4c8a6e06 160\r
e7cb469e 161 #endif\r
ebd04fc2 162#endif\r
163\r
4e094cba 164/**\r
165 Return the pointer to the first instruction of a function given a function pointer.\r
166 On ARM CPU architectures, these two pointer values are the same, \r
167 so the implementation of this macro is very simple.\r
168 \r
169 @param FunctionPointer A pointer to a function.\r
170\r
171 @return The pointer to the first instruction of a function given a function pointer.\r
172 \r
173**/\r
1afe0401 174#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)\r
ebd04fc2 175\r
02eef553
JJ
176#ifndef __USER_LABEL_PREFIX__\r
177#define __USER_LABEL_PREFIX__\r
178#endif\r
179\r
ebd04fc2 180#endif\r
4c8a6e06 181\r
182\r