2 * QEMU System Emulator header
4 * Copyright (c) 2003 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
27 /* we put basic includes here to avoid repeating them in device drivers */
49 #define ENOMEDIUM ENODEV
55 #define lseek _lseeki64
57 extern int qemu_ftruncate64(int, int64_t);
58 #define ftruncate qemu_ftruncate64
61 static inline char *realpath(const char *path
, char *resolved_path
)
63 _fullpath(resolved_path
, path
, _MAX_PATH
);
75 /* we use QEMU_TOOL in the command line tools which do not depend on
76 the target CPU type */
77 #include "config-host.h"
84 #include "audio/audio.h"
87 #endif /* !defined(QEMU_TOOL) */
90 #define xglue(x, y) x ## y
91 #define glue(x, y) xglue(x, y)
92 #define stringify(s) tostring(s)
93 #define tostring(s) #s
97 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
100 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
104 void pstrcpy(char *buf
, int buf_size
, const char *str
);
105 char *pstrcat(char *buf
, int buf_size
, const char *s
);
106 int strstart(const char *str
, const char *val
, const char **ptr
);
107 int stristart(const char *str
, const char *val
, const char **ptr
);
108 int hex2bin(char ch
);
109 char *urldecode(const char *ptr
);
112 void qemu_get_launch_info(int *argc
, char ***argv
, int *opt_daemonize
, const char **opt_incoming
);
114 uint64_t muldiv64(uint64_t a
, uint32_t b
, uint32_t c
);
116 void hw_error(const char *fmt
, ...);
118 extern const char *bios_dir
;
120 extern int vm_running
;
122 typedef struct vm_change_state_entry VMChangeStateEntry
;
123 typedef void VMChangeStateHandler(void *opaque
, int running
);
124 typedef void VMStopHandler(void *opaque
, int reason
);
126 VMChangeStateEntry
*qemu_add_vm_change_state_handler(VMChangeStateHandler
*cb
,
128 void qemu_del_vm_change_state_handler(VMChangeStateEntry
*e
);
130 int qemu_add_vm_stop_handler(VMStopHandler
*cb
, void *opaque
);
131 void qemu_del_vm_stop_handler(VMStopHandler
*cb
, void *opaque
);
134 void vm_stop(int reason
);
136 typedef void QEMUResetHandler(void *opaque
);
138 void qemu_register_reset(QEMUResetHandler
*func
, void *opaque
);
139 void qemu_system_reset(void);
140 void qemu_system_reset_request(void);
141 void qemu_system_shutdown_request(void);
142 void qemu_system_powerdown_request(void);
143 int qemu_shutdown_requested(void);
144 int qemu_reset_requested(void);
145 int qemu_powerdown_requested(void);
147 #if !defined(TARGET_SPARC)
148 // Please implement a power failure function to signal the OS
149 #define qemu_system_powerdown() do{}while(0)
151 void qemu_system_powerdown(void);
154 void main_loop_wait(int timeout
);
156 extern int64_t ram_size
;
157 extern int bios_size
;
159 extern int cirrus_vga_enabled
;
160 extern int graphic_width
;
161 extern int graphic_height
;
162 extern int graphic_depth
;
163 extern const char *keyboard_layout
;
164 extern int kqemu_allowed
;
165 extern int kvm_allowed
;
166 extern int win2k_install_hack
;
167 extern int usb_enabled
;
170 extern int semihosting_enabled
;
171 extern int autostart
;
172 extern int time_drift_fix
;
174 #define MAX_OPTION_ROMS 16
175 extern const char *option_rom
[MAX_OPTION_ROMS
];
176 extern int nb_option_roms
;
178 /* XXX: make it dynamic */
179 #if defined (TARGET_PPC) || defined (TARGET_SPARC64)
180 #define BIOS_SIZE ((512 + 32) * 1024)
181 #elif defined(TARGET_MIPS)
182 #define BIOS_SIZE (4 * 1024 * 1024)
184 #define BIOS_SIZE ((256 + 64) * 1024)
188 #define KVM_EXTRA_PAGES 3
191 /* keyboard/mouse support */
193 #define MOUSE_EVENT_LBUTTON 0x01
194 #define MOUSE_EVENT_RBUTTON 0x02
195 #define MOUSE_EVENT_MBUTTON 0x04
197 typedef void QEMUPutKBDEvent(void *opaque
, int keycode
);
198 typedef void QEMUPutMouseEvent(void *opaque
, int dx
, int dy
, int dz
, int buttons_state
);
200 typedef struct QEMUPutMouseEntry
{
201 QEMUPutMouseEvent
*qemu_put_mouse_event
;
202 void *qemu_put_mouse_event_opaque
;
203 int qemu_put_mouse_event_absolute
;
204 char *qemu_put_mouse_event_name
;
206 /* used internally by qemu for handling mice */
207 struct QEMUPutMouseEntry
*next
;
210 void qemu_add_kbd_event_handler(QEMUPutKBDEvent
*func
, void *opaque
);
211 QEMUPutMouseEntry
*qemu_add_mouse_event_handler(QEMUPutMouseEvent
*func
,
212 void *opaque
, int absolute
,
214 void qemu_remove_mouse_event_handler(QEMUPutMouseEntry
*entry
);
216 void kbd_put_keycode(int keycode
);
217 void kbd_mouse_event(int dx
, int dy
, int dz
, int buttons_state
);
218 int kbd_mouse_is_absolute(void);
220 void do_info_mice(void);
221 void do_mouse_set(int index
);
223 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
225 #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
226 #define QEMU_KEY_BACKSPACE 0x007f
227 #define QEMU_KEY_UP QEMU_KEY_ESC1('A')
228 #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
229 #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
230 #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
231 #define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
232 #define QEMU_KEY_END QEMU_KEY_ESC1(4)
233 #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
234 #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
235 #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
237 #define QEMU_KEY_CTRL_UP 0xe400
238 #define QEMU_KEY_CTRL_DOWN 0xe401
239 #define QEMU_KEY_CTRL_LEFT 0xe402
240 #define QEMU_KEY_CTRL_RIGHT 0xe403
241 #define QEMU_KEY_CTRL_HOME 0xe404
242 #define QEMU_KEY_CTRL_END 0xe405
243 #define QEMU_KEY_CTRL_PAGEUP 0xe406
244 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407
246 void kbd_put_keysym(int keysym
);
248 /* async I/O support */
250 typedef void IOReadHandler(void *opaque
, const uint8_t *buf
, int size
);
251 typedef int IOCanRWHandler(void *opaque
);
252 typedef void IOHandler(void *opaque
);
254 int qemu_set_fd_handler2(int fd
,
255 IOCanRWHandler
*fd_read_poll
,
259 int qemu_set_fd_handler(int fd
,
264 /* Polling handling */
266 /* return TRUE if no sleep should be done afterwards */
267 typedef int PollingFunc(void *opaque
);
269 int qemu_add_polling_cb(PollingFunc
*func
, void *opaque
);
270 void qemu_del_polling_cb(PollingFunc
*func
, void *opaque
);
273 /* Wait objects handling */
274 typedef void WaitObjectFunc(void *opaque
);
276 int qemu_add_wait_object(HANDLE handle
, WaitObjectFunc
*func
, void *opaque
);
277 void qemu_del_wait_object(HANDLE handle
, WaitObjectFunc
*func
, void *opaque
);
280 typedef struct QEMUBH QEMUBH
;
282 /* character device */
284 #define CHR_EVENT_BREAK 0 /* serial break char */
285 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
286 #define CHR_EVENT_RESET 2 /* new connection established */
289 #define CHR_IOCTL_SERIAL_SET_PARAMS 1
295 } QEMUSerialSetParams
;
297 #define CHR_IOCTL_SERIAL_SET_BREAK 2
299 #define CHR_IOCTL_PP_READ_DATA 3
300 #define CHR_IOCTL_PP_WRITE_DATA 4
301 #define CHR_IOCTL_PP_READ_CONTROL 5
302 #define CHR_IOCTL_PP_WRITE_CONTROL 6
303 #define CHR_IOCTL_PP_READ_STATUS 7
305 typedef void IOEventHandler(void *opaque
, int event
);
307 typedef struct CharDriverState
{
308 int (*chr_write
)(struct CharDriverState
*s
, const uint8_t *buf
, int len
);
309 void (*chr_update_read_handler
)(struct CharDriverState
*s
);
310 int (*chr_ioctl
)(struct CharDriverState
*s
, int cmd
, void *arg
);
311 IOEventHandler
*chr_event
;
312 IOCanRWHandler
*chr_can_read
;
313 IOReadHandler
*chr_read
;
314 void *handler_opaque
;
315 void (*chr_send_event
)(struct CharDriverState
*chr
, int event
);
316 void (*chr_close
)(struct CharDriverState
*chr
);
321 CharDriverState
*qemu_chr_open(const char *filename
);
322 void qemu_chr_printf(CharDriverState
*s
, const char *fmt
, ...);
323 int qemu_chr_write(CharDriverState
*s
, const uint8_t *buf
, int len
);
324 void qemu_chr_send_event(CharDriverState
*s
, int event
);
325 void qemu_chr_add_handlers(CharDriverState
*s
,
326 IOCanRWHandler
*fd_can_read
,
327 IOReadHandler
*fd_read
,
328 IOEventHandler
*fd_event
,
330 int qemu_chr_ioctl(CharDriverState
*s
, int cmd
, void *arg
);
331 void qemu_chr_reset(CharDriverState
*s
);
332 int qemu_chr_can_read(CharDriverState
*s
);
333 void qemu_chr_read(CharDriverState
*s
, uint8_t *buf
, int len
);
337 typedef struct DisplayState DisplayState
;
338 typedef struct TextConsole TextConsole
;
340 typedef void (*vga_hw_update_ptr
)(void *);
341 typedef void (*vga_hw_invalidate_ptr
)(void *);
342 typedef void (*vga_hw_screen_dump_ptr
)(void *, const char *);
344 TextConsole
*graphic_console_init(DisplayState
*ds
, vga_hw_update_ptr update
,
345 vga_hw_invalidate_ptr invalidate
,
346 vga_hw_screen_dump_ptr screen_dump
,
348 void vga_hw_update(void);
349 void vga_hw_invalidate(void);
350 void vga_hw_screen_dump(const char *filename
);
352 int is_graphic_console(void);
353 CharDriverState
*text_console_init(DisplayState
*ds
);
354 void console_select(unsigned int index
);
356 /* vmchannel devices */
358 #define MAX_VMCHANNEL_DEVICES 4
362 #define MAX_SERIAL_PORTS 4
364 extern CharDriverState
*serial_hds
[MAX_SERIAL_PORTS
];
368 #define MAX_PARALLEL_PORTS 3
370 extern CharDriverState
*parallel_hds
[MAX_PARALLEL_PORTS
];
374 typedef struct VLANClientState VLANClientState
;
376 struct VLANClientState
{
377 IOReadHandler
*fd_read
;
378 /* Packets may still be sent if this returns zero. It's used to
379 rate-limit the slirp code. */
380 IOCanRWHandler
*fd_can_read
;
382 struct VLANClientState
*next
;
383 struct VLANState
*vlan
;
387 typedef struct VLANState
{
389 VLANClientState
*first_client
;
390 struct VLANState
*next
;
393 VLANState
*qemu_find_vlan(int id
);
394 VLANClientState
*qemu_new_vlan_client(VLANState
*vlan
,
395 IOReadHandler
*fd_read
,
396 IOCanRWHandler
*fd_can_read
,
398 int qemu_can_send_packet(VLANClientState
*vc
);
399 void qemu_send_packet(VLANClientState
*vc
, const uint8_t *buf
, int size
);
400 void qemu_handler_true(void *opaque
);
402 void do_info_network(void);
405 int tap_win32_init(VLANState
*vlan
, const char *ifname
);
411 typedef struct NICInfo
{
418 extern NICInfo nd_table
[MAX_NICS
];
422 typedef struct QEMUClock QEMUClock
;
423 typedef struct QEMUTimer QEMUTimer
;
424 typedef void QEMUTimerCB(void *opaque
);
426 /* The real time clock should be used only for stuff which does not
427 change the virtual machine state, as it is run even if the virtual
428 machine is stopped. The real time clock has a frequency of 1000
430 extern QEMUClock
*rt_clock
;
432 /* The virtual clock is only run during the emulation. It is stopped
433 when the virtual machine is stopped. Virtual timers use a high
434 precision clock, usually cpu cycles (use ticks_per_sec). */
435 extern QEMUClock
*vm_clock
;
437 int64_t qemu_get_clock(QEMUClock
*clock
);
439 QEMUTimer
*qemu_new_timer(QEMUClock
*clock
, QEMUTimerCB
*cb
, void *opaque
);
440 void qemu_free_timer(QEMUTimer
*ts
);
441 void qemu_del_timer(QEMUTimer
*ts
);
442 void qemu_mod_timer(QEMUTimer
*ts
, int64_t expire_time
);
443 int qemu_timer_pending(QEMUTimer
*ts
);
445 extern int64_t ticks_per_sec
;
446 extern int pit_min_timer_count
;
448 int64_t cpu_get_ticks(void);
449 void cpu_enable_ticks(void);
450 void cpu_disable_ticks(void);
454 typedef struct QEMUFile QEMUFile
;
456 typedef void (QEMUFilePutBufferFunc
)(void *opaque
, const uint8_t *buf
, int64_t pos
, int size
);
457 typedef int (QEMUFileGetBufferFunc
)(void *opaque
, uint8_t *buf
, int64_t pos
, int size
);
458 typedef void (QEMUFileCloseFunc
)(void *opaque
);
460 QEMUFile
*qemu_fopen(void *opaque
, QEMUFilePutBufferFunc
*put_buffer
,
461 QEMUFileGetBufferFunc
*get_buffer
, QEMUFileCloseFunc
*close
);
462 QEMUFile
*qemu_fopen_file(const char *filename
, const char *mode
);
463 QEMUFile
*qemu_fopen_fd(int fd
);
464 void qemu_fflush(QEMUFile
*f
);
465 void qemu_fclose(QEMUFile
*f
);
466 void qemu_put_buffer(QEMUFile
*f
, const uint8_t *buf
, int size
);
467 void qemu_put_byte(QEMUFile
*f
, int v
);
468 void qemu_put_be16(QEMUFile
*f
, unsigned int v
);
469 void qemu_put_be32(QEMUFile
*f
, unsigned int v
);
470 void qemu_put_be64(QEMUFile
*f
, uint64_t v
);
471 int qemu_get_buffer(QEMUFile
*f
, uint8_t *buf
, int size
);
472 int qemu_get_byte(QEMUFile
*f
);
473 unsigned int qemu_get_be16(QEMUFile
*f
);
474 unsigned int qemu_get_be32(QEMUFile
*f
);
475 uint64_t qemu_get_be64(QEMUFile
*f
);
477 static inline void qemu_put_be64s(QEMUFile
*f
, const uint64_t *pv
)
479 qemu_put_be64(f
, *pv
);
482 static inline void qemu_put_be32s(QEMUFile
*f
, const uint32_t *pv
)
484 qemu_put_be32(f
, *pv
);
487 static inline void qemu_put_be16s(QEMUFile
*f
, const uint16_t *pv
)
489 qemu_put_be16(f
, *pv
);
492 static inline void qemu_put_8s(QEMUFile
*f
, const uint8_t *pv
)
494 qemu_put_byte(f
, *pv
);
497 static inline void qemu_get_be64s(QEMUFile
*f
, uint64_t *pv
)
499 *pv
= qemu_get_be64(f
);
502 static inline void qemu_get_be32s(QEMUFile
*f
, uint32_t *pv
)
504 *pv
= qemu_get_be32(f
);
507 static inline void qemu_get_be16s(QEMUFile
*f
, uint16_t *pv
)
509 *pv
= qemu_get_be16(f
);
512 static inline void qemu_get_8s(QEMUFile
*f
, uint8_t *pv
)
514 *pv
= qemu_get_byte(f
);
517 #if TARGET_LONG_BITS == 64
518 #define qemu_put_betl qemu_put_be64
519 #define qemu_get_betl qemu_get_be64
520 #define qemu_put_betls qemu_put_be64s
521 #define qemu_get_betls qemu_get_be64s
523 #define qemu_put_betl qemu_put_be32
524 #define qemu_get_betl qemu_get_be32
525 #define qemu_put_betls qemu_put_be32s
526 #define qemu_get_betls qemu_get_be32s
529 int64_t qemu_ftell(QEMUFile
*f
);
530 int64_t qemu_fseek(QEMUFile
*f
, int64_t pos
, int whence
);
532 typedef void SaveStateHandler(QEMUFile
*f
, void *opaque
);
533 typedef int LoadStateHandler(QEMUFile
*f
, void *opaque
, int version_id
);
535 int register_savevm(const char *idstr
,
538 SaveStateHandler
*save_state
,
539 LoadStateHandler
*load_state
,
541 void qemu_get_timer(QEMUFile
*f
, QEMUTimer
*ts
);
542 void qemu_put_timer(QEMUFile
*f
, QEMUTimer
*ts
);
544 void cpu_save(QEMUFile
*f
, void *opaque
);
545 int cpu_load(QEMUFile
*f
, void *opaque
, int version_id
);
547 void do_savevm(const char *name
);
548 void do_loadvm(const char *name
);
549 void do_delvm(const char *name
);
550 void do_info_snapshots(void);
552 int qemu_live_savevm_state(QEMUFile
*f
);
553 int qemu_live_loadvm_state(QEMUFile
*f
);
556 typedef void QEMUBHFunc(void *opaque
);
558 QEMUBH
*qemu_bh_new(QEMUBHFunc
*cb
, void *opaque
);
559 void qemu_bh_schedule(QEMUBH
*bh
);
560 void qemu_bh_cancel(QEMUBH
*bh
);
561 void qemu_bh_delete(QEMUBH
*bh
);
562 int qemu_bh_poll(void);
565 typedef struct BlockDriverState BlockDriverState
;
566 typedef struct BlockDriver BlockDriver
;
568 extern BlockDriver bdrv_raw
;
569 extern BlockDriver bdrv_host_device
;
570 extern BlockDriver bdrv_cow
;
571 extern BlockDriver bdrv_qcow
;
572 extern BlockDriver bdrv_vmdk
;
573 extern BlockDriver bdrv_cloop
;
574 extern BlockDriver bdrv_dmg
;
575 extern BlockDriver bdrv_bochs
;
576 extern BlockDriver bdrv_vpc
;
577 extern BlockDriver bdrv_vvfat
;
578 extern BlockDriver bdrv_qcow2
;
580 typedef struct BlockDriverInfo
{
581 /* in bytes, 0 if irrelevant */
583 /* offset at which the VM state can be saved (0 if not possible) */
584 int64_t vm_state_offset
;
587 typedef struct QEMUSnapshotInfo
{
588 char id_str
[128]; /* unique snapshot id */
589 /* the following fields are informative. They are not needed for
590 the consistency of the snapshot */
591 char name
[256]; /* user choosen name */
592 uint32_t vm_state_size
; /* VM state info size */
593 uint32_t date_sec
; /* UTC date of the snapshot */
595 uint64_t vm_clock_nsec
; /* VM clock relative to boot */
598 typedef struct DiskIOStatistics
{
599 uint64_t read_byte_counter
;
600 uint64_t write_byte_counter
;
603 #define BDRV_O_RDONLY 0x0000
604 #define BDRV_O_RDWR 0x0002
605 #define BDRV_O_ACCESS 0x0003
606 #define BDRV_O_CREAT 0x0004 /* create an empty file */
607 #define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */
608 #define BDRV_O_FILE 0x0010 /* open as a raw file (do not try to
609 use a disk image format on top of
613 void bdrv_init(void);
614 BlockDriver
*bdrv_find_format(const char *format_name
);
615 int bdrv_create(BlockDriver
*drv
,
616 const char *filename
, int64_t size_in_sectors
,
617 const char *backing_file
, int flags
);
618 BlockDriverState
*bdrv_new(const char *device_name
);
619 void bdrv_delete(BlockDriverState
*bs
);
620 int bdrv_file_open(BlockDriverState
**pbs
, const char *filename
, int flags
);
621 int bdrv_open(BlockDriverState
*bs
, const char *filename
, int flags
);
622 int bdrv_open2(BlockDriverState
*bs
, const char *filename
, int flags
,
624 void bdrv_close(BlockDriverState
*bs
);
625 int bdrv_read(BlockDriverState
*bs
, int64_t sector_num
,
626 uint8_t *buf
, int nb_sectors
);
627 int bdrv_write(BlockDriverState
*bs
, int64_t sector_num
,
628 const uint8_t *buf
, int nb_sectors
);
629 int bdrv_pread(BlockDriverState
*bs
, int64_t offset
,
630 void *buf
, int count
);
631 int bdrv_pwrite(BlockDriverState
*bs
, int64_t offset
,
632 const void *buf
, int count
);
633 int bdrv_truncate(BlockDriverState
*bs
, int64_t offset
);
634 int64_t bdrv_getlength(BlockDriverState
*bs
);
635 void bdrv_get_geometry(BlockDriverState
*bs
, int64_t *nb_sectors_ptr
);
636 int bdrv_commit(BlockDriverState
*bs
);
637 void bdrv_set_boot_sector(BlockDriverState
*bs
, const uint8_t *data
, int size
);
638 void bdrv_flush_all(void);
639 /* async block I/O */
640 typedef struct BlockDriverAIOCB BlockDriverAIOCB
;
641 typedef void BlockDriverCompletionFunc(void *opaque
, int ret
);
643 BlockDriverAIOCB
*bdrv_aio_read(BlockDriverState
*bs
, int64_t sector_num
,
644 uint8_t *buf
, int nb_sectors
,
645 BlockDriverCompletionFunc
*cb
, void *opaque
);
646 BlockDriverAIOCB
*bdrv_aio_write(BlockDriverState
*bs
, int64_t sector_num
,
647 const uint8_t *buf
, int nb_sectors
,
648 BlockDriverCompletionFunc
*cb
, void *opaque
);
649 void bdrv_aio_cancel(BlockDriverAIOCB
*acb
);
651 void qemu_aio_init(void);
652 void qemu_aio_poll(void);
653 void qemu_aio_flush(void);
654 void qemu_aio_wait_start(void);
655 void qemu_aio_wait(void);
656 void qemu_aio_wait_end(void);
658 /* Ensure contents are flushed to disk. */
659 void bdrv_flush(BlockDriverState
*bs
);
661 #define BDRV_TYPE_HD 0
662 #define BDRV_TYPE_CDROM 1
663 #define BDRV_TYPE_FLOPPY 2
664 #define BIOS_ATA_TRANSLATION_AUTO 0
665 #define BIOS_ATA_TRANSLATION_NONE 1
666 #define BIOS_ATA_TRANSLATION_LBA 2
667 #define BIOS_ATA_TRANSLATION_LARGE 3
668 #define BIOS_ATA_TRANSLATION_RECHS 4
670 void bdrv_set_geometry_hint(BlockDriverState
*bs
,
671 int cyls
, int heads
, int secs
);
672 void bdrv_set_type_hint(BlockDriverState
*bs
, int type
);
673 void bdrv_set_translation_hint(BlockDriverState
*bs
, int translation
);
674 void bdrv_get_geometry_hint(BlockDriverState
*bs
,
675 int *pcyls
, int *pheads
, int *psecs
);
676 int bdrv_get_type_hint(BlockDriverState
*bs
);
677 int bdrv_get_translation_hint(BlockDriverState
*bs
);
678 int bdrv_is_removable(BlockDriverState
*bs
);
679 int bdrv_is_read_only(BlockDriverState
*bs
);
680 int bdrv_is_inserted(BlockDriverState
*bs
);
681 int bdrv_media_changed(BlockDriverState
*bs
);
682 int bdrv_is_locked(BlockDriverState
*bs
);
683 void bdrv_set_locked(BlockDriverState
*bs
, int locked
);
684 void bdrv_eject(BlockDriverState
*bs
, int eject_flag
);
685 void bdrv_set_change_cb(BlockDriverState
*bs
,
686 void (*change_cb
)(void *opaque
), void *opaque
);
687 void bdrv_get_format(BlockDriverState
*bs
, char *buf
, int buf_size
);
688 void bdrv_info(void);
689 BlockDriverState
*bdrv_find(const char *name
);
690 void bdrv_iterate(void (*it
)(void *opaque
, const char *name
), void *opaque
);
691 int bdrv_is_encrypted(BlockDriverState
*bs
);
692 int bdrv_set_key(BlockDriverState
*bs
, const char *key
);
693 void bdrv_iterate_format(void (*it
)(void *opaque
, const char *name
),
695 const char *bdrv_get_device_name(BlockDriverState
*bs
);
696 int bdrv_write_compressed(BlockDriverState
*bs
, int64_t sector_num
,
697 const uint8_t *buf
, int nb_sectors
);
698 int bdrv_get_info(BlockDriverState
*bs
, BlockDriverInfo
*bdi
);
700 void bdrv_get_backing_filename(BlockDriverState
*bs
,
701 char *filename
, int filename_size
);
702 int bdrv_snapshot_create(BlockDriverState
*bs
,
703 QEMUSnapshotInfo
*sn_info
);
704 int bdrv_snapshot_goto(BlockDriverState
*bs
,
705 const char *snapshot_id
);
706 int bdrv_snapshot_delete(BlockDriverState
*bs
, const char *snapshot_id
);
707 int bdrv_snapshot_list(BlockDriverState
*bs
,
708 QEMUSnapshotInfo
**psn_info
);
709 char *bdrv_snapshot_dump(char *buf
, int buf_size
, QEMUSnapshotInfo
*sn
);
711 char *get_human_readable_size(char *buf
, int buf_size
, int64_t size
);
712 int path_is_absolute(const char *path
);
713 void path_combine(char *dest
, int dest_size
,
714 const char *base_path
,
715 const char *filename
);
719 typedef void QEMUMachineInitFunc(ram_addr_t ram_size
, int vga_ram_size
,
721 DisplayState
*ds
, const char **fd_filename
, int snapshot
,
722 const char *kernel_filename
, const char *kernel_cmdline
,
723 const char *initrd_filename
);
725 typedef struct QEMUMachine
{
728 QEMUMachineInitFunc
*init
;
729 struct QEMUMachine
*next
;
732 int qemu_register_machine(QEMUMachine
*m
);
734 typedef void SetIRQFunc(void *opaque
, int irq_num
, int level
);
735 typedef void IRQRequestFunc(void *opaque
, int level
);
739 extern target_phys_addr_t isa_mem_base
;
741 typedef void (IOPortWriteFunc
)(void *opaque
, uint32_t address
, uint32_t data
);
742 typedef uint32_t (IOPortReadFunc
)(void *opaque
, uint32_t address
);
744 int register_ioport_read(int start
, int length
, int size
,
745 IOPortReadFunc
*func
, void *opaque
);
746 int register_ioport_write(int start
, int length
, int size
,
747 IOPortWriteFunc
*func
, void *opaque
);
748 void isa_unassign_ioport(int start
, int length
);
750 void isa_mmio_init(target_phys_addr_t base
, target_phys_addr_t size
);
754 extern target_phys_addr_t pci_mem_base
;
756 typedef struct PCIBus PCIBus
;
757 typedef struct PCIDevice PCIDevice
;
759 typedef void PCIConfigWriteFunc(PCIDevice
*pci_dev
,
760 uint32_t address
, uint32_t data
, int len
);
761 typedef uint32_t PCIConfigReadFunc(PCIDevice
*pci_dev
,
762 uint32_t address
, int len
);
763 typedef void PCIMapIORegionFunc(PCIDevice
*pci_dev
, int region_num
,
764 uint32_t addr
, uint32_t size
, int type
);
766 #define PCI_ADDRESS_SPACE_MEM 0x00
767 #define PCI_ADDRESS_SPACE_IO 0x01
768 #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
770 typedef struct PCIIORegion
{
771 uint32_t addr
; /* current PCI mapping address. -1 means not mapped */
774 PCIMapIORegionFunc
*map_func
;
777 #define PCI_ROM_SLOT 6
778 #define PCI_NUM_REGIONS 7
780 #define PCI_DEVICES_MAX 64
782 #define PCI_VENDOR_ID 0x00 /* 16 bits */
783 #define PCI_DEVICE_ID 0x02 /* 16 bits */
784 #define PCI_COMMAND 0x04 /* 16 bits */
785 #define PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
786 #define PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
787 #define PCI_CLASS_DEVICE 0x0a /* Device class */
788 #define PCI_INTERRUPT_LINE 0x3c /* 8 bits */
789 #define PCI_INTERRUPT_PIN 0x3d /* 8 bits */
790 #define PCI_MIN_GNT 0x3e /* 8 bits */
791 #define PCI_MAX_LAT 0x3f /* 8 bits */
794 /* PCI config space */
797 /* the following fields are read only */
801 PCIIORegion io_regions
[PCI_NUM_REGIONS
];
803 /* do not access the following fields */
804 PCIConfigReadFunc
*config_read
;
805 PCIConfigWriteFunc
*config_write
;
806 /* ??? This is a PC-specific hack, and should be removed. */
809 /* Current IRQ levels. Used internally by the generic PCI code. */
813 PCIDevice
*pci_register_device(PCIBus
*bus
, const char *name
,
814 int instance_size
, int devfn
,
815 PCIConfigReadFunc
*config_read
,
816 PCIConfigWriteFunc
*config_write
);
818 void pci_register_io_region(PCIDevice
*pci_dev
, int region_num
,
819 uint32_t size
, int type
,
820 PCIMapIORegionFunc
*map_func
);
822 void pci_set_irq(PCIDevice
*pci_dev
, int irq_num
, int level
);
824 uint32_t pci_default_read_config(PCIDevice
*d
,
825 uint32_t address
, int len
);
826 void pci_default_write_config(PCIDevice
*d
,
827 uint32_t address
, uint32_t val
, int len
);
828 void pci_device_save(PCIDevice
*s
, QEMUFile
*f
);
829 int pci_device_load(PCIDevice
*s
, QEMUFile
*f
);
831 typedef void (*pci_set_irq_fn
)(void *pic
, int irq_num
, int level
);
832 typedef int (*pci_map_irq_fn
)(PCIDevice
*pci_dev
, int irq_num
);
833 PCIBus
*pci_register_bus(pci_set_irq_fn set_irq
, pci_map_irq_fn map_irq
,
834 void *pic
, int devfn_min
, int nirq
);
836 void pci_nic_init(PCIBus
*bus
, NICInfo
*nd
, int devfn
);
837 void pci_data_write(void *opaque
, uint32_t addr
, uint32_t val
, int len
);
838 uint32_t pci_data_read(void *opaque
, uint32_t addr
, int len
);
839 int pci_bus_num(PCIBus
*s
);
840 void pci_for_each_device(int bus_num
, void (*fn
)(PCIDevice
*d
));
843 PCIBus
*pci_bridge_init(PCIBus
*bus
, int devfn
, uint32_t id
,
844 pci_map_irq_fn map_irq
, const char *name
);
847 PCIBus
*pci_prep_init(void);
850 PCIBus
*pci_grackle_init(uint32_t base
, void *pic
);
853 PCIBus
*pci_pmac_init(void *pic
);
856 PCIBus
*pci_apb_init(target_ulong special_base
, target_ulong mem_base
,
859 PCIBus
*pci_vpb_init(void *pic
, int irq
, int realview
);
862 PCIBus
*i440fx_init(PCIDevice
**pi440fx_state
);
863 void i440fx_set_smm(PCIDevice
*d
, int val
);
864 int piix3_init(PCIBus
*bus
, int devfn
);
865 void i440fx_init_memory_mappings(PCIDevice
*d
);
867 int piix4_init(PCIBus
*bus
, int devfn
);
870 typedef struct openpic_t openpic_t
;
871 void openpic_set_irq(void *opaque
, int n_IRQ
, int level
);
872 openpic_t
*openpic_init (PCIBus
*bus
, int *pmem_index
, int nb_cpus
,
876 typedef struct HeathrowPICS HeathrowPICS
;
877 void heathrow_pic_set_irq(void *opaque
, int num
, int level
);
878 HeathrowPICS
*heathrow_pic_init(int *pmem_index
);
881 PCIBus
*pci_gt64120_init(void *pic
);
890 int (*init_isa
) (AudioState
*s
);
891 int (*init_pci
) (PCIBus
*bus
, AudioState
*s
);
895 extern struct soundhw soundhw
[];
900 #define VGA_RAM_SIZE (8192 * 1024)
902 struct DisplayState
{
906 int bgr
; /* BGR color order instead of RGB. Only valid for depth == 32 */
911 void (*dpy_update
)(struct DisplayState
*s
, int x
, int y
, int w
, int h
);
912 void (*dpy_resize
)(struct DisplayState
*s
, int w
, int h
);
913 void (*dpy_refresh
)(struct DisplayState
*s
);
914 void (*dpy_copy
)(struct DisplayState
*s
, int src_x
, int src_y
, int dst_x
, int dst_y
, int w
, int h
);
917 static inline void dpy_update(DisplayState
*s
, int x
, int y
, int w
, int h
)
919 s
->dpy_update(s
, x
, y
, w
, h
);
922 static inline void dpy_resize(DisplayState
*s
, int w
, int h
)
924 s
->dpy_resize(s
, w
, h
);
927 int isa_vga_init(DisplayState
*ds
, uint8_t *vga_ram_base
,
928 unsigned long vga_ram_offset
, int vga_ram_size
);
929 int pci_vga_init(PCIBus
*bus
, DisplayState
*ds
, uint8_t *vga_ram_base
,
930 unsigned long vga_ram_offset
, int vga_ram_size
,
931 unsigned long vga_bios_offset
, int vga_bios_size
);
934 void pci_cirrus_vga_init(PCIBus
*bus
, DisplayState
*ds
, uint8_t *vga_ram_base
,
935 unsigned long vga_ram_offset
, int vga_ram_size
);
936 void isa_cirrus_vga_init(DisplayState
*ds
, uint8_t *vga_ram_base
,
937 unsigned long vga_ram_offset
, int vga_ram_size
);
940 void sdl_display_init(DisplayState
*ds
, int full_screen
);
943 void cocoa_display_init(DisplayState
*ds
, int full_screen
);
946 void vnc_display_init(DisplayState
*ds
, const char *display
);
947 void do_info_vnc(void);
950 extern uint8_t _translate_keycode(const int key
);
955 extern BlockDriverState
*bs_table
[MAX_DISKS
+ 1];
957 void isa_ide_init(int iobase
, int iobase2
, int irq
,
958 BlockDriverState
*hd0
, BlockDriverState
*hd1
);
959 void pci_cmd646_ide_init(PCIBus
*bus
, BlockDriverState
**hd_table
,
960 int secondary_ide_enabled
);
961 void pci_piix3_ide_init(PCIBus
*bus
, BlockDriverState
**hd_table
, int devfn
);
962 int pmac_ide_init (BlockDriverState
**hd_table
,
963 SetIRQFunc
*set_irq
, void *irq_opaque
, int irq
);
966 int cdrom_read_toc(int nb_sectors
, uint8_t *buf
, int msf
, int start_track
);
967 int cdrom_read_toc_raw(int nb_sectors
, uint8_t *buf
, int msf
, int session_num
);
970 int es1370_init (PCIBus
*bus
, AudioState
*s
);
973 int SB16_init (AudioState
*s
);
976 int Adlib_init (AudioState
*s
);
979 int GUS_init (AudioState
*s
);
982 typedef int (*DMA_transfer_handler
) (void *opaque
, int nchan
, int pos
, int size
);
983 int DMA_get_channel_mode (int nchan
);
984 int DMA_read_memory (int nchan
, void *buf
, int pos
, int size
);
985 int DMA_write_memory (int nchan
, void *buf
, int pos
, int size
);
986 void DMA_hold_DREQ (int nchan
);
987 void DMA_release_DREQ (int nchan
);
988 void DMA_schedule(int nchan
);
990 void DMA_init (int high_page_enable
);
991 void DMA_register_channel (int nchan
,
992 DMA_transfer_handler transfer_handler
,
996 extern BlockDriverState
*fd_table
[MAX_FD
];
998 typedef struct fdctrl_t fdctrl_t
;
1000 fdctrl_t
*fdctrl_init (int irq_lvl
, int dma_chann
, int mem_mapped
,
1002 BlockDriverState
**fds
);
1003 int fdctrl_get_drive_type(fdctrl_t
*fdctrl
, int drive_num
);
1007 void isa_ne2000_init(int base
, int irq
, NICInfo
*nd
);
1008 void pci_ne2000_init(PCIBus
*bus
, NICInfo
*nd
, int devfn
);
1012 void pci_rtl8139_init(PCIBus
*bus
, NICInfo
*nd
, int devfn
);
1016 void pci_pcnet_init(PCIBus
*bus
, NICInfo
*nd
, int devfn
);
1017 void pcnet_h_reset(void *opaque
);
1018 void *lance_init(NICInfo
*nd
, uint32_t leaddr
, void *dma_opaque
);
1023 void kbd_init(void);
1027 typedef struct RTCState RTCState
;
1029 RTCState
*rtc_init(int base
, int irq
);
1030 void rtc_set_memory(RTCState
*s
, int addr
, int val
);
1031 void rtc_set_date(RTCState
*s
, const struct tm
*tm
);
1035 typedef struct SerialState SerialState
;
1036 SerialState
*serial_init(SetIRQFunc
*set_irq
, void *opaque
,
1037 int base
, int irq
, CharDriverState
*chr
);
1038 SerialState
*serial_mm_init (SetIRQFunc
*set_irq
, void *opaque
,
1039 target_ulong base
, int it_shift
,
1040 int irq
, CharDriverState
*chr
);
1044 typedef struct ParallelState ParallelState
;
1045 ParallelState
*parallel_init(int base
, int irq
, CharDriverState
*chr
);
1049 typedef struct PicState2 PicState2
;
1050 extern PicState2
*isa_pic
;
1051 void pic_set_irq(int irq
, int level
);
1052 void pic_set_irq_new(void *opaque
, int irq
, int level
);
1053 PicState2
*pic_init(IRQRequestFunc
*irq_request
, void *irq_request_opaque
);
1054 void pic_set_alt_irq_func(PicState2
*s
, SetIRQFunc
*alt_irq_func
,
1055 void *alt_irq_opaque
);
1056 int pic_read_irq(PicState2
*s
);
1057 void pic_update_irq(PicState2
*s
);
1058 uint32_t pic_intack_read(PicState2
*s
);
1059 void pic_info(void);
1060 void irq_info(void);
1063 typedef struct IOAPICState IOAPICState
;
1065 int apic_init(CPUState
*env
);
1066 int apic_get_interrupt(CPUState
*env
);
1067 int apic_accept_pic_intr(CPUState
*env
);
1068 IOAPICState
*ioapic_init(void);
1069 void ioapic_set_irq(void *opaque
, int vector
, int level
);
1073 #define PIT_FREQ 1193182
1075 typedef struct PITState PITState
;
1077 PITState
*pit_init(int base
, int irq
);
1078 void pit_set_gate(PITState
*pit
, int channel
, int val
);
1079 int pit_get_gate(PITState
*pit
, int channel
);
1080 int pit_get_initial_count(PITState
*pit
, int channel
);
1081 int pit_get_mode(PITState
*pit
, int channel
);
1082 int pit_get_out(PITState
*pit
, int channel
, int64_t current_time
);
1085 void pcspk_init(PITState
*);
1086 int pcspk_audio_init(AudioState
*);
1088 #include "hw/smbus.h"
1091 extern int acpi_enabled
;
1092 void piix4_pm_init(PCIBus
*bus
, int devfn
);
1093 void piix4_smbus_register_device(SMBusDevice
*dev
, uint8_t addr
);
1094 void acpi_bios_init(void);
1096 /* smbus_eeprom.c */
1097 SMBusDevice
*smbus_eeprom_device_init(uint8_t addr
, uint8_t *buf
);
1100 extern QEMUMachine pc_machine
;
1101 extern QEMUMachine isapc_machine
;
1102 extern int fd_bootchk
;
1104 void ioport_set_a20(int enable
);
1105 int ioport_get_a20(void);
1108 extern QEMUMachine prep_machine
;
1109 extern QEMUMachine core99_machine
;
1110 extern QEMUMachine heathrow_machine
;
1113 extern QEMUMachine mips_machine
;
1116 extern QEMUMachine mips_malta_machine
;
1119 extern void cpu_mips_irq_request(void *opaque
, int irq
, int level
);
1122 extern void cpu_mips_clock_init(CPUState
*);
1123 extern void cpu_mips_irqctrl_init (void);
1126 extern QEMUMachine shix_machine
;
1129 ppc_tb_t
*cpu_ppc_tb_init (CPUState
*env
, uint32_t freq
);
1131 void PREP_debug_write (void *opaque
, uint32_t addr
, uint32_t val
);
1133 extern CPUWriteMemoryFunc
*PPC_io_write
[];
1134 extern CPUReadMemoryFunc
*PPC_io_read
[];
1135 void PPC_debug_write (void *opaque
, uint32_t addr
, uint32_t val
);
1138 extern QEMUMachine sun4m_machine
;
1139 void pic_set_irq_cpu(int irq
, int level
, unsigned int cpu
);
1142 void *iommu_init(uint32_t addr
);
1143 void sparc_iommu_memory_rw(void *opaque
, target_phys_addr_t addr
,
1144 uint8_t *buf
, int len
, int is_write
);
1145 static inline void sparc_iommu_memory_read(void *opaque
,
1146 target_phys_addr_t addr
,
1147 uint8_t *buf
, int len
)
1149 sparc_iommu_memory_rw(opaque
, addr
, buf
, len
, 0);
1152 static inline void sparc_iommu_memory_write(void *opaque
,
1153 target_phys_addr_t addr
,
1154 uint8_t *buf
, int len
)
1156 sparc_iommu_memory_rw(opaque
, addr
, buf
, len
, 1);
1160 void tcx_init(DisplayState
*ds
, uint32_t addr
, uint8_t *vram_base
,
1161 unsigned long vram_offset
, int vram_size
, int width
, int height
);
1163 /* slavio_intctl.c */
1164 void *slavio_intctl_init();
1165 void slavio_intctl_set_cpu(void *opaque
, unsigned int cpu
, CPUState
*env
);
1166 void slavio_pic_info(void *opaque
);
1167 void slavio_irq_info(void *opaque
);
1168 void slavio_pic_set_irq(void *opaque
, int irq
, int level
);
1169 void slavio_pic_set_irq_cpu(void *opaque
, int irq
, int level
, unsigned int cpu
);
1172 int get_image_size(const char *filename
);
1173 int load_image(const char *filename
, uint8_t *addr
);
1174 int load_elf(const char *filename
, int64_t virt_to_phys_addend
, uint64_t *pentry
);
1175 int load_aout(const char *filename
, uint8_t *addr
);
1177 /* slavio_timer.c */
1178 void slavio_timer_init(uint32_t addr
, int irq
, int mode
, unsigned int cpu
);
1180 /* slavio_serial.c */
1181 SerialState
*slavio_serial_init(int base
, int irq
, CharDriverState
*chr1
, CharDriverState
*chr2
);
1182 void slavio_serial_ms_kbd_init(int base
, int irq
);
1185 void *slavio_misc_init(uint32_t base
, int irq
);
1186 void slavio_set_power_fail(void *opaque
, int power_failing
);
1189 void esp_scsi_attach(void *opaque
, BlockDriverState
*bd
, int id
);
1190 void *esp_init(BlockDriverState
**bd
, uint32_t espaddr
, void *dma_opaque
);
1191 void esp_reset(void *opaque
);
1194 void *sparc32_dma_init(uint32_t daddr
, int espirq
, int leirq
, void *iommu
,
1196 void ledma_set_irq(void *opaque
, int isr
);
1197 void ledma_memory_read(void *opaque
, target_phys_addr_t addr
,
1198 uint8_t *buf
, int len
, int do_bswap
);
1199 void ledma_memory_write(void *opaque
, target_phys_addr_t addr
,
1200 uint8_t *buf
, int len
, int do_bswap
);
1201 void espdma_raise_irq(void *opaque
);
1202 void espdma_clear_irq(void *opaque
);
1203 void espdma_memory_read(void *opaque
, uint8_t *buf
, int len
);
1204 void espdma_memory_write(void *opaque
, uint8_t *buf
, int len
);
1205 void sparc32_dma_set_reset_data(void *opaque
, void *esp_opaque
,
1206 void *lance_opaque
);
1209 void cs_init(target_phys_addr_t base
, int irq
, void *intctl
);
1212 extern QEMUMachine sun4u_machine
;
1215 #include "hw/m48t59.h"
1217 void NVRAM_set_byte (m48t59_t
*nvram
, uint32_t addr
, uint8_t value
);
1218 uint8_t NVRAM_get_byte (m48t59_t
*nvram
, uint32_t addr
);
1219 void NVRAM_set_word (m48t59_t
*nvram
, uint32_t addr
, uint16_t value
);
1220 uint16_t NVRAM_get_word (m48t59_t
*nvram
, uint32_t addr
);
1221 void NVRAM_set_lword (m48t59_t
*nvram
, uint32_t addr
, uint32_t value
);
1222 uint32_t NVRAM_get_lword (m48t59_t
*nvram
, uint32_t addr
);
1223 void NVRAM_set_string (m48t59_t
*nvram
, uint32_t addr
,
1224 const unsigned char *str
, uint32_t max
);
1225 int NVRAM_get_string (m48t59_t
*nvram
, uint8_t *dst
, uint16_t addr
, int max
);
1226 void NVRAM_set_crc (m48t59_t
*nvram
, uint32_t addr
,
1227 uint32_t start
, uint32_t count
);
1228 int PPC_NVRAM_set_params (m48t59_t
*nvram
, uint16_t NVRAM_size
,
1229 const unsigned char *arch
,
1230 uint32_t RAM_size
, int boot_device
,
1231 uint32_t kernel_image
, uint32_t kernel_size
,
1232 const char *cmdline
,
1233 uint32_t initrd_image
, uint32_t initrd_size
,
1234 uint32_t NVRAM_image
,
1235 int width
, int height
, int depth
);
1239 #define MAX_ADB_DEVICES 16
1241 #define ADB_MAX_OUT_LEN 16
1243 typedef struct ADBDevice ADBDevice
;
1247 void pci_hypercall_init(PCIBus
*bus
);
1248 void vmchannel_init(CharDriverState
*hd
, uint32_t deviceid
, uint32_t index
);
1250 /* buf = NULL means polling */
1251 typedef int ADBDeviceRequest(ADBDevice
*d
, uint8_t *buf_out
,
1252 const uint8_t *buf
, int len
);
1253 typedef int ADBDeviceReset(ADBDevice
*d
);
1256 struct ADBBusState
*bus
;
1259 ADBDeviceRequest
*devreq
;
1260 ADBDeviceReset
*devreset
;
1264 typedef struct ADBBusState
{
1265 ADBDevice devices
[MAX_ADB_DEVICES
];
1270 int adb_request(ADBBusState
*s
, uint8_t *buf_out
,
1271 const uint8_t *buf
, int len
);
1272 int adb_poll(ADBBusState
*s
, uint8_t *buf_out
);
1274 ADBDevice
*adb_register_device(ADBBusState
*s
, int devaddr
,
1275 ADBDeviceRequest
*devreq
,
1276 ADBDeviceReset
*devreset
,
1278 void adb_kbd_init(ADBBusState
*bus
);
1279 void adb_mouse_init(ADBBusState
*bus
);
1283 extern ADBBusState adb_bus
;
1284 int cuda_init(SetIRQFunc
*set_irq
, void *irq_opaque
, int irq
);
1288 /* usb ports of the VM */
1290 void qemu_register_usb_port(USBPort
*port
, void *opaque
, int index
,
1291 usb_attachfn attach
);
1293 #define VM_USB_HUB_SIZE 8
1295 void do_usb_add(const char *devname
);
1296 void do_usb_del(const char *devname
);
1297 void usb_info(void);
1301 SCSI_REASON_DONE
, /* Command complete. */
1302 SCSI_REASON_DATA
/* Transfer complete, more data required. */
1305 typedef struct SCSIDevice SCSIDevice
;
1306 typedef void (*scsi_completionfn
)(void *opaque
, int reason
, uint32_t tag
,
1309 SCSIDevice
*scsi_disk_init(BlockDriverState
*bdrv
,
1311 scsi_completionfn completion
,
1313 void scsi_disk_destroy(SCSIDevice
*s
);
1315 int32_t scsi_send_command(SCSIDevice
*s
, uint32_t tag
, uint8_t *buf
, int lun
);
1316 /* SCSI data transfers are asynchrnonous. However, unlike the block IO
1317 layer the completion routine may be called directly by
1318 scsi_{read,write}_data. */
1319 void scsi_read_data(SCSIDevice
*s
, uint32_t tag
);
1320 int scsi_write_data(SCSIDevice
*s
, uint32_t tag
);
1321 void scsi_cancel_io(SCSIDevice
*s
, uint32_t tag
);
1322 uint8_t *scsi_get_buf(SCSIDevice
*s
, uint32_t tag
);
1325 void lsi_scsi_attach(void *opaque
, BlockDriverState
*bd
, int id
);
1326 void *lsi_scsi_init(PCIBus
*bus
, int devfn
);
1328 /* integratorcp.c */
1329 extern QEMUMachine integratorcp926_machine
;
1330 extern QEMUMachine integratorcp1026_machine
;
1333 extern QEMUMachine versatilepb_machine
;
1334 extern QEMUMachine versatileab_machine
;
1337 extern QEMUMachine realview_machine
;
1340 void *ps2_kbd_init(void (*update_irq
)(void *, int), void *update_arg
);
1341 void *ps2_mouse_init(void (*update_irq
)(void *, int), void *update_arg
);
1342 void ps2_write_mouse(void *, int val
);
1343 void ps2_write_keyboard(void *, int val
);
1344 uint32_t ps2_read_data(void *);
1345 void ps2_queue(void *, int b
);
1346 void ps2_keyboard_set_translation(void *opaque
, int mode
);
1349 void smc91c111_init(NICInfo
*, uint32_t, void *, int);
1352 void *pl110_init(DisplayState
*ds
, uint32_t base
, void *pic
, int irq
, int);
1355 void pl011_init(uint32_t base
, void *pic
, int irq
, CharDriverState
*chr
);
1358 void pl050_init(uint32_t base
, void *pic
, int irq
, int is_mouse
);
1361 void *pl080_init(uint32_t base
, void *pic
, int irq
, int nchannels
);
1364 void *pl190_init(uint32_t base
, void *parent
, int irq
, int fiq
);
1367 void sp804_init(uint32_t base
, void *pic
, int irq
);
1368 void icp_pit_init(uint32_t base
, void *pic
, int irq
);
1371 void arm_sysctl_init(uint32_t base
, uint32_t sys_id
);
1374 void *arm_gic_init(uint32_t base
, void *parent
, int parent_irq
);
1378 void arm_load_kernel(CPUState
*env
, int ram_size
, const char *kernel_filename
,
1379 const char *kernel_cmdline
, const char *initrd_filename
,
1385 struct SH7750State
*sh7750_init(CPUState
* cpu
);
1388 /* The callback will be triggered if any of the designated lines change */
1389 uint16_t portamask_trigger
;
1390 uint16_t portbmask_trigger
;
1391 /* Return 0 if no action was taken */
1392 int (*port_change_cb
) (uint16_t porta
, uint16_t portb
,
1393 uint16_t * periph_pdtra
,
1394 uint16_t * periph_portdira
,
1395 uint16_t * periph_pdtrb
,
1396 uint16_t * periph_portdirb
);
1399 int sh7750_register_io_device(struct SH7750State
*s
,
1400 sh7750_io_device
* device
);
1402 int tc58128_init(struct SH7750State
*s
, char *zone1
, char *zone2
);
1404 /* NOR flash devices */
1405 typedef struct pflash_t pflash_t
;
1407 pflash_t
*pflash_register (target_ulong base
, ram_addr_t off
,
1408 BlockDriverState
*bs
,
1409 target_ulong sector_len
, int nb_blocs
, int width
,
1410 uint16_t id0
, uint16_t id1
,
1411 uint16_t id2
, uint16_t id3
);
1413 #include "gdbstub.h"
1415 #endif /* defined(QEMU_TOOL) */
1418 void do_info_migration(void);
1419 void do_migrate(int detach
, const char *uri
);
1420 void do_migrate_cancel(void);
1421 void do_migrate_set_speed(const char *value
);
1422 int migrate_incoming(const char *device
);
1425 void monitor_init(CharDriverState
*hd
, int show_banner
);
1426 void term_puts(const char *str
);
1427 void term_vprintf(const char *fmt
, va_list ap
);
1428 void term_printf(const char *fmt
, ...) __attribute__ ((__format__ (__printf__
, 1, 2)));
1429 void term_print_filename(const char *filename
);
1430 void term_flush(void);
1431 void term_print_help(void);
1432 void monitor_readline(const char *prompt
, int is_password
,
1433 char *buf
, int buf_size
);
1434 void monitor_suspend(void);
1435 void monitor_resume(void);
1438 typedef void ReadLineFunc(void *opaque
, const char *str
);
1440 extern int completion_index
;
1441 void add_completion(const char *str
);
1442 void readline_handle_byte(int ch
);
1443 void readline_find_completion(const char *cmdline
);
1444 const char *readline_get_history(unsigned int index
);
1445 void readline_start(const char *prompt
, int is_password
,
1446 ReadLineFunc
*readline_func
, void *opaque
);
1448 void kqemu_record_dump(void);