7 typedef struct DeviceInfo DeviceInfo
;
9 typedef struct DeviceProperty DeviceProperty
;
11 typedef struct BusState BusState
;
13 typedef struct BusInfo BusInfo
;
15 /* This structure should not be accessed directly. We declare it here
16 so that it can be embedded in individual device state structures. */
20 DeviceProperty
*props
;
25 LIST_HEAD(, BusState
) child_bus
;
27 LIST_ENTRY(DeviceState
) sibling
;
30 typedef void (*bus_dev_printfn
)(Monitor
*mon
, DeviceState
*dev
, int indent
);
34 bus_dev_printfn print_dev
;
41 LIST_HEAD(, DeviceState
) children
;
42 LIST_ENTRY(BusState
) sibling
;
45 /*** Board API. This should go away once we have a machine config file. ***/
47 DeviceState
*qdev_create(BusState
*bus
, const char *name
);
48 void qdev_init(DeviceState
*dev
);
49 void qdev_free(DeviceState
*dev
);
51 /* Set properties between creation and init. */
52 void qdev_set_prop_int(DeviceState
*dev
, const char *name
, uint64_t value
);
53 void qdev_set_prop_dev(DeviceState
*dev
, const char *name
, DeviceState
*value
);
54 void qdev_set_prop_ptr(DeviceState
*dev
, const char *name
, void *value
);
55 void qdev_set_netdev(DeviceState
*dev
, NICInfo
*nd
);
57 qemu_irq
qdev_get_gpio_in(DeviceState
*dev
, int n
);
58 void qdev_connect_gpio_out(DeviceState
*dev
, int n
, qemu_irq pin
);
60 BusState
*qdev_get_child_bus(DeviceState
*dev
, const char *name
);
75 typedef void (*qdev_initfn
)(DeviceState
*dev
, DeviceInfo
*info
);
76 typedef void (*SCSIAttachFn
)(DeviceState
*host
, BlockDriverState
*bdrv
,
82 DevicePropList
*props
;
84 /* Private to qdev / bus. */
87 struct DeviceInfo
*next
;
90 void qdev_register(DeviceInfo
*info
);
92 /* Register device properties. */
93 /* GPIO inputs also double as IRQ sinks. */
94 void qdev_init_gpio_in(DeviceState
*dev
, qemu_irq_handler handler
, int n
);
95 void qdev_init_gpio_out(DeviceState
*dev
, qemu_irq
*pins
, int n
);
97 void scsi_bus_new(DeviceState
*host
, SCSIAttachFn attach
);
99 CharDriverState
*qdev_init_chardev(DeviceState
*dev
);
101 BusState
*qdev_get_parent_bus(DeviceState
*dev
);
102 uint64_t qdev_get_prop_int(DeviceState
*dev
, const char *name
, uint64_t def
);
103 DeviceState
*qdev_get_prop_dev(DeviceState
*dev
, const char *name
);
104 /* FIXME: Remove opaque pointer properties. */
105 void *qdev_get_prop_ptr(DeviceState
*dev
, const char *name
);
107 /* Convery from a base type to a parent type, with compile time checking. */
109 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
110 char __attribute__((unused)) offset_must_be_zero[ \
111 -offsetof(type, field)]; \
112 container_of(dev, type, field);}))
114 #define DO_UPCAST(type, field, dev) container_of(dev, type, field)
119 BusState
*qbus_create(BusInfo
*info
, DeviceState
*parent
, const char *name
);
121 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
123 /*** monitor commands ***/
125 void do_info_qtree(Monitor
*mon
);