Subversion Repositories HelenOS

Rev

Rev 2726 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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