[KERNEL] Use PAT if supported. Otherwise MTRR

git-svn-id: svn://kolibrios.org@9950 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2023-12-26 18:33:21 +00:00
parent b9d43b416f
commit bbee219bab
3 changed files with 18 additions and 18 deletions

View File

@ -7,12 +7,22 @@
$Revision$ $Revision$
; Initializes MTRRs. ; Initializes PAT (Page Attribute Table) and MTRRs.
proc init_mtrr proc init_pat_mtrr
cmp [BOOT.mtrr], byte 2 cmp [BOOT.mtrr], byte 2
je .exit je .exit
bt [cpu_caps], CAPS_PAT ; if PAT is not supported, use MTRR
jnc .use_mtrr
; Change PAT_MSR for write combining memory.
mov ecx, MSR_CR_PAT
mov eax, PAT_VALUE ; UC UCM WC WB
mov edx, eax
wrmsr
ret
.use_mtrr:
bt [cpu_caps], CAPS_MTRR bt [cpu_caps], CAPS_MTRR
jnc .exit jnc .exit
@ -739,17 +749,7 @@ end virtual
jmp @b jmp @b
@@: @@:
; 9i. Check PAT support and reprogram PAT_MASR for write combining memory ; 9i. Changes are done.
bt [cpu_caps], CAPS_PAT
jnc @F
mov ecx, MSR_CR_PAT
mov eax, PAT_VALUE ;UC UCM WC WB
mov edx, eax
wrmsr
@@:
; 9j. Changes are done.
call mtrr_end_change call mtrr_end_change
.abort: .abort:

View File

@ -18,12 +18,12 @@ entry start
MAX_VARIABLE_MTRR = 10 MAX_VARIABLE_MTRR = 10
start: start:
; Copy test inputs, run init_mtrr, compare with test outputs. Repeat. ; Copy test inputs, run init_pat_mtrr, compare with test outputs. Repeat.
mov esi, test1_in_data mov esi, test1_in_data
mov edi, mtrrdata mov edi, mtrrdata
mov ecx, mtrrdata_size / 4 mov ecx, mtrrdata_size / 4
rep movsd rep movsd
call init_mtrr call init_pat_mtrr
mov esi, test1_out_data mov esi, test1_out_data
mov edi, mtrrdata mov edi, mtrrdata
mov ecx, mtrrdata_size / 4 mov ecx, mtrrdata_size / 4
@ -33,7 +33,7 @@ start:
mov edi, mtrrdata mov edi, mtrrdata
mov ecx, mtrrdata_size / 4 mov ecx, mtrrdata_size / 4
rep movsd rep movsd
call init_mtrr call init_pat_mtrr
mov esi, test2_out_data mov esi, test2_out_data
mov edi, mtrrdata mov edi, mtrrdata
mov ecx, mtrrdata_size / 4 mov ecx, mtrrdata_size / 4

View File

@ -436,7 +436,7 @@ high_code:
list_init eax list_init eax
call init_video call init_video
call init_mtrr call init_pat_mtrr
mov [LFBAddress], LFB_BASE mov [LFBAddress], LFB_BASE
mov ecx, bios_fb mov ecx, bios_fb
call set_framebuffer call set_framebuffer