OvmfPkg: clone PciHostBridgeLib from MdeModulePkg's Null instance
authorLaszlo Ersek <lersek@redhat.com>
Mon, 25 Jan 2016 19:33:32 +0000 (20:33 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 3 Mar 2016 17:18:35 +0000 (18:18 +0100)
In this patch we clone "MdeModulePkg/Library/PciHostBridgeLibNull" for
customization under OvmfPkg. Differences relative to a verbatim copy:

- the Null suffix is dropped from file names,
- the UNI file is dropped, together with the corresponding MODULE_UNI_FILE
  reference in the INF file,
- the INF file receives a new FILE_GUID,
- the top comments in the files mention OVMF, not a null instance.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Marcel Apfelbaum <marcel@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c [new file with mode: 0644]
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf [new file with mode: 0644]

diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c
new file mode 100644 (file)
index 0000000..3752993
--- /dev/null
@@ -0,0 +1,117 @@
+/** @file\r
+  OVMF's instance of the PCI Host Bridge Library.\r
+\r
+  Copyright (C) 2016, Red Hat, Inc.\r
+  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License which accompanies this\r
+  distribution.  The full 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, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#include <PiDxe.h>\r
+#include <Library/PciHostBridgeLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+GLOBAL_REMOVE_IF_UNREFERENCED\r
+CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {\r
+  L"Mem", L"I/O", L"Bus"\r
+};\r
+\r
+/**\r
+  Return all the root bridge instances in an array.\r
+\r
+  @param Count  Return the count of root bridge instances.\r
+\r
+  @return All the root bridge instances in an array.\r
+          The array should be passed into PciHostBridgeFreeRootBridges()\r
+          when it's not used.\r
+**/\r
+PCI_ROOT_BRIDGE *\r
+EFIAPI\r
+PciHostBridgeGetRootBridges (\r
+  UINTN *Count\r
+  )\r
+{\r
+  *Count = 0;\r
+  return NULL;\r
+}\r
+\r
+/**\r
+  Free the root bridge instances array returned from\r
+  PciHostBridgeGetRootBridges().\r
+\r
+  @param  The root bridge instances array.\r
+  @param  The count of the array.\r
+**/\r
+VOID\r
+EFIAPI\r
+PciHostBridgeFreeRootBridges (\r
+  PCI_ROOT_BRIDGE *Bridges,\r
+  UINTN           Count\r
+  )\r
+{\r
+  return;\r
+}\r
+\r
+/**\r
+  Inform the platform that the resource conflict happens.\r
+\r
+  @param HostBridgeHandle Handle of the Host Bridge.\r
+  @param Configuration    Pointer to PCI I/O and PCI memory resource\r
+                          descriptors. The Configuration contains the resources\r
+                          for all the root bridges. The resource for each root\r
+                          bridge is terminated with END descriptor and an\r
+                          additional END is appended indicating the end of the\r
+                          entire resources. The resource descriptor field\r
+                          values follow the description in\r
+                          EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL\r
+                          .SubmitResources().\r
+**/\r
+VOID\r
+EFIAPI\r
+PciHostBridgeResourceConflict (\r
+  EFI_HANDLE                        HostBridgeHandle,\r
+  VOID                              *Configuration\r
+  )\r
+{\r
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptor;\r
+  UINTN                             RootBridgeIndex;\r
+  DEBUG ((EFI_D_ERROR, "PciHostBridge: Resource conflict happens!\n"));\r
+\r
+  RootBridgeIndex = 0;\r
+  Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *) Configuration;\r
+  while (Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR) {\r
+    DEBUG ((EFI_D_ERROR, "RootBridge[%d]:\n", RootBridgeIndex++));\r
+    for (; Descriptor->Desc == ACPI_ADDRESS_SPACE_DESCRIPTOR; Descriptor++) {\r
+      ASSERT (Descriptor->ResType <\r
+              (sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr) /\r
+               sizeof (mPciHostBridgeLibAcpiAddressSpaceTypeStr[0])\r
+               )\r
+              );\r
+      DEBUG ((EFI_D_ERROR, " %s: Length/Alignment = 0x%lx / 0x%lx\n",\r
+              mPciHostBridgeLibAcpiAddressSpaceTypeStr[Descriptor->ResType],\r
+              Descriptor->AddrLen, Descriptor->AddrRangeMax\r
+              ));\r
+      if (Descriptor->ResType == ACPI_ADDRESS_SPACE_TYPE_MEM) {\r
+        DEBUG ((EFI_D_ERROR, "     Granularity/SpecificFlag = %ld / %02x%s\n",\r
+                Descriptor->AddrSpaceGranularity, Descriptor->SpecificFlag,\r
+                ((Descriptor->SpecificFlag &\r
+                  EFI_ACPI_MEMORY_RESOURCE_SPECIFIC_FLAG_CACHEABLE_PREFETCHABLE\r
+                  ) != 0) ? L" (Prefetchable)" : L""\r
+                ));\r
+      }\r
+    }\r
+    //\r
+    // Skip the END descriptor for root bridge\r
+    //\r
+    ASSERT (Descriptor->Desc == ACPI_END_TAG_DESCRIPTOR);\r
+    Descriptor = (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *)(\r
+                   (EFI_ACPI_END_TAG_DESCRIPTOR *)Descriptor + 1\r
+                   );\r
+  }\r
+}\r
diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf
new file mode 100644 (file)
index 0000000..1f39301
--- /dev/null
@@ -0,0 +1,38 @@
+## @file\r
+#  OVMF's instance of the PCI Host Bridge Library.\r
+#\r
+#  Copyright (C) 2016, Red Hat, Inc.\r
+#  Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials are licensed and made available\r
+#  under the terms and conditions of the BSD License which accompanies this\r
+#  distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\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\r
+#  IMPLIED.\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PciHostBridgeLib\r
+  FILE_GUID                      = 9F2BC05E-51EA-4AED-9A3E-7699641734E8\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PciHostBridgeLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build\r
+# tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  PciHostBridgeLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r