]> git.proxmox.com Git - mirror_edk2.git/commitdiff
fixed assumption 32bit Local Apic timer counter.
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 14 Jan 2009 03:05:45 +0000 (03:05 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 14 Jan 2009 03:05:45 +0000 (03:05 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7266 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c

index c2a4199fb093b4839a884548d5e122df4b04901b..67a3c2cff8bab48b4e88ef70617072a4b0577363 100644 (file)
@@ -49,6 +49,7 @@
 [LibraryClasses.IA32, LibraryClasses.X64]\r
   PcdLib\r
   IoLib\r
+  DebugLib\r
 \r
 [LibraryClasses.IPF]\r
   PalLib\r
index 72c684e236c14652cdb9d230b5c730ef48dd54c0..aff51932f6d9643347ecfafb900d58f1c207d816 100644 (file)
 #include <Library/BaseLib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/DebugLib.h>\r
 \r
 #define APIC_LVTERR     0x370\r
-#define APIC_TMICT      0x380   \r
+#define APIC_TMICT      0x380\r
 #define APIC_TMCCT      0x390\r
 #define APIC_TDCR       0x3e0\r
 \r
@@ -115,7 +116,9 @@ InternalX86Delay (
   // Delay > 2^31 could not be handled by this function\r
   // Timer wrap-arounds are handled correctly by this function\r
   //\r
-  while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0);\r
+  while (((UINT32)(InternalX86GetTimerTick (ApicBase) - Ticks) & GetPowerOfTwo32 ((MmioRead32 (ApicBase + APIC_TMICT)))) == 0) {\r
+    CpuPause ();\r
+  }\r
 }\r
 \r
 /**\r
@@ -238,6 +241,10 @@ GetPerformanceCounterProperties (
 \r
   if (StartValue != NULL) {\r
     *StartValue = MmioRead32 (ApicBase + APIC_TMICT);\r
+    //\r
+    // make sure StartValue is all 1s from High Bit\r
+    //\r
+    ASSERT ((*StartValue & (*StartValue + 1)) == 0);\r
   }\r
 \r
   if (EndValue != NULL) {\r