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 */
48 #define lseek64 _lseeki64
53 /* we use QEMU_TOOL in the command line tools which do not depend on
54 the target CPU type */
55 #include "config-host.h"
64 #endif /* !defined(QEMU_TOOL) */
67 #define xglue(x, y) x ## y
68 #define glue(x, y) xglue(x, y)
69 #define stringify(s) tostring(s)
70 #define tostring(s) #s
74 uint64_t muldiv64(uint64_t a
, uint32_t b
, uint32_t c
);
76 void hw_error(const char *fmt
, ...);
78 int get_image_size(const char *filename
);
79 int load_image(const char *filename
, uint8_t *addr
);
80 extern const char *bios_dir
;
82 void pstrcpy(char *buf
, int buf_size
, const char *str
);
83 char *pstrcat(char *buf
, int buf_size
, const char *s
);
84 int strstart(const char *str
, const char *val
, const char **ptr
);
86 extern int vm_running
;
88 typedef void VMStopHandler(void *opaque
, int reason
);
90 int qemu_add_vm_stop_handler(VMStopHandler
*cb
, void *opaque
);
91 void qemu_del_vm_stop_handler(VMStopHandler
*cb
, void *opaque
);
94 void vm_stop(int reason
);
96 typedef void QEMUResetHandler(void *opaque
);
98 void qemu_register_reset(QEMUResetHandler
*func
, void *opaque
);
99 void qemu_system_reset_request(void);
100 void qemu_system_shutdown_request(void);
102 void main_loop_wait(int timeout
);
104 extern int audio_enabled
;
106 extern int bios_size
;
108 extern int cirrus_vga_enabled
;
109 extern int graphic_width
;
110 extern int graphic_height
;
111 extern int graphic_depth
;
113 /* XXX: make it dynamic */
114 #if defined (TARGET_PPC)
115 #define BIOS_SIZE (512 * 1024)
117 #define BIOS_SIZE ((256 + 64) * 1024)
120 /* keyboard/mouse support */
122 #define MOUSE_EVENT_LBUTTON 0x01
123 #define MOUSE_EVENT_RBUTTON 0x02
124 #define MOUSE_EVENT_MBUTTON 0x04
126 typedef void QEMUPutKBDEvent(void *opaque
, int keycode
);
127 typedef void QEMUPutMouseEvent(void *opaque
, int dx
, int dy
, int dz
, int buttons_state
);
129 void qemu_add_kbd_event_handler(QEMUPutKBDEvent
*func
, void *opaque
);
130 void qemu_add_mouse_event_handler(QEMUPutMouseEvent
*func
, void *opaque
);
132 void kbd_put_keycode(int keycode
);
133 void kbd_mouse_event(int dx
, int dy
, int dz
, int buttons_state
);
135 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
137 #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
138 #define QEMU_KEY_BACKSPACE 0x007f
139 #define QEMU_KEY_UP QEMU_KEY_ESC1('A')
140 #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
141 #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
142 #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
143 #define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
144 #define QEMU_KEY_END QEMU_KEY_ESC1(4)
145 #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
146 #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
147 #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
149 #define QEMU_KEY_CTRL_UP 0xe400
150 #define QEMU_KEY_CTRL_DOWN 0xe401
151 #define QEMU_KEY_CTRL_LEFT 0xe402
152 #define QEMU_KEY_CTRL_RIGHT 0xe403
153 #define QEMU_KEY_CTRL_HOME 0xe404
154 #define QEMU_KEY_CTRL_END 0xe405
155 #define QEMU_KEY_CTRL_PAGEUP 0xe406
156 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407
158 void kbd_put_keysym(int keysym
);
160 /* async I/O support */
162 typedef void IOReadHandler(void *opaque
, const uint8_t *buf
, int size
);
163 typedef int IOCanRWHandler(void *opaque
);
165 int qemu_add_fd_read_handler(int fd
, IOCanRWHandler
*fd_can_read
,
166 IOReadHandler
*fd_read
, void *opaque
);
167 void qemu_del_fd_read_handler(int fd
);
169 /* character device */
171 #define CHR_EVENT_BREAK 0 /* serial break char */
172 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
174 typedef void IOEventHandler(void *opaque
, int event
);
176 typedef struct CharDriverState
{
177 int (*chr_write
)(struct CharDriverState
*s
, const uint8_t *buf
, int len
);
178 void (*chr_add_read_handler
)(struct CharDriverState
*s
,
179 IOCanRWHandler
*fd_can_read
,
180 IOReadHandler
*fd_read
, void *opaque
);
181 IOEventHandler
*chr_event
;
182 IOEventHandler
*chr_send_event
;
186 void qemu_chr_printf(CharDriverState
*s
, const char *fmt
, ...);
187 int qemu_chr_write(CharDriverState
*s
, const uint8_t *buf
, int len
);
188 void qemu_chr_send_event(CharDriverState
*s
, int event
);
189 void qemu_chr_add_read_handler(CharDriverState
*s
,
190 IOCanRWHandler
*fd_can_read
,
191 IOReadHandler
*fd_read
, void *opaque
);
192 void qemu_chr_add_event_handler(CharDriverState
*s
, IOEventHandler
*chr_event
);
194 CharDriverState
*serial_hd
;
198 typedef struct DisplayState DisplayState
;
199 typedef struct TextConsole TextConsole
;
201 extern TextConsole
*vga_console
;
203 TextConsole
*graphic_console_init(DisplayState
*ds
);
204 int is_active_console(TextConsole
*s
);
205 CharDriverState
*text_console_init(DisplayState
*ds
);
206 void console_select(unsigned int index
);
208 /* network redirectors support */
212 typedef struct NetDriverState
{
213 int index
; /* index number in QEMU */
216 void (*send_packet
)(struct NetDriverState
*nd
,
217 const uint8_t *buf
, int size
);
218 void (*add_read_packet
)(struct NetDriverState
*nd
,
219 IOCanRWHandler
*fd_can_read
,
220 IOReadHandler
*fd_read
, void *opaque
);
221 /* tun specific data */
223 /* slirp specific data */
227 extern NetDriverState nd_table
[MAX_NICS
];
229 void qemu_send_packet(NetDriverState
*nd
, const uint8_t *buf
, int size
);
230 void qemu_add_read_packet(NetDriverState
*nd
, IOCanRWHandler
*fd_can_read
,
231 IOReadHandler
*fd_read
, void *opaque
);
235 typedef struct QEMUClock QEMUClock
;
236 typedef struct QEMUTimer QEMUTimer
;
237 typedef void QEMUTimerCB(void *opaque
);
239 /* The real time clock should be used only for stuff which does not
240 change the virtual machine state, as it is run even if the virtual
241 machine is stopped. The real time clock has a frequency of 1000
243 extern QEMUClock
*rt_clock
;
245 /* Rge virtual clock is only run during the emulation. It is stopped
246 when the virtual machine is stopped. Virtual timers use a high
247 precision clock, usually cpu cycles (use ticks_per_sec). */
248 extern QEMUClock
*vm_clock
;
250 int64_t qemu_get_clock(QEMUClock
*clock
);
252 QEMUTimer
*qemu_new_timer(QEMUClock
*clock
, QEMUTimerCB
*cb
, void *opaque
);
253 void qemu_free_timer(QEMUTimer
*ts
);
254 void qemu_del_timer(QEMUTimer
*ts
);
255 void qemu_mod_timer(QEMUTimer
*ts
, int64_t expire_time
);
256 int qemu_timer_pending(QEMUTimer
*ts
);
258 extern int64_t ticks_per_sec
;
259 extern int pit_min_timer_count
;
261 void cpu_enable_ticks(void);
262 void cpu_disable_ticks(void);
266 typedef FILE QEMUFile
;
268 void qemu_put_buffer(QEMUFile
*f
, const uint8_t *buf
, int size
);
269 void qemu_put_byte(QEMUFile
*f
, int v
);
270 void qemu_put_be16(QEMUFile
*f
, unsigned int v
);
271 void qemu_put_be32(QEMUFile
*f
, unsigned int v
);
272 void qemu_put_be64(QEMUFile
*f
, uint64_t v
);
273 int qemu_get_buffer(QEMUFile
*f
, uint8_t *buf
, int size
);
274 int qemu_get_byte(QEMUFile
*f
);
275 unsigned int qemu_get_be16(QEMUFile
*f
);
276 unsigned int qemu_get_be32(QEMUFile
*f
);
277 uint64_t qemu_get_be64(QEMUFile
*f
);
279 static inline void qemu_put_be64s(QEMUFile
*f
, const uint64_t *pv
)
281 qemu_put_be64(f
, *pv
);
284 static inline void qemu_put_be32s(QEMUFile
*f
, const uint32_t *pv
)
286 qemu_put_be32(f
, *pv
);
289 static inline void qemu_put_be16s(QEMUFile
*f
, const uint16_t *pv
)
291 qemu_put_be16(f
, *pv
);
294 static inline void qemu_put_8s(QEMUFile
*f
, const uint8_t *pv
)
296 qemu_put_byte(f
, *pv
);
299 static inline void qemu_get_be64s(QEMUFile
*f
, uint64_t *pv
)
301 *pv
= qemu_get_be64(f
);
304 static inline void qemu_get_be32s(QEMUFile
*f
, uint32_t *pv
)
306 *pv
= qemu_get_be32(f
);
309 static inline void qemu_get_be16s(QEMUFile
*f
, uint16_t *pv
)
311 *pv
= qemu_get_be16(f
);
314 static inline void qemu_get_8s(QEMUFile
*f
, uint8_t *pv
)
316 *pv
= qemu_get_byte(f
);
319 int64_t qemu_ftell(QEMUFile
*f
);
320 int64_t qemu_fseek(QEMUFile
*f
, int64_t pos
, int whence
);
322 typedef void SaveStateHandler(QEMUFile
*f
, void *opaque
);
323 typedef int LoadStateHandler(QEMUFile
*f
, void *opaque
, int version_id
);
325 int qemu_loadvm(const char *filename
);
326 int qemu_savevm(const char *filename
);
327 int register_savevm(const char *idstr
,
330 SaveStateHandler
*save_state
,
331 LoadStateHandler
*load_state
,
333 void qemu_get_timer(QEMUFile
*f
, QEMUTimer
*ts
);
334 void qemu_put_timer(QEMUFile
*f
, QEMUTimer
*ts
);
337 typedef struct BlockDriverState BlockDriverState
;
338 typedef struct BlockDriver BlockDriver
;
340 extern BlockDriver bdrv_raw
;
341 extern BlockDriver bdrv_cow
;
342 extern BlockDriver bdrv_qcow
;
343 extern BlockDriver bdrv_vmdk
;
345 void bdrv_init(void);
346 BlockDriver
*bdrv_find_format(const char *format_name
);
347 int bdrv_create(BlockDriver
*drv
,
348 const char *filename
, int64_t size_in_sectors
,
349 const char *backing_file
, int flags
);
350 BlockDriverState
*bdrv_new(const char *device_name
);
351 void bdrv_delete(BlockDriverState
*bs
);
352 int bdrv_open(BlockDriverState
*bs
, const char *filename
, int snapshot
);
353 int bdrv_open2(BlockDriverState
*bs
, const char *filename
, int snapshot
,
355 void bdrv_close(BlockDriverState
*bs
);
356 int bdrv_read(BlockDriverState
*bs
, int64_t sector_num
,
357 uint8_t *buf
, int nb_sectors
);
358 int bdrv_write(BlockDriverState
*bs
, int64_t sector_num
,
359 const uint8_t *buf
, int nb_sectors
);
360 void bdrv_get_geometry(BlockDriverState
*bs
, int64_t *nb_sectors_ptr
);
361 int bdrv_commit(BlockDriverState
*bs
);
362 void bdrv_set_boot_sector(BlockDriverState
*bs
, const uint8_t *data
, int size
);
364 #define BDRV_TYPE_HD 0
365 #define BDRV_TYPE_CDROM 1
366 #define BDRV_TYPE_FLOPPY 2
368 void bdrv_set_geometry_hint(BlockDriverState
*bs
,
369 int cyls
, int heads
, int secs
);
370 void bdrv_set_type_hint(BlockDriverState
*bs
, int type
);
371 void bdrv_get_geometry_hint(BlockDriverState
*bs
,
372 int *pcyls
, int *pheads
, int *psecs
);
373 int bdrv_get_type_hint(BlockDriverState
*bs
);
374 int bdrv_is_removable(BlockDriverState
*bs
);
375 int bdrv_is_read_only(BlockDriverState
*bs
);
376 int bdrv_is_inserted(BlockDriverState
*bs
);
377 int bdrv_is_locked(BlockDriverState
*bs
);
378 void bdrv_set_locked(BlockDriverState
*bs
, int locked
);
379 void bdrv_set_change_cb(BlockDriverState
*bs
,
380 void (*change_cb
)(void *opaque
), void *opaque
);
381 void bdrv_get_format(BlockDriverState
*bs
, char *buf
, int buf_size
);
382 void bdrv_info(void);
383 BlockDriverState
*bdrv_find(const char *name
);
384 void bdrv_iterate(void (*it
)(void *opaque
, const char *name
), void *opaque
);
385 int bdrv_is_encrypted(BlockDriverState
*bs
);
386 int bdrv_set_key(BlockDriverState
*bs
, const char *key
);
387 void bdrv_iterate_format(void (*it
)(void *opaque
, const char *name
),
389 const char *bdrv_get_device_name(BlockDriverState
*bs
);
391 int qcow_get_cluster_size(BlockDriverState
*bs
);
392 int qcow_compress_cluster(BlockDriverState
*bs
, int64_t sector_num
,
398 extern target_phys_addr_t isa_mem_base
;
400 typedef void (IOPortWriteFunc
)(void *opaque
, uint32_t address
, uint32_t data
);
401 typedef uint32_t (IOPortReadFunc
)(void *opaque
, uint32_t address
);
403 int register_ioport_read(int start
, int length
, int size
,
404 IOPortReadFunc
*func
, void *opaque
);
405 int register_ioport_write(int start
, int length
, int size
,
406 IOPortWriteFunc
*func
, void *opaque
);
407 void isa_unassign_ioport(int start
, int length
);
411 extern int pci_enabled
;
413 extern target_phys_addr_t pci_mem_base
;
415 typedef struct PCIBus PCIBus
;
416 typedef struct PCIDevice PCIDevice
;
418 typedef void PCIConfigWriteFunc(PCIDevice
*pci_dev
,
419 uint32_t address
, uint32_t data
, int len
);
420 typedef uint32_t PCIConfigReadFunc(PCIDevice
*pci_dev
,
421 uint32_t address
, int len
);
422 typedef void PCIMapIORegionFunc(PCIDevice
*pci_dev
, int region_num
,
423 uint32_t addr
, uint32_t size
, int type
);
425 #define PCI_ADDRESS_SPACE_MEM 0x00
426 #define PCI_ADDRESS_SPACE_IO 0x01
427 #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
429 typedef struct PCIIORegion
{
430 uint32_t addr
; /* current PCI mapping address. -1 means not mapped */
433 PCIMapIORegionFunc
*map_func
;
436 #define PCI_ROM_SLOT 6
437 #define PCI_NUM_REGIONS 7
439 /* PCI config space */
442 /* the following fields are read only */
446 PCIIORegion io_regions
[PCI_NUM_REGIONS
];
448 /* do not access the following fields */
449 PCIConfigReadFunc
*config_read
;
450 PCIConfigWriteFunc
*config_write
;
454 PCIDevice
*pci_register_device(PCIBus
*bus
, const char *name
,
455 int instance_size
, int devfn
,
456 PCIConfigReadFunc
*config_read
,
457 PCIConfigWriteFunc
*config_write
);
459 void pci_register_io_region(PCIDevice
*pci_dev
, int region_num
,
460 uint32_t size
, int type
,
461 PCIMapIORegionFunc
*map_func
);
463 void pci_set_irq(PCIDevice
*pci_dev
, int irq_num
, int level
);
465 uint32_t pci_default_read_config(PCIDevice
*d
,
466 uint32_t address
, int len
);
467 void pci_default_write_config(PCIDevice
*d
,
468 uint32_t address
, uint32_t val
, int len
);
470 extern struct PIIX3State
*piix3_state
;
472 PCIBus
*i440fx_init(void);
473 void piix3_init(PCIBus
*bus
);
474 void pci_bios_init(void);
477 /* temporary: will be moved in platform specific file */
478 PCIBus
*pci_prep_init(void);
480 void pci_pmac_set_openpic(PCIBus
*bus
, struct openpic_t
*openpic
);
481 PCIBus
*pci_pmac_init(void);
484 typedef struct openpic_t openpic_t
;
485 void openpic_set_irq (openpic_t
*opp
, int n_IRQ
, int level
);
486 openpic_t
*openpic_init (PCIBus
*bus
, int *pmem_index
, int nb_cpus
);
490 #define VGA_RAM_SIZE (4096 * 1024)
492 struct DisplayState
{
498 void (*dpy_update
)(struct DisplayState
*s
, int x
, int y
, int w
, int h
);
499 void (*dpy_resize
)(struct DisplayState
*s
, int w
, int h
);
500 void (*dpy_refresh
)(struct DisplayState
*s
);
503 static inline void dpy_update(DisplayState
*s
, int x
, int y
, int w
, int h
)
505 s
->dpy_update(s
, x
, y
, w
, h
);
508 static inline void dpy_resize(DisplayState
*s
, int w
, int h
)
510 s
->dpy_resize(s
, w
, h
);
513 int vga_initialize(PCIBus
*bus
, DisplayState
*ds
, uint8_t *vga_ram_base
,
514 unsigned long vga_ram_offset
, int vga_ram_size
);
515 void vga_update_display(void);
516 void vga_invalidate_display(void);
517 void vga_screen_dump(const char *filename
);
520 void pci_cirrus_vga_init(PCIBus
*bus
, DisplayState
*ds
, uint8_t *vga_ram_base
,
521 unsigned long vga_ram_offset
, int vga_ram_size
);
522 void isa_cirrus_vga_init(DisplayState
*ds
, uint8_t *vga_ram_base
,
523 unsigned long vga_ram_offset
, int vga_ram_size
);
526 void sdl_display_init(DisplayState
*ds
);
531 extern BlockDriverState
*bs_table
[MAX_DISKS
];
533 void isa_ide_init(int iobase
, int iobase2
, int irq
,
534 BlockDriverState
*hd0
, BlockDriverState
*hd1
);
535 void pci_ide_init(PCIBus
*bus
, BlockDriverState
**hd_table
);
536 void pci_piix3_ide_init(PCIBus
*bus
, BlockDriverState
**hd_table
);
537 int pmac_ide_init (BlockDriverState
**hd_table
,
538 openpic_t
*openpic
, int irq
);
548 void AUD_open (int rfreq
, int rnchannels
, audfmt_e rfmt
);
549 void AUD_reset (int rfreq
, int rnchannels
, audfmt_e rfmt
);
550 int AUD_write (void *in_buf
, int size
);
552 void AUD_adjust_estimate (int _leftover
);
553 int AUD_get_free (void);
554 int AUD_get_live (void);
555 int AUD_get_buffer_size (void);
556 void AUD_init (void);
559 typedef int (*DMA_transfer_handler
) (void *opaque
, target_ulong addr
, int size
);
560 int DMA_get_channel_mode (int nchan
);
561 void DMA_hold_DREQ (int nchan
);
562 void DMA_release_DREQ (int nchan
);
563 void DMA_schedule(int nchan
);
565 void DMA_init (int high_page_enable
);
566 void DMA_register_channel (int nchan
,
567 DMA_transfer_handler transfer_handler
, void *opaque
);
570 void SB16_run (void);
571 void SB16_init (void);
575 extern BlockDriverState
*fd_table
[MAX_FD
];
577 typedef struct fdctrl_t fdctrl_t
;
579 fdctrl_t
*fdctrl_init (int irq_lvl
, int dma_chann
, int mem_mapped
,
581 BlockDriverState
**fds
);
582 int fdctrl_get_drive_type(fdctrl_t
*fdctrl
, int drive_num
);
586 void isa_ne2000_init(int base
, int irq
, NetDriverState
*nd
);
587 void pci_ne2000_init(PCIBus
*bus
, NetDriverState
*nd
);
595 typedef struct RTCState RTCState
;
597 RTCState
*rtc_init(int base
, int irq
);
598 void rtc_set_memory(RTCState
*s
, int addr
, int val
);
599 void rtc_set_date(RTCState
*s
, const struct tm
*tm
);
603 typedef struct SerialState SerialState
;
604 SerialState
*serial_init(int base
, int irq
, CharDriverState
*chr
);
608 void pic_set_irq(int irq
, int level
);
610 uint32_t pic_intack_read(CPUState
*env
);
616 #define PIT_FREQ 1193182
618 typedef struct PITState PITState
;
620 PITState
*pit_init(int base
, int irq
);
621 void pit_set_gate(PITState
*pit
, int channel
, int val
);
622 int pit_get_gate(PITState
*pit
, int channel
);
623 int pit_get_out(PITState
*pit
, int channel
, int64_t current_time
);
626 void pc_init(int ram_size
, int vga_ram_size
, int boot_device
,
627 DisplayState
*ds
, const char **fd_filename
, int snapshot
,
628 const char *kernel_filename
, const char *kernel_cmdline
,
629 const char *initrd_filename
);
632 void ppc_init (int ram_size
, int vga_ram_size
, int boot_device
,
633 DisplayState
*ds
, const char **fd_filename
, int snapshot
,
634 const char *kernel_filename
, const char *kernel_cmdline
,
635 const char *initrd_filename
);
636 void ppc_prep_init (int ram_size
, int vga_ram_size
, int boot_device
,
637 DisplayState
*ds
, const char **fd_filename
, int snapshot
,
638 const char *kernel_filename
, const char *kernel_cmdline
,
639 const char *initrd_filename
);
640 void ppc_chrp_init(int ram_size
, int vga_ram_size
, int boot_device
,
641 DisplayState
*ds
, const char **fd_filename
, int snapshot
,
642 const char *kernel_filename
, const char *kernel_cmdline
,
643 const char *initrd_filename
);
645 ppc_tb_t
*cpu_ppc_tb_init (CPUState
*env
, uint32_t freq
);
647 void PREP_debug_write (void *opaque
, uint32_t addr
, uint32_t val
);
649 extern CPUWriteMemoryFunc
*PPC_io_write
[];
650 extern CPUReadMemoryFunc
*PPC_io_read
[];
651 extern int prep_enabled
;
654 #include "hw/m48t59.h"
656 void NVRAM_set_byte (m48t59_t
*nvram
, uint32_t addr
, uint8_t value
);
657 uint8_t NVRAM_get_byte (m48t59_t
*nvram
, uint32_t addr
);
658 void NVRAM_set_word (m48t59_t
*nvram
, uint32_t addr
, uint16_t value
);
659 uint16_t NVRAM_get_word (m48t59_t
*nvram
, uint32_t addr
);
660 void NVRAM_set_lword (m48t59_t
*nvram
, uint32_t addr
, uint32_t value
);
661 uint32_t NVRAM_get_lword (m48t59_t
*nvram
, uint32_t addr
);
662 void NVRAM_set_string (m48t59_t
*nvram
, uint32_t addr
,
663 const unsigned char *str
, uint32_t max
);
664 int NVRAM_get_string (m48t59_t
*nvram
, uint8_t *dst
, uint16_t addr
, int max
);
665 void NVRAM_set_crc (m48t59_t
*nvram
, uint32_t addr
,
666 uint32_t start
, uint32_t count
);
667 int PPC_NVRAM_set_params (m48t59_t
*nvram
, uint16_t NVRAM_size
,
668 const unsigned char *arch
,
669 uint32_t RAM_size
, int boot_device
,
670 uint32_t kernel_image
, uint32_t kernel_size
,
672 uint32_t initrd_image
, uint32_t initrd_size
,
673 uint32_t NVRAM_image
,
674 int width
, int height
, int depth
);
678 #define MAX_ADB_DEVICES 16
680 #define ADB_MAX_OUT_LEN 16
682 typedef struct ADBDevice ADBDevice
;
684 /* buf = NULL means polling */
685 typedef int ADBDeviceRequest(ADBDevice
*d
, uint8_t *buf_out
,
686 const uint8_t *buf
, int len
);
687 typedef int ADBDeviceReset(ADBDevice
*d
);
690 struct ADBBusState
*bus
;
693 ADBDeviceRequest
*devreq
;
694 ADBDeviceReset
*devreset
;
698 typedef struct ADBBusState
{
699 ADBDevice devices
[MAX_ADB_DEVICES
];
704 int adb_request(ADBBusState
*s
, uint8_t *buf_out
,
705 const uint8_t *buf
, int len
);
706 int adb_poll(ADBBusState
*s
, uint8_t *buf_out
);
708 ADBDevice
*adb_register_device(ADBBusState
*s
, int devaddr
,
709 ADBDeviceRequest
*devreq
,
710 ADBDeviceReset
*devreset
,
712 void adb_kbd_init(ADBBusState
*bus
);
713 void adb_mouse_init(ADBBusState
*bus
);
717 extern ADBBusState adb_bus
;
718 int cuda_init(openpic_t
*openpic
, int irq
);
720 #endif /* defined(QEMU_TOOL) */
723 void monitor_init(CharDriverState
*hd
, int show_banner
);
724 void term_puts(const char *str
);
725 void term_vprintf(const char *fmt
, va_list ap
);
726 void term_printf(const char *fmt
, ...) __attribute__ ((__format__ (__printf__
, 1, 2)));
727 void term_flush(void);
728 void term_print_help(void);
729 void monitor_readline(const char *prompt
, int is_password
,
730 char *buf
, int buf_size
);
733 typedef void ReadLineFunc(void *opaque
, const char *str
);
735 extern int completion_index
;
736 void add_completion(const char *str
);
737 void readline_handle_byte(int ch
);
738 void readline_find_completion(const char *cmdline
);
739 const char *readline_get_history(unsigned int index
);
740 void readline_start(const char *prompt
, int is_password
,
741 ReadLineFunc
*readline_func
, void *opaque
);
745 #define DEFAULT_GDBSTUB_PORT 1234
747 int gdbserver_start(int port
);