kern

annotate src/proc.h @ 54:4eaecb14fe31

bringing the task switching thing into shape with proper per-process kernel stacks and shit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 14 Aug 2011 16:57:23 +0300
parents 23abbeea4d5f
children 88a6c4e192f9
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@54 10 /*struct registers regs;*/ /* saved general purpose registers */
nuclear@54 11 /*uint32_t instr_ptr;*/ /* saved eip */
nuclear@47 12 uint32_t stack_ptr; /* saved esp */
nuclear@54 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@53 19 STATE_RUNNABLE,
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@54 34 int user_stack_pg;
nuclear@54 35 /* first page of the kernel stack, (KERN_STACK_SIZE) */
nuclear@54 36 int kern_stack_pg;
nuclear@52 37
nuclear@42 38 struct context ctx;
nuclear@51 39
nuclear@51 40 struct process *next, *prev; /* for the scheduler queues */
nuclear@29 41 };
nuclear@29 42
nuclear@47 43 void init_proc(void);
nuclear@47 44
nuclear@47 45 void context_switch(int pid);
nuclear@47 46
nuclear@51 47 int get_current_pid(void);
nuclear@51 48 struct process *get_current_proc(void);
nuclear@51 49 struct process *get_process(int pid);
nuclear@51 50
nuclear@29 51 #endif /* PROC_H_ */