efibind.h (143250) | efibind.h (163898) |
---|---|
1/* $FreeBSD: head/sys/boot/efi/include/i386/efibind.h 143250 2005-03-07 15:38:37Z stefanf $ */ | 1/* $FreeBSD: head/sys/boot/efi/include/i386/efibind.h 163898 2006-11-02 02:42:48Z marcel $ */ |
2/*++ 3 | 2/*++ 3 |
4Copyright (c) 1998 Intel Corporation | 4Copyright (c) 1999 - 2003 Intel Corporation. All rights reserved 5This software and associated documentation (if any) is furnished 6under a license and may only be used or copied in accordance 7with the terms of the license. Except as permitted by such 8license, no part of this software or documentation may be 9reproduced, stored in a retrieval system, or transmitted in any 10form or by any means without the express written consent of 11Intel Corporation. |
5 6Module Name: 7 8 efefind.h 9 10Abstract: 11 12 EFI to compile bindings 13 14 15 16 17Revision History 18 19--*/ 20 21#pragma pack() 22 23 | 12 13Module Name: 14 15 efefind.h 16 17Abstract: 18 19 EFI to compile bindings 20 21 22 23 24Revision History 25 26--*/ 27 28#pragma pack() 29 30 |
24/* 25 * Basic int types of various widths 26 */ | 31#ifdef __FreeBSD__ 32#include <sys/stdint.h> 33#else 34// 35// Basic int types of various widths 36// |
27 28#if (__STDC_VERSION__ < 199901L ) 29 | 37 38#if (__STDC_VERSION__ < 199901L ) 39 |
30/* No ANSI C 1999/2000 stdint.h integer width declarations */ | 40 // No ANSI C 1999/2000 stdint.h integer width declarations |
31 32 #if _MSC_EXTENSIONS 33 | 41 42 #if _MSC_EXTENSIONS 43 |
34/* Use Microsoft C compiler integer width declarations */ | 44 // Use Microsoft C compiler integer width declarations |
35 36 typedef unsigned __int64 uint64_t; 37 typedef __int64 int64_t; 38 typedef unsigned __int32 uint32_t; 39 typedef __int32 int32_t; 40 typedef unsigned short uint16_t; 41 typedef short int16_t; 42 typedef unsigned char uint8_t; 43 typedef char int8_t; 44 #else 45 #ifdef UNIX_LP64 46 | 45 46 typedef unsigned __int64 uint64_t; 47 typedef __int64 int64_t; 48 typedef unsigned __int32 uint32_t; 49 typedef __int32 int32_t; 50 typedef unsigned short uint16_t; 51 typedef short int16_t; 52 typedef unsigned char uint8_t; 53 typedef char int8_t; 54 #else 55 #ifdef UNIX_LP64 56 |
47/* Use LP64 programming model from C_FLAGS for integer width declarations */ | 57 // Use LP64 programming model from C_FLAGS for integer width declarations |
48 49 typedef unsigned long uint64_t; 50 typedef long int64_t; 51 typedef unsigned int uint32_t; 52 typedef int int32_t; 53 typedef unsigned short uint16_t; 54 typedef short int16_t; 55 typedef unsigned char uint8_t; 56 typedef char int8_t; 57 #else 58 | 58 59 typedef unsigned long uint64_t; 60 typedef long int64_t; 61 typedef unsigned int uint32_t; 62 typedef int int32_t; 63 typedef unsigned short uint16_t; 64 typedef short int16_t; 65 typedef unsigned char uint8_t; 66 typedef char int8_t; 67 #else 68 |
59/* Assume P64 programming model from C_FLAGS for integer width declarations */ | 69 // Assume P64 programming model from C_FLAGS for integer width declarations |
60 61 typedef unsigned long long uint64_t; 62 typedef long long int64_t; 63 typedef unsigned int uint32_t; 64 typedef int int32_t; 65 typedef unsigned short uint16_t; 66 typedef short int16_t; 67 typedef unsigned char uint8_t; 68 typedef char int8_t; 69 #endif 70 #endif 71#endif | 70 71 typedef unsigned long long uint64_t; 72 typedef long long int64_t; 73 typedef unsigned int uint32_t; 74 typedef int int32_t; 75 typedef unsigned short uint16_t; 76 typedef short int16_t; 77 typedef unsigned char uint8_t; 78 typedef char int8_t; 79 #endif 80 #endif 81#endif |
82#endif /* __FreeBSD__ */ |
|
72 | 83 |
73/* 74 * Basic EFI types of various widths 75 */ | 84// 85// Basic EFI types of various widths 86// |
76 77typedef uint64_t UINT64; 78typedef int64_t INT64; 79 80#ifndef _BASETSD_H_ 81 typedef uint32_t UINT32; 82 typedef int32_t INT32; 83#endif --- 24 unchanged lines hidden (view full) --- 108#define EFIERR(a) (0x80000000 | a) 109#define EFI_ERROR_MASK 0x80000000 110#define EFIERR_OEM(a) (0xc0000000 | a) 111 112 113#define BAD_POINTER 0xFBFBFBFB 114#define MAX_ADDRESS 0xFFFFFFFF 115 | 87 88typedef uint64_t UINT64; 89typedef int64_t INT64; 90 91#ifndef _BASETSD_H_ 92 typedef uint32_t UINT32; 93 typedef int32_t INT32; 94#endif --- 24 unchanged lines hidden (view full) --- 119#define EFIERR(a) (0x80000000 | a) 120#define EFI_ERROR_MASK 0x80000000 121#define EFIERR_OEM(a) (0xc0000000 | a) 122 123 124#define BAD_POINTER 0xFBFBFBFB 125#define MAX_ADDRESS 0xFFFFFFFF 126 |
116#ifdef EFI_NT_EMULATOR 117 #define BREAKPOINT() __asm { int 3 } 118#else 119 #define BREAKPOINT() while (TRUE); 120#endif | 127#define BREAKPOINT() __asm { int 3 } |
121 | 128 |
122/* 123 * Pointers must be aligned to these address to function 124 */ | 129// 130// Pointers must be aligned to these address to function 131// |
125 126#define MIN_ALIGNMENT_SIZE 4 127 128#define ALIGN_VARIABLE(Value ,Adjustment) \ 129 (UINTN)Adjustment = 0; \ 130 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 131 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 132 Value = (UINTN)Value + (UINTN)Adjustment 133 134 | 132 133#define MIN_ALIGNMENT_SIZE 4 134 135#define ALIGN_VARIABLE(Value ,Adjustment) \ 136 (UINTN)Adjustment = 0; \ 137 if((UINTN)Value % MIN_ALIGNMENT_SIZE) \ 138 (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \ 139 Value = (UINTN)Value + (UINTN)Adjustment 140 141 |
135/* 136 * Define macros to build data structure signatures from characters. 137 */ | 142// 143// Define macros to build data structure signatures from characters. 144// |
138 139#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 140#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 141#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)) 142 | 145 146#define EFI_SIGNATURE_16(A,B) ((A) | (B<<8)) 147#define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16)) 148#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)) 149 |
143/* 144 * To export & import functions in the EFI emulator environment 145 */ | 150// 151// EFIAPI - prototype calling convention for EFI function pointers 152// BOOTSERVICE - prototype for implementation of a boot service interface 153// RUNTIMESERVICE - prototype for implementation of a runtime service interface 154// RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service 155// RUNTIME_CODE - pragma macro for declaring runtime code 156// |
146 | 157 |
147#if EFI_NT_EMULATOR 148 #define EXPORTAPI __declspec( dllexport ) 149#else 150 #define EXPORTAPI 151#endif 152 153 154/* 155 * EFIAPI - prototype calling convention for EFI function pointers 156 * BOOTSERVICE - prototype for implementation of a boot service interface 157 * RUNTIMESERVICE - prototype for implementation of a runtime service interface 158 * RUNTIMEFUNCTION - prototype for implementation of a runtime function that 159 * is not a service 160 * RUNTIME_CODE - pragma macro for declaring runtime code 161 */ 162 163/* Forces EFI calling conventions reguardless of compiler options */ 164#ifndef EFIAPI | 158#ifndef EFIAPI // Forces EFI calling conventions reguardless of compiler options |
165 #if _MSC_EXTENSIONS | 159 #if _MSC_EXTENSIONS |
166 #define EFIAPI __cdecl | 160 #define EFIAPI __cdecl // Force C calling convention for Microsoft C compiler |
167 #else | 161 #else |
168 #define EFIAPI | 162 #define EFIAPI // Substitute expresion to force C calling convention |
169 #endif 170#endif 171 172#define BOOTSERVICE | 163 #endif 164#endif 165 166#define BOOTSERVICE |
167//#define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a 168//#define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a |
|
173#define RUNTIMESERVICE 174#define RUNTIMEFUNCTION 175 176 177#define RUNTIME_CODE(a) alloc_text("rtcode", a) 178#define BEGIN_RUNTIME_DATA() data_seg("rtdata") | 169#define RUNTIMESERVICE 170#define RUNTIMEFUNCTION 171 172 173#define RUNTIME_CODE(a) alloc_text("rtcode", a) 174#define BEGIN_RUNTIME_DATA() data_seg("rtdata") |
179#define END_RUNTIME_DATA() data_seg("") | 175#define END_RUNTIME_DATA() data_seg() |
180 181#define VOLATILE volatile 182 183#define MEMORY_FENCE() 184 | 176 177#define VOLATILE volatile 178 179#define MEMORY_FENCE() 180 |
181#ifdef EFI_NO_INTERFACE_DECL 182 #define EFI_FORWARD_DECLARATION(x) 183 #define EFI_INTERFACE_DECL(x) 184#else 185 #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x 186 #define EFI_INTERFACE_DECL(x) typedef struct x 187#endif 188 |
|
185#ifdef EFI_NT_EMULATOR 186 | 189#ifdef EFI_NT_EMULATOR 190 |
187/* 188 * To help ensure proper coding of integrated drivers, they are 189 * compiled as DLLs. In NT they require a dll init entry pointer. 190 * The macro puts a stub entry point into the DLL so it will load. 191 */ | 191// 192// To help ensure proper coding of integrated drivers, they are 193// compiled as DLLs. In NT they require a dll init entry pointer. 194// The macro puts a stub entry point into the DLL so it will load. 195// |
192 | 196 |
193#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 194 UINTN \ 195 __stdcall \ 196 _DllMainCRTStartup ( \ 197 UINTN Inst, \ 198 UINTN reason_for_call, \ 199 VOID *rserved \ 200 ) \ 201 { \ 202 return 1; \ 203 } \ 204 \ 205 int \ 206 EXPORTAPI \ 207 __cdecl \ 208 InitializeDriver ( \ 209 void *ImageHandle, \ 210 void *SystemTable \ 211 ) \ 212 { \ 213 return InitFunction(ImageHandle, SystemTable); \ | 197#define EFI_DRIVER_ENTRY_POINT(InitFunction) \ 198 EFI_STATUS \ 199 InitFunction ( \ 200 EFI_HANDLE ImageHandle, \ 201 EFI_SYSTEM_TABLE *SystemTable \ 202 ); \ 203 \ 204 UINTN \ 205 __stdcall \ 206 _DllMainCRTStartup ( \ 207 UINTN Inst, \ 208 UINTN reason_for_call, \ 209 VOID *rserved \ 210 ) \ 211 { \ 212 return 1; \ 213 } \ 214 \ 215 int \ 216 __declspec( dllexport ) \ 217 __cdecl \ 218 InitializeDriver ( \ 219 void *ImageHandle, \ 220 void *SystemTable \ 221 ) \ 222 { \ 223 return InitFunction(ImageHandle, SystemTable); \ |
214 } 215 216 217 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 218 (_if)->LoadInternal(type, name, NULL) 219 | 224 } 225 226 227 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 228 (_if)->LoadInternal(type, name, NULL) 229 |
220#else /* EFI_NT_EMULATOR */ | 230#else // EFI_NT_EMULATOR |
221 | 231 |
222/* 223 * When build similiar to FW, then link everything together as 224 * one big module. 225 */ | 232// 233// When build similiar to FW, then link everything together as 234// one big module. 235// |
226 227 #define EFI_DRIVER_ENTRY_POINT(InitFunction) 228 229 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 230 (_if)->LoadInternal(type, name, entry) 231 | 236 237 #define EFI_DRIVER_ENTRY_POINT(InitFunction) 238 239 #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \ 240 (_if)->LoadInternal(type, name, entry) 241 |
232#endif /* EFI_FW_NT */ | 242#endif // EFI_FW_NT |
233 | 243 |
244#ifdef __FreeBSD__ |
|
234#define INTERFACE_DECL(x) struct x | 245#define INTERFACE_DECL(x) struct x |
246#else 247// 248// Some compilers don't support the forward reference construct: 249// typedef struct XXXXX 250// 251// The following macro provide a workaround for such cases. 252// 253#ifdef NO_INTERFACE_DECL 254#define INTERFACE_DECL(x) 255#else 256#define INTERFACE_DECL(x) typedef struct x 257#endif 258#endif /* __FreeBSD__ */ |
|
235 236#if _MSC_EXTENSIONS | 259 260#if _MSC_EXTENSIONS |
237#pragma warning ( disable : 4731 ) | 261#pragma warning ( disable : 4731 ) // Suppress warnings about modification of EBP |
238#endif 239 | 262#endif 263 |