1#ifndef SYSEMU_H 2#define SYSEMU_H 3/* Misc. things related to the system emulator. */ 4 5#include "qemu-common.h" 6#include "qemu/option.h" 7#include "qemu/queue.h" 8#include "qemu/timer.h" 9#include "qapi/qmp/qdict.h" 10#include "qapi/qmp/qerror.h" 11 12#include "exec/hwaddr.h" 13 14#ifdef _WIN32 15#include <windows.h> 16#endif 17 18/* vl.c */ 19extern const char *bios_name; 20 21extern const char* savevm_on_exit; 22extern int no_shutdown; 23extern int vm_running; 24extern int vm_can_run(void); 25extern int qemu_debug_requested(void); 26extern const char *qemu_name; 27extern uint8_t qemu_uuid[]; 28int qemu_uuid_parse(const char *str, uint8_t *uuid); 29#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" 30 31typedef struct vm_change_state_entry VMChangeStateEntry; 32typedef void VMChangeStateHandler(void *opaque, int running, int reason); 33 34VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, 35 void *opaque); 36void qemu_del_vm_change_state_handler(VMChangeStateEntry *e); 37 38void vm_start(void); 39void vm_stop(int reason); 40 41uint64_t ram_bytes_remaining(void); 42uint64_t ram_bytes_transferred(void); 43uint64_t ram_bytes_total(void); 44 45int64_t cpu_get_ticks(void); 46void cpu_enable_ticks(void); 47void cpu_disable_ticks(void); 48 49void configure_icount(const char* opts); 50void configure_alarms(const char* opts); 51int init_timer_alarm(void); 52int qemu_timer_alarm_pending(void); 53void quit_timers(void); 54 55int64_t qemu_icount; 56int64_t qemu_icount_bias; 57int icount_time_shift; 58 59int tcg_has_work(void); 60 61void qemu_system_reset_request(void); 62void qemu_system_shutdown_request(void); 63void qemu_system_powerdown_request(void); 64int qemu_shutdown_requested(void); 65int qemu_reset_requested(void); 66int qemu_vmstop_requested(void); 67int qemu_powerdown_requested(void); 68void qemu_system_killed(int signal, pid_t pid); 69#ifdef NEED_CPU_H 70#if !defined(TARGET_SPARC) 71// Please implement a power failure function to signal the OS 72#define qemu_system_powerdown() do{}while(0) 73#else 74void qemu_system_powerdown(void); 75#endif 76#endif 77void qemu_system_reset(void); 78 79void do_savevm(Monitor *mon, const char *name); 80void do_loadvm(Monitor *mon, const char *name); 81void do_delvm(Monitor *mon, const char *name); 82void do_info_snapshots(Monitor *mon, Monitor* err); 83 84void qemu_announce_self(void); 85 86void main_loop_wait(int timeout); 87 88int qemu_savevm_state_begin(QEMUFile *f); 89int qemu_savevm_state_iterate(QEMUFile *f); 90int qemu_savevm_state_complete(QEMUFile *f); 91int qemu_savevm_state(QEMUFile *f); 92int qemu_loadvm_state(QEMUFile *f); 93 94void qemu_errors_to_file(FILE *fp); 95void qemu_errors_to_mon(Monitor *mon); 96void qemu_errors_to_previous(void); 97void qemu_error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); 98void qemu_error_internal(const char *file, int linenr, const char *func, 99 const char *fmt, ...) 100 __attribute__ ((format(printf, 4, 5))); 101 102#define qemu_error_new(fmt, ...) \ 103 qemu_error_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) 104 105/* TAP win32 */ 106int tap_win32_init(VLANState *vlan, const char *model, 107 const char *name, const char *ifname); 108 109/* SLIRP */ 110void do_info_slirp(Monitor *mon); 111 112typedef enum DisplayType 113{ 114 DT_DEFAULT, 115 DT_CURSES, 116 DT_SDL, 117 DT_GTK, 118 DT_VNC, 119 DT_NOGRAPHIC, 120 DT_NONE, 121} DisplayType; 122 123extern int autostart; 124extern int bios_size; 125extern int cirrus_vga_enabled; 126extern int std_vga_enabled; 127extern int vmsvga_enabled; 128extern int xenfb_enabled; 129extern int graphic_width; 130extern int graphic_height; 131extern int graphic_depth; 132extern DisplayType display_type; 133extern const char *keyboard_layout; 134extern int win2k_install_hack; 135extern int rtc_td_hack; 136extern int alt_grab; 137extern int usb_enabled; 138extern int no_virtio_balloon; 139extern int smp_cpus; 140extern int cursor_hide; 141extern int graphic_rotate; 142extern int no_quit; 143extern int semihosting_enabled; 144extern int old_param; 145 146const char* dns_log_filename; 147const char* drop_log_filename; 148 149#define MAX_NODES 64 150extern int nb_numa_nodes; 151extern uint64_t node_mem[MAX_NODES]; 152 153#define MAX_OPTION_ROMS 16 154extern const char *option_rom[MAX_OPTION_ROMS]; 155extern int nb_option_roms; 156 157#ifdef NEED_CPU_H 158#if defined(TARGET_SPARC) || defined(TARGET_PPC) 159#define MAX_PROM_ENVS 128 160extern const char *prom_envs[MAX_PROM_ENVS]; 161extern unsigned int nb_prom_envs; 162#endif 163#endif 164 165#if 0 166typedef enum { 167 BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC, 168 BLOCK_ERR_STOP_ANY 169} BlockInterfaceErrorAction; 170 171struct DriveInfo { 172 BlockDriverState *bdrv; 173 BlockInterfaceType type; 174 int bus; 175 int unit; 176 int used; 177 int drive_opt_idx; 178 BlockInterfaceErrorAction onerror; 179 char serial[21]; 180}; 181 182#define MAX_IDE_DEVS 2 183#define MAX_SCSI_DEVS 7 184#define MAX_DRIVES 32 185 186extern int nb_drives; 187extern DriveInfo drives_table[MAX_DRIVES+1]; 188 189extern int drive_get_index(BlockInterfaceType type, int bus, int unit); 190extern int drive_get_max_bus(BlockInterfaceType type); 191extern void drive_uninit(BlockDriverState *bdrv); 192extern void drive_remove(int index); 193extern const char *drive_get_serial(BlockDriverState *bdrv); 194extern BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv); 195 196BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type); 197 198struct drive_opt { 199 const char *file; 200 char opt[1024]; 201 int used; 202}; 203 204extern struct drive_opt drives_opt[MAX_DRIVES]; 205extern int nb_drives_opt; 206 207extern int drive_add(const char *file, const char *fmt, ...); 208extern int drive_init(struct drive_opt *arg, int snapshot, void *machine); 209int add_init_drive(const char *opts); 210#endif 211 212/* acpi */ 213void qemu_system_hot_add_init(void); 214void qemu_system_device_hot_add(int pcibus, int slot, int state); 215 216/* device-hotplug */ 217 218typedef int (dev_match_fn)(void *dev_private, void *arg); 219 220void destroy_nic(dev_match_fn *match_fn, void *arg); 221void destroy_bdrvs(dev_match_fn *match_fn, void *arg); 222 223#ifndef CONFIG_ANDROID 224/* pci-hotplug */ 225void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type, 226 const char *opts); 227void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts); 228void pci_device_hot_remove(Monitor *mon, const char *pci_addr); 229void pci_device_hot_remove_success(int pcibus, int slot); 230#endif 231 232/* serial ports */ 233 234#define MAX_SERIAL_PORTS 4 235 236extern CharDriverState *serial_hds[MAX_SERIAL_PORTS]; 237 238/* parallel ports */ 239 240#define MAX_PARALLEL_PORTS 3 241 242extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; 243 244/* virtio consoles */ 245 246#define MAX_VIRTIO_CONSOLES 1 247 248extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; 249 250#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) 251 252void do_usb_add(Monitor *mon, const char *devname); 253void do_usb_del(Monitor *mon, const char *devname); 254void usb_info(Monitor *mon); 255 256int get_param_value(char *buf, int buf_size, 257 const char *tag, const char *str); 258int check_params(char *buf, int buf_size, 259 const char * const *params, const char *str); 260 261void register_devices(void); 262 263#endif 264