Revision db0f8888
b/hw/i386/kvm/ioapic.c | ||
---|---|---|
127 | 127 |
apic_report_irq_delivered(delivered); |
128 | 128 |
} |
129 | 129 |
|
130 |
static void kvm_ioapic_init(IOAPICCommonState *s, int instance_no)
|
|
130 |
static void kvm_ioapic_realize(DeviceState *dev, Error **errp)
|
|
131 | 131 |
{ |
132 |
DeviceState *dev = DEVICE(s);
|
|
132 |
IOAPICCommonState *s = IOAPIC_COMMON(dev);
|
|
133 | 133 |
|
134 | 134 |
memory_region_init_reservation(&s->io_memory, NULL, "kvm-ioapic", 0x1000); |
135 | 135 |
|
... | ... | |
146 | 146 |
IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass); |
147 | 147 |
DeviceClass *dc = DEVICE_CLASS(klass); |
148 | 148 |
|
149 |
k->init = kvm_ioapic_init;
|
|
149 |
k->realize = kvm_ioapic_realize;
|
|
150 | 150 |
k->pre_save = kvm_ioapic_get; |
151 | 151 |
k->post_load = kvm_ioapic_put; |
152 | 152 |
dc->reset = kvm_ioapic_reset; |
b/hw/intc/ioapic.c | ||
---|---|---|
36 | 36 |
|
37 | 37 |
static IOAPICCommonState *ioapics[MAX_IOAPICS]; |
38 | 38 |
|
39 |
/* global variable from ioapic_common.c */ |
|
40 |
extern int ioapic_no; |
|
41 |
|
|
39 | 42 |
static void ioapic_service(IOAPICCommonState *s) |
40 | 43 |
{ |
41 | 44 |
uint8_t i; |
... | ... | |
225 | 228 |
.endianness = DEVICE_NATIVE_ENDIAN, |
226 | 229 |
}; |
227 | 230 |
|
228 |
static void ioapic_init(IOAPICCommonState *s, int instance_no)
|
|
231 |
static void ioapic_realize(DeviceState *dev, Error **errp)
|
|
229 | 232 |
{ |
230 |
DeviceState *dev = DEVICE(s);
|
|
233 |
IOAPICCommonState *s = IOAPIC_COMMON(dev);
|
|
231 | 234 |
|
232 | 235 |
memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s, |
233 | 236 |
"ioapic", 0x1000); |
234 | 237 |
|
235 | 238 |
qdev_init_gpio_in(dev, ioapic_set_irq, IOAPIC_NUM_PINS); |
236 | 239 |
|
237 |
ioapics[instance_no] = s;
|
|
240 |
ioapics[ioapic_no] = s;
|
|
238 | 241 |
} |
239 | 242 |
|
240 | 243 |
static void ioapic_class_init(ObjectClass *klass, void *data) |
... | ... | |
242 | 245 |
IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass); |
243 | 246 |
DeviceClass *dc = DEVICE_CLASS(klass); |
244 | 247 |
|
245 |
k->init = ioapic_init;
|
|
248 |
k->realize = ioapic_realize;
|
|
246 | 249 |
dc->reset = ioapic_reset_common; |
247 | 250 |
} |
248 | 251 |
|
b/hw/intc/ioapic_common.c | ||
---|---|---|
23 | 23 |
#include "hw/i386/ioapic_internal.h" |
24 | 24 |
#include "hw/sysbus.h" |
25 | 25 |
|
26 |
/* ioapic_no count start from 0 to MAX_IOAPICS, |
|
27 |
* remove as static variable from ioapic_common_init. |
|
28 |
* now as a global variable, let child to increase the counter |
|
29 |
* then we can drop the 'instance_no' argument |
|
30 |
* and convert to our QOM's realize function |
|
31 |
*/ |
|
32 |
int ioapic_no; |
|
33 |
|
|
26 | 34 |
void ioapic_reset_common(DeviceState *dev) |
27 | 35 |
{ |
28 | 36 |
IOAPICCommonState *s = IOAPIC_COMMON(dev); |
... | ... | |
61 | 69 |
{ |
62 | 70 |
IOAPICCommonState *s = IOAPIC_COMMON(dev); |
63 | 71 |
IOAPICCommonClass *info; |
64 |
static int ioapic_no; |
|
65 | 72 |
|
66 | 73 |
if (ioapic_no >= MAX_IOAPICS) { |
67 | 74 |
error_setg(errp, "Only %d ioapics allowed", MAX_IOAPICS); |
... | ... | |
69 | 76 |
} |
70 | 77 |
|
71 | 78 |
info = IOAPIC_COMMON_GET_CLASS(s); |
72 |
info->init(s, ioapic_no);
|
|
79 |
info->realize(dev, errp);
|
|
73 | 80 |
|
74 | 81 |
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->io_memory); |
75 | 82 |
ioapic_no++; |
b/include/hw/i386/ioapic_internal.h | ||
---|---|---|
83 | 83 |
|
84 | 84 |
typedef struct IOAPICCommonClass { |
85 | 85 |
SysBusDeviceClass parent_class; |
86 |
void (*init)(IOAPICCommonState *s, int instance_no); |
|
86 |
|
|
87 |
DeviceRealize realize; |
|
87 | 88 |
void (*pre_save)(IOAPICCommonState *s); |
88 | 89 |
void (*post_load)(IOAPICCommonState *s); |
89 | 90 |
} IOAPICCommonClass; |
Also available in: Unified diff