kern
annotate src/proc.c @ 43:5f6c5751ae05
- implemented clone_vmem
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 25 Jul 2011 11:29:02 +0300 |
parents | e6de3c6015cb |
children | b8f02479e3f4 |
rev | line source |
---|---|
nuclear@42 | 1 #include "proc.h" |
nuclear@42 | 2 #include "tss.h" |
nuclear@42 | 3 |
nuclear@42 | 4 static struct process proc[MAX_PROC]; |
nuclear@42 | 5 static int cur_pid; |
nuclear@42 | 6 |
nuclear@42 | 7 void init_proc(void) |
nuclear@42 | 8 { |
nuclear@42 | 9 cur_pid = -1; |
nuclear@42 | 10 |
nuclear@42 | 11 /* prepare the first process */ |
nuclear@42 | 12 |
nuclear@42 | 13 /* create the virtual address space for this process */ |
nuclear@43 | 14 proc[0].ctx.pgtbl_paddr = clone_vmem(); |
nuclear@42 | 15 |
nuclear@42 | 16 /* allocate a chunk of memory for the process image |
nuclear@42 | 17 * and copy the code of test_proc there. |
nuclear@42 | 18 * (should be mapped at a fixed address) |
nuclear@42 | 19 */ |
nuclear@42 | 20 |
nuclear@42 | 21 /* fill in the proc[0].ctx with the appropriate process stack |
nuclear@42 | 22 * and instruction pointers |
nuclear@42 | 23 */ |
nuclear@42 | 24 |
nuclear@42 | 25 /* switch to it by calling a function that takes the context |
nuclear@42 | 26 * of the current process, plugs the values into the interrupt |
nuclear@42 | 27 * stack, and calls iret. |
nuclear@42 | 28 * (should also set ss0/sp0 in TSS before returning) |
nuclear@42 | 29 */ |
nuclear@42 | 30 } |
nuclear@42 | 31 |
nuclear@43 | 32 /* |
nuclear@42 | 33 void save_context(struct intr_frame *ifrm) |
nuclear@42 | 34 { |
nuclear@42 | 35 proc[cur_pid].ctx->regs = ifrm->regs; |
nuclear@42 | 36 proc[cur_pid].ctx->instr_ptr = ifrm->eip; |
nuclear@42 | 37 proc[cur_pid].ctx->stack_ptr = ifrm->esp; |
nuclear@42 | 38 proc[cur_pid].ctx->flags = ifrm->eflags; |
nuclear@43 | 39 }*/ |