2012-08-06 20:42:50 +02:00
|
|
|
|
2012-10-23 23:44:02 +02:00
|
|
|
/* Common header file that is included by all of QEMU.
|
|
|
|
*
|
|
|
|
* This file is supposed to be included only by .c files. No header file should
|
|
|
|
* depend on qemu-common.h, as this would easily lead to circular header
|
|
|
|
* dependencies.
|
|
|
|
*
|
|
|
|
* If a header file uses a definition from qemu-common.h, that definition
|
|
|
|
* must be moved to a separate header file, and the header that uses it
|
|
|
|
* must include that header.
|
|
|
|
*/
|
2007-11-11 03:51:17 +01:00
|
|
|
#ifndef QEMU_COMMON_H
|
|
|
|
#define QEMU_COMMON_H
|
|
|
|
|
2015-07-03 16:18:24 +02:00
|
|
|
#include "qemu/fprintf-fn.h"
|
2010-01-15 12:56:41 +01:00
|
|
|
|
2011-07-28 12:10:28 +02:00
|
|
|
#if defined(__arm__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__) || defined(__ia64__)
|
|
|
|
#define WORDS_ALIGNED
|
|
|
|
#endif
|
|
|
|
|
2011-03-27 11:04:57 +02:00
|
|
|
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
|
2010-02-18 21:25:23 +01:00
|
|
|
|
2014-07-25 11:56:28 +02:00
|
|
|
#include "qemu/option.h"
|
2015-07-24 14:33:12 +02:00
|
|
|
#include "qemu/host-utils.h"
|
2007-11-11 03:51:17 +01:00
|
|
|
|
2014-09-01 07:34:49 +02:00
|
|
|
void cpu_ticks_init(void);
|
|
|
|
|
2011-09-12 13:57:37 +02:00
|
|
|
/* icount */
|
2014-07-25 11:56:28 +02:00
|
|
|
void configure_icount(QemuOpts *opts, Error **errp);
|
2011-09-12 13:57:37 +02:00
|
|
|
extern int use_icount;
|
2014-07-25 11:56:29 +02:00
|
|
|
extern int icount_align_option;
|
2014-07-25 11:56:33 +02:00
|
|
|
/* drift information for info jit command */
|
|
|
|
extern int64_t max_delay;
|
|
|
|
extern int64_t max_advance;
|
|
|
|
void dump_drift_info(FILE *f, fprintf_function cpu_fprintf);
|
2011-09-12 13:57:37 +02:00
|
|
|
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/bswap.h"
|
2007-11-11 03:51:17 +01:00
|
|
|
|
2013-04-21 12:01:06 +02:00
|
|
|
/* FIXME: Remove NEED_CPU_H. */
|
|
|
|
#ifdef NEED_CPU_H
|
2007-11-11 03:51:17 +01:00
|
|
|
#include "cpu.h"
|
|
|
|
#endif /* !defined(NEED_CPU_H) */
|
|
|
|
|
2011-05-29 19:42:51 +02:00
|
|
|
/* main function, renamed */
|
|
|
|
#if defined(CONFIG_COCOA)
|
|
|
|
int qemu_main(int argc, char **argv, char **envp);
|
|
|
|
#endif
|
|
|
|
|
2008-02-17 12:42:19 +01:00
|
|
|
void qemu_get_timedate(struct tm *tm, int offset);
|
|
|
|
int qemu_timedate_diff(struct tm *tm);
|
|
|
|
|
2008-11-16 14:53:32 +01:00
|
|
|
#define qemu_isalnum(c) isalnum((unsigned char)(c))
|
|
|
|
#define qemu_isalpha(c) isalpha((unsigned char)(c))
|
|
|
|
#define qemu_iscntrl(c) iscntrl((unsigned char)(c))
|
|
|
|
#define qemu_isdigit(c) isdigit((unsigned char)(c))
|
|
|
|
#define qemu_isgraph(c) isgraph((unsigned char)(c))
|
|
|
|
#define qemu_islower(c) islower((unsigned char)(c))
|
|
|
|
#define qemu_isprint(c) isprint((unsigned char)(c))
|
|
|
|
#define qemu_ispunct(c) ispunct((unsigned char)(c))
|
|
|
|
#define qemu_isspace(c) isspace((unsigned char)(c))
|
|
|
|
#define qemu_isupper(c) isupper((unsigned char)(c))
|
|
|
|
#define qemu_isxdigit(c) isxdigit((unsigned char)(c))
|
|
|
|
#define qemu_tolower(c) tolower((unsigned char)(c))
|
|
|
|
#define qemu_toupper(c) toupper((unsigned char)(c))
|
|
|
|
#define qemu_isascii(c) isascii((unsigned char)(c))
|
|
|
|
#define qemu_toascii(c) toascii((unsigned char)(c))
|
|
|
|
|
2010-10-26 10:39:26 +02:00
|
|
|
void *qemu_oom_check(void *ptr);
|
2008-04-11 23:35:42 +02:00
|
|
|
|
2010-01-20 00:56:09 +01:00
|
|
|
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
|
|
|
|
QEMU_WARN_UNUSED_RESULT;
|
2009-12-02 12:24:42 +01:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
int qemu_pipe(int pipefd[2]);
|
2013-06-05 16:44:54 +02:00
|
|
|
/* like openpty() but also makes it raw; return master fd */
|
|
|
|
int qemu_openpty_raw(int *aslave, char *pty_name);
|
2009-12-02 12:24:42 +01:00
|
|
|
#endif
|
|
|
|
|
2011-07-23 22:04:29 +02:00
|
|
|
#ifdef _WIN32
|
2012-09-28 19:07:39 +02:00
|
|
|
/* MinGW needs type casts for the 'buf' and 'optval' arguments. */
|
|
|
|
#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
|
|
|
|
getsockopt(sockfd, level, optname, (void *)optval, optlen)
|
|
|
|
#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
|
|
|
|
setsockopt(sockfd, level, optname, (const void *)optval, optlen)
|
2011-07-23 22:04:29 +02:00
|
|
|
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
|
2012-09-22 21:13:28 +02:00
|
|
|
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
|
|
|
|
sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
|
2011-07-23 22:04:29 +02:00
|
|
|
#else
|
2012-09-28 19:07:39 +02:00
|
|
|
#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
|
|
|
|
getsockopt(sockfd, level, optname, optval, optlen)
|
|
|
|
#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
|
|
|
|
setsockopt(sockfd, level, optname, optval, optlen)
|
2011-07-23 22:04:29 +02:00
|
|
|
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
|
2012-09-22 21:13:28 +02:00
|
|
|
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
|
|
|
|
sendto(sockfd, buf, len, flags, destaddr, addrlen)
|
2011-07-23 22:04:29 +02:00
|
|
|
#endif
|
|
|
|
|
2011-08-02 16:10:21 +02:00
|
|
|
void tcg_exec_init(unsigned long tb_size);
|
|
|
|
bool tcg_enabled(void);
|
|
|
|
|
|
|
|
void cpu_exec_init_all(void);
|
2010-03-29 21:23:48 +02:00
|
|
|
|
2009-04-24 20:03:45 +02:00
|
|
|
/* Unblock cpu */
|
2011-02-01 22:15:59 +01:00
|
|
|
void qemu_cpu_kick_self(void);
|
2009-04-24 20:03:45 +02:00
|
|
|
|
2010-05-04 14:45:22 +02:00
|
|
|
/* work queue */
|
|
|
|
struct qemu_work_item {
|
|
|
|
struct qemu_work_item *next;
|
|
|
|
void (*func)(void *data);
|
|
|
|
void *data;
|
|
|
|
int done;
|
2013-06-24 11:49:41 +02:00
|
|
|
bool free;
|
2010-05-04 14:45:22 +02:00
|
|
|
};
|
|
|
|
|
2011-09-08 13:46:25 +02:00
|
|
|
|
|
|
|
/**
|
2012-06-07 18:22:46 +02:00
|
|
|
* Sends a (part of) iovec down a socket, yielding when the socket is full, or
|
|
|
|
* Receives data into a (part of) iovec from a socket,
|
|
|
|
* yielding when there is no data in the socket.
|
|
|
|
* The same interface as qemu_sendv_recvv(), with added yielding.
|
|
|
|
* XXX should mark these as coroutine_fn
|
2011-09-08 13:46:25 +02:00
|
|
|
*/
|
2012-06-07 18:22:46 +02:00
|
|
|
ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
|
|
|
|
size_t offset, size_t bytes, bool do_send);
|
|
|
|
#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
|
|
|
|
qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
|
|
|
|
#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
|
|
|
|
qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true)
|
2011-09-08 13:46:25 +02:00
|
|
|
|
|
|
|
/**
|
2012-06-07 18:22:46 +02:00
|
|
|
* The same as above, but with just a single buffer
|
2011-09-08 13:46:25 +02:00
|
|
|
*/
|
2012-06-07 18:22:46 +02:00
|
|
|
ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
|
|
|
|
#define qemu_co_recv(sockfd, buf, bytes) \
|
|
|
|
qemu_co_send_recv(sockfd, buf, bytes, false)
|
|
|
|
#define qemu_co_send(sockfd, buf, bytes) \
|
|
|
|
qemu_co_send_recv(sockfd, buf, bytes, true)
|
2011-09-08 13:46:25 +02:00
|
|
|
|
2011-03-30 14:16:25 +02:00
|
|
|
void qemu_progress_init(int enabled, float min_skip);
|
|
|
|
void qemu_progress_end(void);
|
2011-05-09 17:32:20 +02:00
|
|
|
void qemu_progress_print(float delta, int max);
|
2012-08-06 10:24:55 +02:00
|
|
|
const char *qemu_get_vm_name(void);
|
2011-03-30 14:16:25 +02:00
|
|
|
|
2011-03-27 11:04:57 +02:00
|
|
|
#define QEMU_FILE_TYPE_BIOS 0
|
|
|
|
#define QEMU_FILE_TYPE_KEYMAP 1
|
|
|
|
char *qemu_find_file(int type, const char *name);
|
|
|
|
|
|
|
|
/* OS specific functions */
|
|
|
|
void os_setup_early_signal_handling(void);
|
2014-02-10 07:48:51 +01:00
|
|
|
char *os_find_datadir(void);
|
2011-03-27 11:04:57 +02:00
|
|
|
void os_parse_cmd_args(int index, const char *optarg);
|
|
|
|
|
2012-12-17 18:20:00 +01:00
|
|
|
#include "qemu/module.h"
|
2009-05-14 20:29:53 +02:00
|
|
|
|
2013-03-15 17:41:58 +01:00
|
|
|
/*
|
|
|
|
* Hexdump a buffer to a file. An optional string prefix is added to every line
|
|
|
|
*/
|
|
|
|
|
2013-05-16 17:32:28 +02:00
|
|
|
void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
|
2013-03-15 17:41:58 +01:00
|
|
|
|
2013-03-04 17:41:28 +01:00
|
|
|
/*
|
|
|
|
* helper to parse debug environment variables
|
|
|
|
*/
|
|
|
|
int parse_debug_env(const char *name, int max, int initial);
|
|
|
|
|
2014-03-11 00:42:26 +01:00
|
|
|
const char *qemu_ether_ntoa(const MACAddr *mac);
|
2015-11-05 19:10:31 +01:00
|
|
|
void page_size_init(void);
|
2014-03-11 00:42:26 +01:00
|
|
|
|
2016-02-18 06:16:49 +01:00
|
|
|
/* returns non-zero if dump is in progress, otherwise zero is
|
|
|
|
* returned. */
|
|
|
|
bool dump_in_progress(void);
|
|
|
|
|
2007-11-11 03:51:17 +01:00
|
|
|
#endif
|