Skip to content
Permalink
Browse files

arch/x86: x2APIC support is not specific to jailhouse

Simple renaming and Kconfig reorganization. Choice of local APIC
access method isn't specific to the Jailhouse hypervisor.

Signed-off-by: Charles E. Youse <charles.youse@intel.com>
  • Loading branch information...
Charles E. Youse authored and nashif committed Jun 5, 2019
1 parent ba516e8 commit 0fe4e1b3a8838c23850d51e1aa7f2a383ef59a3e
@@ -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)
@@ -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
@@ -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
@@ -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
@@ -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);
@@ -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);
@@ -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);
@@ -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);
}
@@ -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,
@@ -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);
@@ -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,
@@ -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);
@@ -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)
@@ -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)

0 comments on commit 0fe4e1b

Please sign in to comment.
You can’t perform that action at this time.