1199767f8SToomas Soome /* $FreeBSD$ */
2199767f8SToomas Soome /*++
3199767f8SToomas Soome 
4199767f8SToomas Soome Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
5199767f8SToomas Soome 
6199767f8SToomas Soome This program and the accompanying materials
7199767f8SToomas Soome are licensed and made available under the terms and conditions of the BSD License
8199767f8SToomas Soome which accompanies this distribution.  The full text of the license may be found at
9199767f8SToomas Soome http://opensource.org/licenses/bsd-license.php
10199767f8SToomas Soome 
11199767f8SToomas Soome THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12199767f8SToomas Soome WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13199767f8SToomas Soome 
14199767f8SToomas Soome Module Name:
15199767f8SToomas Soome 
16199767f8SToomas Soome   EfiBind.h
17199767f8SToomas Soome 
18199767f8SToomas Soome Abstract:
19199767f8SToomas Soome 
20199767f8SToomas Soome   Processor or Compiler specific defines and types for IA-32.
21199767f8SToomas Soome   We are using the ANSI C 2000 _t type definitions for basic types.
22199767f8SToomas Soome   This it technically a violation of the coding standard, but they
23199767f8SToomas Soome   are used to make EfiTypes.h portable. Code other than EfiTypes.h
24199767f8SToomas Soome   should never use any ANSI C 2000 _t integer types.
25199767f8SToomas Soome 
26199767f8SToomas Soome --*/
27199767f8SToomas Soome 
28199767f8SToomas Soome #ifndef _EFI_BIND_H_
29199767f8SToomas Soome #define _EFI_BIND_H_
30199767f8SToomas Soome 
31199767f8SToomas Soome 
32199767f8SToomas Soome #define EFI_DRIVER_ENTRY_POINT(InitFunction)
33199767f8SToomas Soome #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
34199767f8SToomas Soome 
35199767f8SToomas Soome 
36199767f8SToomas Soome //
37*03502720SToomas Soome // Make sure we are using the correct packing rules per EFI specification
38199767f8SToomas Soome //
39199767f8SToomas Soome #ifndef __GNUC__
40199767f8SToomas Soome #pragma pack()
41199767f8SToomas Soome #endif
42199767f8SToomas Soome 
43199767f8SToomas Soome 
44199767f8SToomas Soome #ifdef __FreeBSD__
45199767f8SToomas Soome #include <sys/stdint.h>
46199767f8SToomas Soome #else
47199767f8SToomas Soome //
48199767f8SToomas Soome // Assume standard IA-32 alignment.
49199767f8SToomas Soome // BugBug: Need to check portability of long long
50199767f8SToomas Soome //
51199767f8SToomas Soome typedef unsigned long long  uint64_t;
52199767f8SToomas Soome typedef long long           int64_t;
53199767f8SToomas Soome typedef unsigned int        uint32_t;
54199767f8SToomas Soome typedef int                 int32_t;
55199767f8SToomas Soome typedef unsigned short      uint16_t;
56199767f8SToomas Soome typedef short               int16_t;
57199767f8SToomas Soome typedef unsigned char       uint8_t;
58199767f8SToomas Soome typedef signed char         int8_t;
59199767f8SToomas Soome #endif
60199767f8SToomas Soome 
61199767f8SToomas Soome typedef uint64_t   UINT64;
62199767f8SToomas Soome typedef int64_t    INT64;
63199767f8SToomas Soome typedef uint32_t   UINT32;
64199767f8SToomas Soome typedef int32_t    INT32;
65199767f8SToomas Soome typedef uint16_t   UINT16;
66199767f8SToomas Soome typedef int16_t    INT16;
67199767f8SToomas Soome typedef uint8_t    UINT8;
68199767f8SToomas Soome typedef int8_t     INT8;
69199767f8SToomas Soome 
70199767f8SToomas Soome #undef VOID
71199767f8SToomas Soome #define VOID    void
72199767f8SToomas Soome 
73199767f8SToomas Soome //
74199767f8SToomas Soome // Native integer size in stdint.h
75199767f8SToomas Soome //
76199767f8SToomas Soome typedef uint32_t  UINTN;
77199767f8SToomas Soome typedef int32_t   INTN;
78199767f8SToomas Soome 
79199767f8SToomas Soome #define EFIERR(a)           (0x80000000 | a)
80199767f8SToomas Soome #define EFI_ERROR_MASK      0x80000000
81199767f8SToomas Soome #define EFIERR_OEM(a)       (0xc0000000 | a)
82199767f8SToomas Soome 
83199767f8SToomas Soome //
84199767f8SToomas Soome // Processor specific defines
85199767f8SToomas Soome //
86199767f8SToomas Soome #define EFI_MAX_BIT       0x80000000
87199767f8SToomas Soome #define MAX_2_BITS        0xC0000000
88199767f8SToomas Soome 
89199767f8SToomas Soome //
90199767f8SToomas Soome // Maximum legal IA-32 address
91199767f8SToomas Soome //
92199767f8SToomas Soome #define EFI_MAX_ADDRESS   0xFFFFFFFF
93199767f8SToomas Soome 
94199767f8SToomas Soome //
95199767f8SToomas Soome //  Bad pointer value to use in check builds.
96199767f8SToomas Soome //  if you see this value you are using uninitialized or free'ed data
97199767f8SToomas Soome //
98199767f8SToomas Soome #define EFI_BAD_POINTER          0xAFAFAFAF
99199767f8SToomas Soome #define EFI_BAD_POINTER_AS_BYTE  0xAF
100199767f8SToomas Soome 
101199767f8SToomas Soome #define EFI_DEADLOOP()    { volatile UINTN __iii; __iii = 1; while (__iii); }
102199767f8SToomas Soome 
103199767f8SToomas Soome //
104199767f8SToomas Soome // Inject a break point in the code to assist debugging for NT Emulation Environment
105199767f8SToomas Soome // For real hardware, just put in a halt loop. Don't do a while(1) because the
106199767f8SToomas Soome // compiler will optimize away the rest of the function following, so that you run out in
107199767f8SToomas Soome // the weeds if you skip over it with a debugger.
108199767f8SToomas Soome //
109199767f8SToomas Soome #define EFI_BREAKPOINT EFI_DEADLOOP()
110199767f8SToomas Soome 
111199767f8SToomas Soome 
112199767f8SToomas Soome //
113199767f8SToomas Soome // Memory Fence forces serialization, and is needed to support out of order
114199767f8SToomas Soome //  memory transactions. The Memory Fence is mainly used to make sure IO
115199767f8SToomas Soome //  transactions complete in a deterministic sequence, and to syncronize locks
116199767f8SToomas Soome //  an other MP code. Currently no memory fencing is required.
117199767f8SToomas Soome //
118199767f8SToomas Soome #define MEMORY_FENCE()
119199767f8SToomas Soome 
120199767f8SToomas Soome //
121199767f8SToomas Soome // Some compilers don't support the forward reference construct:
122199767f8SToomas Soome //  typedef struct XXXXX. The forward reference is required for
123199767f8SToomas Soome //  ANSI compatibility.
124199767f8SToomas Soome //
125199767f8SToomas Soome // The following macro provide a workaround for such cases.
126199767f8SToomas Soome //
127199767f8SToomas Soome 
128199767f8SToomas Soome 
129199767f8SToomas Soome #ifdef EFI_NO_INTERFACE_DECL
130199767f8SToomas Soome   #define EFI_FORWARD_DECLARATION(x)
131199767f8SToomas Soome #else
132199767f8SToomas Soome   #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
133199767f8SToomas Soome #endif
134199767f8SToomas Soome 
135199767f8SToomas Soome 
136199767f8SToomas Soome //
137199767f8SToomas Soome // Some C compilers optimize the calling conventions to increase performance.
138199767f8SToomas Soome // EFIAPI is used to make all public APIs follow the standard C calling
139199767f8SToomas Soome // convention.
140199767f8SToomas Soome //
141199767f8SToomas Soome #define EFIAPI
142199767f8SToomas Soome 
143199767f8SToomas Soome 
144199767f8SToomas Soome 
145199767f8SToomas Soome //
146199767f8SToomas Soome // For symbol name in GNU assembly code, an extra "_" is necessary
147199767f8SToomas Soome //
148199767f8SToomas Soome #if defined(__GNUC__)
149199767f8SToomas Soome   ///
150199767f8SToomas Soome   /// Private worker functions for ASM_PFX()
151199767f8SToomas Soome   ///
152199767f8SToomas Soome   #define _CONCATENATE(a, b)  __CONCATENATE(a, b)
153199767f8SToomas Soome   #define __CONCATENATE(a, b) a ## b
154199767f8SToomas Soome 
155199767f8SToomas Soome   ///
156199767f8SToomas Soome   /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix
157199767f8SToomas Soome   /// on symbols in assembly language.
158199767f8SToomas Soome   ///
159199767f8SToomas Soome   #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
160199767f8SToomas Soome 
161199767f8SToomas Soome #endif
162199767f8SToomas Soome 
163199767f8SToomas Soome #define INTERFACE_DECL(x) struct x
164199767f8SToomas Soome 
165199767f8SToomas Soome #endif
166