tasking: fix stack corruption on the scheduler trigger
This commit is contained in:
@@ -68,6 +68,8 @@ typedef struct Process
|
||||
l9660_dir* cwd;
|
||||
|
||||
void* brk;
|
||||
|
||||
uint32_t kstack_top;
|
||||
} Process;
|
||||
|
||||
extern Process* current;
|
||||
|
||||
+4
-1
@@ -32,6 +32,9 @@ Process* task_create(uint32_t func, uint32_t user_esp, uint32_t ring, uint32_t*
|
||||
p->kstack = (char*)((uint32_t)kstack_physical+0xC0000000);
|
||||
map_page(kstack_physical, p->kstack, PAGE_PRESENT | PAGE_RW);
|
||||
debug_log("kstack: %X!!!!!!!!!!!!\n", p->kstack);
|
||||
|
||||
p->kstack_top = (uint32_t)p->kstack + KSTACKSIZE;
|
||||
|
||||
uint8_t* sp = (uint8_t*)(p->kstack + KSTACKSIZE);
|
||||
|
||||
sp -= sizeof(TrapFrame);
|
||||
@@ -146,7 +149,7 @@ void schedule() {
|
||||
}
|
||||
|
||||
if (next && next != current) {
|
||||
tss.esp0 = next->kesp;
|
||||
tss.esp0 = next->kstack_top;
|
||||
switchProcess(next);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user