summaryrefslogtreecommitdiff
path: root/PerformancePkg
diff options
context:
space:
mode:
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-02-15 02:02:06 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-02-15 02:02:06 +0000
commitd50f6f8be8e2a738ac1422364963a6936e02d13d (patch)
treea1db29a793ca850a24a1b14f94195d2285296ca3 /PerformancePkg
parentb7bc11a4ff619ad03fce5b76b9c957563b16d2d8 (diff)
downloadedk2-d50f6f8be8e2a738ac1422364963a6936e02d13d.zip
edk2-d50f6f8be8e2a738ac1422364963a6936e02d13d.tar.gz
edk2-d50f6f8be8e2a738ac1422364963a6936e02d13d.tar.bz2
TscTimerLib in PerformancePkg is a BASE type library, which should be used by any module type.
But its constructor uses the global variable mTscFrequency to store frequency, which doesn't work on XIP PEIM. Split it to two LIBs for PEI and DXE separately. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11312 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'PerformancePkg')
-rw-r--r--PerformancePkg/Include/Guid/PerformancePkgTokenSpace.h25
-rw-r--r--PerformancePkg/Include/Guid/TscFrequency.h25
-rw-r--r--PerformancePkg/Include/Ich/GenericIch.h3
-rw-r--r--PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c (renamed from PerformancePkg/Library/TscTimerLib/TscTimerLib.c)66
-rw-r--r--PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf56
-rw-r--r--PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.c265
-rw-r--r--PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.inf (renamed from PerformancePkg/Library/TscTimerLib/TscTimerLib.inf)20
-rw-r--r--PerformancePkg/PerformancePkg.dec5
-rw-r--r--PerformancePkg/PerformancePkg.dsc8
9 files changed, 440 insertions, 33 deletions
diff --git a/PerformancePkg/Include/Guid/PerformancePkgTokenSpace.h b/PerformancePkg/Include/Guid/PerformancePkgTokenSpace.h
new file mode 100644
index 0000000..86dfe87
--- /dev/null
+++ b/PerformancePkg/Include/Guid/PerformancePkgTokenSpace.h
@@ -0,0 +1,25 @@
+/** @file
+ GUID for PerformancePkg PCD Token Space
+
+ Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+ 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.
+
+**/
+
+#ifndef _PERFORMANCEPKG_TOKEN_SPACE_GUID_H_
+#define _PERFORMANCEPKG_TOKEN_SPACE_GUID_H_
+
+#define PERFORMANCEPKG_TOKEN_SPACE_GUID \
+ { \
+ 0x669346ef, 0xFDad, 0x4aeb, { 0x08, 0xa6, 0x21, 0x46, 0x2d, 0x3f, 0xef, 0x7d } \
+ }
+
+extern EFI_GUID gPerformancePkgTokenSpaceGuid;
+
+#endif
diff --git a/PerformancePkg/Include/Guid/TscFrequency.h b/PerformancePkg/Include/Guid/TscFrequency.h
new file mode 100644
index 0000000..f7c4a1c
--- /dev/null
+++ b/PerformancePkg/Include/Guid/TscFrequency.h
@@ -0,0 +1,25 @@
+/** @file
+ GUID for TSC frequency
+
+ Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+ 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.
+
+**/
+
+#ifndef _TSC_FREQUENCY_GUID_H_
+#define _TSC_FREQUENCY_GUID_H_
+
+#define EFI_TSC_FREQUENCY_GUID \
+ { \
+ 0xdba6a7e3, 0xbb57, 0x4be7, { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \
+ }
+
+extern EFI_GUID gEfiTscFrequencyGuid;
+
+#endif
diff --git a/PerformancePkg/Include/Ich/GenericIch.h b/PerformancePkg/Include/Ich/GenericIch.h
index 8df74e1..697ea04 100644
--- a/PerformancePkg/Include/Ich/GenericIch.h
+++ b/PerformancePkg/Include/Ich/GenericIch.h
@@ -3,7 +3,7 @@
These definitions should work for any version of Ich.
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
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
@@ -35,6 +35,7 @@ Definitions beginning with "V_" are meaningful values of bits within the registe
/// IchAcpiCntr Control for the ICH's ACPI Counter.
///@{
#define R_ICH_LPC_ACPI_BASE 0x40
+#define B_ICH_LPC_ACPI_BASE_BAR 0x0000FF80
#define R_ICH_LPC_ACPI_CNT 0x44
#define B_ICH_LPC_ACPI_CNT_ACPI_EN 0x80
///@}
diff --git a/PerformancePkg/Library/TscTimerLib/TscTimerLib.c b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c
index 69d93ce..f8a4b68 100644
--- a/PerformancePkg/Library/TscTimerLib/TscTimerLib.c
+++ b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c
@@ -1,5 +1,5 @@
/** @file
- A Timer Library implementation which uses the Time Stamp Counter in the processor.
+ A Dxe Timer Library implementation which uses the Time Stamp Counter in the processor.
For Pentium 4 processors, Intel Xeon processors (family [0FH], models [03H and higher]);
for Intel Core Solo and Intel Core Duo processors (family [06H], model [0EH]);
@@ -13,14 +13,14 @@
The specific processor configuration determines the behavior. Constant TSC behavior ensures that the
duration of each clock tick is uniform and supports the use of the TSC as a wall clock timer even if
- the processor core changes frequency. This is the architectural behavior moving forward.
+ the processor core changes frequency. This is the architectural behavior moving forward.
A Processor's support for invariant TSC is indicated by CPUID.0x80000007.EDX[8].
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
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
+ 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,
@@ -28,7 +28,7 @@
**/
-#include <Base.h>
+#include <PiDxe.h>
#include <Ich/GenericIch.h>
#include <Library/TimerLib.h>
@@ -36,36 +36,59 @@
#include <Library/IoLib.h>
#include <Library/PciLib.h>
#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
-STATIC UINT64 mTscFrequency;
+#include <Guid/TscFrequency.h>
+
+UINT64 mTscFrequency;
/** The constructor function determines the actual TSC frequency.
+ First, Get TSC frequency from TSC frequency GUID HOB,
+ If the HOB is not found, calculate it.
+
The TSC counting frequency is determined by comparing how far it counts
- during a 1ms period as determined by the ACPI timer. The ACPI timer is
+ during a 1ms period as determined by the ACPI timer. The ACPI timer is
used because it counts at a known frequency.
- If ACPI I/O space not enabled, this function will enable it. Then the
+ If ACPI I/O space not enabled, this function will enable it. Then the
TSC is sampled, followed by waiting for 3579 clocks of the ACPI timer, or 1ms.
The TSC is then sampled again. The difference multiplied by 1000 is the TSC
- frequency. There will be a small error because of the overhead of reading
- the ACPI timer. An attempt is made to determine and compensate for this error.
- This function will always return RETURN_SUCCESS.
+ frequency. There will be a small error because of the overhead of reading
+ the ACPI timer. An attempt is made to determine and compensate for this error.
+ This function will always return EFI_SUCCESS.
- @retval RETURN_SUCCESS The constructor always returns RETURN_SUCCESS.
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
**/
-RETURN_STATUS
+EFI_STATUS
EFIAPI
-TscTimerLibConstructor (
- VOID
+DxeTscTimerLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ VOID *DataInHob;
UINT64 StartTSC;
UINT64 EndTSC;
UINT32 TimerAddr;
UINT32 Ticks;
//
+ // Get TSC frequency from TSC frequency GUID HOB.
+ //
+ GuidHob = GetFirstGuidHob (&gEfiTscFrequencyGuid);
+ if (GuidHob != NULL) {
+ DataInHob = GET_GUID_HOB_DATA (GuidHob);
+ mTscFrequency = * (UINT64 *) DataInHob;
+ return EFI_SUCCESS;
+ }
+
+ //
+ // TSC frequency GUID HOB is not found, calculate it.
+ //
+
+ //
// If ACPI I/O space is not enabled yet, program ACPI I/O base address and enable it.
//
if ((PciRead8 (PCI_ICH_LPC_ADDRESS (R_ICH_LPC_ACPI_CNT)) & B_ICH_LPC_ACPI_CNT_ACPI_EN) == 0) {
@@ -73,15 +96,20 @@ TscTimerLibConstructor (
PciOr8 (PCI_ICH_LPC_ADDRESS (R_ICH_LPC_ACPI_CNT), B_ICH_LPC_ACPI_CNT_ACPI_EN);
}
- TimerAddr = PcdGet16 (PcdPerfPkgAcpiIoPortBaseAddress) + R_ACPI_PM1_TMR; // Locate the ACPI Timer
- Ticks = IoRead32( TimerAddr) + (3579); // Set Ticks to 1ms in the future
+ //
+ // ACPI I/O space should be enabled now, locate the ACPI Timer.
+ // ACPI I/O base address maybe have be initialized by other driver with different value,
+ // So get it from PCI space directly.
+ //
+ TimerAddr = ((PciRead16 (PCI_ICH_LPC_ADDRESS (R_ICH_LPC_ACPI_BASE))) & B_ICH_LPC_ACPI_BASE_BAR) + R_ACPI_PM1_TMR;
+ Ticks = IoRead32 (TimerAddr) + (3579); // Set Ticks to 1ms in the future
StartTSC = AsmReadTsc(); // Get base value for the TSC
//
// Wait until the ACPI timer has counted 1ms.
// Timer wrap-arounds are handled correctly by this function.
// When the current ACPI timer value is greater than 'Ticks', the while loop will exit.
//
- while (((Ticks - IoRead32( TimerAddr)) & BIT23) == 0) {
+ while (((Ticks - IoRead32 (TimerAddr)) & BIT23) == 0) {
CpuPause();
}
EndTSC = AsmReadTsc(); // TSC value 1ms later
@@ -93,7 +121,7 @@ TscTimerLibConstructor (
//
// mTscFrequency is now equal to the number of TSC counts per second
//
- return RETURN_SUCCESS;
+ return EFI_SUCCESS;
}
/** Stalls the CPU for at least the given number of ticks.
diff --git a/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
new file mode 100644
index 0000000..88a6cb9
--- /dev/null
+++ b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
@@ -0,0 +1,56 @@
+#/** @file
+# Dxe Timer Library which uses the Time Stamp Counter in the processor.
+#
+# A version of the Timer Library using the processor's TSC.
+# The time stamp counter in newer processors may support an enhancement, referred to as invariant TSC.
+# The invariant TSC runs at a constant rate in all ACPI P-, C-. and T-states.
+# This is the architectural behavior moving forward.
+# TSC reads are much more efficient and do not incur the overhead associated with a ring transition or
+# access to a platform resource.
+#
+# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+# 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.
+#
+#**/
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTscTimerLib
+ FILE_GUID = 95ab030f-b4fd-4ee4-92a5-9e04e87634d9
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+ CONSTRUCTOR = DxeTscTimerLibConstructor
+
+
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources.common]
+ DxeTscTimerLib.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ PerformancePkg/PerformancePkg.dec
+
+
+[LibraryClasses]
+ PcdLib
+ PciLib
+ IoLib
+ BaseLib
+ HobLib
+
+[Guids]
+ gEfiTscFrequencyGuid ## SOMETIMES_CONSUMES ## Hob
+
+[Pcd.common]
+ gPerformancePkgTokenSpaceGuid.PcdPerfPkgAcpiIoPortBaseAddress
diff --git a/PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.c b/PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.c
new file mode 100644
index 0000000..be6b66e
--- /dev/null
+++ b/PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.c
@@ -0,0 +1,265 @@
+/** @file
+ A Pei Timer Library implementation which uses the Time Stamp Counter in the processor.
+
+ For Pentium 4 processors, Intel Xeon processors (family [0FH], models [03H and higher]);
+ for Intel Core Solo and Intel Core Duo processors (family [06H], model [0EH]);
+ for the Intel Xeon processor 5100 series and Intel Core 2 Duo processors (family [06H], model [0FH]);
+ for Intel Core 2 and Intel Xeon processors (family [06H], display_model [17H]);
+ for Intel Atom processors (family [06H], display_model [1CH]):
+ the time-stamp counter increments at a constant rate.
+ That rate may be set by the maximum core-clock to bus-clock ratio of the processor or may be set by
+ the maximum resolved frequency at which the processor is booted. The maximum resolved frequency may
+ differ from the maximum qualified frequency of the processor.
+
+ The specific processor configuration determines the behavior. Constant TSC behavior ensures that the
+ duration of each clock tick is uniform and supports the use of the TSC as a wall clock timer even if
+ the processor core changes frequency. This is the architectural behavior moving forward.
+
+ A Processor's support for invariant TSC is indicated by CPUID.0x80000007.EDX[8].
+
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+ 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 <PiPei.h>
+#include <Ich/GenericIch.h>
+
+#include <Library/TimerLib.h>
+#include <Library/BaseLib.h>
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+
+#include <Guid/TscFrequency.h>
+
+/** Get TSC frequency from TSC frequency GUID HOB, if the HOB is not found, build it.
+
+ The TSC counting frequency is determined by comparing how far it counts
+ during a 1ms period as determined by the ACPI timer. The ACPI timer is
+ used because it counts at a known frequency.
+ If ACPI I/O space not enabled, this function will enable it. Then the
+ TSC is sampled, followed by waiting for 3579 clocks of the ACPI timer, or 1ms.
+ The TSC is then sampled again. The difference multiplied by 1000 is the TSC
+ frequency. There will be a small error because of the overhead of reading
+ the ACPI timer.
+
+ @return The number of TSC counts per second.
+
+**/
+UINT64
+InternalGetTscFrequency (
+ VOID
+ )
+{
+ EFI_HOB_GUID_TYPE *GuidHob;
+ VOID *DataInHob;
+ UINT64 StartTSC;
+ UINT64 EndTSC;
+ UINT32 TimerAddr;
+ UINT32 Ticks;
+ UINT64 TscFrequency;
+
+ //
+ // Get TSC frequency from TSC frequency GUID HOB.
+ //
+ GuidHob = GetFirstGuidHob (&gEfiTscFrequencyGuid);
+ if (GuidHob != NULL) {
+ DataInHob = GET_GUID_HOB_DATA (GuidHob);
+ TscFrequency = * (UINT64 *) DataInHob;
+ return TscFrequency;
+ }
+
+ //
+ // TSC frequency GUID HOB is not found, build it.
+ //
+
+ //
+ // If ACPI I/O space is not enabled yet, program ACPI I/O base address and enable it.
+ //
+ if ((PciRead8 (PCI_ICH_LPC_ADDRESS (R_ICH_LPC_ACPI_CNT)) & B_ICH_LPC_ACPI_CNT_ACPI_EN) == 0) {
+ PciWrite16 (PCI_ICH_LPC_ADDRESS (R_ICH_LPC_ACPI_BASE), PcdGet16 (PcdPerfPkgAcpiIoPortBaseAddress));
+ PciOr8 (PCI_ICH_LPC_ADDRESS (R_ICH_LPC_ACPI_CNT), B_ICH_LPC_ACPI_CNT_ACPI_EN);
+ }
+
+ //
+ // ACPI I/O space should be enabled now, locate the ACPI Timer.
+ // ACPI I/O base address maybe have be initialized by other driver with different value,
+ // So get it from PCI space directly.
+ //
+ TimerAddr = ((PciRead16 (PCI_ICH_LPC_ADDRESS (R_ICH_LPC_ACPI_BASE))) & B_ICH_LPC_ACPI_BASE_BAR) + R_ACPI_PM1_TMR;
+ Ticks = IoRead32 (TimerAddr) + (3579); // Set Ticks to 1ms in the future
+ StartTSC = AsmReadTsc(); // Get base value for the TSC
+ //
+ // Wait until the ACPI timer has counted 1ms.
+ // Timer wrap-arounds are handled correctly by this function.
+ // When the current ACPI timer value is greater than 'Ticks', the while loop will exit.
+ //
+ while (((Ticks - IoRead32 (TimerAddr)) & BIT23) == 0) {
+ CpuPause();
+ }
+ EndTSC = AsmReadTsc(); // TSC value 1ms later
+
+ TscFrequency = MultU64x32 (
+ (EndTSC - StartTSC), // Number of TSC counts in 1ms
+ 1000 // Number of ms in a second
+ );
+ //
+ // TscFrequency is now equal to the number of TSC counts per second, build GUID HOB for it.
+ //
+ BuildGuidDataHob (
+ &gEfiTscFrequencyGuid,
+ &TscFrequency,
+ sizeof (UINT64)
+ );
+
+ return TscFrequency;
+}
+
+/** Stalls the CPU for at least the given number of ticks.
+
+ Stalls the CPU for at least the given number of ticks. It's invoked by
+ MicroSecondDelay() and NanoSecondDelay().
+
+ @param[in] Delay A period of time to delay in ticks.
+
+**/
+VOID
+InternalX86Delay (
+ IN UINT64 Delay
+ )
+{
+ UINT64 Ticks;
+
+ //
+ // The target timer count is calculated here
+ //
+ Ticks = AsmReadTsc() + Delay;
+
+ //
+ // Wait until time out
+ // Timer wrap-arounds are NOT handled correctly by this function.
+ // Thus, this function must be called within 10 years of reset since
+ // Intel guarantees a minimum of 10 years before the TSC wraps.
+ //
+ while (AsmReadTsc() <= Ticks) CpuPause();
+}
+
+/** Stalls the CPU for at least the specified number of MicroSeconds.
+
+ @param[in] MicroSeconds The minimum number of microseconds to delay.
+
+ @return The value of MicroSeconds input.
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+ IN UINTN MicroSeconds
+ )
+{
+ InternalX86Delay (
+ DivU64x32 (
+ MultU64x64 (
+ InternalGetTscFrequency (),
+ MicroSeconds
+ ),
+ 1000000u
+ )
+ );
+ return MicroSeconds;
+}
+
+/** Stalls the CPU for at least the specified number of NanoSeconds.
+
+ @param[in] NanoSeconds The minimum number of nanoseconds to delay.
+
+ @return The value of NanoSeconds input.
+
+**/
+UINTN
+EFIAPI
+NanoSecondDelay (
+ IN UINTN NanoSeconds
+ )
+{
+ InternalX86Delay (
+ DivU64x32 (
+ MultU64x32 (
+ InternalGetTscFrequency (),
+ (UINT32)NanoSeconds
+ ),
+ 1000000000u
+ )
+ );
+ return NanoSeconds;
+}
+
+/** Retrieves the current value of the 64-bit free running Time-Stamp counter.
+
+ The time-stamp counter (as implemented in the P6 family, Pentium, Pentium M,
+ Pentium 4, Intel Xeon, Intel Core Solo and Intel Core Duo processors and
+ later processors) is a 64-bit counter that is set to 0 following a RESET of
+ the processor. Following a RESET, the counter increments even when the
+ processor is halted by the HLT instruction or the external STPCLK# pin. Note
+ that the assertion of the external DPSLP# pin may cause the time-stamp
+ counter to stop.
+
+ The properties of the counter can be retrieved by the
+ GetPerformanceCounterProperties() function.
+
+ @return The current value of the free running performance counter.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounter (
+ VOID
+ )
+{
+ return AsmReadTsc();
+}
+
+/** Retrieves the 64-bit frequency in Hz and the range of performance counter
+ values.
+
+ If StartValue is not NULL, then the value that the performance counter starts
+ with, 0x0, is returned in StartValue. If EndValue is not NULL, then the value
+ that the performance counter end with, 0xFFFFFFFFFFFFFFFF, is returned in
+ EndValue.
+
+ The 64-bit frequency of the performance counter, in Hz, is always returned.
+ To determine average processor clock frequency, Intel recommends the use of
+ EMON logic to count processor core clocks over the period of time for which
+ the average is required.
+
+
+ @param[out] StartValue Pointer to where the performance counter's starting value is saved, or NULL.
+ @param[out] EndValue Pointer to where the performance counter's ending value is saved, or NULL.
+
+ @return The frequency in Hz.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounterProperties (
+ OUT UINT64 *StartValue, OPTIONAL
+ OUT UINT64 *EndValue OPTIONAL
+ )
+{
+ if (StartValue != NULL) {
+ *StartValue = 0;
+ }
+ if (EndValue != NULL) {
+ *EndValue = 0xFFFFFFFFFFFFFFFFull;
+ }
+
+ return InternalGetTscFrequency ();
+}
diff --git a/PerformancePkg/Library/TscTimerLib/TscTimerLib.inf b/PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.inf
index 7c17ecd..3c10519 100644
--- a/PerformancePkg/Library/TscTimerLib/TscTimerLib.inf
+++ b/PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.inf
@@ -1,5 +1,5 @@
#/** @file
-# Timer Library which uses the Time Stamp Counter in the processor.
+# Pei Timer Library which uses the Time Stamp Counter in the processor.
#
# A version of the Timer Library using the processor's TSC.
# The time stamp counter in newer processors may support an enhancement, referred to as invariant TSC.
@@ -8,7 +8,7 @@
# TSC reads are much more efficient and do not incur the overhead associated with a ring transition or
# access to a platform resource.
#
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
# 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
@@ -20,13 +20,11 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = TscTimerLib
- FILE_GUID = 95ab030f-b4fd-4ee4-92a5-9e04e87634d9
- MODULE_TYPE = BASE
+ BASE_NAME = PeiTscTimerLib
+ FILE_GUID = 342C36C0-15DF-43b4-9EC9-FBF748BFB3D1
+ MODULE_TYPE = PEIM
VERSION_STRING = 1.0
- LIBRARY_CLASS = TimerLib
-
- CONSTRUCTOR = TscTimerLibConstructor
+ LIBRARY_CLASS = TimerLib|SEC PEIM PEI_CORE
#
@@ -34,7 +32,7 @@
#
[Sources.common]
- TscTimerLib.c
+ PeiTscTimerLib.c
[Packages]
@@ -47,6 +45,10 @@
PciLib
IoLib
BaseLib
+ HobLib
+
+[Guids]
+ gEfiTscFrequencyGuid ## PRODUCES ## Hob
[Pcd.common]
gPerformancePkgTokenSpaceGuid.PcdPerfPkgAcpiIoPortBaseAddress
diff --git a/PerformancePkg/PerformancePkg.dec b/PerformancePkg/PerformancePkg.dec
index 52091b6..44f1f10 100644
--- a/PerformancePkg/PerformancePkg.dec
+++ b/PerformancePkg/PerformancePkg.dec
@@ -2,7 +2,7 @@
# Build description file to generate Shell DP application and
# Performance Libraries.
#
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
# 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
@@ -28,6 +28,9 @@
# 669346ef-fdad-4aeb-a608-7def3f2d4621
gPerformancePkgTokenSpaceGuid = { 0x669346ef, 0xFDad, 0x4aeb, { 0x08, 0xa6, 0x21, 0x46, 0x2d, 0x3f, 0xef, 0x7d }}
+ ## Include/Guid/TscFrequency.h
+ gEfiTscFrequencyGuid = { 0xdba6a7e3, 0xbb57, 0x4be7, { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 }}
+
[PcdsFixedAtBuild.common]
## The base address of the ACPI registers within the ICH PCI space.
# This space must be 128-byte aligned.
diff --git a/PerformancePkg/PerformancePkg.dsc b/PerformancePkg/PerformancePkg.dsc
index 414c17e..ea38387 100644
--- a/PerformancePkg/PerformancePkg.dsc
+++ b/PerformancePkg/PerformancePkg.dsc
@@ -1,7 +1,7 @@
#/** @file
# Build description file to generate Shell DP application.
#
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
# 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
@@ -35,6 +35,7 @@
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
+ HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
@@ -60,14 +61,15 @@
# that is different than the one below.
#
# TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
- TimerLib|PerformancePkg/Library/TscTimerLib/TscTimerLib.inf
+ TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
[LibraryClasses.IPF]
PalLib|MdePkg/Library/UefiPalLib/UefiPalLib.inf
TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
[Components.IA32, Components.X64]
- PerformancePkg/Library/TscTimerLib/TscTimerLib.inf
+ PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
+ PerformancePkg/Library/PeiTscTimerLib/PeiTscTimerLib.inf
[Components]
PerformancePkg/Dp_App/Dp.inf