root / sysemu.h @ 651721b2
History | View | Annotate | Download (7.3 kB)
1 | 87ecb68b | pbrook | #ifndef SYSEMU_H
|
---|---|---|---|
2 | 87ecb68b | pbrook | #define SYSEMU_H
|
3 | 87ecb68b | pbrook | /* Misc. things related to the system emulator. */
|
4 | 87ecb68b | pbrook | |
5 | 376253ec | aliguori | #include "qemu-common.h" |
6 | 376253ec | aliguori | |
7 | 49dc768d | aliguori | #ifdef _WIN32
|
8 | 49dc768d | aliguori | #include <windows.h> |
9 | 49dc768d | aliguori | #endif
|
10 | 49dc768d | aliguori | |
11 | 87ecb68b | pbrook | /* vl.c */
|
12 | 87ecb68b | pbrook | extern const char *bios_name; |
13 | 87ecb68b | pbrook | extern const char *bios_dir; |
14 | 87ecb68b | pbrook | |
15 | 87ecb68b | pbrook | extern int vm_running; |
16 | 87ecb68b | pbrook | extern const char *qemu_name; |
17 | 8fcb1b90 | blueswir1 | extern uint8_t qemu_uuid[];
|
18 | 8fcb1b90 | blueswir1 | #define UUID_FMT "%02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx" |
19 | 87ecb68b | pbrook | |
20 | 87ecb68b | pbrook | typedef struct vm_change_state_entry VMChangeStateEntry; |
21 | 9781e040 | aliguori | typedef void VMChangeStateHandler(void *opaque, int running, int reason); |
22 | 87ecb68b | pbrook | |
23 | 87ecb68b | pbrook | VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, |
24 | 87ecb68b | pbrook | void *opaque);
|
25 | 87ecb68b | pbrook | void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
|
26 | 87ecb68b | pbrook | |
27 | 87ecb68b | pbrook | void vm_start(void); |
28 | 87ecb68b | pbrook | void vm_stop(int reason); |
29 | 87ecb68b | pbrook | |
30 | 87ecb68b | pbrook | int64_t cpu_get_ticks(void);
|
31 | 87ecb68b | pbrook | void cpu_enable_ticks(void); |
32 | 87ecb68b | pbrook | void cpu_disable_ticks(void); |
33 | 87ecb68b | pbrook | |
34 | 87ecb68b | pbrook | void qemu_system_reset_request(void); |
35 | 87ecb68b | pbrook | void qemu_system_shutdown_request(void); |
36 | 87ecb68b | pbrook | void qemu_system_powerdown_request(void); |
37 | cf7a2fe2 | aurel32 | int qemu_shutdown_requested(void); |
38 | cf7a2fe2 | aurel32 | int qemu_reset_requested(void); |
39 | cf7a2fe2 | aurel32 | int qemu_powerdown_requested(void); |
40 | cf7a2fe2 | aurel32 | #if !defined(TARGET_SPARC) && !defined(TARGET_I386)
|
41 | 87ecb68b | pbrook | // Please implement a power failure function to signal the OS
|
42 | 87ecb68b | pbrook | #define qemu_system_powerdown() do{}while(0) |
43 | 87ecb68b | pbrook | #else
|
44 | 87ecb68b | pbrook | void qemu_system_powerdown(void); |
45 | 87ecb68b | pbrook | #endif
|
46 | cf7a2fe2 | aurel32 | void qemu_system_reset(void); |
47 | 87ecb68b | pbrook | |
48 | 376253ec | aliguori | void do_savevm(Monitor *mon, const char *name); |
49 | 376253ec | aliguori | void do_loadvm(Monitor *mon, const char *name); |
50 | 376253ec | aliguori | void do_delvm(Monitor *mon, const char *name); |
51 | 376253ec | aliguori | void do_info_snapshots(Monitor *mon);
|
52 | 87ecb68b | pbrook | |
53 | 210f41ba | aliguori | void qemu_announce_self(void); |
54 | 210f41ba | aliguori | |
55 | 87ecb68b | pbrook | void main_loop_wait(int timeout); |
56 | 87ecb68b | pbrook | |
57 | 9366f418 | aliguori | int qemu_savevm_state_begin(QEMUFile *f);
|
58 | 9366f418 | aliguori | int qemu_savevm_state_iterate(QEMUFile *f);
|
59 | 9366f418 | aliguori | int qemu_savevm_state_complete(QEMUFile *f);
|
60 | 9366f418 | aliguori | int qemu_savevm_state(QEMUFile *f);
|
61 | 9366f418 | aliguori | int qemu_loadvm_state(QEMUFile *f);
|
62 | 9366f418 | aliguori | |
63 | 56f3a5d0 | aliguori | #ifdef _WIN32
|
64 | 87ecb68b | pbrook | /* Polling handling */
|
65 | 87ecb68b | pbrook | |
66 | 87ecb68b | pbrook | /* return TRUE if no sleep should be done afterwards */
|
67 | 87ecb68b | pbrook | typedef int PollingFunc(void *opaque); |
68 | 87ecb68b | pbrook | |
69 | 87ecb68b | pbrook | int qemu_add_polling_cb(PollingFunc *func, void *opaque); |
70 | 87ecb68b | pbrook | void qemu_del_polling_cb(PollingFunc *func, void *opaque); |
71 | 87ecb68b | pbrook | |
72 | 87ecb68b | pbrook | /* Wait objects handling */
|
73 | 87ecb68b | pbrook | typedef void WaitObjectFunc(void *opaque); |
74 | 87ecb68b | pbrook | |
75 | 87ecb68b | pbrook | int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
76 | 87ecb68b | pbrook | void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
77 | 87ecb68b | pbrook | #endif
|
78 | 87ecb68b | pbrook | |
79 | 87ecb68b | pbrook | /* TAP win32 */
|
80 | 7a9f6e4a | aliguori | int tap_win32_init(VLANState *vlan, const char *model, |
81 | 7a9f6e4a | aliguori | const char *name, const char *ifname); |
82 | 87ecb68b | pbrook | |
83 | 87ecb68b | pbrook | /* SLIRP */
|
84 | 376253ec | aliguori | void do_info_slirp(Monitor *mon);
|
85 | 87ecb68b | pbrook | |
86 | 87ecb68b | pbrook | extern int bios_size; |
87 | 87ecb68b | pbrook | extern int cirrus_vga_enabled; |
88 | c2b3b41a | aliguori | extern int std_vga_enabled; |
89 | 87ecb68b | pbrook | extern int vmsvga_enabled; |
90 | 87ecb68b | pbrook | extern int graphic_width; |
91 | 87ecb68b | pbrook | extern int graphic_height; |
92 | 87ecb68b | pbrook | extern int graphic_depth; |
93 | 2bfdab63 | blueswir1 | extern int nographic; |
94 | 87ecb68b | pbrook | extern const char *keyboard_layout; |
95 | 87ecb68b | pbrook | extern int win2k_install_hack; |
96 | 73822ec8 | aliguori | extern int rtc_td_hack; |
97 | 87ecb68b | pbrook | extern int alt_grab; |
98 | 87ecb68b | pbrook | extern int usb_enabled; |
99 | 87ecb68b | pbrook | extern int smp_cpus; |
100 | 87ecb68b | pbrook | extern int cursor_hide; |
101 | 87ecb68b | pbrook | extern int graphic_rotate; |
102 | 87ecb68b | pbrook | extern int no_quit; |
103 | 87ecb68b | pbrook | extern int semihosting_enabled; |
104 | 87ecb68b | pbrook | extern int old_param; |
105 | 87ecb68b | pbrook | extern const char *bootp_filename; |
106 | 87ecb68b | pbrook | |
107 | 87ecb68b | pbrook | #ifdef USE_KQEMU
|
108 | 87ecb68b | pbrook | extern int kqemu_allowed; |
109 | 87ecb68b | pbrook | #endif
|
110 | 87ecb68b | pbrook | |
111 | 87ecb68b | pbrook | #define MAX_OPTION_ROMS 16 |
112 | 87ecb68b | pbrook | extern const char *option_rom[MAX_OPTION_ROMS]; |
113 | 87ecb68b | pbrook | extern int nb_option_roms; |
114 | 87ecb68b | pbrook | |
115 | 95efd11c | blueswir1 | #if defined(TARGET_SPARC) || defined(TARGET_PPC)
|
116 | 87ecb68b | pbrook | #define MAX_PROM_ENVS 128 |
117 | 87ecb68b | pbrook | extern const char *prom_envs[MAX_PROM_ENVS]; |
118 | 87ecb68b | pbrook | extern unsigned int nb_prom_envs; |
119 | 87ecb68b | pbrook | #endif
|
120 | 87ecb68b | pbrook | |
121 | 87ecb68b | pbrook | #if defined (TARGET_PPC)
|
122 | 87ecb68b | pbrook | #define BIOS_SIZE (1024 * 1024) |
123 | 87ecb68b | pbrook | #elif defined (TARGET_SPARC64)
|
124 | 87ecb68b | pbrook | #define BIOS_SIZE ((512 + 32) * 1024) |
125 | 87ecb68b | pbrook | #elif defined(TARGET_MIPS)
|
126 | 87ecb68b | pbrook | #define BIOS_SIZE (4 * 1024 * 1024) |
127 | 87ecb68b | pbrook | #endif
|
128 | 87ecb68b | pbrook | |
129 | e4bcb14c | ths | typedef enum { |
130 | 6e02c38d | aliguori | IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO |
131 | e4bcb14c | ths | } BlockInterfaceType; |
132 | e4bcb14c | ths | |
133 | 428c5705 | aliguori | typedef enum { |
134 | 428c5705 | aliguori | BLOCK_ERR_REPORT, BLOCK_ERR_IGNORE, BLOCK_ERR_STOP_ENOSPC, |
135 | 428c5705 | aliguori | BLOCK_ERR_STOP_ANY |
136 | 428c5705 | aliguori | } BlockInterfaceErrorAction; |
137 | 428c5705 | aliguori | |
138 | e4bcb14c | ths | typedef struct DriveInfo { |
139 | e4bcb14c | ths | BlockDriverState *bdrv; |
140 | f60d39bc | ths | BlockInterfaceType type; |
141 | e4bcb14c | ths | int bus;
|
142 | e4bcb14c | ths | int unit;
|
143 | 7d5aca9e | aliguori | int used;
|
144 | b01b1111 | aliguori | int drive_opt_idx;
|
145 | 428c5705 | aliguori | BlockInterfaceErrorAction onerror; |
146 | fa879c64 | aliguori | char serial[21]; |
147 | e4bcb14c | ths | } DriveInfo; |
148 | e4bcb14c | ths | |
149 | e4bcb14c | ths | #define MAX_IDE_DEVS 2 |
150 | e4bcb14c | ths | #define MAX_SCSI_DEVS 7 |
151 | e4bcb14c | ths | #define MAX_DRIVES 32 |
152 | e4bcb14c | ths | |
153 | 4d7a0880 | blueswir1 | extern int nb_drives; |
154 | 4d7a0880 | blueswir1 | extern DriveInfo drives_table[MAX_DRIVES+1]; |
155 | e4bcb14c | ths | |
156 | f60d39bc | ths | extern int drive_get_index(BlockInterfaceType type, int bus, int unit); |
157 | f60d39bc | ths | extern int drive_get_max_bus(BlockInterfaceType type); |
158 | b01b1111 | aliguori | extern void drive_uninit(BlockDriverState *bdrv); |
159 | b01b1111 | aliguori | extern void drive_remove(int index); |
160 | fa879c64 | aliguori | extern const char *drive_get_serial(BlockDriverState *bdrv); |
161 | 428c5705 | aliguori | extern BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv);
|
162 | 87ecb68b | pbrook | |
163 | ec691c80 | aliguori | struct drive_opt {
|
164 | ec691c80 | aliguori | const char *file; |
165 | ec691c80 | aliguori | char opt[1024]; |
166 | ec691c80 | aliguori | int used;
|
167 | ec691c80 | aliguori | }; |
168 | ec691c80 | aliguori | |
169 | ec691c80 | aliguori | extern struct drive_opt drives_opt[MAX_DRIVES]; |
170 | ec691c80 | aliguori | extern int nb_drives_opt; |
171 | ec691c80 | aliguori | |
172 | 4d73cd3b | aliguori | extern int drive_add(const char *file, const char *fmt, ...); |
173 | 4d73cd3b | aliguori | extern int drive_init(struct drive_opt *arg, int snapshot, void *machine); |
174 | 4d73cd3b | aliguori | |
175 | 5e3cb534 | aliguori | /* acpi */
|
176 | 5e3cb534 | aliguori | void qemu_system_hot_add_init(void); |
177 | ca2c72be | aliguori | void qemu_system_device_hot_add(int pcibus, int slot, int state); |
178 | 5e3cb534 | aliguori | |
179 | 6f338c34 | aliguori | /* device-hotplug */
|
180 | 6f338c34 | aliguori | |
181 | 6f338c34 | aliguori | typedef int (dev_match_fn)(void *dev_private, void *arg); |
182 | 6f338c34 | aliguori | |
183 | 6f338c34 | aliguori | int add_init_drive(const char *opts); |
184 | 6f338c34 | aliguori | void destroy_nic(dev_match_fn *match_fn, void *arg); |
185 | 6f338c34 | aliguori | void destroy_bdrvs(dev_match_fn *match_fn, void *arg); |
186 | 6f338c34 | aliguori | |
187 | 6f338c34 | aliguori | /* pci-hotplug */
|
188 | 376253ec | aliguori | void pci_device_hot_add(Monitor *mon, const char *pci_addr, const char *type, |
189 | 376253ec | aliguori | const char *opts); |
190 | 376253ec | aliguori | void drive_hot_add(Monitor *mon, const char *pci_addr, const char *opts); |
191 | 376253ec | aliguori | void pci_device_hot_remove(Monitor *mon, const char *pci_addr); |
192 | 6f338c34 | aliguori | void pci_device_hot_remove_success(int pcibus, int slot); |
193 | 6f338c34 | aliguori | |
194 | 87ecb68b | pbrook | /* serial ports */
|
195 | 87ecb68b | pbrook | |
196 | 87ecb68b | pbrook | #define MAX_SERIAL_PORTS 4 |
197 | 87ecb68b | pbrook | |
198 | 87ecb68b | pbrook | extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
|
199 | 87ecb68b | pbrook | |
200 | 87ecb68b | pbrook | /* parallel ports */
|
201 | 87ecb68b | pbrook | |
202 | 87ecb68b | pbrook | #define MAX_PARALLEL_PORTS 3 |
203 | 87ecb68b | pbrook | |
204 | 87ecb68b | pbrook | extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
|
205 | 87ecb68b | pbrook | |
206 | 9ede2fde | aliguori | /* virtio consoles */
|
207 | 9ede2fde | aliguori | |
208 | 9ede2fde | aliguori | #define MAX_VIRTIO_CONSOLES 1 |
209 | 9ede2fde | aliguori | |
210 | 9ede2fde | aliguori | extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
|
211 | 9ede2fde | aliguori | |
212 | 0e82f34d | aliguori | #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) |
213 | 0e82f34d | aliguori | |
214 | 87ecb68b | pbrook | #ifdef NEED_CPU_H
|
215 | 87ecb68b | pbrook | /* loader.c */
|
216 | 87ecb68b | pbrook | int get_image_size(const char *filename); |
217 | 293f78bc | blueswir1 | int load_image(const char *filename, uint8_t *addr); /* deprecated */ |
218 | 293f78bc | blueswir1 | int load_image_targphys(const char *filename, target_phys_addr_t, int max_sz); |
219 | 83c1f87c | pbrook | int load_elf(const char *filename, int64_t address_offset, |
220 | 87ecb68b | pbrook | uint64_t *pentry, uint64_t *lowaddr, uint64_t *highaddr); |
221 | 293f78bc | blueswir1 | int load_aout(const char *filename, target_phys_addr_t addr, int max_sz); |
222 | 5a9154e0 | aliguori | int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr, |
223 | 5a9154e0 | aliguori | int *is_linux);
|
224 | 293f78bc | blueswir1 | |
225 | 293f78bc | blueswir1 | int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
|
226 | 293f78bc | blueswir1 | int fread_targphys_ok(target_phys_addr_t dst_addr, size_t nbytes, FILE *f);
|
227 | 293f78bc | blueswir1 | int read_targphys(int fd, target_phys_addr_t dst_addr, size_t nbytes); |
228 | 293f78bc | blueswir1 | void pstrcpy_targphys(target_phys_addr_t dest, int buf_size, |
229 | 293f78bc | blueswir1 | const char *source); |
230 | 87ecb68b | pbrook | #endif
|
231 | 87ecb68b | pbrook | |
232 | 87ecb68b | pbrook | #ifdef HAS_AUDIO
|
233 | 87ecb68b | pbrook | struct soundhw {
|
234 | 87ecb68b | pbrook | const char *name; |
235 | 87ecb68b | pbrook | const char *descr; |
236 | 87ecb68b | pbrook | int enabled;
|
237 | 87ecb68b | pbrook | int isa;
|
238 | 87ecb68b | pbrook | union {
|
239 | 87ecb68b | pbrook | int (*init_isa) (AudioState *s, qemu_irq *pic);
|
240 | 87ecb68b | pbrook | int (*init_pci) (PCIBus *bus, AudioState *s);
|
241 | 87ecb68b | pbrook | } init; |
242 | 87ecb68b | pbrook | }; |
243 | 87ecb68b | pbrook | |
244 | 87ecb68b | pbrook | extern struct soundhw soundhw[]; |
245 | 87ecb68b | pbrook | #endif
|
246 | 87ecb68b | pbrook | |
247 | 376253ec | aliguori | void do_usb_add(Monitor *mon, const char *devname); |
248 | 376253ec | aliguori | void do_usb_del(Monitor *mon, const char *devname); |
249 | 376253ec | aliguori | void usb_info(Monitor *mon);
|
250 | 87ecb68b | pbrook | |
251 | 63a01ef8 | aliguori | const char *get_opt_name(char *buf, int buf_size, const char *p); |
252 | 63a01ef8 | aliguori | const char *get_opt_value(char *buf, int buf_size, const char *p); |
253 | 63a01ef8 | aliguori | int get_param_value(char *buf, int buf_size, |
254 | 63a01ef8 | aliguori | const char *tag, const char *str); |
255 | 63a01ef8 | aliguori | int check_params(char *buf, int buf_size, |
256 | 63a01ef8 | aliguori | const char * const *params, const char *str); |
257 | 63a01ef8 | aliguori | |
258 | 87ecb68b | pbrook | #endif |