[edk2] [patch V2 3/3] ShellPkg/Dp: Make the help info align with code
Currently in DP, the Trace mode is enabled by default. And the profile mode is not implemented. but the help info of DP tool doesn't match current implementation. Which will make user confused. So now remove the unused source code related to the profile mode and update the help information of DP tool. V2: Remove the unused code related to profile mode. Cc: Liming Gao Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 96 ++-- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 7 -- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 6 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 1 - .../DpDynamicCommand/DpDynamicCommand.inf | 1 - .../DynamicCommand/DpDynamicCommand/DpInternal.h | 48 -- .../DynamicCommand/DpDynamicCommand/DpProfile.c| 100 - 7 files changed, 26 insertions(+), 233 deletions(-) delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index d8451dbf59f..38766613175 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -82,14 +82,10 @@ UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA); STATIC CONST SHELL_PARAM_ITEM ParamList[] = { {L"-v", TypeFlag}, // -v Verbose Mode {L"-A", TypeFlag}, // -A All, Cooked {L"-R", TypeFlag}, // -R RAW All {L"-s", TypeFlag}, // -s Summary -#if PROFILING_IMPLEMENTED - {L"-P", TypeFlag}, // -P Dump Profile Data - {L"-T", TypeFlag}, // -T Dump Trace Data -#endif // PROFILING_IMPLEMENTED {L"-x", TypeFlag}, // -x eXclude Cumulative Items {L"-i", TypeFlag}, // -i Display Identifier {L"-c", TypeValue}, // -c Display cumulative data. {L"-n", TypeValue}, // -n # Number of records to display for A and R {L"-t", TypeValue}, // -t # Threshold of interest @@ -114,13 +110,10 @@ DumpStatistics( void ) ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle,SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle, SummaryData.NumPEIMs); ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle,SummaryData.NumGlobal); -#if PROFILING_IMPLEMENTED - ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), mDpHiiHandle,SummaryData.NumProfile); -#endif // PROFILING_IMPLEMENTED SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtrUnknown); } /** @@ -682,11 +675,10 @@ VOID InitSummaryData ( VOID ) { SummaryData.NumTrace = 0; - SummaryData.NumProfile= 0 ; SummaryData.NumIncomplete = 0; SummaryData.NumSummary= 0; SummaryData.NumHandles= 0; SummaryData.NumPEIMs = 0; SummaryData.NumGlobal = 0; @@ -719,12 +711,10 @@ RunDp ( EFI_STRINGStringPtr; BOOLEAN SummaryMode; BOOLEAN VerboseMode; BOOLEAN AllMode; BOOLEAN RawMode; - BOOLEAN TraceMode; - BOOLEAN ProfileMode; BOOLEAN ExcludeMode; BOOLEAN CumulativeMode; CONST CHAR16 *CustomCumulativeToken; PERF_CUM_DATA *CustomCumulativeData; UINTN NameSize; @@ -734,12 +724,10 @@ RunDp ( StringPtr = NULL; SummaryMode = FALSE; VerboseMode = FALSE; AllMode = FALSE; RawMode = FALSE; - TraceMode = FALSE; - ProfileMode = FALSE; ExcludeMode = FALSE; CumulativeMode = FALSE; CustomCumulativeData = NULL; ShellStatus = SHELL_SUCCESS; @@ -763,14 +751,10 @@ RunDp ( // VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v"); SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s")); AllMode = ShellCommandLineGetFlag (ParamPackage, L"-A"); RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R"); -#if PROFILING_IMPLEMENTED - TraceMode = ShellCommandLineGetFlag (ParamPackage, L"-T"); - ProfileMode = ShellCommandLineGetFlag (ParamPackage, L"-P"); -#endif // PROFILING_IMPLEMENTED ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x
[edk2] [patch V2 1/3] ShellPkg/Dp: make sure memory is freed before exit
Run dp command now: Firstly it will get performance records from FPDT and then parse the DP command. And if encounter invalid parameters, it will exit directly. Thus the performance records got before are invalid. And what's worse is that the memory allocated in getting performance records phase is not freed. This patch update the code to parse the command firstly and then get the performance records. And make sure that all the clean work has been done before exiting. Cc: Liming Gao Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Ruiyu Ni --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 70 ++- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index aa9c2cdf7a8..fe85937f557 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -390,11 +390,11 @@ BuildCachedGuidHandleTable ( } if (HandleBuffer != NULL) { FreePool (HandleBuffer); HandleBuffer = NULL; } - return Status; + return EFI_SUCCESS; } /** Get Measurement form Fpdt records. @@ -729,39 +729,10 @@ RunDp ( // initialize the shell lib (we must be in non-auto-init...) // Status = ShellInitialize(); ASSERT_EFI_ERROR(Status); - // - // DP dump performance data by parsing FPDT table in ACPI table. - // Folloing 3 steps are to get the measurement form the FPDT table. - // - - // - //1. Get FPDT from ACPI table. - // - Status = GetBootPerformanceTable (); - if (EFI_ERROR(Status)) { -return Status; - } - - // - //2. Cache the ModuleGuid and hanlde mapping table. - // - Status = BuildCachedGuidHandleTable(); - if (EFI_ERROR (Status)) { -return Status; - } - - // - //3. Build the measurement array form the FPDT records. - // - Status = BuildMeasurementList (); - if (EFI_ERROR(Status)) { -return Status; - } - // // Process Command Line arguments // Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE); if (EFI_ERROR(Status)) { @@ -809,10 +780,42 @@ RunDp ( #if PROFILING_IMPLEMENTED ProfileMode = TRUE; #endif // PROFILING_IMPLEMENTED } + // + // DP dump performance data by parsing FPDT table in ACPI table. + // Folloing 3 steps are to get the measurement form the FPDT table. + // + + // + //1. Get FPDT from ACPI table. + // + Status = GetBootPerformanceTable (); + if (EFI_ERROR (Status)) { +ShellStatus = Status; +goto Done; + } + + // + //2. Cache the ModuleGuid and hanlde mapping table. + // + Status = BuildCachedGuidHandleTable(); + if (EFI_ERROR (Status)) { +ShellStatus = Status; +goto Done; + } + + // + //3. Build the measurement array form the FPDT records. + // + Status = BuildMeasurementList (); + if (EFI_ERROR (Status)) { +ShellStatus = SHELL_OUT_OF_RESOURCES; +goto Done; + } + // // Initialize the pre-defined cumulative data. // InitCumulativeData (); @@ -821,21 +824,22 @@ RunDp ( // CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c"); if (CustomCumulativeToken != NULL) { CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA)); if (CustomCumulativeData == NULL) { - return SHELL_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; } CustomCumulativeData->MinDur = PERF_MAXDUR; CustomCumulativeData->MaxDur = 0; CustomCumulativeData->Count = 0; CustomCumulativeData->Duration = 0; NameSize = StrLen (CustomCumulativeToken) + 1; CustomCumulativeData->Name = AllocateZeroPool (NameSize); if (CustomCumulativeData->Name == NULL) { - FreePool (CustomCumulativeData); - return SHELL_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; } UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize); } // -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [RFC] MdePkg/PerformanceLib.h: Add new Perf macros
We plan to add a group of new Perf macros in performance library for performance logging. Which will simplify the usage model of performance measurement. New Perf Macros: Macros 1: #define PERF_START_IMAGE_BEGIN(ModuleHandle) #define PERF_START_IMAGE_END(ModuleHandle) Macros 2: #define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) #define PERF_LOAD_IMAGE_END(ModuleHandle) Macros 3: #define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) #define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) Macros 4: #define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) #define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) Macros 5: #define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) #define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) Macros 6: #define PERF_EVENT(EventString) Macros 7: #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) #define PERF_EVENT_SIGNAL_END(EventGuid) Macros 8: #define PERF_CALLBACK_BEGIN(TriggerGuid) #define PERF_CALLBACK_END(TriggerGuid) Macros 9: #define PERF_FUNCTION_BEGIN() #define PERF_FUNCTION_END() Macros 10: #define PERF_INMODULE_BEGIN(MeasurementString) #define PERF_INMODULE_END(MeasurementString) Macros 11: #define PERF_CROSSMODULE_BEGIN(MeasurementString) #define PERF_CROSSMODULE_END(MeasurementString) The detailed descriptions and changes are listed here. 1. Reasons of introducing these new Perf macros: a. Simplify the usage model of Perf macros. New Perf macros will have less input parameters. And different use cases can map to different Perf macros. b. Introduce new control functionality for performance logging. Such as there are lots of DriverBinding Support (Start/Stop) Perf entries in core codes. User can stop logging the performance of these entries by configure PCD. c. User can get more info through the new Perf macros. Like the ControllerHandle for DriverBinding Perf entries... 2. Macros 1-11, each macro will be identified by different perf identifiers. Macros 1-5 are for core use cases and used in the PeiCore, DxeCore and SmmCore. Macros 6-11 are for general use cases and can be used in any modules. Map each pair of core macros in Macros 1-5 to a core Perf type: PERF_CORE_START_IMAGE PERF_CORE_LOAD_IMAGE PERF_CORE_DB_SUPPORT PERF_CORE_DB_START PERF_CORE_DB_STOP And map all general Perf macros in Macros 6-11 to PERF_GENERAL_TYPE Then we can configure PCD to disable different Perf macros. 3. Update PcdPerformanceLibraryPropertyMask to control performance logging. Now BIT0 of PcdPerformanceLibraryPropertyMaskis is to enable the performance measurement. We will add BIT1-BIT6 to control different Perf types. Only when performance measurement is enabled, we can check BIT1-BIT6 to see whether a specific Perf type is disabled or not. This configuration are compatible with current performance enable behavior, set BIT0 can enable all the performance measurement. PcdPerformanceLibraryPropertyMask in MdePkg # BIT0 - Enable Performance Measurement. # BIT1 - Disable Start Image Logging. # BIT2 - Disable Load Image logging. # BIT3 - Disable Binding Support logging. # BIT4 - Disable Binding Start logging. # BIT5 - Disable Binding Stop logging. # BIT6 - Disable all other general Perfs. # BIT1-BIT6 are evaluated when BIT0 is set. 4. Introduce two new Library APIs for PerformanceLib library class. a. LogPerformanceMeasurementEnabled (Type); b. LogPerformanceMeasurement (CallerId, Guid, String, Address, PerfId); LogPerformanceMeasurementEnabled (Type): check whether a specified performance measurement can be logged. LogPerformanceMeasurement (CallerId, Guid, String, Address, PerfId): Log performance measurement info. 5. Code updates a. Performance library instances update: MdePkg: BasePerformanceLibNull MdeModulePkg: PeiPerformanceLib DxePerformanceLib DxeCorePerformanceLib SmmPerformanceLib SmmCorePerformanceLib b. Consumer code update: Update the old perf macros to use new perf macros for MdeModulePkg, UefiCpuPkg and SecurityPkg. For other packages, if old Perf macros are used, packages owners can decide whether using new Perf macros to replace old ones. Can refer to the following patch for more detailed code changes and description of new macros, APIs, definitions and PCD updating. Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdePkg/Include/Library/PerformanceLib.h | 407 +++- MdePkg/MdePkg.dec | 9 +- 2 files changed, 414 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h index 3ecd62bd201..dea79a9ff53 100644 --- a/MdePkg/Include/Library/PerformanceLib.h +++ b
[edk2] [patch V2 1/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
Make the function comments follow EDK2 coding style. Cc: Sami Mujawar Cc: Evan Lloyd Cc: Jaben Carsey Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 130 ++-- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 223 - .../UefiShellAcpiViewCommandLib/AcpiTableParser.c | 27 ++- .../UefiShellAcpiViewCommandLib/AcpiTableParser.h | 39 ++-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 55 +++-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 59 +++--- .../Parsers/Bgrt/BgrtParser.c | 12 +- .../Parsers/Dbg2/Dbg2Parser.c | 29 +-- .../Parsers/Dsdt/DsdtParser.c | 7 +- .../Parsers/Fadt/FadtParser.c | 68 +-- .../Parsers/Gtdt/GtdtParser.c | 52 +++-- .../Parsers/Iort/IortParser.c | 133 +++- .../Parsers/Madt/MadtParser.c | 63 +++--- .../Parsers/Mcfg/McfgParser.c | 18 +- .../Parsers/Rsdp/RsdpParser.c | 32 +-- .../Parsers/Slit/SlitParser.c | 17 +- .../Parsers/Spcr/SpcrParser.c | 32 +-- .../Parsers/Srat/SratParser.c | 61 +++--- .../Parsers/Ssdt/SsdtParser.c | 7 +- .../Parsers/Xsdt/XsdtParser.c | 11 +- .../UefiShellAcpiViewCommandLib.c | 13 +- .../UefiShellAcpiViewCommandLib.h | 4 +- 22 files changed, 645 insertions(+), 447 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 318f386fda1..088575d0144 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -1,6 +1,6 @@ -/** +/** @file ACPI parser Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -19,88 +19,95 @@ STATIC UINT32 gIndent; STATIC UINT32 mTableErrorCount; STATIC UINT32 mTableWarningCount; -/** This function resets the ACPI table error counter to Zero. -*/ +/** + This function resets the ACPI table error counter to Zero. +**/ VOID ResetErrorCount ( VOID ) { mTableErrorCount = 0; } -/** This function returns the ACPI table error count. +/** + This function returns the ACPI table error count. @retval Returns the count of errors detected in the ACPI tables. -*/ +**/ UINT32 GetErrorCount ( VOID ) { return mTableErrorCount; } -/** This function resets the ACPI table warning counter to Zero. -*/ +/** + This function resets the ACPI table warning counter to Zero. +**/ VOID ResetWarningCount ( VOID ) { mTableWarningCount = 0; } -/** This function returns the ACPI table warning count. +/** + This function returns the ACPI table warning count. @retval Returns the count of warning detected in the ACPI tables. -*/ +**/ UINT32 GetWarningCount ( VOID ) { return mTableWarningCount; } -/** This function increments the ACPI table error counter. -*/ +/** + This function increments the ACPI table error counter. +**/ VOID EFIAPI IncrementErrorCount ( VOID ) { mTableErrorCount++; } -/** This function increments the ACPI table warning counter. -*/ +/** + This function increments the ACPI table warning counter. +**/ VOID EFIAPI IncrementWarningCount ( VOID ) { mTableWarningCount++; } -/** This function verifies the ACPI table checksum. +/** + This function verifies the ACPI table checksum. This function verifies the checksum for the ACPI table and optionally prints the status. @param [in] Log If TRUE log the status of the checksum. @param [in] Ptr Pointer to the start of the table buffer. @param [in] Length The length of the buffer. @retval TRUEThe checksum is OK. @retval FALSE The checksum failed. -*/ +**/ BOOLEAN EFIAPI VerifyChecksum ( IN BOOLEAN Log, IN UINT8* Ptr, @@ -144,15 +151,16 @@ VerifyChecksum ( } return (Checksum == 0); } -/** This function performs a raw data dump of the ACPI table. +/** + This function performs a raw data dump of the ACPI table. @param [in] Ptr Pointer to the start of the table buffer. @param [in] Length The length of the buffer. -*/ +**/ VOID EFIAPI DumpRaw ( IN UINT8* Ptr, IN UINT32 Length @@ -203,64 +211,64 @@ DumpRaw ( // Print ASCII data for the final line. AsciiBuffer[AsciiBufferIndex] = '\0'; Print (L" %a", AsciiBuffer); } -/** This function traces 1 byte of data as specified in the -format string. +/** + This function traces 1 byte of data
[edk2] [patch V2 2/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
1. Separate variable definition and initialization. 2. Make the variable naming following Edk2 rule. V2: Remove the updates of guard macros in header files. Cc: Sami Mujawar Cc: Evan Lloyd Cc: Jaben Carsey Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 44 ++-- .../UefiShellAcpiViewCommandLib/AcpiTableParser.c | 50 +-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 58 ++ .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 10 ++-- .../Parsers/Dbg2/Dbg2Parser.c | 5 +- .../Parsers/Gtdt/GtdtParser.c | 5 +- .../Parsers/Iort/IortParser.c | 26 +- .../Parsers/Madt/MadtParser.c | 4 +- .../Parsers/Rsdp/RsdpParser.c | 10 +++- .../Parsers/Slit/SlitParser.c | 44 .../Parsers/Spcr/SpcrParser.c | 10 +++- .../Parsers/Srat/SratParser.c | 21 +--- .../UefiShellAcpiViewCommandLib.c | 5 +- .../UefiShellAcpiViewCommandLib.inf| 3 ++ 14 files changed, 178 insertions(+), 117 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 088575d0144..6d3bc451acd 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -19,10 +19,19 @@ STATIC UINT32 gIndent; STATIC UINT32 mTableErrorCount; STATIC UINT32 mTableWarningCount; +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +/** + An ACPI_PARSER array describing the ACPI header. +**/ +STATIC CONST ACPI_PARSER AcpiHeaderParser[] = { + PARSE_ACPI_HEADER (&AcpiHdrInfo) +}; + /** This function resets the ACPI table error counter to Zero. **/ VOID ResetErrorCount ( @@ -112,14 +121,17 @@ VerifyChecksum ( IN BOOLEAN Log, IN UINT8* Ptr, IN UINT32 Length ) { - UINTN ByteCount = 0; - UINT8 Checksum = 0; + UINTN ByteCount; + UINT8 Checksum; UINTN OriginalAttribute; + ByteCount = 0; + Checksum = 0; + while (ByteCount < Length) { Checksum += *(Ptr++); ByteCount++; } @@ -164,15 +176,18 @@ EFIAPI DumpRaw ( IN UINT8* Ptr, IN UINT32 Length ) { - UINTN ByteCount = 0; + UINTN ByteCount; UINTN PartLineChars; - UINTN AsciiBufferIndex = 0; + UINTN AsciiBufferIndex; CHAR8 AsciiBuffer[17]; + ByteCount = 0; + AsciiBufferIndex = 0; + Print (L"Address : 0x%p\n", Ptr); Print (L"Length : %d\n", Length); while (ByteCount < Length) { if ((ByteCount & 0x0F) == 0) { @@ -275,11 +290,14 @@ DumpUint64 ( ) { // Some fields are not aligned and this causes alignment faults // on ARM platforms if the compiler generates LDRD instructions. // Perform word access so that LDRD instructions are not generated. - UINT64 Val = *(UINT32*)(Ptr + sizeof (UINT32)); + UINT64 Val; + + Val = *(UINT32*)(Ptr + sizeof (UINT32)); + Val <<= 32; Val |= *(UINT32*)Ptr; Print (Format, Val); } @@ -454,17 +472,20 @@ ParseAcpi ( IN CONST ACPI_PARSER* Parser, IN UINT32 ParserItems ) { UINT32 Index; - UINT32 Offset = 0; + UINT32 Offset; + BOOLEAN HighLight; + + Offset = 0; // Increment the Indent gIndent += Indent; if (Trace && (AsciiName != NULL)){ -BOOLEAN HighLight = GetColourHighlighting (); +HighLight = GetColourHighlighting (); UINTN OriginalAttribute; if (HighLight) { OriginalAttribute = gST->ConOut->Mode->Attribute; gST->ConOut->SetAttribute ( @@ -618,15 +639,10 @@ UINT32 EFIAPI DumpAcpiHeader ( IN UINT8* Ptr ) { - ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; - ACPI_PARSER AcpiHeaderParser[] = { -PARSE_ACPI_HEADER (&AcpiHdrInfo) - }; - return ParseAcpi ( TRUE, 0, "ACPI Table Header", Ptr, @@ -656,14 +672,10 @@ ParseAcpiHeader ( OUT CONST UINT32** Length, OUT CONST UINT8** Revision ) { UINT32BytesParsed; - ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; - ACPI_PARSER AcpiHeaderParser[] = { -PARSE_ACPI_HEADER (&AcpiHdrInfo) - }; BytesParsed = ParseAcpi ( FALSE, 0, NULL, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c index 7b1a02cad3e..fff5757bf58 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c @@ -43,36 +43,36 @@ EFIAPI RegisterParser ( IN UINT32 Signature, IN PARSE_ACPI_TABLE_PROC ParserProc )
[edk2] [patch V2 0/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
ECC tool report some coding style issue in UefiShellAcpiViewCommandLib. This patch series is to clean these issues. V2: Remove the updates of guard macros in header files in patch 2. Cc: Sami Mujawar Cc: Evan Lloyd Cc: Jaben Carsey Cc: Ruiyu Ni Dandan Bi (2): ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues .../UefiShellAcpiViewCommandLib/AcpiParser.c | 174 +--- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 223 - .../UefiShellAcpiViewCommandLib/AcpiTableParser.c | 77 +++ .../UefiShellAcpiViewCommandLib/AcpiTableParser.h | 39 ++-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 113 +++ .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 69 --- .../Parsers/Bgrt/BgrtParser.c | 12 +- .../Parsers/Dbg2/Dbg2Parser.c | 34 ++-- .../Parsers/Dsdt/DsdtParser.c | 7 +- .../Parsers/Fadt/FadtParser.c | 68 +-- .../Parsers/Gtdt/GtdtParser.c | 57 -- .../Parsers/Iort/IortParser.c | 159 --- .../Parsers/Madt/MadtParser.c | 67 --- .../Parsers/Mcfg/McfgParser.c | 18 +- .../Parsers/Rsdp/RsdpParser.c | 42 ++-- .../Parsers/Slit/SlitParser.c | 61 +++--- .../Parsers/Spcr/SpcrParser.c | 42 ++-- .../Parsers/Srat/SratParser.c | 82 +--- .../Parsers/Ssdt/SsdtParser.c | 7 +- .../Parsers/Xsdt/XsdtParser.c | 11 +- .../UefiShellAcpiViewCommandLib.c | 18 +- .../UefiShellAcpiViewCommandLib.h | 4 +- .../UefiShellAcpiViewCommandLib.inf| 3 + 23 files changed, 823 insertions(+), 564 deletions(-) -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdeModulePkg/DisplayUpdateProgressLib: Fix ECC issues
Make the comment align with Edk2 coding style. Cc: Star Zeng Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../DisplayUpdateProgressLibGraphics.c | 6 +++--- .../DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c b/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c index 007522cea08..2c916105136 100644 --- a/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.c @@ -1,6 +1,6 @@ -/** @file +/** @file Provides services to display completion progress of a firmware update on a graphical console that supports the Graphics Output Protocol. Copyright (c) 2016, Microsoft Corporation. All rights reserved. Copyright (c) 2018, Intel Corporation. All rights reserved. @@ -116,17 +116,17 @@ const EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION mProgressBarDefaultColor = { // Set to TRUE if a valid Graphics Output Protocol is found and the progress // bar fits under the boot logo using the current graphics mode. // BOOLEAN mGraphicsGood = FALSE; -/* +/** Internal function used to find the bounds of the white logo (on black or red background). These bounds are then computed to find the block size, 0%, 100%, etc. -*/ +**/ VOID FindDim ( VOID ) { diff --git a/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c b/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c index 7aca8b89d01..960ccc015fe 100644 --- a/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c +++ b/MdeModulePkg/Library/DisplayUpdateProgressLibText/DisplayUpdateProgressLibText.c @@ -1,6 +1,6 @@ -/** @file +/** @file Provides services to display completion progress of a firmware update on a text console. Copyright (c) 2016, Microsoft Corporation. All rights reserved. Copyright (c) 2018, Intel Corporation. All rights reserved. -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 2/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
1. Separate variable definition and initialization. 2. Make the variable naming following Edk2 rule. Naming convention of local variable: a.First character should be upper case. b.Must contain lower case characters. c.No white space characters. Cc: Sami Mujawar Cc: Evan Lloyd Cc: Sami Mujawar Cc: Evan Lloyd Cc: Jaben Carsey Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 44 ++-- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 6 +-- .../UefiShellAcpiViewCommandLib/AcpiTableParser.c | 50 +-- .../UefiShellAcpiViewCommandLib/AcpiTableParser.h | 6 +-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 58 ++ .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 16 +++--- .../Parsers/Dbg2/Dbg2Parser.c | 5 +- .../Parsers/Gtdt/GtdtParser.c | 5 +- .../Parsers/Iort/IortParser.c | 26 +- .../Parsers/Madt/MadtParser.c | 4 +- .../Parsers/Rsdp/RsdpParser.c | 10 +++- .../Parsers/Slit/SlitParser.c | 44 .../Parsers/Spcr/SpcrParser.c | 10 +++- .../Parsers/Srat/SratParser.c | 21 +--- .../UefiShellAcpiViewCommandLib.c | 5 +- .../UefiShellAcpiViewCommandLib.h | 6 +-- .../UefiShellAcpiViewCommandLib.inf| 3 ++ 17 files changed, 190 insertions(+), 129 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 088575d0144..6d3bc451acd 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -19,10 +19,19 @@ STATIC UINT32 gIndent; STATIC UINT32 mTableErrorCount; STATIC UINT32 mTableWarningCount; +STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; + +/** + An ACPI_PARSER array describing the ACPI header. +**/ +STATIC CONST ACPI_PARSER AcpiHeaderParser[] = { + PARSE_ACPI_HEADER (&AcpiHdrInfo) +}; + /** This function resets the ACPI table error counter to Zero. **/ VOID ResetErrorCount ( @@ -112,14 +121,17 @@ VerifyChecksum ( IN BOOLEAN Log, IN UINT8* Ptr, IN UINT32 Length ) { - UINTN ByteCount = 0; - UINT8 Checksum = 0; + UINTN ByteCount; + UINT8 Checksum; UINTN OriginalAttribute; + ByteCount = 0; + Checksum = 0; + while (ByteCount < Length) { Checksum += *(Ptr++); ByteCount++; } @@ -164,15 +176,18 @@ EFIAPI DumpRaw ( IN UINT8* Ptr, IN UINT32 Length ) { - UINTN ByteCount = 0; + UINTN ByteCount; UINTN PartLineChars; - UINTN AsciiBufferIndex = 0; + UINTN AsciiBufferIndex; CHAR8 AsciiBuffer[17]; + ByteCount = 0; + AsciiBufferIndex = 0; + Print (L"Address : 0x%p\n", Ptr); Print (L"Length : %d\n", Length); while (ByteCount < Length) { if ((ByteCount & 0x0F) == 0) { @@ -275,11 +290,14 @@ DumpUint64 ( ) { // Some fields are not aligned and this causes alignment faults // on ARM platforms if the compiler generates LDRD instructions. // Perform word access so that LDRD instructions are not generated. - UINT64 Val = *(UINT32*)(Ptr + sizeof (UINT32)); + UINT64 Val; + + Val = *(UINT32*)(Ptr + sizeof (UINT32)); + Val <<= 32; Val |= *(UINT32*)Ptr; Print (Format, Val); } @@ -454,17 +472,20 @@ ParseAcpi ( IN CONST ACPI_PARSER* Parser, IN UINT32 ParserItems ) { UINT32 Index; - UINT32 Offset = 0; + UINT32 Offset; + BOOLEAN HighLight; + + Offset = 0; // Increment the Indent gIndent += Indent; if (Trace && (AsciiName != NULL)){ -BOOLEAN HighLight = GetColourHighlighting (); +HighLight = GetColourHighlighting (); UINTN OriginalAttribute; if (HighLight) { OriginalAttribute = gST->ConOut->Mode->Attribute; gST->ConOut->SetAttribute ( @@ -618,15 +639,10 @@ UINT32 EFIAPI DumpAcpiHeader ( IN UINT8* Ptr ) { - ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; - ACPI_PARSER AcpiHeaderParser[] = { -PARSE_ACPI_HEADER (&AcpiHdrInfo) - }; - return ParseAcpi ( TRUE, 0, "ACPI Table Header", Ptr, @@ -656,14 +672,10 @@ ParseAcpiHeader ( OUT CONST UINT32** Length, OUT CONST UINT8** Revision ) { UINT32BytesParsed; - ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; - ACPI_PARSER AcpiHeaderParser[] = { -PARSE_ACPI_HEADER (&AcpiHdrInfo) - }; BytesParsed = ParseAcpi ( FALSE, 0, NULL, diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h index e
[edk2] [patch 0/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
ECC tool report some coding style issue in UefiShellAcpiViewCommandLib. This patch series is to clean these issues. Cc: Sami Mujawar Cc: Evan Lloyd Cc: Sami Mujawar Cc: Evan Lloyd Cc: Jaben Carsey Cc: Ruiyu Ni Dandan Bi (2): ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues .../UefiShellAcpiViewCommandLib/AcpiParser.c | 174 +--- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 229 - .../UefiShellAcpiViewCommandLib/AcpiTableParser.c | 77 +++ .../UefiShellAcpiViewCommandLib/AcpiTableParser.h | 45 ++-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 113 ++ .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 75 --- .../Parsers/Bgrt/BgrtParser.c | 12 +- .../Parsers/Dbg2/Dbg2Parser.c | 34 +-- .../Parsers/Dsdt/DsdtParser.c | 7 +- .../Parsers/Fadt/FadtParser.c | 68 -- .../Parsers/Gtdt/GtdtParser.c | 57 +++-- .../Parsers/Iort/IortParser.c | 159 -- .../Parsers/Madt/MadtParser.c | 67 +++--- .../Parsers/Mcfg/McfgParser.c | 18 +- .../Parsers/Rsdp/RsdpParser.c | 42 ++-- .../Parsers/Slit/SlitParser.c | 61 +++--- .../Parsers/Spcr/SpcrParser.c | 42 ++-- .../Parsers/Srat/SratParser.c | 82 +--- .../Parsers/Ssdt/SsdtParser.c | 7 +- .../Parsers/Xsdt/XsdtParser.c | 11 +- .../UefiShellAcpiViewCommandLib.c | 18 +- .../UefiShellAcpiViewCommandLib.h | 10 +- .../UefiShellAcpiViewCommandLib.inf| 3 + 23 files changed, 835 insertions(+), 576 deletions(-) -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 1/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
Make the function comments follow EDK2 coding style. Cc: Sami Mujawar Cc: Evan Lloyd Cc: Sami Mujawar Cc: Evan Lloyd Cc: Jaben Carsey Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 130 ++-- .../UefiShellAcpiViewCommandLib/AcpiParser.h | 223 - .../UefiShellAcpiViewCommandLib/AcpiTableParser.c | 27 ++- .../UefiShellAcpiViewCommandLib/AcpiTableParser.h | 39 ++-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 55 +++-- .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 59 +++--- .../Parsers/Bgrt/BgrtParser.c | 12 +- .../Parsers/Dbg2/Dbg2Parser.c | 29 +-- .../Parsers/Dsdt/DsdtParser.c | 7 +- .../Parsers/Fadt/FadtParser.c | 68 +-- .../Parsers/Gtdt/GtdtParser.c | 52 +++-- .../Parsers/Iort/IortParser.c | 133 +++- .../Parsers/Madt/MadtParser.c | 63 +++--- .../Parsers/Mcfg/McfgParser.c | 18 +- .../Parsers/Rsdp/RsdpParser.c | 32 +-- .../Parsers/Slit/SlitParser.c | 17 +- .../Parsers/Spcr/SpcrParser.c | 32 +-- .../Parsers/Srat/SratParser.c | 61 +++--- .../Parsers/Ssdt/SsdtParser.c | 7 +- .../Parsers/Xsdt/XsdtParser.c | 11 +- .../UefiShellAcpiViewCommandLib.c | 13 +- .../UefiShellAcpiViewCommandLib.h | 4 +- 22 files changed, 645 insertions(+), 447 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 318f386fda1..088575d0144 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -1,6 +1,6 @@ -/** +/** @file ACPI parser Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -19,88 +19,95 @@ STATIC UINT32 gIndent; STATIC UINT32 mTableErrorCount; STATIC UINT32 mTableWarningCount; -/** This function resets the ACPI table error counter to Zero. -*/ +/** + This function resets the ACPI table error counter to Zero. +**/ VOID ResetErrorCount ( VOID ) { mTableErrorCount = 0; } -/** This function returns the ACPI table error count. +/** + This function returns the ACPI table error count. @retval Returns the count of errors detected in the ACPI tables. -*/ +**/ UINT32 GetErrorCount ( VOID ) { return mTableErrorCount; } -/** This function resets the ACPI table warning counter to Zero. -*/ +/** + This function resets the ACPI table warning counter to Zero. +**/ VOID ResetWarningCount ( VOID ) { mTableWarningCount = 0; } -/** This function returns the ACPI table warning count. +/** + This function returns the ACPI table warning count. @retval Returns the count of warning detected in the ACPI tables. -*/ +**/ UINT32 GetWarningCount ( VOID ) { return mTableWarningCount; } -/** This function increments the ACPI table error counter. -*/ +/** + This function increments the ACPI table error counter. +**/ VOID EFIAPI IncrementErrorCount ( VOID ) { mTableErrorCount++; } -/** This function increments the ACPI table warning counter. -*/ +/** + This function increments the ACPI table warning counter. +**/ VOID EFIAPI IncrementWarningCount ( VOID ) { mTableWarningCount++; } -/** This function verifies the ACPI table checksum. +/** + This function verifies the ACPI table checksum. This function verifies the checksum for the ACPI table and optionally prints the status. @param [in] Log If TRUE log the status of the checksum. @param [in] Ptr Pointer to the start of the table buffer. @param [in] Length The length of the buffer. @retval TRUEThe checksum is OK. @retval FALSE The checksum failed. -*/ +**/ BOOLEAN EFIAPI VerifyChecksum ( IN BOOLEAN Log, IN UINT8* Ptr, @@ -144,15 +151,16 @@ VerifyChecksum ( } return (Checksum == 0); } -/** This function performs a raw data dump of the ACPI table. +/** + This function performs a raw data dump of the ACPI table. @param [in] Ptr Pointer to the start of the table buffer. @param [in] Length The length of the buffer. -*/ +**/ VOID EFIAPI DumpRaw ( IN UINT8* Ptr, IN UINT32 Length @@ -203,64 +211,64 @@ DumpRaw ( // Print ASCII data for the final line. AsciiBuffer[AsciiBufferIndex] = '\0'; Print (L" %a", AsciiBuffer); } -/** This function traces 1 byte of data as specified in the -format string. +/** + This fu
[edk2] [patch 3/3] ShellPkg/Dp: Make the help info align with code
Remove -T, -P, -h flags in the help info of DP to align with current code implementation. Cc: Liming Gao Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni index c7eb0fbd71e..ede59069b79 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni @@ -96,21 +96,19 @@ #string STR_GET_HELP_DP #language en-US "" ".TH dp 0 "Display performance metrics"\r\n" ".SH NAME\r\n" "Displays performance metrics that are stored in memory.\r\n" ".SH SYNOPSIS\r\n" -"DP [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]][-i] [-h | -?]\r\n" +"DP [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]][-i] [-?]\r\n" ".SH OPTIONS\r\n" " \r\n" " -b - Displays on multiple pages\r\n" " -v - Displays additional information\r\n" " -x - Prevents display of individual measurements for cumulative items\r\n" " -s - Displays summary information only\r\n" " -A - Displays all measurements in a list\r\n" " -R - Displays all measurements in raw format\r\n" -" -T - Displays trace measurements only\r\n" -" -P - Displays profile measurements only\r\n" " -t VALUE - Sets display threshold to VALUE microseconds\r\n" " -n COUNT - Limits display to COUNT lines in All and Raw modes\r\n" " -i - Displays identifier\r\n" " -c TOKEN - Display pre-defined and custom cumulative data\r\n" " Pre-defined cumulative token are:\r\n" -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 2/3] ShellPkg/Dp: Initialize summary date when run DP
Issue: When run "dp -s" or ("dp -v") command in shell several times, the summary reuslts are different each time. The root cause is that the previous global data "SummaryData" is not cleaned when the dp command is callled next time. This patch initializes the global data "SummaryData" when the dp dymanic command is called. Cc: Liming Gao Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index fe85937f557..d8451dbf59f 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -672,10 +672,28 @@ InitCumulativeData ( CumData[Index].MaxDur = 0; CumData[Index].Duration = 0; } } +/** + Initialize the Summary data. + +**/ +VOID +InitSummaryData ( + VOID + ) +{ + SummaryData.NumTrace = 0; + SummaryData.NumProfile= 0 ; + SummaryData.NumIncomplete = 0; + SummaryData.NumSummary= 0; + SummaryData.NumHandles= 0; + SummaryData.NumPEIMs = 0; + SummaryData.NumGlobal = 0; +} + /** Dump performance data. @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. @@ -817,10 +835,15 @@ RunDp ( // // Initialize the pre-defined cumulative data. // InitCumulativeData (); + // + // Initialize the Summary data. + // + InitSummaryData (); + // // Init the custom cumulative data. // CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c"); if (CustomCumulativeToken != NULL) { -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 1/3] ShellPkg/Dp: make sure memory is freed before exit
Run dp command now: Firstly it will get performance records from FPDT and then parse the DP command. And if encounter invalid parameters, it will exit directly. Thus the performance records got before are invalid. And what's worse is that the memory allocated in getting performance records phase is not freed. This patch update the code to parse the command firstly and then get the performance records. And make sure that all the clean work has been done before exiting. Cc: Liming Gao Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 70 ++- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index aa9c2cdf7a8..fe85937f557 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -390,11 +390,11 @@ BuildCachedGuidHandleTable ( } if (HandleBuffer != NULL) { FreePool (HandleBuffer); HandleBuffer = NULL; } - return Status; + return EFI_SUCCESS; } /** Get Measurement form Fpdt records. @@ -729,39 +729,10 @@ RunDp ( // initialize the shell lib (we must be in non-auto-init...) // Status = ShellInitialize(); ASSERT_EFI_ERROR(Status); - // - // DP dump performance data by parsing FPDT table in ACPI table. - // Folloing 3 steps are to get the measurement form the FPDT table. - // - - // - //1. Get FPDT from ACPI table. - // - Status = GetBootPerformanceTable (); - if (EFI_ERROR(Status)) { -return Status; - } - - // - //2. Cache the ModuleGuid and hanlde mapping table. - // - Status = BuildCachedGuidHandleTable(); - if (EFI_ERROR (Status)) { -return Status; - } - - // - //3. Build the measurement array form the FPDT records. - // - Status = BuildMeasurementList (); - if (EFI_ERROR(Status)) { -return Status; - } - // // Process Command Line arguments // Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE); if (EFI_ERROR(Status)) { @@ -809,10 +780,42 @@ RunDp ( #if PROFILING_IMPLEMENTED ProfileMode = TRUE; #endif // PROFILING_IMPLEMENTED } + // + // DP dump performance data by parsing FPDT table in ACPI table. + // Folloing 3 steps are to get the measurement form the FPDT table. + // + + // + //1. Get FPDT from ACPI table. + // + Status = GetBootPerformanceTable (); + if (EFI_ERROR (Status)) { +ShellStatus = Status; +goto Done; + } + + // + //2. Cache the ModuleGuid and hanlde mapping table. + // + Status = BuildCachedGuidHandleTable(); + if (EFI_ERROR (Status)) { +ShellStatus = Status; +goto Done; + } + + // + //3. Build the measurement array form the FPDT records. + // + Status = BuildMeasurementList (); + if (EFI_ERROR (Status)) { +ShellStatus = SHELL_OUT_OF_RESOURCES; +goto Done; + } + // // Initialize the pre-defined cumulative data. // InitCumulativeData (); @@ -821,21 +824,22 @@ RunDp ( // CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c"); if (CustomCumulativeToken != NULL) { CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA)); if (CustomCumulativeData == NULL) { - return SHELL_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; } CustomCumulativeData->MinDur = PERF_MAXDUR; CustomCumulativeData->MaxDur = 0; CustomCumulativeData->Count = 0; CustomCumulativeData->Duration = 0; NameSize = StrLen (CustomCumulativeToken) + 1; CustomCumulativeData->Name = AllocateZeroPool (NameSize); if (CustomCumulativeData->Name == NULL) { - FreePool (CustomCumulativeData); - return SHELL_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; } UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize); } // -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] IntelFrameworkPkg/UefiLib: Fix build fail caused by commit b6d5def2fa
In commit b6d5def2faf56334128ea2f056356d7e3852831e when adding 'OUT' decorator for the parameter in AddUnicodeString(), it delete the function name by mistake. This patch is to fix this issue. CC: Marvin Haeuser CC: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c index 61a32e29760..443a7391721 100644 --- a/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c +++ b/IntelFrameworkPkg/Library/FrameworkUefiLib/UefiLib.c @@ -863,10 +863,11 @@ LookupUnicodeString2 ( member of SupportedLanguages. **/ EFI_STATUS EFIAPI +AddUnicodeString ( IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString ) -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 2/3] ShellPkg/Dp: Initialize summary date when run DP
Issue: When run "dp -s" or ("dp -v") command in shell several times, the summary reuslts are different each time. The root cause is that the previous global data "SummaryData" is not cleaned when the dp command is callled next time. This patch initializes the global data "SummaryData" when the dp dymanic command is called. Cc: Liming Gao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index fe85937f557..d8451dbf59f 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -672,10 +672,28 @@ InitCumulativeData ( CumData[Index].MaxDur = 0; CumData[Index].Duration = 0; } } +/** + Initialize the Summary data. + +**/ +VOID +InitSummaryData ( + VOID + ) +{ + SummaryData.NumTrace = 0; + SummaryData.NumProfile= 0 ; + SummaryData.NumIncomplete = 0; + SummaryData.NumSummary= 0; + SummaryData.NumHandles= 0; + SummaryData.NumPEIMs = 0; + SummaryData.NumGlobal = 0; +} + /** Dump performance data. @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. @@ -817,10 +835,15 @@ RunDp ( // // Initialize the pre-defined cumulative data. // InitCumulativeData (); + // + // Initialize the Summary data. + // + InitSummaryData (); + // // Init the custom cumulative data. // CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c"); if (CustomCumulativeToken != NULL) { -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 3/3] ShellPkg/Dp: Make the help info align with code
Remove -T, -P, -h flags in the help info of DP to align with current code implementation. Cc: Liming Gao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni index c7eb0fbd71e..ede59069b79 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni @@ -96,21 +96,19 @@ #string STR_GET_HELP_DP #language en-US "" ".TH dp 0 "Display performance metrics"\r\n" ".SH NAME\r\n" "Displays performance metrics that are stored in memory.\r\n" ".SH SYNOPSIS\r\n" -"DP [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]][-i] [-h | -?]\r\n" +"DP [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]][-i] [-?]\r\n" ".SH OPTIONS\r\n" " \r\n" " -b - Displays on multiple pages\r\n" " -v - Displays additional information\r\n" " -x - Prevents display of individual measurements for cumulative items\r\n" " -s - Displays summary information only\r\n" " -A - Displays all measurements in a list\r\n" " -R - Displays all measurements in raw format\r\n" -" -T - Displays trace measurements only\r\n" -" -P - Displays profile measurements only\r\n" " -t VALUE - Sets display threshold to VALUE microseconds\r\n" " -n COUNT - Limits display to COUNT lines in All and Raw modes\r\n" " -i - Displays identifier\r\n" " -c TOKEN - Display pre-defined and custom cumulative data\r\n" " Pre-defined cumulative token are:\r\n" -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 1/3] ShellPkg/Dp: make sure memory is freed before exit
Run dp command now: Firstly it will get performance records from FPDT and then parse the DP command. And if encounter invalid parameters, it will exit directly. Thus the performance records got before are invalid. And what's worse is that the memory allocated in getting performance records phase is not freed. This patch update the code to parse the command firstly and then get the performance records. And make sure that all the clean work has been done before exiting. Cc: Liming Gao Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 70 ++- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index aa9c2cdf7a8..fe85937f557 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -390,11 +390,11 @@ BuildCachedGuidHandleTable ( } if (HandleBuffer != NULL) { FreePool (HandleBuffer); HandleBuffer = NULL; } - return Status; + return EFI_SUCCESS; } /** Get Measurement form Fpdt records. @@ -729,39 +729,10 @@ RunDp ( // initialize the shell lib (we must be in non-auto-init...) // Status = ShellInitialize(); ASSERT_EFI_ERROR(Status); - // - // DP dump performance data by parsing FPDT table in ACPI table. - // Folloing 3 steps are to get the measurement form the FPDT table. - // - - // - //1. Get FPDT from ACPI table. - // - Status = GetBootPerformanceTable (); - if (EFI_ERROR(Status)) { -return Status; - } - - // - //2. Cache the ModuleGuid and hanlde mapping table. - // - Status = BuildCachedGuidHandleTable(); - if (EFI_ERROR (Status)) { -return Status; - } - - // - //3. Build the measurement array form the FPDT records. - // - Status = BuildMeasurementList (); - if (EFI_ERROR(Status)) { -return Status; - } - // // Process Command Line arguments // Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE); if (EFI_ERROR(Status)) { @@ -809,10 +780,42 @@ RunDp ( #if PROFILING_IMPLEMENTED ProfileMode = TRUE; #endif // PROFILING_IMPLEMENTED } + // + // DP dump performance data by parsing FPDT table in ACPI table. + // Folloing 3 steps are to get the measurement form the FPDT table. + // + + // + //1. Get FPDT from ACPI table. + // + Status = GetBootPerformanceTable (); + if (EFI_ERROR (Status)) { +ShellStatus = Status; +goto Done; + } + + // + //2. Cache the ModuleGuid and hanlde mapping table. + // + Status = BuildCachedGuidHandleTable(); + if (EFI_ERROR (Status)) { +ShellStatus = Status; +goto Done; + } + + // + //3. Build the measurement array form the FPDT records. + // + Status = BuildMeasurementList (); + if (EFI_ERROR (Status)) { +ShellStatus = SHELL_OUT_OF_RESOURCES; +goto Done; + } + // // Initialize the pre-defined cumulative data. // InitCumulativeData (); @@ -821,21 +824,22 @@ RunDp ( // CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c"); if (CustomCumulativeToken != NULL) { CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA)); if (CustomCumulativeData == NULL) { - return SHELL_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; } CustomCumulativeData->MinDur = PERF_MAXDUR; CustomCumulativeData->MaxDur = 0; CustomCumulativeData->Count = 0; CustomCumulativeData->Duration = 0; NameSize = StrLen (CustomCumulativeToken) + 1; CustomCumulativeData->Name = AllocateZeroPool (NameSize); if (CustomCumulativeData->Name == NULL) { - FreePool (CustomCumulativeData); - return SHELL_OUT_OF_RESOURCES; + ShellStatus = SHELL_OUT_OF_RESOURCES; + goto Done; } UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize); } // -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer
V2: Add function _INIT_OPHDR_COND () for variable initialization. Make code logic more clean. Previously _CLEAR_SAVED_OPHDR () is used for variable initialization, and we updated it to clean memory. But _CLEAR_SAVED_OPHDR () is still called for variable initialization. This will cause uninitialized pointer will be checked to free and cause unexpected issue. This patch is to add new function for variable initialization and keep _CLEAR_SAVED_OPHDR () to clean memory which is aligned with its function name. Cc: Eric Dong Cc: Liming Gao Cc: Gary Lin Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 23 --- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 4b0a43606ea..84dd2c3ed3f 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -4084,11 +4084,19 @@ vfrStatementInvalidSaveRestoreDefaults : // // Root expression extension function called by other function. // vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] : - << if ($RootLevel == 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!"); _CLEAR_SAVED_OPHDR ();} >> + << + if ($RootLevel == 0) { +mCIfrOpHdrIndex ++; +if (mCIfrOpHdrIndex >= MAX_IFR_EXPRESSION_DEPTH) { + _PCATCH (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the max supported level 8!"); +} +_INIT_OPHDR_COND (); + } + >> andTerm[$RootLevel, $ExpOpCount] ( L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount++; CIfrOr OObj(L->getLine()); >> )* << @@ -4988,10 +4996,11 @@ private: CIfrOpHeader * mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH]; UINT32 mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH]; UINT8 mCIfrOpHdrIndex; VOID_SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, UINT32 LineNo = 0); VOID_CLEAR_SAVED_OPHDR (VOID); + VOID_INIT_OPHDR_COND (VOID); BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID); EFI_VARSTORE_INFO mCurrQestVarInfo; EFI_GUID*mOverrideClassGuid; @@ -5077,20 +5086,28 @@ EfiVfrParser::_SAVE_OPHDR_COND ( mCIfrOpHdr[mCIfrOpHdrIndex] = new CIfrOpHeader(OpHdr); mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = LineNo; } } +VOID +EfiVfrParser::_INIT_OPHDR_COND ( + VOID + ) +{ + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; + mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; +} + VOID EfiVfrParser::_CLEAR_SAVED_OPHDR ( VOID ) { if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) { delete mCIfrOpHdr[mCIfrOpHdrIndex]; -mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; +mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; } - mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; } BOOLEAN EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( VOID -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] BaseTools/VfrCompile: Avoid using uninitialized pointer
_CLEAR_SAVED_OPHDR () is used for initialize the variables. We should not update it to free memory. It will cause some pointer used before initialization. This patch is to fix this issue. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 4b0a43606ea..cc042ab4307 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -4103,12 +4103,15 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] : } } } if ($RootLevel == 0) { -_CLEAR_SAVED_OPHDR (); -mCIfrOpHdrIndex --; +if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) { + delete mCIfrOpHdr[mCIfrOpHdrIndex]; + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; +} + mCIfrOpHdrIndex --; } >> ; // @@ -5082,14 +5085,11 @@ EfiVfrParser::_SAVE_OPHDR_COND ( VOID EfiVfrParser::_CLEAR_SAVED_OPHDR ( VOID ) { - if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) { -delete mCIfrOpHdr[mCIfrOpHdrIndex]; -mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; - } + mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; } BOOLEAN EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] UefiCpuPkg/PiSmmCpuDxeSmm: Add "extern" keyword for "gPatchxxx"
Background description: In SmmProfileInternal.h, ECC check tool report an issue at line 103. Detailed ECC Error info:Variable definition appears in header file. Include files should contain only public or only private data and cannot contain code or define data variables ECC report similar issues in PiSmmCpuDxeSmm.h. Then we review all the new introduced "gPatchxxx", since they have been defined in the nasm file, we can add "extern" keyword for them in the C source or header files. Cc: Eric Dong Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 8 UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h | 2 +- UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 6 +++--- UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index 1d016594e02..bcfbab51144 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -295,16 +295,16 @@ WriteSaveStateRegister ( IN CONST VOID *Buffer ); extern CONST UINT8 gcSmmInitTemplate[]; extern CONST UINT16 gcSmmInitSize; -X86_ASSEMBLY_PATCH_LABELgPatchSmmCr0; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr0; extern UINT32 mSmmCr0; -X86_ASSEMBLY_PATCH_LABELgPatchSmmCr3; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr3; extern UINT32 mSmmCr4; -X86_ASSEMBLY_PATCH_LABELgPatchSmmCr4; -X86_ASSEMBLY_PATCH_LABELgPatchSmmInitStack; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr4; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmmInitStack; /** Semaphore operation for all processor relocate SMMBase. **/ VOID diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h index 1613e9cd5cb..662814412b2 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h @@ -98,11 +98,11 @@ typedef struct { } SMM_PROFILE_ENTRY; extern SMM_S3_RESUME_STATE *mSmmS3ResumeState; extern UINTN gSmiExceptionHandlers[]; extern BOOLEAN mXdSupported; -X86_ASSEMBLY_PATCH_LABEL gPatchXdSupported; +extern X86_ASSEMBLY_PATCH_LABEL gPatchXdSupported; extern UINTN *mPFEntryCount; extern UINT64(*mLastPFEntryValue)[MAX_PF_ENTRY_COUNT]; extern UINT64*(*mLastPFEntryPointer)[MAX_PF_ENTRY_COUNT]; // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c index 5c2eb9ab6a1..dddc2f12325 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c @@ -103,13 +103,13 @@ typedef struct { } CPU_SMM_SAVE_STATE_IO_WIDTH; /// /// Variables from SMI Handler /// -X86_ASSEMBLY_PATCH_LABEL gPatchSmbase; -X86_ASSEMBLY_PATCH_LABEL gPatchSmiStack; -X86_ASSEMBLY_PATCH_LABEL gPatchSmiCr3; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmbase; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmiStack; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmiCr3; extern volatile UINT8gcSmiHandlerTemplate[]; extern CONST UINT16 gcSmiHandlerSize; // // Variables used by SMI Handler diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c index 87f595ddb8c..dfee5416161 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/Semaphore.c @@ -13,12 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "PiSmmCpuDxeSmm.h" -X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32; -X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32; +extern X86_ASSEMBLY_PATCH_LABEL gPatchSmmRelocationOriginalAddressPtr32; +extern X86_ASSEMBLY_PATCH_LABEL gPatchRebasedFlagAddr32; UINTN mSmmRelocationOriginalAddress; volatile BOOLEAN *mRebasedFlag; /** -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 1/3] MdeModulePkg/UiApp: Signal event when enter/exit setup menu
These changes are to support notify callbacks when enter/exit setup menu, since some driver may need to hook setup enter/exit points to do something. We will signal setup enter/exit events for all setup menu enter/exit cases.Then the module which pay attention to these events can execute the callback. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Application/UiApp/FrontPage.c| 4 +++- MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c | 3 ++- MdeModulePkg/Application/UiApp/UiApp.inf | 4 +++- MdeModulePkg/MdeModulePkg.dec | 6 ++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Application/UiApp/FrontPage.c b/MdeModulePkg/Application/UiApp/FrontPage.c index adee67a8ac1..e5d2cb00c62 100644 --- a/MdeModulePkg/Application/UiApp/FrontPage.c +++ b/MdeModulePkg/Application/UiApp/FrontPage.c @@ -1,9 +1,9 @@ /** @file FrontPage routines to handle the callbacks and browser calls -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -992,10 +992,11 @@ UiEntry ( REPORT_STATUS_CODE ( EFI_PROGRESS_CODE, (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_PC_USER_SETUP) ); + EfiEventGroupSignal(&gEdkiiSetupEnterGuid); // // Indicate if the connect all has been performed before. // If has not been performed before, do here. // if (!ConnectAllHappened) { @@ -1024,10 +1025,11 @@ UiEntry ( if (mLanguageString != NULL) { FreePool (mLanguageString); mLanguageString = NULL; } + EfiEventGroupSignal(&gEdkiiSetupExitGuid); // //Will leave browser, check any reset required change is applied? if yes, reset system // SetupResetReminder (); } diff --git a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c index 17fc3db507d..2c5f9d24204 100644 --- a/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c +++ b/MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c @@ -1,10 +1,10 @@ /** @file This library class defines a set of interfaces to customize Ui module -Copyright (c) 2016, Intel Corporation. All rights reserved. +Copyright (c) 2016 - 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 that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -232,10 +232,11 @@ UiSupportLibCallbackHandler ( case FRONT_PAGE_KEY_RESET: // // Reset // + EfiEventGroupSignal(&gEdkiiSetupExitGuid); gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); *Status = EFI_UNSUPPORTED; default: break; diff --git a/MdeModulePkg/Application/UiApp/UiApp.inf b/MdeModulePkg/Application/UiApp/UiApp.inf index d144462ce46..c212387e5be 100644 --- a/MdeModulePkg/Application/UiApp/UiApp.inf +++ b/MdeModulePkg/Application/UiApp/UiApp.inf @@ -1,9 +1,9 @@ ## @file # UiApp module is driver for BDS phase. # -# Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved. +# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # @@ -62,10 +62,12 @@ UefiBootManagerLib [Guids] gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode) gEfiIfrFrontPageGuid ## CONSUMES ## GUID + gEdkiiSetupEnterGuid ## CONSUMES ## GUID + gEdkiiSetupExitGuid ## CONSUMES ## GUID [Protocols] gEfiSmbiosProtocolGuid## CONSUMES gEfiHiiConfigAccessProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index cc397185f7b..e0bdf5ecdf3 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -407,10 +407,16 @@ gEdkiiEndOfS3ResumeGuid = { 0x96f5296d, 0x05f7, 0x4f3c, {0x84, 0x67, 0xe4, 0x56, 0x89, 0x0e, 0x0c, 0xb5 } } ## Include/Guid/S3SmmInitDone.h gEdkiiS3SmmInitDoneGuid = { 0x8f9d4825, 0x797d, 0x48fc, { 0x84, 0x71, 0x84, 0x50, 0x25, 0x79, 0x2e, 0xf6 } } + ## Guid used to create/s
[edk2] [patch 3/3] MdeModulePkg/BMUiLib: Signal event when enter/exit setup menu
These changes are to support notify callbacks when enter/exit setup menu, since some driver may need to hook setup enter/exit points to do something. We will signal setup enter/exit events for all setup menu enter/exit cases.Then the module which pay attention to these events can execute the callback. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Library/BootManagerUiLib/BootManager.c| 7 ++- MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c index 8e776327883..3dd4de06b16 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c @@ -1,9 +1,9 @@ /** @file The boot manager reference implementation -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 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 that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -823,10 +823,14 @@ BootManagerCallback ( // Clear the screen before. // gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->ClearScreen (gST->ConOut); + // + // Signal the exit setup event before reset the system or boot to another boot option. + // + EfiEventGroupSignal(&gEdkiiSetupExitGuid); // //check any reset required change is applied? if yes, reset system // BmSetupResetReminder (); @@ -834,10 +838,11 @@ BootManagerCallback ( // parse the selected option // BmSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption[QuestionId - 1]); BmSetConsoleMode (TRUE); + EfiEventGroupSignal(&gEdkiiSetupEnterGuid); if (EFI_ERROR (BootOption[QuestionId - 1].Status)) { gST->ConOut->OutputString ( gST->ConOut, HiiGetString (gBootManagerPrivate.HiiHandle, STRING_TOKEN (STR_ANY_KEY_CONTINUE), NULL) diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf b/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf index 7983b079493..dbe99ca7018 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf @@ -1,9 +1,9 @@ ## @file # Boot Manager Library used by UiApp. # -# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials are licensed and made available under # the terms and conditions of the BSD License that accompanies this distribution. # The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php. # @@ -50,10 +50,12 @@ UefiBootManagerLib [Guids] gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode) gEfiIfrFrontPageGuid ## CONSUMES ## GUID + gEdkiiSetupEnterGuid ## CONSUMES ## GUID + gEdkiiSetupExitGuid ## CONSUMES ## GUID [Protocols] gEfiHiiConfigAccessProtocolGuid ## CONSUMES gEfiDevicePathToTextProtocolGuid ## CONSUMES gEdkiiFormBrowserEx2ProtocolGuid ## CONSUMES -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 2/3] MdeModulePkg/BMMUiLib: Signal event when enter/exit setup menu
These changes are to support notify callbacks when enter/exit setup menu, since some driver may need to hook setup enter/exit points to do something. We will signal setup enter/exit events for all setup menu enter/exit cases.Then the module which pay attention to these events can execute the callback. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf | 4 +++- MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c | 8 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf index def923b977d..e716e053777 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf @@ -1,9 +1,9 @@ ## @file # Boot Maintenance Manager Library used by UiApp. # -# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials are licensed and made available under # the terms and conditions of the BSD License that accompanies this distribution. # The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php. # @@ -80,10 +80,12 @@ ## SOMETIMES_CONSUMES ## Variable:L"ConOut" (The device path of console out device) ## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device) gEfiIfrTianoGuid ## SOMETIMES_CONSUMES ## GUID (Extended IFR Guid Opcode) gEfiIfrFrontPageGuid ## CONSUMES ## GUID gEfiIfrBootMaintenanceGuid## CONSUMES ## GUID + gEdkiiSetupEnterGuid ## CONSUMES ## GUID + gEdkiiSetupExitGuid ## CONSUMES ## GUID [Protocols] gEfiSimpleFileSystemProtocolGuid ## CONSUMES gEfiLoadFileProtocolGuid ## CONSUMES gEfiHiiConfigAccessProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c index 8680a51d78c..e3363b469ce 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c @@ -3,11 +3,11 @@ Include file system navigation, system handle selection Boot option manipulation -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -926,18 +926,24 @@ BootFromFile ( ); // // Since current no boot from removable media directly is allowed */ // gST->ConOut->ClearScreen (gST->ConOut); + +// +// Signal exit setup event berfore reset the system or boot to another boot option. +// +EfiEventGroupSignal(&gEdkiiSetupExitGuid); // // Check whether need to reset system. // BmmSetupResetReminder (); BmmSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption); BmmSetConsoleMode (TRUE); +EfiEventGroupSignal(&gEdkiiSetupEnterGuid); FreePool(FileName); EfiBootManagerFreeLoadOption (&BootOption); } -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 0/3] MdeModulePkg/UiApp: Signal event when enter/exit setup menu
These changes are to support notify callbacks when enter/exit setup menu, since some driver may need to hook setup enter/exit points to do something. We will signal setup enter/exit events for all setup menu enter/exit cases.Then the module which pay attention to these events can execute the callback. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Dandan Bi (3): MdeModulePkg/UiApp: Signal event when enter/exit setup menu MdeModulePkg/BMMUiLib: Signal event when enter/exit setup menu MdeModulePkg/BMUiLib: Signal event when enter/exit setup menu MdeModulePkg/Application/UiApp/FrontPage.c| 4 +++- MdeModulePkg/Application/UiApp/FrontPageCustomizedUiSupport.c | 3 ++- MdeModulePkg/Application/UiApp/UiApp.inf | 4 +++- .../BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf | 4 +++- MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c | 8 +++- MdeModulePkg/Library/BootManagerUiLib/BootManager.c | 7 ++- MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf| 4 +++- MdeModulePkg/MdeModulePkg.dec | 6 ++ 8 files changed, 33 insertions(+), 7 deletions(-) -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdeModulePkg/FPDT: Add error message for unsupported case
We have updated performance infrastructure in previous commits: between https://github.com/tianocore/edk2/commit/73fef64f14d1b97ae9bd4705df3becc022391eba and https://github.com/tianocore/edk2/commit/115eae650bfd2be2c2bc37360f4a755065e774c4 Update FPDT drivers to collect the performance data reported by gEdkiiFpdtExtendedFirmwarePerformanceGuid. The old implementation which collected performance data through gEfiFirmwarePerformanceGuid is not supported now. We should add error message to remind user for this unsupported case in case anyone use it by mistake. Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c| 3 +++ .../Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c| 5 + 2 files changed, 8 insertions(+) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index e5a38121e9d..e719e9e482c 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -552,10 +552,13 @@ FpdtStatusCodeListenerDxe ( } 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. // Status = EFI_UNSUPPORTED; diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c index d4ac849ed00..b011ec11030 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c @@ -104,10 +104,15 @@ FpdtStatusCodeListenerSmm ( ReleaseSpinLock (&mSmmFpdtLock); return EFI_SUCCESS; } + if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { +DEBUG ((DEBUG_ERROR, "FpdtStatusCodeListenerSmm: Performance data reported through gEfiFirmwarePerformanceGuid will not be collected by FirmwarePerformanceDataTableSmm\n")); +return EFI_UNSUPPORTED; + } + if ((Value != PcdGet32 (PcdProgressCodeS3SuspendStart)) && (Value != PcdGet32 (PcdProgressCodeS3SuspendEnd))) { return EFI_UNSUPPORTED; } -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 2/2] BaseTool/VfrCompile: make delete[] match with new[]
Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index 5cab7bbfa1a..d795ef01bda 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -3038,11 +3038,12 @@ CVfrQuestionDB::RegisterNewDateQuestion ( pNode[2]->mNext = mQuestionList; mQuestionList = pNode[0]; for (Index = 0; Index < 3; Index++) { if (VarIdStr[Index] != NULL) { - delete VarIdStr[Index]; + delete[] VarIdStr[Index]; + VarIdStr[Index] = NULL; } } gCFormPkg.DoPendingAssign (VarIdStr[0], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID)); gCFormPkg.DoPendingAssign (VarIdStr[1], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID)); @@ -3055,11 +3056,12 @@ Err: if (pNode[Index] != NULL) { delete pNode[Index]; } if (VarIdStr[Index] != NULL) { - delete VarIdStr[Index]; + delete[] VarIdStr [Index]; + VarIdStr [Index] = NULL; } } } VOID @@ -3214,11 +3216,12 @@ CVfrQuestionDB::RegisterNewTimeQuestion ( pNode[2]->mNext = mQuestionList; mQuestionList = pNode[0]; for (Index = 0; Index < 3; Index++) { if (VarIdStr[Index] != NULL) { - delete VarIdStr[Index]; + delete[] VarIdStr[Index]; + VarIdStr[Index] = NULL; } } gCFormPkg.DoPendingAssign (VarIdStr[0], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID)); gCFormPkg.DoPendingAssign (VarIdStr[1], (VOID *)&QuestionId, sizeof(EFI_QUESTION_ID)); @@ -3231,11 +3234,12 @@ Err: if (pNode[Index] != NULL) { delete pNode[Index]; } if (VarIdStr[Index] != NULL) { - delete VarIdStr[Index]; + delete[] VarIdStr[Index]; + VarIdStr[Index] = NULL; } } } VOID -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 1/2] BaseTools/VfrCompile:Fix memory leak issues
Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 32 ++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index d48072a8adf..4b0a43606ea 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@ -4103,10 +4103,11 @@ vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount = 0] : } } } if ($RootLevel == 0) { +_CLEAR_SAVED_OPHDR (); mCIfrOpHdrIndex --; } >> ; @@ -4387,10 +4388,16 @@ vareqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : ">" V5:Number<< ConstVal = _STOU16(V5->getText(), V5->getLine()); >> << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >> ) ) + << + if (VarIdStr != NULL) { + delete[] VarIdStr; + VarIdStr = NULL; + } + >> ; ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : << EFI_QUESTION_ID QId; @@ -4440,10 +4447,16 @@ ideqvalExp [UINT32 & RootLevel, UINT32 & ExpOpCount] : ">" V5:Number<< ConstVal = _STOU16(V5->getText(), V5->getLine()); >> << IdEqValDoSpecial ($ExpOpCount, L->getLine(), QId, VarIdStr, Mask, ConstVal, GREATER_THAN); >> ) ) + << + if (VarIdStr != NULL) { + delete[] VarIdStr; + VarIdStr = NULL; + } + >> ; ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << EFI_QUESTION_ID QId[2]; @@ -4492,10 +4505,20 @@ ideqidExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : ">" vfrQuestionDataFieldName[QId[1], Mask[1], VarIdStr[1], LineNo[1]] << IdEqIdDoSpecial ($ExpOpCount, L->getLine(), QId[0], VarIdStr[0], Mask[0], QId[1], VarIdStr[1], Mask[1], GREATER_THAN); >> ) ) + << + if (VarIdStr[0] != NULL) { + delete[] VarIdStr[0]; + VarIdStr[0] = NULL; + } + if (VarIdStr[1] != NULL) { + delete[] VarIdStr[1]; + VarIdStr[1] = NULL; + } + >> ; ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << UINT16 ListLen = 0; @@ -4531,10 +4554,14 @@ ideqvallistExp[UINT32 & RootLevel, UINT32 & ExpOpCount] : if (QId == EFI_QUESTION_ID_INVALID) { EILObj.SetQuestionId (QId, VarIdStr, LineNo); } $ExpOpCount++; } + if (VarIdStr != NULL) { +delete[] VarIdStr; +VarIdStr = NULL; + } >> ; questionref1Exp[UINT32 & RootLevel, UINT32 & ExpOpCount] : << @@ -5055,11 +5082,14 @@ EfiVfrParser::_SAVE_OPHDR_COND ( VOID EfiVfrParser::_CLEAR_SAVED_OPHDR ( VOID ) { - mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; + if (mCIfrOpHdr[mCIfrOpHdrIndex] != NULL) { +delete mCIfrOpHdr[mCIfrOpHdrIndex]; +mCIfrOpHdr[mCIfrOpHdrIndex] = NULL; + } mCIfrOpHdrLineNo[mCIfrOpHdrIndex] = 0; } BOOLEAN EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( -- 2.14.3.windows.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] OvmfPkg:Fix VS2012 build failure
Initialize local variable to suppress warning C4701/C4703: potentially uninitialized local variable/pointer variable. 1.In VirtualMemory.c: Read of "PageMapLevel4Entry" in SetMemoryEncDe() is only reached when "PageMapLevel4Entry" is got correctly. 2.In VirtioBlk.c: Reads (dereferences) of "BufferMapping" and "BufferDeviceAddress" in SynchronousRequest() are only reached if "BufferSize > 0" *and* we map the data buffer successfully. 3.In VirtioScsi.c: Reads (dereferences) of "InDataMapping" and "InDataDeviceAddress", in VirtioScsiPassThru() are only reached if "Packet->InTransferLength > 0", *and* we map the input buffer successfully. The similar reason for "OutDataMapping" and "OutDataDeviceAddress". Cc: Laszlo Ersek Cc: Ard Biesheuvel Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c | 7 ++- OvmfPkg/VirtioBlkDxe/VirtioBlk.c | 8 +++- OvmfPkg/VirtioScsiDxe/VirtioScsi.c | 10 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c index c1bfa35d7a..1f1225dd13 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/VirtualMemory.c @@ -1,10 +1,10 @@ /** @file Virtual Memory Management Services to set or clear the memory encryption bit - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. Copyright (c) 2017, AMD Incorporated. 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 @@ -594,10 +594,15 @@ SetMemoryEncDec ( UINT64 PgTableMask; UINT64 AddressEncMask; BOOLEANIsWpEnabled; RETURN_STATUS Status; + // + // Set LocalVariable to suppress incorrect compiler/analyzer warnigns. + // + PageMapLevel4Entry = NULL; + DEBUG (( DEBUG_VERBOSE, "%a:%a: Cr3Base=0x%Lx Physical=0x%Lx Length=0x%Lx Mode=%a CacheFlush=%u\n", gEfiCallerBaseName, __FUNCTION__, diff --git a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c index 5559884345..653715fb7b 100644 --- a/OvmfPkg/VirtioBlkDxe/VirtioBlk.c +++ b/OvmfPkg/VirtioBlkDxe/VirtioBlk.c @@ -9,11 +9,11 @@ - Although the non-blocking interfaces of EFI_BLOCK_IO2_PROTOCOL could be a good match for multiple in-flight virtio-blk requests, we stick to synchronous requests and EFI_BLOCK_IO_PROTOCOL for now. Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012 - 2016, Intel Corporation. All rights reserved. + Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved. Copyright (c) 2017, AMD Inc, 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 @@ -262,10 +262,16 @@ SynchronousRequest ( EFI_STATUS Status; EFI_STATUS UnmapStatus; BlockSize = Dev->BlockIoMedia.BlockSize; + // + // Set LocalVariable to suppress incorrect compiler/analyzer warnigns. + // + BufferMapping = NULL; + BufferDeviceAddress = 0; + // // ensured by VirtioBlkInit() // ASSERT (BlockSize > 0); ASSERT (BlockSize % 512 == 0); diff --git a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c index 1a68f06210..81aa89e6d9 100644 --- a/OvmfPkg/VirtioScsiDxe/VirtioScsi.c +++ b/OvmfPkg/VirtioScsiDxe/VirtioScsi.c @@ -24,11 +24,11 @@ VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET could be a good match. That would however require client code for the control queue, which is deemed unreasonable for now. Copyright (C) 2012, Red Hat, Inc. - Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved. + Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved. Copyright (c) 2017, AMD Inc, 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 @@ -453,10 +453,18 @@ VirtioScsiPassThru ( EFI_PHYSICAL_ADDRESS OutDataDeviceAddress; VOID *InDataBuffer; UINTN InDataNumPages; BOOLEAN OutDataBufferIsMapped; + // + // Set LocalVariable to suppress incorrect
[edk2] [patch] MdeModulePkg: Fix coding style issues in file/function comments
Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Include/Protocol/BootLogo2.h| 2 +- MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf | 1 + MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c | 12 +--- MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c| 4 ++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/MdeModulePkg/Include/Protocol/BootLogo2.h b/MdeModulePkg/Include/Protocol/BootLogo2.h index 583a253..905197a 100644 --- a/MdeModulePkg/Include/Protocol/BootLogo2.h +++ b/MdeModulePkg/Include/Protocol/BootLogo2.h @@ -1,6 +1,6 @@ -/** +/** @file Boot Logo 2 Protocol is used to convey information of Logo dispayed during boot. The Boot Logo 2 Protocol is a replacement for the Boot Logo Protocol. If a platform produces both the Boot Logo 2 Protocol and the Boot Logo Protocol then the Boot Logo 2 Protocol must be used instead of the Boot Logo Protocol. diff --git a/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf b/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf index 02c3fae..2ee2e7e 100644 --- a/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf +++ b/MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf @@ -1,6 +1,7 @@ ## @file +# Base library to support BMP graphics image conversion. # # Provides services to convert a BMP graphics image to a GOP BLT buffer and # from a GOP BLT buffer to a BMP graphics image. # # Copyright (c) 2017, Microsoft Corporation diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c index b98430e..3da4a62 100644 --- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c +++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmp.c @@ -36,13 +36,16 @@ #include #include #include #include -// -// Print ESRT to debug console -// +/** + Print ESRT to debug console. + + @param[in] Table Pointer to the ESRT table. + +**/ VOID EFIAPI PrintTable ( IN EFI_SYSTEM_RESOURCE_TABLE *Table ); @@ -130,10 +133,13 @@ IsSystemFmp ( /** Function to create a single ESRT Entry and add it to the ESRT given a FMP descriptor. If the guid is already in the ESRT it will be ignored. The ESRT will grow if it does not have enough room. + @param[in] FmpImageInfoBufPointer to the EFI_FIRMWARE_IMAGE_DESCRIPTOR. + @param[in] FmpVersion FMP Version. + @return Status code. **/ EFI_STATUS EFIAPI diff --git a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c index b4e5135..8e60385 100644 --- a/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c +++ b/MdeModulePkg/Universal/EsrtFmpDxe/EsrtFmpDebugPrint.c @@ -32,11 +32,11 @@ #include #include #include /** - Function to print a single ESRT Entry (ESRE) to the debug console + Function to print a single ESRT Entry (ESRE) to the debug console. Print Format: | ---- | | 0x | 0x | 0x | 0x | 0x | @param[in] Entry - Pointer to an ESRE entry @@ -99,11 +99,11 @@ PrintOutEsrtEntry ( return EFI_SUCCESS; } /** - Function to print the ESRT table to the debug console + Function to print the ESRT table to the debug console. @param[in] Table - Pointer to the ESRT table **/ VOID EFIAPI -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] UefiCpuPkg/CpuCommonFeaturesLib: Fix coding style issue
Boolean values do not need to use explicit comparisons to TRUE or FALSE. Cc: Eric Dong Cc: Laszlo Ersek Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c index cc64dbb..27ca911 100644 --- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c +++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c @@ -138,11 +138,11 @@ McaInitialize ( ) { MSR_IA32_MCG_CAP_REGISTER McgCap; UINT32 BankIndex; - if (State == TRUE) { + if (State) { McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP); for (BankIndex = 0; BankIndex < (UINT32) McgCap.Bits.Count; BankIndex++) { CPU_REGISTER_TABLE_WRITE64 ( ProcessorNumber, Msr, -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] SecurityPkg/SmmTcg2PhysicalPresenceLib: Fix coding style issue
Boolean values do not need to use explicit comparisons to TRUE or FALSE. Cc: Chao Zhang Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c index dfef6c8..6a4dce9 100644 --- a/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c +++ b/SecurityPkg/Library/SmmTcg2PhysicalPresenceLib/SmmTcg2PhysicalPresenceLib.c @@ -339,11 +339,11 @@ Tcg2PhysicalPresenceLibGetUserConfirmationStatusFunction ( case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_ENABLE_BLOCK_SID_FUNC_FALSE: case TCG2_PHYSICAL_PRESENCE_SET_PP_REQUIRED_FOR_DISABLE_BLOCK_SID_FUNC_FALSE: break; default: - if (mIsTcg2PPVerLowerThan_1_3 == FALSE) { + if (!mIsTcg2PPVerLowerThan_1_3) { if (OperationRequest < TCG2_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) { // // TCG2 PP1.3 spec defined operations that are reserved or un-implemented // return TCG_PP_GET_USER_CONFIRMATION_NOT_IMPLEMENTED; -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdeModulePkg/DriverSampleDxe: Refine the sample case for UNION type
The example of UNION storage is not good, now update it. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h | 6 +++--- MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr| 14 ++ MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni | 6 +- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h index 6f092de..208a4c6 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -1,8 +1,8 @@ /** @file -Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -51,12 +51,12 @@ typedef struct { UINT8: 0; // Special width 0 can be used to force alignment at the next word boundary UINT8NestBitNumeric : 4; } MY_BITS_DATA; typedef union { - UINT16 BitField : 10; - UINT8ByteField; + UINT8UnionNumeric; + UINT8UnionNumericAlias; } MY_EFI_UNION_DATA; typedef struct { UINT16 MyStringData[40]; UINT16 SomethingHiddenForHtml; diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index b1017d9..9d99dcf 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -1,10 +1,10 @@ ///** @file // //Sample Setup formset. // -// Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +// Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. // This program and the accompanying materials // are licensed and made available under the terms and conditions of the BSD License // which accompanies this distribution. The full text of the license may be found at // http://opensource.org/licenses/bsd-license.php // @@ -913,30 +913,20 @@ formset endnumeric; subtitle text = STRING_TOKEN(STR_SUBTITLE_TEXT2); subtitle text = STRING_TOKEN(STR_UNION_EFI_VARSTORE); -numeric varid = MyEfiUnionVar.ByteField, +numeric varid = MyEfiUnionVar.UnionNumeric, prompt = STRING_TOKEN(STR_UNION_BYTE_NUMERIC_PROMPT), help= STRING_TOKEN(STR_UNION_BYTE_NUMERIC_HELP), minimum = 0, maximum = 20, step= 0, default = 7, defaultstore = MyStandardDefault, default = 8, defaultstore = MyManufactureDefault, endnumeric; -numeric varid = MyEfiUnionVar.BitField, -prompt = STRING_TOKEN(STR_UNION_BIT_NUMERIC_PROMPT), -help= STRING_TOKEN(STR_UNION_BIT_NUMERIC_HELP), -minimum = 0, -maximum = 20, -step= 0, -default = 7, defaultstore = MyStandardDefault, -default = 8, defaultstore = MyManufactureDefault, -endnumeric; - guidop guid = DRIVER_SAMPLE_FORMSET_GUID, datatype = MY_EFI_BITS_VARSTORE_DATA, data.EfiBitNumeric = 1, data.EfiBitOneof = 1, diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni index 7cc6a19..2215c08 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni @@ -1,8 +1,8 @@ // *++ // -// Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved. +// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. // This program and the accompanying materials // are licensed and made available under the terms and conditions of the BSD License // which accompanies this distribution. The full text of the license may be found at // http://opensource.org/licenses/bsd-license.php // @@ -330,14 +330,10 @@ #language fr-FR "The question refer to byte field in BIT structure" #string STR_UNION_BYTE_NUMERIC_PROMPT #language en-US "UNION EfiVarStore byte numeric" #language fr-FR "UNION EfiVarStore byte numeric" #string STR_UNION_BYTE_NUMERIC_HELP#language en-US "Question refer to byte field in UNION type efivastore, the Standard default is 7 Manufacture default is 8" #language fr-FR "Question refer
[edk2] [patch] MdeModulePkg: Fix incorrect commit introduced by commit SHA-1:052c98
The default value of PcdExtFpdtBootRecordPadSize is 0x2 But the following commit in master update it to 0 by mistake. SHA-1: 052c98ce246a1ffb0b4c5185a644aa9f902650f7 Subject: MdeModulePkg: Add ResetSystemPei PEIM This patch is to restore the value. Cc: Liming Gao Cc: Star Zeng Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/MdeModulePkg.dec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index ba05859..d1b1af5 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -1743,11 +1743,11 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosEntryPointProvideMethod|0x3|UINT32|0x00010069 ## This PCD specifies the additional pad size in FPDT Basic Boot Performance Table for # the extension FPDT boot records received after ReadyToBoot and before ExitBootService. # @Prompt Pad size for extension FPDT boot records. - gEfiMdeModulePkgTokenSpaceGuid.PcdExtFpdtBootRecordPadSize|0x0|UINT32|0x0001005F + gEfiMdeModulePkgTokenSpaceGuid.PcdExtFpdtBootRecordPadSize|0x2|UINT32|0x0001005F ## Indicates if ConIn device are connected on demand. # TRUE - ConIn device are not connected during BDS and ReadKeyStroke/ReadKeyStrokeEx produced # by Consplitter should be called before any real key read operation. # FALSE - ConIn device may be connected normally during BDS. -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdeModulePkg/DxeCorePerfLib: Add status check instead of ASSERT
Currently DxeCorePerformanceLib will get SMM performance data based on SMM communication handler. If SMM communication handler returns error, the library will ASSERT. In fact, if SMM perf data is not found. DXE perf data can still be dumped. So using status check instead of ASSERT is better. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 9b3224e..71d624f 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -281,13 +281,12 @@ AllocateBootPerformanceTable ( // Get the size of boot records. // 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) { +if (!EFI_ERROR (Status) && !EFI_ERROR (SmmCommData->ReturnStatus) && SmmCommData->BootRecordSize != 0) { // // Get all boot records // SmmCommData->Function = SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA_BY_OFFSET; SmmBootRecordDataSize = SmmCommData->BootRecordSize; @@ -315,11 +314,11 @@ AllocateBootPerformanceTable ( // // Prepare memory for Boot Performance table. // Boot Performance table includes BasicBoot record, and one or more appended Boot Records. // BootPerformanceDataSize = sizeof (BOOT_PERFORMANCE_TABLE) + mPerformanceLength + PcdGet32 (PcdExtFpdtBootRecordPadSize); - if (SmmCommData != NULL) { + if (SmmCommData != NULL && SmmBootRecordData != NULL) { BootPerformanceDataSize += SmmBootRecordDataSize; } // // Try to allocate the same runtime buffer as last time boot. -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 1/2] BaseTool/VfrCompile: make delete[] match with new[]
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=764 Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrCompiler.cpp | 14 +++--- BaseTools/Source/C/VfrCompile/VfrError.cpp | 2 +- BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp| 6 +++--- BaseTools/Source/C/VfrCompile/VfrSyntax.g | 14 +++--- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 8 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp index ff2a837..84c0e59 100644 --- a/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrCompiler.cpp @@ -1,10 +1,10 @@ /** @file VfrCompiler main class and main function. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -282,11 +282,11 @@ CVfrCompiler::AppendIncludePath ( strcat (IncludePaths, mOptions.IncludePaths); } strcat (IncludePaths, " -I "); strcat (IncludePaths, PathStr); if (mOptions.IncludePaths != NULL) { -delete mOptions.IncludePaths; +delete[] mOptions.IncludePaths; } mOptions.IncludePaths = IncludePaths; } VOID @@ -311,11 +311,11 @@ CVfrCompiler::AppendCPreprocessorOptions ( strcat (Opt, mOptions.CPreprocessorOptions); } strcat (Opt, " "); strcat (Opt, Options); if (mOptions.CPreprocessorOptions != NULL) { -delete mOptions.CPreprocessorOptions; +delete[] mOptions.CPreprocessorOptions; } mOptions.CPreprocessorOptions = Opt; } INT8 @@ -529,16 +529,16 @@ CVfrCompiler::~CVfrCompiler ( free (mOptions.RecordListFile); mOptions.RecordListFile = NULL; } if (mOptions.IncludePaths != NULL) { -delete mOptions.IncludePaths; +delete[] mOptions.IncludePaths; mOptions.IncludePaths = NULL; } if (mOptions.CPreprocessorOptions != NULL) { -delete mOptions.CPreprocessorOptions; +delete[] mOptions.CPreprocessorOptions; mOptions.CPreprocessorOptions = NULL; } SET_RUN_STATUS(STATUS_DEAD); } @@ -963,15 +963,15 @@ main ( if ((Status == STATUS_DEAD) || (Status == STATUS_FAILED)) { return 2; } if (gCBuffer.Buffer != NULL) { -delete gCBuffer.Buffer; +delete[] gCBuffer.Buffer; } if (gRBuffer.Buffer != NULL) { -delete gRBuffer.Buffer; +delete[] gRBuffer.Buffer; } return GetUtilityStatus (); } diff --git a/BaseTools/Source/C/VfrCompile/VfrError.cpp b/BaseTools/Source/C/VfrCompile/VfrError.cpp index 2366fac..14771a2 100644 --- a/BaseTools/Source/C/VfrCompile/VfrError.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrError.cpp @@ -75,11 +75,11 @@ CVfrErrorHandle::~CVfrErrorHandle ( ) { SVfrFileScopeRecord *pNode = NULL; if (mInputFileName != NULL) { -delete mInputFileName; +delete[] mInputFileName; } while (mScopeRecordListHead != NULL) { pNode = mScopeRecordListHead; mScopeRecordListHead = mScopeRecordListHead->mNext; diff --git a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp index 090ee13..b40bcdf 100644 --- a/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp @@ -142,11 +142,11 @@ CFormPkg::~CFormPkg () while (mBufferNodeQueueHead != NULL) { pBNode = mBufferNodeQueueHead; mBufferNodeQueueHead = mBufferNodeQueueHead->mNext; if (pBNode->mBufferStart != NULL) { - delete pBNode->mBufferStart; + delete[] pBNode->mBufferStart; delete pBNode; } } mBufferNodeQueueTail = NULL; mCurrBufferNode = NULL; @@ -1150,11 +1150,11 @@ CIfrRecordInfoDB::IfrRecordOutput ( { CHAR8 *Temp; SIfrRecord *pNode; if (TBuffer.Buffer != NULL) { -delete TBuffer.Buffer; +delete[] TBuffer.Buffer; } TBuffer.Size = 0; TBuffer.Buffer = NULL; @@ -2257,11 +2257,11 @@ CIfrObj::_EMIT_PENDING_OBJ ( // // update bin buffer to package data buffer // if (mObjBinBuf != NULL) { -delete mObjBinBuf; +delete[] mObjBinBuf; mObjBinBuf = ObjBinBuf; } mDelayEmit = FALSE; } diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g b/BaseTools/Source/C/VfrCompile/VfrSyntax.g index 4c7c6f2..d48072a 100644 --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g @@
[edk2] [patch 2/2] BaseTool/VfrCompile: Fix potential memory leak issue
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=771 Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp | 4 1 file changed, 4 insertions(+) diff --git a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp index 9bdc544..5cab7bb 100644 --- a/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp +++ b/BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp @@ -3502,10 +3502,14 @@ CVfrStringDB::SetStringFileName(IN CHAR8 *StringFileName) if (StringFileName == NULL) { return; } + if (mStringFileName != NULL) { +delete[] mStringFileName; + } + FileLen = strlen (StringFileName) + 1; mStringFileName = new CHAR8[FileLen]; if (mStringFileName == NULL) { return; } -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch v2] MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build failure
v2: Add [LibraryClasses] section in INF file and refine coding style. There are VS2015 NOOPT IA32 build failure like below in BaseSafeIntLib. XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allmul XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allshl XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __aullshr This patch replaces direct shift/multiplication of 64-bit integer with related function call to fix these failure. Cc: Laszlo Ersek Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf | 3 +++ MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 9 + MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf index 20a83ed..8fbdafe 100644 --- a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf +++ b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf @@ -54,5 +54,8 @@ [Sources.EBC] SafeIntLibEbc.c [Packages] MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c index c5f13d7..e96327d 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c @@ -26,10 +26,11 @@ **/ #include #include +#include // // Magnitude of MIN_INT64 as expressed by a UINT64 number. // @@ -3371,12 +3372,12 @@ SafeUint64Mult ( // a * c must be 0 or there would be bits in the high 64-bits // a * d must be less than 2^32 or there would be bits in the high 64-bits // b * c must be less than 2^32 or there would be bits in the high 64-bits // then there must be no overflow of the resulting values summed up. // - DwordA = (UINT32)(Multiplicand >> 32); - DwordC = (UINT32)(Multiplier >> 32); + DwordA = (UINT32)RShiftU64 (Multiplicand, 32); + DwordC = (UINT32)RShiftU64 (Multiplier, 32); // // common case -- if high dwords are both zero, no chance for overflow // if ((DwordA == 0) && (DwordC == 0)) { @@ -3407,11 +3408,11 @@ SafeUint64Mult ( if ((ProductBC & 0x) == 0) { // // now sum them all up checking for overflow. // shifting is safe because we already checked for overflow above // - if (!RETURN_ERROR (SafeUint64Add (ProductBC << 32, ProductAD << 32, &UnsignedResult))) { + if (!RETURN_ERROR (SafeUint64Add (LShiftU64 (ProductBC, 32), LShiftU64 (ProductAD, 32), &UnsignedResult))) { // // b * d // ProductBD = (((UINT64)DwordB) *(UINT64)DwordD); @@ -4073,11 +4074,11 @@ SafeInt32Mult ( IN INT32 Multiplicand, IN INT32 Multiplier, OUT INT32 *Result ) { - return SafeInt64ToInt32 (((INT64)Multiplicand) *((INT64)Multiplier), Result); + return SafeInt64ToInt32 (MultS64x64 (Multiplicand, Multiplier), Result); } /** INT64 multiplication diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c index 18bfb9e..ce66a92 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c @@ -26,10 +26,11 @@ **/ #include #include +#include /** INT32 -> UINTN conversion Converts the value specified by Operand to a value specified by Result type @@ -547,8 +548,8 @@ SafeIntnMult ( IN INTN Multiplicand, IN INTN Multiplier, OUT INTN *Result ) { - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Result); + return SafeInt64ToIntn (MultS64x64 (Multiplicand, Multiplier), Result); } -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdePkg/BaseSafeIntLib: Fix VS2015 IA32 NOOPT build failure
There are VS2015 NOOPT IA32 build failure like below in BaseSafeIntLib. XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allmul XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __allshl XXX.lib(XXX.obj): error LNK2001: unresolved external symbol __aullshr This patch replaces direct shift/multiplication of 64-bit integer with related function call to fix these failure. Cc: Liming Gao Cc: Michael Kinney Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 9 + MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c index c5f13d7..ccffbb6 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c @@ -26,10 +26,11 @@ **/ #include #include +#include // // Magnitude of MIN_INT64 as expressed by a UINT64 number. // @@ -3371,12 +3372,12 @@ SafeUint64Mult ( // a * c must be 0 or there would be bits in the high 64-bits // a * d must be less than 2^32 or there would be bits in the high 64-bits // b * c must be less than 2^32 or there would be bits in the high 64-bits // then there must be no overflow of the resulting values summed up. // - DwordA = (UINT32)(Multiplicand >> 32); - DwordC = (UINT32)(Multiplier >> 32); + DwordA = (UINT32)RShiftU64 (Multiplicand, 32); + DwordC = (UINT32)RShiftU64 (Multiplier, 32); // // common case -- if high dwords are both zero, no chance for overflow // if ((DwordA == 0) && (DwordC == 0)) { @@ -3407,11 +3408,11 @@ SafeUint64Mult ( if ((ProductBC & 0x) == 0) { // // now sum them all up checking for overflow. // shifting is safe because we already checked for overflow above // - if (!RETURN_ERROR (SafeUint64Add (ProductBC << 32, ProductAD << 32, &UnsignedResult))) { + if (!RETURN_ERROR (SafeUint64Add (LShiftU64(ProductBC, 32), LShiftU64(ProductAD, 32), &UnsignedResult))) { // // b * d // ProductBD = (((UINT64)DwordB) *(UINT64)DwordD); @@ -4073,11 +4074,11 @@ SafeInt32Mult ( IN INT32 Multiplicand, IN INT32 Multiplier, OUT INT32 *Result ) { - return SafeInt64ToInt32 (((INT64)Multiplicand) *((INT64)Multiplier), Result); + return SafeInt64ToInt32 (MultS64x64((INT64)Multiplicand, (INT64)Multiplier), Result); } /** INT64 multiplication diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c index 18bfb9e..5e30db4 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c @@ -26,10 +26,11 @@ **/ #include #include +#include /** INT32 -> UINTN conversion Converts the value specified by Operand to a value specified by Result type @@ -547,8 +548,8 @@ SafeIntnMult ( IN INTN Multiplicand, IN INTN Multiplier, OUT INTN *Result ) { - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Result); + return SafeInt64ToIntn (MultS64x64((INT64)Multiplicand, (INT64)Multiplier), Result); } -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v2 4/7] MdeModulePkg/UefiBootManagerLib: Remove the useless pref codes
V2: Just update the commit message to reference the hash value of new new performance infrastructure. Our new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4) can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Liming Gao Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Ruiyu Ni --- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 27 +- .../Library/UefiBootManagerLib/BmPerformance.c | 317 - .../Library/UefiBootManagerLib/InternalBm.h| 17 -- .../UefiBootManagerLib/UefiBootManagerLib.inf | 4 +- 4 files changed, 26 insertions(+), 339 deletions(-) delete mode 100644 MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 6404233..ce19ae4 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -26,10 +26,33 @@ EFI_BOOT_MANAGER_LEGACY_BOOT mBmLegacyBoot = NULL; /// EFI_GUID mBmHardDriveBootVariableGuid = { 0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x08, 0xe2, 0x0e, 0x90, 0x6c, 0xb6, 0xde } }; EFI_GUID mBmAutoCreateBootOptionGuid = { 0x8108ac4e, 0x9f11, 0x4d59, { 0x85, 0x0e, 0xe2, 0x1a, 0x52, 0x2c, 0x59, 0xb2 } }; /** + + End Perf entry of BDS + + @param Event The triggered event. + @param Context Context for this event. + +**/ +VOID +EFIAPI +BmEndOfBdsPerfCode ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Record the performance data for End of BDS + // + PERF_END(NULL, "BDS", NULL, 0); + + return ; +} + +/** The function registers the legacy boot support capabilities. @param RefreshLegacyBootOption The function pointer to create all the legacy boot options. @param LegacyBoot The function pointer to boot the legacy boot option. **/ @@ -1828,11 +1851,11 @@ EfiBootManagerBoot ( // // Create an event to be signalled when Legacy Boot occurs to write performance data. // Status = EfiCreateEventLegacyBootEx( TPL_NOTIFY, - BmWriteBootToOsPerformanceData, + BmEndOfBdsPerfCode, NULL, &LegacyBootEvent ); ASSERT_EFI_ERROR (Status); ); @@ -1869,11 +1892,11 @@ EfiBootManagerBoot ( // // Write boot to OS performance data for UEFI boot // PERF_CODE ( -BmWriteBootToOsPerformanceData (NULL, NULL); +BmEndOfBdsPerfCode (NULL, NULL); ); REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderStart)); Status = gBS->StartImage (ImageHandle, &BootOption->ExitDataSize, &BootOption->ExitData); diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c deleted file mode 100644 index 4d4495b..000 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c +++ /dev/null @@ -1,317 +0,0 @@ -/** @file - This file include the file which can help to get the system - performance, all the function will only include if the performance - switch is set. - -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "InternalBm.h" - -PERF_HEADER mBmPerfHeader; -PERF_DATA mBmPerfData; -EFI_PHYSICAL_ADDRESS mBmAcpiLowMemoryBase = 0x0ULL; - -/** - Get the short verion of PDB file name to be - used in performance data logging. - - @param PdbFileName The long PDB file name. - @param GaugeString The output string to be logged by performance logger. - @param StringSize The buffer size of GaugeString in bytes. - -**/ -VOID -BmGetShortPdbFileName ( - IN CONST CHAR8 *PdbFileName, - OUT CHAR8 *GaugeString, - INUINTN StringSize - ) -{ - UINTN Index; - UINTN Index1; - UINTN StartIndex; - UINTN EndIndex; - - if (PdbFileName == NULL) { -AsciiStrCpyS (GaugeString, StringSize, " "); - } else { -StartIndex = 0; -for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++) - ; - -for (Index = 0; PdbFileName[Index] != 0; Index++) {
[edk2] [PATCH v2 7/7] Vlv2TbltDevicePkg/Override/GenericBdsLib:Remove useless Perf code
Our new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4) can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: David Wei Cc: Mang Guo Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/GenericBdsLib/BdsBoot.c| 29 +- .../Library/GenericBdsLib/GenericBdsLib.inf| 4 +- .../Library/GenericBdsLib/InternalBdsLib.h | 19 +- .../Library/GenericBdsLib/Performance.c| 358 - 4 files changed, 28 insertions(+), 382 deletions(-) delete mode 100644 Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c diff --git a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index 6ada862..282ab8e 100644 --- a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -1,9 +1,9 @@ /** @file BDS Lib functions which relate with create or process the boot option. -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -19,10 +19,33 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. BOOLEAN mEnumBootDevice = FALSE; EFI_HII_HANDLE gBdsLibStringPackHandle = NULL; /** + + End Perf entry of BDS + + @param Event The triggered event. + @param Context Context for this event. + +**/ +VOID +EFIAPI +BmEndOfBdsPerfCode ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Record the performance data for End of BDS + // + PERF_END(NULL, "BDS", NULL, 0); + + return ; +} + +/** The constructor function register UNI strings into imageHandle. It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. @param ImageHandle The firmware allocated handle for the EFI image. @@ -1695,11 +1718,11 @@ BdsLibDoLegacyBoot ( // // Create an event to be signalled when Legacy Boot occurs to write performance data. // Status = EfiCreateEventLegacyBootEx( TPL_NOTIFY, - WriteBootToOsPerformanceData, + BmEndOfBdsPerfCode, NULL, &LegacyBootEvent ); ASSERT_EFI_ERROR (Status); ); @@ -2434,11 +2457,11 @@ BdsLibBootViaBootOption ( // // Write boot to OS performance data for UEFI boot // PERF_CODE ( -WriteBootToOsPerformanceData (NULL, NULL); +BmEndOfBdsPerfCode (NULL, NULL); ); // // Report status code for OS Loader StartImage. // diff --git a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf index 33ca298..95a0023 100644 --- a/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf +++ b/Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf @@ -4,11 +4,11 @@ # General BDS defines and produce general interfaces for platform BDS driver including: # 1) BDS boot policy interface; # 2) BDS boot device connect interface; # 3) BDS Misc interfaces for mainting boot variable, ouput string, etc. # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved. +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # @@ -33,11 +33,10 @@ # VALID_ARCHITECTURES = IA32 X64 IPF EBC # [Sources] DevicePath.c - Performance.c BdsConnect.c BdsMisc.c BdsConsole.c BdsBoot.c InternalBdsLib.h @@ -95,11 +94,10 @@ ## SOMETIMES_PRODUCES ## Variable:L"ErrOut" # The device path of error out device ## SOMETIMES_PRODUCES ## Variable:L"BootCurrent" # The boot option of current boot ## SOMETIMES_PRODUCES ## Variable:L"BootNext"# The number of next boot option gEfiGlobalVariableGuid gEfiFileInfoGuid ## SOMETIMES_CONSUMES ## GUID - gPerformanceProtocolGui
[edk2] [PATCH v2 2/7] UefiCpuPkg/S3Resume: Remove useless pref code
V2: Just update the commit message to reference the hash value of new new performance infrastructure. Our new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4)can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Eric Dong Cc: Laszlo Ersek Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Laszlo Ersek --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 131 - .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 3 +- 2 files changed, 1 insertion(+), 133 deletions(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index d7d2a4d..4d77689 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -20,11 +20,10 @@ #include #include #include -#include #include #include #include #include #include @@ -284,136 +283,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries[] = { GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR mGdt = { sizeof (mGdtEntries) - 1, (UINTN) mGdtEntries }; -/** - Performance measure function to get S3 detailed performance data. - - This function will getS3 detailed performance data and saved in pre-reserved ACPI memory. -**/ -VOID -WriteToOsS3PerformanceData ( - VOID - ) -{ - EFI_STATUSStatus; - EFI_PHYSICAL_ADDRESS mAcpiLowMemoryBase; - PERF_HEADER *PerfHeader; - PERF_DATA *PerfData; - UINT64Ticker; - UINTN Index; - EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; - UINTN VarSize; - UINTN LogEntryKey; - CONST VOID*Handle; - CONST CHAR8 *Token; - CONST CHAR8 *Module; - UINT64StartTicker; - UINT64EndTicker; - UINT64StartValue; - UINT64EndValue; - BOOLEAN CountUp; - UINT64Freq; - - // - // Retrieve time stamp count as early as possible - // - Ticker = GetPerformanceCounter (); - - Freq = GetPerformanceCounterProperties (&StartValue, &EndValue); - - Freq = DivU64x32 (Freq, 1000); - - Status = PeiServicesLocatePpi ( - &gEfiPeiReadOnlyVariable2PpiGuid, - 0, - NULL, - (VOID **) &VariableServices - ); - if (EFI_ERROR (Status)) { -return; - } - - VarSize = sizeof (EFI_PHYSICAL_ADDRESS); - Status = VariableServices->GetVariable ( - VariableServices, - L"PerfDataMemAddr", - &gPerformanceProtocolGuid, - NULL, - &VarSize, - &mAcpiLowMemoryBase - ); - if (EFI_ERROR (Status)) { -DEBUG ((EFI_D_ERROR, "Fail to retrieve variable to log S3 performance data \n")); -return; - } - - PerfHeader = (PERF_HEADER *) (UINTN) mAcpiLowMemoryBase; - - if (PerfHeader->Signiture != PERFORMANCE_SIGNATURE) { -DEBUG ((EFI_D_ERROR, "Performance data in ACPI memory get corrupted! \n")); -return; - } - - // - // Record total S3 resume time. - // - if (EndValue >= StartValue) { -PerfHeader->S3Resume = Ticker - StartValue; -CountUp = TRUE; - } else { -PerfHeader->S3Resume = StartValue - Ticker; -CountUp = FALSE; - } - - // - // Get S3 detailed performance data - // - Index = 0; - LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( - LogEntryKey, - &Handle, - &Token, - &Module, - &StartTicker, - &EndTicker)) != 0) { -if (EndTicker != 0) { - PerfData = &PerfHeader->S3Entry[Index]; - - // - // Use File Handle to specify the different performance log for PEIM. - // File Handle is the base address of PEIM FFS file. - // - if ((AsciiStrnCmp (Token, "PEIM", PEI_PERFORMANCE_STRING_SIZE) == 0) && (Handle != NULL)) { -AsciiSPrint (PerfData->Tok
[edk2] [PATCH v2 3/7] MdeModulePkg/BdsDxe: Remove useless Pref Code
V2: Just update the commit message to reference the hash value of new new performance infrastructure. Our new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4) can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Liming Gao Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Ruiyu Ni --- MdeModulePkg/Universal/BdsDxe/Bds.h | 3 +- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 3 +- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 57 +--- 3 files changed, 3 insertions(+), 60 deletions(-) diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h b/MdeModulePkg/Universal/BdsDxe/Bds.h index 5658e61..63d961f 100644 --- a/MdeModulePkg/Universal/BdsDxe/Bds.h +++ b/MdeModulePkg/Universal/BdsDxe/Bds.h @@ -1,9 +1,9 @@ /** @file Head file for BDS Architectural Protocol implementation -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -16,11 +16,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define _BDS_MODULE_H_ #include #include #include -#include #include #include #include #include diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf index a00b442..b8c5aa9 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf @@ -3,11 +3,11 @@ # # When DxeCore dispatching all DXE driver, this module will produce architecture protocol # gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry # interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered. # -# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved. +# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # @@ -76,11 +76,10 @@ ## SOMETIMES_CONSUMES ## Variable:L"ConIn" (The device path of console in device) ## SOMETIMES_CONSUMES ## Variable:L"ConOut" (The device path of console out device) ## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device) gConnectConInEventGuid## SOMETIMES_CONSUMES ## Event gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID - gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data) gEfiEventReadyToBootGuid ## CONSUMES ## Event [Protocols] gEfiBdsArchProtocolGuid ## PRODUCES gEfiSimpleTextInputExProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 2b24755..3191a98 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -3,11 +3,11 @@ When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed which contains interface of BdsEntry. After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked to enter BDS phase. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP (C) Copyright 2015 Hewlett-Packard Development Company, L.P. 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 @@ -633,61 +633,10 @@ BdsFormalizeEfiGlobalVariable ( // BdsFormalizeOSIndicationVariable (); } /** - - Allocate a block of memory that will contain performance data to OS. - -**/ -VOID -BdsAllocateMemoryForPerformanceData ( - VOID - ) -{ - EFI_STATUSStatus; - EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase; - EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; - - AcpiLowMemoryBase = 0x0ULL; - - //
[edk2] [PATCH v2 6/7] IntelFrameworkModulePkg/GenericBdsLib: Remove the useless Perf codes
Our new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4) can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/GenericBdsLib/BdsBoot.c| 29 +- .../Library/GenericBdsLib/GenericBdsLib.inf| 4 +- .../Library/GenericBdsLib/InternalBdsLib.h | 19 +- .../Library/GenericBdsLib/Performance.c| 313 - 4 files changed, 28 insertions(+), 337 deletions(-) delete mode 100644 IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c index d1da635..9c2d592 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsBoot.c @@ -1,9 +1,9 @@ /** @file BDS Lib functions which relate with create or process the boot option. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -17,10 +17,33 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. BOOLEAN mEnumBootDevice = FALSE; EFI_HII_HANDLE gBdsLibStringPackHandle = NULL; /** + + End Perf entry of BDS + + @param Event The triggered event. + @param Context Context for this event. + +**/ +VOID +EFIAPI +BmEndOfBdsPerfCode ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Record the performance data for End of BDS + // + PERF_END(NULL, "BDS", NULL, 0); + + return ; +} + +/** The constructor function register UNI strings into imageHandle. It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. @param ImageHandle The firmware allocated handle for the EFI image. @@ -1693,11 +1716,11 @@ BdsLibDoLegacyBoot ( // // Create an event to be signalled when Legacy Boot occurs to write performance data. // Status = EfiCreateEventLegacyBootEx( TPL_NOTIFY, - WriteBootToOsPerformanceData, + BmEndOfBdsPerfCode, NULL, &LegacyBootEvent ); ASSERT_EFI_ERROR (Status); ); @@ -2423,11 +2446,11 @@ BdsLibBootViaBootOption ( // // Write boot to OS performance data for UEFI boot // PERF_CODE ( -WriteBootToOsPerformanceData (NULL, NULL); +BmEndOfBdsPerfCode (NULL, NULL); ); // // Report status code for OS Loader StartImage. // diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf index 9d879c2..a9e0f51 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf @@ -4,11 +4,11 @@ # General BDS defines and produce general interfaces for platform BDS driver including: # 1) BDS boot policy interface; # 2) BDS boot device connect interface; # 3) BDS Misc interfaces for mainting boot variable, ouput string, etc. # -# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved. +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # @@ -33,11 +33,10 @@ # VALID_ARCHITECTURES = IA32 X64 IPF EBC # [Sources] DevicePath.c - Performance.c BdsConnect.c BdsMisc.c BdsConsole.c BdsBoot.c InternalBdsLib.h @@ -94,11 +93,10 @@ ## SOMETIMES_PRODUCES ## Variable:L"ErrOut" # The device path of error out device ## SOMETIMES_PRODUCES ## Variable:L"BootCurrent" # The boot option of current boot ## SOMETIMES_PRODUCES ## Variable:L"BootNext"# The number of next boot option gEfiGlobalVariableGuid gEfiFileInfoGuid ## SOMETIMES_CONSUMES ## GUID - gPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## Variable:L"PerfDataMemAddr" # The ACPI address of performance data gLastEnumLangGuid ## SOMETIMES_PRODUCES ## Variable:L"LastEnumLang" # Platform la
[edk2] [PATCH v2 5/7] IntelFrameworkModulePkg/BdsDxe: Remove the useless Perf codes
Our new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4) can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h | 3 +- .../Universal/BdsDxe/BdsDxe.inf| 3 +- .../Universal/BdsDxe/BdsEntry.c| 57 +- 3 files changed, 3 insertions(+), 60 deletions(-) diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h b/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h index 93bafd2..beb9226 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h @@ -1,9 +1,9 @@ /** @file Head file for BDS Architectural Protocol implementation -Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -34,11 +34,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include #include #include -#include #include #include #include #include #include diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf index 95a707c..92a4737 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf @@ -12,11 +12,11 @@ # EFI\BOOT\BOOTIA64.EFI file from selected boot device and transfer control to boot loader. # # BDSDxe also maintain the UI for "Boot Manager, Boot Maintaince Manager, Device Manager" which # is used for user to configure boot option or maintain hardware device. # -# Copyright (c) 2008 - 2015, Intel Corporation. All rights reserved. +# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # @@ -155,11 +155,10 @@ ## SOMETIMES_CONSUMES ## Event gConnectConInEventGuid gEfiFmpCapsuleGuid## SOMETIMES_CONSUMES ## GUID # FMP Capsule gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID gEfiUartDevicePathGuid## SOMETIMES_CONSUMES ## GUID (Identify the device path for UARD device) - gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data) [Protocols] gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES gEfiLoadFileProtocolGuid ## SOMETIMES_CONSUMES gEfiBdsArchProtocolGuid ## PRODUCES diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c index 6e3e5b0..9c5a91b 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/BdsEntry.c @@ -3,11 +3,11 @@ When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed which contains interface of BdsEntry. After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked to enter BDS phase. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -443,61 +443,10 @@ BdsFormalizeEfiGlobalVariable ( } /** - Allocate a block of memory that will contain performance data to OS. - -**/ -VOID -BdsAllocateMemoryForPerformanceData ( - VOID - ) -{ - EFI_STATUSStatus; - EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase; - EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; - - AcpiLowMemoryBase = 0x0ULL; - - // - // Allocate a block of memory that will contain performance data to OS. - // - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - EFI_SIZE_TO_PAGES (PERF_DATA_MAX_LENGTH), - &AcpiLowMemoryBase -
[edk2] [PATCH v2 0/7] Remove the useless pref codes
V2: a. Remove defintions related to old perf code and clean all useless perf codes in edk2 code base. b.Update commit message. Our new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4) can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS and related definitions. Cc: Star Zeng Cc: Liming Gao Cc: Ruiyu Ni Cc: Eric Dong Cc: Laszlo Ersek Cc: David Wei Cc: Mang Guo Dandan Bi (7): MdeModulePkg/Performance.h: Remove the useless definition UefiCpuPkg/S3Resume: Remove useless pref code MdeModulePkg/BdsDxe: Remove useless Pref Code MdeModulePkg/UefiBootManagerLib: Remove the useless pref codes IntelFrameworkModulePkg/BdsDxe: Remove the useless Perf codes IntelFrameworkModulePkg/GenericBdsLib: Remove the useless Perf codes Vlv2TbltDevicePkg/Override/GenericBdsLib:Remove useless Perf code .../Library/GenericBdsLib/BdsBoot.c| 29 +- .../Library/GenericBdsLib/GenericBdsLib.inf| 4 +- .../Library/GenericBdsLib/InternalBdsLib.h | 19 +- .../Library/GenericBdsLib/Performance.c| 313 -- IntelFrameworkModulePkg/Universal/BdsDxe/Bds.h | 3 +- .../Universal/BdsDxe/BdsDxe.inf| 3 +- .../Universal/BdsDxe/BdsEntry.c| 57 +--- MdeModulePkg/Include/Guid/Performance.h| 27 +- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 27 +- .../Library/UefiBootManagerLib/BmPerformance.c | 317 -- .../Library/UefiBootManagerLib/InternalBm.h| 17 - .../UefiBootManagerLib/UefiBootManagerLib.inf | 4 +- MdeModulePkg/Universal/BdsDxe/Bds.h| 3 +- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 3 +- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 57 +--- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 131 .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 3 +- .../Library/GenericBdsLib/BdsBoot.c| 29 +- .../Library/GenericBdsLib/GenericBdsLib.inf| 4 +- .../Library/GenericBdsLib/InternalBdsLib.h | 19 +- .../Library/GenericBdsLib/Performance.c| 358 - 21 files changed, 90 insertions(+), 1337 deletions(-) delete mode 100644 IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c delete mode 100644 MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c delete mode 100644 Vlv2TbltDevicePkg/Override/IntelFrameworkModulePkg/Library/GenericBdsLib/Performance.c -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v2 1/7] MdeModulePkg/Performance.h: Remove the useless definition
Remove the definitions related to old perf codes. Cc: Star Zeng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Include/Guid/Performance.h | 27 +-- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/MdeModulePkg/Include/Guid/Performance.h b/MdeModulePkg/Include/Guid/Performance.h index df40c6c..6e21ed0 100644 --- a/MdeModulePkg/Include/Guid/Performance.h +++ b/MdeModulePkg/Include/Guid/Performance.h @@ -2,11 +2,11 @@ This file defines performance-related definitions, including the format of: * performance GUID HOB. * performance protocol interfaces. * performance variables. -Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2009 - 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 that accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php. @@ -49,35 +49,10 @@ typedef struct { UINT32NumberOfEntries; ///< The number of all performance log entries. UINT32Reserved; } PEI_PERFORMANCE_LOG_HEADER; -// -// The data structure for performance data in ACPI memory. -// -#define PERFORMANCE_SIGNATURE SIGNATURE_32 ('P', 'e', 'r', 'f') -#define PERF_TOKEN_SIZE 28 -#define PERF_TOKEN_LENGTH (PERF_TOKEN_SIZE - 1) -#define PERF_PEI_ENTRY_MAX_NUM 50 -#define PERF_DATA_MAX_LENGTH0x4000 - -typedef struct { - CHAR8 Token[PERF_TOKEN_SIZE]; - UINT32 Duration; -} PERF_DATA; - -typedef struct { - UINT64BootToOs; - UINT64S3Resume; - UINT32S3EntryNum; - PERF_DATA S3Entry[PERF_PEI_ENTRY_MAX_NUM]; - UINT64CpuFreq; - UINT64BDSRaw; - UINT32Count; - UINT32Signiture; -} PERF_HEADER; - #define PERFORMANCE_PROTOCOL_GUID \ { 0x76b6bdfa, 0x2acd, 0x4462, { 0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 } } #define PERFORMANCE_EX_PROTOCOL_GUID \ { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2, 0x1, 0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } } -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdeModulePkg/PerfLib: Add NULL pointer check for "Token"
"Token" is passed through the perf entry, it's may be NULL. So we need to add NULL pointer check before reference it. Cc: Liming Gao Cc: Star Zeng Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 6 +- MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c | 6 +- MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c | 6 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 8363b0e..9b3224e 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -113,10 +113,14 @@ Check whether the Token is a known one which is uesed by core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token == NULL) { +return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) == 0 || AsciiStrCmp (Token, PEI_TOK) == 0 || AsciiStrCmp (Token, DXE_TOK) == 0 || AsciiStrCmp (Token, BDS_TOK) == 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || @@ -845,11 +849,11 @@ InsertFpdtMeasurement ( return Status; } // // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority. - // !!! Note: If the Pref is not the known Token used in the core but have same + // !!! Note: If the Perf is not the known Token used in the core but have same // ID with the core Token, this case will not be supported. // And in currtnt usage mode, for the unkown ID, there is a general rule: // If it is start pref: the lower 4 bits of the ID should be 0. // If it is end pref: the lower 4 bits of the ID should not be 0. // If input ID doesn't follow the rule, we will adjust it. diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 79b67e8..f770a35 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -47,10 +47,14 @@ Check whether the Token is a known one which is uesed by core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token == NULL) { +return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) == 0 || AsciiStrCmp (Token, PEI_TOK) == 0 || AsciiStrCmp (Token, DXE_TOK) == 0 || AsciiStrCmp (Token, BDS_TOK) == 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || @@ -264,11 +268,11 @@ InsertPeiFpdtMeasurement ( return Status; } // // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority. - // !!! Note: If the Pref is not the known Token used in the core but have same + // !!! Note: If the Perf is not the known Token used in the core but have same // ID with the core Token, this case will not be supported. // And in currtnt usage mode, for the unkown ID, there is a general rule: // If it is start pref: the lower 4 bits of the ID should be 0. // If it is end pref: the lower 4 bits of the ID should not be 0. // If input ID doesn't follow the rule, we will adjust it. diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 2834a68..dbc1166 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -83,10 +83,14 @@ Check whether the Token is a known one which is uesed by core. BOOLEAN IsKnownTokens ( IN CONST CHAR8 *Token ) { + if (Token == NULL) { +return FALSE; + } + if (AsciiStrCmp (Token, SEC_TOK) == 0 || AsciiStrCmp (Token, PEI_TOK) == 0 || AsciiStrCmp (Token, DXE_TOK) == 0 || AsciiStrCmp (Token, BDS_TOK) == 0 || AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || @@ -495,11 +499,11 @@ InsertFpdtMeasurement ( return Status; } // // If PERF_START()/PERF_END() have specified the ProgressID,it has high priority. - // !!! Note: If the Pref is not the known Token used in the core but have same + // !!! Note: If the Perf is not the known Token used in the core but have same // ID with the core Token, this case will not be supported. // And in currtnt usage mode, for the unkown ID, there is a general rule: // If it is start pref: the lower 4 bits of the ID should be 0. // If it is end pref: the lower 4 bits of the ID should not be 0. // If input ID doesn't follow the rule, we will adjust it. -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 2/2] ShellPkg/DP: Update the error message info
Make the error message clearer if fail to get ACPI/FPDT table. Cc: Liming Gao Cc: Jiewen Yao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 3 ++- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index 4dd7dd9..aa9c2cd 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -256,18 +256,20 @@ GetBootPerformanceTable ( &gEfiAcpi10TableGuid, &AcpiTable ); } if (EFI_ERROR(Status) || AcpiTable == NULL) { +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_TABLE_FAIL), mDpHiiHandle); return Status; } FirmwarePerformanceTable = FindAcpiPtr ( (EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable, EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE ); if (FirmwarePerformanceTable == NULL) { +ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle); return EFI_NOT_FOUND; } mBootPerformanceTable = (UINT8*) (UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer; mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *) mBootPerformanceTable)->Header.Length; @@ -737,11 +739,10 @@ RunDp ( // //1. Get FPDT from ACPI table. // Status = GetBootPerformanceTable (); if (EFI_ERROR(Status)) { -ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_BOOT_PERFORMANCE_TABLE_FAIL), mDpHiiHandle); return Status; } // //2. Cache the ModuleGuid and hanlde mapping table. diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni index b6069ae..c7eb0fb 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni @@ -88,11 +88,12 @@ #string STR_DP_RAW_VARS2 #language en-US "%5d: %16LX %16LX %16LX %31a %31a %5d\n" #string STR_DP_RAW_HEADR2 #language en-US "\nIndex Handle Start Count End Count Token Module ID\n" #string STR_DP_INCOMPLETE #language en-US " I " #string STR_DP_COMPLETE#language en-US " " #string STR_ALIT_UNKNOWN #language en-US "Unknown" -#string STR_DP_GET_BOOT_PERFORMANCE_TABLE_FAIL #language en-US "Fail to get boot performance table\n" +#string STR_DP_GET_ACPI_TABLE_FAIL #language en-US "Fail to get ACPI Table\n" +#string STR_DP_GET_ACPI_FPDT_FAIL #language en-US "Fail to get Firmware Performance Data Table (FPDT) in ACPI Table\n" #string STR_GET_HELP_DP #language en-US "" ".TH dp 0 "Display performance metrics"\r\n" ".SH NAME\r\n" "Displays performance metrics that are stored in memory.\r\n" -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 1/2] ShellPkg/Dp: Add null pointer check
Cc: Liming Gao Cc: Hao Wu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index fafc64f..4dd7dd9 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -255,11 +255,11 @@ GetBootPerformanceTable ( Status = EfiGetSystemConfigurationTable ( &gEfiAcpi10TableGuid, &AcpiTable ); } - if (EFI_ERROR(Status)) { + if (EFI_ERROR(Status) || AcpiTable == NULL) { return Status; } FirmwarePerformanceTable = FindAcpiPtr ( (EFI_ACPI_5_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable, -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdeModulePkg/DriverSampleDxe: Make bit fields aligned in C structure
For a structure with a series of bit fields and used as a storage in vfr file, and if the bit fields do not add up to the size of the defined type.In the C code use sizeof() to get size of the structure, the results may vary form the compiler(VS,GCC...). But the size of the storage calculated by VfrCompiler is fixed (calculate with alignment).To avoid the issue cased by above case, we need to make the total width of the bit fields in the structure aligned with the size of the defined type for these bit fields. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h index 40fb3d0..af3d4bc 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/NVDataStruc.h @@ -33,10 +33,18 @@ Revision History: #define CONFIGURATION_VARSTORE_ID0x1234 #define BITS_VARSTORE_ID 0x2345 #pragma pack(1) +// +// !!! For a structure with a series of bit fields and used as a storage in vfr file, and if the bit fields do not add up to the size of the defined type. +// In the C code use sizeof() to get the size the strucure, the results may vary form the compiler(VS,GCC...). +// But the size of the storage calculated by VfrCompiler is fixed (calculate with alignment). +// To avoid above case, we need to make the total bit width in the structure aligned with the size of the defined type for these bit fields. We can: +// 1. Add bit field (with/without name) with remianing with for padding. +// 2. Add unnamed bit field with 0 for padding, the amount of padding is determined by the alignment characteristics of the members of the structure. +// typedef struct { UINT16 NestByteField; UINT8: 1; // unamed field can be used for padding UINT8NestBitCheckbox : 1; UINT8NestBitOneof: 2; @@ -82,11 +90,13 @@ typedef struct { EFI_HII_TIME Time; UINT8 RefreshGuidCount; UINT8 Match2; UINT8 GetDefaultValueFromCallBackForOrderedList[3]; UINT8 BitCheckbox : 1; + UINT8 ReservedBits: 7; // Reserved bit fields for padding. UINT16 BitOneof: 6; + UINT16 : 0; // Width 0 used to force alignment. UINT16 BitNumeric : 12; MY_BITS_DATA MyBitData; MY_EFI_UNION_DATA MyUnionData; } DRIVER_SAMPLE_CONFIGURATION; @@ -107,10 +117,11 @@ typedef struct { MY_BITS_DATA BitsData; UINT32 EfiBitGrayoutTest : 5; UINT32 EfiBitNumeric : 4; UINT32 EfiBitOneof : 10; UINT32 EfiBitCheckbox: 1; + UINT32 : 0; // Width 0 used to force alignment. } MY_EFI_BITS_VARSTORE_DATA; // // Labels definition // -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v2] UefiCpuPkg/S3Resume: Add more perf entry for S3 phase
V2: Just update the commit message. Add more perf entry to hook BootScriptDonePpi/EndOfPeiPpi/ EndOfS3Resume. Add the new perf entry with Identifier PERF_INMODULE_START_ID/PERF_INMODULE_END_ID which are defined in new performance infrastructure (edk2 trunk commit hash value: SHA-1: 73fef64f14d1b97ae9bd4705df3becc022391eba ~ SHA-1: 115eae650bfd2be2c2bc37360f4a755065e774c4). PERF_INMODULE_START_ID/PERF_INMODULE_END_ID are general Identifier which are used within a module. Cc: Eric Dong Cc: Laszlo Ersek Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index b597ac7..d7d2a4d 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -2,11 +2,11 @@ This module produces the EFI_PEI_S3_RESUME2_PPI. This module works with StandAloneBootScriptExecutor to S3 resume to OS. This module will execute the boot script saved during last boot and after that, control is passed to OS waking up handler. - Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. Copyright (c) 2017, AMD Incorporated. 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 @@ -21,10 +21,11 @@ #include #include #include #include +#include #include #include #include #include #include @@ -551,13 +552,17 @@ S3ResumeBootOs ( PERF_END (NULL, "ScriptExec", NULL, 0); // // Install BootScriptDonePpi // + PERF_START_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_START_ID); + Status = PeiServicesInstallPpi (&mPpiListPostScriptTable); ASSERT_EFI_ERROR (Status); + PERF_END_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_END_ID); + // // Get ACPI Table Address // Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)); @@ -576,18 +581,26 @@ S3ResumeBootOs ( } // // Install EndOfPeiPpi // + PERF_START_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_START_ID); + Status = PeiServicesInstallPpi (&mPpiListEndOfPeiTable); ASSERT_EFI_ERROR (Status); + PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID); + // // Signal EndOfS3Resume event. // + PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID); + SignalEndOfS3Resume (); + PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID); + // // report status code on S3 resume // REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE); -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] MdeModulePkg/PciBusDxe: Fix VS2012 build failure
Initialize local variable to suppress warning C4703: potentially uninitialized local pointer variable. Cc: Star Zeng Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c index c48e3bb..13221b9 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c @@ -242,10 +242,12 @@ PciBusDriverBindingStart ( { EFI_STATUS Status; EFI_DEVICE_PATH_PROTOCOL*ParentDevicePath; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; + PciRootBridgeIo = NULL; + // // Check RemainingDevicePath validation // if (RemainingDevicePath != NULL) { // -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v5 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase
V3:Handle the case when string is empty in String Record. Updated to convert Pref entry to FPDT record in PEI phase and then report the records to DxeCorePerfLib through GUID hob. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 567 ++--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- 2 files changed, 382 insertions(+), 199 deletions(-) diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 62527b2..79b67e8 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -5,11 +5,11 @@ performance logging GUIDed HOB on the first performance logging and then logs the performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or PcdMaxPeiPerformanceLogEntries16. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,215 +20,448 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include -#include +#include #include #include #include #include #include #include #include +#define STRING_SIZE(FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE) /** - Gets the GUID HOB for PEI performance. +Check whether the Token is a known one which is uesed by core. - This internal function searches for the GUID HOB for PEI performance. - If that GUID HOB is not found, it will build a new one. - It outputs the data area of that GUID HOB to record performance log. +@param Token Pointer to a Null-terminated ASCII string - @paramPeiPerformanceLog Pointer to Pointer to PEI performance log header. - @paramPeiPerformanceIdArray Pointer to Pointer to PEI performance identifier array. +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. **/ -VOID -InternalGetPerformanceHobLog ( - OUT PEI_PERFORMANCE_LOG_HEADER**PeiPerformanceLog, - OUT UINT32**PeiPerformanceIdArray +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token ) { - EFI_HOB_GUID_TYPE *GuidHob; - UINTN PeiPerformanceSize; - UINT16 PeiPerformanceLogEntries; + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} - ASSERT (PeiPerformanceLog != NULL); - ASSERT (PeiPerformanceIdArray != NULL); +/** +Check whether the ID is a known one which map to the known Token. - PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ? - PcdGet16 (PcdMaxPeiPerformanceLogEntries16) : - PcdGet8 (PcdMaxPeiPerformanceLogEntries)); - GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid); +@param Identifier 32-bit identifier. - if (GuidHob != NULL) { -// -// PEI Performance HOB was found, then return the existing one. -// -*PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob); +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. -GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid); -ASSERT (GuidHob != NULL); -*PeiPerformanceIdArray = GET_GUID_HOB_DATA (GuidHob); +**/ +BOOLEAN +IsKnownID ( + IN UINT32 Identifier + ) +{ + if (Identifier == MODULE_START_ID || + Identifier == MODULE_END_ID || + Identifier == MODULE_LOADIMAGE_START_ID || + Identifier == MODULE_LOADIMAGE_END_ID || + Identifier == MODULE_DB_START_ID || + Identifier == MODULE_DB_END_ID || + Identifier == MODULE_DB_SUPPORT_START_ID || + Identifier == MODULE_DB_SUPPORT_END_ID || + Identifier == MODULE_DB_STOP_
[edk2] [PATCH v5 7/8] MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure
V3: a. Remove unused definitions b. Get records size form the records buffer when getting size action is triggered. V2: Update FirmwarePerformanceSmm to receive the address of performance records instead of records content. Receive buffer address of Boot performance records which are reported by SmmCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceSmm.c | 35 ++ .../FirmwarePerformanceSmm.inf | 1 + 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c index c750331..d4ac849 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c @@ -38,17 +38,16 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1000 +SMM_BOOT_PERFORMANCE_TABLE*mSmmBootPerformanceTable = NULL; EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol= NULL; UINT64mSuspendStartTime = 0; BOOLEAN mS3SuspendLockBoxSaved = FALSE; UINT32mBootRecordSize = 0; -UINT32mBootRecordMaxSize = 0; UINT8 *mBootRecordBuffer = NULL; SPIN_LOCK mSmmFpdtLock; BOOLEAN mSmramIsOutOfResource = FALSE; @@ -82,11 +81,10 @@ FpdtStatusCodeListenerSmm ( ) { EFI_STATUS Status; UINT64 CurrentTime; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; - UINT8*NewRecordBuffer; // // Check whether status code is what we are interested in. // if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { @@ -94,36 +92,18 @@ FpdtStatusCodeListenerSmm ( } // // Collect one or more Boot records in boot time // - if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { + if (Data != NULL && CompareGuid (&Data->Type, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) { AcquireSpinLock (&mSmmFpdtLock); - -if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { - // - // Try to allocate big SMRAM data to store Boot record. - // - if (mSmramIsOutOfResource) { -ReleaseSpinLock (&mSmmFpdtLock); -return EFI_OUT_OF_RESOURCES; - } - NewRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer); - if (NewRecordBuffer == NULL) { -ReleaseSpinLock (&mSmmFpdtLock); -mSmramIsOutOfResource = TRUE; -return EFI_OUT_OF_RESOURCES; - } - mBootRecordBuffer = NewRecordBuffer; - mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE; -} // -// Save boot record into the temp memory space. +// Get the boot performance data. // -CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size); -mBootRecordSize += Data->Size; - +CopyMem (&mSmmBootPerformanceTable, Data + 1, Data->Size); +mBootRecordBuffer = ((UINT8 *) (mSmmBootPerformanceTable)) + sizeof (SMM_BOOT_PERFORMANCE_TABLE); + ReleaseSpinLock (&mSmmFpdtLock); return EFI_SUCCESS; } if ((Value != PcdGet32 (PcdProgressCodeS3SuspendStart)) && @@ -237,10 +217,13 @@ FpdtSmiHandler ( Status = EFI_SUCCESS; switch (SmmCommData->Function) { case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE : + if (mSmmBootPerformanceTable != NULL) { +mBootRecordSize = mSmmBootPerformanceTable->Header.Length - sizeof (SMM_BOOT_PERFORMANCE_TABLE); + } SmmCommData->BootRecordSize = mBootRecordSize; break; case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA : Status = EFI_UNSUPPORTED; diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf index 724e7bc..cae0111 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf @@ -58,10 +58,11 @@ [Guids] ## SOMETIMES_PRODUCES ## UNDEFINED # SaveLockBox ## PRODUCES ## UNDEFINED # SmiHandlerRegister ## SOMETIMES_CONSUMES ## UNDEFINED # StatusCode Data gEfiFirmwarePerformanceGuid + gEdkiiFpdtExtendedFirmwarePerformanceGuid ## SOMETIMES_PRODUCES ## UNDEFINED # S
[edk2] [PATCH v5 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table
Cc: Liming Gao Cc: Star Zeng Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 5 +- .../DpDynamicCommand/DpDynamicCommand.inf | 5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h | 9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 ++-- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h | 8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 11 files changed, 724 insertions(+), 127 deletions(-) delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index 3ecc753..fafc64f 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -11,40 +11,64 @@ Measurement records contain identifying information (Handle, Token, Module) and start and end time values. Dp uses this information to group records in different ways. It also uses timer information to calculate elapsed time for each measurement. - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include "PerformanceTokens.h" #include "Dp.h" #include "Literals.h" #include "DpInternal.h" +#pragma pack(1) + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Entry; +} RSDT_TABLE; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 Entry; +} XSDT_TABLE; + +#pragma pack() + EFI_HANDLE mDpHiiHandle; +typedef struct { + EFI_HANDLEHandle; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP *mCacheHandleGuidTable; +UINTNmCachePairCount = 0; + // /// Module-Global Variables ///@{ CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; UINT64 mInterestThreshold; BOOLEAN mShowId = FALSE; +UINT8*mBootPerformanceTable; +UINTNmBootPerformanceTableSize; +BOOLEAN mPeiPhase = FALSE; +BOOLEAN mDxePhase = FALSE; PERF_SUMMARY_DATA SummaryData = { 0 };///< Create the SummaryData structure and init. to ZERO. - -/// Timer Specific Information. -TIMER_INFO TimerInfo; +MEASUREMENT_RECORD *mMeasurementList = NULL; +UINTN mMeasurementNum= 0; /// Items for which to gather cumulative statistics. PERF_CUM_DATA CumData[] = { PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK), PERF_INIT_CUM_DATA (START_IMAGE_TOK), @@ -98,10 +122,540 @@ DumpStatistics( void ) SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtrUnknown); } /** + This function scan ACPI table in RSDT. + + @param RsdtACPI RSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInRSDT ( + IN RSDT_TABLE *Rsdt, + IN UINT32 Signature + ) +{ + UINTN Index; + UINT32EntryCount; + UINT32*EntryPtr; + EFI_ACPI_DESCRIPTION_HEADER *Table; + + EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32); + + EntryPtr = &Rsdt->Entry; + for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) { +Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); +if (Table->Signature == Signature) { + return Table; +} + } + + return NULL; +} + +/** + This function scan ACPI table in XSDT. + + @param Xsdt ACPI XSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInXSDT ( + IN XSDT_TABLE *Xsdt, + IN UINT32 Signature + ) +{ + UINTNIndex; + UINT32 EntryCount; + UINT64 EntryPtr; + UINTNBasePtr; + EFI_ACPI_DESCRI
[edk2] [PATCH v5 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
V4: Update the GUID for status code in DxeCorePerformanceLib and FirmwarePerformanceDxe. V3:Add handling for the case when performance feature is not enabled. V2: Update FirmwarePerformanceDxe to receive the address of performance records instead of records content. 1. Remove the macro EXTENSION_RECORD_SIZE, since the extension size can be got through PcdExtFpdtBootRecordPadSize. 2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table 3. Copy SMM record accord to the allocated size 4. Receive Boot performance table address instead of contents which are reported DxeCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceDxe.c | 294 - .../FirmwarePerformanceDxe.inf | 5 +- 2 files changed, 52 insertions(+), 247 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index b004cac..e5a3812 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -3,11 +3,11 @@ This module register report status code listener to collect performance data for Firmware Basic Boot Performance Record and other boot performance records, and install FPDT to ACPI table. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -18,19 +18,17 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include #include @@ -40,26 +38,23 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1 -#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE) +#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)) EFI_RSC_HANDLER_PROTOCOL*mRscHandlerProtocol = NULL; BOOLEAN mLockBoxReady = FALSE; EFI_EVENT mReadyToBootEvent; 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 = { { EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE, @@ -327,186 +322,66 @@ InstallFirmwarePerformanceDataTable ( VOID ) { EFI_STATUSStatus; 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; - EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable; - EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion; - UINTN Index; - VOID *SmmBootRecordData; - UINTN SmmBootRecordDataSize; - UINTN ReservedMemSize; + UINTN Size; // // Get AcpiTable Protocol. // Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); if (EFI_ERROR (Status)) { return Status; } - // - // Collect boot records from SMM drivers. - // - SmmBootRecordCommBuffer = NULL; - SmmCommData = NULL; - SmmBootRecordData = NULL; - SmmBootRecordDataSize = 0; - ReservedMemSize = 0; - Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication); -
[edk2] [PATCH v5 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase
V3: a. Handle the case when string is empty in String Record. b. Use gEdkiiFpdtExtendedFirmwarePerformanceGuid to report status code. c. Refine the code logic. V2: Update SmmCorePerformanceLib to report the buffer address of boot performance records instead of records contents. Updated to convert Pref entry to FPDT record in SMM phase and then export records to FPDT table. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1068 .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- 3 files changed, 649 insertions(+), 440 deletions(-) diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index cd1f1a5..57a6240 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -14,11 +14,11 @@ This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation. -Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -28,30 +28,32 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "SmmCorePerformanceLibInternal.h" -// -// The data structure to hold global performance data. -// -GAUGE_DATA_HEADER *mGaugeData; +#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define FIRMWARE_RECORD_BUFFER0x1000 +#define CACHE_HANDLE_GUID_COUNT 0x1000 -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; +SMM_BOOT_PERFORMANCE_TABLE*mSmmBootPerformanceTable = NULL; -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; -BOOLEAN mPerformanceMeasurementEnabled; +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTNmCachePairCount = 0; -SPIN_LOCK mSmmPerfLock; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +BOOLEAN mFpdtDataIsReported = FALSE; +BOOLEAN mLackSpaceIsReport= FALSE; +CHAR8*mPlatformLanguage= NULL; +SPIN_LOCKmSmmFpdtLock; +PERFORMANCE_PROPERTY mPerformanceProperty; // // Interfaces for SMM Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -67,172 +69,630 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { StartGaugeEx, EndGaugeEx, GetGaugeEx }; -PERFORMANCE_PROPERTY mPerformanceProperty; +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} /** - Searches in the gauge array with keyword Handle, Token, Module and Identfier. +Check whether the ID is a known one which map to the known Token. - This internal function searches for the gauge entry in the gauge array. - If there is an entry that exactly matches the given keywords - and its end time stamp is zero, then the index of that gauge entry is returned; - otherwise, the the number of gauge entries in the array is returned. +@param Identifier 32-bit identifier. +@retval TRUEIs a known one used by core. +@re
[edk2] [PATCH v5 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
Add FPDT records into boot performance table for S3 phase Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf | 5 +- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c index e4800b7..9639fbc 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c @@ -3,11 +3,11 @@ Data Table in S3 resume boot mode. This module register report status code listener to collect performance data for S3 Resume Performance Record on S3 resume boot path. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -17,20 +17,24 @@ **/ #include #include +#include #include +#include +#include #include #include #include #include #include #include #include +#include /** Report status code listener for PEI. This is used to record the performance data for S3 FullResume in FPDT. @@ -68,10 +72,17 @@ FpdtStatusCodeListenerPei ( S3_PERFORMANCE_TABLE *AcpiS3PerformanceTable; EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD *AcpiS3ResumeRecord; UINT64 S3ResumeTotal; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD *AcpiS3SuspendRecord; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + UINT8*BootPerformanceTable; + FIRMWARE_PERFORMANCE_VARIABLEPerformanceVariable; + EFI_HOB_GUID_TYPE*GuidHob; + FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader; + UINT8*FirmwarePerformanceData; + UINT8*FirmwarePerformanceTablePtr; // // Check whether status code is what we are interested in. // if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) || @@ -128,10 +139,56 @@ FpdtStatusCodeListenerPei ( AcpiS3SuspendRecord->SuspendEnd = S3SuspendRecord.SuspendEnd; DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart)); DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd)); + Status = PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + ASSERT_EFI_ERROR (Status); + + // + // Update S3 boot records into the basic boot performance table. + // + VarSize = sizeof (PerformanceVariable); + Status = VariableServices->GetVariable ( + VariableServices, + EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, + &gEfiFirmwarePerformanceGuid, + NULL, + &VarSize, + &PerformanceVariable + ); + if (EFI_ERROR (Status)) { +return Status; + } + BootPerformanceTable = (UINT8*) (UINTN) PerformanceVariable.BootPerformanceTablePointer; + + // + // Dump PEI boot records + // + FirmwarePerformanceTablePtr = (BootPerformanceTable + sizeof (BOOT_PERFORMANCE_TABLE)); + GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid); + while (GuidHob != NULL) { +FirmwarePerformanceData = GET_GUID_HOB_DATA (GuidHob); +PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *) FirmwarePerformanceData; + +CopyMem (FirmwarePerformanceTablePtr, FirmwarePerformanceData + sizeof (FPDT_PEI_EXT_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries)); + +GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob)); + +FirmwarePerformanceTablePtr += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries); + } + + // + // Update Table length. + // + ((BOOT_PERFORMANCE_TABLE *) BootPerformanceTable)->Header.Length = (UINT32)((UINTN)FirmwarePerformanceTablePtr - (UINTN)BootPerformanceTable); + return EFI_SUCCESS; } /** Main entry for Firmware Performance Data Table PEIM. diff --git a/MdeModulePkg/Universal/Acpi/Fi
[edk2] [PATCH v5 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase
V4: a.Update the GUID for status code in DxeCorePerformanceLib and FirmwarePerformanceDxe. b. Add check for Insert FPDT record in DxeCorePerformanceLib to avoid re-entry case. V3: a. Handle the case when string is empty in String Record. b. refine the code logic. V2: Update DxecorePerformanceLib to report the boot performance table address instead of records contents. Updated to convert Pref entry to FPDT record in DXE phase and then allocate boot performance table to save the record and report the address of boot performance table to FirmwarePerformanceDxe. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1367 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- 3 files changed, 1086 insertions(+), 318 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 7c0e207..5cb020f 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -8,11 +8,11 @@ which are consumed by DxePerformanceLib to logging performance data in DXE phase. 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. -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -23,27 +23,65 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeCorePerformanceLibInternal.h" - // -// The data structure to hold global performance data. +// Data for FPDT performance records. // -GAUGE_DATA_HEADER*mGaugeData; +#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 0x1 +#define CACHE_HANDLE_GUID_COUNT 0x1000 + +BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL; +BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = { + { +EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE, +sizeof (BOOT_PERFORMANCE_TABLE) + }, + { +{ + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT,// Type + sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD),// Length + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT // Revision +}, +0, // Reserved +// +// These values will be updated at runtime. +// +0, // ResetEnd +0, // OsLoaderLoadImageStart +0, // OsLoaderStartImageStart +0, // ExitBootServicesEntry +0 // ExitBootServicesExit + } +}; -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTN mCachePairCount = 0; + +UINT32 mLoadImageCount = 0; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +UINT32 mBootRecordSize = 0; +UINT32 mBootRecordMaxSize= 0; + +BOOLEAN mFpdtBufferIsReported = FALSE; +BOOLEAN mLackSpaceIsReported = FALSE; +CHAR8 *mPlatformLanguage= NULL; +UINT8 *mPerformancePointer = NULL; +UINT8 *mBootRecordBuffer= NULL; +BOOLEAN mLockInsertRecord= FALSE; + +EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL; // // Interfaces for Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -61,179 +99,1047 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { GetGaugeEx }; PERFORMANCE_PROPERTY mPerformanceProperty; -// -// Gauge record lock to avoid data corruption or even memory overflow -// -STATIC EFI_LOCK mPerfRecordLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE
[edk2] [PATCH v5 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table
V5: Rename global variable LockInsertRecord to mLockInsertRecord. V4: a.Update the GUID for status code in DxeCorePerformanceLib and FirmwarePerformanceDxe. b. Add check for Insert FPDT record in DxeCorePerformanceLib to avoid re-entry case. V3: a. Add "FPDT_" prefix for related definitions in ExtendedFirmwarePerformance.h. b. Refine the code logic. V2: a. Update DxecorePerformanceLib/SmmCorePerformanceLib to report the boot performance table address instead of records contents. b. Update FirmwarePerformanceDxe/FirmwarePerformanceSmm to receive the address of performance records. This patch series also can be accessed at: https://github.com/dandanbi/edk2/tree/NewPerformanceInfrastructureV4 These patches are to update EDKII performance infrastructure to log and dump the performance entry as FPDT record in ACPI FPDT table.This new infrastructure can support to dump performance data in UEFI Shell and OS both. (1)PeiPerformanceLib/DxeCorePerformanceLib/SmmCorePerformanceLib log the performance entry as FPDT record. (2)FirmwarePerformancePei/FirmwarePerformanceDxe/FirmwarePerformanceSmm install the FPDT records to the ACPI table. (3)Update DP to dump the performance info from the FPDT records in FPDT table. Cc: Liming Gao Cc: Star Zeng Dandan Bi (7): MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure ShellPkg/Dp: Updated to dump perf log based on FPDT table Gao, Liming (1): MdeModulePkg:Add definitions for new Performance infrastructure .../Include/Guid/ExtendedFirmwarePerformance.h | 291 + MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1367 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 567 +--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1068 --- .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni |8 +- .../FirmwarePerformanceDxe.c | 294 + .../FirmwarePerformanceDxe.inf |5 +- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf |5 +- .../FirmwarePerformanceSmm.c | 35 +- .../FirmwarePerformanceSmm.inf |1 + ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h |7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |5 +- .../DpDynamicCommand/DpDynamicCommand.inf |5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h |9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 +- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h |8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 29 files changed, 3285 insertions(+), 1362 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v5 1/8] MdeModulePkg:Add definitions for new Performance infrastructure
From: "Gao, Liming" V3: Add "FPDT_" prefix for related definitions. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Signed-off-by: Dandan Bi --- .../Include/Guid/ExtendedFirmwarePerformance.h | 291 + MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni | 8 +- 4 files changed, 320 insertions(+), 3 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h new file mode 100644 index 000..f2db02d --- /dev/null +++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h @@ -0,0 +1,291 @@ +/** @file + This file defines edk2 extended firmware performance records. + These records will be added into ACPI FPDT Firmware Basic Boot Performance Table. + +Copyright (c) 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EXTENDED_FIRMWARE_PERFORMANCE_H__ +#define __EXTENDED_FIRMWARE_PERFORMANCE_H__ + +#include + +// +// Known performance tokens +// +#define SEC_TOK "SEC" ///< SEC Phase +#define DXE_TOK "DXE" ///< DXE Phase +#define PEI_TOK "PEI" ///< PEI Phase +#define BDS_TOK "BDS" ///< BDS Phase +#define DRIVERBINDING_START_TOK "DB:Start:" ///< Driver Binding Start() function call +#define DRIVERBINDING_SUPPORT_TOK "DB:Support:" ///< Driver Binding Support() function call +#define DRIVERBINDING_STOP_TOK "DB:Stop:"///< Driver Binding Stop() function call +#define LOAD_IMAGE_TOK "LoadImage:" ///< Load a dispatched module +#define START_IMAGE_TOK "StartImage:" ///< Dispatched Modules Entry Point execution +#define PEIM_TOK"PEIM"///< PEIM Modules Entry Point execution + +// +// Public Progress Identifiers for Event Records to map the above known token +// +#define MODULE_START_ID 0x01 +#define MODULE_END_ID 0x02 +#define MODULE_LOADIMAGE_START_ID 0x03 +#define MODULE_LOADIMAGE_END_ID 0x04 +#define MODULE_DB_START_ID 0x05 +#define MODULE_DB_END_ID0x06 +#define MODULE_DB_SUPPORT_START_ID 0x07 +#define MODULE_DB_SUPPORT_END_ID0x08 +#define MODULE_DB_STOP_START_ID 0x09 +#define MODULE_DB_STOP_END_ID 0x0A + +#define PERF_EVENTSIGNAL_START_ID 0x10 +#define PERF_EVENTSIGNAL_END_ID 0x11 +#define PERF_CALLBACK_START_ID 0x20 +#define PERF_CALLBACK_END_ID0x21 +#define PERF_FUNCTION_START_ID 0x30 +#define PERF_FUNCTION_END_ID0x31 +#define PERF_INMODULE_START_ID 0x40 +#define PERF_INMODULE_END_ID0x41 +#define PERF_CROSSMODULE_START_ID 0x50 +#define PERF_CROSSMODULE_END_ID 0x51 + +// +// Misc defines +// +#define FPDT_RECORD_REVISION_1 (0x01) + +// +// Length field in EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER is a UINT8, thus: +// +#define FPDT_MAX_PERF_RECORD_SIZE (MAX_UINT8) + +// +// FPDT Record Types +// +#define FPDT_GUID_EVENT_TYPE 0x1010 +#define FPDT_DYNAMIC_STRING_EVENT_TYPE 0x1011 +#define FPDT_DUAL_GUID_STRING_EVENT_TYPE 0x1012 +#define FPDT_GUID_QWORD_EVENT_TYPE 0x1013 +#define FPDT_GUID_QWORD_STRING_EVENT_TYPE 0x1014 + +// +// EDKII extended Fpdt record structures +// +#define FPDT_STRING_EVENT_RECORD_NAME_LENGTH 24 + +#pragma pack(1) +// +// FPDT Boot Performance Guid Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-zero value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock source. + /// If only one timestamp clock source is used, this field is Re
[edk2] [PATCH v4 7/8] MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure
V3: a. Remove unused definitions b. Get records size form the records buffer when getting size action is triggered. V2: Update FirmwarePerformanceSmm to receive the address of performance records instead of records content. Receive buffer address of Boot performance records which are reported by SmmCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceSmm.c | 35 ++ .../FirmwarePerformanceSmm.inf | 1 + 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c index c750331..d4ac849 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c @@ -38,17 +38,16 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1000 +SMM_BOOT_PERFORMANCE_TABLE*mSmmBootPerformanceTable = NULL; EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol= NULL; UINT64mSuspendStartTime = 0; BOOLEAN mS3SuspendLockBoxSaved = FALSE; UINT32mBootRecordSize = 0; -UINT32mBootRecordMaxSize = 0; UINT8 *mBootRecordBuffer = NULL; SPIN_LOCK mSmmFpdtLock; BOOLEAN mSmramIsOutOfResource = FALSE; @@ -82,11 +81,10 @@ FpdtStatusCodeListenerSmm ( ) { EFI_STATUS Status; UINT64 CurrentTime; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; - UINT8*NewRecordBuffer; // // Check whether status code is what we are interested in. // if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { @@ -94,36 +92,18 @@ FpdtStatusCodeListenerSmm ( } // // Collect one or more Boot records in boot time // - if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { + if (Data != NULL && CompareGuid (&Data->Type, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) { AcquireSpinLock (&mSmmFpdtLock); - -if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { - // - // Try to allocate big SMRAM data to store Boot record. - // - if (mSmramIsOutOfResource) { -ReleaseSpinLock (&mSmmFpdtLock); -return EFI_OUT_OF_RESOURCES; - } - NewRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer); - if (NewRecordBuffer == NULL) { -ReleaseSpinLock (&mSmmFpdtLock); -mSmramIsOutOfResource = TRUE; -return EFI_OUT_OF_RESOURCES; - } - mBootRecordBuffer = NewRecordBuffer; - mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE; -} // -// Save boot record into the temp memory space. +// Get the boot performance data. // -CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size); -mBootRecordSize += Data->Size; - +CopyMem (&mSmmBootPerformanceTable, Data + 1, Data->Size); +mBootRecordBuffer = ((UINT8 *) (mSmmBootPerformanceTable)) + sizeof (SMM_BOOT_PERFORMANCE_TABLE); + ReleaseSpinLock (&mSmmFpdtLock); return EFI_SUCCESS; } if ((Value != PcdGet32 (PcdProgressCodeS3SuspendStart)) && @@ -237,10 +217,13 @@ FpdtSmiHandler ( Status = EFI_SUCCESS; switch (SmmCommData->Function) { case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE : + if (mSmmBootPerformanceTable != NULL) { +mBootRecordSize = mSmmBootPerformanceTable->Header.Length - sizeof (SMM_BOOT_PERFORMANCE_TABLE); + } SmmCommData->BootRecordSize = mBootRecordSize; break; case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA : Status = EFI_UNSUPPORTED; diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf index 724e7bc..cae0111 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf @@ -58,10 +58,11 @@ [Guids] ## SOMETIMES_PRODUCES ## UNDEFINED # SaveLockBox ## PRODUCES ## UNDEFINED # SmiHandlerRegister ## SOMETIMES_CONSUMES ## UNDEFINED # StatusCode Data gEfiFirmwarePerformanceGuid + gEdkiiFpdtExtendedFirmwarePerformanceGuid ## SOMETIMES_PRODUCES ## UNDEFINED # S
[edk2] [PATCH v4 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
V4: Update the GUID for status code in DxeCorePerformanceLib and FirmwarePerformanceDxe. V3:Add handling for the case when performance feature is not enabled. V2: Update FirmwarePerformanceDxe to receive the address of performance records instead of records content. 1. Remove the macro EXTENSION_RECORD_SIZE, since the extension size can be got through PcdExtFpdtBootRecordPadSize. 2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table 3. Copy SMM record accord to the allocated size 4. Receive Boot performance table address instead of contents which are reported DxeCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceDxe.c | 294 - .../FirmwarePerformanceDxe.inf | 5 +- 2 files changed, 52 insertions(+), 247 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index b004cac..e5a3812 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -3,11 +3,11 @@ This module register report status code listener to collect performance data for Firmware Basic Boot Performance Record and other boot performance records, and install FPDT to ACPI table. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -18,19 +18,17 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include #include @@ -40,26 +38,23 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1 -#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE) +#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)) EFI_RSC_HANDLER_PROTOCOL*mRscHandlerProtocol = NULL; BOOLEAN mLockBoxReady = FALSE; EFI_EVENT mReadyToBootEvent; 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 = { { EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE, @@ -327,186 +322,66 @@ InstallFirmwarePerformanceDataTable ( VOID ) { EFI_STATUSStatus; 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; - EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable; - EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion; - UINTN Index; - VOID *SmmBootRecordData; - UINTN SmmBootRecordDataSize; - UINTN ReservedMemSize; + UINTN Size; // // Get AcpiTable Protocol. // Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); if (EFI_ERROR (Status)) { return Status; } - // - // Collect boot records from SMM drivers. - // - SmmBootRecordCommBuffer = NULL; - SmmCommData = NULL; - SmmBootRecordData = NULL; - SmmBootRecordDataSize = 0; - ReservedMemSize = 0; - Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication); -
[edk2] [PATCH v4 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase
V3: a. Handle the case when string is empty in String Record. b. Use gEdkiiFpdtExtendedFirmwarePerformanceGuid to report status code. c. Refine the code logic. V2: Update SmmCorePerformanceLib to report the buffer address of boot performance records instead of records contents. Updated to convert Pref entry to FPDT record in SMM phase and then export records to FPDT table. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1068 .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- 3 files changed, 649 insertions(+), 440 deletions(-) diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index cd1f1a5..57a6240 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -14,11 +14,11 @@ This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation. -Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -28,30 +28,32 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "SmmCorePerformanceLibInternal.h" -// -// The data structure to hold global performance data. -// -GAUGE_DATA_HEADER *mGaugeData; +#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define FIRMWARE_RECORD_BUFFER0x1000 +#define CACHE_HANDLE_GUID_COUNT 0x1000 -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; +SMM_BOOT_PERFORMANCE_TABLE*mSmmBootPerformanceTable = NULL; -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; -BOOLEAN mPerformanceMeasurementEnabled; +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTNmCachePairCount = 0; -SPIN_LOCK mSmmPerfLock; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +BOOLEAN mFpdtDataIsReported = FALSE; +BOOLEAN mLackSpaceIsReport= FALSE; +CHAR8*mPlatformLanguage= NULL; +SPIN_LOCKmSmmFpdtLock; +PERFORMANCE_PROPERTY mPerformanceProperty; // // Interfaces for SMM Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -67,172 +69,630 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { StartGaugeEx, EndGaugeEx, GetGaugeEx }; -PERFORMANCE_PROPERTY mPerformanceProperty; +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} /** - Searches in the gauge array with keyword Handle, Token, Module and Identfier. +Check whether the ID is a known one which map to the known Token. - This internal function searches for the gauge entry in the gauge array. - If there is an entry that exactly matches the given keywords - and its end time stamp is zero, then the index of that gauge entry is returned; - otherwise, the the number of gauge entries in the array is returned. +@param Identifier 32-bit identifier. +@retval TRUEIs a known one used by core. +@re
[edk2] [PATCH v4 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
Add FPDT records into boot performance table for S3 phase Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf | 5 +- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c index e4800b7..9639fbc 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c @@ -3,11 +3,11 @@ Data Table in S3 resume boot mode. This module register report status code listener to collect performance data for S3 Resume Performance Record on S3 resume boot path. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -17,20 +17,24 @@ **/ #include #include +#include #include +#include +#include #include #include #include #include #include #include #include +#include /** Report status code listener for PEI. This is used to record the performance data for S3 FullResume in FPDT. @@ -68,10 +72,17 @@ FpdtStatusCodeListenerPei ( S3_PERFORMANCE_TABLE *AcpiS3PerformanceTable; EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD *AcpiS3ResumeRecord; UINT64 S3ResumeTotal; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD *AcpiS3SuspendRecord; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + UINT8*BootPerformanceTable; + FIRMWARE_PERFORMANCE_VARIABLEPerformanceVariable; + EFI_HOB_GUID_TYPE*GuidHob; + FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader; + UINT8*FirmwarePerformanceData; + UINT8*FirmwarePerformanceTablePtr; // // Check whether status code is what we are interested in. // if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) || @@ -128,10 +139,56 @@ FpdtStatusCodeListenerPei ( AcpiS3SuspendRecord->SuspendEnd = S3SuspendRecord.SuspendEnd; DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart)); DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd)); + Status = PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + ASSERT_EFI_ERROR (Status); + + // + // Update S3 boot records into the basic boot performance table. + // + VarSize = sizeof (PerformanceVariable); + Status = VariableServices->GetVariable ( + VariableServices, + EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, + &gEfiFirmwarePerformanceGuid, + NULL, + &VarSize, + &PerformanceVariable + ); + if (EFI_ERROR (Status)) { +return Status; + } + BootPerformanceTable = (UINT8*) (UINTN) PerformanceVariable.BootPerformanceTablePointer; + + // + // Dump PEI boot records + // + FirmwarePerformanceTablePtr = (BootPerformanceTable + sizeof (BOOT_PERFORMANCE_TABLE)); + GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid); + while (GuidHob != NULL) { +FirmwarePerformanceData = GET_GUID_HOB_DATA (GuidHob); +PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *) FirmwarePerformanceData; + +CopyMem (FirmwarePerformanceTablePtr, FirmwarePerformanceData + sizeof (FPDT_PEI_EXT_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries)); + +GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob)); + +FirmwarePerformanceTablePtr += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries); + } + + // + // Update Table length. + // + ((BOOT_PERFORMANCE_TABLE *) BootPerformanceTable)->Header.Length = (UINT32)((UINTN)FirmwarePerformanceTablePtr - (UINTN)BootPerformanceTable); + return EFI_SUCCESS; } /** Main entry for Firmware Performance Data Table PEIM. diff --git a/MdeModulePkg/Universal/Acpi/Fi
[edk2] [PATCH v4 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table
Cc: Liming Gao Cc: Star Zeng Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 5 +- .../DpDynamicCommand/DpDynamicCommand.inf | 5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h | 9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 ++-- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h | 8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 11 files changed, 724 insertions(+), 127 deletions(-) delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index 3ecc753..fafc64f 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -11,40 +11,64 @@ Measurement records contain identifying information (Handle, Token, Module) and start and end time values. Dp uses this information to group records in different ways. It also uses timer information to calculate elapsed time for each measurement. - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include "PerformanceTokens.h" #include "Dp.h" #include "Literals.h" #include "DpInternal.h" +#pragma pack(1) + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Entry; +} RSDT_TABLE; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 Entry; +} XSDT_TABLE; + +#pragma pack() + EFI_HANDLE mDpHiiHandle; +typedef struct { + EFI_HANDLEHandle; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP *mCacheHandleGuidTable; +UINTNmCachePairCount = 0; + // /// Module-Global Variables ///@{ CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; UINT64 mInterestThreshold; BOOLEAN mShowId = FALSE; +UINT8*mBootPerformanceTable; +UINTNmBootPerformanceTableSize; +BOOLEAN mPeiPhase = FALSE; +BOOLEAN mDxePhase = FALSE; PERF_SUMMARY_DATA SummaryData = { 0 };///< Create the SummaryData structure and init. to ZERO. - -/// Timer Specific Information. -TIMER_INFO TimerInfo; +MEASUREMENT_RECORD *mMeasurementList = NULL; +UINTN mMeasurementNum= 0; /// Items for which to gather cumulative statistics. PERF_CUM_DATA CumData[] = { PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK), PERF_INIT_CUM_DATA (START_IMAGE_TOK), @@ -98,10 +122,540 @@ DumpStatistics( void ) SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtrUnknown); } /** + This function scan ACPI table in RSDT. + + @param RsdtACPI RSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInRSDT ( + IN RSDT_TABLE *Rsdt, + IN UINT32 Signature + ) +{ + UINTN Index; + UINT32EntryCount; + UINT32*EntryPtr; + EFI_ACPI_DESCRIPTION_HEADER *Table; + + EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32); + + EntryPtr = &Rsdt->Entry; + for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) { +Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); +if (Table->Signature == Signature) { + return Table; +} + } + + return NULL; +} + +/** + This function scan ACPI table in XSDT. + + @param Xsdt ACPI XSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInXSDT ( + IN XSDT_TABLE *Xsdt, + IN UINT32 Signature + ) +{ + UINTNIndex; + UINT32 EntryCount; + UINT64 EntryPtr; + UINTNBasePtr; + EFI_ACPI_DESCRI
[edk2] [PATCH v4 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase
V4: a.Update the GUID for status code in DxeCorePerformanceLib and FirmwarePerformanceDxe. b. Add check for Insert FPDT record in DxeCorePerformanceLib to avoid re-entry case. V3: a. Handle the case when string is empty in String Record. b. refine the code logic. V2: Update DxecorePerformanceLib to report the boot performance table address instead of records contents. Updated to convert Pref entry to FPDT record in DXE phase and then allocate boot performance table to save the record and report the address of boot performance table to FirmwarePerformanceDxe. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1367 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- 3 files changed, 1086 insertions(+), 318 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 7c0e207..5cb020f 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -8,11 +8,11 @@ which are consumed by DxePerformanceLib to logging performance data in DXE phase. 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. -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -23,27 +23,65 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeCorePerformanceLibInternal.h" - // -// The data structure to hold global performance data. +// Data for FPDT performance records. // -GAUGE_DATA_HEADER*mGaugeData; +#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 0x1 +#define CACHE_HANDLE_GUID_COUNT 0x1000 + +BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL; +BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = { + { +EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE, +sizeof (BOOT_PERFORMANCE_TABLE) + }, + { +{ + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT,// Type + sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD),// Length + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT // Revision +}, +0, // Reserved +// +// These values will be updated at runtime. +// +0, // ResetEnd +0, // OsLoaderLoadImageStart +0, // OsLoaderStartImageStart +0, // ExitBootServicesEntry +0 // ExitBootServicesExit + } +}; -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTN mCachePairCount = 0; + +UINT32 mLoadImageCount = 0; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +UINT32 mBootRecordSize = 0; +UINT32 mBootRecordMaxSize= 0; + +BOOLEAN mFpdtBufferIsReported = FALSE; +BOOLEAN mLackSpaceIsReported = FALSE; +CHAR8 *mPlatformLanguage= NULL; +UINT8 *mPerformancePointer = NULL; +UINT8 *mBootRecordBuffer= NULL; +BOOLEAN LockInsertRecord = FALSE; + +EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL; // // Interfaces for Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -61,179 +99,1047 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { GetGaugeEx }; PERFORMANCE_PROPERTY mPerformanceProperty; -// -// Gauge record lock to avoid data corruption or even memory overflow -// -STATIC EFI_LOCK mPerfRecordLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE
[edk2] [PATCH v4 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase
V3:Handle the case when string is empty in String Record. Updated to convert Pref entry to FPDT record in PEI phase and then report the records to DxeCorePerfLib through GUID hob. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 567 ++--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- 2 files changed, 382 insertions(+), 199 deletions(-) diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 62527b2..79b67e8 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -5,11 +5,11 @@ performance logging GUIDed HOB on the first performance logging and then logs the performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or PcdMaxPeiPerformanceLogEntries16. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,215 +20,448 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include -#include +#include #include #include #include #include #include #include #include +#define STRING_SIZE(FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE) /** - Gets the GUID HOB for PEI performance. +Check whether the Token is a known one which is uesed by core. - This internal function searches for the GUID HOB for PEI performance. - If that GUID HOB is not found, it will build a new one. - It outputs the data area of that GUID HOB to record performance log. +@param Token Pointer to a Null-terminated ASCII string - @paramPeiPerformanceLog Pointer to Pointer to PEI performance log header. - @paramPeiPerformanceIdArray Pointer to Pointer to PEI performance identifier array. +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. **/ -VOID -InternalGetPerformanceHobLog ( - OUT PEI_PERFORMANCE_LOG_HEADER**PeiPerformanceLog, - OUT UINT32**PeiPerformanceIdArray +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token ) { - EFI_HOB_GUID_TYPE *GuidHob; - UINTN PeiPerformanceSize; - UINT16 PeiPerformanceLogEntries; + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} - ASSERT (PeiPerformanceLog != NULL); - ASSERT (PeiPerformanceIdArray != NULL); +/** +Check whether the ID is a known one which map to the known Token. - PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ? - PcdGet16 (PcdMaxPeiPerformanceLogEntries16) : - PcdGet8 (PcdMaxPeiPerformanceLogEntries)); - GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid); +@param Identifier 32-bit identifier. - if (GuidHob != NULL) { -// -// PEI Performance HOB was found, then return the existing one. -// -*PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob); +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. -GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid); -ASSERT (GuidHob != NULL); -*PeiPerformanceIdArray = GET_GUID_HOB_DATA (GuidHob); +**/ +BOOLEAN +IsKnownID ( + IN UINT32 Identifier + ) +{ + if (Identifier == MODULE_START_ID || + Identifier == MODULE_END_ID || + Identifier == MODULE_LOADIMAGE_START_ID || + Identifier == MODULE_LOADIMAGE_END_ID || + Identifier == MODULE_DB_START_ID || + Identifier == MODULE_DB_END_ID || + Identifier == MODULE_DB_SUPPORT_START_ID || + Identifier == MODULE_DB_SUPPORT_END_ID || + Identifier == MODULE_DB_STOP_
[edk2] [PATCH v4 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table
V4: a.Update the GUID for status code in DxeCorePerformanceLib and FirmwarePerformanceDxe. b. Add check for Insert FPDT record in DxeCorePerformanceLib to avoid re-entry case. V3: a. Add "FPDT_" prefix for related definitions in ExtendedFirmwarePerformance.h. b. Refine the code logic. V2: a. Update DxecorePerformanceLib/SmmCorePerformanceLib to report the boot performance table address instead of records contents. b. Update FirmwarePerformanceDxe/FirmwarePerformanceSmm to receive the address of performance records. This patch series also can be accessed at: https://github.com/dandanbi/edk2/tree/NewPerformanceInfrastructureV4 These patches are to update EDKII performance infrastructure to log and dump the performance entry as FPDT record in ACPI FPDT table.This new infrastructure can support to dump performance data in UEFI Shell and OS both. (1)PeiPerformanceLib/DxeCorePerformanceLib/SmmCorePerformanceLib log the performance entry as FPDT record. (2)FirmwarePerformancePei/FirmwarePerformanceDxe/FirmwarePerformanceSmm install the FPDT records to the ACPI table. (3)Update DP to dump the performance info from the FPDT records in FPDT table. Cc: Liming Gao Cc: Star Zeng Dandan Bi (7): MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure ShellPkg/Dp: Updated to dump perf log based on FPDT table Gao, Liming (1): MdeModulePkg:Add definitions for new Performance infrastructure .../Include/Guid/ExtendedFirmwarePerformance.h | 291 + MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1367 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 567 +--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1068 --- .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni |8 +- .../FirmwarePerformanceDxe.c | 294 + .../FirmwarePerformanceDxe.inf |5 +- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf |5 +- .../FirmwarePerformanceSmm.c | 35 +- .../FirmwarePerformanceSmm.inf |1 + ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h |7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |5 +- .../DpDynamicCommand/DpDynamicCommand.inf |5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h |9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 +- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h |8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 29 files changed, 3285 insertions(+), 1362 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v4 1/8] MdeModulePkg:Add definitions for new Performance infrastructure
From: "Gao, Liming" V3: Add "FPDT_" prefix for related definitions. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Signed-off-by: Dandan Bi --- .../Include/Guid/ExtendedFirmwarePerformance.h | 291 + MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni | 8 +- 4 files changed, 320 insertions(+), 3 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h new file mode 100644 index 000..f2db02d --- /dev/null +++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h @@ -0,0 +1,291 @@ +/** @file + This file defines edk2 extended firmware performance records. + These records will be added into ACPI FPDT Firmware Basic Boot Performance Table. + +Copyright (c) 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EXTENDED_FIRMWARE_PERFORMANCE_H__ +#define __EXTENDED_FIRMWARE_PERFORMANCE_H__ + +#include + +// +// Known performance tokens +// +#define SEC_TOK "SEC" ///< SEC Phase +#define DXE_TOK "DXE" ///< DXE Phase +#define PEI_TOK "PEI" ///< PEI Phase +#define BDS_TOK "BDS" ///< BDS Phase +#define DRIVERBINDING_START_TOK "DB:Start:" ///< Driver Binding Start() function call +#define DRIVERBINDING_SUPPORT_TOK "DB:Support:" ///< Driver Binding Support() function call +#define DRIVERBINDING_STOP_TOK "DB:Stop:"///< Driver Binding Stop() function call +#define LOAD_IMAGE_TOK "LoadImage:" ///< Load a dispatched module +#define START_IMAGE_TOK "StartImage:" ///< Dispatched Modules Entry Point execution +#define PEIM_TOK"PEIM"///< PEIM Modules Entry Point execution + +// +// Public Progress Identifiers for Event Records to map the above known token +// +#define MODULE_START_ID 0x01 +#define MODULE_END_ID 0x02 +#define MODULE_LOADIMAGE_START_ID 0x03 +#define MODULE_LOADIMAGE_END_ID 0x04 +#define MODULE_DB_START_ID 0x05 +#define MODULE_DB_END_ID0x06 +#define MODULE_DB_SUPPORT_START_ID 0x07 +#define MODULE_DB_SUPPORT_END_ID0x08 +#define MODULE_DB_STOP_START_ID 0x09 +#define MODULE_DB_STOP_END_ID 0x0A + +#define PERF_EVENTSIGNAL_START_ID 0x10 +#define PERF_EVENTSIGNAL_END_ID 0x11 +#define PERF_CALLBACK_START_ID 0x20 +#define PERF_CALLBACK_END_ID0x21 +#define PERF_FUNCTION_START_ID 0x30 +#define PERF_FUNCTION_END_ID0x31 +#define PERF_INMODULE_START_ID 0x40 +#define PERF_INMODULE_END_ID0x41 +#define PERF_CROSSMODULE_START_ID 0x50 +#define PERF_CROSSMODULE_END_ID 0x51 + +// +// Misc defines +// +#define FPDT_RECORD_REVISION_1 (0x01) + +// +// Length field in EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER is a UINT8, thus: +// +#define FPDT_MAX_PERF_RECORD_SIZE (MAX_UINT8) + +// +// FPDT Record Types +// +#define FPDT_GUID_EVENT_TYPE 0x1010 +#define FPDT_DYNAMIC_STRING_EVENT_TYPE 0x1011 +#define FPDT_DUAL_GUID_STRING_EVENT_TYPE 0x1012 +#define FPDT_GUID_QWORD_EVENT_TYPE 0x1013 +#define FPDT_GUID_QWORD_STRING_EVENT_TYPE 0x1014 + +// +// EDKII extended Fpdt record structures +// +#define FPDT_STRING_EVENT_RECORD_NAME_LENGTH 24 + +#pragma pack(1) +// +// FPDT Boot Performance Guid Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-zero value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock source. + /// If only one timestamp clock source is used, this field is Re
[edk2] [PATCH v3 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase
V3: a. Handle the case when string is empty in String Record. b. refine the code logic. V2: Update DxecorePerformanceLib to report the boot performance table address instead of records contents. Updated to convert Pref entry to FPDT record in DXE phase and then allocate boot performance table to save the record and report the address of boot performance table to FirmwarePerformanceDxe. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1361 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- 3 files changed, 1080 insertions(+), 318 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 7c0e207..44d3bd1 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -8,11 +8,11 @@ which are consumed by DxePerformanceLib to logging performance data in DXE phase. 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. -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -23,27 +23,64 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeCorePerformanceLibInternal.h" - // -// The data structure to hold global performance data. +// Data for FPDT performance records. // -GAUGE_DATA_HEADER*mGaugeData; +#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 0x1 +#define CACHE_HANDLE_GUID_COUNT 0x1000 + +BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL; +BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = { + { +EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE, +sizeof (BOOT_PERFORMANCE_TABLE) + }, + { +{ + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT,// Type + sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD),// Length + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT // Revision +}, +0, // Reserved +// +// These values will be updated at runtime. +// +0, // ResetEnd +0, // OsLoaderLoadImageStart +0, // OsLoaderStartImageStart +0, // ExitBootServicesEntry +0 // ExitBootServicesExit + } +}; -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTN mCachePairCount = 0; + +UINT32 mLoadImageCount = 0; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +UINT32 mBootRecordSize = 0; +UINT32 mBootRecordMaxSize= 0; + +BOOLEAN mFpdtBufferIsReported = FALSE; +BOOLEAN mLackSpaceIsReported = FALSE; +CHAR8 *mPlatformLanguage= NULL; +UINT8 *mPerformancePointer = NULL; +UINT8 *mBootRecordBuffer= NULL; + +EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL; // // Interfaces for Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -61,179 +98,1042 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { GetGaugeEx }; PERFORMANCE_PROPERTY mPerformanceProperty; -// -// Gauge record lock to avoid data corruption or even memory overflow -// -STATIC EFI_LOCK mPerfRecordLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI
[edk2] [PATCH v3 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table
Cc: Liming Gao Cc: Star Zeng Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 5 +- .../DpDynamicCommand/DpDynamicCommand.inf | 5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h | 9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 ++-- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h | 8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 11 files changed, 724 insertions(+), 127 deletions(-) delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index 3ecc753..fafc64f 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -11,40 +11,64 @@ Measurement records contain identifying information (Handle, Token, Module) and start and end time values. Dp uses this information to group records in different ways. It also uses timer information to calculate elapsed time for each measurement. - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include "PerformanceTokens.h" #include "Dp.h" #include "Literals.h" #include "DpInternal.h" +#pragma pack(1) + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Entry; +} RSDT_TABLE; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 Entry; +} XSDT_TABLE; + +#pragma pack() + EFI_HANDLE mDpHiiHandle; +typedef struct { + EFI_HANDLEHandle; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP *mCacheHandleGuidTable; +UINTNmCachePairCount = 0; + // /// Module-Global Variables ///@{ CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; UINT64 mInterestThreshold; BOOLEAN mShowId = FALSE; +UINT8*mBootPerformanceTable; +UINTNmBootPerformanceTableSize; +BOOLEAN mPeiPhase = FALSE; +BOOLEAN mDxePhase = FALSE; PERF_SUMMARY_DATA SummaryData = { 0 };///< Create the SummaryData structure and init. to ZERO. - -/// Timer Specific Information. -TIMER_INFO TimerInfo; +MEASUREMENT_RECORD *mMeasurementList = NULL; +UINTN mMeasurementNum= 0; /// Items for which to gather cumulative statistics. PERF_CUM_DATA CumData[] = { PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK), PERF_INIT_CUM_DATA (START_IMAGE_TOK), @@ -98,10 +122,540 @@ DumpStatistics( void ) SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtrUnknown); } /** + This function scan ACPI table in RSDT. + + @param RsdtACPI RSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInRSDT ( + IN RSDT_TABLE *Rsdt, + IN UINT32 Signature + ) +{ + UINTN Index; + UINT32EntryCount; + UINT32*EntryPtr; + EFI_ACPI_DESCRIPTION_HEADER *Table; + + EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32); + + EntryPtr = &Rsdt->Entry; + for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) { +Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); +if (Table->Signature == Signature) { + return Table; +} + } + + return NULL; +} + +/** + This function scan ACPI table in XSDT. + + @param Xsdt ACPI XSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInXSDT ( + IN XSDT_TABLE *Xsdt, + IN UINT32 Signature + ) +{ + UINTNIndex; + UINT32 EntryCount; + UINT64 EntryPtr; + UINTNBasePtr; + EFI_ACPI_DESCRI
[edk2] [PATCH v3 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
Add FPDT records into boot performance table for S3 phase Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf | 5 +- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c index e4800b7..9639fbc 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c @@ -3,11 +3,11 @@ Data Table in S3 resume boot mode. This module register report status code listener to collect performance data for S3 Resume Performance Record on S3 resume boot path. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -17,20 +17,24 @@ **/ #include #include +#include #include +#include +#include #include #include #include #include #include #include #include +#include /** Report status code listener for PEI. This is used to record the performance data for S3 FullResume in FPDT. @@ -68,10 +72,17 @@ FpdtStatusCodeListenerPei ( S3_PERFORMANCE_TABLE *AcpiS3PerformanceTable; EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD *AcpiS3ResumeRecord; UINT64 S3ResumeTotal; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD *AcpiS3SuspendRecord; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + UINT8*BootPerformanceTable; + FIRMWARE_PERFORMANCE_VARIABLEPerformanceVariable; + EFI_HOB_GUID_TYPE*GuidHob; + FPDT_PEI_EXT_PERF_HEADER *PeiPerformanceLogHeader; + UINT8*FirmwarePerformanceData; + UINT8*FirmwarePerformanceTablePtr; // // Check whether status code is what we are interested in. // if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) || @@ -128,10 +139,56 @@ FpdtStatusCodeListenerPei ( AcpiS3SuspendRecord->SuspendEnd = S3SuspendRecord.SuspendEnd; DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart)); DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd)); + Status = PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + ASSERT_EFI_ERROR (Status); + + // + // Update S3 boot records into the basic boot performance table. + // + VarSize = sizeof (PerformanceVariable); + Status = VariableServices->GetVariable ( + VariableServices, + EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, + &gEfiFirmwarePerformanceGuid, + NULL, + &VarSize, + &PerformanceVariable + ); + if (EFI_ERROR (Status)) { +return Status; + } + BootPerformanceTable = (UINT8*) (UINTN) PerformanceVariable.BootPerformanceTablePointer; + + // + // Dump PEI boot records + // + FirmwarePerformanceTablePtr = (BootPerformanceTable + sizeof (BOOT_PERFORMANCE_TABLE)); + GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid); + while (GuidHob != NULL) { +FirmwarePerformanceData = GET_GUID_HOB_DATA (GuidHob); +PeiPerformanceLogHeader = (FPDT_PEI_EXT_PERF_HEADER *) FirmwarePerformanceData; + +CopyMem (FirmwarePerformanceTablePtr, FirmwarePerformanceData + sizeof (FPDT_PEI_EXT_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries)); + +GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob)); + +FirmwarePerformanceTablePtr += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries); + } + + // + // Update Table length. + // + ((BOOT_PERFORMANCE_TABLE *) BootPerformanceTable)->Header.Length = (UINT32)((UINTN)FirmwarePerformanceTablePtr - (UINTN)BootPerformanceTable); + return EFI_SUCCESS; } /** Main entry for Firmware Performance Data Table PEIM. diff --git a/MdeModulePkg/Universal/Acpi/Fi
[edk2] [PATCH v3 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase
V3: a. Handle the case when string is empty in String Record. b. Use gEdkiiFpdtExtendedFirmwarePerformanceGuid to report status code to distinguish with the one in DxeCorePerformanceLib. c. Refine the code logic. V2: Update SmmCorePerformanceLib to report the buffer address of boot performance records instead of records contents. Updated to convert Pref entry to FPDT record in SMM phase and then export records to FPDT table. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1068 .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- 3 files changed, 649 insertions(+), 440 deletions(-) diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index cd1f1a5..57a6240 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -14,11 +14,11 @@ This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation. -Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -28,30 +28,32 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "SmmCorePerformanceLibInternal.h" -// -// The data structure to hold global performance data. -// -GAUGE_DATA_HEADER *mGaugeData; +#define STRING_SIZE (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define FIRMWARE_RECORD_BUFFER0x1000 +#define CACHE_HANDLE_GUID_COUNT 0x1000 -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; +SMM_BOOT_PERFORMANCE_TABLE*mSmmBootPerformanceTable = NULL; -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[FPDT_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; -BOOLEAN mPerformanceMeasurementEnabled; +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTNmCachePairCount = 0; -SPIN_LOCK mSmmPerfLock; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +BOOLEAN mFpdtDataIsReported = FALSE; +BOOLEAN mLackSpaceIsReport= FALSE; +CHAR8*mPlatformLanguage= NULL; +SPIN_LOCKmSmmFpdtLock; +PERFORMANCE_PROPERTY mPerformanceProperty; // // Interfaces for SMM Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -67,172 +69,630 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { StartGaugeEx, EndGaugeEx, GetGaugeEx }; -PERFORMANCE_PROPERTY mPerformanceProperty; +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} /** - Searches in the gauge array with keyword Handle, Token, Module and Identfier. +Check whether the ID is a known one which map to the known Token. - This internal function searches for the gauge entry in the gauge array. - If there is an entry that exactly matches the given keywords - and its end time stamp is zero, then the index of that gauge entry is returned; - otherwise, the the number of gauge entries in the array is returned. +@param Identifier 32-bit identifier. +@r
[edk2] [PATCH v3 7/8] MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure
V3: a. Remove unused definitions b. Get records size form the records buffer when getting size action is triggered. V2: Update FirmwarePerformanceSmm to receive the address of performance records instead of records content. Receive buffer address of Boot performance records which are reported by SmmCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceSmm.c | 35 ++ .../FirmwarePerformanceSmm.inf | 1 + 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c index c750331..d4ac849 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c @@ -38,17 +38,16 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1000 +SMM_BOOT_PERFORMANCE_TABLE*mSmmBootPerformanceTable = NULL; EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol= NULL; UINT64mSuspendStartTime = 0; BOOLEAN mS3SuspendLockBoxSaved = FALSE; UINT32mBootRecordSize = 0; -UINT32mBootRecordMaxSize = 0; UINT8 *mBootRecordBuffer = NULL; SPIN_LOCK mSmmFpdtLock; BOOLEAN mSmramIsOutOfResource = FALSE; @@ -82,11 +81,10 @@ FpdtStatusCodeListenerSmm ( ) { EFI_STATUS Status; UINT64 CurrentTime; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; - UINT8*NewRecordBuffer; // // Check whether status code is what we are interested in. // if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { @@ -94,36 +92,18 @@ FpdtStatusCodeListenerSmm ( } // // Collect one or more Boot records in boot time // - if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { + if (Data != NULL && CompareGuid (&Data->Type, &gEdkiiFpdtExtendedFirmwarePerformanceGuid)) { AcquireSpinLock (&mSmmFpdtLock); - -if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { - // - // Try to allocate big SMRAM data to store Boot record. - // - if (mSmramIsOutOfResource) { -ReleaseSpinLock (&mSmmFpdtLock); -return EFI_OUT_OF_RESOURCES; - } - NewRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer); - if (NewRecordBuffer == NULL) { -ReleaseSpinLock (&mSmmFpdtLock); -mSmramIsOutOfResource = TRUE; -return EFI_OUT_OF_RESOURCES; - } - mBootRecordBuffer = NewRecordBuffer; - mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE; -} // -// Save boot record into the temp memory space. +// Get the boot performance data. // -CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size); -mBootRecordSize += Data->Size; - +CopyMem (&mSmmBootPerformanceTable, Data + 1, Data->Size); +mBootRecordBuffer = ((UINT8 *) (mSmmBootPerformanceTable)) + sizeof (SMM_BOOT_PERFORMANCE_TABLE); + ReleaseSpinLock (&mSmmFpdtLock); return EFI_SUCCESS; } if ((Value != PcdGet32 (PcdProgressCodeS3SuspendStart)) && @@ -237,10 +217,13 @@ FpdtSmiHandler ( Status = EFI_SUCCESS; switch (SmmCommData->Function) { case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE : + if (mSmmBootPerformanceTable != NULL) { +mBootRecordSize = mSmmBootPerformanceTable->Header.Length - sizeof (SMM_BOOT_PERFORMANCE_TABLE); + } SmmCommData->BootRecordSize = mBootRecordSize; break; case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA : Status = EFI_UNSUPPORTED; diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf index 724e7bc..cae0111 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.inf @@ -58,10 +58,11 @@ [Guids] ## SOMETIMES_PRODUCES ## UNDEFINED # SaveLockBox ## PRODUCES ## UNDEFINED # SmiHandlerRegister ## SOMETIMES_CONSUMES ## UNDEFINED # StatusCode Data gEfiFirmwarePerformanceGuid + gEdkiiFpdtExtendedFirmwarePerformanceGuid ## SOMETIMES_PRODUCES ## UNDEFINED # S
[edk2] [PATCH v3 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase
V3:Handle the case when string is empty in String Record. Updated to convert Pref entry to FPDT record in PEI phase and then report the records to DxeCorePerfLib through GUID hob. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 567 ++--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- 2 files changed, 382 insertions(+), 199 deletions(-) diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 62527b2..79b67e8 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -5,11 +5,11 @@ performance logging GUIDed HOB on the first performance logging and then logs the performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or PcdMaxPeiPerformanceLogEntries16. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,215 +20,448 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include -#include +#include #include #include #include #include #include #include #include +#define STRING_SIZE(FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE(sizeof (FPDT_DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE) /** - Gets the GUID HOB for PEI performance. +Check whether the Token is a known one which is uesed by core. - This internal function searches for the GUID HOB for PEI performance. - If that GUID HOB is not found, it will build a new one. - It outputs the data area of that GUID HOB to record performance log. +@param Token Pointer to a Null-terminated ASCII string - @paramPeiPerformanceLog Pointer to Pointer to PEI performance log header. - @paramPeiPerformanceIdArray Pointer to Pointer to PEI performance identifier array. +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. **/ -VOID -InternalGetPerformanceHobLog ( - OUT PEI_PERFORMANCE_LOG_HEADER**PeiPerformanceLog, - OUT UINT32**PeiPerformanceIdArray +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token ) { - EFI_HOB_GUID_TYPE *GuidHob; - UINTN PeiPerformanceSize; - UINT16 PeiPerformanceLogEntries; + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} - ASSERT (PeiPerformanceLog != NULL); - ASSERT (PeiPerformanceIdArray != NULL); +/** +Check whether the ID is a known one which map to the known Token. - PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ? - PcdGet16 (PcdMaxPeiPerformanceLogEntries16) : - PcdGet8 (PcdMaxPeiPerformanceLogEntries)); - GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid); +@param Identifier 32-bit identifier. - if (GuidHob != NULL) { -// -// PEI Performance HOB was found, then return the existing one. -// -*PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob); +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. -GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid); -ASSERT (GuidHob != NULL); -*PeiPerformanceIdArray = GET_GUID_HOB_DATA (GuidHob); +**/ +BOOLEAN +IsKnownID ( + IN UINT32 Identifier + ) +{ + if (Identifier == MODULE_START_ID || + Identifier == MODULE_END_ID || + Identifier == MODULE_LOADIMAGE_START_ID || + Identifier == MODULE_LOADIMAGE_END_ID || + Identifier == MODULE_DB_START_ID || + Identifier == MODULE_DB_END_ID || + Identifier == MODULE_DB_SUPPORT_START_ID || + Identifier == MODULE_DB_SUPPORT_END_ID || + Identifier == MODULE_DB_STOP_
[edk2] [PATCH v3 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
V3:Add handling for the case when performance feature is not enabled. V2: Update FirmwarePerformanceDxe to receive the address of performance records instead of records content. 1. Remove the macro EXTENSION_RECORD_SIZE, since the extension size can be got through PcdExtFpdtBootRecordPadSize. 2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table 3. Copy SMM record accord to the allocated size 4. Receive Boot performance table address instead of contents which are reported DxeCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceDxe.c | 294 - .../FirmwarePerformanceDxe.inf | 4 +- 2 files changed, 51 insertions(+), 247 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index b004cac..51a72f0 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -3,11 +3,11 @@ This module register report status code listener to collect performance data for Firmware Basic Boot Performance Record and other boot performance records, and install FPDT to ACPI table. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -18,19 +18,17 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include #include @@ -40,26 +38,23 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1 -#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE) +#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)) EFI_RSC_HANDLER_PROTOCOL*mRscHandlerProtocol = NULL; BOOLEAN mLockBoxReady = FALSE; EFI_EVENT mReadyToBootEvent; 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 = { { EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE, @@ -327,186 +322,66 @@ InstallFirmwarePerformanceDataTable ( VOID ) { EFI_STATUSStatus; 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; - EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable; - EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion; - UINTN Index; - VOID *SmmBootRecordData; - UINTN SmmBootRecordDataSize; - UINTN ReservedMemSize; + UINTN Size; // // Get AcpiTable Protocol. // Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); if (EFI_ERROR (Status)) { return Status; } - // - // Collect boot records from SMM drivers. - // - SmmBootRecordCommBuffer = NULL; - SmmCommData = NULL; - SmmBootRecordData = NULL; - SmmBootRecordDataSize = 0; - ReservedMemSize = 0; - Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication); - if (!EFI_ERROR (Status)) { -// -// Initialize communicate buffer -// Get the prepared
[edk2] [PATCH v3 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table
V3: a. Add "FPDT_" prefix for related definitions in ExtendedFirmwarePerformance.h. b. Refine the code logic. V2: a. Update DxecorePerformanceLib/SmmCorePerformanceLib to report the boot performance table address instead of records contents. b. Update FirmwarePerformanceDxe/FirmwarePerformanceSmm to receive the address of performance records. This patch series also can be accessed at: https://github.com/dandanbi/edk2/tree/NewPerformanceInfrastructureV3 These patches are to update EDKII performance infrastructure to log and dump the performance entry as FPDT record in ACPI FPDT table.This new infrastructure can support to dump performance data in UEFI Shell and OS both. (1)PeiPerformanceLib/DxeCorePerformanceLib/SmmCorePerformanceLib log the performance entry as FPDT record. (2)FirmwarePerformancePei/FirmwarePerformanceDxe/FirmwarePerformanceSmm install the FPDT records to the ACPI table. (3)Update DP to dump the performance info from the FPDT records in FPDT table. Cc: Liming Gao Cc: Star Zeng Dandan Bi (7): MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure ShellPkg/Dp: Updated to dump perf log based on FPDT table Gao, Liming (1): MdeModulePkg:Add definitions for new Performance infrastructure .../Include/Guid/ExtendedFirmwarePerformance.h | 291 + MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1361 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 567 +--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1068 --- .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni |8 +- .../FirmwarePerformanceDxe.c | 294 + .../FirmwarePerformanceDxe.inf |4 +- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf |5 +- .../FirmwarePerformanceSmm.c | 35 +- .../FirmwarePerformanceSmm.inf |1 + ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h |7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |5 +- .../DpDynamicCommand/DpDynamicCommand.inf |5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h |9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 +- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h |8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 29 files changed, 3278 insertions(+), 1362 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v3 1/8] MdeModulePkg:Add definitions for new Performance infrastructure
From: "Gao, Liming" V3: Add "FPDT_" prefix for related definitions. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Signed-off-by: Dandan Bi --- .../Include/Guid/ExtendedFirmwarePerformance.h | 291 + MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni | 8 +- 4 files changed, 320 insertions(+), 3 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h new file mode 100644 index 000..f2db02d --- /dev/null +++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h @@ -0,0 +1,291 @@ +/** @file + This file defines edk2 extended firmware performance records. + These records will be added into ACPI FPDT Firmware Basic Boot Performance Table. + +Copyright (c) 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EXTENDED_FIRMWARE_PERFORMANCE_H__ +#define __EXTENDED_FIRMWARE_PERFORMANCE_H__ + +#include + +// +// Known performance tokens +// +#define SEC_TOK "SEC" ///< SEC Phase +#define DXE_TOK "DXE" ///< DXE Phase +#define PEI_TOK "PEI" ///< PEI Phase +#define BDS_TOK "BDS" ///< BDS Phase +#define DRIVERBINDING_START_TOK "DB:Start:" ///< Driver Binding Start() function call +#define DRIVERBINDING_SUPPORT_TOK "DB:Support:" ///< Driver Binding Support() function call +#define DRIVERBINDING_STOP_TOK "DB:Stop:"///< Driver Binding Stop() function call +#define LOAD_IMAGE_TOK "LoadImage:" ///< Load a dispatched module +#define START_IMAGE_TOK "StartImage:" ///< Dispatched Modules Entry Point execution +#define PEIM_TOK"PEIM"///< PEIM Modules Entry Point execution + +// +// Public Progress Identifiers for Event Records to map the above known token +// +#define MODULE_START_ID 0x01 +#define MODULE_END_ID 0x02 +#define MODULE_LOADIMAGE_START_ID 0x03 +#define MODULE_LOADIMAGE_END_ID 0x04 +#define MODULE_DB_START_ID 0x05 +#define MODULE_DB_END_ID0x06 +#define MODULE_DB_SUPPORT_START_ID 0x07 +#define MODULE_DB_SUPPORT_END_ID0x08 +#define MODULE_DB_STOP_START_ID 0x09 +#define MODULE_DB_STOP_END_ID 0x0A + +#define PERF_EVENTSIGNAL_START_ID 0x10 +#define PERF_EVENTSIGNAL_END_ID 0x11 +#define PERF_CALLBACK_START_ID 0x20 +#define PERF_CALLBACK_END_ID0x21 +#define PERF_FUNCTION_START_ID 0x30 +#define PERF_FUNCTION_END_ID0x31 +#define PERF_INMODULE_START_ID 0x40 +#define PERF_INMODULE_END_ID0x41 +#define PERF_CROSSMODULE_START_ID 0x50 +#define PERF_CROSSMODULE_END_ID 0x51 + +// +// Misc defines +// +#define FPDT_RECORD_REVISION_1 (0x01) + +// +// Length field in EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER is a UINT8, thus: +// +#define FPDT_MAX_PERF_RECORD_SIZE (MAX_UINT8) + +// +// FPDT Record Types +// +#define FPDT_GUID_EVENT_TYPE 0x1010 +#define FPDT_DYNAMIC_STRING_EVENT_TYPE 0x1011 +#define FPDT_DUAL_GUID_STRING_EVENT_TYPE 0x1012 +#define FPDT_GUID_QWORD_EVENT_TYPE 0x1013 +#define FPDT_GUID_QWORD_STRING_EVENT_TYPE 0x1014 + +// +// EDKII extended Fpdt record structures +// +#define FPDT_STRING_EVENT_RECORD_NAME_LENGTH 24 + +#pragma pack(1) +// +// FPDT Boot Performance Guid Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-zero value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock source. + /// If only one timestamp clock source is used, this field is Re
[edk2] [PATCH v2 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table
Cc: Liming Gao Cc: Star Zeng Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 5 +- .../DpDynamicCommand/DpDynamicCommand.inf | 5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h | 9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 ++-- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h | 8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 11 files changed, 724 insertions(+), 127 deletions(-) delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index 3ecc753..f41f18d 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -11,40 +11,64 @@ Measurement records contain identifying information (Handle, Token, Module) and start and end time values. Dp uses this information to group records in different ways. It also uses timer information to calculate elapsed time for each measurement. - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include "PerformanceTokens.h" #include "Dp.h" #include "Literals.h" #include "DpInternal.h" +#pragma pack(1) + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Entry; +} RSDT_TABLE; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 Entry; +} XSDT_TABLE; + +#pragma pack() + EFI_HANDLE mDpHiiHandle; +typedef struct { + EFI_HANDLEHandle; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP *mCacheHandleGuidTable; +UINTNmCachePairCount = 0; + // /// Module-Global Variables ///@{ CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; UINT64 mInterestThreshold; BOOLEAN mShowId = FALSE; +UINT8*mBootPerformanceTable; +UINTNmBootPerformanceTableSize; +BOOLEAN mPeiPhase = FALSE; +BOOLEAN mDxePhase = FALSE; PERF_SUMMARY_DATA SummaryData = { 0 };///< Create the SummaryData structure and init. to ZERO. - -/// Timer Specific Information. -TIMER_INFO TimerInfo; +MEASUREMENT_RECORD *mMeasurementList = NULL; +UINTN mMeasurementNum= 0; /// Items for which to gather cumulative statistics. PERF_CUM_DATA CumData[] = { PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK), PERF_INIT_CUM_DATA (START_IMAGE_TOK), @@ -98,10 +122,540 @@ DumpStatistics( void ) SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtrUnknown); } /** + This function scan ACPI table in RSDT. + + @param RsdtACPI RSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInRSDT ( + IN RSDT_TABLE *Rsdt, + IN UINT32 Signature + ) +{ + UINTN Index; + UINT32EntryCount; + UINT32*EntryPtr; + EFI_ACPI_DESCRIPTION_HEADER *Table; + + EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32); + + EntryPtr = &Rsdt->Entry; + for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) { +Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); +if (Table->Signature == Signature) { + return Table; +} + } + + return NULL; +} + +/** + This function scan ACPI table in XSDT. + + @param Xsdt ACPI XSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInXSDT ( + IN XSDT_TABLE *Xsdt, + IN UINT32 Signature + ) +{ + UINTNIndex; + UINT32 EntryCount; + UINT64 EntryPtr; + UINTNBasePtr; + EFI_ACPI_DESCRI
[edk2] [PATCH v2 7/8] MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure
V2: Update FirmwarePerformanceSmm to receive the address of performance records instead of records content. Receive buffer address of Boot performance records which are reported by SmmCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceSmm.c | 29 +- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c index c750331..28fb3d0 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c @@ -82,11 +82,11 @@ FpdtStatusCodeListenerSmm ( ) { EFI_STATUS Status; UINT64 CurrentTime; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; - UINT8*NewRecordBuffer; + SMM_BOOT_PERFORMANCE_TABLE *mSmmBootPerformanceTable; // // Check whether status code is what we are interested in. // if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { @@ -96,34 +96,17 @@ FpdtStatusCodeListenerSmm ( // // Collect one or more Boot records in boot time // if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { AcquireSpinLock (&mSmmFpdtLock); - -if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { - // - // Try to allocate big SMRAM data to store Boot record. - // - if (mSmramIsOutOfResource) { -ReleaseSpinLock (&mSmmFpdtLock); -return EFI_OUT_OF_RESOURCES; - } - NewRecordBuffer = ReallocatePool (mBootRecordSize, mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE, mBootRecordBuffer); - if (NewRecordBuffer == NULL) { -ReleaseSpinLock (&mSmmFpdtLock); -mSmramIsOutOfResource = TRUE; -return EFI_OUT_OF_RESOURCES; - } - mBootRecordBuffer = NewRecordBuffer; - mBootRecordMaxSize = mBootRecordSize + Data->Size + EXTENSION_RECORD_SIZE; -} // -// Save boot record into the temp memory space. +// Get the boot performance data. // -CopyMem (mBootRecordBuffer + mBootRecordSize, Data + 1, Data->Size); -mBootRecordSize += Data->Size; - +CopyMem (&mSmmBootPerformanceTable, Data + 1, Data->Size); +mBootRecordBuffer = ((UINT8 *) (mSmmBootPerformanceTable)) + sizeof (SMM_BOOT_PERFORMANCE_TABLE); +mBootRecordSize = mSmmBootPerformanceTable->Header.Length - sizeof (SMM_BOOT_PERFORMANCE_TABLE) ; + ReleaseSpinLock (&mSmmFpdtLock); return EFI_SUCCESS; } if ((Value != PcdGet32 (PcdProgressCodeS3SuspendStart)) && -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [PATCH v2 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase
V2: Update SmmCorePerformanceLib to report the buffer address of boot performance records instead of records contents. Updated to convert Pref entry to FPDT record in SMM phase and then export records to FPDT table. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1145 .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- 3 files changed, 724 insertions(+), 442 deletions(-) diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index cd1f1a5..815ed45 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -14,11 +14,11 @@ This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation. -Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -28,30 +28,38 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "SmmCorePerformanceLibInternal.h" -// -// The data structure to hold global performance data. -// -GAUGE_DATA_HEADER *mGaugeData; - -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; - -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; - -BOOLEAN mPerformanceMeasurementEnabled; - -SPIN_LOCK mSmmPerfLock; +#define STRING_SIZE (EDKII_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE (sizeof (DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE) +#define FIRMWARE_RECORD_BUFFER0x1000 +#define EXTENSION_RECORD_SIZE 0x1000 +#define CACHE_HANDLE_GUID_COUNT 0x1000 + +SMM_BOOT_PERFORMANCE_TABLE*mSmmBootPerformanceTable = NULL; + +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[EDKII_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTNmCachePairCount = 0; + +UINT8*mBootRecordBuffer= NULL; +UINT32 mBootRecordSize = 0; +UINT32 mBootRecordMaxSize= 0; +UINT8*mPerformancePointer = NULL; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +BOOLEAN mFpdtDataIsReported = FALSE; +BOOLEAN mLackSpaceIsReport= FALSE; +CHAR8*mPlatformLanguage= NULL; +SPIN_LOCKmSmmFpdtLock; +PERFORMANCE_PROPERTY mPerformanceProperty; // // Interfaces for SMM Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -67,172 +75,680 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { StartGaugeEx, EndGaugeEx, GetGaugeEx }; -PERFORMANCE_PROPERTY mPerformanceProperty; +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} /** - Searches in the gauge array with keyword Handle, Token, Module and Identfier. +Check whether the ID is a known one which map to the known Token. + +@param Identifier 32-bit identifier. + +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. - This internal function searches for the gauge entry in the g
[edk2] [PATCH v2 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase
Updated to convert Pref entry to FPDT record in PEI phase and then report the records to DxeCorePerfLib through GUID hob. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 565 ++--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- 2 files changed, 380 insertions(+), 199 deletions(-) diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 62527b2..75b4c31 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -5,11 +5,11 @@ performance logging GUIDed HOB on the first performance logging and then logs the performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or PcdMaxPeiPerformanceLogEntries16. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,215 +20,446 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include -#include +#include #include #include #include #include #include #include #include +#define STRING_SIZE(EDKII_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE(sizeof (DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE) /** - Gets the GUID HOB for PEI performance. +Check whether the Token is a known one which is uesed by core. - This internal function searches for the GUID HOB for PEI performance. - If that GUID HOB is not found, it will build a new one. - It outputs the data area of that GUID HOB to record performance log. +@param Token Pointer to a Null-terminated ASCII string - @paramPeiPerformanceLog Pointer to Pointer to PEI performance log header. - @paramPeiPerformanceIdArray Pointer to Pointer to PEI performance identifier array. +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. **/ -VOID -InternalGetPerformanceHobLog ( - OUT PEI_PERFORMANCE_LOG_HEADER**PeiPerformanceLog, - OUT UINT32**PeiPerformanceIdArray +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token ) { - EFI_HOB_GUID_TYPE *GuidHob; - UINTN PeiPerformanceSize; - UINT16 PeiPerformanceLogEntries; + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} - ASSERT (PeiPerformanceLog != NULL); - ASSERT (PeiPerformanceIdArray != NULL); +/** +Check whether the ID is a known one which map to the known Token. - PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ? - PcdGet16 (PcdMaxPeiPerformanceLogEntries16) : - PcdGet8 (PcdMaxPeiPerformanceLogEntries)); - GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid); +@param Identifier 32-bit identifier. - if (GuidHob != NULL) { -// -// PEI Performance HOB was found, then return the existing one. -// -*PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob); +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. -GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid); -ASSERT (GuidHob != NULL); -*PeiPerformanceIdArray = GET_GUID_HOB_DATA (GuidHob); +**/ +BOOLEAN +IsKnownID ( + IN UINT32 Identifier + ) +{ + if (Identifier == MODULE_START_ID || + Identifier == MODULE_END_ID || + Identifier == MODULE_LOADIMAGE_START_ID || + Identifier == MODULE_LOADIMAGE_END_ID || + Identifier == MODULE_DB_START_ID || + Identifier == MODULE_DB_END_ID || + Identifier == MODULE_DB_SUPPORT_START_ID || + Identifier == MODULE_DB_SUPPORT_END_ID || + Identifier == MODULE_DB_STOP_START_ID || + Identifier == MODULE_DB_STOP_END_ID) { +return TRUE;
[edk2] [PATCH v2 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase
V2: Update DxecorePerformanceLib to report the boot performance table address instead of records contents. Updated to convert Pref entry to FPDT record in DXE phase and then allocate boot performance table to save the record and report the address of boot performance table to FirmwarePerformanceDxe. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1389 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- 3 files changed, 1108 insertions(+), 318 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 7c0e207..c6f8a16 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -8,11 +8,11 @@ which are consumed by DxePerformanceLib to logging performance data in DXE phase. 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. -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -23,27 +23,65 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeCorePerformanceLibInternal.h" - // -// The data structure to hold global performance data. +// Data for FPDT performance records. // -GAUGE_DATA_HEADER*mGaugeData; +#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)) +#define STRING_SIZE (EDKII_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE (sizeof (DYNAMIC_STRING_EVENT_RECORD) + STRING_SIZE) +#define FIRMWARE_RECORD_BUFFER 0x1 +#define CACHE_HANDLE_GUID_COUNT 0x1000 + +BOOT_PERFORMANCE_TABLE *mAcpiBootPerformanceTable = NULL; +BOOT_PERFORMANCE_TABLE mBootPerformanceTableTemplate = { + { +EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_SIGNATURE, +sizeof (BOOT_PERFORMANCE_TABLE) + }, + { +{ + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_TYPE_FIRMWARE_BASIC_BOOT,// Type + sizeof (EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD),// Length + EFI_ACPI_5_0_FPDT_RUNTIME_RECORD_REVISION_FIRMWARE_BASIC_BOOT // Revision +}, +0, // Reserved +// +// These values will be updated at runtime. +// +0, // ResetEnd +0, // OsLoaderLoadImageStart +0, // OsLoaderStartImageStart +0, // ExitBootServicesEntry +0 // ExitBootServicesExit + } +}; -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[EDKII_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTN mCachePairCount = 0; + +UINT32 mLoadImageCount = 0; +UINT32 mPerformanceLength= 0; +UINT32 mMaxPerformanceLength = 0; +UINT32 mBootRecordSize = 0; +UINT32 mBootRecordMaxSize= 0; + +BOOLEAN mFpdtBufferIsReported = FALSE; +BOOLEAN mLackSpaceIsReported = FALSE; +CHAR8 *mPlatformLanguage= NULL; +UINT8 *mPerformancePointer = NULL; +UINT8 *mBootRecordBuffer= NULL; + +EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL; // // Interfaces for Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -61,179 +99,1069 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { GetGaugeEx }; PERFORMANCE_PROPERTY mPerformanceProperty; -// -// Gauge record lock to avoid data corruption or even memory overflow -// -STATIC EFI_LOCK mPerfRecordLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI
[edk2] [PATCH v2 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
Add FPDT records into boot performance table for S3 phase Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf | 5 +- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c index e4800b7..e81f96c 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c @@ -3,11 +3,11 @@ Data Table in S3 resume boot mode. This module register report status code listener to collect performance data for S3 Resume Performance Record on S3 resume boot path. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -17,20 +17,24 @@ **/ #include #include +#include #include +#include +#include #include #include #include #include #include #include #include +#include /** Report status code listener for PEI. This is used to record the performance data for S3 FullResume in FPDT. @@ -68,10 +72,17 @@ FpdtStatusCodeListenerPei ( S3_PERFORMANCE_TABLE *AcpiS3PerformanceTable; EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD *AcpiS3ResumeRecord; UINT64 S3ResumeTotal; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD *AcpiS3SuspendRecord; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + UINT8*BootPerformanceTable; + FIRMWARE_PERFORMANCE_VARIABLEPerformanceVariable; + EFI_HOB_GUID_TYPE*GuidHob; + PEI_EXT_FIRMWARE_PERF_HEADER *PeiPerformanceLogHeader; + UINT8*FirmwarePerformanceData; + UINT8*FirmwarePerformanceTablePtr; // // Check whether status code is what we are interested in. // if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) || @@ -128,10 +139,56 @@ FpdtStatusCodeListenerPei ( AcpiS3SuspendRecord->SuspendEnd = S3SuspendRecord.SuspendEnd; DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart)); DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd)); + Status = PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + ASSERT_EFI_ERROR (Status); + + // + // Update S3 boot records into the basic boot performance table. + // + VarSize = sizeof (PerformanceVariable); + Status = VariableServices->GetVariable ( + VariableServices, + EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, + &gEfiFirmwarePerformanceGuid, + NULL, + &VarSize, + &PerformanceVariable + ); + if (EFI_ERROR (Status)) { +return Status; + } + BootPerformanceTable = (UINT8*) (UINTN) PerformanceVariable.BootPerformanceTablePointer; + + // + // Dump PEI boot records + // + FirmwarePerformanceTablePtr = (BootPerformanceTable + sizeof (BOOT_PERFORMANCE_TABLE)); + GuidHob = GetFirstGuidHob (&gEdkiiExtendedFirmwarePerformanceGuid); + while (GuidHob != NULL) { +FirmwarePerformanceData = GET_GUID_HOB_DATA (GuidHob); +PeiPerformanceLogHeader = (PEI_EXT_FIRMWARE_PERF_HEADER *) FirmwarePerformanceData; + +CopyMem (FirmwarePerformanceTablePtr, FirmwarePerformanceData + sizeof (PEI_EXT_FIRMWARE_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries)); + +GuidHob = GetNextGuidHob (&gEdkiiExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob)); + +FirmwarePerformanceTablePtr += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries); + } + + // + // Update Table length. + // + ((BOOT_PERFORMANCE_TABLE *) BootPerformanceTable)->Header.Length = (UINT32)((UINTN)FirmwarePerformanceTablePtr - (UINTN)BootPerformanceTable); + return EFI_SUCCESS; } /** Main entry for Firmware Performance Data Table PEIM. diff --git a/MdeModulePkg/Universal/Acpi/Fi
[edk2] [PATCH v2 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
V2: Update FirmwarePerformanceDxe to receive the address of performance records instead of records content. 1. Remove the macro EXTENSION_RECORD_SIZE, since the extension size can be got through PcdExtFpdtBootRecordPadSize. 2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table 3. Copy SMM record accord to the allocated size 4. Receive Boot performance table address instead of contents which are reported DxeCorePerformanceLib. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceDxe.c | 271 ++--- .../FirmwarePerformanceDxe.inf | 4 +- 2 files changed, 18 insertions(+), 257 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index b004cac..da1db9b 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -3,11 +3,11 @@ This module register report status code listener to collect performance data for Firmware Basic Boot Performance Record and other boot performance records, and install FPDT to ACPI table. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -18,19 +18,17 @@ #include #include #include -#include #include #include #include #include #include #include -#include #include #include #include #include @@ -40,26 +38,23 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1 -#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE) +#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)) EFI_RSC_HANDLER_PROTOCOL*mRscHandlerProtocol = NULL; BOOLEAN mLockBoxReady = FALSE; EFI_EVENT mReadyToBootEvent; 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 = { { EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE, @@ -327,186 +322,23 @@ InstallFirmwarePerformanceDataTable ( VOID ) { EFI_STATUSStatus; 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; - EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *SmmCommRegionTable; - EFI_MEMORY_DESCRIPTOR *SmmCommMemRegion; - UINTN Index; - VOID *SmmBootRecordData; - UINTN SmmBootRecordDataSize; - UINTN ReservedMemSize; // // Get AcpiTable Protocol. // Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTableProtocol); if (EFI_ERROR (Status)) { return Status; } - // - // Collect boot records from SMM drivers. - // - SmmBootRecordCommBuffer = NULL; - SmmCommData = NULL; - SmmBootRecordData = NULL; - SmmBootRecordDataSize = 0; - ReservedMemSize = 0; - Status = gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &Communication); - if (!EFI_ERROR (Status)) { -// -// Initialize communicate buffer -// Get the prepared Reserved Memory Range -// -Status = EfiGetSystemConfigurationTable ( - &gEdkiiPiSmmCo
[edk2] [PATCH v2 1/8] MdeModulePkg:Add definitions for new Performance infrastructure
From: "Gao, Liming" Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Signed-off-by: Dandan Bi --- .../Include/Guid/ExtendedFirmwarePerformance.h | 291 + MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni | 8 +- 4 files changed, 320 insertions(+), 3 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h diff --git a/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h new file mode 100644 index 000..0395495 --- /dev/null +++ b/MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h @@ -0,0 +1,291 @@ +/** @file + This file defines edk2 extended firmware performance records. + These records will be added into ACPI FPDT Firmware Basic Boot Performance Table. + +Copyright (c) 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 that accompanies this distribution. +The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php. + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EXTENDED_FIRMWARE_PERFORMANCE_H__ +#define __EXTENDED_FIRMWARE_PERFORMANCE_H__ + +#include + +// +// Known performance tokens +// +#define SEC_TOK "SEC" ///< SEC Phase +#define DXE_TOK "DXE" ///< DXE Phase +#define PEI_TOK "PEI" ///< PEI Phase +#define BDS_TOK "BDS" ///< BDS Phase +#define DRIVERBINDING_START_TOK "DB:Start:" ///< Driver Binding Start() function call +#define DRIVERBINDING_SUPPORT_TOK "DB:Support:" ///< Driver Binding Support() function call +#define DRIVERBINDING_STOP_TOK "DB:Stop:"///< Driver Binding Stop() function call +#define LOAD_IMAGE_TOK "LoadImage:" ///< Load a dispatched module +#define START_IMAGE_TOK "StartImage:" ///< Dispatched Modules Entry Point execution +#define PEIM_TOK"PEIM"///< PEIM Modules Entry Point execution + +// +// Public Progress Identifiers for Event Records to map the above known token +// +#define MODULE_START_ID 0x01 +#define MODULE_END_ID 0x02 +#define MODULE_LOADIMAGE_START_ID 0x03 +#define MODULE_LOADIMAGE_END_ID 0x04 +#define MODULE_DB_START_ID 0x05 +#define MODULE_DB_END_ID0x06 +#define MODULE_DB_SUPPORT_START_ID 0x07 +#define MODULE_DB_SUPPORT_END_ID0x08 +#define MODULE_DB_STOP_START_ID 0x09 +#define MODULE_DB_STOP_END_ID 0x0A + +#define PERF_EVENTSIGNAL_START_ID 0x10 +#define PERF_EVENTSIGNAL_END_ID 0x11 +#define PERF_CALLBACK_START_ID 0x20 +#define PERF_CALLBACK_END_ID0x21 +#define PERF_FUNCTION_START_ID 0x30 +#define PERF_FUNCTION_END_ID0x31 +#define PERF_INMODULE_START_ID 0x40 +#define PERF_INMODULE_END_ID0x41 +#define PERF_CROSSMODULE_START_ID 0x50 +#define PERF_CROSSMODULE_END_ID 0x51 + +// +// Misc defines +// +#define RECORD_REVISION_1 (0x01) + +// +// Length field in EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER is a UINT8, thus: +// +#define MAX_PERF_RECORD_SIZE (MAX_UINT8) + +// +// FPDT Record Types +// +#define GUID_EVENT_TYPE 0x1010 +#define DYNAMIC_STRING_EVENT_TYPE 0x1011 +#define DUAL_GUID_STRING_EVENT_TYPE 0x1012 +#define GUID_QWORD_EVENT_TYPE 0x1013 +#define GUID_QWORD_STRING_EVENT_TYPE 0x1014 + +// +// EDKII extended Fpdt record structures +// +#define EDKII_STRING_EVENT_RECORD_NAME_LENGTH 24 + +#pragma pack(1) +// +// FPDT Boot Performance Guid Event Record Structure +// +typedef struct { + EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER Header; + /// + /// ProgressID < 0x10 are reserved for core performance entries. + /// Start measurement point shall have lowered one nibble set to zero and + /// corresponding end points shall have lowered one nibble set to non-zero value; + /// keeping other nibbles same as start point. + /// + UINT16 ProgressID; + /// + /// APIC ID for the processor in the system used as a timestamp clock source. + /// If only one timestamp clock source is used, this field is Reserved and populated as 0. + /// + UINT32
[edk2] [PATCH v2 0/8] Update EDKII Performance infrastructure based on ACPI FPDT table
V2: a.Update DxecorePerformanceLib/SmmCorePerformanceLib to report the boot performance table address instead of records contents. b.Update FirmwarePerformanceDxe/FirmwarePerformanceSmm to receive the address of performance records. This patch series also can be accessed at: https://github.com/dandanbi/edk2/tree/NewPerformanceInfrastructureV2 These patches are to update EDKII performance infrastructure to log and dump the performance entry as FPDT record in ACPI FPDT table.This new infrastructure can support to dump performance data in UEFI Shell and OS both. (1)PeiPerformanceLib/DxeCorePerformanceLib/SmmCorePerformanceLib log the performance entry as FPDT record. (2)FirmwarePerformancePei/FirmwarePerformanceDxe/FirmwarePerformanceSmm install the FPDT records to the ACPI table. (3)Update DP to dump the performance info from the FPDT records in FPDT table. Cc: Liming Gao Cc: Star Zeng Dandan Bi (7): MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure MdeModulePkg/FirmwarePerfSmm:Enhance for new pref infrastructure ShellPkg/Dp: Updated to dump perf log based on FPDT table Gao, Liming (1): MdeModulePkg:Add definitions for new Performance infrastructure .../Include/Guid/ExtendedFirmwarePerformance.h | 291 MdeModulePkg/Include/Guid/FirmwarePerformance.h| 13 +- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1389 +++- .../DxeCorePerformanceLib.inf | 20 +- .../DxeCorePerformanceLibInternal.h| 17 +- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 565 +--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1145 +--- .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- MdeModulePkg/MdeModulePkg.dec | 11 +- MdeModulePkg/MdeModulePkg.uni |8 +- .../FirmwarePerformanceDxe.c | 271 +--- .../FirmwarePerformanceDxe.inf |4 +- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf |5 +- .../FirmwarePerformanceSmm.c | 29 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h |7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |5 +- .../DpDynamicCommand/DpDynamicCommand.inf |5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h |9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 108 +- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 37 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h |8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 28 files changed, 3342 insertions(+), 1371 deletions(-) create mode 100644 MdeModulePkg/Include/Guid/ExtendedFirmwarePerformance.h delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 2/3] MdeModulePkg/BdsDxe: Remove useless Pref Code
Our new performance infrastructure can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Liming Gao Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Universal/BdsDxe/Bds.h | 3 +- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 3 +- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 57 +--- 3 files changed, 3 insertions(+), 60 deletions(-) diff --git a/MdeModulePkg/Universal/BdsDxe/Bds.h b/MdeModulePkg/Universal/BdsDxe/Bds.h index 5658e61..63d961f 100644 --- a/MdeModulePkg/Universal/BdsDxe/Bds.h +++ b/MdeModulePkg/Universal/BdsDxe/Bds.h @@ -1,9 +1,9 @@ /** @file Head file for BDS Architectural Protocol implementation -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -16,11 +16,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define _BDS_MODULE_H_ #include #include #include -#include #include #include #include #include diff --git a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf index a00b442..b8c5aa9 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf +++ b/MdeModulePkg/Universal/BdsDxe/BdsDxe.inf @@ -3,11 +3,11 @@ # # When DxeCore dispatching all DXE driver, this module will produce architecture protocol # gEfiBdsArchProtocolGuid. After DxeCore finish dispatching, DxeCore will invoke Entry # interface of protocol gEfiBdsArchProtocolGuid, then BDS phase is entered. # -# Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved. +# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved. # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at # http://opensource.org/licenses/bsd-license.php # @@ -76,11 +76,10 @@ ## SOMETIMES_CONSUMES ## Variable:L"ConIn" (The device path of console in device) ## SOMETIMES_CONSUMES ## Variable:L"ConOut" (The device path of console out device) ## SOMETIMES_CONSUMES ## Variable:L"ErrOut" (The device path of error out device) gConnectConInEventGuid## SOMETIMES_CONSUMES ## Event gEdkiiStatusCodeDataTypeVariableGuid ## SOMETIMES_CONSUMES ## GUID - gPerformanceProtocolGuid ## SOMETIMES_PRODUCES ## Variable:L"PerfDataMemAddr" (The ACPI address of performance data) gEfiEventReadyToBootGuid ## CONSUMES ## Event [Protocols] gEfiBdsArchProtocolGuid ## PRODUCES gEfiSimpleTextInputExProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index 2b24755..3191a98 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -3,11 +3,11 @@ When this module was dispatched by DxeCore, gEfiBdsArchProtocolGuid will be installed which contains interface of BdsEntry. After DxeCore finish DXE phase, gEfiBdsArchProtocolGuid->BdsEntry will be invoked to enter BDS phase. -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP (C) Copyright 2015 Hewlett-Packard Development Company, L.P. 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 @@ -633,61 +633,10 @@ BdsFormalizeEfiGlobalVariable ( // BdsFormalizeOSIndicationVariable (); } /** - - Allocate a block of memory that will contain performance data to OS. - -**/ -VOID -BdsAllocateMemoryForPerformanceData ( - VOID - ) -{ - EFI_STATUSStatus; - EFI_PHYSICAL_ADDRESS AcpiLowMemoryBase; - EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock; - - AcpiLowMemoryBase = 0x0ULL; - - // - // Allocate a block of memory that will contain performance data to OS. - // - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - EFI_SIZE_TO_PAGES (PERF_DATA_MAX_
[edk2] [patch 1/3] UefiCpuPkg/S3Resume: Remove useless pref code
Our new performance infrastructure can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Eric Dong Cc: Laszlo Ersek Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 131 - .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 3 +- 2 files changed, 1 insertion(+), 133 deletions(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index d7d2a4d..4d77689 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -20,11 +20,10 @@ #include #include #include -#include #include #include #include #include #include @@ -284,136 +283,10 @@ GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries[] = { GLOBAL_REMOVE_IF_UNREFERENCED CONST IA32_DESCRIPTOR mGdt = { sizeof (mGdtEntries) - 1, (UINTN) mGdtEntries }; -/** - Performance measure function to get S3 detailed performance data. - - This function will getS3 detailed performance data and saved in pre-reserved ACPI memory. -**/ -VOID -WriteToOsS3PerformanceData ( - VOID - ) -{ - EFI_STATUSStatus; - EFI_PHYSICAL_ADDRESS mAcpiLowMemoryBase; - PERF_HEADER *PerfHeader; - PERF_DATA *PerfData; - UINT64Ticker; - UINTN Index; - EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; - UINTN VarSize; - UINTN LogEntryKey; - CONST VOID*Handle; - CONST CHAR8 *Token; - CONST CHAR8 *Module; - UINT64StartTicker; - UINT64EndTicker; - UINT64StartValue; - UINT64EndValue; - BOOLEAN CountUp; - UINT64Freq; - - // - // Retrieve time stamp count as early as possible - // - Ticker = GetPerformanceCounter (); - - Freq = GetPerformanceCounterProperties (&StartValue, &EndValue); - - Freq = DivU64x32 (Freq, 1000); - - Status = PeiServicesLocatePpi ( - &gEfiPeiReadOnlyVariable2PpiGuid, - 0, - NULL, - (VOID **) &VariableServices - ); - if (EFI_ERROR (Status)) { -return; - } - - VarSize = sizeof (EFI_PHYSICAL_ADDRESS); - Status = VariableServices->GetVariable ( - VariableServices, - L"PerfDataMemAddr", - &gPerformanceProtocolGuid, - NULL, - &VarSize, - &mAcpiLowMemoryBase - ); - if (EFI_ERROR (Status)) { -DEBUG ((EFI_D_ERROR, "Fail to retrieve variable to log S3 performance data \n")); -return; - } - - PerfHeader = (PERF_HEADER *) (UINTN) mAcpiLowMemoryBase; - - if (PerfHeader->Signiture != PERFORMANCE_SIGNATURE) { -DEBUG ((EFI_D_ERROR, "Performance data in ACPI memory get corrupted! \n")); -return; - } - - // - // Record total S3 resume time. - // - if (EndValue >= StartValue) { -PerfHeader->S3Resume = Ticker - StartValue; -CountUp = TRUE; - } else { -PerfHeader->S3Resume = StartValue - Ticker; -CountUp = FALSE; - } - - // - // Get S3 detailed performance data - // - Index = 0; - LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( - LogEntryKey, - &Handle, - &Token, - &Module, - &StartTicker, - &EndTicker)) != 0) { -if (EndTicker != 0) { - PerfData = &PerfHeader->S3Entry[Index]; - - // - // Use File Handle to specify the different performance log for PEIM. - // File Handle is the base address of PEIM FFS file. - // - if ((AsciiStrnCmp (Token, "PEIM", PEI_PERFORMANCE_STRING_SIZE) == 0) && (Handle != NULL)) { -AsciiSPrint (PerfData->Token, PERF_TOKEN_LENGTH, "0x%11p", Handle); - } else { -AsciiStrnCpyS (PerfData->Token, PERF_TOKEN_SIZE, Token, PERF_TOKEN_LENGTH); - } - if (StartTicker == 1) { -StartTicker = StartValue; - } - if (End
[edk2] [patch 3/3] MdeModulePkg/UefiBootManagerLib: Remove useless pref codes
Our new performance infrastructure can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Liming Gao Cc: Ruiyu Ni Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 30 +- .../Library/UefiBootManagerLib/BmPerformance.c | 317 - .../Library/UefiBootManagerLib/InternalBm.h| 1 - .../UefiBootManagerLib/UefiBootManagerLib.inf | 4 +- 4 files changed, 28 insertions(+), 324 deletions(-) delete mode 100644 MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index d684482..eb8f3b5 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1,9 +1,9 @@ /** @file Library functions which relates with booting. -Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -26,10 +26,34 @@ EFI_BOOT_MANAGER_LEGACY_BOOT mBmLegacyBoot = NULL; /// EFI_GUID mBmHardDriveBootVariableGuid = { 0xfab7e9e1, 0x39dd, 0x4f2b, { 0x84, 0x08, 0xe2, 0x0e, 0x90, 0x6c, 0xb6, 0xde } }; EFI_GUID mBmAutoCreateBootOptionGuid = { 0x8108ac4e, 0x9f11, 0x4d59, { 0x85, 0x0e, 0xe2, 0x1a, 0x52, 0x2c, 0x59, 0xb2 } }; /** + + The end of BDS perf code. + + @param Event The triggered event. + @param Context Context for this event. + +**/ +VOID +EFIAPI +BmEndOfBdsPrefCode ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // Record the performance data for End of BDS + // + PERF_END(NULL, "BDS", NULL, 0); + + return ; +} + +/** The function registers the legacy boot support capabilities. @param RefreshLegacyBootOption The function pointer to create all the legacy boot options. @param LegacyBoot The function pointer to boot the legacy boot option. **/ @@ -1820,11 +1844,11 @@ EfiBootManagerBoot ( // // Create an event to be signalled when Legacy Boot occurs to write performance data. // Status = EfiCreateEventLegacyBootEx( TPL_NOTIFY, - BmWriteBootToOsPerformanceData, + BmEndOfBdsPrefCode, NULL, &LegacyBootEvent ); ASSERT_EFI_ERROR (Status); ); @@ -1861,11 +1885,11 @@ EfiBootManagerBoot ( // // Write boot to OS performance data for UEFI boot // PERF_CODE ( -BmWriteBootToOsPerformanceData (NULL, NULL); +BmEndOfBdsPrefCode (NULL, NULL); ); REPORT_STATUS_CODE (EFI_PROGRESS_CODE, PcdGet32 (PcdProgressCodeOsLoaderStart)); Status = gBS->StartImage (ImageHandle, &BootOption->ExitDataSize, &BootOption->ExitData); diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c b/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c deleted file mode 100644 index 4d4495b..000 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c +++ /dev/null @@ -1,317 +0,0 @@ -/** @file - This file include the file which can help to get the system - performance, all the function will only include if the performance - switch is set. - -Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved. -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include "InternalBm.h" - -PERF_HEADER mBmPerfHeader; -PERF_DATA mBmPerfData; -EFI_PHYSICAL_ADDRESS mBmAcpiLowMemoryBase = 0x0ULL; - -/** - Get the short verion of PDB file name to be - used in performance data logging. - - @param PdbFileName The long PDB file name. - @param GaugeString The output string to be logged by performance logger. - @param StringSize The buffer size of GaugeString in bytes. - -**/ -VOID -BmGetShortPdbFileName ( - IN CONST CHAR8 *PdbFileName, - OUT CHAR8 *GaugeString, - INUINTN StringSize - ) -{ - UINTN Index; - UINTN Index1; - UINTN StartInd
[edk2] [patch 0/3] Remove the useless pref codes
Our new performance infrastructure can support to dump performance date form ACPI table in OS. So we can remove the old pref code to write performance data to OS. Cc: Eric Dong Cc: Laszlo Ersek Cc: Liming Gao Cc: Ruiyu Ni Cc: Star Zeng Dandan Bi (3): UefiCpuPkg/S3Resume: Remove useless pref code MdeModulePkg/BdsDxe: Remove useless Pref Code MdeModulePkg/UefiBootManagerLib: Remove the useless pref codes MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c | 30 +- .../Library/UefiBootManagerLib/BmPerformance.c | 317 - .../Library/UefiBootManagerLib/InternalBm.h| 1 - .../UefiBootManagerLib/UefiBootManagerLib.inf | 4 +- MdeModulePkg/Universal/BdsDxe/Bds.h| 3 +- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf | 3 +- MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 57 +--- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 131 - .../Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf | 3 +- 9 files changed, 32 insertions(+), 517 deletions(-) delete mode 100644 MdeModulePkg/Library/UefiBootManagerLib/BmPerformance.c -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch] UefiCpuPkg/S3Resume: Add more perf enrty for S3 phase
Add more perf entry to hook BootScriptDonePpi/EndOfPeiPpi/ EndOfS3Resume. Notes: This patch depends on the new performance infrastructure. Cc: Eric Dong Cc: Laszlo Ersek Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c index b597ac7..d7d2a4d 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -2,11 +2,11 @@ This module produces the EFI_PEI_S3_RESUME2_PPI. This module works with StandAloneBootScriptExecutor to S3 resume to OS. This module will execute the boot script saved during last boot and after that, control is passed to OS waking up handler. - Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. Copyright (c) 2017, AMD Incorporated. 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 @@ -21,10 +21,11 @@ #include #include #include #include +#include #include #include #include #include #include @@ -551,13 +552,17 @@ S3ResumeBootOs ( PERF_END (NULL, "ScriptExec", NULL, 0); // // Install BootScriptDonePpi // + PERF_START_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_START_ID); + Status = PeiServicesInstallPpi (&mPpiListPostScriptTable); ASSERT_EFI_ERROR (Status); + PERF_END_EX (NULL, "BootScriptDonePpi", NULL, 0, PERF_INMODULE_END_ID); + // // Get ACPI Table Address // Facs = (EFI_ACPI_4_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *) ((UINTN) (AcpiS3Context->AcpiFacsTable)); @@ -576,18 +581,26 @@ S3ResumeBootOs ( } // // Install EndOfPeiPpi // + PERF_START_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_START_ID); + Status = PeiServicesInstallPpi (&mPpiListEndOfPeiTable); ASSERT_EFI_ERROR (Status); + PERF_END_EX (NULL, "EndOfPeiPpi", NULL, 0, PERF_INMODULE_END_ID); + // // Signal EndOfS3Resume event. // + PERF_START_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_START_ID); + SignalEndOfS3Resume (); + PERF_END_EX (NULL, "EndOfS3Resume", NULL, 0, PERF_INMODULE_END_ID); + // // report status code on S3 resume // REPORT_STATUS_CODE (EFI_PROGRESS_CODE, EFI_SOFTWARE_PEI_MODULE | EFI_SW_PEI_PC_OS_WAKE); -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 8/8] ShellPkg/Dp: Updated to dump perf log based on FPDT table
Cc: Liming Gao Cc: Star Zeng Cc: Ruiyu Ni Cc: Jaben Carsey Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 609 - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h | 7 +- ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni| 11 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf | 5 +- .../DpDynamicCommand/DpDynamicCommand.inf | 5 +- .../DynamicCommand/DpDynamicCommand/DpInternal.h | 9 +- ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 92 +++- .../DynamicCommand/DpDynamicCommand/DpUtilities.c | 31 +- .../DynamicCommand/DpDynamicCommand/Literals.c | 24 +- .../DynamicCommand/DpDynamicCommand/Literals.h | 8 +- .../DpDynamicCommand/PerformanceTokens.h | 28 - 11 files changed, 713 insertions(+), 116 deletions(-) delete mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c index 3ecc753..6013d99 100644 --- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c @@ -11,40 +11,64 @@ Measurement records contain identifying information (Handle, Token, Module) and start and end time values. Dp uses this information to group records in different ways. It also uses timer information to calculate elapsed time for each measurement. - Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ -#include "PerformanceTokens.h" #include "Dp.h" #include "Literals.h" #include "DpInternal.h" +#pragma pack(1) + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT32 Entry; +} RSDT_TABLE; + +typedef struct { + EFI_ACPI_DESCRIPTION_HEADER Header; + UINT64 Entry; +} XSDT_TABLE; + +#pragma pack() + EFI_HANDLE mDpHiiHandle; +typedef struct { + EFI_HANDLEHandle; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP *mCacheHandleGuidTable; +UINTNmCachePairCount = 0; + // /// Module-Global Variables ///@{ CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1]; CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE]; UINT64 mInterestThreshold; BOOLEAN mShowId = FALSE; +UINT8*mBootPerformanceTable; +UINTNmBootPerformanceTableSize; +BOOLEAN mPeiPhase = FALSE; +BOOLEAN mDxePhase = FALSE; PERF_SUMMARY_DATA SummaryData = { 0 };///< Create the SummaryData structure and init. to ZERO. - -/// Timer Specific Information. -TIMER_INFO TimerInfo; +MEASUREMENT_RECORD *mMeasurementList = NULL; +UINTN mMeasurementNum= 0; /// Items for which to gather cumulative statistics. PERF_CUM_DATA CumData[] = { PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK), PERF_INIT_CUM_DATA (START_IMAGE_TOK), @@ -98,10 +122,540 @@ DumpStatistics( void ) SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtrUnknown); } /** + This function scan ACPI table in RSDT. + + @param RsdtACPI RSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInRSDT ( + IN RSDT_TABLE *Rsdt, + IN UINT32 Signature + ) +{ + UINTN Index; + UINT32EntryCount; + UINT32*EntryPtr; + EFI_ACPI_DESCRIPTION_HEADER *Table; + + EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32); + + EntryPtr = &Rsdt->Entry; + for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) { +Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr)); +if (Table->Signature == Signature) { + return Table; +} + } + + return NULL; +} + +/** + This function scan ACPI table in XSDT. + + @param Xsdt ACPI XSDT + @param Signature ACPI table signature + + @return ACPI table +**/ +VOID * +ScanTableInXSDT ( + IN XSDT_TABLE *Xsdt, + IN UINT32 Signature + ) +{ + UINTNIndex; + UINT32 EntryCount; + UINT64 EntryPtr; + UINTNBasePtr; + EFI_ACPI_DESCRI
[edk2] [patch 6/8] MdeModulePkg/FirmwarePerfDxe:Enhance for new pref infrastructure
1. Remove the macro EXTENSION_RECORD_SIZE, since the extension size can be got through PcdExtFpdtBootRecordPadSize. 2. Hook EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT to install ACPI table 3. Copy SMM record according to the allocated size Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceDxe.c | 58 ++ 1 file changed, 16 insertions(+), 42 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index b004cac..0de6bfa 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -3,11 +3,11 @@ This module register report status code listener to collect performance data for Firmware Basic Boot Performance Record and other boot performance records, and install FPDT to ACPI table. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -40,12 +40,11 @@ #include #include #include #include -#define EXTENSION_RECORD_SIZE 0x1 -#define SMM_BOOT_RECORD_COMM_SIZE OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE) +#define SMM_BOOT_RECORD_COMM_SIZE (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_BOOT_RECORD_COMMUNICATE)) EFI_RSC_HANDLER_PROTOCOL*mRscHandlerProtocol = NULL; BOOLEAN mLockBoxReady = FALSE; EFI_EVENT mReadyToBootEvent; @@ -419,11 +418,15 @@ InstallFirmwarePerformanceDataTable ( SmmCommData->BootRecordSize = ReservedMemSize - SMM_BOOT_RECORD_COMM_SIZE; while (SmmCommData->BootRecordOffset < SmmBootRecordDataSize) { Status = Communication->Communicate (Communication, SmmBootRecordCommBuffer, &CommSize); ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR(SmmCommData->ReturnStatus); -CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize); +if (SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize > SmmBootRecordDataSize) { + CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmBootRecordDataSize - SmmCommData->BootRecordOffset); +} else { + CopyMem ((UINT8 *) SmmBootRecordData + SmmCommData->BootRecordOffset, SmmCommData->BootRecordData, SmmCommData->BootRecordSize); +} SmmCommData->BootRecordOffset = SmmCommData->BootRecordOffset + SmmCommData->BootRecordSize; } } } } @@ -567,33 +570,10 @@ InstallFirmwarePerformanceDataTable ( return EFI_SUCCESS; } /** - Notify function for event group EFI_EVENT_GROUP_READY_TO_BOOT. This is used to - install the Firmware Performance Data Table. - - @param[in] Event The Event that is being processed. - @param[in] Context The Event Context. - -**/ -VOID -EFIAPI -FpdtReadyToBootEventNotify ( - IN EFI_EVENTEvent, - IN VOID *Context - ) -{ - if (mAcpiBootPerformanceTable == NULL) { -// -// ACPI Firmware Performance Data Table not installed yet, install it now. -// -InstallFirmwarePerformanceDataTable (); - } -} - -/** Report status code listener of FPDT. This is used to collect performance data for OsLoaderLoadImageStart and OsLoaderStartImageStart in FPDT. @param[in] CodeTypeIndicates the type of status code being reported. @param[in] Value Describes the current status of a hardware or software entity. @@ -697,22 +677,29 @@ FpdtStatusCodeListenerDxe ( DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ResetEnd= %ld\n", mAcpiBootPerformanceTable->BasicBoot.ResetEnd)); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderLoadImageStart = 0\n")); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - OsLoaderStartImageStart = %ld\n", mAcpiBootPerformanceTable->BasicBoot.OsLoaderStartImageStart)); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesEntry = 0\n")); DEBUG ((EFI_D_INFO, "FPDT: Boot Performance - ExitBootServicesExit= 0\n")); + } else if (Value == (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT)
[edk2] [patch 3/8] MdeModulePkg/DxeCorePerformanceLib:Track FPDT record in DXE phase
Updated to convert Pref enrty to FPDT record in DXE phase and then export records to FPDT table. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 1130 ++-- .../DxeCorePerformanceLib.inf | 14 +- .../DxeCorePerformanceLibInternal.h| 14 +- 3 files changed, 839 insertions(+), 319 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 7c0e207..6c7dd35 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -8,11 +8,11 @@ which are consumed by DxePerformanceLib to logging performance data in DXE phase. 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. -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -23,27 +23,36 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "DxeCorePerformanceLibInternal.h" - -// -// The data structure to hold global performance data. -// -GAUGE_DATA_HEADER*mGaugeData; - -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; - // -// The handle to install Performance Protocol instance. +// Data for FPDT performance records. // -EFI_HANDLE mHandle = NULL; +#define STRING_SIZE (EDKII_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE (sizeof (FPDT_RECORD) + STRING_SIZE) +#define FIRMWARE_RECORD_BUFFER 0x10 +#define CACHE_HANDLE_GUID_COUNT 0x1000 + +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[EDKII_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTN mCachePairCount = 0; + +UINT32 mLoadImageCount = 0; +UINTN mPerformanceLength= 0; +UINTN mMaxPerformanceLength = 0; +BOOLEAN mFpdtDataIsReported = FALSE; +BOOLEAN mStartFpdtDataReport = FALSE; +CHAR8 *mPlatformLanguage= NULL; +UINT8 *mPerformancePointer = NULL; + +EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL; // // Interfaces for Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -61,179 +70,837 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { GetGaugeEx }; PERFORMANCE_PROPERTY mPerformanceProperty; -// -// Gauge record lock to avoid data corruption or even memory overflow -// -STATIC EFI_LOCK mPerfRecordLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_NOTIFY); +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} /** - Searches in the gauge array with keyword Handle, Token, Module and Identifier. +Check whether the ID is a known one which map to the known Token. + +@param Identifier 32-bit identifier. + +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownID ( + IN UINT32 Identifier + ) +{ + if (Identifier == MODULE_START_ID || + Identifier == MODULE_END_ID || + Identifier == MODULE_LOADIMAGE_START_ID || + Identifier == MODULE_LOADIMAGE_END_ID || + Identifier == MODULE_DB_START_ID || + Identifier == MODULE_DB_END_ID || + Identifier == MODULE_DB_SUPPORT_START_ID || + Identifier == MODULE_DB_SUPPORT_END_ID || +
[edk2] [patch 7/8] MdeModulePkg/FirmwarePerfSmm: Add check for collecting SMM records
After DXE driver communicating with SMM driver to get the size and contents of the SMM records, make SMM???driver not to allocate buffer to collect new SMM records if the pre-allocate buffer is not enough. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformanceSmm.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c index c750331..160f6c0 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableSmm/FirmwarePerformanceSmm.c @@ -9,11 +9,11 @@ This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. FpdtSmiHandler() will receive untrusted input and do basic validation. - Copyright (c) 2011 - 2016, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -49,10 +49,11 @@ UINT32mBootRecordSize = 0; UINT32mBootRecordMaxSize = 0; UINT8 *mBootRecordBuffer = NULL; SPIN_LOCK mSmmFpdtLock; BOOLEAN mSmramIsOutOfResource = FALSE; +BOOLEAN mHaveReportedSmmRecord = FALSE; /** Report status code listener for SMM. This is used to record the performance data for S3 Suspend Start and S3 Suspend End in FPDT. @@ -90,19 +91,27 @@ FpdtStatusCodeListenerSmm ( // Check whether status code is what we are interested in. // if ((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) { return EFI_UNSUPPORTED; } - + // // Collect one or more Boot records in boot time // if (Data != NULL && CompareGuid (&Data->Type, &gEfiFirmwarePerformanceGuid)) { AcquireSpinLock (&mSmmFpdtLock); if (mBootRecordSize + Data->Size > mBootRecordMaxSize) { // + // If SMM records have been reported to DXE driver, don't re-allocate buffer + // to collect the new SMM records when pre-allocate buffer is not enough. + // + if (mHaveReportedSmmRecord) { +ReleaseSpinLock (&mSmmFpdtLock); +return EFI_OUT_OF_RESOURCES; + } + // // Try to allocate big SMRAM data to store Boot record. // if (mSmramIsOutOfResource) { ReleaseSpinLock (&mSmmFpdtLock); return EFI_OUT_OF_RESOURCES; @@ -237,10 +246,11 @@ FpdtSmiHandler ( Status = EFI_SUCCESS; switch (SmmCommData->Function) { case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_SIZE : + mHaveReportedSmmRecord = TRUE; SmmCommData->BootRecordSize = mBootRecordSize; break; case SMM_FPDT_FUNCTION_GET_BOOT_RECORD_DATA : Status = EFI_UNSUPPORTED; -- 1.9.5.msysgit.1 ___ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
[edk2] [patch 4/8] MdeModulePkg/SmmCorePerformanceLib:Track FPDT record in SMM phase
Updated to convert Pref entry to FPDT record in SMM phase and then export records to FPDT table. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 1094 .../SmmCorePerformanceLib.inf | 10 +- .../SmmCorePerformanceLibInternal.h| 11 +- 3 files changed, 681 insertions(+), 434 deletions(-) diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index cd1f1a5..cb880ef 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -14,11 +14,11 @@ This external input must be validated carefully to avoid security issue like buffer overflow, integer overflow. SmmPerformanceHandlerEx(), SmmPerformanceHandler() will receive untrusted input and do basic validation. -Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. +Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -28,30 +28,32 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "SmmCorePerformanceLibInternal.h" -// -// The data structure to hold global performance data. -// -GAUGE_DATA_HEADER *mGaugeData; - -// -// The current maximum number of logging entries. If current number of -// entries exceeds this value, it will re-allocate a larger array and -// migration the old data to the larger array. -// -UINT32 mMaxGaugeRecords; - -// -// The handle to install Performance Protocol instance. -// -EFI_HANDLE mHandle = NULL; - -BOOLEAN mPerformanceMeasurementEnabled; - -SPIN_LOCK mSmmPerfLock; +#define STRING_SIZE (EDKII_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE (sizeof (FPDT_RECORD) + STRING_SIZE) +#define FIRMWARE_RECORD_BUFFER0x1000 +#define CACHE_HANDLE_GUID_COUNT 0x1000 + +typedef struct { + EFI_HANDLEHandle; + CHAR8 NameString[EDKII_STRING_EVENT_RECORD_NAME_LENGTH]; + EFI_GUID ModuleGuid; +} HANDLE_GUID_MAP; + +HANDLE_GUID_MAP mCacheHandleGuidTable[CACHE_HANDLE_GUID_COUNT]; +UINTNmCachePairCount = 0; + +UINT8*mPerformancePointer = NULL; +UINTNmPerformanceLength= 0; +UINTNmMaxPerformanceLength = 0; +BOOLEAN mFpdtDataIsReported = FALSE; +BOOLEAN mStartFpdtDataReport = FALSE; +CHAR8*mPlatformLanguage= NULL; +SPIN_LOCKmSmmFpdtLock; +PERFORMANCE_PROPERTY mPerformanceProperty; // // Interfaces for SMM Performance Protocol. // PERFORMANCE_PROTOCOL mPerformanceInterface = { @@ -67,172 +69,634 @@ PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = { StartGaugeEx, EndGaugeEx, GetGaugeEx }; -PERFORMANCE_PROPERTY mPerformanceProperty; +/** +Check whether the Token is a known one which is uesed by core. + +@param Token Pointer to a Null-terminated ASCII string + +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. + +**/ +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token + ) +{ + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} /** - Searches in the gauge array with keyword Handle, Token, Module and Identfier. +Check whether the ID is a known one which map to the known Token. + +@param Identifier 32-bit identifier. - This internal function searches for the gauge entry in the gauge array. - If there is an entry that exactly matches the given keywords - and its end time stamp is zero, then the index of that gauge entry is returned; - otherwise, the the number of gauge entries in the array is returned. +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. +**/ +BOOLEAN +IsKnownID ( + IN UINT32 Identifier + ) +{ + if (Identifier == MODULE_START_ID || + Identifier == MODULE_END_ID || +
[edk2] [patch 2/8] MdeModulePkg/PeiPerformance:Updated to track FPDT record in PEI phase
Updated to convert Pref entry to FPDT record in PEI phase and then export records to FPDT table. Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../Library/PeiPerformanceLib/PeiPerformanceLib.c | 563 ++--- .../PeiPerformanceLib/PeiPerformanceLib.inf| 14 +- 2 files changed, 378 insertions(+), 199 deletions(-) diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 62527b2..f78c349 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -5,11 +5,11 @@ performance logging GUIDed HOB on the first performance logging and then logs the performance data to the GUIDed HOB. Due to the limitation of temporary RAM, the maximum number of performance logging entry is specified by PcdMaxPeiPerformanceLogEntries or PcdMaxPeiPerformanceLogEntries16. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved. +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved. (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -20,215 +20,444 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include -#include +#include #include #include #include #include #include #include #include +#define STRING_SIZE(EDKII_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8)) +#define MAX_RECORD_SIZE(sizeof (FPDT_RECORD) + STRING_SIZE) /** - Gets the GUID HOB for PEI performance. +Check whether the Token is a known one which is uesed by core. - This internal function searches for the GUID HOB for PEI performance. - If that GUID HOB is not found, it will build a new one. - It outputs the data area of that GUID HOB to record performance log. +@param Token Pointer to a Null-terminated ASCII string - @paramPeiPerformanceLog Pointer to Pointer to PEI performance log header. - @paramPeiPerformanceIdArray Pointer to Pointer to PEI performance identifier array. +@retval TRUE Is a known one used by core. +@retval FALSE Not a known one. **/ -VOID -InternalGetPerformanceHobLog ( - OUT PEI_PERFORMANCE_LOG_HEADER**PeiPerformanceLog, - OUT UINT32**PeiPerformanceIdArray +BOOLEAN +IsKnownTokens ( + IN CONST CHAR8 *Token ) { - EFI_HOB_GUID_TYPE *GuidHob; - UINTN PeiPerformanceSize; - UINT16 PeiPerformanceLogEntries; + if (AsciiStrCmp (Token, SEC_TOK) == 0 || + AsciiStrCmp (Token, PEI_TOK) == 0 || + AsciiStrCmp (Token, DXE_TOK) == 0 || + AsciiStrCmp (Token, BDS_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_START_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_SUPPORT_TOK) == 0 || + AsciiStrCmp (Token, DRIVERBINDING_STOP_TOK) == 0 || + AsciiStrCmp (Token, LOAD_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, START_IMAGE_TOK) == 0 || + AsciiStrCmp (Token, PEIM_TOK) == 0) { +return TRUE; + } else { +return FALSE; + } +} - ASSERT (PeiPerformanceLog != NULL); - ASSERT (PeiPerformanceIdArray != NULL); +/** +Check whether the ID is a known one which map to the known Token. - PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ? - PcdGet16 (PcdMaxPeiPerformanceLogEntries16) : - PcdGet8 (PcdMaxPeiPerformanceLogEntries)); - GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid); +@param Identifier 32-bit identifier. - if (GuidHob != NULL) { -// -// PEI Performance HOB was found, then return the existing one. -// -*PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob); +@retval TRUEIs a known one used by core. +@retval FALSE Not a known one. -GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid); -ASSERT (GuidHob != NULL); -*PeiPerformanceIdArray = GET_GUID_HOB_DATA (GuidHob); +**/ +BOOLEAN +IsKnownID ( + IN UINT32 Identifier + ) +{ + if (Identifier == MODULE_START_ID || + Identifier == MODULE_END_ID || + Identifier == MODULE_LOADIMAGE_START_ID || + Identifier == MODULE_LOADIMAGE_END_ID || + Identifier == MODULE_DB_START_ID || + Identifier == MODULE_DB_END_ID || + Identifier == MODULE_DB_SUPPORT_START_ID || + Identifier == MODULE_DB_SUPPORT_END_ID || + Identifier == MODULE_DB_STOP_START_ID || + Identifier == MODULE_DB_STOP_END_ID) { +return TRUE; } else { -// -// PEI Performance HOB
[edk2] [patch 5/8] MdeModulePkg/FirmwarePerformancePei:Add FPDT records for S3 phase
Add FPDT records into boot performance table for S3 phase Cc: Liming Gao Cc: Star Zeng Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi --- .../FirmwarePerformancePei.c | 59 +- .../FirmwarePerformancePei.inf | 5 +- 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c index e4800b7..e81f96c 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTablePei/FirmwarePerformancePei.c @@ -3,11 +3,11 @@ Data Table in S3 resume boot mode. This module register report status code listener to collect performance data for S3 Resume Performance Record on S3 resume boot path. - Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved. + Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -17,20 +17,24 @@ **/ #include #include +#include #include +#include +#include #include #include #include #include #include #include #include +#include /** Report status code listener for PEI. This is used to record the performance data for S3 FullResume in FPDT. @@ -68,10 +72,17 @@ FpdtStatusCodeListenerPei ( S3_PERFORMANCE_TABLE *AcpiS3PerformanceTable; EFI_ACPI_5_0_FPDT_S3_RESUME_RECORD *AcpiS3ResumeRecord; UINT64 S3ResumeTotal; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD S3SuspendRecord; EFI_ACPI_5_0_FPDT_S3_SUSPEND_RECORD *AcpiS3SuspendRecord; + EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices; + UINT8*BootPerformanceTable; + FIRMWARE_PERFORMANCE_VARIABLEPerformanceVariable; + EFI_HOB_GUID_TYPE*GuidHob; + PEI_EXT_FIRMWARE_PERF_HEADER *PeiPerformanceLogHeader; + UINT8*FirmwarePerformanceData; + UINT8*FirmwarePerformanceTablePtr; // // Check whether status code is what we are interested in. // if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) != EFI_PROGRESS_CODE) || @@ -128,10 +139,56 @@ FpdtStatusCodeListenerPei ( AcpiS3SuspendRecord->SuspendEnd = S3SuspendRecord.SuspendEnd; DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendStart = %ld\n", AcpiS3SuspendRecord->SuspendStart)); DEBUG ((EFI_D_INFO, "FPDT: S3 Suspend Performance - SuspendEnd = %ld\n", AcpiS3SuspendRecord->SuspendEnd)); + Status = PeiServicesLocatePpi ( + &gEfiPeiReadOnlyVariable2PpiGuid, + 0, + NULL, + (VOID **) &VariableServices + ); + ASSERT_EFI_ERROR (Status); + + // + // Update S3 boot records into the basic boot performance table. + // + VarSize = sizeof (PerformanceVariable); + Status = VariableServices->GetVariable ( + VariableServices, + EFI_FIRMWARE_PERFORMANCE_VARIABLE_NAME, + &gEfiFirmwarePerformanceGuid, + NULL, + &VarSize, + &PerformanceVariable + ); + if (EFI_ERROR (Status)) { +return Status; + } + BootPerformanceTable = (UINT8*) (UINTN) PerformanceVariable.BootPerformanceTablePointer; + + // + // Dump PEI boot records + // + FirmwarePerformanceTablePtr = (BootPerformanceTable + sizeof (BOOT_PERFORMANCE_TABLE)); + GuidHob = GetFirstGuidHob (&gEdkiiExtendedFirmwarePerformanceGuid); + while (GuidHob != NULL) { +FirmwarePerformanceData = GET_GUID_HOB_DATA (GuidHob); +PeiPerformanceLogHeader = (PEI_EXT_FIRMWARE_PERF_HEADER *) FirmwarePerformanceData; + +CopyMem (FirmwarePerformanceTablePtr, FirmwarePerformanceData + sizeof (PEI_EXT_FIRMWARE_PERF_HEADER), (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries)); + +GuidHob = GetNextGuidHob (&gEdkiiExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob)); + +FirmwarePerformanceTablePtr += (UINTN)(PeiPerformanceLogHeader->SizeOfAllEntries); + } + + // + // Update Table length. + // + ((BOOT_PERFORMANCE_TABLE *) BootPerformanceTable)->Header.Length = (UINT32)((UINTN)FirmwarePerformanceTablePtr - (UINTN)BootPerformanceTable); + return EFI_SUCCESS; } /** Main entry for Firmware Performance Data Table PEIM. diff --git a/MdeModulePkg/Universal/Acpi/Fi