From a176509a7f1fd0d78c0cc26d4c9543c8c871c4f3 Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Wed, 20 Apr 2011 05:14:00 +0000 Subject: [PATCH] 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 --- .../Library/DxeTscTimerLib/DxeTscTimerLib.c | 28 ++++++++++--------- .../Library/DxeTscTimerLib/DxeTscTimerLib.inf | 5 ++-- 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 #include +#include #include #include #include #include #include -#include +#include #include -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 -- 2.39.2