work on page loading
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "thread.h"
|
||||
#include "../arch/core_ring.h"
|
||||
#include "../memory/pageframealloc.h"
|
||||
#include "../memory/pagetable.h"
|
||||
#include "../debug/kernelpanic.h"
|
||||
#include "../interrupt/guard.h"
|
||||
#include "debug/output.h"
|
||||
@@ -34,9 +35,32 @@ void Thread::kickoffUsermode (Thread *object){
|
||||
((void(*)())object->start)();
|
||||
}
|
||||
|
||||
extern four_lvl_paging_t paging_tree;
|
||||
Thread::Thread (bool kernel, void * start): queue_link(nullptr), isKernel(kernel), start(start), id(idCounter++), kill_flag(false){
|
||||
StackPointer.isr = reinterpret_cast<void *>(reserved_stack_space_isr + STACK_SIZE);
|
||||
StackPointer.user = reinterpret_cast<void *>(PageFrameAllocator::alloc(false) + STACK_SIZE);
|
||||
StackPointer.user = reinterpret_cast<void *>((uintptr_t)PageFrameAllocator::alloc(false)+STACK_SIZE);
|
||||
|
||||
subtable = (pagetable_t*) PageFrameAllocator::alloc(true);
|
||||
|
||||
subtable->entries[0] = {
|
||||
.present = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)start >> 12
|
||||
};
|
||||
|
||||
subtable->entries[1] = {
|
||||
.present = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)StackPointer.user >> 12
|
||||
};
|
||||
|
||||
//paging_tree.l2.entries[32] = {
|
||||
// .present = 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);
|
||||
}
|
||||
|
||||
@@ -48,6 +72,11 @@ Thread::Thread() : Thread(false, 0) {}
|
||||
|
||||
void Thread::resume(Thread *next) {
|
||||
assert(next != nullptr && "Pointer to next Thread must not be nullptr!");
|
||||
paging_tree.l2.entries[32] = {
|
||||
.present = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)&next->subtable>>12
|
||||
};
|
||||
context_switch(&next->context, &context);
|
||||
}
|
||||
|
||||
@@ -61,6 +90,13 @@ void* Thread::operator new(size_t sz) noexcept
|
||||
}
|
||||
|
||||
|
||||
void Thread::go() { context_launch(&context); }
|
||||
void Thread::go() {
|
||||
paging_tree.l2.entries[32] = {
|
||||
.present = 1,
|
||||
.user = 1,
|
||||
.address = (uintptr_t)&subtable>>12
|
||||
};
|
||||
context_launch(&context);
|
||||
}
|
||||
|
||||
void Thread::action() { kernelpanic("Wrong entry / missing action in Thread"); }
|
||||
|
||||
Reference in New Issue
Block a user