Kernel: Good news, everyone! Now kernel starts at 0.25 seconds faster.

git-svn-id: svn://kolibrios.org@5792 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2015-09-04 15:20:25 +00:00
parent a410b6abe3
commit e2da0771d6
2 changed files with 34 additions and 12 deletions

View File

@ -439,7 +439,7 @@ acpi_hpet_base rd 1
hpet_base rd 1 hpet_base rd 1
hpet_period rd 1 hpet_period rd 1
hpet_timers rd 1 hpet_timers rd 1
hpet_tsc_start rd 2
cpu_count rd 1 cpu_count rd 1
smpt rd 16 smpt rd 16
endg endg
@ -613,7 +613,7 @@ align 4
init_hpet: init_hpet:
mov ebx, [hpet_base-OS_BASE] mov ebx, [hpet_base-OS_BASE]
test ebx, ebx test ebx, ebx
jz @F jz .done
mov eax, [ebx] mov eax, [ebx]
and ah, 0x1F and ah, 0x1F
@ -649,7 +649,12 @@ init_hpet:
or esi, HPET_CFG_ENABLE or esi, HPET_CFG_ENABLE
mov [ebx+HPET_CFG], esi ;and start again 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 ret

View File

@ -701,19 +701,11 @@ setvideomode:
mov eax, [hpet_base] mov eax, [hpet_base]
test eax, eax test eax, eax
jz @F 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] mov eax, [hpet_base]
stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR stdcall map_io_mem, [hpet_base], 1024, PG_GLOBAL+PAT_UC+PG_SWR
mov [hpet_base], eax mov [hpet_base], eax
mov eax, [eax] mov eax, [eax]
DEBUGF 1, "K : HPET caps %x\n", eax DEBUGF 1, "K : HPET caps %x\n", eax
@@: @@:
; SET UP OS TASK ; SET UP OS TASK
@ -1041,7 +1033,31 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
mov esi, boot_cpufreq mov esi, boot_cpufreq
call boot_log 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 rdtsc
mov ecx, eax mov ecx, eax
mov esi, 250 ; wait 1/4 a second mov esi, 250 ; wait 1/4 a second
@ -1053,6 +1069,7 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
xor edx, edx xor edx, edx
shld edx, eax, 2 shld edx, eax, 2
shl eax, 2 shl eax, 2
.next:
mov dword [cpu_freq], eax mov dword [cpu_freq], eax
mov dword [cpu_freq+4], edx mov dword [cpu_freq+4], edx
mov ebx, 1000000 mov ebx, 1000000