From patchwork Sat Feb 27 00:23:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 63134 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp145894lbc; Fri, 26 Feb 2016 16:24:23 -0800 (PST) X-Received: by 10.98.1.85 with SMTP id 82mr6205655pfb.10.1456532653539; Fri, 26 Feb 2016 16:24:13 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id o80si2632490pfj.216.2016.02.26.16.24.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Feb 2016 16:24:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4E0791A1E52; Fri, 26 Feb 2016 16:24:13 -0800 (PST) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A343D1A1E61 for ; Fri, 26 Feb 2016 16:24:11 -0800 (PST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id D9064859F8; Sat, 27 Feb 2016 00:24:05 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-45.phx2.redhat.com [10.3.113.45]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1R0NdFf026697; Fri, 26 Feb 2016 19:24:04 -0500 From: Laszlo Ersek To: edk2-devel-01 Date: Sat, 27 Feb 2016 01:23:34 +0100 Message-Id: <1456532616-32475-16-git-send-email-lersek@redhat.com> In-Reply-To: <1456532616-32475-1-git-send-email-lersek@redhat.com> References: <1456532616-32475-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: Ruiyu Ni , Jordan Justen , Marcel Apfelbaum Subject: [edk2] [PATCH 15/17] OvmfPkg: PciHostBridgeLib: initialize RootBus->DevicePath X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 Cc: Ruiyu Ni Cc: Marcel Apfelbaum Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf | 1 + OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c | 53 +++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) -- 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf index e95ebfdc9326..5467fff8aa15 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.inf @@ -41,6 +41,7 @@ [Packages] [LibraryClasses] BaseMemoryLib DebugLib + DevicePathLib MemoryAllocationLib PciLib QemuFwCfgLib diff --git a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c index e045442ecad0..4cf934ac40f9 100644 --- a/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c +++ b/OvmfPkg/Library/PciHostBridgeLib/PciHostBridgeLib.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,12 +31,47 @@ #define MAX_PCI_DEVICE_NUMBER 31 +#pragma pack(1) +typedef struct { + ACPI_HID_DEVICE_PATH AcpiDevicePath; + EFI_DEVICE_PATH_PROTOCOL EndDevicePath; +} OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH; +#pragma pack () + + GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mPciHostBridgeLibAcpiAddressSpaceTypeStr[] = { L"Mem", L"I/O", L"Bus" }; +STATIC +CONST +OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH mRootBridgeDevicePathTemplate = { + { + { + ACPI_DEVICE_PATH, + ACPI_DP, + { + (UINT8) (sizeof(ACPI_HID_DEVICE_PATH)), + (UINT8) ((sizeof(ACPI_HID_DEVICE_PATH)) >> 8) + } + }, + EISA_PNP_ID(0x0A03), // HID + 0 // UID + }, + + { + END_DEVICE_PATH_TYPE, + END_ENTIRE_DEVICE_PATH_SUBTYPE, + { + END_DEVICE_PATH_LENGTH, + 0 + } + } +}; + + /** Initialize a PCI_ROOT_BRIDGE structure. @@ -69,6 +105,8 @@ InitRootBridge ( OUT PCI_ROOT_BRIDGE *RootBus ) { + OVMF_PCI_ROOT_BRIDGE_DEVICE_PATH *DevicePath; + // // Be safe if other fields are added to PCI_ROOT_BRIDGE later. // @@ -106,7 +144,19 @@ InitRootBridge ( RootBus->Pci.Base = 0x00; RootBus->Pci.Limit = 0xFF; - return EFI_OUT_OF_RESOURCES; + DevicePath = AllocateCopyPool (sizeof mRootBridgeDevicePathTemplate, + &mRootBridgeDevicePathTemplate); + if (DevicePath == NULL) { + DEBUG ((EFI_D_ERROR, "%a: %r\n", __FUNCTION__, EFI_OUT_OF_RESOURCES)); + return EFI_OUT_OF_RESOURCES; + } + DevicePath->AcpiDevicePath.UID = RootBusNumber; + RootBus->DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)DevicePath; + + DEBUG ((EFI_D_INFO, + "%a: populated root bus %d, with room for %d subordinate bus(es)\n", + __FUNCTION__, RootBusNumber, MaxSubBusNumber - RootBusNumber)); + return EFI_SUCCESS; } @@ -123,6 +173,7 @@ UninitRootBridge ( IN PCI_ROOT_BRIDGE *RootBus ) { + FreePool (RootBus->DevicePath); }