]> git.proxmox.com Git - mirror_qemu.git/blame - vl.h
interlace support
[mirror_qemu.git] / vl.h
CommitLineData
fc01f7e7
FB
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
67b915a5
FB
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>
8a7ddc38 33#include <time.h>
67b915a5
FB
34#include <ctype.h>
35#include <errno.h>
36#include <unistd.h>
37#include <fcntl.h>
7d3505c5 38#include <sys/stat.h>
67b915a5
FB
39
40#ifndef O_LARGEFILE
41#define O_LARGEFILE 0
42#endif
40c3bac3
FB
43#ifndef O_BINARY
44#define O_BINARY 0
45#endif
67b915a5
FB
46
47#ifdef _WIN32
bfbc9133 48#define lseek64 _lseeki64
67b915a5 49#endif
8a7ddc38 50
16f62432
FB
51#include "cpu.h"
52
67b915a5
FB
53#ifndef glue
54#define xglue(x, y) x ## y
55#define glue(x, y) xglue(x, y)
56#define stringify(s) tostring(s)
57#define tostring(s) #s
58#endif
59
60#if defined(WORDS_BIGENDIAN)
61static inline uint32_t be32_to_cpu(uint32_t v)
62{
63 return v;
64}
65
66static inline uint16_t be16_to_cpu(uint16_t v)
67{
68 return v;
69}
70
165c6fc8
FB
71static inline uint32_t cpu_to_be32(uint32_t v)
72{
73 return v;
74}
75
76static inline uint16_t cpu_to_be16(uint16_t v)
77{
78 return v;
79}
80
67b915a5
FB
81static inline uint32_t le32_to_cpu(uint32_t v)
82{
83 return bswap32(v);
84}
85
86static inline uint16_t le16_to_cpu(uint16_t v)
87{
88 return bswap16(v);
89}
90
165c6fc8
FB
91static inline uint32_t cpu_to_le32(uint32_t v)
92{
93 return bswap32(v);
94}
95
96static inline uint16_t cpu_to_le16(uint16_t v)
97{
98 return bswap16(v);
99}
100
67b915a5 101#else
165c6fc8 102
67b915a5
FB
103static inline uint32_t be32_to_cpu(uint32_t v)
104{
105 return bswap32(v);
106}
107
108static inline uint16_t be16_to_cpu(uint16_t v)
109{
110 return bswap16(v);
111}
112
165c6fc8
FB
113static inline uint32_t cpu_to_be32(uint32_t v)
114{
115 return bswap32(v);
116}
117
118static inline uint16_t cpu_to_be16(uint16_t v)
119{
120 return bswap16(v);
121}
122
67b915a5
FB
123static inline uint32_t le32_to_cpu(uint32_t v)
124{
125 return v;
126}
127
128static inline uint16_t le16_to_cpu(uint16_t v)
129{
130 return v;
131}
165c6fc8
FB
132
133static inline uint32_t cpu_to_le32(uint32_t v)
134{
135 return v;
136}
137
138static inline uint16_t cpu_to_le16(uint16_t v)
139{
140 return v;
141}
67b915a5
FB
142#endif
143
eb26db16
FB
144static inline void cpu_to_le16w(uint16_t *p, uint16_t v)
145{
146 *p = cpu_to_le16(v);
147}
148
149static inline void cpu_to_le32w(uint32_t *p, uint32_t v)
150{
151 *p = cpu_to_le32(v);
152}
153
154static inline uint16_t le16_to_cpup(const uint16_t *p)
155{
156 return le16_to_cpu(*p);
157}
158
159static inline uint32_t le32_to_cpup(const uint32_t *p)
160{
161 return le32_to_cpu(*p);
162}
163
164/* unaligned versions (optimized for frequent unaligned accesses)*/
165
166#if defined(__i386__) || defined(__powerpc__)
167
168#define cpu_to_le16wu(p, v) cpu_to_le16w(p, v)
169#define cpu_to_le32wu(p, v) cpu_to_le32w(p, v)
170#define le16_to_cpupu(p) le16_to_cpup(p)
171#define le32_to_cpupu(p) le32_to_cpup(p)
172
173#else
174
175static inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
176{
177 uint8_t *p1 = (uint8_t *)p;
178
179 p1[0] = v;
180 p1[1] = v >> 8;
181}
182
183static inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
184{
185 uint8_t *p1 = (uint8_t *)p;
186
187 p1[0] = v;
188 p1[1] = v >> 8;
189 p1[2] = v >> 16;
190 p1[3] = v >> 24;
191}
192
193static inline uint16_t le16_to_cpupu(const uint16_t *p)
194{
195 const uint8_t *p1 = (const uint8_t *)p;
196 return p1[0] | (p1[1] << 8);
197}
198
199static inline uint32_t le32_to_cpupu(const uint32_t *p)
200{
201 const uint8_t *p1 = (const uint8_t *)p;
202 return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
203}
204
205#endif
67b915a5 206
33e3963e 207/* vl.c */
313aa567
FB
208extern int reset_requested;
209
80cabfad 210uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
313aa567 211
80cabfad
FB
212void hw_error(const char *fmt, ...);
213
214int load_image(const char *filename, uint8_t *addr);
215extern const char *bios_dir;
216
217void pstrcpy(char *buf, int buf_size, const char *str);
218char *pstrcat(char *buf, int buf_size, const char *s);
33e3963e 219
c4b1fcc0
FB
220int serial_open_device(void);
221
8a7ddc38
FB
222extern int vm_running;
223
224typedef void VMStopHandler(void *opaque, int reason);
225
226int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
227void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
228
229void vm_start(void);
230void vm_stop(int reason);
231
aaaa7df6 232extern int audio_enabled;
0ced6589
FB
233extern int ram_size;
234extern int bios_size;
ee22c2f7 235extern int rtc_utc;
1f04275e 236extern int cirrus_vga_enabled;
0ced6589
FB
237
238/* XXX: make it dynamic */
239#if defined (TARGET_PPC)
240#define BIOS_SIZE (512 * 1024)
241#else
242#define BIOS_SIZE 0
243#endif
aaaa7df6 244
63066f4f
FB
245/* keyboard/mouse support */
246
247#define MOUSE_EVENT_LBUTTON 0x01
248#define MOUSE_EVENT_RBUTTON 0x02
249#define MOUSE_EVENT_MBUTTON 0x04
250
251typedef void QEMUPutKBDEvent(void *opaque, int keycode);
252typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
253
254void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
255void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
256
257void kbd_put_keycode(int keycode);
258void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
259
c20709aa
FB
260/* async I/O support */
261
262typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
263typedef int IOCanRWHandler(void *opaque);
264
265int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read,
266 IOReadHandler *fd_read, void *opaque);
267void qemu_del_fd_read_handler(int fd);
268
c4b1fcc0
FB
269/* network redirectors support */
270
271#define MAX_NICS 8
272
273typedef struct NetDriverState {
c20709aa 274 int index; /* index number in QEMU */
c4b1fcc0
FB
275 uint8_t macaddr[6];
276 char ifname[16];
c20709aa
FB
277 void (*send_packet)(struct NetDriverState *nd,
278 const uint8_t *buf, int size);
279 void (*add_read_packet)(struct NetDriverState *nd,
280 IOCanRWHandler *fd_can_read,
281 IOReadHandler *fd_read, void *opaque);
282 /* tun specific data */
283 int fd;
284 /* slirp specific data */
c4b1fcc0
FB
285} NetDriverState;
286
287extern int nb_nics;
288extern NetDriverState nd_table[MAX_NICS];
289
c20709aa
FB
290void qemu_send_packet(NetDriverState *nd, const uint8_t *buf, int size);
291void qemu_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read,
292 IOReadHandler *fd_read, void *opaque);
8a7ddc38
FB
293
294/* timers */
295
296typedef struct QEMUClock QEMUClock;
297typedef struct QEMUTimer QEMUTimer;
298typedef void QEMUTimerCB(void *opaque);
299
300/* The real time clock should be used only for stuff which does not
301 change the virtual machine state, as it is run even if the virtual
69b91039 302 machine is stopped. The real time clock has a frequency of 1000
8a7ddc38
FB
303 Hz. */
304extern QEMUClock *rt_clock;
305
306/* Rge virtual clock is only run during the emulation. It is stopped
307 when the virtual machine is stopped. Virtual timers use a high
308 precision clock, usually cpu cycles (use ticks_per_sec). */
309extern QEMUClock *vm_clock;
310
311int64_t qemu_get_clock(QEMUClock *clock);
312
313QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
314void qemu_free_timer(QEMUTimer *ts);
315void qemu_del_timer(QEMUTimer *ts);
316void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
317int qemu_timer_pending(QEMUTimer *ts);
318
319extern int64_t ticks_per_sec;
320extern int pit_min_timer_count;
321
322void cpu_enable_ticks(void);
323void cpu_disable_ticks(void);
324
325/* VM Load/Save */
326
327typedef FILE QEMUFile;
328
329void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
330void qemu_put_byte(QEMUFile *f, int v);
331void qemu_put_be16(QEMUFile *f, unsigned int v);
332void qemu_put_be32(QEMUFile *f, unsigned int v);
333void qemu_put_be64(QEMUFile *f, uint64_t v);
334int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
335int qemu_get_byte(QEMUFile *f);
336unsigned int qemu_get_be16(QEMUFile *f);
337unsigned int qemu_get_be32(QEMUFile *f);
338uint64_t qemu_get_be64(QEMUFile *f);
339
340static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
341{
342 qemu_put_be64(f, *pv);
343}
344
345static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
346{
347 qemu_put_be32(f, *pv);
348}
349
350static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
351{
352 qemu_put_be16(f, *pv);
353}
354
355static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
356{
357 qemu_put_byte(f, *pv);
358}
359
360static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
361{
362 *pv = qemu_get_be64(f);
363}
364
365static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
366{
367 *pv = qemu_get_be32(f);
368}
369
370static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
371{
372 *pv = qemu_get_be16(f);
373}
374
375static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
376{
377 *pv = qemu_get_byte(f);
378}
379
380int64_t qemu_ftell(QEMUFile *f);
381int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
382
383typedef void SaveStateHandler(QEMUFile *f, void *opaque);
384typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
385
386int qemu_loadvm(const char *filename);
387int qemu_savevm(const char *filename);
388int register_savevm(const char *idstr,
389 int instance_id,
390 int version_id,
391 SaveStateHandler *save_state,
392 LoadStateHandler *load_state,
393 void *opaque);
394void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
395void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
c4b1fcc0 396
fc01f7e7
FB
397/* block.c */
398typedef struct BlockDriverState BlockDriverState;
399
c4b1fcc0
FB
400BlockDriverState *bdrv_new(const char *device_name);
401void bdrv_delete(BlockDriverState *bs);
402int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
fc01f7e7
FB
403void bdrv_close(BlockDriverState *bs);
404int bdrv_read(BlockDriverState *bs, int64_t sector_num,
405 uint8_t *buf, int nb_sectors);
406int bdrv_write(BlockDriverState *bs, int64_t sector_num,
407 const uint8_t *buf, int nb_sectors);
408void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
33e3963e 409int bdrv_commit(BlockDriverState *bs);
77fef8c1 410void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
33e3963e 411
c4b1fcc0
FB
412#define BDRV_TYPE_HD 0
413#define BDRV_TYPE_CDROM 1
414#define BDRV_TYPE_FLOPPY 2
415
416void bdrv_set_geometry_hint(BlockDriverState *bs,
417 int cyls, int heads, int secs);
418void bdrv_set_type_hint(BlockDriverState *bs, int type);
419void bdrv_get_geometry_hint(BlockDriverState *bs,
420 int *pcyls, int *pheads, int *psecs);
421int bdrv_get_type_hint(BlockDriverState *bs);
422int bdrv_is_removable(BlockDriverState *bs);
423int bdrv_is_read_only(BlockDriverState *bs);
424int bdrv_is_inserted(BlockDriverState *bs);
425int bdrv_is_locked(BlockDriverState *bs);
426void bdrv_set_locked(BlockDriverState *bs, int locked);
427void bdrv_set_change_cb(BlockDriverState *bs,
428 void (*change_cb)(void *opaque), void *opaque);
429
430void bdrv_info(void);
431BlockDriverState *bdrv_find(const char *name);
432
26aa7d72
FB
433/* ISA bus */
434
435extern target_phys_addr_t isa_mem_base;
436
437typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
438typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
439
440int register_ioport_read(int start, int length, int size,
441 IOPortReadFunc *func, void *opaque);
442int register_ioport_write(int start, int length, int size,
443 IOPortWriteFunc *func, void *opaque);
69b91039
FB
444void isa_unassign_ioport(int start, int length);
445
446/* PCI bus */
447
448extern int pci_enabled;
449
450extern target_phys_addr_t pci_mem_base;
451
452typedef struct PCIDevice PCIDevice;
453
454typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
455 uint32_t address, uint32_t data, int len);
456typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
457 uint32_t address, int len);
458typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
459 uint32_t addr, uint32_t size, int type);
460
461#define PCI_ADDRESS_SPACE_MEM 0x00
462#define PCI_ADDRESS_SPACE_IO 0x01
463#define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
464
465typedef struct PCIIORegion {
5768f5ac 466 uint32_t addr; /* current PCI mapping address. -1 means not mapped */
69b91039
FB
467 uint32_t size;
468 uint8_t type;
469 PCIMapIORegionFunc *map_func;
470} PCIIORegion;
471
8a8696a3
FB
472#define PCI_ROM_SLOT 6
473#define PCI_NUM_REGIONS 7
69b91039
FB
474struct PCIDevice {
475 /* PCI config space */
476 uint8_t config[256];
477
478 /* the following fields are read only */
479 int bus_num;
480 int devfn;
481 char name[64];
8a8696a3 482 PCIIORegion io_regions[PCI_NUM_REGIONS];
69b91039
FB
483
484 /* do not access the following fields */
485 PCIConfigReadFunc *config_read;
486 PCIConfigWriteFunc *config_write;
5768f5ac 487 int irq_index;
69b91039
FB
488};
489
490PCIDevice *pci_register_device(const char *name, int instance_size,
491 int bus_num, int devfn,
492 PCIConfigReadFunc *config_read,
493 PCIConfigWriteFunc *config_write);
494
495void pci_register_io_region(PCIDevice *pci_dev, int region_num,
496 uint32_t size, int type,
497 PCIMapIORegionFunc *map_func);
498
5768f5ac
FB
499void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
500
501uint32_t pci_default_read_config(PCIDevice *d,
502 uint32_t address, int len);
503void pci_default_write_config(PCIDevice *d,
504 uint32_t address, uint32_t val, int len);
505
9995c51f
FB
506extern struct PIIX3State *piix3_state;
507
69b91039
FB
508void i440fx_init(void);
509void piix3_init(void);
510void pci_bios_init(void);
5768f5ac 511void pci_info(void);
26aa7d72 512
77d4bc34
FB
513/* temporary: will be moved in platform specific file */
514void pci_prep_init(void);
515void pci_pmac_init(void);
516void pci_ppc_bios_init(void);
517
313aa567
FB
518/* vga.c */
519
4fa0f5d2 520#define VGA_RAM_SIZE (4096 * 1024)
313aa567
FB
521
522typedef struct DisplayState {
523 uint8_t *data;
524 int linesize;
525 int depth;
526 void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
527 void (*dpy_resize)(struct DisplayState *s, int w, int h);
528 void (*dpy_refresh)(struct DisplayState *s);
529} DisplayState;
530
531static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
532{
533 s->dpy_update(s, x, y, w, h);
534}
535
536static inline void dpy_resize(DisplayState *s, int w, int h)
537{
538 s->dpy_resize(s, w, h);
539}
540
7138fcfb 541int vga_initialize(DisplayState *ds, uint8_t *vga_ram_base,
5768f5ac
FB
542 unsigned long vga_ram_offset, int vga_ram_size,
543 int is_pci);
313aa567 544void vga_update_display(void);
ee38b4c8 545void vga_invalidate_display(void);
59a983b9 546void vga_screen_dump(const char *filename);
313aa567 547
d6bfa22f
FB
548/* cirrus_vga.c */
549void pci_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
550 unsigned long vga_ram_offset, int vga_ram_size);
551
552void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
553 unsigned long vga_ram_offset, int vga_ram_size);
554
313aa567
FB
555/* sdl.c */
556void sdl_display_init(DisplayState *ds);
557
5391d806
FB
558/* ide.c */
559#define MAX_DISKS 4
560
561extern BlockDriverState *bs_table[MAX_DISKS];
562
69b91039
FB
563void isa_ide_init(int iobase, int iobase2, int irq,
564 BlockDriverState *hd0, BlockDriverState *hd1);
565void pci_ide_init(BlockDriverState **hd_table);
9995c51f 566void pci_piix3_ide_init(BlockDriverState **hd_table);
5391d806 567
27503323
FB
568/* oss.c */
569typedef enum {
570 AUD_FMT_U8,
571 AUD_FMT_S8,
572 AUD_FMT_U16,
573 AUD_FMT_S16
574} audfmt_e;
575
576void AUD_open (int rfreq, int rnchannels, audfmt_e rfmt);
577void AUD_reset (int rfreq, int rnchannels, audfmt_e rfmt);
578int AUD_write (void *in_buf, int size);
579void AUD_run (void);
580void AUD_adjust_estimate (int _leftover);
581int AUD_get_free (void);
582int AUD_get_live (void);
583int AUD_get_buffer_size (void);
584void AUD_init (void);
585
586/* dma.c */
16f62432 587typedef int (*DMA_transfer_handler) (void *opaque, target_ulong addr, int size);
27503323
FB
588int DMA_get_channel_mode (int nchan);
589void DMA_hold_DREQ (int nchan);
590void DMA_release_DREQ (int nchan);
16f62432 591void DMA_schedule(int nchan);
27503323
FB
592void DMA_run (void);
593void DMA_init (void);
594void DMA_register_channel (int nchan,
16f62432 595 DMA_transfer_handler transfer_handler, void *opaque);
27503323
FB
596
597/* sb16.c */
598void SB16_run (void);
599void SB16_init (void);
600
7138fcfb
FB
601/* fdc.c */
602#define MAX_FD 2
603extern BlockDriverState *fd_table[MAX_FD];
604
baca51fa
FB
605typedef struct fdctrl_t fdctrl_t;
606
607fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
608 uint32_t io_base,
609 BlockDriverState **fds);
610int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
7138fcfb 611
80cabfad
FB
612/* ne2000.c */
613
69b91039
FB
614void isa_ne2000_init(int base, int irq, NetDriverState *nd);
615void pci_ne2000_init(NetDriverState *nd);
80cabfad
FB
616
617/* pckbd.c */
618
80cabfad
FB
619void kbd_init(void);
620
621/* mc146818rtc.c */
622
8a7ddc38 623typedef struct RTCState RTCState;
80cabfad 624
8a7ddc38
FB
625RTCState *rtc_init(int base, int irq);
626void rtc_set_memory(RTCState *s, int addr, int val);
627void rtc_set_date(RTCState *s, const struct tm *tm);
80cabfad
FB
628
629/* serial.c */
630
c4b1fcc0
FB
631typedef struct SerialState SerialState;
632
633extern SerialState *serial_console;
634
635SerialState *serial_init(int base, int irq, int fd);
636int serial_can_receive(SerialState *s);
637void serial_receive_byte(SerialState *s, int ch);
638void serial_receive_break(SerialState *s);
80cabfad
FB
639
640/* i8259.c */
641
642void pic_set_irq(int irq, int level);
643void pic_init(void);
c5df018e 644uint32_t pic_intack_read(CPUState *env);
c20709aa 645void pic_info(void);
4a0fb71e 646void irq_info(void);
80cabfad
FB
647
648/* i8254.c */
649
650#define PIT_FREQ 1193182
651
ec844b96
FB
652typedef struct PITState PITState;
653
654PITState *pit_init(int base, int irq);
655void pit_set_gate(PITState *pit, int channel, int val);
656int pit_get_gate(PITState *pit, int channel);
657int pit_get_out(PITState *pit, int channel, int64_t current_time);
80cabfad
FB
658
659/* pc.c */
660void pc_init(int ram_size, int vga_ram_size, int boot_device,
661 DisplayState *ds, const char **fd_filename, int snapshot,
662 const char *kernel_filename, const char *kernel_cmdline,
663 const char *initrd_filename);
664
26aa7d72
FB
665/* ppc.c */
666void ppc_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);
77d4bc34
FB
670void ppc_prep_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);
674void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
675 DisplayState *ds, const char **fd_filename, int snapshot,
676 const char *kernel_filename, const char *kernel_cmdline,
677 const char *initrd_filename);
8cc43fef
FB
678#ifdef TARGET_PPC
679ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
680#endif
64201201 681void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
77d4bc34
FB
682
683extern CPUWriteMemoryFunc *PPC_io_write[];
684extern CPUReadMemoryFunc *PPC_io_read[];
685extern int prep_enabled;
26aa7d72 686
64201201
FB
687/* NVRAM helpers */
688#include "hw/m48t59.h"
689
690void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
691uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
692void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
693uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
694void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
695uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
696void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
697 const unsigned char *str, uint32_t max);
698int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
699void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
700 uint32_t start, uint32_t count);
701int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
702 const unsigned char *arch,
703 uint32_t RAM_size, int boot_device,
704 uint32_t kernel_image, uint32_t kernel_size,
705 uint32_t cmdline, uint32_t cmdline_size,
706 uint32_t initrd_image, uint32_t initrd_size,
707 uint32_t NVRAM_image);
708
63066f4f
FB
709/* adb.c */
710
711#define MAX_ADB_DEVICES 16
712
713typedef struct ADBDevice ADBDevice;
714
715typedef void ADBDeviceReceivePacket(ADBDevice *d, const uint8_t *buf, int len);
716
717struct ADBDevice {
718 struct ADBBusState *bus;
719 int devaddr;
720 int handler;
721 ADBDeviceReceivePacket *receive_packet;
722 void *opaque;
723};
724
725typedef struct ADBBusState {
726 ADBDevice devices[MAX_ADB_DEVICES];
727 int nb_devices;
728} ADBBusState;
729
730void adb_receive_packet(ADBBusState *s, const uint8_t *buf, int len);
731void adb_send_packet(ADBBusState *s, const uint8_t *buf, int len);
732
733ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
734 ADBDeviceReceivePacket *receive_packet,
735 void *opaque);
736void adb_kbd_init(ADBBusState *bus);
737void adb_mouse_init(ADBBusState *bus);
738
739/* cuda.c */
740
741extern ADBBusState adb_bus;
742int cuda_init(void);
743
c4b1fcc0
FB
744/* monitor.c */
745void monitor_init(void);
40c3bac3 746void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
c4b1fcc0
FB
747void term_flush(void);
748void term_print_help(void);
749
8a7ddc38
FB
750/* gdbstub.c */
751
752#define DEFAULT_GDBSTUB_PORT 1234
753
754int gdbserver_start(int port);
755
fc01f7e7 756#endif /* VL_H */