diff options
author | rtm <rtm> | 2006-06-15 16:02:20 +0000 |
---|---|---|
committer | rtm <rtm> | 2006-06-15 16:02:20 +0000 |
commit | a4c03dea09b7b5f2463147e979d20b035b81de96 (patch) | |
tree | 3ba362f412faf45f0fb0e93b72f613ecc3956193 /trap.c | |
parent | cb83c71628378bc0e295dd71bf6641379fbcdf37 (diff) | |
download | xv6-labs-a4c03dea09b7b5f2463147e979d20b035b81de96.tar.gz xv6-labs-a4c03dea09b7b5f2463147e979d20b035b81de96.tar.bz2 xv6-labs-a4c03dea09b7b5f2463147e979d20b035b81de96.zip |
primitive fork and exit system calls
Diffstat (limited to 'trap.c')
-rw-r--r-- | trap.c | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -4,6 +4,7 @@ #include "proc.h" #include "defs.h" #include "x86.h" +#include "traps.h" struct Gatedesc idt[256]; struct Pseudodesc idt_pd = { 0, sizeof(idt) - 1, (unsigned) &idt }; @@ -12,29 +13,36 @@ extern unsigned vectors[]; /* vectors.S, array of 256 entry point addresses */ extern void trapenter(); extern void trapenter1(); - -int xx; - void tinit() { int i; - xx = 0; for(i = 0; i < 256; i++){ - SETGATE(idt[i], 1, SEG_KCODE << 3, vectors[i], 3); + SETGATE(idt[i], 1, SEG_KCODE << 3, vectors[i], 0); } + SETGATE(idt[T_SYSCALL], T_SYSCALL, SEG_KCODE << 3, vectors[48], 3); asm volatile("lidt %0" : : "g" (idt_pd.pd_lim)); } void trap(struct Trapframe *tf) { - /* which process are we running? */ - if(xx < 10) - cprintf("%d\n", tf->tf_trapno); - xx++; - //while(1) - //; + int v = tf->tf_trapno; + cprintf("trap %d eip %x:%x\n", tf->tf_trapno, tf->tf_cs, tf->tf_eip); + + if(v == T_SYSCALL){ + curproc->tf = tf; + syscall(); + return; + } + + if(v == 32){ + // probably clock + return; + } + + while(1) + ; // XXX probably ought to lgdt on trap return } |