--- /dev/null
+/**
+ * @file arch/x86/include/arch/io-apic.h
+ *
+ * %x86 IO-APIC register definitions and utility functions.
+ *
+ * The IO-APIC MMIO window is expected to be in its default location for the
+ * benefit of unpaged environments.
+ */
+
+#ifndef XTF_X86_IO_APIC_H
+#define XTF_X86_IO_APIC_H
+
+#include <xtf/numbers.h>
+#include <xtf/types.h>
+
+/* MMIO window registers. */
+#define IOAPIC_REGSEL 0x00
+#define IOAPIC_IOWIN 0x10
+
+/* IO-APIC registers. */
+#define IOAPIC_ID 0x0
+
+
+#define IOAPIC_DEFAULT_BASE 0xfec00000
+
+/**
+ * Discover and initialise the IO-APIC. May fail if there is no IO-APIC.
+ */
+int ioapic_init(void);
+
+static inline uint32_t ioapic_read32(unsigned int reg)
+{
+ *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_REGSEL) = reg;
+
+ return *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_IOWIN);
+}
+
+static inline uint64_t ioapic_read64(unsigned int reg)
+{
+ *(volatile uint64_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_REGSEL) = reg;
+
+ return *(volatile uint64_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_IOWIN);
+}
+
+static inline void ioapic_write32(unsigned int reg, uint32_t val)
+{
+ *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_REGSEL) = reg;
+ *(volatile uint32_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_IOWIN) = val;
+}
+
+static inline void ioapic_write64(unsigned int reg, uint64_t val)
+{
+ *(volatile uint64_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_REGSEL) = reg;
+ *(volatile uint64_t *)_p(IOAPIC_DEFAULT_BASE + IOAPIC_IOWIN) = val;
+}
+
+#endif /* !XTF_X86_IO_APIC_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--- /dev/null
+/**
+ * @file arch/x86/io-apic.c
+ *
+ * Basic x86 IO-APIC driver.
+ */
+
+#include <xtf/lib.h>
+
+#include <xen/errno.h>
+
+#include <arch/io-apic.h>
+
+int ioapic_init(void)
+{
+ uint32_t id = ioapic_read32(IOAPIC_ID);
+
+ /* Bare MMIO? */
+ if ( id == ~0u )
+ return -ENODEV;
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
obj-hvm += $(ROOT)/arch/x86/hpet.o
obj-hvm += $(ROOT)/arch/x86/hvm/pagetables.o
obj-hvm += $(ROOT)/arch/x86/hvm/traps.o
+obj-hvm += $(ROOT)/arch/x86/io-apic.o
# Arguably common objects, but PV guests will have no interest in them.
obj-hvm += $(ROOT)/arch/x86/vmx.o