summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-01-14 03:05:45 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-01-14 03:05:45 +0000
commit1553d073632e1307950f8648444071a0ec27759f (patch)
tree0de54d8bb029522fcc15db4fc4a74c51c6f091fe
parent6ef5ab88d7a8246114701cdacff674aefcf5813e (diff)
downloadedk2-platforms-1553d073632e1307950f8648444071a0ec27759f.tar.xz
fixed assumption 32bit Local Apic timer counter.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7266 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf1
-rw-r--r--MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c11
2 files changed, 10 insertions, 2 deletions
diff --git a/MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf b/MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
index c2a4199fb0..67a3c2cff8 100644
--- a/MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
+++ b/MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
@@ -49,6 +49,7 @@
[LibraryClasses.IA32, LibraryClasses.X64]
PcdLib
IoLib
+ DebugLib
[LibraryClasses.IPF]
PalLib
diff --git a/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c b/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c
index 72c684e236..aff51932f6 100644
--- a/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c
+++ b/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c
@@ -17,9 +17,10 @@
#include <Library/BaseLib.h>
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
+#include <Library/DebugLib.h>
#define APIC_LVTERR 0x370
-#define APIC_TMICT 0x380
+#define APIC_TMICT 0x380
#define APIC_TMCCT 0x390
#define APIC_TDCR 0x3e0
@@ -115,7 +116,9 @@ InternalX86Delay (
// Delay > 2^31 could not be handled by this function
// Timer wrap-arounds are handled correctly by this function
//
- while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0);
+ while (((UINT32)(InternalX86GetTimerTick (ApicBase) - Ticks) & GetPowerOfTwo32 ((MmioRead32 (ApicBase + APIC_TMICT)))) == 0) {
+ CpuPause ();
+ }
}
/**
@@ -238,6 +241,10 @@ GetPerformanceCounterProperties (
if (StartValue != NULL) {
*StartValue = MmioRead32 (ApicBase + APIC_TMICT);
+ //
+ // make sure StartValue is all 1s from High Bit
+ //
+ ASSERT ((*StartValue & (*StartValue + 1)) == 0);
}
if (EndValue != NULL) {