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