From e2da0771d6ee1b0a9f41f0f92753e12dd94dae57 Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Fri, 4 Sep 2015 15:20:25 +0000 Subject: [PATCH] Kernel: Good news, everyone! Now kernel starts at 0.25 seconds faster. git-svn-id: svn://kolibrios.org@5792 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/init.inc | 11 ++++++++--- kernel/trunk/kernel.asm | 35 ++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/kernel/trunk/init.inc b/kernel/trunk/init.inc index a60e1eb0b..3b9af4672 100644 --- a/kernel/trunk/init.inc +++ b/kernel/trunk/init.inc @@ -439,7 +439,7 @@ acpi_hpet_base rd 1 hpet_base rd 1 hpet_period rd 1 hpet_timers rd 1 - +hpet_tsc_start rd 2 cpu_count rd 1 smpt rd 16 endg @@ -613,7 +613,7 @@ align 4 init_hpet: mov ebx, [hpet_base-OS_BASE] test ebx, ebx - jz @F + jz .done mov eax, [ebx] and ah, 0x1F @@ -649,7 +649,12 @@ init_hpet: or esi, HPET_CFG_ENABLE mov [ebx+HPET_CFG], esi ;and start again -@@: + +.done: + rdtsc + mov [hpet_tsc_start-OS_BASE], eax + mov [hpet_tsc_start+4-OS_BASE], edx + ret diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 854a734a9..7b08d1a42 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -701,19 +701,11 @@ setvideomode: mov eax, [hpet_base] test eax, eax jz @F - DEBUGF 1, "K : HPET base %x\n", eax - mov eax, [hpet_period] - DEBUGF 1, "K : HPET period %d\n", eax - mov eax, [hpet_timers] - DEBUGF 1, "K : HPET timers %d\n", eax - mov eax, [hpet_base] stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR mov [hpet_base], eax - mov eax, [eax] DEBUGF 1, "K : HPET caps %x\n", eax - @@: ; SET UP OS TASK @@ -1041,7 +1033,31 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code mov esi, boot_cpufreq call boot_log - cli ;FIXME check IF + cli + mov ebx, [hpet_base] + test ebx, ebx + jz @F + mov ebx, [ebx+0xF0] + + rdtsc + mov ecx, 1000 + sub eax, [hpet_tsc_start] + sbb edx, [hpet_tsc_start+4] + shld edx, eax, 10 + shl eax, 10 + mov esi, eax + mov eax, edx + mul ecx + xchg eax, esi + mul ecx + adc edx, esi + div ebx + mul ecx + div [hpet_period] + mul ecx + DEBUGF 1, "K : cpu frequency %u Hz\n", eax + jmp .next +@@: rdtsc mov ecx, eax mov esi, 250 ; wait 1/4 a second @@ -1053,6 +1069,7 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code xor edx, edx shld edx, eax, 2 shl eax, 2 +.next: mov dword [cpu_freq], eax mov dword [cpu_freq+4], edx mov ebx, 1000000