wip on pagetable
compiles&runs now
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
|
||||
#include "pagetable.h"
|
||||
#include "pageframealloc.h"
|
||||
#include "../utils/string.h"
|
||||
|
||||
void load_cr3( void* cr3_value ) {
|
||||
asm volatile("mov %0, %%cr3" :: "r"((uint64_t)cr3_value) : "memory");
|
||||
@@ -18,25 +19,32 @@ void write_identity_map(pagetable_t* identity_table, uint64_t size){
|
||||
}
|
||||
|
||||
void create_basic_page_table(four_lvl_paging_t* table, pagetable_t* kernel_identity){
|
||||
//pagetable_t* l2 = (pagetable_t*)PageFrameAllocator::alloc(true);
|
||||
|
||||
table->l4.entries[0] = {
|
||||
assert(table);
|
||||
assert(kernel_identity);
|
||||
|
||||
table->l4 = (pagetable_t*)PageFrameAllocator::alloc(true);
|
||||
table->l3 = (pagetable_t*)PageFrameAllocator::alloc(true);
|
||||
table->l2 = (pagetable_t*)PageFrameAllocator::alloc(true);
|
||||
|
||||
//memset(table, 0, sizeof(four_lvl_paging_t));
|
||||
table->l4->entries[0] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = ((uintptr_t)&(table->l3.entries[0])) >> 12,
|
||||
.address = ((uintptr_t)(table->l3)) >> 12,
|
||||
};
|
||||
|
||||
table->l3.entries[0] = {
|
||||
table->l3->entries[0] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = ((uintptr_t)&(table->l2.entries[0])) >> 12,
|
||||
.address = ((uintptr_t)(table->l2)) >> 12,
|
||||
};
|
||||
|
||||
//kernel memory
|
||||
for(uint32_t i=0; i<KERNEL_MEMORY_BORDER/4096/512; i++){
|
||||
table->l2.entries[i] = {
|
||||
table->l2->entries[i] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
@@ -55,19 +63,23 @@ void create_basic_page_table(four_lvl_paging_t* table, pagetable_t* kernel_ident
|
||||
//}
|
||||
|
||||
//add ioapic address to pagetable
|
||||
table->l3.entries[3] = {
|
||||
table->l2_apic = (pagetable_t*)PageFrameAllocator::alloc(true);
|
||||
table->ioapic = (pagetable_t*)PageFrameAllocator::alloc(true);
|
||||
table->lapic = (pagetable_t*)PageFrameAllocator::alloc(true);
|
||||
|
||||
table->l3->entries[3] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)&(table->l2_apic) >> 12,
|
||||
.address = (uintptr_t)(table->l2_apic) >> 12,
|
||||
};
|
||||
table->l2_apic.entries[502] = {
|
||||
table->l2_apic->entries[502] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)&(table->ioapic) >> 12,
|
||||
.address = (uintptr_t)(table->ioapic) >> 12,
|
||||
};
|
||||
table->ioapic.entries[0] = {
|
||||
table->ioapic->entries[0] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 0,
|
||||
@@ -75,13 +87,13 @@ void create_basic_page_table(four_lvl_paging_t* table, pagetable_t* kernel_ident
|
||||
};
|
||||
|
||||
//lapic
|
||||
table->l2_apic.entries[503] = {
|
||||
table->l2_apic->entries[503] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)&(table->lapic) >> 12,
|
||||
.address = (uintptr_t)(table->lapic) >> 12,
|
||||
};
|
||||
table->lapic.entries[0] = {
|
||||
table->lapic->entries[0] = {
|
||||
.present = 1,
|
||||
.write = 1,
|
||||
.user = 0,
|
||||
|
||||
Reference in New Issue
Block a user