MdePkg/Library/SecPeiDxeTimerLibCpu/X86TimerLib.c File Reference


Defines

#define APIC_LVTERR   0x370
#define APIC_TMICT   0x380
#define APIC_TMCCT   0x390
#define APIC_TDCR   0x3e0

Functions

UINTN EFIAPI InternalX86GetApicBase (VOID)
UINT32 EFIAPI InternalX86GetTimerFrequency (IN UINTN ApicBase)
INT32 EFIAPI InternalX86GetTimerTick (IN UINTN ApicBase)
UINT32 InternalX86GetInitTimerCount (IN UINTN ApicBase)
VOID EFIAPI InternalX86Delay (IN UINTN ApicBase, IN UINT32 Delay)
UINTN EFIAPI MicroSecondDelay (IN UINTN MicroSeconds)
UINTN EFIAPI NanoSecondDelay (IN UINTN NanoSeconds)
UINT64 EFIAPI GetPerformanceCounter (VOID)
UINT64 EFIAPI GetPerformanceCounterProperties (OUT UINT64 *StartValue, OUT UINT64 *EndValue)
UINT64 EFIAPI GetTimeInNanoSecond (IN UINT64 Ticks)

Variables

GLOBAL_REMOVE_IF_UNREFERENCED
CONST UINT8 
mTimerLibLocalApicDivisor []

Detailed Description

Timer Library functions built upon local APIC on IA32/x64.

Copyright (c) 2006 - 2013, 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.

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.


Define Documentation

#define APIC_LVTERR   0x370

#define APIC_TDCR   0x3e0

#define APIC_TMCCT   0x390

Referenced by InternalX86GetTimerTick().

#define APIC_TMICT   0x380


Function Documentation

UINT64 EFIAPI GetPerformanceCounter ( VOID   ) 

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 performance counter counts by a larger increment, then the counter values must be translated. The properties of the counter can be retrieved from GetPerformanceCounterProperties().

Returns:
The current value of the free running performance counter.

References InternalX86GetApicBase(), and InternalX86GetTimerTick().

Referenced by AcquireSpinLock(), PeriodicSmiDispatchFunctionOnCpu(), and PeriodicSmiExecutionTime().

UINT64 EFIAPI GetPerformanceCounterProperties ( OUT UINT64 StartValue,
OUT UINT64 EndValue 
)

Retrieves the 64-bit frequency in Hz and the range of performance counter values.

If StartValue is not NULL, then the value that the performance counter starts with immediately after is it rolls over is returned in StartValue. If EndValue is not NULL, then the value that the performance counter end with immediately before it rolls over is returned in EndValue. The 64-bit frequency of the performance counter in Hz is always returned. If StartValue is less than EndValue, then the performance counter counts up. If StartValue is greater than EndValue, then the performance counter counts down. For example, a 64-bit free running counter that counts up would have a StartValue of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.

Parameters:
StartValue The value the performance counter starts with when it rolls over.
EndValue The value that the performance counter ends with before it rolls over.
Returns:
The frequency in Hz.

References InternalX86GetApicBase(), InternalX86GetInitTimerCount(), InternalX86GetTimerFrequency(), and NULL.

Referenced by AcquireSpinLock(), GetTimeInNanoSecond(), MicroSecondDelay(), NanoSecondDelay(), and PeriodicSmiEnable().

UINT64 EFIAPI GetTimeInNanoSecond ( IN UINT64  Ticks  ) 

Converts elapsed ticks of performance counter to time in nanoseconds.

This function converts the elapsed ticks of running performance counter to time value in unit of nanoseconds.

Parameters:
Ticks The number of elapsed ticks of running performance counter.
Returns:
The elapsed time in nanoseconds.

References DivU64x64Remainder(), GetPerformanceCounterProperties(), HighBitSet64(), MAX, MultU64x32(), NULL, and RShiftU64().

VOID EFIAPI InternalX86Delay ( IN UINTN  ApicBase,
IN UINT32  Delay 
)

Stalls the CPU for at least the given number of ticks.

Stalls the CPU for at least the given number of ticks. It's invoked by MicroSecondDelay() and NanoSecondDelay().

Parameters:
ApicBase The base address of memory mapped registers of local APIC.
Delay A period of time to delay in ticks.

References CpuPause(), InternalX86GetInitTimerCount(), and InternalX86GetTimerTick().

Referenced by MicroSecondDelay(), and NanoSecondDelay().

UINTN EFIAPI InternalX86GetApicBase ( VOID   ) 

Internal function to retrieve the base address of local APIC.

Returns:
The base address of local APIC

References AsmMsrBitFieldRead64().

Referenced by GetPerformanceCounter(), GetPerformanceCounterProperties(), MicroSecondDelay(), and NanoSecondDelay().

UINT32 InternalX86GetInitTimerCount ( IN UINTN  ApicBase  ) 

Internal function to read the initial timer count of local APIC.

Parameters:
ApicBase The base address of memory mapped registers of local APIC.
Returns:
The initial timer count read.

References APIC_TMICT, and MmioRead32().

Referenced by GetPerformanceCounterProperties(), and InternalX86Delay().

UINT32 EFIAPI InternalX86GetTimerFrequency ( IN UINTN  ApicBase  ) 

Internal function to return the frequency of the local APIC timer.

Parameters:
ApicBase The base address of memory mapped registers of local APIC.
Returns:
The frequency of the timer in Hz.

References APIC_TDCR, MmioBitFieldRead32(), mTimerLibLocalApicDivisor, and PcdGet32.

Referenced by GetPerformanceCounterProperties(), MicroSecondDelay(), and NanoSecondDelay().

INT32 EFIAPI InternalX86GetTimerTick ( IN UINTN  ApicBase  ) 

Internal function to read the current tick counter of local APIC.

Parameters:
ApicBase The base address of memory mapped registers of local APIC.
Returns:
The tick counter read.

References APIC_TMCCT, and MmioRead32().

Referenced by GetPerformanceCounter(), and InternalX86Delay().

UINTN EFIAPI MicroSecondDelay ( IN UINTN  MicroSeconds  ) 

Stalls the CPU for at least the given number of microseconds.

Stalls the CPU for the number of microseconds specified by MicroSeconds.

Parameters:
MicroSeconds The minimum number of microseconds to delay.
Returns:
The value of MicroSeconds inputted.

References DivU64x32(), InternalX86Delay(), InternalX86GetApicBase(), InternalX86GetTimerFrequency(), and MultU64x64().

Referenced by S3Stall().

UINTN EFIAPI NanoSecondDelay ( IN UINTN  NanoSeconds  ) 

Stalls the CPU for at least the given number of nanoseconds.

Stalls the CPU for the number of nanoseconds specified by NanoSeconds.

Parameters:
NanoSeconds The minimum number of nanoseconds to delay.
Returns:
The value of NanoSeconds inputted.

References DivU64x32(), InternalX86Delay(), InternalX86GetApicBase(), InternalX86GetTimerFrequency(), and MultU64x64().


Variable Documentation

GLOBAL_REMOVE_IF_UNREFERENCED CONST UINT8 mTimerLibLocalApicDivisor[]

Initial value:

 {
  0x02, 0x04, 0x08, 0x10,
  0x02, 0x04, 0x08, 0x10,
  0x20, 0x40, 0x80, 0x01,
  0x20, 0x40, 0x80, 0x01
}

Referenced by InternalX86GetTimerFrequency().


Generated on Thu Sep 24 23:14:24 2015 for MdePkg[ALL] by  doxygen 1.5.7.1