00001
00002 #ifndef QEMU_COMMON_H
00003 #define QEMU_COMMON_H
00004
00005 #ifdef _WIN32
00006 #define WIN32_LEAN_AND_MEAN
00007 #define WINVER 0x0501
00008 #include <windows.h>
00009 #endif
00010
00011 #define QEMU_NORETURN __attribute__ ((__noreturn__))
00012
00013
00014
00015
00016 #ifndef __DYNGEN_EXEC_H__
00017
00018
00019 #include <stdlib.h>
00020 #include <stdio.h>
00021 #include <stdarg.h>
00022 #include <string.h>
00023 #include <strings.h>
00024 #include <inttypes.h>
00025 #include <limits.h>
00026 #include <time.h>
00027 #include <ctype.h>
00028 #include <errno.h>
00029 #include <unistd.h>
00030 #include <fcntl.h>
00031 #include <sys/stat.h>
00032 #include "config-host.h"
00033
00034 #ifndef O_LARGEFILE
00035 #define O_LARGEFILE 0
00036 #endif
00037 #ifndef O_BINARY
00038 #define O_BINARY 0
00039 #endif
00040
00041 #ifndef ENOMEDIUM
00042 #define ENOMEDIUM ENODEV
00043 #endif
00044
00045 #ifndef HAVE_IOVEC
00046 #define HAVE_IOVEC
00047 struct iovec {
00048 void *iov_base;
00049 size_t iov_len;
00050 };
00051 #else
00052 #include <sys/uio.h>
00053 #endif
00054
00055 #ifdef _WIN32
00056 #define fsync _commit
00057 #define lseek _lseeki64
00058 #define ENOTSUP 4096
00059 extern int qemu_ftruncate64(int, int64_t);
00060 #define ftruncate qemu_ftruncate64
00061
00062
00063 static inline char *realpath(const char *path, char *resolved_path)
00064 {
00065 _fullpath(resolved_path, path, _MAX_PATH);
00066 return resolved_path;
00067 }
00068
00069 #define PRId64 "I64d"
00070 #define PRIx64 "I64x"
00071 #define PRIu64 "I64u"
00072 #define PRIo64 "I64o"
00073 #endif
00074
00075
00076 #ifndef NEED_CPU_H
00077
00078 #include <setjmp.h>
00079 #include "osdep.h"
00080 #include "bswap.h"
00081
00082 #else
00083
00084 #include "cpu.h"
00085
00086 #endif
00087
00088
00089 typedef struct QEMUBH QEMUBH;
00090
00091 typedef void QEMUBHFunc(void *opaque);
00092
00093 QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
00094 void qemu_bh_schedule(QEMUBH *bh);
00095
00096
00097
00098
00099
00100
00101 void qemu_bh_schedule_idle(QEMUBH *bh);
00102 void qemu_bh_cancel(QEMUBH *bh);
00103 void qemu_bh_delete(QEMUBH *bh);
00104 int qemu_bh_poll(void);
00105
00106 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
00107
00108 void qemu_get_timedate(struct tm *tm, int offset);
00109 int qemu_timedate_diff(struct tm *tm);
00110
00111
00112 void pstrcpy(char *buf, int buf_size, const char *str);
00113 char *pstrcat(char *buf, int buf_size, const char *s);
00114 int strstart(const char *str, const char *val, const char **ptr);
00115 int stristart(const char *str, const char *val, const char **ptr);
00116 time_t mktimegm(struct tm *tm);
00117 int qemu_fls(int i);
00118
00119 #define qemu_isalnum(c) isalnum((unsigned char)(c))
00120 #define qemu_isalpha(c) isalpha((unsigned char)(c))
00121 #define qemu_iscntrl(c) iscntrl((unsigned char)(c))
00122 #define qemu_isdigit(c) isdigit((unsigned char)(c))
00123 #define qemu_isgraph(c) isgraph((unsigned char)(c))
00124 #define qemu_islower(c) islower((unsigned char)(c))
00125 #define qemu_isprint(c) isprint((unsigned char)(c))
00126 #define qemu_ispunct(c) ispunct((unsigned char)(c))
00127 #define qemu_isspace(c) isspace((unsigned char)(c))
00128 #define qemu_isupper(c) isupper((unsigned char)(c))
00129 #define qemu_isxdigit(c) isxdigit((unsigned char)(c))
00130 #define qemu_tolower(c) tolower((unsigned char)(c))
00131 #define qemu_toupper(c) toupper((unsigned char)(c))
00132 #define qemu_isascii(c) isascii((unsigned char)(c))
00133 #define qemu_toascii(c) toascii((unsigned char)(c))
00134
00135 void *qemu_malloc(size_t size);
00136 void *qemu_realloc(void *ptr, size_t size);
00137 void *qemu_mallocz(size_t size);
00138 void qemu_free(void *ptr);
00139 char *qemu_strdup(const char *str);
00140 char *qemu_strndup(const char *str, size_t size);
00141
00142 void *get_mmap_addr(unsigned long size);
00143
00144
00145
00146
00147 void QEMU_NORETURN hw_error(const char *fmt, ...)
00148 __attribute__ ((__format__ (__printf__, 1, 2)));
00149
00150
00151 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
00152 typedef int IOCanRWHandler(void *opaque);
00153 typedef void IOHandler(void *opaque);
00154
00155 struct ParallelIOArg {
00156 void *buffer;
00157 int count;
00158 };
00159
00160 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
00161
00162
00163
00164 typedef struct NICInfo NICInfo;
00165 typedef struct HCIInfo HCIInfo;
00166 typedef struct AudioState AudioState;
00167 typedef struct BlockDriverState BlockDriverState;
00168 typedef struct DisplayState DisplayState;
00169 typedef struct DisplayChangeListener DisplayChangeListener;
00170 typedef struct DisplaySurface DisplaySurface;
00171 typedef struct PixelFormat PixelFormat;
00172 typedef struct TextConsole TextConsole;
00173 typedef TextConsole QEMUConsole;
00174 typedef struct CharDriverState CharDriverState;
00175 typedef struct VLANState VLANState;
00176 typedef struct QEMUFile QEMUFile;
00177 typedef struct i2c_bus i2c_bus;
00178 typedef struct i2c_slave i2c_slave;
00179 typedef struct SMBusDevice SMBusDevice;
00180 typedef struct QEMUTimer QEMUTimer;
00181 typedef struct PCIBus PCIBus;
00182 typedef struct PCIDevice PCIDevice;
00183 typedef struct SerialState SerialState;
00184 typedef struct IRQState *qemu_irq;
00185 struct pcmcia_card_s;
00186
00187
00188 void cpu_save(QEMUFile *f, void *opaque);
00189 int cpu_load(QEMUFile *f, void *opaque, int version_id);
00190
00191
00192 void qemu_service_io(void);
00193
00194 typedef struct QEMUIOVector {
00195 struct iovec *iov;
00196 int niov;
00197 int nalloc;
00198 size_t size;
00199 } QEMUIOVector;
00200
00201 void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint);
00202 void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len);
00203 void qemu_iovec_destroy(QEMUIOVector *qiov);
00204 void qemu_iovec_reset(QEMUIOVector *qiov);
00205 void qemu_iovec_to_buffer(QEMUIOVector *qiov, void *buf);
00206 void qemu_iovec_from_buffer(QEMUIOVector *qiov, const void *buf, size_t count);
00207
00208 #endif
00209
00210 #endif