root / qemu-common.h @ 9dd69d65
History | View | Annotate | Download (11.4 kB)
1 | faf07963 | pbrook | /* Common header file that is included by all of qemu. */
|
---|---|---|---|
2 | faf07963 | pbrook | #ifndef QEMU_COMMON_H
|
3 | faf07963 | pbrook | #define QEMU_COMMON_H
|
4 | faf07963 | pbrook | |
5 | 5c026320 | Luiz Capitulino | #include "compiler.h" |
6 | beb6f0de | Kevin Wolf | #include "config-host.h" |
7 | beb6f0de | Kevin Wolf | |
8 | 332ae28d | Paolo Bonzini | #if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__)
|
9 | 332ae28d | Paolo Bonzini | #define WORDS_ALIGNED
|
10 | 332ae28d | Paolo Bonzini | #endif
|
11 | 332ae28d | Paolo Bonzini | |
12 | 082b5557 | Blue Swirl | #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) |
13 | 24ebf5f3 | Paolo Bonzini | |
14 | 29e922b6 | Blue Swirl | typedef struct QEMUTimer QEMUTimer; |
15 | 29e922b6 | Blue Swirl | typedef struct QEMUFile QEMUFile; |
16 | 92a16d7a | Blue Swirl | typedef struct DeviceState DeviceState; |
17 | 29e922b6 | Blue Swirl | |
18 | 316378e4 | Jan Kiszka | struct Monitor;
|
19 | 316378e4 | Jan Kiszka | typedef struct Monitor Monitor; |
20 | 316378e4 | Jan Kiszka | |
21 | faf07963 | pbrook | /* we put basic includes here to avoid repeating them in device drivers */
|
22 | faf07963 | pbrook | #include <stdlib.h> |
23 | faf07963 | pbrook | #include <stdio.h> |
24 | faf07963 | pbrook | #include <stdarg.h> |
25 | 11165820 | Paul Brook | #include <stdbool.h> |
26 | faf07963 | pbrook | #include <string.h> |
27 | c8906845 | balrog | #include <strings.h> |
28 | faf07963 | pbrook | #include <inttypes.h> |
29 | faf07963 | pbrook | #include <limits.h> |
30 | faf07963 | pbrook | #include <time.h> |
31 | faf07963 | pbrook | #include <ctype.h> |
32 | faf07963 | pbrook | #include <errno.h> |
33 | faf07963 | pbrook | #include <unistd.h> |
34 | faf07963 | pbrook | #include <fcntl.h> |
35 | faf07963 | pbrook | #include <sys/stat.h> |
36 | dcfd0865 | Hervé Poussineau | #include <sys/time.h> |
37 | 55616505 | Paul Brook | #include <assert.h> |
38 | 86f69a92 | Alexandre Raymond | #include <signal.h> |
39 | 14015304 | Anthony Liguori | #include <glib.h> |
40 | faf07963 | pbrook | |
41 | 082b5557 | Blue Swirl | #ifdef _WIN32
|
42 | 082b5557 | Blue Swirl | #include "qemu-os-win32.h" |
43 | 082b5557 | Blue Swirl | #endif
|
44 | 082b5557 | Blue Swirl | |
45 | 082b5557 | Blue Swirl | #ifdef CONFIG_POSIX
|
46 | 082b5557 | Blue Swirl | #include "qemu-os-posix.h" |
47 | 082b5557 | Blue Swirl | #endif
|
48 | 082b5557 | Blue Swirl | |
49 | faf07963 | pbrook | #ifndef O_LARGEFILE
|
50 | faf07963 | pbrook | #define O_LARGEFILE 0 |
51 | faf07963 | pbrook | #endif
|
52 | faf07963 | pbrook | #ifndef O_BINARY
|
53 | faf07963 | pbrook | #define O_BINARY 0 |
54 | faf07963 | pbrook | #endif
|
55 | 0e74e66b | Juan Quintela | #ifndef MAP_ANONYMOUS
|
56 | 0e74e66b | Juan Quintela | #define MAP_ANONYMOUS MAP_ANON
|
57 | 0e74e66b | Juan Quintela | #endif
|
58 | faf07963 | pbrook | #ifndef ENOMEDIUM
|
59 | faf07963 | pbrook | #define ENOMEDIUM ENODEV
|
60 | faf07963 | pbrook | #endif
|
61 | 4c955388 | Anthony Liguori | #if !defined(ENOTSUP)
|
62 | 2880bc32 | Juan Quintela | #define ENOTSUP 4096 |
63 | 2880bc32 | Juan Quintela | #endif
|
64 | 2084a8e3 | Paolo Bonzini | #if !defined(ECANCELED)
|
65 | 2084a8e3 | Paolo Bonzini | #define ECANCELED 4097 |
66 | 2084a8e3 | Paolo Bonzini | #endif
|
67 | 3c9405a0 | Gerd Hoffmann | #ifndef TIME_MAX
|
68 | 3c9405a0 | Gerd Hoffmann | #define TIME_MAX LONG_MAX
|
69 | 3c9405a0 | Gerd Hoffmann | #endif
|
70 | faf07963 | pbrook | |
71 | c0fd260e | Stefan Weil | /* HOST_LONG_BITS is the size of a native pointer in bits. */
|
72 | c0fd260e | Stefan Weil | #if UINTPTR_MAX == UINT32_MAX
|
73 | c0fd260e | Stefan Weil | # define HOST_LONG_BITS 32 |
74 | c0fd260e | Stefan Weil | #elif UINTPTR_MAX == UINT64_MAX
|
75 | c0fd260e | Stefan Weil | # define HOST_LONG_BITS 64 |
76 | c0fd260e | Stefan Weil | #else
|
77 | c0fd260e | Stefan Weil | # error Unknown pointer size
|
78 | c0fd260e | Stefan Weil | #endif
|
79 | c0fd260e | Stefan Weil | |
80 | 6114fdb0 | Juan Quintela | #ifndef CONFIG_IOVEC
|
81 | 6114fdb0 | Juan Quintela | #define CONFIG_IOVEC
|
82 | bf9298b9 | aliguori | struct iovec {
|
83 | bf9298b9 | aliguori | void *iov_base;
|
84 | bf9298b9 | aliguori | size_t iov_len; |
85 | bf9298b9 | aliguori | }; |
86 | e2a305fb | Christoph Hellwig | /*
|
87 | e2a305fb | Christoph Hellwig | * Use the same value as Linux for now.
|
88 | e2a305fb | Christoph Hellwig | */
|
89 | e2a305fb | Christoph Hellwig | #define IOV_MAX 1024 |
90 | 331dadde | blueswir1 | #else
|
91 | 331dadde | blueswir1 | #include <sys/uio.h> |
92 | bf9298b9 | aliguori | #endif
|
93 | bf9298b9 | aliguori | |
94 | f868445a | Stefan Weil | typedef int (*fprintf_function)(FILE *f, const char *fmt, ...) |
95 | f868445a | Stefan Weil | GCC_FMT_ATTR(2, 3); |
96 | f868445a | Stefan Weil | |
97 | faf07963 | pbrook | #ifdef _WIN32
|
98 | faf07963 | pbrook | #define fsync _commit
|
99 | 371c6489 | Stefan Weil | #if !defined(lseek)
|
100 | 371c6489 | Stefan Weil | # define lseek _lseeki64
|
101 | 371c6489 | Stefan Weil | #endif
|
102 | 64b85a8f | Blue Swirl | int qemu_ftruncate64(int, int64_t); |
103 | 371c6489 | Stefan Weil | #if !defined(ftruncate)
|
104 | 371c6489 | Stefan Weil | # define ftruncate qemu_ftruncate64
|
105 | 371c6489 | Stefan Weil | #endif
|
106 | faf07963 | pbrook | |
107 | faf07963 | pbrook | static inline char *realpath(const char *path, char *resolved_path) |
108 | faf07963 | pbrook | { |
109 | faf07963 | pbrook | _fullpath(resolved_path, path, _MAX_PATH); |
110 | faf07963 | pbrook | return resolved_path;
|
111 | faf07963 | pbrook | } |
112 | faf07963 | pbrook | #endif
|
113 | faf07963 | pbrook | |
114 | 946fb27c | Paolo Bonzini | /* icount */
|
115 | 946fb27c | Paolo Bonzini | void configure_icount(const char *option); |
116 | 946fb27c | Paolo Bonzini | extern int use_icount; |
117 | 946fb27c | Paolo Bonzini | |
118 | faf07963 | pbrook | /* FIXME: Remove NEED_CPU_H. */
|
119 | faf07963 | pbrook | #ifndef NEED_CPU_H
|
120 | faf07963 | pbrook | |
121 | faf07963 | pbrook | #include "osdep.h" |
122 | faf07963 | pbrook | #include "bswap.h" |
123 | faf07963 | pbrook | |
124 | faf07963 | pbrook | #else
|
125 | faf07963 | pbrook | |
126 | faf07963 | pbrook | #include "cpu.h" |
127 | faf07963 | pbrook | |
128 | faf07963 | pbrook | #endif /* !defined(NEED_CPU_H) */ |
129 | faf07963 | pbrook | |
130 | 3bbbee18 | Andreas Färber | /* main function, renamed */
|
131 | 3bbbee18 | Andreas Färber | #if defined(CONFIG_COCOA)
|
132 | 3bbbee18 | Andreas Färber | int qemu_main(int argc, char **argv, char **envp); |
133 | 3bbbee18 | Andreas Färber | #endif
|
134 | 3bbbee18 | Andreas Färber | |
135 | f6503059 | balrog | void qemu_get_timedate(struct tm *tm, int offset); |
136 | f6503059 | balrog | int qemu_timedate_diff(struct tm *tm); |
137 | f6503059 | balrog | |
138 | faf07963 | pbrook | /* cutils.c */
|
139 | faf07963 | pbrook | void pstrcpy(char *buf, int buf_size, const char *str); |
140 | faf07963 | pbrook | char *pstrcat(char *buf, int buf_size, const char *s); |
141 | faf07963 | pbrook | int strstart(const char *str, const char *val, const char **ptr); |
142 | faf07963 | pbrook | int stristart(const char *str, const char *val, const char **ptr); |
143 | d43277c5 | Blue Swirl | int qemu_strnlen(const char *s, int max_len); |
144 | faf07963 | pbrook | time_t mktimegm(struct tm *tm);
|
145 | ad46db9a | blueswir1 | int qemu_fls(int i); |
146 | 6f1953c4 | Christoph Hellwig | int qemu_fdatasync(int fd); |
147 | db1a4972 | Paolo Bonzini | int fcntl_setfl(int fd, int flag); |
148 | 443916d1 | Stefan Berger | int qemu_parse_fd(const char *param); |
149 | d8427002 | Jes Sorensen | |
150 | d7142456 | Jes Sorensen | /*
|
151 | d7142456 | Jes Sorensen | * strtosz() suffixes used to specify the default treatment of an
|
152 | d7142456 | Jes Sorensen | * argument passed to strtosz() without an explicit suffix.
|
153 | d7142456 | Jes Sorensen | * These should be defined using upper case characters in the range
|
154 | d7142456 | Jes Sorensen | * A-Z, as strtosz() will use qemu_toupper() on the given argument
|
155 | d7142456 | Jes Sorensen | * prior to comparison.
|
156 | d7142456 | Jes Sorensen | */
|
157 | d8427002 | Jes Sorensen | #define STRTOSZ_DEFSUFFIX_TB 'T' |
158 | d8427002 | Jes Sorensen | #define STRTOSZ_DEFSUFFIX_GB 'G' |
159 | d8427002 | Jes Sorensen | #define STRTOSZ_DEFSUFFIX_MB 'M' |
160 | d8427002 | Jes Sorensen | #define STRTOSZ_DEFSUFFIX_KB 'K' |
161 | d8427002 | Jes Sorensen | #define STRTOSZ_DEFSUFFIX_B 'B' |
162 | 70b4f4bb | Jes Sorensen | int64_t strtosz(const char *nptr, char **end); |
163 | 70b4f4bb | Jes Sorensen | int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix); |
164 | a732e1ba | Joerg Roedel | int64_t strtosz_suffix_unit(const char *nptr, char **end, |
165 | a732e1ba | Joerg Roedel | const char default_suffix, int64_t unit); |
166 | faf07963 | pbrook | |
167 | 37022086 | Blue Swirl | /* path.c */
|
168 | 37022086 | Blue Swirl | void init_paths(const char *prefix); |
169 | 37022086 | Blue Swirl | const char *path(const char *pathname); |
170 | 37022086 | Blue Swirl | |
171 | cd390083 | blueswir1 | #define qemu_isalnum(c) isalnum((unsigned char)(c)) |
172 | cd390083 | blueswir1 | #define qemu_isalpha(c) isalpha((unsigned char)(c)) |
173 | cd390083 | blueswir1 | #define qemu_iscntrl(c) iscntrl((unsigned char)(c)) |
174 | cd390083 | blueswir1 | #define qemu_isdigit(c) isdigit((unsigned char)(c)) |
175 | cd390083 | blueswir1 | #define qemu_isgraph(c) isgraph((unsigned char)(c)) |
176 | cd390083 | blueswir1 | #define qemu_islower(c) islower((unsigned char)(c)) |
177 | cd390083 | blueswir1 | #define qemu_isprint(c) isprint((unsigned char)(c)) |
178 | cd390083 | blueswir1 | #define qemu_ispunct(c) ispunct((unsigned char)(c)) |
179 | cd390083 | blueswir1 | #define qemu_isspace(c) isspace((unsigned char)(c)) |
180 | cd390083 | blueswir1 | #define qemu_isupper(c) isupper((unsigned char)(c)) |
181 | cd390083 | blueswir1 | #define qemu_isxdigit(c) isxdigit((unsigned char)(c)) |
182 | cd390083 | blueswir1 | #define qemu_tolower(c) tolower((unsigned char)(c)) |
183 | cd390083 | blueswir1 | #define qemu_toupper(c) toupper((unsigned char)(c)) |
184 | cd390083 | blueswir1 | #define qemu_isascii(c) isascii((unsigned char)(c)) |
185 | cd390083 | blueswir1 | #define qemu_toascii(c) toascii((unsigned char)(c)) |
186 | cd390083 | blueswir1 | |
187 | b152aa84 | Jes Sorensen | void *qemu_oom_check(void *ptr); |
188 | ca10f867 | aurel32 | |
189 | 40ff6d7e | Kevin Wolf | int qemu_open(const char *name, int flags, ...); |
190 | 7c7c0629 | Juan Quintela | ssize_t qemu_write_full(int fd, const void *buf, size_t count) |
191 | 7c7c0629 | Juan Quintela | QEMU_WARN_UNUSED_RESULT; |
192 | 993295fe | Paolo Bonzini | ssize_t qemu_send_full(int fd, const void *buf, size_t count, int flags) |
193 | 993295fe | Paolo Bonzini | QEMU_WARN_UNUSED_RESULT; |
194 | 8c5135f9 | Paolo Bonzini | ssize_t qemu_recv_full(int fd, void *buf, size_t count, int flags) |
195 | 993295fe | Paolo Bonzini | QEMU_WARN_UNUSED_RESULT; |
196 | 40ff6d7e | Kevin Wolf | |
197 | 40ff6d7e | Kevin Wolf | #ifndef _WIN32
|
198 | f3dfda61 | Paolo Bonzini | int qemu_eventfd(int pipefd[2]); |
199 | 40ff6d7e | Kevin Wolf | int qemu_pipe(int pipefd[2]); |
200 | 40ff6d7e | Kevin Wolf | #endif
|
201 | 40ff6d7e | Kevin Wolf | |
202 | 00aa0040 | Blue Swirl | #ifdef _WIN32
|
203 | 00aa0040 | Blue Swirl | #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags) |
204 | 00aa0040 | Blue Swirl | #else
|
205 | 00aa0040 | Blue Swirl | #define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
|
206 | 00aa0040 | Blue Swirl | #endif
|
207 | 00aa0040 | Blue Swirl | |
208 | 8c5135f9 | Paolo Bonzini | int qemu_recvv(int sockfd, struct iovec *iov, int len, int iov_offset); |
209 | 8c5135f9 | Paolo Bonzini | int qemu_sendv(int sockfd, struct iovec *iov, int len, int iov_offset); |
210 | 8c5135f9 | Paolo Bonzini | |
211 | 87ecb68b | pbrook | /* Error handling. */
|
212 | 87ecb68b | pbrook | |
213 | e5924d89 | Stefan Weil | void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2); |
214 | 87ecb68b | pbrook | |
215 | 87ecb68b | pbrook | struct ParallelIOArg {
|
216 | 87ecb68b | pbrook | void *buffer;
|
217 | 87ecb68b | pbrook | int count;
|
218 | 87ecb68b | pbrook | }; |
219 | 87ecb68b | pbrook | |
220 | 87ecb68b | pbrook | typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); |
221 | 87ecb68b | pbrook | |
222 | 87ecb68b | pbrook | /* A load of opaque types so that device init declarations don't have to
|
223 | 87ecb68b | pbrook | pull in all the real definitions. */
|
224 | 87ecb68b | pbrook | typedef struct NICInfo NICInfo; |
225 | 1ae26a18 | balrog | typedef struct HCIInfo HCIInfo; |
226 | 87ecb68b | pbrook | typedef struct AudioState AudioState; |
227 | 87ecb68b | pbrook | typedef struct BlockDriverState BlockDriverState; |
228 | 2446333c | Blue Swirl | typedef struct DriveInfo DriveInfo; |
229 | 87ecb68b | pbrook | typedef struct DisplayState DisplayState; |
230 | 7d957bd8 | aliguori | typedef struct DisplayChangeListener DisplayChangeListener; |
231 | 7d957bd8 | aliguori | typedef struct DisplaySurface DisplaySurface; |
232 | 7b5d76da | aliguori | typedef struct DisplayAllocator DisplayAllocator; |
233 | 7d957bd8 | aliguori | typedef struct PixelFormat PixelFormat; |
234 | 87ecb68b | pbrook | typedef struct TextConsole TextConsole; |
235 | c60e08d9 | pbrook | typedef TextConsole QEMUConsole;
|
236 | 87ecb68b | pbrook | typedef struct CharDriverState CharDriverState; |
237 | 76d32cba | Gerd Hoffmann | typedef struct MACAddr MACAddr; |
238 | 87ecb68b | pbrook | typedef struct VLANState VLANState; |
239 | f7105843 | Mark McLoughlin | typedef struct VLANClientState VLANClientState; |
240 | 87ecb68b | pbrook | typedef struct i2c_bus i2c_bus; |
241 | 48a18b3c | Hervé Poussineau | typedef struct ISABus ISABus; |
242 | dfc65f1f | Markus Armbruster | typedef struct ISADevice ISADevice; |
243 | 87ecb68b | pbrook | typedef struct SMBusDevice SMBusDevice; |
244 | fb47a2e9 | Isaku Yamahata | typedef struct PCIHostState PCIHostState; |
245 | fb47a2e9 | Isaku Yamahata | typedef struct PCIExpressHost PCIExpressHost; |
246 | 87ecb68b | pbrook | typedef struct PCIBus PCIBus; |
247 | 87ecb68b | pbrook | typedef struct PCIDevice PCIDevice; |
248 | 0428527c | Isaku Yamahata | typedef struct PCIExpressDevice PCIExpressDevice; |
249 | 68f79994 | Isaku Yamahata | typedef struct PCIBridge PCIBridge; |
250 | 34e65944 | Isaku Yamahata | typedef struct PCIEAERMsg PCIEAERMsg; |
251 | 34e65944 | Isaku Yamahata | typedef struct PCIEAERLog PCIEAERLog; |
252 | 34e65944 | Isaku Yamahata | typedef struct PCIEAERErr PCIEAERErr; |
253 | bc20ba98 | Isaku Yamahata | typedef struct PCIEPort PCIEPort; |
254 | bc20ba98 | Isaku Yamahata | typedef struct PCIESlot PCIESlot; |
255 | 14de9bab | Jan Kiszka | typedef struct MSIMessage MSIMessage; |
256 | 87ecb68b | pbrook | typedef struct SerialState SerialState; |
257 | 87ecb68b | pbrook | typedef struct IRQState *qemu_irq; |
258 | bc24a225 | Paul Brook | typedef struct PCMCIACardState PCMCIACardState; |
259 | bc24a225 | Paul Brook | typedef struct MouseTransformInfo MouseTransformInfo; |
260 | bc24a225 | Paul Brook | typedef struct uWireSlave uWireSlave; |
261 | bc24a225 | Paul Brook | typedef struct I2SCodec I2SCodec; |
262 | 90d37239 | Paul Brook | typedef struct SSIBus SSIBus; |
263 | 2292b339 | Michael S. Tsirkin | typedef struct EventNotifier EventNotifier; |
264 | 2be24aaa | Michael S. Tsirkin | typedef struct VirtIODevice VirtIODevice; |
265 | d35bf9ad | Gerd Hoffmann | typedef struct QEMUSGList QEMUSGList; |
266 | 1dc324d2 | Michael S. Tsirkin | typedef struct SHPCDevice SHPCDevice; |
267 | 87ecb68b | pbrook | |
268 | 186993ee | Michael S. Tsirkin | typedef uint64_t pcibus_t;
|
269 | 186993ee | Michael S. Tsirkin | |
270 | 4e4fa398 | Jan Kiszka | typedef enum LostTickPolicy { |
271 | 4e4fa398 | Jan Kiszka | LOST_TICK_DISCARD, |
272 | 4e4fa398 | Jan Kiszka | LOST_TICK_DELAY, |
273 | 4e4fa398 | Jan Kiszka | LOST_TICK_MERGE, |
274 | 4e4fa398 | Jan Kiszka | LOST_TICK_SLEW, |
275 | 1ce05125 | Paolo Bonzini | LOST_TICK_MAX |
276 | 4e4fa398 | Jan Kiszka | } LostTickPolicy; |
277 | 4e4fa398 | Jan Kiszka | |
278 | 679042f0 | Anthony PERARD | typedef struct PCIHostDeviceAddress { |
279 | 679042f0 | Anthony PERARD | unsigned int domain; |
280 | 679042f0 | Anthony PERARD | unsigned int bus; |
281 | 679042f0 | Anthony PERARD | unsigned int slot; |
282 | 679042f0 | Anthony PERARD | unsigned int function; |
283 | 679042f0 | Anthony PERARD | } PCIHostDeviceAddress; |
284 | 679042f0 | Anthony PERARD | |
285 | d5ab9713 | Jan Kiszka | void tcg_exec_init(unsigned long tb_size); |
286 | d5ab9713 | Jan Kiszka | bool tcg_enabled(void); |
287 | d5ab9713 | Jan Kiszka | |
288 | d5ab9713 | Jan Kiszka | void cpu_exec_init_all(void); |
289 | d2053c3c | Blue Swirl | |
290 | b3c7724c | pbrook | /* CPU save/load. */
|
291 | b3c7724c | pbrook | void cpu_save(QEMUFile *f, void *opaque); |
292 | b3c7724c | pbrook | int cpu_load(QEMUFile *f, void *opaque, int version_id); |
293 | b3c7724c | pbrook | |
294 | 8edac960 | aliguori | /* Unblock cpu */
|
295 | 8edac960 | aliguori | void qemu_cpu_kick(void *env); |
296 | 46d62fac | Jan Kiszka | void qemu_cpu_kick_self(void); |
297 | b7680cb6 | Jan Kiszka | int qemu_cpu_is_self(void *env); |
298 | ab33fcda | Paolo Bonzini | bool all_cpu_threads_idle(void); |
299 | 8edac960 | aliguori | |
300 | e82bcec2 | Marcelo Tosatti | /* work queue */
|
301 | e82bcec2 | Marcelo Tosatti | struct qemu_work_item {
|
302 | e82bcec2 | Marcelo Tosatti | struct qemu_work_item *next;
|
303 | e82bcec2 | Marcelo Tosatti | void (*func)(void *data); |
304 | e82bcec2 | Marcelo Tosatti | void *data;
|
305 | e82bcec2 | Marcelo Tosatti | int done;
|
306 | e82bcec2 | Marcelo Tosatti | }; |
307 | e82bcec2 | Marcelo Tosatti | |
308 | 0bf46a40 | aliguori | #ifdef CONFIG_USER_ONLY
|
309 | 0bf46a40 | aliguori | #define qemu_init_vcpu(env) do { } while (0) |
310 | 0bf46a40 | aliguori | #else
|
311 | 0bf46a40 | aliguori | void qemu_init_vcpu(void *env); |
312 | 0bf46a40 | aliguori | #endif
|
313 | 0bf46a40 | aliguori | |
314 | 8c5135f9 | Paolo Bonzini | /**
|
315 | 8c5135f9 | Paolo Bonzini | * Sends an iovec (or optionally a part of it) down a socket, yielding
|
316 | 8c5135f9 | Paolo Bonzini | * when the socket is full.
|
317 | 8c5135f9 | Paolo Bonzini | */
|
318 | 8c5135f9 | Paolo Bonzini | int qemu_co_sendv(int sockfd, struct iovec *iov, |
319 | 8c5135f9 | Paolo Bonzini | int len, int iov_offset); |
320 | 8c5135f9 | Paolo Bonzini | |
321 | 8c5135f9 | Paolo Bonzini | /**
|
322 | 8c5135f9 | Paolo Bonzini | * Receives data into an iovec (or optionally into a part of it) from
|
323 | 8c5135f9 | Paolo Bonzini | * a socket, yielding when there is no data in the socket.
|
324 | 8c5135f9 | Paolo Bonzini | */
|
325 | 8c5135f9 | Paolo Bonzini | int qemu_co_recvv(int sockfd, struct iovec *iov, |
326 | 8c5135f9 | Paolo Bonzini | int len, int iov_offset); |
327 | 8c5135f9 | Paolo Bonzini | |
328 | 8c5135f9 | Paolo Bonzini | |
329 | 8c5135f9 | Paolo Bonzini | /**
|
330 | 8c5135f9 | Paolo Bonzini | * Sends a buffer down a socket, yielding when the socket is full.
|
331 | 8c5135f9 | Paolo Bonzini | */
|
332 | 8c5135f9 | Paolo Bonzini | int qemu_co_send(int sockfd, void *buf, int len); |
333 | 8c5135f9 | Paolo Bonzini | |
334 | 8c5135f9 | Paolo Bonzini | /**
|
335 | 8c5135f9 | Paolo Bonzini | * Receives data into a buffer from a socket, yielding when there
|
336 | 8c5135f9 | Paolo Bonzini | * is no data in the socket.
|
337 | 8c5135f9 | Paolo Bonzini | */
|
338 | 8c5135f9 | Paolo Bonzini | int qemu_co_recv(int sockfd, void *buf, int len); |
339 | 8c5135f9 | Paolo Bonzini | |
340 | 8c5135f9 | Paolo Bonzini | |
341 | 44e3ee8a | aliguori | typedef struct QEMUIOVector { |
342 | 44e3ee8a | aliguori | struct iovec *iov;
|
343 | 44e3ee8a | aliguori | int niov;
|
344 | 44e3ee8a | aliguori | int nalloc;
|
345 | 249aa745 | aliguori | size_t size; |
346 | 44e3ee8a | aliguori | } QEMUIOVector; |
347 | 44e3ee8a | aliguori | |
348 | 44e3ee8a | aliguori | void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); |
349 | 522584a5 | aliguori | void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov); |
350 | 44e3ee8a | aliguori | void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); |
351 | b8a83a4f | Kevin Wolf | void qemu_iovec_copy(QEMUIOVector *dst, QEMUIOVector *src, uint64_t skip,
|
352 | b8a83a4f | Kevin Wolf | size_t size); |
353 | 40b4f539 | Kevin Wolf | void qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t size);
|
354 | 44e3ee8a | aliguori | void qemu_iovec_destroy(QEMUIOVector *qiov);
|
355 | be959463 | aliguori | void qemu_iovec_reset(QEMUIOVector *qiov);
|
356 | 44e3ee8a | aliguori | void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf); |
357 | 249aa745 | aliguori | void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count); |
358 | b8a83a4f | Kevin Wolf | void qemu_iovec_memset(QEMUIOVector *qiov, int c, size_t count); |
359 | e0d9c6f9 | Chunqiang Tang | void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count, |
360 | e0d9c6f9 | Chunqiang Tang | size_t skip); |
361 | 44e3ee8a | aliguori | |
362 | 1a6d39fd | Stefan Hajnoczi | bool buffer_is_zero(const void *buf, size_t len); |
363 | 1a6d39fd | Stefan Hajnoczi | |
364 | 6b837bc4 | Jes Sorensen | void qemu_progress_init(int enabled, float min_skip); |
365 | 6b837bc4 | Jes Sorensen | void qemu_progress_end(void); |
366 | 3bfe4dbf | Jes Sorensen | void qemu_progress_print(float delta, int max); |
367 | 6b837bc4 | Jes Sorensen | |
368 | 082b5557 | Blue Swirl | #define QEMU_FILE_TYPE_BIOS 0 |
369 | 082b5557 | Blue Swirl | #define QEMU_FILE_TYPE_KEYMAP 1 |
370 | 082b5557 | Blue Swirl | char *qemu_find_file(int type, const char *name); |
371 | 082b5557 | Blue Swirl | |
372 | 082b5557 | Blue Swirl | /* OS specific functions */
|
373 | 082b5557 | Blue Swirl | void os_setup_early_signal_handling(void); |
374 | 082b5557 | Blue Swirl | char *os_find_datadir(const char *argv0); |
375 | 082b5557 | Blue Swirl | void os_parse_cmd_args(int index, const char *optarg); |
376 | 082b5557 | Blue Swirl | void os_pidfile_error(void); |
377 | 082b5557 | Blue Swirl | |
378 | abd0c6bd | Paul Brook | /* Convert a byte between binary and BCD. */
|
379 | abd0c6bd | Paul Brook | static inline uint8_t to_bcd(uint8_t val) |
380 | abd0c6bd | Paul Brook | { |
381 | abd0c6bd | Paul Brook | return ((val / 10) << 4) | (val % 10); |
382 | abd0c6bd | Paul Brook | } |
383 | abd0c6bd | Paul Brook | |
384 | abd0c6bd | Paul Brook | static inline uint8_t from_bcd(uint8_t val) |
385 | abd0c6bd | Paul Brook | { |
386 | abd0c6bd | Paul Brook | return ((val >> 4) * 10) + (val & 0x0f); |
387 | abd0c6bd | Paul Brook | } |
388 | abd0c6bd | Paul Brook | |
389 | 338b922e | malc | /* compute with 96 bit intermediate result: (a*b)/c */
|
390 | 338b922e | malc | static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) |
391 | 338b922e | malc | { |
392 | 338b922e | malc | union {
|
393 | 338b922e | malc | uint64_t ll; |
394 | 338b922e | malc | struct {
|
395 | 338b922e | malc | #ifdef HOST_WORDS_BIGENDIAN
|
396 | 338b922e | malc | uint32_t high, low; |
397 | 338b922e | malc | #else
|
398 | 338b922e | malc | uint32_t low, high; |
399 | 338b922e | malc | #endif
|
400 | 338b922e | malc | } l; |
401 | 338b922e | malc | } u, res; |
402 | 338b922e | malc | uint64_t rl, rh; |
403 | 338b922e | malc | |
404 | 338b922e | malc | u.ll = a; |
405 | 338b922e | malc | rl = (uint64_t)u.l.low * (uint64_t)b; |
406 | 338b922e | malc | rh = (uint64_t)u.l.high * (uint64_t)b; |
407 | 338b922e | malc | rh += (rl >> 32);
|
408 | 338b922e | malc | res.l.high = rh / c; |
409 | 338b922e | malc | res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c; |
410 | 338b922e | malc | return res.ll;
|
411 | 338b922e | malc | } |
412 | 338b922e | malc | |
413 | 3951690a | Stefan Hajnoczi | /* Round number down to multiple */
|
414 | 3951690a | Stefan Hajnoczi | #define QEMU_ALIGN_DOWN(n, m) ((n) / (m) * (m))
|
415 | 3951690a | Stefan Hajnoczi | |
416 | 3951690a | Stefan Hajnoczi | /* Round number up to multiple */
|
417 | 3951690a | Stefan Hajnoczi | #define QEMU_ALIGN_UP(n, m) QEMU_ALIGN_DOWN((n) + (m) - 1, (m)) |
418 | 3951690a | Stefan Hajnoczi | |
419 | 0bfe3ca5 | Anthony Liguori | #include "module.h" |
420 | 0bfe3ca5 | Anthony Liguori | |
421 | faf07963 | pbrook | #endif |