From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jiewen.yao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 53F6721143593 for ; Tue, 18 Sep 2018 23:01:04 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2018 23:01:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,392,1531810800"; d="scan'208";a="71157671" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga007.fm.intel.com with ESMTP; 18 Sep 2018 23:00:42 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 18 Sep 2018 23:00:39 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 18 Sep 2018 23:00:37 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.226]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.150]) with mapi id 14.03.0319.002; Wed, 19 Sep 2018 13:59:59 +0800 From: "Yao, Jiewen" To: "Zeng, Star" , "edk2-devel@lists.01.org" CC: Younas khan , "Kinney, Michael D" , "Gao, Liming" Thread-Topic: [PATCH V3 2/6] IntelSiliconPkg IntelVTdDxe: Use new EfiLocateFirstAcpiTable() Thread-Index: AQHUTmYFETGGeKoYv0uV6ATM9smuUaT3Hyew Date: Wed, 19 Sep 2018 05:59:58 +0000 Message-ID: <74D8A39837DF1E4DA445A8C0B3885C503AD65C96@shsmsx102.ccr.corp.intel.com> References: <1537175295-37508-1-git-send-email-star.zeng@intel.com> <1537175295-37508-3-git-send-email-star.zeng@intel.com> In-Reply-To: <1537175295-37508-3-git-send-email-star.zeng@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTc3MDJlNjUtNDNmYy00OWQ3LTkyYTctZjQyODc3MGZiYmNjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibGFwK0hvTXFCVURqMnBuTENMNXRYZkJrZnZ2OVdcL1FSbDRLQXl4TmgzeWVycU9HejQ0RmJjZ0VudXBvRUI0Wk4ifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH V3 2/6] IntelSiliconPkg IntelVTdDxe: Use new EfiLocateFirstAcpiTable() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2018 06:01:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Zeng, Star > Sent: Monday, September 17, 2018 5:08 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star ; Younas khan > ; Kinney, Michael D > ; Gao, Liming ; Yao, > Jiewen > Subject: [PATCH V3 2/6] IntelSiliconPkg IntelVTdDxe: Use new > EfiLocateFirstAcpiTable() >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D967 > Request to add a library function for GetAcpiTable() in order > to get ACPI table using signature as input. >=20 > After evaluation, we found there are many duplicated code to > find ACPI table by signature in different modules. >=20 > This patch updates IntelVTdDxe to use new > EfiLocateFirstAcpiTable() and remove the duplicated code. >=20 > Cc: Younas khan > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Jiewen Yao > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Star Zeng > --- > .../Feature/VTd/IntelVTdDxe/DmarAcpiTable.c | 136 > +-------------------- > 1 file changed, 3 insertions(+), 133 deletions(-) >=20 > diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > index 24723fe4972a..92b09f985533 100644 > --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c > @@ -868,116 +868,6 @@ ParseDmarAcpiTableRmrr ( > } >=20 > /** > - This function scan ACPI table in RSDT. > - > - @param[in] Rsdt ACPI RSDT > - @param[in] Signature ACPI table signature > - > - @return ACPI table > -**/ > -VOID * > -ScanTableInRSDT ( > - IN RSDT_TABLE *Rsdt, > - IN UINT32 Signature > - ) > -{ > - UINTN Index; > - UINT32 EntryCount; > - UINT32 *EntryPtr; > - EFI_ACPI_DESCRIPTION_HEADER *Table; > - > - EntryCount =3D (Rsdt->Header.Length - sizeof > (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32); > - > - EntryPtr =3D &Rsdt->Entry; > - for (Index =3D 0; Index < EntryCount; Index ++, EntryPtr ++) { > - Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); > - if ((Table !=3D NULL) && (Table->Signature =3D=3D Signature)) { > - return Table; > - } > - } > - > - return NULL; > -} > - > -/** > - This function scan ACPI table in XSDT. > - > - @param[in] Xsdt ACPI XSDT > - @param[in] Signature ACPI table signature > - > - @return ACPI table > -**/ > -VOID * > -ScanTableInXSDT ( > - IN XSDT_TABLE *Xsdt, > - IN UINT32 Signature > - ) > -{ > - UINTN Index; > - UINT32 EntryCount; > - UINT64 EntryPtr; > - UINTN BasePtr; > - EFI_ACPI_DESCRIPTION_HEADER *Table; > - > - EntryCount =3D (Xsdt->Header.Length - sizeof > (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64); > - > - BasePtr =3D (UINTN)(&(Xsdt->Entry)); > - for (Index =3D 0; Index < EntryCount; Index ++) { > - CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), > sizeof(UINT64)); > - Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr)); > - if ((Table !=3D NULL) && (Table->Signature =3D=3D Signature)) { > - return Table; > - } > - } > - > - return NULL; > -} > - > -/** > - This function scan ACPI table in RSDP. > - > - @param[in] Rsdp ACPI RSDP > - @param[in] Signature ACPI table signature > - > - @return ACPI table > -**/ > -VOID * > -FindAcpiPtr ( > - IN EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp, > - IN UINT32 Signature > - ) > -{ > - EFI_ACPI_DESCRIPTION_HEADER *AcpiTable; > - RSDT_TABLE *Rsdt; > - XSDT_TABLE *Xsdt; > - > - AcpiTable =3D NULL; > - > - // > - // Check ACPI2.0 table > - // > - Rsdt =3D (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress; > - Xsdt =3D NULL; > - if ((Rsdp->Revision >=3D 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)= ) { > - Xsdt =3D (XSDT_TABLE *)(UINTN)Rsdp->XsdtAddress; > - } > - // > - // Check Xsdt > - // > - if (Xsdt !=3D NULL) { > - AcpiTable =3D ScanTableInXSDT (Xsdt, Signature); > - } > - // > - // Check Rsdt > - // > - if ((AcpiTable =3D=3D NULL) && (Rsdt !=3D NULL)) { > - AcpiTable =3D ScanTableInRSDT (Rsdt, Signature); > - } > - > - return AcpiTable; > -} > - > -/** > Get the DMAR ACPI table. >=20 > @retval EFI_SUCCESS The DMAR ACPI table is got. > @@ -989,33 +879,13 @@ GetDmarAcpiTable ( > VOID > ) > { > - VOID *AcpiTable; > - EFI_STATUS Status; > - > if (mAcpiDmarTable !=3D NULL) { > return EFI_ALREADY_STARTED; > } >=20 > - AcpiTable =3D NULL; > - Status =3D EfiGetSystemConfigurationTable ( > - &gEfiAcpi20TableGuid, > - &AcpiTable > - ); > - if (EFI_ERROR (Status)) { > - Status =3D EfiGetSystemConfigurationTable ( > - &gEfiAcpi10TableGuid, > - &AcpiTable > - ); > - } > - if (EFI_ERROR (Status)) { > - return EFI_NOT_FOUND; > - } > - ASSERT (AcpiTable !=3D NULL); > - > - mAcpiDmarTable =3D FindAcpiPtr ( > - > (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable, > - > EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE > - ); > + mAcpiDmarTable =3D (EFI_ACPI_DMAR_HEADER *) EfiLocateFirstAcpiTable > ( > + > EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE > + ); > if (mAcpiDmarTable =3D=3D NULL) { > return EFI_NOT_FOUND; > } > -- > 2.7.0.windows.1