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 1F85C2110A3FA for ; Fri, 31 Aug 2018 04:29:30 -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:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,311,1531810800"; d="scan'208";a="253450320" Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.158.46]) by orsmga005.jf.intel.com with ESMTP; 31 Aug 2018 04:29:28 -0700 From: Star Zeng To: edk2-devel@lists.01.org Cc: Star Zeng , Younas khan , Michael D Kinney , Liming Gao , Jiewen Yao , Ruiyu Ni Date: Fri, 31 Aug 2018 19:29:17 +0800 Message-Id: <1535714959-73472-5-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 4/6] PcAtChipsetPkg PcRtc: 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:30 -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 PcatRealTimeClockRuntimeDxe 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 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng --- PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c | 80 +--------------------- 1 file changed, 3 insertions(+), 77 deletions(-) diff --git a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c index 2105acf35f7b..72daff719f29 100644 --- a/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c +++ b/PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c @@ -1203,49 +1203,6 @@ IsWithinOneDay ( } /** - This function find ACPI table with the specified signature in RSDT or XSDT. - - @param Sdt ACPI RSDT or XSDT. - @param Signature ACPI table signature. - @param TablePointerSize Size of table pointer: 4 or 8. - - @return ACPI table or NULL if not found. -**/ -VOID * -ScanTableInSDT ( - IN EFI_ACPI_DESCRIPTION_HEADER *Sdt, - IN UINT32 Signature, - IN UINTN TablePointerSize - ) -{ - UINTN Index; - UINTN EntryCount; - UINTN EntryBase; - EFI_ACPI_DESCRIPTION_HEADER *Table; - - EntryCount = (Sdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / TablePointerSize; - - EntryBase = (UINTN) (Sdt + 1); - for (Index = 0; Index < EntryCount; Index++) { - // - // When TablePointerSize is 4 while sizeof (VOID *) is 8, make sure the upper 4 bytes are zero. - // - Table = 0; - CopyMem (&Table, (VOID *) (EntryBase + Index * TablePointerSize), TablePointerSize); - - if (Table == NULL) { - continue; - } - - if (Table->Signature == Signature) { - return Table; - } - } - - return NULL; -} - -/** Get the century RTC address from the ACPI FADT table. @return The century RTC address or 0 if not found. @@ -1255,42 +1212,11 @@ GetCenturyRtcAddress ( VOID ) { - EFI_STATUS Status; - EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt; - Status = EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID **) &Rsdp); - if (EFI_ERROR (Status)) { - Status = EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, (VOID **) &Rsdp); - } - - if (EFI_ERROR (Status) || (Rsdp == NULL)) { - return 0; - } - - Fadt = NULL; - - // - // Find FADT in XSDT - // - if (Rsdp->Revision >= EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp->XsdtAddress != 0) { - Fadt = ScanTableInSDT ( - (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress, - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, - sizeof (UINTN) - ); - } - - // - // Find FADT in RSDT - // - if (Fadt == NULL && Rsdp->RsdtAddress != 0) { - Fadt = ScanTableInSDT ( - (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress, - EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, - sizeof (UINT32) - ); - } + Fadt = (EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE *) EfiFindAcpiTableBySignature ( + EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE + ); if ((Fadt != NULL) && (Fadt->Century > RTC_ADDRESS_REGISTER_D) && (Fadt->Century < 0x80) -- 2.7.0.windows.1