diff options
author | Robert Morris <[email protected]> | 2017-08-08 13:27:06 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2017-08-08 13:27:06 -0400 |
commit | 14270288b7e5327832cdf6a8d9da52ef58fce652 (patch) | |
tree | b604cb49fb049a14966418eda4589cd1271f8e53 /lapic.c | |
parent | aba8423c4a5ae01828040d04f668f07ec544dcd0 (diff) | |
parent | 825ce074b10a0e1f63fd3a1fe245220d04054e0a (diff) | |
download | xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.tar.gz xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.tar.bz2 xv6-labs-14270288b7e5327832cdf6a8d9da52ef58fce652.zip |
Merge branch 'master' of g.csail.mit.edu:xv6-dev
Diffstat (limited to 'lapic.c')
-rw-r--r-- | lapic.c | 25 |
1 files changed, 2 insertions, 23 deletions
@@ -9,7 +9,6 @@ #include "traps.h" #include "mmu.h" #include "x86.h" -#include "proc.h" // ncpu // Local APIC registers, divided by 4 for use as uint[] indices. #define ID (0x0020/4) // ID @@ -99,31 +98,11 @@ lapicinit(void) } int -cpunum(void) +lapicid(void) { - int apicid, i; - - // Cannot call cpu when interrupts are enabled: - // result not guaranteed to last long enough to be used! - // Would prefer to panic but even printing is chancy here: - // almost everything, including cprintf and panic, calls cpu, - // often indirectly through acquire and release. - if(readeflags()&FL_IF){ - static int n; - if(n++ == 0) - cprintf("cpu called from %x with interrupts enabled\n", - __builtin_return_address(0)); - } - if (!lapic) return 0; - - apicid = lapic[ID] >> 24; - for (i = 0; i < ncpu; ++i) { - if (cpus[i].apicid == apicid) - return i; - } - panic("unknown apicid\n"); + return lapic[ID] >> 24; } // Acknowledge interrupt. |