summaryrefslogtreecommitdiff
path: root/trap.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2016-09-02 08:31:13 -0400
committerFrans Kaashoek <[email protected]>2016-09-02 08:31:13 -0400
commitae15515d80559ff95b315e3342c3baa00b87be1c (patch)
treeb61b17981cce96f0b66efc77a7ce479e3e66a843 /trap.c
parent37939f24c2fbb12a57a628fedd024a4865741e74 (diff)
downloadxv6-labs-ae15515d80559ff95b315e3342c3baa00b87be1c.tar.gz
xv6-labs-ae15515d80559ff95b315e3342c3baa00b87be1c.tar.bz2
xv6-labs-ae15515d80559ff95b315e3342c3baa00b87be1c.zip
APIC IDs may not be consecutive and start from zero, so we cannot really use it
as a direct index into cpus. Record apicid in struct cpu and have cpunum() look for it. Replace cpu->id with cpunum() everywhere, and replace cpu->id with cpu->apicid. Thanks to Xi Wang.
Diffstat (limited to 'trap.c')
-rw-r--r--trap.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/trap.c b/trap.c
index 20ae62d..e6b3784 100644
--- a/trap.c
+++ b/trap.c
@@ -48,7 +48,7 @@ trap(struct trapframe *tf)
switch(tf->trapno){
case T_IRQ0 + IRQ_TIMER:
- if(cpu->id == 0){
+ if(cpunum() == 0){
acquire(&tickslock);
ticks++;
wakeup(&ticks);
@@ -74,7 +74,7 @@ trap(struct trapframe *tf)
case T_IRQ0 + 7:
case T_IRQ0 + IRQ_SPURIOUS:
cprintf("cpu%d: spurious interrupt at %x:%x\n",
- cpu->id, tf->cs, tf->eip);
+ cpunum(), tf->cs, tf->eip);
lapiceoi();
break;
@@ -83,13 +83,13 @@ trap(struct trapframe *tf)
if(proc == 0 || (tf->cs&3) == 0){
// In kernel, it must be our mistake.
cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n",
- tf->trapno, cpu->id, tf->eip, rcr2());
+ tf->trapno, cpunum(), tf->eip, rcr2());
panic("trap");
}
// In user space, assume process misbehaved.
cprintf("pid %d %s: trap %d err %d on cpu %d "
"eip 0x%x addr 0x%x--kill proc\n",
- proc->pid, proc->name, tf->trapno, tf->err, cpu->id, tf->eip,
+ proc->pid, proc->name, tf->trapno, tf->err, cpunum(), tf->eip,
rcr2());
proc->killed = 1;
}