summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-20 05:14:00 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-04-20 05:14:00 +0000
commita176509a7f1fd0d78c0cc26d4c9543c8c871c4f3 (patch)
treeda003f9d811f6fb0b8d98c853a881e8dc26380ee
parent0ec4f1cb6f97913de807964695e6a0d3e9455341 (diff)
downloadedk2-a176509a7f1fd0d78c0cc26d4c9543c8c871c4f3.tar.gz
edk2-a176509a7f1fd0d78c0cc26d4c9543c8c871c4f3.tar.bz2
edk2-a176509a7f1fd0d78c0cc26d4c9543c8c871c4f3.zip
Store and get TSC Frequency with system configuration Table.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11572 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c28
-rw-r--r--PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf5
2 files changed, 18 insertions, 15 deletions
diff --git a/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c
index a77e33e219..95f265558c 100644
--- a/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c
+++ b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c
@@ -31,21 +31,22 @@
#include <PiDxe.h>
#include <Ich/GenericIch.h>
+#include <Library/UefiBootServicesTableLib.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 <Library/UefiLib.h>
#include <Guid/TscFrequency.h>
-UINT64 mTscFrequency;
+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.
+ First, Get TSC frequency from system configuration table with TSC frequency GUID,
+ if the table is not found, install 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
@@ -70,25 +71,24 @@ DxeTscTimerLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_HOB_GUID_TYPE *GuidHob;
- VOID *DataInHob;
+ EFI_STATUS Status;
+ UINT64 *TscFrequency;
UINT64 StartTSC;
UINT64 EndTSC;
UINT32 TimerAddr;
UINT32 Ticks;
//
- // Get TSC frequency from TSC frequency GUID HOB.
+ // Get TSC frequency from system configuration table with TSC frequency GUID.
//
- GuidHob = GetFirstGuidHob (&gEfiTscFrequencyGuid);
- if (GuidHob != NULL) {
- DataInHob = GET_GUID_HOB_DATA (GuidHob);
- mTscFrequency = * (UINT64 *) DataInHob;
+ Status = EfiGetSystemConfigurationTable (&gEfiTscFrequencyGuid, (VOID **) &TscFrequency);
+ if (Status == EFI_SUCCESS) {
+ mTscFrequency = *TscFrequency;
return EFI_SUCCESS;
}
//
- // TSC frequency GUID HOB is not found, calculate it.
+ // TSC frequency GUID system configuration table is not found, install it.
//
//
@@ -122,8 +122,10 @@ DxeTscTimerLibConstructor (
1000 // Number of ms in a second
);
//
- // mTscFrequency is now equal to the number of TSC counts per second
+ // mTscFrequency is now equal to the number of TSC counts per second, install system configuration table for it.
//
+ gBS->InstallConfigurationTable (&gEfiTscFrequencyGuid, &mTscFrequency);
+
return EFI_SUCCESS;
}
diff --git a/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
index f56e5a2064..28978d78c7 100644
--- a/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
+++ b/PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
@@ -43,14 +43,15 @@
[LibraryClasses]
+ UefiBootServicesTableLib
PcdLib
PciLib
IoLib
BaseLib
- HobLib
+ UefiLib
[Guids]
- gEfiTscFrequencyGuid ## SOMETIMES_CONSUMES ## Hob
+ gEfiTscFrequencyGuid ## CONSUMES ## System Configuration Table
[Pcd.common]
gPerformancePkgTokenSpaceGuid.PcdPerfPkgAcpiIoPortBaseAddress