fsp_support.h 5.8 KB

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