routed - Apply FreeBSD-SA-14:21.routed
[dragonfly.git] / sys / boot / efi / include / ia64 / efibind.h
1 /*
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 $
4  */
5 /*++
6
7 Copyright (c) 1998  Intel Corporation
8
9 Module Name:
10
11     efefind.h
12
13 Abstract:
14
15     EFI to compile bindings
16
17
18
19
20 Revision History
21
22 --*/
23
24 #pragma pack()
25
26 #include <sys/stdint.h>
27
28 /* Basic EFI types of various widths. */
29
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;
37 typedef int8_t     INT8;
38
39
40 #undef VOID
41 #define VOID    void
42
43
44 typedef int64_t    INTN;
45 typedef uint64_t   UINTN;
46
47 /*
48  *XXX BugBug: Code to debug
49  */
50 #define BIT63   0x8000000000000000
51
52 #define PLATFORM_IOBASE_ADDRESS   (0xffffc000000 | BIT63)
53 #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
54
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))
58
59 #define EFIERR(a)           (0x8000000000000000 | a)
60 #define EFI_ERROR_MASK      0x8000000000000000
61 #define EFIERR_OEM(a)       (0xc000000000000000 | a)      
62
63 #define BAD_POINTER         0xFBFBFBFBFBFBFBFB
64 #define MAX_ADDRESS         0xFFFFFFFFFFFFFFFF
65
66 #define BREAKPOINT()        while (TRUE)
67
68 /*
69  * Pointers must be aligned to these address to function
70  *  you will get an alignment fault if this value is less than 8
71  */
72 #define MIN_ALIGNMENT_SIZE  8
73
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
79
80 /*
81  * Define macros to create data structure signatures.
82  */
83
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))
87
88 /*
89  * To export & import functions in the EFI emulator environment
90  */
91
92 #define EXPORTAPI
93
94 /*
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    
100  */
101
102 #ifndef EFIAPI                  /* Forces EFI calling conventions reguardless of compiler options */
103 #if _MSC_EXTENSIONS
104 #define EFIAPI __cdecl
105 #else
106 #define EFIAPI
107 #endif
108 #endif
109
110 #define BOOTSERVICE
111 #define RUNTIMESERVICE
112 #define RUNTIMEFUNCTION
113
114 #define RUNTIME_CODE(a)         alloc_text("rtcode", a)
115 #define BEGIN_RUNTIME_DATA()    data_seg("rtdata")
116 #define END_RUNTIME_DATA()      data_seg("")
117
118 #define VOLATILE    volatile
119
120 /*
121  * XXX Need to find out if this is portable accross compliers.
122  */
123 void __mf (void);                       
124 #ifndef __GNUC__
125 #pragma intrinsic (__mf)  
126 #endif
127 #define MEMORY_FENCE()    __mf()
128
129 /*
130  * When build similiar to FW, then link everything together as
131  * one big module.
132  */
133
134 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
135
136 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry)    \
137         (_if)->LoadInternal(type, name, entry)
138
139 /*
140  * Some compilers don't support the forward reference construct:
141  *  typedef struct XXXXX
142  *
143  * The following macro provide a workaround for such cases.
144  */
145 #ifdef NO_INTERFACE_DECL
146 #define INTERFACE_DECL(x)
147 #else
148 #ifdef __GNUC__
149 #define INTERFACE_DECL(x) struct x
150 #else
151 #define INTERFACE_DECL(x) typedef struct x
152 #endif
153 #endif