X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FAcpi%2FFirmwarePerformanceDataTableDxe%2FFirmwarePerformanceDxe.c;h=e719e9e482cb2d280ce8852cd3ed298be85ba64c;hp=f834778acdcfebb4cdda480a18fa2be9aeb56175;hb=d4ee449d1dabee20fc36650545143a5430fa718f;hpb=9cf37b40183ee94a128321a97d9b72c334b002cc diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index f834778acd..e719e9e482 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -5,7 +5,7 @@ for Firmware Basic Boot Performance Record and other boot performance records, and install FPDT to ACPI table. - Copyright (c) 2011 - 2013, 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 @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -41,16 +40,7 @@ #include #include -// -// ACPI table information used to initialize tables. -// -#define EFI_ACPI_OEM_ID "INTEL" -#define EFI_ACPI_OEM_TABLE_ID 0x2020204F4E414954ULL // "TIANO " -#define EFI_ACPI_OEM_REVISION 0x00000001 -#define EFI_ACPI_CREATOR_ID 0x5446534D // TBD "MSFT" -#define EFI_ACPI_CREATOR_REVISION 0x01000013 // TBD -#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; @@ -59,11 +49,10 @@ EFI_EVENT mReadyToBootEvent; EFI_EVENT mLegacyBootEvent; EFI_EVENT mExitBootServicesEvent; UINTN mFirmwarePerformanceTableTemplateKey = 0; -UINT32 mBootRecordSize = 0; -UINT32 mBootRecordMaxSize = 0; -UINT8 *mBootRecordBuffer = NULL; +BOOLEAN mDxeCoreReportStatusCodeEnable = FALSE; BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL; +BOOT_PERFORMANCE_TABLE *mReceivedAcpiBootPerformanceTable = NULL; S3_PERFORMANCE_TABLE *mAcpiS3PerformanceTable = NULL; FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate = { @@ -73,13 +62,13 @@ FIRMWARE_PERFORMANCE_TABLE mFirmwarePerformanceTableTemplate = { EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_REVISION, // Revision 0x00, // Checksum will be updated at runtime // - // It is expected that these values will be updated at runtime. + // It is expected that these values will be updated at EntryPoint. // - EFI_ACPI_OEM_ID, // OEMID is a 6 bytes long field - EFI_ACPI_OEM_TABLE_ID, // OEM table identification(8 bytes long) - EFI_ACPI_OEM_REVISION, // OEM revision number - EFI_ACPI_CREATOR_ID, // ASL compiler vendor ID - EFI_ACPI_CREATOR_REVISION, // ASL compiler revision number + {0x00}, // OEM ID is a 6 bytes long field + 0x00, // OEM Table ID(8 bytes long) + 0x00, // OEM Revision + 0x00, // Creator ID + 0x00, // Creator Revision }, // // Firmware Basic Boot Performance Table Pointer Record. @@ -335,15 +324,9 @@ InstallFirmwarePerformanceDataTable ( { EFI_STATUS Status; EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; - UINTN Size; - UINT8 *SmmBootRecordCommBuffer; - EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader; - SMM_BOOT_RECORD_COMMUNICATE *SmmCommData; - UINTN CommSize; UINTN BootPerformanceDataSize; - UINT8 *BootPerformanceData; - EFI_SMM_COMMUNICATION_PROTOCOL *Communication; FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable; + UINTN Size; // // Get AcpiTable Protocol. @@ -353,129 +336,50 @@ InstallFirmwarePerformanceDataTable ( return Status; } - // - // Collect boot records from SMM drivers. - // - SmmBootRecordCommBuffer = NULL; - SmmCommData = NULL; - Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication); - if (!EFI_ERROR (Status)) { - // - // Initialize communicate buffer - // - SmmBootRecordCommBuffer = AllocateZeroPool (SMM_BOOT_RECORD_COMM_SIZE); - ASSERT (SmmBootRecordCommBuffer != NULL); - SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER*)SmmBootRecordCommBuffer; - SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE*)SmmCommBufferHeader->Data; - ZeroMem((UINT8*)SmmCommData, sizeof(SMM_BOOT_RECORD_COMMUNICATE)); - - CopyGuid (&SmmCommBufferHeader->HeaderGuid, &gEfiFirmwarePerformanceGuid); - SmmCommBufferHeader->MessageLength = sizeof(SMM_BOOT_RECORD_COMMUNICATE); - CommSize = SMM_BOOT_RECORD_COMM_SIZE; - - // - // Get the size of boot records. + if (mReceivedAcpiBootPerformanceTable != NULL) { + mAcpiBootPerformanceTable = mReceivedAcpiBootPerformanceTable; + mAcpiBootPerformanceTable->BasicBoot.ResetEnd = mBootPerformanceTableTemplate.BasicBoot.ResetEnd; + } else { // - SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE; - SmmCommData->BootRecordData = NULL; - Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize); - ASSERT_EFI_ERROR (Status); - - if (!EFI_ERROR (SmmCommData->ReturnStatus) && SmmCommData->BootRecordSize != 0) { - // - // Get all boot records - // - SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA; - SmmCommData->BootRecordData = AllocateZeroPool(SmmCommData->BootRecordSize); - ASSERT (SmmCommData->BootRecordData != NULL); - - Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize); - ASSERT_EFI_ERROR (Status); - ASSERT_EFI_ERROR(SmmCommData->ReturnStatus); - } - } - - // - // Prepare memory for Boot Performance table. - // Boot Performance table includes BasicBoot record, and one or more appended Boot Records. - // - BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE) + mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize); - if (SmmCommData != NULL) { - BootPerformanceDataSize += SmmCommData->BootRecordSize; - } - - // - // Try to allocate the same runtime buffer as last time boot. - // - ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable)); - Size = sizeof (PerformanceVariable); - Status = gRT->GetVariable ( - EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, - &gEfiFirmwarePerformanceGuid, - NULL, - &Size, - &PerformanceVariable - ); - if (!EFI_ERROR (Status)) { - Status = gBS->AllocatePages ( - AllocateAddress, - EfiReservedMemoryType, - EFI_SIZE_TO_PAGES (BootPerformanceDataSize), - &PerformanceVariable.BootPerformanceTablePointer + // Try to allocate the same runtime buffer as last time boot. + // + BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE); + ZeroMem (&PerformanceVariable, sizeof (PerformanceVariable)); + Size = sizeof (PerformanceVariable); + Status = gRT->GetVariable ( + EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, + &gEfiFirmwarePerformanceGuid, + NULL, + &Size, + &PerformanceVariable ); if (!EFI_ERROR (Status)) { - mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.BootPerformanceTablePointer; - } - } - - if (mAcpiBootPerformanceTable == NULL) { - // - // Fail to allocate at specified address, continue to allocate at any address. - // - mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize); - } - DEBUG ((EFI_D_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable)); - - if (mAcpiBootPerformanceTable == NULL) { - if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) { - FreePool (SmmCommData->BootRecordData); + Status = gBS->AllocatePages ( + AllocateAddress, + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (BootPerformanceDataSize), + &PerformanceVariable.BootPerformanceTablePointer + ); + if (!EFI_ERROR (Status)) { + mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) (UINTN) PerformanceVariable.BootPerformanceTablePointer; + } } - if (SmmBootRecordCommBuffer != NULL) { - FreePool (SmmBootRecordCommBuffer); + if (mAcpiBootPerformanceTable == NULL) { + // + // Fail to allocate at specified address, continue to allocate at any address. + // + mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize); } - if (mAcpiS3PerformanceTable != NULL) { - FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE))); + DEBUG ((DEBUG_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable)); + if (mAcpiBootPerformanceTable == NULL) { + return EFI_OUT_OF_RESOURCES; } - return EFI_OUT_OF_RESOURCES; - } - - // - // Prepare Boot Performance Table. - // - BootPerformanceData = (UINT8 *) mAcpiBootPerformanceTable; - // - // Fill Basic Boot record to Boot Performance Table. - // - CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate)); - BootPerformanceData = BootPerformanceData + mAcpiBootPerformanceTable->Header.Length; - // - // Fill Boot records from boot drivers. - // - CopyMem (BootPerformanceData, mBootRecordBuffer, mBootRecordSize); - mAcpiBootPerformanceTable->Header.Length += mBootRecordSize; - BootPerformanceData = BootPerformanceData + mBootRecordSize; - if (SmmCommData != NULL && SmmCommData->BootRecordData != NULL) { // - // Fill Boot records from SMM drivers. + // Fill Basic Boot record to Boot Performance Table. // - CopyMem (BootPerformanceData, SmmCommData->BootRecordData, SmmCommData->BootRecordSize); - FreePool (SmmCommData->BootRecordData); - mAcpiBootPerformanceTable->Header.Length = (UINT32) (mAcpiBootPerformanceTable->Header.Length + SmmCommData->BootRecordSize); - BootPerformanceData = BootPerformanceData + SmmCommData->BootRecordSize; - } - if (SmmBootRecordCommBuffer != NULL) { - FreePool (SmmBootRecordCommBuffer); + CopyMem (mAcpiBootPerformanceTable, &mBootPerformanceTableTemplate, sizeof (mBootPerformanceTableTemplate)); } + BootPerformanceDataSize = mAcpiBootPerformanceTable->Header.Length; // // Save Boot Performance Table address to Variable for use in S4 resume. @@ -496,15 +400,15 @@ InstallFirmwarePerformanceDataTable ( mFirmwarePerformanceTableTemplate.S3PointerRecord.S3PerformanceTablePointer = (UINT64) (UINTN) mAcpiS3PerformanceTable; // // Save Runtime Performance Table pointers to Variable. + // Don't check SetVariable return status. It doesn't impact FPDT table generation. // - Status = gRT->SetVariable ( - EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, - &gEfiFirmwarePerformanceGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, - sizeof (PerformanceVariable), - &PerformanceVariable - ); - ASSERT_EFI_ERROR (Status); + gRT->SetVariable ( + EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, + &gEfiFirmwarePerformanceGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, + sizeof (PerformanceVariable), + &PerformanceVariable + ); // // Publish Firmware Performance Data Table. @@ -517,7 +421,9 @@ InstallFirmwarePerformanceDataTable ( &mFirmwarePerformanceTableTemplateKey ); if (EFI_ERROR (Status)) { - FreePages (mAcpiBootPerformanceTable, EFI_SIZE_TO_PAGES (BootPerformanceDataSize)); + if (mAcpiBootPerformanceTable != NULL) { + FreePages (mAcpiBootPerformanceTable, EFI_SIZE_TO_PAGES (BootPerformanceDataSize)); + } if (mAcpiS3PerformanceTable != NULL) { FreePages (mAcpiS3PerformanceTable, EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE))); } @@ -525,122 +431,9 @@ InstallFirmwarePerformanceDataTable ( mAcpiS3PerformanceTable = NULL; return Status; } - - // - // Free temp Boot record, and update Boot Record to point to Basic Boot performance table. - // - if (mBootRecordBuffer != NULL) { - FreePool (mBootRecordBuffer); - } - mBootRecordBuffer = (UINT8 *) mAcpiBootPerformanceTable; - mBootRecordSize = mAcpiBootPerformanceTable->Header.Length; - mBootRecordMaxSize = mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize); - 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 (); - } -} - -/** - Notify function for event group EFI_EVENT_LEGACY_BOOT_GUID. This is used to - record performance data for OsLoaderLoadImageStart in FPDT for legacy boot. - - @param[in] Event The Event that is being processed. - @param[in] Context The Event Context. - -**/ -VOID -EFIAPI -FpdtLegacyBootEventNotify ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - if (mAcpiBootPerformanceTable == NULL) { - // - // Firmware Performance Data Table not installed, do nothing. - // - return ; - } - - // - // Update Firmware Basic Boot Performance Record for legacy boot. - // - mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart = 0; - mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart = GetTimeInNanoSecond (GetPerformanceCounter ()); - mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry = 0; - mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesExit = 0; - - // - // Dump FPDT Boot Performance record. - // - 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")); -} - -/** - Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record - performance data for ExitBootServicesEntry in FPDT. - - @param[in] Event The Event that is being processed. - @param[in] Context The Event Context. - -**/ -VOID -EFIAPI -FpdtExitBootServicesEventNotify ( - IN EFI_EVENT Event, - IN VOID *Context - ) -{ - if (mAcpiBootPerformanceTable == NULL) { - // - // Firmware Performance Data Table not installed, do nothing. - // - return ; - } - - // - // Update Firmware Basic Boot Performance Record for UEFI boot. - // - mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry = GetTimeInNanoSecond (GetPerformanceCounter ()); - - // - // Dump FPDT Boot Performance record. - // - DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); - DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart)); - DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); - DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry)); - // - // ExitBootServicesExit will be updated later, so don't dump it here. - // -} - /** Report status code listener of FPDT. This is used to collect performance data for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT. @@ -678,6 +471,13 @@ FpdtStatusCodeListenerDxe ( if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { return EFI_UNSUPPORTED; } + + if (Value == (EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT)) { + // + // DxeCore ReportStatusCode Enable so that the capability can be supported. + // + mDxeCoreReportStatusCodeEnable = TRUE; + } Status = EFI_SUCCESS; if (Value == PcdGet32 (PcdProgressCodeOsLoaderLoad)) { @@ -705,6 +505,11 @@ FpdtStatusCodeListenerDxe ( // mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart = GetTimeInNanoSecond (GetPerformanceCounter ()); } else if (Value == (EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES)) { + // + // Unregister boot time report status code listener. + // + mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe); + // // Progress code for ExitBootServices. // @@ -716,47 +521,42 @@ FpdtStatusCodeListenerDxe ( // Update ExitBootServicesExit for UEFI boot. // mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesExit = GetTimeInNanoSecond (GetPerformanceCounter ()); + } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT)) { + if (mAcpiBootPerformanceTable == NULL) { + // + // Firmware Performance Data Table not installed, do nothing. + // + return Status; + } // - // Unregister boot time report status code listener. + // Update Firmware Basic Boot Performance Record for legacy boot. // - mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe); - } else if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { + mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart = GetTimeInNanoSecond (GetPerformanceCounter ()); + // - // Append one or more Boot records + // Dump FPDT Boot Performance record. // + 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) { // - // Append Boot records before FPDT ACPI table is installed. - // - if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { - mBootRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer); - ASSERT (mBootRecordBuffer != NULL); - mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE; - } - // - // Save boot record into the temp memory space. - // - CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size); - mBootRecordSize += Data->Size; - } else { + // ACPI Firmware Performance Data Table not installed yet, install it now. // - // Append Boot records after FPDT ACPI table is installed. - // - if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { - // - // No enough space to save boot record. - // - Status = EFI_OUT_OF_RESOURCES; - } else { - // - // Save boot record into BootPerformance table - // - CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size); - mBootRecordSize += Data->Size; - mAcpiBootPerformanceTable->Header.Length = mBootRecordSize; - } + InstallFirmwarePerformanceDataTable (); } + } else if (Data != NULL && CompareGuid (&Data->Type, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) { + // + // Get the Boot performance table and then install it to ACPI table. + // + CopyMem (&mReceivedAcpiBootPerformanceTable, Data + 1, Data->Size); + } else if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { + DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerDxe: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableDxe\n")); + Status = EFI_UNSUPPORTED; } else { // // Ignore else progress code. @@ -767,6 +567,54 @@ FpdtStatusCodeListenerDxe ( return Status; } + +/** + Notify function for event EVT_SIGNAL_EXIT_BOOT_SERVICES. This is used to record + performance data for ExitBootServicesEntry in FPDT. + + @param[in] Event The Event that is being processed. + @param[in] Context The Event Context. + +**/ +VOID +EFIAPI +FpdtExitBootServicesEventNotify ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + if (!mDxeCoreReportStatusCodeEnable) { + // + // When DxeCore Report Status Code is disabled, + // Unregister boot time report status code listener at ExitBootService Event. + // + mRscHandlerProtocol->Unregister (FpdtStatusCodeListenerDxe); + } + + if (mAcpiBootPerformanceTable == NULL) { + // + // Firmware Performance Data Table not installed, do nothing. + // + return ; + } + + // + // Update Firmware Basic Boot Performance Record for UEFI boot. + // + mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry = GetTimeInNanoSecond (GetPerformanceCounter ()); + + // + // Dump FPDT Boot Performance record. + // + DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); + DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderLoadImageStart)); + DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); + DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = %ld\n", mAcpiBootPerformanceTable->BasicBoot.ExitBootServicesEntry)); + // + // ExitBootServicesExit will be updated later, so don't dump it here. + // +} + /** The module Entry Point of the Firmware Performance Data Table DXE driver. @@ -788,6 +636,18 @@ FirmwarePerformanceDxeEntryPoint ( EFI_HOB_GUID_TYPE *GuidHob; FIRMWARE_SEC_PERFORMANCE *Performance; VOID *Registration; + UINT64 OemTableId; + + CopyMem ( + mFirmwarePerformanceTableTemplate.Header.OemId, + PcdGetPtr (PcdAcpiDefaultOemId), + sizeof (mFirmwarePerformanceTableTemplate.Header.OemId) + ); + OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId); + CopyMem (&mFirmwarePerformanceTableTemplate.Header.OemTableId, &OemTableId, sizeof (UINT64)); + mFirmwarePerformanceTableTemplate.Header.OemRevision = PcdGet32 (PcdAcpiDefaultOemRevision); + mFirmwarePerformanceTableTemplate.Header.CreatorId = PcdGet32 (PcdAcpiDefaultCreatorId); + mFirmwarePerformanceTableTemplate.Header.CreatorRevision = PcdGet32 (PcdAcpiDefaultCreatorRevision); // // Get Report Status Code Handler Protocol. @@ -814,32 +674,6 @@ FirmwarePerformanceDxeEntryPoint ( ); 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); - - // - // Create legacy boot event to log OsLoaderStartImageStart for legacy boot. - // - Status = gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_NOTIFY, - FpdtLegacyBootEventNotify, - NULL, - &gEfiEventLegacyBootGuid, - &mLegacyBootEvent - ); - ASSERT_EFI_ERROR (Status); - // // Retrieve GUID HOB data that contains the ResetEnd. // @@ -851,7 +685,7 @@ FirmwarePerformanceDxeEntryPoint ( // // SEC Performance Data Hob not found, ResetEnd in ACPI FPDT table will be 0. // - DEBUG ((EFI_D_ERROR, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n")); + DEBUG ((DEBUG_WARN, "FPDT: WARNING: SEC Performance Data Hob not found, ResetEnd will be set to 0!\n")); } if (FeaturePcdGet (PcdFirmwarePerformanceDataTableS3Support)) {