working on new paging structure

This commit is contained in:
2026-02-24 02:15:36 +01:00
parent c644ba6e42
commit ec53b15ce1
5 changed files with 51 additions and 41 deletions

View File

@@ -9,7 +9,8 @@
#include "debug/output.h"
static int idCounter = 1; // counter for task IDs
extern four_lvl_paging_t paging_tree;
//extern four_lvl_paging_t paging_tree;
extern pagetable_t identity_table;
void Thread::kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3) {
Thread *thread = reinterpret_cast<Thread *>(param1);
@@ -29,19 +30,15 @@ void Thread::kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3) {
}
void Thread::load_paging(Thread* t){
paging_tree.l2.entries[32] = {
.present = 1,
.write = 1,
.user = 1,
.address = (uintptr_t)(t->subtable) >> 12
};
load_cr3((void*)&paging_tree.l4);
load_cr3((void*)&(t->paging_tree.l4.entries[0]));
}
Thread::Thread (bool kernel, void * startframe, int num_pages): queue_link(nullptr), isKernel(kernel), start(startframe), id(idCounter++), kill_flag(false){
StackPointer.isr = reinterpret_cast<void *>((uintptr_t)PageFrameAllocator::alloc(true)+STACK_SIZE);//(reserved_stack_space_isr + STACK_SIZE);
StackPointer.user = (void*)(0x4100000+STACK_SIZE);
create_basic_page_table(&paging_tree, &identity_table);
subtable = (pagetable_t*) PageFrameAllocator::alloc(true);
for(uint8_t i=0; i<num_pages; i++){
subtable->entries[i] = {
@@ -58,6 +55,15 @@ Thread::Thread (bool kernel, void * startframe, int num_pages): queue_link(null
.address = user_stackframe_p >> 12
};
//pagetable_t* l2addr = (pagetable_t*)(paging_tree.l3.entries[0].address<<12);
//l2addr->entries[32] = {
paging_tree.l2.entries[32] = {
.present = 1,
.write = 1,
.user = 1,
.address = (uintptr_t)(subtable) >> 12
};
//map_pageframe(&paging_tree, (uintptr_t)StackPointer.user, 0x4001000);
prepareContext(StackPointer.isr, context, kickoff, reinterpret_cast<uintptr_t>(this), 0, 0);

View File

@@ -34,6 +34,7 @@ class Thread {
void* start;
four_lvl_paging_t paging_tree;
friend class Queue<Thread>;
friend class Semaphore;