diff options
author | Frans Kaashoek <[email protected]> | 2017-08-07 14:35:05 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2017-08-07 14:35:05 -0400 |
commit | 61cb32aa9bc457a6b39c5055cbf7fdd718dab7c2 (patch) | |
tree | 74f1a818d7722264d8a0fe825760d01ea7a83a9a /lapic.c | |
parent | 5cbccef811ce0347370723c0b931e108c306279e (diff) | |
parent | c9fa90f7e514f27fa1ac071cd9795f3830ab6a1b (diff) | |
download | xv6-labs-61cb32aa9bc457a6b39c5055cbf7fdd718dab7c2.tar.gz xv6-labs-61cb32aa9bc457a6b39c5055cbf7fdd718dab7c2.tar.bz2 xv6-labs-61cb32aa9bc457a6b39c5055cbf7fdd718dab7c2.zip |
Merge branch 'nogs'
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. |