kern

view src/proc.c @ 42:e6de3c6015cb

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