]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/Include/Arm/ProcessorBind.h
856d2bd9eff7de2127b6d202342f601e1e9a9ab0
[mirror_edk2.git] / BaseTools / Source / C / Include / Arm / ProcessorBind.h
1 /** @file
2 Processor or Compiler specific defines and types for ARM.
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 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef __PROCESSOR_BIND_H__
17 #define __PROCESSOR_BIND_H__
18
19 ///
20 /// Define the processor type so other code can make processor based choices
21 ///
22 #define MDE_CPU_ARM
23
24 //
25 // Make sure we are using the correct packing rules per EFI specification
26 //
27 #ifndef __GNUC__
28 #pragma pack()
29 #endif
30
31 #if _MSC_EXTENSIONS
32 //
33 // use Microsoft* C complier dependent integer width types
34 //
35 typedef unsigned __int64 UINT64;
36 typedef __int64 INT64;
37 typedef unsigned __int32 UINT32;
38 typedef __int32 INT32;
39 typedef unsigned short UINT16;
40 typedef unsigned short CHAR16;
41 typedef short INT16;
42 typedef unsigned char BOOLEAN;
43 typedef unsigned char UINT8;
44 typedef char CHAR8;
45 typedef signed char INT8;
46 #else
47 //
48 // Assume standard ARM alignment.
49 //
50 typedef unsigned long long UINT64;
51 typedef long long INT64;
52 typedef unsigned int UINT32;
53 typedef int INT32;
54 typedef unsigned short UINT16;
55 typedef unsigned short CHAR16;
56 typedef short INT16;
57 typedef unsigned char BOOLEAN;
58 typedef unsigned char UINT8;
59 typedef char CHAR8;
60 typedef signed char INT8;
61
62 #define UINT8_MAX 0xff
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 UINT32 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 INT32 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 0x80000000
85
86 ///
87 /// A value of native width with the two highest bits set.
88 ///
89 #define MAX_2_BITS 0xC0000000
90
91 ///
92 /// The stack alignment required for ARM
93 ///
94 #define CPU_STACK_ALIGNMENT sizeof(UINT64)
95
96 //
97 // Modifier to ensure that all protocol member functions and EFI intrinsics
98 // use the correct C calling convention. All protocol member functions and
99 // EFI intrinsics are required to modify their member functions with EFIAPI.
100 //
101 #define EFIAPI
102
103 #if defined(__GNUC__)
104 ///
105 /// For GNU assembly code, .global or .globl can declare global symbols.
106 /// Define this macro to unify the usage.
107 ///
108 #define ASM_GLOBAL .globl
109
110 #if !defined(__APPLE__)
111 ///
112 /// ARM EABI defines that the linker should not manipulate call relocations
113 /// (do bl/blx conversion) unless the target symbol has function type.
114 /// CodeSourcery 2010.09 started requiring the .type to function properly
115 ///
116 #define INTERWORK_FUNC(func__) .type ASM_PFX(func__), %function
117
118 #define GCC_ASM_EXPORT(func__) \
119 .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
120 .type ASM_PFX(func__), %function
121
122 #define GCC_ASM_IMPORT(func__) \
123 .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
124
125 #else
126 //
127 // .type not supported by Apple Xcode tools
128 //
129 #define INTERWORK_FUNC(func__)
130
131 #define GCC_ASM_EXPORT(func__) \
132 .globl _CONCATENATE (__USER_LABEL_PREFIX__, func__) \
133
134 #define GCC_ASM_IMPORT(name)
135
136 #endif
137 #endif
138
139 /**
140 Return the pointer to the first instruction of a function given a function pointer.
141 On ARM CPU architectures, these two pointer values are the same,
142 so the implementation of this macro is very simple.
143
144 @param FunctionPointer A pointer to a function.
145
146 @return The pointer to the first instruction of a function given a function pointer.
147
148 **/
149 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
150
151 #endif
152
153