7 typedef struct DeviceType DeviceType;
9 typedef struct DeviceProperty DeviceProperty;
11 typedef struct BusState BusState;
13 /* This structure should not be accessed directly. We declare it here
14 so that it can be embedded in individual device state structures. */
19 DeviceProperty *props;
26 LIST_HEAD(, BusState) child_bus;
28 LIST_ENTRY(DeviceState) sibling;
43 LIST_HEAD(, DeviceState) children;
44 LIST_ENTRY(BusState) sibling;
47 /*** Board API. This should go away once we have a machine config file. ***/
49 DeviceState *qdev_create(BusState *bus, const char *name);
50 void qdev_init(DeviceState *dev);
51 void qdev_free(DeviceState *dev);
53 /* Set properties between creation and init. */
54 void qdev_set_prop_int(DeviceState *dev, const char *name, uint64_t value);
55 void qdev_set_prop_ptr(DeviceState *dev, const char *name, void *value);
56 void qdev_set_netdev(DeviceState *dev, NICInfo *nd);
58 qemu_irq qdev_get_irq_sink(DeviceState *dev, int n);
59 qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
60 void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
62 BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
66 typedef struct DeviceInfo DeviceInfo;
68 typedef void (*qdev_initfn)(DeviceState *dev, DeviceInfo *info);
69 typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
77 void qdev_register(const char *name, int size, DeviceInfo *info);
79 /* Register device properties. */
80 void qdev_init_irq_sink(DeviceState *dev, qemu_irq_handler handler, int nirq);
81 void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
82 void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
84 void scsi_bus_new(DeviceState *host, SCSIAttachFn attach);
86 CharDriverState *qdev_init_chardev(DeviceState *dev);
88 BusState *qdev_get_parent_bus(DeviceState *dev);
89 uint64_t qdev_get_prop_int(DeviceState *dev, const char *name, uint64_t def);
90 void *qdev_get_prop_ptr(DeviceState *dev, const char *name);
92 /* Convery from a base type to a parent type, with compile time checking. */
94 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
95 char __attribute__((unused)) offset_must_be_zero[ \
96 -offsetof(type, field)]; \
97 container_of(dev, type, field);}))
99 #define DO_UPCAST(type, field, dev) container_of(dev, type, field)
104 BusState *qbus_create(BusType type, size_t size,
105 DeviceState *parent, const char *name);
107 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)