Skip to content

Commit

Permalink
arch/x86: x2APIC support is not specific to jailhouse
Browse files Browse the repository at this point in the history
Simple renaming and Kconfig reorganization. Choice of local APIC
access method isn't specific to the Jailhouse hypervisor.

Signed-off-by: Charles E. Youse <[email protected]>
  • Loading branch information
Charles E. Youse authored and nashif committed Jun 8, 2019
1 parent ba516e8 commit 0fe4e1b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion arch/x86/include/kernel_arch_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ z_set_thread_return_value(struct k_thread *thread, unsigned int value)

extern void k_cpu_atomic_idle(unsigned int key);

#ifdef CONFIG_JAILHOUSE_X2APIC
#ifdef CONFIG_X2APIC
#define MSR_X2APIC_BASE 0x00000800

static inline u32_t read_x2apic(unsigned int reg)
Expand Down
4 changes: 0 additions & 4 deletions boards/x86/x86_jailhouse/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,4 @@ config JAILHOUSE
bool "Zephyr port to boot as a (x86) Jailhouse inmate cell payload"
default y

config JAILHOUSE_X2APIC
depends on JAILHOUSE
bool "When in Jailhouse inmate cell mode, access APIC in x2APIC mode"

endif # BOARD_X86_JAILHOUSE
2 changes: 1 addition & 1 deletion boards/x86/x86_jailhouse/x86_jailhouse_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ CONFIG_BOARD_X86_JAILHOUSE=y
CONFIG_CPU_MINUTEIA=y
CONFIG_IA32_LEGACY_IO_PORTS=y
CONFIG_JAILHOUSE=y
CONFIG_JAILHOUSE_X2APIC=y
CONFIG_X2APIC=y
CONFIG_KERNEL_ENTRY="__jh_entry"
CONFIG_IOAPIC_MASK_RTE=n
CONFIG_PIC_DISABLE=n
Expand Down
6 changes: 6 additions & 0 deletions drivers/interrupt_controller/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ config LOAPIC_BASE_ADDRESS
help
This option specifies the base address of the Local APIC device.

config X2APIC
bool "Access local APIC in x2APIC mode"
default n
help
If your local APIC supports x2APIC mode, turn this on.

config LOAPIC_SPURIOUS_VECTOR
bool "Handle LOAPIC spurious interrupts"
help
Expand Down
9 changes: 4 additions & 5 deletions drivers/interrupt_controller/loapic_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static u32_t loapic_device_power_state = DEVICE_PM_ACTIVE_STATE;

static ALWAYS_INLINE u32_t LOAPIC_READ(mem_addr_t addr)
{
#ifndef CONFIG_JAILHOUSE_X2APIC
#ifndef CONFIG_X2APIC
return sys_read32(CONFIG_LOAPIC_BASE_ADDRESS + addr);
#else
return read_x2apic(addr >> 4);
Expand All @@ -181,7 +181,7 @@ static ALWAYS_INLINE u32_t LOAPIC_READ(mem_addr_t addr)

static ALWAYS_INLINE void LOAPIC_WRITE(mem_addr_t addr, u32_t data)
{
#ifndef CONFIG_JAILHOUSE_X2APIC
#ifndef CONFIG_X2APIC
sys_write32(data, CONFIG_LOAPIC_BASE_ADDRESS + addr);
#else
write_x2apic(addr >> 4, data);
Expand Down Expand Up @@ -209,9 +209,8 @@ static int loapic_init(struct device *unused)

/* reset the DFR, TPR, TIMER_CONFIG, and TIMER_ICR */

/* Jailhouse does not allow writes to DFR in x2APIC mode */
#ifndef CONFIG_JAILHOUSE_X2APIC
LOAPIC_WRITE(LOAPIC_DFR, 0xffffffff);
#ifndef CONFIG_X2APIC
LOAPIC_WRITE(LOAPIC_DFR, 0xffffffff); /* no DFR in x2APIC mode */
#endif

LOAPIC_WRITE(LOAPIC_TPR, 0x0);
Expand Down
12 changes: 6 additions & 6 deletions drivers/timer/loapic_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ static u32_t reg_timer_cfg_save;
#endif
#endif

#ifdef CONFIG_JAILHOUSE_X2APIC
void z_jailhouse_eoi(void)
#ifdef CONFIG_X2APIC
void z_x2apic_eoi(void)
{
write_x2apic(LOAPIC_EOI >> 4, 0);
}
Expand All @@ -167,7 +167,7 @@ void z_jailhouse_eoi(void)
*/
static inline void periodic_mode_set(void)
{
#ifndef CONFIG_JAILHOUSE_X2APIC
#ifndef CONFIG_X2APIC
*_REG_TIMER |= LOAPIC_TIMER_PERIODIC;
#else
write_x2apic(LOAPIC_TIMER >> 4,
Expand All @@ -188,7 +188,7 @@ static inline void periodic_mode_set(void)
*/
static inline void initial_count_register_set(u32_t count)
{
#ifndef CONFIG_JAILHOUSE_X2APIC
#ifndef CONFIG_X2APIC
*_REG_TIMER_ICR = count;
#else
write_x2apic(LOAPIC_TIMER_ICR >> 4, count);
Expand Down Expand Up @@ -223,7 +223,7 @@ static inline void one_shot_mode_set(void)
#ifndef CONFIG_MVIC
static inline void divide_configuration_register_set(void)
{
#ifndef CONFIG_JAILHOUSE_X2APIC
#ifndef CONFIG_X2APIC
*_REG_TIMER_CFG = (*_REG_TIMER_CFG & ~0xf) | LOAPIC_TIMER_DIVBY_1;
#else
write_x2apic(LOAPIC_TIMER_CONFIG >> 4,
Expand All @@ -246,7 +246,7 @@ static inline void divide_configuration_register_set(void)
*/
static inline u32_t current_count_register_get(void)
{
#ifndef CONFIG_JAILHOUSE_X2APIC
#ifndef CONFIG_X2APIC
return *_REG_TIMER_CCR;
#else
return read_x2apic(LOAPIC_TIMER_CCR >> 4);
Expand Down
8 changes: 4 additions & 4 deletions include/drivers/sysapic.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ void __irq_controller_irq_config(unsigned int vector, unsigned int irq,

int __irq_controller_isr_vector_get(void);

#ifdef CONFIG_JAILHOUSE_X2APIC
void z_jailhouse_eoi(void);
#ifdef CONFIG_X2APIC
void z_x2apic_eoi(void);
#endif

static inline void __irq_controller_eoi(void)
Expand All @@ -48,8 +48,8 @@ static inline void __irq_controller_eoi(void)
.endm
#else
.macro __irq_controller_eoi_macro
#ifdef CONFIG_JAILHOUSE_X2APIC
call z_jailhouse_eoi
#ifdef CONFIG_X2APIC
call z_x2apic_eoi
#else
xorl %eax, %eax /* zeroes eax */
loapic_eoi_reg = (CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_EOI)
Expand Down

0 comments on commit 0fe4e1b

Please sign in to comment.