static void machine_init_notify(Notifier *notifier, void *data) { MachineState *machine = MACHINE(qdev_get_machine()); /* * Loop through all dynamically created sysbus devices and check if they are * all allowed. If a device is not allowed, error out. */ foreach_dynamic_sysbus_device(validate_sysbus_device, machine); }
static void machine_init_notify(Notifier *notifier, void *data) { Object *machine = qdev_get_machine(); ObjectClass *oc = object_get_class(machine); MachineClass *mc = MACHINE_CLASS(oc); if (mc->has_dynamic_sysbus) { /* Our machine can handle dynamic sysbus devices, we're all good */ return; } /* * Loop through all dynamically created devices and check whether there * are sysbus devices among them. If there are, error out. */ foreach_dynamic_sysbus_device(error_on_sysbus_device, NULL); }
static void platform_bus_create_devtree(PPCE500Params *params, void *fdt, const char *mpic) { gchar *node = g_strdup_printf("/platform@%"PRIx64, params->platform_bus_base); const char platcomp[] = "qemu,platform\0simple-bus"; uint64_t addr = params->platform_bus_base; uint64_t size = params->platform_bus_size; int irq_start = params->platform_bus_first_irq; PlatformBusDevice *pbus; DeviceState *dev; /* Create a /platform node that we can put all devices into */ qemu_fdt_add_subnode(fdt, node); qemu_fdt_setprop(fdt, node, "compatible", platcomp, sizeof(platcomp)); /* Our platform bus region is less than 32bit big, so 1 cell is enough for address and size */ qemu_fdt_setprop_cells(fdt, node, "#size-cells", 1); qemu_fdt_setprop_cells(fdt, node, "#address-cells", 1); qemu_fdt_setprop_cells(fdt, node, "ranges", 0, addr >> 32, addr, size); qemu_fdt_setprop_phandle(fdt, node, "interrupt-parent", mpic); dev = qdev_find_recursive(sysbus_get_default(), TYPE_PLATFORM_BUS_DEVICE); pbus = PLATFORM_BUS_DEVICE(dev); /* We can only create dt nodes for dynamic devices when they're ready */ if (pbus->done_gathering) { PlatformDevtreeData data = { .fdt = fdt, .mpic = mpic, .irq_start = irq_start, .node = node, .pbus = pbus, }; /* Loop through all dynamic sysbus devices and create nodes for them */ foreach_dynamic_sysbus_device(sysbus_device_create_devtree, &data); }