Statistics
| Branch: | Revision:

root / qemu-common.h @ a74cdab4

History | View | Annotate | Download (11.2 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 beb6f0de Kevin Wolf
#include "config-host.h"
6 beb6f0de Kevin Wolf
7 a5e50b26 malc
#define QEMU_NORETURN __attribute__ ((__noreturn__))
8 747bbdf7 Blue Swirl
#ifdef CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT
9 747bbdf7 Blue Swirl
#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
10 747bbdf7 Blue Swirl
#else
11 747bbdf7 Blue Swirl
#define QEMU_WARN_UNUSED_RESULT
12 747bbdf7 Blue Swirl
#endif
13 7d99a001 blueswir1
14 24ebf5f3 Paolo Bonzini
#define QEMU_BUILD_BUG_ON(x) typedef char __build_bug_on__##__LINE__[(x)?-1:1];
15 082b5557 Blue Swirl
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
16 24ebf5f3 Paolo Bonzini
17 29e922b6 Blue Swirl
typedef struct QEMUTimer QEMUTimer;
18 29e922b6 Blue Swirl
typedef struct QEMUFile QEMUFile;
19 29e922b6 Blue Swirl
typedef struct QEMUBH QEMUBH;
20 92a16d7a Blue Swirl
typedef struct DeviceState DeviceState;
21 29e922b6 Blue Swirl
22 316378e4 Jan Kiszka
struct Monitor;
23 316378e4 Jan Kiszka
typedef struct Monitor Monitor;
24 316378e4 Jan Kiszka
25 faf07963 pbrook
/* we put basic includes here to avoid repeating them in device drivers */
26 faf07963 pbrook
#include <stdlib.h>
27 faf07963 pbrook
#include <stdio.h>
28 faf07963 pbrook
#include <stdarg.h>
29 11165820 Paul Brook
#include <stdbool.h>
30 faf07963 pbrook
#include <string.h>
31 c8906845 balrog
#include <strings.h>
32 faf07963 pbrook
#include <inttypes.h>
33 faf07963 pbrook
#include <limits.h>
34 faf07963 pbrook
#include <time.h>
35 faf07963 pbrook
#include <ctype.h>
36 faf07963 pbrook
#include <errno.h>
37 faf07963 pbrook
#include <unistd.h>
38 faf07963 pbrook
#include <fcntl.h>
39 faf07963 pbrook
#include <sys/stat.h>
40 dcfd0865 Hervé Poussineau
#include <sys/time.h>
41 55616505 Paul Brook
#include <assert.h>
42 faf07963 pbrook
43 082b5557 Blue Swirl
#ifdef _WIN32
44 082b5557 Blue Swirl
#include "qemu-os-win32.h"
45 082b5557 Blue Swirl
#endif
46 082b5557 Blue Swirl
47 082b5557 Blue Swirl
#ifdef CONFIG_POSIX
48 082b5557 Blue Swirl
#include "qemu-os-posix.h"
49 082b5557 Blue Swirl
#endif
50 082b5557 Blue Swirl
51 faf07963 pbrook
#ifndef O_LARGEFILE
52 faf07963 pbrook
#define O_LARGEFILE 0
53 faf07963 pbrook
#endif
54 faf07963 pbrook
#ifndef O_BINARY
55 faf07963 pbrook
#define O_BINARY 0
56 faf07963 pbrook
#endif
57 0e74e66b Juan Quintela
#ifndef MAP_ANONYMOUS
58 0e74e66b Juan Quintela
#define MAP_ANONYMOUS MAP_ANON
59 0e74e66b Juan Quintela
#endif
60 faf07963 pbrook
#ifndef ENOMEDIUM
61 faf07963 pbrook
#define ENOMEDIUM ENODEV
62 faf07963 pbrook
#endif
63 4c955388 Anthony Liguori
#if !defined(ENOTSUP)
64 2880bc32 Juan Quintela
#define ENOTSUP 4096
65 2880bc32 Juan Quintela
#endif
66 3c9405a0 Gerd Hoffmann
#ifndef TIME_MAX
67 3c9405a0 Gerd Hoffmann
#define TIME_MAX LONG_MAX
68 3c9405a0 Gerd Hoffmann
#endif
69 faf07963 pbrook
70 6114fdb0 Juan Quintela
#ifndef CONFIG_IOVEC
71 6114fdb0 Juan Quintela
#define CONFIG_IOVEC
72 bf9298b9 aliguori
struct iovec {
73 bf9298b9 aliguori
    void *iov_base;
74 bf9298b9 aliguori
    size_t iov_len;
75 bf9298b9 aliguori
};
76 e2a305fb Christoph Hellwig
/*
77 e2a305fb Christoph Hellwig
 * Use the same value as Linux for now.
78 e2a305fb Christoph Hellwig
 */
79 e2a305fb Christoph Hellwig
#define IOV_MAX                1024
80 331dadde blueswir1
#else
81 331dadde blueswir1
#include <sys/uio.h>
82 bf9298b9 aliguori
#endif
83 bf9298b9 aliguori
84 9c9e7d51 Stefan Weil
#if defined __GNUC__
85 9c9e7d51 Stefan Weil
# if (__GNUC__ < 4) || \
86 9c9e7d51 Stefan Weil
     defined(__GNUC_MINOR__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 4)
87 9c9e7d51 Stefan Weil
   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
88 9c9e7d51 Stefan Weil
#  define GCC_ATTR __attribute__((__unused__, format(printf, 1, 2)))
89 9c9e7d51 Stefan Weil
#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
90 9c9e7d51 Stefan Weil
# else
91 9c9e7d51 Stefan Weil
   /* Use gnu_printf when supported (qemu uses standard format strings). */
92 9c9e7d51 Stefan Weil
#  define GCC_ATTR __attribute__((__unused__, format(gnu_printf, 1, 2)))
93 9c9e7d51 Stefan Weil
#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
94 9c9e7d51 Stefan Weil
# endif
95 9c9e7d51 Stefan Weil
#else
96 9c9e7d51 Stefan Weil
#define GCC_ATTR /**/
97 9c9e7d51 Stefan Weil
#define GCC_FMT_ATTR(n, m)
98 9c9e7d51 Stefan Weil
#endif
99 9c9e7d51 Stefan Weil
100 f868445a Stefan Weil
typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
101 f868445a Stefan Weil
    GCC_FMT_ATTR(2, 3);
102 f868445a Stefan Weil
103 faf07963 pbrook
#ifdef _WIN32
104 faf07963 pbrook
#define fsync _commit
105 faf07963 pbrook
#define lseek _lseeki64
106 64b85a8f Blue Swirl
int qemu_ftruncate64(int, int64_t);
107 faf07963 pbrook
#define ftruncate qemu_ftruncate64
108 faf07963 pbrook
109 faf07963 pbrook
static inline char *realpath(const char *path, char *resolved_path)
110 faf07963 pbrook
{
111 faf07963 pbrook
    _fullpath(resolved_path, path, _MAX_PATH);
112 faf07963 pbrook
    return resolved_path;
113 faf07963 pbrook
}
114 faf07963 pbrook
115 faf07963 pbrook
#define PRId64 "I64d"
116 faf07963 pbrook
#define PRIx64 "I64x"
117 faf07963 pbrook
#define PRIu64 "I64u"
118 faf07963 pbrook
#define PRIo64 "I64o"
119 faf07963 pbrook
#endif
120 faf07963 pbrook
121 faf07963 pbrook
/* FIXME: Remove NEED_CPU_H.  */
122 faf07963 pbrook
#ifndef NEED_CPU_H
123 faf07963 pbrook
124 faf07963 pbrook
#include <setjmp.h>
125 faf07963 pbrook
#include "osdep.h"
126 faf07963 pbrook
#include "bswap.h"
127 faf07963 pbrook
128 faf07963 pbrook
#else
129 faf07963 pbrook
130 faf07963 pbrook
#include "cpu.h"
131 faf07963 pbrook
132 faf07963 pbrook
#endif /* !defined(NEED_CPU_H) */
133 faf07963 pbrook
134 faf07963 pbrook
/* bottom halves */
135 faf07963 pbrook
typedef void QEMUBHFunc(void *opaque);
136 faf07963 pbrook
137 9a1e9481 Kevin Wolf
void async_context_push(void);
138 9a1e9481 Kevin Wolf
void async_context_pop(void);
139 9a1e9481 Kevin Wolf
int get_async_context_id(void);
140 9a1e9481 Kevin Wolf
141 faf07963 pbrook
QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
142 faf07963 pbrook
void qemu_bh_schedule(QEMUBH *bh);
143 80d3580b aliguori
/* Bottom halfs that are scheduled from a bottom half handler are instantly
144 80d3580b aliguori
 * invoked.  This can create an infinite loop if a bottom half handler
145 80d3580b aliguori
 * schedules itself.  qemu_bh_schedule_idle() avoids this infinite loop by
146 80d3580b aliguori
 * ensuring that the bottom half isn't executed until the next main loop
147 80d3580b aliguori
 * iteration.
148 80d3580b aliguori
 */
149 1b435b10 aliguori
void qemu_bh_schedule_idle(QEMUBH *bh);
150 faf07963 pbrook
void qemu_bh_cancel(QEMUBH *bh);
151 faf07963 pbrook
void qemu_bh_delete(QEMUBH *bh);
152 faf07963 pbrook
int qemu_bh_poll(void);
153 4f999d05 Kevin Wolf
void qemu_bh_update_timeout(int *timeout);
154 faf07963 pbrook
155 f6503059 balrog
void qemu_get_timedate(struct tm *tm, int offset);
156 f6503059 balrog
int qemu_timedate_diff(struct tm *tm);
157 f6503059 balrog
158 faf07963 pbrook
/* cutils.c */
159 faf07963 pbrook
void pstrcpy(char *buf, int buf_size, const char *str);
160 faf07963 pbrook
char *pstrcat(char *buf, int buf_size, const char *s);
161 faf07963 pbrook
int strstart(const char *str, const char *val, const char **ptr);
162 faf07963 pbrook
int stristart(const char *str, const char *val, const char **ptr);
163 d43277c5 Blue Swirl
int qemu_strnlen(const char *s, int max_len);
164 faf07963 pbrook
time_t mktimegm(struct tm *tm);
165 ad46db9a blueswir1
int qemu_fls(int i);
166 6f1953c4 Christoph Hellwig
int qemu_fdatasync(int fd);
167 db1a4972 Paolo Bonzini
int fcntl_setfl(int fd, int flag);
168 d8427002 Jes Sorensen
169 d7142456 Jes Sorensen
/*
170 d7142456 Jes Sorensen
 * strtosz() suffixes used to specify the default treatment of an
171 d7142456 Jes Sorensen
 * argument passed to strtosz() without an explicit suffix.
172 d7142456 Jes Sorensen
 * These should be defined using upper case characters in the range
173 d7142456 Jes Sorensen
 * A-Z, as strtosz() will use qemu_toupper() on the given argument
174 d7142456 Jes Sorensen
 * prior to comparison.
175 d7142456 Jes Sorensen
 */
176 d8427002 Jes Sorensen
#define STRTOSZ_DEFSUFFIX_TB        'T'
177 d8427002 Jes Sorensen
#define STRTOSZ_DEFSUFFIX_GB        'G'
178 d8427002 Jes Sorensen
#define STRTOSZ_DEFSUFFIX_MB        'M'
179 d8427002 Jes Sorensen
#define STRTOSZ_DEFSUFFIX_KB        'K'
180 d8427002 Jes Sorensen
#define STRTOSZ_DEFSUFFIX_B        'B'
181 70b4f4bb Jes Sorensen
int64_t strtosz(const char *nptr, char **end);
182 70b4f4bb Jes Sorensen
int64_t strtosz_suffix(const char *nptr, char **end, const char default_suffix);
183 faf07963 pbrook
184 37022086 Blue Swirl
/* path.c */
185 37022086 Blue Swirl
void init_paths(const char *prefix);
186 37022086 Blue Swirl
const char *path(const char *pathname);
187 37022086 Blue Swirl
188 cd390083 blueswir1
#define qemu_isalnum(c)                isalnum((unsigned char)(c))
189 cd390083 blueswir1
#define qemu_isalpha(c)                isalpha((unsigned char)(c))
190 cd390083 blueswir1
#define qemu_iscntrl(c)                iscntrl((unsigned char)(c))
191 cd390083 blueswir1
#define qemu_isdigit(c)                isdigit((unsigned char)(c))
192 cd390083 blueswir1
#define qemu_isgraph(c)                isgraph((unsigned char)(c))
193 cd390083 blueswir1
#define qemu_islower(c)                islower((unsigned char)(c))
194 cd390083 blueswir1
#define qemu_isprint(c)                isprint((unsigned char)(c))
195 cd390083 blueswir1
#define qemu_ispunct(c)                ispunct((unsigned char)(c))
196 cd390083 blueswir1
#define qemu_isspace(c)                isspace((unsigned char)(c))
197 cd390083 blueswir1
#define qemu_isupper(c)                isupper((unsigned char)(c))
198 cd390083 blueswir1
#define qemu_isxdigit(c)        isxdigit((unsigned char)(c))
199 cd390083 blueswir1
#define qemu_tolower(c)                tolower((unsigned char)(c))
200 cd390083 blueswir1
#define qemu_toupper(c)                toupper((unsigned char)(c))
201 cd390083 blueswir1
#define qemu_isascii(c)                isascii((unsigned char)(c))
202 cd390083 blueswir1
#define qemu_toascii(c)                toascii((unsigned char)(c))
203 cd390083 blueswir1
204 b152aa84 Jes Sorensen
void *qemu_oom_check(void *ptr);
205 ca10f867 aurel32
void *qemu_malloc(size_t size);
206 2137b4cc ths
void *qemu_realloc(void *ptr, size_t size);
207 ca10f867 aurel32
void *qemu_mallocz(size_t size);
208 ca10f867 aurel32
void qemu_free(void *ptr);
209 ca10f867 aurel32
char *qemu_strdup(const char *str);
210 ac4b0d0c balrog
char *qemu_strndup(const char *str, size_t size);
211 ca10f867 aurel32
212 d549db5a Glauber Costa
void qemu_mutex_lock_iothread(void);
213 d549db5a Glauber Costa
void qemu_mutex_unlock_iothread(void);
214 d549db5a Glauber Costa
215 40ff6d7e Kevin Wolf
int qemu_open(const char *name, int flags, ...);
216 7c7c0629 Juan Quintela
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
217 7c7c0629 Juan Quintela
    QEMU_WARN_UNUSED_RESULT;
218 40ff6d7e Kevin Wolf
void qemu_set_cloexec(int fd);
219 40ff6d7e Kevin Wolf
220 40ff6d7e Kevin Wolf
#ifndef _WIN32
221 4d54ec78 Paolo Bonzini
int qemu_add_child_watch(pid_t pid);
222 f3dfda61 Paolo Bonzini
int qemu_eventfd(int pipefd[2]);
223 40ff6d7e Kevin Wolf
int qemu_pipe(int pipefd[2]);
224 40ff6d7e Kevin Wolf
#endif
225 40ff6d7e Kevin Wolf
226 87ecb68b pbrook
/* Error handling.  */
227 87ecb68b pbrook
228 e5924d89 Stefan Weil
void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
229 87ecb68b pbrook
230 87ecb68b pbrook
/* IO callbacks.  */
231 87ecb68b pbrook
typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
232 7b27a769 Juan Quintela
typedef int IOCanReadHandler(void *opaque);
233 87ecb68b pbrook
typedef void IOHandler(void *opaque);
234 87ecb68b pbrook
235 02981419 Paolo Bonzini
void qemu_iohandler_fill(int *pnfds, fd_set *readfds, fd_set *writefds, fd_set *xfds);
236 02981419 Paolo Bonzini
void qemu_iohandler_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, int rc);
237 02981419 Paolo Bonzini
238 87ecb68b pbrook
struct ParallelIOArg {
239 87ecb68b pbrook
    void *buffer;
240 87ecb68b pbrook
    int count;
241 87ecb68b pbrook
};
242 87ecb68b pbrook
243 87ecb68b pbrook
typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
244 87ecb68b pbrook
245 87ecb68b pbrook
/* A load of opaque types so that device init declarations don't have to
246 87ecb68b pbrook
   pull in all the real definitions.  */
