blob: 38a20a3b0453c3459d306d1934c192f9e91366b9 [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
Gleb Natapov4cab9462010-12-08 13:35:08 +020063void qemu_add_machine_init_done_notifier(Notifier *notify);
64
Luiz Capitulinod54908a2009-08-28 15:27:13 -030065void do_savevm(Monitor *mon, const QDict *qdict);
Markus Armbruster03cd4652010-02-17 16:24:10 +010066int load_vmstate(const char *name);
Luiz Capitulinod54908a2009-08-28 15:27:13 -030067void do_delvm(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +000068void do_info_snapshots(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000069
Jan Kiszkaea375f92010-03-01 19:10:30 +010070void cpu_synchronize_all_states(void);
71void cpu_synchronize_all_post_reset(void);
72void cpu_synchronize_all_post_init(void);
73
aliguori210f41b2008-10-13 03:13:12 +000074void qemu_announce_self(void);
75
Paolo Bonzinid6f4ade2010-03-10 11:38:54 +010076void main_loop_wait(int nonblocking);
pbrook87ecb682007-11-17 17:14:51 +000077
Jan Kiszkaf327aa02009-11-30 18:21:21 +010078int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
79 int shared);
80int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
81int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
82void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
aliguori9366f412008-10-06 14:53:52 +000083int qemu_loadvm_state(QEMUFile *f);
84
pbrook87ecb682007-11-17 17:14:51 +000085/* SLIRP */
aliguori376253e2009-03-05 23:01:23 +000086void do_info_slirp(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +000087
Jes Sorensen61705402010-06-10 11:42:23 +020088/* OS specific functions */
Jes Sorensenfe98ac12010-06-10 11:42:21 +020089void os_setup_early_signal_handling(void);
Jes Sorensen61705402010-06-10 11:42:23 +020090char *os_find_datadir(const char *argv0);
Jes Sorensen59a52642010-06-10 11:42:25 +020091void os_parse_cmd_args(int index, const char *optarg);
Jes Sorenseneb505be2010-06-10 11:42:28 +020092void os_pidfile_error(void);
Jes Sorensen69bd73b2010-06-10 11:42:20 +020093
Anthony Liguori993fbfd2009-05-21 16:54:00 -050094typedef enum DisplayType
95{
96 DT_DEFAULT,
97 DT_CURSES,
98 DT_SDL,
Anthony Liguori993fbfd2009-05-21 16:54:00 -050099 DT_NOGRAPHIC,
100} DisplayType;
101
Paolo Bonzinid399f672009-07-27 23:17:51 +0200102extern int autostart;
Amit Shah8e848652010-07-27 15:49:19 +0530103extern int incoming_expected;
pbrook87ecb682007-11-17 17:14:51 +0000104extern int bios_size;
Zachary Amsden86176752009-07-30 00:15:02 -1000105
106typedef enum {
107 VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB
108} VGAInterfaceType;
109
110extern int vga_interface_type;
111#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
112#define std_vga_enabled (vga_interface_type == VGA_STD)
113#define xenfb_enabled (vga_interface_type == VGA_XENFB)
114#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)
115
pbrook87ecb682007-11-17 17:14:51 +0000116extern int graphic_width;
117extern int graphic_height;
118extern int graphic_depth;
Jes Sorensen6b35e7b2009-08-06 16:25:50 +0200119extern uint8_t irq0override;
Anthony Liguori993fbfd2009-05-21 16:54:00 -0500120extern DisplayType display_type;
pbrook87ecb682007-11-17 17:14:51 +0000121extern const char *keyboard_layout;
122extern int win2k_install_hack;
aliguori73822ec2009-01-15 20:11:34 +0000123extern int rtc_td_hack;
pbrook87ecb682007-11-17 17:14:51 +0000124extern int alt_grab;
Dustin Kirkland0ca9f8a2009-09-17 15:48:04 -0500125extern int ctrl_grab;
pbrook87ecb682007-11-17 17:14:51 +0000126extern int usb_enabled;
127extern int smp_cpus;
Jes Sorensen6be68d72009-07-23 17:03:42 +0200128extern int max_cpus;
pbrook87ecb682007-11-17 17:14:51 +0000129extern int cursor_hide;
130extern int graphic_rotate;
131extern int no_quit;
Luiz Capitulinoa691d412010-05-11 18:07:04 -0300132extern int no_shutdown;
pbrook87ecb682007-11-17 17:14:51 +0000133extern int semihosting_enabled;
pbrook87ecb682007-11-17 17:14:51 +0000134extern int old_param;
Jan Kiszka95387492009-07-02 00:19:02 +0200135extern int boot_menu;
Jan Kiszka68752042009-09-15 13:36:04 +0200136extern QEMUClock *rtc_clock;
pbrook87ecb682007-11-17 17:14:51 +0000137
aliguori268a3622009-04-21 22:30:27 +0000138#define MAX_NODES 64
139extern int nb_numa_nodes;
140extern uint64_t node_mem[MAX_NODES];
Blue Swirl075cd322009-09-13 08:32:39 +0000141extern uint64_t node_cpumask[MAX_NODES];
aliguori268a3622009-04-21 22:30:27 +0000142
pbrook87ecb682007-11-17 17:14:51 +0000143#define MAX_OPTION_ROMS 16
Gleb Natapov2e55e842010-12-08 13:35:07 +0200144typedef struct QEMUOptionRom {
145 const char *name;
146 int32_t bootindex;
147} QEMUOptionRom;
148extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
pbrook87ecb682007-11-17 17:14:51 +0000149extern int nb_option_roms;
150
pbrook87ecb682007-11-17 17:14:51 +0000151#define MAX_PROM_ENVS 128
152extern const char *prom_envs[MAX_PROM_ENVS];
153extern unsigned int nb_prom_envs;
pbrook87ecb682007-11-17 17:14:51 +0000154
aliguori6f338c32009-02-11 15:21:54 +0000155/* pci-hotplug */
Markus Armbruster6c6a58a2010-05-12 10:53:00 +0200156void pci_device_hot_add(Monitor *mon, const QDict *qdict);
Luiz Capitulinof18c16d2009-08-28 15:27:14 -0300157void drive_hot_add(Monitor *mon, const QDict *qdict);
Markus Armbrusterb752daf2010-05-12 10:53:01 +0200158void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict);
aliguori6f338c32009-02-11 15:21:54 +0000159
pbrook87ecb682007-11-17 17:14:51 +0000160/* serial ports */
161
162#define MAX_SERIAL_PORTS 4
163
164extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
165
166/* parallel ports */
167
168#define MAX_PARALLEL_PORTS 3
169
170extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
171
aliguori0e82f342008-10-31 18:44:40 +0000172#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
173
pbrook87ecb682007-11-17 17:14:51 +0000174#ifdef HAS_AUDIO
175struct soundhw {
176 const char *name;
177 const char *descr;
178 int enabled;
179 int isa;
180 union {
Paul Brook22d83b12009-05-12 12:33:04 +0100181 int (*init_isa) (qemu_irq *pic);
182 int (*init_pci) (PCIBus *bus);
pbrook87ecb682007-11-17 17:14:51 +0000183 } init;
184};
185
186extern struct soundhw soundhw[];
187#endif
188
Luiz Capitulinod54908a2009-08-28 15:27:13 -0300189void do_usb_add(Monitor *mon, const QDict *qdict);
190void do_usb_del(Monitor *mon, const QDict *qdict);
aliguori376253e2009-03-05 23:01:23 +0000191void usb_info(Monitor *mon);
pbrook87ecb682007-11-17 17:14:51 +0000192
Luiz Capitulino80cd3472010-02-25 12:11:44 -0300193void rtc_change_mon_event(struct tm *tm);
194
Paul Brookaae94602009-05-14 22:35:06 +0100195void register_devices(void);
196
Gleb Natapov1ca4d092010-12-08 13:35:05 +0200197void add_boot_device_path(int32_t bootindex, DeviceState *dev,
198 const char *suffix);
Gleb Natapov962630f2010-12-08 13:35:09 +0200199char *get_boot_devices_list(uint32_t *size);
pbrook87ecb682007-11-17 17:14:51 +0000200#endif