From 8d675abae95e5583a7dc335ce6f49800b5529e9e Mon Sep 17 00:00:00 2001 From: karina Date: Wed, 29 Apr 2026 08:56:34 +0400 Subject: [PATCH] fix: changed phyisical timer to virtual timer --- Kernel/Include/Arch/Timer.h | 2 +- Kernel/Source/Arch/GIC.c | 4 +++- Kernel/Source/Arch/Timer.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Kernel/Include/Arch/Timer.h b/Kernel/Include/Arch/Timer.h index eb93df6..3fbe2e4 100644 --- a/Kernel/Include/Arch/Timer.h +++ b/Kernel/Include/Arch/Timer.h @@ -2,7 +2,7 @@ #include static const UInt64 kTimerFrequency = 1000; // 1ms -static const UInt8 kTimerIRQ = 30; +static const UInt8 kTimerIRQ = 27; void TimerInitialize(); void TimerReset(UInt64 interval); \ No newline at end of file diff --git a/Kernel/Source/Arch/GIC.c b/Kernel/Source/Arch/GIC.c index 732f096..c98326b 100644 --- a/Kernel/Source/Arch/GIC.c +++ b/Kernel/Source/Arch/GIC.c @@ -53,11 +53,13 @@ void GICCWriteEOIR(UInt32 irqID) { } void GICDispatch(ExceptionsType type) { + OSLog("GICDispatch: %d\n", type); if (type != ExceptionsIRQEl1h && type != ExceptionsIRQEl064) return; UInt32 irqID = GICCReadIAR() & 0x3FF; if (irqID == 1023) return; // spurious interrupt - if (irqID == 30) { + if (irqID == kTimerIRQ) { + OSLog("Timer IRQ\n"); TimerReset(kTimerFrequency); } diff --git a/Kernel/Source/Arch/Timer.c b/Kernel/Source/Arch/Timer.c index 4967695..7d875f3 100644 --- a/Kernel/Source/Arch/Timer.c +++ b/Kernel/Source/Arch/Timer.c @@ -9,6 +9,6 @@ void TimerInitialize() { void TimerReset(UInt64 interval) { UInt64 frequency; __asm__ volatile ("mrs %0, cntfrq_el0" : "=r"(frequency)); - __asm__ volatile ("msr cntp_tval_el0, %0" :: "r"(frequency /interval)); - __asm__ volatile ("msr cntp_ctl_el0, %0" :: "r" (1)); + __asm__ volatile ("msr cntv_tval_el0, %0" :: "r"(frequency /interval)); + __asm__ volatile ("msr cntv_ctl_el0, %0" :: "r" (1)); }