summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
authorrsc <rsc>2006-09-07 14:12:30 +0000
committerrsc <rsc>2006-09-07 14:12:30 +0000
commit31085bb4166c18b3dee059160d64b4edd7c5e2f4 (patch)
treed3b166a2c39f77e06e7104659b537521282f9260 /trap.c
parent7e019461c8bf0afbe73f959ca3394cce832501fd (diff)
downloadxv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.tar.gz
xv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.tar.bz2
xv6-labs-31085bb4166c18b3dee059160d64b4edd7c5e2f4.zip
more comments
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/trap.c b/trap.c
index 4fb3039..b35107f 100644
--- a/trap.c
+++ b/trap.c
@@ -7,11 +7,11 @@
#include "traps.h"
#include "syscall.h"
+// Interrupt descriptor table (shared by all CPUs).
struct gatedesc idt[256];
+
extern uint vectors[]; // in vectors.S: array of 256 entry pointers
-extern void trapenter(void);
-extern void trapenter1(void);
void
tvinit(void)
@@ -65,30 +65,34 @@ trap(struct trapframe *tf)
return;
}
- if(v == (IRQ_OFFSET + IRQ_IDE)){
+ if(v == IRQ_OFFSET + IRQ_IDE){
ide_intr();
cli(); // prevent a waiting interrupt from overflowing stack
lapic_eoi();
return;
}
- if(v == (IRQ_OFFSET + IRQ_KBD)){
+ if(v == IRQ_OFFSET + IRQ_KBD){
kbd_intr();
cli(); // prevent a waiting interrupt from overflowing stack
lapic_eoi();
return;
}
- if(v == (IRQ_OFFSET + IRQ_SPURIOUS)){
+ if(v == IRQ_OFFSET + IRQ_SPURIOUS){
cprintf("spurious interrupt from cpu %d eip %x\n", cpu(), tf->eip);
return; // no eoi for this one.
}
if(curproc[cpu()]) {
+ // assume process caused unexpected trap,
+ // for example by dividing by zero or dereferencing a bad pointer
cprintf("pid %d: unhandled trap %d on cpu %d eip %x -- kill proc\n",
curproc[cpu()]->pid, v, cpu(), tf->eip);
proc_exit();
}
+
+ // otherwise it's our mistake
cprintf("unexpected trap %d from cpu %d eip %x\n", v, cpu(), tf->eip);
panic("trap");
}