forked from KolibriOS/kolibrios
Fusion frequencies detection
git-svn-id: svn://kolibrios.org@3573 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
65c483cc45
commit
f138c2f662
@ -298,25 +298,41 @@ sys_rdmsr:
|
|||||||
pop edx ecx
|
pop edx ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
;------------------------------------------------
|
||||||
|
uglobal
|
||||||
|
|
||||||
|
align 4
|
||||||
|
diff16 "apic_data : ", 0, $
|
||||||
|
apic_data:
|
||||||
|
|
||||||
|
.counter dd ?
|
||||||
|
.ticks dd ?
|
||||||
|
.t_freq dd ?
|
||||||
|
endg
|
||||||
|
|
||||||
apic_timer_reset:
|
apic_timer_reset:
|
||||||
xor eax, eax
|
mov eax, [pll_frequency.osc]
|
||||||
mov [apic_data+0], eax
|
shr eax, 1 ; default prescaler - fix it !!
|
||||||
|
mov [apic_data.t_freq], eax
|
||||||
|
shr eax, 4 ; 16 per second
|
||||||
|
mov [apic_data.ticks], eax
|
||||||
|
|
||||||
mov ebx, LAPIC_BAR+ 0x320
|
mov ebx, LAPIC_BAR+ 0x320
|
||||||
mov eax, [ebx]
|
mov edx, [ebx]
|
||||||
and eax, 0xFFFEFF00
|
and edx, 0xFFFEFF00
|
||||||
or eax, 0x0000003F ; int vector + norestart
|
or edx, 0x0002003F ; int vector + restart
|
||||||
mov [ebx], eax
|
mov [ebx], edx
|
||||||
mov dword[apic_data + 8], 100000000
|
mov dword [LAPIC_BAR + 0x380], eax ; load APICTIC
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
apic_timer_int:
|
apic_timer_int:
|
||||||
push eax
|
push eax
|
||||||
inc dword [apic_data + 0]
|
inc dword [apic_data.counter]
|
||||||
mov eax, [apic_data + 8]
|
; mov eax, [apic_data.ticks]
|
||||||
mov dword [LAPIC_BAR + 0x380], eax ; load APICTIC
|
; mov dword [LAPIC_BAR + 0x380], eax ; reload APICTIC
|
||||||
mov dword [LAPIC_BAR + 0x0B0], 0 ; end of interrupt
|
mov dword [LAPIC_BAR + 0x0B0], 0 ; end of interrupt
|
||||||
; mov dword [LAPIC_BAR + 0x420], 0x3F ; end of interrupt
|
; mov dword [LAPIC_BAR + 0x420], 0x3F ; end of interrupt
|
||||||
pop eax
|
pop eax
|
||||||
iretd
|
iretd
|
||||||
|
|
||||||
|
@ -273,7 +273,6 @@ FONT_I equ (OS_BASE+0x005E600)
|
|||||||
|
|
||||||
TMP_STACK_TOP equ 0x006C000
|
TMP_STACK_TOP equ 0x006C000
|
||||||
|
|
||||||
apic_data equ (OS_BASE+0x006D000)
|
|
||||||
mmio_pte equ 0x006E000
|
mmio_pte equ 0x006E000
|
||||||
sys_pgdir equ (OS_BASE+0x006F000)
|
sys_pgdir equ (OS_BASE+0x006F000)
|
||||||
|
|
||||||
|
@ -628,51 +628,90 @@ include 'detect/disks.inc'
|
|||||||
mov [SLOT_BASE+APPDATA.cursor+256],eax
|
mov [SLOT_BASE+APPDATA.cursor+256],eax
|
||||||
|
|
||||||
|
|
||||||
; READ TSC / SECOND == Fusion only!
|
; READ TSC / SECOND === Fusion fam.14h only! ===
|
||||||
|
|
||||||
cli
|
uglobal
|
||||||
mov edx, PCIe_CONFIG_SPACE + 0xE0
|
align 4
|
||||||
mov eax, 0x013080F0 ; BIOS timer reg.
|
diff16 "pll_freq : ", 0, $
|
||||||
mov [edx], eax
|
pll_frequency:
|
||||||
add dl, 4
|
.main dd ?
|
||||||
mov edi, edx
|
.divd dd ?
|
||||||
mov eax, [edi] ; old microseconds
|
.nclk dd ?
|
||||||
inc eax ; next precise microsecond
|
.osc dd ?
|
||||||
mov esi, eax
|
endg
|
||||||
@@:
|
mov ecx, 0xC0010064 ; P0-state register
|
||||||
mov eax, [edi]
|
rdmsr
|
||||||
cmp eax, esi
|
and eax, 0x000001F3
|
||||||
jne @b
|
xor ebx, ebx
|
||||||
|
mov bl, al
|
||||||
|
shr eax, 2 ; divd = 4*((1 + bits[8:4]) + 0.25*(bits[1:0]))
|
||||||
|
add al, 4
|
||||||
|
and bl, 3
|
||||||
|
add al, bl
|
||||||
|
mov [pll_frequency.divd], eax
|
||||||
|
|
||||||
rdtsc
|
|
||||||
mov ebp, eax ; clockmark
|
|
||||||
add esi, 20 ; wait 20us
|
|
||||||
@@:
|
|
||||||
mov eax, [edi]
|
|
||||||
cmp eax, esi
|
|
||||||
jne @b
|
|
||||||
|
|
||||||
rdtsc
|
mov eax, [PCIe_CONFIG_SPACE + 0xC30D4] ; bdf: 0.18.3; reg.0xD4
|
||||||
sub eax, ebp
|
and eax, 0x0000003F ; 100 * (16 + bits[5:0]) = MHz
|
||||||
mov ebx, 50000
|
add al, 16
|
||||||
mul ebx ; clks per second
|
imul eax, 100
|
||||||
sti
|
mov [pll_frequency.main], eax
|
||||||
|
|
||||||
|
shl eax, 2
|
||||||
|
xor edx, edx
|
||||||
|
mov ebx, [pll_frequency.divd]
|
||||||
|
div ebx
|
||||||
|
mov ecx, 1000000
|
||||||
|
push edx
|
||||||
|
xor edx, edx
|
||||||
|
mul ecx
|
||||||
|
mov [CPU_FREQ], eax ; Hz
|
||||||
|
pop eax
|
||||||
|
xor edx, edx
|
||||||
|
mov ecx, 250000 ; remainder in MHz/4
|
||||||
|
mul ecx
|
||||||
|
div ebx
|
||||||
|
add eax, [CPU_FREQ]
|
||||||
|
|
||||||
|
mov [CPU_FREQ],eax ; save tsc / sec
|
||||||
|
mov ebx, 1000000
|
||||||
|
div ebx
|
||||||
|
mov [stall_mcs], eax ; (core/memory.inc:stall)
|
||||||
|
|
||||||
|
mov ebx, [PCIe_CONFIG_SPACE + 0xC30DC] ; bdf: 0.18.3; reg.0xDC
|
||||||
|
shr ebx, 20
|
||||||
|
and bx, 0x3F ; NbP0NclkDiv
|
||||||
|
mov eax, [pll_frequency.main]
|
||||||
|
shl eax, 2
|
||||||
|
xor edx, edx
|
||||||
|
div ebx
|
||||||
|
push edx
|
||||||
|
imul eax, 1000000
|
||||||
|
mov [pll_frequency.nclk], eax ; +-MHz
|
||||||
|
pop eax
|
||||||
|
xor edx, edx
|
||||||
|
imul eax, 1000000
|
||||||
|
div ebx
|
||||||
|
add [pll_frequency.nclk], eax ; precise bus clk
|
||||||
|
mov eax, 200000000
|
||||||
|
mov [pll_frequency.osc], eax ; 200MHz main oscillator
|
||||||
|
|
||||||
|
|
||||||
mov [CPU_FREQ],eax ; save tsc / sec
|
|
||||||
mov ebx, 1000000
|
|
||||||
div ebx
|
|
||||||
mov [stall_mcs], eax
|
|
||||||
; PRINT CPU FREQUENCY
|
; PRINT CPU FREQUENCY
|
||||||
mov esi, boot_cpufreq
|
mov esi, boot_cpufreq
|
||||||
call boot_log
|
call boot_log
|
||||||
|
|
||||||
|
mov eax, [CPU_FREQ]
|
||||||
|
xor edx, edx
|
||||||
|
mov ebx, 1000000
|
||||||
|
div ebx
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
movzx ecx, word [boot_y]
|
movzx ecx, word [boot_y]
|
||||||
add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is '
|
add ecx, (10+17*6) shl 16 - 10 ; 'CPU frequency is '
|
||||||
mov edx, 0xFFFFFF
|
mov edx, 0xFFFFFF
|
||||||
xor edi,edi
|
xor edi,edi
|
||||||
mov eax, 0x00040000
|
mov eax, 0x00040000
|
||||||
inc edi
|
inc edi
|
||||||
call display_number_force
|
call display_number_force
|
||||||
|
|
||||||
; SET VARIABLES
|
; SET VARIABLES
|
||||||
|
Loading…
Reference in New Issue
Block a user