Skip to content

Commit

Permalink
Merge branch 'dev/202405' into dependabot/pip/edk2-pytool-extensions-…
Browse files Browse the repository at this point in the history
…approx-eq-0.28.1
  • Loading branch information
apop5 authored Feb 14, 2025
2 parents a7c79c8 + 27eb6af commit 1ecfb77
Show file tree
Hide file tree
Showing 21 changed files with 2,754 additions and 1,854 deletions.
17 changes: 11 additions & 6 deletions BaseTools/Plugin/ClangPdbToolChain/ClangPdbToolChain.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ def do_post_build(self, thebuilder):

def do_pre_build(self, thebuilder):
self.Logger = logging.getLogger("ClangPdbToolChain")

##
# CLANGPBD
# - Need to find the clang path.
# - Report path and version for logging
#
#
# if CLANG_BIN already set the plugin will confirm it exists and get the version of clang
# If not set it will look for clang on the path. If found it will configure for that.
# if still not found it will try the default install directory.
# if still not found it will try the default install directory.
# finally an error will be reported if not found
##
if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "CLANGPDB":

HostInfo = GetHostInfo()
ClangBin_Default = "UNDEFINED"
clang_exe = "clang"
Expand Down Expand Up @@ -67,10 +67,15 @@ def do_pre_build(self, thebuilder):

version_aggregator.GetVersionAggregator().ReportVersion(
"CLANG BIN", ClangBin, version_aggregator.VersionTypes.INFO)

# now confirm it exists
if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("CLANG_BIN")):
self.Logger.error(f"Path for CLANGPDB toolchain is invalid. {ClangBin}")
self.Logger.error("Clang was not found!")
if ClangBin == ClangBin_Default:
self.Logger.error(f"The default clang bin path does not exist: {ClangBin.rstrip(os.sep)}.")
self.Logger.error("Set the CLANG_BIN variable in your shell to the installation bin directory.")
else:
self.Logger.error(f"The path provided in CLANG_BIN does not exist: {ClangBin}.")
return -2

