This commit is contained in:
2026-03-20 10:04:16 +01:00
parent 3607a7179c
commit 03f87723d1
5 changed files with 44 additions and 24 deletions

View File

@@ -4,10 +4,30 @@
* @license GPL-3.0-only
*/
#include <mem/gdt.h>
#include <stdint.h>
#include <arch/x86.h>
#include <kernel.h>
/*
* x86_overwrite_pat - Set PAT to WC
*
* This function overwrites the 1st Page Attribute
* Table entry, to enable the Write-Combining property
* when we map memory regions later on.
* The framebuffer will be mapped with WC, which makes
* memory access significantly faster by using burst
* operations.
*/
static void x86_overwrite_pat()
{
uint64_t pat = rdmsr(0x277);
pat &= ~(0xFFULL << 8); // Clear PAT1
pat |= (0x01ULL << 8); // PAT1 = 0x01 (WC)
wrmsr(0x277, pat);
}
/*
* x86_arch_init - Initialize x86 CPU structures
*
@@ -20,9 +40,7 @@
*/
void x86_arch_init()
{
uint64_t pat = rdmsr(0x277);
pat &= ~(0xFFULL << 8); // Clear PAT1
pat |= (0x01ULL << 8); // PAT1 = 0x01 (WC)
wrmsr(0x277, pat);
DEBUG("Overrode PAT1 entry to set up Write-Combining");
x86_overwrite_pat();
idt_init();
gdt_init();
}