fsp_hob.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /* SPDX-License-Identifier: Intel */
  2. /*
  3. * Copyright (C) 2013, Intel Corporation
  4. * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
  5. */
  6. #ifndef __FSP_HOB_H__
  7. #define __FSP_HOB_H__
  8. #include <efi.h>
  9. /* Type of HOB Header */
  10. #define HOB_TYPE_MEM_ALLOC 0x0002
  11. #define HOB_TYPE_RES_DESC 0x0003
  12. #define HOB_TYPE_GUID_EXT 0x0004
  13. #define HOB_TYPE_UNUSED 0xFFFE
  14. #define HOB_TYPE_EOH 0xFFFF
  15. /*
  16. * Describes the format and size of the data inside the HOB.
  17. * All HOBs must contain this generic HOB header.
  18. */
  19. struct hob_header {
  20. u16 type; /* HOB type */
  21. u16 len; /* HOB length */
  22. u32 reserved; /* always zero */
  23. };
  24. /*
  25. * Describes all memory ranges used during the HOB producer phase that
  26. * exist outside the HOB list. This HOB type describes how memory is used,
  27. * not the physical attributes of memory.
  28. */
  29. struct hob_mem_alloc {
  30. struct hob_header hdr;
  31. /*
  32. * A GUID that defines the memory allocation region's type and purpose,
  33. * as well as other fields within the memory allocation HOB. This GUID
  34. * is used to define the additional data within the HOB that may be
  35. * present for the memory allocation HOB. Type efi_guid is defined in
  36. * InstallProtocolInterface() in the UEFI 2.0 specification.
  37. */
  38. struct efi_guid name;
  39. /*
  40. * The base address of memory allocated by this HOB.
  41. * Type phys_addr_t is defined in AllocatePages() in the UEFI 2.0
  42. * specification.
  43. */
  44. phys_addr_t mem_base;
  45. /* The length in bytes of memory allocated by this HOB */
  46. phys_size_t mem_len;
  47. /*
  48. * Defines the type of memory allocated by this HOB.
  49. * The memory type definition follows the EFI_MEMORY_TYPE definition.
  50. * Type EFI_MEMORY_TYPE is defined in AllocatePages() in the UEFI 2.0
  51. * specification.
  52. */
  53. enum efi_mem_type mem_type;
  54. /* padding */
  55. u8 reserved[4];
  56. };
  57. /* Value of ResourceType in HOB_RES_DESC */
  58. #define RES_SYS_MEM 0x00000000
  59. #define RES_MMAP_IO 0x00000001
  60. #define RES_IO 0x00000002
  61. #define RES_FW_DEVICE 0x00000003
  62. #define RES_MMAP_IO_PORT 0x00000004
  63. #define RES_MEM_RESERVED 0x00000005
  64. #define RES_IO_RESERVED 0x00000006
  65. #define RES_MAX_MEM_TYPE 0x00000007
  66. /*
  67. * These types can be ORed together as needed.
  68. *
  69. * The first three enumerations describe settings
  70. * The rest of the settings describe capabilities
  71. */
  72. #define RES_ATTR_PRESENT 0x00000001
  73. #define RES_ATTR_INITIALIZED 0x00000002
  74. #define RES_ATTR_TESTED 0x00000004
  75. #define RES_ATTR_SINGLE_BIT_ECC 0x00000008
  76. #define RES_ATTR_MULTIPLE_BIT_ECC 0x00000010
  77. #define RES_ATTR_ECC_RESERVED_1 0x00000020
  78. #define RES_ATTR_ECC_RESERVED_2 0x00000040
  79. #define RES_ATTR_READ_PROTECTED 0x00000080
  80. #define RES_ATTR_WRITE_PROTECTED 0x00000100
  81. #define RES_ATTR_EXECUTION_PROTECTED 0x00000200
  82. #define RES_ATTR_UNCACHEABLE 0x00000400
  83. #define RES_ATTR_WRITE_COMBINEABLE 0x00000800
  84. #define RES_ATTR_WRITE_THROUGH_CACHEABLE 0x00001000
  85. #define RES_ATTR_WRITE_BACK_CACHEABLE 0x00002000
  86. #define RES_ATTR_16_BIT_IO 0x00004000
  87. #define RES_ATTR_32_BIT_IO 0x00008000
  88. #define RES_ATTR_64_BIT_IO 0x00010000
  89. #define RES_ATTR_UNCACHED_EXPORTED 0x00020000
  90. /*
  91. * Describes the resource properties of all fixed, nonrelocatable resource
  92. * ranges found on the processor host bus during the HOB producer phase.
  93. */
  94. struct hob_res_desc {
  95. struct hob_header hdr;
  96. /*
  97. * A GUID representing the owner of the resource. This GUID is
  98. * used by HOB consumer phase components to correlate device
  99. * ownership of a resource.
  100. */
  101. struct efi_guid owner;
  102. u32 type;
  103. u32 attr;
  104. /* The physical start address of the resource region */
  105. phys_addr_t phys_start;
  106. /* The number of bytes of the resource region */
  107. phys_size_t len;
  108. };
  109. /*
  110. * Allows writers of executable content in the HOB producer phase to
  111. * maintain and manage HOBs with specific GUID.
  112. */
  113. struct hob_guid {
  114. struct hob_header hdr;
  115. /* A GUID that defines the contents of this HOB */
  116. struct efi_guid name;
  117. /* GUID specific data goes here */
  118. };
  119. enum pixel_format {
  120. pixel_rgbx_8bpc, /* RGB 8 bit per color */
  121. pixel_bgrx_8bpc, /* BGR 8 bit per color */
  122. pixel_bitmask,
  123. };
  124. struct __packed hob_graphics_info {
  125. phys_addr_t fb_base; /* framebuffer base address */
  126. u32 fb_size; /* framebuffer size */
  127. u32 version;
  128. u32 width;
  129. u32 height;
  130. enum pixel_format pixel_format;
  131. u32 red_mask;
  132. u32 green_mask;
  133. u32 blue_mask;
  134. u32 reserved_mask;
  135. u32 pixels_per_scanline;
  136. };
  137. /**
  138. * get_next_hob() - return a pointer to the next HOB in the HOB list
  139. *
  140. * This macro returns a pointer to HOB that follows the HOB specified by hob
  141. * in the HOB List.
  142. *
  143. * @hdr: A pointer to a HOB.
  144. *
  145. * @return: A pointer to the next HOB in the HOB list.
  146. */
  147. static inline const struct hob_header *get_next_hob(const struct hob_header *hdr)
  148. {
  149. return (const struct hob_header *)((uintptr_t)hdr + hdr->len);
  150. }
  151. /**
  152. * end_of_hob() - determine if a HOB is the last HOB in the HOB list
  153. *
  154. * This macro determine if the HOB specified by hob is the last HOB in the
  155. * HOB list. If hob is last HOB in the HOB list, then true is returned.
  156. * Otherwise, false is returned.
  157. *
  158. * @hdr: A pointer to a HOB.
  159. *
  160. * @retval true: The HOB specified by hdr is the last HOB in the HOB list.
  161. * @retval false: The HOB specified by hdr is not the last HOB in the HOB list.
  162. */
  163. static inline bool end_of_hob(const struct hob_header *hdr)
  164. {
  165. return hdr->type == HOB_TYPE_EOH;
  166. }
  167. /**
  168. * get_guid_hob_data() - return a pointer to data buffer from a HOB of
  169. * type HOB_TYPE_GUID_EXT
  170. *
  171. * This macro returns a pointer to the data buffer in a HOB specified by hob.
  172. * hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
  173. *
  174. * @hdr: A pointer to a HOB.
  175. *
  176. * @return: A pointer to the data buffer in a HOB.
  177. */
  178. static inline void *get_guid_hob_data(const struct hob_header *hdr)
  179. {
  180. return (void *)((uintptr_t)hdr + sizeof(struct hob_guid));
  181. }
  182. /**
  183. * get_guid_hob_data_size() - return the size of the data buffer from a HOB
  184. * of type HOB_TYPE_GUID_EXT
  185. *
  186. * This macro returns the size, in bytes, of the data buffer in a HOB
  187. * specified by hob. hob is assumed to be a HOB of type HOB_TYPE_GUID_EXT.
  188. *
  189. * @hdr: A pointer to a HOB.
  190. *
  191. * @return: The size of the data buffer.
  192. */
  193. static inline u16 get_guid_hob_data_size(const struct hob_header *hdr)
  194. {
  195. return hdr->len - sizeof(struct hob_guid);
  196. }
  197. /* FSP specific GUID HOB definitions */
  198. #define FSP_GUID_DATA1 0x912740be
  199. #define FSP_GUID_DATA2 0x2284
  200. #define FSP_GUID_DATA3 0x4734
  201. #define FSP_GUID_DATA4_0 0xb9
  202. #define FSP_GUID_DATA4_1 0x71
  203. #define FSP_GUID_DATA4_2 0x84
  204. #define FSP_GUID_DATA4_3 0xb0
  205. #define FSP_GUID_DATA4_4 0x27
  206. #define FSP_GUID_DATA4_5 0x35
  207. #define FSP_GUID_DATA4_6 0x3f
  208. #define FSP_GUID_DATA4_7 0x0c
  209. #define FSP_HEADER_GUID \
  210. { \
  211. FSP_GUID_DATA1, FSP_GUID_DATA2, FSP_GUID_DATA3, \
  212. { FSP_GUID_DATA4_0, FSP_GUID_DATA4_1, FSP_GUID_DATA4_2, \
  213. FSP_GUID_DATA4_3, FSP_GUID_DATA4_4, FSP_GUID_DATA4_5, \
  214. FSP_GUID_DATA4_6, FSP_GUID_DATA4_7 } \
  215. }
  216. #define FSP_NON_VOLATILE_STORAGE_HOB_GUID \
  217. { \
  218. 0x721acf02, 0x4d77, 0x4c2a, \
  219. { 0xb3, 0xdc, 0x27, 0xb, 0x7b, 0xa9, 0xe4, 0xb0 } \
  220. }
  221. #define FSP_BOOTLOADER_TEMP_MEM_HOB_GUID \
  222. { \
  223. 0xbbcff46c, 0xc8d3, 0x4113, \
  224. { 0x89, 0x85, 0xb9, 0xd4, 0xf3, 0xb3, 0xf6, 0x4e } \
  225. }
  226. #define FSP_HOB_RESOURCE_OWNER_FSP_GUID \
  227. { \
  228. 0x69a79759, 0x1373, 0x4367, \
  229. { 0xa6, 0xc4, 0xc7, 0xf5, 0x9e, 0xfd, 0x98, 0x6e } \
  230. }
  231. #define FSP_HOB_RESOURCE_OWNER_TSEG_GUID \
  232. { \
  233. 0xd038747c, 0xd00c, 0x4980, \
  234. { 0xb3, 0x19, 0x49, 0x01, 0x99, 0xa4, 0x7d, 0x55 } \
  235. }
  236. #define FSP_HOB_RESOURCE_OWNER_GRAPHICS_GUID \
  237. { \
  238. 0x9c7c3aa7, 0x5332, 0x4917, \
  239. { 0x82, 0xb9, 0x56, 0xa5, 0xf3, 0xe6, 0x2a, 0x07 } \
  240. }
  241. /* The following GUIDs are newly introduced in FSP spec 1.1 */
  242. #define FSP_HOB_RESOURCE_OWNER_BOOTLOADER_TOLUM_GUID \
  243. { \
  244. 0x73ff4f56, 0xaa8e, 0x4451, \
  245. { 0xb3, 0x16, 0x36, 0x35, 0x36, 0x67, 0xad, 0x44 } \
  246. }
  247. #define FSP_GRAPHICS_INFO_HOB_GUID \
  248. { \
  249. 0x39f62cce, 0x6825, 0x4669, \
  250. { 0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07 } \
  251. }
  252. #endif