kern

annotate src/proc.h @ 90:7ff2b4971216

started work on the filesystem
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 09 Dec 2011 13:44:15 +0200
parents 3941e82b07f2
children 07fe6a614185
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@72 54 struct process *child_list;
nuclear@72 55
nuclear@51 56 struct process *next, *prev; /* for the scheduler queues */
nuclear@72 57 struct process *sib_next; /* for the sibling list */
nuclear@29 58 };
nuclear@29 59
nuclear@47 60 void init_proc(void);
nuclear@47 61
nuclear@72 62 int sys_fork(void);
nuclear@72 63 int sys_exit(int status);
nuclear@72 64 int sys_waitpid(int pid, int *status, int opt);
nuclear@57 65
nuclear@47 66 void context_switch(int pid);
nuclear@47 67
nuclear@56 68 void set_current_pid(int pid);
nuclear@51 69 int get_current_pid(void);
nuclear@51 70 struct process *get_current_proc(void);
nuclear@51 71 struct process *get_process(int pid);
nuclear@51 72
nuclear@72 73 int sys_getpid(void);
nuclear@72 74 int sys_getppid(void);
nuclear@72 75
nuclear@57 76 /* defined in proc-asm.S */
nuclear@57 77 uint32_t get_instr_ptr(void);
nuclear@57 78 uint32_t get_caller_instr_ptr(void);
nuclear@57 79 void get_instr_stack_ptr(uint32_t *iptr, uint32_t *sptr);
nuclear@57 80
nuclear@29 81 #endif /* PROC_H_ */