hw/riscv: Move sifive_plic model to hw/intc
[qemu/ar7.git] / hw / i386 / xen / xen_apic.c
blob7c7a60b166e59bea23dce5f4eb3a2703132094a8
1 /*
2 * Xen basic APIC support
4 * Copyright (c) 2012 Citrix
6 * Authors:
7 * Wei Liu <wei.liu2@citrix.com>
9 * This work is licensed under the terms of the GNU GPL version 2 or
10 * later. See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "hw/i386/apic_internal.h"
15 #include "hw/pci/msi.h"
16 #include "hw/xen/xen.h"
17 #include "qemu/module.h"
19 static uint64_t xen_apic_mem_read(void *opaque, hwaddr addr,
20 unsigned size)
22 return ~(uint64_t)0;
25 static void xen_apic_mem_write(void *opaque, hwaddr addr,
26 uint64_t data, unsigned size)
28 if (size != sizeof(uint32_t)) {
29 fprintf(stderr, "Xen: APIC write data size = %d, invalid\n", size);
30 return;
33 xen_hvm_inject_msi(addr, data);
36 static const MemoryRegionOps xen_apic_io_ops = {
37 .read = xen_apic_mem_read,
38 .write = xen_apic_mem_write,
39 .endianness = DEVICE_NATIVE_ENDIAN,
42 static void xen_apic_realize(DeviceState *dev, Error **errp)
44 APICCommonState *s = APIC_COMMON(dev);
46 s->vapic_control = 0;
47 memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, s,
48 "xen-apic-msi", APIC_SPACE_SIZE);
49 msi_nonbroken = true;
52 static void xen_apic_set_base(APICCommonState *s, uint64_t val)
56 static void xen_apic_set_tpr(APICCommonState *s, uint8_t val)
60 static uint8_t xen_apic_get_tpr(APICCommonState *s)
62 return 0;
65 static void xen_apic_vapic_base_update(APICCommonState *s)
69 static void xen_apic_external_nmi(APICCommonState *s)
73 static void xen_send_msi(MSIMessage *msi)
75 xen_hvm_inject_msi(msi->address, msi->data);
78 static void xen_apic_class_init(ObjectClass *klass, void *data)
80 APICCommonClass *k = APIC_COMMON_CLASS(klass);
82 k->realize = xen_apic_realize;
83 k->set_base = xen_apic_set_base;
84 k->set_tpr = xen_apic_set_tpr;
85 k->get_tpr = xen_apic_get_tpr;
86 k->vapic_base_update = xen_apic_vapic_base_update;
87 k->external_nmi = xen_apic_external_nmi;
88 k->send_msi = xen_send_msi;
91 static const TypeInfo xen_apic_info = {
92 .name = "xen-apic",
93 .parent = TYPE_APIC_COMMON,
94 .instance_size = sizeof(APICCommonState),
95 .class_init = xen_apic_class_init,
98 static void xen_apic_register_types(void)
100 type_register_static(&xen_apic_info);
103 type_init(xen_apic_register_types)