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 B8B882110A3FA for ; Fri, 31 Aug 2018 04:29:31 -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:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,311,1531810800"; d="scan'208";a="253450327" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga005.jf.intel.com with ESMTP; 31 Aug 2018 04:29:30 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Younas khan , Michael D Kinney , Liming Gao , Jiewen Yao , Ruiyu Ni , Dandan Bi Date: Fri, 31 Aug 2018 19:29:18 +0800 Message-Id: <1535714959-73472-6-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 5/6] ShellPkg DpDynamicCommand: 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:31 -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 DpDynamicCommand to use new EfiFindAcpiTableBySignature() and remove the duplicated code. Cc: Younas khan Cc: Michael D Kinney Cc: Liming Gao Cc: Jiewen Yao Cc: Ruiyu Ni Cc: Dandan Bi Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 136 +-------------------- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 1 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 1 - ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 2 - .../DpDynamicCommand/DpDynamicCommand.inf | 2 - 5 files changed, 3 insertions(+), 139 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index 2c094b63c94a..3b9549c2be8e 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -118,116 +118,6 @@ DumpStatistics( void ) } /** - This function scan ACPI table in RSDT. - - @param Rsdt ACPI RSDT - @param 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->Signature == Signature) { - return Table; - } - } - - return NULL; -} - -/** - This function scan ACPI table in XSDT. - - @param Xsdt ACPI XSDT - @param 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->Signature == Signature) { - return Table; - } - } - - return NULL; -} - -/** - This function scan ACPI table in RSDP. - - @param Rsdp ACPI RSDP - @param Signature ACPI table signature - - @return ACPI table -**/ -VOID * -FindAcpiPtr ( - IN EFI_ACPI_5_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 Boot performance table form Acpi table. **/ @@ -235,31 +125,11 @@ EFI_STATUS GetBootPerformanceTable ( ) { - EFI_STATUS Status; - VOID *AcpiTable; FIRMWARE_PERFORMANCE_TABLE *FirmwarePerformanceTable; - AcpiTable = NULL; - - Status = EfiGetSystemConfigurationTable ( - &gEfiAcpi20TableGuid, - &AcpiTable - ); - if (EFI_ERROR (Status)) { - Status = EfiGetSystemConfigurationTable ( - &gEfiAcpi10TableGuid, - &AcpiTable - ); - } - if (EFI_ERROR(Status) || AcpiTable == NULL) { - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_TABLE_FAIL), mDpHiiHandle); - return Status; - } - - FirmwarePerformanceTable = FindAcpiPtr ( - (EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable, - EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE - ); + FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE *) EfiFindAcpiTableBySignature ( + EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE + ); if (FirmwarePerformanceTable == NULL) { ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle); return EFI_NOT_FOUND; diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h index 0e6e9422effc..db8472f6558f 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni index 1d6f25b8c252..7fc2b8d1c966 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni @@ -94,7 +94,6 @@ #string STR_DP_INCOMPLETE #language en-US " I " #string STR_DP_COMPLETE #language en-US " " #string STR_ALIT_UNKNOWN #language en-US "Unknown" -#string STR_DP_GET_ACPI_TABLE_FAIL #language en-US "Fail to get ACPI Table\n" #string STR_DP_GET_ACPI_FPDT_FAIL #language en-US "Fail to get Firmware Performance Data Table (FPDT) in ACPI Table\n" #string STR_GET_HELP_DP #language en-US "" diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf index cedb333b285c..3a35fca310b0 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf @@ -59,8 +59,6 @@ [LibraryClasses] [Guids] gPerformanceProtocolGuid ## CONSUMES ## SystemTable - gEfiAcpi20TableGuid ## CONSUMES ## SystemTable - gEfiAcpi10TableGuid ## CONSUMES ## SystemTable [Protocols] gEfiLoadedImageProtocolGuid ## CONSUMES diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf index 8fd3bbd5df83..62a3b5246500 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf @@ -60,8 +60,6 @@ [LibraryClasses] [Guids] gPerformanceProtocolGuid ## CONSUMES ## SystemTable - gEfiAcpi20TableGuid ## CONSUMES - gEfiAcpi10TableGuid ## CONSUMES [Protocols] gEfiLoadedImageProtocolGuid ## CONSUMES -- 2.7.0.windows.1