static int sysbus_device_init(DeviceState *dev) { SysBusDevice *sd = SYS_BUS_DEVICE(dev); SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd); return sbc->init(sd); }
void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq) { SysBusDeviceClass *sbd = SYS_BUS_DEVICE_GET_CLASS(dev); qdev_connect_gpio_out_named(DEVICE(dev), SYSBUS_DEVICE_GPIO_IRQ, n, irq); if (sbd->connect_irq_notifier) { sbd->connect_irq_notifier(dev, irq); } }
/* TODO remove once all sysbus devices have been converted to realize */ static void sysbus_realize(DeviceState *dev, Error **errp) { SysBusDevice *sd = SYS_BUS_DEVICE(dev); SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(sd); if (!sbc->init) { return; } if (sbc->init(sd) < 0) { error_setg(errp, "Device initialization failed"); } }
static char *sysbus_get_fw_dev_path(DeviceState *dev) { SysBusDevice *s = SYS_BUS_DEVICE(dev); SysBusDeviceClass *sbc = SYS_BUS_DEVICE_GET_CLASS(s); char *addr, *fw_dev_path; if (sbc->explicit_ofw_unit_address) { addr = sbc->explicit_ofw_unit_address(s); if (addr) { fw_dev_path = g_strdup_printf("%s@%s", qdev_fw_name(dev), addr); g_free(addr); return fw_dev_path; } } if (s->num_mmio) { return g_strdup_printf("%s@" TARGET_FMT_plx, qdev_fw_name(dev), s->mmio[0].addr); } if (s->num_pio) { return g_strdup_printf("%s@i%04x", qdev_fw_name(dev), s->pio[0]); } return g_strdup(qdev_fw_name(dev)); }