]> Git Repo - qemu.git/blame - vl.h
Switch include for Solaris to avoid namespace issues. By Juergen Keil.
[qemu.git] / vl.h
CommitLineData
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>
67b915a5
FB
40
41#ifndef O_LARGEFILE
42#define O_LARGEFILE 0
43#endif
40c3bac3
FB
44#ifndef O_BINARY
45#define O_BINARY 0
46#endif
67b915a5 47
71c2fd5c
TS
48#ifndef ENOMEDIUM
49#define ENOMEDIUM ENODEV
50#endif
2e9671da 51
67b915a5 52#ifdef _WIN32
a18e524a 53#include <windows.h>
ac62f715 54#define fsync _commit
57d1a2b6
FB
55#define lseek _lseeki64
56#define ENOTSUP 4096
beac80cd
FB
57extern int qemu_ftruncate64(int, int64_t);
58#define ftruncate qemu_ftruncate64
59
57d1a2b6
FB
60
61static inline char *realpath(const char *path, char *resolved_path)
62{
63 _fullpath(resolved_path, path, _MAX_PATH);
64 return resolved_path;
65}
ec3757de
FB
66
67#define PRId64 "I64d"
26a76461
FB
68#define PRIx64 "I64x"
69#define PRIu64 "I64u"
70#define PRIo64 "I64o"
67b915a5 71#endif
8a7ddc38 72
ea2384d3
FB
73#ifdef QEMU_TOOL
74
75/* we use QEMU_TOOL in the command line tools which do not depend on
76 the target CPU type */
77#include "config-host.h"
78#include <setjmp.h>
79#include "osdep.h"
80#include "bswap.h"
81
82#else
83
4f209290 84#include "audio/audio.h"
16f62432
FB
85#include "cpu.h"
86
ea2384d3
FB
87#endif /* !defined(QEMU_TOOL) */
88
67b915a5
FB
89#ifndef glue
90#define xglue(x, y) x ## y
91#define glue(x, y) xglue(x, y)
92#define stringify(s) tostring(s)
93#define tostring(s) #s
94#endif
95
24236869
FB
96#ifndef MIN
97#define MIN(a, b) (((a) < (b)) ? (a) : (b))
98#endif
99#ifndef MAX
100#define MAX(a, b) (((a) > (b)) ? (a) : (b))
101#endif
102
18607dcb
FB
103/* cutils.c */
104void pstrcpy(char *buf, int buf_size, const char *str);
105char *pstrcat(char *buf, int buf_size, const char *s);
106int strstart(const char *str, const char *val, const char **ptr);
107int stristart(const char *str, const char *val, const char **ptr);
108
33e3963e 109/* vl.c */
80cabfad 110uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
313aa567 111
80cabfad
FB
112void hw_error(const char *fmt, ...);
113
80cabfad
FB
114extern const char *bios_dir;
115
8a7ddc38 116extern int vm_running;
c35734b2 117extern const char *qemu_name;
8a7ddc38 118
0bd48850
FB
119typedef struct vm_change_state_entry VMChangeStateEntry;
120typedef void VMChangeStateHandler(void *opaque, int running);
8a7ddc38
FB
121typedef void VMStopHandler(void *opaque, int reason);
122
0bd48850
FB
123VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
124 void *opaque);
125void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
126
8a7ddc38
FB
127int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
128void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
129
130void vm_start(void);
131void vm_stop(int reason);
132
bb0c6722
FB
133typedef void QEMUResetHandler(void *opaque);
134
135void qemu_register_reset(QEMUResetHandler *func, void *opaque);
136void qemu_system_reset_request(void);
137void qemu_system_shutdown_request(void);
3475187d
FB
138void qemu_system_powerdown_request(void);
139#if !defined(TARGET_SPARC)
140// Please implement a power failure function to signal the OS
141#define qemu_system_powerdown() do{}while(0)
142#else
143void qemu_system_powerdown(void);
144#endif
bb0c6722 145
ea2384d3
FB
146void main_loop_wait(int timeout);
147
0ced6589
FB
148extern int ram_size;
149extern int bios_size;
ee22c2f7 150extern int rtc_utc;
1f04275e 151extern int cirrus_vga_enabled;
28b9b5af
FB
152extern int graphic_width;
153extern int graphic_height;
154extern int graphic_depth;
3d11d0eb 155extern const char *keyboard_layout;
d993e026 156extern int kqemu_allowed;
a09db21f 157extern int win2k_install_hack;
bb36d470 158extern int usb_enabled;
6a00d601 159extern int smp_cpus;
667accab 160extern int no_quit;
8e71621f 161extern int semihosting_enabled;
3c07f8e8 162extern int autostart;
47d5d01a 163extern const char *bootp_filename;
0ced6589 164
9ae02555
TS
165#define MAX_OPTION_ROMS 16
166extern const char *option_rom[MAX_OPTION_ROMS];
167extern int nb_option_roms;
168
0ced6589 169/* XXX: make it dynamic */
970ac5a3 170#define MAX_BIOS_SIZE (4 * 1024 * 1024)
75956cf0 171#if defined (TARGET_PPC) || defined (TARGET_SPARC64)
d5295253 172#define BIOS_SIZE ((512 + 32) * 1024)
6af0bf9c 173#elif defined(TARGET_MIPS)
567daa49 174#define BIOS_SIZE (4 * 1024 * 1024)
0ced6589 175#endif
aaaa7df6 176
63066f4f
FB
177/* keyboard/mouse support */
178
179#define MOUSE_EVENT_LBUTTON 0x01
180#define MOUSE_EVENT_RBUTTON 0x02
181#define MOUSE_EVENT_MBUTTON 0x04
182
183typedef void QEMUPutKBDEvent(void *opaque, int keycode);
184typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
185
455204eb
TS
186typedef struct QEMUPutMouseEntry {
187 QEMUPutMouseEvent *qemu_put_mouse_event;
188 void *qemu_put_mouse_event_opaque;
189 int qemu_put_mouse_event_absolute;
190 char *qemu_put_mouse_event_name;
191
192 /* used internally by qemu for handling mice */
193 struct QEMUPutMouseEntry *next;
194} QEMUPutMouseEntry;
195
63066f4f 196void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
455204eb
TS
197QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
198 void *opaque, int absolute,
199 const char *name);
200void qemu_remove_mouse_event_handler(QEMUPutMouseEntry *entry);
63066f4f
FB
201
202void kbd_put_keycode(int keycode);
203void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
09b26c5e 204int kbd_mouse_is_absolute(void);
63066f4f 205
455204eb
TS
206void do_info_mice(void);
207void do_mouse_set(int index);
208
82c643ff
FB
209/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
210 constants) */
211#define QEMU_KEY_ESC1(c) ((c) | 0xe100)
212#define QEMU_KEY_BACKSPACE 0x007f
213#define QEMU_KEY_UP QEMU_KEY_ESC1('A')
214#define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
215#define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
216#define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
217#define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
218#define QEMU_KEY_END QEMU_KEY_ESC1(4)
219#define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
220#define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
221#define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
222
223#define QEMU_KEY_CTRL_UP 0xe400
224#define QEMU_KEY_CTRL_DOWN 0xe401
225#define QEMU_KEY_CTRL_LEFT 0xe402
226#define QEMU_KEY_CTRL_RIGHT 0xe403
227#define QEMU_KEY_CTRL_HOME 0xe404
228#define QEMU_KEY_CTRL_END 0xe405
229#define QEMU_KEY_CTRL_PAGEUP 0xe406
230#define QEMU_KEY_CTRL_PAGEDOWN 0xe407
231
232void kbd_put_keysym(int keysym);
233
c20709aa
FB
234/* async I/O support */
235
236typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
237typedef int IOCanRWHandler(void *opaque);
7c9d8e07 238typedef void IOHandler(void *opaque);
c20709aa 239
7c9d8e07
FB
240int qemu_set_fd_handler2(int fd,
241 IOCanRWHandler *fd_read_poll,
242 IOHandler *fd_read,
243 IOHandler *fd_write,
244 void *opaque);
245int qemu_set_fd_handler(int fd,
246 IOHandler *fd_read,
247 IOHandler *fd_write,
248 void *opaque);
c20709aa 249
f331110f
FB
250/* Polling handling */
251
252/* return TRUE if no sleep should be done afterwards */
253typedef int PollingFunc(void *opaque);
254
255int qemu_add_polling_cb(PollingFunc *func, void *opaque);
256void qemu_del_polling_cb(PollingFunc *func, void *opaque);
257
a18e524a
FB
258#ifdef _WIN32
259/* Wait objects handling */
260typedef void WaitObjectFunc(void *opaque);
261
262int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
263void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
264#endif
265
86e94dea
TS
266typedef struct QEMUBH QEMUBH;
267
82c643ff
FB
268/* character device */
269
270#define CHR_EVENT_BREAK 0 /* serial break char */
ea2384d3 271#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
86e94dea 272#define CHR_EVENT_RESET 2 /* new connection established */
2122c51a
FB
273
274
275#define CHR_IOCTL_SERIAL_SET_PARAMS 1
276typedef struct {
277 int speed;
278 int parity;
279 int data_bits;
280 int stop_bits;
281} QEMUSerialSetParams;
282
283#define CHR_IOCTL_SERIAL_SET_BREAK 2
284
285#define CHR_IOCTL_PP_READ_DATA 3
286#define CHR_IOCTL_PP_WRITE_DATA 4
287#define CHR_IOCTL_PP_READ_CONTROL 5
288#define CHR_IOCTL_PP_WRITE_CONTROL 6
289#define CHR_IOCTL_PP_READ_STATUS 7
5867c88a
TS
290#define CHR_IOCTL_PP_EPP_READ_ADDR 8
291#define CHR_IOCTL_PP_EPP_READ 9
292#define CHR_IOCTL_PP_EPP_WRITE_ADDR 10
293#define CHR_IOCTL_PP_EPP_WRITE 11
2122c51a 294
82c643ff
FB
295typedef void IOEventHandler(void *opaque, int event);
296
297typedef struct CharDriverState {
298 int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
e5b0bc44 299 void (*chr_update_read_handler)(struct CharDriverState *s);
2122c51a 300 int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
82c643ff 301 IOEventHandler *chr_event;
e5b0bc44
PB
302 IOCanRWHandler *chr_can_read;
303 IOReadHandler *chr_read;
304 void *handler_opaque;
eb45f5fe 305 void (*chr_send_event)(struct CharDriverState *chr, int event);
f331110f 306 void (*chr_close)(struct CharDriverState *chr);
82c643ff 307 void *opaque;
20d8a3ed 308 int focus;
86e94dea 309 QEMUBH *bh;
82c643ff
FB
310} CharDriverState;
311
5856de80 312CharDriverState *qemu_chr_open(const char *filename);
82c643ff
FB
313void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
314int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
ea2384d3 315void qemu_chr_send_event(CharDriverState *s, int event);
e5b0bc44
PB
316void qemu_chr_add_handlers(CharDriverState *s,
317 IOCanRWHandler *fd_can_read,
318 IOReadHandler *fd_read,
319 IOEventHandler *fd_event,
320 void *opaque);
2122c51a 321int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
86e94dea 322void qemu_chr_reset(CharDriverState *s);
e5b0bc44
PB
323int qemu_chr_can_read(CharDriverState *s);
324void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
f8d179e3 325
82c643ff
FB
326/* consoles */
327
328typedef struct DisplayState DisplayState;
329typedef struct TextConsole TextConsole;
330
95219897
PB
331typedef void (*vga_hw_update_ptr)(void *);
332typedef void (*vga_hw_invalidate_ptr)(void *);
333typedef void (*vga_hw_screen_dump_ptr)(void *, const char *);
334
335TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
336 vga_hw_invalidate_ptr invalidate,
337 vga_hw_screen_dump_ptr screen_dump,
338 void *opaque);
339void vga_hw_update(void);
340void vga_hw_invalidate(void);
341void vga_hw_screen_dump(const char *filename);
342
343int is_graphic_console(void);
82c643ff
FB
344CharDriverState *text_console_init(DisplayState *ds);
345void console_select(unsigned int index);
346
8d11df9e
FB
347/* serial ports */
348
349#define MAX_SERIAL_PORTS 4
350
351extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
352
6508fe59
FB
353/* parallel ports */
354
355#define MAX_PARALLEL_PORTS 3
356
357extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
358
5867c88a
TS
359struct ParallelIOArg {
360 void *buffer;
361 int count;
362};
363
7c9d8e07
FB
364/* VLANs support */
365
366typedef struct VLANClientState VLANClientState;
367
368struct VLANClientState {
369 IOReadHandler *fd_read;
d861b05e
PB
370 /* Packets may still be sent if this returns zero. It's used to
371 rate-limit the slirp code. */
372 IOCanRWHandler *fd_can_read;
7c9d8e07
FB
373 void *opaque;
374 struct VLANClientState *next;
375 struct VLANState *vlan;
376 char info_str[256];
377};
378
379typedef struct VLANState {
380 int id;
381 VLANClientState *first_client;
382 struct VLANState *next;
383} VLANState;
384
385VLANState *qemu_find_vlan(int id);
386VLANClientState *qemu_new_vlan_client(VLANState *vlan,
d861b05e
PB
387 IOReadHandler *fd_read,
388 IOCanRWHandler *fd_can_read,
389 void *opaque);
390int qemu_can_send_packet(VLANClientState *vc);
7c9d8e07 391void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
d861b05e 392void qemu_handler_true(void *opaque);
7c9d8e07
FB
393
394void do_info_network(void);
395
7fb843f8
FB
396/* TAP win32 */
397int tap_win32_init(VLANState *vlan, const char *ifname);
7fb843f8 398
7c9d8e07 399/* NIC info */
c4b1fcc0
FB
400
401#define MAX_NICS 8
402
7c9d8e07 403typedef struct NICInfo {
c4b1fcc0 404 uint8_t macaddr[6];
a41b2ff2 405 const char *model;
7c9d8e07
FB
406 VLANState *vlan;
407} NICInfo;
c4b1fcc0
FB
408
409extern int nb_nics;
7c9d8e07 410extern NICInfo nd_table[MAX_NICS];
8a7ddc38
FB
411
412/* timers */
413
414typedef struct QEMUClock QEMUClock;
415typedef struct QEMUTimer QEMUTimer;
416typedef void QEMUTimerCB(void *opaque);
417
418/* The real time clock should be used only for stuff which does not
419 change the virtual machine state, as it is run even if the virtual
69b91039 420 machine is stopped. The real time clock has a frequency of 1000
8a7ddc38
FB
421 Hz. */
422extern QEMUClock *rt_clock;
423
e80cfcfc 424/* The virtual clock is only run during the emulation. It is stopped
8a7ddc38
FB
425 when the virtual machine is stopped. Virtual timers use a high
426 precision clock, usually cpu cycles (use ticks_per_sec). */
427extern QEMUClock *vm_clock;
428
429int64_t qemu_get_clock(QEMUClock *clock);
430
431QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
432void qemu_free_timer(QEMUTimer *ts);
433void qemu_del_timer(QEMUTimer *ts);
434void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
435int qemu_timer_pending(QEMUTimer *ts);
436
437extern int64_t ticks_per_sec;
438extern int pit_min_timer_count;
439
1dce7c3c 440int64_t cpu_get_ticks(void);
8a7ddc38
FB
441void cpu_enable_ticks(void);
442void cpu_disable_ticks(void);
443
444/* VM Load/Save */
445
faea38e7 446typedef struct QEMUFile QEMUFile;
8a7ddc38 447
faea38e7
FB
448QEMUFile *qemu_fopen(const char *filename, const char *mode);
449void qemu_fflush(QEMUFile *f);
450void qemu_fclose(QEMUFile *f);
8a7ddc38
FB
451void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
452void qemu_put_byte(QEMUFile *f, int v);
453void qemu_put_be16(QEMUFile *f, unsigned int v);
454void qemu_put_be32(QEMUFile *f, unsigned int v);
455void qemu_put_be64(QEMUFile *f, uint64_t v);
456int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
457int qemu_get_byte(QEMUFile *f);
458unsigned int qemu_get_be16(QEMUFile *f);
459unsigned int qemu_get_be32(QEMUFile *f);
460uint64_t qemu_get_be64(QEMUFile *f);
461
462static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
463{
464 qemu_put_be64(f, *pv);
465}
466
467static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
468{
469 qemu_put_be32(f, *pv);
470}
471
472static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
473{
474 qemu_put_be16(f, *pv);
475}
476
477static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
478{
479 qemu_put_byte(f, *pv);
480}
481
482static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
483{
484 *pv = qemu_get_be64(f);
485}
486
487static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
488{
489 *pv = qemu_get_be32(f);
490}
491
492static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
493{
494 *pv = qemu_get_be16(f);
495}
496
497static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
498{
499 *pv = qemu_get_byte(f);
500}
501
c27004ec
FB
502#if TARGET_LONG_BITS == 64
503#define qemu_put_betl qemu_put_be64
504#define qemu_get_betl qemu_get_be64
505#define qemu_put_betls qemu_put_be64s
506#define qemu_get_betls qemu_get_be64s
507#else
508#define qemu_put_betl qemu_put_be32
509#define qemu_get_betl qemu_get_be32
510#define qemu_put_betls qemu_put_be32s
511#define qemu_get_betls qemu_get_be32s
512#endif
513
8a7ddc38
FB
514int64_t qemu_ftell(QEMUFile *f);
515int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
516
517typedef void SaveStateHandler(QEMUFile *f, void *opaque);
518typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
519
8a7ddc38
FB
520int register_savevm(const char *idstr,
521 int instance_id,
522 int version_id,
523 SaveStateHandler *save_state,
524 LoadStateHandler *load_state,
525 void *opaque);
526void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
527void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
c4b1fcc0 528
6a00d601
FB
529void cpu_save(QEMUFile *f, void *opaque);
530int cpu_load(QEMUFile *f, void *opaque, int version_id);
531
faea38e7
FB
532void do_savevm(const char *name);
533void do_loadvm(const char *name);
534void do_delvm(const char *name);
535void do_info_snapshots(void);
536
83f64091 537/* bottom halves */
83f64091
FB
538typedef void QEMUBHFunc(void *opaque);
539
540QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque);
541void qemu_bh_schedule(QEMUBH *bh);
542void qemu_bh_cancel(QEMUBH *bh);
543void qemu_bh_delete(QEMUBH *bh);
6eb5733a 544int qemu_bh_poll(void);
83f64091 545
fc01f7e7
FB
546/* block.c */
547typedef struct BlockDriverState BlockDriverState;
ea2384d3
FB
548typedef struct BlockDriver BlockDriver;
549
550extern BlockDriver bdrv_raw;
19cb3738 551extern BlockDriver bdrv_host_device;
ea2384d3
FB
552extern BlockDriver bdrv_cow;
553extern BlockDriver bdrv_qcow;
554extern BlockDriver bdrv_vmdk;
3c56521b 555extern BlockDriver bdrv_cloop;
585d0ed9 556extern BlockDriver bdrv_dmg;
a8753c34 557extern BlockDriver bdrv_bochs;
6a0f9e82 558extern BlockDriver bdrv_vpc;
de167e41 559extern BlockDriver bdrv_vvfat;
faea38e7
FB
560extern BlockDriver bdrv_qcow2;
561
562typedef struct BlockDriverInfo {
563 /* in bytes, 0 if irrelevant */
564 int cluster_size;
565 /* offset at which the VM state can be saved (0 if not possible) */
566 int64_t vm_state_offset;
567} BlockDriverInfo;
568
569typedef struct QEMUSnapshotInfo {
570 char id_str[128]; /* unique snapshot id */
571 /* the following fields are informative. They are not needed for
572 the consistency of the snapshot */
573 char name[256]; /* user choosen name */
574 uint32_t vm_state_size; /* VM state info size */
575 uint32_t date_sec; /* UTC date of the snapshot */
576 uint32_t date_nsec;
577 uint64_t vm_clock_nsec; /* VM clock relative to boot */
578} QEMUSnapshotInfo;
ea2384d3 579
83f64091
FB
580#define BDRV_O_RDONLY 0x0000
581#define BDRV_O_RDWR 0x0002
582#define BDRV_O_ACCESS 0x0003
583#define BDRV_O_CREAT 0x0004 /* create an empty file */
584#define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */
585#define BDRV_O_FILE 0x0010 /* open as a raw file (do not try to
586 use a disk image format on top of
587 it (default for
588 bdrv_file_open()) */
589
ea2384d3
FB
590void bdrv_init(void);
591BlockDriver *bdrv_find_format(const char *format_name);
592int bdrv_create(BlockDriver *drv,
593 const char *filename, int64_t size_in_sectors,
594 const char *backing_file, int flags);
c4b1fcc0
FB
595BlockDriverState *bdrv_new(const char *device_name);
596void bdrv_delete(BlockDriverState *bs);
83f64091
FB
597int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags);
598int bdrv_open(BlockDriverState *bs, const char *filename, int flags);
599int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
ea2384d3 600 BlockDriver *drv);
fc01f7e7
FB
601void bdrv_close(BlockDriverState *bs);
602int bdrv_read(BlockDriverState *bs, int64_t sector_num,
603 uint8_t *buf, int nb_sectors);
604int bdrv_write(BlockDriverState *bs, int64_t sector_num,
605 const uint8_t *buf, int nb_sectors);
83f64091
FB
606int bdrv_pread(BlockDriverState *bs, int64_t offset,
607 void *buf, int count);
608int bdrv_pwrite(BlockDriverState *bs, int64_t offset,
609 const void *buf, int count);
610int bdrv_truncate(BlockDriverState *bs, int64_t offset);
611int64_t bdrv_getlength(BlockDriverState *bs);
fc01f7e7 612void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
33e3963e 613int bdrv_commit(BlockDriverState *bs);
77fef8c1 614void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
83f64091
FB
615/* async block I/O */
616typedef struct BlockDriverAIOCB BlockDriverAIOCB;
617typedef void BlockDriverCompletionFunc(void *opaque, int ret);
618
ce1a14dc
PB
619BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num,
620 uint8_t *buf, int nb_sectors,
621 BlockDriverCompletionFunc *cb, void *opaque);
622BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num,
623 const uint8_t *buf, int nb_sectors,
624 BlockDriverCompletionFunc *cb, void *opaque);
83f64091 625void bdrv_aio_cancel(BlockDriverAIOCB *acb);
83f64091
FB
626
627void qemu_aio_init(void);
628void qemu_aio_poll(void);
6192bc37 629void qemu_aio_flush(void);
83f64091
FB
630void qemu_aio_wait_start(void);
631void qemu_aio_wait(void);
632void qemu_aio_wait_end(void);
633
7a6cba61
PB
634/* Ensure contents are flushed to disk. */
635void bdrv_flush(BlockDriverState *bs);
33e3963e 636
c4b1fcc0
FB
637#define BDRV_TYPE_HD 0
638#define BDRV_TYPE_CDROM 1
639#define BDRV_TYPE_FLOPPY 2
4dbb0f50
TS
640#define BIOS_ATA_TRANSLATION_AUTO 0
641#define BIOS_ATA_TRANSLATION_NONE 1
642#define BIOS_ATA_TRANSLATION_LBA 2
643#define BIOS_ATA_TRANSLATION_LARGE 3
644#define BIOS_ATA_TRANSLATION_RECHS 4
c4b1fcc0
FB
645
646void bdrv_set_geometry_hint(BlockDriverState *bs,
647 int cyls, int heads, int secs);
648void bdrv_set_type_hint(BlockDriverState *bs, int type);
46d4767d 649void bdrv_set_translation_hint(BlockDriverState *bs, int translation);
c4b1fcc0
FB
650void bdrv_get_geometry_hint(BlockDriverState *bs,
651 int *pcyls, int *pheads, int *psecs);
652int bdrv_get_type_hint(BlockDriverState *bs);
46d4767d 653int bdrv_get_translation_hint(BlockDriverState *bs);
c4b1fcc0
FB
654int bdrv_is_removable(BlockDriverState *bs);
655int bdrv_is_read_only(BlockDriverState *bs);
656int bdrv_is_inserted(BlockDriverState *bs);
19cb3738 657int bdrv_media_changed(BlockDriverState *bs);
c4b1fcc0
FB
658int bdrv_is_locked(BlockDriverState *bs);
659void bdrv_set_locked(BlockDriverState *bs, int locked);
19cb3738 660void bdrv_eject(BlockDriverState *bs, int eject_flag);
c4b1fcc0
FB
661void bdrv_set_change_cb(BlockDriverState *bs,
662 void (*change_cb)(void *opaque), void *opaque);
ea2384d3 663void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
c4b1fcc0
FB
664void bdrv_info(void);
665BlockDriverState *bdrv_find(const char *name);
82c643ff 666void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
ea2384d3
FB
667int bdrv_is_encrypted(BlockDriverState *bs);
668int bdrv_set_key(BlockDriverState *bs, const char *key);
669void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
670 void *opaque);
671const char *bdrv_get_device_name(BlockDriverState *bs);
faea38e7
FB
672int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num,
673 const uint8_t *buf, int nb_sectors);
674int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
c4b1fcc0 675
83f64091
FB
676void bdrv_get_backing_filename(BlockDriverState *bs,
677 char *filename, int filename_size);
faea38e7
FB
678int bdrv_snapshot_create(BlockDriverState *bs,
679 QEMUSnapshotInfo *sn_info);
680int bdrv_snapshot_goto(BlockDriverState *bs,
681 const char *snapshot_id);
682int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id);
683int bdrv_snapshot_list(BlockDriverState *bs,
684 QEMUSnapshotInfo **psn_info);
685char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
686
687char *get_human_readable_size(char *buf, int buf_size, int64_t size);
83f64091
FB
688int path_is_absolute(const char *path);
689void path_combine(char *dest, int dest_size,
690 const char *base_path,
691 const char *filename);
ea2384d3
FB
692
693#ifndef QEMU_TOOL
54fa5af5
FB
694
695typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size,
696 int boot_device,
697 DisplayState *ds, const char **fd_filename, int snapshot,
698 const char *kernel_filename, const char *kernel_cmdline,
94fc95cd 699 const char *initrd_filename, const char *cpu_model);
54fa5af5
FB
700
701typedef struct QEMUMachine {
702 const char *name;
703 const char *desc;
704 QEMUMachineInitFunc *init;
705 struct QEMUMachine *next;
706} QEMUMachine;
707
708int qemu_register_machine(QEMUMachine *m);
709
710typedef void SetIRQFunc(void *opaque, int irq_num, int level);
3de388f6 711typedef void IRQRequestFunc(void *opaque, int level);
54fa5af5 712
94fc95cd
JM
713#if defined(TARGET_PPC)
714void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
715#endif
716
33d68b5f
TS
717#if defined(TARGET_MIPS)
718void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
719#endif
720
26aa7d72
FB
721/* ISA bus */
722
723extern target_phys_addr_t isa_mem_base;
724
725typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
726typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
727
728int register_ioport_read(int start, int length, int size,
729 IOPortReadFunc *func, void *opaque);
730int register_ioport_write(int start, int length, int size,
731 IOPortWriteFunc *func, void *opaque);
69b91039
FB
732void isa_unassign_ioport(int start, int length);
733
aef445bd
PB
734void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
735
69b91039
FB
736/* PCI bus */
737
69b91039
FB
738extern target_phys_addr_t pci_mem_base;
739
46e50e9d 740typedef struct PCIBus PCIBus;
69b91039
FB
741typedef struct PCIDevice PCIDevice;
742
743typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
744 uint32_t address, uint32_t data, int len);
745typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
746 uint32_t address, int len);
747typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
748 uint32_t addr, uint32_t size, int type);
749
750#define PCI_ADDRESS_SPACE_MEM 0x00
751#define PCI_ADDRESS_SPACE_IO 0x01
752#define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
753
754typedef struct PCIIORegion {
5768f5ac 755 uint32_t addr; /* current PCI mapping address. -1 means not mapped */
69b91039
FB
756 uint32_t size;
757 uint8_t type;
758 PCIMapIORegionFunc *map_func;
759} PCIIORegion;
760
8a8696a3
FB
761#define PCI_ROM_SLOT 6
762#define PCI_NUM_REGIONS 7
502a5395
PB
763
764#define PCI_DEVICES_MAX 64
765
766#define PCI_VENDOR_ID 0x00 /* 16 bits */
767#define PCI_DEVICE_ID 0x02 /* 16 bits */
768#define PCI_COMMAND 0x04 /* 16 bits */
769#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
770#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
771#define PCI_CLASS_DEVICE 0x0a /* Device class */
772#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
773#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
774#define PCI_MIN_GNT 0x3e /* 8 bits */
775#define PCI_MAX_LAT 0x3f /* 8 bits */
776
69b91039
FB
777struct PCIDevice {
778 /* PCI config space */
779 uint8_t config[256];
780
781 /* the following fields are read only */
46e50e9d 782 PCIBus *bus;
69b91039
FB
783 int devfn;
784 char name[64];
8a8696a3 785 PCIIORegion io_regions[PCI_NUM_REGIONS];
69b91039
FB
786
787 /* do not access the following fields */
788 PCIConfigReadFunc *config_read;
789 PCIConfigWriteFunc *config_write;
502a5395 790 /* ??? This is a PC-specific hack, and should be removed. */
5768f5ac 791 int irq_index;
d2b59317
PB
792
793 /* Current IRQ levels. Used internally by the generic PCI code. */
794 int irq_state[4];
69b91039
FB
795};
796
46e50e9d
FB
797PCIDevice *pci_register_device(PCIBus *bus, const char *name,
798 int instance_size, int devfn,
69b91039
FB
799 PCIConfigReadFunc *config_read,
800 PCIConfigWriteFunc *config_write);
801
802void pci_register_io_region(PCIDevice *pci_dev, int region_num,
803 uint32_t size, int type,
804 PCIMapIORegionFunc *map_func);
805
5768f5ac
FB
806void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
807
808uint32_t pci_default_read_config(PCIDevice *d,
809 uint32_t address, int len);
810void pci_default_write_config(PCIDevice *d,
811 uint32_t address, uint32_t val, int len);
89b6b508
FB
812void pci_device_save(PCIDevice *s, QEMUFile *f);
813int pci_device_load(PCIDevice *s, QEMUFile *f);
5768f5ac 814
d2b59317
PB
815typedef void (*pci_set_irq_fn)(void *pic, int irq_num, int level);
816typedef int (*pci_map_irq_fn)(PCIDevice *pci_dev, int irq_num);
817PCIBus *pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq,
80b3ada7 818 void *pic, int devfn_min, int nirq);
502a5395 819
abcebc7e 820void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn);
502a5395
PB
821void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len);
822uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
823int pci_bus_num(PCIBus *s);
80b3ada7 824void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
9995c51f 825
5768f5ac 826void pci_info(void);
80b3ada7
PB
827PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
828 pci_map_irq_fn map_irq, const char *name);
26aa7d72 829
502a5395 830/* prep_pci.c */
46e50e9d 831PCIBus *pci_prep_init(void);
77d4bc34 832
502a5395
PB
833/* grackle_pci.c */
834PCIBus *pci_grackle_init(uint32_t base, void *pic);
835
836/* unin_pci.c */
837PCIBus *pci_pmac_init(void *pic);
838
839/* apb_pci.c */
840PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base,
841 void *pic);
842
e69954b9 843PCIBus *pci_vpb_init(void *pic, int irq, int realview);
502a5395
PB
844
845/* piix_pci.c */
f00fc47c
FB
846PCIBus *i440fx_init(PCIDevice **pi440fx_state);
847void i440fx_set_smm(PCIDevice *d, int val);
8f1c91d8 848int piix3_init(PCIBus *bus, int devfn);
f00fc47c 849void i440fx_init_memory_mappings(PCIDevice *d);
a41b2ff2 850
5856de80
TS
851int piix4_init(PCIBus *bus, int devfn);
852
28b9b5af
FB
853/* openpic.c */
854typedef struct openpic_t openpic_t;
47103572
JM
855enum {
856 OPENPIC_EVT_INT = 0, /* IRQ */
857 OPENPIC_EVT_CINT, /* critical IRQ */
858 OPENPIC_EVT_MCK, /* Machine check event */
859 OPENPIC_EVT_DEBUG, /* Inconditional debug event */
860 OPENPIC_EVT_RESET, /* Core reset event */
861};
e69f67b6 862struct CPUPPCState;
54fa5af5 863void openpic_set_irq(void *opaque, int n_IRQ, int level);
47103572 864openpic_t *openpic_init (PCIBus *bus, SetIRQFunc *set_irq,
e69f67b6
TS
865 int *pmem_index, int nb_cpus,
866 struct CPUPPCState **envp);
28b9b5af 867
54fa5af5
FB
868/* heathrow_pic.c */
869typedef struct HeathrowPICS HeathrowPICS;
870void heathrow_pic_set_irq(void *opaque, int num, int level);
871HeathrowPICS *heathrow_pic_init(int *pmem_index);
872
fde7d5bd
TS
873/* gt64xxx.c */
874PCIBus *pci_gt64120_init(void *pic);
875
6a36d84e
FB
876#ifdef HAS_AUDIO
877struct soundhw {
878 const char *name;
879 const char *descr;
880 int enabled;
881 int isa;
882 union {
883 int (*init_isa) (AudioState *s);
884 int (*init_pci) (PCIBus *bus, AudioState *s);
885 } init;
886};
887
888extern struct soundhw soundhw[];
889#endif
890
313aa567
FB
891/* vga.c */
892
74a14f22 893#define VGA_RAM_SIZE (8192 * 1024)
313aa567 894
82c643ff 895struct DisplayState {
313aa567
FB
896 uint8_t *data;
897 int linesize;
898 int depth;
d3079cd2 899 int bgr; /* BGR color order instead of RGB. Only valid for depth == 32 */
82c643ff
FB
900 int width;
901 int height;
24236869
FB
902 void *opaque;
903
313aa567
FB
904 void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
905 void (*dpy_resize)(struct DisplayState *s, int w, int h);
906 void (*dpy_refresh)(struct DisplayState *s);
24236869 907 void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h);
82c643ff 908};
313aa567
FB
909
910static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
911{
912 s->dpy_update(s, x, y, w, h);
913}
914
915static inline void dpy_resize(DisplayState *s, int w, int h)
916{
917 s->dpy_resize(s, w, h);
918}
919
89b6b508
FB
920int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
921 unsigned long vga_ram_offset, int vga_ram_size);
922int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
923 unsigned long vga_ram_offset, int vga_ram_size,
924 unsigned long vga_bios_offset, int vga_bios_size);
313aa567 925
d6bfa22f 926/* cirrus_vga.c */
46e50e9d 927void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
d6bfa22f 928 unsigned long vga_ram_offset, int vga_ram_size);
d6bfa22f
FB
929void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
930 unsigned long vga_ram_offset, int vga_ram_size);
931
313aa567 932/* sdl.c */
43523e93 933void sdl_display_init(DisplayState *ds, int full_screen, int no_frame);
313aa567 934
da4dbf74
FB
935/* cocoa.m */
936void cocoa_display_init(DisplayState *ds, int full_screen);
937
24236869 938/* vnc.c */
73fc9742 939void vnc_display_init(DisplayState *ds, const char *display);
a9ce8590 940void do_info_vnc(void);
24236869 941
6070dd07
TS
942/* x_keymap.c */
943extern uint8_t _translate_keycode(const int key);
944
5391d806
FB
945/* ide.c */
946#define MAX_DISKS 4
947
faea38e7 948extern BlockDriverState *bs_table[MAX_DISKS + 1];
5391d806 949
69b91039
FB
950void isa_ide_init(int iobase, int iobase2, int irq,
951 BlockDriverState *hd0, BlockDriverState *hd1);
54fa5af5
FB
952void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
953 int secondary_ide_enabled);
502a5395 954void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn);
28b9b5af 955int pmac_ide_init (BlockDriverState **hd_table,
54fa5af5 956 SetIRQFunc *set_irq, void *irq_opaque, int irq);
5391d806 957
2e5d83bb
PB
958/* cdrom.c */
959int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track);
960int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num);
961
9542611a
TS
962/* ds1225y.c */
963typedef struct ds1225y_t ds1225y_t;
964ds1225y_t *ds1225y_init(target_ulong mem_base, const char *filename);
965
1d14ffa9 966/* es1370.c */
c0fe3827 967int es1370_init (PCIBus *bus, AudioState *s);
1d14ffa9 968
fb065187 969/* sb16.c */
c0fe3827 970int SB16_init (AudioState *s);
fb065187
FB
971
972/* adlib.c */
c0fe3827 973int Adlib_init (AudioState *s);
fb065187
FB
974
975/* gus.c */
c0fe3827 976int GUS_init (AudioState *s);
27503323
FB
977
978/* dma.c */
85571bc7 979typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
27503323 980int DMA_get_channel_mode (int nchan);
85571bc7
FB
981int DMA_read_memory (int nchan, void *buf, int pos, int size);
982int DMA_write_memory (int nchan, void *buf, int pos, int size);
27503323
FB
983void DMA_hold_DREQ (int nchan);
984void DMA_release_DREQ (int nchan);
16f62432 985void DMA_schedule(int nchan);
27503323 986void DMA_run (void);
28b9b5af 987void DMA_init (int high_page_enable);
27503323 988void DMA_register_channel (int nchan,
85571bc7
FB
989 DMA_transfer_handler transfer_handler,
990 void *opaque);
7138fcfb
FB
991/* fdc.c */
992#define MAX_FD 2
993extern BlockDriverState *fd_table[MAX_FD];
994
baca51fa
FB
995typedef struct fdctrl_t fdctrl_t;
996
997fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
998 uint32_t io_base,
999 BlockDriverState **fds);
1000int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
7138fcfb 1001
80cabfad
FB
1002/* ne2000.c */
1003
7c9d8e07 1004void isa_ne2000_init(int base, int irq, NICInfo *nd);
abcebc7e 1005void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn);
80cabfad 1006
a41b2ff2
PB
1007/* rtl8139.c */
1008
abcebc7e 1009void pci_rtl8139_init(PCIBus *bus, NICInfo *nd, int devfn);
a41b2ff2 1010
e3c2613f
FB
1011/* pcnet.c */
1012
abcebc7e 1013void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int devfn);
67e999be
FB
1014void pcnet_h_reset(void *opaque);
1015void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque);
1016
548df2ac
TS
1017/* vmmouse.c */
1018void *vmmouse_init(void *m);
e3c2613f 1019
80cabfad
FB
1020/* pckbd.c */
1021
80cabfad
FB
1022void kbd_init(void);
1023
1024/* mc146818rtc.c */
1025
8a7ddc38 1026typedef struct RTCState RTCState;
80cabfad 1027
8a7ddc38
FB
1028RTCState *rtc_init(int base, int irq);
1029void rtc_set_memory(RTCState *s, int addr, int val);
1030void rtc_set_date(RTCState *s, const struct tm *tm);
80cabfad
FB
1031
1032/* serial.c */
1033
c4b1fcc0 1034typedef struct SerialState SerialState;
e5d13e2f
FB
1035SerialState *serial_init(SetIRQFunc *set_irq, void *opaque,
1036 int base, int irq, CharDriverState *chr);
1037SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque,
1038 target_ulong base, int it_shift,
1039 int irq, CharDriverState *chr);
80cabfad 1040
6508fe59
FB
1041/* parallel.c */
1042
1043typedef struct ParallelState ParallelState;
1044ParallelState *parallel_init(int base, int irq, CharDriverState *chr);
1045
80cabfad
FB
1046/* i8259.c */
1047
3de388f6
FB
1048typedef struct PicState2 PicState2;
1049extern PicState2 *isa_pic;
80cabfad 1050void pic_set_irq(int irq, int level);
54fa5af5 1051void pic_set_irq_new(void *opaque, int irq, int level);
3de388f6 1052PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque);
d592d303
FB
1053void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,
1054 void *alt_irq_opaque);
3de388f6
FB
1055int pic_read_irq(PicState2 *s);
1056void pic_update_irq(PicState2 *s);
1057uint32_t pic_intack_read(PicState2 *s);
c20709aa 1058void pic_info(void);
4a0fb71e 1059void irq_info(void);
80cabfad 1060
c27004ec 1061/* APIC */
d592d303
FB
1062typedef struct IOAPICState IOAPICState;
1063
c27004ec
FB
1064int apic_init(CPUState *env);
1065int apic_get_interrupt(CPUState *env);
d592d303
FB
1066IOAPICState *ioapic_init(void);
1067void ioapic_set_irq(void *opaque, int vector, int level);
c27004ec 1068
80cabfad
FB
1069/* i8254.c */
1070
1071#define PIT_FREQ 1193182
1072
ec844b96
FB
1073typedef struct PITState PITState;
1074
1075PITState *pit_init(int base, int irq);
1076void pit_set_gate(PITState *pit, int channel, int val);
1077int pit_get_gate(PITState *pit, int channel);
fd06c375
FB
1078int pit_get_initial_count(PITState *pit, int channel);
1079int pit_get_mode(PITState *pit, int channel);
ec844b96 1080int pit_get_out(PITState *pit, int channel, int64_t current_time);
80cabfad 1081
fd06c375
FB
1082/* pcspk.c */
1083void pcspk_init(PITState *);
1084int pcspk_audio_init(AudioState *);
1085
3fffc223
TS
1086#include "hw/smbus.h"
1087
6515b203
FB
1088/* acpi.c */
1089extern int acpi_enabled;
502a5395 1090void piix4_pm_init(PCIBus *bus, int devfn);
3fffc223 1091void piix4_smbus_register_device(SMBusDevice *dev, uint8_t addr);
6515b203
FB
1092void acpi_bios_init(void);
1093
3fffc223
TS
1094/* smbus_eeprom.c */
1095SMBusDevice *smbus_eeprom_device_init(uint8_t addr, uint8_t *buf);
1096
80cabfad 1097/* pc.c */
54fa5af5 1098extern QEMUMachine pc_machine;
3dbbdc25 1099extern QEMUMachine isapc_machine;
52ca8d6a 1100extern int fd_bootchk;
80cabfad 1101
6a00d601
FB
1102void ioport_set_a20(int enable);
1103int ioport_get_a20(void);
1104
26aa7d72 1105/* ppc.c */
54fa5af5
FB
1106extern QEMUMachine prep_machine;
1107extern QEMUMachine core99_machine;
1108extern QEMUMachine heathrow_machine;
1109
6af0bf9c
FB
1110/* mips_r4k.c */
1111extern QEMUMachine mips_machine;
1112
5856de80
TS
1113/* mips_malta.c */
1114extern QEMUMachine mips_malta_machine;
1115
4de9b249
TS
1116/* mips_int */
1117extern void cpu_mips_irq_request(void *opaque, int irq, int level);
1118
e16fe40c
TS
1119/* mips_timer.c */
1120extern void cpu_mips_clock_init(CPUState *);
1121extern void cpu_mips_irqctrl_init (void);
1122
27c7ca7e
FB
1123/* shix.c */
1124extern QEMUMachine shix_machine;
1125
8cc43fef 1126#ifdef TARGET_PPC
47103572
JM
1127/* PowerPC hardware exceptions management helpers */
1128void ppc_set_irq (void *opaque, int n_IRQ, int level);
1129void ppc_openpic_irq (void *opaque, int n_IRQ, int level);
1130int ppc_hw_interrupt (CPUState *env);
8cc43fef
FB
1131ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
1132#endif
64201201 1133void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
77d4bc34
FB
1134
1135extern CPUWriteMemoryFunc *PPC_io_write[];
1136extern CPUReadMemoryFunc *PPC_io_read[];
54fa5af5 1137void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val);
26aa7d72 1138
e95c8d51 1139/* sun4m.c */
54fa5af5 1140extern QEMUMachine sun4m_machine;
ba3c64fb 1141void pic_set_irq_cpu(int irq, int level, unsigned int cpu);
e95c8d51
FB
1142
1143/* iommu.c */
e80cfcfc 1144void *iommu_init(uint32_t addr);
67e999be 1145void sparc_iommu_memory_rw(void *opaque, target_phys_addr_t addr,
a917d384 1146 uint8_t *buf, int len, int is_write);
67e999be
FB
1147static inline void sparc_iommu_memory_read(void *opaque,
1148 target_phys_addr_t addr,
1149 uint8_t *buf, int len)
1150{
1151 sparc_iommu_memory_rw(opaque, addr, buf, len, 0);
1152}
e95c8d51 1153
67e999be
FB
1154static inline void sparc_iommu_memory_write(void *opaque,
1155 target_phys_addr_t addr,
1156 uint8_t *buf, int len)
1157{
1158 sparc_iommu_memory_rw(opaque, addr, buf, len, 1);
1159}
e95c8d51
FB
1160
1161/* tcx.c */
95219897 1162void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
6f7e9aec 1163 unsigned long vram_offset, int vram_size, int width, int height);
e80cfcfc
FB
1164
1165/* slavio_intctl.c */
1166void *slavio_intctl_init();
ba3c64fb 1167void slavio_intctl_set_cpu(void *opaque, unsigned int cpu, CPUState *env);
e80cfcfc
FB
1168void slavio_pic_info(void *opaque);
1169void slavio_irq_info(void *opaque);
1170void slavio_pic_set_irq(void *opaque, int irq, int level);
ba3c64fb 1171void slavio_pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu);
e95c8d51 1172
5fe141fd
FB
1173/* loader.c */
1174int get_image_size(const char *filename);
1175int load_image(const char *filename, uint8_t *addr);
9ee3c029 1176int load_elf(const char *filename, int64_t virt_to_phys_addend, uint64_t *pentry);
e80cfcfc 1177int load_aout(const char *filename, uint8_t *addr);
1c7b3754 1178int load_uboot(const char *filename, target_ulong *ep, int *is_linux);
e80cfcfc
FB
1179
1180/* slavio_timer.c */
ba3c64fb 1181void slavio_timer_init(uint32_t addr, int irq, int mode, unsigned int cpu);
8d5f07fa 1182
e80cfcfc
FB
1183/* slavio_serial.c */
1184SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2);
1185void slavio_serial_ms_kbd_init(int base, int irq);
e95c8d51 1186
3475187d
FB
1187/* slavio_misc.c */
1188void *slavio_misc_init(uint32_t base, int irq);
1189void slavio_set_power_fail(void *opaque, int power_failing);
1190
6f7e9aec 1191/* esp.c */
fa1fb14c 1192void esp_scsi_attach(void *opaque, BlockDriverState *bd, int id);
67e999be
FB
1193void *esp_init(BlockDriverState **bd, uint32_t espaddr, void *dma_opaque);
1194void esp_reset(void *opaque);
1195
1196/* sparc32_dma.c */
1197void *sparc32_dma_init(uint32_t daddr, int espirq, int leirq, void *iommu,
1198 void *intctl);
1199void ledma_set_irq(void *opaque, int isr);
9b94dc32
FB
1200void ledma_memory_read(void *opaque, target_phys_addr_t addr,
1201 uint8_t *buf, int len, int do_bswap);
1202void ledma_memory_write(void *opaque, target_phys_addr_t addr,
1203 uint8_t *buf, int len, int do_bswap);
67e999be
FB
1204void espdma_raise_irq(void *opaque);
1205void espdma_clear_irq(void *opaque);
1206void espdma_memory_read(void *opaque, uint8_t *buf, int len);
1207void espdma_memory_write(void *opaque, uint8_t *buf, int len);
1208void sparc32_dma_set_reset_data(void *opaque, void *esp_opaque,
1209 void *lance_opaque);
6f7e9aec 1210
b8174937
FB
1211/* cs4231.c */
1212void cs_init(target_phys_addr_t base, int irq, void *intctl);
1213
3475187d
FB
1214/* sun4u.c */
1215extern QEMUMachine sun4u_machine;
1216
64201201
FB
1217/* NVRAM helpers */
1218#include "hw/m48t59.h"
1219
1220void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
1221uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
1222void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
1223uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
1224void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
1225uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
1226void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
1227 const unsigned char *str, uint32_t max);
1228int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
1229void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
1230 uint32_t start, uint32_t count);
1231int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
1232 const unsigned char *arch,
1233 uint32_t RAM_size, int boot_device,
1234 uint32_t kernel_image, uint32_t kernel_size,
28b9b5af 1235 const char *cmdline,
64201201 1236 uint32_t initrd_image, uint32_t initrd_size,
28b9b5af
FB
1237 uint32_t NVRAM_image,
1238 int width, int height, int depth);
64201201 1239
63066f4f
FB
1240/* adb.c */
1241
1242#define MAX_ADB_DEVICES 16
1243
e2733d20 1244#define ADB_MAX_OUT_LEN 16
63066f4f 1245
e2733d20 1246typedef struct ADBDevice ADBDevice;
63066f4f 1247
e2733d20
FB
1248/* buf = NULL means polling */
1249typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
1250 const uint8_t *buf, int len);
12c28fed
FB
1251typedef int ADBDeviceReset(ADBDevice *d);
1252
63066f4f
FB
1253struct ADBDevice {
1254 struct ADBBusState *bus;
1255 int devaddr;
1256 int handler;
e2733d20 1257 ADBDeviceRequest *devreq;
12c28fed 1258 ADBDeviceReset *devreset;
63066f4f
FB
1259 void *opaque;
1260};
1261
1262typedef struct ADBBusState {
1263 ADBDevice devices[MAX_ADB_DEVICES];
1264 int nb_devices;
e2733d20 1265 int poll_index;
63066f4f
FB
1266} ADBBusState;
1267
e2733d20
FB
1268int adb_request(ADBBusState *s, uint8_t *buf_out,
1269 const uint8_t *buf, int len);
1270int adb_poll(ADBBusState *s, uint8_t *buf_out);
63066f4f
FB
1271
1272ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
e2733d20 1273 ADBDeviceRequest *devreq,
12c28fed 1274 ADBDeviceReset *devreset,
63066f4f
FB
1275 void *opaque);
1276void adb_kbd_init(ADBBusState *bus);
1277void adb_mouse_init(ADBBusState *bus);
1278
1279/* cuda.c */
1280
1281extern ADBBusState adb_bus;
54fa5af5 1282int cuda_init(SetIRQFunc *set_irq, void *irq_opaque, int irq);
63066f4f 1283
bb36d470
FB
1284#include "hw/usb.h"
1285
a594cfbf
FB
1286/* usb ports of the VM */
1287
0d92ed30
PB
1288void qemu_register_usb_port(USBPort *port, void *opaque, int index,
1289 usb_attachfn attach);
a594cfbf 1290
0d92ed30 1291#define VM_USB_HUB_SIZE 8
a594cfbf
FB
1292
1293void do_usb_add(const char *devname);
1294void do_usb_del(const char *devname);
1295void usb_info(void);
1296
2e5d83bb 1297/* scsi-disk.c */
4d611c9a
PB
1298enum scsi_reason {
1299 SCSI_REASON_DONE, /* Command complete. */
1300 SCSI_REASON_DATA /* Transfer complete, more data required. */
1301};
1302
2e5d83bb 1303typedef struct SCSIDevice SCSIDevice;
a917d384
PB
1304typedef void (*scsi_completionfn)(void *opaque, int reason, uint32_t tag,
1305 uint32_t arg);
2e5d83bb
PB
1306
1307SCSIDevice *scsi_disk_init(BlockDriverState *bdrv,
a917d384 1308 int tcq,
2e5d83bb
PB
1309 scsi_completionfn completion,
1310 void *opaque);
1311void scsi_disk_destroy(SCSIDevice *s);
1312
0fc5c15a 1313int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun);
4d611c9a
PB
1314/* SCSI data transfers are asynchrnonous. However, unlike the block IO
1315 layer the completion routine may be called directly by
1316 scsi_{read,write}_data. */
a917d384
PB
1317void scsi_read_data(SCSIDevice *s, uint32_t tag);
1318int scsi_write_data(SCSIDevice *s, uint32_t tag);
1319void scsi_cancel_io(SCSIDevice *s, uint32_t tag);
1320uint8_t *scsi_get_buf(SCSIDevice *s, uint32_t tag);
2e5d83bb 1321
7d8406be
PB
1322/* lsi53c895a.c */
1323void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
1324void *lsi_scsi_init(PCIBus *bus, int devfn);
1325
b5ff1b31 1326/* integratorcp.c */
3371d272 1327extern QEMUMachine integratorcp_machine;
b5ff1b31 1328
cdbdb648
PB
1329/* versatilepb.c */
1330extern QEMUMachine versatilepb_machine;
16406950 1331extern QEMUMachine versatileab_machine;
cdbdb648 1332
e69954b9
PB
1333/* realview.c */
1334extern QEMUMachine realview_machine;
1335
daa57963
FB
1336/* ps2.c */
1337void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
1338void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
1339void ps2_write_mouse(void *, int val);
1340void ps2_write_keyboard(void *, int val);
1341uint32_t ps2_read_data(void *);
1342void ps2_queue(void *, int b);
f94f5d71 1343void ps2_keyboard_set_translation(void *opaque, int mode);
548df2ac 1344void ps2_mouse_fake_event(void *opaque);
daa57963 1345
80337b66
FB
1346/* smc91c111.c */
1347void smc91c111_init(NICInfo *, uint32_t, void *, int);
1348
bdd5003a 1349/* pl110.c */
95219897 1350void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int);
bdd5003a 1351
cdbdb648
PB
1352/* pl011.c */
1353void pl011_init(uint32_t base, void *pic, int irq, CharDriverState *chr);
1354
1355/* pl050.c */
1356void pl050_init(uint32_t base, void *pic, int irq, int is_mouse);
1357
1358/* pl080.c */
e69954b9 1359void *pl080_init(uint32_t base, void *pic, int irq, int nchannels);
cdbdb648
PB
1360
1361/* pl190.c */
1362void *pl190_init(uint32_t base, void *parent, int irq, int fiq);
1363
1364/* arm-timer.c */
1365void sp804_init(uint32_t base, void *pic, int irq);
1366void icp_pit_init(uint32_t base, void *pic, int irq);
1367
e69954b9
PB
1368/* arm_sysctl.c */
1369void arm_sysctl_init(uint32_t base, uint32_t sys_id);
1370
1371/* arm_gic.c */
1372void *arm_gic_init(uint32_t base, void *parent, int parent_irq);
1373
16406950
PB
1374/* arm_boot.c */
1375
daf90626 1376void arm_load_kernel(CPUState *env, int ram_size, const char *kernel_filename,
16406950
PB
1377 const char *kernel_cmdline, const char *initrd_filename,
1378 int board_id);
1379
27c7ca7e
FB
1380/* sh7750.c */
1381struct SH7750State;
1382
008a8818 1383struct SH7750State *sh7750_init(CPUState * cpu);
27c7ca7e
FB
1384
1385typedef struct {
1386 /* The callback will be triggered if any of the designated lines change */
1387 uint16_t portamask_trigger;
1388 uint16_t portbmask_trigger;
1389 /* Return 0 if no action was taken */
1390 int (*port_change_cb) (uint16_t porta, uint16_t portb,
1391 uint16_t * periph_pdtra,
1392 uint16_t * periph_portdira,
1393 uint16_t * periph_pdtrb,
1394 uint16_t * periph_portdirb);
1395} sh7750_io_device;
1396
1397int sh7750_register_io_device(struct SH7750State *s,
1398 sh7750_io_device * device);
1399/* tc58128.c */
1400int tc58128_init(struct SH7750State *s, char *zone1, char *zone2);
1401
29133e9a
FB
1402/* NOR flash devices */
1403typedef struct pflash_t pflash_t;
1404
1405pflash_t *pflash_register (target_ulong base, ram_addr_t off,
1406 BlockDriverState *bs,
1407 target_ulong sector_len, int nb_blocs, int width,
1408 uint16_t id0, uint16_t id1,
1409 uint16_t id2, uint16_t id3);
1410
4046d913
PB
1411#include "gdbstub.h"
1412
ea2384d3
FB
1413#endif /* defined(QEMU_TOOL) */
1414
c4b1fcc0 1415/* monitor.c */
82c643ff 1416void monitor_init(CharDriverState *hd, int show_banner);
ea2384d3
FB
1417void term_puts(const char *str);
1418void term_vprintf(const char *fmt, va_list ap);
40c3bac3 1419void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
fef30743 1420void term_print_filename(const char *filename);
c4b1fcc0
FB
1421void term_flush(void);
1422void term_print_help(void);
ea2384d3
FB
1423void monitor_readline(const char *prompt, int is_password,
1424 char *buf, int buf_size);
1425
1426/* readline.c */
1427typedef void ReadLineFunc(void *opaque, const char *str);
1428
1429extern int completion_index;
1430void add_completion(const char *str);
1431void readline_handle_byte(int ch);
1432void readline_find_completion(const char *cmdline);
1433const char *readline_get_history(unsigned int index);
1434void readline_start(const char *prompt, int is_password,
1435 ReadLineFunc *readline_func, void *opaque);
c4b1fcc0 1436
5e6ad6f9
FB
1437void kqemu_record_dump(void);
1438
fc01f7e7 1439#endif /* VL_H */
This page took 0.348701 seconds and 4 git commands to generate.