199767f8919635c4928607450d9e0abb932109ceToomas Soome/* $FreeBSD$ */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*++
199767f8919635c4928607450d9e0abb932109ceToomas Soome
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
199767f8919635c4928607450d9e0abb932109ceToomas SoomeModule Name:
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome efefind.h
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeAbstract:
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome EFI to compile bindings
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas SoomeRevision History
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome--*/
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#pragma pack()
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __FreeBSD__
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/stdint.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Basic int types of various widths
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#if (__STDC_VERSION__ < 199901L )
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome // No ANSI C 1999/2000 stdint.h integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome #ifdef _MSC_EXTENSIONS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome // Use Microsoft C compiler integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned __int64 uint64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef __int64 int64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned __int32 uint32_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef __int32 int32_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned __int16 uint16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef __int16 int16_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned __int8 uint8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef __int8 int8_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome #else
199767f8919635c4928607450d9e0abb932109ceToomas Soome #ifdef UNIX_LP64
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome // Use LP64 programming model from C_FLAGS for integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned long uint64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef long int64_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef unsigned int uint32_t;
199767f8919635c4928607450d9e0abb932109ceToomas Soome typedef int int32_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 #else
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome // Assume P64 programming model from C_FLAGS for integer width declarations
199767f8919635c4928607450d9e0abb932109ceToomas Soome
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 int int32_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 #endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome #endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* __FreeBSD__ */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Basic EFI types of various widths
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef uint64_t UINT64;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int64_t INT64;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef uint32_t UINT32;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int32_t INT32;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef uint16_t UINT16;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int16_t INT16;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef uint8_t UINT8;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int8_t INT8;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#undef VOID
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define VOID void
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int64_t INTN;
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef uint64_t UINTN;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
199767f8919635c4928607450d9e0abb932109ceToomas Soome// BugBug: Code to debug
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BIT63 0x8000000000000000
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Macro's with casts make this much easier to use and read.
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data))
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// BugBug: End Debug Code!!!
199767f8919635c4928607450d9e0abb932109ceToomas Soome//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFIERR(a) (0x8000000000000000 | a)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_ERROR_MASK 0x8000000000000000
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFIERR_OEM(a) (0xc000000000000000 | a)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BAD_POINTER 0xFBFBFBFBFBFBFBFB
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BREAKPOINT() __break(0)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Pointers must be aligned to these address to function
199767f8919635c4928607450d9e0abb932109ceToomas Soome// you will get an alignment fault if this value is less than 8
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MIN_ALIGNMENT_SIZE 8
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ALIGN_VARIABLE(Value , Adjustment) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome (UINTN) Adjustment = 0; \
199767f8919635c4928607450d9e0abb932109ceToomas Soome if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
199767f8919635c4928607450d9e0abb932109ceToomas Soome Value = (UINTN)Value + (UINTN)Adjustment
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Define macros to create data structure signatures.
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
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
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
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//
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options
199767f8919635c4928607450d9e0abb932109ceToomas Soome #ifdef _MSC_EXTENSIONS
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler
199767f8919635c4928607450d9e0abb932109ceToomas Soome #else
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFIAPI // Substitute expresion to force C calling convention
199767f8919635c4928607450d9e0abb932109ceToomas Soome #endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BOOTSERVICE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define RUNTIMESERVICE
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define RUNTIMEFUNCTION
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define RUNTIME_CODE(a) alloc_text("rtcode", a)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define BEGIN_RUNTIME_DATA() data_seg("rtdata")
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define END_RUNTIME_DATA() data_seg()
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define VOLATILE volatile
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// BugBug: Need to find out if this is portable accross compliers.
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid __mfa (void);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MEMORY_FENCE() __mfa()
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef EFI_NO_INTERFACE_DECL
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFI_FORWARD_DECLARATION(x)
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFI_INTERFACE_DECL(x)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
199767f8919635c4928607450d9e0abb932109ceToomas Soome #define EFI_INTERFACE_DECL(x) typedef struct x
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// When build similiar to FW, then link everything together as
199767f8919635c4928607450d9e0abb932109ceToomas Soome// one big module.
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define EFI_DRIVER_ENTRY_POINT(InitFunction)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome (_if)->LoadInternal(type, name, entry)
199767f8919635c4928607450d9e0abb932109ceToomas Soome// entry(NULL, ST)
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __FreeBSD__
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INTERFACE_DECL(x) struct x
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// Some compilers don't support the forward reference construct:
199767f8919635c4928607450d9e0abb932109ceToomas Soome// typedef struct XXXXX
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome// The following macro provide a workaround for such cases.
199767f8919635c4928607450d9e0abb932109ceToomas Soome//
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef NO_INTERFACE_DECL
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INTERFACE_DECL(x)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#else
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INTERFACE_DECL(x) typedef struct x
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif