]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: PciHostBridgeLib: initialize RootBus->DevicePath
authorLaszlo Ersek <lersek@redhat.com>
Mon, 25 Jan 2016 23:52:05 +0000 (00:52 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 3 Mar 2016 17:18:43 +0000 (18:18 +0100)
We copy the code from InitRootBridge()
[OvmfPkg/PciHostBridgeDxe/PciHostBridge.c], with a slight change: the
device path is allocated separately now.

This is the final field to initialize in PCI_ROOT_BRIDGE.

The type EFI_PCI_ROOT_BRIDGE_DEVICE_PATH is renamed to
OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH. The original is a misnomer (it is not a
standard UEFI type) that dates back to PcAtChipsetPkg/PciHostBridgeDxe.
Simply removing the EFI_ suffix would result in
PCI_ROOT_BRIDGE_DEVICE_PATH, where PCI_ could incorrectly suggest a
relation with the PCI standards or the PCI-related generic edk2 code.

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
OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf

index cc782c1cc3bed57a22a58d6ad73ce37e13f6506b..582e87dd9ac0d132d324faadd62669dc30e3a3b3 100644 (file)
 \r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/DevicePathLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/PciHostBridgeLib.h>\r
 #include <Library/PciLib.h>\r
 #include <Library/QemuFwCfgLib.h>\r
 \r
 \r
+#pragma pack(1)\r
+typedef struct {\r
+  ACPI_HID_DEVICE_PATH     AcpiDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL EndDevicePath;\r
+} OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH;\r
+#pragma pack ()\r
+\r
+\r
 GLOBAL_REMOVE_IF_UNREFERENCED\r
 CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = {\r
   L"Mem", L"I/O", L"Bus"\r
 };\r
 \r
 \r
+STATIC\r
+CONST\r
+OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = {\r
+  {\r
+    {\r
+      ACPI_DEVICE_PATH,\r
+      ACPI_DP,\r
+      {\r
+        (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)),\r
+        (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8)\r
+      }\r
+    },\r
+    EISA_PNP_ID(0x0A03), // HID\r
+    0                    // UID\r
+  },\r
+\r
+  {\r
+    END_DEVICE_PATH_TYPE,\r
+    END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+    {\r
+      END_DEVICE_PATH_LENGTH,\r
+      0\r
+    }\r
+  }\r
+};\r
+\r
+\r
 /**\r
   Initialize a PCI_ROOT_BRIDGE structure.\r
 \r
@@ -67,6 +103,8 @@ InitRootBridge (
   OUT PCI_ROOT_BRIDGE *RootBus\r
   )\r
 {\r
+  OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath;\r
+\r
   //\r
   // Be safe if other fields are added to PCI_ROOT_BRIDGE later.\r
   //\r
@@ -103,7 +141,19 @@ InitRootBridge (
 \r
   RootBus->NoExtendedConfigSpace = TRUE;\r
 \r
-  return EFI_OUT_OF_RESOURCES;\r
+  DevicePath = AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate,\r
+                 &mRootBridgeDevicePathTemplate);\r
+  if (DevicePath == NULL) {\r
+    DEBUG ((EFI_D_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES));\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+  DevicePath->AcpiDevicePath.UID = RootBusNumber;\r
+  RootBus->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath;\r
+\r
+  DEBUG ((EFI_D_INFO,\r
+    "%a: populated root bus %d, with room for %d subordinate bus(es)\n",\r
+    __FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber));\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 \r
@@ -120,6 +170,7 @@ UninitRootBridge (
   IN PCI_ROOT_BRIDGE *RootBus\r
   )\r
 {\r
+  FreePool (RootBus->DevicePath);\r
 }\r
 \r
 \r
index e95ebfdc9326d2a8c8e4ad1410b01f13b4d744fb..5467fff8aa15bf7be96f2b44b860157d7af5f3aa 100644 (file)
@@ -41,6 +41,7 @@
 [LibraryClasses]\r
   BaseMemoryLib\r
   DebugLib\r
+  DevicePathLib\r
   MemoryAllocationLib\r
   PciLib\r
   QemuFwCfgLib\r