From nobody Wed Dec 25 14:06:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1509087289724996.0147209453739; Thu, 26 Oct 2017 23:54:49 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 641DC2034A895; Thu, 26 Oct 2017 23:51:00 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 B9CE22034A88B for ; Thu, 26 Oct 2017 23:50:57 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Oct 2017 23:54:44 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.7]) by orsmga003.jf.intel.com with ESMTP; 26 Oct 2017 23:54:43 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,303,1505804400"; d="scan'208";a="1030015309" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Fri, 27 Oct 2017 14:54:37 +0800 Message-Id: <20171027065438.284440-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 In-Reply-To: <20171027065438.284440-1-ruiyu.ni@intel.com> References: <20171027065438.284440-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/3] MdeModulePkg/PciBus: Don't create entry when recording ImageHandle X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The patch shouldn't impact functionality. Original code records the ImageHandle of Option ROM by creating a new entry. It's not necessary. The patch updates the ImageHandle in the old entry. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni Cc: Star Zeng --- MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c | 72 ++++++++++++++++++------= ---- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c b/MdeModulePkg/Bu= s/Pci/PciBusDxe/PciRomTable.c index 0eef41739c..fc6f579293 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciRomTable.c @@ -53,31 +53,54 @@ PciRomAddImageMapping ( IN UINT64 RomSize ) { + UINTN Index; PCI_ROM_IMAGE *NewTable; =20 - if (mNumberOfPciRomImages =3D=3D mMaxNumberOfPciRomImages) { - - NewTable =3D ReallocatePool ( - mMaxNumberOfPciRomImages * sizeof (PCI_ROM_IMAGE), - (mMaxNumberOfPciRomImages + 0x20) * sizeof (PCI_ROM_IMAGE= ), - mRomImageTable - ); - if (NewTable =3D=3D NULL) { - return ; + for (Index =3D 0; Index < mNumberOfPciRomImages; Index++) { + if (mRomImageTable[Index].Seg =3D=3D Seg && + mRomImageTable[Index].Bus =3D=3D Bus && + mRomImageTable[Index].Dev =3D=3D Dev && + mRomImageTable[Index].Func =3D=3D Func) { + // + // Expect once RomImage and RomSize are recorded, they will be passe= d in + // later when updating ImageHandle + // + ASSERT ((mRomImageTable[Index].RomImage =3D=3D NULL) || (RomImage = =3D=3D mRomImageTable[Index].RomImage)); + ASSERT ((mRomImageTable[Index].RomSize =3D=3D 0 ) || (RomSize = =3D=3D mRomImageTable[Index].RomSize )); + break; } + } =20 - mRomImageTable =3D NewTable; - mMaxNumberOfPciRomImages +=3D 0x20; + if (Index =3D=3D mNumberOfPciRomImages) { + // + // Rom Image Table buffer needs to grow. + // + if (mNumberOfPciRomImages =3D=3D mMaxNumberOfPciRomImages) { + NewTable =3D ReallocatePool ( + mMaxNumberOfPciRomImages * sizeof (PCI_ROM_IMAGE), + (mMaxNumberOfPciRomImages + 0x20) * sizeof (PCI_ROM_IMA= GE), + mRomImageTable + ); + if (NewTable =3D=3D NULL) { + return ; + } + + mRomImageTable =3D NewTable; + mMaxNumberOfPciRomImages +=3D 0x20; + } + // + // Record the new PCI device + // + mRomImageTable[Index].Seg =3D Seg; + mRomImageTable[Index].Bus =3D Bus; + mRomImageTable[Index].Dev =3D Dev; + mRomImageTable[Index].Func =3D Func; + mNumberOfPciRomImages++; } =20 - mRomImageTable[mNumberOfPciRomImages].ImageHandle =3D ImageHandle; - mRomImageTable[mNumberOfPciRomImages].Seg =3D Seg; - mRomImageTable[mNumberOfPciRomImages].Bus =3D Bus; - mRomImageTable[mNumberOfPciRomImages].Dev =3D Dev; - mRomImageTable[mNumberOfPciRomImages].Func =3D Func; - mRomImageTable[mNumberOfPciRomImages].RomImage =3D RomImage; - mRomImageTable[mNumberOfPciRomImages].RomSize =3D RomSize; - mNumberOfPciRomImages++; + mRomImageTable[Index].ImageHandle =3D ImageHandle; + mRomImageTable[Index].RomImage =3D RomImage; + mRomImageTable[Index].RomSize =3D RomSize; } =20 /** @@ -96,26 +119,23 @@ PciRomGetImageMapping ( { EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; UINTN Index; - BOOLEAN Found; =20 PciRootBridgeIo =3D PciIoDevice->PciRootBridgeIo; - Found =3D FALSE; =20 for (Index =3D 0; Index < mNumberOfPciRomImages; Index++) { if (mRomImageTable[Index].Seg =3D=3D PciRootBridgeIo->SegmentNumber && mRomImageTable[Index].Bus =3D=3D PciIoDevice->BusNumber && mRomImageTable[Index].Dev =3D=3D PciIoDevice->DeviceNumber && mRomImageTable[Index].Func =3D=3D PciIoDevice->FunctionNumber )= { - Found =3D TRUE; =20 if (mRomImageTable[Index].ImageHandle !=3D NULL) { AddDriver (PciIoDevice, mRomImageTable[Index].ImageHandle); - } else { - PciIoDevice->PciIo.RomImage =3D mRomImageTable[Index].RomImage; - PciIoDevice->PciIo.RomSize =3D mRomImageTable[Index].RomSize; } + PciIoDevice->PciIo.RomImage =3D mRomImageTable[Index].RomImage; + PciIoDevice->PciIo.RomSize =3D mRomImageTable[Index].RomSize; + return TRUE; } } =20 - return Found; + return FALSE; } --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel