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