PrintHob.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700
  1. /** @file
  2. Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #include "UefiPayloadEntry.h"
  6. #include <UniversalPayload/AcpiTable.h>
  7. #include <UniversalPayload/SerialPortInfo.h>
  8. #include <UniversalPayload/PciRootBridges.h>
  9. #include <UniversalPayload/ExtraData.h>
  10. #include <Guid/MemoryTypeInformation.h>
  11. #include <Guid/AcpiBoardInfoGuid.h>
  12. #include <Guid/BootManagerMenu.h>
  13. #define ROW_LIMITER 16
  14. typedef
  15. EFI_STATUS
  16. (*HOB_PRINT_HANDLER) (
  17. IN VOID *Hob,
  18. IN UINT16 HobLength
  19. );
  20. typedef struct {
  21. UINT16 Type;
  22. CHAR8 *Name;
  23. HOB_PRINT_HANDLER PrintHandler;
  24. } HOB_PRINT_HANDLER_TABLE;
  25. CHAR8 *mMemoryTypeStr[] = {
  26. "EfiReservedMemoryType",
  27. "EfiLoaderCode",
  28. "EfiLoaderData",
  29. "EfiBootServicesCode",
  30. "EfiBootServicesData",
  31. "EfiRuntimeServicesCode",
  32. "EfiRuntimeServicesData",
  33. "EfiConventionalMemory",
  34. "EfiUnusableMemory",
  35. "EfiACPIReclaimMemory",
  36. "EfiACPIMemoryNVS",
  37. "EfiMemoryMappedIO",
  38. "EfiMemoryMappedIOPortSpace",
  39. "EfiPalCode",
  40. "EfiPersistentMemory",
  41. "EfiMaxMemoryType"
  42. };
  43. CHAR8 *mResource_Type_List[] = {
  44. "EFI_RESOURCE_SYSTEM_MEMORY ", // 0x00000000
  45. "EFI_RESOURCE_MEMORY_MAPPED_IO ", // 0x00000001
  46. "EFI_RESOURCE_IO ", // 0x00000002
  47. "EFI_RESOURCE_FIRMWARE_DEVICE ", // 0x00000003
  48. "EFI_RESOURCE_MEMORY_MAPPED_IO_PORT ", // 0x00000004
  49. "EFI_RESOURCE_MEMORY_RESERVED ", // 0x00000005
  50. "EFI_RESOURCE_IO_RESERVED ", // 0x00000006
  51. "EFI_RESOURCE_MAX_MEMORY_TYPE " // 0x00000007
  52. };
  53. typedef
  54. EFI_STATUS
  55. (*GUID_HOB_PRINT) (
  56. IN UINT8 *HobRaw,
  57. IN UINT16 HobLength
  58. );
  59. typedef struct {
  60. EFI_GUID *Guid;
  61. GUID_HOB_PRINT PrintHandler;
  62. CHAR8 *GuidName;
  63. } GUID_HOB_PRINT_HANDLE;
  64. typedef struct {
  65. EFI_GUID *Guid;
  66. CHAR8 *Type;
  67. } PRINT_MEMORY_ALLOCCATION_HOB;
  68. /**
  69. Print the Hex value of a given range.
  70. @param[in] DataStart A pointer to the start of data to be printed.
  71. @param[in] DataSize The length of the data to be printed.
  72. @retval EFI_SUCCESS If it completed successfully.
  73. **/
  74. EFI_STATUS
  75. PrintHex (
  76. IN UINT8 *DataStart,
  77. IN UINT16 DataSize
  78. )
  79. {
  80. UINTN Index1;
  81. UINTN Index2;
  82. UINT8 *StartAddr;
  83. StartAddr = DataStart;
  84. for (Index1 = 0; Index1 * ROW_LIMITER < DataSize; Index1++) {
  85. DEBUG ((DEBUG_VERBOSE, " 0x%04p:", (DataStart - StartAddr)));
  86. for (Index2 = 0; (Index2 < ROW_LIMITER) && (Index1 * ROW_LIMITER + Index2 < DataSize); Index2++) {
  87. DEBUG ((DEBUG_VERBOSE, " %02x", *DataStart));
  88. DataStart++;
  89. }
  90. DEBUG ((DEBUG_VERBOSE, "\n"));
  91. }
  92. return EFI_SUCCESS;
  93. }
  94. /**
  95. Print the information in HandOffHob.
  96. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_HANDOFF.
  97. @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TYPE_HANDOFF.
  98. @retval EFI_SUCCESS If it completed successfully.
  99. **/
  100. EFI_STATUS
  101. PrintHandOffHob (
  102. IN VOID *HobStart,
  103. IN UINT16 HobLength
  104. )
  105. {
  106. EFI_PEI_HOB_POINTERS Hob;
  107. Hob.Raw = (UINT8 *)HobStart;
  108. ASSERT (HobLength >= sizeof (*Hob.HandoffInformationTable));
  109. DEBUG ((DEBUG_INFO, " BootMode = 0x%x\n", Hob.HandoffInformationTable->BootMode));
  110. DEBUG ((DEBUG_INFO, " EfiMemoryTop = 0x%lx\n", Hob.HandoffInformationTable->EfiMemoryTop));
  111. DEBUG ((DEBUG_INFO, " EfiMemoryBottom = 0x%lx\n", Hob.HandoffInformationTable->EfiMemoryBottom));
  112. DEBUG ((DEBUG_INFO, " EfiFreeMemoryTop = 0x%lx\n", Hob.HandoffInformationTable->EfiFreeMemoryTop));
  113. DEBUG ((DEBUG_INFO, " EfiFreeMemoryBottom = 0x%lx\n", Hob.HandoffInformationTable->EfiFreeMemoryBottom));
  114. DEBUG ((DEBUG_INFO, " EfiEndOfHobList = 0x%lx\n", Hob.HandoffInformationTable->EfiEndOfHobList));
  115. return EFI_SUCCESS;
  116. }
  117. /**
  118. Print the information in Memory Allocation Hob.
  119. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_ALLOCATION.
  120. @param[in] HobLength The length in bytes of HOB of type EFI_HOB_TYPE_MEMORY_ALLOCATION.
  121. @retval EFI_SUCCESS If it completed successfully.
  122. **/
  123. EFI_STATUS
  124. PrintMemoryAllocationHob (
  125. IN VOID *HobStart,
  126. IN UINT16 HobLength
  127. )
  128. {
  129. EFI_PEI_HOB_POINTERS Hob;
  130. Hob.Raw = (UINT8 *)HobStart;
  131. if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocStackGuid)) {
  132. ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationStack));
  133. DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_STACK\n"));
  134. } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocBspStoreGuid)) {
  135. ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationBspStore));
  136. DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_BSP_STORE\n"));
  137. } else if (CompareGuid (&Hob.MemoryAllocation->AllocDescriptor.Name, &gEfiHobMemoryAllocModuleGuid)) {
  138. ASSERT (HobLength >= sizeof (*Hob.MemoryAllocationModule));
  139. DEBUG ((DEBUG_INFO, " Type = EFI_HOB_MEMORY_ALLOCATION_MODULE\n"));
  140. DEBUG ((DEBUG_INFO, " Module Name = %g\n", Hob.MemoryAllocationModule->ModuleName));
  141. DEBUG ((DEBUG_INFO, " Physical Address = 0x%lx\n", Hob.MemoryAllocationModule->EntryPoint));
  142. } else {
  143. ASSERT (HobLength >= sizeof (*Hob.MemoryAllocation));
  144. DEBUG ((DEBUG_INFO, " Type = EFI_HOB_TYPE_MEMORY_ALLOCATION\n"));
  145. }
  146. DEBUG ((DEBUG_INFO, " MemoryBaseAddress = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress));
  147. DEBUG ((DEBUG_INFO, " MemoryLength = 0x%lx\n", Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength));
  148. DEBUG ((DEBUG_INFO, " MemoryType = %a \n", mMemoryTypeStr[Hob.MemoryAllocationStack->AllocDescriptor.MemoryType]));
  149. return EFI_SUCCESS;
  150. }
  151. /**
  152. Print the information in Resource Discriptor Hob.
  153. @param[in] HobStart A pointer to HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.
  154. @param[in] HobLength The Length in bytes of HOB of type EFI_HOB_TYPE_RESOURCE_DESCRIPTOR.
  155. @retval EFI_SUCCESS If it completed successfully.
  156. **/
  157. EFI_STATUS
  158. PrintResourceDiscriptorHob (
  159. IN VOID *HobStart,
  160. IN UINT16 HobLength
  161. )
  162. {
  163. EFI_PEI_HOB_POINTERS Hob;
  164. Hob.Raw = (UINT8 *)HobStart;
  165. ASSERT (HobLength >= sizeof (*Hob.ResourceDescriptor));
  166. DEBUG ((DEBUG_INFO, " ResourceType = %a\n", mResource_Type_List[Hob.ResourceDescriptor->ResourceType]));
  167. if (!IsZeroGuid (&Hob.ResourceDescriptor->Owner)) {
  168. DEBUG ((DEBUG_INFO, " Owner = %g\n", Hob.ResourceDescriptor->Owner));
  169. }
  170. DEBUG ((DEBUG_INFO, " ResourceAttribute = 0x%x\n", Hob.ResourceDescriptor->ResourceAttribute));
  171. DEBUG ((DEBUG_INFO, " PhysicalStart = 0x%lx\n", Hob.ResourceDescriptor->PhysicalStart));
  172. DEBUG ((DEBUG_INFO, " ResourceLength = 0x%lx\n", Hob.ResourceDescriptor->ResourceLength));
  173. return EFI_SUCCESS;
  174. }
  175. /**
  176. Print the information in Acpi Guid Hob.
  177. @param[in] HobRaw A pointer to the start of gUniversalPayloadAcpiTableGuid HOB.
  178. @param[in] HobLength The size of the HOB data buffer.
  179. @retval EFI_SUCCESS If it completed successfully.
  180. **/
  181. EFI_STATUS
  182. PrintAcpiGuidHob (
  183. IN UINT8 *HobRaw,
  184. IN UINT16 HobLength
  185. )
  186. {
  187. UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob;
  188. AcpiTableHob = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GET_GUID_HOB_DATA (HobRaw);
  189. ASSERT (HobLength >= AcpiTableHob->Header.Length);
  190. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpiTableHob->Header.Revision));
  191. DEBUG ((DEBUG_INFO, " Length = 0x%x\n", AcpiTableHob->Header.Length));
  192. DEBUG ((DEBUG_INFO, " Rsdp = 0x%p\n", (UINT64)AcpiTableHob->Rsdp));
  193. return EFI_SUCCESS;
  194. }
  195. /**
  196. Print the information in Serial Guid Hob.
  197. @param[in] HobRaw A pointer to the start of gUniversalPayloadSerialPortInfoGuid HOB.
  198. @param[in] HobLength The size of the HOB data buffer.
  199. @retval EFI_SUCCESS If it completed successfully.
  200. **/
  201. EFI_STATUS
  202. PrintSerialGuidHob (
  203. IN UINT8 *HobRaw,
  204. IN UINT16 HobLength
  205. )
  206. {
  207. UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *SerialPortInfo;
  208. SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)GET_GUID_HOB_DATA (HobRaw);
  209. ASSERT (HobLength >= SerialPortInfo->Header.Length);
  210. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SerialPortInfo->Header.Revision));
  211. DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SerialPortInfo->Header.Length));
  212. DEBUG ((DEBUG_INFO, " UseMmio = 0x%x\n", SerialPortInfo->UseMmio));
  213. DEBUG ((DEBUG_INFO, " RegisterStride = 0x%x\n", SerialPortInfo->RegisterStride));
  214. DEBUG ((DEBUG_INFO, " BaudRate = %d\n", SerialPortInfo->BaudRate));
  215. DEBUG ((DEBUG_INFO, " RegisterBase = 0x%lx\n", SerialPortInfo->RegisterBase));
  216. return EFI_SUCCESS;
  217. }
  218. /**
  219. Print the information in Smbios Guid Hob.
  220. @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbios3TableGuid HOB.
  221. @param[in] HobLength The size of the HOB data buffer.
  222. @retval EFI_SUCCESS If it completed successfully.
  223. **/
  224. EFI_STATUS
  225. PrintSmbios3GuidHob (
  226. IN UINT8 *HobRaw,
  227. IN UINT16 HobLength
  228. )
  229. {
  230. UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;
  231. SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw);
  232. ASSERT (HobLength >= SmBiosTable->Header.Length);
  233. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
  234. DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));
  235. DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64)SmBiosTable->SmBiosEntryPoint));
  236. return EFI_SUCCESS;
  237. }
  238. /**
  239. Print the information in Smbios Guid Hob.
  240. @param[in] HobRaw A pointer to the start of gUniversalPayloadSmbiosTableGuid HOB.
  241. @param[in] HobLength The size of the HOB data buffer.
  242. @retval EFI_SUCCESS If it completed successfully.
  243. **/
  244. EFI_STATUS
  245. PrintSmbiosTablGuidHob (
  246. IN UINT8 *HobRaw,
  247. IN UINT16 HobLength
  248. )
  249. {
  250. UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmBiosTable;
  251. SmBiosTable = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GET_GUID_HOB_DATA (HobRaw);
  252. ASSERT (HobLength >= SmBiosTable->Header.Length);
  253. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", SmBiosTable->Header.Revision));
  254. DEBUG ((DEBUG_INFO, " Length = 0x%x\n", SmBiosTable->Header.Length));
  255. DEBUG ((DEBUG_INFO, " SmBiosEntryPoint = 0x%lx\n", (UINT64)SmBiosTable->SmBiosEntryPoint));
  256. return EFI_SUCCESS;
  257. }
  258. /**
  259. Print the information in Acpi BoardInfo Guid Hob.
  260. @param[in] HobRaw A pointer to the start of gUefiAcpiBoardInfoGuid HOB.
  261. @param[in] HobLength The size of the HOB data buffer.
  262. @retval EFI_SUCCESS If it completed successfully.
  263. **/
  264. EFI_STATUS
  265. PrintAcpiBoardInfoGuidHob (
  266. IN UINT8 *HobRaw,
  267. IN UINT16 HobLength
  268. )
  269. {
  270. ACPI_BOARD_INFO *AcpBoardInfo;
  271. AcpBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (HobRaw);
  272. ASSERT (HobLength >= sizeof (*AcpBoardInfo));
  273. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", AcpBoardInfo->Revision));
  274. DEBUG ((DEBUG_INFO, " Reserved0 = 0x%x\n", AcpBoardInfo->Reserved0));
  275. DEBUG ((DEBUG_INFO, " ResetValue = 0x%x\n", AcpBoardInfo->ResetValue));
  276. DEBUG ((DEBUG_INFO, " PmEvtBase = 0x%lx\n", AcpBoardInfo->PmEvtBase));
  277. DEBUG ((DEBUG_INFO, " PmGpeEnBase = 0x%lx\n", AcpBoardInfo->PmGpeEnBase));
  278. DEBUG ((DEBUG_INFO, " PmCtrlRegBase = 0x%lx\n", AcpBoardInfo->PmCtrlRegBase));
  279. DEBUG ((DEBUG_INFO, " PmTimerRegBase = 0x%lx\n", AcpBoardInfo->PmTimerRegBase));
  280. DEBUG ((DEBUG_INFO, " ResetRegAddress = 0x%lx\n", AcpBoardInfo->ResetRegAddress));
  281. DEBUG ((DEBUG_INFO, " PcieBaseAddress = 0x%lx\n", AcpBoardInfo->PcieBaseAddress));
  282. DEBUG ((DEBUG_INFO, " PcieBaseSize = 0x%lx\n", AcpBoardInfo->PcieBaseSize));
  283. return EFI_SUCCESS;
  284. }
  285. /**
  286. Print the information in Pci RootBridge Info Guid Hob.
  287. @param[in] HobRaw A pointer to the start of gUniversalPayloadPciRootBridgeInfoGuid HOB.
  288. @param[in] HobLength The size of the HOB data buffer.
  289. @retval EFI_SUCCESS If it completed successfully.
  290. **/
  291. EFI_STATUS
  292. PrintPciRootBridgeInfoGuidHob (
  293. IN UINT8 *HobRaw,
  294. IN UINT16 HobLength
  295. )
  296. {
  297. UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *PciRootBridges;
  298. UINTN Index;
  299. UINTN Length;
  300. Index = 0;
  301. PciRootBridges = (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES *)GET_GUID_HOB_DATA (HobRaw);
  302. Length = sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGES) + PciRootBridges->Count * sizeof (UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE);
  303. ASSERT (HobLength >= Length);
  304. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", PciRootBridges->Header.Revision));
  305. DEBUG ((DEBUG_INFO, " Length = 0x%x\n", PciRootBridges->Header.Length));
  306. DEBUG ((DEBUG_INFO, " Count = 0x%x\n", PciRootBridges->Count));
  307. DEBUG ((DEBUG_INFO, " ResourceAssigned = %a\n", (PciRootBridges->ResourceAssigned ? "True" : "False")));
  308. while (Index < PciRootBridges->Count) {
  309. DEBUG ((DEBUG_INFO, " Root Bridge Index[%d]:\n", Index));
  310. DEBUG ((DEBUG_INFO, " Segment = 0x%x\n", PciRootBridges->RootBridge[Index].Segment));
  311. DEBUG ((DEBUG_INFO, " Supports = 0x%lx\n", PciRootBridges->RootBridge[Index].Supports));
  312. DEBUG ((DEBUG_INFO, " Attributes = 0x%lx\n", PciRootBridges->RootBridge[Index].Attributes));
  313. DEBUG ((DEBUG_INFO, " DmaAbove4G = 0x%x\n", PciRootBridges->RootBridge[Index].DmaAbove4G));
  314. DEBUG ((DEBUG_INFO, " NoExtendedConfigSpace = 0x%x\n", PciRootBridges->RootBridge[Index].NoExtendedConfigSpace));
  315. DEBUG ((DEBUG_INFO, " AllocationAttributes = 0x%lx\n", PciRootBridges->RootBridge[Index].AllocationAttributes));
  316. DEBUG ((DEBUG_INFO, " Bus.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Base));
  317. DEBUG ((DEBUG_INFO, " Bus.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Limit));
  318. DEBUG ((DEBUG_INFO, " Bus.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Bus.Translation));
  319. DEBUG ((DEBUG_INFO, " Io.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Base));
  320. DEBUG ((DEBUG_INFO, " Io.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Limit));
  321. DEBUG ((DEBUG_INFO, " Io.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Io.Translation));
  322. DEBUG ((DEBUG_INFO, " Mem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Base));
  323. DEBUG ((DEBUG_INFO, " Mem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Limit));
  324. DEBUG ((DEBUG_INFO, " Mem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].Mem.Translation));
  325. DEBUG ((DEBUG_INFO, " MemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Base));
  326. DEBUG ((DEBUG_INFO, " MemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Limit));
  327. DEBUG ((DEBUG_INFO, " MemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].MemAbove4G.Translation));
  328. DEBUG ((DEBUG_INFO, " PMem.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Base));
  329. DEBUG ((DEBUG_INFO, " PMem.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Limit));
  330. DEBUG ((DEBUG_INFO, " PMem.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMem.Translation));
  331. DEBUG ((DEBUG_INFO, " PMemAbove4G.Base = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Base));
  332. DEBUG ((DEBUG_INFO, " PMemAbove4G.Limit = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Limit));
  333. DEBUG ((DEBUG_INFO, " PMemAbove4G.Translation = 0x%lx\n", PciRootBridges->RootBridge[Index].PMemAbove4G.Translation));
  334. Index += 1;
  335. }
  336. return EFI_SUCCESS;
  337. }
  338. /**
  339. Print the information in Extra Data Guid Hob.
  340. @param[in] HobRaw A pointer to the start of gUniversalPayloadExtraDataGuid HOB.
  341. @param[in] HobLength The size of the HOB data buffer.
  342. @retval EFI_SUCCESS If it completed successfully.
  343. **/
  344. EFI_STATUS
  345. PrintExtraDataGuidHob (
  346. IN UINT8 *HobRaw,
  347. IN UINT16 HobLength
  348. )
  349. {
  350. UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
  351. UINTN Index;
  352. UINTN Length;
  353. Index = 0;
  354. ExtraData = (UNIVERSAL_PAYLOAD_EXTRA_DATA *)GET_GUID_HOB_DATA (HobRaw);
  355. Length = sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA) + ExtraData->Count * sizeof (UNIVERSAL_PAYLOAD_EXTRA_DATA_ENTRY);
  356. ASSERT (HobLength >= Length);
  357. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", ExtraData->Header.Revision));
  358. DEBUG ((DEBUG_INFO, " Length = 0x%x\n", ExtraData->Header.Length));
  359. DEBUG ((DEBUG_INFO, " Count = 0x%x\n", ExtraData->Count));
  360. while (Index < ExtraData->Count) {
  361. DEBUG ((DEBUG_INFO, " Id[%d] = %a\n", Index, ExtraData->Entry[Index].Identifier));
  362. DEBUG ((DEBUG_INFO, " Base[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Base));
  363. DEBUG ((DEBUG_INFO, " Size[%d] = 0x%lx\n", Index, ExtraData->Entry[Index].Size));
  364. Index += 1;
  365. }
  366. return EFI_SUCCESS;
  367. }
  368. /**
  369. Print the information in MemoryTypeInfoGuidHob.
  370. @param[in] HobRaw A pointer to the start of gEfiMemoryTypeInformationGuid HOB.
  371. @param[in] HobLength The size of the HOB data buffer.
  372. @retval EFI_SUCCESS If it completed successfully.
  373. **/
  374. EFI_STATUS
  375. PrintMemoryTypeInfoGuidHob (
  376. IN UINT8 *HobRaw,
  377. IN UINT16 HobLength
  378. )
  379. {
  380. EFI_MEMORY_TYPE_INFORMATION *MemoryTypeInfo;
  381. MemoryTypeInfo = (EFI_MEMORY_TYPE_INFORMATION *)GET_GUID_HOB_DATA (HobRaw);
  382. ASSERT (HobLength >= sizeof (*MemoryTypeInfo));
  383. DEBUG ((DEBUG_INFO, " Type = 0x%x\n", MemoryTypeInfo->Type));
  384. DEBUG ((DEBUG_INFO, " NumberOfPages = 0x%x\n", MemoryTypeInfo->NumberOfPages));
  385. return EFI_SUCCESS;
  386. }
  387. /**
  388. Print the information in EdkiiBootManagerMenuFileGuid.
  389. @param[in] HobRaw A pointer to the start of gEdkiiBootManagerMenuFileGuid HOB.
  390. @param[in] HobLength The size of the HOB data buffer.
  391. @retval EFI_SUCCESS If it completed successfully.
  392. **/
  393. EFI_STATUS
  394. PrintBootManagerMenuGuidHob (
  395. IN UINT8 *HobRaw,
  396. IN UINT16 HobLength
  397. )
  398. {
  399. UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *BootManagerMenuFile;
  400. BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *)GET_GUID_HOB_DATA (HobRaw);
  401. ASSERT (HobLength >= sizeof (*BootManagerMenuFile));
  402. DEBUG ((DEBUG_INFO, " Revision = 0x%x\n", BootManagerMenuFile->Header.Revision));
  403. DEBUG ((DEBUG_INFO, " Length = 0x%x\n", BootManagerMenuFile->Header.Length));
  404. DEBUG ((DEBUG_INFO, " FileName = %g\n", &BootManagerMenuFile->FileName));
  405. return EFI_SUCCESS;
  406. }
  407. //
  408. // Mappint table for dump Guid Hob information.
  409. // This table can be easily extented.
  410. //
  411. GUID_HOB_PRINT_HANDLE GuidHobPrintHandleTable[] = {
  412. { &gUniversalPayloadAcpiTableGuid, PrintAcpiGuidHob, "gUniversalPayloadAcpiTableGuid(ACPI table Guid)" },
  413. { &gUniversalPayloadSerialPortInfoGuid, PrintSerialGuidHob, "gUniversalPayloadSerialPortInfoGuid(Serial Port Info)" },
  414. { &gUniversalPayloadSmbios3TableGuid, PrintSmbios3GuidHob, "gUniversalPayloadSmbios3TableGuid(SmBios Guid)" },
  415. { &gUniversalPayloadSmbiosTableGuid, PrintSmbiosTablGuidHob, "gUniversalPayloadSmbiosTableGuid(SmBios Guid)" },
  416. { &gUefiAcpiBoardInfoGuid, PrintAcpiBoardInfoGuidHob, "gUefiAcpiBoardInfoGuid(Acpi Guid)" },
  417. { &gUniversalPayloadPciRootBridgeInfoGuid, PrintPciRootBridgeInfoGuidHob, "gUniversalPayloadPciRootBridgeInfoGuid(Pci Guid)" },
  418. { &gEfiMemoryTypeInformationGuid, PrintMemoryTypeInfoGuidHob, "gEfiMemoryTypeInformationGuid(Memory Type Information Guid)" },
  419. { &gUniversalPayloadExtraDataGuid, PrintExtraDataGuidHob, "gUniversalPayloadExtraDataGuid(PayLoad Extra Data Guid)" },
  420. { &gEdkiiBootManagerMenuFileGuid, PrintBootManagerMenuGuidHob, "gEdkiiBootManagerMenuFileGuid(Boot Manager Menu File Guid)" }
  421. };
  422. /**
  423. Print the Guid Hob using related print handle function.
  424. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
  425. @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_GUID_EXTENSION.
  426. @retval EFI_SUCCESS If it completed successfully.
  427. **/
  428. EFI_STATUS
  429. PrintGuidHob (
  430. IN VOID *HobStart,
  431. IN UINT16 HobLength
  432. )
  433. {
  434. EFI_PEI_HOB_POINTERS Hob;
  435. UINTN Index;
  436. EFI_STATUS Status;
  437. Hob.Raw = (UINT8 *)HobStart;
  438. ASSERT (HobLength >= sizeof (Hob.Guid));
  439. for (Index = 0; Index < ARRAY_SIZE (GuidHobPrintHandleTable); Index++) {
  440. if (CompareGuid (&Hob.Guid->Name, GuidHobPrintHandleTable[Index].Guid)) {
  441. DEBUG ((DEBUG_INFO, " Guid = %a\n", GuidHobPrintHandleTable[Index].GuidName));
  442. Status = GuidHobPrintHandleTable[Index].PrintHandler (Hob.Raw, GET_GUID_HOB_DATA_SIZE (Hob.Raw));
  443. return Status;
  444. }
  445. }
  446. DEBUG ((DEBUG_INFO, " Name = %g\n", &Hob.Guid->Name));
  447. PrintHex (GET_GUID_HOB_DATA (Hob.Raw), GET_GUID_HOB_DATA_SIZE (Hob.Raw));
  448. return EFI_SUCCESS;
  449. }
  450. /**
  451. Print the information in FV Hob.
  452. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV.
  453. @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV.
  454. @retval EFI_SUCCESS If it completed successfully.
  455. **/
  456. EFI_STATUS
  457. PrintFvHob (
  458. IN VOID *HobStart,
  459. IN UINT16 HobLength
  460. )
  461. {
  462. EFI_PEI_HOB_POINTERS Hob;
  463. Hob.Raw = (UINT8 *)HobStart;
  464. ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume));
  465. DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume->BaseAddress));
  466. DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume->Length));
  467. return EFI_SUCCESS;
  468. }
  469. /**
  470. Print the information in Cpu Hob.
  471. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_CPU.
  472. @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_CPU.
  473. @retval EFI_SUCCESS If it completed successfully.
  474. **/
  475. EFI_STATUS
  476. PrintCpuHob (
  477. IN VOID *HobStart,
  478. IN UINT16 HobLength
  479. )
  480. {
  481. EFI_PEI_HOB_POINTERS Hob;
  482. Hob.Raw = (UINT8 *)HobStart;
  483. ASSERT (HobLength >= sizeof (*Hob.Cpu));
  484. DEBUG ((DEBUG_INFO, " SizeOfMemorySpace = 0x%lx\n", Hob.Cpu->SizeOfMemorySpace));
  485. DEBUG ((DEBUG_INFO, " SizeOfIoSpace = 0x%lx\n", Hob.Cpu->SizeOfIoSpace));
  486. return EFI_SUCCESS;
  487. }
  488. /**
  489. Print the information in MemoryPoolHob.
  490. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_MEMORY_POOL.
  491. @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_MEMORY_POOL.
  492. @retval EFI_SUCCESS If it completed successfully.
  493. **/
  494. EFI_STATUS
  495. PrintMemoryPoolHob (
  496. IN VOID *HobStart,
  497. IN UINT16 HobLength
  498. )
  499. {
  500. return EFI_SUCCESS;
  501. }
  502. /**
  503. Print the information in Fv2Hob.
  504. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV2.
  505. @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV2.
  506. @retval EFI_SUCCESS If it completed successfully.
  507. **/
  508. EFI_STATUS
  509. PrintFv2Hob (
  510. IN VOID *HobStart,
  511. IN UINT16 HobLength
  512. )
  513. {
  514. EFI_PEI_HOB_POINTERS Hob;
  515. Hob.Raw = (UINT8 *)HobStart;
  516. ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume2));
  517. DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume2->BaseAddress));
  518. DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume2->Length));
  519. DEBUG ((DEBUG_INFO, " FvName = %g\n", &Hob.FirmwareVolume2->FvName));
  520. DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume2->FileName));
  521. return EFI_SUCCESS;
  522. }
  523. /**
  524. Print the information in Capsule Hob.
  525. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.
  526. @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_UEFI_CAPSULE.
  527. @retval EFI_SUCCESS If it completed successfully.
  528. **/
  529. EFI_STATUS
  530. PrintCapsuleHob (
  531. IN VOID *HobStart,
  532. IN UINT16 HobLength
  533. )
  534. {
  535. EFI_PEI_HOB_POINTERS Hob;
  536. Hob.Raw = (UINT8 *)HobStart;
  537. ASSERT (HobLength >= sizeof (*Hob.Capsule));
  538. DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.Capsule->BaseAddress));
  539. DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.Capsule->Length));
  540. return EFI_SUCCESS;
  541. }
  542. /**
  543. Print the information in Fv3 Hob.
  544. @param[in] HobStart A pointer to the HOB of type EFI_HOB_TYPE_FV3.
  545. @param[in] HobLength The length in bytes of the HOB of type EFI_HOB_TYPE_FV3.
  546. @retval EFI_SUCCESS If it completed successfully.
  547. **/
  548. EFI_STATUS
  549. PrintFv3Hob (
  550. IN VOID *HobStart,
  551. IN UINT16 HobLength
  552. )
  553. {
  554. EFI_PEI_HOB_POINTERS Hob;
  555. Hob.Raw = (UINT8 *)HobStart;
  556. ASSERT (HobLength >= sizeof (*Hob.FirmwareVolume3));
  557. DEBUG ((DEBUG_INFO, " BaseAddress = 0x%lx\n", Hob.FirmwareVolume3->BaseAddress));
  558. DEBUG ((DEBUG_INFO, " Length = 0x%lx\n", Hob.FirmwareVolume3->Length));
  559. DEBUG ((DEBUG_INFO, " AuthenticationStatus = 0x%x\n", Hob.FirmwareVolume3->AuthenticationStatus));
  560. DEBUG ((DEBUG_INFO, " ExtractedFv = %a\n", (Hob.FirmwareVolume3->ExtractedFv ? "True" : "False")));
  561. DEBUG ((DEBUG_INFO, " FVName = %g\n", &Hob.FirmwareVolume3->FvName));
  562. DEBUG ((DEBUG_INFO, " FileName = %g\n", &Hob.FirmwareVolume3->FileName));
  563. return EFI_SUCCESS;
  564. }
  565. //
  566. // Mappint table from Hob type to Hob print function.
  567. //
  568. HOB_PRINT_HANDLER_TABLE mHobHandles[] = {
  569. { EFI_HOB_TYPE_HANDOFF, "EFI_HOB_TYPE_HANDOFF", PrintHandOffHob },
  570. { EFI_HOB_TYPE_MEMORY_ALLOCATION, "EFI_HOB_TYPE_MEMORY_ALLOCATION", PrintMemoryAllocationHob },
  571. { EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, "EFI_HOB_TYPE_RESOURCE_DESCRIPTOR", PrintResourceDiscriptorHob },
  572. { EFI_HOB_TYPE_GUID_EXTENSION, "EFI_HOB_TYPE_GUID_EXTENSION", PrintGuidHob },
  573. { EFI_HOB_TYPE_FV, "EFI_HOB_TYPE_FV", PrintFvHob },
  574. { EFI_HOB_TYPE_CPU, "EFI_HOB_TYPE_CPU", PrintCpuHob },
  575. { EFI_HOB_TYPE_MEMORY_POOL, "EFI_HOB_TYPE_MEMORY_POOL", PrintMemoryPoolHob },
  576. { EFI_HOB_TYPE_FV2, "EFI_HOB_TYPE_FV2", PrintFv2Hob },
  577. { EFI_HOB_TYPE_UEFI_CAPSULE, "EFI_HOB_TYPE_UEFI_CAPSULE", PrintCapsuleHob },
  578. { EFI_HOB_TYPE_FV3, "EFI_HOB_TYPE_FV3", PrintFv3Hob }
  579. };
  580. /**
  581. Print all HOBs info from the HOB list.
  582. @param[in] HobStart A pointer to the HOB list
  583. @return The pointer to the HOB list.
  584. **/
  585. VOID
  586. PrintHob (
  587. IN CONST VOID *HobStart
  588. )
  589. {
  590. EFI_PEI_HOB_POINTERS Hob;
  591. UINTN Count;
  592. UINTN Index;
  593. ASSERT (HobStart != NULL);
  594. Hob.Raw = (UINT8 *)HobStart;
  595. DEBUG ((DEBUG_INFO, "Print all Hob information from Hob 0x%p\n", Hob.Raw));
  596. Count = 0;
  597. //
  598. // Parse the HOB list to see which type it is, and print the information.
  599. //
  600. while (!END_OF_HOB_LIST (Hob)) {
  601. for (Index = 0; Index < ARRAY_SIZE (mHobHandles); Index++) {
  602. if (Hob.Header->HobType == mHobHandles[Index].Type) {
  603. DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %a, Offset = 0x%p, Length = 0x%x\n", Count, mHobHandles[Index].Name, (Hob.Raw - (UINT8 *)HobStart), Hob.Header->HobLength));
  604. mHobHandles[Index].PrintHandler (Hob.Raw, Hob.Header->HobLength);
  605. break;
  606. }
  607. }
  608. if (Index == ARRAY_SIZE (mHobHandles)) {
  609. DEBUG ((DEBUG_INFO, "HOB[%d]: Type = %d, Offset = 0x%p, Length = 0x%x\n", Count, Hob.Header->HobType, (Hob.Raw - (UINT8 *)HobStart), Hob.Header->HobLength));
  610. DEBUG ((DEBUG_INFO, " Unkown Hob type\n"));
  611. PrintHex (Hob.Raw, Hob.Header->HobLength);
  612. }
  613. Count++;
  614. Hob.Raw = GET_NEXT_HOB (Hob);
  615. }
  616. DEBUG ((DEBUG_INFO, "There are totally %d Hobs, the End Hob address is %p\n", Count, Hob.Raw));
  617. }