lsi: use constant name instead of its value
[qemu/ar7.git] / hw / cpu / icc_bus.c
blob9a4ea7e2df590a66b040fcd7f4ac5a6fc2d987c8
1 /* icc_bus.c
2 * emulate x86 ICC (Interrupt Controller Communications) bus
4 * Copyright (c) 2013 Red Hat, Inc
6 * Authors:
7 * Igor Mammedov <imammedo@redhat.com>
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.
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.
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/>
22 #include "hw/cpu/icc_bus.h"
23 #include "hw/sysbus.h"
25 /* icc-bridge implementation */
27 static void icc_bus_init(Object *obj)
29 BusState *b = BUS(obj);
31 b->allow_hotplug = true;
34 static const TypeInfo icc_bus_info = {
35 .name = TYPE_ICC_BUS,
36 .parent = TYPE_BUS,
37 .instance_size = sizeof(ICCBus),
38 .instance_init = icc_bus_init,
42 /* icc-device implementation */
44 static void icc_device_realize(DeviceState *dev, Error **errp)
46 ICCDevice *id = ICC_DEVICE(dev);
47 ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(id);
49 if (idc->init) {
50 if (idc->init(id) < 0) {
51 error_setg(errp, "%s initialization failed.",
52 object_get_typename(OBJECT(dev)));
57 static void icc_device_class_init(ObjectClass *oc, void *data)
59 DeviceClass *dc = DEVICE_CLASS(oc);
61 dc->realize = icc_device_realize;
62 dc->bus_type = TYPE_ICC_BUS;
65 static const TypeInfo icc_device_info = {
66 .name = TYPE_ICC_DEVICE,
67 .parent = TYPE_DEVICE,
68 .abstract = true,
69 .instance_size = sizeof(ICCDevice),
70 .class_size = sizeof(ICCDeviceClass),
71 .class_init = icc_device_class_init,
75 /* icc-bridge implementation */
77 typedef struct ICCBridgeState {
78 /*< private >*/
79 SysBusDevice parent_obj;
80 /*< public >*/
82 ICCBus icc_bus;
83 MemoryRegion apic_container;
84 } ICCBridgeState;
86 #define ICC_BRIGDE(obj) OBJECT_CHECK(ICCBridgeState, (obj), TYPE_ICC_BRIDGE)
88 static void icc_bridge_init(Object *obj)
90 ICCBridgeState *s = ICC_BRIGDE(obj);
91 SysBusDevice *sb = SYS_BUS_DEVICE(obj);
93 qbus_create_inplace(&s->icc_bus, sizeof(s->icc_bus), TYPE_ICC_BUS,
94 DEVICE(s), "icc");
96 /* Do not change order of registering regions,
97 * APIC must be first registered region, board maps it by 0 index
99 memory_region_init(&s->apic_container, obj, "icc-apic-container",
100 APIC_SPACE_SIZE);
101 sysbus_init_mmio(sb, &s->apic_container);
102 s->icc_bus.apic_address_space = &s->apic_container;
105 static void icc_bridge_class_init(ObjectClass *oc, void *data)
107 DeviceClass *dc = DEVICE_CLASS(oc);
109 set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
112 static const TypeInfo icc_bridge_info = {
113 .name = TYPE_ICC_BRIDGE,
114 .parent = TYPE_SYS_BUS_DEVICE,
115 .instance_init = icc_bridge_init,
116 .instance_size = sizeof(ICCBridgeState),
117 .class_init = icc_bridge_class_init,
121 static void icc_bus_register_types(void)
123 type_register_static(&icc_bus_info);
124 type_register_static(&icc_device_info);
125 type_register_static(&icc_bridge_info);
128 type_init(icc_bus_register_types)