X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FSecPeiDxeTimerLibCpu%2FIpfTimerLib.c;h=d61956433e923c8a0c808e7a67378c8377415ed1;hp=8f7651519ed4f26130b4a0f3e24d62a33f1b5b09;hb=19388d2960b2fe0347da23799e93ccc52f540214;hpb=ff242d4066d4c8850e256799fc64e7956c76de24 diff --git a/MdePkg/Library/SecPeiDxeTimerLibCpu/IpfTimerLib.c b/MdePkg/Library/SecPeiDxeTimerLibCpu/IpfTimerLib.c index 8f7651519e..d61956433e 100644 --- a/MdePkg/Library/SecPeiDxeTimerLibCpu/IpfTimerLib.c +++ b/MdePkg/Library/SecPeiDxeTimerLibCpu/IpfTimerLib.c @@ -1,8 +1,8 @@ /** @file Timer Library functions built upon ITC on IPF. - Copyright (c) 2006 - 2007, Intel Corporation
- All rights reserved. This program and the accompanying materials + Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -10,11 +10,12 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - Module Name: IpfTimerLib.c - **/ - +#include +#include +#include +#include /** @@ -26,8 +27,8 @@ @param Delay Number of ticks to delay. **/ -STATIC VOID +EFIAPI InternalIpfDelay ( IN INT64 Delay ) @@ -37,14 +38,14 @@ InternalIpfDelay ( // // The target timer count is calculated here // - Ticks = IpfReadItc () + Delay; + Ticks = (INT64)AsmReadItc () + Delay; // // Wait until time out // Delay > 2^63 could not be handled by this function // Timer wrap-arounds are handled correctly by this function // - while (Ticks - IpfReadItc () >= 0); + while (Ticks - (INT64)AsmReadItc() >= 0); } /** @@ -54,7 +55,7 @@ InternalIpfDelay ( @param MicroSeconds The minimum number of microseconds to delay. - @return MicroSeconds + @return The value of MicroSeconds inputted. **/ UINTN @@ -78,7 +79,7 @@ MicroSecondDelay ( @param NanoSeconds The minimum number of nanoseconds to delay. - @return NanoSeconds + @return The value of NanoSeconds inputted. **/ UINTN @@ -98,8 +99,7 @@ NanoSecondDelay ( /** Retrieves the current value of a 64-bit free running performance counter. - Retrieves the current value of a 64-bit free running performance counter. The - counter can either count up by 1 or count down by 1. If the physical + The counter can either count up by 1 or count down by 1. If the physical performance counter counts by a larger increment, then the counter values must be translated. The properties of the counter can be retrieved from GetPerformanceCounterProperties(). @@ -113,7 +113,7 @@ GetPerformanceCounter ( VOID ) { - return IpfReadItc (); + return AsmReadItc (); } /** @@ -146,16 +146,9 @@ GetPerformanceCounterProperties ( OUT UINT64 *EndValue OPTIONAL ) { - PAL_PROC_RETURN PalRet; + PAL_CALL_RETURN PalRet; UINT64 BaseFrequence; - PalRet = PalCallStatic (NULL, 13, 0, 0, 0); - ASSERT (PalRet.Status == 0); - BaseFrequence = PalRet.r9; - - PalRet = PalCallStatic (NULL, 14, 0, 0, 0); - ASSERT (PalRet.Status == 0); - if (StartValue != NULL) { *StartValue = 0; } @@ -164,5 +157,16 @@ GetPerformanceCounterProperties ( *EndValue = (UINT64)(-1); } + PalRet = PalCall (PAL_FREQ_BASE, 0, 0, 0); + if (PalRet.Status != 0) { + return 1000000; + } + BaseFrequence = PalRet.r9; + + PalRet = PalCall (PAL_FREQ_RATIOS, 0, 0, 0); + if (PalRet.Status != 0) { + return 1000000; + } + return BaseFrequence * (PalRet.r11 >> 32) / (UINT32)PalRet.r11; }