]> Git Repo - qemu.git/blob - vl.h
Virtual PC read-only disk image support (Alex Beregszaszi)
[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 <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
42 #ifndef O_LARGEFILE
43 #define O_LARGEFILE 0
44 #endif
45 #ifndef O_BINARY
46 #define O_BINARY 0
47 #endif
48
49 #ifdef _WIN32
50 #define lseek _lseeki64
51 #define ENOTSUP 4096
52 /* XXX: find 64 bit version */
53 #define ftruncate chsize
54
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
61
62 #ifdef QEMU_TOOL
63
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"
70
71 #else
72
73 #include "cpu.h"
74 #include "gdbstub.h"
75
76 #endif /* !defined(QEMU_TOOL) */
77
78 #ifndef glue
79 #define xglue(x, y) x ## y
80 #define glue(x, y) xglue(x, y)
81 #define stringify(s)    tostring(s)
82 #define tostring(s)     #s
83 #endif
84
85 /* vl.c */
86 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
87
88 void hw_error(const char *fmt, ...);
89
90 int get_image_size(const char *filename);
91 int load_image(const char *filename, uint8_t *addr);
92 extern const char *bios_dir;
93
94 void pstrcpy(char *buf, int buf_size, const char *str);
95 char *pstrcat(char *buf, int buf_size, const char *s);
96 int strstart(const char *str, const char *val, const char **ptr);
97
98 extern int vm_running;
99
100 typedef void VMStopHandler(void *opaque, int reason);
101
102 int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
103 void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
104
105 void vm_start(void);
106 void vm_stop(int reason);
107
108 typedef void QEMUResetHandler(void *opaque);
109
110 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
111 void qemu_system_reset_request(void);
112 void qemu_system_shutdown_request(void);
113
114 void main_loop_wait(int timeout);
115
116 extern int audio_enabled;
117 extern int sb16_enabled;
118 extern int adlib_enabled;
119 extern int gus_enabled;
120 extern int 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;
127 extern const char *keyboard_layout;
128 extern int kqemu_allowed;
129
130 /* XXX: make it dynamic */
131 #if defined (TARGET_PPC)
132 #define BIOS_SIZE (512 * 1024)
133 #else
134 #define BIOS_SIZE ((256 + 64) * 1024)
135 #endif
136
137 /* keyboard/mouse support */
138
139 #define MOUSE_EVENT_LBUTTON 0x01
140 #define MOUSE_EVENT_RBUTTON 0x02
141 #define MOUSE_EVENT_MBUTTON 0x04
142
143 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
144 typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
145
146 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
147 void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque);
148
149 void kbd_put_keycode(int keycode);
150 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
151
152 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
153    constants) */
154 #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
155 #define QEMU_KEY_BACKSPACE  0x007f
156 #define QEMU_KEY_UP         QEMU_KEY_ESC1('A')
157 #define QEMU_KEY_DOWN       QEMU_KEY_ESC1('B')
158 #define QEMU_KEY_RIGHT      QEMU_KEY_ESC1('C')
159 #define QEMU_KEY_LEFT       QEMU_KEY_ESC1('D')
160 #define QEMU_KEY_HOME       QEMU_KEY_ESC1(1)
161 #define QEMU_KEY_END        QEMU_KEY_ESC1(4)
162 #define QEMU_KEY_PAGEUP     QEMU_KEY_ESC1(5)
163 #define QEMU_KEY_PAGEDOWN   QEMU_KEY_ESC1(6)
164 #define QEMU_KEY_DELETE     QEMU_KEY_ESC1(3)
165
166 #define QEMU_KEY_CTRL_UP         0xe400
167 #define QEMU_KEY_CTRL_DOWN       0xe401
168 #define QEMU_KEY_CTRL_LEFT       0xe402
169 #define QEMU_KEY_CTRL_RIGHT      0xe403
170 #define QEMU_KEY_CTRL_HOME       0xe404
171 #define QEMU_KEY_CTRL_END        0xe405
172 #define QEMU_KEY_CTRL_PAGEUP     0xe406
173 #define QEMU_KEY_CTRL_PAGEDOWN   0xe407
174
175 void kbd_put_keysym(int keysym);
176
177 /* async I/O support */
178
179 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
180 typedef int IOCanRWHandler(void *opaque);
181
182 int qemu_add_fd_read_handler(int fd, IOCanRWHandler *fd_can_read, 
183                              IOReadHandler *fd_read, void *opaque);
184 void qemu_del_fd_read_handler(int fd);
185
186 /* character device */
187
188 #define CHR_EVENT_BREAK 0 /* serial break char */
189 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
190
191 typedef void IOEventHandler(void *opaque, int event);
192
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;
202
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);
210                                
211 /* consoles */
212
213 typedef struct DisplayState DisplayState;
214 typedef struct TextConsole TextConsole;
215
216 extern TextConsole *vga_console;
217
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);
222
223 /* serial ports */
224
225 #define MAX_SERIAL_PORTS 4
226
227 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
228
229 /* parallel ports */
230
231 #define MAX_PARALLEL_PORTS 3
232
233 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
234
235 /* network redirectors support */
236
237 #define MAX_NICS 8
238
239 typedef struct NetDriverState {
240     int index; /* index number in QEMU */
241     uint8_t macaddr[6];
242     char ifname[16];
243     void (*send_packet)(struct NetDriverState *nd, 
244                         const uint8_t *buf, int size);
245     void (*add_read_packet)(struct NetDriverState *nd, 
246                             IOCanRWHandler *fd_can_read, 
247                             IOReadHandler *fd_read, void *opaque);
248     /* tun specific data */
249     int fd;
250     /* slirp specific data */
251 } NetDriverState;
252
253 extern int nb_nics;
254 extern NetDriverState nd_table[MAX_NICS];
255
256 void qemu_send_packet(NetDriverState *nd, const uint8_t *buf, int size);
257 void qemu_add_read_packet(NetDriverState *nd, IOCanRWHandler *fd_can_read, 
258                           IOReadHandler *fd_read, void *opaque);
259
260 /* timers */
261
262 typedef struct QEMUClock QEMUClock;
263 typedef struct QEMUTimer QEMUTimer;
264 typedef void QEMUTimerCB(void *opaque);
265
266 /* The real time clock should be used only for stuff which does not
267    change the virtual machine state, as it is run even if the virtual
268    machine is stopped. The real time clock has a frequency of 1000
269    Hz. */
270 extern QEMUClock *rt_clock;
271
272 /* The virtual clock is only run during the emulation. It is stopped
273    when the virtual machine is stopped. Virtual timers use a high
274    precision clock, usually cpu cycles (use ticks_per_sec). */
275 extern QEMUClock *vm_clock;
276
277 int64_t qemu_get_clock(QEMUClock *clock);
278
279 QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
280 void qemu_free_timer(QEMUTimer *ts);
281 void qemu_del_timer(QEMUTimer *ts);
282 void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
283 int qemu_timer_pending(QEMUTimer *ts);
284
285 extern int64_t ticks_per_sec;
286 extern int pit_min_timer_count;
287
288 void cpu_enable_ticks(void);
289 void cpu_disable_ticks(void);
290
291 /* VM Load/Save */
292
293 typedef FILE QEMUFile;
294
295 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
296 void qemu_put_byte(QEMUFile *f, int v);
297 void qemu_put_be16(QEMUFile *f, unsigned int v);
298 void qemu_put_be32(QEMUFile *f, unsigned int v);
299 void qemu_put_be64(QEMUFile *f, uint64_t v);
300 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
301 int qemu_get_byte(QEMUFile *f);
302 unsigned int qemu_get_be16(QEMUFile *f);
303 unsigned int qemu_get_be32(QEMUFile *f);
304 uint64_t qemu_get_be64(QEMUFile *f);
305
306 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
307 {
308     qemu_put_be64(f, *pv);
309 }
310
311 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
312 {
313     qemu_put_be32(f, *pv);
314 }
315
316 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
317 {
318     qemu_put_be16(f, *pv);
319 }
320
321 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
322 {
323     qemu_put_byte(f, *pv);
324 }
325
326 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
327 {
328     *pv = qemu_get_be64(f);
329 }
330
331 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
332 {
333     *pv = qemu_get_be32(f);
334 }
335
336 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
337 {
338     *pv = qemu_get_be16(f);
339 }
340
341 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
342 {
343     *pv = qemu_get_byte(f);
344 }
345
346 #if TARGET_LONG_BITS == 64
347 #define qemu_put_betl qemu_put_be64
348 #define qemu_get_betl qemu_get_be64
349 #define qemu_put_betls qemu_put_be64s
350 #define qemu_get_betls qemu_get_be64s
351 #else
352 #define qemu_put_betl qemu_put_be32
353 #define qemu_get_betl qemu_get_be32
354 #define qemu_put_betls qemu_put_be32s
355 #define qemu_get_betls qemu_get_be32s
356 #endif
357
358 int64_t qemu_ftell(QEMUFile *f);
359 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
360
361 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
362 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
363
364 int qemu_loadvm(const char *filename);
365 int qemu_savevm(const char *filename);
366 int register_savevm(const char *idstr, 
367                     int instance_id, 
368                     int version_id,
369                     SaveStateHandler *save_state,
370                     LoadStateHandler *load_state,
371                     void *opaque);
372 void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
373 void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
374
375 /* block.c */
376 typedef struct BlockDriverState BlockDriverState;
377 typedef struct BlockDriver BlockDriver;
378
379 extern BlockDriver bdrv_raw;
380 extern BlockDriver bdrv_cow;
381 extern BlockDriver bdrv_qcow;
382 extern BlockDriver bdrv_vmdk;
383 extern BlockDriver bdrv_cloop;
384 extern BlockDriver bdrv_dmg;
385 extern BlockDriver bdrv_bochs;
386 extern BlockDriver bdrv_vpc;
387
388 void bdrv_init(void);
389 BlockDriver *bdrv_find_format(const char *format_name);
390 int bdrv_create(BlockDriver *drv, 
391                 const char *filename, int64_t size_in_sectors,
392                 const char *backing_file, int flags);
393 BlockDriverState *bdrv_new(const char *device_name);
394 void bdrv_delete(BlockDriverState *bs);
395 int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
396 int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot,
397                BlockDriver *drv);
398 void bdrv_close(BlockDriverState *bs);
399 int bdrv_read(BlockDriverState *bs, int64_t sector_num, 
400               uint8_t *buf, int nb_sectors);
401 int bdrv_write(BlockDriverState *bs, int64_t sector_num, 
402                const uint8_t *buf, int nb_sectors);
403 void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
404 int bdrv_commit(BlockDriverState *bs);
405 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
406
407 #define BDRV_TYPE_HD     0
408 #define BDRV_TYPE_CDROM  1
409 #define BDRV_TYPE_FLOPPY 2
410 #define BIOS_ATA_TRANSLATION_AUTO 0
411 #define BIOS_ATA_TRANSLATION_NONE 1
412 #define BIOS_ATA_TRANSLATION_LBA  2
413
414 void bdrv_set_geometry_hint(BlockDriverState *bs, 
415                             int cyls, int heads, int secs);
416 void bdrv_set_type_hint(BlockDriverState *bs, int type);
417 void bdrv_set_translation_hint(BlockDriverState *bs, int translation);
418 void bdrv_get_geometry_hint(BlockDriverState *bs, 
419                             int *pcyls, int *pheads, int *psecs);
420 int bdrv_get_type_hint(BlockDriverState *bs);
421 int bdrv_get_translation_hint(BlockDriverState *bs);
422 int bdrv_is_removable(BlockDriverState *bs);
423 int bdrv_is_read_only(BlockDriverState *bs);
424 int bdrv_is_inserted(BlockDriverState *bs);
425 int bdrv_is_locked(BlockDriverState *bs);
426 void bdrv_set_locked(BlockDriverState *bs, int locked);
427 void bdrv_set_change_cb(BlockDriverState *bs, 
428                         void (*change_cb)(void *opaque), void *opaque);
429 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
430 void bdrv_info(void);
431 BlockDriverState *bdrv_find(const char *name);
432 void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
433 int bdrv_is_encrypted(BlockDriverState *bs);
434 int bdrv_set_key(BlockDriverState *bs, const char *key);
435 void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 
436                          void *opaque);
437 const char *bdrv_get_device_name(BlockDriverState *bs);
438
439 int qcow_get_cluster_size(BlockDriverState *bs);
440 int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
441                           const uint8_t *buf);
442
443 #ifndef QEMU_TOOL
444 /* ISA bus */
445
446 extern target_phys_addr_t isa_mem_base;
447
448 typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
449 typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
450
451 int register_ioport_read(int start, int length, int size, 
452                          IOPortReadFunc *func, void *opaque);
453 int register_ioport_write(int start, int length, int size, 
454                           IOPortWriteFunc *func, void *opaque);
455 void isa_unassign_ioport(int start, int length);
456
457 /* PCI bus */
458
459 extern int pci_enabled;
460
461 extern target_phys_addr_t pci_mem_base;
462
463 typedef struct PCIBus PCIBus;
464 typedef struct PCIDevice PCIDevice;
465
466 typedef void PCIConfigWriteFunc(PCIDevice *pci_dev, 
467                                 uint32_t address, uint32_t data, int len);
468 typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev, 
469                                    uint32_t address, int len);
470 typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num, 
471                                 uint32_t addr, uint32_t size, int type);
472
473 #define PCI_ADDRESS_SPACE_MEM           0x00
474 #define PCI_ADDRESS_SPACE_IO            0x01
475 #define PCI_ADDRESS_SPACE_MEM_PREFETCH  0x08
476
477 typedef struct PCIIORegion {
478     uint32_t addr; /* current PCI mapping address. -1 means not mapped */
479     uint32_t size;
480     uint8_t type;
481     PCIMapIORegionFunc *map_func;
482 } PCIIORegion;
483
484 #define PCI_ROM_SLOT 6
485 #define PCI_NUM_REGIONS 7
486 struct PCIDevice {
487     /* PCI config space */
488     uint8_t config[256];
489
490     /* the following fields are read only */
491     PCIBus *bus;
492     int devfn;
493     char name[64];
494     PCIIORegion io_regions[PCI_NUM_REGIONS];
495     
496     /* do not access the following fields */
497     PCIConfigReadFunc *config_read;
498     PCIConfigWriteFunc *config_write;
499     int irq_index;
500 };
501
502 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
503                                int instance_size, int devfn,
504                                PCIConfigReadFunc *config_read, 
505                                PCIConfigWriteFunc *config_write);
506
507 void pci_register_io_region(PCIDevice *pci_dev, int region_num, 
508                             uint32_t size, int type, 
509                             PCIMapIORegionFunc *map_func);
510
511 void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
512
513 uint32_t pci_default_read_config(PCIDevice *d, 
514                                  uint32_t address, int len);
515 void pci_default_write_config(PCIDevice *d, 
516                               uint32_t address, uint32_t val, int len);
517 void generic_pci_save(QEMUFile* f, void *opaque);
518 int generic_pci_load(QEMUFile* f, void *opaque, int version_id);
519
520 extern struct PIIX3State *piix3_state;
521
522 PCIBus *i440fx_init(void);
523 void piix3_init(PCIBus *bus);
524 void pci_bios_init(void);
525 void pci_info(void);
526
527 /* temporary: will be moved in platform specific file */
528 PCIBus *pci_prep_init(void);
529 struct openpic_t;
530 void pci_pmac_set_openpic(PCIBus *bus, struct openpic_t *openpic);
531 PCIBus *pci_pmac_init(void);
532
533 /* openpic.c */
534 typedef struct openpic_t openpic_t;
535 void openpic_set_irq (openpic_t *opp, int n_IRQ, int level);
536 openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus);
537
538 /* vga.c */
539
540 #define VGA_RAM_SIZE (4096 * 1024)
541
542 struct DisplayState {
543     uint8_t *data;
544     int linesize;
545     int depth;
546     int width;
547     int height;
548     void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
549     void (*dpy_resize)(struct DisplayState *s, int w, int h);
550     void (*dpy_refresh)(struct DisplayState *s);
551 };
552
553 static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
554 {
555     s->dpy_update(s, x, y, w, h);
556 }
557
558 static inline void dpy_resize(DisplayState *s, int w, int h)
559 {
560     s->dpy_resize(s, w, h);
561 }
562
563 int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, 
564                    unsigned long vga_ram_offset, int vga_ram_size);
565 void vga_update_display(void);
566 void vga_invalidate_display(void);
567 void vga_screen_dump(const char *filename);
568
569 /* cirrus_vga.c */
570 void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base, 
571                          unsigned long vga_ram_offset, int vga_ram_size);
572 void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base, 
573                          unsigned long vga_ram_offset, int vga_ram_size);
574
575 /* sdl.c */
576 void sdl_display_init(DisplayState *ds, int full_screen);
577
578 /* cocoa.m */
579 void cocoa_display_init(DisplayState *ds, int full_screen);
580
581 /* ide.c */
582 #define MAX_DISKS 4
583
584 extern BlockDriverState *bs_table[MAX_DISKS];
585
586 void isa_ide_init(int iobase, int iobase2, int irq,
587                   BlockDriverState *hd0, BlockDriverState *hd1);
588 void pci_ide_init(PCIBus *bus, BlockDriverState **hd_table);
589 void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table);
590 int pmac_ide_init (BlockDriverState **hd_table,
591                    openpic_t *openpic, int irq);
592
593 /* sb16.c */
594 void SB16_init (void);
595
596 /* adlib.c */
597 void Adlib_init (void);
598
599 /* gus.c */
600 void GUS_init (void);
601
602 /* dma.c */
603 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
604 int DMA_get_channel_mode (int nchan);
605 int DMA_read_memory (int nchan, void *buf, int pos, int size);
606 int DMA_write_memory (int nchan, void *buf, int pos, int size);
607 void DMA_hold_DREQ (int nchan);
608 void DMA_release_DREQ (int nchan);
609 void DMA_schedule(int nchan);
610 void DMA_run (void);
611 void DMA_init (int high_page_enable);
612 void DMA_register_channel (int nchan,
613                            DMA_transfer_handler transfer_handler,
614                            void *opaque);
615 /* fdc.c */
616 #define MAX_FD 2
617 extern BlockDriverState *fd_table[MAX_FD];
618
619 typedef struct fdctrl_t fdctrl_t;
620
621 fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped, 
622                        uint32_t io_base,
623                        BlockDriverState **fds);
624 int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
625
626 /* ne2000.c */
627
628 void isa_ne2000_init(int base, int irq, NetDriverState *nd);
629 void pci_ne2000_init(PCIBus *bus, NetDriverState *nd);
630
631 /* pckbd.c */
632
633 void kbd_init(void);
634
635 /* mc146818rtc.c */
636
637 typedef struct RTCState RTCState;
638
639 RTCState *rtc_init(int base, int irq);
640 void rtc_set_memory(RTCState *s, int addr, int val);
641 void rtc_set_date(RTCState *s, const struct tm *tm);
642
643 /* serial.c */
644
645 typedef struct SerialState SerialState;
646 SerialState *serial_init(int base, int irq, CharDriverState *chr);
647
648 /* parallel.c */
649
650 typedef struct ParallelState ParallelState;
651 ParallelState *parallel_init(int base, int irq, CharDriverState *chr);
652
653 /* i8259.c */
654
655 void pic_set_irq(int irq, int level);
656 void pic_init(void);
657 uint32_t pic_intack_read(CPUState *env);
658 void pic_info(void);
659 void irq_info(void);
660
661 /* APIC */
662 int apic_init(CPUState *env);
663 int apic_get_interrupt(CPUState *env);
664
665 /* i8254.c */
666
667 #define PIT_FREQ 1193182
668
669 typedef struct PITState PITState;
670
671 PITState *pit_init(int base, int irq);
672 void pit_set_gate(PITState *pit, int channel, int val);
673 int pit_get_gate(PITState *pit, int channel);
674 int pit_get_out(PITState *pit, int channel, int64_t current_time);
675
676 /* pc.c */
677 void pc_init(int ram_size, int vga_ram_size, int boot_device,
678              DisplayState *ds, const char **fd_filename, int snapshot,
679              const char *kernel_filename, const char *kernel_cmdline,
680              const char *initrd_filename);
681
682 /* ppc.c */
683 void ppc_init (int ram_size, int vga_ram_size, int boot_device,
684                DisplayState *ds, const char **fd_filename, int snapshot,
685                const char *kernel_filename, const char *kernel_cmdline,
686                const char *initrd_filename);
687 void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
688                     DisplayState *ds, const char **fd_filename, int snapshot,
689                     const char *kernel_filename, const char *kernel_cmdline,
690                     const char *initrd_filename);
691 void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
692                    DisplayState *ds, const char **fd_filename, int snapshot,
693                    const char *kernel_filename, const char *kernel_cmdline,
694                    const char *initrd_filename);
695 #ifdef TARGET_PPC
696 ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
697 #endif
698 void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
699
700 extern CPUWriteMemoryFunc *PPC_io_write[];
701 extern CPUReadMemoryFunc *PPC_io_read[];
702 extern int prep_enabled;
703
704 /* sun4m.c */
705 void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
706              DisplayState *ds, const char **fd_filename, int snapshot,
707              const char *kernel_filename, const char *kernel_cmdline,
708              const char *initrd_filename);
709 uint32_t iommu_translate(uint32_t addr);
710
711 /* iommu.c */
712 void *iommu_init(uint32_t addr);
713 uint32_t iommu_translate_local(void *opaque, uint32_t addr);
714
715 /* lance.c */
716 void lance_init(NetDriverState *nd, int irq, uint32_t leaddr, uint32_t ledaddr);
717
718 /* tcx.c */
719 void *tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
720                unsigned long vram_offset, int vram_size, int width, int height);
721 void tcx_update_display(void *opaque);
722 void tcx_invalidate_display(void *opaque);
723 void tcx_screen_dump(void *opaque, const char *filename);
724
725 /* slavio_intctl.c */
726 void *slavio_intctl_init();
727 void slavio_pic_info(void *opaque);
728 void slavio_irq_info(void *opaque);
729 void slavio_pic_set_irq(void *opaque, int irq, int level);
730
731 /* magic-load.c */
732 int load_elf(const char *filename, uint8_t *addr);
733 int load_aout(const char *filename, uint8_t *addr);
734
735 /* slavio_timer.c */
736 void slavio_timer_init(uint32_t addr1, int irq1, uint32_t addr2, int irq2);
737
738 /* slavio_serial.c */
739 SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2);
740 void slavio_serial_ms_kbd_init(int base, int irq);
741
742 /* esp.c */
743 void esp_init(BlockDriverState **bd, int irq, uint32_t espaddr, uint32_t espdaddr);
744
745 /* NVRAM helpers */
746 #include "hw/m48t59.h"
747
748 void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
749 uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
750 void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
751 uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
752 void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
753 uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
754 void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
755                        const unsigned char *str, uint32_t max);
756 int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
757 void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
758                     uint32_t start, uint32_t count);
759 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
760                           const unsigned char *arch,
761                           uint32_t RAM_size, int boot_device,
762                           uint32_t kernel_image, uint32_t kernel_size,
763                           const char *cmdline,
764                           uint32_t initrd_image, uint32_t initrd_size,
765                           uint32_t NVRAM_image,
766                           int width, int height, int depth);
767
768 /* adb.c */
769
770 #define MAX_ADB_DEVICES 16
771
772 #define ADB_MAX_OUT_LEN 16
773
774 typedef struct ADBDevice ADBDevice;
775
776 /* buf = NULL means polling */
777 typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
778                               const uint8_t *buf, int len);
779 typedef int ADBDeviceReset(ADBDevice *d);
780
781 struct ADBDevice {
782     struct ADBBusState *bus;
783     int devaddr;
784     int handler;
785     ADBDeviceRequest *devreq;
786     ADBDeviceReset *devreset;
787     void *opaque;
788 };
789
790 typedef struct ADBBusState {
791     ADBDevice devices[MAX_ADB_DEVICES];
792     int nb_devices;
793     int poll_index;
794 } ADBBusState;
795
796 int adb_request(ADBBusState *s, uint8_t *buf_out,
797                 const uint8_t *buf, int len);
798 int adb_poll(ADBBusState *s, uint8_t *buf_out);
799
800 ADBDevice *adb_register_device(ADBBusState *s, int devaddr, 
801                                ADBDeviceRequest *devreq, 
802                                ADBDeviceReset *devreset, 
803                                void *opaque);
804 void adb_kbd_init(ADBBusState *bus);
805 void adb_mouse_init(ADBBusState *bus);
806
807 /* cuda.c */
808
809 extern ADBBusState adb_bus;
810 int cuda_init(openpic_t *openpic, int irq);
811
812 #endif /* defined(QEMU_TOOL) */
813
814 /* monitor.c */
815 void monitor_init(CharDriverState *hd, int show_banner);
816 void term_puts(const char *str);
817 void term_vprintf(const char *fmt, va_list ap);
818 void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
819 void term_flush(void);
820 void term_print_help(void);
821 void monitor_readline(const char *prompt, int is_password,
822                       char *buf, int buf_size);
823
824 /* readline.c */
825 typedef void ReadLineFunc(void *opaque, const char *str);
826
827 extern int completion_index;
828 void add_completion(const char *str);
829 void readline_handle_byte(int ch);
830 void readline_find_completion(const char *cmdline);
831 const char *readline_get_history(unsigned int index);
832 void readline_start(const char *prompt, int is_password,
833                     ReadLineFunc *readline_func, void *opaque);
834
835 #endif /* VL_H */
This page took 0.067229 seconds and 4 git commands to generate.