xref: /freebsd/stand/efi/include/arm/efibind.h (revision 42249ef2)
1 /* $FreeBSD$ */
2 /*++
3 
4 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
5 
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution.  The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10 
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 Module Name:
15 
16   EfiBind.h
17 
18 Abstract:
19 
20   Processor or Compiler specific defines and types for IA-32.
21   We are using the ANSI C 2000 _t type definitions for basic types.
22   This it technically a violation of the coding standard, but they
23   are used to make EfiTypes.h portable. Code other than EfiTypes.h
24   should never use any ANSI C 2000 _t integer types.
25 
26 --*/
27 
28 #ifndef _EFI_BIND_H_
29 #define _EFI_BIND_H_
30 
31 
32 #define EFI_DRIVER_ENTRY_POINT(InitFunction)
33 #define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
34 
35 
36 //
37 // Make sure we are using the correct packing rules per EFI specification
38 //
39 #ifndef __GNUC__
40 #pragma pack()
41 #endif
42 
43 
44 #ifdef __FreeBSD__
45 #include <sys/stdint.h>
46 #else
47 //
48 // Assume standard IA-32 alignment.
49 // BugBug: Need to check portability of long long
50 //
51 typedef unsigned long long  uint64_t;
52 typedef long long           int64_t;
53 typedef unsigned int        uint32_t;
54 typedef int                 int32_t;
55 typedef unsigned short      uint16_t;
56 typedef short               int16_t;
57 typedef unsigned char       uint8_t;
58 typedef signed char         int8_t;
59 #endif
60 
61 typedef uint64_t   UINT64;
62 typedef int64_t    INT64;
63 typedef uint32_t   UINT32;
64 typedef int32_t    INT32;
65 typedef uint16_t   UINT16;
66 typedef int16_t    INT16;
67 typedef uint8_t    UINT8;
68 typedef int8_t     INT8;
69 
70 #undef VOID
71 #define VOID    void
72 
73 //
74 // Native integer size in stdint.h
75 //
76 typedef uint32_t  UINTN;
77 typedef int32_t   INTN;
78 
79 #define EFIERR(a)           (0x80000000 | a)
80 #define EFI_ERROR_MASK      0x80000000
81 #define EFIERR_OEM(a)       (0xc0000000 | a)
82 
83 //
84 // Processor specific defines
85 //
86 #define EFI_MAX_BIT       0x80000000
87 #define MAX_2_BITS        0xC0000000
88 
89 //
90 // Maximum legal IA-32 address
91 //
92 #define EFI_MAX_ADDRESS   0xFFFFFFFF
93 
94 //
95 //  Bad pointer value to use in check builds.
96 //  if you see this value you are using uninitialized or free'ed data
97 //
98 #define EFI_BAD_POINTER          0xAFAFAFAF
99 #define EFI_BAD_POINTER_AS_BYTE  0xAF
100 
101 #define EFI_DEADLOOP()    { volatile UINTN __iii; __iii = 1; while (__iii); }
102 
103 //
104 // Inject a break point in the code to assist debugging for NT Emulation Environment
105 // For real hardware, just put in a halt loop. Don't do a while(1) because the
106 // compiler will optimize away the rest of the function following, so that you run out in
107 // the weeds if you skip over it with a debugger.
108 //
109 #define EFI_BREAKPOINT EFI_DEADLOOP()
110 
111 
112 //
113 // Memory Fence forces serialization, and is needed to support out of order
114 //  memory transactions. The Memory Fence is mainly used to make sure IO
115 //  transactions complete in a deterministic sequence, and to syncronize locks
116 //  an other MP code. Currently no memory fencing is required.
117 //
118 #define MEMORY_FENCE()
119 
120 //
121 // Some compilers don't support the forward reference construct:
122 //  typedef struct XXXXX. The forward reference is required for
123 //  ANSI compatibility.
124 //
125 // The following macro provide a workaround for such cases.
126 //
127 
128 
129 #ifdef EFI_NO_INTERFACE_DECL
130   #define EFI_FORWARD_DECLARATION(x)
131 #else
132   #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
133 #endif
134 
135 
136 //
137 // Some C compilers optimize the calling conventions to increase performance.
138 // EFIAPI is used to make all public APIs follow the standard C calling
139 // convention.
140 //
141 #define EFIAPI
142 
143 
144 
145 //
146 // For symbol name in GNU assembly code, an extra "_" is necessary
147 //
148 #if defined(__GNUC__)
149   ///
150   /// Private worker functions for ASM_PFX()
151   ///
152   #define _CONCATENATE(a, b)  __CONCATENATE(a, b)
153   #define __CONCATENATE(a, b) a ## b
154 
155   ///
156   /// The __USER_LABEL_PREFIX__ macro predefined by GNUC represents the prefix
157   /// on symbols in assembly language.
158   ///
159   #define ASM_PFX(name) _CONCATENATE (__USER_LABEL_PREFIX__, name)
160 
161 #endif
162 
163 #define INTERFACE_DECL(x) struct x
164 
165 #endif
166