Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

244 lines
6.7 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. efefind.h
  5. Abstract:
  6. EFI to compile bindings
  7. Revision History
  8. --*/
  9. #pragma pack()
  10. /*
  11. * Basic int types of various widths
  12. */
  13. #if (__STDC_VERSION__ < 199901L )
  14. /* No ANSI C 1999/2000 stdint.h integer width declarations */
  15. #if _MSC_EXTENSIONS
  16. /* Use Microsoft C compiler integer width declarations */
  17. typedef unsigned __int64 uint64_t;
  18. typedef __int64 int64_t;
  19. typedef unsigned __int32 uint32_t;
  20. typedef __int32 int32_t;
  21. typedef unsigned short uint16_t;
  22. typedef short int16_t;
  23. typedef unsigned char uint8_t;
  24. typedef char int8_t;
  25. #else
  26. #ifdef UNIX_LP64
  27. /* Use LP64 programming model from C_FLAGS for integer width declarations */
  28. typedef unsigned long uint64_t;
  29. typedef long int64_t;
  30. typedef unsigned int uint32_t;
  31. typedef int int32_t;
  32. typedef unsigned short uint16_t;
  33. typedef short int16_t;
  34. typedef unsigned char uint8_t;
  35. typedef char int8_t;
  36. #else
  37. /* Assume P64 programming model from C_FLAGS for integer width declarations */
  38. typedef unsigned long long uint64_t;
  39. typedef long long int64_t;
  40. typedef unsigned int uint32_t;
  41. typedef int int32_t;
  42. typedef unsigned short uint16_t;
  43. typedef short int16_t;
  44. typedef unsigned char uint8_t;
  45. typedef char int8_t;
  46. #endif
  47. #endif
  48. #endif
  49. /*
  50. * Basic EFI types of various widths
  51. */
  52. typedef uint64_t UINT64;
  53. typedef int64_t INT64;
  54. #ifndef _BASETSD_H_
  55. typedef uint32_t UINT32;
  56. typedef int32_t INT32;
  57. #endif
  58. typedef uint16_t UINT16;
  59. typedef int16_t INT16;
  60. typedef uint8_t UINT8;
  61. typedef int8_t INT8;
  62. #undef VOID
  63. #define VOID void
  64. typedef int32_t INTN;
  65. typedef uint32_t UINTN;
  66. #ifdef EFI_NT_EMULATOR
  67. #define POST_CODE(_Data)
  68. #else
  69. #ifdef EFI_DEBUG
  70. #define POST_CODE(_Data) __asm mov eax,(_Data) __asm out 0x80,al
  71. #else
  72. #define POST_CODE(_Data)
  73. #endif
  74. #endif
  75. #define EFIERR(a) (0x80000000 | a)
  76. #define EFI_ERROR_MASK 0x80000000
  77. #define EFIERR_OEM(a) (0xc0000000 | a)
  78. #define BAD_POINTER 0xFBFBFBFB
  79. #define MAX_ADDRESS 0xFFFFFFFF
  80. #ifdef EFI_NT_EMULATOR
  81. #define BREAKPOINT() __asm { int 3 }
  82. #else
  83. #define BREAKPOINT() while (TRUE); /* Make it hang on Bios[Dbg]32 */
  84. #endif
  85. /*
  86. * Pointers must be aligned to these address to function
  87. */
  88. #define MIN_ALIGNMENT_SIZE 4
  89. #define ALIGN_VARIABLE(Value ,Adjustment) \
  90. (UINTN)Adjustment = 0; \
  91. if((UINTN)Value % MIN_ALIGNMENT_SIZE) \
  92. (UINTN)Adjustment = MIN_ALIGNMENT_SIZE - ((UINTN)Value % MIN_ALIGNMENT_SIZE); \
  93. Value = (UINTN)Value + (UINTN)Adjustment
  94. /*
  95. * Define macros to build data structure signatures from characters.
  96. */
  97. #define EFI_SIGNATURE_16(A,B) ((A) | (B<<8))
  98. #define EFI_SIGNATURE_32(A,B,C,D) (EFI_SIGNATURE_16(A,B) | (EFI_SIGNATURE_16(C,D) << 16))
  99. #define EFI_SIGNATURE_64(A,B,C,D,E,F,G,H) (EFI_SIGNATURE_32(A,B,C,D) | (EFI_SIGNATURE_32(E,F,G,H) << 32))
  100. /*
  101. * To export & import functions in the EFI emulator environment
  102. */
  103. #if EFI_NT_EMULATOR
  104. #define EXPORTAPI __declspec( dllexport )
  105. #else
  106. #define EXPORTAPI
  107. #endif
  108. /*
  109. * EFIAPI - prototype calling convention for EFI function pointers
  110. * BOOTSERVICE - prototype for implementation of a boot service interface
  111. * RUNTIMESERVICE - prototype for implementation of a runtime service interface
  112. * RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
  113. * RUNTIME_CODE - pragma macro for declaring runtime code
  114. */
  115. #ifndef EFIAPI /* Forces EFI calling conventions reguardless of compiler options */
  116. #if _MSC_EXTENSIONS
  117. #define EFIAPI __cdecl /* Force C calling convention for Microsoft C compiler */
  118. #else
  119. #define EFIAPI /* Substitute expresion to force C calling convention */
  120. #endif
  121. #endif
  122. #define BOOTSERVICE
  123. /* #define RUNTIMESERVICE(proto,a) alloc_text("rtcode",a); proto a
  124. * #define RUNTIMEFUNCTION(proto,a) alloc_text("rtcode",a); proto a */
  125. #define RUNTIMESERVICE
  126. #define RUNTIMEFUNCTION
  127. #define RUNTIME_CODE(a) alloc_text("rtcode", a)
  128. #define BEGIN_RUNTIME_DATA() data_seg("rtdata")
  129. #define END_RUNTIME_DATA() data_seg("")
  130. #define VOLATILE volatile
  131. #define MEMORY_FENCE()
  132. #ifdef EFI_NT_EMULATOR
  133. /*
  134. * To help ensure proper coding of integrated drivers, they are
  135. * compiled as DLLs. In NT they require a dll init entry pointer.
  136. * The macro puts a stub entry point into the DLL so it will load.
  137. */
  138. #define EFI_DRIVER_ENTRY_POINT(InitFunction) \
  139. UINTN \
  140. __stdcall \
  141. _DllMainCRTStartup ( \
  142. UINTN Inst, \
  143. UINTN reason_for_call, \
  144. VOID *rserved \
  145. ) \
  146. { \
  147. return 1; \
  148. } \
  149. \
  150. int \
  151. EXPORTAPI \
  152. __cdecl \
  153. InitializeDriver ( \
  154. void *ImageHandle, \
  155. void *SystemTable \
  156. ) \
  157. { \
  158. return InitFunction(ImageHandle, SystemTable); \
  159. }
  160. #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
  161. (_if)->LoadInternal(type, name, NULL)
  162. #else /* EFI_NT_EMULATOR */
  163. /*
  164. * When build similiar to FW, then link everything together as
  165. * one big module.
  166. */
  167. #define EFI_DRIVER_ENTRY_POINT(InitFunction)
  168. #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
  169. (_if)->LoadInternal(type, name, entry)
  170. #endif /* EFI_FW_NT */
  171. /*
  172. * Some compilers don't support the forward reference construct:
  173. * typedef struct XXXXX
  174. *
  175. * The following macro provide a workaround for such cases.
  176. */
  177. #ifdef NO_INTERFACE_DECL
  178. #define INTERFACE_DECL(x)
  179. #else
  180. #define INTERFACE_DECL(x) typedef struct x
  181. #endif