From 857dfc455d7999f61c9b55f0a930c6b4087804b9 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Mon, 15 Dec 2008 15:56:02 +0000 Subject: [PATCH] Code scrub performance library instances in MdeModulePkg git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7037 6f19259b-4bc3-4df7-8a09-765794883524 --- .../DxeCorePerformanceLib.c | 34 +++++++++++++++---- .../DxeCorePerformanceLib.inf | 11 ++++-- .../DxeCorePerformanceLibInternal.h | 7 ++-- .../DxePerformanceLib/DxePerformanceLib.c | 12 +++++-- .../DxePerformanceLib/DxePerformanceLib.inf | 10 +++--- .../PeiPerformanceLib/PeiPerformanceLib.c | 7 +++- .../PeiPerformanceLib/PeiPerformanceLib.inf | 9 ++--- 7 files changed, 68 insertions(+), 22 deletions(-) diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 0b925b3c7d..f861d61430 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -1,5 +1,14 @@ /** @file - Support for measurement of DXE performance + Performance library instance mainly used by DxeCore. + + This library provides the performance measurement interfaces and initializes performance + logging for DXE phase. It first initializes its private global data structure for + performance logging and saves the performance GUIDed HOB passed from PEI phase. + It initializes DXE phase performance logging by publishing the Performance Protocol, + which is 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 - 2008, Intel Corporation.
All rights reserved. This program and the accompanying materials @@ -17,12 +26,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. // -// Definition for global variables. +// 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; + +// +// Interfaces for performance protocol. +// PERFORMANCE_PROTOCOL mPerformanceInterface = { StartGauge, EndGauge, @@ -122,7 +144,7 @@ StartGauge ( Index = mGaugeData->NumberOfEntries; if (Index >= mMaxGaugeRecords) { // - // Try to enlarge the scale of gauge arrary. + // Try to enlarge the scale of gauge array. // OldGaugeData = mGaugeData; OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords; @@ -135,7 +157,7 @@ StartGauge ( return EFI_OUT_OF_RESOURCES; } // - // Initialize new data arry and migrate old data one. + // Initialize new data array and migrate old data one. // mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize); @@ -224,7 +246,7 @@ EndGauge ( @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey if the retrieval is successful. - @retval EFI_SUCCESS The GuageDataEntry is successfuly found based on LogEntryKey. + @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey. @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number). @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number). @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. @@ -450,7 +472,7 @@ EndPerformanceMeasurement ( @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. + On exit, the key of the next performance log 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 diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf index 6e6324213d..704256dd18 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf @@ -1,8 +1,13 @@ #/** @file +# Performance library instance mainly for DxeCore usage. # -# Component description file for DxeCore Performance Library -# -# This library provides intrastructure for DxeCore to log performance. +# This library provides the performance measurement interfaces and initializes performance +# logging for DXE phase. It first initializes its private global data structure for +# performance logging and saves the performance GUIDed HOB passed from PEI phase. +# It initializes DXE phase performance logging by publishing the Performance Protocol, +# which is 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 - 2008, Intel Corporation.
# All rights reserved. This program and the accompanying materials diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h index 1c02959e26..cfa35fa847 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h @@ -1,5 +1,8 @@ /** @file - Module functions' declarations are included here. + Master header files for DxeCorePerformanceLib instance. + + This header file holds the prototypes of the Performance Protocol published by this + library instance at its constructor. Copyright (c) 2006 - 2008, Intel Corporation.
All rights reserved. This program and the accompanying materials @@ -111,7 +114,7 @@ EndGauge ( @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey if the retrieval is successful. - @retval EFI_SUCCESS The GuageDataEntry is successfuly found based on LogEntryKey. + @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey. @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number). @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number). @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c index 35a50f726b..8da302769a 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c @@ -1,7 +1,12 @@ /** @file Performance Library -Copyright (c) 2006 - 2008, Intel Corporation.
+ This library instance provides infrastructure for DXE phase drivers to log performance + data. It consumes Performance Protocol published by DxeCorePerformanceLib + to log performance data. If Performance Protocol is not available, it does not log any + performance information. + + Copyright (c) 2006 - 2008, 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 @@ -22,6 +27,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +// +// The cached performance protocol interface. +// PERFORMANCE_PROTOCOL *mPerformance = NULL; /** @@ -165,7 +173,7 @@ EndPerformanceMeasurement ( @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. + On exit, the key of the next performance log 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 diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf index ff1f03b3c9..70c19db97a 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf @@ -1,8 +1,10 @@ #/** @file +# Performance library instance used in DXE phase. # -# Component description file for Dxe Performance Library -# -# This library provides intrastructure for Dxe driver to log performance. +# This library instance provides infrastructure for DXE phase drivers to log performance +# data. It consumes Performance Protocol published by DxeCorePerformanceLib +# to log performance data. If Performance Protocol is not available, it does not log any +# performance information. # # Copyright (c) 2006 - 2008, Intel Corporation.
# All rights reserved. This program and the accompanying materials @@ -45,7 +47,7 @@ [Protocols] - gPerformanceProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gPerformanceProtocolGuid [Pcd.common] diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 64b488369a..97dfd0d817 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -1,5 +1,10 @@ /** @file - Performance Library + Performance library instance used in PEI phase. + + This file implements all APIs in Performance Library class in MdePkg. It creates + 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. Copyright (c) 2006 - 2008, Intel Corporation.
All rights reserved. This program and the accompanying materials diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf index d3f611c225..8913239ca7 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf @@ -1,9 +1,10 @@ #/** @file # -# Memory-only library functions with no library constructor/destructor +# Performance library instance used in PEI phase. # -# This module provides the performance measurement interfaces in PEI phase, it is -# one instance of Performance Libarary. +# This library provides the performance measurement interfaces in PEI phase, it creates +# and consumes GUIDed HOB for performance logging. The GUIDed HOB is passed to DXE phase +# so that it can be taken over by DxeCorePerformanceLib. # # Copyright (c) 2006 - 2008, Intel Corporation.
# All rights reserved. This program and the accompanying materials @@ -49,7 +50,7 @@ [Guids] - gPeiPerformanceHobGuid # SOMETIMES_CONSUMED + gPeiPerformanceHobGuid [Pcd.common] gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries -- 2.39.2