version_aggregator.GetVersionAggregator().ReportVersion(
Expand Down
79 changes: 53 additions & 26 deletions MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Data for FPDT performance records.
//
#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
#define FIRMWARE_RECORD_BUFFER 0x10000
#define CACHE_HANDLE_GUID_COUNT 0x800
// MU_CHANGE [BEGIN] - Standalone MM Perf Support
#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE))
// MU_CHANGE [END] - Standalone MM Perf Support
#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
#define FIRMWARE_RECORD_BUFFER 0x10000
#define CACHE_HANDLE_GUID_COUNT 0x800

BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL;
BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = {
Expand Down Expand Up @@ -228,16 +230,18 @@ InternalGetSmmPerfData (
{
EFI_STATUS Status;
UINT8 *SmmBootRecordCommBuffer;
EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
EFI_MM_COMMUNICATE_HEADER *MmCommBufferHeader; // MU_CHANGE - Standalone MM Perf Support
SMM_BOOT_RECORD_COMMUNICATE *SmmCommData;
UINTN CommSize;
EFI_SMM_COMMUNICATION_PROTOCOL *Communication;
EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable;
EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion;
UINTN Index;
VOID *CurrentBootRecordData; // MU_CHANGE - Standalone MM Perf Support
VOID *SmmBootRecordData;
UINTN SmmBootRecordDataSize;
UINTN ReservedMemSize;
UINTN BootRecordDataPayloadSize; // MU_CHANGE - Standalone MM Perf Support
UINTN SmmBootRecordDataRetrieved;

//
Expand Down Expand Up @@ -278,21 +282,28 @@ InternalGetSmmPerfData (
//
if (ReservedMemSize > SMM_BOOT_RECORD_COMM_SIZE) {
SmmBootRecordCommBuffer = (VOID *)(UINTN)SmmCommMemRegion->PhysicalStart;
SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER *)SmmBootRecordCommBuffer;
SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE *)SmmCommBufferHeader->Data;
MmCommBufferHeader = (EFI_MM_COMMUNICATE_HEADER *)SmmBootRecordCommBuffer; // MU_CHANGE - Standalone MM Perf Support
SmmCommData = (SMM_BOOT_RECORD_COMMUNICATE *)MmCommBufferHeader->Data; // MU_CHANGE - Standalone MM Perf Support
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;
CopyGuid (&MmCommBufferHeader->HeaderGuid, &gEfiFirmwarePerformanceGuid); // MU_CHANGE - Standalone MM Perf Support
MmCommBufferHeader->MessageLength = sizeof (SMM_BOOT_RECORD_COMMUNICATE); // MU_CHANGE - Standalone MM Perf Support
CommSize = SMM_BOOT_RECORD_COMM_SIZE;

//
// Get the size of boot records.
//
SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE;
SmmCommData->BootRecordData = NULL;
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
// MU_CHANGE [BEGIN] - Standalone MM Perf Support
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_WARN, "Perf handler MMI not found or communicate failed. Status = %r.\n", Status));
} else if (EFI_ERROR (SmmCommData->ReturnStatus)) {
DEBUG ((DEBUG_ERROR, "Perf handler MMI returned an error. Status = %r.\n", SmmCommData->ReturnStatus));
}

// MU_CHANGE [END] - Standalone MM Perf Support
if (!EFI_ERROR (Status) && !EFI_ERROR (SmmCommData->ReturnStatus) && (SmmCommData->BootRecordSize != 0)) {
if (SkipGetPerfData) {
*SmmPerfDataSize = SmmCommData->BootRecordSize;
Expand All @@ -308,26 +319,42 @@ InternalGetSmmPerfData (
SmmBootRecordData = AllocateZeroPool (SmmBootRecordDataSize);
SmmBootRecordDataRetrieved = 0;
ASSERT (SmmBootRecordData != NULL);
SmmCommData->BootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE;
while (SmmBootRecordDataRetrieved < SmmBootRecordDataSize) {
Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
ASSERT_EFI_ERROR (Status);
ASSERT_EFI_ERROR (SmmCommData->ReturnStatus);
if (SmmBootRecordDataRetrieved + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmBootRecordDataRetrieved);
} else {
CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, SmmCommData->BootRecordData, SmmCommData->BootRecordSize);
// MU_CHANGE [BEGIN] - Standalone MM Perf Support
if (SmmBootRecordData != NULL) {
CurrentBootRecordData = (VOID *)((UINTN)SmmCommMemRegion->PhysicalStart + SMM_BOOT_RECORD_COMM_SIZE);
while (SmmBootRecordDataRetrieved < SmmBootRecordDataSize) {
// Note: Maximum comm buffer data payload size is ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE
BootRecordDataPayloadSize = MIN (
ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE,
SmmBootRecordDataSize - SmmBootRecordDataRetrieved
);

MmCommBufferHeader->MessageLength = sizeof (SMM_BOOT_RECORD_COMMUNICATE) + BootRecordDataPayloadSize;
CommSize = sizeof (EFI_MM_COMMUNICATE_HEADER) + (UINTN)MmCommBufferHeader->MessageLength;

Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status) || EFI_ERROR (SmmCommData->ReturnStatus)) {
break;
}

if (SmmBootRecordDataRetrieved + SmmCommData->BootRecordSize > SmmBootRecordDataSize) {
CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, CurrentBootRecordData, SmmBootRecordDataSize - SmmBootRecordDataRetrieved);
} else {
CopyMem ((UINT8 *)SmmBootRecordData + SmmBootRecordDataRetrieved, CurrentBootRecordData, SmmCommData->BootRecordSize);
}

SmmBootRecordDataRetrieved += SmmCommData->BootRecordSize;
SmmCommData->BootRecordOffset += SmmCommData->BootRecordSize;
}

SmmBootRecordDataRetrieved += SmmCommData->BootRecordSize;
SmmCommData->BootRecordOffset += SmmCommData->BootRecordSize;
}
mSmmBootRecordOffset = SmmCommData->BootRecordOffset;

mSmmBootRecordOffset = SmmCommData->BootRecordOffset;
*SmmPerfData = SmmBootRecordData;
*SmmPerfDataSize = SmmBootRecordDataSize;
}

*SmmPerfData = SmmBootRecordData;
*SmmPerfDataSize = SmmBootRecordDataSize;
// MU_CHANGE [END] - Standalone MM Perf Support
}
}
}
Expand Down
Loading

0 comments on commit 1ecfb77

Please sign in to comment.