kern

annotate src/proc.h @ 51:b1e8c8251884

lalalala
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 01 Aug 2011 06:45:29 +0300
parents f65b348780e3
children fa65b4f45366
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@42 30 struct context ctx;
nuclear@51 31
nuclear@51 32 struct process *next, *prev; /* for the scheduler queues */
nuclear@29 33 };
nuclear@29 34
nuclear@47 35 void init_proc(void);
nuclear@47 36
nuclear@47 37 void context_switch(int pid);
nuclear@47 38
nuclear@51 39 int get_current_pid(void);
nuclear@51 40 struct process *get_current_proc(void);
nuclear@51 41 struct process *get_process(int pid);
nuclear@51 42
nuclear@29 43 #endif /* PROC_H_ */