fsp_support.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright (C) 2013, Intel Corporation
  3. * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
  4. *
  5. * SPDX-License-Identifier: Intel
  6. */
  7. #ifndef __FSP_SUPPORT_H__
  8. #define __FSP_SUPPORT_H__
  9. #include "fsp_types.h"
  10. #include "fsp_fv.h"
  11. #include "fsp_ffs.h"
  12. #include "fsp_api.h"
  13. #include "fsp_hob.h"
  14. #include "fsp_platform.h"
  15. #include "fsp_infoheader.h"
  16. #include "fsp_bootmode.h"
  17. #include "fsp_vpd.h"
  18. struct shared_data {
  19. struct fsp_header *fsp_hdr;
  20. u32 *stack_top;
  21. struct upd_region fsp_upd;
  22. };
  23. #define FSP_LOWMEM_BASE 0x100000UL
  24. #define FSP_HIGHMEM_BASE 0x100000000ULL
  25. /**
  26. * FSP Continuation assembly helper routine
  27. *
  28. * This routine jumps to the C version of FSP continuation function
  29. */
  30. void asm_continuation(void);
  31. /**
  32. * FSP initialization complete
  33. *
  34. * This is the function that indicates FSP initialization is complete and jumps
  35. * back to the bootloader with HOB list pointer as the parameter.
  36. *
  37. * @hob_list: HOB list pointer
  38. */
  39. void fsp_init_done(void *hob_list);
  40. /**
  41. * FSP Continuation function
  42. *
  43. * @shared_data: Shared data base before stack migration
  44. * @status: Always 0
  45. * @hob_list: HOB list pointer
  46. *
  47. * @retval: Never returns
  48. */
  49. void fsp_continue(struct shared_data *shared_data, u32 status,
  50. void *hob_list);
  51. /**
  52. * Find FSP header offset in FSP image
  53. *
  54. * @retval: the offset of FSP header. If signature is invalid, returns 0.
  55. */
  56. u32 find_fsp_header(void);
  57. /**
  58. * FSP initialization wrapper function.
  59. *
  60. * @stack_top: bootloader stack top address
  61. * @boot_mode: boot mode defined in fsp_bootmode.h
  62. * @nvs_buf: Non-volatile memory buffer pointer
  63. */
  64. void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf);
  65. /**
  66. * FSP notification wrapper function
  67. *
  68. * @fsp_hdr: Pointer to FSP information header
  69. * @phase: FSP initialization phase defined in enum fsp_phase
  70. *
  71. * @retval: compatible status code with EFI_STATUS defined in PI spec
  72. */
  73. u32 fsp_notify(struct fsp_header *fsp_hdr, u32 phase);
  74. /**
  75. * This function retrieves the top of usable low memory.
  76. *
  77. * @hob_list: A HOB list pointer.
  78. *
  79. * @retval: Usable low memory top.
  80. */
  81. u32 fsp_get_usable_lowmem_top(const void *hob_list);
  82. /**
  83. * This function retrieves the top of usable high memory.
  84. *
  85. * @hob_list: A HOB list pointer.
  86. *
  87. * @retval: Usable high memory top.
  88. */
  89. u64 fsp_get_usable_highmem_top(const void *hob_list);
  90. /**
  91. * This function retrieves a special reserved memory region.
  92. *
  93. * @hob_list: A HOB list pointer.
  94. * @len: A pointer to the GUID HOB data buffer length.
  95. * If the GUID HOB is located, the length will be updated.
  96. * @guid: A pointer to the owner guild.
  97. *
  98. * @retval: Reserved region start address.
  99. * 0 if this region does not exist.
  100. */
  101. u64 fsp_get_reserved_mem_from_guid(const void *hob_list,
  102. u64 *len, struct efi_guid *guid);
  103. /**
  104. * This function retrieves the FSP reserved normal memory.
  105. *
  106. * @hob_list: A HOB list pointer.
  107. * @len: A pointer to the FSP reserved memory length buffer.
  108. * If the GUID HOB is located, the length will be updated.
  109. * @retval: FSP reserved memory base
  110. * 0 if this region does not exist.
  111. */
  112. u32 fsp_get_fsp_reserved_mem(const void *hob_list, u32 *len);
  113. /**
  114. * This function retrieves the TSEG reserved normal memory.
  115. *
  116. * @hob_list: A HOB list pointer.
  117. * @len: A pointer to the TSEG reserved memory length buffer.
  118. * If the GUID HOB is located, the length will be updated.
  119. *
  120. * @retval NULL: Failed to find the TSEG reserved memory.
  121. * @retval others: TSEG reserved memory base.
  122. */
  123. u32 fsp_get_tseg_reserved_mem(const void *hob_list, u32 *len);
  124. /**
  125. * Returns the next instance of a HOB type from the starting HOB.
  126. *
  127. * @type: HOB type to search
  128. * @hob_list: A pointer to the HOB list
  129. *
  130. * @retval: A HOB object with matching type; Otherwise NULL.
  131. */
  132. void *fsp_get_next_hob(u16 type, const void *hob_list);
  133. /**
  134. * Returns the next instance of the matched GUID HOB from the starting HOB.
  135. *
  136. * @guid: GUID to search
  137. * @hob_list: A pointer to the HOB list
  138. *
  139. * @retval: A HOB object with matching GUID; Otherwise NULL.
  140. */
  141. void *fsp_get_next_guid_hob(const struct efi_guid *guid, const void *hob_list);
  142. /**
  143. * This function retrieves a GUID HOB data buffer and size.
  144. *
  145. * @hob_list: A HOB list pointer.
  146. * @len: A pointer to the GUID HOB data buffer length.
  147. * If the GUID HOB is located, the length will be updated.
  148. * @guid A pointer to HOB GUID.
  149. *
  150. * @retval NULL: Failed to find the GUID HOB.
  151. * @retval others: GUID HOB data buffer pointer.
  152. */
  153. void *fsp_get_guid_hob_data(const void *hob_list, u32 *len,
  154. struct efi_guid *guid);
  155. /**
  156. * This function retrieves FSP Non-volatile Storage HOB buffer and size.
  157. *
  158. * @hob_list: A HOB list pointer.
  159. * @len: A pointer to the NVS data buffer length.
  160. * If the HOB is located, the length will be updated.
  161. *
  162. * @retval NULL: Failed to find the NVS HOB.
  163. * @retval others: FSP NVS data buffer pointer.
  164. */
  165. void *fsp_get_nvs_data(const void *hob_list, u32 *len);
  166. /**
  167. * This function retrieves Bootloader temporary stack buffer and size.
  168. *
  169. * @hob_list: A HOB list pointer.
  170. * @len: A pointer to the bootloader temporary stack length.
  171. * If the HOB is located, the length will be updated.
  172. *
  173. * @retval NULL: Failed to find the bootloader temporary stack HOB.
  174. * @retval others: Bootloader temporary stackbuffer pointer.
  175. */
  176. void *fsp_get_bootloader_tmp_mem(const void *hob_list, u32 *len);
  177. /**
  178. * This function overrides the default configurations in the UPD data region.
  179. *
  180. * @fsp_upd: A pointer to the upd_region data strcture
  181. *
  182. * @return: None
  183. */
  184. void update_fsp_upd(struct upd_region *fsp_upd);
  185. #endif