]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c
Code have been checked with spec
[mirror_edk2.git] / MdePkg / Library / SecPeiDxeTimerLibCpu / X86TimerLib.c
index 81b4c902979f9ed1bc9d6514c70852031607ad2a..72c684e236c14652cdb9d230b5c730ef48dd54c0 100644 (file)
 #include <Library/IoLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
+#define APIC_LVTERR     0x370\r
+#define APIC_TMICT      0x380   \r
+#define APIC_TMCCT      0x390\r
+#define APIC_TDCR       0x3e0\r
 \r
 //\r
 // The following array is used in calculating the frequency of local APIC\r
@@ -62,7 +66,7 @@ InternalX86GetTimerFrequency (
 {\r
   return\r
     PcdGet32(PcdFSBClock) /\r
-    mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + 0x3e0, 0, 3)];\r
+    mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + APIC_TDCR, 0, 3)];\r
 }\r
 \r
 /**\r
@@ -79,7 +83,7 @@ InternalX86GetTimerTick (
   IN      UINTN                     ApicBase\r
   )\r
 {\r
-  return MmioRead32 (ApicBase + 0x390);\r
+  return MmioRead32 (ApicBase + APIC_TMCCT);\r
 }\r
 \r
 /**\r
@@ -179,8 +183,9 @@ NanoSecondDelay (
 }\r
 \r
 /**\r
-  Retrieves the current value of a 64-bit free running performance counter. The\r
-  counter can either count up by 1 or count down by 1. If the physical\r
+  Retrieves the current value of a 64-bit free running performance counter.\r
+\r
+  The counter can either count up by 1 or count down by 1. If the physical\r
   performance counter counts by a larger increment, then the counter values\r
   must be translated. The properties of the counter can be retrieved from\r
   GetPerformanceCounterProperties().\r
@@ -232,12 +237,12 @@ GetPerformanceCounterProperties (
   ApicBase = InternalX86GetApicBase ();\r
 \r
   if (StartValue != NULL) {\r
-    *StartValue = MmioRead32 (ApicBase + 0x380);\r
+    *StartValue = MmioRead32 (ApicBase + APIC_TMICT);\r
   }\r
 \r
   if (EndValue != NULL) {\r
     *EndValue = 0;\r
   }\r
 \r
-  return (UINT64) InternalX86GetTimerFrequency (ApicBase);;\r
+  return (UINT64) InternalX86GetTimerFrequency (ApicBase);\r
 }\r