2 apps working

This commit is contained in:
2026-02-17 18:53:41 +01:00
parent 4cedc4088f
commit e1d99d5129
3 changed files with 38 additions and 36 deletions

View File

@@ -20,7 +20,7 @@ void Thread::kickoff(uintptr_t param1, uintptr_t param2, uintptr_t param3) {
Guard::leave();
if(!thread->isKernel)
Core::Ring::switchToUsermode(thread->StackPointer.user, thread->start, 0);
Core::Ring::switchToUsermode(thread->StackPointer.user, (void*)0x4000000, 0);
else
if(thread->start == nullptr)
thread->action();
@@ -38,21 +38,24 @@ void Thread::load_paging(Thread* t){
load_cr3((void*)&paging_tree.l4);
}
Thread::Thread (bool kernel, void * start): queue_link(nullptr), isKernel(kernel), start(start), id(idCounter++), kill_flag(false){
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 = reinterpret_cast<void *>((uintptr_t)PageFrameAllocator::alloc(false)+STACK_SIZE);
StackPointer.user = (void*)(0x4100000+STACK_SIZE);
subtable = (pagetable_t*) PageFrameAllocator::alloc(true);
subtable->entries[0] = {
.present = 1,
.user = 1,
.address = (uintptr_t)start >> 12
};
subtable->entries[1] = {
for(uint8_t i=0; i<num_pages; i++){
subtable->entries[i] = {
.present = 1,
.user = 1,
.address = ((uintptr_t)startframe >> 12) + i
};
}
uintptr_t user_stackframe_p = ((uintptr_t)PageFrameAllocator::alloc(false));
subtable->entries[256] = {
.present = 1,
.write = 1,
.user = 1,
.address = (uintptr_t)StackPointer.user >> 12
.address = user_stackframe_p >> 12
};
//map_pageframe(&paging_tree, (uintptr_t)StackPointer.user, 0x4001000);