kern

annotate src/proc.h @ 98:921a264297a4

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