From ae15515d80559ff95b315e3342c3baa00b87be1c Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Fri, 2 Sep 2016 08:31:13 -0400 Subject: 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. --- trap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'trap.c') 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; } -- cgit v1.2.3