From bbee219bab918e5a1d43031a27475dcdffea5dc5 Mon Sep 17 00:00:00 2001 From: turbocat Date: Tue, 26 Dec 2023 18:33:21 +0000 Subject: [PATCH] [KERNEL] Use PAT if supported. Otherwise MTRR git-svn-id: svn://kolibrios.org@9950 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/core/mtrr.inc | 28 ++++++++++++++-------------- kernel/trunk/core/mtrrtest.asm | 6 +++--- kernel/trunk/kernel.asm | 2 +- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/kernel/trunk/core/mtrr.inc b/kernel/trunk/core/mtrr.inc index 6eef4ae5ae..36f23b2409 100644 --- a/kernel/trunk/core/mtrr.inc +++ b/kernel/trunk/core/mtrr.inc @@ -7,12 +7,22 @@ $Revision$ -; Initializes MTRRs. -proc init_mtrr - +; Initializes PAT (Page Attribute Table) and MTRRs. +proc init_pat_mtrr cmp [BOOT.mtrr], byte 2 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 jnc .exit @@ -739,17 +749,7 @@ end virtual jmp @b @@: -; 9i. Check PAT support and reprogram PAT_MASR for write combining memory - 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. +; 9i. Changes are done. call mtrr_end_change .abort: diff --git a/kernel/trunk/core/mtrrtest.asm b/kernel/trunk/core/mtrrtest.asm index dede91186a..d8694e3ae8 100644 --- a/kernel/trunk/core/mtrrtest.asm +++ b/kernel/trunk/core/mtrrtest.asm @@ -18,12 +18,12 @@ entry start MAX_VARIABLE_MTRR = 10 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 edi, mtrrdata mov ecx, mtrrdata_size / 4 rep movsd - call init_mtrr + call init_pat_mtrr mov esi, test1_out_data mov edi, mtrrdata mov ecx, mtrrdata_size / 4 @@ -33,7 +33,7 @@ start: mov edi, mtrrdata mov ecx, mtrrdata_size / 4 rep movsd - call init_mtrr + call init_pat_mtrr mov esi, test2_out_data mov edi, mtrrdata mov ecx, mtrrdata_size / 4 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 5ab1ec71e5..a6139d450f 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -436,7 +436,7 @@ high_code: list_init eax call init_video - call init_mtrr + call init_pat_mtrr mov [LFBAddress], LFB_BASE mov ecx, bios_fb call set_framebuffer