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