2012-08-07 02:42:50 +08:00
|
|
|
|
2012-10-24 05:44:02 +08: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 10:51:17 +08:00
|
|
|
#ifndef QEMU_COMMON_H
|
|
|
|
#define QEMU_COMMON_H
|
|
|
|
|
2015-07-03 22:18:24 +08:00
|
|
|
#include "qemu/fprintf-fn.h"
|
2010-01-15 19:56:41 +08:00
|
|
|
|
2011-03-27 17:04:57 +08:00
|
|
|
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
|
2010-02-19 04:25:23 +08:00
|
|
|
|
2016-08-04 19:14:36 +08:00
|
|
|
/* Copyright string for -version arguments, About dialogs, etc */
|
2019-02-02 01:36:55 +08:00
|
|
|
#define QEMU_COPYRIGHT "Copyright (c) 2003-2019 " \
|
2016-08-04 19:14:36 +08:00
|
|
|
"Fabrice Bellard and the QEMU Project developers"
|
|
|
|
|
2017-08-04 00:33:53 +08:00
|
|
|
/* Bug reporting information for --help arguments, About dialogs, etc */
|
|
|
|
#define QEMU_HELP_BOTTOM \
|
2017-11-21 20:04:35 +08:00
|
|
|
"See <https://qemu.org/contribute/report-a-bug> for how to report bugs.\n" \
|
|
|
|
"More information on the QEMU project at <https://qemu.org>."
|
2017-08-04 00:33:53 +08:00
|
|
|
|
2011-05-30 01:42:51 +08:00
|
|
|
/* main function, renamed */
|
|
|
|
#if defined(CONFIG_COCOA)
|
|
|
|
int qemu_main(int argc, char **argv, char **envp);
|
|
|
|
#endif
|
|
|
|
|
2008-02-17 19:42:19 +08:00
|
|
|
void qemu_get_timedate(struct tm *tm, int offset);
|
|
|
|
int qemu_timedate_diff(struct tm *tm);
|
|
|
|
|
2008-11-16 21:53:32 +08: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 16:39:26 +08:00
|
|
|
void *qemu_oom_check(void *ptr);
|
2008-04-12 05:35:42 +08:00
|
|
|
|
2010-01-20 07:56:09 +08:00
|
|
|
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
|
|
|
|
QEMU_WARN_UNUSED_RESULT;
|
2009-12-02 19:24:42 +08:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
int qemu_pipe(int pipefd[2]);
|
2013-06-05 22:44:54 +08:00
|
|
|
/* like openpty() but also makes it raw; return master fd */
|
|
|
|
int qemu_openpty_raw(int *aslave, char *pty_name);
|
2009-12-02 19:24:42 +08:00
|
|
|
#endif
|
|
|
|
|
2011-07-24 04:04:29 +08:00
|
|
|
#ifdef _WIN32
|
2012-09-29 01:07:39 +08: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-24 04:04:29 +08:00
|
|
|
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
|
2012-09-23 03:13:28 +08:00
|
|
|
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
|
|
|
|
sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
|
2011-07-24 04:04:29 +08:00
|
|
|
#else
|
2012-09-29 01:07:39 +08: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-24 04:04:29 +08:00
|
|
|
#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
|
2012-09-23 03:13:28 +08:00
|
|
|
#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
|
|
|
|
sendto(sockfd, buf, len, flags, destaddr, addrlen)
|
2011-07-24 04:04:29 +08:00
|
|
|
#endif
|
|
|
|
|
2017-07-03 18:12:12 +08:00
|
|
|
extern bool tcg_allowed;
|
2011-08-02 22:10:21 +08:00
|
|
|
void tcg_exec_init(unsigned long tb_size);
|
2017-07-03 18:12:12 +08:00
|
|
|
#ifdef CONFIG_TCG
|
|
|
|
#define tcg_enabled() (tcg_allowed)
|
|
|
|
#else
|
|
|
|
#define tcg_enabled() 0
|
|
|
|
#endif
|
2011-08-02 22:10:21 +08:00
|
|
|
|
|
|
|
void cpu_exec_init_all(void);
|
2016-06-30 13:12:55 +08:00
|
|
|
void cpu_exec_step_atomic(CPUState *cpu);
|
2010-03-30 03:23:48 +08:00
|
|
|
|
2016-10-24 23:26:49 +08:00
|
|
|
/**
|
|
|
|
* set_preferred_target_page_bits:
|
|
|
|
* @bits: number of bits needed to represent an address within the page
|
|
|
|
*
|
|
|
|
* Set the preferred target page size (the actual target page
|
|
|
|
* size may be smaller than any given CPU's preference).
|
|
|
|
* Returns true on success, false on failure (which can only happen
|
|
|
|
* if this is called after the system has already finalized its
|
|
|
|
* choice of page size and the requested page size is smaller than that).
|
|
|
|
*/
|
|
|
|
bool set_preferred_target_page_bits(int bits);
|
|
|
|
|
2011-09-08 19:46:25 +08:00
|
|
|
/**
|
2012-06-08 00:22:46 +08: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 19:46:25 +08:00
|
|
|
*/
|
2012-06-08 00:22:46 +08: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 19:46:25 +08:00
|
|
|
|
|
|
|
/**
|
2012-06-08 00:22:46 +08:00
|
|
|
* The same as above, but with just a single buffer
|
2011-09-08 19:46:25 +08:00
|
|
|
*/
|
2012-06-08 00:22:46 +08: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 19:46:25 +08:00
|
|
|
|
2011-03-30 20:16:25 +08:00
|
|
|
void qemu_progress_init(int enabled, float min_skip);
|
|
|
|
void qemu_progress_end(void);
|
2011-05-09 23:32:20 +08:00
|
|
|
void qemu_progress_print(float delta, int max);
|
2012-08-06 16:24:55 +08:00
|
|
|
const char *qemu_get_vm_name(void);
|
2011-03-30 20:16:25 +08:00
|
|
|
|
2011-03-27 17:04:57 +08: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 14:48:51 +08:00
|
|
|
char *os_find_datadir(void);
|
2018-05-05 01:01:07 +08:00
|
|
|
int os_parse_cmd_args(int index, const char *optarg);
|
2011-03-27 17:04:57 +08:00
|
|
|
|
2012-12-18 01:20:00 +08:00
|
|
|
#include "qemu/module.h"
|
2009-05-15 02:29:53 +08:00
|
|
|
|
2013-03-16 00:41:58 +08:00
|
|
|
/*
|
|
|
|
* Hexdump a buffer to a file. An optional string prefix is added to every line
|
|
|
|
*/
|
|
|
|
|
2013-05-16 23:32:28 +08:00
|
|
|
void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size);
|
2013-03-16 00:41:58 +08:00
|
|
|
|
2013-03-05 00:41:28 +08:00
|
|
|
/*
|
|
|
|
* helper to parse debug environment variables
|
|
|
|
*/
|
|
|
|
int parse_debug_env(const char *name, int max, int initial);
|
|
|
|
|
2014-03-11 07:42:26 +08:00
|
|
|
const char *qemu_ether_ntoa(const MACAddr *mac);
|
2017-05-12 12:17:40 +08:00
|
|
|
char *size_to_str(uint64_t val);
|
2015-11-06 02:10:31 +08:00
|
|
|
void page_size_init(void);
|
2014-03-11 07:42:26 +08:00
|
|
|
|
2016-02-18 13:16:49 +08:00
|
|
|
/* returns non-zero if dump is in progress, otherwise zero is
|
|
|
|
* returned. */
|
|
|
|
bool dump_in_progress(void);
|
|
|
|
|
2007-11-11 10:51:17 +08:00
|
|
|
#endif
|