Commit 6f68ecb2c11d90212d6f7d06c857843d30abcfdc

Authored by Paul Brook
1 parent 6b1b92d3

qdev scsi bus infrastructure

Signed-off-by: Paul Brook <paul@codesourcery.com>
Showing 2 changed files with 23 additions and 0 deletions
hw/qdev.c
@@ -265,3 +265,22 @@ void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus) @@ -265,3 +265,22 @@ void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus)
265 p->next = dev->child_bus; 265 p->next = dev->child_bus;
266 dev->child_bus = p; 266 dev->child_bus = p;
267 } 267 }
  268 +
  269 +static int next_scsi_bus;
  270 +
  271 +/* Create a scsi bus, and attach devices to it. */
  272 +/* TODO: Actually create a scsi bus for hotplug to use. */
  273 +void scsi_bus_new(DeviceState *host, SCSIAttachFn attach)
  274 +{
  275 + int bus = next_scsi_bus++;
  276 + int unit;
  277 + int index;
  278 +
  279 + for (unit = 0; unit < MAX_SCSI_DEVS; unit++) {
  280 + index = drive_get_index(IF_SCSI, bus, unit);
  281 + if (index == -1) {
  282 + continue;
  283 + }
  284 + attach(host, drives_table[index].bdrv, unit);
  285 + }
  286 +}
hw/qdev.h
@@ -44,6 +44,8 @@ void *qdev_get_child_bus(DeviceState *dev, const char *name); @@ -44,6 +44,8 @@ void *qdev_get_child_bus(DeviceState *dev, const char *name);
44 /*** Device API. ***/ 44 /*** Device API. ***/
45 45
46 typedef void (*qdev_initfn)(DeviceState *dev, void *opaque); 46 typedef void (*qdev_initfn)(DeviceState *dev, void *opaque);
  47 +typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
  48 + int unit);
47 49
48 DeviceType *qdev_register(const char *name, int size, qdev_initfn init, 50 DeviceType *qdev_register(const char *name, int size, qdev_initfn init,
49 void *opaque); 51 void *opaque);
@@ -54,6 +56,8 @@ void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n); @@ -54,6 +56,8 @@ void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
54 void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n); 56 void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
55 void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus); 57 void qdev_attach_child_bus(DeviceState *dev, const char *name, void *bus);
56 58
  59 +void scsi_bus_new(DeviceState *host, SCSIAttachFn attach);
  60 +
57 CharDriverState *qdev_init_chardev(DeviceState *dev); 61 CharDriverState *qdev_init_chardev(DeviceState *dev);
58 62
59 void *qdev_get_bus(DeviceState *dev); 63 void *qdev_get_bus(DeviceState *dev);