00001 #ifndef SYSEMU_H
00002 #define SYSEMU_H
00003
00004
00005
00006 extern const char *bios_name;
00007 extern const char *bios_dir;
00008
00009 extern int vm_running;
00010 extern const char *qemu_name;
00011 extern uint8_t qemu_uuid[];
00012 #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
00013
00014 typedef struct vm_change_state_entry VMChangeStateEntry;
00015 typedef void VMChangeStateHandler(void *opaque, int running, int reason);
00016
00017 VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
00018 void *opaque);
00019 void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
00020
00021 void vm_start(void);
00022 void vm_stop(int reason);
00023
00024 int64_t cpu_get_ticks(void);
00025 void cpu_enable_ticks(void);
00026 void cpu_disable_ticks(void);
00027
00028 void qemu_system_reset_request(void);
00029 void qemu_system_shutdown_request(void);
00030 void qemu_system_powerdown_request(void);
00031 int qemu_shutdown_requested(void);
00032 int qemu_reset_requested(void);
00033 int qemu_powerdown_requested(void);
00034 #if !defined(TARGET_SPARC) && !defined(TARGET_I386)
00035
00036 #define qemu_system_powerdown() do{}while(0)
00037 #else
00038 void qemu_system_powerdown(void);
00039 #endif
00040 void qemu_system_reset(void);
00041
00042 void do_savevm(const char *name);
00043 void do_loadvm(const char *name);
00044 void do_delvm(const char *name);
00045 void do_info_snapshots(void);
00046
00047 void qemu_announce_self(void);
00048
00049 void main_loop_wait(int timeout);
00050
00051 int qemu_savevm_state_begin(QEMUFile *f);
00052 int qemu_savevm_state_iterate(QEMUFile *f);
00053 int qemu_savevm_state_complete(QEMUFile *f);
00054 int qemu_savevm_state(QEMUFile *f);
00055 int qemu_loadvm_state(QEMUFile *f);
00056
00057 #ifdef _WIN32
00058
00059
00060
00061 typedef int PollingFunc(void *opaque);
00062
00063 int qemu_add_polling_cb(PollingFunc *func, void *opaque);
00064 void qemu_del_polling_cb(PollingFunc *func, void *opaque);
00065
00066
00067 typedef void WaitObjectFunc(void *opaque);
00068
00069 int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
00070 void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
00071 #endif
00072
00073
00074 int tap_win32_init(VLANState *vlan, const char *model,
00075 const char *name, const char *ifname);
00076
00077
00078 void do_info_slirp(void);
00079
00080 extern int bios_size;
00081 extern int cirrus_vga_enabled;
00082 extern int std_vga_enabled;
00083 extern int vmsvga_enabled;
00084 extern int graphic_width;
00085 extern int graphic_height;
00086 extern int graphic_depth;
00087 extern int nographic;
00088 extern const char *keyboard_layout;
00089 extern int win2k_install_hack;
00090 extern int rtc_td_hack;
00091 extern int alt_grab;
00092 extern int usb_enabled;
00093 extern int smp_cpus;
00094 extern int cursor_hide;
00095 extern int graphic_rotate;
00096 extern int no_quit;
00097 extern int semihosting_enabled;
00098 extern int old_param;
00099 extern const char *bootp_filename;
00100
00101 #ifdef USE_KQEMU
00102 extern int kqemu_allowed;
00103 #endif
00104
00105 #define MAX_OPTION_ROMS 16
00106 extern const char *option_rom[MAX_OPTION_ROMS];
00107 extern int nb_option_roms;
00108
00109 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
00110 #define MAX_PROM_ENVS 128
00111 extern const char *prom_envs[MAX_PROM_ENVS];
00112 extern unsigned int nb_prom_envs;
00113 #endif
00114
00115 #if defined (TARGET_PPC)
00116 #define BIOS_SIZE (1024 * 1024)
00117 #elif defined (TARGET_SPARC64)
00118 #define BIOS_SIZE ((512 + 32) * 1024)
00119 #elif defined(TARGET_MIPS)
00120 #define BIOS_SIZE (4 * 1024 * 1024)
00121 #endif
00122
00123 typedef enum {
00124 IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO
00125 } BlockInterfaceType;
00126
00127 typedef enum {
00128 BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC,
00129 BLOCK_ERR_STOP_ANY
00130 } BlockInterfaceErrorAction;
00131
00132 typedef struct DriveInfo {
00133 BlockDriverState *bdrv;
00134 BlockInterfaceType type;
00135 int bus;
00136 int unit;
00137 int used;
00138 int drive_opt_idx;
00139 BlockInterfaceErrorAction onerror;
00140 char serial[21];
00141 } DriveInfo;
00142
00143 #define MAX_IDE_DEVS 2
00144 #define MAX_SCSI_DEVS 7
00145 #define MAX_DRIVES 32
00146
00147 extern int nb_drives;
00148 extern DriveInfo drives_table[MAX_DRIVES+1];
00149
00150 extern int drive_get_index(BlockInterfaceType type, int bus, int unit);
00151 extern int drive_get_max_bus(BlockInterfaceType type);
00152 extern void drive_uninit(BlockDriverState *bdrv);
00153 extern void drive_remove(int index);
00154 extern const char *drive_get_serial(BlockDriverState *bdrv);
00155 extern BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv);
00156
00157 struct drive_opt {
00158 const char *file;
00159 char opt[1024];
00160 int used;
00161 };
00162
00163 extern struct drive_opt drives_opt[MAX_DRIVES];
00164 extern int nb_drives_opt;
00165
00166 extern int drive_add(const char *file, const char *fmt, ...);
00167 extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
00168
00169
00170 void qemu_system_hot_add_init(void);
00171 void qemu_system_device_hot_add(int pcibus, int slot, int state);
00172
00173
00174
00175 typedef int (dev_match_fn)(void *dev_private, void *arg);
00176
00177 int add_init_drive(const char *opts);
00178 void destroy_nic(dev_match_fn *match_fn, void *arg);
00179 void destroy_bdrvs(dev_match_fn *match_fn, void *arg);
00180
00181
00182 void pci_device_hot_add(const char *pci_addr, const char *type, const char *opts);
00183 void drive_hot_add(const char *pci_addr, const char *opts);
00184 void pci_device_hot_remove(const char *pci_addr);
00185 void pci_device_hot_remove_success(int pcibus, int slot);
00186
00187
00188
00189 #define MAX_SERIAL_PORTS 4
00190
00191 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
00192
00193
00194
00195 #define MAX_PARALLEL_PORTS 3
00196
00197 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
00198
00199
00200
00201 #define MAX_VIRTIO_CONSOLES 1
00202
00203 extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
00204
00205 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
00206
00207 #ifdef NEED_CPU_H
00208
00209 int get_image_size(const char *filename);
00210 int load_image(const char *filename, uint8_t *addr);
00211 int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz);
00212 int load_elf(const char *filename, int64_t address_offset,
00213 uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr);
00214 int load_aout(const char *filename, target_phys_addr_t addr, int max_sz);
00215 int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
00216 int *is_linux);
00217
00218 int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
00219 int fread_targphys_ok(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
00220 int read_targphys(int fd, target_phys_addr_t dst_addr, size_t nbytes);
00221 void pstrcpy_targphys(target_phys_addr_t dest, int buf_size,
00222 const char *source);
00223 #endif
00224
00225 #ifdef HAS_AUDIO
00226 struct soundhw {
00227 const char *name;
00228 const char *descr;
00229 int enabled;
00230 int isa;
00231 union {
00232 int (*init_isa) (AudioState *s, qemu_irq *pic);
00233 int (*init_pci) (PCIBus *bus, AudioState *s);
00234 } init;
00235 };
00236
00237 extern struct soundhw soundhw[];
00238 #endif
00239
00240 void do_usb_add(const char *devname);
00241 void do_usb_del(const char *devname);
00242 void usb_info(void);
00243
00244 const char *get_opt_name(char *buf, int buf_size, const char *p);
00245 const char *get_opt_value(char *buf, int buf_size, const char *p);
00246 int get_param_value(char *buf, int buf_size,
00247 const char *tag, const char *str);
00248 int check_params(char *buf, int buf_size,
00249 const char * const *params, const char *str);
00250
00251 #endif