]>
Commit | Line | Data |
---|---|---|
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 <[email protected]> | |
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 | ||
27 | static void icc_bus_init(Object *obj) | |
28 | { | |
29 | BusState *b = BUS(obj); | |
30 | ||
31 | b->allow_hotplug = true; | |
32 | } | |
33 | ||
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, | |
39 | }; | |
40 | ||
41 | ||
42 | /* icc-device implementation */ | |
43 | ||
44 | static void icc_device_realize(DeviceState *dev, Error **errp) | |
45 | { | |
46 | ICCDevice *id = ICC_DEVICE(dev); | |
47 | ICCDeviceClass *idc = ICC_DEVICE_GET_CLASS(id); | |
48 | ||
49 | if (idc->init) { | |
50 | if (idc->init(id) < 0) { | |
51 | error_setg(errp, "%s initialization failed.", | |
52 | object_get_typename(OBJECT(dev))); | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
57 | static void icc_device_class_init(ObjectClass *oc, void *data) | |
58 | { | |
59 | DeviceClass *dc = DEVICE_CLASS(oc); | |
60 | ||
61 | dc->realize = icc_device_realize; | |
62 | dc->bus_type = TYPE_ICC_BUS; | |
63 | } | |
64 | ||
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, | |
72 | }; | |
73 | ||
74 | ||
75 | /* icc-bridge implementation */ | |
76 | ||
77 | typedef struct ICCBridgeState { | |
78 | /*< private >*/ | |
79 | SysBusDevice parent_obj; | |
80 | /*< public >*/ | |
81 | ||
82 | ICCBus icc_bus; | |
53a89e26 | 83 | MemoryRegion apic_container; |
f0513d2c IM |
84 | } ICCBridgeState; |
85 | ||
86 | #define ICC_BRIGDE(obj) OBJECT_CHECK(ICCBridgeState, (obj), TYPE_ICC_BRIDGE) | |
87 | ||
88 | static void icc_bridge_init(Object *obj) | |
89 | { | |
90 | ICCBridgeState *s = ICC_BRIGDE(obj); | |
53a89e26 | 91 | SysBusDevice *sb = SYS_BUS_DEVICE(obj); |
f0513d2c IM |
92 | |
93 | qbus_create_inplace(&s->icc_bus, TYPE_ICC_BUS, DEVICE(s), "icc"); | |
53a89e26 IM |
94 | |
95 | /* Do not change order of registering regions, | |
96 | * APIC must be first registered region, board maps it by 0 index | |
97 | */ | |
98 | memory_region_init(&s->apic_container, "icc-apic-container", | |
99 | APIC_SPACE_SIZE); | |
100 | sysbus_init_mmio(sb, &s->apic_container); | |
101 | s->icc_bus.apic_address_space = &s->apic_container; | |
f0513d2c IM |
102 | } |
103 | ||
104 | static const TypeInfo icc_bridge_info = { | |
105 | .name = TYPE_ICC_BRIDGE, | |
106 | .parent = TYPE_SYS_BUS_DEVICE, | |
107 | .instance_init = icc_bridge_init, | |
108 | .instance_size = sizeof(ICCBridgeState), | |
109 | }; | |
110 | ||
111 | ||
112 | static void icc_bus_register_types(void) | |
113 | { | |
114 | type_register_static(&icc_bus_info); | |
115 | type_register_static(&icc_device_info); | |
116 | type_register_static(&icc_bridge_info); | |
117 | } | |
118 | ||
119 | type_init(icc_bus_register_types) |