blob: 0a83ab9e56cb5eb45ba67075bbcade96e41a6e05 [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);
Blue Swirld9c32312009-08-09 08:42:19 +000069extern qemu_irq qemu_system_powerdown;
aurel32cf7a2fe2008-03-18 06:53:05 +000070void qemu_system_reset(void);
pbrook87ecb682007-11-17 17:14:51 +000071
Gerd Hoffmannfd42dee2010-06-04 14:08:07 +020072void qemu_add_exit_notifier(Notifier *notify);
73void qemu_remove_exit_notifier(Notifier *notify);
74
Gleb Natapov4cab9462010-12-08 13:35:08 +020075void qemu_add_machine_init_done_notifier(Notifier *notify);
76
Luiz Capitulinod54908a2009-08-28 15:27:13 -030077void do_savevm(Monitor *mon, const QDict *qdict);
Markus Armbruster03cd4652010-02-17 16:24:10 +010078int load_vmstate(const char *name);
Luiz Capitulinod54908a2009-08-28 15:27:13 -030079void do_delvm(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +000080void do_info_snapshots(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000081
Jan Kiszkaea375f92010-03-01 19:10:30 +010082void cpu_synchronize_all_states(void);
83void cpu_synchronize_all_post_reset(void);
84void cpu_synchronize_all_post_init(void);
85
aliguori210f41b2008-10-13 03:13:12 +000086void qemu_announce_self(void);
87
Paolo Bonzinid6f4ade2010-03-10 11:38:54 +010088void main_loop_wait(int nonblocking);
pbrook87ecb682007-11-17 17:14:51 +000089
Alex Williamsondc912122011-01-11 14:39:43 -070090bool qemu_savevm_state_blocked(Monitor *mon);
Jan Kiszkaf327aa02009-11-30 18:21:21 +010091int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
92 int shared);
93int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
94int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
95void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
aliguori9366f412008-10-06 14:53:52 +000096int qemu_loadvm_state(QEMUFile *f);
97
pbrook87ecb682007-11-17 17:14:51 +000098/* SLIRP */
aliguori376253e2009-03-05 23:01:23 +000099void do_info_slirp(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000100
Jes Sorensen61705402010-06-10 11:42:23 +0200101/* OS specific functions */
Jes Sorensenfe98ac12010-06-10 11:42:21 +0200102void os_setup_early_signal_handling(void);
Jes Sorensen61705402010-06-10 11:42:23 +0200103char *os_find_datadir(const char *argv0);
Jes Sorensen59a52642010-06-10 11:42:25 +0200104void os_parse_cmd_args(int index, const char *optarg);
Jes Sorenseneb505be2010-06-10 11:42:28 +0200105void os_pidfile_error(void);
Jes Sorensen69bd73b2010-06-10 11:42:20 +0200106
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500107typedef enum DisplayType
108{
109 DT_DEFAULT,
110 DT_CURSES,
111 DT_SDL,
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500112 DT_NOGRAPHIC,
113} DisplayType;
114
Paolo Bonzinid399f672009-07-27 23:17:51 +0200115extern int autostart;
Amit Shah8e848652010-07-27 15:49:19 +0530116extern int incoming_expected;
pbrook87ecb682007-11-17 17:14:51 +0000117extern int bios_size;
Zachary Amsden86176752009-07-30 00:15:02 -1000118
119typedef enum {
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200120 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL,
Zachary Amsden86176752009-07-30 00:15:02 -1000121} VGAInterfaceType;
122
123extern int vga_interface_type;
124#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
125#define std_vga_enabled (vga_interface_type == VGA_STD)
126#define xenfb_enabled (vga_interface_type == VGA_XENFB)
127#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
Gerd Hoffmanna19cbfb2010-04-27 11:50:11 +0200128#define qxl_enabled (vga_interface_type == VGA_QXL)
Zachary Amsden86176752009-07-30 00:15:02 -1000129
pbrook87ecb682007-11-17 17:14:51 +0000130extern int graphic_width;
131extern int graphic_height;
132extern int graphic_depth;
Jes Sorensen6b35e7b2009-08-06 16:25:50 +0200133extern uint8_t irq0override;
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500134extern DisplayType display_type;
pbrook87ecb682007-11-17 17:14:51 +0000135extern const char *keyboard_layout;
136extern int win2k_install_hack;
aliguori73822ec2009-01-15 20:11:34 +0000137extern int rtc_td_hack;
pbrook87ecb682007-11-17 17:14:51 +0000138extern int alt_grab;
Dustin Kirkland0ca9f8a2009-09-17 15:48:04 -0500139extern int ctrl_grab;
pbrook87ecb682007-11-17 17:14:51 +0000140extern int usb_enabled;
141extern int smp_cpus;
Jes Sorensen6be68d72009-07-23 17:03:42 +0200142extern int max_cpus;
pbrook87ecb682007-11-17 17:14:51 +0000143extern int cursor_hide;
144extern int graphic_rotate;
145extern int no_quit;
Luiz Capitulinoa691d412010-05-11 18:07:04 -0300146extern int no_shutdown;
pbrook87ecb682007-11-17 17:14:51 +0000147extern int semihosting_enabled;
pbrook87ecb682007-11-17 17:14:51 +0000148extern int old_param;
Jan Kiszka95387492009-07-02 00:19:02 +0200149extern int boot_menu;
Jan Kiszka68752042009-09-15 13:36:04 +0200150extern QEMUClock *rtc_clock;
pbrook87ecb682007-11-17 17:14:51 +0000151
aliguori268a3622009-04-21 22:30:27 +0000152#define MAX_NODES 64
153extern int nb_numa_nodes;
154extern uint64_t node_mem[MAX_NODES];
Blue Swirl075cd322009-09-13 08:32:39 +0000155extern uint64_t node_cpumask[MAX_NODES];
aliguori268a3622009-04-21 22:30:27 +0000156
pbrook87ecb682007-11-17 17:14:51 +0000157#define MAX_OPTION_ROMS 16
Gleb Natapov2e55e842010-12-08 13:35:07 +0200158typedef struct QEMUOptionRom {
159 const char *name;
160 int32_t bootindex;
161} QEMUOptionRom;
162extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
pbrook87ecb682007-11-17 17:14:51 +0000163extern int nb_option_roms;
164
pbrook87ecb682007-11-17 17:14:51 +0000165#define MAX_PROM_ENVS 128
166extern const char *prom_envs[MAX_PROM_ENVS];
167extern unsigned int nb_prom_envs;
pbrook87ecb682007-11-17 17:14:51 +0000168
aliguori6f338c32009-02-11 15:21:54 +0000169/* pci-hotplug */
Markus Armbruster6c6a58a2010-05-12 10:53:00 +0200170void pci_device_hot_add(Monitor *mon, const QDict *qdict);
Luiz Capitulinof18c16d2009-08-28 15:27:14 -0300171void drive_hot_add(Monitor *mon, const QDict *qdict);
Markus Armbrusterb752daf2010-05-12 10:53:01 +0200172void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
aliguori6f338c32009-02-11 15:21:54 +0000173
Isaku Yamahata2ae63bd2010-12-24 12:14:14 +0900174/* pcie aer error injection */
175void pcie_aer_inject_error_print(Monitor *mon, const QObject *data);
176int do_pcie_aer_inejct_error(Monitor *mon,
177 const QDict *qdict, QObject **ret_data);
178
pbrook87ecb682007-11-17 17:14:51 +0000179/* serial ports */
180
181#define MAX_SERIAL_PORTS 4
182
183extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
184
185/* parallel ports */
186
187#define MAX_PARALLEL_PORTS 3
188
189extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
190
aliguori0e82f342008-10-31 18:44:40 +0000191#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
192
Luiz Capitulinod54908a2009-08-28 15:27:13 -0300193void do_usb_add(Monitor *mon, const QDict *qdict);
194void do_usb_del(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +0000195void usb_info(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000196
Luiz Capitulino80cd3472010-02-25 12:11:44 -0300197void rtc_change_mon_event(struct tm *tm);
198
Paul Brookaae94602009-05-14 22:35:06 +0100199void register_devices(void);
200
Gleb Natapov1ca4d092010-12-08 13:35:05 +0200201void add_boot_device_path(int32_t bootindex, DeviceState *dev,
202 const char *suffix);
Gleb Natapov962630f2010-12-08 13:35:09 +0200203char *get_boot_devices_list(uint32_t *size);
pbrook87ecb682007-11-17 17:14:51 +0000204#endif