qdev scsi bus infrastructure
Signed-off-by: Paul Brook <paul@codesourcery.com>
This commit is contained in:
parent
6b1b92d35b
commit
6f68ecb2c1
19
hw/qdev.c
19
hw/qdev.c
|
@ -265,3 +265,22 @@ void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus)
|
||||||
p->next = dev->child_bus;
|
p->next = dev->child_bus;
|
||||||
dev->child_bus = p;
|
dev->child_bus = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int next_scsi_bus;
|
||||||
|
|
||||||
|
/* Create a scsi bus, and attach devices to it. */
|
||||||
|
/* TODO: Actually create a scsi bus for hotplug to use. */
|
||||||
|
void scsi_bus_new(DeviceState *host, SCSIAttachFn attach)
|
||||||
|
{
|
||||||
|
int bus = next_scsi_bus++;
|
||||||
|
int unit;
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (unit = 0; unit < MAX_SCSI_DEVS; unit++) {
|
||||||
|
index = drive_get_index(IF_SCSI, bus, unit);
|
||||||
|
if (index == -1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
attach(host, drives_table[index].bdrv, unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,8 @@ void *qdev_get_child_bus(DeviceState *dev, const char *name);
|
||||||
/*** Device API. ***/
|
/*** Device API. ***/
|
||||||
|
|
||||||
typedef void (*qdev_initfn)(DeviceState *dev, void *opaque);
|
typedef void (*qdev_initfn)(DeviceState *dev, void *opaque);
|
||||||
|
typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
|
||||||
|
int unit);
|
||||||
|
|
||||||
DeviceType *qdev_register(const char *name, int size, qdev_initfn init,
|
DeviceType *qdev_register(const char *name, int size, qdev_initfn init,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
@ -54,6 +56,8 @@ void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
|
||||||
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
|
void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
|
||||||
void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus);
|
void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus);
|
||||||
|
|
||||||
|
void scsi_bus_new(DeviceState *host, SCSIAttachFn attach);
|
||||||
|
|
||||||
CharDriverState *qdev_init_chardev(DeviceState *dev);
|
CharDriverState *qdev_init_chardev(DeviceState *dev);
|
||||||
|
|
||||||
void *qdev_get_bus(DeviceState *dev);
|
void *qdev_get_bus(DeviceState *dev);
|
||||||
|
|
Loading…
Reference in a new issue