make trap fit on one page
This commit is contained in:
parent
1656b1b232
commit
cd12eea3c7
1 changed files with 6 additions and 12 deletions
18
trap.c
18
trap.c
|
@ -9,10 +9,8 @@
|
||||||
|
|
||||||
// Interrupt descriptor table (shared by all CPUs).
|
// Interrupt descriptor table (shared by all CPUs).
|
||||||
struct gatedesc idt[256];
|
struct gatedesc idt[256];
|
||||||
|
|
||||||
extern uint vectors[]; // in vectors.S: array of 256 entry pointers
|
extern uint vectors[]; // in vectors.S: array of 256 entry pointers
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tvinit(void)
|
tvinit(void)
|
||||||
{
|
{
|
||||||
|
@ -46,8 +44,7 @@ trap(struct trapframe *tf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment nlock to make sure interrupts stay off
|
// Increment nlock to make sure interrupts stay off
|
||||||
// during interrupt handler. Must decrement before
|
// during interrupt handler. Decrement before returning.
|
||||||
// returning.
|
|
||||||
cpus[cpu()].nlock++;
|
cpus[cpu()].nlock++;
|
||||||
|
|
||||||
switch(v){
|
switch(v){
|
||||||
|
@ -55,11 +52,9 @@ trap(struct trapframe *tf)
|
||||||
lapic_timerintr();
|
lapic_timerintr();
|
||||||
cpus[cpu()].nlock--;
|
cpus[cpu()].nlock--;
|
||||||
if(cp){
|
if(cp){
|
||||||
// Force process exit if it has been killed
|
// Force process exit if it has been killed and is in user space.
|
||||||
// and the interrupt came from user space.
|
// (If it is still executing in the kernel, let it keep running
|
||||||
// (If the kernel was executing at time of interrupt,
|
// until it gets to the regular system call return.)
|
||||||
// don't kill the process. Let the process get back
|
|
||||||
// out to its regular system call return.)
|
|
||||||
if((tf->cs&3) == 3 && cp->killed)
|
if((tf->cs&3) == 3 && cp->killed)
|
||||||
proc_exit();
|
proc_exit();
|
||||||
|
|
||||||
|
@ -85,14 +80,13 @@ trap(struct trapframe *tf)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if(curproc[cpu()]) {
|
if(curproc[cpu()]) {
|
||||||
// assume process caused unexpected trap,
|
// Assume process divided by zero or dereferenced null, etc.
|
||||||
// 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",
|
cprintf("pid %d: unhandled trap %d on cpu %d eip %x -- kill proc\n",
|
||||||
curproc[cpu()]->pid, v, cpu(), tf->eip);
|
curproc[cpu()]->pid, v, cpu(), tf->eip);
|
||||||
proc_exit();
|
proc_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise it's our mistake
|
// Otherwise it's our mistake.
|
||||||
cprintf("unexpected trap %d from cpu %d eip %x\n", v, cpu(), tf->eip);
|
cprintf("unexpected trap %d from cpu %d eip %x\n", v, cpu(), tf->eip);
|
||||||
panic("trap");
|
panic("trap");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue