13#include <Library/EmuThunkLib.h>
19STATIC UINT64 gTimerPeriod = 0;
26RegisterTimerArchProtocol (
33 Status =
gBS->LocateProtocol (&gEfiTimerArchProtocolGuid,
NULL, (VOID **)&gTimerAp);
34 if (!EFI_ERROR (Status)) {
35 Status = gTimerAp->GetTimerPeriod (gTimerAp, &gTimerPeriod);
41 if (gTimerEvent ==
NULL) {
42 Status =
gBS->CreateEvent (EVT_TIMER, 0,
NULL,
NULL, &gTimerEvent);
84 UINT64 HundredNanoseconds;
87 if ((gTimerPeriod != 0) &&
88 ((UINT64)NanoSeconds > gTimerPeriod) &&
95 HundredNanoseconds =
DivU64x32 (NanoSeconds, 100);
99 Status =
gBS->WaitForEvent (
sizeof (gTimerEvent)/
sizeof (
EFI_EVENT), &gTimerEvent, &Index);
102 gEmuThunk->Sleep (NanoSeconds);
125 return gEmuThunk->QueryPerformanceCounter ();
154 OUT UINT64 *StartValue OPTIONAL,
155 OUT UINT64 *EndValue OPTIONAL
158 if (StartValue !=
NULL) {
162 if (EndValue !=
NULL) {
163 *EndValue = (UINT64)-1LL;
166 return gEmuThunk->QueryPerformanceFrequency ();
186 &gEfiTimerArchProtocolGuid,
188 RegisterTimerArchProtocol,
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
UINT64 EFIAPI RShiftU64(IN UINT64 Operand, IN UINTN Count)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
UINT64 EFIAPI DivU64x64Remainder(IN UINT64 Dividend, IN UINT64 Divisor, OUT UINT64 *Remainder OPTIONAL)
INTN EFIAPI HighBitSet64(IN UINT64 Operand)
UINT64 EFIAPI GetPerformanceCounterProperties(OUT UINT64 *StartValue OPTIONAL, OUT UINT64 *EndValue OPTIONAL)
UINT64 EFIAPI GetTimeInNanoSecond(IN UINT64 Ticks)
EFI_STATUS EFIAPI DxeTimerLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
UINT64 EFIAPI GetPerformanceCounter(VOID)
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
UINTN EFIAPI NanoSecondDelay(IN UINTN NanoSeconds)
#define ASSERT_EFI_ERROR(StatusParameter)
EFI_TPL EFIAPI EfiGetCurrentTpl(VOID)
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent(IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)