fix: changed phyisical timer to virtual timer

This commit is contained in:
karina
2026-04-29 08:56:34 +04:00
parent 7fcb50587e
commit 8d675abae9
3 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
#include <Types.h>
static const UInt64 kTimerFrequency = 1000; // 1ms
static const UInt8 kTimerIRQ = 30;
static const UInt8 kTimerIRQ = 27;
void TimerInitialize();
void TimerReset(UInt64 interval);
+3 -1
View File
@@ -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);
}
+2 -2
View File
@@ -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));
}