kern

view src/proc.h @ 67:ebca81749ef5

added strcmp
author John Tsiombikas <nuclear@mutantstargoat.com>
date Sun, 09 Oct 2011 20:38:35 +0300
parents 0be4615594df
children 0a205396e1a0
line source
1 #ifndef PROC_H_
2 #define PROC_H_
4 #include <inttypes.h>
5 #include "asmops.h"
7 #define MAX_PROC 128
9 struct context {
10 /*struct registers regs;*/ /* saved general purpose registers */
11 /*uint32_t instr_ptr;*/ /* saved eip */
12 uint32_t stack_ptr; /* saved esp */
13 /*uint32_t flags;*/ /* saved eflags */
14 uint32_t pgtbl_paddr; /* physical address of the page table */
15 /* TODO add FPU state */
16 };
18 enum proc_state {
19 STATE_RUNNABLE,
20 STATE_BLOCKED,
21 STATE_ZOMBIE
22 };
25 struct process {
26 int id, parent;
27 enum proc_state state;
29 /* when blocked it's waiting for a wakeup on this address */
30 void *wait_addr;
32 int ticks_left;
34 /* extends of the process heap, increased by sbrk */
36 /* first page of the user stack, extends up to KMEM_START */
37 int user_stack_pg;
38 /* first page of the kernel stack, (KERN_STACK_SIZE) */
39 int kern_stack_pg;
41 struct context ctx;
43 struct process *next, *prev; /* for the scheduler queues */
44 };
46 void init_proc(void);
48 int fork(void);
50 void context_switch(int pid);
52 void set_current_pid(int pid);
53 int get_current_pid(void);
54 struct process *get_current_proc(void);
55 struct process *get_process(int pid);
57 /* defined in proc-asm.S */
58 uint32_t get_instr_ptr(void);
59 uint32_t get_caller_instr_ptr(void);
60 void get_instr_stack_ptr(uint32_t *iptr, uint32_t *sptr);
62 #endif /* PROC_H_ */