X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=EdkModulePkg%2FLibrary%2FDxeCorePerformanceLib%2FDxeCorePerformanceLib.c;h=5874902e2e37c0f6521a6bc3bb08a06887ca4bd7;hp=c75ab851f70c2377b60e874c05f0041fde7ab5a7;hb=23c2f30c5ec63ab509991f1ddcdd6108fc53ba91;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4 diff --git a/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index c75ab851f7..5874902e2e 100644 --- a/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/EdkModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -118,7 +118,8 @@ GetGauge ( STATIC GAUGE_DATA_HEADER *mGaugeData; STATIC UINT32 mMaxGaugeRecords; -PERFORMANCE_PROTOCOL PerformanceInterface = { +EFI_HANDLE mHandle = NULL; +PERFORMANCE_PROTOCOL mPerformanceInterface = { StartGauge, EndGauge, GetGauge @@ -213,7 +214,6 @@ StartGauge ( UINTN GaugeDataSize; UINTN OldGaugeDataSize; GAUGE_DATA_HEADER *OldGaugeData; - EFI_STATUS Status; UINT32 Index; Index = mGaugeData->NumberOfEntries; @@ -223,21 +223,18 @@ StartGauge ( // OldGaugeData = mGaugeData; OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords; + mMaxGaugeRecords *= 2; GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords; - Status = gBS->AllocatePool ( - EfiBootServicesData, - GaugeDataSize, - (VOID **) &mGaugeData - ); - if (EFI_ERROR (Status)) { - return Status; + + mGaugeData = AllocateZeroPool (GaugeDataSize); + if (mGaugeData == NULL) { + return EFI_OUT_OF_RESOURCES; } // // Initialize new data arry and migrate old data one. // - mGaugeData = ZeroMem (mGaugeData, GaugeDataSize); - mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize); + mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize); gBS->FreePool (OldGaugeData); } @@ -423,31 +420,22 @@ DxeCorePerformanceLibConstructor ( ) { EFI_STATUS Status; - EFI_HANDLE Handle; - UINTN GaugeDataSize; // // Install the protocol interfaces. // - Handle = NULL; Status = gBS->InstallProtocolInterface ( - &Handle, + &mHandle, &gPerformanceProtocolGuid, EFI_NATIVE_INTERFACE, - &PerformanceInterface + &mPerformanceInterface ); ASSERT_EFI_ERROR (Status); mMaxGaugeRecords = INIT_DXE_GAUGE_DATA_ENTRIES + MAX_PEI_PERFORMANCE_LOG_ENTRIES; - GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords; - Status = gBS->AllocatePool ( - EfiBootServicesData, - GaugeDataSize, - (VOID **) &mGaugeData - ); - ASSERT_EFI_ERROR (Status); - ZeroMem (mGaugeData, GaugeDataSize); + mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords)); + ASSERT (mGaugeData != NULL); InternalGetPeiPerformance (); @@ -532,34 +520,46 @@ EndPerformanceMeasurement ( } /** - Retrieves a previously logged performance measurement. + Attempts to retrieve a performance measurement log entry from the performance measurement log. - Retrieves the performance log entry from the performance log - that immediately follows the log entry specified by LogEntryKey. - If LogEntryKey is zero, then the first entry from the performance log is returned. - If the log entry specified by LogEntryKey is the last entry in the performance log, - then 0 is returned. Otherwise, the performance log entry is returned in Handle, - Token, Module, StartTimeStamp, and EndTimeStamp. - The key for the current performance log entry is returned. - - @param LogEntryKey The key for the previous performance measurement log entry. - If 0, then the first performance measurement log entry is retrieved. - @param Handle Pointer to environment specific context used - to identify the component being measured. - @param Token Pointer to a Null-terminated ASCII string - that identifies the component being measured. - @param Module Pointer to a Null-terminated ASCII string - that identifies the module being measured. - @param StartTimeStamp The 64-bit time stamp that was recorded when the measurement was started. - @param EndTimeStamp The 64-bit time stamp that was recorded when the measurement was ended. - - @return The key for the current performance log entry. + Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is + zero on entry, then an attempt is made to retrieve the first entry from the performance log, + and the key for the second entry in the log is returned. If the performance log is empty, + then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance + log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is + returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is + retrieved and an implementation specific non-zero key value that specifies the end of the performance + log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry + is retrieved and zero is returned. In the cases where a performance log entry can be returned, + the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp. + If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT(). + If Handle is NULL, then ASSERT(). + If Token is NULL, then ASSERT(). + If Module is NULL, then ASSERT(). + If StartTimeStamp is NULL, then ASSERT(). + If EndTimeStamp is NULL, then ASSERT(). + + @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve. + 0, then the first performance measurement log entry is retrieved. + On exit, the key of the next performance lof entry entry. + @param Handle Pointer to environment specific context used to identify the component + being measured. + @param Token Pointer to a Null-terminated ASCII string that identifies the component + being measured. + @param Module Pointer to a Null-terminated ASCII string that identifies the module + being measured. + @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement + was started. + @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement + was ended. + + @return The key for the next performance log entry (in general case). **/ UINTN EFIAPI GetPerformanceMeasurement ( - UINTN LogEntryKey, + IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module,