root / vl.h @ 26a76461
History | View | Annotate | Download (35.8 kB)
1 |
/*
|
---|---|
2 |
* QEMU System Emulator header
|
3 |
*
|
4 |
* Copyright (c) 2003 Fabrice Bellard
|
5 |
*
|
6 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 |
* of this software and associated documentation files (the "Software"), to deal
|
8 |
* in the Software without restriction, including without limitation the rights
|
9 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 |
* copies of the Software, and to permit persons to whom the Software is
|
11 |
* furnished to do so, subject to the following conditions:
|
12 |
*
|
13 |
* The above copyright notice and this permission notice shall be included in
|
14 |
* all copies or substantial portions of the Software.
|
15 |
*
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 |
* THE SOFTWARE.
|
23 |
*/
|
24 |
#ifndef VL_H
|
25 |
#define VL_H
|
26 |
|
27 |
/* we put basic includes here to avoid repeating them in device drivers */
|
28 |
#include <stdlib.h> |
29 |
#include <stdio.h> |
30 |
#include <stdarg.h> |
31 |
#include <string.h> |
32 |
#include <inttypes.h> |
33 |
#include <limits.h> |
34 |
#include <time.h> |
35 |
#include <ctype.h> |
36 |
#include <errno.h> |
37 |
#include <unistd.h> |
38 |
#include <fcntl.h> |
39 |
#include <sys/stat.h> |
40 |
#include "audio/audio.h" |
41 |
|
42 |
#ifndef O_LARGEFILE
|
43 |
#define O_LARGEFILE 0 |
44 |
#endif
|
45 |
#ifndef O_BINARY
|
46 |
#define O_BINARY 0 |
47 |
#endif
|
48 |
|
49 |
#ifdef _WIN32
|
50 |
#include <windows.h> |
51 |
#define fsync _commit
|
52 |
#define lseek _lseeki64
|
53 |
#define ENOTSUP 4096 |
54 |
/* XXX: find 64 bit version */
|
55 |
#define ftruncate chsize
|
56 |
|
57 |
static inline char *realpath(const char *path, char *resolved_path) |
58 |
{ |
59 |
_fullpath(resolved_path, path, _MAX_PATH); |
60 |
return resolved_path;
|
61 |
} |
62 |
|
63 |
#define PRId64 "I64d" |
64 |
#define PRIx64 "I64x" |
65 |
#define PRIu64 "I64u" |
66 |
#define PRIo64 "I64o" |
67 |
#endif
|
68 |
|
69 |
#ifdef QEMU_TOOL
|
70 |
|
71 |
/* we use QEMU_TOOL in the command line tools which do not depend on
|
72 |
the target CPU type */
|
73 |
#include "config-host.h" |
74 |
#include <setjmp.h> |
75 |
#include "osdep.h" |
76 |
#include "bswap.h" |
77 |
|
78 |
#else
|
79 |
|
80 |
#include "cpu.h" |
81 |
#include "gdbstub.h" |
82 |
|
83 |
#endif /* !defined(QEMU_TOOL) */ |
84 |
|
85 |
#ifndef glue
|
86 |
#define xglue(x, y) x ## y |
87 |
#define glue(x, y) xglue(x, y)
|
88 |
#define stringify(s) tostring(s)
|
89 |
#define tostring(s) #s |
90 |
#endif
|
91 |
|
92 |
#ifndef MIN
|
93 |
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
94 |
#endif
|
95 |
#ifndef MAX
|
96 |
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
97 |
#endif
|
98 |
|
99 |
/* vl.c */
|
100 |
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
101 |
|
102 |
void hw_error(const char *fmt, ...); |
103 |
|
104 |
extern const char *bios_dir; |
105 |
|
106 |
void pstrcpy(char *buf, int buf_size, const char *str); |
107 |
char *pstrcat(char *buf, int buf_size, const char *s); |
108 |
int strstart(const char *str, const char *val, const char **ptr); |
109 |
|
110 |
extern int vm_running; |
111 |
|
112 |
typedef struct vm_change_state_entry VMChangeStateEntry; |
113 |
typedef void VMChangeStateHandler(void *opaque, int running); |
114 |
typedef void VMStopHandler(void *opaque, int reason); |
115 |
|
116 |
VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, |
117 |
void *opaque);
|
118 |
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
|
119 |
|
120 |
int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque); |
121 |
void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque); |
122 |
|
123 |
void vm_start(void); |
124 |
void vm_stop(int reason); |
125 |
|
126 |
typedef void QEMUResetHandler(void *opaque); |
127 |
|
128 |
void qemu_register_reset(QEMUResetHandler *func, void *opaque); |
129 |
void qemu_system_reset_request(void); |
130 |
void qemu_system_shutdown_request(void); |
131 |
void qemu_system_powerdown_request(void); |
132 |
#if !defined(TARGET_SPARC)
|
133 |
// Please implement a power failure function to signal the OS
|
134 |
#define qemu_system_powerdown() do{}while(0) |
135 |
#else
|
136 |
void qemu_system_powerdown(void); |
137 |
#endif
|
138 |
|
139 |
void main_loop_wait(int timeout); |
140 |
|
141 |
extern int ram_size; |
142 |
extern int bios_size; |
143 |
extern int rtc_utc; |
144 |
extern int cirrus_vga_enabled; |
145 |
extern int graphic_width; |
146 |
extern int graphic_height; |
147 |
extern int graphic_depth; |
148 |
extern const char *keyboard_layout; |
149 |
extern int kqemu_allowed; |
150 |
extern int win2k_install_hack; |
151 |
extern int usb_enabled; |
152 |
extern int smp_cpus; |
153 |
|
154 |
/* XXX: make it dynamic */
|
155 |
#if defined (TARGET_PPC) || defined (TARGET_SPARC64)
|
156 |
#define BIOS_SIZE ((512 + 32) * 1024) |
157 |
#elif defined(TARGET_MIPS)
|
158 |
#define BIOS_SIZE (128 * 1024) |
159 |
#else
|
160 |
#define BIOS_SIZE ((256 + 64) * 1024) |
161 |
#endif
|
162 |
|
163 |
/* keyboard/mouse support */
|
164 |
|
165 |
#define MOUSE_EVENT_LBUTTON 0x01 |
166 |
#define MOUSE_EVENT_RBUTTON 0x02 |
167 |
#define MOUSE_EVENT_MBUTTON 0x04 |
168 |
|
169 |
typedef void QEMUPutKBDEvent(void *opaque, int keycode); |
170 |
typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state); |
171 |
|
172 |
void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque); |
173 |
void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute); |
174 |
|
175 |
void kbd_put_keycode(int keycode); |
176 |
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); |
177 |
int kbd_mouse_is_absolute(void); |
178 |
|
179 |
/* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
|
180 |
constants) */
|
181 |
#define QEMU_KEY_ESC1(c) ((c) | 0xe100) |
182 |
#define QEMU_KEY_BACKSPACE 0x007f |
183 |
#define QEMU_KEY_UP QEMU_KEY_ESC1('A') |
184 |
#define QEMU_KEY_DOWN QEMU_KEY_ESC1('B') |
185 |
#define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C') |
186 |
#define QEMU_KEY_LEFT QEMU_KEY_ESC1('D') |
187 |
#define QEMU_KEY_HOME QEMU_KEY_ESC1(1) |
188 |
#define QEMU_KEY_END QEMU_KEY_ESC1(4) |
189 |
#define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5) |
190 |
#define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6) |
191 |
#define QEMU_KEY_DELETE QEMU_KEY_ESC1(3) |
192 |
|
193 |
#define QEMU_KEY_CTRL_UP 0xe400 |
194 |
#define QEMU_KEY_CTRL_DOWN 0xe401 |
195 |
#define QEMU_KEY_CTRL_LEFT 0xe402 |
196 |
#define QEMU_KEY_CTRL_RIGHT 0xe403 |
197 |
#define QEMU_KEY_CTRL_HOME 0xe404 |
198 |
#define QEMU_KEY_CTRL_END 0xe405 |
199 |
#define QEMU_KEY_CTRL_PAGEUP 0xe406 |
200 |
#define QEMU_KEY_CTRL_PAGEDOWN 0xe407 |
201 |
|
202 |
void kbd_put_keysym(int keysym); |
203 |
|
204 |
/* async I/O support */
|
205 |
|
206 |
typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size); |
207 |
typedef int IOCanRWHandler(void *opaque); |
208 |
typedef void IOHandler(void *opaque); |
209 |
|
210 |
int qemu_set_fd_handler2(int fd, |
211 |
IOCanRWHandler *fd_read_poll, |
212 |
IOHandler *fd_read, |
213 |
IOHandler *fd_write, |
214 |
void *opaque);
|
215 |
int qemu_set_fd_handler(int fd, |
216 |
IOHandler *fd_read, |
217 |
IOHandler *fd_write, |
218 |
void *opaque);
|
219 |
|
220 |
/* Polling handling */
|
221 |
|
222 |
/* return TRUE if no sleep should be done afterwards */
|
223 |
typedef int PollingFunc(void *opaque); |
224 |
|
225 |
int qemu_add_polling_cb(PollingFunc *func, void *opaque); |
226 |
void qemu_del_polling_cb(PollingFunc *func, void *opaque); |
227 |
|
228 |
#ifdef _WIN32
|
229 |
/* Wait objects handling */
|
230 |
typedef void WaitObjectFunc(void *opaque); |
231 |
|
232 |
int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
233 |
void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
234 |
#endif
|
235 |
|
236 |
/* character device */
|
237 |
|
238 |
#define CHR_EVENT_BREAK 0 /* serial break char */ |
239 |
#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ |
240 |
|
241 |
|
242 |
|
243 |
#define CHR_IOCTL_SERIAL_SET_PARAMS 1 |
244 |
typedef struct { |
245 |
int speed;
|
246 |
int parity;
|
247 |
int data_bits;
|
248 |
int stop_bits;
|
249 |
} QEMUSerialSetParams; |
250 |
|
251 |
#define CHR_IOCTL_SERIAL_SET_BREAK 2 |
252 |
|
253 |
#define CHR_IOCTL_PP_READ_DATA 3 |
254 |
#define CHR_IOCTL_PP_WRITE_DATA 4 |
255 |
#define CHR_IOCTL_PP_READ_CONTROL 5 |
256 |
#define CHR_IOCTL_PP_WRITE_CONTROL 6 |
257 |
#define CHR_IOCTL_PP_READ_STATUS 7 |
258 |
|
259 |
typedef void IOEventHandler(void *opaque, int event); |
260 |
|
261 |
typedef struct CharDriverState { |
262 |
int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len); |
263 |
void (*chr_add_read_handler)(struct CharDriverState *s, |
264 |
IOCanRWHandler *fd_can_read, |
265 |
IOReadHandler *fd_read, void *opaque);
|
266 |
int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg); |
267 |
IOEventHandler *chr_event; |
268 |
void (*chr_send_event)(struct CharDriverState *chr, int event); |
269 |
void (*chr_close)(struct CharDriverState *chr); |
270 |
void *opaque;
|
271 |
} CharDriverState; |
272 |
|
273 |
void qemu_chr_printf(CharDriverState *s, const char *fmt, ...); |
274 |
int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len); |
275 |
void qemu_chr_send_event(CharDriverState *s, int event); |
276 |
void qemu_chr_add_read_handler(CharDriverState *s,
|
277 |
IOCanRWHandler *fd_can_read, |
278 |
IOReadHandler *fd_read, void *opaque);
|
279 |
void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
|
280 |
int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg); |
281 |
|
282 |
/* consoles */
|
283 |
|
284 |
typedef struct DisplayState DisplayState; |
285 |
typedef struct TextConsole TextConsole; |
286 |
|
287 |
typedef void (*vga_hw_update_ptr)(void *); |
288 |
typedef void (*vga_hw_invalidate_ptr)(void *); |
289 |
typedef void (*vga_hw_screen_dump_ptr)(void *, const char *); |
290 |
|
291 |
TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update, |
292 |
vga_hw_invalidate_ptr invalidate, |
293 |
vga_hw_screen_dump_ptr screen_dump, |
294 |
void *opaque);
|
295 |
void vga_hw_update(void); |
296 |
void vga_hw_invalidate(void); |
297 |
void vga_hw_screen_dump(const char *filename); |
298 |
|
299 |
int is_graphic_console(void); |
300 |
CharDriverState *text_console_init(DisplayState *ds); |
301 |
void console_select(unsigned int index); |
302 |
|
303 |
/* serial ports */
|
304 |
|
305 |
#define MAX_SERIAL_PORTS 4 |
306 |
|
307 |
extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
|
308 |
|
309 |
/* parallel ports */
|
310 |
|
311 |
#define MAX_PARALLEL_PORTS 3 |
312 |
|
313 |
extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
|
314 |
|
315 |
/* VLANs support */
|
316 |
|
317 |
typedef struct VLANClientState VLANClientState; |
318 |
|
319 |
struct VLANClientState {
|
320 |
IOReadHandler *fd_read; |
321 |
/* Packets may still be sent if this returns zero. It's used to
|
322 |
rate-limit the slirp code. */
|
323 |
IOCanRWHandler *fd_can_read; |
324 |
void *opaque;
|
325 |
struct VLANClientState *next;
|
326 |
struct VLANState *vlan;
|
327 |
char info_str[256]; |
328 |
}; |
329 |
|
330 |
typedef struct VLANState { |
331 |
int id;
|
332 |
VLANClientState *first_client; |
333 |
struct VLANState *next;
|
334 |
} VLANState; |
335 |
|
336 |
VLANState *qemu_find_vlan(int id);
|
337 |
VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
338 |
IOReadHandler *fd_read, |
339 |
IOCanRWHandler *fd_can_read, |
340 |
void *opaque);
|
341 |
int qemu_can_send_packet(VLANClientState *vc);
|
342 |
void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
343 |
void qemu_handler_true(void *opaque); |
344 |
|
345 |
void do_info_network(void); |
346 |
|
347 |
/* TAP win32 */
|
348 |
int tap_win32_init(VLANState *vlan, const char *ifname); |
349 |
void tap_win32_poll(void); |
350 |
|
351 |
/* NIC info */
|
352 |
|
353 |
#define MAX_NICS 8 |
354 |
|
355 |
typedef struct NICInfo { |
356 |
uint8_t macaddr[6];
|
357 |
const char *model; |
358 |
VLANState *vlan; |
359 |
} NICInfo; |
360 |
|
361 |
extern int nb_nics; |
362 |
extern NICInfo nd_table[MAX_NICS];
|
363 |
|
364 |
/* timers */
|
365 |
|
366 |
typedef struct QEMUClock QEMUClock; |
367 |
typedef struct QEMUTimer QEMUTimer; |
368 |
typedef void QEMUTimerCB(void *opaque); |
369 |
|
370 |
/* The real time clock should be used only for stuff which does not
|
371 |
change the virtual machine state, as it is run even if the virtual
|
372 |
machine is stopped. The real time clock has a frequency of 1000
|
373 |
Hz. */
|
374 |
extern QEMUClock *rt_clock;
|
375 |
|
376 |
/* The virtual clock is only run during the emulation. It is stopped
|
377 |
when the virtual machine is stopped. Virtual timers use a high
|
378 |
precision clock, usually cpu cycles (use ticks_per_sec). */
|
379 |
extern QEMUClock *vm_clock;
|
380 |
|
381 |
int64_t qemu_get_clock(QEMUClock *clock); |
382 |
|
383 |
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
|
384 |
void qemu_free_timer(QEMUTimer *ts);
|
385 |
void qemu_del_timer(QEMUTimer *ts);
|
386 |
void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
|
387 |
int qemu_timer_pending(QEMUTimer *ts);
|
388 |
|
389 |
extern int64_t ticks_per_sec;
|
390 |
extern int pit_min_timer_count; |
391 |
|
392 |
void cpu_enable_ticks(void); |
393 |
void cpu_disable_ticks(void); |
394 |
|
395 |
/* VM Load/Save */
|
396 |
|
397 |
typedef FILE QEMUFile;
|
398 |
|
399 |
void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size); |
400 |
void qemu_put_byte(QEMUFile *f, int v); |
401 |
void qemu_put_be16(QEMUFile *f, unsigned int v); |
402 |
void qemu_put_be32(QEMUFile *f, unsigned int v); |
403 |
void qemu_put_be64(QEMUFile *f, uint64_t v);
|
404 |
int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size); |
405 |
int qemu_get_byte(QEMUFile *f);
|
406 |
unsigned int qemu_get_be16(QEMUFile *f); |
407 |
unsigned int qemu_get_be32(QEMUFile *f); |
408 |
uint64_t qemu_get_be64(QEMUFile *f); |
409 |
|
410 |
static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) |
411 |
{ |
412 |
qemu_put_be64(f, *pv); |
413 |
} |
414 |
|
415 |
static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv) |
416 |
{ |
417 |
qemu_put_be32(f, *pv); |
418 |
} |
419 |
|
420 |
static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv) |
421 |
{ |
422 |
qemu_put_be16(f, *pv); |
423 |
} |
424 |
|
425 |
static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv) |
426 |
{ |
427 |
qemu_put_byte(f, *pv); |
428 |
} |
429 |
|
430 |
static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv) |
431 |
{ |
432 |
*pv = qemu_get_be64(f); |
433 |
} |
434 |
|
435 |
static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv) |
436 |
{ |
437 |
*pv = qemu_get_be32(f); |
438 |
} |
439 |
|
440 |
static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv) |
441 |
{ |
442 |
*pv = qemu_get_be16(f); |
443 |
} |
444 |
|
445 |
static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) |
446 |
{ |
447 |
*pv = qemu_get_byte(f); |
448 |
} |
449 |
|
450 |
#if TARGET_LONG_BITS == 64 |
451 |
#define qemu_put_betl qemu_put_be64
|
452 |
#define qemu_get_betl qemu_get_be64
|
453 |
#define qemu_put_betls qemu_put_be64s
|
454 |
#define qemu_get_betls qemu_get_be64s
|
455 |
#else
|
456 |
#define qemu_put_betl qemu_put_be32
|
457 |
#define qemu_get_betl qemu_get_be32
|
458 |
#define qemu_put_betls qemu_put_be32s
|
459 |
#define qemu_get_betls qemu_get_be32s
|
460 |
#endif
|
461 |
|
462 |
int64_t qemu_ftell(QEMUFile *f); |
463 |
int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
|
464 |
|
465 |
typedef void SaveStateHandler(QEMUFile *f, void *opaque); |
466 |
typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id); |
467 |
|
468 |
int qemu_loadvm(const char *filename); |
469 |
int qemu_savevm(const char *filename); |
470 |
int register_savevm(const char *idstr, |
471 |
int instance_id,
|
472 |
int version_id,
|
473 |
SaveStateHandler *save_state, |
474 |
LoadStateHandler *load_state, |
475 |
void *opaque);
|
476 |
void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
|
477 |
void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
|
478 |
|
479 |
void cpu_save(QEMUFile *f, void *opaque); |
480 |
int cpu_load(QEMUFile *f, void *opaque, int version_id); |
481 |
|
482 |
/* block.c */
|
483 |
typedef struct BlockDriverState BlockDriverState; |
484 |
typedef struct BlockDriver BlockDriver; |
485 |
|
486 |
extern BlockDriver bdrv_raw;
|
487 |
extern BlockDriver bdrv_cow;
|
488 |
extern BlockDriver bdrv_qcow;
|
489 |
extern BlockDriver bdrv_vmdk;
|
490 |
extern BlockDriver bdrv_cloop;
|
491 |
extern BlockDriver bdrv_dmg;
|
492 |
extern BlockDriver bdrv_bochs;
|
493 |
extern BlockDriver bdrv_vpc;
|
494 |
extern BlockDriver bdrv_vvfat;
|
495 |
|
496 |
void bdrv_init(void); |
497 |
BlockDriver *bdrv_find_format(const char *format_name); |
498 |
int bdrv_create(BlockDriver *drv,
|
499 |
const char *filename, int64_t size_in_sectors, |
500 |
const char *backing_file, int flags); |
501 |
BlockDriverState *bdrv_new(const char *device_name); |
502 |
void bdrv_delete(BlockDriverState *bs);
|
503 |
int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot); |
504 |
int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot, |
505 |
BlockDriver *drv); |
506 |
void bdrv_close(BlockDriverState *bs);
|
507 |
int bdrv_read(BlockDriverState *bs, int64_t sector_num,
|
508 |
uint8_t *buf, int nb_sectors);
|
509 |
int bdrv_write(BlockDriverState *bs, int64_t sector_num,
|
510 |
const uint8_t *buf, int nb_sectors); |
511 |
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
|
512 |
int bdrv_commit(BlockDriverState *bs);
|
513 |
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); |
514 |
/* Ensure contents are flushed to disk. */
|
515 |
void bdrv_flush(BlockDriverState *bs);
|
516 |
|
517 |
#define BDRV_TYPE_HD 0 |
518 |
#define BDRV_TYPE_CDROM 1 |
519 |
#define BDRV_TYPE_FLOPPY 2 |
520 |
#define BIOS_ATA_TRANSLATION_AUTO 0 |
521 |
#define BIOS_ATA_TRANSLATION_NONE 1 |
522 |
#define BIOS_ATA_TRANSLATION_LBA 2 |
523 |
|
524 |
void bdrv_set_geometry_hint(BlockDriverState *bs,
|
525 |
int cyls, int heads, int secs); |
526 |
void bdrv_set_type_hint(BlockDriverState *bs, int type); |
527 |
void bdrv_set_translation_hint(BlockDriverState *bs, int translation); |
528 |
void bdrv_get_geometry_hint(BlockDriverState *bs,
|
529 |
int *pcyls, int *pheads, int *psecs); |
530 |
int bdrv_get_type_hint(BlockDriverState *bs);
|
531 |
int bdrv_get_translation_hint(BlockDriverState *bs);
|
532 |
int bdrv_is_removable(BlockDriverState *bs);
|
533 |
int bdrv_is_read_only(BlockDriverState *bs);
|
534 |
int bdrv_is_inserted(BlockDriverState *bs);
|
535 |
int bdrv_is_locked(BlockDriverState *bs);
|
536 |
void bdrv_set_locked(BlockDriverState *bs, int locked); |
537 |
void bdrv_set_change_cb(BlockDriverState *bs,
|
538 |
void (*change_cb)(void *opaque), void *opaque); |
539 |
void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size); |
540 |
void bdrv_info(void); |
541 |
BlockDriverState *bdrv_find(const char *name); |
542 |
void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque); |
543 |
int bdrv_is_encrypted(BlockDriverState *bs);
|
544 |
int bdrv_set_key(BlockDriverState *bs, const char *key); |
545 |
void bdrv_iterate_format(void (*it)(void *opaque, const char *name), |
546 |
void *opaque);
|
547 |
const char *bdrv_get_device_name(BlockDriverState *bs); |
548 |
|
549 |
int qcow_get_cluster_size(BlockDriverState *bs);
|
550 |
int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
|
551 |
const uint8_t *buf);
|
552 |
|
553 |
#ifndef QEMU_TOOL
|
554 |
|
555 |
typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, |
556 |
int boot_device,
|
557 |
DisplayState *ds, const char **fd_filename, int snapshot, |
558 |
const char *kernel_filename, const char *kernel_cmdline, |
559 |
const char *initrd_filename); |
560 |
|
561 |
typedef struct QEMUMachine { |
562 |
const char *name; |
563 |
const char *desc; |
564 |
QEMUMachineInitFunc *init; |
565 |
struct QEMUMachine *next;
|
566 |
} QEMUMachine; |
567 |
|
568 |
int qemu_register_machine(QEMUMachine *m);
|
569 |
|
570 |
typedef void SetIRQFunc(void *opaque, int irq_num, int level); |
571 |
typedef void IRQRequestFunc(void *opaque, int level); |
572 |
|
573 |
/* ISA bus */
|
574 |
|
575 |
extern target_phys_addr_t isa_mem_base;
|
576 |
|
577 |
typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); |
578 |
typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); |
579 |
|
580 |
int register_ioport_read(int start, int length, int size, |
581 |
IOPortReadFunc *func, void *opaque);
|
582 |
int register_ioport_write(int start, int length, int size, |
583 |
IOPortWriteFunc *func, void *opaque);
|
584 |
void isa_unassign_ioport(int start, int length); |
585 |
|
586 |
/* PCI bus */
|
587 |
|
588 |
extern target_phys_addr_t pci_mem_base;
|
589 |
|
590 |
typedef struct PCIBus PCIBus; |
591 |
typedef struct PCIDevice PCIDevice; |
592 |
|
593 |
typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, |
594 |
uint32_t address, uint32_t data, int len);
|
595 |
typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
|
596 |
uint32_t address, int len);
|
597 |
typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num, |
598 |
uint32_t addr, uint32_t size, int type);
|
599 |
|
600 |
#define PCI_ADDRESS_SPACE_MEM 0x00 |
601 |
#define PCI_ADDRESS_SPACE_IO 0x01 |
602 |
#define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08 |
603 |
|
604 |
typedef struct PCIIORegion { |
605 |
uint32_t addr; /* current PCI mapping address. -1 means not mapped */
|
606 |
uint32_t size; |
607 |
uint8_t type; |
608 |
PCIMapIORegionFunc *map_func; |
609 |
} PCIIORegion; |
610 |
|
611 |
#define PCI_ROM_SLOT 6 |
612 |
#define PCI_NUM_REGIONS 7 |
613 |
|
614 |
#define PCI_DEVICES_MAX 64 |
615 |
|
616 |
#define PCI_VENDOR_ID 0x00 /* 16 bits */ |
617 |
#define PCI_DEVICE_ID 0x02 /* 16 bits */ |
618 |
#define PCI_COMMAND 0x04 /* 16 bits */ |
619 |
#define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */ |
620 |
#define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */ |
621 |
#define PCI_CLASS_DEVICE 0x0a /* Device class */ |
622 |
#define PCI_INTERRUPT_LINE 0x3c /* 8 bits */ |
623 |
#define PCI_INTERRUPT_PIN 0x3d /* 8 bits */ |
624 |
#define PCI_MIN_GNT 0x3e /* 8 bits */ |
625 |
#define PCI_MAX_LAT 0x3f /* 8 bits */ |
626 |
|
627 |
struct PCIDevice {
|
628 |
/* PCI config space */
|
629 |
uint8_t config[256];
|
630 |
|
631 |
/* the following fields are read only */
|
632 |
PCIBus *bus; |
633 |
int devfn;
|
634 |
char name[64]; |
635 |
PCIIORegion io_regions[PCI_NUM_REGIONS]; |
636 |
|
637 |
/* do not access the following fields */
|
638 |
PCIConfigReadFunc *config_read; |
639 |
PCIConfigWriteFunc *config_write; |
640 |
/* ??? This is a PC-specific hack, and should be removed. */
|
641 |
int irq_index;
|
642 |
}; |
643 |
|
644 |
PCIDevice *pci_register_device(PCIBus *bus, const char *name, |
645 |
int instance_size, int devfn, |
646 |
PCIConfigReadFunc *config_read, |
647 |
PCIConfigWriteFunc *config_write); |
648 |
|
649 |
void pci_register_io_region(PCIDevice *pci_dev, int region_num, |
650 |
uint32_t size, int type,
|
651 |
PCIMapIORegionFunc *map_func); |
652 |
|
653 |
void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level); |
654 |
|
655 |
uint32_t pci_default_read_config(PCIDevice *d, |
656 |
uint32_t address, int len);
|
657 |
void pci_default_write_config(PCIDevice *d,
|
658 |
uint32_t address, uint32_t val, int len);
|
659 |
void generic_pci_save(QEMUFile* f, void *opaque); |
660 |
int generic_pci_load(QEMUFile* f, void *opaque, int version_id); |
661 |
|
662 |
typedef void (*pci_set_irq_fn)(PCIDevice *pci_dev, void *pic, |
663 |
int irq_num, int level); |
664 |
PCIBus *pci_register_bus(pci_set_irq_fn set_irq, void *pic, int devfn_min); |
665 |
|
666 |
void pci_nic_init(PCIBus *bus, NICInfo *nd);
|
667 |
void pci_data_write(void *opaque, uint32_t addr, uint32_t val, int len); |
668 |
uint32_t pci_data_read(void *opaque, uint32_t addr, int len); |
669 |
int pci_bus_num(PCIBus *s);
|
670 |
void pci_for_each_device(void (*fn)(PCIDevice *d)); |
671 |
|
672 |
void pci_info(void); |
673 |
|
674 |
/* prep_pci.c */
|
675 |
PCIBus *pci_prep_init(void);
|
676 |
|
677 |
/* grackle_pci.c */
|
678 |
PCIBus *pci_grackle_init(uint32_t base, void *pic);
|
679 |
|
680 |
/* unin_pci.c */
|
681 |
PCIBus *pci_pmac_init(void *pic);
|
682 |
|
683 |
/* apb_pci.c */
|
684 |
PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base, |
685 |
void *pic);
|
686 |
|
687 |
PCIBus *pci_vpb_init(void *pic);
|
688 |
|
689 |
/* piix_pci.c */
|
690 |
PCIBus *i440fx_init(void);
|
691 |
int piix3_init(PCIBus *bus);
|
692 |
void pci_bios_init(void); |
693 |
|
694 |
/* openpic.c */
|
695 |
typedef struct openpic_t openpic_t; |
696 |
void openpic_set_irq(void *opaque, int n_IRQ, int level); |
697 |
openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, |
698 |
CPUState **envp); |
699 |
|
700 |
/* heathrow_pic.c */
|
701 |
typedef struct HeathrowPICS HeathrowPICS; |
702 |
void heathrow_pic_set_irq(void *opaque, int num, int level); |
703 |
HeathrowPICS *heathrow_pic_init(int *pmem_index);
|
704 |
|
705 |
#ifdef HAS_AUDIO
|
706 |
struct soundhw {
|
707 |
const char *name; |
708 |
const char *descr; |
709 |
int enabled;
|
710 |
int isa;
|
711 |
union {
|
712 |
int (*init_isa) (AudioState *s);
|
713 |
int (*init_pci) (PCIBus *bus, AudioState *s);
|
714 |
} init; |
715 |
}; |
716 |
|
717 |
extern struct soundhw soundhw[]; |
718 |
#endif
|
719 |
|
720 |
/* vga.c */
|
721 |
|
722 |
#define VGA_RAM_SIZE (8192 * 1024) |
723 |
|
724 |
struct DisplayState {
|
725 |
uint8_t *data; |
726 |
int linesize;
|
727 |
int depth;
|
728 |
int bgr; /* BGR color order instead of RGB. Only valid for depth == 32 */ |
729 |
int width;
|
730 |
int height;
|
731 |
void *opaque;
|
732 |
|
733 |
void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h); |
734 |
void (*dpy_resize)(struct DisplayState *s, int w, int h); |
735 |
void (*dpy_refresh)(struct DisplayState *s); |
736 |
void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h); |
737 |
}; |
738 |
|
739 |
static inline void dpy_update(DisplayState *s, int x, int y, int w, int h) |
740 |
{ |
741 |
s->dpy_update(s, x, y, w, h); |
742 |
} |
743 |
|
744 |
static inline void dpy_resize(DisplayState *s, int w, int h) |
745 |
{ |
746 |
s->dpy_resize(s, w, h); |
747 |
} |
748 |
|
749 |
int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
|
750 |
unsigned long vga_ram_offset, int vga_ram_size, |
751 |
unsigned long vga_bios_offset, int vga_bios_size); |
752 |
|
753 |
/* cirrus_vga.c */
|
754 |
void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
|
755 |
unsigned long vga_ram_offset, int vga_ram_size); |
756 |
void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
|
757 |
unsigned long vga_ram_offset, int vga_ram_size); |
758 |
|
759 |
/* sdl.c */
|
760 |
void sdl_display_init(DisplayState *ds, int full_screen); |
761 |
|
762 |
/* cocoa.m */
|
763 |
void cocoa_display_init(DisplayState *ds, int full_screen); |
764 |
|
765 |
/* vnc.c */
|
766 |
void vnc_display_init(DisplayState *ds, int display); |
767 |
|
768 |
/* ide.c */
|
769 |
#define MAX_DISKS 4 |
770 |
|
771 |
extern BlockDriverState *bs_table[MAX_DISKS];
|
772 |
|
773 |
void isa_ide_init(int iobase, int iobase2, int irq, |
774 |
BlockDriverState *hd0, BlockDriverState *hd1); |
775 |
void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
|
776 |
int secondary_ide_enabled);
|
777 |
void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn); |
778 |
int pmac_ide_init (BlockDriverState **hd_table,
|
779 |
SetIRQFunc *set_irq, void *irq_opaque, int irq); |
780 |
|
781 |
/* cdrom.c */
|
782 |
int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track); |
783 |
int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num); |
784 |
|
785 |
/* es1370.c */
|
786 |
int es1370_init (PCIBus *bus, AudioState *s);
|
787 |
|
788 |
/* sb16.c */
|
789 |
int SB16_init (AudioState *s);
|
790 |
|
791 |
/* adlib.c */
|
792 |
int Adlib_init (AudioState *s);
|
793 |
|
794 |
/* gus.c */
|
795 |
int GUS_init (AudioState *s);
|
796 |
|
797 |
/* dma.c */
|
798 |
typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size); |
799 |
int DMA_get_channel_mode (int nchan); |
800 |
int DMA_read_memory (int nchan, void *buf, int pos, int size); |
801 |
int DMA_write_memory (int nchan, void *buf, int pos, int size); |
802 |
void DMA_hold_DREQ (int nchan); |
803 |
void DMA_release_DREQ (int nchan); |
804 |
void DMA_schedule(int nchan); |
805 |
void DMA_run (void); |
806 |
void DMA_init (int high_page_enable); |
807 |
void DMA_register_channel (int nchan, |
808 |
DMA_transfer_handler transfer_handler, |
809 |
void *opaque);
|
810 |
/* fdc.c */
|
811 |
#define MAX_FD 2 |
812 |
extern BlockDriverState *fd_table[MAX_FD];
|
813 |
|
814 |
typedef struct fdctrl_t fdctrl_t; |
815 |
|
816 |
fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, |
817 |
uint32_t io_base, |
818 |
BlockDriverState **fds); |
819 |
int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num); |
820 |
|
821 |
/* ne2000.c */
|
822 |
|
823 |
void isa_ne2000_init(int base, int irq, NICInfo *nd); |
824 |
void pci_ne2000_init(PCIBus *bus, NICInfo *nd);
|
825 |
|
826 |
/* rtl8139.c */
|
827 |
|
828 |
void pci_rtl8139_init(PCIBus *bus, NICInfo *nd);
|
829 |
|
830 |
/* pckbd.c */
|
831 |
|
832 |
void kbd_init(void); |
833 |
|
834 |
/* mc146818rtc.c */
|
835 |
|
836 |
typedef struct RTCState RTCState; |
837 |
|
838 |
RTCState *rtc_init(int base, int irq); |
839 |
void rtc_set_memory(RTCState *s, int addr, int val); |
840 |
void rtc_set_date(RTCState *s, const struct tm *tm); |
841 |
|
842 |
/* serial.c */
|
843 |
|
844 |
typedef struct SerialState SerialState; |
845 |
SerialState *serial_init(SetIRQFunc *set_irq, void *opaque,
|
846 |
int base, int irq, CharDriverState *chr); |
847 |
SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque,
|
848 |
target_ulong base, int it_shift,
|
849 |
int irq, CharDriverState *chr);
|
850 |
|
851 |
/* parallel.c */
|
852 |
|
853 |
typedef struct ParallelState ParallelState; |
854 |
ParallelState *parallel_init(int base, int irq, CharDriverState *chr); |
855 |
|
856 |
/* i8259.c */
|
857 |
|
858 |
typedef struct PicState2 PicState2; |
859 |
extern PicState2 *isa_pic;
|
860 |
void pic_set_irq(int irq, int level); |
861 |
void pic_set_irq_new(void *opaque, int irq, int level); |
862 |
PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque);
|
863 |
void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,
|
864 |
void *alt_irq_opaque);
|
865 |
int pic_read_irq(PicState2 *s);
|
866 |
void pic_update_irq(PicState2 *s);
|
867 |
uint32_t pic_intack_read(PicState2 *s); |
868 |
void pic_info(void); |
869 |
void irq_info(void); |
870 |
|
871 |
/* APIC */
|
872 |
typedef struct IOAPICState IOAPICState; |
873 |
|
874 |
int apic_init(CPUState *env);
|
875 |
int apic_get_interrupt(CPUState *env);
|
876 |
IOAPICState *ioapic_init(void);
|
877 |
void ioapic_set_irq(void *opaque, int vector, int level); |
878 |
|
879 |
/* i8254.c */
|
880 |
|
881 |
#define PIT_FREQ 1193182 |
882 |
|
883 |
typedef struct PITState PITState; |
884 |
|
885 |
PITState *pit_init(int base, int irq); |
886 |
void pit_set_gate(PITState *pit, int channel, int val); |
887 |
int pit_get_gate(PITState *pit, int channel); |
888 |
int pit_get_initial_count(PITState *pit, int channel); |
889 |
int pit_get_mode(PITState *pit, int channel); |
890 |
int pit_get_out(PITState *pit, int channel, int64_t current_time); |
891 |
|
892 |
/* pcspk.c */
|
893 |
void pcspk_init(PITState *);
|
894 |
int pcspk_audio_init(AudioState *);
|
895 |
|
896 |
/* acpi.c */
|
897 |
extern int acpi_enabled; |
898 |
void piix4_pm_init(PCIBus *bus, int devfn); |
899 |
void acpi_bios_init(void); |
900 |
|
901 |
/* pc.c */
|
902 |
extern QEMUMachine pc_machine;
|
903 |
extern QEMUMachine isapc_machine;
|
904 |
extern int fd_bootchk; |
905 |
|
906 |
void ioport_set_a20(int enable); |
907 |
int ioport_get_a20(void); |
908 |
|
909 |
/* ppc.c */
|
910 |
extern QEMUMachine prep_machine;
|
911 |
extern QEMUMachine core99_machine;
|
912 |
extern QEMUMachine heathrow_machine;
|
913 |
|
914 |
/* mips_r4k.c */
|
915 |
extern QEMUMachine mips_machine;
|
916 |
|
917 |
/* shix.c */
|
918 |
extern QEMUMachine shix_machine;
|
919 |
|
920 |
#ifdef TARGET_PPC
|
921 |
ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq); |
922 |
#endif
|
923 |
void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val); |
924 |
|
925 |
extern CPUWriteMemoryFunc *PPC_io_write[];
|
926 |
extern CPUReadMemoryFunc *PPC_io_read[];
|
927 |
void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val); |
928 |
|
929 |
/* sun4m.c */
|
930 |
extern QEMUMachine sun4m_machine;
|
931 |
uint32_t iommu_translate(uint32_t addr); |
932 |
void pic_set_irq_cpu(int irq, int level, unsigned int cpu); |
933 |
|
934 |
/* iommu.c */
|
935 |
void *iommu_init(uint32_t addr);
|
936 |
uint32_t iommu_translate_local(void *opaque, uint32_t addr);
|
937 |
|
938 |
/* lance.c */
|
939 |
void lance_init(NICInfo *nd, int irq, uint32_t leaddr, uint32_t ledaddr); |
940 |
|
941 |
/* tcx.c */
|
942 |
void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
|
943 |
unsigned long vram_offset, int vram_size, int width, int height); |
944 |
|
945 |
/* slavio_intctl.c */
|
946 |
void *slavio_intctl_init();
|
947 |
void slavio_intctl_set_cpu(void *opaque, unsigned int cpu, CPUState *env); |
948 |
void slavio_pic_info(void *opaque); |
949 |
void slavio_irq_info(void *opaque); |
950 |
void slavio_pic_set_irq(void *opaque, int irq, int level); |
951 |
void slavio_pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu); |
952 |
|
953 |
/* loader.c */
|
954 |
int get_image_size(const char *filename); |
955 |
int load_image(const char *filename, uint8_t *addr); |
956 |
int load_elf(const char *filename, int64_t virt_to_phys_addend, uint64_t *pentry); |
957 |
int load_aout(const char *filename, uint8_t *addr); |
958 |
|
959 |
/* slavio_timer.c */
|
960 |
void slavio_timer_init(uint32_t addr, int irq, int mode, unsigned int cpu); |
961 |
|
962 |
/* slavio_serial.c */
|
963 |
SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2); |
964 |
void slavio_serial_ms_kbd_init(int base, int irq); |
965 |
|
966 |
/* slavio_misc.c */
|
967 |
void *slavio_misc_init(uint32_t base, int irq); |
968 |
void slavio_set_power_fail(void *opaque, int power_failing); |
969 |
|
970 |
/* esp.c */
|
971 |
void esp_init(BlockDriverState **bd, int irq, uint32_t espaddr, uint32_t espdaddr); |
972 |
|
973 |
/* sun4u.c */
|
974 |
extern QEMUMachine sun4u_machine;
|
975 |
|
976 |
/* NVRAM helpers */
|
977 |
#include "hw/m48t59.h" |
978 |
|
979 |
void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
|
980 |
uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr); |
981 |
void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
|
982 |
uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr); |
983 |
void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
|
984 |
uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr); |
985 |
void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
|
986 |
const unsigned char *str, uint32_t max); |
987 |
int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max); |
988 |
void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
|
989 |
uint32_t start, uint32_t count); |
990 |
int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
|
991 |
const unsigned char *arch, |
992 |
uint32_t RAM_size, int boot_device,
|
993 |
uint32_t kernel_image, uint32_t kernel_size, |
994 |
const char *cmdline, |
995 |
uint32_t initrd_image, uint32_t initrd_size, |
996 |
uint32_t NVRAM_image, |
997 |
int width, int height, int depth); |
998 |
|
999 |
/* adb.c */
|
1000 |
|
1001 |
#define MAX_ADB_DEVICES 16 |
1002 |
|
1003 |
#define ADB_MAX_OUT_LEN 16 |
1004 |
|
1005 |
typedef struct ADBDevice ADBDevice; |
1006 |
|
1007 |
/* buf = NULL means polling */
|
1008 |
typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out, |
1009 |
const uint8_t *buf, int len); |
1010 |
typedef int ADBDeviceReset(ADBDevice *d); |
1011 |
|
1012 |
struct ADBDevice {
|
1013 |
struct ADBBusState *bus;
|
1014 |
int devaddr;
|
1015 |
int handler;
|
1016 |
ADBDeviceRequest *devreq; |
1017 |
ADBDeviceReset *devreset; |
1018 |
void *opaque;
|
1019 |
}; |
1020 |
|
1021 |
typedef struct ADBBusState { |
1022 |
ADBDevice devices[MAX_ADB_DEVICES]; |
1023 |
int nb_devices;
|
1024 |
int poll_index;
|
1025 |
} ADBBusState; |
1026 |
|
1027 |
int adb_request(ADBBusState *s, uint8_t *buf_out,
|
1028 |
const uint8_t *buf, int len); |
1029 |
int adb_poll(ADBBusState *s, uint8_t *buf_out);
|
1030 |
|
1031 |
ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
|
1032 |
ADBDeviceRequest *devreq, |
1033 |
ADBDeviceReset *devreset, |
1034 |
void *opaque);
|
1035 |
void adb_kbd_init(ADBBusState *bus);
|
1036 |
void adb_mouse_init(ADBBusState *bus);
|
1037 |
|
1038 |
/* cuda.c */
|
1039 |
|
1040 |
extern ADBBusState adb_bus;
|
1041 |
int cuda_init(SetIRQFunc *set_irq, void *irq_opaque, int irq); |
1042 |
|
1043 |
#include "hw/usb.h" |
1044 |
|
1045 |
/* usb ports of the VM */
|
1046 |
|
1047 |
void qemu_register_usb_port(USBPort *port, void *opaque, int index, |
1048 |
usb_attachfn attach); |
1049 |
|
1050 |
#define VM_USB_HUB_SIZE 8 |
1051 |
|
1052 |
void do_usb_add(const char *devname); |
1053 |
void do_usb_del(const char *devname); |
1054 |
void usb_info(void); |
1055 |
|
1056 |
/* scsi-disk.c */
|
1057 |
typedef struct SCSIDevice SCSIDevice; |
1058 |
typedef void (*scsi_completionfn)(void *, uint32_t, int); |
1059 |
|
1060 |
SCSIDevice *scsi_disk_init(BlockDriverState *bdrv, |
1061 |
scsi_completionfn completion, |
1062 |
void *opaque);
|
1063 |
void scsi_disk_destroy(SCSIDevice *s);
|
1064 |
|
1065 |
int32_t scsi_send_command(SCSIDevice *s, uint32_t tag, uint8_t *buf, int lun);
|
1066 |
int scsi_read_data(SCSIDevice *s, uint8_t *data, uint32_t len);
|
1067 |
int scsi_write_data(SCSIDevice *s, uint8_t *data, uint32_t len);
|
1068 |
|
1069 |
/* lsi53c895a.c */
|
1070 |
void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id); |
1071 |
void *lsi_scsi_init(PCIBus *bus, int devfn); |
1072 |
|
1073 |
/* integratorcp.c */
|
1074 |
extern QEMUMachine integratorcp926_machine;
|
1075 |
extern QEMUMachine integratorcp1026_machine;
|
1076 |
|
1077 |
/* versatilepb.c */
|
1078 |
extern QEMUMachine versatilepb_machine;
|
1079 |
extern QEMUMachine versatileab_machine;
|
1080 |
|
1081 |
/* ps2.c */
|
1082 |
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg); |
1083 |
void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg); |
1084 |
void ps2_write_mouse(void *, int val); |
1085 |
void ps2_write_keyboard(void *, int val); |
1086 |
uint32_t ps2_read_data(void *);
|
1087 |
void ps2_queue(void *, int b); |
1088 |
void ps2_keyboard_set_translation(void *opaque, int mode); |
1089 |
|
1090 |
/* smc91c111.c */
|
1091 |
void smc91c111_init(NICInfo *, uint32_t, void *, int); |
1092 |
|
1093 |
/* pl110.c */
|
1094 |
void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int); |
1095 |
|
1096 |
/* pl011.c */
|
1097 |
void pl011_init(uint32_t base, void *pic, int irq, CharDriverState *chr); |
1098 |
|
1099 |
/* pl050.c */
|
1100 |
void pl050_init(uint32_t base, void *pic, int irq, int is_mouse); |
1101 |
|
1102 |
/* pl080.c */
|
1103 |
void *pl080_init(uint32_t base, void *pic, int irq); |
1104 |
|
1105 |
/* pl190.c */
|
1106 |
void *pl190_init(uint32_t base, void *parent, int irq, int fiq); |
1107 |
|
1108 |
/* arm-timer.c */
|
1109 |
void sp804_init(uint32_t base, void *pic, int irq); |
1110 |
void icp_pit_init(uint32_t base, void *pic, int irq); |
1111 |
|
1112 |
/* arm_boot.c */
|
1113 |
|
1114 |
void arm_load_kernel(int ram_size, const char *kernel_filename, |
1115 |
const char *kernel_cmdline, const char *initrd_filename, |
1116 |
int board_id);
|
1117 |
|
1118 |
/* sh7750.c */
|
1119 |
struct SH7750State;
|
1120 |
|
1121 |
struct SH7750State *sh7750_init(CPUState * cpu);
|
1122 |
|
1123 |
typedef struct { |
1124 |
/* The callback will be triggered if any of the designated lines change */
|
1125 |
uint16_t portamask_trigger; |
1126 |
uint16_t portbmask_trigger; |
1127 |
/* Return 0 if no action was taken */
|
1128 |
int (*port_change_cb) (uint16_t porta, uint16_t portb,
|
1129 |
uint16_t * periph_pdtra, |
1130 |
uint16_t * periph_portdira, |
1131 |
uint16_t * periph_pdtrb, |
1132 |
uint16_t * periph_portdirb); |
1133 |
} sh7750_io_device; |
1134 |
|
1135 |
int sh7750_register_io_device(struct SH7750State *s, |
1136 |
sh7750_io_device * device); |
1137 |
/* tc58128.c */
|
1138 |
int tc58128_init(struct SH7750State *s, char *zone1, char *zone2); |
1139 |
|
1140 |
#endif /* defined(QEMU_TOOL) */ |
1141 |
|
1142 |
/* monitor.c */
|
1143 |
void monitor_init(CharDriverState *hd, int show_banner); |
1144 |
void term_puts(const char *str); |
1145 |
void term_vprintf(const char *fmt, va_list ap); |
1146 |
void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); |
1147 |
void term_flush(void); |
1148 |
void term_print_help(void); |
1149 |
void monitor_readline(const char *prompt, int is_password, |
1150 |
char *buf, int buf_size); |
1151 |
|
1152 |
/* readline.c */
|
1153 |
typedef void ReadLineFunc(void *opaque, const char *str); |
1154 |
|
1155 |
extern int completion_index; |
1156 |
void add_completion(const char *str); |
1157 |
void readline_handle_byte(int ch); |
1158 |
void readline_find_completion(const char *cmdline); |
1159 |
const char *readline_get_history(unsigned int index); |
1160 |
void readline_start(const char *prompt, int is_password, |
1161 |
ReadLineFunc *readline_func, void *opaque);
|
1162 |
|
1163 |
void kqemu_record_dump(void); |
1164 |
|
1165 |
#endif /* VL_H */ |