2012-08-10 07:16:11 +04:00
|
|
|
#ifndef STREAM_H
|
2016-06-29 16:29:06 +03:00
|
|
|
#define STREAM_H
|
2012-08-10 07:16:11 +04:00
|
|
|
|
|
|
|
#include "qemu-common.h"
|
2012-12-17 21:19:50 +04:00
|
|
|
#include "qom/object.h"
|
2012-08-10 07:16:11 +04:00
|
|
|
|
|
|
|
/* stream slave. Used until qdev provides a generic way. */
|
|
|
|
#define TYPE_STREAM_SLAVE "stream-slave"
|
|
|
|
|
|
|
|
#define STREAM_SLAVE_CLASS(klass) \
|
|
|
|
OBJECT_CLASS_CHECK(StreamSlaveClass, (klass), TYPE_STREAM_SLAVE)
|
|
|
|
#define STREAM_SLAVE_GET_CLASS(obj) \
|
|
|
|
OBJECT_GET_CLASS(StreamSlaveClass, (obj), TYPE_STREAM_SLAVE)
|
|
|
|
#define STREAM_SLAVE(obj) \
|
|
|
|
INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
|
|
|
|
|
2018-12-04 17:20:06 +03:00
|
|
|
typedef struct StreamSlave StreamSlave;
|
2012-08-10 07:16:11 +04:00
|
|
|
|
2013-04-16 04:27:16 +04:00
|
|
|
typedef void (*StreamCanPushNotifyFn)(void *opaque);
|
|
|
|
|
2012-08-10 07:16:11 +04:00
|
|
|
typedef struct StreamSlaveClass {
|
|
|
|
InterfaceClass parent;
|
2013-04-16 04:27:16 +04:00
|
|
|
/**
|
|
|
|
* 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
|
2013-04-28 13:49:57 +04:00
|
|
|
* slave is assumed to always be capable of receiving.
|
2013-04-16 04:27:16 +04:00
|
|
|
* @notify: Optional callback that the slave will call when the slave is
|
2013-04-28 13:49:57 +04:00
|
|
|
* capable of receiving again. Only called if false is returned.
|
2013-04-16 04:27:16 +04:00
|
|
|
* @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
|
2013-04-28 13:49:57 +04:00
|
|
|
* where the slave is ready to receive again, otherwise polling on a QEMU
|
2013-04-16 04:27:16 +04:00
|
|
|
* timer will work.
|
|
|
|
* @obj: Stream slave to push to
|
|
|
|
* @buf: Data to write
|
|
|
|
* @len: Maximum number of bytes to write
|
|
|
|
*/
|
2013-04-16 04:28:35 +04:00
|
|
|
size_t (*push)(StreamSlave *obj, unsigned char *buf, size_t len);
|
2012-08-10 07:16:11 +04:00
|
|
|
} StreamSlaveClass;
|
|
|
|
|
2013-04-16 04:27:16 +04:00
|
|
|
size_t
|
2013-04-16 04:28:35 +04:00
|
|
|
stream_push(StreamSlave *sink, uint8_t *buf, size_t len);
|
2012-08-10 07:16:11 +04:00
|
|
|
|
2013-04-16 04:27:16 +04:00
|
|
|
bool
|
|
|
|
stream_can_push(StreamSlave *sink, StreamCanPushNotifyFn notify,
|
|
|
|
void *notify_opaque);
|
|
|
|
|
|
|
|
|
2012-08-10 07:16:11 +04:00
|
|
|
#endif /* STREAM_H */
|