sync with tizen_2.2
[sdk/emulator/qemu.git] / hw / xen_apic.c
1 /*
2  * Xen basic APIC support
3  *
4  * Copyright (c) 2012 Citrix
5  *
6  * Authors:
7  *  Wei Liu <wei.liu2@citrix.com>
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  */
12 #include "hw/apic_internal.h"
13 #include "hw/msi.h"
14 #include "xen.h"
15
16 static uint64_t xen_apic_mem_read(void *opaque, target_phys_addr_t addr,
17                                   unsigned size)
18 {
19     return ~(uint64_t)0;
20 }
21
22 static void xen_apic_mem_write(void *opaque, target_phys_addr_t addr,
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
39 static void xen_apic_init(APICCommonState *s)
40 {
41     memory_region_init_io(&s->io_memory, &xen_apic_io_ops, s, "xen-apic-msi",
42                           MSI_SPACE_SIZE);
43
44 #if defined(CONFIG_XEN_CTRL_INTERFACE_VERSION) \
45     && CONFIG_XEN_CTRL_INTERFACE_VERSION >= 420
46     msi_supported = true;
47 #endif
48 }
49
50 static void xen_apic_set_base(APICCommonState *s, uint64_t val)
51 {
52 }
53
54 static void xen_apic_set_tpr(APICCommonState *s, uint8_t val)
55 {
56 }
57
58 static uint8_t xen_apic_get_tpr(APICCommonState *s)
59 {
60     return 0;
61 }
62
63 static void xen_apic_vapic_base_update(APICCommonState *s)
64 {
65 }
66
67 static void xen_apic_external_nmi(APICCommonState *s)
68 {
69 }
70
71 static void xen_apic_class_init(ObjectClass *klass, void *data)
72 {
73     APICCommonClass *k = APIC_COMMON_CLASS(klass);
74
75     k->init = xen_apic_init;
76     k->set_base = xen_apic_set_base;
77     k->set_tpr = xen_apic_set_tpr;
78     k->get_tpr = xen_apic_get_tpr;
79     k->vapic_base_update = xen_apic_vapic_base_update;
80     k->external_nmi = xen_apic_external_nmi;
81 }
82
83 static TypeInfo xen_apic_info = {
84     .name = "xen-apic",
85     .parent = TYPE_APIC_COMMON,
86     .instance_size = sizeof(APICCommonState),
87     .class_init = xen_apic_class_init,
88 };
89
90 static void xen_apic_register_types(void)
91 {
92     type_register_static(&xen_apic_info);
93 }
94
95 type_init(xen_apic_register_types)