sysemu.h 6.6 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"
A
aliguori 已提交
9

10 11 12 13
#ifdef _WIN32
#include <windows.h>
#endif

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

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

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

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

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);

37 38 39 40
uint64_t ram_bytes_remaining(void);
uint64_t ram_bytes_transferred(void);
uint64_t ram_bytes_total(void);

P
pbrook 已提交
41 42 43 44 45 46 47
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 已提交
48 49 50
int qemu_shutdown_requested(void);
int qemu_reset_requested(void);
int qemu_powerdown_requested(void);
B
Blue Swirl 已提交
51
extern qemu_irq qemu_system_powerdown;
A
aurel32 已提交
52
void qemu_system_reset(void);
P
pbrook 已提交
53

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

59 60 61 62
void cpu_synchronize_all_states(void);
void cpu_synchronize_all_post_reset(void);
void cpu_synchronize_all_post_init(void);

63 64
void qemu_announce_self(void);

65
void main_loop_wait(int nonblocking);
P
pbrook 已提交
66

67 68 69 70 71
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 已提交
72 73
int qemu_loadvm_state(QEMUFile *f);

A
aliguori 已提交
74
#ifdef _WIN32
P
pbrook 已提交
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
/* 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 已提交
91
void do_info_slirp(Monitor *mon);
P
pbrook 已提交
92

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

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

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

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

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

#define MAX_PROM_ENVS 128
extern const char *prom_envs[MAX_PROM_ENVS];
extern unsigned int nb_prom_envs;

T
ths 已提交
149
typedef enum {
G
Gerd Hoffmann 已提交
150
    IF_NONE,
P
Paul Brook 已提交
151 152
    IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
    IF_COUNT
T
ths 已提交
153 154
} BlockInterfaceType;

155 156 157 158 159
typedef enum {
    BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC,
    BLOCK_ERR_STOP_ANY
} BlockInterfaceErrorAction;

160 161
#define BLOCK_SERIAL_STRLEN 20

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

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

B
Blue Swirl 已提交
180 181
extern QTAILQ_HEAD(drivelist, DriveInfo) drives;
extern QTAILQ_HEAD(driveoptlist, DriveOpt) driveopts;
T
ths 已提交
182

G
Gerd Hoffmann 已提交
183
extern DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
G
Gerd Hoffmann 已提交
184
extern DriveInfo *drive_get_by_id(const char *id);
185
extern int drive_get_max_bus(BlockInterfaceType type);
G
Gerd Hoffmann 已提交
186
extern void drive_uninit(DriveInfo *dinfo);
187
extern const char *drive_get_serial(BlockDriverState *bdrv);
188 189 190

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

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

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

197 198
/* device-hotplug */

G
Gerd Hoffmann 已提交
199
DriveInfo *add_init_drive(const char *opts);
200 201

/* pci-hotplug */
202
void pci_device_hot_add_print(Monitor *mon, const QObject *data);
203
int pci_device_hot_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
204
void drive_hot_add(Monitor *mon, const QDict *qdict);
205 206 207
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);
208

P
pbrook 已提交
209 210 211 212 213 214 215 216 217 218 219 220
/* 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];

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

P
pbrook 已提交
223 224 225 226 227 228 229
#ifdef HAS_AUDIO
struct soundhw {
    const char *name;
    const char *descr;
    int enabled;
    int isa;
    union {
P
Paul Brook 已提交
230 231
        int (*init_isa) (qemu_irq *pic);
        int (*init_pci) (PCIBus *bus);
P
pbrook 已提交
232 233 234 235 236 237
    } init;
};

extern struct soundhw soundhw[];
#endif

238 239
void do_usb_add(Monitor *mon, const QDict *qdict);
void do_usb_del(Monitor *mon, const QDict *qdict);
A
aliguori 已提交
240
void usb_info(Monitor *mon);
P
pbrook 已提交
241

242 243
void rtc_change_mon_event(struct tm *tm);

P
Paul Brook 已提交
244 245
void register_devices(void);

P
pbrook 已提交
246
#endif