-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuffered_file.h
62 lines (51 loc) · 1.66 KB
/
buffered_file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* QEMU buffered QEMUFile
*
* Copyright IBM, Corp. 2008
*
* Authors:
* Anthony Liguori <[email protected]>
*
* This work is licensed under the terms of the GNU GPL, version 2. See
* the COPYING file in the top-level directory.
*
*/
#ifndef QEMU_BUFFERED_FILE_H
#define QEMU_BUFFERED_FILE_H
#include "hw/hw.h"
struct QEMUBuffer {
uint8_t *buffer;
size_t buffer_size;
size_t buffer_capacity;
bool freeze_output;
};
typedef struct QEMUBuffer QEMUBuffer;
struct QEMUFileBuf {
QEMUFile *file;
QEMUBuffer buf;
};
typedef struct QEMUFileBuf QEMUFileBuf;
QEMUFileBuf *qemu_fopen_buf_write(void);
/* This get the ownership of buf. */
QEMUFile *qemu_fopen_buf_read(uint8_t *buf, size_t size);
struct QEMUFileNonblock {
int fd;
QEMUFile *file;
QEMUBuffer buf;
};
typedef struct QEMUFileNonblock QEMUFileNonblock;
QEMUFileNonblock *qemu_fopen_nonblock(int fd);
int nonblock_pending_size(QEMUFileNonblock *s);
void nonblock_fflush(QEMUFileNonblock *s);
void nonblock_wait_for_flush(QEMUFileNonblock *s);
typedef ssize_t (BufferedPutFunc)(void *opaque, const void *data, size_t size);
typedef void (BufferedPutReadyFunc)(void *opaque);
typedef void (BufferedWaitForUnfreezeFunc)(void *opaque);
typedef int (BufferedCloseFunc)(void *opaque);
QEMUFile *qemu_fopen_ops_buffered(void *opaque, size_t xfer_limit,
BufferedPutFunc *put_buffer,
BufferedPutReadyFunc *put_ready,
BufferedWaitForUnfreezeFunc *wait_for_unfreeze,
BufferedCloseFunc *close);
void qemu_buffered_file_drain_buffer(void *buffered_file);
#endif