root / qemu-common.h @ 927e3a4e
History | View | Annotate | Download (5.8 kB)
1 | faf07963 | pbrook | /* Common header file that is included by all of qemu. */
|
---|---|---|---|
2 | faf07963 | pbrook | #ifndef QEMU_COMMON_H
|
3 | faf07963 | pbrook | #define QEMU_COMMON_H
|
4 | faf07963 | pbrook | |
5 | 02082dc9 | aliguori | #ifdef _WIN32
|
6 | 02082dc9 | aliguori | #define WIN32_LEAN_AND_MEAN
|
7 | 02082dc9 | aliguori | #define WINVER 0x0501 /* needed for ipv6 bits */ |
8 | 02082dc9 | aliguori | #include <windows.h> |
9 | 02082dc9 | aliguori | #endif
|
10 | 02082dc9 | aliguori | |
11 | a5e50b26 | malc | #define QEMU_NORETURN __attribute__ ((__noreturn__))
|
12 | 7d99a001 | blueswir1 | |
13 | a5e50b26 | malc | /* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that
|
14 | 7d99a001 | blueswir1 | cannot include the following headers without conflicts. This condition has
|
15 | 7d99a001 | blueswir1 | to be removed once dyngen is gone. */
|
16 | 7d99a001 | blueswir1 | #ifndef __DYNGEN_EXEC_H__
|
17 | 7d99a001 | blueswir1 | |
18 | faf07963 | pbrook | /* we put basic includes here to avoid repeating them in device drivers */
|
19 | faf07963 | pbrook | #include <stdlib.h> |
20 | faf07963 | pbrook | #include <stdio.h> |
21 | faf07963 | pbrook | #include <stdarg.h> |
22 | faf07963 | pbrook | #include <string.h> |
23 | c8906845 | balrog | #include <strings.h> |
24 | faf07963 | pbrook | #include <inttypes.h> |
25 | faf07963 | pbrook | #include <limits.h> |
26 | faf07963 | pbrook | #include <time.h> |
27 | faf07963 | pbrook | #include <ctype.h> |
28 | faf07963 | pbrook | #include <errno.h> |
29 | faf07963 | pbrook | #include <unistd.h> |
30 | faf07963 | pbrook | #include <fcntl.h> |
31 | faf07963 | pbrook | #include <sys/stat.h> |
32 | bf9298b9 | aliguori | #include "config-host.h" |
33 | faf07963 | pbrook | |
34 | faf07963 | pbrook | #ifndef O_LARGEFILE
|
35 | faf07963 | pbrook | #define O_LARGEFILE 0 |
36 | faf07963 | pbrook | #endif
|
37 | faf07963 | pbrook | #ifndef O_BINARY
|
38 | faf07963 | pbrook | #define O_BINARY 0 |
39 | faf07963 | pbrook | #endif
|
40 | faf07963 | pbrook | |
41 | faf07963 | pbrook | #ifndef ENOMEDIUM
|
42 | faf07963 | pbrook | #define ENOMEDIUM ENODEV
|
43 | faf07963 | pbrook | #endif
|
44 | faf07963 | pbrook | |
45 | bf9298b9 | aliguori | #ifndef HAVE_IOVEC
|
46 | bf9298b9 | aliguori | #define HAVE_IOVEC
|
47 | bf9298b9 | aliguori | struct iovec {
|
48 | bf9298b9 | aliguori | void *iov_base;
|
49 | bf9298b9 | aliguori | size_t iov_len; |
50 | bf9298b9 | aliguori | }; |
51 | 331dadde | blueswir1 | #else
|
52 | 331dadde | blueswir1 | #include <sys/uio.h> |
53 | bf9298b9 | aliguori | #endif
|
54 | bf9298b9 | aliguori | |
55 | faf07963 | pbrook | #ifdef _WIN32
|
56 | faf07963 | pbrook | #define fsync _commit
|
57 | faf07963 | pbrook | #define lseek _lseeki64
|
58 | faf07963 | pbrook | #define ENOTSUP 4096 |
59 | faf07963 | pbrook | extern int qemu_ftruncate64(int, int64_t); |
60 | faf07963 | pbrook | #define ftruncate qemu_ftruncate64
|
61 | faf07963 | pbrook | |
62 | faf07963 | pbrook | |
63 | faf07963 | pbrook | static inline char *realpath(const char *path, char *resolved_path) |
64 | faf07963 | pbrook | { |
65 | faf07963 | pbrook | _fullpath(resolved_path, path, _MAX_PATH); |
66 | faf07963 | pbrook | return resolved_path;
|
67 | faf07963 | pbrook | } |
68 | faf07963 | pbrook | |
69 | faf07963 | pbrook | #define PRId64 "I64d" |
70 | faf07963 | pbrook | #define PRIx64 "I64x" |
71 | faf07963 | pbrook | #define PRIu64 "I64u" |
72 | faf07963 | pbrook | #define PRIo64 "I64o" |
73 | faf07963 | pbrook | #endif
|
74 | faf07963 | pbrook | |
75 | faf07963 | pbrook | /* FIXME: Remove NEED_CPU_H. */
|
76 | faf07963 | pbrook | #ifndef NEED_CPU_H
|
77 | faf07963 | pbrook | |
78 | faf07963 | pbrook | #include <setjmp.h> |
79 | faf07963 | pbrook | #include "osdep.h" |
80 | faf07963 | pbrook | #include "bswap.h" |
81 | faf07963 | pbrook | |
82 | faf07963 | pbrook | #else
|
83 | faf07963 | pbrook | |
84 | faf07963 | pbrook | #include "cpu.h" |
85 | faf07963 | pbrook | |
86 | faf07963 | pbrook | #endif /* !defined(NEED_CPU_H) */ |
87 | faf07963 | pbrook | |
88 | faf07963 | pbrook | /* bottom halves */
|
89 | faf07963 | pbrook | typedef struct QEMUBH QEMUBH; |
90 | faf07963 | pbrook | |
91 | faf07963 | pbrook | typedef void QEMUBHFunc(void *opaque); |
92 | faf07963 | pbrook | |
93 | faf07963 | pbrook | QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
|
94 | faf07963 | pbrook | void qemu_bh_schedule(QEMUBH *bh);
|
95 | 80d3580b | aliguori | /* Bottom halfs that are scheduled from a bottom half handler are instantly
|
96 | 80d3580b | aliguori | * invoked. This can create an infinite loop if a bottom half handler
|
97 | 80d3580b | aliguori | * schedules itself. qemu_bh_schedule_idle() avoids this infinite loop by
|
98 | 80d3580b | aliguori | * ensuring that the bottom half isn't executed until the next main loop
|
99 | 80d3580b | aliguori | * iteration.
|
100 | 80d3580b | aliguori | */
|
101 | 1b435b10 | aliguori | void qemu_bh_schedule_idle(QEMUBH *bh);
|
102 | faf07963 | pbrook | void qemu_bh_cancel(QEMUBH *bh);
|
103 | faf07963 | pbrook | void qemu_bh_delete(QEMUBH *bh);
|
104 | faf07963 | pbrook | int qemu_bh_poll(void); |
105 | faf07963 | pbrook | |
106 | 87ecb68b | pbrook | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
107 | 87ecb68b | pbrook | |
108 | f6503059 | balrog | void qemu_get_timedate(struct tm *tm, int offset); |
109 | f6503059 | balrog | int qemu_timedate_diff(struct tm *tm); |
110 | f6503059 | balrog | |
111 | faf07963 | pbrook | /* cutils.c */
|
112 | faf07963 | pbrook | void pstrcpy(char *buf, int buf_size, const char *str); |
113 | faf07963 | pbrook | char *pstrcat(char *buf, int buf_size, const char *s); |
114 | faf07963 | pbrook | int strstart(const char *str, const char *val, const char **ptr); |
115 | faf07963 | pbrook | int stristart(const char *str, const char *val, const char **ptr); |
116 | faf07963 | pbrook | time_t mktimegm(struct tm *tm);
|
117 | ad46db9a | blueswir1 | int qemu_fls(int i); |
118 | faf07963 | pbrook | |
119 | cd390083 | blueswir1 | #define qemu_isalnum(c) isalnum((unsigned char)(c)) |
120 | cd390083 | blueswir1 | #define qemu_isalpha(c) isalpha((unsigned char)(c)) |
121 | cd390083 | blueswir1 | #define qemu_iscntrl(c) iscntrl((unsigned char)(c)) |
122 | cd390083 | blueswir1 | #define qemu_isdigit(c) isdigit((unsigned char)(c)) |
123 | cd390083 | blueswir1 | #define qemu_isgraph(c) isgraph((unsigned char)(c)) |
124 | cd390083 | blueswir1 | #define qemu_islower(c) islower((unsigned char)(c)) |
125 | cd390083 | blueswir1 | #define qemu_isprint(c) isprint((unsigned char)(c)) |
126 | cd390083 | blueswir1 | #define qemu_ispunct(c) ispunct((unsigned char)(c)) |
127 | cd390083 | blueswir1 | #define qemu_isspace(c) isspace((unsigned char)(c)) |
128 | cd390083 | blueswir1 | #define qemu_isupper(c) isupper((unsigned char)(c)) |
129 | cd390083 | blueswir1 | #define qemu_isxdigit(c) isxdigit((unsigned char)(c)) |
130 | cd390083 | blueswir1 | #define qemu_tolower(c) tolower((unsigned char)(c)) |
131 | cd390083 | blueswir1 | #define qemu_toupper(c) toupper((unsigned char)(c)) |
132 | cd390083 | blueswir1 | #define qemu_isascii(c) isascii((unsigned char)(c)) |
133 | cd390083 | blueswir1 | #define qemu_toascii(c) toascii((unsigned char)(c)) |
134 | cd390083 | blueswir1 | |
135 | ca10f867 | aurel32 | void *qemu_malloc(size_t size);
|
136 | 2137b4cc | ths | void *qemu_realloc(void *ptr, size_t size); |
137 | ca10f867 | aurel32 | void *qemu_mallocz(size_t size);
|
138 | ca10f867 | aurel32 | void qemu_free(void *ptr); |
139 | ca10f867 | aurel32 | char *qemu_strdup(const char *str); |
140 | ac4b0d0c | balrog | char *qemu_strndup(const char *str, size_t size); |
141 | ca10f867 | aurel32 | |
142 | ca10f867 | aurel32 | void *get_mmap_addr(unsigned long size); |
143 | ca10f867 | aurel32 | |
144 | ca10f867 | aurel32 | |
145 | 87ecb68b | pbrook | /* Error handling. */
|
146 | 87ecb68b | pbrook | |
147 | a5e50b26 | malc | void QEMU_NORETURN hw_error(const char *fmt, ...) |
148 | 7d99a001 | blueswir1 | __attribute__ ((__format__ (__printf__, 1, 2))); |
149 | 87ecb68b | pbrook | |
150 | 87ecb68b | pbrook | /* IO callbacks. */
|
151 | 87ecb68b | pbrook | typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); |
152 | 87ecb68b | pbrook | typedef int IOCanRWHandler(void *opaque); |
153 | 87ecb68b | pbrook | typedef void IOHandler(void *opaque); |
154 | 87ecb68b | pbrook | |
155 | 87ecb68b | pbrook | struct ParallelIOArg {
|
156 | 87ecb68b | pbrook | void *buffer;
|
157 | 87ecb68b | pbrook | int count;
|
158 | 87ecb68b | pbrook | }; |
159 | 87ecb68b | pbrook | |
160 | 87ecb68b | pbrook | typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); |
161 | 87ecb68b | pbrook | |
162 | 87ecb68b | pbrook | /* A load of opaque types so that device init declarations don't have to
|
163 | 87ecb68b | pbrook | pull in all the real definitions. */
|
164 | 87ecb68b | pbrook | typedef struct NICInfo NICInfo; |
165 | 1ae26a18 | balrog | typedef struct HCIInfo HCIInfo; |
166 | 87ecb68b | pbrook | typedef struct AudioState AudioState; |
167 | 87ecb68b | pbrook | typedef struct BlockDriverState BlockDriverState; |
168 | 87ecb68b | pbrook | typedef struct DisplayState DisplayState; |
169 | 7d957bd8 | aliguori | typedef struct DisplayChangeListener DisplayChangeListener; |
170 | 7d957bd8 | aliguori | typedef struct DisplaySurface DisplaySurface; |
171 | 7d957bd8 | aliguori | typedef struct PixelFormat PixelFormat; |
172 | 87ecb68b | pbrook | typedef struct TextConsole TextConsole; |
173 | c60e08d9 | pbrook | typedef TextConsole QEMUConsole;
|
174 | 87ecb68b | pbrook | typedef struct CharDriverState CharDriverState; |
175 | 87ecb68b | pbrook | typedef struct VLANState VLANState; |
176 | 87ecb68b | pbrook | typedef struct QEMUFile QEMUFile; |
177 | 87ecb68b | pbrook | typedef struct i2c_bus i2c_bus; |
178 | 87ecb68b | pbrook | typedef struct i2c_slave i2c_slave; |
179 | 87ecb68b | pbrook | typedef struct SMBusDevice SMBusDevice; |
180 | 87ecb68b | pbrook | typedef struct QEMUTimer QEMUTimer; |
181 | 87ecb68b | pbrook | typedef struct PCIBus PCIBus; |
182 | 87ecb68b | pbrook | typedef struct PCIDevice PCIDevice; |
183 | 87ecb68b | pbrook | typedef struct SerialState SerialState; |
184 | 87ecb68b | pbrook | typedef struct IRQState *qemu_irq; |
185 | 87ecb68b | pbrook | struct pcmcia_card_s;
|
186 | 87ecb68b | pbrook | |
187 | b3c7724c | pbrook | /* CPU save/load. */
|
188 | b3c7724c | pbrook | void cpu_save(QEMUFile *f, void *opaque); |
189 | b3c7724c | pbrook | int cpu_load(QEMUFile *f, void *opaque, int version_id); |
190 | b3c7724c | pbrook | |
191 | 9e472e10 | aliguori | /* Force QEMU to stop what it's doing and service IO */
|
192 | 9e472e10 | aliguori | void qemu_service_io(void); |
193 | 9e472e10 | aliguori | |
194 | 44e3ee8a | aliguori | typedef struct QEMUIOVector { |
195 | 44e3ee8a | aliguori | struct iovec *iov;
|
196 | 44e3ee8a | aliguori | int niov;
|
197 | 44e3ee8a | aliguori | int nalloc;
|
198 | 249aa745 | aliguori | size_t size; |
199 | 44e3ee8a | aliguori | } QEMUIOVector; |
200 | 44e3ee8a | aliguori | |
201 | 44e3ee8a | aliguori | void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint); |
202 | 44e3ee8a | aliguori | void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len); |
203 | 44e3ee8a | aliguori | void qemu_iovec_destroy(QEMUIOVector *qiov);
|
204 | be959463 | aliguori | void qemu_iovec_reset(QEMUIOVector *qiov);
|
205 | 44e3ee8a | aliguori | void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf); |
206 | 249aa745 | aliguori | void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count); |
207 | 44e3ee8a | aliguori | |
208 | 7d99a001 | blueswir1 | #endif /* dyngen-exec.h hack */ |
209 | 7d99a001 | blueswir1 | |
210 | faf07963 | pbrook | #endif |