root / vl.h @ a8c490cd
History | View | Annotate | Download (13.5 kB)
1 | fc01f7e7 | bellard | /*
|
---|---|---|---|
2 | fc01f7e7 | bellard | * QEMU System Emulator header
|
3 | fc01f7e7 | bellard | *
|
4 | fc01f7e7 | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | fc01f7e7 | bellard | *
|
6 | fc01f7e7 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | fc01f7e7 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | fc01f7e7 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | fc01f7e7 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | fc01f7e7 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | fc01f7e7 | bellard | * furnished to do so, subject to the following conditions:
|
12 | fc01f7e7 | bellard | *
|
13 | fc01f7e7 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | fc01f7e7 | bellard | * all copies or substantial portions of the Software.
|
15 | fc01f7e7 | bellard | *
|
16 | fc01f7e7 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | fc01f7e7 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | fc01f7e7 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | fc01f7e7 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | fc01f7e7 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | fc01f7e7 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | fc01f7e7 | bellard | * THE SOFTWARE.
|
23 | fc01f7e7 | bellard | */
|
24 | fc01f7e7 | bellard | #ifndef VL_H
|
25 | fc01f7e7 | bellard | #define VL_H
|
26 | fc01f7e7 | bellard | |
27 | 67b915a5 | bellard | /* we put basic includes here to avoid repeating them in device drivers */
|
28 | 67b915a5 | bellard | #include <stdlib.h> |
29 | 67b915a5 | bellard | #include <stdio.h> |
30 | 67b915a5 | bellard | #include <stdarg.h> |
31 | 67b915a5 | bellard | #include <string.h> |
32 | 67b915a5 | bellard | #include <inttypes.h> |
33 | 8a7ddc38 | bellard | #include <time.h> |
34 | 67b915a5 | bellard | #include <ctype.h> |
35 | 67b915a5 | bellard | #include <errno.h> |
36 | 67b915a5 | bellard | #include <unistd.h> |
37 | 67b915a5 | bellard | #include <fcntl.h> |
38 | 67b915a5 | bellard | |
39 | 67b915a5 | bellard | #ifndef O_LARGEFILE
|
40 | 67b915a5 | bellard | #define O_LARGEFILE 0 |
41 | 67b915a5 | bellard | #endif
|
42 | 40c3bac3 | bellard | #ifndef O_BINARY
|
43 | 40c3bac3 | bellard | #define O_BINARY 0 |
44 | 40c3bac3 | bellard | #endif
|
45 | 67b915a5 | bellard | |
46 | 67b915a5 | bellard | #ifdef _WIN32
|
47 | bfbc9133 | bellard | #define lseek64 _lseeki64
|
48 | 67b915a5 | bellard | #endif
|
49 | 8a7ddc38 | bellard | |
50 | 16f62432 | bellard | #include "cpu.h" |
51 | 16f62432 | bellard | |
52 | 67b915a5 | bellard | #ifndef glue
|
53 | 67b915a5 | bellard | #define xglue(x, y) x ## y |
54 | 67b915a5 | bellard | #define glue(x, y) xglue(x, y)
|
55 | 67b915a5 | bellard | #define stringify(s) tostring(s)
|
56 | 67b915a5 | bellard | #define tostring(s) #s |
57 | 67b915a5 | bellard | #endif
|
58 | 67b915a5 | bellard | |
59 | 67b915a5 | bellard | #if defined(WORDS_BIGENDIAN)
|
60 | 67b915a5 | bellard | static inline uint32_t be32_to_cpu(uint32_t v) |
61 | 67b915a5 | bellard | { |
62 | 67b915a5 | bellard | return v;
|
63 | 67b915a5 | bellard | } |
64 | 67b915a5 | bellard | |
65 | 67b915a5 | bellard | static inline uint16_t be16_to_cpu(uint16_t v) |
66 | 67b915a5 | bellard | { |
67 | 67b915a5 | bellard | return v;
|
68 | 67b915a5 | bellard | } |
69 | 67b915a5 | bellard | |
70 | 165c6fc8 | bellard | static inline uint32_t cpu_to_be32(uint32_t v) |
71 | 165c6fc8 | bellard | { |
72 | 165c6fc8 | bellard | return v;
|
73 | 165c6fc8 | bellard | } |
74 | 165c6fc8 | bellard | |
75 | 165c6fc8 | bellard | static inline uint16_t cpu_to_be16(uint16_t v) |
76 | 165c6fc8 | bellard | { |
77 | 165c6fc8 | bellard | return v;
|
78 | 165c6fc8 | bellard | } |
79 | 165c6fc8 | bellard | |
80 | 67b915a5 | bellard | static inline uint32_t le32_to_cpu(uint32_t v) |
81 | 67b915a5 | bellard | { |
82 | 67b915a5 | bellard | return bswap32(v);
|
83 | 67b915a5 | bellard | } |
84 | 67b915a5 | bellard | |
85 | 67b915a5 | bellard | static inline uint16_t le16_to_cpu(uint16_t v) |
86 | 67b915a5 | bellard | { |
87 | 67b915a5 | bellard | return bswap16(v);
|
88 | 67b915a5 | bellard | } |
89 | 67b915a5 | bellard | |
90 | 165c6fc8 | bellard | static inline uint32_t cpu_to_le32(uint32_t v) |
91 | 165c6fc8 | bellard | { |
92 | 165c6fc8 | bellard | return bswap32(v);
|
93 | 165c6fc8 | bellard | } |
94 | 165c6fc8 | bellard | |
95 | 165c6fc8 | bellard | static inline uint16_t cpu_to_le16(uint16_t v) |
96 | 165c6fc8 | bellard | { |
97 | 165c6fc8 | bellard | return bswap16(v);
|
98 | 165c6fc8 | bellard | } |
99 | 165c6fc8 | bellard | |
100 | 67b915a5 | bellard | #else
|
101 | 165c6fc8 | bellard | |
102 | 67b915a5 | bellard | static inline uint32_t be32_to_cpu(uint32_t v) |
103 | 67b915a5 | bellard | { |
104 | 67b915a5 | bellard | return bswap32(v);
|
105 | 67b915a5 | bellard | } |
106 | 67b915a5 | bellard | |
107 | 67b915a5 | bellard | static inline uint16_t be16_to_cpu(uint16_t v) |
108 | 67b915a5 | bellard | { |
109 | 67b915a5 | bellard | return bswap16(v);
|
110 | 67b915a5 | bellard | } |
111 | 67b915a5 | bellard | |
112 | 165c6fc8 | bellard | static inline uint32_t cpu_to_be32(uint32_t v) |
113 | 165c6fc8 | bellard | { |
114 | 165c6fc8 | bellard | return bswap32(v);
|
115 | 165c6fc8 | bellard | } |
116 | 165c6fc8 | bellard | |
117 | 165c6fc8 | bellard | static inline uint16_t cpu_to_be16(uint16_t v) |
118 | 165c6fc8 | bellard | { |
119 | 165c6fc8 | bellard | return bswap16(v);
|
120 | 165c6fc8 | bellard | } |
121 | 165c6fc8 | bellard | |
122 | 67b915a5 | bellard | static inline uint32_t le32_to_cpu(uint32_t v) |
123 | 67b915a5 | bellard | { |
124 | 67b915a5 | bellard | return v;
|
125 | 67b915a5 | bellard | } |
126 | 67b915a5 | bellard | |
127 | 67b915a5 | bellard | static inline uint16_t le16_to_cpu(uint16_t v) |
128 | 67b915a5 | bellard | { |
129 | 67b915a5 | bellard | return v;
|
130 | 67b915a5 | bellard | } |
131 | 165c6fc8 | bellard | |
132 | 165c6fc8 | bellard | static inline uint32_t cpu_to_le32(uint32_t v) |
133 | 165c6fc8 | bellard | { |
134 | 165c6fc8 | bellard | return v;
|
135 | 165c6fc8 | bellard | } |
136 | 165c6fc8 | bellard | |
137 | 165c6fc8 | bellard | static inline uint16_t cpu_to_le16(uint16_t v) |
138 | 165c6fc8 | bellard | { |
139 | 165c6fc8 | bellard | return v;
|
140 | 165c6fc8 | bellard | } |
141 | 67b915a5 | bellard | #endif
|
142 | 67b915a5 | bellard | |
143 | 67b915a5 | bellard | |
144 | 33e3963e | bellard | /* vl.c */
|
145 | 313aa567 | bellard | extern int reset_requested; |
146 | 313aa567 | bellard | |
147 | c4b1fcc0 | bellard | typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); |
148 | c4b1fcc0 | bellard | typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); |
149 | 313aa567 | bellard | |
150 | c4b1fcc0 | bellard | int register_ioport_read(int start, int length, int size, |
151 | c4b1fcc0 | bellard | IOPortReadFunc *func, void *opaque);
|
152 | c4b1fcc0 | bellard | int register_ioport_write(int start, int length, int size, |
153 | c4b1fcc0 | bellard | IOPortWriteFunc *func, void *opaque);
|
154 | 80cabfad | bellard | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
155 | 313aa567 | bellard | |
156 | 80cabfad | bellard | void hw_error(const char *fmt, ...); |
157 | 80cabfad | bellard | |
158 | 80cabfad | bellard | int load_image(const char *filename, uint8_t *addr); |
159 | 80cabfad | bellard | extern const char *bios_dir; |
160 | 80cabfad | bellard | |
161 | 80cabfad | bellard | void pstrcpy(char *buf, int buf_size, const char *str); |
162 | 80cabfad | bellard | char *pstrcat(char *buf, int buf_size, const char *s); |
163 | 33e3963e | bellard | |
164 | c4b1fcc0 | bellard | int serial_open_device(void); |
165 | c4b1fcc0 | bellard | |
166 | 8a7ddc38 | bellard | extern int vm_running; |
167 | 8a7ddc38 | bellard | |
168 | 8a7ddc38 | bellard | typedef void VMStopHandler(void *opaque, int reason); |
169 | 8a7ddc38 | bellard | |
170 | 8a7ddc38 | bellard | int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque); |
171 | 8a7ddc38 | bellard | void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque); |
172 | 8a7ddc38 | bellard | |
173 | 8a7ddc38 | bellard | void vm_start(void); |
174 | 8a7ddc38 | bellard | void vm_stop(int reason); |
175 | 8a7ddc38 | bellard | |
176 | aaaa7df6 | bellard | extern int audio_enabled; |
177 | aaaa7df6 | bellard | |
178 | c20709aa | bellard | /* async I/O support */
|
179 | c20709aa | bellard | |
180 | c20709aa | bellard | typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); |
181 | c20709aa | bellard | typedef int IOCanRWHandler(void *opaque); |
182 | c20709aa | bellard | |
183 | c20709aa | bellard | int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, |
184 | c20709aa | bellard | IOReadHandler *fd_read, void *opaque);
|
185 | c20709aa | bellard | void qemu_del_fd_read_handler(int fd); |
186 | c20709aa | bellard | |
187 | c4b1fcc0 | bellard | /* network redirectors support */
|
188 | c4b1fcc0 | bellard | |
189 | c4b1fcc0 | bellard | #define MAX_NICS 8 |
190 | c4b1fcc0 | bellard | |
191 | c4b1fcc0 | bellard | typedef struct NetDriverState { |
192 | c20709aa | bellard | int index; /* index number in QEMU */ |
193 | c4b1fcc0 | bellard | uint8_t macaddr[6];
|
194 | c4b1fcc0 | bellard | char ifname[16]; |
195 | c20709aa | bellard | void (*send_packet)(struct NetDriverState *nd, |
196 | c20709aa | bellard | const uint8_t *buf, int size); |
197 | c20709aa | bellard | void (*add_read_packet)(struct NetDriverState *nd, |
198 | c20709aa | bellard | IOCanRWHandler *fd_can_read, |
199 | c20709aa | bellard | IOReadHandler *fd_read, void *opaque);
|
200 | c20709aa | bellard | /* tun specific data */
|
201 | c20709aa | bellard | int fd;
|
202 | c20709aa | bellard | /* slirp specific data */
|
203 | c4b1fcc0 | bellard | } NetDriverState; |
204 | c4b1fcc0 | bellard | |
205 | c4b1fcc0 | bellard | extern int nb_nics; |
206 | c4b1fcc0 | bellard | extern NetDriverState nd_table[MAX_NICS];
|
207 | c4b1fcc0 | bellard | |
208 | c20709aa | bellard | void qemu_send_packet(NetDriverState *nd, const uint8_t *buf, int size); |
209 | c20709aa | bellard | void qemu_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read,
|
210 | c20709aa | bellard | IOReadHandler *fd_read, void *opaque);
|
211 | 8a7ddc38 | bellard | |
212 | 8a7ddc38 | bellard | /* timers */
|
213 | 8a7ddc38 | bellard | |
214 | 8a7ddc38 | bellard | typedef struct QEMUClock QEMUClock; |
215 | 8a7ddc38 | bellard | typedef struct QEMUTimer QEMUTimer; |
216 | 8a7ddc38 | bellard | typedef void QEMUTimerCB(void *opaque); |
217 | 8a7ddc38 | bellard | |
218 | 8a7ddc38 | bellard | /* The real time clock should be used only for stuff which does not
|
219 | 8a7ddc38 | bellard | change the virtual machine state, as it is run even if the virtual
|
220 | 8a7ddc38 | bellard | machine is stopped. The real time clock has a frequency or 1000
|
221 | 8a7ddc38 | bellard | Hz. */
|
222 | 8a7ddc38 | bellard | extern QEMUClock *rt_clock;
|
223 | 8a7ddc38 | bellard | |
224 | 8a7ddc38 | bellard | /* Rge virtual clock is only run during the emulation. It is stopped
|
225 | 8a7ddc38 | bellard | when the virtual machine is stopped. Virtual timers use a high
|
226 | 8a7ddc38 | bellard | precision clock, usually cpu cycles (use ticks_per_sec). */
|
227 | 8a7ddc38 | bellard | extern QEMUClock *vm_clock;
|
228 | 8a7ddc38 | bellard | |
229 | 8a7ddc38 | bellard | int64_t qemu_get_clock(QEMUClock *clock); |
230 | 8a7ddc38 | bellard | |
231 | 8a7ddc38 | bellard | QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
|
232 | 8a7ddc38 | bellard | void qemu_free_timer(QEMUTimer *ts);
|
233 | 8a7ddc38 | bellard | void qemu_del_timer(QEMUTimer *ts);
|
234 | 8a7ddc38 | bellard | void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
|
235 | 8a7ddc38 | bellard | int qemu_timer_pending(QEMUTimer *ts);
|
236 | 8a7ddc38 | bellard | |
237 | 8a7ddc38 | bellard | extern int64_t ticks_per_sec;
|
238 | 8a7ddc38 | bellard | extern int pit_min_timer_count; |
239 | 8a7ddc38 | bellard | |
240 | 8a7ddc38 | bellard | void cpu_enable_ticks(void); |
241 | 8a7ddc38 | bellard | void cpu_disable_ticks(void); |
242 | 8a7ddc38 | bellard | |
243 | 8a7ddc38 | bellard | /* VM Load/Save */
|
244 | 8a7ddc38 | bellard | |
245 | 8a7ddc38 | bellard | typedef FILE QEMUFile;
|
246 | 8a7ddc38 | bellard | |
247 | 8a7ddc38 | bellard | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); |
248 | 8a7ddc38 | bellard | void qemu_put_byte(QEMUFile *f, int v); |
249 | 8a7ddc38 | bellard | void qemu_put_be16(QEMUFile *f, unsigned int v); |
250 | 8a7ddc38 | bellard | void qemu_put_be32(QEMUFile *f, unsigned int v); |
251 | 8a7ddc38 | bellard | void qemu_put_be64(QEMUFile *f, uint64_t v);
|
252 | 8a7ddc38 | bellard | int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); |
253 | 8a7ddc38 | bellard | int qemu_get_byte(QEMUFile *f);
|
254 | 8a7ddc38 | bellard | unsigned int qemu_get_be16(QEMUFile *f); |
255 | 8a7ddc38 | bellard | unsigned int qemu_get_be32(QEMUFile *f); |
256 | 8a7ddc38 | bellard | uint64_t qemu_get_be64(QEMUFile *f); |
257 | 8a7ddc38 | bellard | |
258 | 8a7ddc38 | bellard | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) |
259 | 8a7ddc38 | bellard | { |
260 | 8a7ddc38 | bellard | qemu_put_be64(f, *pv); |
261 | 8a7ddc38 | bellard | } |
262 | 8a7ddc38 | bellard | |
263 | 8a7ddc38 | bellard | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) |
264 | 8a7ddc38 | bellard | { |
265 | 8a7ddc38 | bellard | qemu_put_be32(f, *pv); |
266 | 8a7ddc38 | bellard | } |
267 | 8a7ddc38 | bellard | |
268 | 8a7ddc38 | bellard | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) |
269 | 8a7ddc38 | bellard | { |
270 | 8a7ddc38 | bellard | qemu_put_be16(f, *pv); |
271 | 8a7ddc38 | bellard | } |
272 | 8a7ddc38 | bellard | |
273 | 8a7ddc38 | bellard | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) |
274 | 8a7ddc38 | bellard | { |
275 | 8a7ddc38 | bellard | qemu_put_byte(f, *pv); |
276 | 8a7ddc38 | bellard | } |
277 | 8a7ddc38 | bellard | |
278 | 8a7ddc38 | bellard | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) |
279 | 8a7ddc38 | bellard | { |
280 | 8a7ddc38 | bellard | *pv = qemu_get_be64(f); |
281 | 8a7ddc38 | bellard | } |
282 | 8a7ddc38 | bellard | |
283 | 8a7ddc38 | bellard | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) |
284 | 8a7ddc38 | bellard | { |
285 | 8a7ddc38 | bellard | *pv = qemu_get_be32(f); |
286 | 8a7ddc38 | bellard | } |
287 | 8a7ddc38 | bellard | |
288 | 8a7ddc38 | bellard | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) |
289 | 8a7ddc38 | bellard | { |
290 | 8a7ddc38 | bellard | *pv = qemu_get_be16(f); |
291 | 8a7ddc38 | bellard | } |
292 | 8a7ddc38 | bellard | |
293 | 8a7ddc38 | bellard | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) |
294 | 8a7ddc38 | bellard | { |
295 | 8a7ddc38 | bellard | *pv = qemu_get_byte(f); |
296 | 8a7ddc38 | bellard | } |
297 | 8a7ddc38 | bellard | |
298 | 8a7ddc38 | bellard | int64_t qemu_ftell(QEMUFile *f); |
299 | 8a7ddc38 | bellard | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
|
300 | 8a7ddc38 | bellard | |
301 | 8a7ddc38 | bellard | typedef void SaveStateHandler(QEMUFile *f, void *opaque); |
302 | 8a7ddc38 | bellard | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); |
303 | 8a7ddc38 | bellard | |
304 | 8a7ddc38 | bellard | int qemu_loadvm(const char *filename); |
305 | 8a7ddc38 | bellard | int qemu_savevm(const char *filename); |
306 | 8a7ddc38 | bellard | int register_savevm(const char *idstr, |
307 | 8a7ddc38 | bellard | int instance_id,
|
308 | 8a7ddc38 | bellard | int version_id,
|
309 | 8a7ddc38 | bellard | SaveStateHandler *save_state, |
310 | 8a7ddc38 | bellard | LoadStateHandler *load_state, |
311 | 8a7ddc38 | bellard | void *opaque);
|
312 | 8a7ddc38 | bellard | void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
|
313 | 8a7ddc38 | bellard | void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
|
314 | c4b1fcc0 | bellard | |
315 | fc01f7e7 | bellard | /* block.c */
|
316 | fc01f7e7 | bellard | typedef struct BlockDriverState BlockDriverState; |
317 | fc01f7e7 | bellard | |
318 | c4b1fcc0 | bellard | BlockDriverState *bdrv_new(const char *device_name); |
319 | c4b1fcc0 | bellard | void bdrv_delete(BlockDriverState *bs);
|
320 | c4b1fcc0 | bellard | int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot); |
321 | fc01f7e7 | bellard | void bdrv_close(BlockDriverState *bs);
|
322 | fc01f7e7 | bellard | int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
323 | fc01f7e7 | bellard | uint8_t *buf, int nb_sectors);
|
324 | fc01f7e7 | bellard | int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
325 | fc01f7e7 | bellard | const uint8_t *buf, int nb_sectors); |
326 | fc01f7e7 | bellard | void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
|
327 | 33e3963e | bellard | int bdrv_commit(BlockDriverState *bs);
|
328 | 77fef8c1 | bellard | void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); |
329 | 33e3963e | bellard | |
330 | c4b1fcc0 | bellard | #define BDRV_TYPE_HD 0 |
331 | c4b1fcc0 | bellard | #define BDRV_TYPE_CDROM 1 |
332 | c4b1fcc0 | bellard | #define BDRV_TYPE_FLOPPY 2 |
333 | c4b1fcc0 | bellard | |
334 | c4b1fcc0 | bellard | void bdrv_set_geometry_hint(BlockDriverState *bs,
|
335 | c4b1fcc0 | bellard | int cyls, int heads, int secs); |
336 | c4b1fcc0 | bellard | void bdrv_set_type_hint(BlockDriverState *bs, int type); |
337 | c4b1fcc0 | bellard | void bdrv_get_geometry_hint(BlockDriverState *bs,
|
338 | c4b1fcc0 | bellard | int *pcyls, int *pheads, int *psecs); |
339 | c4b1fcc0 | bellard | int bdrv_get_type_hint(BlockDriverState *bs);
|
340 | c4b1fcc0 | bellard | int bdrv_is_removable(BlockDriverState *bs);
|
341 | c4b1fcc0 | bellard | int bdrv_is_read_only(BlockDriverState *bs);
|
342 | c4b1fcc0 | bellard | int bdrv_is_inserted(BlockDriverState *bs);
|
343 | c4b1fcc0 | bellard | int bdrv_is_locked(BlockDriverState *bs);
|
344 | c4b1fcc0 | bellard | void bdrv_set_locked(BlockDriverState *bs, int locked); |
345 | c4b1fcc0 | bellard | void bdrv_set_change_cb(BlockDriverState *bs,
|
346 | c4b1fcc0 | bellard | void (*change_cb)(void *opaque), void *opaque); |
347 | c4b1fcc0 | bellard | |
348 | c4b1fcc0 | bellard | void bdrv_info(void); |
349 | c4b1fcc0 | bellard | BlockDriverState *bdrv_find(const char *name); |
350 | c4b1fcc0 | bellard | |
351 | 313aa567 | bellard | /* vga.c */
|
352 | 313aa567 | bellard | |
353 | 4fa0f5d2 | bellard | #define VGA_RAM_SIZE (4096 * 1024) |
354 | 313aa567 | bellard | |
355 | 313aa567 | bellard | typedef struct DisplayState { |
356 | 313aa567 | bellard | uint8_t *data; |
357 | 313aa567 | bellard | int linesize;
|
358 | 313aa567 | bellard | int depth;
|
359 | 313aa567 | bellard | void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); |
360 | 313aa567 | bellard | void (*dpy_resize)(struct DisplayState *s, int w, int h); |
361 | 313aa567 | bellard | void (*dpy_refresh)(struct DisplayState *s); |
362 | 313aa567 | bellard | } DisplayState; |
363 | 313aa567 | bellard | |
364 | 313aa567 | bellard | static inline void dpy_update(DisplayState *s, int x, int y, int w, int h) |
365 | 313aa567 | bellard | { |
366 | 313aa567 | bellard | s->dpy_update(s, x, y, w, h); |
367 | 313aa567 | bellard | } |
368 | 313aa567 | bellard | |
369 | 313aa567 | bellard | static inline void dpy_resize(DisplayState *s, int w, int h) |
370 | 313aa567 | bellard | { |
371 | 313aa567 | bellard | s->dpy_resize(s, w, h); |
372 | 313aa567 | bellard | } |
373 | 313aa567 | bellard | |
374 | 7138fcfb | bellard | int vga_initialize(DisplayState *ds, uint8_t *vga_ram_base,
|
375 | 7138fcfb | bellard | unsigned long vga_ram_offset, int vga_ram_size); |
376 | 313aa567 | bellard | void vga_update_display(void); |
377 | 59a983b9 | bellard | void vga_screen_dump(const char *filename); |
378 | 313aa567 | bellard | |
379 | 313aa567 | bellard | /* sdl.c */
|
380 | 313aa567 | bellard | void sdl_display_init(DisplayState *ds);
|
381 | 313aa567 | bellard | |
382 | 5391d806 | bellard | /* ide.c */
|
383 | 5391d806 | bellard | #define MAX_DISKS 4 |
384 | 5391d806 | bellard | |
385 | 5391d806 | bellard | extern BlockDriverState *bs_table[MAX_DISKS];
|
386 | 5391d806 | bellard | |
387 | c4b1fcc0 | bellard | void ide_init(int iobase, int iobase2, int irq, |
388 | c4b1fcc0 | bellard | BlockDriverState *hd0, BlockDriverState *hd1); |
389 | 5391d806 | bellard | |
390 | 27503323 | bellard | /* oss.c */
|
391 | 27503323 | bellard | typedef enum { |
392 | 27503323 | bellard | AUD_FMT_U8, |
393 | 27503323 | bellard | AUD_FMT_S8, |
394 | 27503323 | bellard | AUD_FMT_U16, |
395 | 27503323 | bellard | AUD_FMT_S16 |
396 | 27503323 | bellard | } audfmt_e; |
397 | 27503323 | bellard | |
398 | 27503323 | bellard | void AUD_open (int rfreq, int rnchannels, audfmt_e rfmt); |
399 | 27503323 | bellard | void AUD_reset (int rfreq, int rnchannels, audfmt_e rfmt); |
400 | 27503323 | bellard | int AUD_write (void *in_buf, int size); |
401 | 27503323 | bellard | void AUD_run (void); |
402 | 27503323 | bellard | void AUD_adjust_estimate (int _leftover); |
403 | 27503323 | bellard | int AUD_get_free (void); |
404 | 27503323 | bellard | int AUD_get_live (void); |
405 | 27503323 | bellard | int AUD_get_buffer_size (void); |
406 | 27503323 | bellard | void AUD_init (void); |
407 | 27503323 | bellard | |
408 | 27503323 | bellard | /* dma.c */
|
409 | 16f62432 | bellard | typedef int (*DMA_transfer_handler) (void *opaque, target_ulong addr, int size); |
410 | 27503323 | bellard | int DMA_get_channel_mode (int nchan); |
411 | 27503323 | bellard | void DMA_hold_DREQ (int nchan); |
412 | 27503323 | bellard | void DMA_release_DREQ (int nchan); |
413 | 16f62432 | bellard | void DMA_schedule(int nchan); |
414 | 27503323 | bellard | void DMA_run (void); |
415 | 27503323 | bellard | void DMA_init (void); |
416 | 27503323 | bellard | void DMA_register_channel (int nchan, |
417 | 16f62432 | bellard | DMA_transfer_handler transfer_handler, void *opaque);
|
418 | 27503323 | bellard | |
419 | 27503323 | bellard | /* sb16.c */
|
420 | 27503323 | bellard | void SB16_run (void); |
421 | 27503323 | bellard | void SB16_init (void); |
422 | 27503323 | bellard | |
423 | 7138fcfb | bellard | /* fdc.c */
|
424 | 7138fcfb | bellard | #define MAX_FD 2 |
425 | 7138fcfb | bellard | extern BlockDriverState *fd_table[MAX_FD];
|
426 | 7138fcfb | bellard | |
427 | baca51fa | bellard | typedef struct fdctrl_t fdctrl_t; |
428 | baca51fa | bellard | |
429 | baca51fa | bellard | fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, |
430 | baca51fa | bellard | uint32_t io_base, |
431 | baca51fa | bellard | BlockDriverState **fds); |
432 | baca51fa | bellard | int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num); |
433 | 7138fcfb | bellard | |
434 | 80cabfad | bellard | /* ne2000.c */
|
435 | 80cabfad | bellard | |
436 | c4b1fcc0 | bellard | void ne2000_init(int base, int irq, NetDriverState *nd); |
437 | 80cabfad | bellard | |
438 | 80cabfad | bellard | /* pckbd.c */
|
439 | 80cabfad | bellard | |
440 | 80cabfad | bellard | void kbd_put_keycode(int keycode); |
441 | 80cabfad | bellard | |
442 | 80cabfad | bellard | #define MOUSE_EVENT_LBUTTON 0x01 |
443 | 80cabfad | bellard | #define MOUSE_EVENT_RBUTTON 0x02 |
444 | 80cabfad | bellard | #define MOUSE_EVENT_MBUTTON 0x04 |
445 | 80cabfad | bellard | void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); |
446 | 80cabfad | bellard | |
447 | 80cabfad | bellard | void kbd_init(void); |
448 | 80cabfad | bellard | |
449 | 80cabfad | bellard | /* mc146818rtc.c */
|
450 | 80cabfad | bellard | |
451 | 8a7ddc38 | bellard | typedef struct RTCState RTCState; |
452 | 80cabfad | bellard | |
453 | 8a7ddc38 | bellard | RTCState *rtc_init(int base, int irq); |
454 | 8a7ddc38 | bellard | void rtc_set_memory(RTCState *s, int addr, int val); |
455 | 8a7ddc38 | bellard | void rtc_set_date(RTCState *s, const struct tm *tm); |
456 | 80cabfad | bellard | |
457 | 80cabfad | bellard | /* serial.c */
|
458 | 80cabfad | bellard | |
459 | c4b1fcc0 | bellard | typedef struct SerialState SerialState; |
460 | c4b1fcc0 | bellard | |
461 | c4b1fcc0 | bellard | extern SerialState *serial_console;
|
462 | c4b1fcc0 | bellard | |
463 | c4b1fcc0 | bellard | SerialState *serial_init(int base, int irq, int fd); |
464 | c4b1fcc0 | bellard | int serial_can_receive(SerialState *s);
|
465 | c4b1fcc0 | bellard | void serial_receive_byte(SerialState *s, int ch); |
466 | c4b1fcc0 | bellard | void serial_receive_break(SerialState *s);
|
467 | 80cabfad | bellard | |
468 | 80cabfad | bellard | /* i8259.c */
|
469 | 80cabfad | bellard | |
470 | 80cabfad | bellard | void pic_set_irq(int irq, int level); |
471 | 80cabfad | bellard | void pic_init(void); |
472 | c5df018e | bellard | uint32_t pic_intack_read(CPUState *env); |
473 | c20709aa | bellard | void pic_info(void); |
474 | 80cabfad | bellard | |
475 | 80cabfad | bellard | /* i8254.c */
|
476 | 80cabfad | bellard | |
477 | 80cabfad | bellard | #define PIT_FREQ 1193182 |
478 | 80cabfad | bellard | |
479 | 80cabfad | bellard | typedef struct PITChannelState { |
480 | 80cabfad | bellard | int count; /* can be 65536 */ |
481 | 80cabfad | bellard | uint16_t latched_count; |
482 | 80cabfad | bellard | uint8_t rw_state; |
483 | 80cabfad | bellard | uint8_t mode; |
484 | 80cabfad | bellard | uint8_t bcd; /* not supported */
|
485 | 80cabfad | bellard | uint8_t gate; /* timer start */
|
486 | 80cabfad | bellard | int64_t count_load_time; |
487 | 8a7ddc38 | bellard | /* irq handling */
|
488 | 8a7ddc38 | bellard | int64_t next_transition_time; |
489 | 8a7ddc38 | bellard | QEMUTimer *irq_timer; |
490 | 8a7ddc38 | bellard | int irq;
|
491 | 80cabfad | bellard | } PITChannelState; |
492 | 80cabfad | bellard | |
493 | 80cabfad | bellard | extern PITChannelState pit_channels[3]; |
494 | 80cabfad | bellard | |
495 | 8a7ddc38 | bellard | void pit_init(int base, int irq); |
496 | 80cabfad | bellard | void pit_set_gate(PITChannelState *s, int val); |
497 | 8a7ddc38 | bellard | int pit_get_out(PITChannelState *s, int64_t current_time);
|
498 | 80cabfad | bellard | int pit_get_out_edges(PITChannelState *s);
|
499 | 80cabfad | bellard | |
500 | 80cabfad | bellard | /* pc.c */
|
501 | 80cabfad | bellard | void pc_init(int ram_size, int vga_ram_size, int boot_device, |
502 | 80cabfad | bellard | DisplayState *ds, const char **fd_filename, int snapshot, |
503 | 80cabfad | bellard | const char *kernel_filename, const char *kernel_cmdline, |
504 | 80cabfad | bellard | const char *initrd_filename); |
505 | 80cabfad | bellard | |
506 | c4b1fcc0 | bellard | /* monitor.c */
|
507 | c4b1fcc0 | bellard | void monitor_init(void); |
508 | 40c3bac3 | bellard | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); |
509 | c4b1fcc0 | bellard | void term_flush(void); |
510 | c4b1fcc0 | bellard | void term_print_help(void); |
511 | c4b1fcc0 | bellard | |
512 | 8a7ddc38 | bellard | /* gdbstub.c */
|
513 | 8a7ddc38 | bellard | |
514 | 8a7ddc38 | bellard | #define DEFAULT_GDBSTUB_PORT 1234 |
515 | 8a7ddc38 | bellard | |
516 | 8a7ddc38 | bellard | int gdbserver_start(int port); |
517 | 8a7ddc38 | bellard | |
518 | fc01f7e7 | bellard | #endif /* VL_H */ |