]> git.proxmox.com Git - mirror_qemu.git/blame - include/qemu-common.h
hw/i2c: pmbus: add registers
[mirror_qemu.git] / include / qemu-common.h
CommitLineData
a8d25326 1/*
04509ad9
EH
2 * This file is supposed to be included only by .c files. No header file should
3 * depend on qemu-common.h, as this would easily lead to circular header
4 * dependencies.
5 *
6 * If a header file uses a definition from qemu-common.h, that definition
7 * must be moved to a separate header file, and the header that uses it
8 * must include that header.
9 */
faf07963
PB
10#ifndef QEMU_COMMON_H
11#define QEMU_COMMON_H
12
082b5557 13#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
24ebf5f3 14
d915b7bb 15/* Copyright string for -version arguments, About dialogs, etc */
fd50a00a 16#define QEMU_COPYRIGHT "Copyright (c) 2003-2022 " \
d915b7bb
PM
17 "Fabrice Bellard and the QEMU Project developers"
18
f5048cb7
EB
19/* Bug reporting information for --help arguments, About dialogs, etc */
20#define QEMU_HELP_BOTTOM \
70b7fba9
SH
21 "See <https://qemu.org/contribute/report-a-bug> for how to report bugs.\n" \
22 "More information on the QEMU project at <https://qemu.org>."
f5048cb7 23
3bbbee18
AF
24/* main function, renamed */
25#if defined(CONFIG_COCOA)
26int qemu_main(int argc, char **argv, char **envp);
27#endif
28
7c7c0629
JQ
29ssize_t qemu_write_full(int fd, const void *buf, size_t count)
30 QEMU_WARN_UNUSED_RESULT;
40ff6d7e
KW
31
32#ifndef _WIN32
33int qemu_pipe(int pipefd[2]);
4efeabbb
MT
34/* like openpty() but also makes it raw; return master fd */
35int qemu_openpty_raw(int *aslave, char *pty_name);
40ff6d7e
KW
36#endif
37
00aa0040 38#ifdef _WIN32
58455eb9
SW
39/* MinGW needs type casts for the 'buf' and 'optval' arguments. */
40#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
41 getsockopt(sockfd, level, optname, (void *)optval, optlen)
42#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
43 setsockopt(sockfd, level, optname, (const void *)optval, optlen)
00aa0040 44#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
73062dfe
SW
45#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
46 sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
00aa0040 47#else
58455eb9
SW
48#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
49 getsockopt(sockfd, level, optname, optval, optlen)
50#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
51 setsockopt(sockfd, level, optname, optval, optlen)
00aa0040 52#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
73062dfe
SW
53#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
54 sendto(sockfd, buf, len, flags, destaddr, addrlen)
00aa0040
BS
55#endif
56
d5ab9713 57void cpu_exec_init_all(void);
fdbc2b57 58void cpu_exec_step_atomic(CPUState *cpu);
d2053c3c 59
20bccb82
PM
60/**
61 * set_preferred_target_page_bits:
62 * @bits: number of bits needed to represent an address within the page
63 *
64 * Set the preferred target page size (the actual target page
65 * size may be smaller than any given CPU's preference).
66 * Returns true on success, false on failure (which can only happen
67 * if this is called after the system has already finalized its
68 * choice of page size and the requested page size is smaller than that).
69 */
70bool set_preferred_target_page_bits(int bits);
71
7886cefe
RH
72/**
73 * finalize_target_page_bits:
74 * Commit the final value set by set_preferred_target_page_bits.
75 */
76void finalize_target_page_bits(void);
77
8c5135f9 78/**
2fc8ae1d
MT
79 * Sends a (part of) iovec down a socket, yielding when the socket is full, or
80 * Receives data into a (part of) iovec from a socket,
81 * yielding when there is no data in the socket.
82 * The same interface as qemu_sendv_recvv(), with added yielding.
83 * XXX should mark these as coroutine_fn
8c5135f9 84 */
2fc8ae1d
MT
85ssize_t qemu_co_sendv_recvv(int sockfd, struct iovec *iov, unsigned iov_cnt,
86 size_t offset, size_t bytes, bool do_send);
87#define qemu_co_recvv(sockfd, iov, iov_cnt, offset, bytes) \
88 qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, false)
89#define qemu_co_sendv(sockfd, iov, iov_cnt, offset, bytes) \
90 qemu_co_sendv_recvv(sockfd, iov, iov_cnt, offset, bytes, true)
8c5135f9
PB
91
92/**
2fc8ae1d 93 * The same as above, but with just a single buffer
8c5135f9 94 */
2fc8ae1d
MT
95ssize_t qemu_co_send_recv(int sockfd, void *buf, size_t bytes, bool do_send);
96#define qemu_co_recv(sockfd, buf, bytes) \
97 qemu_co_send_recv(sockfd, buf, bytes, false)
98#define qemu_co_send(sockfd, buf, bytes) \
99 qemu_co_send_recv(sockfd, buf, bytes, true)
8c5135f9 100
6b837bc4
JS
101void qemu_progress_init(int enabled, float min_skip);
102void qemu_progress_end(void);
3bfe4dbf 103void qemu_progress_print(float delta, int max);
31459f46 104const char *qemu_get_vm_name(void);
6b837bc4 105
082b5557
BS
106/* OS specific functions */
107void os_setup_early_signal_handling(void);
1217d6ca 108int os_parse_cmd_args(int index, const char *optarg);
082b5557 109
bbb16908
LV
110/*
111 * Hexdump a line of a byte buffer into a hexadecimal/ASCII buffer
112 */
113#define QEMU_HEXDUMP_LINE_BYTES 16 /* Number of bytes to dump */
114#define QEMU_HEXDUMP_LINE_LEN 75 /* Number of characters in line */
115void qemu_hexdump_line(char *line, unsigned int b, const void *bufptr,
116 unsigned int len, bool ascii);
117
6ff66f50
PC
118/*
119 * Hexdump a buffer to a file. An optional string prefix is added to every line
120 */
121
b42581f5
PMD
122void qemu_hexdump(FILE *fp, const char *prefix,
123 const void *bufptr, size_t size);
6ff66f50 124
b16352ac
AL
125/*
126 * helper to parse debug environment variables
127 */
128int parse_debug_env(const char *name, int max, int initial);
129
4297c8ee 130const char *qemu_ether_ntoa(const MACAddr *mac);
87f50caa 131void page_size_init(void);
4297c8ee 132
65d64f36
PX
133/* returns non-zero if dump is in progress, otherwise zero is
134 * returned. */
135bool dump_in_progress(void);
136
faf07963 137#endif