sysemu.h 6.7 KB
Newer Older
P
pbrook 已提交
1 2 3 4
#ifndef SYSEMU_H
#define SYSEMU_H
/* Misc. things related to the system emulator.  */

A
aliguori 已提交
5
#include "qemu-common.h"
6
#include "qemu-option.h"
B
Blue Swirl 已提交
7
#include "qemu-queue.h"
J
Jan Kiszka 已提交
8
#include "qemu-timer.h"
9
#include "qdict.h"
L
Luiz Capitulino 已提交
10
#include "qerror.h"
A
aliguori 已提交
11

12 13 14 15
#ifdef _WIN32
#include <windows.h>
#endif

P
pbrook 已提交
16 17
/* vl.c */
extern const char *bios_name;
P
Paul Brook 已提交
18 19 20 21

#define QEMU_FILE_TYPE_BIOS   0
#define QEMU_FILE_TYPE_KEYMAP 1
char *qemu_find_file(int type, const char *name);
P
pbrook 已提交
22 23 24

extern int vm_running;
extern const char *qemu_name;
25
extern uint8_t qemu_uuid[];
26
int qemu_uuid_parse(const char *str, uint8_t *uuid);
27
#define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
P
pbrook 已提交
28 29

typedef struct vm_change_state_entry VMChangeStateEntry;
30
typedef void VMChangeStateHandler(void *opaque, int running, int reason);
P
pbrook 已提交
31 32 33 34 35 36 37 38

VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
                                                     void *opaque);
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);

void vm_start(void);
void vm_stop(int reason);

39 40 41 42
uint64_t ram_bytes_remaining(void);
uint64_t ram_bytes_transferred(void);
uint64_t ram_bytes_total(void);

P
pbrook 已提交
43 44 45 46 47 48 49
int64_t cpu_get_ticks(void);
void cpu_enable_ticks(void);
void cpu_disable_ticks(void);

void qemu_system_reset_request(void);
void qemu_system_shutdown_request(void);
void qemu_system_powerdown_request(void);
A
aurel32 已提交
50 51 52
int qemu_shutdown_requested(void);
int qemu_reset_requested(void);
int qemu_powerdown_requested(void);
B
Blue Swirl 已提交
53
extern qemu_irq qemu_system_powerdown;
A
aurel32 已提交
54
void qemu_system_reset(void);
P
pbrook 已提交
55

56
void do_savevm(Monitor *mon, const QDict *qdict);
57
int load_vmstate(const char *name);
58
void do_delvm(Monitor *mon, const QDict *qdict);
A
aliguori 已提交
59
void do_info_snapshots(Monitor *mon);
P
pbrook 已提交
60

61 62 63 64
void cpu_synchronize_all_states(void);
void cpu_synchronize_all_post_reset(void);
void cpu_synchronize_all_post_init(void);

65 66
void qemu_announce_self(void);

P
pbrook 已提交
67 68
void main_loop_wait(int timeout);

69 70 71 72 73
int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable,
                            int shared);
int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f);
int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f);
void qemu_savevm_state_cancel(Monitor *mon, QEMUFile *f);
A
aliguori 已提交
74 75
int qemu_loadvm_state(QEMUFile *f);

A
aliguori 已提交
76
#ifdef _WIN32
P
pbrook 已提交
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
/* Polling handling */

/* return TRUE if no sleep should be done afterwards */
typedef int PollingFunc(void *opaque);

int qemu_add_polling_cb(PollingFunc *func, void *opaque);
void qemu_del_polling_cb(PollingFunc *func, void *opaque);

/* Wait objects handling */
typedef void WaitObjectFunc(void *opaque);

int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque);
#endif

/* SLIRP */
A
aliguori 已提交
93
void do_info_slirp(Monitor *mon);
P
pbrook 已提交
94

95 96 97 98 99 100 101 102 103
typedef enum DisplayType
{
    DT_DEFAULT,
    DT_CURSES,
    DT_SDL,
    DT_VNC,
    DT_NOGRAPHIC,
} DisplayType;

P
Paolo Bonzini 已提交
104
extern int autostart;
P
pbrook 已提交
105
extern int bios_size;
106 107 108 109 110 111 112 113 114 115 116

typedef enum {
    VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB
} VGAInterfaceType;

extern int vga_interface_type;
#define cirrus_vga_enabled (vga_interface_type == VGA_CIRRUS)
#define std_vga_enabled (vga_interface_type == VGA_STD)
#define xenfb_enabled (vga_interface_type == VGA_XENFB)
#define vmsvga_enabled (vga_interface_type == VGA_VMWARE)

P
pbrook 已提交
117 118 119
extern int graphic_width;
extern int graphic_height;
extern int graphic_depth;
J
Jes Sorensen 已提交
120
extern uint8_t irq0override;
121
extern DisplayType display_type;
P
pbrook 已提交
122 123
extern const char *keyboard_layout;
extern int win2k_install_hack;
124
extern int rtc_td_hack;
P
pbrook 已提交
125
extern int alt_grab;
126
extern int ctrl_grab;
P
pbrook 已提交
127 128
extern int usb_enabled;
extern int smp_cpus;
129
extern int max_cpus;
P
pbrook 已提交
130 131 132 133 134
extern int cursor_hide;
extern int graphic_rotate;
extern int no_quit;
extern int semihosting_enabled;
extern int old_param;
135
extern int boot_menu;
J
Jan Kiszka 已提交
136
extern QEMUClock *rtc_clock;
P
pbrook 已提交
137

