/*++12Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved3This software and associated documentation (if any) is furnished4under a license and may only be used or copied in accordance5with the terms of the license. Except as permitted by such6license, no part of this software or documentation may be7reproduced, stored in a retrieval system, or transmitted in any8form or by any means without the express written consent of9Intel Corporation.1011Module Name:1213efefind.h1415Abstract:1617EFI to compile bindings1819202122Revision History2324--*/2526#pragma pack()2728#ifdef EFI_NT_EMULATOR29#define POST_CODE(_Data)30#else31#ifdef EFI_DEBUG32#define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al33#else34#define POST_CODE(_Data)35#endif36#endif3738#define EFIERR(a) (0x8000000000000000 | a)39#define EFI_ERROR_MASK 0x800000000000000040#define EFIERR_OEM(a) (0xc000000000000000 | a)414243#define BAD_POINTER 0xFBFBFBFBFBFBFBFB44#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF4546#define BREAKPOINT() __asm { int 3 }4748//49// Pointers must be aligned to these address to function50//5152#define MIN_ALIGNMENT_SIZE 45354#define ALIGN_VARIABLE(Value ,Adjustment) \55(UINTN)Adjustment = 0; \56if((UINTN)Value % MIN_ALIGNMENT_SIZE) \57(UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \58Value = (UINTN)Value + (UINTN)Adjustment596061//62// Define macros to build data structure signatures from characters.63//6465#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))66#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))67#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))6869//70// EFIAPI - prototype calling convention for EFI function pointers71// BOOTSERVICE - prototype for implementation of a boot service interface72// RUNTIMESERVICE - prototype for implementation of a runtime service interface73// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service74// RUNTIME_CODE - pragma macro for declaring runtime code75//7677#ifdef __amd64__78#define EFIAPI __attribute__((ms_abi))79#endif8081#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options82#ifdef _MSC_EXTENSIONS83#define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler84#else85#define EFIAPI // Substitute expresion to force C calling convention86#endif87#endif8889#define BOOTSERVICE90//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a91//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a92#define RUNTIMESERVICE93#define RUNTIMEFUNCTION949596#define RUNTIME_CODE(a) alloc_text("rtcode", a)97#define BEGIN_RUNTIME_DATA() data_seg("rtdata")98#define END_RUNTIME_DATA() data_seg("")99100#define VOLATILE volatile101102#define MEMORY_FENCE()103104#ifdef EFI_NO_INTERFACE_DECL105#define EFI_FORWARD_DECLARATION(x)106#define EFI_INTERFACE_DECL(x)107#else108#define EFI_FORWARD_DECLARATION(x) typedef struct _##x x109#define EFI_INTERFACE_DECL(x) typedef struct x110#endif111112#ifdef EFI_NT_EMULATOR113114//115// To help ensure proper coding of integrated drivers, they are116// compiled as DLLs. In NT they require a dll init entry pointer.117// The macro puts a stub entry point into the DLL so it will load.118//119120#define EFI_DRIVER_ENTRY_POINT(InitFunction) \121EFI_STATUS \122InitFunction ( \123EFI_HANDLE ImageHandle, \124EFI_SYSTEM_TABLE *SystemTable \125); \126\127UINTN \128__stdcall \129_DllMainCRTStartup ( \130UINTN Inst, \131UINTN reason_for_call, \132VOID *rserved \133) \134{ \135return 1; \136} \137\138int \139__declspec( dllexport ) \140__cdecl \141InitializeDriver ( \142void *ImageHandle, \143void *SystemTable \144) \145{ \146return InitFunction(ImageHandle, SystemTable); \147}148149150#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \151(_if)->LoadInternal(type, name, NULL)152153#else // EFI_NT_EMULATOR154155//156// When building similar to FW, link everything together as157// one big module.158//159160#define EFI_DRIVER_ENTRY_POINT(InitFunction)161162#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \163(_if)->LoadInternal(type, name, entry)164165#endif // EFI_FW_NT166167#ifdef __FreeBSD__168#define INTERFACE_DECL(x) struct x169#else170//171// Some compilers don't support the forward reference construct:172// typedef struct XXXXX173//174// The following macro provide a workaround for such cases.175//176#ifdef NO_INTERFACE_DECL177#define INTERFACE_DECL(x)178#else179#define INTERFACE_DECL(x) typedef struct x180#endif181#endif /* __FreeBSD__ */182183#ifdef _MSC_EXTENSIONS184#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP185#endif186187188189