1*2192efc0SMitchell Horne /*++ 2*2192efc0SMitchell Horne 3*2192efc0SMitchell Horne Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved 4*2192efc0SMitchell Horne This software and associated documentation (if any) is furnished 5*2192efc0SMitchell Horne under a license and may only be used or copied in accordance 6*2192efc0SMitchell Horne with the terms of the license. Except as permitted by such 7*2192efc0SMitchell Horne license, no part of this software or documentation may be 8*2192efc0SMitchell Horne reproduced, stored in a retrieval system, or transmitted in any 9*2192efc0SMitchell Horne form or by any means without the express written consent of 10*2192efc0SMitchell Horne Intel Corporation. 11*2192efc0SMitchell Horne 12*2192efc0SMitchell Horne Module Name: 13*2192efc0SMitchell Horne 14*2192efc0SMitchell Horne efefind.h 15*2192efc0SMitchell Horne 16*2192efc0SMitchell Horne Abstract: 17*2192efc0SMitchell Horne 18*2192efc0SMitchell Horne EFI to compile bindings 19*2192efc0SMitchell Horne 20*2192efc0SMitchell Horne 21*2192efc0SMitchell Horne 22*2192efc0SMitchell Horne 23*2192efc0SMitchell Horne Revision History 24*2192efc0SMitchell Horne 25*2192efc0SMitchell Horne --*/ 26*2192efc0SMitchell Horne 27*2192efc0SMitchell Horne #pragma pack() 28*2192efc0SMitchell Horne 29*2192efc0SMitchell Horne //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 30*2192efc0SMitchell Horne // BugBug: Code to debug 31*2192efc0SMitchell Horne // 32*2192efc0SMitchell Horne #define BIT63 0x8000000000000000 33*2192efc0SMitchell Horne 34*2192efc0SMitchell Horne #define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63) 35*2192efc0SMitchell Horne #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) ) 36*2192efc0SMitchell Horne 37*2192efc0SMitchell Horne // 38*2192efc0SMitchell Horne // Macro's with casts make this much easier to use and read. 39*2192efc0SMitchell Horne // 40*2192efc0SMitchell Horne #define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port))) 41*2192efc0SMitchell Horne #define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data)) 42*2192efc0SMitchell Horne // 43*2192efc0SMitchell Horne // BugBug: End Debug Code!!! 44*2192efc0SMitchell Horne //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 45*2192efc0SMitchell Horne 46*2192efc0SMitchell Horne #define EFIERR(a) (0x8000000000000000 | a) 47*2192efc0SMitchell Horne #define EFI_ERROR_MASK 0x8000000000000000 48*2192efc0SMitchell Horne #define EFIERR_OEM(a) (0xc000000000000000 | a) 49*2192efc0SMitchell Horne 50*2192efc0SMitchell Horne #define BAD_POINTER 0xFBFBFBFBFBFBFBFB 51*2192efc0SMitchell Horne #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF 52*2192efc0SMitchell Horne 53*2192efc0SMitchell Horne #define BREAKPOINT() __break(0) 54*2192efc0SMitchell Horne 55*2192efc0SMitchell Horne // 56*2192efc0SMitchell Horne // Pointers must be aligned to these address to function 57*2192efc0SMitchell Horne // you will get an alignment fault if this value is less than 8 58*2192efc0SMitchell Horne // 59*2192efc0SMitchell Horne #define MIN_ALIGNMENT_SIZE 8 60*2192efc0SMitchell Horne 61*2192efc0SMitchell Horne #define ALIGN_VARIABLE(Value , Adjustment) \ 62*2192efc0SMitchell Horne (UINTN) Adjustment = 0; \ 63*2192efc0SMitchell Horne if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 64*2192efc0SMitchell Horne (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 65*2192efc0SMitchell Horne Value = (UINTN)Value + (UINTN)Adjustment 66*2192efc0SMitchell Horne 67*2192efc0SMitchell Horne // 68*2192efc0SMitchell Horne // Define macros to create data structure signatures. 69*2192efc0SMitchell Horne // 70*2192efc0SMitchell Horne 71*2192efc0SMitchell Horne #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 72*2192efc0SMitchell Horne #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 73*2192efc0SMitchell Horne #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)) 74*2192efc0SMitchell Horne 75*2192efc0SMitchell Horne // 76*2192efc0SMitchell Horne // EFIAPI - prototype calling convention for EFI function pointers 77*2192efc0SMitchell Horne // BOOTSERVICE - prototype for implementation of a boot service interface 78*2192efc0SMitchell Horne // RUNTIMESERVICE - prototype for implementation of a runtime service interface 79*2192efc0SMitchell Horne // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 80*2192efc0SMitchell Horne // RUNTIME_CODE - pragma macro for declaring runtime code 81*2192efc0SMitchell Horne // 82*2192efc0SMitchell Horne 83*2192efc0SMitchell Horne #ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options 84*2192efc0SMitchell Horne #ifdef _MSC_EXTENSIONS 85*2192efc0SMitchell Horne #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler 86*2192efc0SMitchell Horne #else 87*2192efc0SMitchell Horne #define EFIAPI // Substitute expresion to force C calling convention 88*2192efc0SMitchell Horne #endif 89*2192efc0SMitchell Horne #endif 90*2192efc0SMitchell Horne 91*2192efc0SMitchell Horne #define BOOTSERVICE 92*2192efc0SMitchell Horne #define RUNTIMESERVICE 93*2192efc0SMitchell Horne #define RUNTIMEFUNCTION 94*2192efc0SMitchell Horne 95*2192efc0SMitchell Horne #define RUNTIME_CODE(a) alloc_text("rtcode", a) 96*2192efc0SMitchell Horne #define BEGIN_RUNTIME_DATA() data_seg("rtdata") 97*2192efc0SMitchell Horne #define END_RUNTIME_DATA() data_seg() 98*2192efc0SMitchell Horne 99*2192efc0SMitchell Horne #define VOLATILE volatile 100*2192efc0SMitchell Horne 101*2192efc0SMitchell Horne // 102*2192efc0SMitchell Horne // BugBug: Need to find out if this is portable across compilers. 103*2192efc0SMitchell Horne // 104*2192efc0SMitchell Horne void __mfa (void); 105*2192efc0SMitchell Horne #define MEMORY_FENCE() __mfa() 106*2192efc0SMitchell Horne 107*2192efc0SMitchell Horne #ifdef EFI_NO_INTERFACE_DECL 108*2192efc0SMitchell Horne #define EFI_FORWARD_DECLARATION(x) 109*2192efc0SMitchell Horne #define EFI_INTERFACE_DECL(x) 110*2192efc0SMitchell Horne #else 111*2192efc0SMitchell Horne #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x 112*2192efc0SMitchell Horne #define EFI_INTERFACE_DECL(x) typedef struct x 113*2192efc0SMitchell Horne #endif 114*2192efc0SMitchell Horne 115*2192efc0SMitchell Horne // 116*2192efc0SMitchell Horne // When build similar to FW, then link everything together as 117*2192efc0SMitchell Horne // one big module. 118*2192efc0SMitchell Horne // 119*2192efc0SMitchell Horne 120*2192efc0SMitchell Horne #define EFI_DRIVER_ENTRY_POINT(InitFunction) 121*2192efc0SMitchell Horne 122*2192efc0SMitchell Horne #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 123*2192efc0SMitchell Horne (_if)->LoadInternal(type, name, entry) 124*2192efc0SMitchell Horne // entry(NULL, ST) 125*2192efc0SMitchell Horne 126*2192efc0SMitchell Horne #ifdef __FreeBSD__ 127*2192efc0SMitchell Horne #define INTERFACE_DECL(x) struct x 128*2192efc0SMitchell Horne #else 129*2192efc0SMitchell Horne // 130*2192efc0SMitchell Horne // Some compilers don't support the forward reference construct: 131*2192efc0SMitchell Horne // typedef struct XXXXX 132*2192efc0SMitchell Horne // 133*2192efc0SMitchell Horne // The following macro provide a workaround for such cases. 134*2192efc0SMitchell Horne // 135*2192efc0SMitchell Horne #ifdef NO_INTERFACE_DECL 136*2192efc0SMitchell Horne #define INTERFACE_DECL(x) 137*2192efc0SMitchell Horne #else 138*2192efc0SMitchell Horne #define INTERFACE_DECL(x) typedef struct x 139*2192efc0SMitchell Horne #endif 140*2192efc0SMitchell Horne #endif 141