2012-04-12 12:02:47 +02:00
|
|
|
/*
|
|
|
|
* Xen basic APIC support
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012 Citrix
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Wei Liu <wei.liu2@citrix.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL version 2 or
|
|
|
|
* later. See the COPYING file in the top-level directory.
|
|
|
|
*/
|
2019-05-23 16:35:07 +02:00
|
|
|
|
2016-01-26 19:17:03 +01:00
|
|
|
#include "qemu/osdep.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/i386/apic_internal.h"
|
2012-12-12 13:24:50 +01:00
|
|
|
#include "hw/pci/msi.h"
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/xen/xen.h"
|
2019-05-23 16:35:07 +02:00
|
|
|
#include "qemu/module.h"
|
2012-04-12 12:02:47 +02:00
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t xen_apic_mem_read(void *opaque, hwaddr addr,
|
2012-04-12 12:02:47 +02:00
|
|
|
unsigned size)
|
|
|
|
{
|
|
|
|
return ~(uint64_t)0;
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void xen_apic_mem_write(void *opaque, hwaddr addr,
|
2012-04-12 12:02:47 +02:00
|
|
|
uint64_t data, unsigned size)
|
|
|
|
{
|
|
|
|
if (size != sizeof(uint32_t)) {
|
|
|
|
fprintf(stderr, "Xen: APIC write data size = %d, invalid\n", size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
xen_hvm_inject_msi(addr, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const MemoryRegionOps xen_apic_io_ops = {
|
|
|
|
.read = xen_apic_mem_read,
|
|
|
|
.write = xen_apic_mem_write,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
};
|
|
|
|
|
2013-11-05 11:16:03 +01:00
|
|
|
static void xen_apic_realize(DeviceState *dev, Error **errp)
|
2012-04-12 12:02:47 +02:00
|
|
|
{
|
2013-11-05 11:16:03 +01:00
|
|
|
APICCommonState *s = APIC_COMMON(dev);
|
|
|
|
|
2014-07-07 08:34:35 +02:00
|
|
|
s->vapic_control = 0;
|
2013-06-07 03:25:08 +02:00
|
|
|
memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, s,
|
|
|
|
"xen-apic-msi", APIC_SPACE_SIZE);
|
2016-03-04 10:24:28 +01:00
|
|
|
msi_nonbroken = true;
|
2012-04-12 12:02:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void xen_apic_set_base(APICCommonState *s, uint64_t val)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xen_apic_set_tpr(APICCommonState *s, uint8_t val)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t xen_apic_get_tpr(APICCommonState *s)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xen_apic_vapic_base_update(APICCommonState *s)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void xen_apic_external_nmi(APICCommonState *s)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-10 17:28:43 +02:00
|
|
|
static void xen_send_msi(MSIMessage *msi)
|
|
|
|
{
|
|
|
|
xen_hvm_inject_msi(msi->address, msi->data);
|
|
|
|
}
|
|
|
|
|
2012-04-12 12:02:47 +02:00
|
|
|
static void xen_apic_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
APICCommonClass *k = APIC_COMMON_CLASS(klass);
|
|
|
|
|
2013-11-05 11:16:03 +01:00
|
|
|
k->realize = xen_apic_realize;
|
2012-04-12 12:02:47 +02:00
|
|
|
k->set_base = xen_apic_set_base;
|
|
|
|
k->set_tpr = xen_apic_set_tpr;
|
|
|
|
k->get_tpr = xen_apic_get_tpr;
|
|
|
|
k->vapic_base_update = xen_apic_vapic_base_update;
|
|
|
|
k->external_nmi = xen_apic_external_nmi;
|
2016-10-10 17:28:43 +02:00
|
|
|
k->send_msi = xen_send_msi;
|
2012-04-12 12:02:47 +02:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo xen_apic_info = {
|
2012-04-12 12:02:47 +02:00
|
|
|
.name = "xen-apic",
|
|
|
|
.parent = TYPE_APIC_COMMON,
|
|
|
|
.instance_size = sizeof(APICCommonState),
|
|
|
|
.class_init = xen_apic_class_init,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void xen_apic_register_types(void)
|
|
|
|
{
|
|
|
|
type_register_static(&xen_apic_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
type_init(xen_apic_register_types)
|