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