mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-02-10 00:01:31 +01:00
fix some memory leaks and crashes, according to Tiano
Signed-off-by: Slice <sergey.slice@gmail.com>
This commit is contained in:
parent
7adb640a42
commit
b91c9dec6f
@ -2470,7 +2470,7 @@ GetDriverNameWorker (
|
|||||||
BestLanguage,
|
BestLanguage,
|
||||||
DriverName
|
DriverName
|
||||||
);
|
);
|
||||||
FreePool(BestLanguage);
|
// FreePool(BestLanguage); // it was not allocated
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -699,6 +699,10 @@ CoreLocateHandleBuffer (
|
|||||||
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
|
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
*NumberHandles = 0;
|
*NumberHandles = 0;
|
||||||
|
if (*Buffer != NULL) {
|
||||||
|
CoreFreePool (*Buffer);
|
||||||
|
*Buffer = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -496,13 +496,13 @@ LoadOpRomImage (
|
|||||||
Indicator = RomPcir->Indicator;
|
Indicator = RomPcir->Indicator;
|
||||||
RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
|
RomImageSize = RomImageSize + RomPcir->ImageLength * 512;
|
||||||
RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512;
|
RomBarOffset = RomBarOffset + RomPcir->ImageLength * 512;
|
||||||
} while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize));
|
} while (((Indicator & 0x80) == 0x00) && ((RomBarOffset - RomBar) < RomSize) && (RomImageSize > 0));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Some Legacy Cards do not report the correct ImageLength so used the maximum
|
// Some Legacy Cards do not report the correct ImageLength so used the maximum
|
||||||
// of the legacy length and the PCIR Image Length
|
// of the legacy length and the PCIR Image Length
|
||||||
//
|
//
|
||||||
if (CodeType == PCI_CODE_TYPE_PCAT_IMAGE) {
|
if ((RomImageSize > 0) && (CodeType == PCI_CODE_TYPE_PCAT_IMAGE)) {
|
||||||
RomImageSize = MAX (RomImageSize, LegacyImageLength);
|
RomImageSize = MAX (RomImageSize, LegacyImageLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Locate handle functions
|
Locate handle functions
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -693,6 +693,10 @@ CoreLocateHandleBuffer (
|
|||||||
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
|
*NumberHandles = BufferSize / sizeof(EFI_HANDLE);
|
||||||
if (EFI_ERROR(Status)) {
|
if (EFI_ERROR(Status)) {
|
||||||
*NumberHandles = 0;
|
*NumberHandles = 0;
|
||||||
|
if (*Buffer != NULL) {
|
||||||
|
CoreFreePool (*Buffer);
|
||||||
|
*Buffer = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
|
@ -10,13 +10,12 @@
|
|||||||
This library is mainly used by DxeCore to start performance logging to ensure that
|
This library is mainly used by DxeCore to start performance logging to ensure that
|
||||||
Performance Protocol is installed at the very beginning of DXE phase.
|
Performance Protocol is installed at the very beginning of DXE phase.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.<BR>
|
||||||
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
|
||||||
#include "DxeCorePerformanceLibInternal.h"
|
#include "DxeCorePerformanceLibInternal.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -64,7 +63,7 @@ UINT32 mLoadImageCount = 0;
|
|||||||
UINT32 mPerformanceLength = 0;
|
UINT32 mPerformanceLength = 0;
|
||||||
UINT32 mMaxPerformanceLength = 0;
|
UINT32 mMaxPerformanceLength = 0;
|
||||||
UINT32 mBootRecordSize = 0;
|
UINT32 mBootRecordSize = 0;
|
||||||
UINT32 mBootRecordMaxSize = 0;
|
UINTN mBootRecordMaxSize = 0;
|
||||||
UINT32 mCachedLength = 0;
|
UINT32 mCachedLength = 0;
|
||||||
|
|
||||||
BOOLEAN mFpdtBufferIsReported = FALSE;
|
BOOLEAN mFpdtBufferIsReported = FALSE;
|
||||||
@ -74,6 +73,7 @@ UINT8 *mPerformancePointer = NULL;
|
|||||||
UINT8 *mBootRecordBuffer = NULL;
|
UINT8 *mBootRecordBuffer = NULL;
|
||||||
BOOLEAN mLockInsertRecord = FALSE;
|
BOOLEAN mLockInsertRecord = FALSE;
|
||||||
CHAR8 *mDevicePathString = NULL;
|
CHAR8 *mDevicePathString = NULL;
|
||||||
|
UINTN mSmmBootRecordOffset = 0;
|
||||||
|
|
||||||
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;
|
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;
|
||||||
|
|
||||||
@ -110,6 +110,7 @@ GetFpdtRecordPtr (
|
|||||||
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save boot records\n"));
|
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save boot records\n"));
|
||||||
mLackSpaceIsReported = TRUE;
|
mLackSpaceIsReported = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
@ -130,13 +131,16 @@ GetFpdtRecordPtr (
|
|||||||
if (mPerformancePointer == NULL) {
|
if (mPerformancePointer == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;
|
mMaxPerformanceLength = mPerformanceLength + RecordSize + FIRMWARE_RECORD_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Covert buffer to FPDT Ptr Union type.
|
// Covert buffer to FPDT Ptr Union type.
|
||||||
//
|
//
|
||||||
FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mPerformanceLength);
|
FpdtRecordPtr->RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mPerformanceLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,16 +162,17 @@ IsKnownTokens (
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AsciiStrCmp(Token, SEC_TOK) == 0 ||
|
if ((AsciiStrCmp (Token, SEC_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, PEI_TOK) == 0 ||
|
(AsciiStrCmp (Token, PEI_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, DXE_TOK) == 0 ||
|
(AsciiStrCmp (Token, DXE_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, BDS_TOK) == 0 ||
|
(AsciiStrCmp (Token, BDS_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, DRIVERBINDING_START_TOK) == 0 ||
|
(AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, DRIVERBINDING_SUPPORT_TOK) == 0 ||
|
(AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, DRIVERBINDING_STOP_TOK) == 0 ||
|
(AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, LOAD_IMAGE_TOK) == 0 ||
|
(AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, START_IMAGE_TOK) == 0 ||
|
(AsciiStrCmp (Token, START_IMAGE_TOK) == 0) ||
|
||||||
AsciiStrCmp(Token, PEIM_TOK) == 0) {
|
(AsciiStrCmp (Token, PEIM_TOK) == 0))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -188,16 +193,17 @@ IsKnownID (
|
|||||||
IN UINT32 Identifier
|
IN UINT32 Identifier
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (Identifier == MODULE_START_ID ||
|
if ((Identifier == MODULE_START_ID) ||
|
||||||
Identifier == MODULE_END_ID ||
|
(Identifier == MODULE_END_ID) ||
|
||||||
Identifier == MODULE_LOADIMAGE_START_ID ||
|
(Identifier == MODULE_LOADIMAGE_START_ID) ||
|
||||||
Identifier == MODULE_LOADIMAGE_END_ID ||
|
(Identifier == MODULE_LOADIMAGE_END_ID) ||
|
||||||
Identifier == MODULE_DB_START_ID ||
|
(Identifier == MODULE_DB_START_ID) ||
|
||||||
Identifier == MODULE_DB_END_ID ||
|
(Identifier == MODULE_DB_END_ID) ||
|
||||||
Identifier == MODULE_DB_SUPPORT_START_ID ||
|
(Identifier == MODULE_DB_SUPPORT_START_ID) ||
|
||||||
Identifier == MODULE_DB_SUPPORT_END_ID ||
|
(Identifier == MODULE_DB_SUPPORT_END_ID) ||
|
||||||
Identifier == MODULE_DB_STOP_START_ID ||
|
(Identifier == MODULE_DB_STOP_START_ID) ||
|
||||||
Identifier == MODULE_DB_STOP_END_ID) {
|
(Identifier == MODULE_DB_STOP_END_ID))
|
||||||
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -205,31 +211,33 @@ IsKnownID (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate buffer for Boot Performance table.
|
This internal function dumps all the SMM performance data and size.
|
||||||
|
|
||||||
@return Status code.
|
@param SmmPerfData Smm Performance data. The buffer contain the SMM perf data is allocated by this function and caller needs to free it.
|
||||||
|
@param SmmPerfDataSize Smm Performance data size.
|
||||||
|
@param SkipGetPerfData Skip to get performance data, just get the size.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
VOID
|
||||||
AllocateBootPerformanceTable (
|
InternalGetSmmPerfData (
|
||||||
|
OUT VOID **SmmPerfData,
|
||||||
|
OUT UINTN *SmmPerfDataSize,
|
||||||
|
IN BOOLEAN SkipGetPerfData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Size;
|
|
||||||
UINT8 *SmmBootRecordCommBuffer;
|
UINT8 *SmmBootRecordCommBuffer;
|
||||||
EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
|
EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
|
||||||
SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
|
SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
|
||||||
UINTN CommSize;
|
UINTN CommSize;
|
||||||
UINTN BootPerformanceDataSize;
|
|
||||||
UINT8 *BootPerformanceData;
|
|
||||||
EFI_SMM_COMMUNICATION_PROTOCOL *Communication;
|
EFI_SMM_COMMUNICATION_PROTOCOL *Communication;
|
||||||
FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
|
|
||||||
EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable;
|
EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable;
|
||||||
EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion;
|
EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
VOID *SmmBootRecordData;
|
VOID *SmmBootRecordData;
|
||||||
UINTN SmmBootRecordDataSize;
|
UINTN SmmBootRecordDataSize;
|
||||||
UINTN ReservedMemSize;
|
UINTN ReservedMemSize;
|
||||||
|
UINTN SmmBootRecordDataRetrieved;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Collect boot records from SMM drivers.
|
// Collect boot records from SMM drivers.
|
||||||
@ -237,7 +245,6 @@ AllocateBootPerformanceTable (
|
|||||||
SmmBootRecordCommBuffer = NULL;
|
SmmBootRecordCommBuffer = NULL;
|
||||||
SmmCommData = NULL;
|
SmmCommData = NULL;
|
||||||
SmmBootRecordData = NULL;
|
SmmBootRecordData = NULL;
|
||||||
SmmBootRecordDataSize = 0;
|
|
||||||
ReservedMemSize = 0;
|
ReservedMemSize = 0;
|
||||||
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&Communication);
|
Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&Communication);
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
@ -256,8 +263,10 @@ AllocateBootPerformanceTable (
|
|||||||
if (SmmCommMemRegion->Type == EfiConventionalMemory) {
|
if (SmmCommMemRegion->Type == EfiConventionalMemory) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)SmmCommMemRegion + SmmCommRegionTable->DescriptorSize);
|
SmmCommMemRegion = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)SmmCommMemRegion + SmmCommRegionTable->DescriptorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT (Index < SmmCommRegionTable->NumberOfEntries);
|
ASSERT (Index < SmmCommRegionTable->NumberOfEntries);
|
||||||
ASSERT (SmmCommMemRegion->PhysicalStart > 0);
|
ASSERT (SmmCommMemRegion->PhysicalStart > 0);
|
||||||
ASSERT (SmmCommMemRegion->NumberOfPages > 0);
|
ASSERT (SmmCommMemRegion->NumberOfPages > 0);
|
||||||
@ -283,41 +292,78 @@ AllocateBootPerformanceTable (
|
|||||||
SmmCommData->BootRecordData = NULL;
|
SmmCommData->BootRecordData = NULL;
|
||||||
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
|
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && !EFI_ERROR(SmmCommData->ReturnStatus) && SmmCommData->BootRecordSize != 0) {
|
if (!EFI_ERROR (Status) && !EFI_ERROR (SmmCommData->ReturnStatus) && (SmmCommData->BootRecordSize != 0)) {
|
||||||
|
if (SkipGetPerfData) {
|
||||||
|
*SmmPerfDataSize = SmmCommData->BootRecordSize;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get all boot records
|
// Get boot records starting from mSmmBootRecordOffset
|
||||||
//
|
//
|
||||||
SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;
|
SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET;
|
||||||
SmmBootRecordDataSize = SmmCommData->BootRecordSize;
|
SmmCommData->BootRecordOffset = mSmmBootRecordOffset;
|
||||||
|
SmmBootRecordDataSize = SmmCommData->BootRecordSize - mSmmBootRecordOffset;
|
||||||
SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize);
|
SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize);
|
||||||
|
SmmBootRecordDataRetrieved = 0;
|
||||||
ASSERT (SmmBootRecordData != NULL);
|
ASSERT (SmmBootRecordData != NULL);
|
||||||
SmmCommData->BootRecordOffset = 0;
|
|
||||||
SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
|
SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
|
||||||
SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;
|
SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;
|
||||||
while (SmmCommData->BootRecordOffset < SmmBootRecordDataSize) {
|
while (SmmBootRecordDataRetrieved < SmmBootRecordDataSize) {
|
||||||
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
|
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
ASSERT_EFI_ERROR (SmmCommData->ReturnStatus);
|
ASSERT_EFI_ERROR (SmmCommData->ReturnStatus);
|
||||||
if (SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
|
if (SmmBootRecordDataRetrieved + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
|
||||||
CopyMem((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset);
|
CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmBootRecordDataRetrieved);
|
||||||
} else {
|
} else {
|
||||||
CopyMem((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
|
CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
|
||||||
}
|
}
|
||||||
SmmCommData->BootRecordOffset = SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize;
|
|
||||||
|
SmmBootRecordDataRetrieved += SmmCommData->BootRecordSize;
|
||||||
|
SmmCommData->BootRecordOffset += SmmCommData->BootRecordSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
mSmmBootRecordOffset = SmmCommData->BootRecordOffset;
|
||||||
|
|
||||||
|
*SmmPerfData = SmmBootRecordData;
|
||||||
|
*SmmPerfDataSize = SmmBootRecordDataSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Allocate buffer for Boot Performance table.
|
||||||
|
|
||||||
|
@return Status code.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
AllocateBootPerformanceTable (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN Size;
|
||||||
|
UINTN BootPerformanceDataSize;
|
||||||
|
UINT8 *BootPerformanceData;
|
||||||
|
FIRMWARE_PERFORMANCE_VARIABLE PerformanceVariable;
|
||||||
|
UINTN SmmBootRecordDataSize;
|
||||||
|
|
||||||
|
SmmBootRecordDataSize = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get SMM performance data size at the point of EndOfDxe in order to allocate the boot performance table.
|
||||||
|
// Will Get all the data at ReadyToBoot.
|
||||||
|
//
|
||||||
|
InternalGetSmmPerfData (NULL, &SmmBootRecordDataSize, TRUE);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Prepare memory for Boot Performance table.
|
// Prepare memory for Boot Performance table.
|
||||||
// Boot Performance table includes BasicBoot record, and one or more appended Boot Records.
|
// Boot Performance table includes BasicBoot record, and one or more appended Boot Records.
|
||||||
//
|
//
|
||||||
BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE) + mPerformanceLength + PcdGet32 (PcdExtFpdtBootRecordPadSize);
|
BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE) + mPerformanceLength + SmmBootRecordDataSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);
|
||||||
if (SmmCommData != NULL && SmmBootRecordData != NULL) {
|
|
||||||
BootPerformanceDataSize += SmmBootRecordDataSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to allocate the same runtime buffer as last time boot.
|
// Try to allocate the same runtime buffer as last time boot.
|
||||||
@ -355,12 +401,10 @@ AllocateBootPerformanceTable (
|
|||||||
ZeroMem (mAcpiBootPerformanceTable, BootPerformanceDataSize);
|
ZeroMem (mAcpiBootPerformanceTable, BootPerformanceDataSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
|
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));
|
||||||
|
|
||||||
if (mAcpiBootPerformanceTable == NULL) {
|
if (mAcpiBootPerformanceTable == NULL) {
|
||||||
if (SmmCommData != NULL && SmmBootRecordData != NULL) {
|
|
||||||
FreePool(SmmBootRecordData);
|
|
||||||
}
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,19 +429,10 @@ AllocateBootPerformanceTable (
|
|||||||
mPerformanceLength = 0;
|
mPerformanceLength = 0;
|
||||||
mMaxPerformanceLength = 0;
|
mMaxPerformanceLength = 0;
|
||||||
}
|
}
|
||||||
if (SmmCommData != NULL && SmmBootRecordData != NULL) {
|
|
||||||
//
|
|
||||||
// Fill Boot records from SMM drivers.
|
|
||||||
//
|
|
||||||
CopyMem(BootPerformanceData, SmmBootRecordData, SmmBootRecordDataSize);
|
|
||||||
FreePool(SmmBootRecordData);
|
|
||||||
mAcpiBootPerformanceTable->Header.Length = (UINT32) (mAcpiBootPerformanceTable->Header.Length + SmmBootRecordDataSize);
|
|
||||||
BootPerformanceData = BootPerformanceData + SmmBootRecordDataSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBootRecordBuffer = (UINT8 *)mAcpiBootPerformanceTable;
|
mBootRecordBuffer = (UINT8 *)mAcpiBootPerformanceTable;
|
||||||
mBootRecordSize = mAcpiBootPerformanceTable->Header.Length;
|
mBootRecordSize = mAcpiBootPerformanceTable->Header.Length;
|
||||||
mBootRecordMaxSize = mBootRecordSize + PcdGet32 (PcdExtFpdtBootRecordPadSize);
|
mBootRecordMaxSize = BootPerformanceDataSize;
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -438,9 +473,10 @@ GetModuleInfoFromHandle (
|
|||||||
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
|
EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
|
||||||
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
|
||||||
|
|
||||||
if (NameString == NULL || BufferSize == 0) {
|
if ((NameString == NULL) || (BufferSize == 0)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to get the ModuleGuid and name string form the caached array.
|
// Try to get the ModuleGuid and name string form the caached array.
|
||||||
//
|
//
|
||||||
@ -502,14 +538,15 @@ GetModuleInfoFromHandle (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EFI_ERROR(Status) && LoadedImage != NULL) {
|
if (!EFI_ERROR (Status) && (LoadedImage != NULL)) {
|
||||||
//
|
//
|
||||||
// Get Module Guid from DevicePath.
|
// Get Module Guid from DevicePath.
|
||||||
//
|
//
|
||||||
if (LoadedImage->FilePath != NULL &&
|
if ((LoadedImage->FilePath != NULL) &&
|
||||||
LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&
|
(LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
|
||||||
LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP
|
(LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP)
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Determine GUID associated with module logging performance
|
// Determine GUID associated with module logging performance
|
||||||
//
|
//
|
||||||
@ -522,20 +559,21 @@ GetModuleInfoFromHandle (
|
|||||||
// Method 1 Get Module Name from PDB string.
|
// Method 1 Get Module Name from PDB string.
|
||||||
//
|
//
|
||||||
PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
|
PdbFileName = PeCoffLoaderGetPdbPointer (LoadedImage->ImageBase);
|
||||||
if (PdbFileName != NULL && BufferSize > 0) {
|
if ((PdbFileName != NULL) && (BufferSize > 0)) {
|
||||||
StartIndex = 0;
|
StartIndex = 0;
|
||||||
for (Index = 0; PdbFileName[Index] != 0; Index++) {
|
for (Index = 0; PdbFileName[Index] != 0; Index++) {
|
||||||
if ((PdbFileName[Index] == '\\') || (PdbFileName[Index] == '/')) {
|
if ((PdbFileName[Index] == '\\') || (PdbFileName[Index] == '/')) {
|
||||||
StartIndex = Index + 1;
|
StartIndex = Index + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Copy the PDB file name to our temporary string.
|
// Copy the PDB file name to our temporary string.
|
||||||
// If the length is bigger than BufferSize, trim the redudant characters to avoid overflow in array boundary.
|
// If the length is bigger than BufferSize, trim the redudant characters to avoid overflow in array boundary.
|
||||||
//
|
//
|
||||||
for (Index = 0; Index < BufferSize - 1; Index++) {
|
for (Index = 0; Index < BufferSize - 1; Index++) {
|
||||||
NameString[Index] = PdbFileName[Index + StartIndex];
|
NameString[Index] = PdbFileName[Index + StartIndex];
|
||||||
if (NameString[Index] == 0 || NameString[Index] == '.') {
|
if ((NameString[Index] == 0) || (NameString[Index] == '.')) {
|
||||||
NameString[Index] = 0;
|
NameString[Index] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -544,6 +582,7 @@ GetModuleInfoFromHandle (
|
|||||||
if (Index == BufferSize - 1) {
|
if (Index == BufferSize - 1) {
|
||||||
NameString[Index] = 0;
|
NameString[Index] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Module Name is got.
|
// Module Name is got.
|
||||||
//
|
//
|
||||||
@ -566,6 +605,7 @@ GetModuleInfoFromHandle (
|
|||||||
if (mPlatformLanguage == NULL) {
|
if (mPlatformLanguage == NULL) {
|
||||||
GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&mPlatformLanguage, NULL);
|
GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&mPlatformLanguage, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPlatformLanguage != NULL) {
|
if (mPlatformLanguage != NULL) {
|
||||||
Status = ComponentName2->GetDriverName (
|
Status = ComponentName2->GetDriverName (
|
||||||
ComponentName2,
|
ComponentName2,
|
||||||
@ -576,6 +616,7 @@ GetModuleInfoFromHandle (
|
|||||||
for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
|
for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
|
||||||
NameString[Index] = (CHAR8)StringPtr[Index];
|
NameString[Index] = (CHAR8)StringPtr[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
NameString[Index] = 0;
|
NameString[Index] = 0;
|
||||||
//
|
//
|
||||||
// Module Name is got.
|
// Module Name is got.
|
||||||
@ -606,6 +647,7 @@ GetModuleInfoFromHandle (
|
|||||||
for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
|
for (Index = 0; Index < BufferSize - 1 && StringPtr[Index] != 0; Index++) {
|
||||||
NameString[Index] = (CHAR8)StringPtr[Index];
|
NameString[Index] = (CHAR8)StringPtr[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
NameString[Index] = 0;
|
NameString[Index] = 0;
|
||||||
FreePool (StringPtr);
|
FreePool (StringPtr);
|
||||||
}
|
}
|
||||||
@ -662,58 +704,68 @@ GetFpdtRecordId (
|
|||||||
// Token to PerfId.
|
// Token to PerfId.
|
||||||
//
|
//
|
||||||
if (String != NULL) {
|
if (String != NULL) {
|
||||||
if (AsciiStrCmp(String, START_IMAGE_TOK) == 0) { // "StartImage:"
|
if (AsciiStrCmp (String, START_IMAGE_TOK) == 0) {
|
||||||
|
// "StartImage:"
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = MODULE_START_ID;
|
*ProgressID = MODULE_START_ID;
|
||||||
} else {
|
} else {
|
||||||
*ProgressID = MODULE_END_ID;
|
*ProgressID = MODULE_END_ID;
|
||||||
}
|
}
|
||||||
} else if (AsciiStrCmp(String, LOAD_IMAGE_TOK) == 0) { // "LoadImage:"
|
} else if (AsciiStrCmp (String, LOAD_IMAGE_TOK) == 0) {
|
||||||
|
// "LoadImage:"
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = MODULE_LOADIMAGE_START_ID;
|
*ProgressID = MODULE_LOADIMAGE_START_ID;
|
||||||
} else {
|
} else {
|
||||||
*ProgressID = MODULE_LOADIMAGE_END_ID;
|
*ProgressID = MODULE_LOADIMAGE_END_ID;
|
||||||
}
|
}
|
||||||
} else if (AsciiStrCmp(String, DRIVERBINDING_START_TOK) == 0) { // "DB:Start:"
|
} else if (AsciiStrCmp (String, DRIVERBINDING_START_TOK) == 0) {
|
||||||
|
// "DB:Start:"
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = MODULE_DB_START_ID;
|
*ProgressID = MODULE_DB_START_ID;
|
||||||
} else {
|
} else {
|
||||||
*ProgressID = MODULE_DB_END_ID;
|
*ProgressID = MODULE_DB_END_ID;
|
||||||
}
|
}
|
||||||
} else if (AsciiStrCmp(String, DRIVERBINDING_SUPPORT_TOK) == 0) { // "DB:Support:"
|
} else if (AsciiStrCmp (String, DRIVERBINDING_SUPPORT_TOK) == 0) {
|
||||||
|
// "DB:Support:"
|
||||||
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = MODULE_DB_SUPPORT_START_ID;
|
*ProgressID = MODULE_DB_SUPPORT_START_ID;
|
||||||
} else {
|
} else {
|
||||||
*ProgressID = MODULE_DB_SUPPORT_END_ID;
|
*ProgressID = MODULE_DB_SUPPORT_END_ID;
|
||||||
}
|
}
|
||||||
} else if (AsciiStrCmp(String, DRIVERBINDING_STOP_TOK) == 0) { // "DB:Stop:"
|
} else if (AsciiStrCmp (String, DRIVERBINDING_STOP_TOK) == 0) {
|
||||||
|
// "DB:Stop:"
|
||||||
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
return RETURN_UNSUPPORTED;
|
return RETURN_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = MODULE_DB_STOP_START_ID;
|
*ProgressID = MODULE_DB_STOP_START_ID;
|
||||||
} else {
|
} else {
|
||||||
*ProgressID = MODULE_DB_STOP_END_ID;
|
*ProgressID = MODULE_DB_STOP_END_ID;
|
||||||
}
|
}
|
||||||
} else if (AsciiStrCmp(String, PEI_TOK) == 0 || // "PEI"
|
} else if ((AsciiStrCmp (String, PEI_TOK) == 0) || // "PEI"
|
||||||
AsciiStrCmp(String, DXE_TOK) == 0 || // "DXE"
|
(AsciiStrCmp (String, DXE_TOK) == 0) || // "DXE"
|
||||||
AsciiStrCmp(String, BDS_TOK) == 0) { // "BDS"
|
(AsciiStrCmp (String, BDS_TOK) == 0)) // "BDS"
|
||||||
|
{
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = PERF_CROSSMODULE_START_ID;
|
*ProgressID = PERF_CROSSMODULE_START_ID;
|
||||||
} else {
|
} else {
|
||||||
*ProgressID = PERF_CROSSMODULE_END_ID;
|
*ProgressID = PERF_CROSSMODULE_END_ID;
|
||||||
}
|
}
|
||||||
} else { // Pref used in Modules.
|
} else {
|
||||||
|
// Pref used in Modules.
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = PERF_INMODULE_START_ID;
|
*ProgressID = PERF_INMODULE_START_ID;
|
||||||
} else {
|
} else {
|
||||||
*ProgressID = PERF_INMODULE_END_ID;
|
*ProgressID = PERF_INMODULE_END_ID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (Handle!= NULL) { // Pref used in Modules.
|
} else if (Handle != NULL) {
|
||||||
|
// Pref used in Modules.
|
||||||
if (Attribute == PerfStartEntry) {
|
if (Attribute == PerfStartEntry) {
|
||||||
*ProgressID = PERF_INMODULE_START_ID;
|
*ProgressID = PERF_INMODULE_START_ID;
|
||||||
} else {
|
} else {
|
||||||
@ -722,6 +774,7 @@ GetFpdtRecordId (
|
|||||||
} else {
|
} else {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,6 +807,7 @@ CopyStringIntoPerfRecordAndUpdateLength (
|
|||||||
DestMax = STRING_SIZE;
|
DestMax = STRING_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringLen = AsciiStrLen (Source);
|
StringLen = AsciiStrLen (Source);
|
||||||
if (StringLen >= DestMax) {
|
if (StringLen >= DestMax) {
|
||||||
StringLen = DestMax -1;
|
StringLen = DestMax -1;
|
||||||
@ -837,7 +891,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
|
|||||||
ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) - 1;
|
ControllerNameStringSize = FPDT_MAX_PERF_RECORD_SIZE - (*Length) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnicodeStrToAsciiStrS(StringPtr, ComponentNameString, ControllerNameStringSize);
|
UnicodeStrnToAsciiStrS (StringPtr, ControllerNameStringSize - 1, ComponentNameString, ControllerNameStringSize, &ControllerNameStringSize);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add a space in the end of the ControllerName
|
// Add a space in the end of the ControllerName
|
||||||
@ -879,7 +933,7 @@ GetDeviceInfoFromHandleAndUpdateLength (
|
|||||||
AsciiStringPtr = ComponentNameString;
|
AsciiStringPtr = ComponentNameString;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnicodeStrToAsciiStrS(StringPtr, AsciiStringPtr, DevicePathStringSize);
|
UnicodeStrnToAsciiStrS (StringPtr, DevicePathStringSize - 1, AsciiStringPtr, DevicePathStringSize, &DevicePathStringSize);
|
||||||
*Length += (UINT8)DevicePathStringSize;
|
*Length += (UINT8)DevicePathStringSize;
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -914,11 +968,11 @@ GetDeviceInfoFromHandleAndUpdateLength (
|
|||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
InsertFpdtRecord (
|
InsertFpdtRecord (
|
||||||
IN CONST VOID *CallerIdentifier, OPTIONAL
|
IN CONST VOID *CallerIdentifier OPTIONAL,
|
||||||
IN CONST VOID *Guid, OPTIONAL
|
IN CONST VOID *Guid OPTIONAL,
|
||||||
IN CONST CHAR8 *String, OPTIONAL
|
IN CONST CHAR8 *String OPTIONAL,
|
||||||
IN UINT64 Ticker,
|
IN UINT64 Ticker,
|
||||||
IN UINT64 Address, OPTIONAL
|
IN UINT64 Address OPTIONAL,
|
||||||
IN UINT16 PerfId,
|
IN UINT16 PerfId,
|
||||||
IN PERF_MEASUREMENT_ATTRIBUTE Attribute
|
IN PERF_MEASUREMENT_ATTRIBUTE Attribute
|
||||||
)
|
)
|
||||||
@ -968,6 +1022,7 @@ InsertFpdtRecord (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
PerfId = ProgressId;
|
PerfId = ProgressId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -998,18 +1053,19 @@ InsertFpdtRecord (
|
|||||||
switch (PerfId) {
|
switch (PerfId) {
|
||||||
case MODULE_START_ID:
|
case MODULE_START_ID:
|
||||||
case MODULE_END_ID:
|
case MODULE_END_ID:
|
||||||
GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
||||||
StringPtr = ModuleName;
|
StringPtr = ModuleName;
|
||||||
//
|
//
|
||||||
// Cache the offset of start image start record and use to update the start image end record if needed.
|
// Cache the offset of start image start record and use to update the start image end record if needed.
|
||||||
//
|
//
|
||||||
if (Attribute == PerfEntry && PerfId == MODULE_START_ID) {
|
if ((Attribute == PerfEntry) && (PerfId == MODULE_START_ID)) {
|
||||||
if (mFpdtBufferIsReported) {
|
if (mFpdtBufferIsReported) {
|
||||||
mCachedLength = mBootRecordSize;
|
mCachedLength = mBootRecordSize;
|
||||||
} else {
|
} else {
|
||||||
mCachedLength = mPerformanceLength;
|
mCachedLength = mPerformanceLength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
|
FpdtRecordPtr.GuidEvent->Header.Type = FPDT_GUID_EVENT_TYPE;
|
||||||
FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
|
FpdtRecordPtr.GuidEvent->Header.Length = sizeof (FPDT_GUID_EVENT_RECORD);
|
||||||
@ -1017,28 +1073,30 @@ InsertFpdtRecord (
|
|||||||
FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
|
FpdtRecordPtr.GuidEvent->ProgressID = PerfId;
|
||||||
FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
|
FpdtRecordPtr.GuidEvent->Timestamp = TimeStamp;
|
||||||
CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
|
CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
|
||||||
if (CallerIdentifier == NULL && PerfId == MODULE_END_ID && mCachedLength != 0) {
|
if ((CallerIdentifier == NULL) && (PerfId == MODULE_END_ID) && (mCachedLength != 0)) {
|
||||||
if (mFpdtBufferIsReported) {
|
if (mFpdtBufferIsReported) {
|
||||||
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
|
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
|
||||||
} else {
|
} else {
|
||||||
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
|
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.GuidEvent->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
|
CopyMem (&FpdtRecordPtr.GuidEvent->Guid, &CachedFpdtRecordPtr.GuidEvent->Guid, sizeof (FpdtRecordPtr.GuidEvent->Guid));
|
||||||
mCachedLength = 0;
|
mCachedLength = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODULE_LOADIMAGE_START_ID:
|
case MODULE_LOADIMAGE_START_ID:
|
||||||
case MODULE_LOADIMAGE_END_ID:
|
case MODULE_LOADIMAGE_END_ID:
|
||||||
GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
||||||
StringPtr = ModuleName;
|
StringPtr = ModuleName;
|
||||||
if (PerfId == MODULE_LOADIMAGE_START_ID) {
|
if (PerfId == MODULE_LOADIMAGE_START_ID) {
|
||||||
mLoadImageCount++;
|
mLoadImageCount++;
|
||||||
//
|
//
|
||||||
// Cache the offset of load image start record and use to be updated by the load image end record if needed.
|
// Cache the offset of load image start record and use to be updated by the load image end record if needed.
|
||||||
//
|
//
|
||||||
if (CallerIdentifier == NULL && Attribute == PerfEntry) {
|
if ((CallerIdentifier == NULL) && (Attribute == PerfEntry)) {
|
||||||
if (mFpdtBufferIsReported) {
|
if (mFpdtBufferIsReported) {
|
||||||
mCachedLength = mBootRecordSize;
|
mCachedLength = mBootRecordSize;
|
||||||
} else {
|
} else {
|
||||||
@ -1046,6 +1104,7 @@ InsertFpdtRecord (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
|
FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
|
||||||
FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
|
FpdtRecordPtr.GuidQwordEvent->Header.Length = sizeof (FPDT_GUID_QWORD_EVENT_RECORD);
|
||||||
@ -1054,16 +1113,18 @@ InsertFpdtRecord (
|
|||||||
FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
|
FpdtRecordPtr.GuidQwordEvent->Timestamp = TimeStamp;
|
||||||
FpdtRecordPtr.GuidQwordEvent->Qword = mLoadImageCount;
|
FpdtRecordPtr.GuidQwordEvent->Qword = mLoadImageCount;
|
||||||
CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
|
CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
|
||||||
if (PerfId == MODULE_LOADIMAGE_END_ID && mCachedLength != 0) {
|
if ((PerfId == MODULE_LOADIMAGE_END_ID) && (mCachedLength != 0)) {
|
||||||
if (mFpdtBufferIsReported) {
|
if (mFpdtBufferIsReported) {
|
||||||
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
|
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
|
||||||
} else {
|
} else {
|
||||||
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
|
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid));
|
CopyMem (&CachedFpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.GuidQwordEvent->Guid));
|
||||||
mCachedLength = 0;
|
mCachedLength = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODULE_DB_START_ID:
|
case MODULE_DB_START_ID:
|
||||||
@ -1071,7 +1132,7 @@ InsertFpdtRecord (
|
|||||||
case MODULE_DB_SUPPORT_END_ID:
|
case MODULE_DB_SUPPORT_END_ID:
|
||||||
case MODULE_DB_STOP_START_ID:
|
case MODULE_DB_STOP_START_ID:
|
||||||
case MODULE_DB_STOP_END_ID:
|
case MODULE_DB_STOP_END_ID:
|
||||||
GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
||||||
StringPtr = ModuleName;
|
StringPtr = ModuleName;
|
||||||
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
|
FpdtRecordPtr.GuidQwordEvent->Header.Type = FPDT_GUID_QWORD_EVENT_TYPE;
|
||||||
@ -1082,14 +1143,15 @@ InsertFpdtRecord (
|
|||||||
FpdtRecordPtr.GuidQwordEvent->Qword = Address;
|
FpdtRecordPtr.GuidQwordEvent->Qword = Address;
|
||||||
CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
|
CopyMem (&FpdtRecordPtr.GuidQwordEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.GuidQwordEvent->Guid));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODULE_DB_END_ID:
|
case MODULE_DB_END_ID:
|
||||||
GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
||||||
StringPtr = ModuleName;
|
StringPtr = ModuleName;
|
||||||
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
FpdtRecordPtr.GuidQwordStringEvent->Header.Type = FPDT_GUID_QWORD_STRING_EVENT_TYPE;
|
FpdtRecordPtr.GuidQwordStringEvent->Header.Type = FPDT_GUID_QWORD_STRING_EVENT_TYPE;
|
||||||
FpdtRecordPtr.GuidQwordStringEvent->Header.Length = sizeof (FPDT_GUID_QWORD_STRING_EVENT_RECORD);;
|
FpdtRecordPtr.GuidQwordStringEvent->Header.Length = sizeof (FPDT_GUID_QWORD_STRING_EVENT_RECORD);
|
||||||
FpdtRecordPtr.GuidQwordStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
|
FpdtRecordPtr.GuidQwordStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
|
||||||
FpdtRecordPtr.GuidQwordStringEvent->ProgressID = PerfId;
|
FpdtRecordPtr.GuidQwordStringEvent->ProgressID = PerfId;
|
||||||
FpdtRecordPtr.GuidQwordStringEvent->Timestamp = TimeStamp;
|
FpdtRecordPtr.GuidQwordStringEvent->Timestamp = TimeStamp;
|
||||||
@ -1099,19 +1161,22 @@ InsertFpdtRecord (
|
|||||||
GetDeviceInfoFromHandleAndUpdateLength (CallerIdentifier, (EFI_HANDLE)(UINTN)Address, FpdtRecordPtr.GuidQwordStringEvent->String, &FpdtRecordPtr.GuidQwordStringEvent->Header.Length);
|
GetDeviceInfoFromHandleAndUpdateLength (CallerIdentifier, (EFI_HANDLE)(UINTN)Address, FpdtRecordPtr.GuidQwordStringEvent->String, &FpdtRecordPtr.GuidQwordStringEvent->Header.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_EVENTSIGNAL_START_ID:
|
case PERF_EVENTSIGNAL_START_ID:
|
||||||
case PERF_EVENTSIGNAL_END_ID:
|
case PERF_EVENTSIGNAL_END_ID:
|
||||||
case PERF_CALLBACK_START_ID:
|
case PERF_CALLBACK_START_ID:
|
||||||
case PERF_CALLBACK_END_ID:
|
case PERF_CALLBACK_END_ID:
|
||||||
if (String == NULL || Guid == NULL) {
|
if ((String == NULL) || (Guid == NULL)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringPtr = String;
|
StringPtr = String;
|
||||||
if (AsciiStrLen (String) == 0) {
|
if (AsciiStrLen (String) == 0) {
|
||||||
StringPtr = "unknown name";
|
StringPtr = "unknown name";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
|
FpdtRecordPtr.DualGuidStringEvent->Header.Type = FPDT_DUAL_GUID_STRING_EVENT_TYPE;
|
||||||
FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
|
FpdtRecordPtr.DualGuidStringEvent->Header.Length = sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD);
|
||||||
@ -1122,6 +1187,7 @@ InsertFpdtRecord (
|
|||||||
CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
|
CopyMem (&FpdtRecordPtr.DualGuidStringEvent->Guid2, Guid, sizeof (FpdtRecordPtr.DualGuidStringEvent->Guid2));
|
||||||
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
|
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DualGuidStringEvent->String, StringPtr, &FpdtRecordPtr.DualGuidStringEvent->Header.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PERF_EVENT_ID:
|
case PERF_EVENT_ID:
|
||||||
@ -1131,15 +1197,17 @@ InsertFpdtRecord (
|
|||||||
case PERF_INMODULE_END_ID:
|
case PERF_INMODULE_END_ID:
|
||||||
case PERF_CROSSMODULE_START_ID:
|
case PERF_CROSSMODULE_START_ID:
|
||||||
case PERF_CROSSMODULE_END_ID:
|
case PERF_CROSSMODULE_END_ID:
|
||||||
GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
||||||
if (String != NULL) {
|
if (String != NULL) {
|
||||||
StringPtr = String;
|
StringPtr = String;
|
||||||
} else {
|
} else {
|
||||||
StringPtr = ModuleName;
|
StringPtr = ModuleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AsciiStrLen (StringPtr) == 0) {
|
if (AsciiStrLen (StringPtr) == 0) {
|
||||||
StringPtr = "unknown name";
|
StringPtr = "unknown name";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
|
FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
||||||
@ -1149,19 +1217,22 @@ InsertFpdtRecord (
|
|||||||
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
|
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
|
||||||
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
|
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (Attribute != PerfEntry) {
|
if (Attribute != PerfEntry) {
|
||||||
GetModuleInfoFromHandle ((EFI_HANDLE *)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
GetModuleInfoFromHandle ((EFI_HANDLE)CallerIdentifier, ModuleName, sizeof (ModuleName), &ModuleGuid);
|
||||||
if (String != NULL) {
|
if (String != NULL) {
|
||||||
StringPtr = String;
|
StringPtr = String;
|
||||||
} else {
|
} else {
|
||||||
StringPtr = ModuleName;
|
StringPtr = ModuleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AsciiStrLen (StringPtr) == 0) {
|
if (AsciiStrLen (StringPtr) == 0) {
|
||||||
StringPtr = "unknown name";
|
StringPtr = "unknown name";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (!PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
|
FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
||||||
@ -1174,6 +1245,7 @@ InsertFpdtRecord (
|
|||||||
} else {
|
} else {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1181,9 +1253,10 @@ InsertFpdtRecord (
|
|||||||
// 4.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.
|
// 4.2 When PcdEdkiiFpdtStringRecordEnableOnly==TRUE, create string record for all Perf entries.
|
||||||
//
|
//
|
||||||
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
if (PcdGetBool (PcdEdkiiFpdtStringRecordEnableOnly)) {
|
||||||
if (StringPtr == NULL ||PerfId == MODULE_DB_SUPPORT_START_ID || PerfId == MODULE_DB_SUPPORT_END_ID) {
|
if ((StringPtr == NULL) || (PerfId == MODULE_DB_SUPPORT_START_ID) || (PerfId == MODULE_DB_SUPPORT_END_ID)) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
|
FpdtRecordPtr.DynamicStringEvent->Header.Type = FPDT_DYNAMIC_STRING_EVENT_TYPE;
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
FpdtRecordPtr.DynamicStringEvent->Header.Length = sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
|
FpdtRecordPtr.DynamicStringEvent->Header.Revision = FPDT_RECORD_REVISION_1;
|
||||||
@ -1197,26 +1270,31 @@ InsertFpdtRecord (
|
|||||||
} else {
|
} else {
|
||||||
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
|
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (FpdtRecordPtr.DynamicStringEvent->Guid));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AsciiStrLen (StringPtr) == 0) {
|
if (AsciiStrLen (StringPtr) == 0) {
|
||||||
StringPtr = "unknown name";
|
StringPtr = "unknown name";
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
|
CopyStringIntoPerfRecordAndUpdateLength (FpdtRecordPtr.DynamicStringEvent->String, StringPtr, &FpdtRecordPtr.DynamicStringEvent->Header.Length);
|
||||||
|
|
||||||
if ((PerfId == MODULE_LOADIMAGE_START_ID) || (PerfId == MODULE_END_ID)) {
|
if ((PerfId == MODULE_LOADIMAGE_START_ID) || (PerfId == MODULE_END_ID)) {
|
||||||
FpdtRecordPtr.DynamicStringEvent->Header.Length = (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)+ STRING_SIZE);
|
FpdtRecordPtr.DynamicStringEvent->Header.Length = (UINT8)(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD)+ STRING_SIZE);
|
||||||
}
|
}
|
||||||
if ((PerfId == MODULE_LOADIMAGE_END_ID || PerfId == MODULE_END_ID) && mCachedLength != 0) {
|
|
||||||
|
if (((PerfId == MODULE_LOADIMAGE_END_ID) || (PerfId == MODULE_END_ID)) && (mCachedLength != 0)) {
|
||||||
if (mFpdtBufferIsReported) {
|
if (mFpdtBufferIsReported) {
|
||||||
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
|
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mBootRecordBuffer + mCachedLength);
|
||||||
} else {
|
} else {
|
||||||
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
|
CachedFpdtRecordPtr.RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *)(mPerformancePointer + mCachedLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PerfId == MODULE_LOADIMAGE_END_ID) {
|
if (PerfId == MODULE_LOADIMAGE_END_ID) {
|
||||||
DestMax = CachedFpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
DestMax = CachedFpdtRecordPtr.DynamicStringEvent->Header.Length - sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD);
|
||||||
StringLen = AsciiStrLen (StringPtr);
|
StringLen = AsciiStrLen (StringPtr);
|
||||||
if (StringLen >= DestMax) {
|
if (StringLen >= DestMax) {
|
||||||
StringLen = DestMax -1;
|
StringLen = DestMax -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
|
CopyMem (&CachedFpdtRecordPtr.DynamicStringEvent->Guid, &ModuleGuid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
|
||||||
AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->String, DestMax, StringPtr, StringLen);
|
AsciiStrnCpyS (CachedFpdtRecordPtr.DynamicStringEvent->String, DestMax, StringPtr, StringLen);
|
||||||
} else if (PerfId == MODULE_END_ID) {
|
} else if (PerfId == MODULE_END_ID) {
|
||||||
@ -1225,9 +1303,11 @@ InsertFpdtRecord (
|
|||||||
if (StringLen >= DestMax) {
|
if (StringLen >= DestMax) {
|
||||||
StringLen = DestMax -1;
|
StringLen = DestMax -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &CachedFpdtRecordPtr.DynamicStringEvent->Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
|
CopyMem (&FpdtRecordPtr.DynamicStringEvent->Guid, &CachedFpdtRecordPtr.DynamicStringEvent->Guid, sizeof (CachedFpdtRecordPtr.DynamicStringEvent->Guid));
|
||||||
AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, CachedFpdtRecordPtr.DynamicStringEvent->String, StringLen);
|
AsciiStrnCpyS (FpdtRecordPtr.DynamicStringEvent->String, DestMax, CachedFpdtRecordPtr.DynamicStringEvent->String, StringLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
mCachedLength = 0;
|
mCachedLength = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1241,6 +1321,7 @@ InsertFpdtRecord (
|
|||||||
} else {
|
} else {
|
||||||
mPerformanceLength += FpdtRecordPtr.RecordHeader->Length;
|
mPerformanceLength += FpdtRecordPtr.RecordHeader->Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1329,6 +1410,7 @@ ReportFpdtRecordBuffer (
|
|||||||
sizeof (UINT64)
|
sizeof (UINT64)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set FPDT report state to TRUE.
|
// Set FPDT report state to TRUE.
|
||||||
//
|
//
|
||||||
@ -1336,6 +1418,50 @@ ReportFpdtRecordBuffer (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Update Boot Performance table.
|
||||||
|
|
||||||
|
@param Event The event of notify protocol.
|
||||||
|
@param Context Notify event context.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
UpdateBootPerformanceTable (
|
||||||
|
IN EFI_EVENT Event,
|
||||||
|
IN VOID *Context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
VOID *SmmBootRecordData;
|
||||||
|
UINTN SmmBootRecordDataSize;
|
||||||
|
UINTN AppendSize;
|
||||||
|
UINT8 *FirmwarePerformanceTablePtr;
|
||||||
|
|
||||||
|
SmmBootRecordDataSize = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get SMM performance data.
|
||||||
|
//
|
||||||
|
SmmBootRecordData = NULL;
|
||||||
|
InternalGetSmmPerfData (&SmmBootRecordData, &SmmBootRecordDataSize, FALSE);
|
||||||
|
|
||||||
|
FirmwarePerformanceTablePtr = (UINT8 *)mAcpiBootPerformanceTable + mAcpiBootPerformanceTable->Header.Length;
|
||||||
|
|
||||||
|
if (mAcpiBootPerformanceTable->Header.Length + SmmBootRecordDataSize > mBootRecordMaxSize) {
|
||||||
|
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save all SMM boot performance data\n"));
|
||||||
|
AppendSize = mBootRecordMaxSize - mAcpiBootPerformanceTable->Header.Length;
|
||||||
|
} else {
|
||||||
|
AppendSize = SmmBootRecordDataSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SmmBootRecordData != NULL) {
|
||||||
|
CopyMem (FirmwarePerformanceTablePtr, SmmBootRecordData, AppendSize);
|
||||||
|
mAcpiBootPerformanceTable->Header.Length += (UINT32)AppendSize;
|
||||||
|
mBootRecordSize += (UINT32)AppendSize;
|
||||||
|
FreePool (SmmBootRecordData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The constructor function initializes Performance infrastructure for DXE phase.
|
The constructor function initializes Performance infrastructure for DXE phase.
|
||||||
|
|
||||||
@ -1358,6 +1484,7 @@ DxeCorePerformanceLibConstructor (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_HANDLE Handle;
|
EFI_HANDLE Handle;
|
||||||
|
EFI_EVENT EndOfDxeEvent;
|
||||||
EFI_EVENT ReadyToBootEvent;
|
EFI_EVENT ReadyToBootEvent;
|
||||||
PERFORMANCE_PROPERTY *PerformanceProperty;
|
PERFORMANCE_PROPERTY *PerformanceProperty;
|
||||||
|
|
||||||
@ -1386,12 +1513,24 @@ DxeCorePerformanceLibConstructor (
|
|||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register ReadyToBoot event to report StatusCode data
|
// Register EndOfDxe event to allocate the boot performance table and report the table address through status code.
|
||||||
|
//
|
||||||
|
Status = gBS->CreateEventEx (
|
||||||
|
EVT_NOTIFY_SIGNAL,
|
||||||
|
TPL_NOTIFY,
|
||||||
|
ReportFpdtRecordBuffer,
|
||||||
|
NULL,
|
||||||
|
&gEfiEndOfDxeEventGroupGuid,
|
||||||
|
&EndOfDxeEvent
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register ReadyToBoot event to update the boot performance table for SMM performance data.
|
||||||
//
|
//
|
||||||
Status = gBS->CreateEventEx (
|
Status = gBS->CreateEventEx (
|
||||||
EVT_NOTIFY_SIGNAL,
|
EVT_NOTIFY_SIGNAL,
|
||||||
TPL_CALLBACK,
|
TPL_CALLBACK,
|
||||||
ReportFpdtRecordBuffer,
|
UpdateBootPerformanceTable,
|
||||||
NULL,
|
NULL,
|
||||||
&gEfiEventReadyToBootGuid,
|
&gEfiEventReadyToBootGuid,
|
||||||
&ReadyToBootEvent
|
&ReadyToBootEvent
|
||||||
@ -1439,10 +1578,10 @@ EFI_STATUS
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
CreatePerformanceMeasurement (
|
CreatePerformanceMeasurement (
|
||||||
IN CONST VOID *CallerIdentifier,
|
IN CONST VOID *CallerIdentifier,
|
||||||
IN CONST VOID *Guid, OPTIONAL
|
IN CONST VOID *Guid OPTIONAL,
|
||||||
IN CONST CHAR8 *String, OPTIONAL
|
IN CONST CHAR8 *String OPTIONAL,
|
||||||
IN UINT64 TimeStamp,
|
IN UINT64 TimeStamp,
|
||||||
IN UINT64 Address, OPTIONAL
|
IN UINT64 Address OPTIONAL,
|
||||||
IN UINT32 Identifier,
|
IN UINT32 Identifier,
|
||||||
IN PERF_MEASUREMENT_ATTRIBUTE Attribute
|
IN PERF_MEASUREMENT_ATTRIBUTE Attribute
|
||||||
)
|
)
|
||||||
@ -1454,6 +1593,7 @@ CreatePerformanceMeasurement (
|
|||||||
if (mLockInsertRecord) {
|
if (mLockInsertRecord) {
|
||||||
return EFI_INVALID_PARAMETER;
|
return EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
mLockInsertRecord = TRUE;
|
mLockInsertRecord = TRUE;
|
||||||
|
|
||||||
Status = InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute);
|
Status = InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute);
|
||||||
@ -1491,9 +1631,9 @@ CreatePerformanceMeasurement (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
StartPerformanceMeasurementEx (
|
StartPerformanceMeasurementEx (
|
||||||
IN CONST VOID *Handle, OPTIONAL
|
IN CONST VOID *Handle OPTIONAL,
|
||||||
IN CONST CHAR8 *Token, OPTIONAL
|
IN CONST CHAR8 *Token OPTIONAL,
|
||||||
IN CONST CHAR8 *Module, OPTIONAL
|
IN CONST CHAR8 *Module OPTIONAL,
|
||||||
IN UINT64 TimeStamp,
|
IN UINT64 TimeStamp,
|
||||||
IN UINT32 Identifier
|
IN UINT32 Identifier
|
||||||
)
|
)
|
||||||
@ -1540,9 +1680,9 @@ StartPerformanceMeasurementEx (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
EndPerformanceMeasurementEx (
|
EndPerformanceMeasurementEx (
|
||||||
IN CONST VOID *Handle, OPTIONAL
|
IN CONST VOID *Handle OPTIONAL,
|
||||||
IN CONST CHAR8 *Token, OPTIONAL
|
IN CONST CHAR8 *Token OPTIONAL,
|
||||||
IN CONST CHAR8 *Module, OPTIONAL
|
IN CONST CHAR8 *Module OPTIONAL,
|
||||||
IN UINT64 TimeStamp,
|
IN UINT64 TimeStamp,
|
||||||
IN UINT32 Identifier
|
IN UINT32 Identifier
|
||||||
)
|
)
|
||||||
@ -1645,9 +1785,9 @@ GetPerformanceMeasurementEx (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
StartPerformanceMeasurement (
|
StartPerformanceMeasurement (
|
||||||
IN CONST VOID *Handle, OPTIONAL
|
IN CONST VOID *Handle OPTIONAL,
|
||||||
IN CONST CHAR8 *Token, OPTIONAL
|
IN CONST CHAR8 *Token OPTIONAL,
|
||||||
IN CONST CHAR8 *Module, OPTIONAL
|
IN CONST CHAR8 *Module OPTIONAL,
|
||||||
IN UINT64 TimeStamp
|
IN UINT64 TimeStamp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -1681,9 +1821,9 @@ StartPerformanceMeasurement (
|
|||||||
RETURN_STATUS
|
RETURN_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
EndPerformanceMeasurement (
|
EndPerformanceMeasurement (
|
||||||
IN CONST VOID *Handle, OPTIONAL
|
IN CONST VOID *Handle OPTIONAL,
|
||||||
IN CONST CHAR8 *Token, OPTIONAL
|
IN CONST CHAR8 *Token OPTIONAL,
|
||||||
IN CONST CHAR8 *Module, OPTIONAL
|
IN CONST CHAR8 *Module OPTIONAL,
|
||||||
IN UINT64 TimeStamp
|
IN UINT64 TimeStamp
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -1785,9 +1925,9 @@ RETURN_STATUS
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
LogPerformanceMeasurement (
|
LogPerformanceMeasurement (
|
||||||
IN CONST VOID *CallerIdentifier,
|
IN CONST VOID *CallerIdentifier,
|
||||||
IN CONST VOID *Guid, OPTIONAL
|
IN CONST VOID *Guid OPTIONAL,
|
||||||
IN CONST CHAR8 *String, OPTIONAL
|
IN CONST CHAR8 *String OPTIONAL,
|
||||||
IN UINT64 Address, OPTIONAL
|
IN UINT64 Address OPTIONAL,
|
||||||
IN UINT32 Identifier
|
IN UINT32 Identifier
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -1815,8 +1955,9 @@ LogPerformanceMeasurementEnabled (
|
|||||||
//
|
//
|
||||||
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
|
// When Performance measurement is enabled and the type is not filtered, the performance can be logged.
|
||||||
//
|
//
|
||||||
if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
|
if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
#ifndef _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
|
#ifndef _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
|
||||||
#define _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
|
#define _DXE_CORE_PERFORMANCE_LIB_INTERNAL_H_
|
||||||
|
|
||||||
|
|
||||||
#include <PiDxe.h>
|
#include <PiDxe.h>
|
||||||
|
|
||||||
#include <Guid/Performance.h>
|
#include <Guid/Performance.h>
|
||||||
@ -66,11 +65,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CreatePerformanceMeasurement (
|
CreatePerformanceMeasurement (
|
||||||
IN CONST VOID *CallerIdentifier, OPTIONAL
|
IN CONST VOID *CallerIdentifier OPTIONAL,
|
||||||
IN CONST VOID *Guid, OPTIONAL
|
IN CONST VOID *Guid OPTIONAL,
|
||||||
IN CONST CHAR8 *String, OPTIONAL
|
IN CONST CHAR8 *String OPTIONAL,
|
||||||
IN UINT64 TimeStamp, OPTIONAL
|
IN UINT64 TimeStamp OPTIONAL,
|
||||||
IN UINT64 Address, OPTIONAL
|
IN UINT64 Address OPTIONAL,
|
||||||
IN UINT32 Identifier,
|
IN UINT32 Identifier,
|
||||||
IN PERF_MEASUREMENT_ATTRIBUTE Attribute
|
IN PERF_MEASUREMENT_ATTRIBUTE Attribute
|
||||||
);
|
);
|
||||||
|
@ -93,6 +93,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
|||||||
#define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE 42
|
#define SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE 42
|
||||||
#define SMBIOS_TYPE_TPM_DEVICE 43
|
#define SMBIOS_TYPE_TPM_DEVICE 43
|
||||||
#define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION 44
|
#define SMBIOS_TYPE_PROCESSOR_ADDITIONAL_INFORMATION 44
|
||||||
|
#define SMBIOS_TYPE_FIRMWARE_INVENTORY_INFORMATION 45
|
||||||
|
#define SMBIOS_TYPE_STRING_PROPERTY_INFORMATION 46
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Inactive type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.43.
|
/// Inactive type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.43.
|
||||||
@ -812,7 +814,24 @@ typedef enum {
|
|||||||
ProcessorUpgradeSocketBGA1528 = 0x3C,
|
ProcessorUpgradeSocketBGA1528 = 0x3C,
|
||||||
ProcessorUpgradeSocketLGA4189 = 0x3D,
|
ProcessorUpgradeSocketLGA4189 = 0x3D,
|
||||||
ProcessorUpgradeSocketLGA1200 = 0x3E,
|
ProcessorUpgradeSocketLGA1200 = 0x3E,
|
||||||
ProcessorUpgradeSocketLGA4677 = 0x3F
|
ProcessorUpgradeSocketLGA4677 = 0x3F,
|
||||||
|
ProcessorUpgradeSocketLGA1700 = 0x40,
|
||||||
|
ProcessorUpgradeSocketBGA1744 = 0x41,
|
||||||
|
ProcessorUpgradeSocketBGA1781 = 0x42,
|
||||||
|
ProcessorUpgradeSocketBGA1211 = 0x43,
|
||||||
|
ProcessorUpgradeSocketBGA2422 = 0x44,
|
||||||
|
ProcessorUpgradeSocketLGA1211 = 0x45,
|
||||||
|
ProcessorUpgradeSocketLGA2422 = 0x46,
|
||||||
|
ProcessorUpgradeSocketLGA5773 = 0x47,
|
||||||
|
ProcessorUpgradeSocketBGA5773 = 0x48,
|
||||||
|
ProcessorUpgradeSocketAM5 = 0x49,
|
||||||
|
ProcessorUpgradeSocketSP5 = 0x4A,
|
||||||
|
ProcessorUpgradeSocketSP6 = 0x4B,
|
||||||
|
ProcessorUpgradeSocketBGA883 = 0x4C,
|
||||||
|
ProcessorUpgradeSocketBGA1190 = 0x4D,
|
||||||
|
ProcessorUpgradeSocketBGA4129 = 0x4E,
|
||||||
|
ProcessorUpgradeSocketLGA4710 = 0x4F,
|
||||||
|
ProcessorUpgradeSocketLGA7529 = 0x50
|
||||||
} PROCESSOR_UPGRADE;
|
} PROCESSOR_UPGRADE;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user