diff --git a/xtoskrnl/hl/x86/timer.cc b/xtoskrnl/hl/x86/timer.cc index 0259934..15a83bf 100644 --- a/xtoskrnl/hl/x86/timer.cc +++ b/xtoskrnl/hl/x86/timer.cc @@ -447,6 +447,37 @@ HL::Timer::InitializeHpetTimer(VOID) return STATUS_SUCCESS; } +/** + * Initializes the local hardware clock for the executing processor and registers + * the necessary clock interrupt handlers. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTAPI +VOID +HL::Timer::InitializeLocalClock(VOID) +{ + XTSTATUS Status; + + /* Check if LAPIC timer was selected as the system clock */ + if(ClockType == TimerLapic && TimerRoutines.InitializeClock != NULLPTR) + { + /* Proceed with system clock initialization */ + Status = TimerRoutines.InitializeClock(); + if(Status != STATUS_SUCCESS) + { + /* CPU cannot operate without a functional system clock interrupt */ + KE::Crash::Panic(0); + } + } + + /* Register the system clock interrupt handler */ + HL::Irq::RegisterSystemInterruptHandler(APIC_VECTOR_CLOCK, HL::Timer::HandleClockInterrupt); + HL::Irq::RegisterSystemInterruptHandler(APIC_VECTOR_CLOCK_IPI, HL::Timer::HandleClockIpiInterrupt); +} + /** * Initializes the legacy Programmable Interval Timer (PIT). * diff --git a/xtoskrnl/includes/hl/timer.hh b/xtoskrnl/includes/hl/timer.hh index 8ecab7e..8d9d5d0 100644 --- a/xtoskrnl/includes/hl/timer.hh +++ b/xtoskrnl/includes/hl/timer.hh @@ -38,6 +38,7 @@ namespace HL STATIC TIMER_TYPE TimerType; public: + STATIC XTAPI VOID InitializeLocalClock(VOID); STATIC XTAPI VOID InitializeTimer(VOID); STATIC XTAPI LARGE_INTEGER QueryPerformanceCounter(OUT PLARGE_INTEGER PerformanceFrequency); STATIC XTAPI ULONG SetClockRate(IN ULONG Rate);