From ff284f656606548f122c59a9ffb6ab453ca89149 Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Fri, 18 Aug 2017 12:11:16 +0300 Subject: arch/x86: Fix ugly NEED_LAPIC use MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2d6fdfd0465fe5f558daa04c6f980f7226596b55 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/21087 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/include/cpu/x86/lapic.h | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/include/cpu/x86/lapic.h') diff --git a/src/include/cpu/x86/lapic.h b/src/include/cpu/x86/lapic.h index e781b5a5bb..6121230a22 100644 --- a/src/include/cpu/x86/lapic.h +++ b/src/include/cpu/x86/lapic.h @@ -6,13 +6,6 @@ #include #include -/* See if I need to initialize the local APIC */ -#if IS_ENABLED(CONFIG_SMP) || IS_ENABLED(CONFIG_IOAPIC) -# define NEED_LAPIC 1 -#else -# define NEED_LAPIC 0 -#endif - static inline __attribute__((always_inline)) unsigned long lapic_read( unsigned long reg) { @@ -32,12 +25,12 @@ static inline __attribute__((always_inline)) void lapic_wait_icr_idle(void) static inline void enable_lapic(void) { - msr_t msr; msr = rdmsr(LAPIC_BASE_MSR); msr.hi &= 0xffffff00; - msr.lo &= 0x000007ff; - msr.lo |= LAPIC_DEFAULT_BASE | (1 << 11); + msr.lo &= ~LAPIC_BASE_MSR_ADDR_MASK; + msr.lo |= LAPIC_DEFAULT_BASE; + msr.lo |= LAPIC_BASE_MSR_ENABLE; wrmsr(LAPIC_BASE_MSR, msr); } @@ -45,7 +38,7 @@ static inline void disable_lapic(void) { msr_t msr; msr = rdmsr(LAPIC_BASE_MSR); - msr.lo &= ~(1 << 11); + msr.lo &= ~LAPIC_BASE_MSR_ENABLE; wrmsr(LAPIC_BASE_MSR, msr); } @@ -146,13 +139,24 @@ static inline int lapic_remote_read(int apicid, int reg, unsigned long *pvalue) return result; } +void do_lapic_init(void); -void setup_lapic(void); +/* See if I need to initialize the local APIC */ +static inline int need_lapic_init(void) +{ + return IS_ENABLED(CONFIG_SMP) || IS_ENABLED(CONFIG_IOAPIC); +} + +static inline void setup_lapic(void) +{ + if (need_lapic_init()) + do_lapic_init(); + else + disable_lapic(); +} -#if IS_ENABLED(CONFIG_SMP) struct device; int start_cpu(struct device *cpu); -#endif /* CONFIG_SMP */ #endif /* !__PRE_RAM__ */ -- cgit v1.2.3