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
+6 -5
View File
@@ -5,14 +5,15 @@
*/
#include <stdint.h>
#include <stddef.h>
/*
* cpuid - Wrapper for CPUID instruction
* @leaf: Requested leaf
* @eax: EAX register value
* @ebx: EBX register value
* @ecx: ECX register value
* @edx: EDX register value
* @leaf: Requested leaf (input EAX)
* @eax: EAX register value (output)
* @ebx: EBX register value (output)
* @ecx: ECX register value (output)
* @edx: EDX register value (output)
*/
void cpuid(uint32_t leaf, uint32_t* eax, uint32_t* ebx, uint32_t* ecx, uint32_t* edx)
{
+23 -5
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();
}