From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org 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 4F55822333762 for ; Mon, 22 Jan 2018 19:42:50 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 19:48:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,399,1511856000"; d="scan'208";a="12262560" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by orsmga008.jf.intel.com with ESMTP; 22 Jan 2018 19:48:15 -0800 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Liming Gao , Star Zeng Date: Tue, 23 Jan 2018 11:47:33 +0800 Message-Id: <1516679255-12328-7-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1516679255-12328-1-git-send-email-dandan.bi@intel.com> References: <1516679255-12328-1-git-send-email-dandan.bi@intel.com> Subject: [patch 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Jan 2018 03:42:50 -0000 1. Remove the macro EXTENSION_RECORD_SIZE, since the extension size can be got through PcdExtFpdtBootRecordPadSize. 2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table 3. Copy SMM record according to the allocated size Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceDxe.c | 58 ++++++---------------- 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index b004cac..0de6bfa 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -3,11 +3,11 @@ This module register report status code listener to collect performance data for Firmware Basic Boot Performance Record and other boot performance records, and install FPDT to ACPI table. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.
+ Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -40,12 +40,11 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x10000 -#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE) +#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)) EFI_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL; BOOLEAN mLockBoxReady = FALSE; EFI_EVENT mReadyToBootEvent; @@ -419,11 +418,15 @@ InstallFirmwarePerformanceDataTable ( SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE; while (SmmCommData->BootRecordOffset < SmmBootRecordDataSize) { Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize); ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR(SmmCommData->ReturnStatus); - CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize); + if (SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) { + CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset); + } else { + CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize); + } SmmCommData->BootRecordOffset = SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize; } } } } @@ -567,33 +570,10 @@ InstallFirmwarePerformanceDataTable ( return EFI_SUCCESS; } /** - Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to - install the Firmware Performance Data Table. - - @param[in] Event The Event that is being processed. - @param[in] Context The Event Context. - -**/ -VOID -EFIAPI -FpdtReadyToBootEventNotify ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - if (mAcpiBootPerformanceTable == NULL) { - // - // ACPI Firmware Performance Data Table not installed yet, install it now. - // - InstallFirmwarePerformanceDataTable (); - } -} - -/** Report status code listener of FPDT. This is used to collect performance data for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT. @param[in] CodeType Indicates the type of status code being reported. @param[in] Value Describes the current status of a hardware or software entity. @@ -697,22 +677,29 @@ FpdtStatusCodeListenerDxe ( DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n")); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n")); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesExit = 0\n")); + } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)) { + if (mAcpiBootPerformanceTable == NULL) { + // + // ACPI Firmware Performance Data Table not installed yet, install it now. + // + InstallFirmwarePerformanceDataTable (); + } } else if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { // // Append one or more Boot records // if (mAcpiBootPerformanceTable == NULL) { // // Append Boot records before FPDT ACPI table is installed. // if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { - mBootRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer); + mBootRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + PcdGet32 (PcdExtFpdtBootRecordPadSize), mBootRecordBuffer); ASSERT (mBootRecordBuffer != NULL); - mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE; + mBootRecordMaxSize = mBootRecordSize + Data->Size + PcdGet32 (PcdExtFpdtBootRecordPadSize); } // // Save boot record into the temp memory space. // CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size); @@ -851,23 +838,10 @@ FirmwarePerformanceDxeEntryPoint ( &mExitBootServicesEvent ); ASSERT_EFI_ERROR (Status); // - // Create ready to boot event to install ACPI FPDT table. - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - FpdtReadyToBootEventNotify, - NULL, - &gEfiEventReadyToBootGuid, - &mReadyToBootEvent - ); - ASSERT_EFI_ERROR (Status); - - // // Retrieve GUID HOB data that contains the ResetEnd. // GuidHob = GetFirstGuidHob (&gEfiFirmwarePerformanceGuid); if (GuidHob != NULL) { Performance = (FIRMWARE_SEC_PERFORMANCE *) GET_GUID_HOB_DATA (GuidHob); -- 1.9.5.msysgit.1