load cr3 in dispatcher

This commit is contained in:
2026-02-16 22:49:42 +01:00
parent ef534e2ac7
commit f0bda5f466
2 changed files with 5 additions and 0 deletions

View File

@@ -10,11 +10,13 @@
Dispatcher::Dispatcher() : life(nullptr) {} Dispatcher::Dispatcher() : life(nullptr) {}
Thread *Dispatcher::active() const { return life; } Thread *Dispatcher::active() const { return life; }
extern four_lvl_paging_t paging_tree;
void Dispatcher::go(Thread *first) { void Dispatcher::go(Thread *first) {
assert(active() == nullptr); assert(active() == nullptr);
setActive(first); setActive(first);
mytss.sp0 = first->StackPointer.isr; mytss.sp0 = first->StackPointer.isr;
load_cr3((void*)&paging_tree.l4);
first->go(); first->go();
} }
@@ -24,6 +26,7 @@ void Dispatcher::dispatch(Thread *next) {
if (current != next) { if (current != next) {
setActive(next); setActive(next);
mytss.sp0 = next->StackPointer.isr; mytss.sp0 = next->StackPointer.isr;
load_cr3((void*)&paging_tree.l4);
current->resume(next); current->resume(next);
} }
} }

View File

@@ -69,6 +69,7 @@ void Thread::resume(Thread *next) {
.user = 1, .user = 1,
.address = (uintptr_t)&next->subtable>>12 .address = (uintptr_t)&next->subtable>>12
}; };
load_cr3((void*)&paging_tree.l4);
context_switch(&next->context, &context); context_switch(&next->context, &context);
} }
@@ -88,6 +89,7 @@ void Thread::go() {
.user = 1, .user = 1,
.address = (uintptr_t)&subtable>>12 .address = (uintptr_t)&subtable>>12
}; };
load_cr3((void*)&paging_tree.l4);
context_launch(&context); context_launch(&context);
} }