30UINT64 mTimerPeriod = 0;
32UINT64 mTimerTicks = 0;
34UINT64 mElapsedPeriod = 1;
75 return EFI_INVALID_PARAMETER;
79 return EFI_ALREADY_STARTED;
97 ArmGenericTimerDisableTimer ();
132 IN UINT64 TimerPeriod
140 ArmGenericTimerDisableTimer ();
142 if (TimerPeriod != 0) {
146 TimerTicks =
MultU64x32 (TimerPeriod, ArmGenericTimerGetTimerFreq ());
147 TimerTicks =
DivU64x32 (TimerTicks, 10000000U);
151 OriginalTPL =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
153 mTimerTicks = TimerTicks;
154 mTimerPeriod = TimerPeriod;
157 gBS->RestoreTPL (OriginalTPL);
160 CounterValue = ArmGenericTimerGetSystemCount ();
162 ArmGenericTimerSetCompareVal (CounterValue + mTimerTicks);
165 ArmGenericTimerEnableTimer ();
168 mTimerPeriod = TimerPeriod;
195 OUT UINT64 *TimerPeriod
198 if (TimerPeriod ==
NULL) {
199 return EFI_INVALID_PARAMETER;
202 *TimerPeriod = mTimerPeriod;
227 return EFI_UNSUPPORTED;
287 IN HARDWARE_INTERRUPT_SOURCE Source,
300 OriginalTPL =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
304 gInterrupt->EndOfInterrupt (gInterrupt, Source);
307 if ((ArmGenericTimerGetTimerCtrlReg ()) & ARM_ARCH_TIMER_ISTATUS) {
308 if (mTimerNotifyFunction != 0) {
309 mTimerNotifyFunction (mTimerPeriod * mElapsedPeriod);
317 CurrentValue = ArmGenericTimerGetSystemCount ();
319 CompareValue = ArmGenericTimerGetCompareVal ();
326 CompareValue += mTimerTicks;
328 }
while (CompareValue < CurrentValue);
331 ArmGenericTimerSetCompareVal (CompareValue);
332 ArmGenericTimerReenableTimer ();
333 ArmInstructionSynchronizationBarrier ();
336 gBS->RestoreTPL (OriginalTPL);
362 UINT32 TimerHypIntrNum;
364 if (ArmIsArchTimerImplemented () == 0) {
365 DEBUG ((DEBUG_ERROR,
"ARM Architectural Timer is not available in the CPU, hence can't use this Driver \n"));
370 Status =
gBS->LocateProtocol (&gHardwareInterruptProtocolGuid,
NULL, (VOID **)&gInterrupt);
374 TimerCtrlReg = ArmGenericTimerGetTimerCtrlReg ();
375 TimerCtrlReg |= ARM_ARCH_TIMER_IMASK;
376 TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
377 ArmGenericTimerSetTimerCtrlReg (TimerCtrlReg);
392 TimerHypIntrNum =
PcdGet32 (PcdArmArchTimerHypIntrNum);
393 if (TimerHypIntrNum != 0) {
410 Status =
gBS->InstallMultipleProtocolInterfaces (
412 &gEfiTimerArchProtocolGuid,
419 TimerCtrlReg = ARM_ARCH_TIMER_ENABLE;
420 ArmGenericTimerSetTimerCtrlReg (TimerCtrlReg);
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID(EFIAPI * EFI_TIMER_NOTIFY)(IN UINT64 Time)
#define FixedPcdGet32(TokenName)
#define PcdGet32(TokenName)
VOID EFIAPI NotifyFunction(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI ExitBootServicesEvent(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI TimerDriverRegisterHandler(IN EFI_TIMER_ARCH_PROTOCOL *This, IN EFI_TIMER_NOTIFY NotifyFunction)
EFI_STATUS EFIAPI TimerInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI TimerDriverGetTimerPeriod(IN EFI_TIMER_ARCH_PROTOCOL *This, OUT UINT64 *TimerPeriod)
EFI_STATUS EFIAPI TimerDriverSetTimerPeriod(IN EFI_TIMER_ARCH_PROTOCOL *This, IN UINT64 TimerPeriod)
EFI_STATUS EFIAPI TimerDriverGenerateSoftInterrupt(IN EFI_TIMER_ARCH_PROTOCOL *This)
EFI_TIMER_ARCH_PROTOCOL gTimer
VOID EFIAPI TimerInterruptHandler(IN HARDWARE_INTERRUPT_SOURCE Source, IN EFI_SYSTEM_CONTEXT SystemContext)