6 typedef struct DeviceType DeviceType
;
8 typedef struct DeviceProperty DeviceProperty
;
10 typedef struct ChildBusList ChildBusList
;
12 /* This structure should not be accessed directly. We declare it here
13 so that it can be embedded in individual device state structures. */
19 DeviceProperty
*props
;
26 ChildBusList
*child_bus
;
30 /*** Board API. This should go away once we have a machine config file. ***/
32 DeviceState
*qdev_create(void *bus
, const char *name
);
33 void qdev_init(DeviceState
*dev
);
35 /* Set properties between creation and init. */
36 void qdev_set_prop_int(DeviceState
*dev
, const char *name
, uint64_t value
);
37 void qdev_set_prop_ptr(DeviceState
*dev
, const char *name
, void *value
);
38 void qdev_set_netdev(DeviceState
*dev
, NICInfo
*nd
);
40 qemu_irq
qdev_get_irq_sink(DeviceState
*dev
, int n
);
41 qemu_irq
qdev_get_gpio_in(DeviceState
*dev
, int n
);
42 void qdev_connect_gpio_out(DeviceState
*dev
, int n
, qemu_irq pin
);
44 void *qdev_get_child_bus(DeviceState
*dev
, const char *name
);
48 typedef void (*qdev_initfn
)(DeviceState
*dev
, void *opaque
);
49 typedef void (*SCSIAttachFn
)(DeviceState
*host
, BlockDriverState
*bdrv
,
52 DeviceType
*qdev_register(const char *name
, int size
, qdev_initfn init
,
55 /* Register device properties. */
56 void qdev_init_irq_sink(DeviceState
*dev
, qemu_irq_handler handler
, int nirq
);
57 void qdev_init_gpio_in(DeviceState
*dev
, qemu_irq_handler handler
, int n
);
58 void qdev_init_gpio_out(DeviceState
*dev
, qemu_irq
*pins
, int n
);
59 void qdev_attach_child_bus(DeviceState
*dev
, const char *name
, void *bus
);
61 void scsi_bus_new(DeviceState
*host
, SCSIAttachFn attach
);
63 CharDriverState
*qdev_init_chardev(DeviceState
*dev
);
65 void *qdev_get_bus(DeviceState
*dev
);
66 uint64_t qdev_get_prop_int(DeviceState
*dev
, const char *name
, uint64_t def
);
67 void *qdev_get_prop_ptr(DeviceState
*dev
, const char *name
);
69 /* Convery from a base type to a parent type, with compile time checking. */
71 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
72 char __attribute__((unused)) offset_must_be_zero[ \
73 -offsetof(type, field)]; \
74 container_of(dev, type, field);}))
76 #define DO_UPCAST(type, field, dev) container_of(dev, type, field)