summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/trap.c b/trap.c
index 01c2f14..e36540d 100644
--- a/trap.c
+++ b/trap.c
@@ -35,16 +35,28 @@ trap(struct Trapframe *tf)
{
int v = tf->tf_trapno;
+ if(tf->tf_cs == 0x8 && kernel_lock == cpu())
+ cprintf("cpu %d: trap from %x:%x with lock=%d\n",
+ cpu(), tf->tf_cs, tf->tf_eip, kernel_lock);
+
acquire_spinlock(&kernel_lock); // released in trapret in trapasm.S
if(v == T_SYSCALL){
- curproc[cpu()]->tf = tf;
+ struct proc *cp = curproc[cpu()];
+ cp->tf = tf;
syscall();
+ if(cp != curproc[cpu()])
+ panic("trap ret wrong curproc");
+ if(cp->state != RUNNING)
+ panic("trap ret but not RUNNING");
+ if(tf != cp->tf)
+ panic("trap ret wrong tf");
+ if(read_esp() < cp->kstack || read_esp() >= cp->kstack + KSTACKSIZE)
+ panic("trap ret esp wrong");
return;
}
if(v == (IRQ_OFFSET + IRQ_TIMER)){
- curproc[cpu()]->tf = tf;
lapic_timerintr();
return;
}