X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FSecPeiDxeTimerLibCpu%2FX86TimerLib.c;fp=MdePkg%2FLibrary%2FSecPeiDxeTimerLibCpu%2FX86TimerLib.c;h=c60589607fde1d5f07fe4199b4d4a39cb1841799;hp=9f61d4d32a53474500a0c7ddafae0cecb50e807f;hb=2f88bd3a1296c522317f1c21377876de63de5be7;hpb=1436aea4d5707e672672a11bda72be2c63c936c3 diff --git a/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c b/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c index 9f61d4d32a..c60589607f 100644 --- a/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c +++ b/MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c @@ -13,18 +13,18 @@ #include #include -#define APIC_SVR 0x0f0 -#define APIC_LVTERR 0x370 -#define APIC_TMICT 0x380 -#define APIC_TMCCT 0x390 -#define APIC_TDCR 0x3e0 +#define APIC_SVR 0x0f0 +#define APIC_LVTERR 0x370 +#define APIC_TMICT 0x380 +#define APIC_TMCCT 0x390 +#define APIC_TDCR 0x3e0 // // The following array is used in calculating the frequency of local APIC // timer. Refer to IA-32 developers' manual for more details. // GLOBAL_REMOVE_IF_UNREFERENCED -CONST UINT8 mTimerLibLocalApicDivisor[] = { +CONST UINT8 mTimerLibLocalApicDivisor[] = { 0x02, 0x04, 0x08, 0x10, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x01, @@ -48,10 +48,10 @@ InternalX86GetApicBase ( VOID ) { - UINTN MsrValue; - UINTN ApicBase; + UINTN MsrValue; + UINTN ApicBase; - MsrValue = (UINTN) AsmReadMsr64 (27); + MsrValue = (UINTN)AsmReadMsr64 (27); ApicBase = MsrValue & 0xffffff000ULL; // @@ -87,11 +87,11 @@ InternalX86GetApicBase ( UINT32 EFIAPI InternalX86GetTimerFrequency ( - IN UINTN ApicBase + IN UINTN ApicBase ) { return - PcdGet32(PcdFSBClock) / + PcdGet32 (PcdFSBClock) / mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + APIC_TDCR, 0, 3)]; } @@ -106,7 +106,7 @@ InternalX86GetTimerFrequency ( INT32 EFIAPI InternalX86GetTimerTick ( - IN UINTN ApicBase + IN UINTN ApicBase ) { return MmioRead32 (ApicBase + APIC_TMCCT); @@ -122,7 +122,7 @@ InternalX86GetTimerTick ( **/ UINT32 InternalX86GetInitTimerCount ( - IN UINTN ApicBase + IN UINTN ApicBase ) { return MmioRead32 (ApicBase + APIC_TMICT); @@ -144,14 +144,14 @@ InternalX86GetInitTimerCount ( VOID EFIAPI InternalX86Delay ( - IN UINTN ApicBase, - IN UINT32 Delay + IN UINTN ApicBase, + IN UINT32 Delay ) { - INT32 Ticks; - UINT32 Times; - UINT32 InitCount; - UINT32 StartTick; + INT32 Ticks; + UINT32 Times; + UINT32 InitCount; + UINT32 StartTick; // // In case Delay is too larger, separate it into several small delay slot. @@ -162,13 +162,13 @@ InternalX86Delay ( // InitCount = InternalX86GetInitTimerCount (ApicBase); ASSERT (InitCount != 0); - Times = Delay / (InitCount / 2); - Delay = Delay % (InitCount / 2); + Times = Delay / (InitCount / 2); + Delay = Delay % (InitCount / 2); // // Get Start Tick and do delay // - StartTick = InternalX86GetTimerTick (ApicBase); + StartTick = InternalX86GetTimerTick (ApicBase); do { // // Wait until time out by Delay value @@ -208,10 +208,10 @@ InternalX86Delay ( UINTN EFIAPI MicroSecondDelay ( - IN UINTN MicroSeconds + IN UINTN MicroSeconds ) { - UINTN ApicBase; + UINTN ApicBase; ApicBase = InternalX86GetApicBase (); InternalX86Delay ( @@ -240,10 +240,10 @@ MicroSecondDelay ( UINTN EFIAPI NanoSecondDelay ( - IN UINTN NanoSeconds + IN UINTN NanoSeconds ) { - UINTN ApicBase; + UINTN ApicBase; ApicBase = InternalX86GetApicBase (); InternalX86Delay ( @@ -305,11 +305,11 @@ GetPerformanceCounter ( UINT64 EFIAPI GetPerformanceCounterProperties ( - OUT UINT64 *StartValue OPTIONAL, - OUT UINT64 *EndValue OPTIONAL + OUT UINT64 *StartValue OPTIONAL, + OUT UINT64 *EndValue OPTIONAL ) { - UINTN ApicBase; + UINTN ApicBase; ApicBase = InternalX86GetApicBase (); @@ -321,7 +321,7 @@ GetPerformanceCounterProperties ( *EndValue = 0; } - return (UINT64) InternalX86GetTimerFrequency (ApicBase); + return (UINT64)InternalX86GetTimerFrequency (ApicBase); } /** @@ -338,7 +338,7 @@ GetPerformanceCounterProperties ( UINT64 EFIAPI GetTimeInNanoSecond ( - IN UINT64 Ticks + IN UINT64 Ticks ) { UINT64 Frequency; @@ -360,9 +360,9 @@ GetTimeInNanoSecond ( // Since 2^29 < 1,000,000,000 = 0x3B9ACA00 < 2^30, Remainder should < 2^(64-30) = 2^34, // i.e. highest bit set in Remainder should <= 33. // - Shift = MAX (0, HighBitSet64 (Remainder) - 33); - Remainder = RShiftU64 (Remainder, (UINTN) Shift); - Frequency = RShiftU64 (Frequency, (UINTN) Shift); + Shift = MAX (0, HighBitSet64 (Remainder) - 33); + Remainder = RShiftU64 (Remainder, (UINTN)Shift); + Frequency = RShiftU64 (Frequency, (UINTN)Shift); NanoSeconds += DivU64x64Remainder (MultU64x32 (Remainder, 1000000000u), Frequency, NULL); return NanoSeconds;