Merge remote-tracking branch 'remotes/sstabellini/tags/xen-2015-09-10-tag' into staging
[qemu.git] / hw / cpu / icc_bus.c
CommitLineData
f0513d2c
IM
1/* icc_bus.c
2 * emulate x86 ICC (Interrupt Controller Communications) bus
3 *
4 * Copyright (c) 2013 Red Hat, Inc
5 *
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, see <http://www.gnu.org/licenses/>
21 */
22#include "hw/cpu/icc_bus.h"
23#include "hw/sysbus.h"
24
25/* icc-bridge implementation */
26
f0513d2c
IM
27static const TypeInfo icc_bus_info = {
28 .name = TYPE_ICC_BUS,
29 .parent = TYPE_BUS,
30 .instance_size = sizeof(ICCBus),
f0513d2c
IM
31};
32
33
34/* icc-device implementation */
35
36static void icc_device_realize(DeviceState *dev, Error **errp)
37{
494c2717
XZ
38 ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(dev);
39
40 /* convert to QOM */
41 if (idc->realize) {
42 idc->realize(dev, errp);
f0513d2c 43 }
494c2717 44
f0513d2c
IM
45}
46
47static void icc_device_class_init(ObjectClass *oc, void *data)
48{
49 DeviceClass *dc = DEVICE_CLASS(oc);
50
51 dc->realize = icc_device_realize;
52 dc->bus_type = TYPE_ICC_BUS;
53}
54
55static const TypeInfo icc_device_info = {
56 .name = TYPE_ICC_DEVICE,
57 .parent = TYPE_DEVICE,
58 .abstract = true,
59 .instance_size = sizeof(ICCDevice),
60 .class_size = sizeof(ICCDeviceClass),
61 .class_init = icc_device_class_init,
62};
63
64
65/* icc-bridge implementation */
66
67typedef struct ICCBridgeState {
68 /*< private >*/
69 SysBusDevice parent_obj;
70 /*< public >*/
71
72 ICCBus icc_bus;
53a89e26 73 MemoryRegion apic_container;
f0513d2c
IM
74} ICCBridgeState;
75
3a0614c6 76#define ICC_BRIDGE(obj) OBJECT_CHECK(ICCBridgeState, (obj), TYPE_ICC_BRIDGE)
f0513d2c
IM
77
78static void icc_bridge_init(Object *obj)
79{
3a0614c6 80 ICCBridgeState *s = ICC_BRIDGE(obj);
53a89e26 81 SysBusDevice *sb = SYS_BUS_DEVICE(obj);
f0513d2c 82
fb17dfe0
AF
83 qbus_create_inplace(&s->icc_bus, sizeof(s->icc_bus), TYPE_ICC_BUS,
84 DEVICE(s), "icc");
53a89e26
IM
85
86 /* Do not change order of registering regions,
87 * APIC must be first registered region, board maps it by 0 index
88 */
300b1fc6 89 memory_region_init(&s->apic_container, obj, "icc-apic-container",
53a89e26
IM
90 APIC_SPACE_SIZE);
91 sysbus_init_mmio(sb, &s->apic_container);
92 s->icc_bus.apic_address_space = &s->apic_container;
f0513d2c
IM
93}
94
125ee0ed
MA
95static void icc_bridge_class_init(ObjectClass *oc, void *data)
96{
97 DeviceClass *dc = DEVICE_CLASS(oc);
98
99 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
100}
101
f0513d2c
IM
102static const TypeInfo icc_bridge_info = {
103 .name = TYPE_ICC_BRIDGE,
104 .parent = TYPE_SYS_BUS_DEVICE,
105 .instance_init = icc_bridge_init,
106 .instance_size = sizeof(ICCBridgeState),
125ee0ed 107 .class_init = icc_bridge_class_init,
f0513d2c
IM
108};
109
110
111static void icc_bus_register_types(void)
112{
113 type_register_static(&icc_bus_info);
114 type_register_static(&icc_device_info);
115 type_register_static(&icc_bridge_info);
116}
117
118type_init(icc_bus_register_types)
This page took 0.149483 seconds and 4 git commands to generate.