7 typedef struct Property Property;
9 typedef struct PropertyInfo PropertyInfo;
11 typedef struct DeviceInfo DeviceInfo;
13 typedef struct BusState BusState;
15 typedef struct BusInfo BusInfo;
17 /* This structure should not be accessed directly. We declare it here
18 so that it can be embedded in individual device state structures. */
26 LIST_HEAD(, BusState) child_bus;
28 LIST_ENTRY(DeviceState) sibling;
31 typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent);
35 bus_dev_printfn print_dev;
43 LIST_HEAD(, DeviceState) children;
44 LIST_ENTRY(BusState) sibling;
66 enum PropertyType type;
67 int (*parse)(DeviceState *dev, Property *prop, const char *str);
68 int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len);
71 /*** Board API. This should go away once we have a machine config file. ***/
73 DeviceState *qdev_create(BusState *bus, const char *name);
74 void qdev_init(DeviceState *dev);
75 void qdev_free(DeviceState *dev);
77 qemu_irq qdev_get_gpio_in(DeviceState *dev, int n);
78 void qdev_connect_gpio_out(DeviceState *dev, int n, qemu_irq pin);
80 BusState *qdev_get_child_bus(DeviceState *dev, const char *name);
84 typedef void (*qdev_initfn)(DeviceState *dev, DeviceInfo *info);
85 typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
93 /* Private to qdev / bus. */
96 struct DeviceInfo *next;
99 void qdev_register(DeviceInfo *info);
101 /* Register device properties. */
102 /* GPIO inputs also double as IRQ sinks. */
103 void qdev_init_gpio_in(DeviceState *dev, qemu_irq_handler handler, int n);
104 void qdev_init_gpio_out(DeviceState *dev, qemu_irq *pins, int n);
106 void scsi_bus_new(DeviceState *host, SCSIAttachFn attach);
108 CharDriverState *qdev_init_chardev(DeviceState *dev);
110 BusState *qdev_get_parent_bus(DeviceState *dev);
112 /* Convery from a base type to a parent type, with compile time checking. */
114 #define DO_UPCAST(type, field, dev) ( __extension__ ( { \
115 char __attribute__((unused)) offset_must_be_zero[ \
116 -offsetof(type, field)]; \
117 container_of(dev, type, field);}))
119 #define DO_UPCAST(type, field, dev) container_of(dev, type, field)
124 BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name);
126 #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
128 /*** monitor commands ***/
130 void do_info_qtree(Monitor *mon);
132 /*** qdev-properties.c ***/
134 extern PropertyInfo qdev_prop_uint16;
135 extern PropertyInfo qdev_prop_uint32;
136 extern PropertyInfo qdev_prop_hex32;
137 extern PropertyInfo qdev_prop_ptr;
138 extern PropertyInfo qdev_prop_macaddr;
140 /* Set properties between creation and init. */
141 void *qdev_get_prop_ptr(DeviceState *dev, Property *prop);
142 int qdev_prop_parse(DeviceState *dev, const char *name, const char *value);
143 void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type);
144 void qdev_prop_set_uint16(DeviceState *dev, const char *name, uint16_t value);
145 void qdev_prop_set_uint32(DeviceState *dev, const char *name, uint32_t value);
146 /* FIXME: Remove opaque pointer properties. */
147 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
148 void qdev_prop_set_defaults(DeviceState *dev, Property *props);