7 typedef struct Property Property
;
9 typedef struct PropertyInfo PropertyInfo
;
11 typedef struct CompatProperty CompatProperty
;
13 typedef struct DeviceInfo DeviceInfo
;
15 typedef struct BusState BusState
;
17 typedef struct BusInfo BusInfo
;
19 /* This structure should not be accessed directly. We declare it here
20 so that it can be embedded in individual device state structures. */
28 LIST_HEAD(, BusState
) child_bus
;
30 LIST_ENTRY(DeviceState
) sibling
;
33 typedef void (*bus_dev_printfn
)(Monitor
*mon
, DeviceState
*dev
, int indent
);
37 bus_dev_printfn print_dev
;
45 LIST_HEAD(, DeviceState
) children
;
46 LIST_ENTRY(BusState
) sibling
;
68 enum PropertyType type
;
69 int (*parse
)(DeviceState
*dev
, Property
*prop
, const char *str
);
70 int (*print
)(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
);
73 struct CompatProperty
{
79 /*** Board API. This should go away once we have a machine config file. ***/
81 DeviceState
*qdev_create(BusState
*bus
, const char *name
);
82 void qdev_init(DeviceState
*dev
);
83 void qdev_free(DeviceState
*dev
);
85 qemu_irq
qdev_get_gpio_in(DeviceState
*dev
, int n
);
86 void qdev_connect_gpio_out(DeviceState
*dev
, int n
, qemu_irq pin
);
88 BusState
*qdev_get_child_bus(DeviceState
*dev
, const char *name
);
92 typedef void (*qdev_initfn
)(DeviceState
*dev
, DeviceInfo
*info
);
93 typedef void (*SCSIAttachFn
)(DeviceState
*host
, BlockDriverState
*bdrv
,
101 /* Private to qdev / bus. */
104 struct DeviceInfo
*next
;
107 void qdev_register(DeviceInfo
*info
);
109 /* Register device properties. */
110 /* GPIO inputs also double as IRQ sinks. */
111 void qdev_init_gpio_in(DeviceState
*dev
, qemu_irq_handler handler
, int n
);
112 void qdev_init_gpio_out(DeviceState
*dev
, qemu_irq
*pins
, int n
);
114 void scsi_bus_new(DeviceState
*host
, SCSIAttachFn attach
);
116 CharDriverState
*qdev_init_chardev(DeviceState
*dev
);
118 BusState
*qdev_get_parent_bus(DeviceState
*dev
);
120 /* Convery from a base type to a parent type, with compile time checking. */
122 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
123 char __attribute__((unused)) offset_must_be_zero[ \
124 -offsetof(type, field)]; \
125 container_of(dev, type, field);}))
127 #define DO_UPCAST(type, field, dev) container_of(dev, type, field)
132 BusState
*qbus_create(BusInfo
*info
, DeviceState
*parent
, const char *name
);
134 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
136 /*** monitor commands ***/
138 void do_info_qtree(Monitor
*mon
);
140 /*** qdev-properties.c ***/
142 extern PropertyInfo qdev_prop_uint16
;
143 extern PropertyInfo qdev_prop_uint32
;
144 extern PropertyInfo qdev_prop_hex32
;
145 extern PropertyInfo qdev_prop_ptr
;
146 extern PropertyInfo qdev_prop_macaddr
;
148 /* Set properties between creation and init. */
149 void *qdev_get_prop_ptr(DeviceState
*dev
, Property
*prop
);
150 int qdev_prop_parse(DeviceState
*dev
, const char *name
, const char *value
);
151 void qdev_prop_set(DeviceState
*dev
, const char *name
, void *src
, enum PropertyType type
);
152 void qdev_prop_set_uint16(DeviceState
*dev
, const char *name
, uint16_t value
);
153 void qdev_prop_set_uint32(DeviceState
*dev
, const char *name
, uint32_t value
);
154 /* FIXME: Remove opaque pointer properties. */
155 void qdev_prop_set_ptr(DeviceState
*dev
, const char *name
, void *value
);
156 void qdev_prop_set_defaults(DeviceState
*dev
, Property
*props
);
158 void qdev_prop_register_compat(CompatProperty
*props
);
159 void qdev_prop_set_compat(DeviceState
*dev
);