+/** @file\r
+ PCI Segment Information Library that returns one segment whose\r
+ segment base address is retrieved from AcpiBoardInfo HOB.\r
+\r
+ Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Guid/AcpiBoardInfoGuid.h>\r
+\r
+#include <Library/HobLib.h>\r
+#include <Library/PciSegmentInfoLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+STATIC PCI_SEGMENT_INFO mPciSegment0 = {\r
+ 0, // Segment number\r
+ 0, // To be fixed later\r
+ 0, // Start bus number\r
+ 255 // End bus number\r
+};\r
+\r
+/**\r
+ Return an array of PCI_SEGMENT_INFO holding the segment information.\r
+\r
+ Note: The returned array/buffer is owned by callee.\r
+\r
+ @param Count Return the count of segments.\r
+\r
+ @retval A callee owned array holding the segment information.\r
+**/\r
+PCI_SEGMENT_INFO *\r
+EFIAPI\r
+GetPciSegmentInfo (\r
+ UINTN *Count\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+ ACPI_BOARD_INFO *AcpiBoardInfo;\r
+\r
+ ASSERT (Count != NULL);\r
+ if (Count == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ if (mPciSegment0.BaseAddress == 0) {\r
+ //\r
+ // Find the acpi board information guid hob\r
+ //\r
+ GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
+ ASSERT (GuidHob != NULL);\r
+\r
+ AcpiBoardInfo = (ACPI_BOARD_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
+ mPciSegment0.BaseAddress = AcpiBoardInfo->PcieBaseAddress;\r
+ }\r
+ *Count = 1;\r
+ return &mPciSegment0;\r
+}\r