ia64/xen-unstable

view tools/ioemu/vl.h @ 8740:3d7ea7972b39

Update patches for linux 2.6.15.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu Feb 02 17:16:00 2006 +0000 (2006-02-02)
parents b29954d81e6d
children d4e433d615b0
line source
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
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"
42 #ifndef O_LARGEFILE
43 #define O_LARGEFILE 0
44 #endif
45 #ifndef O_BINARY
46 #define O_BINARY 0
47 #endif
49 #ifdef _WIN32
50 #define lseek _lseeki64
51 #define ENOTSUP 4096
52 /* XXX: find 64 bit version */
53 #define ftruncate chsize
55 static inline char *realpath(const char *path, char *resolved_path)
56 {
57 _fullpath(resolved_path, path, _MAX_PATH);
58 return resolved_path;
59 }
60 #endif
62 #ifdef QEMU_TOOL
64 /* we use QEMU_TOOL in the command line tools which do not depend on
65 the target CPU type */
66 #include "config-host.h"
67 #include <setjmp.h>
68 #include "osdep.h"
69 #include "bswap.h"
71 #else
73 #include "cpu.h"
75 #endif /* !defined(QEMU_TOOL) */
77 #ifndef glue
78 #define xglue(x, y) x ## y
79 #define glue(x, y) xglue(x, y)
80 #define stringify(s) tostring(s)
81 #define tostring(s) #s
82 #endif
84 /* vl.c */
85 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
87 void hw_error(const char *fmt, ...);
89 int get_image_size(const char *filename);
90 int load_image(const char *filename, uint8_t *addr);
91 extern const char *bios_dir;
93 void pstrcpy(char *buf, int buf_size, const char *str);
94 char *pstrcat(char *buf, int buf_size, const char *s);
95 int strstart(const char *str, const char *val, const char **ptr);
97 extern int vm_running;
99 typedef void VMStopHandler(void *opaque, int reason);
101 int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
102 void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
104 void vm_start(void);
105 void vm_stop(int reason);
107 typedef void QEMUResetHandler(void *opaque);
109 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
110 void qemu_system_reset_request(void);
111 void qemu_system_reset(void);
112 void qemu_system_shutdown_request(void);
114 void main_loop_wait(int timeout);
116 extern int audio_enabled;
117 extern int sb16_enabled;
118 extern int adlib_enabled;
119 extern int gus_enabled;
120 extern uint64_t ram_size;
121 extern int bios_size;
122 extern int rtc_utc;
123 extern int cirrus_vga_enabled;
124 extern int graphic_width;
125 extern int graphic_height;
126 extern int graphic_depth;
128 /* XXX: make it dynamic */
129 #if defined (TARGET_PPC)
130 #define BIOS_SIZE (512 * 1024)
131 #else
132 #define BIOS_SIZE ((256 + 64) * 1024)
133 #endif
135 /* keyboard/mouse support */
137 #define MOUSE_EVENT_LBUTTON 0x01
138 #define MOUSE_EVENT_RBUTTON 0x02
139 #define MOUSE_EVENT_MBUTTON 0x04
141 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
142 typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
144 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
145 void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
147 void kbd_put_keycode(int keycode);
148 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
150 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
151 constants) */
152 #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
153 #define QEMU_KEY_BACKSPACE 0x007f
154 #define QEMU_KEY_UP QEMU_KEY_ESC1('A')
155 #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
156 #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
157 #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
158 #define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
159 #define QEMU_KEY_END QEMU_KEY_ESC1(4)
160 #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
161 #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
162 #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
164 #define QEMU_KEY_CTRL_UP 0xe400
165 #define QEMU_KEY_CTRL_DOWN 0xe401
166 #define QEMU_KEY_CTRL_LEFT 0xe402
167 #define QEMU_KEY_CTRL_RIGHT 0xe403
168 #define QEMU_KEY_CTRL_HOME 0xe404
169 #define QEMU_KEY_CTRL_END 0xe405
170 #define QEMU_KEY_CTRL_PAGEUP 0xe406
171 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407
173 void kbd_put_keysym(int keysym);
175 /* async I/O support */
177 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
178 typedef int IOCanRWHandler(void *opaque);
180 int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read,
181 IOReadHandler *fd_read, void *opaque);
182 int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read,
183 IOReadHandler *fd_read, void *opaque);
184 void qemu_del_fd_read_handler(int fd);
186 /* character device */
188 #define CHR_EVENT_BREAK 0 /* serial break char */
189 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
191 typedef void IOEventHandler(void *opaque, int event);
193 typedef struct CharDriverState {
194 int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
195 void (*chr_add_read_handler)(struct CharDriverState *s,
196 IOCanRWHandler *fd_can_read,
197 IOReadHandler *fd_read, void *opaque);
198 IOEventHandler *chr_event;
199 void (*chr_send_event)(struct CharDriverState *chr, int event);
200 void *opaque;
201 } CharDriverState;
203 void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
204 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
205 void qemu_chr_send_event(CharDriverState *s, int event);
206 void qemu_chr_add_read_handler(CharDriverState *s,
207 IOCanRWHandler *fd_can_read,
208 IOReadHandler *fd_read, void *opaque);
209 void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
211 /* consoles */
213 typedef struct DisplayState DisplayState;
214 typedef struct TextConsole TextConsole;
216 extern TextConsole *vga_console;
218 TextConsole *graphic_console_init(DisplayState *ds);
219 int is_active_console(TextConsole *s);
220 CharDriverState *text_console_init(DisplayState *ds);
221 void console_select(unsigned int index);
223 /* serial ports */
225 #define MAX_SERIAL_PORTS 4
227 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
229 /* network redirectors support */
231 #define MAX_NICS 8
233 typedef struct NetDriverState {
234 int index; /* index number in QEMU */
235 uint8_t macaddr[6];
236 char ifname[16];
237 void (*send_packet)(struct NetDriverState *nd,
238 const uint8_t *buf, int size);
239 void (*add_read_packet)(struct NetDriverState *nd,
240 IOCanRWHandler *fd_can_read,
241 IOReadHandler *fd_read, void *opaque);
242 /* tun specific data */
243 int fd;
244 /* slirp specific data */
245 } NetDriverState;
247 extern int nb_nics;
248 extern NetDriverState nd_table[MAX_NICS];
250 void qemu_send_packet(NetDriverState *nd, const uint8_t *buf, int size);
251 void qemu_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read,
252 IOReadHandler *fd_read, void *opaque);
254 /* timers */
256 typedef struct QEMUClock QEMUClock;
257 typedef struct QEMUTimer QEMUTimer;
258 typedef void QEMUTimerCB(void *opaque);
260 /* The real time clock should be used only for stuff which does not
261 change the virtual machine state, as it is run even if the virtual
262 machine is stopped. The real time clock has a frequency of 1000
263 Hz. */
264 extern QEMUClock *rt_clock;
266 /* Rge virtual clock is only run during the emulation. It is stopped
267 when the virtual machine is stopped. Virtual timers use a high
268 precision clock, usually cpu cycles (use ticks_per_sec). */
269 extern QEMUClock *vm_clock;
271 int64_t qemu_get_clock(QEMUClock *clock);
273 QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
274 void qemu_free_timer(QEMUTimer *ts);
275 void qemu_del_timer(QEMUTimer *ts);
276 void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
277 int qemu_timer_pending(QEMUTimer *ts);
279 extern int64_t ticks_per_sec;
280 extern int pit_min_timer_count;
282 void cpu_enable_ticks(void);
283 void cpu_disable_ticks(void);
285 /* VM Load/Save */
287 typedef FILE QEMUFile;
289 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
290 void qemu_put_byte(QEMUFile *f, int v);
291 void qemu_put_be16(QEMUFile *f, unsigned int v);
292 void qemu_put_be32(QEMUFile *f, unsigned int v);
293 void qemu_put_be64(QEMUFile *f, uint64_t v);
294 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
295 int qemu_get_byte(QEMUFile *f);
296 unsigned int qemu_get_be16(QEMUFile *f);
297 unsigned int qemu_get_be32(QEMUFile *f);
298 uint64_t qemu_get_be64(QEMUFile *f);
300 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
301 {
302 qemu_put_be64(f, *pv);
303 }
305 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
306 {
307 qemu_put_be32(f, *pv);
308 }
310 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
311 {
312 qemu_put_be16(f, *pv);
313 }
315 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
316 {
317 qemu_put_byte(f, *pv);
318 }
320 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
321 {
322 *pv = qemu_get_be64(f);
323 }
325 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
326 {
327 *pv = qemu_get_be32(f);
328 }
330 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
331 {
332 *pv = qemu_get_be16(f);
333 }
335 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
336 {
337 *pv = qemu_get_byte(f);
338 }
340 int64_t qemu_ftell(QEMUFile *f);
341 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
343 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
344 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
346 int qemu_loadvm(const char *filename);
347 int qemu_savevm(const char *filename);
348 int register_savevm(const char *idstr,
349 int instance_id,
350 int version_id,
351 SaveStateHandler *save_state,
352 LoadStateHandler *load_state,
353 void *opaque);
354 void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
355 void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
357 /* port-e9.c */
358 void port_e9_init(void);
360 /* block.c */
361 typedef struct BlockDriverState BlockDriverState;
362 typedef struct BlockDriver BlockDriver;
364 extern BlockDriver bdrv_raw;
365 extern BlockDriver bdrv_cow;
366 extern BlockDriver bdrv_qcow;
367 extern BlockDriver bdrv_vmdk;
368 extern BlockDriver bdrv_cloop;
370 void bdrv_init(void);
371 BlockDriver *bdrv_find_format(const char *format_name);
372 int bdrv_create(BlockDriver *drv,
373 const char *filename, int64_t size_in_sectors,
374 const char *backing_file, int flags);
375 BlockDriverState *bdrv_new(const char *device_name);
376 void bdrv_delete(BlockDriverState *bs);
377 int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
378 int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot,
379 BlockDriver *drv);
380 void bdrv_close(BlockDriverState *bs);
381 int bdrv_read(BlockDriverState *bs, int64_t sector_num,
382 uint8_t *buf, int nb_sectors);
383 int bdrv_write(BlockDriverState *bs, int64_t sector_num,
384 const uint8_t *buf, int nb_sectors);
385 void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
386 int bdrv_commit(BlockDriverState *bs);
387 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
389 #define BDRV_TYPE_HD 0
390 #define BDRV_TYPE_CDROM 1
391 #define BDRV_TYPE_FLOPPY 2
393 void bdrv_set_geometry_hint(BlockDriverState *bs,
394 int cyls, int heads, int secs);
395 void bdrv_set_type_hint(BlockDriverState *bs, int type);
396 void bdrv_get_geometry_hint(BlockDriverState *bs,
397 int *pcyls, int *pheads, int *psecs);
398 int bdrv_get_type_hint(BlockDriverState *bs);
399 int bdrv_is_removable(BlockDriverState *bs);
400 int bdrv_is_read_only(BlockDriverState *bs);
401 int bdrv_is_inserted(BlockDriverState *bs);
402 int bdrv_is_locked(BlockDriverState *bs);
403 void bdrv_set_locked(BlockDriverState *bs, int locked);
404 void bdrv_set_change_cb(BlockDriverState *bs,
405 void (*change_cb)(void *opaque), void *opaque);
406 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
407 void bdrv_info(void);
408 BlockDriverState *bdrv_find(const char *name);
409 void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
410 int bdrv_is_encrypted(BlockDriverState *bs);
411 int bdrv_set_key(BlockDriverState *bs, const char *key);
412 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
413 void *opaque);
414 const char *bdrv_get_device_name(BlockDriverState *bs);
416 int qcow_get_cluster_size(BlockDriverState *bs);
417 int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
418 const uint8_t *buf);
420 #ifndef QEMU_TOOL
421 /* ISA bus */
423 extern target_phys_addr_t isa_mem_base;
425 typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
426 typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
428 int register_ioport_read(int start, int length, int size,
429 IOPortReadFunc *func, void *opaque);
430 int register_ioport_write(int start, int length, int size,
431 IOPortWriteFunc *func, void *opaque);
432 void isa_unassign_ioport(int start, int length);
434 /* PCI bus */
436 extern int pci_enabled;
438 extern target_phys_addr_t pci_mem_base;
440 typedef struct PCIBus PCIBus;
441 typedef struct PCIDevice PCIDevice;
443 typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
444 uint32_t address, uint32_t data, int len);
445 typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
446 uint32_t address, int len);
447 typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
448 uint32_t addr, uint32_t size, int type);
450 #define PCI_ADDRESS_SPACE_MEM 0x00
451 #define PCI_ADDRESS_SPACE_IO 0x01
452 #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
454 typedef struct PCIIORegion {
455 uint32_t addr; /* current PCI mapping address. -1 means not mapped */
456 uint32_t size;
457 uint8_t type;
458 PCIMapIORegionFunc *map_func;
459 } PCIIORegion;
461 #define PCI_ROM_SLOT 6
462 #define PCI_NUM_REGIONS 7
463 struct PCIDevice {
464 /* PCI config space */
465 uint8_t config[256];
467 /* the following fields are read only */
468 PCIBus *bus;
469 int devfn;
470 char name[64];
471 PCIIORegion io_regions[PCI_NUM_REGIONS];
473 /* do not access the following fields */
474 PCIConfigReadFunc *config_read;
475 PCIConfigWriteFunc *config_write;
476 int irq_index;
477 };
479 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
480 int instance_size, int devfn,
481 PCIConfigReadFunc *config_read,
482 PCIConfigWriteFunc *config_write);
484 void pci_register_io_region(PCIDevice *pci_dev, int region_num,
485 uint32_t size, int type,
486 PCIMapIORegionFunc *map_func);
488 void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
490 uint32_t pci_default_read_config(PCIDevice *d,
491 uint32_t address, int len);
492 void pci_default_write_config(PCIDevice *d,
493 uint32_t address, uint32_t val, int len);
494 void generic_pci_save(QEMUFile* f, void *opaque);
495 int generic_pci_load(QEMUFile* f, void *opaque, int version_id);
497 extern struct PIIX3State *piix3_state;
499 PCIBus *i440fx_init(void);
500 void piix3_init(PCIBus *bus);
501 void pci_bios_init(void);
502 void pci_info(void);
504 /* temporary: will be moved in platform specific file */
505 PCIBus *pci_prep_init(void);
506 struct openpic_t;
507 void pci_pmac_set_openpic(PCIBus *bus, struct openpic_t *openpic);
508 PCIBus *pci_pmac_init(void);
510 /* openpic.c */
511 typedef struct openpic_t openpic_t;
512 void openpic_set_irq (openpic_t *opp, int n_IRQ, int level);
513 openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus);
515 /* vga.c */
517 #define VGA_RAM_SIZE (4096 * 1024)
519 struct DisplayState {
520 uint8_t *data;
521 int linesize;
522 int depth;
523 int width;
524 int height;
525 void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
526 void (*dpy_resize)(struct DisplayState *s, int w, int h);
527 void (*dpy_refresh)(struct DisplayState *s);
528 };
530 static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
531 {
532 s->dpy_update(s, x, y, w, h);
533 }
535 static inline void dpy_resize(DisplayState *s, int w, int h)
536 {
537 s->dpy_resize(s, w, h);
538 }
540 int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
541 unsigned long vga_ram_offset, int vga_ram_size);
542 void vga_update_display(void);
543 void vga_invalidate_display(void);
544 void vga_screen_dump(const char *filename);
546 /* vnc.c */
547 void vnc_display_init(DisplayState *ds, int useAlsoSDL,
548 long port, const char* connect);
550 /* cirrus_vga.c */
551 void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
552 unsigned long vga_ram_offset, int vga_ram_size);
553 void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
554 unsigned long vga_ram_offset, int vga_ram_size);
556 /* sdl.c */
557 void sdl_display_init(DisplayState *ds, int full_screen);
559 /* ide.c */
560 #define MAX_DISKS 4
562 extern BlockDriverState *bs_table[MAX_DISKS];
564 void isa_ide_init(int iobase, int iobase2, int irq,
565 BlockDriverState *hd0, BlockDriverState *hd1);
566 void pci_ide_init(PCIBus *bus, BlockDriverState **hd_table);
567 void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table);
568 int pmac_ide_init (BlockDriverState **hd_table,
569 openpic_t *openpic, int irq);
571 /* sb16.c */
572 void SB16_init (void);
574 /* adlib.c */
575 void Adlib_init (void);
577 /* gus.c */
578 void GUS_init (void);
580 /* dma.c */
581 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
582 int DMA_get_channel_mode (int nchan);
583 int DMA_read_memory (int nchan, void *buf, int pos, int size);
584 int DMA_write_memory (int nchan, void *buf, int pos, int size);
585 void DMA_hold_DREQ (int nchan);
586 void DMA_release_DREQ (int nchan);
587 void DMA_schedule(int nchan);
588 void DMA_run (void);
589 void DMA_init (int high_page_enable);
590 void DMA_register_channel (int nchan,
591 DMA_transfer_handler transfer_handler,
592 void *opaque);
593 /* fdc.c */
594 #define MAX_FD 2
595 extern BlockDriverState *fd_table[MAX_FD];
597 typedef struct fdctrl_t fdctrl_t;
599 fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
600 uint32_t io_base,
601 BlockDriverState **fds);
602 int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
604 /* ne2000.c */
606 void isa_ne2000_init(int base, int irq, NetDriverState *nd);
607 void pci_ne2000_init(PCIBus *bus, NetDriverState *nd);
609 /* pcnet.c */
611 extern int nic_ne2000;
613 void pci_pcnet_init(PCIBus *bus, NetDriverState *nd);
615 /* pckbd.c */
617 void kbd_init(void);
618 extern const char* keyboard_layout;
619 extern int repeat_key;
621 /* mc146818rtc.c */
623 typedef struct RTCState RTCState;
625 RTCState *rtc_init(int base, int irq);
626 void rtc_set_memory(RTCState *s, int addr, int val);
627 void rtc_set_date(RTCState *s, const struct tm *tm);
629 /* serial.c */
631 typedef struct SerialState SerialState;
632 SerialState *serial_init(int base, int irq, CharDriverState *chr);
634 /* i8259.c */
636 void pic_set_irq(int irq, int level);
637 void pic_init(void);
638 uint32_t pic_intack_read(CPUState *env);
639 void pic_info(void);
640 void irq_info(void);
641 void sp_info(void);
642 int pic_irq2vec(int irq);
644 /* i8254.c */
646 #define PIT_FREQ 1193182
648 typedef struct PITState PITState;
650 PITState *pit_init(int base, int irq);
651 void pit_set_gate(PITState *pit, int channel, int val);
652 int pit_get_gate(PITState *pit, int channel);
653 int pit_get_out(PITState *pit, int channel, int64_t current_time);
655 /* pc.c */
656 void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device,
657 DisplayState *ds, const char **fd_filename, int snapshot,
658 const char *kernel_filename, const char *kernel_cmdline,
659 const char *initrd_filename);
661 /* ppc.c */
662 void ppc_init (int ram_size, int vga_ram_size, int boot_device,
663 DisplayState *ds, const char **fd_filename, int snapshot,
664 const char *kernel_filename, const char *kernel_cmdline,
665 const char *initrd_filename);
666 void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
667 DisplayState *ds, const char **fd_filename, int snapshot,
668 const char *kernel_filename, const char *kernel_cmdline,
669 const char *initrd_filename);
670 void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
671 DisplayState *ds, const char **fd_filename, int snapshot,
672 const char *kernel_filename, const char *kernel_cmdline,
673 const char *initrd_filename);
674 #ifdef TARGET_PPC
675 ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
676 #endif
677 void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
679 extern CPUWriteMemoryFunc *PPC_io_write[];
680 extern CPUReadMemoryFunc *PPC_io_read[];
681 extern int prep_enabled;
683 /* sun4m.c */
684 void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
685 DisplayState *ds, const char **fd_filename, int snapshot,
686 const char *kernel_filename, const char *kernel_cmdline,
687 const char *initrd_filename);
689 /* iommu.c */
690 void iommu_init(uint32_t addr);
691 uint32_t iommu_translate(uint32_t addr);
693 /* lance.c */
694 void lance_init(NetDriverState *nd, int irq, uint32_t leaddr, uint32_t ledaddr);
696 /* tcx.c */
697 void tcx_init(DisplayState *ds, uint32_t addr);
699 /* sched.c */
700 void sched_init();
702 /* magic-load.c */
703 void magic_init(const char *kfn, int kloadaddr, uint32_t addr);
705 /* timer.c */
706 void timer_init(uint32_t addr, int irq);
708 /* NVRAM helpers */
709 #include "hw/m48t59.h"
711 void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
712 uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
713 void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
714 uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
715 void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
716 uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
717 void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
718 const unsigned char *str, uint32_t max);
719 int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
720 void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
721 uint32_t start, uint32_t count);
722 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
723 const unsigned char *arch,
724 uint32_t RAM_size, int boot_device,
725 uint32_t kernel_image, uint32_t kernel_size,
726 const char *cmdline,
727 uint32_t initrd_image, uint32_t initrd_size,
728 uint32_t NVRAM_image,
729 int width, int height, int depth);
731 /* adb.c */
733 #define MAX_ADB_DEVICES 16
735 #define ADB_MAX_OUT_LEN 16
737 typedef struct ADBDevice ADBDevice;
739 /* buf = NULL means polling */
740 typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
741 const uint8_t *buf, int len);
742 typedef int ADBDeviceReset(ADBDevice *d);
744 struct ADBDevice {
745 struct ADBBusState *bus;
746 int devaddr;
747 int handler;
748 ADBDeviceRequest *devreq;
749 ADBDeviceReset *devreset;
750 void *opaque;
751 };
753 typedef struct ADBBusState {
754 ADBDevice devices[MAX_ADB_DEVICES];
755 int nb_devices;
756 int poll_index;
757 } ADBBusState;
759 int adb_request(ADBBusState *s, uint8_t *buf_out,
760 const uint8_t *buf, int len);
761 int adb_poll(ADBBusState *s, uint8_t *buf_out);
763 ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
764 ADBDeviceRequest *devreq,
765 ADBDeviceReset *devreset,
766 void *opaque);
767 void adb_kbd_init(ADBBusState *bus);
768 void adb_mouse_init(ADBBusState *bus);
770 /* cuda.c */
772 extern ADBBusState adb_bus;
773 int cuda_init(openpic_t *openpic, int irq);
775 #endif /* defined(QEMU_TOOL) */
777 /* monitor.c */
778 void monitor_init(CharDriverState *hd, int show_banner);
779 void term_puts(const char *str);
780 void term_vprintf(const char *fmt, va_list ap);
781 void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
782 void term_flush(void);
783 void term_print_help(void);
785 /* readline.c */
786 typedef void ReadLineFunc(void *opaque, const char *str);
788 extern int completion_index;
789 void add_completion(const char *str);
790 void readline_handle_byte(int ch);
791 void readline_find_completion(const char *cmdline);
792 const char *readline_get_history(unsigned int index);
793 void readline_start(const char *prompt, int is_password,
794 ReadLineFunc *readline_func, void *opaque);
796 /* gdbstub.c */
798 #define DEFAULT_GDBSTUB_PORT 1234
800 int gdbserver_start(int port);
801 void update_select_wakeup_events(void);
802 void tun_receive_handler();
804 extern char domain_name[];
805 #endif /* VL_H */