2 * $FreeBSD: src/sys/boot/efi/include/ia64/efibind.h,v 1.3 2002/05/19 03:17:22 marcel Exp $
3 * $DragonFly: src/sys/boot/efi/include/ia64/efibind.h,v 1.1 2003/11/10 06:08:32 dillon Exp $
7 Copyright (c) 1998 Intel Corporation
15 EFI to compile bindings
26 #include <sys/stdint.h>
28 /* Basic EFI types of various widths. */
30 typedef uint64_t UINT64;
31 typedef int64_t INT64;
32 typedef uint32_t UINT32;
33 typedef int32_t INT32;
34 typedef uint16_t UINT16;
35 typedef int16_t INT16;
36 typedef uint8_t UINT8;
45 typedef uint64_t UINTN;
48 *XXX BugBug: Code to debug
50 #define BIT63 0x8000000000000000
52 #define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63)
53 #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
55 /* Macro's with casts make this much easier to use and read. */
56 #define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port)))
57 #define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data))
59 #define EFIERR(a) (0x8000000000000000 | a)
60 #define EFI_ERROR_MASK 0x8000000000000000
61 #define EFIERR_OEM(a) (0xc000000000000000 | a)
63 #define BAD_POINTER 0xFBFBFBFBFBFBFBFB
64 #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
66 #define BREAKPOINT() while (TRUE)
69 * Pointers must be aligned to these address to function
70 * you will get an alignment fault if this value is less than 8
72 #define MIN_ALIGNMENT_SIZE 8
74 #define ALIGN_VARIABLE(Value , Adjustment) \
75 (UINTN) Adjustment = 0; \
76 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
77 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
78 Value = (UINTN)Value + (UINTN)Adjustment
81 * Define macros to create data structure signatures.
84 #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
85 #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
86 #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))
89 * To export & import functions in the EFI emulator environment
95 * EFIAPI - prototype calling convention for EFI function pointers
96 * BOOTSERVICE - prototype for implementation of a boot service interface
97 * RUNTIMESERVICE - prototype for implementation of a runtime service interface
98 * RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
99 * RUNTIME_CODE - pragma macro for declaring runtime code
102 #ifndef EFIAPI /* Forces EFI calling conventions reguardless of compiler options */
104 #define EFIAPI __cdecl
111 #define RUNTIMESERVICE
112 #define RUNTIMEFUNCTION
114 #define RUNTIME_CODE(a) alloc_text("rtcode", a)
115 #define BEGIN_RUNTIME_DATA() data_seg("rtdata")
116 #define END_RUNTIME_DATA() data_seg("")
118 #define VOLATILE volatile
121 * XXX Need to find out if this is portable accross compliers.
125 #pragma intrinsic (__mf)
127 #define MEMORY_FENCE() __mf()
130 * When build similiar to FW, then link everything together as
134 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
136 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
137 (_if)->LoadInternal(type, name, entry)
140 * Some compilers don't support the forward reference construct:
141 * typedef struct XXXXX
143 * The following macro provide a workaround for such cases.
145 #ifdef NO_INTERFACE_DECL
146 #define INTERFACE_DECL(x)
149 #define INTERFACE_DECL(x) struct x
151 #define INTERFACE_DECL(x) typedef struct x