UefiPayloadEntry.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. /** @file
  2. Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef __UEFI_PAYLOAD_ENTRY_H__
  6. #define __UEFI_PAYLOAD_ENTRY_H__
  7. #include <PiPei.h>
  8. #include <Library/BaseLib.h>
  9. #include <Library/BaseMemoryLib.h>
  10. #include <Library/MemoryAllocationLib.h>
  11. #include <Library/DebugLib.h>
  12. #include <Library/PeCoffLib.h>
  13. #include <Library/HobLib.h>
  14. #include <Library/PcdLib.h>
  15. #include <Guid/MemoryAllocationHob.h>
  16. #include <Library/IoLib.h>
  17. #include <Library/PeCoffLib.h>
  18. #include <Library/BlParseLib.h>
  19. #include <Library/PlatformSupportLib.h>
  20. #include <Library/CpuLib.h>
  21. #include <Library/UefiCpuLib.h>
  22. #include <IndustryStandard/Acpi.h>
  23. #include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
  24. #include <Guid/SerialPortInfoGuid.h>
  25. #include <Guid/MemoryMapInfoGuid.h>
  26. #include <Guid/AcpiBoardInfoGuid.h>
  27. #include <Guid/GraphicsInfoHob.h>
  28. #include <UniversalPayload/SmbiosTable.h>
  29. #include <UniversalPayload/AcpiTable.h>
  30. #include <UniversalPayload/UniversalPayload.h>
  31. #include <UniversalPayload/ExtraData.h>
  32. #include <UniversalPayload/SerialPortInfo.h>
  33. #include <Guid/PcdDataBaseSignatureGuid.h>
  34. #define LEGACY_8259_MASK_REGISTER_MASTER 0x21
  35. #define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1
  36. #define GET_OCCUPIED_SIZE(ActualSize, Alignment) \
  37. ((ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1)))
  38. #define E820_RAM 1
  39. #define E820_RESERVED 2
  40. #define E820_ACPI 3
  41. #define E820_NVS 4
  42. #define E820_UNUSABLE 5
  43. #define E820_DISABLED 6
  44. #define E820_PMEM 7
  45. #define E820_UNDEFINED 8
  46. /**
  47. Auto-generated function that calls the library constructors for all of the module's
  48. dependent libraries.
  49. **/
  50. VOID
  51. EFIAPI
  52. ProcessLibraryConstructorList (
  53. VOID
  54. );
  55. /**
  56. Add a new HOB to the HOB List.
  57. @param HobType Type of the new HOB.
  58. @param HobLength Length of the new HOB to allocate.
  59. @return NULL if there is no space to create a hob.
  60. @return The address point to the new created hob.
  61. **/
  62. VOID *
  63. EFIAPI
  64. CreateHob (
  65. IN UINT16 HobType,
  66. IN UINT16 HobLength
  67. );
  68. /**
  69. Update the Stack Hob if the stack has been moved
  70. @param BaseAddress The 64 bit physical address of the Stack.
  71. @param Length The length of the stack in bytes.
  72. **/
  73. VOID
  74. EFIAPI
  75. UpdateStackHob (
  76. IN EFI_PHYSICAL_ADDRESS BaseAddress,
  77. IN UINT64 Length
  78. );
  79. /**
  80. Build a Handoff Information Table HOB
  81. This function initialize a HOB region from EfiMemoryBegin to
  82. EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
  83. be inside the HOB region.
  84. @param[in] EfiMemoryBottom Total memory start address
  85. @param[in] EfiMemoryTop Total memory end address.
  86. @param[in] EfiFreeMemoryBottom Free memory start address
  87. @param[in] EfiFreeMemoryTop Free memory end address.
  88. @return The pointer to the handoff HOB table.
  89. **/
  90. EFI_HOB_HANDOFF_INFO_TABLE *
  91. EFIAPI
  92. HobConstructor (
  93. IN VOID *EfiMemoryBottom,
  94. IN VOID *EfiMemoryTop,
  95. IN VOID *EfiFreeMemoryBottom,
  96. IN VOID *EfiFreeMemoryTop
  97. );
  98. /**
  99. Find DXE core from FV and build DXE core HOBs.
  100. @param[out] DxeCoreEntryPoint DXE core entry point
  101. @retval EFI_SUCCESS If it completed successfully.
  102. @retval EFI_NOT_FOUND If it failed to load DXE FV.
  103. **/
  104. EFI_STATUS
  105. LoadDxeCore (
  106. OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
  107. );
  108. /**
  109. Find DXE core from FV and build DXE core HOBs.
  110. @param[in] DxeFv The FV where to find the DXE core.
  111. @param[out] DxeCoreEntryPoint DXE core entry point
  112. @retval EFI_SUCCESS If it completed successfully.
  113. @retval EFI_NOT_FOUND If it failed to load DXE FV.
  114. **/
  115. EFI_STATUS
  116. UniversalLoadDxeCore (
  117. IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
  118. OUT PHYSICAL_ADDRESS *DxeCoreEntryPoint
  119. );
  120. /**
  121. Transfers control to DxeCore.
  122. This function performs a CPU architecture specific operations to execute
  123. the entry point of DxeCore with the parameters of HobList.
  124. @param DxeCoreEntryPoint The entry point of DxeCore.
  125. @param HobList The start of HobList passed to DxeCore.
  126. **/
  127. VOID
  128. HandOffToDxeCore (
  129. IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
  130. IN EFI_PEI_HOB_POINTERS HobList
  131. );
  132. EFI_STATUS
  133. FixUpPcdDatabase (
  134. IN EFI_FIRMWARE_VOLUME_HEADER *DxeFv
  135. );
  136. /**
  137. This function searchs a given section type within a valid FFS file.
  138. @param FileHeader A pointer to the file header that contains the set of sections to
  139. be searched.
  140. @param SearchType The value of the section type to search.
  141. @param SectionData A pointer to the discovered section, if successful.
  142. @retval EFI_SUCCESS The section was found.
  143. @retval EFI_NOT_FOUND The section was not found.
  144. **/
  145. EFI_STATUS
  146. FileFindSection (
  147. IN EFI_FFS_FILE_HEADER *FileHeader,
  148. IN EFI_SECTION_TYPE SectionType,
  149. OUT VOID **SectionData
  150. );
  151. /**
  152. This function searchs a given file type with a given Guid within a valid FV.
  153. If input Guid is NULL, will locate the first section having the given file type
  154. @param FvHeader A pointer to firmware volume header that contains the set of files
  155. to be searched.
  156. @param FileType File type to be searched.
  157. @param Guid Will ignore if it is NULL.
  158. @param FileHeader A pointer to the discovered file, if successful.
  159. @retval EFI_SUCCESS Successfully found FileType
  160. @retval EFI_NOT_FOUND File type can't be found.
  161. **/
  162. EFI_STATUS
  163. FvFindFileByTypeGuid (
  164. IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader,
  165. IN EFI_FV_FILETYPE FileType,
  166. IN EFI_GUID *Guid OPTIONAL,
  167. OUT EFI_FFS_FILE_HEADER **FileHeader
  168. );
  169. /**
  170. Build ACPI board info HOB using infomation from ACPI table
  171. @param AcpiTableBase ACPI table start address in memory
  172. @retval A pointer to ACPI board HOB ACPI_BOARD_INFO. Null if build HOB failure.
  173. **/
  174. ACPI_BOARD_INFO *
  175. BuildHobFromAcpi (
  176. IN UINT64 AcpiTableBase
  177. );
  178. #endif