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 | # if !defined(_MSC_VER)
|
---|
9 | # include <inttypes.h>
|
---|
10 | # endif
|
---|
11 |
|
---|
12 | void pstrcpy(char *buf, int buf_size, const char *str);
|
---|
13 | char *pstrcat(char *buf, int buf_size, const char *s);
|
---|
14 | # define snprintf RTStrPrintf
|
---|
15 |
|
---|
16 | # ifdef _MSC_VER
|
---|
17 | # define PRId32 "d"
|
---|
18 | # define PRIx32 "x"
|
---|
19 | # define PRIu32 "u"
|
---|
20 | # define PRIo32 "o"
|
---|
21 | # ifdef DEBUG_TMP_LOGGING
|
---|
22 | # define PRId64 "I64d"
|
---|
23 | # define PRIx64 "I64x"
|
---|
24 | # define PRIu64 "I64u"
|
---|
25 | # define PRIo64 "I64o"
|
---|
26 | # else
|
---|
27 | # define PRId64 "RI64"
|
---|
28 | # define PRIx64 "RX64"
|
---|
29 | # define PRIu64 "RU64"
|
---|
30 | # endif
|
---|
31 | # endif /* _MSC_VER */
|
---|
32 |
|
---|
33 | #else /* !VBOX */
|
---|
34 | /* we put basic includes here to avoid repeating them in device drivers */
|
---|
35 | #include <stdlib.h>
|
---|
36 | #include <stdio.h>
|
---|
37 | #include <stdarg.h>
|
---|
38 | #include <string.h>
|
---|
39 | #include <inttypes.h>
|
---|
40 | #include <limits.h>
|
---|
41 | #include <time.h>
|
---|
42 | #include <ctype.h>
|
---|
43 | #include <errno.h>
|
---|
44 | #include <unistd.h>
|
---|
45 | #include <fcntl.h>
|
---|
46 | #include <sys/stat.h>
|
---|
47 |
|
---|
48 | #ifndef O_LARGEFILE
|
---|
49 | #define O_LARGEFILE 0
|
---|
50 | #endif
|
---|
51 | #ifndef O_BINARY
|
---|
52 | #define O_BINARY 0
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | #ifndef ENOMEDIUM
|
---|
56 | #define ENOMEDIUM ENODEV
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | #ifdef _WIN32
|
---|
60 | #define WIN32_LEAN_AND_MEAN
|
---|
61 | #include <windows.h>
|
---|
62 | #define fsync _commit
|
---|
63 | #define lseek _lseeki64
|
---|
64 | #define ENOTSUP 4096
|
---|
65 | extern int qemu_ftruncate64(int, int64_t);
|
---|
66 | #define ftruncate qemu_ftruncate64
|
---|
67 |
|
---|
68 |
|
---|
69 | static inline char *realpath(const char *path, char *resolved_path)
|
---|
70 | {
|
---|
71 | _fullpath(resolved_path, path, _MAX_PATH);
|
---|
72 | return resolved_path;
|
---|
73 | }
|
---|
74 |
|
---|
75 | #define PRId64 "I64d"
|
---|
76 | #define PRIx64 "I64x"
|
---|
77 | #define PRIu64 "I64u"
|
---|
78 | #define PRIo64 "I64o"
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | /* FIXME: Remove NEED_CPU_H. */
|
---|
82 | #ifndef NEED_CPU_H
|
---|
83 |
|
---|
84 | #include "config-host.h"
|
---|
85 | #include <setjmp.h>
|
---|
86 | #include "osdep.h"
|
---|
87 | #include "bswap.h"
|
---|
88 |
|
---|
89 | #else
|
---|
90 |
|
---|
91 | #include "cpu.h"
|
---|
92 |
|
---|
93 | #endif /* !defined(NEED_CPU_H) */
|
---|
94 |
|
---|
95 | /* bottom halves */
|
---|
96 | typedef struct QEMUBH QEMUBH;
|
---|
97 |
|
---|
98 | typedef void QEMUBHFunc(void *opaque);
|
---|
99 |
|
---|
100 | QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
|
---|
101 | void qemu_bh_schedule(QEMUBH *bh);
|
---|
102 | void qemu_bh_cancel(QEMUBH *bh);
|
---|
103 | void qemu_bh_delete(QEMUBH *bh);
|
---|
104 | int qemu_bh_poll(void);
|
---|
105 |
|
---|
106 | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
|
---|
107 |
|
---|
108 | void qemu_get_timedate(struct tm *tm, int offset);
|
---|
109 | int qemu_timedate_diff(struct tm *tm);
|
---|
110 |
|
---|
111 | /* cutils.c */
|
---|
112 | void pstrcpy(char *buf, int buf_size, const char *str);
|
---|
113 | char *pstrcat(char *buf, int buf_size, const char *s);
|
---|
114 | int strstart(const char *str, const char *val, const char **ptr);
|
---|
115 | int stristart(const char *str, const char *val, const char **ptr);
|
---|
116 | time_t mktimegm(struct tm *tm);
|
---|
117 |
|
---|
118 | void *qemu_malloc(size_t size);
|
---|
119 | void *qemu_realloc(void *ptr, size_t size);
|
---|
120 | void *qemu_mallocz(size_t size);
|
---|
121 | void qemu_free(void *ptr);
|
---|
122 | char *qemu_strdup(const char *str);
|
---|
123 |
|
---|
124 | void *get_mmap_addr(unsigned long size);
|
---|
125 |
|
---|
126 |
|
---|
127 | /* Error handling. */
|
---|
128 |
|
---|
129 | void hw_error(const char *fmt, ...)
|
---|
130 | __attribute__ ((__format__ (__printf__, 1, 2)))
|
---|
131 | __attribute__ ((__noreturn__));
|
---|
132 |
|
---|
133 | /* IO callbacks. */
|
---|
134 | typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
|
---|
135 | typedef int IOCanRWHandler(void *opaque);
|
---|
136 | typedef void IOHandler(void *opaque);
|
---|
137 |
|
---|
138 | struct ParallelIOArg {
|
---|
139 | void *buffer;
|
---|
140 | int count;
|
---|
141 | };
|
---|
142 |
|
---|
143 | typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
|
---|
144 |
|
---|
145 | /* A load of opaque types so that device init declarations don't have to
|
---|
146 | pull in all the real definitions. */
|
---|
147 | typedef struct NICInfo NICInfo;
|
---|
148 | typedef struct HCIInfo HCIInfo;
|
---|
149 | typedef struct AudioState AudioState;
|
---|
150 | typedef struct BlockDriverState BlockDriverState;
|
---|
151 | typedef struct DisplayState DisplayState;
|
---|
152 | typedef struct TextConsole TextConsole;
|
---|
153 | typedef TextConsole QEMUConsole;
|
---|
154 | typedef struct CharDriverState CharDriverState;
|
---|
155 | typedef struct VLANState VLANState;
|
---|
156 | typedef struct QEMUFile QEMUFile;
|
---|
157 | typedef struct i2c_bus i2c_bus;
|
---|
158 | typedef struct i2c_slave i2c_slave;
|
---|
159 | typedef struct SMBusDevice SMBusDevice;
|
---|
160 | typedef struct QEMUTimer QEMUTimer;
|
---|
161 | typedef struct PCIBus PCIBus;
|
---|
162 | typedef struct PCIDevice PCIDevice;
|
---|
163 | typedef struct SerialState SerialState;
|
---|
164 | typedef struct IRQState *qemu_irq;
|
---|
165 | struct pcmcia_card_s;
|
---|
166 |
|
---|
167 | /* CPU save/load. */
|
---|
168 | void cpu_save(QEMUFile *f, void *opaque);
|
---|
169 | int cpu_load(QEMUFile *f, void *opaque, int version_id);
|
---|
170 |
|
---|
171 | /* Force QEMU to stop what it's doing and service IO */
|
---|
172 | void qemu_service_io(void);
|
---|
173 | #endif /* !VBOX */
|
---|
174 |
|
---|
175 | #endif
|
---|