VirtualBox

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

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

rem: synced up to svn://svn.savannah.nongnu.org/qemu/trunk@6686 (repo UUID c046a42c-6fe2-441c-8c8c-71466251a162).

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

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