mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 17:53:56 -06:00
QOM infrastructure fixes and device conversions
* QOM interface fixes and unit test * Device no_user sanitization and documentation * Device error reporting improvement * Conversion of APIC, ICC, IOAPIC to QOM realization model -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJSub6FAAoJEPou0S0+fgE/JGcP/RvIMVyldoUN1buS+ynXkNGS UXCwnGGwE6dw7V8eTHxgm7vj1SznaIFZd1jxhbU/PSRn7SkLjHhM4Ei5Nu06nsJD Dwe22muiGxPIucnwhhuyPni9gP386yR7/4cwqMqvEuB696ZO7tdcMQ4PxwMWW6GN 8XsgF/3nlNFYTTxkG5KhmqqYEQdoQc5aloR7BZiziNaSIXLgIKAFp/T3vl+cwOyV j2N4Wq+egPNA821Y+sb9V8ZDkwQamE4qsSdIvWSaR24vFEQ8D+U6Sll2qkfcKo4H dmVu27OYFGJ4hJfyNoJ+7RKF1ET+IcmPW6Hcdri0CZNg5f3rHWur3mvasEMB3I3S sSQNfItp2bSj0LlTnOcbjE7kP3DTrunAoQ9TJaHo9N94sjXwr8EnCIwHqOZODZbr j07uKaRyQp4BCSQwP5QP4XEirLvzJOYCxCmT9pXELW/DMjgzjl1XgZVtEowvzHx4 JNoF9mVGjVLDdwb9Tm+nR+9dQsNiGyF7HUYfIf1EwKshp6kwqOmO+YkNKq05kfRN 0GhQB5exB6xN4zUqZTQ544WxB+hls6bOXpOlbKAEWQWpJ2Gj2hlBYTPCuFMwWrfl rH0jhC9zzlNqRyTUN+KZjU3GTa0T6neOSIXtDiS/VXWKDEV35zohYgwdpAfvpse2 61a4MkgXwy7eqUeZ0Jqu =WrhM -----END PGP SIGNATURE----- Merge remote-tracking branch 'afaerber/tags/qom-devices-for-anthony' into staging QOM infrastructure fixes and device conversions * QOM interface fixes and unit test * Device no_user sanitization and documentation * Device error reporting improvement * Conversion of APIC, ICC, IOAPIC to QOM realization model # gpg: Signature made Tue 24 Dec 2013 09:04:05 AM PST using RSA key ID 3E7E013F # gpg: Good signature from "Andreas Färber <afaerber@suse.de>" # gpg: aka "Andreas Färber <afaerber@suse.com>" # gpg: WARNING: This key is not certified with a trusted signature! # gpg: There is no indication that the signature belongs to the owner. # Primary key fingerprint: 174F 0347 1BCC 221A 6175 6F96 FA2E D12D 3E7E 013F * afaerber/tags/qom-devices-for-anthony: (24 commits) qdev-monitor: Improve error message for -device nonexistant ioapic: QOM'ify ioapic ioapic: Cleanup for QOM'ification icc_bus: QOM'ify ICC apic: QOM'ify APIC apic: Cleanup for QOM'ification qdev: Drop misleading qbus_free() function qom: Detect bad reentrance during object_class_foreach() tests: Test QOM interface casting qom: Do not register interface "types" in the type table and fix names qom: Split out object and class caches qdev: Document that pointer properties kill device_add hw: cannot_instantiate_with_device_add_yet due to pointer props qdev-monitor: Avoid device_add crashing on non-device driver name qdev: Do not let the user try to device_add when it cannot work isa: Clean up use of cannot_instantiate_with_device_add_yet vt82c686: Clean up use of cannot_instantiate_with_device_add_yet piix3 piix4: Clean up use of cannot_instantiate_with_device_add_yet ich9: Document why cannot_instantiate_with_device_add_yet pci-host: Consistently set cannot_instantiate_with_device_add_yet ...
This commit is contained in:
commit
c06f13c6da
84 changed files with 492 additions and 182 deletions
|
@ -171,9 +171,9 @@ static void apic_local_deliver(APICCommonState *s, int vector)
|
|||
}
|
||||
}
|
||||
|
||||
void apic_deliver_pic_intr(DeviceState *d, int level)
|
||||
void apic_deliver_pic_intr(DeviceState *dev, int level)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
|
||||
if (level) {
|
||||
apic_local_deliver(s, APIC_LVT_LINT0);
|
||||
|
@ -376,9 +376,9 @@ static void apic_update_irq(APICCommonState *s)
|
|||
}
|
||||
}
|
||||
|
||||
void apic_poll_irq(DeviceState *d)
|
||||
void apic_poll_irq(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s = APIC_COMMON(d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
|
||||
apic_sync_vapic(s, SYNC_FROM_VAPIC);
|
||||
apic_update_irq(s);
|
||||
|
@ -482,9 +482,9 @@ static void apic_startup(APICCommonState *s, int vector_num)
|
|||
cpu_interrupt(CPU(s->cpu), CPU_INTERRUPT_SIPI);
|
||||
}
|
||||
|
||||
void apic_sipi(DeviceState *d)
|
||||
void apic_sipi(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
|
||||
cpu_reset_interrupt(CPU(s->cpu), CPU_INTERRUPT_SIPI);
|
||||
|
||||
|
@ -494,11 +494,11 @@ void apic_sipi(DeviceState *d)
|
|||
s->wait_for_sipi = 0;
|
||||
}
|
||||
|
||||
static void apic_deliver(DeviceState *d, uint8_t dest, uint8_t dest_mode,
|
||||
static void apic_deliver(DeviceState *dev, uint8_t dest, uint8_t dest_mode,
|
||||
uint8_t delivery_mode, uint8_t vector_num,
|
||||
uint8_t trigger_mode)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
uint32_t deliver_bitmask[MAX_APIC_WORDS];
|
||||
int dest_shorthand = (s->icr[0] >> 18) & 3;
|
||||
APICCommonState *apic_iter;
|
||||
|
@ -551,9 +551,9 @@ static bool apic_check_pic(APICCommonState *s)
|
|||
return true;
|
||||
}
|
||||
|
||||
int apic_get_interrupt(DeviceState *d)
|
||||
int apic_get_interrupt(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
int intno;
|
||||
|
||||
/* if the APIC is installed or enabled, we let the 8259 handle the
|
||||
|
@ -585,9 +585,9 @@ int apic_get_interrupt(DeviceState *d)
|
|||
return intno;
|
||||
}
|
||||
|
||||
int apic_accept_pic_intr(DeviceState *d)
|
||||
int apic_accept_pic_intr(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
uint32_t lvt0;
|
||||
|
||||
if (!s)
|
||||
|
@ -657,16 +657,16 @@ static void apic_mem_writew(void *opaque, hwaddr addr, uint32_t val)
|
|||
|
||||
static uint32_t apic_mem_readl(void *opaque, hwaddr addr)
|
||||
{
|
||||
DeviceState *d;
|
||||
DeviceState *dev;
|
||||
APICCommonState *s;
|
||||
uint32_t val;
|
||||
int index;
|
||||
|
||||
d = cpu_get_current_apic();
|
||||
if (!d) {
|
||||
dev = cpu_get_current_apic();
|
||||
if (!dev) {
|
||||
return 0;
|
||||
}
|
||||
s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
s = APIC_COMMON(dev);
|
||||
|
||||
index = (addr >> 4) & 0xff;
|
||||
switch(index) {
|
||||
|
@ -752,7 +752,7 @@ static void apic_send_msi(hwaddr addr, uint32_t data)
|
|||
|
||||
static void apic_mem_writel(void *opaque, hwaddr addr, uint32_t val)
|
||||
{
|
||||
DeviceState *d;
|
||||
DeviceState *dev;
|
||||
APICCommonState *s;
|
||||
int index = (addr >> 4) & 0xff;
|
||||
if (addr > 0xfff || !index) {
|
||||
|
@ -765,11 +765,11 @@ static void apic_mem_writel(void *opaque, hwaddr addr, uint32_t val)
|
|||
return;
|
||||
}
|
||||
|
||||
d = cpu_get_current_apic();
|
||||
if (!d) {
|
||||
dev = cpu_get_current_apic();
|
||||
if (!dev) {
|
||||
return;
|
||||
}
|
||||
s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
s = APIC_COMMON(dev);
|
||||
|
||||
trace_apic_mem_writel(addr, val);
|
||||
|
||||
|
@ -810,7 +810,7 @@ static void apic_mem_writel(void *opaque, hwaddr addr, uint32_t val)
|
|||
break;
|
||||
case 0x30:
|
||||
s->icr[0] = val;
|
||||
apic_deliver(d, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,
|
||||
apic_deliver(dev, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1,
|
||||
(s->icr[0] >> 8) & 7, (s->icr[0] & 0xff),
|
||||
(s->icr[0] >> 15) & 1);
|
||||
break;
|
||||
|
@ -871,8 +871,10 @@ static const MemoryRegionOps apic_io_ops = {
|
|||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
};
|
||||
|
||||
static void apic_init(APICCommonState *s)
|
||||
static void apic_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
|
||||
memory_region_init_io(&s->io_memory, OBJECT(s), &apic_io_ops, s, "apic-msi",
|
||||
APIC_SPACE_SIZE);
|
||||
|
||||
|
@ -886,7 +888,7 @@ static void apic_class_init(ObjectClass *klass, void *data)
|
|||
{
|
||||
APICCommonClass *k = APIC_COMMON_CLASS(klass);
|
||||
|
||||
k->init = apic_init;
|
||||
k->realize = apic_realize;
|
||||
k->set_base = apic_set_base;
|
||||
k->set_tpr = apic_set_tpr;
|
||||
k->get_tpr = apic_get_tpr;
|
||||
|
|
|
@ -27,21 +27,21 @@
|
|||
static int apic_irq_delivered;
|
||||
bool apic_report_tpr_access;
|
||||
|
||||
void cpu_set_apic_base(DeviceState *d, uint64_t val)
|
||||
void cpu_set_apic_base(DeviceState *dev, uint64_t val)
|
||||
{
|
||||
trace_cpu_set_apic_base(val);
|
||||
|
||||
if (d) {
|
||||
APICCommonState *s = APIC_COMMON(d);
|
||||
if (dev) {
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
|
||||
info->set_base(s, val);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t cpu_get_apic_base(DeviceState *d)
|
||||
uint64_t cpu_get_apic_base(DeviceState *dev)
|
||||
{
|
||||
if (d) {
|
||||
APICCommonState *s = APIC_COMMON(d);
|
||||
if (dev) {
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
trace_cpu_get_apic_base((uint64_t)s->apicbase);
|
||||
return s->apicbase;
|
||||
} else {
|
||||
|
@ -50,39 +50,39 @@ uint64_t cpu_get_apic_base(DeviceState *d)
|
|||
}
|
||||
}
|
||||
|
||||
void cpu_set_apic_tpr(DeviceState *d, uint8_t val)
|
||||
void cpu_set_apic_tpr(DeviceState *dev, uint8_t val)
|
||||
{
|
||||
APICCommonState *s;
|
||||
APICCommonClass *info;
|
||||
|
||||
if (!d) {
|
||||
if (!dev) {
|
||||
return;
|
||||
}
|
||||
|
||||
s = APIC_COMMON(d);
|
||||
s = APIC_COMMON(dev);
|
||||
info = APIC_COMMON_GET_CLASS(s);
|
||||
|
||||
info->set_tpr(s, val);
|
||||
}
|
||||
|
||||
uint8_t cpu_get_apic_tpr(DeviceState *d)
|
||||
uint8_t cpu_get_apic_tpr(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s;
|
||||
APICCommonClass *info;
|
||||
|
||||
if (!d) {
|
||||
if (!dev) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
s = APIC_COMMON(d);
|
||||
s = APIC_COMMON(dev);
|
||||
info = APIC_COMMON_GET_CLASS(s);
|
||||
|
||||
return info->get_tpr(s);
|
||||
}
|
||||
|
||||
void apic_enable_tpr_access_reporting(DeviceState *d, bool enable)
|
||||
void apic_enable_tpr_access_reporting(DeviceState *dev, bool enable)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
|
||||
|
||||
apic_report_tpr_access = enable;
|
||||
|
@ -91,19 +91,19 @@ void apic_enable_tpr_access_reporting(DeviceState *d, bool enable)
|
|||
}
|
||||
}
|
||||
|
||||
void apic_enable_vapic(DeviceState *d, hwaddr paddr)
|
||||
void apic_enable_vapic(DeviceState *dev, hwaddr paddr)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
|
||||
|
||||
s->vapic_paddr = paddr;
|
||||
info->vapic_base_update(s);
|
||||
}
|
||||
|
||||
void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip,
|
||||
void apic_handle_tpr_access_report(DeviceState *dev, target_ulong ip,
|
||||
TPRAccess access)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
|
||||
vapic_report_tpr_access(s->vapic, CPU(s->cpu), ip, access);
|
||||
}
|
||||
|
@ -129,9 +129,9 @@ int apic_get_irq_delivered(void)
|
|||
return apic_irq_delivered;
|
||||
}
|
||||
|
||||
void apic_deliver_nmi(DeviceState *d)
|
||||
void apic_deliver_nmi(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s = APIC_COMMON(d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
|
||||
|
||||
info->external_nmi(s);
|
||||
|
@ -170,9 +170,9 @@ bool apic_next_timer(APICCommonState *s, int64_t current_time)
|
|||
return true;
|
||||
}
|
||||
|
||||
void apic_init_reset(DeviceState *d)
|
||||
void apic_init_reset(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
int i;
|
||||
|
||||
if (!s) {
|
||||
|
@ -203,19 +203,19 @@ void apic_init_reset(DeviceState *d)
|
|||
s->timer_expiry = -1;
|
||||
}
|
||||
|
||||
void apic_designate_bsp(DeviceState *d)
|
||||
void apic_designate_bsp(DeviceState *dev)
|
||||
{
|
||||
if (d == NULL) {
|
||||
if (dev == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
APICCommonState *s = APIC_COMMON(d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
s->apicbase |= MSR_IA32_APICBASE_BSP;
|
||||
}
|
||||
|
||||
static void apic_reset_common(DeviceState *d)
|
||||
static void apic_reset_common(DeviceState *dev)
|
||||
{
|
||||
APICCommonState *s = DO_UPCAST(APICCommonState, busdev.qdev, d);
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
|
||||
bool bsp;
|
||||
|
||||
|
@ -226,7 +226,7 @@ static void apic_reset_common(DeviceState *d)
|
|||
s->vapic_paddr = 0;
|
||||
info->vapic_base_update(s);
|
||||
|
||||
apic_init_reset(d);
|
||||
apic_init_reset(dev);
|
||||
|
||||
if (bsp) {
|
||||
/*
|
||||
|
@ -284,7 +284,7 @@ static int apic_load_old(QEMUFile *f, void *opaque, int version_id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int apic_init_common(ICCDevice *dev)
|
||||
static void apic_common_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
APICCommonState *s = APIC_COMMON(dev);
|
||||
APICCommonClass *info;
|
||||
|
@ -293,14 +293,16 @@ static int apic_init_common(ICCDevice *dev)
|
|||
static bool mmio_registered;
|
||||
|
||||
if (apic_no >= MAX_APICS) {
|
||||
return -1;
|
||||
error_setg(errp, "%s initialization failed.",
|
||||
object_get_typename(OBJECT(dev)));
|
||||
return;
|
||||
}
|
||||
s->idx = apic_no++;
|
||||
|
||||
info = APIC_COMMON_GET_CLASS(s);
|
||||
info->init(s);
|
||||
info->realize(dev, errp);
|
||||
if (!mmio_registered) {
|
||||
ICCBus *b = ICC_BUS(qdev_get_parent_bus(DEVICE(dev)));
|
||||
ICCBus *b = ICC_BUS(qdev_get_parent_bus(dev));
|
||||
memory_region_add_subregion(b->apic_address_space, 0, &s->io_memory);
|
||||
mmio_registered = true;
|
||||
}
|
||||
|
@ -315,7 +317,6 @@ static int apic_init_common(ICCDevice *dev)
|
|||
info->enable_tpr_reporting(s, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void apic_dispatch_pre_save(void *opaque)
|
||||
|
@ -386,9 +387,13 @@ static void apic_common_class_init(ObjectClass *klass, void *data)
|
|||
|
||||
dc->vmsd = &vmstate_apic_common;
|
||||
dc->reset = apic_reset_common;
|
||||
dc->no_user = 1;
|
||||
dc->props = apic_properties_common;
|
||||
idc->init = apic_init_common;
|
||||
idc->realize = apic_common_realize;
|
||||
/*
|
||||
* Reason: APIC and CPU need to be wired up by
|
||||
* x86_cpu_apic_create()
|
||||
*/
|
||||
dc->cannot_instantiate_with_device_add_yet = true;
|
||||
}
|
||||
|
||||
static const TypeInfo apic_common_type = {
|
||||
|
@ -400,9 +405,9 @@ static const TypeInfo apic_common_type = {
|
|||
.abstract = true,
|
||||
};
|
||||
|
||||
static void register_types(void)
|
||||
static void apic_common_register_types(void)
|
||||
{
|
||||
type_register_static(&apic_common_type);
|
||||
}
|
||||
|
||||
type_init(register_types)
|
||||
type_init(apic_common_register_types)
|
||||
|
|
|
@ -709,7 +709,6 @@ static void arm_gic_class_init(ObjectClass *klass, void *data)
|
|||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
ARMGICClass *agc = ARM_GIC_CLASS(klass);
|
||||
|
||||
dc->no_user = 1;
|
||||
agc->parent_realize = dc->realize;
|
||||
dc->realize = arm_gic_realize;
|
||||
}
|
||||
|
|
|
@ -156,7 +156,6 @@ static void arm_gic_common_class_init(ObjectClass *klass, void *data)
|
|||
dc->realize = arm_gic_common_realize;
|
||||
dc->props = arm_gic_common_properties;
|
||||
dc->vmsd = &vmstate_gic;
|
||||
dc->no_user = 1;
|
||||
}
|
||||
|
||||
static const TypeInfo arm_gic_common_type = {
|
||||
|
|
|
@ -150,7 +150,6 @@ static void kvm_arm_gic_class_init(ObjectClass *klass, void *data)
|
|||
kgc->parent_reset = dc->reset;
|
||||
dc->realize = kvm_arm_gic_realize;
|
||||
dc->reset = kvm_arm_gic_reset;
|
||||
dc->no_user = 1;
|
||||
}
|
||||
|
||||
static const TypeInfo kvm_arm_gic_info = {
|
||||
|
|
|
@ -170,6 +170,10 @@ static void etraxfs_pic_class_init(ObjectClass *klass, void *data)
|
|||
|
||||
k->init = etraxfs_pic_init;
|
||||
dc->props = etraxfs_pic_properties;
|
||||
/*
|
||||
* Note: pointer property "interrupt_vector" may remain null, thus
|
||||
* no need for dc->cannot_instantiate_with_device_add_yet = true;
|
||||
*/
|
||||
}
|
||||
|
||||
static const TypeInfo etraxfs_pic_info = {
|
||||
|
|
|
@ -355,6 +355,8 @@ static void grlib_irqmp_class_init(ObjectClass *klass, void *data)
|
|||
k->init = grlib_irqmp_init;
|
||||
dc->reset = grlib_irqmp_reset;
|
||||
dc->props = grlib_irqmp_properties;
|
||||
/* Reason: pointer properties "set_pil_in", "set_pil_in_opaque" */
|
||||
dc->cannot_instantiate_with_device_add_yet = true;
|
||||
}
|
||||
|
||||
static const TypeInfo grlib_irqmp_info = {
|
||||
|
|
|
@ -135,9 +135,15 @@ static void pic_common_class_init(ObjectClass *klass, void *data)
|
|||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
dc->vmsd = &vmstate_pic_common;
|
||||
dc->no_user = 1;
|
||||
dc->props = pic_properties_common;
|
||||
dc->realize = pic_common_realize;
|
||||
/*
|
||||
* Reason: unlike ordinary ISA devices, the PICs need additional
|
||||
* wiring: its IRQ input lines are set up by board code, and the
|
||||
* wiring of the slave to the master is hard-coded in device model
|
||||
* code.
|
||||
*/
|
||||
dc->cannot_instantiate_with_device_add_yet = true;
|
||||
}
|
||||
|
||||
static const TypeInfo pic_common_type = {
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
|
||||
static IOAPICCommonState *ioapics[MAX_IOAPICS];
|
||||
|
||||
/* global variable from ioapic_common.c */
|
||||
extern int ioapic_no;
|
||||
|
||||
static void ioapic_service(IOAPICCommonState *s)
|
||||
{
|
||||
uint8_t i;
|
||||
|
@ -225,14 +228,16 @@ static const MemoryRegionOps ioapic_io_ops = {
|
|||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
};
|
||||
|
||||
static void ioapic_init(IOAPICCommonState *s, int instance_no)
|
||||
static void ioapic_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
IOAPICCommonState *s = IOAPIC_COMMON(dev);
|
||||
|
||||
memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s,
|
||||
"ioapic", 0x1000);
|
||||
|
||||
qdev_init_gpio_in(DEVICE(s), ioapic_set_irq, IOAPIC_NUM_PINS);
|
||||
qdev_init_gpio_in(dev, ioapic_set_irq, IOAPIC_NUM_PINS);
|
||||
|
||||
ioapics[instance_no] = s;
|
||||
ioapics[ioapic_no] = s;
|
||||
}
|
||||
|
||||
static void ioapic_class_init(ObjectClass *klass, void *data)
|
||||
|
@ -240,7 +245,7 @@ static void ioapic_class_init(ObjectClass *klass, void *data)
|
|||
IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass);
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
|
||||
k->init = ioapic_init;
|
||||
k->realize = ioapic_realize;
|
||||
dc->reset = ioapic_reset_common;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,14 @@
|
|||
#include "hw/i386/ioapic_internal.h"
|
||||
#include "hw/sysbus.h"
|
||||
|
||||
/* ioapic_no count start from 0 to MAX_IOAPICS,
|
||||
* remove as static variable from ioapic_common_init.
|
||||
* now as a global variable, let child to increase the counter
|
||||
* then we can drop the 'instance_no' argument
|
||||
* and convert to our QOM's realize function
|
||||
*/
|
||||
int ioapic_no;
|
||||
|
||||
void ioapic_reset_common(DeviceState *dev)
|
||||
{
|
||||
IOAPICCommonState *s = IOAPIC_COMMON(dev);
|
||||
|
@ -61,7 +69,6 @@ static void ioapic_common_realize(DeviceState *dev, Error **errp)
|
|||
{
|
||||
IOAPICCommonState *s = IOAPIC_COMMON(dev);
|
||||
IOAPICCommonClass *info;
|
||||
static int ioapic_no;
|
||||
|
||||
if (ioapic_no >= MAX_IOAPICS) {
|
||||
error_setg(errp, "Only %d ioapics allowed", MAX_IOAPICS);
|
||||
|
@ -69,7 +76,7 @@ static void ioapic_common_realize(DeviceState *dev, Error **errp)
|
|||
}
|
||||
|
||||
info = IOAPIC_COMMON_GET_CLASS(s);
|
||||
info->init(s, ioapic_no);
|
||||
info->realize(dev, errp);
|
||||
|
||||
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->io_memory);
|
||||
ioapic_no++;
|
||||
|
@ -98,7 +105,6 @@ static void ioapic_common_class_init(ObjectClass *klass, void *data)
|
|||
|
||||
dc->realize = ioapic_common_realize;
|
||||
dc->vmsd = &vmstate_ioapic_common;
|
||||
dc->no_user = 1;
|
||||
}
|
||||
|
||||
static const TypeInfo ioapic_common_type = {
|
||||
|
@ -110,9 +116,9 @@ static const TypeInfo ioapic_common_type = {
|
|||
.abstract = true,
|
||||
};
|
||||
|
||||
static void register_types(void)
|
||||
static void ioapic_common_register_types(void)
|
||||
{
|
||||
type_register_static(&ioapic_common_type);
|
||||
}
|
||||
|
||||
type_init(register_types)
|
||||
type_init(ioapic_common_register_types)
|
||||
|
|
|
@ -392,6 +392,8 @@ static void omap_intc_class_init(ObjectClass *klass, void *data)
|
|||
k->init = omap_intc_init;
|
||||
dc->reset = omap_inth_reset;
|
||||
dc->props = omap_intc_properties;
|
||||
/* Reason: pointer property "clk" */
|
||||
dc->cannot_instantiate_with_device_add_yet = true;
|
||||
}
|
||||
|
||||
static const TypeInfo omap_intc_info = {
|
||||
|
@ -637,6 +639,8 @@ static void omap2_intc_class_init(ObjectClass *klass, void *data)
|
|||
k->init = omap2_intc_init;
|
||||
dc->reset = omap_inth_reset;
|
||||
dc->props = omap2_intc_properties;
|
||||
/* Reason: pointer property "iclk", "fclk" */
|
||||
dc->cannot_instantiate_with_device_add_yet = true;
|
||||
}
|
||||
|
||||
static const TypeInfo omap2_intc_info = {
|
||||
|
|
|
@ -273,7 +273,6 @@ static void pl190_class_init(ObjectClass *klass, void *data)
|
|||
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
|
||||
|
||||
k->init = pl190_init;
|
||||
dc->no_user = 1;
|
||||
dc->reset = pl190_reset;
|
||||
dc->vmsd = &vmstate_pl190;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue