blob: bbbd0fd79931a94629699338b6b7486fa4f38c4c [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
Jan Kiszkae07bbac2011-02-09 16:29:40 +010040#define VMSTOP_USER 0
41#define VMSTOP_DEBUG 1
42#define VMSTOP_SHUTDOWN 2
43#define VMSTOP_DISKFULL 3
44#define VMSTOP_WATCHDOG 4
45#define VMSTOP_PANIC 5
46#define VMSTOP_SAVEVM 6
47#define VMSTOP_LOADVM 7
48#define VMSTOP_MIGRATE 8
49
pbrook87ecb682007-11-17 17:14:51 +000050void vm_start(void);
51void vm_stop(int reason);
52
Glauber Costa9f9e28c2009-05-21 17:38:01 -040053uint64_t ram_bytes_remaining(void);
54uint64_t ram_bytes_transferred(void);
55uint64_t ram_bytes_total(void);
56
pbrook87ecb682007-11-17 17:14:51 +000057int64_t cpu_get_ticks(void);
58void cpu_enable_ticks(void);
59void cpu_disable_ticks(void);
60
61void qemu_system_reset_request(void);
62void qemu_system_shutdown_request(void);
63void qemu_system_powerdown_request(void);
Jan Kiszka8cf71712011-02-07 12:19:16 +010064void qemu_system_debug_request(void);
65void qemu_system_vmstop_request(int reason);
aurel32cf7a2fe2008-03-18 06:53:05 +000066int qemu_shutdown_requested(void);
67int qemu_reset_requested(void);
68int qemu_powerdown_requested(void);
Gleb Natapovf64622c2011-03-15 13:56:04 +020069void qemu_system_killed(int signal, pid_t pid);
70void qemu_kill_report(void);
Blue Swirld9c32312009-08-09 08:42:19 +000071extern qemu_irq qemu_system_powerdown;
aurel32cf7a2fe2008-03-18 06:53:05 +000072void qemu_system_reset(void);
pbrook87ecb682007-11-17 17:14:51 +000073
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +020074void qemu_add_exit_notifier(Notifier *notify);
75void qemu_remove_exit_notifier(Notifier *notify);
76
Gleb Natapov4cab9462010-12-08 13:35:08 +020077void qemu_add_machine_init_done_notifier(Notifier *notify);
78
Luiz Capitulinod54908a2009-08-28 15:27:13 -030079void do_savevm(Monitor *mon, const QDict *qdict);
Markus Armbruster03cd4652010-02-17 16:24:10 +010080int load_vmstate(const char *name);
Luiz Capitulinod54908a2009-08-28 15:27:13 -030081void do_delvm(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +000082void do_info_snapshots(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000083
Jan Kiszkaea375f92010-03-01 19:10:30 +010084void cpu_synchronize_all_states(void);
85void cpu_synchronize_all_post_reset(void);
86void cpu_synchronize_all_post_init(void);
87
aliguori210f41b2008-10-13 03:13:12 +000088void qemu_announce_self(void);
89
Paolo Bonzinid6f4ade2010-03-10 11:38:54 +010090void main_loop_wait(int nonblocking);
pbrook87ecb682007-11-17 17:14:51 +000091
Alex Williamsondc912122011-01-11 14:39:43 -070092bool qemu_savevm_state_blocked(Monitor *mon);
Jan Kiszkaf327aa02009-11-30 18:21:21 +010093int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
94 int shared);
95int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
96int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
97void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
aliguori9366f412008-10-06 14:53:52 +000098int qemu_loadvm_state(QEMUFile *f);
99
pbrook87ecb682007-11-17 17:14:51 +0000100/* SLIRP */
aliguori376253e2009-03-05 23:01:23 +0000101void do_info_slirp(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000102
Jes Sorensen61705402010-06-10 11:42:23 +0200103/* OS specific functions */
Jes Sorensenfe98ac12010-06-10 11:42:21 +0200104void os_setup_early_signal_handling(void);
Jes Sorensen61705402010-06-10 11:42:23 +0200105char *os_find_datadir(const char *argv0);
Jes Sorensen59a52642010-06-10 11:42:25 +0200106void os_parse_cmd_args(int index, const char *optarg);
Jes Sorenseneb505be2010-06-10 11:42:28 +0200107void os_pidfile_error(void);
Jes Sorensen69bd73b2010-06-10 11:42:20 +0200108
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500109typedef enum DisplayType
110{
111 DT_DEFAULT,
112 DT_CURSES,
113 DT_SDL,
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500114 DT_NOGRAPHIC,
Jes Sorensen4171d322011-03-16 13:33:32 +0100115 DT_NONE,
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500116} DisplayType;
117
Paolo Bonzinid399f672009-07-27 23:17:51 +0200118extern int autostart;
Amit Shah8e848652010-07-27 15:49:19 +0530119extern int incoming_expected;
pbrook87ecb682007-11-17 17:14:51 +0000120extern int bios_size;
Zachary Amsden86176752009-07-30 00:15:02 -1000121
122typedef enum {
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200123 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
Zachary Amsden86176752009-07-30 00:15:02 -1000124} VGAInterfaceType;
125
126extern int vga_interface_type;
127#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
128#define std_vga_enabled (vga_interface_type == VGA_STD)
129#define xenfb_enabled (vga_interface_type == VGA_XENFB)
130#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200131#define qxl_enabled (vga_interface_type == VGA_QXL)
Zachary Amsden86176752009-07-30 00:15:02 -1000132
pbrook87ecb682007-11-17 17:14:51 +0000133extern int graphic_width;
134extern int graphic_height;
135extern int graphic_depth;
Jes Sorensen6b35e7b2009-08-06 16:25:50 +0200136extern uint8_t irq0override;
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500137extern DisplayType display_type;
pbrook87ecb682007-11-17 17:14:51 +0000138extern const char *keyboard_layout;
139extern int win2k_install_hack;
aliguori73822ec2009-01-15 20:11:34 +0000140extern int rtc_td_hack;
pbrook87ecb682007-11-17 17:14:51 +0000141extern int alt_grab;
Dustin Kirkland0ca9f8a2009-09-17 15:48:04 -0500142extern int ctrl_grab;
pbrook87ecb682007-11-17 17:14:51 +0000143extern int usb_enabled;
144extern int smp_cpus;
Jes Sorensen6be68d72009-07-23 17:03:42 +0200145extern int max_cpus;
pbrook87ecb682007-11-17 17:14:51 +0000146extern int cursor_hide;
147extern int graphic_rotate;
148extern int no_quit;
Luiz Capitulinoa691d412010-05-11 18:07:04 -0300149extern int no_shutdown;
pbrook87ecb682007-11-17 17:14:51 +0000150extern int semihosting_enabled;
pbrook87ecb682007-11-17 17:14:51 +0000151extern int old_param;
Jan Kiszka95387492009-07-02 00:19:02 +0200152extern int boot_menu;
Jan Kiszka68752042009-09-15 13:36:04 +0200153extern QEMUClock *rtc_clock;
pbrook87ecb682007-11-17 17:14:51 +0000154
aliguori268a3622009-04-21 22:30:27 +0000155#define MAX_NODES 64
156extern int nb_numa_nodes;
157extern uint64_t node_mem[MAX_NODES];
Blue Swirl075cd322009-09-13 08:32:39 +0000158extern uint64_t node_cpumask[MAX_NODES];
aliguori268a3622009-04-21 22:30:27 +0000159
pbrook87ecb682007-11-17 17:14:51 +0000160#define MAX_OPTION_ROMS 16
Gleb Natapov2e55e842010-12-08 13:35:07 +0200161typedef struct QEMUOptionRom {
162 const char *name;
163 int32_t bootindex;
164} QEMUOptionRom;
165extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
pbrook87ecb682007-11-17 17:14:51 +0000166extern int nb_option_roms;
167
pbrook87ecb682007-11-17 17:14:51 +0000168#define MAX_PROM_ENVS 128
169extern const char *prom_envs[MAX_PROM_ENVS];
170extern unsigned int nb_prom_envs;
pbrook87ecb682007-11-17 17:14:51 +0000171
aliguori6f338c32009-02-11 15:21:54 +0000172/* pci-hotplug */
Markus Armbruster6c6a58a2010-05-12 10:53:00 +0200173void pci_device_hot_add(Monitor *mon, const QDict *qdict);
Luiz Capitulinof18c16d2009-08-28 15:27:14 -0300174void drive_hot_add(Monitor *mon, const QDict *qdict);
Markus Armbrusterb752daf2010-05-12 10:53:01 +0200175void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
aliguori6f338c32009-02-11 15:21:54 +0000176
Isaku Yamahata2ae63bd2010-12-24 12:14:14 +0900177/* pcie aer error injection */
178void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
179int do_pcie_aer_inejct_error(Monitor *mon,
180 const QDict *qdict, QObject **ret_data);
181
pbrook87ecb682007-11-17 17:14:51 +0000182/* serial ports */
183
184#define MAX_SERIAL_PORTS 4
185
186extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
187
188/* parallel ports */
189
190#define MAX_PARALLEL_PORTS 3
191
192extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
193
aliguori0e82f342008-10-31 18:44:40 +0000194#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
195
Luiz Capitulinod54908a2009-08-28 15:27:13 -0300196void do_usb_add(Monitor *mon, const QDict *qdict);
197void do_usb_del(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +0000198void usb_info(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000199
Luiz Capitulino80cd3472010-02-25 12:11:44 -0300200void rtc_change_mon_event(struct tm *tm);
201
Paul Brookaae94602009-05-14 22:35:06 +0100202void register_devices(void);
203
Gleb Natapov1ca4d092010-12-08 13:35:05 +0200204void add_boot_device_path(int32_t bootindex, DeviceState *dev,
205 const char *suffix);
Gleb Natapov962630f2010-12-08 13:35:09 +0200206char *get_boot_devices_list(uint32_t *size);
pbrook87ecb682007-11-17 17:14:51 +0000207#endif