ia64/xen-unstable

view tools/ioemu/vl.h @ 10078:345464c2fd47

Allow to specify different time-of-day clock offsets for HVM guests.

There are some usage scenarios in which differing user domains want
to be using different base TOD clocks. This patch adds the ability
to specify the base TOD time difference. The patch also adds a
hook point to notify another entity when the domain changes this
offset. This might occur, for instance, on a Linux domain using
hwclock -w.

Signed-off-by: Ben Thomas <ben@virtualiron.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed May 17 23:43:32 2006 +0100 (2006-05-17)
parents c92fbde4074d
children 61e2ea81bd65
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"
41 #include "xenctrl.h"
42 #include "xs.h"
44 #ifndef O_LARGEFILE
45 #define O_LARGEFILE 0
46 #endif
47 #ifndef O_BINARY
48 #define O_BINARY 0
49 #endif
51 #ifdef _WIN32
52 #define lseek _lseeki64
53 #define ENOTSUP 4096
54 /* XXX: find 64 bit version */
55 #define ftruncate chsize
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 #endif
64 #ifdef QEMU_TOOL
66 /* we use QEMU_TOOL in the command line tools which do not depend on
67 the target CPU type */
68 #include "config-host.h"
69 #include <setjmp.h>
70 #include "osdep.h"
71 #include "bswap.h"
73 #else
75 #include "cpu.h"
77 #endif /* !defined(QEMU_TOOL) */
79 #ifndef glue
80 #define xglue(x, y) x ## y
81 #define glue(x, y) xglue(x, y)
82 #define stringify(s) tostring(s)
83 #define tostring(s) #s
84 #endif
86 /* vl.c */
87 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
89 void hw_error(const char *fmt, ...);
91 int get_image_size(const char *filename);
92 int load_image(const char *filename, uint8_t *addr);
93 extern const char *bios_dir;
95 void pstrcpy(char *buf, int buf_size, const char *str);
96 char *pstrcat(char *buf, int buf_size, const char *s);
97 int strstart(const char *str, const char *val, const char **ptr);
99 extern int vm_running;
101 typedef void VMStopHandler(void *opaque, int reason);
103 int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
104 void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
106 void vm_start(void);
107 void vm_stop(int reason);
109 typedef void QEMUResetHandler(void *opaque);
111 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
112 void qemu_system_reset_request(void);
113 void qemu_system_reset(void);
114 void qemu_system_shutdown_request(void);
116 void main_loop_wait(int timeout);
118 int unset_mm_mapping(int xc_handle,
119 uint32_t domid,
120 unsigned long nr_pages,
121 unsigned int address_bits,
122 unsigned long *extent_start);
123 int set_mm_mapping(int xc_handle,
124 uint32_t domid,
125 unsigned long nr_pages,
126 unsigned int address_bits,
127 unsigned long *extent_start);
129 extern int xc_handle;
130 extern int domid;
131 extern int audio_enabled;
132 extern int sb16_enabled;
133 extern int adlib_enabled;
134 extern int gus_enabled;
135 extern uint64_t ram_size;
136 extern int bios_size;
137 extern int rtc_utc;
138 extern int cirrus_vga_enabled;
139 extern int graphic_width;
140 extern int graphic_height;
141 extern int graphic_depth;
143 /* XXX: make it dynamic */
144 #if defined (TARGET_PPC)
145 #define BIOS_SIZE (512 * 1024)
146 #else
147 #define BIOS_SIZE ((256 + 64) * 1024)
148 #endif
150 /* keyboard/mouse support */
152 #define MOUSE_EVENT_LBUTTON 0x01
153 #define MOUSE_EVENT_RBUTTON 0x02
154 #define MOUSE_EVENT_MBUTTON 0x04
156 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
157 typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state, int x, int y);
159 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
160 void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
162 void kbd_put_keycode(int keycode);
163 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state, int x, int y);
165 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
166 constants) */
167 #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
168 #define QEMU_KEY_BACKSPACE 0x007f
169 #define QEMU_KEY_UP QEMU_KEY_ESC1('A')
170 #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
171 #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
172 #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
173 #define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
174 #define QEMU_KEY_END QEMU_KEY_ESC1(4)
175 #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
176 #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
177 #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
179 #define QEMU_KEY_CTRL_UP 0xe400
180 #define QEMU_KEY_CTRL_DOWN 0xe401
181 #define QEMU_KEY_CTRL_LEFT 0xe402
182 #define QEMU_KEY_CTRL_RIGHT 0xe403
183 #define QEMU_KEY_CTRL_HOME 0xe404
184 #define QEMU_KEY_CTRL_END 0xe405
185 #define QEMU_KEY_CTRL_PAGEUP 0xe406
186 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407
188 void kbd_put_keysym(int keysym);
190 /* async I/O support */
192 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
193 typedef int IOCanRWHandler(void *opaque);
195 int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read,
196 IOReadHandler *fd_read, void *opaque);
197 int qemu_add_fd_event_read_handler(int fd, IOCanRWHandler *fd_can_read,
198 IOReadHandler *fd_read, void *opaque);
199 void qemu_del_fd_read_handler(int fd);
201 /* character device */
203 #define CHR_EVENT_BREAK 0 /* serial break char */
204 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
206 typedef void IOEventHandler(void *opaque, int event);
208 typedef struct CharDriverState {
209 int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
210 void (*chr_add_read_handler)(struct CharDriverState *s,
211 IOCanRWHandler *fd_can_read,
212 IOReadHandler *fd_read, void *opaque);
213 IOEventHandler *chr_event;
214 void (*chr_send_event)(struct CharDriverState *chr, int event);
215 void *opaque;
216 } CharDriverState;
218 void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
219 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
220 void qemu_chr_send_event(CharDriverState *s, int event);
221 void qemu_chr_add_read_handler(CharDriverState *s,
222 IOCanRWHandler *fd_can_read,
223 IOReadHandler *fd_read, void *opaque);
224 void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
226 /* consoles */
228 typedef struct DisplayState DisplayState;
229 typedef struct TextConsole TextConsole;
231 extern TextConsole *vga_console;
233 TextConsole *graphic_console_init(DisplayState *ds);
234 int is_active_console(TextConsole *s);
235 CharDriverState *text_console_init(DisplayState *ds);
236 void console_select(unsigned int index);
238 /* serial ports */
240 #define MAX_SERIAL_PORTS 4
241 #define SUMMA_PORT 1
243 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
245 /* network redirectors support */
247 #define MAX_NICS 8
249 typedef struct NetDriverState {
250 int index; /* index number in QEMU */
251 uint8_t macaddr[6];
252 char ifname[16];
253 void (*send_packet)(struct NetDriverState *nd,
254 const uint8_t *buf, int size);
255 void (*add_read_packet)(struct NetDriverState *nd,
256 IOCanRWHandler *fd_can_read,
257 IOReadHandler *fd_read, void *opaque);
258 /* tun specific data */
259 int fd;
260 /* slirp specific data */
261 } NetDriverState;
263 extern int nb_nics;
264 extern NetDriverState nd_table[MAX_NICS];
266 void qemu_send_packet(NetDriverState *nd, const uint8_t *buf, int size);
267 void qemu_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read,
268 IOReadHandler *fd_read, void *opaque);
270 /* timers */
272 typedef struct QEMUClock QEMUClock;
273 typedef struct QEMUTimer QEMUTimer;
274 typedef void QEMUTimerCB(void *opaque);
276 /* The real time clock should be used only for stuff which does not
277 change the virtual machine state, as it is run even if the virtual
278 machine is stopped. The real time clock has a frequency of 1000
279 Hz. */
280 extern QEMUClock *rt_clock;
282 /* Rge virtual clock is only run during the emulation. It is stopped
283 when the virtual machine is stopped. Virtual timers use a high
284 precision clock, usually cpu cycles (use ticks_per_sec). */
285 extern QEMUClock *vm_clock;
287 int64_t qemu_get_clock(QEMUClock *clock);
289 QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
290 void qemu_free_timer(QEMUTimer *ts);
291 void qemu_del_timer(QEMUTimer *ts);
292 void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
293 int qemu_timer_pending(QEMUTimer *ts);
295 extern int64_t ticks_per_sec;
296 extern int pit_min_timer_count;
298 void cpu_enable_ticks(void);
299 void cpu_disable_ticks(void);
301 /* VM Load/Save */
303 typedef FILE QEMUFile;
305 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
306 void qemu_put_byte(QEMUFile *f, int v);
307 void qemu_put_be16(QEMUFile *f, unsigned int v);
308 void qemu_put_be32(QEMUFile *f, unsigned int v);
309 void qemu_put_be64(QEMUFile *f, uint64_t v);
310 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
311 int qemu_get_byte(QEMUFile *f);
312 unsigned int qemu_get_be16(QEMUFile *f);
313 unsigned int qemu_get_be32(QEMUFile *f);
314 uint64_t qemu_get_be64(QEMUFile *f);
316 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
317 {
318 qemu_put_be64(f, *pv);
319 }
321 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
322 {
323 qemu_put_be32(f, *pv);
324 }
326 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
327 {
328 qemu_put_be16(f, *pv);
329 }
331 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
332 {
333 qemu_put_byte(f, *pv);
334 }
336 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
337 {
338 *pv = qemu_get_be64(f);
339 }
341 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
342 {
343 *pv = qemu_get_be32(f);
344 }
346 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
347 {
348 *pv = qemu_get_be16(f);
349 }
351 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
352 {
353 *pv = qemu_get_byte(f);
354 }
356 int64_t qemu_ftell(QEMUFile *f);
357 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
359 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
360 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
362 int qemu_loadvm(const char *filename);
363 int qemu_savevm(const char *filename);
364 int register_savevm(const char *idstr,
365 int instance_id,
366 int version_id,
367 SaveStateHandler *save_state,
368 LoadStateHandler *load_state,
369 void *opaque);
370 void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
371 void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
373 /* port-e9.c */
374 void port_e9_init(void);
376 /* block.c */
377 typedef struct BlockDriverState BlockDriverState;
378 typedef struct BlockDriver BlockDriver;
380 extern BlockDriver bdrv_raw;
381 extern BlockDriver bdrv_cow;
382 extern BlockDriver bdrv_qcow;
383 extern BlockDriver bdrv_vmdk;
384 extern BlockDriver bdrv_cloop;
386 void bdrv_init(void);
387 BlockDriver *bdrv_find_format(const char *format_name);
388 int bdrv_create(BlockDriver *drv,
389 const char *filename, int64_t size_in_sectors,
390 const char *backing_file, int flags);
391 BlockDriverState *bdrv_new(const char *device_name);
392 void bdrv_delete(BlockDriverState *bs);
393 int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
394 int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot,
395 BlockDriver *drv);
396 void bdrv_close(BlockDriverState *bs);
397 int bdrv_read(BlockDriverState *bs, int64_t sector_num,
398 uint8_t *buf, int nb_sectors);
399 int bdrv_write(BlockDriverState *bs, int64_t sector_num,
400 const uint8_t *buf, int nb_sectors);
401 void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
402 int bdrv_commit(BlockDriverState *bs);
403 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
405 #define BDRV_TYPE_HD 0
406 #define BDRV_TYPE_CDROM 1
407 #define BDRV_TYPE_FLOPPY 2
409 void bdrv_set_geometry_hint(BlockDriverState *bs,
410 int cyls, int heads, int secs);
411 void bdrv_set_type_hint(BlockDriverState *bs, int type);
412 void bdrv_get_geometry_hint(BlockDriverState *bs,
413 int *pcyls, int *pheads, int *psecs);
414 int bdrv_get_type_hint(BlockDriverState *bs);
415 int bdrv_is_removable(BlockDriverState *bs);
416 int bdrv_is_read_only(BlockDriverState *bs);
417 int bdrv_is_inserted(BlockDriverState *bs);
418 int bdrv_is_locked(BlockDriverState *bs);
419 void bdrv_set_locked(BlockDriverState *bs, int locked);
420 void bdrv_set_change_cb(BlockDriverState *bs,
421 void (*change_cb)(void *opaque), void *opaque);
422 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
423 void bdrv_info(void);
424 BlockDriverState *bdrv_find(const char *name);
425 void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
426 int bdrv_is_encrypted(BlockDriverState *bs);
427 int bdrv_set_key(BlockDriverState *bs, const char *key);
428 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
429 void *opaque);
430 const char *bdrv_get_device_name(BlockDriverState *bs);
432 int qcow_get_cluster_size(BlockDriverState *bs);
433 int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
434 const uint8_t *buf);
436 #ifndef QEMU_TOOL
437 /* ISA bus */
439 extern target_phys_addr_t isa_mem_base;
441 typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
442 typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
444 int register_ioport_read(int start, int length, int size,
445 IOPortReadFunc *func, void *opaque);
446 int register_ioport_write(int start, int length, int size,
447 IOPortWriteFunc *func, void *opaque);
448 void isa_unassign_ioport(int start, int length);
450 /* PCI bus */
452 extern int pci_enabled;
454 extern target_phys_addr_t pci_mem_base;
456 typedef struct PCIBus PCIBus;
457 typedef struct PCIDevice PCIDevice;
459 typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
460 uint32_t address, uint32_t data, int len);
461 typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
462 uint32_t address, int len);
463 typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
464 uint32_t addr, uint32_t size, int type);
466 #define PCI_ADDRESS_SPACE_MEM 0x00
467 #define PCI_ADDRESS_SPACE_IO 0x01
468 #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
470 typedef struct PCIIORegion {
471 uint32_t addr; /* current PCI mapping address. -1 means not mapped */
472 uint32_t size;
473 uint8_t type;
474 PCIMapIORegionFunc *map_func;
475 } PCIIORegion;
477 #define PCI_ROM_SLOT 6
478 #define PCI_NUM_REGIONS 7
479 struct PCIDevice {
480 /* PCI config space */
481 uint8_t config[256];
483 /* the following fields are read only */
484 PCIBus *bus;
485 int devfn;
486 char name[64];
487 PCIIORegion io_regions[PCI_NUM_REGIONS];
489 /* do not access the following fields */
490 PCIConfigReadFunc *config_read;
491 PCIConfigWriteFunc *config_write;
492 int irq_index;
493 };
495 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
496 int instance_size, int devfn,
497 PCIConfigReadFunc *config_read,
498 PCIConfigWriteFunc *config_write);
500 void pci_register_io_region(PCIDevice *pci_dev, int region_num,
501 uint32_t size, int type,
502 PCIMapIORegionFunc *map_func);
504 void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
506 uint32_t pci_default_read_config(PCIDevice *d,
507 uint32_t address, int len);
508 void pci_default_write_config(PCIDevice *d,
509 uint32_t address, uint32_t val, int len);
510 void generic_pci_save(QEMUFile* f, void *opaque);
511 int generic_pci_load(QEMUFile* f, void *opaque, int version_id);
513 extern struct PIIX3State *piix3_state;
515 PCIBus *i440fx_init(void);
516 void piix3_init(PCIBus *bus);
517 void pci_bios_init(void);
518 void pci_info(void);
520 /* temporary: will be moved in platform specific file */
521 PCIBus *pci_prep_init(void);
522 struct openpic_t;
523 void pci_pmac_set_openpic(PCIBus *bus, struct openpic_t *openpic);
524 PCIBus *pci_pmac_init(void);
526 /* openpic.c */
527 typedef struct openpic_t openpic_t;
528 void openpic_set_irq (openpic_t *opp, int n_IRQ, int level);
529 openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus);
531 /* vga.c */
533 #define VGA_RAM_SIZE (4096 * 1024)
535 struct DisplayState {
536 uint8_t *data;
537 int linesize;
538 int depth;
539 int width;
540 int height;
541 void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
542 void (*dpy_resize)(struct DisplayState *s, int w, int h);
543 void (*dpy_refresh)(struct DisplayState *s);
544 };
546 static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
547 {
548 s->dpy_update(s, x, y, w, h);
549 }
551 static inline void dpy_resize(DisplayState *s, int w, int h)
552 {
553 s->dpy_resize(s, w, h);
554 }
556 int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
557 unsigned long vga_ram_offset, int vga_ram_size);
558 void vga_update_display(void);
559 void vga_invalidate_display(void);
560 void vga_screen_dump(const char *filename);
562 /* vnc.c */
563 void vnc_display_init(DisplayState *ds, int useAlsoSDL,
564 long port, const char* connect);
566 /* cirrus_vga.c */
567 void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
568 unsigned long vga_ram_offset, int vga_ram_size);
569 void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
570 unsigned long vga_ram_offset, int vga_ram_size);
572 /* sdl.c */
573 void sdl_display_init(DisplayState *ds, int full_screen);
575 /* ide.c */
576 #define MAX_DISKS 4
578 extern BlockDriverState *bs_table[MAX_DISKS];
580 void isa_ide_init(int iobase, int iobase2, int irq,
581 BlockDriverState *hd0, BlockDriverState *hd1);
582 void pci_ide_init(PCIBus *bus, BlockDriverState **hd_table);
583 void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table);
584 int pmac_ide_init (BlockDriverState **hd_table,
585 openpic_t *openpic, int irq);
587 /* sb16.c */
588 void SB16_init (void);
590 /* adlib.c */
591 void Adlib_init (void);
593 /* gus.c */
594 void GUS_init (void);
596 /* dma.c */
597 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
598 int DMA_get_channel_mode (int nchan);
599 int DMA_read_memory (int nchan, void *buf, int pos, int size);
600 int DMA_write_memory (int nchan, void *buf, int pos, int size);
601 void DMA_hold_DREQ (int nchan);
602 void DMA_release_DREQ (int nchan);
603 void DMA_schedule(int nchan);
604 void DMA_run (void);
605 void DMA_init (int high_page_enable);
606 void DMA_register_channel (int nchan,
607 DMA_transfer_handler transfer_handler,
608 void *opaque);
609 /* fdc.c */
610 #define MAX_FD 2
611 extern BlockDriverState *fd_table[MAX_FD];
613 typedef struct fdctrl_t fdctrl_t;
615 fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
616 uint32_t io_base,
617 BlockDriverState **fds);
618 int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
620 /* ne2000.c */
622 void isa_ne2000_init(int base, int irq, NetDriverState *nd);
623 void pci_ne2000_init(PCIBus *bus, NetDriverState *nd);
625 /* pcnet.c */
627 extern int nic_ne2000;
629 void pci_pcnet_init(PCIBus *bus, NetDriverState *nd);
631 /* pckbd.c */
633 void kbd_init(void);
634 extern const char* keyboard_layout;
635 extern int repeat_key;
637 /* mc146818rtc.c */
639 typedef struct RTCState RTCState;
641 RTCState *rtc_init(int base, int irq);
642 void rtc_set_memory(RTCState *s, int addr, int val);
643 void rtc_set_date(RTCState *s, const struct tm *tm);
645 /* serial.c */
647 typedef struct SerialState SerialState;
648 SerialState *serial_init(int base, int irq, CharDriverState *chr);
649 void ser_queue(SerialState *s, unsigned char c);
651 /* Mice */
653 void summa_init(SerialState *serial, CharDriverState *chr);
655 extern int summa_ok;
657 /* i8259.c */
659 void pic_set_irq(int irq, int level);
660 void pic_init(void);
661 uint32_t pic_intack_read(CPUState *env);
662 void pic_info(void);
663 void irq_info(void);
664 void sp_info(void);
665 int pic_irq2vec(int irq);
667 /* i8254.c */
669 #define PIT_FREQ 1193182
671 typedef struct PITState PITState;
673 PITState *pit_init(int base, int irq);
674 void pit_set_gate(PITState *pit, int channel, int val);
675 int pit_get_gate(PITState *pit, int channel);
676 int pit_get_out(PITState *pit, int channel, int64_t current_time);
678 /* pc.c */
679 void pc_init(uint64_t ram_size, int vga_ram_size, int boot_device,
680 DisplayState *ds, const char **fd_filename, int snapshot,
681 const char *kernel_filename, const char *kernel_cmdline,
682 const char *initrd_filename, time_t timeoffset);
684 /* ppc.c */
685 void ppc_init (int ram_size, int vga_ram_size, int boot_device,
686 DisplayState *ds, const char **fd_filename, int snapshot,
687 const char *kernel_filename, const char *kernel_cmdline,
688 const char *initrd_filename);
689 void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
690 DisplayState *ds, const char **fd_filename, int snapshot,
691 const char *kernel_filename, const char *kernel_cmdline,
692 const char *initrd_filename);
693 void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
694 DisplayState *ds, const char **fd_filename, int snapshot,
695 const char *kernel_filename, const char *kernel_cmdline,
696 const char *initrd_filename);
697 #ifdef TARGET_PPC
698 ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
699 #endif
700 void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
702 extern CPUWriteMemoryFunc *PPC_io_write[];
703 extern CPUReadMemoryFunc *PPC_io_read[];
704 extern int prep_enabled;
706 /* sun4m.c */
707 void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
708 DisplayState *ds, const char **fd_filename, int snapshot,
709 const char *kernel_filename, const char *kernel_cmdline,
710 const char *initrd_filename);
712 /* iommu.c */
713 void iommu_init(uint32_t addr);
714 uint32_t iommu_translate(uint32_t addr);
716 /* lance.c */
717 void lance_init(NetDriverState *nd, int irq, uint32_t leaddr, uint32_t ledaddr);
719 /* tcx.c */
720 void tcx_init(DisplayState *ds, uint32_t addr);
722 /* sched.c */
723 void sched_init(uint32_t, uint32_t);
725 /* magic-load.c */
726 void magic_init(const char *kfn, int kloadaddr, uint32_t addr);
728 /* timer.c */
729 void timer_init(uint32_t addr, int irq);
731 /* NVRAM helpers */
732 #include "hw/m48t59.h"
734 void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
735 uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
736 void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
737 uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
738 void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
739 uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
740 void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
741 const unsigned char *str, uint32_t max);
742 int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
743 void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
744 uint32_t start, uint32_t count);
745 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
746 const unsigned char *arch,
747 uint32_t RAM_size, int boot_device,
748 uint32_t kernel_image, uint32_t kernel_size,
749 const char *cmdline,
750 uint32_t initrd_image, uint32_t initrd_size,
751 uint32_t NVRAM_image,
752 int width, int height, int depth);
754 /* adb.c */
756 #define MAX_ADB_DEVICES 16
758 #define ADB_MAX_OUT_LEN 16
760 typedef struct ADBDevice ADBDevice;
762 /* buf = NULL means polling */
763 typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
764 const uint8_t *buf, int len);
765 typedef int ADBDeviceReset(ADBDevice *d);
767 struct ADBDevice {
768 struct ADBBusState *bus;
769 int devaddr;
770 int handler;
771 ADBDeviceRequest *devreq;
772 ADBDeviceReset *devreset;
773 void *opaque;
774 };
776 typedef struct ADBBusState {
777 ADBDevice devices[MAX_ADB_DEVICES];
778 int nb_devices;
779 int poll_index;
780 } ADBBusState;
782 int adb_request(ADBBusState *s, uint8_t *buf_out,
783 const uint8_t *buf, int len);
784 int adb_poll(ADBBusState *s, uint8_t *buf_out);
786 ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
787 ADBDeviceRequest *devreq,
788 ADBDeviceReset *devreset,
789 void *opaque);
790 void adb_kbd_init(ADBBusState *bus);
791 void adb_mouse_init(ADBBusState *bus);
793 /* cuda.c */
795 extern ADBBusState adb_bus;
796 int cuda_init(openpic_t *openpic, int irq);
798 #endif /* defined(QEMU_TOOL) */
800 /* monitor.c */
801 void monitor_init(CharDriverState *hd, int show_banner);
802 void term_puts(const char *str);
803 void term_vprintf(const char *fmt, va_list ap);
804 void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
805 void term_flush(void);
806 void term_print_help(void);
808 /* readline.c */
809 typedef void ReadLineFunc(void *opaque, const char *str);
811 extern int completion_index;
812 void add_completion(const char *str);
813 void readline_handle_byte(int ch);
814 void readline_find_completion(const char *cmdline);
815 const char *readline_get_history(unsigned int index);
816 void readline_start(const char *prompt, int is_password,
817 ReadLineFunc *readline_func, void *opaque);
819 /* gdbstub.c */
821 #define DEFAULT_GDBSTUB_PORT 1234
823 int gdbserver_start(int port);
824 void update_select_wakeup_events(void);
825 void tun_receive_handler(fd_set *);
827 extern char domain_name[];
828 #endif /* VL_H */