Align the perf data between FPDT and DP.

Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13461 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lzeng14 2012-06-19 14:43:33 +00:00
parent 23b0b15526
commit 26c0ba7799
4 changed files with 94 additions and 49 deletions

View File

@ -1664,6 +1664,7 @@ BdsLibDoLegacyBoot (
{
EFI_STATUS Status;
EFI_LEGACY_BIOS_PROTOCOL *LegacyBios;
EFI_EVENT LegacyBootEvent;
Status = gBS->LocateProtocol (&gEfiLegacyBiosProtocolGuid, NULL, (VOID **) &LegacyBios);
if (EFI_ERROR (Status)) {
@ -1681,7 +1682,16 @@ BdsLibDoLegacyBoot (
// Write boot to OS performance data for legacy boot.
//
PERF_CODE (
WriteBootToOsPerformanceData ();
//
// Create an event to be signalled when Legacy Boot occurs to write performance data.
//
Status = EfiCreateEventLegacyBootEx(
TPL_NOTIFY,
WriteBootToOsPerformanceData,
NULL,
&LegacyBootEvent
);
ASSERT_EFI_ERROR (Status);
);
DEBUG ((DEBUG_INFO | DEBUG_LOAD, "Legacy Boot: %S\n", Option->Description));
@ -2219,10 +2229,9 @@ BdsLibBootViaBootOption (
LIST_ENTRY TempBootLists;
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
//
// Record the performance data for End of BDS
//
PERF_END(NULL, "BDS", NULL, 0);
PERF_CODE (
AllocateMemoryForPerformanceData ();
);
*ExitDataSize = 0;
*ExitData = NULL;
@ -2423,7 +2432,7 @@ BdsLibBootViaBootOption (
// Write boot to OS performance data for UEFI boot
//
PERF_CODE (
WriteBootToOsPerformanceData ();
WriteBootToOsPerformanceData (NULL, NULL);
);
//

View File

@ -87,15 +87,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
Allocates a block of memory and writes performance data of booting into it.
OS can processing these record.
Allocates a block of memory to store performance data.
**/
VOID
WriteBootToOsPerformanceData (
AllocateMemoryForPerformanceData (
VOID
);
/**
Writes performance data of booting into the allocated memory.
OS can process these records.
@param Event The triggered event.
@param Context Context for this event.
**/
VOID
EFIAPI
WriteBootToOsPerformanceData (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
Get the headers (dos, image, optional header) from an image

View File

@ -3,7 +3,7 @@
performance, all the function will only include if the performance
switch is set.
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
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
@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
PERF_HEADER mPerfHeader;
PERF_DATA mPerfData;
EFI_PHYSICAL_ADDRESS mAcpiLowMemoryBase = 0x0FFFFFFFFULL;
UINT32 mAcpiLowMemoryLength = 0x4000;
/**
Get the short verion of PDB file name to be
@ -135,17 +136,55 @@ GetNameFromHandle (
/**
Allocates a block of memory and writes performance data of booting into it.
OS can processing these record.
Allocates a block of memory to store performance data.
**/
VOID
WriteBootToOsPerformanceData (
AllocateMemoryForPerformanceData (
VOID
)
{
EFI_STATUS Status;
UINT32 AcpiLowMemoryLength;
if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {
//
// Allocate a block of memory that contain performance data to OS
//
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiReservedMemoryType,
EFI_SIZE_TO_PAGES (mAcpiLowMemoryLength),
&mAcpiLowMemoryBase
);
if (!EFI_ERROR (Status)) {
gRT->SetVariable (
L"PerfDataMemAddr",
&gPerformanceProtocolGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (EFI_PHYSICAL_ADDRESS),
&mAcpiLowMemoryBase
);
}
}
}
/**
Writes performance data of booting into the allocated memory.
OS can process these records.
@param Event The triggered event.
@param Context Context for this event.
**/
VOID
EFIAPI
WriteBootToOsPerformanceData (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
UINT32 LimitCount;
EFI_HANDLE *Handles;
UINTN NoHandles;
@ -171,6 +210,15 @@ WriteBootToOsPerformanceData (
//
BOOLEAN *PerfEntriesAsDxeHandle;
//
// Record the performance data for End of BDS
//
PERF_END(NULL, "BDS", NULL, 0);
if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {
return;
}
//
// Retrieve time stamp count as early as possible
//
@ -208,27 +256,8 @@ WriteBootToOsPerformanceData (
return ;
}
AcpiLowMemoryLength = 0x4000;
if (mAcpiLowMemoryBase == 0x0FFFFFFFF) {
//
// Allocate a block of memory that contain performance data to OS
//
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiReservedMemoryType,
EFI_SIZE_TO_PAGES (AcpiLowMemoryLength),
&mAcpiLowMemoryBase
);
if (EFI_ERROR (Status)) {
FreePool (Handles);
return ;
}
}
Ptr = (UINT8 *) ((UINT32) mAcpiLowMemoryBase + sizeof (PERF_HEADER));
LimitCount = (AcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
LimitCount = (mAcpiLowMemoryLength - sizeof (PERF_HEADER)) / sizeof (PERF_DATA);
NumPerfEntries = 0;
LogEntryKey = 0;
@ -346,13 +375,5 @@ Done:
sizeof (PERF_HEADER)
);
gRT->SetVariable (
L"PerfDataMemAddr",
&gPerformanceProtocolGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof (EFI_PHYSICAL_ADDRESS),
&mAcpiLowMemoryBase
);
return ;
}

View File

@ -410,17 +410,17 @@ S3ResumeBootOs (
return ;
}
//
// report status code on S3 resume
//
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE);
//
// Install EndOfPeiPpi
//
Status = PeiServicesInstallPpi (&mPpiListEndOfPeiTable);
ASSERT_EFI_ERROR (Status);
//
// report status code on S3 resume
//
REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE);
PERF_CODE (
WriteToOsS3PerformanceData ();
);