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