46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/*
|
|
* @author xamidev <xamidev@riseup.net>
|
|
* @brief x86 architecture-dependant initialization
|
|
* @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
|
|
*
|
|
* 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()
|
|
{
|
|
x86_overwrite_pat();
|
|
idt_init();
|
|
gdt_init();
|
|
} |