static void powernv_populate_ipmi_bt(ISADevice *d, void *fdt, int lpc_off) { const char compatible[] = "bt\0ipmi-bt"; uint32_t io_base; uint32_t io_regs[] = { cpu_to_be32(1), 0, /* 'io_base' retrieved from the 'ioport' property of 'isa-ipmi-bt' */ cpu_to_be32(3) }; uint32_t irq; char *name; int node; io_base = object_property_get_int(OBJECT(d), "ioport", &error_fatal); io_regs[1] = cpu_to_be32(io_base); irq = object_property_get_int(OBJECT(d), "irq", &error_fatal); name = g_strdup_printf("%s@i%x", qdev_fw_name(DEVICE(d)), io_base); node = fdt_add_subnode(fdt, lpc_off, name); _FDT(node); g_free(name); _FDT((fdt_setprop(fdt, node, "reg", io_regs, sizeof(io_regs)))); _FDT((fdt_setprop(fdt, node, "compatible", compatible, sizeof(compatible)))); /* Mark it as reserved to avoid Linux trying to claim it */ _FDT((fdt_setprop_string(fdt, node, "status", "reserved"))); _FDT((fdt_setprop_cell(fdt, node, "interrupts", irq))); _FDT((fdt_setprop_cell(fdt, node, "interrupt-parent", fdt_get_phandle(fdt, lpc_off)))); }
static void powernv_populate_serial(ISADevice *d, void *fdt, int lpc_off) { const char compatible[] = "ns16550\0pnpPNP,501"; uint32_t io_base = d->ioport_id; uint32_t io_regs[] = { cpu_to_be32(1), cpu_to_be32(io_base), cpu_to_be32(8) }; char *name; int node; name = g_strdup_printf("%s@i%x", qdev_fw_name(DEVICE(d)), io_base); node = fdt_add_subnode(fdt, lpc_off, name); _FDT(node); g_free(name); _FDT((fdt_setprop(fdt, node, "reg", io_regs, sizeof(io_regs)))); _FDT((fdt_setprop(fdt, node, "compatible", compatible, sizeof(compatible)))); _FDT((fdt_setprop_cell(fdt, node, "clock-frequency", 1843200))); _FDT((fdt_setprop_cell(fdt, node, "current-speed", 115200))); _FDT((fdt_setprop_cell(fdt, node, "interrupts", d->isairq[0]))); _FDT((fdt_setprop_cell(fdt, node, "interrupt-parent", fdt_get_phandle(fdt, lpc_off)))); /* This is needed by Linux */ _FDT((fdt_setprop_string(fdt, node, "device_type", "serial"))); }
/* * Implementation of an interface to adjust firmware path * for the bootindex property handling. */ static char *vhost_scsi_get_fw_dev_path(FWPathProvider *p, BusState *bus, DeviceState *dev) { VHostSCSI *s = VHOST_SCSI(dev); /* format: channel@channel/vhost-scsi@target,lun */ return g_strdup_printf("/channel@%x/%s@%x,%x", s->channel, qdev_fw_name(dev), s->target, s->lun); }
/* * Implementation of an interface to adjust firmware path * for the bootindex property handling. */ char *vhost_scsi_common_get_fw_dev_path(FWPathProvider *p, BusState *bus, DeviceState *dev) { VHostSCSICommon *vsc = VHOST_SCSI_COMMON(dev); /* format: /channel@channel/vhost-scsi@target,lun */ return g_strdup_printf("/channel@%x/%s@%x,%x", vsc->channel, qdev_fw_name(dev), vsc->target, vsc->lun); }
static char *idebus_get_fw_dev_path(DeviceState *dev) { char path[30]; snprintf(path, sizeof(path), "%s@%x", qdev_fw_name(dev), ((IDEBus*)dev->parent_bus)->bus_id); return g_strdup(path); }
static char *isabus_get_fw_dev_path(DeviceState *dev) { ISADevice *d = ISA_DEVICE(dev); char path[40]; int off; off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev)); if (d->ioport_id) { snprintf(path + off, sizeof(path) - off, "@%04x", d->ioport_id); } return g_strdup(path); }
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)); }
static char *sysbus_get_fw_dev_path(DeviceState *dev) { SysBusDevice *s = sysbus_from_qdev(dev); char path[40]; int off; off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev)); if (s->num_mmio) { snprintf(path + off, sizeof(path) - off, "@"TARGET_FMT_plx, s->mmio[0].addr); } else if (s->num_pio) { snprintf(path + off, sizeof(path) - off, "@i%04x", s->pio[0]); } return g_strdup(path); }
static int powernv_populate_isa_device(DeviceState *dev, void *opaque) { ForeachPopulateArgs *args = opaque; ISADevice *d = ISA_DEVICE(dev); if (object_dynamic_cast(OBJECT(dev), TYPE_MC146818_RTC)) { powernv_populate_rtc(d, args->fdt, args->offset); } else if (object_dynamic_cast(OBJECT(dev), TYPE_ISA_SERIAL)) { powernv_populate_serial(d, args->fdt, args->offset); } else if (object_dynamic_cast(OBJECT(dev), "isa-ipmi-bt")) { powernv_populate_ipmi_bt(d, args->fdt, args->offset); } else { error_report("unknown isa device %s@i%x", qdev_fw_name(dev), d->ioport_id); } return 0; }
static int sysbus_device_create_devtree(SysBusDevice *sbdev, void *opaque) { PlatformDevtreeData *data = opaque; bool matched = false; if (object_dynamic_cast(OBJECT(sbdev), TYPE_ETSEC_COMMON)) { create_devtree_etsec(sbdev, data); matched = true; } if (!matched) { error_report("Device %s is not supported by this machine yet.", qdev_fw_name(DEVICE(sbdev))); exit(1); } return 0; }
static void powernv_populate_rtc(ISADevice *d, void *fdt, int lpc_off) { uint32_t io_base = d->ioport_id; uint32_t io_regs[] = { cpu_to_be32(1), cpu_to_be32(io_base), cpu_to_be32(2) }; char *name; int node; name = g_strdup_printf("%s@i%x", qdev_fw_name(DEVICE(d)), io_base); node = fdt_add_subnode(fdt, lpc_off, name); _FDT(node); g_free(name); _FDT((fdt_setprop(fdt, node, "reg", io_regs, sizeof(io_regs)))); _FDT((fdt_setprop_string(fdt, node, "compatible", "pnpPNP,b00"))); }