/*++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) (0x80000000 | a)39#define EFI_ERROR_MASK 0x8000000040#define EFIERR_OEM(a) (0xc0000000 | a)414243#define BAD_POINTER 0xFBFBFBFB44#define MAX_ADDRESS 0xFFFFFFFF4546#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#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options78#ifdef _MSC_EXTENSIONS79#define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler80#else81#define EFIAPI // Substitute expresion to force C calling convention82#endif83#endif8485#define BOOTSERVICE86//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a87//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a88#define RUNTIMESERVICE89#define RUNTIMEFUNCTION909192#define RUNTIME_CODE(a) alloc_text("rtcode", a)93#define BEGIN_RUNTIME_DATA() data_seg("rtdata")94#define END_RUNTIME_DATA() data_seg()9596#define VOLATILE volatile9798#define MEMORY_FENCE()99100#ifdef EFI_NO_INTERFACE_DECL101#define EFI_FORWARD_DECLARATION(x)102#define EFI_INTERFACE_DECL(x)103#else104#define EFI_FORWARD_DECLARATION(x) typedef struct _##x x105#define EFI_INTERFACE_DECL(x) typedef struct x106#endif107108#ifdef EFI_NT_EMULATOR109110//111// To help ensure proper coding of integrated drivers, they are112// compiled as DLLs. In NT they require a dll init entry pointer.113// The macro puts a stub entry point into the DLL so it will load.114//115116#define EFI_DRIVER_ENTRY_POINT(InitFunction) \117EFI_STATUS \118InitFunction ( \119EFI_HANDLE ImageHandle, \120EFI_SYSTEM_TABLE *SystemTable \121); \122\123UINTN \124__stdcall \125_DllMainCRTStartup ( \126UINTN Inst, \127UINTN reason_for_call, \128VOID *rserved \129) \130{ \131return 1; \132} \133\134int \135__declspec( dllexport ) \136__cdecl \137InitializeDriver ( \138void *ImageHandle, \139void *SystemTable \140) \141{ \142return InitFunction(ImageHandle, SystemTable); \143}144145146#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \147(_if)->LoadInternal(type, name, NULL)148149#else // EFI_NT_EMULATOR150151//152// When build similar to FW, then link everything together as153// one big module.154//155156#define EFI_DRIVER_ENTRY_POINT(InitFunction)157158#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \159(_if)->LoadInternal(type, name, entry)160161#endif // EFI_FW_NT162163#ifdef __FreeBSD__164#define INTERFACE_DECL(x) struct x165#else166//167// Some compilers don't support the forward reference construct:168// typedef struct XXXXX169//170// The following macro provide a workaround for such cases.171//172#ifdef NO_INTERFACE_DECL173#define INTERFACE_DECL(x)174#else175#define INTERFACE_DECL(x) typedef struct x176#endif177#endif /* __FreeBSD__ */178179#ifdef _MSC_EXTENSIONS180#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP181#endif182183184185