Triple fault after enabling paging
Posted: Sun Apr 29, 2018 12:12 am
Hi,
After enabling paging my kernel will cause a page fault, then a double fault and a triple fault. This is my paging library:
The full source code is at https://github.com/weedboi6969/puckos. Can someone help me with that?
These are the guides that I used:
http://www.osdever.net/tutorials/view/i ... sic-paging
https://wiki.osdev.org/Setting_Up_Paging
After enabling paging my kernel will cause a page fault, then a double fault and a triple fault. This is my paging library:
Code: Select all
#include <kernel/paging.h>
uint32_t pageDirectory[1024] __attribute__((aligned(4096)));
uint32_t* pageTable_ID[1024] __attribute__ ((aligned(4096)));
uint32_t* pageTable_Kernel[1024] __attribute__ ((aligned(4096)));
extern void pagingLoadDir(uint32_t* directory);
extern void pagingEnable();
void pagingCalculateAddress(uint32_t vaddr, uint16_t* dirEntry, uint16_t* tableEntry) {
*dirEntry = vaddr / 4194304;
*tableEntry = vaddr % 4194304;
}
void pagingFillTable(void* table, uint32_t* address, uint16_t attributes) {
uint32_t* tablePtr = (uint32_t*) table;
for(uint16_t i = 0; i < 1024; i++) {
tablePtr[i] = address;
tablePtr[i] |= attributes;
address += 4096;
}
}
void pagingAddTable(uint16_t entry, void* table, uint16_t attributes) {
pageDirectory[entry] = table;
pageDirectory[entry] |= attributes;
}
void pagingInit(void) {
for(uint16_t i = 0; i < 1024; i++) pageDirectory[i] = 0;
pagingFillTable(pageTable_ID, 0x00000000, 3);
pagingAddTable(0, pageTable_ID, 3);
pagingFillTable(pageTable_Kernel, 0x00100000, 3);
pagingAddTable(768, pageTable_Kernel, 3);
pagingLoadDir((uint32_t) pageDirectory);
pagingEnable();
}
These are the guides that I used:
http://www.osdever.net/tutorials/view/i ... sic-paging
https://wiki.osdev.org/Setting_Up_Paging