]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Arm/ProcessorBind.h
MdePkg/Base: introduce MAX_ALLOC_ADDRESS
[mirror_edk2.git] / MdePkg / Include / Arm / ProcessorBind.h
1 /** @file
2 Processor or Compiler specific defines and types for ARM.
3
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this 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_ARM
23
24 //
25 // Make sure we are using the correct packing rules per EFI specification
26 //
27 #if !defined(__GNUC__) && !defined(__ASSEMBLER__)
28 #pragma pack()
29 #endif
30
31 #if defined(_MSC_EXTENSIONS)
32
33 //
34 // Disable some level 4 compilation warnings (same as IA32 and X64)
35 //
36
37 //
38 // Disabling bitfield type checking warnings.
39 //
40 #pragma warning ( disable : 4214 )
41
42 //
43 // Disabling the unreferenced formal parameter warnings.
44 //
45 #pragma warning ( disable : 4100 )
46
47 //
48 // Disable slightly different base types warning as CHAR8 * can not be set
49 // to a constant string.
50 //
51 #pragma warning ( disable : 4057 )
52
53 //
54 // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
55 //
56 #pragma warning ( disable : 4127 )
57
58 //
59 // This warning is caused by functions defined but not used. For precompiled header only.
60 //
61 #pragma warning ( disable : 4505 )
62
63 //
64 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
65 //
66 #pragma warning ( disable : 4206 )
67
68 //
69 // Disable 'potentially uninitialized local variable X used' warnings
70 //
71 #pragma warning ( disable : 4701 )
72
73 //
74 // Disable 'potentially uninitialized local pointer variable X used' warnings
75 //
76 #pragma warning ( disable : 4703 )
77
78 #endif
79
80 //
81 // RVCT and MSFT don't support the __builtin_unreachable() macro
82 //
83 #if defined(__ARMCC_VERSION) || defined(_MSC_EXTENSIONS)
84 #define UNREACHABLE()
85 #endif
86
87 #if defined(_MSC_EXTENSIONS)
88 //
89 // use Microsoft* C compiler dependent integer width types
90 //
91 typedef unsigned __int64 UINT64;
92 typedef __int64 INT64;
93 typedef unsigned __int32 UINT32;
94 typedef __int32 INT32;
95 typedef unsigned short UINT16;
96 typedef unsigned short CHAR16;
97 typedef short INT16;
98 typedef unsigned char BOOLEAN;
99 typedef unsigned char UINT8;
100 typedef char CHAR8;
101 typedef signed char INT8;
102 #else
103 //
104 // Assume standard ARM alignment.
105 // Need to check portability of long long
106 //
107 typedef unsigned long long UINT64;
108 typedef long long INT64;
109 typedef unsigned int UINT32;
110 typedef int INT32;
111 typedef unsigned short UINT16;
112 typedef unsigned short CHAR16;
113 typedef short INT16;
114 typedef unsigned char BOOLEAN;
115 typedef unsigned char UINT8;
116 typedef char CHAR8;
117 typedef signed char INT8;
118 #endif
119
120 ///
121 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
122 /// 8 bytes on supported 64-bit processor instructions)
123 ///
124 typedef UINT32 UINTN;
125
126 ///
127 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
128 /// 8 bytes on supported 64-bit processor instructions)
129 ///
130 typedef INT32 INTN;
131
132 //
133 // Processor specific defines
134 //
135
136 ///
137 /// A value of native width with the highest bit set.
138 ///
139 #define MAX_BIT 0x80000000
140
141 ///
142 /// A value of native width with the two highest bits set.
143 ///
144 #define MAX_2_BITS 0xC0000000
145
146 ///
147 /// Maximum legal ARM address
148 ///
149 #define MAX_ADDRESS 0xFFFFFFFF
150
151 ///
152 /// Maximum usable address at boot time
153 ///
154 #define MAX_ALLOC_ADDRESS MAX_ALLOC_ADDRESS
155
156 ///
157 /// Maximum legal ARM INTN and UINTN values.
158 ///
159 #define MAX_INTN ((INTN)0x7FFFFFFF)
160 #define MAX_UINTN ((UINTN)0xFFFFFFFF)
161
162 ///
163 /// Minimum legal ARM INTN value.
164 ///
165 #define MIN_INTN (((INTN)-2147483647) - 1)
166
167 ///
168 /// The stack alignment required for ARM
169 ///
170 #define CPU_STACK_ALIGNMENT sizeof(UINT64)
171
172 ///
173 /// Page allocation granularity for ARM
174 ///
175 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
176 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
177
178 //
179 // Modifier to ensure that all protocol member functions and EFI intrinsics
180 // use the correct C calling convention. All protocol member functions and
181 // EFI intrinsics are required to modify their member functions with EFIAPI.
182 //
183 #define EFIAPI
184
185 // When compiling with Clang, we still use GNU as for the assembler, so we still
186 // need to define the GCC_ASM* macros.
187 #if defined(__GNUC__) || defined(__clang__)
188 ///
189 /// For GNU assembly code, .global or .globl can declare global symbols.
190 /// Define this macro to unify the usage.
191 ///
192 #define ASM_GLOBAL .globl
193
194 #if !defined(__APPLE__)
195 ///
196 /// ARM EABI defines that the linker should not manipulate call relocations
197 /// (do bl/blx conversion) unless the target symbol has function type.
198 /// CodeSourcery 2010.09 started requiring the .type to function properly
199 ///
200 #define INTERWORK_FUNC(func__) .type ASM_PFX(func__), %function
201
202 #define GCC_ASM_EXPORT(func__) \
203 .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
204 .type ASM_PFX(func__), %function
205
206 #define GCC_ASM_IMPORT(func__) \
207 .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
208
209 #else
210 //
211 // .type not supported by Apple Xcode tools
212 //
213 #define INTERWORK_FUNC(func__)
214
215 #define GCC_ASM_EXPORT(func__) \
216 .globl _CONCATENATE (__USER_LABEL_PREFIX__, func__) \
217
218 #define GCC_ASM_IMPORT(name)
219
220 #endif
221 #elif defined(_MSC_EXTENSIONS)
222 //
223 // PRESERVE8 is not supported by the MSFT assembler.
224 //
225 #define PRESERVE8
226 #endif
227
228 /**
229 Return the pointer to the first instruction of a function given a function pointer.
230 On ARM CPU architectures, these two pointer values are the same,
231 so the implementation of this macro is very simple.
232
233 @param FunctionPointer A pointer to a function.
234
235 @return The pointer to the first instruction of a function given a function pointer.
236
237 **/
238 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
239
240 #ifndef __USER_LABEL_PREFIX__
241 #define __USER_LABEL_PREFIX__
242 #endif
243
244 #endif
245
246