4 #include "qom/object.h"
6 /* stream slave. Used until qdev provides a generic way. */
7 #define TYPE_STREAM_SLAVE "stream-slave"
9 typedef struct StreamSlaveClass StreamSlaveClass
;
10 DECLARE_CLASS_CHECKERS(StreamSlaveClass
, STREAM_SLAVE
,
12 #define STREAM_SLAVE(obj) \
13 INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
15 typedef struct StreamSlave StreamSlave
;
17 typedef void (*StreamCanPushNotifyFn
)(void *opaque
);
19 struct StreamSlaveClass
{
20 InterfaceClass parent
;
22 * can push - determine if a stream slave is capable of accepting at least
23 * one byte of data. Returns false if cannot accept. If not implemented, the
24 * slave is assumed to always be capable of receiving.
25 * @notify: Optional callback that the slave will call when the slave is
26 * capable of receiving again. Only called if false is returned.
27 * @notify_opaque: opaque data to pass to notify call.
29 bool (*can_push
)(StreamSlave
*obj
, StreamCanPushNotifyFn notify
,
32 * push - push data to a Stream slave. The number of bytes pushed is
33 * returned. If the slave short returns, the master must wait before trying
34 * again, the slave may continue to just return 0 waiting for the vm time to
35 * advance. The can_push() function can be used to trap the point in time
36 * where the slave is ready to receive again, otherwise polling on a QEMU
38 * @obj: Stream slave to push to
40 * @len: Maximum number of bytes to write
41 * @eop: End of packet flag
43 size_t (*push
)(StreamSlave
*obj
, unsigned char *buf
, size_t len
, bool eop
);
47 stream_push(StreamSlave
*sink
, uint8_t *buf
, size_t len
, bool eop
);
50 stream_can_push(StreamSlave
*sink
, StreamCanPushNotifyFn notify
,