From ee525c2597c78c98a3988d403d4859e4cfd78ed5 Mon Sep 17 00:00:00 2001 From: "Charles E. Youse" Date: Wed, 11 Sep 2019 14:20:49 -0400 Subject: [PATCH] arch/x86: inline x2APIC EOI From the Jailhouse days, this has been a function call. That's silly. We now inline the EOI in the ISR when in x2APIC mode. Also clean up z_irq_controller_eoi(), so it now uses the inline macros. Also, we now enable x2APIC on up_squared by default. Fixes: #17133 Signed-off-by: Charles E. Youse --- arch/x86/core/ia32/intstub.S | 8 +++++--- boards/x86/up_squared/up_squared_defconfig | 1 + include/drivers/interrupt_controller/loapic.h | 12 ++++++------ include/drivers/interrupt_controller/sysapic.h | 10 +--------- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/arch/x86/core/ia32/intstub.S b/arch/x86/core/ia32/intstub.S index 3882f537857..a904f934874 100644 --- a/arch/x86/core/ia32/intstub.S +++ b/arch/x86/core/ia32/intstub.S @@ -204,10 +204,12 @@ alreadyOnIntStack: cli /* disable interrupts again */ #endif -#if defined(CONFIG_X2APIC) - call z_x2apic_eoi -#else /* xAPIC EOI */ xorl %eax, %eax +#if defined(CONFIG_X2APIC) + xorl %edx, %edx + movl $(X86_X2APIC_BASE_MSR + (LOAPIC_EOI >> 4)), %ecx + wrmsr +#else /* xAPIC */ movl %eax, (CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_EOI) #endif diff --git a/boards/x86/up_squared/up_squared_defconfig b/boards/x86/up_squared/up_squared_defconfig index 3ee096aabf3..c88952e25f7 100644 --- a/boards/x86/up_squared/up_squared_defconfig +++ b/boards/x86/up_squared/up_squared_defconfig @@ -11,3 +11,4 @@ CONFIG_SERIAL=y CONFIG_UART_NS16550=y CONFIG_UART_CONSOLE=y CONFIG_I2C=y +CONFIG_X2APIC=y diff --git a/include/drivers/interrupt_controller/loapic.h b/include/drivers/interrupt_controller/loapic.h index 255276fa738..4a0c1b35877 100644 --- a/include/drivers/interrupt_controller/loapic.h +++ b/include/drivers/interrupt_controller/loapic.h @@ -12,10 +12,6 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif - /* Local APIC Register Offset */ #define LOAPIC_ID 0x020 /* Local APIC ID Reg */ @@ -49,6 +45,10 @@ extern "C" { #ifndef _ASMLANGUAGE +#ifdef __cplusplus +extern "C" { +#endif + extern void z_loapic_int_vec_set(unsigned int irq, unsigned int vector); extern void z_loapic_irq_enable(unsigned int irq); extern void z_loapic_irq_disable(unsigned int irq); @@ -136,10 +136,10 @@ static inline void x86_write_loapic(unsigned int reg, u32_t val) #endif } -#endif /* _ASMLANGUAGE */ - #ifdef __cplusplus } #endif +#endif /* _ASMLANGUAGE */ + #endif /* ZEPHYR_INCLUDE_DRIVERS_LOAPIC_H_ */ diff --git a/include/drivers/interrupt_controller/sysapic.h b/include/drivers/interrupt_controller/sysapic.h index f01babe2555..355815274ba 100644 --- a/include/drivers/interrupt_controller/sysapic.h +++ b/include/drivers/interrupt_controller/sysapic.h @@ -26,17 +26,9 @@ void z_irq_controller_irq_config(unsigned int vector, unsigned int irq, int z_irq_controller_isr_vector_get(void); -#ifdef CONFIG_X2APIC -void z_x2apic_eoi(void); -#endif - static inline void z_irq_controller_eoi(void) { -#if defined(CONFIG_X2APIC) - z_x2apic_eoi(); -#else /* xAPIC */ - *(volatile int *)(CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_EOI) = 0; -#endif + x86_write_loapic(LOAPIC_EOI, 0); } #endif /* _ASMLANGUAGE */