diff --git a/include/task.h b/include/task.h index cbb9e15..ef4f9d3 100644 --- a/include/task.h +++ b/include/task.h @@ -68,6 +68,8 @@ typedef struct Process l9660_dir* cwd; void* brk; + + uint32_t kstack_top; } Process; extern Process* current; diff --git a/src/tasking/task.c b/src/tasking/task.c index 5452f53..68297dc 100644 --- a/src/tasking/task.c +++ b/src/tasking/task.c @@ -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); }