xref: /freebsd/stand/efi/include/arm64/efibind.h (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1 /* $FreeBSD$ */
2 /*++
3 
4 Copyright (c)  1999 - 2003 Intel Corporation. All rights reserved
5 This software and associated documentation (if any) is furnished
6 under a license and may only be used or copied in accordance
7 with the terms of the license. Except as permitted by such
8 license, no part of this software or documentation may be
9 reproduced, stored in a retrieval system, or transmitted in any
10 form or by any means without the express written consent of
11 Intel Corporation.
12 
13 Module Name:
14 
15     efefind.h
16 
17 Abstract:
18 
19     EFI to compile bindings
20 
21 
22 
23 
24 Revision History
25 
26 --*/
27 
28 #pragma pack()
29 
30 
31 #ifdef __FreeBSD__
32 #include <sys/stdint.h>
33 #else
34 //
35 // Basic int types of various widths
36 //
37 
38 #if (__STDC_VERSION__ < 199901L )
39 
40     // No ANSI C 1999/2000 stdint.h integer width declarations
41 
42     #ifdef _MSC_EXTENSIONS
43 
44         // Use Microsoft C compiler integer width declarations
45 
46         typedef unsigned __int64    uint64_t;
47         typedef __int64             int64_t;
48         typedef unsigned __int32    uint32_t;
49         typedef __int32             int32_t;
50         typedef unsigned __int16    uint16_t;
51         typedef __int16             int16_t;
52         typedef unsigned __int8     uint8_t;
53         typedef __int8              int8_t;
54     #else
55         #ifdef UNIX_LP64
56 
57             // Use LP64 programming model from C_FLAGS for integer width declarations
58 
59             typedef unsigned long       uint64_t;
60             typedef long                int64_t;
61             typedef unsigned int        uint32_t;
62             typedef int                 int32_t;
63             typedef unsigned short      uint16_t;
64             typedef short               int16_t;
65             typedef unsigned char       uint8_t;
66             typedef char                int8_t;
67         #else
68 
69             // Assume P64 programming model from C_FLAGS for integer width declarations
70 
71             typedef unsigned long long  uint64_t;
72             typedef long long           int64_t;
73             typedef unsigned int        uint32_t;
74             typedef int                 int32_t;
75             typedef unsigned short      uint16_t;
76             typedef short               int16_t;
77             typedef unsigned char       uint8_t;
78             typedef char                int8_t;
79         #endif
80     #endif
81 #endif
82 #endif	/* __FreeBSD__ */
83 
84 //
85 // Basic EFI types of various widths
86 //
87 
88 
89 typedef uint64_t   UINT64;
90 typedef int64_t    INT64;
91 typedef uint32_t   UINT32;
92 typedef int32_t    INT32;
93 typedef uint16_t   UINT16;
94 typedef int16_t    INT16;
95 typedef uint8_t    UINT8;
96 typedef int8_t     INT8;
97 
98 
99 #undef VOID
100 #define VOID    void
101 
102 
103 typedef int64_t    INTN;
104 typedef uint64_t   UINTN;
105 
106 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
107 // BugBug: Code to debug
108 //
109 #define BIT63   0x8000000000000000
110 
111 #define PLATFORM_IOBASE_ADDRESS   (0xffffc000000 | BIT63)
112 #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
113 
114 //
115 // Macro's with casts make this much easier to use and read.
116 //
117 #define PORT_TO_MEM8D(_Port)  (*(UINT8  *)(PORT_TO_MEMD(_Port)))
118 #define POST_CODE(_Data)  (PORT_TO_MEM8D(0x80) = (_Data))
119 //
120 // BugBug: End Debug Code!!!
121 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
122 
123 #define EFIERR(a)           (0x8000000000000000 | a)
124 #define EFI_ERROR_MASK      0x8000000000000000
125 #define EFIERR_OEM(a)       (0xc000000000000000 | a)
126 
127 #define BAD_POINTER         0xFBFBFBFBFBFBFBFB
128 #define MAX_ADDRESS         0xFFFFFFFFFFFFFFFF
129 
130 #define BREAKPOINT()  __break(0)
131 
132 //
133 // Pointers must be aligned to these address to function
134 //  you will get an alignment fault if this value is less than 8
135 //
136 #define MIN_ALIGNMENT_SIZE  8
137 
138 #define ALIGN_VARIABLE(Value , Adjustment) \
139             (UINTN) Adjustment = 0; \
140             if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
141                 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
142             Value = (UINTN)Value + (UINTN)Adjustment
143 
144 //
145 // Define macros to create data structure signatures.
146 //
147 
148 #define EFI_SIGNATURE_16(A,B)             ((A) | (B<<8))
149 #define EFI_SIGNATURE_32(A,B,C,D)         (EFI_SIGNATURE_16(A,B)     | (EFI_SIGNATURE_16(C,D)     << 16))
150 #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))
151 
152 //
153 // EFIAPI - prototype calling convention for EFI function pointers
154 // BOOTSERVICE - prototype for implementation of a boot service interface
155 // RUNTIMESERVICE - prototype for implementation of a runtime service interface
156 // RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
157 // RUNTIME_CODE - pragma macro for declaring runtime code
158 //
159 
160 #ifndef EFIAPI                  // Forces EFI calling conventions reguardless of compiler options
161     #ifdef _MSC_EXTENSIONS
162         #define EFIAPI __cdecl  // Force C calling convention for Microsoft C compiler
163     #else
164         #define EFIAPI          // Substitute expresion to force C calling convention
165     #endif
166 #endif
167 
168 #define BOOTSERVICE
169 #define RUNTIMESERVICE
170 #define RUNTIMEFUNCTION
171 
172 #define RUNTIME_CODE(a)         alloc_text("rtcode", a)
173 #define BEGIN_RUNTIME_DATA()    data_seg("rtdata")
174 #define END_RUNTIME_DATA()      data_seg()
175 
176 #define VOLATILE    volatile
177 
178 //
179 // BugBug: Need to find out if this is portable across compilers.
180 //
181 void __mfa (void);
182 #define MEMORY_FENCE()    __mfa()
183 
184 #ifdef EFI_NO_INTERFACE_DECL
185   #define EFI_FORWARD_DECLARATION(x)
186   #define EFI_INTERFACE_DECL(x)
187 #else
188   #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
189   #define EFI_INTERFACE_DECL(x) typedef struct x
190 #endif
191 
192 //
193 // When build similar to FW, then link everything together as
194 // one big module.
195 //
196 
197 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
198 
199 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry)    \
200             (_if)->LoadInternal(type, name, entry)
201 //        entry(NULL, ST)
202 
203 #ifdef __FreeBSD__
204 #define INTERFACE_DECL(x) struct x
205 #else
206 //
207 // Some compilers don't support the forward reference construct:
208 //  typedef struct XXXXX
209 //
210 // The following macro provide a workaround for such cases.
211 //
212 #ifdef NO_INTERFACE_DECL
213 #define INTERFACE_DECL(x)
214 #else
215 #define INTERFACE_DECL(x) typedef struct x
216 #endif
217 #endif
218