]>
Commit | Line | Data |
---|---|---|
fc01f7e7 FB |
1 | /* |
2 | * QEMU System Emulator header | |
3 | * | |
4 | * Copyright (c) 2003 Fabrice Bellard | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | #ifndef VL_H | |
25 | #define VL_H | |
26 | ||
67b915a5 FB |
27 | /* we put basic includes here to avoid repeating them in device drivers */ |
28 | #include <stdlib.h> | |
29 | #include <stdio.h> | |
30 | #include <stdarg.h> | |
31 | #include <string.h> | |
32 | #include <inttypes.h> | |
85571bc7 | 33 | #include <limits.h> |
8a7ddc38 | 34 | #include <time.h> |
67b915a5 FB |
35 | #include <ctype.h> |
36 | #include <errno.h> | |
37 | #include <unistd.h> | |
38 | #include <fcntl.h> | |
7d3505c5 | 39 | #include <sys/stat.h> |
fb065187 | 40 | #include "audio/audio.h" |
67b915a5 FB |
41 | |
42 | #ifndef O_LARGEFILE | |
43 | #define O_LARGEFILE 0 | |
44 | #endif | |
40c3bac3 FB |
45 | #ifndef O_BINARY |
46 | #define O_BINARY 0 | |
47 | #endif | |
67b915a5 FB |
48 | |
49 | #ifdef _WIN32 | |
a18e524a | 50 | #include <windows.h> |
ac62f715 | 51 | #define fsync _commit |
57d1a2b6 FB |
52 | #define lseek _lseeki64 |
53 | #define ENOTSUP 4096 | |
54 | /* XXX: find 64 bit version */ | |
55 | #define ftruncate chsize | |
56 | ||
57 | static inline char *realpath(const char *path, char *resolved_path) | |
58 | { | |
59 | _fullpath(resolved_path, path, _MAX_PATH); | |
60 | return resolved_path; | |
61 | } | |
ec3757de FB |
62 | |
63 | #define PRId64 "I64d" | |
26a76461 FB |
64 | #define PRIx64 "I64x" |
65 | #define PRIu64 "I64u" | |
66 | #define PRIo64 "I64o" | |
67b915a5 | 67 | #endif |
8a7ddc38 | 68 | |
ea2384d3 FB |
69 | #ifdef QEMU_TOOL |
70 | ||
71 | /* we use QEMU_TOOL in the command line tools which do not depend on | |
72 | the target CPU type */ | |
73 | #include "config-host.h" | |
74 | #include <setjmp.h> | |
75 | #include "osdep.h" | |
76 | #include "bswap.h" | |
77 | ||
78 | #else | |
79 | ||
16f62432 | 80 | #include "cpu.h" |
1fddef4b | 81 | #include "gdbstub.h" |
16f62432 | 82 | |
ea2384d3 FB |
83 | #endif /* !defined(QEMU_TOOL) */ |
84 | ||
67b915a5 FB |
85 | #ifndef glue |
86 | #define xglue(x, y) x ## y | |
87 | #define glue(x, y) xglue(x, y) | |
88 | #define stringify(s) tostring(s) | |
89 | #define tostring(s) #s | |
90 | #endif | |
91 | ||
24236869 FB |
92 | #ifndef MIN |
93 | #define MIN(a, b) (((a) < (b)) ? (a) : (b)) | |
94 | #endif | |
95 | #ifndef MAX | |
96 | #define MAX(a, b) (((a) > (b)) ? (a) : (b)) | |
97 | #endif | |
98 | ||
33e3963e | 99 | /* vl.c */ |
80cabfad | 100 | uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
313aa567 | 101 | |
80cabfad FB |
102 | void hw_error(const char *fmt, ...); |
103 | ||
80cabfad FB |
104 | extern const char *bios_dir; |
105 | ||
106 | void pstrcpy(char *buf, int buf_size, const char *str); | |
107 | char *pstrcat(char *buf, int buf_size, const char *s); | |
82c643ff | 108 | int strstart(const char *str, const char *val, const char **ptr); |
c4b1fcc0 | 109 | |
8a7ddc38 FB |
110 | extern int vm_running; |
111 | ||
0bd48850 FB |
112 | typedef struct vm_change_state_entry VMChangeStateEntry; |
113 | typedef void VMChangeStateHandler(void *opaque, int running); | |
8a7ddc38 FB |
114 | typedef void VMStopHandler(void *opaque, int reason); |
115 | ||
0bd48850 FB |
116 | VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, |
117 | void *opaque); | |
118 | void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); | |
119 | ||
8a7ddc38 FB |
120 | int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque); |
121 | void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque); | |
122 | ||
123 | void vm_start(void); | |
124 | void vm_stop(int reason); | |
125 | ||
bb0c6722 FB |
126 | typedef void QEMUResetHandler(void *opaque); |
127 | ||
128 | void qemu_register_reset(QEMUResetHandler *func, void *opaque); | |
129 | void qemu_system_reset_request(void); | |
130 | void qemu_system_shutdown_request(void); | |
3475187d FB |
131 | void qemu_system_powerdown_request(void); |
132 | #if !defined(TARGET_SPARC) | |
133 | // Please implement a power failure function to signal the OS | |
134 | #define qemu_system_powerdown() do{}while(0) | |
135 | #else | |
136 | void qemu_system_powerdown(void); | |
137 | #endif | |
bb0c6722 | 138 | |
ea2384d3 FB |
139 | void main_loop_wait(int timeout); |
140 | ||
0ced6589 FB |
141 | extern int ram_size; |
142 | extern int bios_size; | |
ee22c2f7 | 143 | extern int rtc_utc; |
1f04275e | 144 | extern int cirrus_vga_enabled; |
28b9b5af FB |
145 | extern int graphic_width; |
146 | extern int graphic_height; | |
147 | extern int graphic_depth; | |
3d11d0eb | 148 | extern const char *keyboard_layout; |
d993e026 | 149 | extern int kqemu_allowed; |
a09db21f | 150 | extern int win2k_install_hack; |
bb36d470 | 151 | extern int usb_enabled; |
6a00d601 | 152 | extern int smp_cpus; |
0ced6589 FB |
153 | |
154 | /* XXX: make it dynamic */ | |
75956cf0 | 155 | #if defined (TARGET_PPC) || defined (TARGET_SPARC64) |
d5295253 | 156 | #define BIOS_SIZE ((512 + 32) * 1024) |
6af0bf9c FB |
157 | #elif defined(TARGET_MIPS) |
158 | #define BIOS_SIZE (128 * 1024) | |
0ced6589 | 159 | #else |
7587cf44 | 160 | #define BIOS_SIZE ((256 + 64) * 1024) |
0ced6589 | 161 | #endif |
aaaa7df6 | 162 | |
63066f4f FB |
163 | /* keyboard/mouse support */ |
164 | ||
165 | #define MOUSE_EVENT_LBUTTON 0x01 | |
166 | #define MOUSE_EVENT_RBUTTON 0x02 | |
167 | #define MOUSE_EVENT_MBUTTON 0x04 | |
168 | ||
169 | typedef void QEMUPutKBDEvent(void *opaque, int keycode); | |
170 | typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); | |
171 | ||
172 | void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); | |
09b26c5e | 173 | void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute); |
63066f4f FB |
174 | |
175 | void kbd_put_keycode(int keycode); | |
176 | void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); | |
09b26c5e | 177 | int kbd_mouse_is_absolute(void); |
63066f4f | 178 | |
82c643ff FB |
179 | /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx |
180 | constants) */ | |
181 | #define QEMU_KEY_ESC1(c) ((c) | 0xe100) | |
182 | #define QEMU_KEY_BACKSPACE 0x007f | |
183 | #define QEMU_KEY_UP QEMU_KEY_ESC1('A') | |
184 | #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B') | |
185 | #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C') | |
186 | #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D') | |
187 | #define QEMU_KEY_HOME QEMU_KEY_ESC1(1) | |
188 | #define QEMU_KEY_END QEMU_KEY_ESC1(4) | |
189 | #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5) | |
190 | #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6) | |
191 | #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3) | |
192 | ||
193 | #define QEMU_KEY_CTRL_UP 0xe400 | |
194 | #define QEMU_KEY_CTRL_DOWN 0xe401 | |
195 | #define QEMU_KEY_CTRL_LEFT 0xe402 | |
196 | #define QEMU_KEY_CTRL_RIGHT 0xe403 | |
197 | #define QEMU_KEY_CTRL_HOME 0xe404 | |
198 | #define QEMU_KEY_CTRL_END 0xe405 | |
199 | #define QEMU_KEY_CTRL_PAGEUP 0xe406 | |
200 | #define QEMU_KEY_CTRL_PAGEDOWN 0xe407 | |
201 | ||
202 | void kbd_put_keysym(int keysym); | |
203 | ||
c20709aa FB |
204 | /* async I/O support */ |
205 | ||
206 | typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); | |
207 | typedef int IOCanRWHandler(void *opaque); | |
7c9d8e07 | 208 | typedef void IOHandler(void *opaque); |
c20709aa | 209 | |
7c9d8e07 FB |
210 | int qemu_set_fd_handler2(int fd, |
211 | IOCanRWHandler *fd_read_poll, | |
212 | IOHandler *fd_read, | |
213 | IOHandler *fd_write, | |
214 | void *opaque); | |
215 | int qemu_set_fd_handler(int fd, | |
216 | IOHandler *fd_read, | |
217 | IOHandler *fd_write, | |
218 | void *opaque); | |
c20709aa | 219 | |
f331110f FB |
220 | /* Polling handling */ |
221 | ||
222 | /* return TRUE if no sleep should be done afterwards */ | |
223 | typedef int PollingFunc(void *opaque); | |
224 | ||
225 | int qemu_add_polling_cb(PollingFunc *func, void *opaque); | |
226 | void qemu_del_polling_cb(PollingFunc *func, void *opaque); | |
227 | ||
a18e524a FB |
228 | #ifdef _WIN32 |
229 | /* Wait objects handling */ | |
230 | typedef void WaitObjectFunc(void *opaque); | |
231 | ||
232 | int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); | |
233 | void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); | |
234 | #endif | |
235 | ||
82c643ff FB |
236 | /* character device */ |
237 | ||
238 | #define CHR_EVENT_BREAK 0 /* serial break char */ | |
ea2384d3 | 239 | #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ |
82c643ff | 240 | |
2122c51a FB |
241 | |
242 | ||
243 | #define CHR_IOCTL_SERIAL_SET_PARAMS 1 | |
244 | typedef struct { | |
245 | int speed; | |
246 | int parity; | |
247 | int data_bits; | |
248 | int stop_bits; | |
249 | } QEMUSerialSetParams; | |
250 | ||
251 | #define CHR_IOCTL_SERIAL_SET_BREAK 2 | |
252 | ||
253 | #define CHR_IOCTL_PP_READ_DATA 3 | |
254 | #define CHR_IOCTL_PP_WRITE_DATA 4 | |
255 | #define CHR_IOCTL_PP_READ_CONTROL 5 | |
256 | #define CHR_IOCTL_PP_WRITE_CONTROL 6 | |
257 | #define CHR_IOCTL_PP_READ_STATUS 7 | |
258 | ||
82c643ff FB |
259 | typedef void IOEventHandler(void *opaque, int event); |
260 | ||
261 | typedef struct CharDriverState { | |
262 | int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); | |
263 | void (*chr_add_read_handler)(struct CharDriverState *s, | |
264 | IOCanRWHandler *fd_can_read, | |
265 | IOReadHandler *fd_read, void *opaque); | |
2122c51a | 266 | int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); |
82c643ff | 267 | IOEventHandler *chr_event; |
eb45f5fe | 268 | void (*chr_send_event)(struct CharDriverState *chr, int event); |
f331110f | 269 | void (*chr_close)(struct CharDriverState *chr); |
82c643ff FB |
270 | void *opaque; |
271 | } CharDriverState; | |
272 | ||
273 | void qemu_chr_printf(CharDriverState *s, const char *fmt, ...); | |
274 | int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len); | |
ea2384d3 | 275 | void qemu_chr_send_event(CharDriverState *s, int event); |
82c643ff FB |
276 | void qemu_chr_add_read_handler(CharDriverState *s, |
277 | IOCanRWHandler *fd_can_read, | |
278 | IOReadHandler *fd_read, void *opaque); | |
279 | void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event); | |
2122c51a | 280 | int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg); |
f8d179e3 | 281 | |
82c643ff FB |
282 | /* consoles */ |
283 | ||
284 | typedef struct DisplayState DisplayState; | |
285 | typedef struct TextConsole TextConsole; | |
286 | ||
95219897 PB |
287 | typedef void (*vga_hw_update_ptr)(void *); |
288 | typedef void (*vga_hw_invalidate_ptr)(void *); | |
289 | typedef void (*vga_hw_screen_dump_ptr)(void *, const char *); | |
290 | ||
291 | TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update, | |
292 | vga_hw_invalidate_ptr invalidate, | |
293 | vga_hw_screen_dump_ptr screen_dump, | |
294 | void *opaque); | |
295 | void vga_hw_update(void); | |
296 | void vga_hw_invalidate(void); | |
297 | void vga_hw_screen_dump(const char *filename); | |
298 | ||
299 | int is_graphic_console(void); | |
82c643ff FB |
300 | CharDriverState *text_console_init(DisplayState *ds); |
301 | void console_select(unsigned int index); | |
302 | ||
8d11df9e FB |
303 | /* serial ports */ |
304 | ||
305 | #define MAX_SERIAL_PORTS 4 | |
306 | ||
307 | extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; | |
308 | ||
6508fe59 FB |
309 | /* parallel ports */ |
310 | ||
311 | #define MAX_PARALLEL_PORTS 3 | |
312 | ||
313 | extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; | |
314 | ||
7c9d8e07 FB |
315 | /* VLANs support */ |
316 | ||
317 | typedef struct VLANClientState VLANClientState; | |
318 | ||
319 | struct VLANClientState { | |
320 | IOReadHandler *fd_read; | |
d861b05e PB |
321 | /* Packets may still be sent if this returns zero. It's used to |
322 | rate-limit the slirp code. */ | |
323 | IOCanRWHandler *fd_can_read; | |
7c9d8e07 FB |
324 | void *opaque; |
325 | struct VLANClientState *next; | |
326 | struct VLANState *vlan; | |
327 | char info_str[256]; | |
328 | }; | |
329 | ||
330 | typedef struct VLANState { | |
331 | int id; | |
332 | VLANClientState *first_client; | |
333 | struct VLANState *next; | |
334 | } VLANState; | |
335 | ||
336 | VLANState *qemu_find_vlan(int id); | |
337 | VLANClientState *qemu_new_vlan_client(VLANState *vlan, | |
d861b05e PB |
338 | IOReadHandler *fd_read, |
339 | IOCanRWHandler *fd_can_read, | |
340 | void *opaque); | |
341 | int qemu_can_send_packet(VLANClientState *vc); | |
7c9d8e07 | 342 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
d861b05e | 343 | void qemu_handler_true(void *opaque); |
7c9d8e07 FB |
344 | |
345 | void do_info_network(void); | |
346 | ||
7fb843f8 FB |
347 | /* TAP win32 */ |
348 | int tap_win32_init(VLANState *vlan, const char *ifname); | |
349 | void tap_win32_poll(void); | |
350 | ||
7c9d8e07 | 351 | /* NIC info */ |
c4b1fcc0 FB |
352 | |
353 | #define MAX_NICS 8 | |
354 | ||
7c9d8e07 | 355 | typedef struct NICInfo { |
c4b1fcc0 | 356 | uint8_t macaddr[6]; |
a41b2ff2 | 357 | const char *model; |
7c9d8e07 FB |
358 | VLANState *vlan; |
359 | } NICInfo; | |
c4b1fcc0 FB |
360 | |
361 | extern int nb_nics; | |
7c9d8e07 | 362 | extern NICInfo nd_table[MAX_NICS]; |
8a7ddc38 FB |
363 | |
364 | /* timers */ | |
365 | ||
366 | typedef struct QEMUClock QEMUClock; | |
367 | typedef struct QEMUTimer QEMUTimer; | |
368 | typedef void QEMUTimerCB(void *opaque); | |
369 | ||
370 | /* The real time clock should be used only for stuff which does not | |
371 | change the virtual machine state, as it is run even if the virtual | |
69b91039 | 372 | machine is stopped. The real time clock has a frequency of 1000 |
8a7ddc38 FB |
373 | Hz. */ |
374 | extern QEMUClock *rt_clock; | |
375 | ||
e80cfcfc | 376 | /* The virtual clock is only run during the emulation. It is stopped |
8a7ddc38 FB |
377 | when the virtual machine is stopped. Virtual timers use a high |
378 | precision clock, usually cpu cycles (use ticks_per_sec). */ | |
379 | extern QEMUClock *vm_clock; | |
380 | ||
381 | int64_t qemu_get_clock(QEMUClock *clock); | |
382 | ||
383 | QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque); | |
384 | void qemu_free_timer(QEMUTimer *ts); | |
385 | void qemu_del_timer(QEMUTimer *ts); | |
386 | void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time); | |
387 | int qemu_timer_pending(QEMUTimer *ts); | |
388 | ||
389 | extern int64_t ticks_per_sec; | |
390 | extern int pit_min_timer_count; | |
391 | ||
392 | void cpu_enable_ticks(void); | |
393 | void cpu_disable_ticks(void); | |
394 | ||
395 | /* VM Load/Save */ | |
396 | ||
397 | typedef FILE QEMUFile; | |
398 | ||
399 | void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); | |
400 | void qemu_put_byte(QEMUFile *f, int v); | |
401 | void qemu_put_be16(QEMUFile *f, unsigned int v); | |
402 | void qemu_put_be32(QEMUFile *f, unsigned int v); | |
403 | void qemu_put_be64(QEMUFile *f, uint64_t v); | |
404 | int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); | |
405 | int qemu_get_byte(QEMUFile *f); | |
406 | unsigned int qemu_get_be16(QEMUFile *f); | |
407 | unsigned int qemu_get_be32(QEMUFile *f); | |
408 | uint64_t qemu_get_be64(QEMUFile *f); | |
409 | ||
410 | static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) | |
411 | { | |
412 | qemu_put_be64(f, *pv); | |
413 | } | |
414 | ||
415 | static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) | |
416 | { | |
417 | qemu_put_be32(f, *pv); | |
418 | } | |
419 | ||
420 | static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) | |
421 | { | |
422 | qemu_put_be16(f, *pv); | |
423 | } | |
424 | ||
425 | static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) | |
426 | { | |
427 | qemu_put_byte(f, *pv); | |
428 | } | |
429 | ||
430 | static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) | |
431 | { | |
432 | *pv = qemu_get_be64(f); | |
433 | } | |
434 | ||
435 | static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) | |
436 | { | |
437 | *pv = qemu_get_be32(f); | |
438 | } | |
439 | ||
440 | static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) | |
441 | { | |
442 | *pv = qemu_get_be16(f); | |
443 | } | |
444 | ||
445 | static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) | |
446 | { | |
447 | *pv = qemu_get_byte(f); | |
448 | } | |
449 | ||
c27004ec FB |
450 | #if TARGET_LONG_BITS == 64 |
451 | #define qemu_put_betl qemu_put_be64 | |
452 | #define qemu_get_betl qemu_get_be64 | |
453 | #define qemu_put_betls qemu_put_be64s | |
454 | #define qemu_get_betls qemu_get_be64s | |
455 | #else | |
456 | #define qemu_put_betl qemu_put_be32 | |
457 | #define qemu_get_betl qemu_get_be32 | |
458 | #define qemu_put_betls qemu_put_be32s | |
459 | #define qemu_get_betls qemu_get_be32s | |
460 | #endif | |
461 | ||
8a7ddc38 FB |
462 | int64_t qemu_ftell(QEMUFile *f); |
463 | int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence); | |
464 | ||
465 | typedef void SaveStateHandler(QEMUFile *f, void *opaque); | |
466 | typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); | |
467 | ||
468 | int qemu_loadvm(const char *filename); | |
469 | int qemu_savevm(const char *filename); | |
470 | int register_savevm(const char *idstr, | |
471 | int instance_id, | |
472 | int version_id, | |
473 | SaveStateHandler *save_state, | |
474 | LoadStateHandler *load_state, | |
475 | void *opaque); | |
476 | void qemu_get_timer(QEMUFile *f, QEMUTimer *ts); | |
477 | void qemu_put_timer(QEMUFile *f, QEMUTimer *ts); | |
c4b1fcc0 | 478 | |
6a00d601 FB |
479 | void cpu_save(QEMUFile *f, void *opaque); |
480 | int cpu_load(QEMUFile *f, void *opaque, int version_id); | |
481 | ||
fc01f7e7 FB |
482 | /* block.c */ |
483 | typedef struct BlockDriverState BlockDriverState; | |
ea2384d3 FB |
484 | typedef struct BlockDriver BlockDriver; |
485 | ||
486 | extern BlockDriver bdrv_raw; | |
487 | extern BlockDriver bdrv_cow; | |
488 | extern BlockDriver bdrv_qcow; | |
489 | extern BlockDriver bdrv_vmdk; | |
3c56521b | 490 | extern BlockDriver bdrv_cloop; |
585d0ed9 | 491 | extern BlockDriver bdrv_dmg; |
a8753c34 | 492 | extern BlockDriver bdrv_bochs; |
6a0f9e82 | 493 | extern BlockDriver bdrv_vpc; |
de167e41 | 494 | extern BlockDriver bdrv_vvfat; |
ea2384d3 FB |
495 | |
496 | void bdrv_init(void); | |
497 | BlockDriver *bdrv_find_format(const char *format_name); | |
498 | int bdrv_create(BlockDriver *drv, | |
499 | const char *filename, int64_t size_in_sectors, | |
500 | const char *backing_file, int flags); | |
c4b1fcc0 FB |
501 | BlockDriverState *bdrv_new(const char *device_name); |
502 | void bdrv_delete(BlockDriverState *bs); | |
503 | int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot); | |
ea2384d3 FB |
504 | int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot, |
505 | BlockDriver *drv); | |
fc01f7e7 FB |
506 | void bdrv_close(BlockDriverState *bs); |
507 | int bdrv_read(BlockDriverState *bs, int64_t sector_num, | |
508 | uint8_t *buf, int nb_sectors); | |
509 | int bdrv_write(BlockDriverState *bs, int64_t sector_num, | |
510 | const uint8_t *buf, int nb_sectors); | |
511 | void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr); | |
33e3963e | 512 | int bdrv_commit(BlockDriverState *bs); |
77fef8c1 | 513 | void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); |
7a6cba61 PB |
514 | /* Ensure contents are flushed to disk. */ |
515 | void bdrv_flush(BlockDriverState *bs); | |
33e3963e | 516 | |
c4b1fcc0 FB |
517 | #define BDRV_TYPE_HD 0 |
518 | #define BDRV_TYPE_CDROM 1 | |
519 | #define BDRV_TYPE_FLOPPY 2 | |
46d4767d FB |
520 | #define BIOS_ATA_TRANSLATION_AUTO 0 |
521 | #define BIOS_ATA_TRANSLATION_NONE 1 | |
522 | #define BIOS_ATA_TRANSLATION_LBA 2 | |
c4b1fcc0 FB |
523 | |
524 | void bdrv_set_geometry_hint(BlockDriverState *bs, | |
525 | int cyls, int heads, int secs); | |
526 | void bdrv_set_type_hint(BlockDriverState *bs, int type); | |
46d4767d | 527 | void bdrv_set_translation_hint(BlockDriverState *bs, int translation); |
c4b1fcc0 FB |
528 | void bdrv_get_geometry_hint(BlockDriverState *bs, |
529 | int *pcyls, int *pheads, int *psecs); | |
530 | int bdrv_get_type_hint(BlockDriverState *bs); | |
46d4767d | 531 | int bdrv_get_translation_hint(BlockDriverState *bs); |
c4b1fcc0 FB |
532 | int bdrv_is_removable(BlockDriverState *bs); |
533 | int bdrv_is_read_only(BlockDriverState *bs); | |
534 | int bdrv_is_inserted(BlockDriverState *bs); | |
535 | int bdrv_is_locked(BlockDriverState *bs); | |
536 | void bdrv_set_locked(BlockDriverState *bs, int locked); | |
537 | void bdrv_set_change_cb(BlockDriverState *bs, | |
538 | void (*change_cb)(void *opaque), void *opaque); | |
ea2384d3 | 539 | void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size); |
c4b1fcc0 FB |
540 | void bdrv_info(void); |
541 | BlockDriverState *bdrv_find(const char *name); | |
82c643ff | 542 | void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque); |
ea2384d3 FB |
543 | int bdrv_is_encrypted(BlockDriverState *bs); |
544 | int bdrv_set_key(BlockDriverState *bs, const char *key); | |
545 | void bdrv_iterate_format(void (*it)(void *opaque, const char *name), | |
546 | void *opaque); | |
547 | const char *bdrv_get_device_name(BlockDriverState *bs); | |
c4b1fcc0 | 548 | |
ea2384d3 FB |
549 | int qcow_get_cluster_size(BlockDriverState *bs); |
550 | int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num, | |
551 | const uint8_t *buf); | |
552 | ||
553 | #ifndef QEMU_TOOL | |
54fa5af5 FB |
554 | |
555 | typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, | |
556 | int boot_device, | |
557 | DisplayState *ds, const char **fd_filename, int snapshot, | |
558 | const char *kernel_filename, const char *kernel_cmdline, | |
559 | const char *initrd_filename); | |
560 | ||
561 | typedef struct QEMUMachine { | |
562 | const char *name; | |
563 | const char *desc; | |
564 | QEMUMachineInitFunc *init; | |
565 | struct QEMUMachine *next; | |
566 | } QEMUMachine; | |
567 | ||
568 | int qemu_register_machine(QEMUMachine *m); | |
569 | ||
570 | typedef void SetIRQFunc(void *opaque, int irq_num, int level); | |
3de388f6 | 571 | typedef void IRQRequestFunc(void *opaque, int level); |
54fa5af5 | 572 | |
26aa7d72 FB |
573 | /* ISA bus */ |
574 | ||
575 | extern target_phys_addr_t isa_mem_base; | |
576 | ||
577 | typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); | |
578 | typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); | |
579 | ||
580 | int register_ioport_read(int start, int length, int size, | |
581 | IOPortReadFunc *func, void *opaque); | |
582 | int register_ioport_write(int start, int length, int size, | |
583 | IOPortWriteFunc *func, void *opaque); | |
69b91039 FB |
584 | void isa_unassign_ioport(int start, int length); |
585 | ||
586 | /* PCI bus */ | |
587 | ||
69b91039 FB |
588 | extern target_phys_addr_t pci_mem_base; |
589 | ||
46e50e9d | 590 | typedef struct PCIBus PCIBus; |
69b91039 FB |
591 | typedef struct PCIDevice PCIDevice; |
592 | ||
593 | typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, | |
594 | uint32_t address, uint32_t data, int len); | |
595 | typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev, | |
596 | uint32_t address, int len); | |
597 | typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num, | |
598 | uint32_t addr, uint32_t size, int type); | |
599 | ||
600 | #define PCI_ADDRESS_SPACE_MEM 0x00 | |
601 | #define PCI_ADDRESS_SPACE_IO 0x01 | |
602 | #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08 | |
603 | ||
604 | typedef struct PCIIORegion { | |
5768f5ac | 605 | uint32_t addr; /* current PCI mapping address. -1 means not mapped */ |
69b91039 FB |
606 | uint32_t size; |
607 | uint8_t type; | |
608 | PCIMapIORegionFunc *map_func; | |
609 | } PCIIORegion; | |
610 | ||
8a8696a3 FB |
611 | #define PCI_ROM_SLOT 6 |
612 | #define PCI_NUM_REGIONS 7 | |
502a5395 PB |
613 | |
614 | #define PCI_DEVICES_MAX 64 | |
615 | ||
616 | #define PCI_VENDOR_ID 0x00 /* 16 bits */ | |
617 | #define PCI_DEVICE_ID 0x02 /* 16 bits */ | |
618 | #define PCI_COMMAND 0x04 /* 16 bits */ | |
619 | #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ | |
620 | #define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ | |
621 | #define PCI_CLASS_DEVICE 0x0a /* Device class */ | |
622 | #define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ | |
623 | #define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ | |
624 | #define PCI_MIN_GNT 0x3e /* 8 bits */ | |
625 | #define PCI_MAX_LAT 0x3f /* 8 bits */ | |
626 | ||
69b91039 FB |
627 | struct PCIDevice { |
628 | /* PCI config space */ | |
629 | uint8_t config[256]; | |
630 | ||
631 | /* the following fields are read only */ | |
46e50e9d | 632 | PCIBus *bus; |
69b91039 FB |
633 | int devfn; |
634 | char name[64]; | |
8a8696a3 | 635 | PCIIORegion io_regions[PCI_NUM_REGIONS]; |
69b91039 FB |
636 | |
637 | /* do not access the following fields */ | |
638 | PCIConfigReadFunc *config_read; | |
639 | PCIConfigWriteFunc *config_write; | |
502a5395 | 640 | /* ??? This is a PC-specific hack, and should be removed. */ |
5768f5ac | 641 | int irq_index; |
69b91039 FB |
642 | }; |
643 | ||
46e50e9d FB |
644 | PCIDevice *pci_register_device(PCIBus *bus, const char *name, |
645 | int instance_size, int devfn, | |
69b91039 FB |
646 | PCIConfigReadFunc *config_read, |
647 | PCIConfigWriteFunc *config_write); | |
648 | ||
649 | void pci_register_io_region(PCIDevice *pci_dev, int region_num, | |
650 | uint32_t size, int type, | |
651 | PCIMapIORegionFunc *map_func); | |
652 | ||
5768f5ac FB |
653 | void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level); |
654 | ||
655 | uint32_t pci_default_read_config(PCIDevice *d, | |
656 | uint32_t address, int len); | |
657 | void pci_default_write_config(PCIDevice *d, | |
658 | uint32_t address, uint32_t val, int len); | |
30ca2aab FB |
659 | void generic_pci_save(QEMUFile* f, void *opaque); |
660 | int generic_pci_load(QEMUFile* f, void *opaque, int version_id); | |
5768f5ac | 661 | |
502a5395 PB |
662 | typedef void (*pci_set_irq_fn)(PCIDevice *pci_dev, void *pic, |
663 | int irq_num, int level); | |
664 | PCIBus *pci_register_bus(pci_set_irq_fn set_irq, void *pic, int devfn_min); | |
665 | ||
666 | void pci_nic_init(PCIBus *bus, NICInfo *nd); | |
667 | void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len); | |
668 | uint32_t pci_data_read(void *opaque, uint32_t addr, int len); | |
669 | int pci_bus_num(PCIBus *s); | |
670 | void pci_for_each_device(void (*fn)(PCIDevice *d)); | |
9995c51f | 671 | |
5768f5ac | 672 | void pci_info(void); |
26aa7d72 | 673 | |
502a5395 | 674 | /* prep_pci.c */ |
46e50e9d | 675 | PCIBus *pci_prep_init(void); |
77d4bc34 | 676 | |
502a5395 PB |
677 | /* grackle_pci.c */ |
678 | PCIBus *pci_grackle_init(uint32_t base, void *pic); | |
679 | ||
680 | /* unin_pci.c */ | |
681 | PCIBus *pci_pmac_init(void *pic); | |
682 | ||
683 | /* apb_pci.c */ | |
684 | PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base, | |
685 | void *pic); | |
686 | ||
687 | PCIBus *pci_vpb_init(void *pic); | |
688 | ||
689 | /* piix_pci.c */ | |
690 | PCIBus *i440fx_init(void); | |
691 | int piix3_init(PCIBus *bus); | |
692 | void pci_bios_init(void); | |
a41b2ff2 | 693 | |
28b9b5af FB |
694 | /* openpic.c */ |
695 | typedef struct openpic_t openpic_t; | |
54fa5af5 | 696 | void openpic_set_irq(void *opaque, int n_IRQ, int level); |
7668a27f FB |
697 | openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, |
698 | CPUState **envp); | |
28b9b5af | 699 | |
54fa5af5 FB |
700 | /* heathrow_pic.c */ |
701 | typedef struct HeathrowPICS HeathrowPICS; | |
702 | void heathrow_pic_set_irq(void *opaque, int num, int level); | |
703 | HeathrowPICS *heathrow_pic_init(int *pmem_index); | |
704 | ||
6a36d84e FB |
705 | #ifdef HAS_AUDIO |
706 | struct soundhw { | |
707 | const char *name; | |
708 | const char *descr; | |
709 | int enabled; | |
710 | int isa; | |
711 | union { | |
712 | int (*init_isa) (AudioState *s); | |
713 | int (*init_pci) (PCIBus *bus, AudioState *s); | |
714 | } init; | |
715 | }; | |
716 | ||
717 | extern struct soundhw soundhw[]; | |
718 | #endif | |
719 | ||
313aa567 FB |
720 | /* vga.c */ |
721 | ||
74a14f22 | 722 | #define VGA_RAM_SIZE (8192 * 1024) |
313aa567 | 723 | |
82c643ff | 724 | struct DisplayState { |
313aa567 FB |
725 | uint8_t *data; |
726 | int linesize; | |
727 | int depth; | |
d3079cd2 | 728 | int bgr; /* BGR color order instead of RGB. Only valid for depth == 32 */ |
82c643ff FB |
729 | int width; |
730 | int height; | |
24236869 FB |
731 | void *opaque; |
732 | ||
313aa567 FB |
733 | void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); |
734 | void (*dpy_resize)(struct DisplayState *s, int w, int h); | |
735 | void (*dpy_refresh)(struct DisplayState *s); | |
24236869 | 736 | void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h); |
82c643ff | 737 | }; |
313aa567 FB |
738 | |
739 | static inline void dpy_update(DisplayState *s, int x, int y, int w, int h) | |
740 | { | |
741 | s->dpy_update(s, x, y, w, h); | |
742 | } | |
743 | ||
744 | static inline void dpy_resize(DisplayState *s, int w, int h) | |
745 | { | |
746 | s->dpy_resize(s, w, h); | |
747 | } | |
748 | ||
46e50e9d | 749 | int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, |
d5295253 FB |
750 | unsigned long vga_ram_offset, int vga_ram_size, |
751 | unsigned long vga_bios_offset, int vga_bios_size); | |
313aa567 | 752 | |
d6bfa22f | 753 | /* cirrus_vga.c */ |
46e50e9d | 754 | void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, |
d6bfa22f | 755 | unsigned long vga_ram_offset, int vga_ram_size); |
d6bfa22f FB |
756 | void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base, |
757 | unsigned long vga_ram_offset, int vga_ram_size); | |
758 | ||
313aa567 | 759 | /* sdl.c */ |
d63d307f | 760 | void sdl_display_init(DisplayState *ds, int full_screen); |
313aa567 | 761 | |
da4dbf74 FB |
762 | /* cocoa.m */ |
763 | void cocoa_display_init(DisplayState *ds, int full_screen); | |
764 | ||
24236869 FB |
765 | /* vnc.c */ |
766 | void vnc_display_init(DisplayState *ds, int display); | |
767 | ||
5391d806 FB |
768 | /* ide.c */ |
769 | #define MAX_DISKS 4 | |
770 | ||
771 | extern BlockDriverState *bs_table[MAX_DISKS]; | |
772 | ||
69b91039 FB |
773 | void isa_ide_init(int iobase, int iobase2, int irq, |
774 | BlockDriverState *hd0, BlockDriverState *hd1); | |
54fa5af5 FB |
775 | void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table, |
776 | int secondary_ide_enabled); | |
502a5395 | 777 | void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn); |
28b9b5af | 778 | int pmac_ide_init (BlockDriverState **hd_table, |
54fa5af5 | 779 | SetIRQFunc *set_irq, void *irq_opaque, int irq); |
5391d806 | 780 | |
2e5d83bb PB |
781 | /* cdrom.c */ |
782 | int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track); | |
783 | int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num); | |
784 | ||
1d14ffa9 | 785 | /* es1370.c */ |
c0fe3827 | 786 | int es1370_init (PCIBus *bus, AudioState *s); |
1d14ffa9 | 787 | |
fb065187 | 788 | /* sb16.c */ |
c0fe3827 | 789 | int SB16_init (AudioState *s); |
fb065187 FB |
790 | |
791 | /* adlib.c */ | |
c0fe3827 | 792 | int Adlib_init (AudioState *s); |
fb065187 FB |
793 | |
794 | /* gus.c */ | |
c0fe3827 | 795 | int GUS_init (AudioState *s); |
27503323 FB |
796 | |
797 | /* dma.c */ | |
85571bc7 | 798 | typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); |
27503323 | 799 | int DMA_get_channel_mode (int nchan); |
85571bc7 FB |
800 | int DMA_read_memory (int nchan, void *buf, int pos, int size); |
801 | int DMA_write_memory (int nchan, void *buf, int pos, int size); | |
27503323 FB |
802 | void DMA_hold_DREQ (int nchan); |
803 | void DMA_release_DREQ (int nchan); | |
16f62432 | 804 | void DMA_schedule(int nchan); |
27503323 | 805 | void DMA_run (void); |
28b9b5af | 806 | void DMA_init (int high_page_enable); |
27503323 | 807 | void DMA_register_channel (int nchan, |
85571bc7 FB |
808 | DMA_transfer_handler transfer_handler, |
809 | void *opaque); | |
7138fcfb FB |
810 | /* fdc.c */ |
811 | #define MAX_FD 2 | |
812 | extern BlockDriverState *fd_table[MAX_FD]; | |
813 | ||
baca51fa FB |
814 | typedef struct fdctrl_t fdctrl_t; |
815 | ||
816 | fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, | |
817 | uint32_t io_base, | |
818 | BlockDriverState **fds); | |
819 | int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num); | |
7138fcfb | 820 | |
80cabfad FB |
821 | /* ne2000.c */ |
822 | ||
7c9d8e07 FB |
823 | void isa_ne2000_init(int base, int irq, NICInfo *nd); |
824 | void pci_ne2000_init(PCIBus *bus, NICInfo *nd); | |
80cabfad | 825 | |
a41b2ff2 PB |
826 | /* rtl8139.c */ |
827 | ||
828 | void pci_rtl8139_init(PCIBus *bus, NICInfo *nd); | |
829 | ||
80cabfad FB |
830 | /* pckbd.c */ |
831 | ||
80cabfad FB |
832 | void kbd_init(void); |
833 | ||
834 | /* mc146818rtc.c */ | |
835 | ||
8a7ddc38 | 836 | typedef struct RTCState RTCState; |
80cabfad | 837 | |
8a7ddc38 FB |
838 | RTCState *rtc_init(int base, int irq); |
839 | void rtc_set_memory(RTCState *s, int addr, int val); | |
840 | void rtc_set_date(RTCState *s, const struct tm *tm); | |
80cabfad FB |
841 | |
842 | /* serial.c */ | |
843 | ||
c4b1fcc0 | 844 | typedef struct SerialState SerialState; |
e5d13e2f FB |
845 | SerialState *serial_init(SetIRQFunc *set_irq, void *opaque, |
846 | int base, int irq, CharDriverState *chr); | |
847 | SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque, | |
848 | target_ulong base, int it_shift, | |
849 | int irq, CharDriverState *chr); | |
80cabfad | 850 | |
6508fe59 FB |
851 | /* parallel.c */ |
852 | ||
853 | typedef struct ParallelState ParallelState; | |
854 | ParallelState *parallel_init(int base, int irq, CharDriverState *chr); | |
855 | ||
80cabfad FB |
856 | /* i8259.c */ |
857 | ||
3de388f6 FB |
858 | typedef struct PicState2 PicState2; |
859 | extern PicState2 *isa_pic; | |
80cabfad | 860 | void pic_set_irq(int irq, int level); |
54fa5af5 | 861 | void pic_set_irq_new(void *opaque, int irq, int level); |
3de388f6 | 862 | PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque); |
d592d303 FB |
863 | void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func, |
864 | void *alt_irq_opaque); | |
3de388f6 FB |
865 | int pic_read_irq(PicState2 *s); |
866 | void pic_update_irq(PicState2 *s); | |
867 | uint32_t pic_intack_read(PicState2 *s); | |
c20709aa | 868 | void pic_info(void); |
4a0fb71e | 869 | void irq_info(void); |
80cabfad | 870 | |
c27004ec | 871 | /* APIC */ |
d592d303 FB |
872 | typedef struct IOAPICState IOAPICState; |
873 | ||
c27004ec FB |
874 | int apic_init(CPUState *env); |
875 | int apic_get_interrupt(CPUState *env); | |
d592d303 FB |
876 | IOAPICState *ioapic_init(void); |
877 | void ioapic_set_irq(void *opaque, int vector, int level); | |
c27004ec | 878 | |
80cabfad FB |
879 | /* i8254.c */ |
880 | ||
881 | #define PIT_FREQ 1193182 | |
882 | ||
ec844b96 FB |
883 | typedef struct PITState PITState; |
884 | ||
885 | PITState *pit_init(int base, int irq); | |
886 | void pit_set_gate(PITState *pit, int channel, int val); | |
887 | int pit_get_gate(PITState *pit, int channel); | |
fd06c375 FB |
888 | int pit_get_initial_count(PITState *pit, int channel); |
889 | int pit_get_mode(PITState *pit, int channel); | |
ec844b96 | 890 | int pit_get_out(PITState *pit, int channel, int64_t current_time); |
80cabfad | 891 | |
fd06c375 FB |
892 | /* pcspk.c */ |
893 | void pcspk_init(PITState *); | |
894 | int pcspk_audio_init(AudioState *); | |
895 | ||
6515b203 FB |
896 | /* acpi.c */ |
897 | extern int acpi_enabled; | |
502a5395 | 898 | void piix4_pm_init(PCIBus *bus, int devfn); |
6515b203 FB |
899 | void acpi_bios_init(void); |
900 | ||
80cabfad | 901 | /* pc.c */ |
54fa5af5 | 902 | extern QEMUMachine pc_machine; |
3dbbdc25 | 903 | extern QEMUMachine isapc_machine; |
52ca8d6a | 904 | extern int fd_bootchk; |
80cabfad | 905 | |
6a00d601 FB |
906 | void ioport_set_a20(int enable); |
907 | int ioport_get_a20(void); | |
908 | ||
26aa7d72 | 909 | /* ppc.c */ |
54fa5af5 FB |
910 | extern QEMUMachine prep_machine; |
911 | extern QEMUMachine core99_machine; | |
912 | extern QEMUMachine heathrow_machine; | |
913 | ||
6af0bf9c FB |
914 | /* mips_r4k.c */ |
915 | extern QEMUMachine mips_machine; | |
916 | ||
27c7ca7e FB |
917 | /* shix.c */ |
918 | extern QEMUMachine shix_machine; | |
919 | ||
8cc43fef FB |
920 | #ifdef TARGET_PPC |
921 | ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq); | |
922 | #endif | |
64201201 | 923 | void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val); |
77d4bc34 FB |
924 | |
925 | extern CPUWriteMemoryFunc *PPC_io_write[]; | |
926 | extern CPUReadMemoryFunc *PPC_io_read[]; | |
54fa5af5 | 927 | void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val); |
26aa7d72 | 928 | |
e95c8d51 | 929 | /* sun4m.c */ |
54fa5af5 | 930 | extern QEMUMachine sun4m_machine; |
e80cfcfc | 931 | uint32_t iommu_translate(uint32_t addr); |
ba3c64fb | 932 | void pic_set_irq_cpu(int irq, int level, unsigned int cpu); |
e95c8d51 FB |
933 | |
934 | /* iommu.c */ | |
e80cfcfc FB |
935 | void *iommu_init(uint32_t addr); |
936 | uint32_t iommu_translate_local(void *opaque, uint32_t addr); | |
e95c8d51 FB |
937 | |
938 | /* lance.c */ | |
7c9d8e07 | 939 | void lance_init(NICInfo *nd, int irq, uint32_t leaddr, uint32_t ledaddr); |
e95c8d51 FB |
940 | |
941 | /* tcx.c */ | |
95219897 | 942 | void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base, |
6f7e9aec | 943 | unsigned long vram_offset, int vram_size, int width, int height); |
e80cfcfc FB |
944 | |
945 | /* slavio_intctl.c */ | |
946 | void *slavio_intctl_init(); | |
ba3c64fb | 947 | void slavio_intctl_set_cpu(void *opaque, unsigned int cpu, CPUState *env); |
e80cfcfc FB |
948 | void slavio_pic_info(void *opaque); |
949 | void slavio_irq_info(void *opaque); | |
950 | void slavio_pic_set_irq(void *opaque, int irq, int level); | |
ba3c64fb | 951 | void slavio_pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu); |
e95c8d51 | 952 | |
5fe141fd FB |
953 | /* loader.c */ |
954 | int get_image_size(const char *filename); | |
955 | int load_image(const char *filename, uint8_t *addr); | |
9ee3c029 | 956 | int load_elf(const char *filename, int64_t virt_to_phys_addend, uint64_t *pentry); |
e80cfcfc FB |
957 | int load_aout(const char *filename, uint8_t *addr); |
958 | ||
959 | /* slavio_timer.c */ | |
ba3c64fb | 960 | void slavio_timer_init(uint32_t addr, int irq, int mode, unsigned int cpu); |
8d5f07fa | 961 | |
e80cfcfc FB |
962 | /* slavio_serial.c */ |
963 | SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2); | |
964 | void slavio_serial_ms_kbd_init(int base, int irq); | |
e95c8d51 | 965 | |
3475187d FB |
966 | /* slavio_misc.c */ |
967 | void *slavio_misc_init(uint32_t base, int irq); | |
968 | void slavio_set_power_fail(void *opaque, int power_failing); | |
969 | ||
6f7e9aec FB |
970 | /* esp.c */ |
971 | void esp_init(BlockDriverState **bd, int irq, uint32_t espaddr, uint32_t espdaddr); | |
972 | ||
3475187d FB |
973 | /* sun4u.c */ |
974 | extern QEMUMachine sun4u_machine; | |
975 | ||
64201201 FB |
976 | /* NVRAM helpers */ |
977 | #include "hw/m48t59.h" | |
978 | ||
979 | void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value); | |
980 | uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr); | |
981 | void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value); | |
982 | uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr); | |
983 | void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value); | |
984 | uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr); | |
985 | void NVRAM_set_string (m48t59_t *nvram, uint32_t addr, | |
986 | const unsigned char *str, uint32_t max); | |
987 | int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max); | |
988 | void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr, | |
989 | uint32_t start, uint32_t count); | |
990 | int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size, | |
991 | const unsigned char *arch, | |
992 | uint32_t RAM_size, int boot_device, | |
993 | uint32_t kernel_image, uint32_t kernel_size, | |
28b9b5af | 994 | const char *cmdline, |
64201201 | 995 | uint32_t initrd_image, uint32_t initrd_size, |
28b9b5af FB |
996 | uint32_t NVRAM_image, |
997 | int width, int height, int depth); | |
64201201 | 998 | |
63066f4f FB |
999 | /* adb.c */ |
1000 | ||
1001 | #define MAX_ADB_DEVICES 16 | |
1002 | ||
e2733d20 | 1003 | #define ADB_MAX_OUT_LEN 16 |
63066f4f | 1004 | |
e2733d20 | 1005 | typedef struct ADBDevice ADBDevice; |
63066f4f | 1006 | |
e2733d20 FB |
1007 | /* buf = NULL means polling */ |
1008 | typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out, | |
1009 | const uint8_t *buf, int len); | |
12c28fed FB |
1010 | typedef int ADBDeviceReset(ADBDevice *d); |
1011 | ||
63066f4f FB |
1012 | struct ADBDevice { |
1013 | struct ADBBusState *bus; | |
1014 | int devaddr; | |
1015 | int handler; | |
e2733d20 | 1016 | ADBDeviceRequest *devreq; |
12c28fed | 1017 | ADBDeviceReset *devreset; |
63066f4f FB |
1018 | void *opaque; |
1019 | }; | |
1020 | ||
1021 | typedef struct ADBBusState { | |
1022 | ADBDevice devices[MAX_ADB_DEVICES]; | |
1023 | int nb_devices; | |
e2733d20 | 1024 | int poll_index; |
63066f4f FB |
1025 | } ADBBusState; |
1026 | ||
e2733d20 FB |
1027 | int adb_request(ADBBusState *s, uint8_t *buf_out, |
1028 | const uint8_t *buf, int len); | |
1029 | int adb_poll(ADBBusState *s, uint8_t *buf_out); | |
63066f4f FB |
1030 | |
1031 | ADBDevice *adb_register_device(ADBBusState *s, int devaddr, | |
e2733d20 | 1032 | ADBDeviceRequest *devreq, |
12c28fed | 1033 | ADBDeviceReset *devreset, |
63066f4f FB |
1034 | void *opaque); |
1035 | void adb_kbd_init(ADBBusState *bus); | |
1036 | void adb_mouse_init(ADBBusState *bus); | |
1037 | ||
1038 | /* cuda.c */ | |
1039 | ||
1040 | extern ADBBusState adb_bus; | |
54fa5af5 | 1041 | int cuda_init(SetIRQFunc *set_irq, void *irq_opaque, int irq); |
63066f4f | 1042 | |
bb36d470 FB |
1043 | #include "hw/usb.h" |
1044 | ||
a594cfbf FB |
1045 | /* usb ports of the VM */ |
1046 | ||
0d92ed30 PB |
1047 | void qemu_register_usb_port(USBPort *port, void *opaque, int index, |
1048 | usb_attachfn attach); | |
a594cfbf | 1049 | |
0d92ed30 | 1050 | #define VM_USB_HUB_SIZE 8 |
a594cfbf FB |
1051 | |
1052 | void do_usb_add(const char *devname); | |
1053 | void do_usb_del(const char *devname); | |
1054 | void usb_info(void); | |
1055 | ||
2e5d83bb PB |
1056 | /* scsi-disk.c */ |
1057 | typedef struct SCSIDevice SCSIDevice; | |
1058 | typedef void (*scsi_completionfn)(void *, uint32_t, int); | |
1059 | ||
1060 | SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, | |
1061 | scsi_completionfn completion, | |
1062 | void *opaque); | |
1063 | void scsi_disk_destroy(SCSIDevice *s); | |
1064 | ||
0fc5c15a | 1065 | int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun); |
2e5d83bb PB |
1066 | int scsi_read_data(SCSIDevice *s, uint8_t *data, uint32_t len); |
1067 | int scsi_write_data(SCSIDevice *s, uint8_t *data, uint32_t len); | |
1068 | ||
7d8406be PB |
1069 | /* lsi53c895a.c */ |
1070 | void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id); | |
1071 | void *lsi_scsi_init(PCIBus *bus, int devfn); | |
1072 | ||
b5ff1b31 | 1073 | /* integratorcp.c */ |
40f137e1 PB |
1074 | extern QEMUMachine integratorcp926_machine; |
1075 | extern QEMUMachine integratorcp1026_machine; | |
b5ff1b31 | 1076 | |
cdbdb648 PB |
1077 | /* versatilepb.c */ |
1078 | extern QEMUMachine versatilepb_machine; | |
16406950 | 1079 | extern QEMUMachine versatileab_machine; |
cdbdb648 | 1080 | |
daa57963 FB |
1081 | /* ps2.c */ |
1082 | void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg); | |
1083 | void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg); | |
1084 | void ps2_write_mouse(void *, int val); | |
1085 | void ps2_write_keyboard(void *, int val); | |
1086 | uint32_t ps2_read_data(void *); | |
1087 | void ps2_queue(void *, int b); | |
f94f5d71 | 1088 | void ps2_keyboard_set_translation(void *opaque, int mode); |
daa57963 | 1089 | |
80337b66 FB |
1090 | /* smc91c111.c */ |
1091 | void smc91c111_init(NICInfo *, uint32_t, void *, int); | |
1092 | ||
bdd5003a | 1093 | /* pl110.c */ |
95219897 | 1094 | void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int); |
bdd5003a | 1095 | |
cdbdb648 PB |
1096 | /* pl011.c */ |
1097 | void pl011_init(uint32_t base, void *pic, int irq, CharDriverState *chr); | |
1098 | ||
1099 | /* pl050.c */ | |
1100 | void pl050_init(uint32_t base, void *pic, int irq, int is_mouse); | |
1101 | ||
1102 | /* pl080.c */ | |
1103 | void *pl080_init(uint32_t base, void *pic, int irq); | |
1104 | ||
1105 | /* pl190.c */ | |
1106 | void *pl190_init(uint32_t base, void *parent, int irq, int fiq); | |
1107 | ||
1108 | /* arm-timer.c */ | |
1109 | void sp804_init(uint32_t base, void *pic, int irq); | |
1110 | void icp_pit_init(uint32_t base, void *pic, int irq); | |
1111 | ||
16406950 PB |
1112 | /* arm_boot.c */ |
1113 | ||
1114 | void arm_load_kernel(int ram_size, const char *kernel_filename, | |
1115 | const char *kernel_cmdline, const char *initrd_filename, | |
1116 | int board_id); | |
1117 | ||
27c7ca7e FB |
1118 | /* sh7750.c */ |
1119 | struct SH7750State; | |
1120 | ||
008a8818 | 1121 | struct SH7750State *sh7750_init(CPUState * cpu); |
27c7ca7e FB |
1122 | |
1123 | typedef struct { | |
1124 | /* The callback will be triggered if any of the designated lines change */ | |
1125 | uint16_t portamask_trigger; | |
1126 | uint16_t portbmask_trigger; | |
1127 | /* Return 0 if no action was taken */ | |
1128 | int (*port_change_cb) (uint16_t porta, uint16_t portb, | |
1129 | uint16_t * periph_pdtra, | |
1130 | uint16_t * periph_portdira, | |
1131 | uint16_t * periph_pdtrb, | |
1132 | uint16_t * periph_portdirb); | |
1133 | } sh7750_io_device; | |
1134 | ||
1135 | int sh7750_register_io_device(struct SH7750State *s, | |
1136 | sh7750_io_device * device); | |
1137 | /* tc58128.c */ | |
1138 | int tc58128_init(struct SH7750State *s, char *zone1, char *zone2); | |
1139 | ||
29133e9a FB |
1140 | /* NOR flash devices */ |
1141 | typedef struct pflash_t pflash_t; | |
1142 | ||
1143 | pflash_t *pflash_register (target_ulong base, ram_addr_t off, | |
1144 | BlockDriverState *bs, | |
1145 | target_ulong sector_len, int nb_blocs, int width, | |
1146 | uint16_t id0, uint16_t id1, | |
1147 | uint16_t id2, uint16_t id3); | |
1148 | ||
ea2384d3 FB |
1149 | #endif /* defined(QEMU_TOOL) */ |
1150 | ||
c4b1fcc0 | 1151 | /* monitor.c */ |
82c643ff | 1152 | void monitor_init(CharDriverState *hd, int show_banner); |
ea2384d3 FB |
1153 | void term_puts(const char *str); |
1154 | void term_vprintf(const char *fmt, va_list ap); | |
40c3bac3 | 1155 | void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); |
c4b1fcc0 FB |
1156 | void term_flush(void); |
1157 | void term_print_help(void); | |
ea2384d3 FB |
1158 | void monitor_readline(const char *prompt, int is_password, |
1159 | char *buf, int buf_size); | |
1160 | ||
1161 | /* readline.c */ | |
1162 | typedef void ReadLineFunc(void *opaque, const char *str); | |
1163 | ||
1164 | extern int completion_index; | |
1165 | void add_completion(const char *str); | |
1166 | void readline_handle_byte(int ch); | |
1167 | void readline_find_completion(const char *cmdline); | |
1168 | const char *readline_get_history(unsigned int index); | |
1169 | void readline_start(const char *prompt, int is_password, | |
1170 | ReadLineFunc *readline_func, void *opaque); | |
c4b1fcc0 | 1171 | |
5e6ad6f9 FB |
1172 | void kqemu_record_dump(void); |
1173 | ||
fc01f7e7 | 1174 | #endif /* VL_H */ |