25#include <Library/EmuThunkLib.h>
36 EmuTimerDriverRegisterHandler,
37 EmuTimerDriverSetTimerPeriod,
38 EmuTimerDriverGetTimerPeriod,
39 EmuTimerDriverGenerateSoftInterrupt
61 OriginalTPL =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
63 if (OriginalTPL < TPL_HIGH_LEVEL) {
75 gBS->RestoreTPL (OriginalTPL);
80EmuTimerDriverRegisterHandler (
131 return EFI_INVALID_PARAMETER;
135 return EFI_ALREADY_STARTED;
140 gEmuThunk->SetTimer (0, TimerCallback);
141 }
else if (mTimerNotifyFunction ==
NULL) {
143 gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);
153EmuTimerDriverSetTimerPeriod (
155 IN UINT64 TimerPeriod
199 if ( (TimerPeriod == 0)
200 || ( (TimerPeriod > TIMER_MINIMUM_VALUE)
201 && (TimerPeriod < TIMER_MAXIMUM_VALUE)))
203 mTimerPeriodMs =
DivU64x32 (TimerPeriod + 5000, 10000);
205 gEmuThunk->SetTimer (mTimerPeriodMs, TimerCallback);
213EmuTimerDriverGetTimerPeriod (
215 OUT UINT64 *TimerPeriod
242 if (TimerPeriod ==
NULL) {
243 return EFI_INVALID_PARAMETER;
246 *TimerPeriod =
MultU64x32 (mTimerPeriodMs, 10000);
253EmuTimerDriverGenerateSoftInterrupt (
281 return EFI_UNSUPPORTED;
286EmuTimerDriverInitialize (
324 Status =
gBS->LocateProtocol (&gEfiCpuArchProtocolGuid,
NULL, (
void *)&mCpu);
330 Status = mTimer.SetTimerPeriod (&mTimer, DEFAULT_TIMER_TICK_DURATION);
331 if (EFI_ERROR (Status)) {
339 Status =
gBS->InstallProtocolInterface (
341 &gEfiTimerArchProtocolGuid,
345 if (EFI_ERROR (Status)) {
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
#define ASSERT_EFI_ERROR(StatusParameter)
#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
VOID(EFIAPI * EFI_TIMER_NOTIFY)(IN UINT64 Time)
VOID EFIAPI NotifyFunction(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI CallbackFunction(IN EFI_EVENT Event, IN VOID *Context)