247 87ecb68b pbrook
typedef struct NICInfo NICInfo;
248 1ae26a18 balrog
typedef struct HCIInfo HCIInfo;
249 87ecb68b pbrook
typedef struct AudioState AudioState;
250 87ecb68b pbrook
typedef struct BlockDriverState BlockDriverState;
251 2446333c Blue Swirl
typedef struct DriveInfo DriveInfo;
252 87ecb68b pbrook
typedef struct DisplayState DisplayState;
253 7d957bd8 aliguori
typedef struct DisplayChangeListener DisplayChangeListener;
254 7d957bd8 aliguori
typedef struct DisplaySurface DisplaySurface;
255 7b5d76da aliguori
typedef struct DisplayAllocator DisplayAllocator;
256 7d957bd8 aliguori
typedef struct PixelFormat PixelFormat;
257 87ecb68b pbrook
typedef struct TextConsole TextConsole;
258 c60e08d9 pbrook
typedef TextConsole QEMUConsole;
259 87ecb68b pbrook
typedef struct CharDriverState CharDriverState;
260 76d32cba Gerd Hoffmann
typedef struct MACAddr MACAddr;
261 87ecb68b pbrook
typedef struct VLANState VLANState;
262 f7105843 Mark McLoughlin
typedef struct VLANClientState VLANClientState;
263 87ecb68b pbrook
typedef struct i2c_bus i2c_bus;
264 87ecb68b pbrook
typedef struct i2c_slave i2c_slave;
265 87ecb68b pbrook
typedef struct SMBusDevice SMBusDevice;
266 fb47a2e9 Isaku Yamahata
typedef struct PCIHostState PCIHostState;
267 fb47a2e9 Isaku Yamahata
typedef struct PCIExpressHost PCIExpressHost;
268 87ecb68b pbrook
typedef struct PCIBus PCIBus;
269 87ecb68b pbrook
typedef struct PCIDevice PCIDevice;
270 0428527c Isaku Yamahata
typedef struct PCIExpressDevice PCIExpressDevice;
271 68f79994 Isaku Yamahata
typedef struct PCIBridge PCIBridge;
272 34e65944 Isaku Yamahata
typedef struct PCIEAERMsg PCIEAERMsg;
273 34e65944 Isaku Yamahata
typedef struct PCIEAERLog PCIEAERLog;
274 34e65944 Isaku Yamahata
typedef struct PCIEAERErr PCIEAERErr;
275 bc20ba98 Isaku Yamahata
typedef struct PCIEPort PCIEPort;
276 bc20ba98 Isaku Yamahata
typedef struct PCIESlot PCIESlot;
277 87ecb68b pbrook
typedef struct SerialState SerialState;
278 87ecb68b pbrook
typedef struct IRQState *qemu_irq;
279 bc24a225 Paul Brook
typedef struct PCMCIACardState PCMCIACardState;
280 bc24a225 Paul Brook
typedef struct MouseTransformInfo MouseTransformInfo;
281 bc24a225 Paul Brook
typedef struct uWireSlave uWireSlave;
282 bc24a225 Paul Brook
typedef struct I2SCodec I2SCodec;
283 90d37239 Paul Brook
typedef struct SSIBus SSIBus;
284 2292b339 Michael S. Tsirkin
typedef struct EventNotifier EventNotifier;
285 2be24aaa Michael S. Tsirkin
typedef struct VirtIODevice VirtIODevice;
286 87ecb68b pbrook
287 186993ee Michael S. Tsirkin
typedef uint64_t pcibus_t;
288 186993ee Michael S. Tsirkin
289 d2053c3c Blue Swirl
void cpu_exec_init_all(unsigned long tb_size);
290 d2053c3c Blue Swirl
291 b3c7724c pbrook
/* CPU save/load.  */
292 b3c7724c pbrook
void cpu_save(QEMUFile *f, void *opaque);
293 b3c7724c pbrook
int cpu_load(QEMUFile *f, void *opaque, int version_id);
294 b3c7724c pbrook
295 9e472e10 aliguori
/* Force QEMU to stop what it's doing and service IO */
296 9e472e10 aliguori
void qemu_service_io(void);
297 9e472e10 aliguori
298 d9f75a4e aliguori
/* Force QEMU to process pending events */
299 d9f75a4e aliguori
void qemu_notify_event(void);
300 d9f75a4e aliguori
301 8edac960 aliguori
/* Unblock cpu */
302 8edac960 aliguori
void qemu_cpu_kick(void *env);
303 46d62fac Jan Kiszka
void qemu_cpu_kick_self(void);
304 b7680cb6 Jan Kiszka
int qemu_cpu_is_self(void *env);
305 ab33fcda Paolo Bonzini
bool all_cpu_threads_idle(void);
306 8edac960 aliguori
307 e82bcec2 Marcelo Tosatti
/* work queue */
308 e82bcec2 Marcelo Tosatti
struct qemu_work_item {
309 e82bcec2 Marcelo Tosatti
    struct qemu_work_item *next;
310 e82bcec2 Marcelo Tosatti
    void (*func)(void *data);
311 e82bcec2 Marcelo Tosatti
    void *data;
312 e82bcec2 Marcelo Tosatti
    int done;
313 e82bcec2 Marcelo Tosatti
};
314 e82bcec2 Marcelo Tosatti
315 0bf46a40 aliguori
#ifdef CONFIG_USER_ONLY
316 0bf46a40 aliguori
#define qemu_init_vcpu(env) do { } while (0)
317 0bf46a40 aliguori
#else
318 0bf46a40 aliguori
void qemu_init_vcpu(void *env);
319 0bf46a40 aliguori
#endif
320 0bf46a40 aliguori
321 44e3ee8a aliguori
typedef struct QEMUIOVector {
322 44e3ee8a aliguori
    struct iovec *iov;
323 44e3ee8a aliguori
    int niov;
324 44e3ee8a aliguori
    int nalloc;
325 249aa745 aliguori
    size_t size;
326 44e3ee8a aliguori
} QEMUIOVector;
327 44e3ee8a aliguori
328 44e3ee8a aliguori
void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint);
329 522584a5 aliguori
void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov);
330 44e3ee8a aliguori
void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len);
331 b8a83a4f Kevin Wolf
void qemu_iovec_copy(QEMUIOVector *dst, QEMUIOVector *src, uint64_t skip,
332 b8a83a4f Kevin Wolf
    size_t size);
