VirtualBox

source: vbox/trunk/src/recompiler/qemu-common.h@ 37270

Last change on this file since 37270 was 36175, checked in by vboxsync, 14 years ago

rem: Synced up to v0.11.1 (35bfc7324e2e6946c4113ada5db30553a1a7c40b) from git://git.savannah.nongnu.org/qemu.git.

  • Property svn:eol-style set to native
File size: 7.8 KB
Line 
1/* Common header file that is included by all of qemu. */
2#ifndef QEMU_COMMON_H
3#define QEMU_COMMON_H
4
5#ifdef VBOX
6
7# include <string.h>
8# include <inttypes.h>
9# include <iprt/ctype.h>
10
11#define QEMU_NORETURN __attribute__ ((__noreturn__))
12
13void pstrcpy(char *buf, int buf_size, const char *str);
14char *pstrcat(char *buf, int buf_size, const char *s);
15# define snprintf RTStrPrintf
16
17#define qemu_isalnum(c) RT_C_IS_ALNUM((unsigned char)(c))
18#define qemu_isalpha(c) RT_C_IS_ALPHA((unsigned char)(c))
19#define qemu_iscntrl(c) RT_C_IS_CNTRL((unsigned char)(c))
20#define qemu_isdigit(c) RT_C_IS_DIGIT((unsigned char)(c))
21#define qemu_isgraph(c) RT_C_IS_GRAPH((unsigned char)(c))
22#define qemu_islower(c) RT_C_IS_LOWER((unsigned char)(c))
23#define qemu_isprint(c) RT_C_IS_PRINT((unsigned char)(c))
24#define qemu_ispunct(c) RT_C_IS_PUNCT((unsigned char)(c))
25#define qemu_isspace(c) RT_C_IS_SPACE((unsigned char)(c))
26#define qemu_isupper(c) RT_C_IS_UPPER((unsigned char)(c))
27#define qemu_isxdigit(c) RT_C_IS_XDIGIT((unsigned char)(c))
28#define qemu_tolower(c) RT_C_TO_LOWER((unsigned char)(c))
29#define qemu_toupper(c) RT_C_TO_UPPER((unsigned char)(c))
30#define qemu_isascii(c) RT_C_IS_ASCII((unsigned char)(c))
31#define qemu_toascii(c) RT_C_TO_ASCII((unsigned char)(c))
32
33#define qemu_init_vcpu(env) do { } while (0) /* we don't need this :-) */
34
35
36#else /* !VBOX */
37#ifdef _WIN32
38#define WIN32_LEAN_AND_MEAN
39#define WINVER 0x0501 /* needed for ipv6 bits */
40#include <windows.h>
41#endif
42
43#define QEMU_NORETURN __attribute__ ((__noreturn__))
44
45/* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that
46 cannot include the following headers without conflicts. This condition has
47 to be removed once dyngen is gone. */
48#ifndef __DYNGEN_EXEC_H__
49
50/* we put basic includes here to avoid repeating them in device drivers */
51#include <stdlib.h>
52#include <stdio.h>
53#include <stdarg.h>
54#include <string.h>
55#include <strings.h>
56#include <inttypes.h>
57#include <limits.h>
58#include <time.h>
59#include <ctype.h>
60#include <errno.h>
61#include <unistd.h>
62#include <fcntl.h>
63#include <sys/stat.h>
64#include <assert.h>
65#include "config-host.h"
66
67#ifndef O_LARGEFILE
68#define O_LARGEFILE 0
69#endif
70#ifndef O_BINARY
71#define O_BINARY 0
72#endif
73
74#ifndef ENOMEDIUM
75#define ENOMEDIUM ENODEV
76#endif
77
78#ifndef HAVE_IOVEC
79#define HAVE_IOVEC
80struct iovec {
81 void *iov_base;
82 size_t iov_len;
83};
84#else
85#include <sys/uio.h>
86#endif
87
88#ifdef _WIN32
89#define fsync _commit
90#define lseek _lseeki64
91#define ENOTSUP 4096
92extern int qemu_ftruncate64(int, int64_t);
93#define ftruncate qemu_ftruncate64
94
95
96static inline char *realpath(const char *path, char *resolved_path)
97{
98 _fullpath(resolved_path, path, _MAX_PATH);
99 return resolved_path;
100}
101
102#define PRId64 "I64d"
103#define PRIx64 "I64x"
104#define PRIu64 "I64u"
105#define PRIo64 "I64o"
106#endif
107
108/* FIXME: Remove NEED_CPU_H. */
109#ifndef NEED_CPU_H
110
111#include <setjmp.h>
112#include "osdep.h"
113#include "bswap.h"
114
115#else
116
117#include "cpu.h"
118
119#endif /* !defined(NEED_CPU_H) */
120
121/* bottom halves */
122typedef struct QEMUBH QEMUBH;
123
124typedef void QEMUBHFunc(void *opaque);
125
126QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
127void qemu_bh_schedule(QEMUBH *bh);
128/* Bottom halfs that are scheduled from a bottom half handler are instantly
129 * invoked. This can create an infinite loop if a bottom half handler
130 * schedules itself. qemu_bh_schedule_idle() avoids this infinite loop by
131 * ensuring that the bottom half isn't executed until the next main loop
132 * iteration.
133 */
134void qemu_bh_schedule_idle(QEMUBH *bh);
135void qemu_bh_cancel(QEMUBH *bh);
136void qemu_bh_delete(QEMUBH *bh);
137int qemu_bh_poll(void);
138
139uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
140
141void qemu_get_timedate(struct tm *tm, int offset);
142int qemu_timedate_diff(struct tm *tm);
143
144/* cutils.c */
145void pstrcpy(char *buf, int buf_size, const char *str);
146char *pstrcat(char *buf, int buf_size, const char *s);
147int strstart(const char *str, const char *val, const char **ptr);
148int stristart(const char *str, const char *val, const char **ptr);
149int qemu_strnlen(const char *s, int max_len);
150time_t mktimegm(struct tm *tm);
151int qemu_fls(int i);
152
153#define qemu_isalnum(c) isalnum((unsigned char)(c))
154#define qemu_isalpha(c) isalpha((unsigned char)(c))
155#define qemu_iscntrl(c) iscntrl((unsigned char)(c))
156#define qemu_isdigit(c) isdigit((unsigned char)(c))
157#define qemu_isgraph(c) isgraph((unsigned char)(c))
158#define qemu_islower(c) islower((unsigned char)(c))
159#define qemu_isprint(c) isprint((unsigned char)(c))
160#define qemu_ispunct(c) ispunct((unsigned char)(c))
161#define qemu_isspace(c) isspace((unsigned char)(c))
162#define qemu_isupper(c) isupper((unsigned char)(c))
163#define qemu_isxdigit(c) isxdigit((unsigned char)(c))
164#define qemu_tolower(c) tolower((unsigned char)(c))
165#define qemu_toupper(c) toupper((unsigned char)(c))
166#define qemu_isascii(c) isascii((unsigned char)(c))
167#define qemu_toascii(c) toascii((unsigned char)(c))
168
169void *qemu_malloc(size_t size);
170void *qemu_realloc(void *ptr, size_t size);
171void *qemu_mallocz(size_t size);
172void qemu_free(void *ptr);
173char *qemu_strdup(const char *str);
174char *qemu_strndup(const char *str, size_t size);
175
176void *get_mmap_addr(unsigned long size);
177
178
179/* Error handling. */
180
181void QEMU_NORETURN hw_error(const char *fmt, ...)
182 __attribute__ ((__format__ (__printf__, 1, 2)));
183
184/* IO callbacks. */
185typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
186typedef int IOCanRWHandler(void *opaque);
187typedef void IOHandler(void *opaque);
188
189struct ParallelIOArg {
190 void *buffer;
191 int count;
192};
193
194typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
195
196/* A load of opaque types so that device init declarations don't have to
197 pull in all the real definitions. */
198typedef struct NICInfo NICInfo;
199typedef struct HCIInfo HCIInfo;
200typedef struct AudioState AudioState;
201typedef struct BlockDriverState BlockDriverState;
202typedef struct DisplayState DisplayState;
203typedef struct DisplayChangeListener DisplayChangeListener;
204typedef struct DisplaySurface DisplaySurface;
205typedef struct DisplayAllocator DisplayAllocator;
206typedef struct PixelFormat PixelFormat;
207typedef struct TextConsole TextConsole;
208typedef TextConsole QEMUConsole;
209typedef struct CharDriverState CharDriverState;
210typedef struct VLANState VLANState;
211typedef struct QEMUFile QEMUFile;
212typedef struct i2c_bus i2c_bus;
213typedef struct i2c_slave i2c_slave;
214typedef struct SMBusDevice SMBusDevice;
215typedef struct QEMUTimer QEMUTimer;
216typedef struct PCIBus PCIBus;
217typedef struct PCIDevice PCIDevice;
218typedef struct SerialState SerialState;
219typedef struct IRQState *qemu_irq;
220typedef struct PCMCIACardState PCMCIACardState;
221typedef struct MouseTransformInfo MouseTransformInfo;
222typedef struct uWireSlave uWireSlave;
223typedef struct I2SCodec I2SCodec;
224typedef struct DeviceState DeviceState;
225typedef struct SSIBus SSIBus;
226
227/* CPU save/load. */
228void cpu_save(QEMUFile *f, void *opaque);
229int cpu_load(QEMUFile *f, void *opaque, int version_id);
230
231/* Force QEMU to stop what it's doing and service IO */
232void qemu_service_io(void);
233
234/* Force QEMU to process pending events */
235void qemu_notify_event(void);
236
237/* Unblock cpu */
238void qemu_cpu_kick(void *env);
239int qemu_cpu_self(void *env);
240
241#ifdef CONFIG_USER_ONLY
242#define qemu_init_vcpu(env) do { } while (0)
243#else
244void qemu_init_vcpu(void *env);
245#endif
246
247typedef struct QEMUIOVector {
248 struct iovec *iov;
249 int niov;
250 int nalloc;
251 size_t size;
252} QEMUIOVector;
253
254void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint);
255void qemu_iovec_init_external(QEMUIOVector *qiov, struct iovec *iov, int niov);
256void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len);
257void qemu_iovec_destroy(QEMUIOVector *qiov);
258void qemu_iovec_reset(QEMUIOVector *qiov);
259void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf);
260void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count);
261
262struct Monitor;
263typedef struct Monitor Monitor;
264
265#include "module.h"
266
267#endif /* dyngen-exec.h hack */
268
269#endif /* !VBOX */
270
271#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette