]>
Commit | Line | Data |
---|---|---|
9468e9c4 WL |
1 | /* |
2 | * Xen basic APIC support | |
3 | * | |
4 | * Copyright (c) 2012 Citrix | |
5 | * | |
6 | * Authors: | |
7 | * Wei Liu <[email protected]> | |
8 | * | |
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. | |
11 | */ | |
0d09e41a | 12 | #include "hw/i386/apic_internal.h" |
a2cb15b0 | 13 | #include "hw/pci/msi.h" |
0d09e41a | 14 | #include "hw/xen/xen.h" |
9468e9c4 | 15 | |
a8170e5e | 16 | static uint64_t xen_apic_mem_read(void *opaque, hwaddr addr, |
9468e9c4 WL |
17 | unsigned size) |
18 | { | |
19 | return ~(uint64_t)0; | |
20 | } | |
21 | ||
a8170e5e | 22 | static void xen_apic_mem_write(void *opaque, hwaddr addr, |
9468e9c4 WL |
23 | uint64_t data, unsigned size) |
24 | { | |
25 | if (size != sizeof(uint32_t)) { | |
26 | fprintf(stderr, "Xen: APIC write data size = %d, invalid\n", size); | |
27 | return; | |
28 | } | |
29 | ||
30 | xen_hvm_inject_msi(addr, data); | |
31 | } | |
32 | ||
33 | static const MemoryRegionOps xen_apic_io_ops = { | |
34 | .read = xen_apic_mem_read, | |
35 | .write = xen_apic_mem_write, | |
36 | .endianness = DEVICE_NATIVE_ENDIAN, | |
37 | }; | |
38 | ||
ff6986ce | 39 | static void xen_apic_realize(DeviceState *dev, Error **errp) |
9468e9c4 | 40 | { |
ff6986ce XZ |
41 | APICCommonState *s = APIC_COMMON(dev); |
42 | ||
b33a5bbf | 43 | s->vapic_control = 0; |
22fc860b PB |
44 | memory_region_init_io(&s->io_memory, OBJECT(s), &xen_apic_io_ops, s, |
45 | "xen-apic-msi", APIC_SPACE_SIZE); | |
08a82ac0 JK |
46 | |
47 | #if defined(CONFIG_XEN_CTRL_INTERFACE_VERSION) \ | |
48 | && CONFIG_XEN_CTRL_INTERFACE_VERSION >= 420 | |
49 | msi_supported = true; | |
50 | #endif | |
9468e9c4 WL |
51 | } |
52 | ||
53 | static void xen_apic_set_base(APICCommonState *s, uint64_t val) | |
54 | { | |
55 | } | |
56 | ||
57 | static void xen_apic_set_tpr(APICCommonState *s, uint8_t val) | |
58 | { | |
59 | } | |
60 | ||
61 | static uint8_t xen_apic_get_tpr(APICCommonState *s) | |
62 | { | |
63 | return 0; | |
64 | } | |
65 | ||
66 | static void xen_apic_vapic_base_update(APICCommonState *s) | |
67 | { | |
68 | } | |
69 | ||
70 | static void xen_apic_external_nmi(APICCommonState *s) | |
71 | { | |
72 | } | |
73 | ||
74 | static void xen_apic_class_init(ObjectClass *klass, void *data) | |
75 | { | |
76 | APICCommonClass *k = APIC_COMMON_CLASS(klass); | |
77 | ||
ff6986ce | 78 | k->realize = xen_apic_realize; |
9468e9c4 WL |
79 | k->set_base = xen_apic_set_base; |
80 | k->set_tpr = xen_apic_set_tpr; | |
81 | k->get_tpr = xen_apic_get_tpr; | |
82 | k->vapic_base_update = xen_apic_vapic_base_update; | |
83 | k->external_nmi = xen_apic_external_nmi; | |
84 | } | |
85 | ||
8c43a6f0 | 86 | static const TypeInfo xen_apic_info = { |
9468e9c4 WL |
87 | .name = "xen-apic", |
88 | .parent = TYPE_APIC_COMMON, | |
89 | .instance_size = sizeof(APICCommonState), | |
90 | .class_init = xen_apic_class_init, | |
91 | }; | |
92 | ||
93 | static void xen_apic_register_types(void) | |
94 | { | |
95 | type_register_static(&xen_apic_info); | |
96 | } | |
97 | ||
98 | type_init(xen_apic_register_types) |