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. */
29 LIST_HEAD(, BusState
) child_bus
;
32 LIST_ENTRY(DeviceState
) sibling
;
35 typedef void (*bus_dev_printfn
)(Monitor
*mon
, DeviceState
*dev
, int indent
);
39 bus_dev_printfn print_dev
;
47 LIST_HEAD(, DeviceState
) children
;
48 LIST_ENTRY(BusState
) sibling
;
71 enum PropertyType type
;
72 int (*parse
)(DeviceState
*dev
, Property
*prop
, const char *str
);
73 int (*print
)(DeviceState
*dev
, Property
*prop
, char *dest
, size_t len
);
76 struct CompatProperty
{
82 /*** Board API. This should go away once we have a machine config file. ***/
84 DeviceState
*qdev_create(BusState
*bus
, const char *name
);
85 void qdev_init(DeviceState
*dev
);
86 void qdev_free(DeviceState
*dev
);
88 qemu_irq
qdev_get_gpio_in(DeviceState
*dev
, int n
);
89 void qdev_connect_gpio_out(DeviceState
*dev
, int n
, qemu_irq pin
);
91 BusState
*qdev_get_child_bus(DeviceState
*dev
, const char *name
);
95 typedef void (*qdev_initfn
)(DeviceState
*dev
, DeviceInfo
*info
);
96 typedef void (*SCSIAttachFn
)(DeviceState
*host
, BlockDriverState
*bdrv
,
107 /* Private to qdev / bus. */
110 struct DeviceInfo
*next
;
113 void qdev_register(DeviceInfo
*info
);
115 /* Register device properties. */
116 /* GPIO inputs also double as IRQ sinks. */
117 void qdev_init_gpio_in(DeviceState
*dev
, qemu_irq_handler handler
, int n
);
118 void qdev_init_gpio_out(DeviceState
*dev
, qemu_irq
*pins
, int n
);
120 void scsi_bus_new(DeviceState
*host
, SCSIAttachFn attach
);
122 CharDriverState
*qdev_init_chardev(DeviceState
*dev
);
124 BusState
*qdev_get_parent_bus(DeviceState
*dev
);
126 /* Convery from a base type to a parent type, with compile time checking. */
128 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
129 char __attribute__((unused)) offset_must_be_zero[ \
130 -offsetof(type, field)]; \
131 container_of(dev, type, field);}))
133 #define DO_UPCAST(type, field, dev) container_of(dev, type, field)
138 BusState
*qbus_create(BusInfo
*info
, DeviceState
*parent
, const char *name
);
140 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
142 /*** monitor commands ***/
144 void do_info_qtree(Monitor
*mon
);
146 /*** qdev-properties.c ***/
148 extern PropertyInfo qdev_prop_uint16
;
149 extern PropertyInfo qdev_prop_uint32
;
150 extern PropertyInfo qdev_prop_uint64
;
151 extern PropertyInfo qdev_prop_hex32
;
152 extern PropertyInfo qdev_prop_hex64
;
153 extern PropertyInfo qdev_prop_ptr
;
154 extern PropertyInfo qdev_prop_macaddr
;
155 extern PropertyInfo qdev_prop_pci_devfn
;
157 /* Set properties between creation and init. */
158 void *qdev_get_prop_ptr(DeviceState
*dev
, Property
*prop
);
159 int qdev_prop_parse(DeviceState
*dev
, const char *name
, const char *value
);
160 void qdev_prop_set(DeviceState
*dev
, const char *name
, void *src
, enum PropertyType type
);
161 void qdev_prop_set_uint16(DeviceState
*dev
, const char *name
, uint16_t value
);
162 void qdev_prop_set_uint32(DeviceState
*dev
, const char *name
, uint32_t value
);
163 void qdev_prop_set_uint64(DeviceState
*dev
, const char *name
, uint64_t value
);
164 /* FIXME: Remove opaque pointer properties. */
165 void qdev_prop_set_ptr(DeviceState
*dev
, const char *name
, void *value
);
166 void qdev_prop_set_defaults(DeviceState
*dev
, Property
*props
);
168 void qdev_prop_register_compat(CompatProperty
*props
);
169 void qdev_prop_set_compat(DeviceState
*dev
);
171 /* This is a nasty hack to allow passing a NULL bus to qdev_create. */
172 extern struct BusInfo system_bus_info
;