kern
annotate src/proc.h @ 57:437360696883
I think we're done for now. two processes seem to be scheduled and switched just fine, fork seems to work (NO CoW YET!)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 16 Aug 2011 03:26:53 +0300 |
parents | 0be4615594df |
children | 0a205396e1a0 |
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@57 | 48 int fork(void); |
nuclear@57 | 49 |
nuclear@47 | 50 void context_switch(int pid); |
nuclear@47 | 51 |
nuclear@56 | 52 void set_current_pid(int pid); |
nuclear@51 | 53 int get_current_pid(void); |
nuclear@51 | 54 struct process *get_current_proc(void); |
nuclear@51 | 55 struct process *get_process(int pid); |
nuclear@51 | 56 |
nuclear@57 | 57 /* defined in proc-asm.S */ |
nuclear@57 | 58 uint32_t get_instr_ptr(void); |
nuclear@57 | 59 uint32_t get_caller_instr_ptr(void); |
nuclear@57 | 60 void get_instr_stack_ptr(uint32_t *iptr, uint32_t *sptr); |
nuclear@57 | 61 |
nuclear@29 | 62 #endif /* PROC_H_ */ |