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