1 /* Common header file that is included by all of qemu. */
5 #define QEMU_NORETURN __attribute__ ((__noreturn__))
6 #ifdef CONFIG_GCC_ATTRIBUTE_WARN_UNUSED_RESULT
7 #define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
9 #define QEMU_WARN_UNUSED_RESULT
12 /* Hack around the mess dyngen-exec.h causes: We need QEMU_NORETURN in files that
13 cannot include the following headers without conflicts. This condition has
14 to be removed once dyngen is gone. */
15 #ifndef __DYNGEN_EXEC_H__
17 /* we put basic includes here to avoid repeating them in device drivers */
32 #include "config-host.h"
41 #define MAP_ANONYMOUS MAP_ANON
44 #define ENOMEDIUM ENODEV
62 #define lseek _lseeki64
63 extern int qemu_ftruncate64(int, int64_t);
64 #define ftruncate qemu_ftruncate64
66 static inline char *realpath(const char *path
, char *resolved_path
)
68 _fullpath(resolved_path
, path
, _MAX_PATH
);
78 /* FIXME: Remove NEED_CPU_H. */
89 #endif /* !defined(NEED_CPU_H) */
92 typedef struct QEMUBH QEMUBH
;
94 typedef void QEMUBHFunc(void *opaque
);
96 void async_context_push(void);
97 void async_context_pop(void);
98 int get_async_context_id(void);
100 QEMUBH
*qemu_bh_new(QEMUBHFunc
*cb
, void *opaque
);
101 void qemu_bh_schedule(QEMUBH
*bh
);
102 /* Bottom halfs that are scheduled from a bottom half handler are instantly
103 * invoked. This can create an infinite loop if a bottom half handler
104 * schedules itself. qemu_bh_schedule_idle() avoids this infinite loop by
105 * ensuring that the bottom half isn't executed until the next main loop
108 void qemu_bh_schedule_idle(QEMUBH
*bh
);
109 void qemu_bh_cancel(QEMUBH
*bh
);
110 void qemu_bh_delete(QEMUBH
*bh
);
111 int qemu_bh_poll(void);
112 void qemu_bh_update_timeout(int *timeout
);
114 uint64_t muldiv64(uint64_t a
, uint32_t b
, uint32_t c
);
116 void qemu_get_timedate(struct tm
*tm
, int offset
);
117 int qemu_timedate_diff(struct tm
*tm
);
120 void pstrcpy(char *buf
, int buf_size
, const char *str
);
121 char *pstrcat(char *buf
, int buf_size
, const char *s
);
122 int strstart(const char *str
, const char *val
, const char **ptr
);
123 int stristart(const char *str
, const char *val
, const char **ptr
);
124 int qemu_strnlen(const char *s
, int max_len
);
125 time_t mktimegm(struct tm
*tm
);
127 int qemu_fdatasync(int fd
);
130 void init_paths(const char *prefix
);
131 const char *path(const char *pathname
);
133 #define qemu_isalnum(c) isalnum((unsigned char)(c))
134 #define qemu_isalpha(c) isalpha((unsigned char)(c))
135 #define qemu_iscntrl(c) iscntrl((unsigned char)(c))
136 #define qemu_isdigit(c) isdigit((unsigned char)(c))
137 #define qemu_isgraph(c) isgraph((unsigned char)(c))
138 #define qemu_islower(c) islower((unsigned char)(c))
139 #define qemu_isprint(c) isprint((unsigned char)(c))
140 #define qemu_ispunct(c) ispunct((unsigned char)(c))
141 #define qemu_isspace(c) isspace((unsigned char)(c))
142 #define qemu_isupper(c) isupper((unsigned char)(c))
143 #define qemu_isxdigit(c) isxdigit((unsigned char)(c))
144 #define qemu_tolower(c) tolower((unsigned char)(c))
145 #define qemu_toupper(c) toupper((unsigned char)(c))
146 #define qemu_isascii(c) isascii((unsigned char)(c))
147 #define qemu_toascii(c) toascii((unsigned char)(c))
149 void *qemu_malloc(size_t size
);
150 void *qemu_realloc(void *ptr
, size_t size
);
151 void *qemu_mallocz(size_t size
);
152 void qemu_free(void *ptr
);
153 char *qemu_strdup(const char *str
);
154 char *qemu_strndup(const char *str
, size_t size
);
156 void *get_mmap_addr(unsigned long size
);
159 void qemu_mutex_lock_iothread(void);
160 void qemu_mutex_unlock_iothread(void);
162 /* Error handling. */
164 void QEMU_NORETURN
hw_error(const char *fmt
, ...)
165 __attribute__ ((__format__ (__printf__
, 1, 2)));
168 typedef void IOReadHandler(void *opaque
, const uint8_t *buf
, int size
);
169 typedef int IOCanRWHandler(void *opaque
);
170 typedef void IOHandler(void *opaque
);
172 struct ParallelIOArg
{
177 typedef int (*DMA_transfer_handler
) (void *opaque
, int nchan
, int pos
, int size
);
179 /* A load of opaque types so that device init declarations don't have to
180 pull in all the real definitions. */
181 typedef struct NICInfo NICInfo
;
182 typedef struct HCIInfo HCIInfo
;
183 typedef struct AudioState AudioState
;
184 typedef struct BlockDriverState BlockDriverState
;
185 typedef struct DisplayState DisplayState
;
186 typedef struct DisplayChangeListener DisplayChangeListener
;
187 typedef struct DisplaySurface DisplaySurface
;
188 typedef struct DisplayAllocator DisplayAllocator
;
189 typedef struct PixelFormat PixelFormat
;
190 typedef struct TextConsole TextConsole
;
191 typedef TextConsole QEMUConsole
;
192 typedef struct CharDriverState CharDriverState
;
193 typedef struct MACAddr MACAddr
;
194 typedef struct VLANState VLANState
;
195 typedef struct VLANClientState VLANClientState
;
196 typedef struct QEMUFile QEMUFile
;
197 typedef struct i2c_bus i2c_bus
;
198 typedef struct i2c_slave i2c_slave
;
199 typedef struct SMBusDevice SMBusDevice
;
200 typedef struct QEMUTimer QEMUTimer
;
201 typedef struct PCIBus PCIBus
;
202 typedef struct PCIDevice PCIDevice
;
203 typedef struct SerialState SerialState
;
204 typedef struct IRQState
*qemu_irq
;
205 typedef struct PCMCIACardState PCMCIACardState
;
206 typedef struct MouseTransformInfo MouseTransformInfo
;
207 typedef struct uWireSlave uWireSlave
;
208 typedef struct I2SCodec I2SCodec
;
209 typedef struct DeviceState DeviceState
;
210 typedef struct SSIBus SSIBus
;
213 void cpu_save(QEMUFile
*f
, void *opaque
);
214 int cpu_load(QEMUFile
*f
, void *opaque
, int version_id
);
216 /* Force QEMU to stop what it's doing and service IO */
217 void qemu_service_io(void);
220 struct qemu_work_item
{
221 struct qemu_work_item
*next
;
222 void (*func
)(void *data
);
227 /* Force QEMU to process pending events */
228 void qemu_notify_event(void);
231 void qemu_cpu_kick(void *env
);
232 int qemu_cpu_self(void *env
);
234 #ifdef CONFIG_USER_ONLY
235 #define qemu_init_vcpu(env) do { } while (0)
237 void qemu_init_vcpu(void *env
);
240 typedef struct QEMUIOVector
{
247 void qemu_iovec_init(QEMUIOVector
*qiov
, int alloc_hint
);
248 void qemu_iovec_init_external(QEMUIOVector
*qiov
, struct iovec
*iov
, int niov
);
249 void qemu_iovec_add(QEMUIOVector
*qiov
, void *base
, size_t len
);
250 void qemu_iovec_concat(QEMUIOVector
*dst
, QEMUIOVector
*src
, size_t size
);
251 void qemu_iovec_destroy(QEMUIOVector
*qiov
);
252 void qemu_iovec_reset(QEMUIOVector
*qiov
);
253 void qemu_iovec_to_buffer(QEMUIOVector
*qiov
, void *buf
);
254 void qemu_iovec_from_buffer(QEMUIOVector
*qiov
, const void *buf
, size_t count
);
257 typedef struct Monitor Monitor
;
261 #endif /* dyngen-exec.h hack */