1281526Sandrew/* $FreeBSD: stable/11/stand/efi/include/arm64/efibind.h 298826 2016-04-30 00:26:38Z pfg $ */ 2281526Sandrew/*++ 3281526Sandrew 4281526SandrewCopyright (c) 1999 - 2003 Intel Corporation. All rights reserved 5281526SandrewThis software and associated documentation (if any) is furnished 6281526Sandrewunder a license and may only be used or copied in accordance 7281526Sandrewwith the terms of the license. Except as permitted by such 8281526Sandrewlicense, no part of this software or documentation may be 9281526Sandrewreproduced, stored in a retrieval system, or transmitted in any 10281526Sandrewform or by any means without the express written consent of 11281526SandrewIntel Corporation. 12281526Sandrew 13281526SandrewModule Name: 14281526Sandrew 15281526Sandrew efefind.h 16281526Sandrew 17281526SandrewAbstract: 18281526Sandrew 19281526Sandrew EFI to compile bindings 20281526Sandrew 21281526Sandrew 22281526Sandrew 23281526Sandrew 24281526SandrewRevision History 25281526Sandrew 26281526Sandrew--*/ 27281526Sandrew 28281526Sandrew#pragma pack() 29281526Sandrew 30281526Sandrew 31281526Sandrew#ifdef __FreeBSD__ 32281526Sandrew#include <sys/stdint.h> 33281526Sandrew#else 34281526Sandrew// 35281526Sandrew// Basic int types of various widths 36281526Sandrew// 37281526Sandrew 38281526Sandrew#if (__STDC_VERSION__ < 199901L ) 39281526Sandrew 40292625Semaste // No ANSI C 1999/2000 stdint.h integer width declarations 41281526Sandrew 42293268Ssmh #ifdef _MSC_EXTENSIONS 43281526Sandrew 44292625Semaste // Use Microsoft C compiler integer width declarations 45281526Sandrew 46281526Sandrew typedef unsigned __int64 uint64_t; 47281526Sandrew typedef __int64 int64_t; 48281526Sandrew typedef unsigned __int32 uint32_t; 49281526Sandrew typedef __int32 int32_t; 50281526Sandrew typedef unsigned __int16 uint16_t; 51281526Sandrew typedef __int16 int16_t; 52281526Sandrew typedef unsigned __int8 uint8_t; 53281526Sandrew typedef __int8 int8_t; 54292625Semaste #else 55281526Sandrew #ifdef UNIX_LP64 56281526Sandrew 57292625Semaste // Use LP64 programming model from C_FLAGS for integer width declarations 58281526Sandrew 59281526Sandrew typedef unsigned long uint64_t; 60281526Sandrew typedef long int64_t; 61281526Sandrew typedef unsigned int uint32_t; 62281526Sandrew typedef int int32_t; 63281526Sandrew typedef unsigned short uint16_t; 64281526Sandrew typedef short int16_t; 65281526Sandrew typedef unsigned char uint8_t; 66281526Sandrew typedef char int8_t; 67281526Sandrew #else 68281526Sandrew 69292625Semaste // Assume P64 programming model from C_FLAGS for integer width declarations 70281526Sandrew 71281526Sandrew typedef unsigned long long uint64_t; 72281526Sandrew typedef long long int64_t; 73281526Sandrew typedef unsigned int uint32_t; 74281526Sandrew typedef int int32_t; 75281526Sandrew typedef unsigned short uint16_t; 76281526Sandrew typedef short int16_t; 77281526Sandrew typedef unsigned char uint8_t; 78281526Sandrew typedef char int8_t; 79281526Sandrew #endif 80281526Sandrew #endif 81281526Sandrew#endif 82281526Sandrew#endif /* __FreeBSD__ */ 83281526Sandrew 84281526Sandrew// 85281526Sandrew// Basic EFI types of various widths 86281526Sandrew// 87281526Sandrew 88281526Sandrew 89281526Sandrewtypedef uint64_t UINT64; 90281526Sandrewtypedef int64_t INT64; 91281526Sandrewtypedef uint32_t UINT32; 92281526Sandrewtypedef int32_t INT32; 93281526Sandrewtypedef uint16_t UINT16; 94281526Sandrewtypedef int16_t INT16; 95281526Sandrewtypedef uint8_t UINT8; 96281526Sandrewtypedef int8_t INT8; 97281526Sandrew 98281526Sandrew 99281526Sandrew#undef VOID 100281526Sandrew#define VOID void 101281526Sandrew 102281526Sandrew 103281526Sandrewtypedef int64_t INTN; 104281526Sandrewtypedef uint64_t UINTN; 105281526Sandrew 106281526Sandrew//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 107281526Sandrew// BugBug: Code to debug 108281526Sandrew// 109281526Sandrew#define BIT63 0x8000000000000000 110281526Sandrew 111292625Semaste#define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63) 112281526Sandrew#define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) ) 113292625Semaste 114292625Semaste// 115281526Sandrew// Macro's with casts make this much easier to use and read. 116281526Sandrew// 117281526Sandrew#define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port))) 118281526Sandrew#define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data)) 119281526Sandrew// 120281526Sandrew// BugBug: End Debug Code!!! 121281526Sandrew//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 122281526Sandrew 123281526Sandrew#define EFIERR(a) (0x8000000000000000 | a) 124281526Sandrew#define EFI_ERROR_MASK 0x8000000000000000 125292625Semaste#define EFIERR_OEM(a) (0xc000000000000000 | a) 126281526Sandrew 127281526Sandrew#define BAD_POINTER 0xFBFBFBFBFBFBFBFB 128281526Sandrew#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 129281526Sandrew 130281526Sandrew#define BREAKPOINT() __break(0) 131281526Sandrew 132281526Sandrew// 133281526Sandrew// Pointers must be aligned to these address to function 134281526Sandrew// you will get an alignment fault if this value is less than 8 135281526Sandrew// 136281526Sandrew#define MIN_ALIGNMENT_SIZE 8 137281526Sandrew 138281526Sandrew#define ALIGN_VARIABLE(Value , Adjustment) \ 139281526Sandrew (UINTN) Adjustment = 0; \ 140281526Sandrew if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 141281526Sandrew (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 142281526Sandrew Value = (UINTN)Value + (UINTN)Adjustment 143281526Sandrew 144281526Sandrew// 145281526Sandrew// Define macros to create data structure signatures. 146281526Sandrew// 147281526Sandrew 148281526Sandrew#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 149281526Sandrew#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 150281526Sandrew#define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | ((UINT64)(EFI_SIGNATURE_32(E,F,G,H)) << 32)) 151281526Sandrew 152281526Sandrew// 153281526Sandrew// EFIAPI - prototype calling convention for EFI function pointers 154281526Sandrew// BOOTSERVICE - prototype for implementation of a boot service interface 155281526Sandrew// RUNTIMESERVICE - prototype for implementation of a runtime service interface 156281526Sandrew// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 157292625Semaste// RUNTIME_CODE - pragma macro for declaring runtime code 158281526Sandrew// 159281526Sandrew 160292625Semaste#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options 161293268Ssmh #ifdef _MSC_EXTENSIONS 162292625Semaste #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler 163281526Sandrew #else 164292625Semaste #define EFIAPI // Substitute expresion to force C calling convention 165281526Sandrew #endif 166281526Sandrew#endif 167281526Sandrew 168281526Sandrew#define BOOTSERVICE 169281526Sandrew#define RUNTIMESERVICE 170281526Sandrew#define RUNTIMEFUNCTION 171281526Sandrew 172281526Sandrew#define RUNTIME_CODE(a) alloc_text("rtcode", a) 173281526Sandrew#define BEGIN_RUNTIME_DATA() data_seg("rtdata") 174281526Sandrew#define END_RUNTIME_DATA() data_seg() 175281526Sandrew 176281526Sandrew#define VOLATILE volatile 177281526Sandrew 178281526Sandrew// 179298826Spfg// BugBug: Need to find out if this is portable across compilers. 180281526Sandrew// 181292625Semastevoid __mfa (void); 182281526Sandrew#define MEMORY_FENCE() __mfa() 183281526Sandrew 184281526Sandrew#ifdef EFI_NO_INTERFACE_DECL 185281526Sandrew #define EFI_FORWARD_DECLARATION(x) 186281526Sandrew #define EFI_INTERFACE_DECL(x) 187281526Sandrew#else 188281526Sandrew #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x 189281526Sandrew #define EFI_INTERFACE_DECL(x) typedef struct x 190281526Sandrew#endif 191281526Sandrew 192281526Sandrew// 193298826Spfg// When build similar to FW, then link everything together as 194281526Sandrew// one big module. 195281526Sandrew// 196281526Sandrew 197281526Sandrew#define EFI_DRIVER_ENTRY_POINT(InitFunction) 198281526Sandrew 199281526Sandrew#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 200281526Sandrew (_if)->LoadInternal(type, name, entry) 201281526Sandrew// entry(NULL, ST) 202281526Sandrew 203281526Sandrew#ifdef __FreeBSD__ 204281526Sandrew#define INTERFACE_DECL(x) struct x 205281526Sandrew#else 206281526Sandrew// 207281526Sandrew// Some compilers don't support the forward reference construct: 208281526Sandrew// typedef struct XXXXX 209281526Sandrew// 210281526Sandrew// The following macro provide a workaround for such cases. 211281526Sandrew// 212281526Sandrew#ifdef NO_INTERFACE_DECL 213281526Sandrew#define INTERFACE_DECL(x) 214281526Sandrew#else 215281526Sandrew#define INTERFACE_DECL(x) typedef struct x 216281526Sandrew#endif 217281526Sandrew#endif 218