summaryrefslogtreecommitdiffstats
path: root/include/hw
diff options
context:
space:
mode:
Diffstat (limited to 'include/hw')
-rw-r--r--include/hw/qdev-properties.h10
-rw-r--r--include/hw/stream.h36
-rw-r--r--include/hw/xilinx.h21
3 files changed, 54 insertions, 13 deletions
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index a37933998a..25dd1bb39a 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -6,6 +6,7 @@
/*** qdev-properties.c ***/
extern PropertyInfo qdev_prop_bit;
+extern PropertyInfo qdev_prop_bool;
extern PropertyInfo qdev_prop_uint8;
extern PropertyInfo qdev_prop_uint16;
extern PropertyInfo qdev_prop_uint32;
@@ -52,6 +53,15 @@ extern PropertyInfo qdev_prop_arraylen;
.defval = (bool)_defval, \
}
+#define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \
+ .name = (_name), \
+ .info = &(qdev_prop_bool), \
+ .offset = offsetof(_state, _field) \
+ + type_check(bool, typeof_field(_state, _field)), \
+ .qtype = QTYPE_QBOOL, \
+ .defval = (bool)_defval, \
+ }
+
#define PROP_ARRAY_LEN_PREFIX "len-"
/**
diff --git a/include/hw/stream.h b/include/hw/stream.h
index f6137d6e25..35eb083a7f 100644
--- a/include/hw/stream.h
+++ b/include/hw/stream.h
@@ -18,14 +18,40 @@ typedef struct StreamSlave {
Object Parent;
} StreamSlave;
+typedef void (*StreamCanPushNotifyFn)(void *opaque);
+
typedef struct StreamSlaveClass {
InterfaceClass parent;
-
- void (*push)(StreamSlave *obj, unsigned char *buf, size_t len,
- uint32_t *app);
+ /**
+ * can push - determine if a stream slave is capable of accepting at least
+ * one byte of data. Returns false if cannot accept. If not implemented, the
+ * slave is assumed to always be capable of recieveing.
+ * @notify: Optional callback that the slave will call when the slave is
+ * capable of recieving again. Only called if false is returned.
+ * @notify_opaque: opaque data to pass to notify call.
+ */
+ bool (*can_push)(StreamSlave *obj, StreamCanPushNotifyFn notify,
+ void *notify_opaque);
+ /**
+ * push - push data to a Stream slave. The number of bytes pushed is
+ * returned. If the slave short returns, the master must wait before trying
+ * again, the slave may continue to just return 0 waiting for the vm time to
+ * advance. The can_push() function can be used to trap the point in time
+ * where the slave is ready to recieve again, otherwise polling on a QEMU
+ * timer will work.
+ * @obj: Stream slave to push to
+ * @buf: Data to write
+ * @len: Maximum number of bytes to write
+ */
+ size_t (*push)(StreamSlave *obj, unsigned char *buf, size_t len);
} StreamSlaveClass;
-void
-stream_push(StreamSlave *sink, uint8_t *buf, size_t len, uint32_t *app);
+size_t
+stream_push(StreamSlave *sink, uint8_t *buf, size_t len);
+
+bool
+stream_can_push(StreamSlave *sink, StreamCanPushNotifyFn notify,
+ void *notify_opaque);
+
#endif /* STREAM_H */
diff --git a/include/hw/xilinx.h b/include/hw/xilinx.h
index 6c1ee21c54..0c0251a2e9 100644
--- a/include/hw/xilinx.h
+++ b/include/hw/xilinx.h
@@ -55,16 +55,19 @@ xilinx_ethlite_create(NICInfo *nd, hwaddr base, qemu_irq irq,
}
static inline void
-xilinx_axiethernet_init(DeviceState *dev, NICInfo *nd, StreamSlave *peer,
- hwaddr base, qemu_irq irq, int txmem, int rxmem)
+xilinx_axiethernet_init(DeviceState *dev, NICInfo *nd, StreamSlave *ds,
+ StreamSlave *cs, hwaddr base, qemu_irq irq, int txmem,
+ int rxmem)
{
Error *errp = NULL;
qdev_set_nic_properties(dev, nd);
qdev_prop_set_uint32(dev, "rxmem", rxmem);
qdev_prop_set_uint32(dev, "txmem", txmem);
- object_property_set_link(OBJECT(dev), OBJECT(peer), "axistream-connected",
- &errp);
+ object_property_set_link(OBJECT(dev), OBJECT(ds),
+ "axistream-connected", &errp);
+ object_property_set_link(OBJECT(dev), OBJECT(cs),
+ "axistream-control-connected", &errp);
assert_no_error(errp);
qdev_init_nofail(dev);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
@@ -72,14 +75,16 @@ xilinx_axiethernet_init(DeviceState *dev, NICInfo *nd, StreamSlave *peer,
}
static inline void
-xilinx_axidma_init(DeviceState *dev, StreamSlave *peer, hwaddr base,
- qemu_irq irq, qemu_irq irq2, int freqhz)
+xilinx_axidma_init(DeviceState *dev, StreamSlave *ds, StreamSlave *cs,
+ hwaddr base, qemu_irq irq, qemu_irq irq2, int freqhz)
{
Error *errp = NULL;
qdev_prop_set_uint32(dev, "freqhz", freqhz);
- object_property_set_link(OBJECT(dev), OBJECT(peer), "axistream-connected",
- &errp);
+ object_property_set_link(OBJECT(dev), OBJECT(ds),
+ "axistream-connected", &errp);
+ object_property_set_link(OBJECT(dev), OBJECT(cs),
+ "axistream-control-connected", &errp);
assert_no_error(errp);
qdev_init_nofail(dev);