333 40b4f539 Kevin Wolf
void qemu_iovec_concat(QEMUIOVector *dst, QEMUIOVector *src, size_t size);
334 44e3ee8a aliguori
void qemu_iovec_destroy(QEMUIOVector *qiov);
335 be959463 aliguori
void qemu_iovec_reset(QEMUIOVector *qiov);
336 44e3ee8a aliguori
void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf);
337 249aa745 aliguori
void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count);
338 b8a83a4f Kevin Wolf
void qemu_iovec_memset(QEMUIOVector *qiov, int c, size_t count);
339 e0d9c6f9 Chunqiang Tang
void qemu_iovec_memset_skip(QEMUIOVector *qiov, int c, size_t count,
340 e0d9c6f9 Chunqiang Tang
                            size_t skip);
341 44e3ee8a aliguori
342 6b837bc4 Jes Sorensen
void qemu_progress_init(int enabled, float min_skip);
343 6b837bc4 Jes Sorensen
void qemu_progress_end(void);
344 3bfe4dbf Jes Sorensen
void qemu_progress_print(float delta, int max);
345 6b837bc4 Jes Sorensen
346 082b5557 Blue Swirl
#define QEMU_FILE_TYPE_BIOS   0
347 082b5557 Blue Swirl
#define QEMU_FILE_TYPE_KEYMAP 1
348 082b5557 Blue Swirl
char *qemu_find_file(int type, const char *name);
349 082b5557 Blue Swirl
350 082b5557 Blue Swirl
/* OS specific functions */
351 082b5557 Blue Swirl
void os_setup_early_signal_handling(void);
352 082b5557 Blue Swirl
char *os_find_datadir(const char *argv0);
353 082b5557 Blue Swirl
void os_parse_cmd_args(int index, const char *optarg);
354 082b5557 Blue Swirl
void os_pidfile_error(void);
355 082b5557 Blue Swirl
356 abd0c6bd Paul Brook
/* Convert a byte between binary and BCD.  */
357 abd0c6bd Paul Brook
static inline uint8_t to_bcd(uint8_t val)
358 abd0c6bd Paul Brook
{
359 abd0c6bd Paul Brook
    return ((val / 10) << 4) | (val % 10);
360 abd0c6bd Paul Brook
}
361 abd0c6bd Paul Brook
362 abd0c6bd Paul Brook
static inline uint8_t from_bcd(uint8_t val)
363 abd0c6bd Paul Brook
{
364 abd0c6bd Paul Brook
    return ((val >> 4) * 10) + (val & 0x0f);
365 abd0c6bd Paul Brook
}
366 abd0c6bd Paul Brook
367 338b922e malc
/* compute with 96 bit intermediate result: (a*b)/c */
368 338b922e malc
static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
369 338b922e malc
{
370 338b922e malc
    union {
371 338b922e malc
        uint64_t ll;
372 338b922e malc
        struct {
373 338b922e malc
#ifdef HOST_WORDS_BIGENDIAN
374 338b922e malc
            uint32_t high, low;
375 338b922e malc
#else
376 338b922e malc
            uint32_t low, high;
377 338b922e malc
#endif
378 338b922e malc
        } l;
379 338b922e malc
    } u, res;
380 338b922e malc
    uint64_t rl, rh;
381 338b922e malc
382 338b922e malc
    u.ll = a;
383 338b922e malc
    rl = (uint64_t)u.l.low * (uint64_t)b;
384 338b922e malc
    rh = (uint64_t)u.l.high * (uint64_t)b;
385 338b922e malc
    rh += (rl >> 32);
386 338b922e malc
    res.l.high = rh / c;
387 338b922e malc
    res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
388 338b922e malc
    return res.ll;
389 338b922e malc
}
390 338b922e malc
391 0bfe3ca5 Anthony Liguori
#include "module.h"
392 0bfe3ca5 Anthony Liguori
393 faf07963 pbrook
#endif