Wrong value for HPET

This commit is contained in:
Alex 2022-12-24 05:51:01 +02:00
parent 7cb935db05
commit 1f399e37af
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD

View File

@ -15,9 +15,18 @@ namespace Time
void time::Sleep(uint64_t Milliseconds) void time::Sleep(uint64_t Milliseconds)
{ {
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
uintptr_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Milliseconds * 1000000000) / clk; uintptr_t Target = mminq(&((HPET *)hpet)->MainCounterValue) + (Milliseconds * 1000000000000) / clk;
#ifdef DEBUG
uint64_t Counter = mminq(&((HPET *)hpet)->MainCounterValue);
while (Counter < Target)
{
Counter = mminq(&((HPET *)hpet)->MainCounterValue);
CPU::Pause();
}
#else
while (mminq(&((HPET *)hpet)->MainCounterValue) < Target) while (mminq(&((HPET *)hpet)->MainCounterValue) < Target)
CPU::Pause(); CPU::Pause();
#endif
#elif defined(__aarch64__) #elif defined(__aarch64__)
#endif #endif
} }