iPXE
ProcessorBind.h
Go to the documentation of this file.
1 /** @file
2  Processor or Compiler specific defines and types for AArch64.
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  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
7 
8  SPDX-License-Identifier: BSD-2-Clause-Patent
9 
10 **/
11 
12 #ifndef __PROCESSOR_BIND_H__
13 #define __PROCESSOR_BIND_H__
14 
15 FILE_LICENCE ( BSD2_PATENT );
16 FILE_SECBOOT ( PERMITTED );
17 
18 ///
19 /// Define the processor type so other code can make processor based choices
20 ///
21 #define MDE_CPU_AARCH64
22 
23 //
24 // Make sure we are using the correct packing rules per EFI specification
25 //
26 #if !defined (__GNUC__) && !defined (__ASSEMBLER__)
27  #pragma pack()
28 #endif
29 
30 #if defined (_MSC_EXTENSIONS)
31 
32 //
33 // Disable some level 4 compilation warnings (same as IA32 and X64)
34 //
35 
36 //
37 // Disabling bitfield type checking warnings.
38 //
39  #pragma warning ( disable : 4214 )
40 
41 //
42 // Disabling the unreferenced formal parameter warnings.
43 //
44  #pragma warning ( disable : 4100 )
45 
46 //
47 // Disable slightly different base types warning as CHAR8 * can not be set
48 // to a constant string.
49 //
50  #pragma warning ( disable : 4057 )
51 
52 //
53 // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
54 //
55  #pragma warning ( disable : 4127 )
56 
57 //
58 // This warning is caused by functions defined but not used. For precompiled header only.
59 //
60  #pragma warning ( disable : 4505 )
61 
62 //
63 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
64 //
65  #pragma warning ( disable : 4206 )
66 
67 //
68 // Disable 'potentially uninitialized local variable X used' warnings
69 //
70  #pragma warning ( disable : 4701 )
71 
72 //
73 // Disable 'potentially uninitialized local pointer variable X used' warnings
74 //
75  #pragma warning ( disable : 4703 )
76 
77 //
78 // use Microsoft* C compiler dependent integer width types
79 //
80 typedef unsigned __int64 UINT64;
81 typedef __int64 INT64;
82 typedef unsigned __int32 UINT32;
83 typedef __int32 INT32;
84 typedef unsigned short UINT16;
85 typedef unsigned short CHAR16;
86 typedef short INT16;
87 typedef unsigned char BOOLEAN;
88 typedef unsigned char UINT8;
89 typedef char CHAR8;
90 typedef signed char INT8;
91 
92 #else
93 
94 //
95 // Assume standard AARCH64 alignment.
96 //
97 typedef unsigned long long UINT64;
98 typedef long long INT64;
99 typedef unsigned int UINT32;
100 typedef int INT32;
101 typedef unsigned short UINT16;
102 typedef unsigned short CHAR16;
103 typedef short INT16;
104 typedef unsigned char BOOLEAN;
105 typedef unsigned char UINT8;
106 typedef char CHAR8;
107 typedef signed char INT8;
108 
109 #endif
110 
111 ///
112 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
113 /// 8 bytes on supported 64-bit processor instructions)
114 ///
115 typedef UINT64 UINTN;
116 
117 ///
118 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
119 /// 8 bytes on supported 64-bit processor instructions)
120 ///
121 typedef INT64 INTN;
122 
123 //
124 // Processor specific defines
125 //
126 
127 ///
128 /// A value of native width with the highest bit set.
129 ///
130 #define MAX_BIT 0x8000000000000000ULL
131 
132 ///
133 /// A value of native width with the two highest bits set.
134 ///
135 #define MAX_2_BITS 0xC000000000000000ULL
136 
137 ///
138 /// Maximum legal AARCH64 address
139 ///
140 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
141 
142 ///
143 /// Maximum usable address at boot time (48 bits using 4 KB pages)
144 ///
145 #define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL
146 
147 ///
148 /// Maximum legal AArch64 INTN and UINTN values.
149 ///
150 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
151 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
152 
153 ///
154 /// Minimum legal AArch64 INTN value.
155 ///
156 #define MIN_INTN (((INTN)-9223372036854775807LL) - 1)
157 
158 ///
159 /// The stack alignment required for AARCH64
160 ///
161 #define CPU_STACK_ALIGNMENT 16
162 
163 ///
164 /// Page allocation granularity for AARCH64
165 ///
166 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
167 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x10000)
168 
169 //
170 // Modifier to ensure that all protocol member functions and EFI intrinsics
171 // use the correct C calling convention. All protocol member functions and
172 // EFI intrinsics are required to modify their member functions with EFIAPI.
173 //
174 #define EFIAPI
175 
176 // When compiling with Clang, we still use GNU as for the assembler, so we still
177 // need to define the GCC_ASM* macros.
178 #if defined (__GNUC__) || defined (__clang__)
179 ///
180 /// For GNU assembly code, .global or .globl can declare global symbols.
181 /// Define this macro to unify the usage.
182 ///
183 #define ASM_GLOBAL .globl
184 
185 #define GCC_ASM_EXPORT(func__) \
186  .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
187  .type ASM_PFX(func__), %function
188 
189 #define GCC_ASM_IMPORT(func__) \
190  .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
191 
192  #if defined (__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
193 #define AARCH64_BTI_NOTE() \
194  .ifndef .Lgnu_bti_notesize ;\
195  .pushsection .note.gnu.property, "a" ;\
196  .set NT_GNU_PROPERTY_TYPE_0, 0x5 ;\
197  .set GNU_PROPERTY_AARCH64_FEATURE_1_AND, 0xc0000000 ;\
198  .set GNU_PROPERTY_AARCH64_FEATURE_1_BTI, 0x1 ;\
199  .align 3 ;\
200  .long .Lnamesize ;\
201  .long .Lgnu_bti_notesize ;\
202  .long NT_GNU_PROPERTY_TYPE_0 ;\
203 0: .asciz "GNU" ;\
204  .set .Lnamesize, . - 0b ;\
205  .align 3 ;\
206 1: .long GNU_PROPERTY_AARCH64_FEATURE_1_AND ;\
207  .long .Lvalsize ;\
208 2: .long GNU_PROPERTY_AARCH64_FEATURE_1_BTI ;\
209  .set .Lvalsize, . - 2b ;\
210  .align 3 ;\
211  .set .Lgnu_bti_notesize, . - 1b ;\
212  .popsection ;\
213  .endif
214 
215 #define AARCH64_BTI(__type) \
216  AARCH64_BTI_NOTE() ;\
217  bti __type
218 
219  #endif
220 
221 #endif
222 
223 #ifndef AARCH64_BTI
224 #define AARCH64_BTI_NOTE()
225 #define AARCH64_BTI(__type)
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
int INT32
FILE_SECBOOT(PERMITTED)
unsigned char BOOLEAN
INT64 INTN
Signed value of native width.
unsigned int UINT32
Definition: ProcessorBind.h:99
unsigned short CHAR16
unsigned char UINT8
long long INT64
Definition: ProcessorBind.h:98
short INT16
unsigned short UINT16
UINT64 UINTN
Unsigned value of native width.
unsigned long long UINT64
Definition: ProcessorBind.h:97
FILE_LICENCE(BSD2_PATENT)
char CHAR8
signed char INT8