iPXE
ProcessorBind.h
Go to the documentation of this file.
00001 /** @file
00002   Processor or Compiler specific defines and types for ARM.
00003 
00004   Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
00005   Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
00006   This program and the accompanying materials
00007   are licensed and made available under the terms and conditions of the BSD License
00008   which accompanies this distribution.  The full text of the license may be found at
00009   http://opensource.org/licenses/bsd-license.php
00010 
00011   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00012   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00013 
00014 **/
00015 
00016 #ifndef __PROCESSOR_BIND_H__
00017 #define __PROCESSOR_BIND_H__
00018 
00019 FILE_LICENCE ( BSD3 );
00020 
00021 ///
00022 /// Define the processor type so other code can make processor based choices
00023 ///
00024 #define MDE_CPU_ARM
00025 
00026 //
00027 // Make sure we are using the correct packing rules per EFI specification
00028 //
00029 #ifndef __GNUC__
00030 #pragma pack()
00031 #endif
00032 
00033 //
00034 // RVCT does not support the __builtin_unreachable() macro
00035 //
00036 #ifdef __ARMCC_VERSION
00037 #define UNREACHABLE()
00038 #endif
00039 
00040 #if _MSC_EXTENSIONS
00041   //
00042   // use Microsoft* C compiler dependent integer width types
00043   //
00044   typedef unsigned __int64    UINT64;
00045   typedef __int64             INT64;
00046   typedef unsigned __int32    UINT32;
00047   typedef __int32             INT32;
00048   typedef unsigned short      UINT16;
00049   typedef unsigned short      CHAR16;
00050   typedef short               INT16;
00051   typedef unsigned char       BOOLEAN;
00052   typedef unsigned char       UINT8;
00053   typedef char                CHAR8;
00054   typedef signed char         INT8;
00055 #else
00056   //
00057   // Assume standard ARM alignment.
00058   // Need to check portability of long long
00059   //
00060   typedef unsigned long long  UINT64;
00061   typedef long long           INT64;
00062   typedef unsigned int        UINT32;
00063   typedef int                 INT32;
00064   typedef unsigned short      UINT16;
00065   typedef unsigned short      CHAR16;
00066   typedef short               INT16;
00067   typedef unsigned char       BOOLEAN;
00068   typedef unsigned char       UINT8;
00069   typedef char                CHAR8;
00070   typedef signed char         INT8;
00071 #endif
00072 
00073 ///
00074 /// Unsigned value of native width.  (4 bytes on supported 32-bit processor instructions,
00075 /// 8 bytes on supported 64-bit processor instructions)
00076 ///
00077 typedef UINT32  UINTN;
00078 
00079 ///
00080 /// Signed value of native width.  (4 bytes on supported 32-bit processor instructions,
00081 /// 8 bytes on supported 64-bit processor instructions)
00082 ///
00083 typedef INT32   INTN;
00084 
00085 //
00086 // Processor specific defines
00087 //
00088 
00089 ///
00090 /// A value of native width with the highest bit set.
00091 ///
00092 #define MAX_BIT      0x80000000
00093 
00094 ///
00095 /// A value of native width with the two highest bits set.
00096 ///
00097 #define MAX_2_BITS   0xC0000000
00098 
00099 ///
00100 /// Maximum legal ARM address
00101 ///
00102 #define MAX_ADDRESS  0xFFFFFFFF
00103 
00104 ///
00105 /// Maximum legal ARM INTN and UINTN values.
00106 ///
00107 #define MAX_INTN   ((INTN)0x7FFFFFFF)
00108 #define MAX_UINTN  ((UINTN)0xFFFFFFFF)
00109 
00110 ///
00111 /// The stack alignment required for ARM
00112 ///
00113 #define CPU_STACK_ALIGNMENT  sizeof(UINT64)
00114 
00115 ///
00116 /// Page allocation granularity for ARM
00117 ///
00118 #define DEFAULT_PAGE_ALLOCATION_GRANULARITY   (0x1000)
00119 #define RUNTIME_PAGE_ALLOCATION_GRANULARITY   (0x1000)
00120 
00121 //
00122 // Modifier to ensure that all protocol member functions and EFI intrinsics
00123 // use the correct C calling convention. All protocol member functions and
00124 // EFI intrinsics are required to modify their member functions with EFIAPI.
00125 //
00126 #define EFIAPI
00127 
00128 // When compiling with Clang, we still use GNU as for the assembler, so we still
00129 // need to define the GCC_ASM* macros.
00130 #if defined(__GNUC__) || defined(__clang__)
00131   ///
00132   /// For GNU assembly code, .global or .globl can declare global symbols.
00133   /// Define this macro to unify the usage.
00134   ///
00135   #define ASM_GLOBAL .globl
00136 
00137   #if !defined(__APPLE__)
00138     ///
00139     /// ARM EABI defines that the linker should not manipulate call relocations
00140     /// (do bl/blx conversion) unless the target symbol has function type.
00141     /// CodeSourcery 2010.09 started requiring the .type to function properly
00142     ///
00143     #define INTERWORK_FUNC(func__)   .type ASM_PFX(func__), %function
00144 
00145     #define GCC_ASM_EXPORT(func__)  \
00146              .global  _CONCATENATE (__USER_LABEL_PREFIX__, func__)    ;\
00147              .type ASM_PFX(func__), %function
00148 
00149     #define GCC_ASM_IMPORT(func__)  \
00150              .extern  _CONCATENATE (__USER_LABEL_PREFIX__, func__)
00151 
00152   #else
00153     //
00154     // .type not supported by Apple Xcode tools
00155     //
00156     #define INTERWORK_FUNC(func__)
00157 
00158     #define GCC_ASM_EXPORT(func__)  \
00159              .globl  _CONCATENATE (__USER_LABEL_PREFIX__, func__)    \
00160 
00161     #define GCC_ASM_IMPORT(name)
00162 
00163   #endif
00164 #endif
00165 
00166 /**
00167   Return the pointer to the first instruction of a function given a function pointer.
00168   On ARM CPU architectures, these two pointer values are the same,
00169   so the implementation of this macro is very simple.
00170 
00171   @param  FunctionPointer   A pointer to a function.
00172 
00173   @return The pointer to the first instruction of a function given a function pointer.
00174 
00175 **/
00176 #define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID *)(UINTN)(FunctionPointer)
00177 
00178 #ifndef __USER_LABEL_PREFIX__
00179 #define __USER_LABEL_PREFIX__
00180 #endif
00181 
00182 #endif
00183 
00184