2 Processor or Compiler specific defines and types for AArch64.
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>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #ifndef __PROCESSOR_BIND_H__
13 #define __PROCESSOR_BIND_H__
16 /// Define the processor type so other code can make processor based choices
18 #define MDE_CPU_AARCH64
21 // Make sure we are using the correct packing rules per EFI specification
23 #if !defined (__GNUC__) && !defined (__ASSEMBLER__)
27 #if defined (_MSC_EXTENSIONS)
30 // Disable some level 4 compilation warnings (same as IA32 and X64)
34 // Disabling bitfield type checking warnings.
36 #pragma warning ( disable : 4214 )
39 // Disabling the unreferenced formal parameter warnings.
41 #pragma warning ( disable : 4100 )
44 // Disable slightly different base types warning as CHAR8 * can not be set
45 // to a constant string.
47 #pragma warning ( disable : 4057 )
50 // ASSERT(FALSE) or while (TRUE) are legal constructs so suppress this warning
52 #pragma warning ( disable : 4127 )
55 // This warning is caused by functions defined but not used. For precompiled header only.
57 #pragma warning ( disable : 4505 )
60 // This warning is caused by empty (after preprocessing) source file. For precompiled header only.
62 #pragma warning ( disable : 4206 )
65 // Disable 'potentially uninitialized local variable X used' warnings
67 #pragma warning ( disable : 4701 )
70 // Disable 'potentially uninitialized local pointer variable X used' warnings
72 #pragma warning ( disable : 4703 )
75 // use Microsoft* C compiler dependent integer width types
77 typedef unsigned __int64 UINT64
;
78 typedef __int64 INT64
;
79 typedef unsigned __int32 UINT32
;
80 typedef __int32 INT32
;
81 typedef unsigned short UINT16
;
82 typedef unsigned short CHAR16
;
84 typedef unsigned char BOOLEAN
;
85 typedef unsigned char UINT8
;
87 typedef signed char INT8
;
92 // Assume standard AARCH64 alignment.
94 typedef unsigned long long UINT64
;
95 typedef long long INT64
;
96 typedef unsigned int UINT32
;
98 typedef unsigned short UINT16
;
99 typedef unsigned short CHAR16
;
101 typedef unsigned char BOOLEAN
;
102 typedef unsigned char UINT8
;
104 typedef signed char INT8
;
109 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
110 /// 8 bytes on supported 64-bit processor instructions)
112 typedef UINT64 UINTN
;
115 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
116 /// 8 bytes on supported 64-bit processor instructions)
121 // Processor specific defines
125 /// A value of native width with the highest bit set.
127 #define MAX_BIT 0x8000000000000000ULL
130 /// A value of native width with the two highest bits set.
132 #define MAX_2_BITS 0xC000000000000000ULL
135 /// Maximum legal AARCH64 address
137 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
140 /// Maximum usable address at boot time (48 bits using 4 KB pages)
142 #define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL
145 /// Maximum legal AArch64 INTN and UINTN values.
147 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
148 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
151 /// Minimum legal AArch64 INTN value.
153 #define MIN_INTN (((INTN)-9223372036854775807LL) - 1)
156 /// The stack alignment required for AARCH64
158 #define CPU_STACK_ALIGNMENT 16
161 /// Page allocation granularity for AARCH64
163 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
164 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x10000)
167 // Modifier to ensure that all protocol member functions and EFI intrinsics
168 // use the correct C calling convention. All protocol member functions and
169 // EFI intrinsics are required to modify their member functions with EFIAPI.
173 // When compiling with Clang, we still use GNU as for the assembler, so we still
174 // need to define the GCC_ASM* macros.
175 #if defined (__GNUC__) || defined (__clang__)
177 /// For GNU assembly code, .global or .globl can declare global symbols.
178 /// Define this macro to unify the usage.
180 #define ASM_GLOBAL .globl
182 #define GCC_ASM_EXPORT(func__) \
183 .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
184 .type ASM_PFX(func__), %function
186 #define GCC_ASM_IMPORT(func__) \
187 .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
192 Return the pointer to the first instruction of a function given a function pointer.
193 On ARM CPU architectures, these two pointer values are the same,
194 so the implementation of this macro is very simple.
196 @param FunctionPointer A pointer to a function.
198 @return The pointer to the first instruction of a function given a function pointer.
201 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
203 #ifndef __USER_LABEL_PREFIX__
204 #define __USER_LABEL_PREFIX__