wip: uncrampt the stack thing in the irq
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
#include "string.h"
|
||||
#include "thread.h"
|
||||
|
||||
struct tcb *create_thread(struct pcb *process, void (*routine)(void))
|
||||
struct tcb *create_thread(struct pcb *process, void (*entry)(void))
|
||||
{
|
||||
static uint32_t tid = 1;
|
||||
struct tcb *new_tcb = vmalloc(sizeof(struct tcb));
|
||||
@ -21,8 +21,14 @@ struct tcb *create_thread(struct pcb *process, void (*routine)(void))
|
||||
}
|
||||
// set esp to "skip" the 4 GPRs and eip later to be used as the context
|
||||
// of the thread
|
||||
new_tcb->esp = new_tcb->esp0 + STACK_SIZE - 5 * 4;
|
||||
new_tcb->esp[4] = (uint32_t)routine;
|
||||
uint32_t *stack =
|
||||
(uint32_t *)((uint8_t *)new_tcb->esp0 + STACK_SIZE - 5 * 4);
|
||||
|
||||
// testing out some stuff
|
||||
*(--stack) = 0x202; // EFLAGS
|
||||
*(--stack) = 0x08; // CS = kernel code segment
|
||||
*(--stack) = (uint32_t)entry;
|
||||
new_tcb->esp = stack;
|
||||
new_tcb->process = process;
|
||||
new_tcb->next = NULL;
|
||||
new_tcb->state = NEW;
|
||||
|
||||
Reference in New Issue
Block a user