Use MSR to map framebuffer as WC (write-combining) = huge speed diff on real HW

This commit is contained in:
2026-03-19 19:34:31 +01:00
parent 6a82d581fb
commit 424b4c4632
6 changed files with 133 additions and 2 deletions

28
src/arch/x86/init.c Normal file
View File

@@ -0,0 +1,28 @@
/*
* @author xamidev <xamidev@riseup.net>
* @brief x86 architecture-dependant initialization
* @license GPL-3.0-only
*/
#include <stdint.h>
#include <arch/x86.h>
#include <kernel.h>
/*
* x86_arch_init - Initialize x86 CPU structures
*
* This function is responsible for overriding a PAT entry
* (to put the framebuffer area in WC mode) only.
*
* Later, all architecture-dependant init (GDT, IDT, TSS, ...)
* should be initialized here, and separate function pointers
* should be set up for each arch.
*/
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");
}