kern
view src/proc.h @ 94:b3351d018ac6
read/write superblock, get/put inode
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 11 Dec 2011 11:12:30 +0200 |
parents | 3941e82b07f2 |
children | 07fe6a614185 |
line source
1 #ifndef PROC_H_
2 #define PROC_H_
4 #include <inttypes.h>
5 #include "asmops.h"
6 #include "rbtree.h"
7 #include "file.h"
9 #define MAX_PROC 128
10 #define MAX_FD 64
12 struct context {
13 /*struct registers regs;*/ /* saved general purpose registers */
14 /*uint32_t instr_ptr;*/ /* saved eip */
15 uint32_t stack_ptr; /* saved esp */
16 /*uint32_t flags;*/ /* saved eflags */
17 uint32_t pgtbl_paddr; /* physical address of the page table */
18 /* TODO add FPU state */
19 };
21 enum proc_state {
22 STATE_RUNNABLE,
23 STATE_BLOCKED,
24 STATE_ZOMBIE
25 };
28 struct process {
29 int id, parent;
30 enum proc_state state;
32 int exit_status;
34 /* when blocked it's waiting for a wakeup on this address */
35 void *wait_addr;
37 int ticks_left;
39 /* process vm map */
40 struct rbtree vmmap;
42 /* extends of the process heap, increased by sbrk */
44 /* first page of the user stack, extends up to KMEM_START */
45 int user_stack_pg;
46 /* first page of the kernel stack, (KERN_STACK_SIZE) */
47 int kern_stack_pg;
49 struct context ctx;
51 /* open files */
52 struct file files[MAX_FD];
54 struct process *child_list;
56 struct process *next, *prev; /* for the scheduler queues */
57 struct process *sib_next; /* for the sibling list */
58 };
60 void init_proc(void);
62 int sys_fork(void);
63 int sys_exit(int status);
64 int sys_waitpid(int pid, int *status, int opt);
66 void context_switch(int pid);
68 void set_current_pid(int pid);
69 int get_current_pid(void);
70 struct process *get_current_proc(void);
71 struct process *get_process(int pid);
73 int sys_getpid(void);
74 int sys_getppid(void);
76 /* defined in proc-asm.S */
77 uint32_t get_instr_ptr(void);
78 uint32_t get_caller_instr_ptr(void);
79 void get_instr_stack_ptr(uint32_t *iptr, uint32_t *sptr);
81 #endif /* PROC_H_ */