kern

annotate src/proc.h @ 52:fa65b4f45366

picking this up again, let's fix it
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 07 Aug 2011 06:42:00 +0300
parents b1e8c8251884
children 23abbeea4d5f
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@42 6
nuclear@42 7 #define MAX_PROC 128
nuclear@42 8
nuclear@42 9 struct context {
nuclear@47 10 struct registers regs; /* saved general purpose registers */
nuclear@47 11 uint32_t instr_ptr; /* saved eip */
nuclear@47 12 uint32_t stack_ptr; /* saved esp */
nuclear@47 13 uint32_t flags; /* saved eflags */
nuclear@47 14 uint32_t pgtbl_paddr; /* physical address of the page table */
nuclear@42 15 /* TODO add FPU state */
nuclear@42 16 };
nuclear@42 17
nuclear@51 18 enum proc_state {
nuclear@51 19 STATE_RUNNING,
nuclear@51 20 STATE_BLOCKED,
nuclear@51 21 STATE_ZOMBIE
nuclear@51 22 };
nuclear@51 23
nuclear@29 24
nuclear@29 25 struct process {
nuclear@51 26 int id, parent;
nuclear@51 27 enum proc_state state;
nuclear@51 28
nuclear@51 29 int ticks_left;
nuclear@52 30
nuclear@52 31 /* extends of the process heap, increased by sbrk */
nuclear@52 32
nuclear@52 33 /* first page of the user stack, extends up to KMEM_START */
nuclear@52 34 int stack_start_pg;
nuclear@52 35
nuclear@42 36 struct context ctx;
nuclear@51 37
nuclear@51 38 struct process *next, *prev; /* for the scheduler queues */
nuclear@29 39 };
nuclear@29 40
nuclear@47 41 void init_proc(void);
nuclear@47 42
nuclear@47 43 void context_switch(int pid);
nuclear@47 44
nuclear@51 45 int get_current_pid(void);
nuclear@51 46 struct process *get_current_proc(void);
nuclear@51 47 struct process *get_process(int pid);
nuclear@51 48
nuclear@29 49 #endif /* PROC_H_ */