blob: b81a70ec3e87d73a9930f85532884f07de0f7518 [file] [log] [blame]
pbrook87ecb682007-11-17 17:14:51 +00001#ifndef SYSEMU_H
2#define SYSEMU_H
3/* Misc. things related to the system emulator. */
4
aliguori376253e2009-03-05 23:01:23 +00005#include "qemu-common.h"
Gerd Hoffmann62c58022009-07-22 16:43:00 +02006#include "qemu-option.h"
Blue Swirl72cf2d42009-09-12 07:36:22 +00007#include "qemu-queue.h"
Jan Kiszka68752042009-09-15 13:36:04 +02008#include "qemu-timer.h"
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +02009#include "notify.h"
aliguori376253e2009-03-05 23:01:23 +000010
aliguori49dc7682009-03-08 16:26:59 +000011#ifdef _WIN32
12#include <windows.h>
Jes Sorensen39626c02010-06-10 11:42:16 +020013#include "qemu-os-win32.h"
aliguori49dc7682009-03-08 16:26:59 +000014#endif
15
Jes Sorensen0d93ca72010-06-10 11:42:18 +020016#ifdef CONFIG_POSIX
17#include "qemu-os-posix.h"
18#endif
19
pbrook87ecb682007-11-17 17:14:51 +000020/* vl.c */
21extern const char *bios_name;
Paul Brook5cea8592009-05-30 00:52:44 +010022
23#define QEMU_FILE_TYPE_BIOS 0
24#define QEMU_FILE_TYPE_KEYMAP 1
25char *qemu_find_file(int type, const char *name);
pbrook87ecb682007-11-17 17:14:51 +000026
27extern int vm_running;
28extern const char *qemu_name;
blueswir18fcb1b92008-09-18 18:29:08 +000029extern uint8_t qemu_uuid[];
aliguoric4be29f2009-04-17 18:58:14 +000030int qemu_uuid_parse(const char *str, uint8_t *uuid);
blueswir18fcb1b92008-09-18 18:29:08 +000031#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
pbrook87ecb682007-11-17 17:14:51 +000032
33typedef struct vm_change_state_entry VMChangeStateEntry;
aliguori9781e042009-01-22 17:15:29 +000034typedef void VMChangeStateHandler(void *opaque, int running, int reason);
pbrook87ecb682007-11-17 17:14:51 +000035
36VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
37 void *opaque);
38void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
39
pbrook87ecb682007-11-17 17:14:51 +000040void vm_start(void);
41void vm_stop(int reason);
42
Glauber Costa9f9e28c2009-05-21 17:38:01 -040043uint64_t ram_bytes_remaining(void);
44uint64_t ram_bytes_transferred(void);
45uint64_t ram_bytes_total(void);
46
pbrook87ecb682007-11-17 17:14:51 +000047int64_t cpu_get_ticks(void);
48void cpu_enable_ticks(void);
49void cpu_disable_ticks(void);
50
51void qemu_system_reset_request(void);
52void qemu_system_shutdown_request(void);
53void qemu_system_powerdown_request(void);
aurel32cf7a2fe2008-03-18 06:53:05 +000054int qemu_shutdown_requested(void);
55int qemu_reset_requested(void);
56int qemu_powerdown_requested(void);
Blue Swirld9c32312009-08-09 08:42:19 +000057extern qemu_irq qemu_system_powerdown;
aurel32cf7a2fe2008-03-18 06:53:05 +000058void qemu_system_reset(void);
pbrook87ecb682007-11-17 17:14:51 +000059
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +020060void qemu_add_exit_notifier(Notifier *notify);
61void qemu_remove_exit_notifier(Notifier *notify);
62
Luiz Capitulinod54908a2009-08-28 15:27:13 -030063void do_savevm(Monitor *mon, const QDict *qdict);
Markus Armbruster03cd4652010-02-17 16:24:10 +010064int load_vmstate(const char *name);
Luiz Capitulinod54908a2009-08-28 15:27:13 -030065void do_delvm(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +000066void do_info_snapshots(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000067
Jan Kiszkaea375f92010-03-01 19:10:30 +010068void cpu_synchronize_all_states(void);
69void cpu_synchronize_all_post_reset(void);
70void cpu_synchronize_all_post_init(void);
71
aliguori210f41b2008-10-13 03:13:12 +000072void qemu_announce_self(void);
73
Paolo Bonzinid6f4ade2010-03-10 11:38:54 +010074void main_loop_wait(int nonblocking);
pbrook87ecb682007-11-17 17:14:51 +000075
Jan Kiszkaf327aa02009-11-30 18:21:21 +010076int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
77 int shared);
78int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
79int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
80void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
aliguori9366f412008-10-06 14:53:52 +000081int qemu_loadvm_state(QEMUFile *f);
82
pbrook87ecb682007-11-17 17:14:51 +000083/* SLIRP */
aliguori376253e2009-03-05 23:01:23 +000084void do_info_slirp(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000085
Jes Sorensen61705402010-06-10 11:42:23 +020086/* OS specific functions */
Jes Sorensenfe98ac12010-06-10 11:42:21 +020087void os_setup_early_signal_handling(void);
Jes Sorensen61705402010-06-10 11:42:23 +020088char *os_find_datadir(const char *argv0);
Jes Sorensen59a52642010-06-10 11:42:25 +020089void os_parse_cmd_args(int index, const char *optarg);
Jes Sorenseneb505be2010-06-10 11:42:28 +020090void os_pidfile_error(void);
Jes Sorensen69bd73b2010-06-10 11:42:20 +020091
Anthony Liguori993fbfd2009-05-21 16:54:00 -050092typedef enum DisplayType
93{
94 DT_DEFAULT,
95 DT_CURSES,
96 DT_SDL,
Anthony Liguori993fbfd2009-05-21 16:54:00 -050097 DT_NOGRAPHIC,
98} DisplayType;
99
Paolo Bonzinid399f672009-07-27 23:17:51 +0200100extern int autostart;
Amit Shah8e848652010-07-27 15:49:19 +0530101extern int incoming_expected;
pbrook87ecb682007-11-17 17:14:51 +0000102extern int bios_size;
Zachary Amsden86176752009-07-30 00:15:02 -1000103
104typedef enum {
105 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB
106} VGAInterfaceType;
107
108extern int vga_interface_type;
109#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
110#define std_vga_enabled (vga_interface_type == VGA_STD)
111#define xenfb_enabled (vga_interface_type == VGA_XENFB)
112#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
113
pbrook87ecb682007-11-17 17:14:51 +0000114extern int graphic_width;
115extern int graphic_height;
116extern int graphic_depth;
Jes Sorensen6b35e7b2009-08-06 16:25:50 +0200117extern uint8_t irq0override;
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500118extern DisplayType display_type;
pbrook87ecb682007-11-17 17:14:51 +0000119extern const char *keyboard_layout;
120extern int win2k_install_hack;
aliguori73822ec2009-01-15 20:11:34 +0000121extern int rtc_td_hack;
pbrook87ecb682007-11-17 17:14:51 +0000122extern int alt_grab;
Dustin Kirkland0ca9f8a2009-09-17 15:48:04 -0500123extern int ctrl_grab;
pbrook87ecb682007-11-17 17:14:51 +0000124extern int usb_enabled;
125extern int smp_cpus;
Jes Sorensen6be68d72009-07-23 17:03:42 +0200126extern int max_cpus;
pbrook87ecb682007-11-17 17:14:51 +0000127extern int cursor_hide;
128extern int graphic_rotate;
129extern int no_quit;
Luiz Capitulinoa691d412010-05-11 18:07:04 -0300130extern int no_shutdown;
pbrook87ecb682007-11-17 17:14:51 +0000131extern int semihosting_enabled;
pbrook87ecb682007-11-17 17:14:51 +0000132extern int old_param;
Jan Kiszka95387492009-07-02 00:19:02 +0200133extern int boot_menu;
Jan Kiszka68752042009-09-15 13:36:04 +0200134extern QEMUClock *rtc_clock;
pbrook87ecb682007-11-17 17:14:51 +0000135
aliguori268a3622009-04-21 22:30:27 +0000136#define MAX_NODES 64
137extern int nb_numa_nodes;
138extern uint64_t node_mem[MAX_NODES];
Blue Swirl075cd322009-09-13 08:32:39 +0000139extern uint64_t node_cpumask[MAX_NODES];
aliguori268a3622009-04-21 22:30:27 +0000140
pbrook87ecb682007-11-17 17:14:51 +0000141#define MAX_OPTION_ROMS 16
142extern const char *option_rom[MAX_OPTION_ROMS];
143extern int nb_option_roms;
144
pbrook87ecb682007-11-17 17:14:51 +0000145#define MAX_PROM_ENVS 128
146extern const char *prom_envs[MAX_PROM_ENVS];
147extern unsigned int nb_prom_envs;
pbrook87ecb682007-11-17 17:14:51 +0000148
aliguori6f338c32009-02-11 15:21:54 +0000149/* pci-hotplug */
Markus Armbruster6c6a58a2010-05-12 10:53:00 +0200150void pci_device_hot_add(Monitor *mon, const QDict *qdict);
Luiz Capitulinof18c16d2009-08-28 15:27:14 -0300151void drive_hot_add(Monitor *mon, const QDict *qdict);
Markus Armbrusterb752daf2010-05-12 10:53:01 +0200152void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
aliguori6f338c32009-02-11 15:21:54 +0000153
pbrook87ecb682007-11-17 17:14:51 +0000154/* serial ports */
155
156#define MAX_SERIAL_PORTS 4
157
158extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
159
160/* parallel ports */
161
162#define MAX_PARALLEL_PORTS 3
163
164extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
165
aliguori0e82f342008-10-31 18:44:40 +0000166#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
167
pbrook87ecb682007-11-17 17:14:51 +0000168#ifdef HAS_AUDIO
169struct soundhw {
170 const char *name;
171 const char *descr;
172 int enabled;
173 int isa;
174 union {
Paul Brook22d83b12009-05-12 12:33:04 +0100175 int (*init_isa) (qemu_irq *pic);
176 int (*init_pci) (PCIBus *bus);
pbrook87ecb682007-11-17 17:14:51 +0000177 } init;
178};
179
180extern struct soundhw soundhw[];
181#endif
182
Luiz Capitulinod54908a2009-08-28 15:27:13 -0300183void do_usb_add(Monitor *mon, const QDict *qdict);
184void do_usb_del(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +0000185void usb_info(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000186
Luiz Capitulino80cd3472010-02-25 12:11:44 -0300187void rtc_change_mon_event(struct tm *tm);
188
Paul Brookaae94602009-05-14 22:35:06 +0100189void register_devices(void);
190
pbrook87ecb682007-11-17 17:14:51 +0000191#endif