]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Include/AArch64/ProcessorBind.h
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / C / Include / AArch64 / ProcessorBind.h
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) 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 ///
16 /// Define the processor type so other code can make processor based choices
17 ///
18 #define MDE_CPU_AARCH64
19
20 //
21 // Make sure we are using the correct packing rules per EFI specification
22 //
23 #ifndef __GNUC__
24 #pragma pack()
25 #endif
26
27 #if _MSC_EXTENSIONS
28 //
29 // use Microsoft* C compiler dependent integer width types
30 //
31 typedef unsigned __int64 UINT64;
32 typedef __int64 INT64;
33 typedef unsigned __int32 UINT32;
34 typedef __int32 INT32;
35 typedef unsigned short UINT16;
36 typedef unsigned short CHAR16;
37 typedef short INT16;
38 typedef unsigned char BOOLEAN;
39 typedef unsigned char UINT8;
40 typedef char CHAR8;
41 typedef signed char INT8;
42 #else
43 //
44 // Assume standard AARCH64 alignment.
45 //
46 typedef unsigned long long UINT64;
47 typedef long long INT64;
48 typedef unsigned int UINT32;
49 typedef int INT32;
50 typedef unsigned short UINT16;
51 typedef unsigned short CHAR16;
52 typedef short INT16;
53 typedef unsigned char BOOLEAN;
54 typedef unsigned char UINT8;
55 typedef char CHAR8;
56 typedef signed char INT8;
57
58 #define UINT8_MAX 0xff
59 #endif
60
61 ///
62 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
63 /// 8 bytes on supported 64-bit processor instructions)
64 ///
65 typedef UINT64 UINTN;
66
67 ///
68 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
69 /// 8 bytes on supported 64-bit processor instructions)
70 ///
71 typedef INT64 INTN;
72
73 //
74 // Processor specific defines
75 //
76
77 ///
78 /// A value of native width with the highest bit set.
79 ///
80 #define MAX_BIT 0x8000000000000000
81
82 ///
83 /// A value of native width with the two highest bits set.
84 ///
85 #define MAX_2_BITS 0xC000000000000000
86
87 ///
88 /// The stack alignment required for AARCH64
89 ///
90 #define CPU_STACK_ALIGNMENT 16
91
92 //
93 // Modifier to ensure that all protocol member functions and EFI intrinsics
94 // use the correct C calling convention. All protocol member functions and
95 // EFI intrinsics are required to modify their member functions with EFIAPI.
96 //
97 #define EFIAPI
98
99 #if defined(__GNUC__)
100 ///
101 /// For GNU assembly code, .global or .globl can declare global symbols.
102 /// Define this macro to unify the usage.
103 ///
104 #define ASM_GLOBAL .globl
105
106 #if !defined(__APPLE__)
107 ///
108 /// ARM EABI defines that the linker should not manipulate call relocations
109 /// (do bl/blx conversion) unless the target symbol has function type.
110 /// CodeSourcery 2010.09 started requiring the .type to function properly
111 ///
112 #define INTERWORK_FUNC(func__) .type ASM_PFX(func__), %function
113
114 #define GCC_ASM_EXPORT(func__) \
115 .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
116 .type ASM_PFX(func__), %function
117
118 #define GCC_ASM_IMPORT(func__) \
119 .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
120
121 #else
122 //
123 // .type not supported by Apple Xcode tools
124 //
125 #define INTERWORK_FUNC(func__)
126
127 #define GCC_ASM_EXPORT(func__) \
128 .globl _CONCATENATE (__USER_LABEL_PREFIX__, func__) \
129
130 #define GCC_ASM_IMPORT(name)
131
132 #endif
133 #endif
134
135 /**
136 Return the pointer to the first instruction of a function given a function pointer.
137 On ARM CPU architectures, these two pointer values are the same,
138 so the implementation of this macro is very simple.
139
140 @param FunctionPointer A pointer to a function.
141
142 @return The pointer to the first instruction of a function given a function pointer.
143
144 **/
145 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
146
147 #endif
148