vmm: brokie paging :)
This commit is contained in:
parent
9c21f343ba
commit
33f88512d4
13 changed files with 324 additions and 100 deletions
|
@ -5,17 +5,46 @@
|
|||
* cpu.c - x86_64 CPU control implementation.
|
||||
*/
|
||||
|
||||
#include "mm/vmm.h"
|
||||
#if defined (__x86_64__)
|
||||
|
||||
#include <arch/x86_64/gdt.h>
|
||||
#include <arch/x86_64/idt.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <mm/pmm.h>
|
||||
|
||||
void arch_init_stage1() {
|
||||
gdt_init();
|
||||
idt_init();
|
||||
}
|
||||
|
||||
void cpu_load_pm(pagemap_t pm) {
|
||||
if (!pm)
|
||||
return;
|
||||
|
||||
__asm__ volatile("mov %0, %%cr3" : : "r"(physical((uint64_t)pm)) : "memory");
|
||||
}
|
||||
|
||||
static uint64_t read_cr3(void)
|
||||
{
|
||||
unsigned long val;
|
||||
asm volatile ( "mov %%cr3, %0" : "=r"(val) );
|
||||
return val;
|
||||
}
|
||||
|
||||
void cpu_invalidate_page(pagemap_t pm, uint64_t vaddr) {
|
||||
uint64_t cr3 = read_cr3();
|
||||
if (physical((uint64_t)pm) != cr3)
|
||||
{
|
||||
// load the provided PM in cr3, invalidate the page and return into the previous cr3.
|
||||
cpu_load_pm(pm);
|
||||
asm volatile ( "invlpg (%0)" : : "b"(vaddr) : "memory" );
|
||||
cpu_load_pm((pagemap_t)cr3);
|
||||
return;
|
||||
}
|
||||
asm volatile ( "invlpg (%0)" : : "b"(vaddr) : "memory" );
|
||||
}
|
||||
|
||||
void hcf() {
|
||||
asm ("cli");
|
||||
for (;;) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue