29#define HPET_INVALID_TIMER_INDEX 0xff
103 IN UINT64 TimerPeriod
124 OUT UINT64 *TimerPeriod
194volatile UINT64 mPreviousComparator;
351 if (Comparator > MainCounter) {
451 return EFI_INVALID_PARAMETER;
455 return EFI_ALREADY_STARTED;
497 IN UINT64 TimerPeriod
503 UINT64 CurrentComparator;
509 Tpl =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
516 if (TimerPeriod == 0) {
534 while (CurrentComparator == mPreviousComparator) {
636 gBS->RestoreTPL (Tpl);
659 OUT UINT64 *TimerPeriod
662 if (TimerPeriod ==
NULL) {
663 return EFI_INVALID_PARAMETER;
701 Tpl =
gBS->RaiseTPL (TPL_HIGH_LEVEL);
750 gBS->RestoreTPL (Tpl);
778 DEBUG ((DEBUG_INFO,
"Init HPET Timer Driver\n"));
788 Status =
gBS->LocateProtocol (&gEfiCpuArchProtocolGuid,
NULL, (VOID **)&
mCpu);
804 DEBUG ((DEBUG_ERROR,
"HPET device is not present. Unload HPET driver.\n"));
805 return EFI_DEVICE_ERROR;
817 DEBUG ((DEBUG_INFO,
"HPET Base Address = 0x%08x\n",
PcdGet32 (PcdHpetBaseAddress)));
820 DEBUG ((DEBUG_INFO,
" HPET_GENERAL_INTERRUPT_STATUS = 0x%016lx\n",
HpetRead (HPET_GENERAL_INTERRUPT_STATUS_OFFSET)));
824 DEBUG ((DEBUG_INFO,
" HPET_TIMER%d_CONFIGURATION = 0x%016lx\n", TimerIndex,
HpetRead (HPET_TIMER_CONFIGURATION_OFFSET + TimerIndex *
HPET_TIMER_STRIDE)));
825 DEBUG ((DEBUG_INFO,
" HPET_TIMER%d_COMPARATOR = 0x%016lx\n", TimerIndex,
HpetRead (HPET_TIMER_COMPARATOR_OFFSET + TimerIndex *
HPET_TIMER_STRIDE)));
826 DEBUG ((DEBUG_INFO,
" HPET_TIMER%d_MSI_ROUTE = 0x%016lx\n", TimerIndex,
HpetRead (HPET_TIMER_MSI_ROUTE_OFFSET + TimerIndex *
HPET_TIMER_STRIDE)));
856 MsiTimerIndex = TimerIndex;
899 DEBUG ((DEBUG_ERROR,
"No HPET timers support MSI or I/O APIC mode. Unload HPET driver.\n"));
900 return EFI_DEVICE_ERROR;
937 DEBUG ((DEBUG_INFO,
"Choose 64-bit HPET timer.\n"));
948 DEBUG ((DEBUG_INFO,
"Choose 32-bit HPET timer.\n"));
957 if (EFI_ERROR (Status)) {
958 DEBUG ((DEBUG_ERROR,
"Unable to register HPET interrupt with CPU Arch Protocol. Unload HPET driver.\n"));
959 return EFI_DEVICE_ERROR;
967 if (EFI_ERROR (Status)) {
968 DEBUG ((DEBUG_ERROR,
"Unable to set HPET default timer rate. Unload HPET driver.\n"));
969 return EFI_DEVICE_ERROR;
977 DEBUG ((DEBUG_INFO,
"HPET Interrupt Mode MSI\n"));
979 DEBUG ((DEBUG_INFO,
"HPET Interrupt Mode I/O APIC\n"));
983 DEBUG ((DEBUG_INFO,
"HPET Interrupt Vector = 0x%02x\n",
PcdGet8 (PcdHpetLocalApicVector)));
1002 Status =
gBS->InstallMultipleProtocolInterfaces (
1004 &gEfiTimerArchProtocolGuid,
INTN EFIAPI LowBitSet32(IN UINT32 Operand)
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
VOID EFIAPI CpuPause(VOID)
UINT64 EFIAPI MultU64x32(IN UINT64 Multiplicand, IN UINT32 Multiplier)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
UINT64 HpetWrite(IN UINTN Offset, IN UINT64 Value)
EFI_STATUS EFIAPI TimerDriverInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
HPET_TIMER_CONFIGURATION_REGISTER mTimerConfiguration
UINT64 HpetRead(IN UINTN Offset)
HPET_GENERAL_CAPABILITIES_ID_REGISTER mHpetGeneralCapabilities
EFI_TIMER_NOTIFY mTimerNotifyFunction
VOID HpetEnable(IN BOOLEAN Enable)
EFI_STATUS EFIAPI TimerDriverRegisterHandler(IN EFI_TIMER_ARCH_PROTOCOL *This, IN EFI_TIMER_NOTIFY NotifyFunction)
volatile UINT64 mPreviousMainCounter
#define HPET_INVALID_TIMER_INDEX
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)
HPET_GENERAL_CONFIGURATION_REGISTER mHpetGeneralConfiguration
EFI_TIMER_ARCH_PROTOCOL mTimer
VOID EFIAPI TimerInterruptHandler(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_SYSTEM_CONTEXT SystemContext)
EFI_CPU_ARCH_PROTOCOL * mCpu
VOID EFIAPI IoApicConfigureInterrupt(IN UINTN Irq, IN UINTN Vector, IN UINTN DeliveryMode, IN BOOLEAN LevelTriggered, IN BOOLEAN AssertionLevel)
VOID EFIAPI IoApicEnableInterrupt(IN UINTN Irq, IN BOOLEAN Enable)
UINT64 EFIAPI MmioWrite64(IN UINTN Address, IN UINT64 Value)
UINT64 EFIAPI MmioRead64(IN UINTN Address)
UINT32 EFIAPI GetApicMsiAddress(VOID)
UINT64 EFIAPI GetApicMsiValue(IN UINT8 Vector, IN UINTN DeliveryMode, IN BOOLEAN LevelTriggered, IN BOOLEAN AssertionLevel)
VOID EFIAPI SendApicEoi(VOID)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
#define DEBUG_CODE(Expression)
VOID(EFIAPI * EFI_TIMER_NOTIFY)(IN UINT64 Time)
#define HPET_MAIN_COUNTER_OFFSET
#define HPET_TIMER_STRIDE
#define HPET_GENERAL_CAPABILITIES_ID_OFFSET
#define PcdGet64(TokenName)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)
#define FeaturePcdGet(TokenName)
VOID EFIAPI NotifyFunction(IN EFI_EVENT Event, IN VOID *Context)