]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Store and get TSC Frequency with system configuration Table.
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Apr 2011 05:14:00 +0000 (05:14 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Apr 2011 05:14:00 +0000 (05:14 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11572 6f19259b-4bc3-4df7-8a09-765794883524

PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.c
PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf

index a77e33e219a34de211942f55ea4ef4be3ea38922..95f265558c2aec8b48a5faa4f7a243d8497677e6 100644 (file)
 #include <PiDxe.h>\r
 #include <Ich/GenericIch.h>\r
 \r
+#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/PciLib.h>\r
 #include <Library/PcdLib.h>\r
-#include <Library/HobLib.h>\r
+#include <Library/UefiLib.h>\r
 \r
 #include <Guid/TscFrequency.h>\r
 \r
-UINT64   mTscFrequency;\r
+UINT64 mTscFrequency;\r
 \r
 /** The constructor function determines the actual TSC frequency.\r
 \r
-  First, Get TSC frequency from TSC frequency GUID HOB,\r
-  If the HOB is not found, calculate it.\r
+  First, Get TSC frequency from system configuration table with TSC frequency GUID,\r
+  if the table is not found, install it.\r
 \r
   The TSC counting frequency is determined by comparing how far it counts\r
   during a 1ms period as determined by the ACPI timer. The ACPI timer is\r
@@ -70,25 +71,24 @@ DxeTscTimerLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  EFI_HOB_GUID_TYPE       *GuidHob;\r
-  VOID        *DataInHob;\r
+  EFI_STATUS  Status;\r
+  UINT64      *TscFrequency;\r
   UINT64      StartTSC;\r
   UINT64      EndTSC;\r
   UINT32      TimerAddr;\r
   UINT32      Ticks;\r
 \r
   //\r
-  // Get TSC frequency from TSC frequency GUID HOB.\r
+  // Get TSC frequency from system configuration table with TSC frequency GUID.\r
   //\r
-  GuidHob = GetFirstGuidHob (&gEfiTscFrequencyGuid);\r
-  if (GuidHob != NULL) {\r
-    DataInHob = GET_GUID_HOB_DATA (GuidHob);\r
-    mTscFrequency = * (UINT64 *) DataInHob;\r
+  Status = EfiGetSystemConfigurationTable (&gEfiTscFrequencyGuid, (VOID **) &TscFrequency);\r
+  if (Status == EFI_SUCCESS) {\r
+    mTscFrequency = *TscFrequency;\r
     return EFI_SUCCESS;\r
   }\r
 \r
   //\r
-  // TSC frequency GUID HOB is not found, calculate it.\r
+  // TSC frequency GUID system configuration table is not found, install it.\r
   //\r
 \r
   //\r
@@ -122,8 +122,10 @@ DxeTscTimerLibConstructor (
                       1000                    // Number of ms in a second\r
                     );\r
   //\r
-  // mTscFrequency is now equal to the number of TSC counts per second\r
+  // mTscFrequency is now equal to the number of TSC counts per second, install system configuration table for it.\r
   //\r
+  gBS->InstallConfigurationTable (&gEfiTscFrequencyGuid, &mTscFrequency);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
index f56e5a20644ff601a4cc2189f2b63bb78c6b699c..28978d78c750e3d30092f31449c0bd1b9003b09c 100644 (file)
 \r
 \r
 [LibraryClasses]\r
+  UefiBootServicesTableLib\r
   PcdLib\r
   PciLib\r
   IoLib\r
   BaseLib\r
-  HobLib\r
+  UefiLib\r
 \r
 [Guids]\r
-  gEfiTscFrequencyGuid                          ## SOMETIMES_CONSUMES ## Hob\r
+  gEfiTscFrequencyGuid                          ## CONSUMES ## System Configuration Table\r
 \r
 [Pcd.common]\r
   gPerformancePkgTokenSpaceGuid.PcdPerfPkgAcpiIoPortBaseAddress\r