]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/SecPeiDxeTimerLibCpu/IpfTimerLib.c
Update the copyright notice format
[mirror_edk2.git] / MdePkg / Library / SecPeiDxeTimerLibCpu / IpfTimerLib.c
index f4e9838745b6f63096fa572978ca6dbfac5ccf96..d61956433e923c8a0c808e7a67378c8377415ed1 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   Timer Library functions built upon ITC on IPF.\r
 \r
-  Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
-  All rights reserved. This program and the accompanying materials\r
+  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   http://opensource.org/licenses/bsd-license.php\r
   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/PalLib.h>\r
 \r
 \r
 /**\r
@@ -26,8 +27,8 @@
   @param  Delay Number of ticks to delay.\r
 \r
 **/\r
-STATIC\r
 VOID\r
+EFIAPI\r
 InternalIpfDelay (\r
   IN      INT64                     Delay\r
   )\r
@@ -37,14 +38,14 @@ InternalIpfDelay (
   //\r
   // The target timer count is calculated here\r
   //\r
-  Ticks = AsmReadItc () + 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 - AsmReadItc () >= 0);\r
+  while (Ticks - (INT64)AsmReadItc() >= 0);\r
 }\r
 \r
 /**\r
@@ -54,7 +55,7 @@ InternalIpfDelay (
 \r
   @param  MicroSeconds  The minimum number of microseconds to delay.\r
 \r
-  @return MicroSeconds\r
+  @return The value of MicroSeconds inputted.\r
 \r
 **/\r
 UINTN\r
@@ -78,7 +79,7 @@ MicroSecondDelay (
 \r
   @param  NanoSeconds The minimum number of nanoseconds to delay.\r
 \r
-  @return NanoSeconds\r
+  @return The value of NanoSeconds inputted.\r
 \r
 **/\r
 UINTN\r
@@ -98,8 +99,7 @@ NanoSecondDelay (
 /**\r
   Retrieves the current value of a 64-bit free running performance counter.\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
+  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
@@ -149,13 +149,6 @@ GetPerformanceCounterProperties (
   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 +157,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