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
This commit is contained in:
qhuang8 2008-12-15 15:56:02 +00:00
parent e05e2b73fc
commit 857dfc455d
7 changed files with 68 additions and 22 deletions

View File

@ -1,5 +1,14 @@
/** @file /** @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. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials 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; 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; UINT32 mMaxGaugeRecords;
//
// The handle to install Performance Protocol instance.
//
EFI_HANDLE mHandle = NULL; EFI_HANDLE mHandle = NULL;
//
// Interfaces for performance protocol.
//
PERFORMANCE_PROTOCOL mPerformanceInterface = { PERFORMANCE_PROTOCOL mPerformanceInterface = {
StartGauge, StartGauge,
EndGauge, EndGauge,
@ -122,7 +144,7 @@ StartGauge (
Index = mGaugeData->NumberOfEntries; Index = mGaugeData->NumberOfEntries;
if (Index >= mMaxGaugeRecords) { if (Index >= mMaxGaugeRecords) {
// //
// Try to enlarge the scale of gauge arrary. // Try to enlarge the scale of gauge array.
// //
OldGaugeData = mGaugeData; OldGaugeData = mGaugeData;
OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords; OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
@ -135,7 +157,7 @@ StartGauge (
return EFI_OUT_OF_RESOURCES; 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); mGaugeData = CopyMem (mGaugeData, OldGaugeData, OldGaugeDataSize);
@ -224,7 +246,7 @@ EndGauge (
@param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
if the retrieval is successful. 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_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 The LogEntryKey is not a valid entry (greater than the total entry number).
@retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. @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. @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
0, then the first performance measurement log entry is retrieved. 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 @param Handle Pointer to environment specific context used to identify the component
being measured. being measured.
@param Token Pointer to a Null-terminated ASCII string that identifies the component @param Token Pointer to a Null-terminated ASCII string that identifies the component

View File

@ -1,8 +1,13 @@
#/** @file #/** @file
# Performance library instance mainly for DxeCore usage.
# #
# Component description file for DxeCore Performance Library # This library provides the performance measurement interfaces and initializes performance
# # logging for DXE phase. It first initializes its private global data structure for
# This library provides intrastructure for DxeCore to log performance. # 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. <BR> # Copyright (c) 2006 - 2008, Intel Corporation. <BR>
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials

View File

@ -1,5 +1,8 @@
/** @file /** @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. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials 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 @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
if the retrieval is successful. 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_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 The LogEntryKey is not a valid entry (greater than the total entry number).
@retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL. @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.

View File

@ -1,7 +1,12 @@
/** @file /** @file
Performance Library Performance Library
Copyright (c) 2006 - 2008, Intel Corporation. <BR> 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. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 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 <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
//
// The cached performance protocol interface.
//
PERFORMANCE_PROTOCOL *mPerformance = NULL; PERFORMANCE_PROTOCOL *mPerformance = NULL;
/** /**
@ -165,7 +173,7 @@ EndPerformanceMeasurement (
@param LogEntryKey On entry, the key of the performance measurement log entry to retrieve. @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
0, then the first performance measurement log entry is retrieved. 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 @param Handle Pointer to environment specific context used to identify the component
being measured. being measured.
@param Token Pointer to a Null-terminated ASCII string that identifies the component @param Token Pointer to a Null-terminated ASCII string that identifies the component

View File

@ -1,8 +1,10 @@
#/** @file #/** @file
# Performance library instance used in DXE phase.
# #
# Component description file for Dxe Performance Library # This library instance provides infrastructure for DXE phase drivers to log performance
# # data. It consumes Performance Protocol published by DxeCorePerformanceLib
# This library provides intrastructure for Dxe driver to log performance. # to log performance data. If Performance Protocol is not available, it does not log any
# performance information.
# #
# Copyright (c) 2006 - 2008, Intel Corporation. <BR> # Copyright (c) 2006 - 2008, Intel Corporation. <BR>
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
@ -45,7 +47,7 @@
[Protocols] [Protocols]
gPerformanceProtocolGuid # PROTOCOL ALWAYS_CONSUMED gPerformanceProtocolGuid
[Pcd.common] [Pcd.common]

View File

@ -1,5 +1,10 @@
/** @file /** @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. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials

View File

@ -1,9 +1,10 @@
#/** @file #/** @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 # This library provides the performance measurement interfaces in PEI phase, it creates
# one instance of Performance Libarary. # 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. <BR> # Copyright (c) 2006 - 2008, Intel Corporation. <BR>
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
@ -49,7 +50,7 @@
[Guids] [Guids]
gPeiPerformanceHobGuid # SOMETIMES_CONSUMED gPeiPerformanceHobGuid
[Pcd.common] [Pcd.common]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries