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.

UefiBaseType.h 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /** @file
  2. Defines data types and constants introduced in UEFI.
  3. Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
  4. This program and the accompanying materials are licensed and made available under
  5. the terms and conditions of the BSD License that accompanies this distribution.
  6. The full text of the license may be found at
  7. http://opensource.org/licenses/bsd-license.php.
  8. THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  10. **/
  11. #ifndef __UEFI_BASETYPE_H__
  12. #define __UEFI_BASETYPE_H__
  13. #include <ipxe/efi/Base.h>
  14. //
  15. // Basic data type definitions introduced in UEFI.
  16. //
  17. ///
  18. /// 128-bit buffer containing a unique identifier value.
  19. ///
  20. typedef GUID EFI_GUID;
  21. ///
  22. /// Function return status for EFI API.
  23. ///
  24. typedef RETURN_STATUS EFI_STATUS;
  25. ///
  26. /// A collection of related interfaces.
  27. ///
  28. typedef VOID *EFI_HANDLE;
  29. ///
  30. /// Handle to an event structure.
  31. ///
  32. typedef VOID *EFI_EVENT;
  33. ///
  34. /// Task priority level.
  35. ///
  36. typedef UINTN EFI_TPL;
  37. ///
  38. /// Logical block address.
  39. ///
  40. typedef UINT64 EFI_LBA;
  41. ///
  42. /// 64-bit physical memory address.
  43. ///
  44. typedef UINT64 EFI_PHYSICAL_ADDRESS;
  45. ///
  46. /// 64-bit virtual memory address.
  47. ///
  48. typedef UINT64 EFI_VIRTUAL_ADDRESS;
  49. ///
  50. /// EFI Time Abstraction:
  51. /// Year: 1900 - 9999
  52. /// Month: 1 - 12
  53. /// Day: 1 - 31
  54. /// Hour: 0 - 23
  55. /// Minute: 0 - 59
  56. /// Second: 0 - 59
  57. /// Nanosecond: 0 - 999,999,999
  58. /// TimeZone: -1440 to 1440 or 2047
  59. ///
  60. typedef struct {
  61. UINT16 Year;
  62. UINT8 Month;
  63. UINT8 Day;
  64. UINT8 Hour;
  65. UINT8 Minute;
  66. UINT8 Second;
  67. UINT8 Pad1;
  68. UINT32 Nanosecond;
  69. INT16 TimeZone;
  70. UINT8 Daylight;
  71. UINT8 Pad2;
  72. } EFI_TIME;
  73. ///
  74. /// 4-byte buffer. An IPv4 internet protocol address.
  75. ///
  76. typedef struct {
  77. UINT8 Addr[4];
  78. } EFI_IPv4_ADDRESS;
  79. ///
  80. /// 16-byte buffer. An IPv6 internet protocol address.
  81. ///
  82. typedef struct {
  83. UINT8 Addr[16];
  84. } EFI_IPv6_ADDRESS;
  85. ///
  86. /// 32-byte buffer containing a network Media Access Control address.
  87. ///
  88. typedef struct {
  89. UINT8 Addr[32];
  90. } EFI_MAC_ADDRESS;
  91. ///
  92. /// 16-byte buffer aligned on a 4-byte boundary.
  93. /// An IPv4 or IPv6 internet protocol address.
  94. ///
  95. typedef union {
  96. UINT32 Addr[4];
  97. EFI_IPv4_ADDRESS v4;
  98. EFI_IPv6_ADDRESS v6;
  99. } EFI_IP_ADDRESS;
  100. ///
  101. /// Enumeration of EFI_STATUS.
  102. ///@{
  103. #define EFI_SUCCESS RETURN_SUCCESS
  104. #define EFI_LOAD_ERROR RETURN_LOAD_ERROR
  105. #define EFI_INVALID_PARAMETER RETURN_INVALID_PARAMETER
  106. #define EFI_UNSUPPORTED RETURN_UNSUPPORTED
  107. #define EFI_BAD_BUFFER_SIZE RETURN_BAD_BUFFER_SIZE
  108. #define EFI_BUFFER_TOO_SMALL RETURN_BUFFER_TOO_SMALL
  109. #define EFI_NOT_READY RETURN_NOT_READY
  110. #define EFI_DEVICE_ERROR RETURN_DEVICE_ERROR
  111. #define EFI_WRITE_PROTECTED RETURN_WRITE_PROTECTED
  112. #define EFI_OUT_OF_RESOURCES RETURN_OUT_OF_RESOURCES
  113. #define EFI_VOLUME_CORRUPTED RETURN_VOLUME_CORRUPTED
  114. #define EFI_VOLUME_FULL RETURN_VOLUME_FULL
  115. #define EFI_NO_MEDIA RETURN_NO_MEDIA
  116. #define EFI_MEDIA_CHANGED RETURN_MEDIA_CHANGED
  117. #define EFI_NOT_FOUND RETURN_NOT_FOUND
  118. #define EFI_ACCESS_DENIED RETURN_ACCESS_DENIED
  119. #define EFI_NO_RESPONSE RETURN_NO_RESPONSE
  120. #define EFI_NO_MAPPING RETURN_NO_MAPPING
  121. #define EFI_TIMEOUT RETURN_TIMEOUT
  122. #define EFI_NOT_STARTED RETURN_NOT_STARTED
  123. #define EFI_ALREADY_STARTED RETURN_ALREADY_STARTED
  124. #define EFI_ABORTED RETURN_ABORTED
  125. #define EFI_ICMP_ERROR RETURN_ICMP_ERROR
  126. #define EFI_TFTP_ERROR RETURN_TFTP_ERROR
  127. #define EFI_PROTOCOL_ERROR RETURN_PROTOCOL_ERROR
  128. #define EFI_INCOMPATIBLE_VERSION RETURN_INCOMPATIBLE_VERSION
  129. #define EFI_SECURITY_VIOLATION RETURN_SECURITY_VIOLATION
  130. #define EFI_CRC_ERROR RETURN_CRC_ERROR
  131. #define EFI_END_OF_MEDIA RETURN_END_OF_MEDIA
  132. #define EFI_END_OF_FILE RETURN_END_OF_FILE
  133. #define EFI_INVALID_LANGUAGE RETURN_INVALID_LANGUAGE
  134. #define EFI_WARN_UNKNOWN_GLYPH RETURN_WARN_UNKNOWN_GLYPH
  135. #define EFI_WARN_DELETE_FAILURE RETURN_WARN_DELETE_FAILURE
  136. #define EFI_WARN_WRITE_FAILURE RETURN_WARN_WRITE_FAILURE
  137. #define EFI_WARN_BUFFER_TOO_SMALL RETURN_WARN_BUFFER_TOO_SMALL
  138. ///@}
  139. ///
  140. /// Define macro to encode the status code.
  141. ///
  142. #define EFIERR(_a) ENCODE_ERROR(_a)
  143. #define EFI_ERROR(A) RETURN_ERROR(A)
  144. ///
  145. /// ICMP error definitions
  146. ///@{
  147. #define EFI_NETWORK_UNREACHABLE EFIERR(100)
  148. #define EFI_HOST_UNREACHABLE EFIERR(101)
  149. #define EFI_PROTOCOL_UNREACHABLE EFIERR(102)
  150. #define EFI_PORT_UNREACHABLE EFIERR(103)
  151. ///@}
  152. ///
  153. /// Tcp connection status definitions
  154. ///@{
  155. #define EFI_CONNECTION_FIN EFIERR(104)
  156. #define EFI_CONNECTION_RESET EFIERR(105)
  157. #define EFI_CONNECTION_REFUSED EFIERR(106)
  158. ///@}
  159. //
  160. // The EFI memory allocation functions work in units of EFI_PAGEs that are
  161. // 4K. This should in no way be confused with the page size of the processor.
  162. // An EFI_PAGE is just the quanta of memory in EFI.
  163. //
  164. #define EFI_PAGE_SIZE 0x1000
  165. #define EFI_PAGE_MASK 0xFFF
  166. #define EFI_PAGE_SHIFT 12
  167. #define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))
  168. #define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)
  169. ///
  170. /// PE32+ Machine type for IA32 UEFI images.
  171. ///
  172. #define EFI_IMAGE_MACHINE_IA32 0x014C
  173. ///
  174. /// PE32+ Machine type for IA64 UEFI images.
  175. ///
  176. #define EFI_IMAGE_MACHINE_IA64 0x0200
  177. ///
  178. /// PE32+ Machine type for EBC UEFI images.
  179. ///
  180. #define EFI_IMAGE_MACHINE_EBC 0x0EBC
  181. ///
  182. /// PE32+ Machine type for X64 UEFI images.
  183. ///
  184. #define EFI_IMAGE_MACHINE_X64 0x8664
  185. ///
  186. /// PE32+ Machine type for ARM mixed ARM and Thumb/Thumb2 images.
  187. ///
  188. #define EFI_IMAGE_MACHINE_ARMTHUMB_MIXED 0x01C2
  189. #if defined (MDE_CPU_IA32)
  190. #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
  191. (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
  192. #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64)
  193. #elif defined (MDE_CPU_IPF)
  194. #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
  195. (((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
  196. #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
  197. #elif defined (MDE_CPU_X64)
  198. #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
  199. (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
  200. #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32)
  201. #elif defined (MDE_CPU_ARM)
  202. #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
  203. (((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
  204. #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_ARMTHUMB_MIXED)
  205. #elif defined (MDE_CPU_EBC)
  206. ///
  207. /// This is just to make sure you can cross compile with the EBC compiler.
  208. /// It does not make sense to have a PE loader coded in EBC.
  209. ///
  210. #define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)
  211. #define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
  212. #else
  213. #error Unknown Processor Type
  214. #endif
  215. #endif