199767f8919635c4928607450d9e0abb932109ceToomas Soome/* $FreeBSD$ */
199767f8919635c4928607450d9e0abb932109ceToomas SoomeCopyright (c) 1999 - 2003 Intel Corporation. All rights reserved
199767f8919635c4928607450d9e0abb932109ceToomas SoomeThis software and associated documentation (if any) is furnished
199767f8919635c4928607450d9e0abb932109ceToomas Soomeunder a license and may only be used or copied in accordance
199767f8919635c4928607450d9e0abb932109ceToomas Soomewith the terms of the license. Except as permitted by such
199767f8919635c4928607450d9e0abb932109ceToomas Soomelicense, no part of this software or documentation may be
199767f8919635c4928607450d9e0abb932109ceToomas Soomereproduced, stored in a retrieval system, or transmitted in any
199767f8919635c4928607450d9e0abb932109ceToomas Soomeform or by any means without the express written consent of
199767f8919635c4928607450d9e0abb932109ceToomas SoomeIntel Corporation.
199767f8919635c4928607450d9e0abb932109ceToomas Soome EFI to compile bindings
199767f8919635c4928607450d9e0abb932109ceToomas SoomeRevision History
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Basic int types of various widths
199767f8919635c4928607450d9e0abb932109ceToomas Soome // No ANSI C 1999/2000 stdint.h integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome // Use Microsoft C compiler integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned short uint16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef short int16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned char uint8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef char int8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome // Use LP64 programming model from C_FLAGS for integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned long uint64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef long int64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned int uint32_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned short uint16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef short int16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned char uint8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef char int8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome // Assume P64 programming model from C_FLAGS for integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned long long uint64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef long long int64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned int uint32_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned short uint16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef short int16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned char uint8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef char int8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Basic EFI types of various widths
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef ACPI_THREAD_ID /* ACPI's definitions are fine */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ACPI_USE_SYSTEM_INTTYPES 1 /* Tell ACPI we've defined types */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Pointers must be aligned to these address to function
199767f8919635c4928607450d9e0abb932109ceToomas Soome (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Define macros to build data structure signatures from characters.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#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))
199767f8919635c4928607450d9e0abb932109ceToomas Soome// EFIAPI - prototype calling convention for EFI function pointers
199767f8919635c4928607450d9e0abb932109ceToomas Soome// BOOTSERVICE - prototype for implementation of a boot service interface
199767f8919635c4928607450d9e0abb932109ceToomas Soome// RUNTIMESERVICE - prototype for implementation of a runtime service interface
199767f8919635c4928607450d9e0abb932109ceToomas Soome// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
199767f8919635c4928607450d9e0abb932109ceToomas Soome// RUNTIME_CODE - pragma macro for declaring runtime code
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFIAPI // Substitute expresion to force C calling convention
199767f8919635c4928607450d9e0abb932109ceToomas Soome//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a
199767f8919635c4928607450d9e0abb932109ceToomas Soome//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
199767f8919635c4928607450d9e0abb932109ceToomas Soome// To help ensure proper coding of integrated drivers, they are
199767f8919635c4928607450d9e0abb932109ceToomas Soome// compiled as DLLs. In NT they require a dll init entry pointer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome// The macro puts a stub entry point into the DLL so it will load.
199767f8919635c4928607450d9e0abb932109ceToomas Soome return InitFunction(ImageHandle, SystemTable); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else // EFI_NT_EMULATOR
199767f8919635c4928607450d9e0abb932109ceToomas Soome// When build similiar to FW, then link everything together as
199767f8919635c4928607450d9e0abb932109ceToomas Soome// one big module.
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif // EFI_FW_NT
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Some compilers don't support the forward reference construct:
199767f8919635c4928607450d9e0abb932109ceToomas Soome// typedef struct XXXXX
199767f8919635c4928607450d9e0abb932109ceToomas Soome// The following macro provide a workaround for such cases.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INTERFACE_DECL(x) typedef struct x
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __FreeBSD__ */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP