From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: Two or more type TXT spf records found.) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 E1E7D2110BD46 for ; Fri, 31 Aug 2018 04:29:26 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Aug 2018 04:29:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,311,1531810800"; d="scan'208";a="253450294" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga005.jf.intel.com with ESMTP; 31 Aug 2018 04:29:25 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Younas khan , Michael D Kinney , Liming Gao , Jiewen Yao Date: Fri, 31 Aug 2018 19:29:15 +0800 Message-Id: <1535714959-73472-3-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 In-Reply-To: <1535714959-73472-1-git-send-email-star.zeng@intel.com> References: <1535714959-73472-1-git-send-email-star.zeng@intel.com> Subject: [PATCH 2/6] IntelSiliconPkg IntelVTdDxe: Use new EfiFindAcpiTableBySignature() 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: Fri, 31 Aug 2018 11:29:27 -0000 https://bugzilla.tianocore.org/show_bug.cgi?id=967 Request to add a library function for GetAcpiTable() in order to get ACPI table using signature as input. After evaluation, we found there are many duplicated code to find ACPI table by signature in different modules. This patch updates IntelVTdDxe to use new EfiFindAcpiTableBySignature() and remove the duplicated code. 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(-) diff --git a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c index 24723fe4972a..1e8c1f620c98 100644 --- a/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c +++ b/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmarAcpiTable.c @@ -868,116 +868,6 @@ ParseDmarAcpiTableRmrr ( } /** - 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 = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32); - - EntryPtr = &Rsdt->Entry; - for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) { - Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); - if ((Table != NULL) && (Table->Signature == 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 = (Xsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64); - - BasePtr = (UINTN)(&(Xsdt->Entry)); - for (Index = 0; Index < EntryCount; Index ++) { - CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64)); - Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr)); - if ((Table != NULL) && (Table->Signature == 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 = NULL; - - // - // Check ACPI2.0 table - // - Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress; - Xsdt = NULL; - if ((Rsdp->Revision >= 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)) { - Xsdt = (XSDT_TABLE *)(UINTN)Rsdp->XsdtAddress; - } - // - // Check Xsdt - // - if (Xsdt != NULL) { - AcpiTable = ScanTableInXSDT (Xsdt, Signature); - } - // - // Check Rsdt - // - if ((AcpiTable == NULL) && (Rsdt != NULL)) { - AcpiTable = ScanTableInRSDT (Rsdt, Signature); - } - - return AcpiTable; -} - -/** Get the DMAR ACPI table. @retval EFI_SUCCESS The DMAR ACPI table is got. @@ -989,33 +879,13 @@ GetDmarAcpiTable ( VOID ) { - VOID *AcpiTable; - EFI_STATUS Status; - if (mAcpiDmarTable != NULL) { return EFI_ALREADY_STARTED; } - AcpiTable = NULL; - Status = EfiGetSystemConfigurationTable ( - &gEfiAcpi20TableGuid, - &AcpiTable - ); - if (EFI_ERROR (Status)) { - Status = EfiGetSystemConfigurationTable ( - &gEfiAcpi10TableGuid, - &AcpiTable - ); - } - if (EFI_ERROR (Status)) { - return EFI_NOT_FOUND; - } - ASSERT (AcpiTable != NULL); - - mAcpiDmarTable = FindAcpiPtr ( - (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable, - EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE - ); + mAcpiDmarTable = (EFI_ACPI_DMAR_HEADER *) EfiFindAcpiTableBySignature ( + EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE + ); if (mAcpiDmarTable == NULL) { return EFI_NOT_FOUND; } -- 2.7.0.windows.1