2 * Xen basic APIC support
4 * Copyright (c) 2012 Citrix
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.
12 #include "hw/apic_internal.h"
16 static uint64_t xen_apic_mem_read(void *opaque
, target_phys_addr_t addr
,
22 static void xen_apic_mem_write(void *opaque
, target_phys_addr_t addr
,
23 uint64_t data
, unsigned size
)
25 if (size
!= sizeof(uint32_t)) {
26 fprintf(stderr
, "Xen: APIC write data size = %d, invalid\n", size
);
30 xen_hvm_inject_msi(addr
, data
);
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
,
39 static void xen_apic_init(APICCommonState
*s
)
41 memory_region_init_io(&s
->io_memory
, &xen_apic_io_ops
, s
, "xen-apic-msi",
45 static void xen_apic_set_base(APICCommonState
*s
, uint64_t val
)
49 static void xen_apic_set_tpr(APICCommonState
*s
, uint8_t val
)
53 static uint8_t xen_apic_get_tpr(APICCommonState
*s
)
58 static void xen_apic_vapic_base_update(APICCommonState
*s
)
62 static void xen_apic_external_nmi(APICCommonState
*s
)
66 static void xen_apic_class_init(ObjectClass
*klass
, void *data
)
68 APICCommonClass
*k
= APIC_COMMON_CLASS(klass
);
70 k
->init
= xen_apic_init
;
71 k
->set_base
= xen_apic_set_base
;
72 k
->set_tpr
= xen_apic_set_tpr
;
73 k
->get_tpr
= xen_apic_get_tpr
;
74 k
->vapic_base_update
= xen_apic_vapic_base_update
;
75 k
->external_nmi
= xen_apic_external_nmi
;
78 static TypeInfo xen_apic_info
= {
80 .parent
= TYPE_APIC_COMMON
,
81 .instance_size
= sizeof(APICCommonState
),
82 .class_init
= xen_apic_class_init
,
85 static void xen_apic_register_types(void)
87 type_register_static(&xen_apic_info
);
90 type_init(xen_apic_register_types
)