]> git.proxmox.com Git - qemu.git/blob - vl.h
new disk image layer
[qemu.git] / vl.h
1 /*
2 * QEMU System Emulator header
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 #ifndef VL_H
25 #define VL_H
26
27 /* we put basic includes here to avoid repeating them in device drivers */
28 #include <stdlib.h>
29 #include <stdio.h>
30 #include <stdarg.h>
31 #include <string.h>
32 #include <inttypes.h>
33 #include <time.h>
34 #include <ctype.h>
35 #include <errno.h>
36 #include <unistd.h>
37 #include <fcntl.h>
38 #include <sys/stat.h>
39
40 #ifndef O_LARGEFILE
41 #define O_LARGEFILE 0
42 #endif
43 #ifndef O_BINARY
44 #define O_BINARY 0
45 #endif
46
47 #ifdef _WIN32
48 #define lseek64 _lseeki64
49 #endif
50
51 #ifdef QEMU_TOOL
52
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"
56 #include <setjmp.h>
57 #include "osdep.h"
58 #include "bswap.h"
59
60 #else
61
62 #include "cpu.h"
63
64 #endif /* !defined(QEMU_TOOL) */
65
66 #ifndef glue
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
71 #endif
72
73 /* vl.c */
74 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
75
76 void hw_error(const char *fmt, ...);
77
78 int get_image_size(const char *filename);
79 int load_image(const char *filename, uint8_t *addr);
80 extern const char *bios_dir;
81
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);
85
86 extern int vm_running;
87
88 typedef void VMStopHandler(void *opaque, int reason);
89
90 int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
91 void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
92
93 void vm_start(void);
94 void vm_stop(int reason);
95
96 typedef void QEMUResetHandler(void *opaque);
97
98 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
99 void qemu_system_reset_request(void);
100 void qemu_system_shutdown_request(void);
101
102 void main_loop_wait(int timeout);
103
104 extern int audio_enabled;
105 extern int ram_size;
106 extern int bios_size;
107 extern int rtc_utc;
108 extern int cirrus_vga_enabled;
109 extern int graphic_width;
110 extern int graphic_height;
111 extern int graphic_depth;
112
113 /* XXX: make it dynamic */
114 #if defined (TARGET_PPC)
115 #define BIOS_SIZE (512 * 1024)
116 #else
117 #define BIOS_SIZE ((256 + 64) * 1024)
118 #endif
119
120 /* keyboard/mouse support */
121
122 #define MOUSE_EVENT_LBUTTON 0x01
123 #define MOUSE_EVENT_RBUTTON 0x02
124 #define MOUSE_EVENT_MBUTTON 0x04
125
126 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
127 typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
128
129 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
130 void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
131
132 void kbd_put_keycode(int keycode);
133 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
134
135 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
136 constants) */
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)
148
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
157
158 void kbd_put_keysym(int keysym);
159
160 /* async I/O support */
161
162 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
163 typedef int IOCanRWHandler(void *opaque);
164
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);
168
169 /* character device */
170
171 #define CHR_EVENT_BREAK 0 /* serial break char */
172 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
173
174 typedef void IOEventHandler(void *opaque, int event);
175
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;
183 void *opaque;
184 } CharDriverState;
185
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);
193
194 CharDriverState *serial_hd;
195
196 /* consoles */
197
198 typedef struct DisplayState DisplayState;
199 typedef struct TextConsole TextConsole;
200
201 extern TextConsole *vga_console;
202
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);
207
208 /* network redirectors support */
209
210 #define MAX_NICS 8
211
212 typedef struct NetDriverState {
213 int index; /* index number in QEMU */
214 uint8_t macaddr[6];
215 char ifname[16];
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 */
222 int fd;
223 /* slirp specific data */
224 } NetDriverState;
225
226 extern int nb_nics;
227 extern NetDriverState nd_table[MAX_NICS];
228
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);
232
233 /* timers */
234
235 typedef struct QEMUClock QEMUClock;
236 typedef struct QEMUTimer QEMUTimer;
237 typedef void QEMUTimerCB(void *opaque);
238
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
242 Hz. */
243 extern QEMUClock *rt_clock;
244
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;
249
250 int64_t qemu_get_clock(QEMUClock *clock);
251
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);
257
258 extern int64_t ticks_per_sec;
259 extern int pit_min_timer_count;
260
261 void cpu_enable_ticks(void);
262 void cpu_disable_ticks(void);
263
264 /* VM Load/Save */
265
266 typedef FILE QEMUFile;
267
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);
278
279 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
280 {
281 qemu_put_be64(f, *pv);
282 }
283
284 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
285 {
286 qemu_put_be32(f, *pv);
287 }
288
289 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
290 {
291 qemu_put_be16(f, *pv);
292 }
293
294 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
295 {
296 qemu_put_byte(f, *pv);
297 }
298
299 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
300 {
301 *pv = qemu_get_be64(f);
302 }
303
304 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
305 {
306 *pv = qemu_get_be32(f);
307 }
308
309 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
310 {
311 *pv = qemu_get_be16(f);
312 }
313
314 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
315 {
316 *pv = qemu_get_byte(f);
317 }
318
319 int64_t qemu_ftell(QEMUFile *f);
320 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
321
322 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
323 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
324
325 int qemu_loadvm(const char *filename);
326 int qemu_savevm(const char *filename);
327 int register_savevm(const char *idstr,
328 int instance_id,
329 int version_id,
330 SaveStateHandler *save_state,
331 LoadStateHandler *load_state,
332 void *opaque);
333 void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
334 void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
335
336 /* block.c */
337 typedef struct BlockDriverState BlockDriverState;
338 typedef struct BlockDriver BlockDriver;
339
340 extern BlockDriver bdrv_raw;
341 extern BlockDriver bdrv_cow;
342 extern BlockDriver bdrv_qcow;
343 extern BlockDriver bdrv_vmdk;
344
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,
354 BlockDriver *drv);
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);
363
364 #define BDRV_TYPE_HD 0
365 #define BDRV_TYPE_CDROM 1
366 #define BDRV_TYPE_FLOPPY 2
367
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),
388 void *opaque);
389 const char *bdrv_get_device_name(BlockDriverState *bs);
390
391 int qcow_get_cluster_size(BlockDriverState *bs);
392 int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
393 const uint8_t *buf);
394
395 #ifndef QEMU_TOOL
396 /* ISA bus */
397
398 extern target_phys_addr_t isa_mem_base;
399
400 typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
401 typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
402
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);
408
409 /* PCI bus */
410
411 extern int pci_enabled;
412
413 extern target_phys_addr_t pci_mem_base;
414
415 typedef struct PCIBus PCIBus;
416 typedef struct PCIDevice PCIDevice;
417
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);
424
425 #define PCI_ADDRESS_SPACE_MEM 0x00
426 #define PCI_ADDRESS_SPACE_IO 0x01
427 #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
428
429 typedef struct PCIIORegion {
430 uint32_t addr; /* current PCI mapping address. -1 means not mapped */
431 uint32_t size;
432 uint8_t type;
433 PCIMapIORegionFunc *map_func;
434 } PCIIORegion;
435
436 #define PCI_ROM_SLOT 6
437 #define PCI_NUM_REGIONS 7
438 struct PCIDevice {
439 /* PCI config space */
440 uint8_t config[256];
441
442 /* the following fields are read only */
443 PCIBus *bus;
444 int devfn;
445 char name[64];
446 PCIIORegion io_regions[PCI_NUM_REGIONS];
447
448 /* do not access the following fields */
449 PCIConfigReadFunc *config_read;
450 PCIConfigWriteFunc *config_write;
451 int irq_index;
452 };
453
454 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
455 int instance_size, int devfn,
456 PCIConfigReadFunc *config_read,
457 PCIConfigWriteFunc *config_write);
458
459 void pci_register_io_region(PCIDevice *pci_dev, int region_num,
460 uint32_t size, int type,
461 PCIMapIORegionFunc *map_func);
462
463 void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
464
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);
469
470 extern struct PIIX3State *piix3_state;
471
472 PCIBus *i440fx_init(void);
473 void piix3_init(PCIBus *bus);
474 void pci_bios_init(void);
475 void pci_info(void);
476
477 /* temporary: will be moved in platform specific file */
478 PCIBus *pci_prep_init(void);
479 struct openpic_t;
480 void pci_pmac_set_openpic(PCIBus *bus, struct openpic_t *openpic);
481 PCIBus *pci_pmac_init(void);
482
483 /* openpic.c */
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);
487
488 /* vga.c */
489
490 #define VGA_RAM_SIZE (4096 * 1024)
491
492 struct DisplayState {
493 uint8_t *data;
494 int linesize;
495 int depth;
496 int width;
497 int height;
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);
501 };
502
503 static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
504 {
505 s->dpy_update(s, x, y, w, h);
506 }
507
508 static inline void dpy_resize(DisplayState *s, int w, int h)
509 {
510 s->dpy_resize(s, w, h);
511 }
512
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);
518
519 /* cirrus_vga.c */
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);
524
525 /* sdl.c */
526 void sdl_display_init(DisplayState *ds);
527
528 /* ide.c */
529 #define MAX_DISKS 4
530
531 extern BlockDriverState *bs_table[MAX_DISKS];
532
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);
539
540 /* oss.c */
541 typedef enum {
542 AUD_FMT_U8,
543 AUD_FMT_S8,
544 AUD_FMT_U16,
545 AUD_FMT_S16
546 } audfmt_e;
547
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);
551 void AUD_run (void);
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);
557
558 /* dma.c */
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);
564 void DMA_run (void);
565 void DMA_init (int high_page_enable);
566 void DMA_register_channel (int nchan,
567 DMA_transfer_handler transfer_handler, void *opaque);
568
569 /* sb16.c */
570 void SB16_run (void);
571 void SB16_init (void);
572
573 /* fdc.c */
574 #define MAX_FD 2
575 extern BlockDriverState *fd_table[MAX_FD];
576
577 typedef struct fdctrl_t fdctrl_t;
578
579 fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
580 uint32_t io_base,
581 BlockDriverState **fds);
582 int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
583
584 /* ne2000.c */
585
586 void isa_ne2000_init(int base, int irq, NetDriverState *nd);
587 void pci_ne2000_init(PCIBus *bus, NetDriverState *nd);
588
589 /* pckbd.c */
590
591 void kbd_init(void);
592
593 /* mc146818rtc.c */
594
595 typedef struct RTCState RTCState;
596
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);
600
601 /* serial.c */
602
603 typedef struct SerialState SerialState;
604 SerialState *serial_init(int base, int irq, CharDriverState *chr);
605
606 /* i8259.c */
607
608 void pic_set_irq(int irq, int level);
609 void pic_init(void);
610 uint32_t pic_intack_read(CPUState *env);
611 void pic_info(void);
612 void irq_info(void);
613
614 /* i8254.c */
615
616 #define PIT_FREQ 1193182
617
618 typedef struct PITState PITState;
619
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);
624
625 /* pc.c */
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);
630
631 /* ppc.c */
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);
644 #ifdef TARGET_PPC
645 ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
646 #endif
647 void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
648
649 extern CPUWriteMemoryFunc *PPC_io_write[];
650 extern CPUReadMemoryFunc *PPC_io_read[];
651 extern int prep_enabled;
652
653 /* NVRAM helpers */
654 #include "hw/m48t59.h"
655
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,
671 const char *cmdline,
672 uint32_t initrd_image, uint32_t initrd_size,
673 uint32_t NVRAM_image,
674 int width, int height, int depth);
675
676 /* adb.c */
677
678 #define MAX_ADB_DEVICES 16
679
680 #define ADB_MAX_OUT_LEN 16
681
682 typedef struct ADBDevice ADBDevice;
683
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);
688
689 struct ADBDevice {
690 struct ADBBusState *bus;
691 int devaddr;
692 int handler;
693 ADBDeviceRequest *devreq;
694 ADBDeviceReset *devreset;
695 void *opaque;
696 };
697
698 typedef struct ADBBusState {
699 ADBDevice devices[MAX_ADB_DEVICES];
700 int nb_devices;
701 int poll_index;
702 } ADBBusState;
703
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);
707
708 ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
709 ADBDeviceRequest *devreq,
710 ADBDeviceReset *devreset,
711 void *opaque);
712 void adb_kbd_init(ADBBusState *bus);
713 void adb_mouse_init(ADBBusState *bus);
714
715 /* cuda.c */
716
717 extern ADBBusState adb_bus;
718 int cuda_init(openpic_t *openpic, int irq);
719
720 #endif /* defined(QEMU_TOOL) */
721
722 /* monitor.c */
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);
731
732 /* readline.c */
733 typedef void ReadLineFunc(void *opaque, const char *str);
734
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);
742
743 /* gdbstub.c */
744
745 #define DEFAULT_GDBSTUB_PORT 1234
746
747 int gdbserver_start(int port);
748
749 #endif /* VL_H */