]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/SecPeiDxeTimerLibCpu/IpfTimerLib.c
Since PciXXXReadBuffer/PciXXXWriteBuffer does not check the alignment of user buffer...
[mirror_edk2.git] / MdePkg / Library / SecPeiDxeTimerLibCpu / IpfTimerLib.c
index 8f7651519ed4f26130b4a0f3e24d62a33f1b5b09..cb5c6d4b739ce4c5f328ddad01ddbfaea873003b 100644 (file)
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-  Module Name:  IpfTimerLib.c\r
-\r
 **/\r
 \r
-\r
+#include <Base.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/PalCallLib.h>\r
 \r
 \r
 /**\r
@@ -37,14 +41,14 @@ InternalIpfDelay (
   //\r
   // The target timer count is calculated here\r
   //\r
-  Ticks = IpfReadItc () + Delay;\r
+  Ticks = (INT64)AsmReadItc () + Delay;\r
 \r
   //\r
   // Wait until time out\r
   // Delay > 2^63 could not be handled by this function\r
   // Timer wrap-arounds are handled correctly by this function\r
   //\r
-  while (Ticks - IpfReadItc () >= 0);\r
+  while (Ticks - (INT64)AsmReadItc() >= 0);\r
 }\r
 \r
 /**\r
@@ -113,7 +117,7 @@ GetPerformanceCounter (
   VOID\r
   )\r
 {\r
-  return IpfReadItc ();\r
+  return AsmReadItc ();\r
 }\r
 \r
 /**\r
@@ -146,16 +150,9 @@ GetPerformanceCounterProperties (
   OUT      UINT64                    *EndValue     OPTIONAL\r
   )\r
 {\r
-  PAL_PROC_RETURN                   PalRet;\r
+  PAL_CALL_RETURN                   PalRet;\r
   UINT64                            BaseFrequence;\r
 \r
-  PalRet = PalCallStatic (NULL, 13, 0, 0, 0);\r
-  ASSERT (PalRet.Status == 0);\r
-  BaseFrequence = PalRet.r9;\r
-\r
-  PalRet = PalCallStatic (NULL, 14, 0, 0, 0);\r
-  ASSERT (PalRet.Status == 0);\r
-\r
   if (StartValue != NULL) {\r
     *StartValue = 0;\r
   }\r
@@ -164,5 +161,16 @@ GetPerformanceCounterProperties (
     *EndValue = (UINT64)(-1);\r
   }\r
 \r
+  PalRet = PalCall (PAL_FREQ_BASE, 0, 0, 0);\r
+  if (PalRet.Status != 0) {\r
+    return 1000000;\r
+  }\r
+  BaseFrequence = PalRet.r9;\r
+\r
+  PalRet = PalCall (PAL_FREQ_RATIOS, 0, 0, 0);\r
+  if (PalRet.Status != 0) {\r
+    return 1000000;\r
+  }\r
+\r
   return BaseFrequence * (PalRet.r11 >> 32) / (UINT32)PalRet.r11;\r
 }\r