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