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.

199 lines
5.8 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 __int16 uint16_t;
  22. typedef __int16 int16_t;
  23. typedef unsigned __int8 uint8_t;
  24. typedef __int8 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. typedef uint32_t UINT32;
  55. typedef int32_t INT32;
  56. typedef uint16_t UINT16;
  57. typedef int16_t INT16;
  58. typedef uint8_t UINT8;
  59. typedef int8_t INT8;
  60. #undef VOID
  61. #define VOID void
  62. typedef int64_t INTN;
  63. typedef uint64_t UINTN;
  64. /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  65. * BugBug: Code to debug
  66. */
  67. #define BIT63 0x8000000000000000
  68. #define PLATFORM_IOBASE_ADDRESS (0xffffc000000 | BIT63)
  69. #define PORT_TO_MEMD(_Port) (PLATFORM_IOBASE_ADDRESS | ( ( ( (_Port) & 0xfffc) << 10 ) | ( (_Port) & 0x0fff) ) )
  70. /*
  71. * Macro's with casts make this much easier to use and read.
  72. */
  73. #define PORT_TO_MEM8D(_Port) (*(UINT8 *)(PORT_TO_MEMD(_Port)))
  74. #define POST_CODE(_Data) (PORT_TO_MEM8D(0x80) = (_Data))
  75. /*
  76. * BugBug: End Debug Code!!!
  77. * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
  78. #define EFIERR(a) (0x8000000000000000 | a)
  79. #define EFI_ERROR_MASK 0x8000000000000000
  80. #define EFIERR_OEM(a) (0xc000000000000000 | a)
  81. #define BAD_POINTER 0xFBFBFBFBFBFBFBFB
  82. #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
  83. #define BREAKPOINT() while (TRUE)
  84. /*
  85. * Pointers must be aligned to these address to function
  86. * you will get an alignment fault if this value is less than 8
  87. */
  88. #define MIN_ALIGNMENT_SIZE 8
  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 create data structure signatures.
  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. #define EXPORTAPI
  104. /*
  105. * EFIAPI - prototype calling convention for EFI function pointers
  106. * BOOTSERVICE - prototype for implementation of a boot service interface
  107. * RUNTIMESERVICE - prototype for implementation of a runtime service interface
  108. * RUNTIMEFUNCTION - prototype for implementation of a runtime function that is not a service
  109. * RUNTIME_CODE - pragma macro for declaring runtime code
  110. */
  111. #ifndef EFIAPI /* Forces EFI calling conventions reguardless of compiler options */
  112. #if _MSC_EXTENSIONS
  113. #define EFIAPI __cdecl /* Force C calling convention for Microsoft C compiler */
  114. #else
  115. #define EFIAPI /* Substitute expresion to force C calling convention */
  116. #endif
  117. #endif
  118. #define BOOTSERVICE
  119. #define RUNTIMESERVICE
  120. #define RUNTIMEFUNCTION
  121. #define RUNTIME_CODE(a) alloc_text("rtcode", a)
  122. #define BEGIN_RUNTIME_DATA() data_seg("rtdata")
  123. #define END_RUNTIME_DATA() data_seg("")
  124. #define VOLATILE volatile
  125. /*
  126. * BugBug: Need to find out if this is portable accross compliers.
  127. */
  128. void __mf (void);
  129. #pragma intrinsic (__mf)
  130. #define MEMORY_FENCE() __mf()
  131. /*
  132. * When build similiar to FW, then link everything together as
  133. * one big module.
  134. */
  135. #define EFI_DRIVER_ENTRY_POINT(InitFunction)
  136. #define LOAD_INTERNAL_DRIVER(_if, type, name, entry) \
  137. (_if)->LoadInternal(type, name, entry)
  138. /*
  139. * Some compilers don't support the forward reference construct:
  140. * typedef struct XXXXX
  141. *
  142. * The following macro provide a workaround for such cases.
  143. */
  144. #ifdef NO_INTERFACE_DECL
  145. #define INTERFACE_DECL(x)
  146. #else
  147. #define INTERFACE_DECL(x) typedef struct x
  148. #endif