1530d68baSNigel Croxon /*++ 2530d68baSNigel Croxon 3530d68baSNigel Croxon Copyright (c) 1998 Intel Corporation 4530d68baSNigel Croxon 5530d68baSNigel Croxon Module Name: 6530d68baSNigel Croxon 7530d68baSNigel Croxon efefind.h 8530d68baSNigel Croxon 9530d68baSNigel Croxon Abstract: 10530d68baSNigel Croxon 11530d68baSNigel Croxon EFI to compile bindings 12530d68baSNigel Croxon 13530d68baSNigel Croxon 14530d68baSNigel Croxon 15530d68baSNigel Croxon 16530d68baSNigel Croxon Revision History 17530d68baSNigel Croxon 18530d68baSNigel Croxon --*/ 19530d68baSNigel Croxon #ifndef X86_64_EFI_BIND 20530d68baSNigel Croxon #define X86_64_EFI_BIND 21530d68baSNigel Croxon #ifndef __GNUC__ 22530d68baSNigel Croxon #pragma pack() 23530d68baSNigel Croxon #endif 24530d68baSNigel Croxon 2570bced02SPete Batard #if defined(_MSC_VER) 2670bced02SPete Batard #define HAVE_USE_MS_ABI 1 2770bced02SPete Batard #elif defined(GNU_EFI_USE_MS_ABI) 2879f4f38dSNigel Croxon #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))||(defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2))) 29530d68baSNigel Croxon #define HAVE_USE_MS_ABI 1 30530d68baSNigel Croxon #else 31530d68baSNigel Croxon #error Compiler is too old for GNU_EFI_USE_MS_ABI 32530d68baSNigel Croxon #endif 33530d68baSNigel Croxon #endif 34530d68baSNigel Croxon 35530d68baSNigel Croxon // 36530d68baSNigel Croxon // Basic int types of various widths 37530d68baSNigel Croxon // 38530d68baSNigel Croxon 396685cd00SAlexander von Gluck IV #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L ) && !defined(__cplusplus) 40530d68baSNigel Croxon 41530d68baSNigel Croxon // No ANSI C 1999/2000 stdint.h integer width declarations 42530d68baSNigel Croxon 43530d68baSNigel Croxon #if defined(_MSC_EXTENSIONS) 44530d68baSNigel Croxon 45530d68baSNigel Croxon // Use Microsoft C compiler integer width declarations 46530d68baSNigel Croxon 47530d68baSNigel Croxon typedef unsigned __int64 uint64_t; 48530d68baSNigel Croxon typedef __int64 int64_t; 49530d68baSNigel Croxon typedef unsigned __int32 uint32_t; 50530d68baSNigel Croxon typedef __int32 int32_t; 51530d68baSNigel Croxon typedef unsigned short uint16_t; 52530d68baSNigel Croxon typedef short int16_t; 53530d68baSNigel Croxon typedef unsigned char uint8_t; 54530d68baSNigel Croxon typedef char int8_t; 55530d68baSNigel Croxon #elif defined(__GNUC__) 56530d68baSNigel Croxon typedef int __attribute__((__mode__(__DI__))) int64_t; 57530d68baSNigel Croxon typedef unsigned int __attribute__((__mode__(__DI__))) uint64_t; 58530d68baSNigel Croxon typedef unsigned int uint32_t; 59530d68baSNigel Croxon typedef int int32_t; 60530d68baSNigel Croxon typedef unsigned short uint16_t; 61530d68baSNigel Croxon typedef short int16_t; 62530d68baSNigel Croxon typedef unsigned char uint8_t; 63530d68baSNigel Croxon typedef signed char int8_t; 64530d68baSNigel Croxon #elif defined(UNIX_LP64) 65530d68baSNigel Croxon 66530d68baSNigel Croxon /* Use LP64 programming model from C_FLAGS for integer width declarations */ 67530d68baSNigel Croxon 68530d68baSNigel Croxon typedef unsigned long uint64_t; 69530d68baSNigel Croxon typedef long int64_t; 70530d68baSNigel Croxon typedef unsigned int uint32_t; 71530d68baSNigel Croxon typedef int int32_t; 72530d68baSNigel Croxon typedef unsigned short uint16_t; 73530d68baSNigel Croxon typedef short int16_t; 74530d68baSNigel Croxon typedef unsigned char uint8_t; 75530d68baSNigel Croxon typedef char int8_t; 76530d68baSNigel Croxon #else 77530d68baSNigel Croxon 78530d68baSNigel Croxon /* Assume P64 programming model from C_FLAGS for integer width declarations */ 79530d68baSNigel Croxon 80530d68baSNigel Croxon typedef unsigned long long uint64_t __attribute__((aligned (8))); 81530d68baSNigel Croxon typedef long long int64_t __attribute__((aligned (8))); 82530d68baSNigel Croxon typedef unsigned int uint32_t; 83530d68baSNigel Croxon typedef int int32_t; 84530d68baSNigel Croxon typedef unsigned short uint16_t; 85530d68baSNigel Croxon typedef short int16_t; 86530d68baSNigel Croxon typedef unsigned char uint8_t; 87530d68baSNigel Croxon typedef char int8_t; 88530d68baSNigel Croxon #endif 891a53d8f8SEsben Haabendal typedef uint64_t uintptr_t; 901a53d8f8SEsben Haabendal typedef int64_t intptr_t; 916685cd00SAlexander von Gluck IV #else 92530d68baSNigel Croxon #include <stdint.h> 93530d68baSNigel Croxon #endif 94530d68baSNigel Croxon 95530d68baSNigel Croxon // 96530d68baSNigel Croxon // Basic EFI types of various widths 97530d68baSNigel Croxon // 98530d68baSNigel Croxon 99189200d0SCallum Farmer #include <stddef.h> 100189200d0SCallum Farmer 101189200d0SCallum Farmer typedef wchar_t CHAR16; 102189200d0SCallum Farmer #define WCHAR CHAR16 103530d68baSNigel Croxon 104530d68baSNigel Croxon typedef uint64_t UINT64; 105530d68baSNigel Croxon typedef int64_t INT64; 106530d68baSNigel Croxon 107530d68baSNigel Croxon #ifndef _BASETSD_H_ 108530d68baSNigel Croxon typedef uint32_t UINT32; 109530d68baSNigel Croxon typedef int32_t INT32; 110530d68baSNigel Croxon #endif 111530d68baSNigel Croxon 112530d68baSNigel Croxon typedef uint16_t UINT16; 113530d68baSNigel Croxon typedef int16_t INT16; 11414899d89SPeter Jones 115530d68baSNigel Croxon typedef uint8_t UINT8; 11614899d89SPeter Jones typedef char CHAR8; 117530d68baSNigel Croxon typedef int8_t INT8; 11814899d89SPeter Jones 119530d68baSNigel Croxon #undef VOID 120*056bdaa5SCallum Farmer typedef void VOID; 121530d68baSNigel Croxon 122530d68baSNigel Croxon 123530d68baSNigel Croxon typedef int64_t INTN; 124530d68baSNigel Croxon typedef uint64_t UINTN; 125530d68baSNigel Croxon 126530d68baSNigel Croxon #ifdef EFI_NT_EMULATOR 127530d68baSNigel Croxon #define POST_CODE(_Data) 128530d68baSNigel Croxon #else 129530d68baSNigel Croxon #ifdef EFI_DEBUG 130530d68baSNigel Croxon #define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al 131530d68baSNigel Croxon #else 132530d68baSNigel Croxon #define POST_CODE(_Data) 133530d68baSNigel Croxon #endif 134530d68baSNigel Croxon #endif 135530d68baSNigel Croxon 136530d68baSNigel Croxon #define EFIERR(a) (0x8000000000000000 | a) 137530d68baSNigel Croxon #define EFI_ERROR_MASK 0x8000000000000000 138530d68baSNigel Croxon #define EFIERR_OEM(a) (0xc000000000000000 | a) 139530d68baSNigel Croxon 140530d68baSNigel Croxon 141530d68baSNigel Croxon #define BAD_POINTER 0xFBFBFBFBFBFBFBFB 142530d68baSNigel Croxon #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 143530d68baSNigel Croxon 144530d68baSNigel Croxon #ifdef EFI_NT_EMULATOR 145530d68baSNigel Croxon #define BREAKPOINT() __asm { int 3 } 146530d68baSNigel Croxon #else 147530d68baSNigel Croxon #define BREAKPOINT() while (TRUE); // Make it hang on Bios[Dbg]32 148530d68baSNigel Croxon #endif 149530d68baSNigel Croxon 150530d68baSNigel Croxon // 151530d68baSNigel Croxon // Pointers must be aligned to these address to function 152530d68baSNigel Croxon // 153530d68baSNigel Croxon 154530d68baSNigel Croxon #define MIN_ALIGNMENT_SIZE 4 155530d68baSNigel Croxon 156530d68baSNigel Croxon #define ALIGN_VARIABLE(Value ,Adjustment) \ 157530d68baSNigel Croxon (UINTN)Adjustment = 0; \ 158530d68baSNigel Croxon if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 159530d68baSNigel Croxon (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 160530d68baSNigel Croxon Value = (UINTN)Value + (UINTN)Adjustment 161530d68baSNigel Croxon 162530d68baSNigel Croxon 163530d68baSNigel Croxon // 164530d68baSNigel Croxon // Define macros to build data structure signatures from characters. 165530d68baSNigel Croxon // 166530d68baSNigel Croxon 167530d68baSNigel Croxon #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 168530d68baSNigel Croxon #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 169530d68baSNigel Croxon #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)) 170530d68baSNigel Croxon // 171530d68baSNigel Croxon // To export & import functions in the EFI emulator environment 172530d68baSNigel Croxon // 173530d68baSNigel Croxon 174530d68baSNigel Croxon #ifdef EFI_NT_EMULATOR 175530d68baSNigel Croxon #define EXPORTAPI __declspec( dllexport ) 176530d68baSNigel Croxon #else 177530d68baSNigel Croxon #define EXPORTAPI 178530d68baSNigel Croxon #endif 179530d68baSNigel Croxon 180530d68baSNigel Croxon 181530d68baSNigel Croxon // 182530d68baSNigel Croxon // EFIAPI - prototype calling convention for EFI function pointers 183530d68baSNigel Croxon // BOOTSERVICE - prototype for implementation of a boot service interface 184530d68baSNigel Croxon // RUNTIMESERVICE - prototype for implementation of a runtime service interface 185530d68baSNigel Croxon // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 186530d68baSNigel Croxon // RUNTIME_CODE - pragma macro for declaring runtime code 187530d68baSNigel Croxon // 188530d68baSNigel Croxon 189530d68baSNigel Croxon #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options 190530d68baSNigel Croxon #ifdef _MSC_EXTENSIONS 191530d68baSNigel Croxon #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler 192530d68baSNigel Croxon #elif defined(HAVE_USE_MS_ABI) 193530d68baSNigel Croxon // Force amd64/ms calling conventions. 194530d68baSNigel Croxon #define EFIAPI __attribute__((ms_abi)) 195530d68baSNigel Croxon #else 196530d68baSNigel Croxon #define EFIAPI // Substitute expresion to force C calling convention 197530d68baSNigel Croxon #endif 198530d68baSNigel Croxon #endif 199530d68baSNigel Croxon 200530d68baSNigel Croxon #define BOOTSERVICE 201530d68baSNigel Croxon //#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a 202530d68baSNigel Croxon //#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a 203530d68baSNigel Croxon #define RUNTIMESERVICE 204530d68baSNigel Croxon #define RUNTIMEFUNCTION 205530d68baSNigel Croxon 206530d68baSNigel Croxon 207530d68baSNigel Croxon #define RUNTIME_CODE(a) alloc_text("rtcode", a) 208530d68baSNigel Croxon #define BEGIN_RUNTIME_DATA() data_seg("rtdata") 209530d68baSNigel Croxon #define END_RUNTIME_DATA() data_seg("") 210530d68baSNigel Croxon 211530d68baSNigel Croxon #define VOLATILE volatile 212530d68baSNigel Croxon 213530d68baSNigel Croxon #define MEMORY_FENCE() 214530d68baSNigel Croxon 215530d68baSNigel Croxon #ifdef EFI_NT_EMULATOR 216530d68baSNigel Croxon 217530d68baSNigel Croxon // 218530d68baSNigel Croxon // To help ensure proper coding of integrated drivers, they are 219530d68baSNigel Croxon // compiled as DLLs. In NT they require a dll init entry pointer. 220530d68baSNigel Croxon // The macro puts a stub entry point into the DLL so it will load. 221530d68baSNigel Croxon // 222530d68baSNigel Croxon 223530d68baSNigel Croxon #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 224530d68baSNigel Croxon UINTN \ 225530d68baSNigel Croxon __stdcall \ 226530d68baSNigel Croxon _DllMainCRTStartup ( \ 227530d68baSNigel Croxon UINTN Inst, \ 228530d68baSNigel Croxon UINTN reason_for_call, \ 229530d68baSNigel Croxon VOID *rserved \ 230530d68baSNigel Croxon ) \ 231530d68baSNigel Croxon { \ 232530d68baSNigel Croxon return 1; \ 233530d68baSNigel Croxon } \ 234530d68baSNigel Croxon \ 235530d68baSNigel Croxon int \ 236530d68baSNigel Croxon EXPORTAPI \ 237530d68baSNigel Croxon __cdecl \ 238530d68baSNigel Croxon InitializeDriver ( \ 239530d68baSNigel Croxon void *ImageHandle, \ 240530d68baSNigel Croxon void *SystemTable \ 241530d68baSNigel Croxon ) \ 242530d68baSNigel Croxon { \ 243530d68baSNigel Croxon return InitFunction(ImageHandle, SystemTable); \ 244530d68baSNigel Croxon } 245530d68baSNigel Croxon 246530d68baSNigel Croxon 247530d68baSNigel Croxon #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 248530d68baSNigel Croxon (_if)->LoadInternal(type, name, NULL) 249530d68baSNigel Croxon 250530d68baSNigel Croxon #else // EFI_NT_EMULATOR 251530d68baSNigel Croxon 252530d68baSNigel Croxon // 253530d68baSNigel Croxon // When build similiar to FW, then link everything together as 25409027207SNigel Croxon // one big module. For the MSVC toolchain, we simply tell the 25509027207SNigel Croxon // linker what our driver init function is using /ENTRY. 256530d68baSNigel Croxon // 25709027207SNigel Croxon #if defined(_MSC_EXTENSIONS) 25809027207SNigel Croxon #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 25909027207SNigel Croxon __pragma(comment(linker, "/ENTRY:" # InitFunction)) 26009027207SNigel Croxon #else 261530d68baSNigel Croxon #define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 262530d68baSNigel Croxon UINTN \ 263530d68baSNigel Croxon InitializeDriver ( \ 264530d68baSNigel Croxon VOID *ImageHandle, \ 265530d68baSNigel Croxon VOID *SystemTable \ 266530d68baSNigel Croxon ) \ 267530d68baSNigel Croxon { \ 268530d68baSNigel Croxon return InitFunction(ImageHandle, \ 269530d68baSNigel Croxon SystemTable); \ 270530d68baSNigel Croxon } \ 271530d68baSNigel Croxon \ 272530d68baSNigel Croxon EFI_STATUS efi_main( \ 273530d68baSNigel Croxon EFI_HANDLE image, \ 274530d68baSNigel Croxon EFI_SYSTEM_TABLE *systab \ 275530d68baSNigel Croxon ) __attribute__((weak, \ 276530d68baSNigel Croxon alias ("InitializeDriver"))); 27709027207SNigel Croxon #endif 278530d68baSNigel Croxon 279530d68baSNigel Croxon #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 280530d68baSNigel Croxon (_if)->LoadInternal(type, name, entry) 281530d68baSNigel Croxon 28209027207SNigel Croxon #endif // EFI_NT_EMULATOR 283530d68baSNigel Croxon 284530d68baSNigel Croxon // 285530d68baSNigel Croxon // Some compilers don't support the forward reference construct: 286530d68baSNigel Croxon // typedef struct XXXXX 287530d68baSNigel Croxon // 288530d68baSNigel Croxon // The following macro provide a workaround for such cases. 289530d68baSNigel Croxon // 290530d68baSNigel Croxon #ifdef NO_INTERFACE_DECL 291530d68baSNigel Croxon #define INTERFACE_DECL(x) 292530d68baSNigel Croxon #else 2930b5f181aSNigel Croxon #if defined(__GNUC__) || defined(_MSC_EXTENSIONS) 294530d68baSNigel Croxon #define INTERFACE_DECL(x) struct x 295530d68baSNigel Croxon #else 296530d68baSNigel Croxon #define INTERFACE_DECL(x) typedef struct x 297530d68baSNigel Croxon #endif 298530d68baSNigel Croxon #endif 299530d68baSNigel Croxon 300530d68baSNigel Croxon /* for x86_64, EFI_FUNCTION_WRAPPER must be defined */ 301530d68baSNigel Croxon #if defined(HAVE_USE_MS_ABI) 302530d68baSNigel Croxon #define uefi_call_wrapper(func, va_num, ...) func(__VA_ARGS__) 303530d68baSNigel Croxon #else 304530d68baSNigel Croxon /* 305530d68baSNigel Croxon Credits for macro-magic: 306530d68baSNigel Croxon https://groups.google.com/forum/?fromgroups#!topic/comp.std.c/d-6Mj5Lko_s 307530d68baSNigel Croxon http://efesx.com/2010/08/31/overloading-macros/ 308530d68baSNigel Croxon */ 309530d68baSNigel Croxon #define __VA_NARG__(...) \ 310530d68baSNigel Croxon __VA_NARG_(_0, ## __VA_ARGS__, __RSEQ_N()) 311530d68baSNigel Croxon #define __VA_NARG_(...) \ 312530d68baSNigel Croxon __VA_ARG_N(__VA_ARGS__) 313530d68baSNigel Croxon #define __VA_ARG_N( \ 314530d68baSNigel Croxon _0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,N,...) N 315530d68baSNigel Croxon #define __RSEQ_N() \ 316530d68baSNigel Croxon 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 317530d68baSNigel Croxon 318530d68baSNigel Croxon #define __VA_ARG_NSUFFIX__(prefix,...) \ 319530d68baSNigel Croxon __VA_ARG_NSUFFIX_N(prefix, __VA_NARG__(__VA_ARGS__)) 320530d68baSNigel Croxon #define __VA_ARG_NSUFFIX_N(prefix,nargs) \ 321530d68baSNigel Croxon __VA_ARG_NSUFFIX_N_(prefix, nargs) 322530d68baSNigel Croxon #define __VA_ARG_NSUFFIX_N_(prefix,nargs) \ 323530d68baSNigel Croxon prefix ## nargs 324530d68baSNigel Croxon 325530d68baSNigel Croxon /* Prototypes of EFI cdecl -> stdcall trampolines */ 326530d68baSNigel Croxon UINT64 efi_call0(void *func); 327530d68baSNigel Croxon UINT64 efi_call1(void *func, UINT64 arg1); 328530d68baSNigel Croxon UINT64 efi_call2(void *func, UINT64 arg1, UINT64 arg2); 329530d68baSNigel Croxon UINT64 efi_call3(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3); 330530d68baSNigel Croxon UINT64 efi_call4(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, 331530d68baSNigel Croxon UINT64 arg4); 332530d68baSNigel Croxon UINT64 efi_call5(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, 333530d68baSNigel Croxon UINT64 arg4, UINT64 arg5); 334530d68baSNigel Croxon UINT64 efi_call6(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, 335530d68baSNigel Croxon UINT64 arg4, UINT64 arg5, UINT64 arg6); 336530d68baSNigel Croxon UINT64 efi_call7(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, 337530d68baSNigel Croxon UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7); 338530d68baSNigel Croxon UINT64 efi_call8(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, 339530d68baSNigel Croxon UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7, 340530d68baSNigel Croxon UINT64 arg8); 341530d68baSNigel Croxon UINT64 efi_call9(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, 342530d68baSNigel Croxon UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7, 343530d68baSNigel Croxon UINT64 arg8, UINT64 arg9); 344530d68baSNigel Croxon UINT64 efi_call10(void *func, UINT64 arg1, UINT64 arg2, UINT64 arg3, 345530d68baSNigel Croxon UINT64 arg4, UINT64 arg5, UINT64 arg6, UINT64 arg7, 346530d68baSNigel Croxon UINT64 arg8, UINT64 arg9, UINT64 arg10); 347530d68baSNigel Croxon 348530d68baSNigel Croxon /* Front-ends to efi_callX to avoid compiler warnings */ 349530d68baSNigel Croxon #define _cast64_efi_call0(f) \ 350530d68baSNigel Croxon efi_call0(f) 351530d68baSNigel Croxon #define _cast64_efi_call1(f,a1) \ 352530d68baSNigel Croxon efi_call1(f, (UINT64)(a1)) 353530d68baSNigel Croxon #define _cast64_efi_call2(f,a1,a2) \ 354530d68baSNigel Croxon efi_call2(f, (UINT64)(a1), (UINT64)(a2)) 355530d68baSNigel Croxon #define _cast64_efi_call3(f,a1,a2,a3) \ 356530d68baSNigel Croxon efi_call3(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3)) 357530d68baSNigel Croxon #define _cast64_efi_call4(f,a1,a2,a3,a4) \ 358530d68baSNigel Croxon efi_call4(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4)) 359530d68baSNigel Croxon #define _cast64_efi_call5(f,a1,a2,a3,a4,a5) \ 360530d68baSNigel Croxon efi_call5(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ 361530d68baSNigel Croxon (UINT64)(a5)) 362530d68baSNigel Croxon #define _cast64_efi_call6(f,a1,a2,a3,a4,a5,a6) \ 363530d68baSNigel Croxon efi_call6(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ 364530d68baSNigel Croxon (UINT64)(a5), (UINT64)(a6)) 365530d68baSNigel Croxon #define _cast64_efi_call7(f,a1,a2,a3,a4,a5,a6,a7) \ 366530d68baSNigel Croxon efi_call7(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ 367530d68baSNigel Croxon (UINT64)(a5), (UINT64)(a6), (UINT64)(a7)) 368530d68baSNigel Croxon #define _cast64_efi_call8(f,a1,a2,a3,a4,a5,a6,a7,a8) \ 369530d68baSNigel Croxon efi_call8(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ 370530d68baSNigel Croxon (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8)) 371530d68baSNigel Croxon #define _cast64_efi_call9(f,a1,a2,a3,a4,a5,a6,a7,a8,a9) \ 372530d68baSNigel Croxon efi_call9(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ 373530d68baSNigel Croxon (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \ 374530d68baSNigel Croxon (UINT64)(a9)) 375530d68baSNigel Croxon #define _cast64_efi_call10(f,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \ 376530d68baSNigel Croxon efi_call10(f, (UINT64)(a1), (UINT64)(a2), (UINT64)(a3), (UINT64)(a4), \ 377530d68baSNigel Croxon (UINT64)(a5), (UINT64)(a6), (UINT64)(a7), (UINT64)(a8), \ 378530d68baSNigel Croxon (UINT64)(a9), (UINT64)(a10)) 379530d68baSNigel Croxon 380530d68baSNigel Croxon /* main wrapper (va_num ignored) */ 381530d68baSNigel Croxon #define uefi_call_wrapper(func,va_num,...) \ 382530d68baSNigel Croxon __VA_ARG_NSUFFIX__(_cast64_efi_call, __VA_ARGS__) (func , ##__VA_ARGS__) 383530d68baSNigel Croxon 384530d68baSNigel Croxon #endif 38509027207SNigel Croxon 38609027207SNigel Croxon #if defined(HAVE_USE_MS_ABI) && !defined(_MSC_EXTENSIONS) 387530d68baSNigel Croxon #define EFI_FUNCTION __attribute__((ms_abi)) 38809027207SNigel Croxon #else 38909027207SNigel Croxon #define EFI_FUNCTION 39009027207SNigel Croxon #endif 391530d68baSNigel Croxon 392530d68baSNigel Croxon #ifdef _MSC_EXTENSIONS 393530d68baSNigel Croxon #pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP 394530d68baSNigel Croxon #endif 395530d68baSNigel Croxon 396530d68baSNigel Croxon #endif 397