iPXE
ProcessorBind.h
Go to the documentation of this file.
1 /** @file
2  Processor or Compiler specific defines and types for ARM.
3 
4  Copyright (c) 2006 - 2013, 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 FILE_LICENCE ( BSD3 );
20 
21 ///
22 /// Define the processor type so other code can make processor based choices
23 ///
24 #define MDE_CPU_ARM
25 
26 //
27 // Make sure we are using the correct packing rules per EFI specification
28 //
29 #ifndef __GNUC__
30 #pragma pack()
31 #endif
32 
33 //
34 // RVCT does not support the __builtin_unreachable() macro
35 //
36 #ifdef __ARMCC_VERSION
37 #define UNREACHABLE()
38 #endif
39 
40 #if _MSC_EXTENSIONS
41  //
42  // use Microsoft* C compiler dependent integer width types
43  //
44  typedef unsigned __int64 UINT64;
45  typedef __int64 INT64;
46  typedef unsigned __int32 UINT32;
47  typedef __int32 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 #else
56  //
57  // Assume standard ARM alignment.
58  // Need to check portability of long long
59  //
60  typedef unsigned long long UINT64;
61  typedef long long INT64;
62  typedef unsigned int UINT32;
63  typedef int INT32;
64  typedef unsigned short UINT16;
65  typedef unsigned short CHAR16;
66  typedef short INT16;
67  typedef unsigned char BOOLEAN;
68  typedef unsigned char UINT8;
69  typedef char CHAR8;
70  typedef signed char INT8;
71 #endif
72 
73 ///
74 /// Unsigned value of native width. (4 bytes on supported 32-bit processor instructions,
75 /// 8 bytes on supported 64-bit processor instructions)
76 ///
77 typedef UINT32 UINTN;
78 
79 ///
80 /// Signed value of native width. (4 bytes on supported 32-bit processor instructions,
81 /// 8 bytes on supported 64-bit processor instructions)
82 ///
83 typedef INT32 INTN;
84 
85 //
86 // Processor specific defines
87 //
88 
89 ///
90 /// A value of native width with the highest bit set.
91 ///
92 #define MAX_BIT 0x80000000
93 
94 ///
95 /// A value of native width with the two highest bits set.
96 ///
97 #define MAX_2_BITS 0xC0000000
98 
99 ///
100 /// Maximum legal ARM address
101 ///
102 #define MAX_ADDRESS 0xFFFFFFFF
103 
104 ///
105 /// Maximum legal ARM INTN and UINTN values.
106 ///
107 #define MAX_INTN ((INTN)0x7FFFFFFF)
108 #define MAX_UINTN ((UINTN)0xFFFFFFFF)
109 
110 ///
111 /// The stack alignment required for ARM
112 ///
113 #define CPU_STACK_ALIGNMENT sizeof(UINT64)
114 
115 ///
116 /// Page allocation granularity for ARM
117 ///
118 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
119 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1000)
120 
121 //
122 // Modifier to ensure that all protocol member functions and EFI intrinsics
123 // use the correct C calling convention. All protocol member functions and
124 // EFI intrinsics are required to modify their member functions with EFIAPI.
125 //
126 #define EFIAPI
127 
128 // When compiling with Clang, we still use GNU as for the assembler, so we still
129 // need to define the GCC_ASM* macros.
130 #if defined(__GNUC__) || defined(__clang__)
131  ///
132  /// For GNU assembly code, .global or .globl can declare global symbols.
133  /// Define this macro to unify the usage.
134  ///
135  #define ASM_GLOBAL .globl
136 
137  #if !defined(__APPLE__)
138  ///
139  /// ARM EABI defines that the linker should not manipulate call relocations
140  /// (do bl/blx conversion) unless the target symbol has function type.
141  /// CodeSourcery 2010.09 started requiring the .type to function properly
142  ///
143  #define INTERWORK_FUNC(func__) .type ASM_PFX(func__), %function
144 
145  #define GCC_ASM_EXPORT(func__) \
146  .global _CONCATENATE (__USER_LABEL_PREFIX__, func__) ;\
147  .type ASM_PFX(func__), %function
148 
149  #define GCC_ASM_IMPORT(func__) \
150  .extern _CONCATENATE (__USER_LABEL_PREFIX__, func__)
151 
152  #else
153  //
154  // .type not supported by Apple Xcode tools
155  //
156  #define INTERWORK_FUNC(func__)
157 
158  #define GCC_ASM_EXPORT(func__) \
159  .globl _CONCATENATE (__USER_LABEL_PREFIX__, func__) \
160 
161  #define GCC_ASM_IMPORT(name)
162 
163  #endif
164 #endif
165 
166 /**
167  Return the pointer to the first instruction of a function given a function pointer.
168  On ARM CPU architectures, these two pointer values are the same,
169  so the implementation of this macro is very simple.
170 
171  @param FunctionPointer A pointer to a function.
172 
173  @return The pointer to the first instruction of a function given a function pointer.
174 
175 **/
176 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
177 
178 #ifndef __USER_LABEL_PREFIX__
179 #define __USER_LABEL_PREFIX__
180 #endif
181 
182 #endif
183 
184 
int INT32
Definition: ProcessorBind.h:57
FILE_LICENCE(BSD3)
unsigned char BOOLEAN
Definition: ProcessorBind.h:61
INT64 INTN
Signed value of native width.
Definition: ProcessorBind.h:77
unsigned int UINT32
Definition: ProcessorBind.h:56
unsigned short CHAR16
Definition: ProcessorBind.h:59
unsigned char UINT8
Definition: ProcessorBind.h:62
long long INT64
Definition: ProcessorBind.h:55
short INT16
Definition: ProcessorBind.h:60
unsigned short UINT16
Definition: ProcessorBind.h:58
UINT64 UINTN
Unsigned value of native width.
Definition: ProcessorBind.h:71
unsigned long long UINT64
Definition: ProcessorBind.h:54
char CHAR8
Definition: ProcessorBind.h:63
signed char INT8
Definition: ProcessorBind.h:64