nuclear@42: #include "proc.h" nuclear@42: #include "tss.h" nuclear@42: nuclear@42: static struct process proc[MAX_PROC]; nuclear@42: static int cur_pid; nuclear@42: nuclear@42: void init_proc(void) nuclear@42: { nuclear@42: cur_pid = -1; nuclear@42: nuclear@42: /* prepare the first process */ nuclear@42: nuclear@42: /* create the virtual address space for this process */ nuclear@43: proc[0].ctx.pgtbl_paddr = clone_vmem(); nuclear@42: nuclear@42: /* allocate a chunk of memory for the process image nuclear@42: * and copy the code of test_proc there. nuclear@42: * (should be mapped at a fixed address) nuclear@42: */ nuclear@42: nuclear@42: /* fill in the proc[0].ctx with the appropriate process stack nuclear@42: * and instruction pointers nuclear@42: */ nuclear@42: nuclear@42: /* switch to it by calling a function that takes the context nuclear@42: * of the current process, plugs the values into the interrupt nuclear@42: * stack, and calls iret. nuclear@42: * (should also set ss0/sp0 in TSS before returning) nuclear@42: */ nuclear@42: } nuclear@42: nuclear@43: /* nuclear@42: void save_context(struct intr_frame *ifrm) nuclear@42: { nuclear@42: proc[cur_pid].ctx->regs = ifrm->regs; nuclear@42: proc[cur_pid].ctx->instr_ptr = ifrm->eip; nuclear@42: proc[cur_pid].ctx->stack_ptr = ifrm->esp; nuclear@42: proc[cur_pid].ctx->flags = ifrm->eflags; nuclear@43: }*/