]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/PciSegmentLibSegmentInfo/BasePciSegmentLib.c
MdePkg/PciSegmentLib: Add instances that consumes PciSegmentInfoLib
[mirror_edk2.git] / MdePkg / Library / PciSegmentLibSegmentInfo / BasePciSegmentLib.c
diff --git a/MdePkg/Library/PciSegmentLibSegmentInfo/BasePciSegmentLib.c b/MdePkg/Library/PciSegmentLibSegmentInfo/BasePciSegmentLib.c
new file mode 100644 (file)
index 0000000..e71624d
--- /dev/null
@@ -0,0 +1,71 @@
+/** @file\r
+  Instance of Base PCI Segment Library that support multi-segment PCI configuration access.\r
+\r
+  PCI Segment Library that consumes segment information provided by PciSegmentInfoLib to\r
+   support multi-segment PCI configuration access through enhanced configuration access mechanism.\r
+\r
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials are\r
+  licensed and made available under the terms and conditions of\r
+  the BSD License which accompanies this distribution.  The full\r
+  text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "PciSegmentLibCommon.h"\r
+\r
+/**\r
+  Return the virtual address for the physical address.\r
+\r
+  @param  Address  The physical address.\r
+\r
+  @retval The virtual address.\r
+**/\r
+UINTN\r
+PciSegmentLibVirtualAddress (\r
+  IN UINTN                     Address\r
+  )\r
+{\r
+  return Address;\r
+}\r
+\r
+/**\r
+  Register a PCI device so PCI configuration registers may be accessed after\r
+  SetVirtualAddressMap().\r
+\r
+  If any reserved bits in Address are set, then ASSERT().\r
+\r
+  @param  Address The address that encodes the PCI Bus, Device, Function and\r
+                  Register.\r
+\r
+  @retval RETURN_SUCCESS           The PCI device was registered for runtime access.\r
+  @retval RETURN_UNSUPPORTED       An attempt was made to call this function\r
+                                   after ExitBootServices().\r
+  @retval RETURN_UNSUPPORTED       The resources required to access the PCI device\r
+                                   at runtime could not be mapped.\r
+  @retval RETURN_OUT_OF_RESOURCES  There are not enough resources available to\r
+                                   complete the registration.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PciSegmentRegisterForRuntimeAccess (\r
+  IN UINTN  Address\r
+  )\r
+{\r
+  //\r
+  // Use PciSegmentLibGetEcamAddress() to validate the Address.\r
+  //\r
+  DEBUG_CODE (\r
+    UINTN                        Count;\r
+    PCI_SEGMENT_INFO             *SegmentInfo;\r
+\r
+    SegmentInfo = GetPciSegmentInfo (&Count);\r
+    PciSegmentLibGetEcamAddress (Address, SegmentInfo, Count);\r
+  );\r
+  return RETURN_SUCCESS;\r
+}\r