nuclear@29: #ifndef PROC_H_ nuclear@29: #define PROC_H_ nuclear@29: nuclear@43: #include nuclear@42: #include "asmops.h" nuclear@42: nuclear@42: #define MAX_PROC 128 nuclear@42: nuclear@42: struct context { nuclear@54: /*struct registers regs;*/ /* saved general purpose registers */ nuclear@54: /*uint32_t instr_ptr;*/ /* saved eip */ nuclear@47: uint32_t stack_ptr; /* saved esp */ nuclear@54: /*uint32_t flags;*/ /* saved eflags */ nuclear@47: uint32_t pgtbl_paddr; /* physical address of the page table */ nuclear@42: /* TODO add FPU state */ nuclear@42: }; nuclear@42: nuclear@51: enum proc_state { nuclear@53: STATE_RUNNABLE, nuclear@51: STATE_BLOCKED, nuclear@51: STATE_ZOMBIE nuclear@51: }; nuclear@51: nuclear@29: nuclear@29: struct process { nuclear@51: int id, parent; nuclear@51: enum proc_state state; nuclear@51: nuclear@55: /* when blocked it's waiting for a wakeup on this address */ nuclear@55: void *wait_addr; nuclear@55: nuclear@51: int ticks_left; nuclear@52: nuclear@52: /* extends of the process heap, increased by sbrk */ nuclear@52: nuclear@52: /* first page of the user stack, extends up to KMEM_START */ nuclear@54: int user_stack_pg; nuclear@54: /* first page of the kernel stack, (KERN_STACK_SIZE) */ nuclear@54: int kern_stack_pg; nuclear@52: nuclear@42: struct context ctx; nuclear@51: nuclear@51: struct process *next, *prev; /* for the scheduler queues */ nuclear@29: }; nuclear@29: nuclear@47: void init_proc(void); nuclear@47: nuclear@47: void context_switch(int pid); nuclear@47: nuclear@51: int get_current_pid(void); nuclear@51: struct process *get_current_proc(void); nuclear@51: struct process *get_process(int pid); nuclear@51: nuclear@29: #endif /* PROC_H_ */