138 139 140
#define MAX_NODES 64
extern int nb_numa_nodes;
extern uint64_t node_mem[MAX_NODES];
B
Blue Swirl 已提交
141
extern uint64_t node_cpumask[MAX_NODES];
142

P
pbrook 已提交
143 144 145 146
#define MAX_OPTION_ROMS 16
extern const char *option_rom[MAX_OPTION_ROMS];
extern int nb_option_roms;

P
Paul Brook 已提交
147
#ifdef NEED_CPU_H
148
#if defined(TARGET_SPARC) || defined(TARGET_PPC)
P
pbrook 已提交
149 150 151 152
#define MAX_PROM_ENVS 128
extern const char *prom_envs[MAX_PROM_ENVS];
extern unsigned int nb_prom_envs;
#endif
P
Paul Brook 已提交
153
#endif
P
pbrook 已提交
154

T
ths 已提交
155
typedef enum {
G
Gerd Hoffmann 已提交
156
    IF_NONE,
P
Paul Brook 已提交
157 158
    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
    IF_COUNT
T
ths 已提交
159 160
} BlockInterfaceType;

161 162 163 164 165
typedef enum {
    BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC,
    BLOCK_ERR_STOP_ANY
} BlockInterfaceErrorAction;

166 167
#define BLOCK_SERIAL_STRLEN 20

T
ths 已提交
168 169
typedef struct DriveInfo {
    BlockDriverState *bdrv;
G
Gerd Hoffmann 已提交
170
    char *id;
171
    const char *devaddr;
172
    BlockInterfaceType type;
T
ths 已提交
173 174
    int bus;
    int unit;
G
Gerd Hoffmann 已提交
175
    QemuOpts *opts;
K
Kevin Wolf 已提交
176
    BlockInterfaceErrorAction on_read_error;
177
    BlockInterfaceErrorAction on_write_error;
178
    char serial[BLOCK_SERIAL_STRLEN + 1];
B
Blue Swirl 已提交
179
    QTAILQ_ENTRY(DriveInfo) next;
T
ths 已提交
180 181 182 183 184 185
} DriveInfo;

#define MAX_IDE_DEVS	2
#define MAX_SCSI_DEVS	7
#define MAX_DRIVES 32

B
Blue Swirl 已提交
186 187
extern QTAILQ_HEAD(drivelist, DriveInfo) drives;
extern QTAILQ_HEAD(driveoptlist, DriveOpt) driveopts;
T
ths 已提交
188

G
Gerd Hoffmann 已提交
189
extern DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
G
Gerd Hoffmann 已提交
190
extern DriveInfo *drive_get_by_id(const char *id);
191
extern int drive_get_max_bus(BlockInterfaceType type);
G
Gerd Hoffmann 已提交
192
extern void drive_uninit(DriveInfo *dinfo);
193
extern const char *drive_get_serial(BlockDriverState *bdrv);
194 195 196

extern BlockInterfaceErrorAction drive_get_on_error(
    BlockDriverState *bdrv, int is_read);
P
pbrook 已提交
197

P
Paul Brook 已提交
198 199
BlockDriverState *qdev_init_bdrv(DeviceState *dev, BlockInterfaceType type);

G
Gerd Hoffmann 已提交
200 201
extern QemuOpts *drive_add(const char *file, const char *fmt, ...);
extern DriveInfo *drive_init(QemuOpts *arg, void *machine, int *fatal_error);
202

203 204
/* device-hotplug */

G
Gerd Hoffmann 已提交
205
DriveInfo *add_init_drive(const char *opts);
206 207

/* pci-hotplug */
208
void pci_device_hot_add_print(Monitor *mon, const QObject *data);
209
int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
210
void drive_hot_add(Monitor *mon, const QDict *qdict);
211 212 213
int pci_device_hot_remove(Monitor *mon, const char *pci_addr);
int do_pci_device_hot_remove(Monitor *mon, const QDict *qdict,
                             QObject **ret_data);
214

P
pbrook 已提交
215 216 217 218 219 220 221 222 223 224 225 226
/* serial ports */

#define MAX_SERIAL_PORTS 4

extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];

/* parallel ports */

#define MAX_PARALLEL_PORTS 3

extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];

227 228
#define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)

P
pbrook 已提交
229 230 231 232 233 234 235
#ifdef HAS_AUDIO
struct soundhw {
    const char *name;
    const char *descr;
    int enabled;
    int isa;
    union {
P
Paul Brook 已提交
236 237
        int (*init_isa) (qemu_irq *pic);
        int (*init_pci) (PCIBus *bus);
P
pbrook 已提交
238 239 240 241 242 243
    } init;
};

extern struct soundhw soundhw[];
#endif

244 245
void do_usb_add(Monitor *mon, const QDict *qdict);
void do_usb_del(Monitor *mon, const QDict *qdict);
A
aliguori 已提交
246
void usb_info(Monitor *mon);
P
pbrook 已提交
247

248 249
void rtc_change_mon_event(struct tm *tm);

P
Paul Brook 已提交
250 251
void register_devices(void);

P
pbrook 已提交
252
#endif