kern
annotate src/proc.h @ 56:0be4615594df
finally, runqueues, blocking, waking up, idle loop etc, all seem to work fine
on a single user process... Next up: try forking another one :)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 15 Aug 2011 06:17:58 +0300 |
parents | 88a6c4e192f9 |
children | 437360696883 |
rev | line source |
---|---|
nuclear@29 | 1 #ifndef PROC_H_ |
nuclear@29 | 2 #define PROC_H_ |
nuclear@29 | 3 |
nuclear@43 | 4 #include <inttypes.h> |
nuclear@42 | 5 #include "asmops.h" |
nuclear@42 | 6 |
nuclear@42 | 7 #define MAX_PROC 128 |
nuclear@42 | 8 |
nuclear@42 | 9 struct context { |
nuclear@54 | 10 /*struct registers regs;*/ /* saved general purpose registers */ |
nuclear@54 | 11 /*uint32_t instr_ptr;*/ /* saved eip */ |
nuclear@47 | 12 uint32_t stack_ptr; /* saved esp */ |
nuclear@54 | 13 /*uint32_t flags;*/ /* saved eflags */ |
nuclear@47 | 14 uint32_t pgtbl_paddr; /* physical address of the page table */ |
nuclear@42 | 15 /* TODO add FPU state */ |
nuclear@42 | 16 }; |
nuclear@42 | 17 |
nuclear@51 | 18 enum proc_state { |
nuclear@53 | 19 STATE_RUNNABLE, |
nuclear@51 | 20 STATE_BLOCKED, |
nuclear@51 | 21 STATE_ZOMBIE |
nuclear@51 | 22 }; |
nuclear@51 | 23 |
nuclear@29 | 24 |
nuclear@29 | 25 struct process { |
nuclear@51 | 26 int id, parent; |
nuclear@51 | 27 enum proc_state state; |
nuclear@51 | 28 |
nuclear@55 | 29 /* when blocked it's waiting for a wakeup on this address */ |
nuclear@55 | 30 void *wait_addr; |
nuclear@55 | 31 |
nuclear@51 | 32 int ticks_left; |
nuclear@52 | 33 |
nuclear@52 | 34 /* extends of the process heap, increased by sbrk */ |
nuclear@52 | 35 |
nuclear@52 | 36 /* first page of the user stack, extends up to KMEM_START */ |
nuclear@54 | 37 int user_stack_pg; |
nuclear@54 | 38 /* first page of the kernel stack, (KERN_STACK_SIZE) */ |
nuclear@54 | 39 int kern_stack_pg; |
nuclear@52 | 40 |
nuclear@42 | 41 struct context ctx; |
nuclear@51 | 42 |
nuclear@51 | 43 struct process *next, *prev; /* for the scheduler queues */ |
nuclear@29 | 44 }; |
nuclear@29 | 45 |
nuclear@47 | 46 void init_proc(void); |
nuclear@47 | 47 |
nuclear@47 | 48 void context_switch(int pid); |
nuclear@47 | 49 |
nuclear@56 | 50 void set_current_pid(int pid); |
nuclear@51 | 51 int get_current_pid(void); |
nuclear@51 | 52 struct process *get_current_proc(void); |
nuclear@51 | 53 struct process *get_process(int pid); |
nuclear@51 | 54 |
nuclear@29 | 55 #endif /* PROC_H_ */ |