From a410b6abe3e2962de448dc0dc78179d520fa54f6 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Fri, 4 Sep 2015 11:50:27 +0000 Subject: [PATCH] Kernel: use 22.10 fixed point arithmetic in HPET timestamp calculation. git-svn-id: svn://kolibrios.org@5791 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/apic.inc | 22 ++++++++++++++++------ kernel/trunk/init.inc | 10 ++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/kernel/trunk/core/apic.inc b/kernel/trunk/core/apic.inc index ef00f1429..0f215b3af 100644 --- a/kernel/trunk/core/apic.inc +++ b/kernel/trunk/core/apic.inc @@ -447,6 +447,7 @@ get_clock_ns: jz .old_tics push ebx + push esi pushfd cli @@ -456,15 +457,24 @@ get_clock_ns: mov eax, [ebx+0xF0] mov ecx, [ebx+0xF4] cmp ecx, edx - jnz @B + jne @B - mov ecx, [hpet_period] - mov ebx, edx - imul ebx, ecx - mul ecx - add edx, ebx + mul [hpet_period] + shrd eax, edx, 10 + shr edx, 10 + + mov ebx, eax + mov esi, edx + + mov eax, ecx + mul [hpet_period] + shld edx, eax, 22 + shl eax, 22 + add eax, ebx + adc edx, esi popfd + pop esi pop ebx ret diff --git a/kernel/trunk/init.inc b/kernel/trunk/init.inc index de3b09cc4..a60e1eb0b 100644 --- a/kernel/trunk/init.inc +++ b/kernel/trunk/init.inc @@ -623,10 +623,12 @@ init_hpet: mov ecx, eax mov eax, [ebx+HPET_PERIOD] - mov edx, 0x431BDE83 - mul edx - shr edx, 18 - mov [hpet_period-OS_BASE], edx + xor edx, edx + shld edx, eax, 10 + shl eax, 10 + mov esi, 1000000 + div esi + mov [hpet_period-OS_BASE], eax mov esi, [ebx+HPET_CFG] and esi, not HPET_CFG_ENABLE