]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/AArch64/ProcessorBind.h
MdePkg/BaseSafeIntLib: Add SafeIntLib class and instance
[mirror_edk2.git] / MdePkg / Include / AArch64 / ProcessorBind.h
1 /** @file
2 Processor or Compiler specific defines and types for AArch64.
3
4 Copyright (c) 2006 - 2017, 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 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __PROCESSOR_BIND_H__
19 #define __PROCESSOR_BIND_H__
20
21 ///
22 /// Define the processor type so other code can make processor based choices
23 ///
24 #define MDE_CPU_AARCH64
25
26 //
27 // Make sure we are using the correct packing rules per EFI specification
28 //
29 #if !defined(__GNUC__) && !defined(__ASSEMBLER__)
30 #pragma pack()
31 #endif
32
33 #if _MSC_EXTENSIONS
34 //
35 // use Microsoft* C compiler dependent integer width types
36 //
37 typedef unsigned __int64 UINT64;
38 typedef __int64 INT64;
39 typedef unsigned __int32 UINT32;
40 typedef __int32 INT32;
41 typedef unsigned short UINT16;
42 typedef unsigned short CHAR16;
43 typedef short INT16;
44 typedef unsigned char BOOLEAN;
45 typedef unsigned char UINT8;
46 typedef char CHAR8;
47 typedef signed char INT8;
48 #else
49 //
50 // Assume standard AARCH64 alignment.
51 //
52 typedef unsigned long long UINT64;
53 typedef long long INT64;
54 typedef unsigned int UINT32;
55 typedef int INT32;
56 typedef unsigned short UINT16;
57 typedef unsigned short CHAR16;
58 typedef short INT16;
59 typedef unsigned char BOOLEAN;
60 typedef unsigned char UINT8;
61 typedef char CHAR8;
62 typedef signed char INT8;
63 #endif
64
65 ///
66 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
67 /// 8 bytes on supported 64-bit processor instructions)
68 ///
69 typedef UINT64 UINTN;
70
71 ///
72 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
73 /// 8 bytes on supported 64-bit processor instructions)
74 ///
75 typedef INT64 INTN;
76
77 //
78 // Processor specific defines
79 //
80
81 ///
82 /// A value of native width with the highest bit set.
83 ///
84 #define MAX_BIT 0x8000000000000000ULL
85
86 ///
87 /// A value of native width with the two highest bits set.
88 ///
89 #define MAX_2_BITS 0xC000000000000000ULL
90
91 ///
92 /// Maximum legal AARCH64 address
93 ///
94 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL
95
96 ///
97 /// Maximum legal AArch64 INTN and UINTN values.
98 ///
99 #define MAX_INTN ((INTN)0x7FFFFFFFFFFFFFFFULL)
100 #define MAX_UINTN ((UINTN)0xFFFFFFFFFFFFFFFFULL)
101
102 ///
103 /// Minimum legal AArch64 INTN value.
104 ///
105 #define MIN_INTN (((INTN)-9223372036854775807LL) - 1)
106
107 ///
108 /// The stack alignment required for AARCH64
109 ///
110 #define CPU_STACK_ALIGNMENT 16
111
112 ///
113 /// Page allocation granularity for AARCH64
114 ///
115 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
116 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x10000)
117
118 //
119 // Modifier to ensure that all protocol member functions and EFI intrinsics
120 // use the correct C calling convention. All protocol member functions and
121 // EFI intrinsics are required to modify their member functions with EFIAPI.
122 //
123 #define EFIAPI
124
125 // When compiling with Clang, we still use GNU as for the assembler, so we still
126 // need to define the GCC_ASM* macros.
127 #if defined(__GNUC__) || defined(__clang__)
128 ///
129 /// For GNU assembly code, .global or .globl can declare global symbols.
130 /// Define this macro to unify the usage.
131 ///
132 #define ASM_GLOBAL .globl
133
134 #define GCC_ASM_EXPORT(func__) \
135 .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
136 .type ASM_PFX(func__), %function
137
138 #define GCC_ASM_IMPORT(func__) \
139 .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
140
141 #endif
142
143 /**
144 Return the pointer to the first instruction of a function given a function pointer.
145 On ARM CPU architectures, these two pointer values are the same,
146 so the implementation of this macro is very simple.
147
148 @param FunctionPointer A pointer to a function.
149
150 @return The pointer to the first instruction of a function given a function pointer.
151
152 **/
153 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
154
155 #ifndef __USER_LABEL_PREFIX__
156 #define __USER_LABEL_PREFIX__
157 #endif
158
159 #endif