sysemu.h 7.0 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(Monitor *mon, 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
void qemu_announce_self(void);

P
pbrook 已提交
63 64
void main_loop_wait(int timeout);

L
lirans@il.ibm.com 已提交
65
int qemu_savevm_state_begin(QEMUFile *f, int blk_enable, int shared);
A
aliguori 已提交
66 67
int qemu_savevm_state_iterate(QEMUFile *f);
int qemu_savevm_state_complete(QEMUFile *f);
68
void qemu_savevm_state_cancel(QEMUFile *f);
A
aliguori 已提交
69 70 71
int qemu_savevm_state(QEMUFile *f);
int qemu_loadvm_state(QEMUFile *f);

G
Gerd Hoffmann 已提交
72 73 74 75
void qemu_errors_to_file(FILE *fp);
void qemu_errors_to_mon(Monitor *mon);
void qemu_errors_to_previous(void);
void qemu_error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
L
Luiz Capitulino 已提交
76 77 78 79 80 81
void qemu_error_internal(const char *file, int linenr, const char *func,
                         const char *fmt, ...)
                         __attribute__ ((format(printf, 4, 5)));

#define qemu_error_new(fmt, ...) \
    qemu_error_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__)
G
Gerd Hoffmann 已提交
82

A
aliguori 已提交
83
#ifdef _WIN32
P
pbrook 已提交
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
/* 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 已提交
100
void do_info_slirp(Monitor *mon);
P
pbrook 已提交
101

102 103 104 105 106 107 108 109 110
typedef enum DisplayType
{
    DT_DEFAULT,
    DT_CURSES,
    DT_SDL,
    DT_VNC,
    DT_NOGRAPHIC,
} DisplayType;

P
Paolo Bonzini 已提交
111
extern int autostart;
P
pbrook 已提交
112
extern int bios_size;
113 114 115 116 117 118 119 120 121 122 123

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 已提交
124 125 126
extern int graphic_width;
extern int graphic_height;
extern int graphic_depth;
J
Jes Sorensen 已提交
127
extern uint8_t irq0override;
128
extern DisplayType display_type;
P
pbrook 已提交
129 130
extern const char *keyboard_layout;
extern int win2k_install_hack;
131
extern int rtc_td_hack;
P
pbrook 已提交
132
extern int alt_grab;
133
extern int ctrl_grab;
P
pbrook 已提交
134 135
extern int usb_enabled;
extern int smp_cpus;
136
extern int max_cpus;
P
pbrook 已提交
137 138 139 140 141
extern int cursor_hide;
extern int graphic_rotate;
extern int no_quit;
extern int semihosting_enabled;
extern int old_param;
142
extern int boot_menu;
J
Jan Kiszka 已提交
143
extern QEMUClock *rtc_clock;
P
pbrook 已提交
144

145 146 147
#define MAX_NODES 64
extern int nb_numa_nodes;
extern uint64_t node_mem[MAX_NODES];
B
Blue Swirl 已提交
148
extern uint64_t node_cpumask[MAX_NODES];
149

P
pbrook 已提交
150 151 152 153
#define MAX_OPTION_ROMS 16
extern const char *option_rom[MAX_OPTION_ROMS];
extern int nb_option_roms;

P
Paul Brook 已提交
154
#ifdef NEED_CPU_H
155
#if defined(TARGET_SPARC) || defined(TARGET_PPC)
P
pbrook 已提交
156 157 158 159
#define MAX_PROM_ENVS 128
extern const char *prom_envs[MAX_PROM_ENVS];
extern unsigned int nb_prom_envs;
#endif
P
Paul Brook 已提交
160
#endif
P
pbrook 已提交
161

T
ths 已提交
162
typedef enum {
G
Gerd Hoffmann 已提交
163
    IF_NONE,
P
Paul Brook 已提交
164 165
    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
    IF_COUNT
T
ths 已提交
166 167
} BlockInterfaceType;

168 169 170 171 172
typedef enum {
    BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC,
    BLOCK_ERR_STOP_ANY
} BlockInterfaceErrorAction;

173 174
#define BLOCK_SERIAL_STRLEN 20

T
ths 已提交
175 176
typedef struct DriveInfo {
    BlockDriverState *bdrv;
G
Gerd Hoffmann 已提交
177
    char *id;
178
    const char *devaddr;
179
    BlockInterfaceType type;
T
ths 已提交
180 181
    int bus;
    int unit;
G
Gerd Hoffmann 已提交
182
    QemuOpts *opts;
183
    BlockInterfaceErrorAction onerror;
184
    char serial[BLOCK_SERIAL_STRLEN + 1];
B
Blue Swirl 已提交
185
    QTAILQ_ENTRY(DriveInfo) next;
T
ths 已提交
186 187 188 189 190 191
} DriveInfo;

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

B
Blue Swirl 已提交
192 193
extern QTAILQ_HEAD(drivelist, DriveInfo) drives;
extern QTAILQ_HEAD(driveoptlist, DriveOpt) driveopts;
T
ths 已提交
194

G
Gerd Hoffmann 已提交
195
extern DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
G
Gerd Hoffmann 已提交
196
extern DriveInfo *drive_get_by_id(const char *id);
197
extern int drive_get_max_bus(BlockInterfaceType type);
G
Gerd Hoffmann 已提交
198
extern void drive_uninit(DriveInfo *dinfo);
199
extern const char *drive_get_serial(BlockDriverState *bdrv);
200
extern BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv);
P
pbrook 已提交
201

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

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

207 208
/* device-hotplug */

G
Gerd Hoffmann 已提交
209
DriveInfo *add_init_drive(const char *opts);
210 211

/* pci-hotplug */
212
void pci_device_hot_add(Monitor *mon, const QDict *qdict);
213
void drive_hot_add(Monitor *mon, const QDict *qdict);
A
aliguori 已提交
214
void pci_device_hot_remove(Monitor *mon, const char *pci_addr);
215 216
void do_pci_device_hot_remove(Monitor *mon, const QDict *qdict,
                              QObject **ret_data);
217

P
pbrook 已提交
218 219 220 221 222 223 224 225 226 227 228 229
/* 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];

230 231 232 233 234 235
/* virtio consoles */

#define MAX_VIRTIO_CONSOLES 1

extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];

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

P
pbrook 已提交
238 239 240 241 242 243 244
#ifdef HAS_AUDIO
struct soundhw {
    const char *name;
    const char *descr;
    int enabled;
    int isa;
    union {
P
Paul Brook 已提交
245 246
        int (*init_isa) (qemu_irq *pic);
        int (*init_pci) (PCIBus *bus);
P
pbrook 已提交
247 248 249 250 251 252
    } init;
};

extern struct soundhw soundhw[];
#endif

253 254
void do_usb_add(Monitor *mon, const QDict *qdict);
void do_usb_del(Monitor *mon, const QDict *qdict);
A
aliguori 已提交
255
void usb_info(Monitor *mon);
P
pbrook 已提交
256

P
Paul Brook 已提交
257 258
void register_devices(void);

P
pbrook 已提交
259
#endif