PciSegmentInfoLibAcpiBoardInfo.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /** @file
  2. PCI Segment Information Library that returns one segment whose
  3. segment base address is retrieved from AcpiBoardInfo HOB.
  4. Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <PiDxe.h>
  8. #include <Guid/AcpiBoardInfoGuid.h>
  9. #include <Library/HobLib.h>
  10. #include <Library/PciSegmentInfoLib.h>
  11. #include <Library/DebugLib.h>
  12. STATIC PCI_SEGMENT_INFO mPciSegment0 = {
  13. 0, // Segment number
  14. 0, // To be fixed later
  15. 0, // Start bus number
  16. 255 // End bus number
  17. };
  18. /**
  19. Return an array of PCI_SEGMENT_INFO holding the segment information.
  20. Note: The returned array/buffer is owned by callee.
  21. @param Count Return the count of segments.
  22. @retval A callee owned array holding the segment information.
  23. **/
  24. PCI_SEGMENT_INFO *
  25. EFIAPI
  26. GetPciSegmentInfo (
  27. UINTN *Count
  28. )
  29. {
  30. EFI_HOB_GUID_TYPE *GuidHob;
  31. ACPI_BOARD_INFO *AcpiBoardInfo;
  32. ASSERT (Count != NULL);
  33. if (Count == NULL) {
  34. return NULL;
  35. }
  36. if (mPciSegment0.BaseAddress == 0) {
  37. //
  38. // Find the acpi board information guid hob
  39. //
  40. GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);
  41. ASSERT (GuidHob != NULL);
  42. AcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
  43. mPciSegment0.BaseAddress = AcpiBoardInfo->PcieBaseAddress;
  44. }
  45. *Count = 1;
  46. return &mPciSegment0;
  47. }