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