kern

annotate src/proc.h @ 79:2dda077c1d38

silenced a warning about a missing prototype in panic.c
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 Dec 2011 12:59:38 +0200
parents 0a205396e1a0
children 7ff2b4971216
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@68 6 #include "rbtree.h"
nuclear@42 7
nuclear@42 8 #define MAX_PROC 128
nuclear@42 9
nuclear@42 10 struct context {
nuclear@54 11 /*struct registers regs;*/ /* saved general purpose registers */
nuclear@54 12 /*uint32_t instr_ptr;*/ /* saved eip */
nuclear@47 13 uint32_t stack_ptr; /* saved esp */
nuclear@54 14 /*uint32_t flags;*/ /* saved eflags */
nuclear@47 15 uint32_t pgtbl_paddr; /* physical address of the page table */
nuclear@42 16 /* TODO add FPU state */
nuclear@42 17 };
nuclear@42 18
nuclear@51 19 enum proc_state {
nuclear@53 20 STATE_RUNNABLE,
nuclear@51 21 STATE_BLOCKED,
nuclear@51 22 STATE_ZOMBIE
nuclear@51 23 };
nuclear@51 24
nuclear@29 25
nuclear@29 26 struct process {
nuclear@51 27 int id, parent;
nuclear@51 28 enum proc_state state;
nuclear@51 29
nuclear@72 30 int exit_status;
nuclear@72 31
nuclear@55 32 /* when blocked it's waiting for a wakeup on this address */
nuclear@55 33 void *wait_addr;
nuclear@55 34
nuclear@51 35 int ticks_left;
nuclear@52 36
nuclear@68 37 /* process vm map */
nuclear@68 38 struct rbtree vmmap;
nuclear@68 39
nuclear@52 40 /* extends of the process heap, increased by sbrk */
nuclear@52 41
nuclear@52 42 /* first page of the user stack, extends up to KMEM_START */
nuclear@54 43 int user_stack_pg;
nuclear@54 44 /* first page of the kernel stack, (KERN_STACK_SIZE) */
nuclear@54 45 int kern_stack_pg;
nuclear@52 46
nuclear@42 47 struct context ctx;
nuclear@51 48
nuclear@72 49 struct process *child_list;
nuclear@72 50
nuclear@51 51 struct process *next, *prev; /* for the scheduler queues */
nuclear@72 52 struct process *sib_next; /* for the sibling list */
nuclear@29 53 };
nuclear@29 54
nuclear@47 55 void init_proc(void);
nuclear@47 56
nuclear@72 57 int sys_fork(void);
nuclear@72 58 int sys_exit(int status);
nuclear@72 59 int sys_waitpid(int pid, int *status, int opt);
nuclear@57 60
nuclear@47 61 void context_switch(int pid);
nuclear@47 62
nuclear@56 63 void set_current_pid(int pid);
nuclear@51 64 int get_current_pid(void);
nuclear@51 65 struct process *get_current_proc(void);
nuclear@51 66 struct process *get_process(int pid);
nuclear@51 67
nuclear@72 68 int sys_getpid(void);
nuclear@72 69 int sys_getppid(void);
nuclear@72 70
nuclear@57 71 /* defined in proc-asm.S */
nuclear@57 72 uint32_t get_instr_ptr(void);
nuclear@57 73 uint32_t get_caller_instr_ptr(void);
nuclear@57 74 void get_instr_stack_ptr(uint32_t *iptr, uint32_t *sptr);
nuclear@57 75
nuclear@29 76 #endif /* PROC_H_ */