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