debuggers.hg

view tools/ioemu/vl.h @ 10971:386990d004b8

[qemu] Add switch to control whether acpi bridge is enabled.

Signed-off-by: Winston Wang <winston.l.wang@intel.com>
author chris@kneesaa.uk.xensource.com
date Fri Aug 04 10:41:27 2006 +0100 (2006-08-04)
parents 155385a02d0b
children 08a11694b109
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"
76 #include "gdbstub.h"
78 #endif /* !defined(QEMU_TOOL) */
80 #ifndef glue
81 #define xglue(x, y) x ## y
82 #define glue(x, y) xglue(x, y)
83 #define stringify(s) tostring(s)
84 #define tostring(s) #s
85 #endif
87 #ifndef MIN
88 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
89 #endif
90 #ifndef MAX
91 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
92 #endif
94 /* vl.c */
95 uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
97 void hw_error(const char *fmt, ...);
99 extern const char *bios_dir;
101 void pstrcpy(char *buf, int buf_size, const char *str);
102 char *pstrcat(char *buf, int buf_size, const char *s);
103 int strstart(const char *str, const char *val, const char **ptr);
105 extern int vm_running;
107 typedef struct vm_change_state_entry VMChangeStateEntry;
108 typedef void VMChangeStateHandler(void *opaque, int running);
109 typedef void VMStopHandler(void *opaque, int reason);
111 VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
112 void *opaque);
113 void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
115 int qemu_add_vm_stop_handler(VMStopHandler *cb, void *opaque);
116 void qemu_del_vm_stop_handler(VMStopHandler *cb, void *opaque);
118 void vm_start(void);
119 void vm_stop(int reason);
121 typedef void QEMUResetHandler(void *opaque);
123 void qemu_register_reset(QEMUResetHandler *func, void *opaque);
124 void qemu_system_reset_request(void);
125 void qemu_system_reset(void);
126 void qemu_system_shutdown_request(void);
127 void qemu_system_powerdown_request(void);
128 #if !defined(TARGET_SPARC)
129 // Please implement a power failure function to signal the OS
130 #define qemu_system_powerdown() do{}while(0)
131 #else
132 void qemu_system_powerdown(void);
133 #endif
135 extern int reset_requested;
137 void main_loop_wait(int timeout);
139 int unset_mm_mapping(int xc_handle, uint32_t domid, unsigned long nr_pages,
140 unsigned int address_bits, unsigned long *extent_start);
141 int set_mm_mapping(int xc_handle, uint32_t domid, unsigned long nr_pages,
142 unsigned int address_bits, unsigned long *extent_start);
144 extern void *shared_vram;
146 extern FILE *logfile;
148 extern int xc_handle;
149 extern int domid;
151 extern uint64_t ram_size;
152 extern int bios_size;
153 extern int rtc_utc;
154 extern int cirrus_vga_enabled;
155 extern int graphic_width;
156 extern int graphic_height;
157 extern int graphic_depth;
158 extern const char *keyboard_layout;
159 extern int kqemu_allowed;
160 extern int win2k_install_hack;
161 extern int usb_enabled;
162 extern int acpi_enabled;
163 extern int smp_cpus;
165 /* XXX: make it dynamic */
166 #if defined (TARGET_PPC)
167 #define BIOS_SIZE ((512 + 32) * 1024)
168 #elif defined(TARGET_MIPS)
169 #define BIOS_SIZE (128 * 1024)
170 #else
171 #define BIOS_SIZE ((256 + 64) * 1024)
172 #endif
174 /* keyboard/mouse support */
176 #define MOUSE_EVENT_LBUTTON 0x01
177 #define MOUSE_EVENT_RBUTTON 0x02
178 #define MOUSE_EVENT_MBUTTON 0x04
180 typedef void QEMUPutKBDEvent(void *opaque, int keycode);
181 typedef void QEMUPutMouseEvent(void *opaque, int dx, int dy, int dz, int buttons_state);
183 void qemu_add_kbd_event_handler(QEMUPutKBDEvent *func, void *opaque);
184 void qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, void *opaque, int absolute);
186 void kbd_put_keycode(int keycode);
187 void kbd_mouse_event(int dx, int dy, int dz, int buttons_state);
188 int kbd_mouse_is_absolute(void);
190 /* keysym is a unicode code except for special keys (see QEMU_KEY_xxx
191 constants) */
192 #define QEMU_KEY_ESC1(c) ((c) | 0xe100)
193 #define QEMU_KEY_BACKSPACE 0x007f
194 #define QEMU_KEY_UP QEMU_KEY_ESC1('A')
195 #define QEMU_KEY_DOWN QEMU_KEY_ESC1('B')
196 #define QEMU_KEY_RIGHT QEMU_KEY_ESC1('C')
197 #define QEMU_KEY_LEFT QEMU_KEY_ESC1('D')
198 #define QEMU_KEY_HOME QEMU_KEY_ESC1(1)
199 #define QEMU_KEY_END QEMU_KEY_ESC1(4)
200 #define QEMU_KEY_PAGEUP QEMU_KEY_ESC1(5)
201 #define QEMU_KEY_PAGEDOWN QEMU_KEY_ESC1(6)
202 #define QEMU_KEY_DELETE QEMU_KEY_ESC1(3)
204 #define QEMU_KEY_CTRL_UP 0xe400
205 #define QEMU_KEY_CTRL_DOWN 0xe401
206 #define QEMU_KEY_CTRL_LEFT 0xe402
207 #define QEMU_KEY_CTRL_RIGHT 0xe403
208 #define QEMU_KEY_CTRL_HOME 0xe404
209 #define QEMU_KEY_CTRL_END 0xe405
210 #define QEMU_KEY_CTRL_PAGEUP 0xe406
211 #define QEMU_KEY_CTRL_PAGEDOWN 0xe407
213 void kbd_put_keysym(int keysym);
215 /* async I/O support */
217 typedef void IOReadHandler(void *opaque, const uint8_t *buf, int size);
218 typedef int IOCanRWHandler(void *opaque);
219 typedef void IOHandler(void *opaque);
221 int qemu_set_fd_handler2(int fd,
222 IOCanRWHandler *fd_read_poll,
223 IOHandler *fd_read,
224 IOHandler *fd_write,
225 void *opaque);
226 int qemu_set_fd_handler(int fd,
227 IOHandler *fd_read,
228 IOHandler *fd_write,
229 void *opaque);
231 /* Polling handling */
233 /* return TRUE if no sleep should be done afterwards */
234 typedef int PollingFunc(void *opaque);
236 int qemu_add_polling_cb(PollingFunc *func, void *opaque);
237 void qemu_del_polling_cb(PollingFunc *func, void *opaque);
239 /* character device */
241 #define CHR_EVENT_BREAK 0 /* serial break char */
242 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
246 #define CHR_IOCTL_SERIAL_SET_PARAMS 1
247 typedef struct {
248 int speed;
249 int parity;
250 int data_bits;
251 int stop_bits;
252 } QEMUSerialSetParams;
254 #define CHR_IOCTL_SERIAL_SET_BREAK 2
256 #define CHR_IOCTL_PP_READ_DATA 3
257 #define CHR_IOCTL_PP_WRITE_DATA 4
258 #define CHR_IOCTL_PP_READ_CONTROL 5
259 #define CHR_IOCTL_PP_WRITE_CONTROL 6
260 #define CHR_IOCTL_PP_READ_STATUS 7
262 typedef void IOEventHandler(void *opaque, int event);
264 typedef struct CharDriverState {
265 int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
266 void (*chr_add_read_handler)(struct CharDriverState *s,
267 IOCanRWHandler *fd_can_read,
268 IOReadHandler *fd_read, void *opaque);
269 int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
270 IOEventHandler *chr_event;
271 void (*chr_send_event)(struct CharDriverState *chr, int event);
272 void (*chr_close)(struct CharDriverState *chr);
273 void *opaque;
274 } CharDriverState;
276 void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
277 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
278 void qemu_chr_send_event(CharDriverState *s, int event);
279 void qemu_chr_add_read_handler(CharDriverState *s,
280 IOCanRWHandler *fd_can_read,
281 IOReadHandler *fd_read, void *opaque);
282 void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
283 int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
285 /* consoles */
287 typedef struct DisplayState DisplayState;
288 typedef struct TextConsole TextConsole;
290 typedef void (*vga_hw_update_ptr)(void *);
291 typedef void (*vga_hw_invalidate_ptr)(void *);
292 typedef void (*vga_hw_screen_dump_ptr)(void *, const char *);
294 TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
295 vga_hw_invalidate_ptr invalidate,
296 vga_hw_screen_dump_ptr screen_dump,
297 void *opaque);
298 void vga_hw_update(void);
299 void vga_hw_invalidate(void);
300 void vga_hw_screen_dump(const char *filename);
302 int is_graphic_console(void);
303 CharDriverState *text_console_init(DisplayState *ds);
304 void console_select(unsigned int index);
305 void set_color_table(DisplayState *ds);
307 /* serial ports */
309 #define MAX_SERIAL_PORTS 4
311 extern CharDriverState *serial_hds[MAX_SERIAL_PORTS];
313 /* parallel ports */
315 #define MAX_PARALLEL_PORTS 3
317 extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
319 /* VLANs support */
321 typedef struct VLANClientState VLANClientState;
323 struct VLANClientState {
324 IOReadHandler *fd_read;
325 /* Packets may still be sent if this returns zero. It's used to
326 rate-limit the slirp code. */
327 IOCanRWHandler *fd_can_read;
328 void *opaque;
329 struct VLANClientState *next;
330 struct VLANState *vlan;
331 char info_str[256];
332 };
334 typedef struct VLANState {
335 int id;
336 VLANClientState *first_client;
337 struct VLANState *next;
338 } VLANState;
340 VLANState *qemu_find_vlan(int id);
341 VLANClientState *qemu_new_vlan_client(VLANState *vlan,
342 IOReadHandler *fd_read,
343 IOCanRWHandler *fd_can_read,
344 void *opaque);
345 int qemu_can_send_packet(VLANClientState *vc);
346 void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
347 void qemu_handler_true(void *opaque);
349 void do_info_network(void);
351 /* TAP win32 */
352 int tap_win32_init(VLANState *vlan, const char *ifname);
353 void tap_win32_poll(void);
355 /* NIC info */
357 #define MAX_NICS 8
359 typedef struct NICInfo {
360 uint8_t macaddr[6];
361 const char *model;
362 VLANState *vlan;
363 } NICInfo;
365 extern int nb_nics;
366 extern NICInfo nd_table[MAX_NICS];
368 /* timers */
370 typedef struct QEMUClock QEMUClock;
371 typedef struct QEMUTimer QEMUTimer;
372 typedef void QEMUTimerCB(void *opaque);
374 /* The real time clock should be used only for stuff which does not
375 change the virtual machine state, as it is run even if the virtual
376 machine is stopped. The real time clock has a frequency of 1000
377 Hz. */
378 extern QEMUClock *rt_clock;
380 /* The virtual clock is only run during the emulation. It is stopped
381 when the virtual machine is stopped. Virtual timers use a high
382 precision clock, usually cpu cycles (use ticks_per_sec). */
383 extern QEMUClock *vm_clock;
385 int64_t qemu_get_clock(QEMUClock *clock);
387 QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque);
388 void qemu_free_timer(QEMUTimer *ts);
389 void qemu_del_timer(QEMUTimer *ts);
390 void qemu_mod_timer(QEMUTimer *ts, int64_t expire_time);
391 int qemu_timer_pending(QEMUTimer *ts);
393 extern int64_t ticks_per_sec;
394 extern int pit_min_timer_count;
396 void cpu_enable_ticks(void);
397 void cpu_disable_ticks(void);
399 /* VM Load/Save */
401 typedef FILE QEMUFile;
403 void qemu_put_buffer(QEMUFile *f, const uint8_t *buf, int size);
404 void qemu_put_byte(QEMUFile *f, int v);
405 void qemu_put_be16(QEMUFile *f, unsigned int v);
406 void qemu_put_be32(QEMUFile *f, unsigned int v);
407 void qemu_put_be64(QEMUFile *f, uint64_t v);
408 int qemu_get_buffer(QEMUFile *f, uint8_t *buf, int size);
409 int qemu_get_byte(QEMUFile *f);
410 unsigned int qemu_get_be16(QEMUFile *f);
411 unsigned int qemu_get_be32(QEMUFile *f);
412 uint64_t qemu_get_be64(QEMUFile *f);
414 static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv)
415 {
416 qemu_put_be64(f, *pv);
417 }
419 static inline void qemu_put_be32s(QEMUFile *f, const uint32_t *pv)
420 {
421 qemu_put_be32(f, *pv);
422 }
424 static inline void qemu_put_be16s(QEMUFile *f, const uint16_t *pv)
425 {
426 qemu_put_be16(f, *pv);
427 }
429 static inline void qemu_put_8s(QEMUFile *f, const uint8_t *pv)
430 {
431 qemu_put_byte(f, *pv);
432 }
434 static inline void qemu_get_be64s(QEMUFile *f, uint64_t *pv)
435 {
436 *pv = qemu_get_be64(f);
437 }
439 static inline void qemu_get_be32s(QEMUFile *f, uint32_t *pv)
440 {
441 *pv = qemu_get_be32(f);
442 }
444 static inline void qemu_get_be16s(QEMUFile *f, uint16_t *pv)
445 {
446 *pv = qemu_get_be16(f);
447 }
449 static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv)
450 {
451 *pv = qemu_get_byte(f);
452 }
454 #if TARGET_LONG_BITS == 64
455 #define qemu_put_betl qemu_put_be64
456 #define qemu_get_betl qemu_get_be64
457 #define qemu_put_betls qemu_put_be64s
458 #define qemu_get_betls qemu_get_be64s
459 #else
460 #define qemu_put_betl qemu_put_be32
461 #define qemu_get_betl qemu_get_be32
462 #define qemu_put_betls qemu_put_be32s
463 #define qemu_get_betls qemu_get_be32s
464 #endif
466 int64_t qemu_ftell(QEMUFile *f);
467 int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence);
469 typedef void SaveStateHandler(QEMUFile *f, void *opaque);
470 typedef int LoadStateHandler(QEMUFile *f, void *opaque, int version_id);
472 int qemu_loadvm(const char *filename);
473 int qemu_savevm(const char *filename);
474 int register_savevm(const char *idstr,
475 int instance_id,
476 int version_id,
477 SaveStateHandler *save_state,
478 LoadStateHandler *load_state,
479 void *opaque);
480 void qemu_get_timer(QEMUFile *f, QEMUTimer *ts);
481 void qemu_put_timer(QEMUFile *f, QEMUTimer *ts);
483 void cpu_save(QEMUFile *f, void *opaque);
484 int cpu_load(QEMUFile *f, void *opaque, int version_id);
486 /* block.c */
487 typedef struct BlockDriverState BlockDriverState;
488 typedef struct BlockDriver BlockDriver;
490 extern BlockDriver bdrv_raw;
491 extern BlockDriver bdrv_cow;
492 extern BlockDriver bdrv_qcow;
493 extern BlockDriver bdrv_vmdk;
494 extern BlockDriver bdrv_cloop;
495 extern BlockDriver bdrv_dmg;
496 extern BlockDriver bdrv_bochs;
497 extern BlockDriver bdrv_vpc;
498 extern BlockDriver bdrv_vvfat;
500 void bdrv_init(void);
501 BlockDriver *bdrv_find_format(const char *format_name);
502 int bdrv_create(BlockDriver *drv,
503 const char *filename, int64_t size_in_sectors,
504 const char *backing_file, int flags);
505 BlockDriverState *bdrv_new(const char *device_name);
506 void bdrv_delete(BlockDriverState *bs);
507 int bdrv_open(BlockDriverState *bs, const char *filename, int snapshot);
508 int bdrv_open2(BlockDriverState *bs, const char *filename, int snapshot,
509 BlockDriver *drv);
510 void bdrv_close(BlockDriverState *bs);
511 int bdrv_read(BlockDriverState *bs, int64_t sector_num,
512 uint8_t *buf, int nb_sectors);
513 int bdrv_write(BlockDriverState *bs, int64_t sector_num,
514 const uint8_t *buf, int nb_sectors);
515 void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr);
516 int bdrv_commit(BlockDriverState *bs);
517 void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size);
519 #define BDRV_TYPE_HD 0
520 #define BDRV_TYPE_CDROM 1
521 #define BDRV_TYPE_FLOPPY 2
522 #define BIOS_ATA_TRANSLATION_AUTO 0
523 #define BIOS_ATA_TRANSLATION_NONE 1
524 #define BIOS_ATA_TRANSLATION_LBA 2
526 void bdrv_set_geometry_hint(BlockDriverState *bs,
527 int cyls, int heads, int secs);
528 void bdrv_set_type_hint(BlockDriverState *bs, int type);
529 void bdrv_set_translation_hint(BlockDriverState *bs, int translation);
530 void bdrv_get_geometry_hint(BlockDriverState *bs,
531 int *pcyls, int *pheads, int *psecs);
532 int bdrv_get_type_hint(BlockDriverState *bs);
533 int bdrv_get_translation_hint(BlockDriverState *bs);
534 int bdrv_is_removable(BlockDriverState *bs);
535 int bdrv_is_read_only(BlockDriverState *bs);
536 int bdrv_is_inserted(BlockDriverState *bs);
537 int bdrv_is_locked(BlockDriverState *bs);
538 void bdrv_set_locked(BlockDriverState *bs, int locked);
539 void bdrv_set_change_cb(BlockDriverState *bs,
540 void (*change_cb)(void *opaque), void *opaque);
541 void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size);
542 void bdrv_info(void);
543 BlockDriverState *bdrv_find(const char *name);
544 void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque);
545 int bdrv_is_encrypted(BlockDriverState *bs);
546 int bdrv_set_key(BlockDriverState *bs, const char *key);
547 void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
548 void *opaque);
549 const char *bdrv_get_device_name(BlockDriverState *bs);
551 int qcow_get_cluster_size(BlockDriverState *bs);
552 int qcow_compress_cluster(BlockDriverState *bs, int64_t sector_num,
553 const uint8_t *buf);
555 #ifndef QEMU_TOOL
557 typedef void QEMUMachineInitFunc(uint64_t ram_size, int vga_ram_size,
558 int boot_device,
559 DisplayState *ds, const char **fd_filename, int snapshot,
560 const char *kernel_filename, const char *kernel_cmdline,
561 const char *initrd_filename, time_t timeoffset);
563 typedef struct QEMUMachine {
564 const char *name;
565 const char *desc;
566 QEMUMachineInitFunc *init;
567 struct QEMUMachine *next;
568 } QEMUMachine;
570 int qemu_register_machine(QEMUMachine *m);
572 typedef void SetIRQFunc(void *opaque, int irq_num, int level);
573 typedef void IRQRequestFunc(void *opaque, int level);
575 /* ISA bus */
577 extern target_phys_addr_t isa_mem_base;
579 typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data);
580 typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address);
582 int register_ioport_read(int start, int length, int size,
583 IOPortReadFunc *func, void *opaque);
584 int register_ioport_write(int start, int length, int size,
585 IOPortWriteFunc *func, void *opaque);
586 void isa_unassign_ioport(int start, int length);
588 /* PCI bus */
590 extern target_phys_addr_t pci_mem_base;
592 typedef struct PCIBus PCIBus;
593 typedef struct PCIDevice PCIDevice;
595 typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
596 uint32_t address, uint32_t data, int len);
597 typedef uint32_t PCIConfigReadFunc(PCIDevice *pci_dev,
598 uint32_t address, int len);
599 typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
600 uint32_t addr, uint32_t size, int type);
602 #define PCI_ADDRESS_SPACE_MEM 0x00
603 #define PCI_ADDRESS_SPACE_IO 0x01
604 #define PCI_ADDRESS_SPACE_MEM_PREFETCH 0x08
606 typedef struct PCIIORegion {
607 uint32_t addr; /* current PCI mapping address. -1 means not mapped */
608 uint32_t size;
609 uint8_t type;
610 PCIMapIORegionFunc *map_func;
611 } PCIIORegion;
613 #define PCI_ROM_SLOT 6
614 #define PCI_NUM_REGIONS 7
615 struct PCIDevice {
616 /* PCI config space */
617 uint8_t config[256];
619 /* the following fields are read only */
620 PCIBus *bus;
621 int devfn;
622 char name[64];
623 PCIIORegion io_regions[PCI_NUM_REGIONS];
625 /* do not access the following fields */
626 PCIConfigReadFunc *config_read;
627 PCIConfigWriteFunc *config_write;
628 int irq_index;
629 };
631 PCIDevice *pci_register_device(PCIBus *bus, const char *name,
632 int instance_size, int devfn,
633 PCIConfigReadFunc *config_read,
634 PCIConfigWriteFunc *config_write);
636 void pci_register_io_region(PCIDevice *pci_dev, int region_num,
637 uint32_t size, int type,
638 PCIMapIORegionFunc *map_func);
640 void pci_set_irq(PCIDevice *pci_dev, int irq_num, int level);
642 uint32_t pci_default_read_config(PCIDevice *d,
643 uint32_t address, int len);
644 void pci_default_write_config(PCIDevice *d,
645 uint32_t address, uint32_t val, int len);
646 void generic_pci_save(QEMUFile* f, void *opaque);
647 int generic_pci_load(QEMUFile* f, void *opaque, int version_id);
649 extern struct PIIX3State *piix3_state;
651 PCIBus *i440fx_init(void);
652 void piix3_init(PCIBus *bus);
653 void pci_bios_init(void);
654 void pci_info(void);
656 /* temporary: will be moved in platform specific file */
657 void pci_set_pic(PCIBus *bus, SetIRQFunc *set_irq, void *irq_opaque);
658 PCIBus *pci_prep_init(void);
659 PCIBus *pci_grackle_init(uint32_t base);
660 PCIBus *pci_pmac_init(void);
661 PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base);
663 void pci_nic_init(PCIBus *bus, NICInfo *nd);
665 /* openpic.c */
666 typedef struct openpic_t openpic_t;
667 void openpic_set_irq(void *opaque, int n_IRQ, int level);
668 openpic_t *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus,
669 CPUState **envp);
671 /* heathrow_pic.c */
672 typedef struct HeathrowPICS HeathrowPICS;
673 void heathrow_pic_set_irq(void *opaque, int num, int level);
674 HeathrowPICS *heathrow_pic_init(int *pmem_index);
676 #ifdef HAS_AUDIO
677 struct soundhw {
678 const char *name;
679 const char *descr;
680 int enabled;
681 int isa;
682 union {
683 int (*init_isa) (AudioState *s);
684 int (*init_pci) (PCIBus *bus, AudioState *s);
685 } init;
686 };
688 extern struct soundhw soundhw[];
689 #endif
691 /* vga.c */
693 #define VGA_RAM_SIZE (4096 * 1024)
695 struct DisplayState {
696 uint8_t *data;
697 int linesize;
698 int depth;
699 int width;
700 int height;
701 void *opaque;
703 void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
704 void (*dpy_resize)(struct DisplayState *s, int w, int h);
705 void (*dpy_refresh)(struct DisplayState *s);
706 void (*dpy_copy)(struct DisplayState *s, int src_x, int src_y, int dst_x, int dst_y, int w, int h);
707 };
709 static inline void dpy_update(DisplayState *s, int x, int y, int w, int h)
710 {
711 s->dpy_update(s, x, y, w, h);
712 }
714 static inline void dpy_resize(DisplayState *s, int w, int h)
715 {
716 s->dpy_resize(s, w, h);
717 }
719 int vga_initialize(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
720 unsigned long vga_ram_offset, int vga_ram_size,
721 unsigned long vga_bios_offset, int vga_bios_size);
723 /* cirrus_vga.c */
724 void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
725 unsigned long vga_ram_offset, int vga_ram_size);
726 void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
727 unsigned long vga_ram_offset, int vga_ram_size);
729 /* sdl.c */
730 void sdl_display_init(DisplayState *ds, int full_screen);
732 /* cocoa.m */
733 void cocoa_display_init(DisplayState *ds, int full_screen);
735 /* vnc.c */
736 void vnc_display_init(DisplayState *ds, int display);
737 int vnc_start_viewer(int port);
739 /* ide.c */
740 #define MAX_DISKS 4
742 extern BlockDriverState *bs_table[MAX_DISKS];
744 void isa_ide_init(int iobase, int iobase2, int irq,
745 BlockDriverState *hd0, BlockDriverState *hd1);
746 void pci_cmd646_ide_init(PCIBus *bus, BlockDriverState **hd_table,
747 int secondary_ide_enabled);
748 void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table);
749 int pmac_ide_init (BlockDriverState **hd_table,
750 SetIRQFunc *set_irq, void *irq_opaque, int irq);
752 /* es1370.c */
753 int es1370_init (PCIBus *bus, AudioState *s);
755 /* sb16.c */
756 int SB16_init (AudioState *s);
758 /* adlib.c */
759 int Adlib_init (AudioState *s);
761 /* gus.c */
762 int GUS_init (AudioState *s);
764 /* dma.c */
765 typedef int (*DMA_transfer_handler) (void *opaque, int nchan, int pos, int size);
766 int DMA_get_channel_mode (int nchan);
767 int DMA_read_memory (int nchan, void *buf, int pos, int size);
768 int DMA_write_memory (int nchan, void *buf, int pos, int size);
769 void DMA_hold_DREQ (int nchan);
770 void DMA_release_DREQ (int nchan);
771 void DMA_schedule(int nchan);
772 void DMA_run (void);
773 void DMA_init (int high_page_enable);
774 void DMA_register_channel (int nchan,
775 DMA_transfer_handler transfer_handler,
776 void *opaque);
777 /* fdc.c */
778 #define MAX_FD 2
779 extern BlockDriverState *fd_table[MAX_FD];
781 typedef struct fdctrl_t fdctrl_t;
783 fdctrl_t *fdctrl_init (int irq_lvl, int dma_chann, int mem_mapped,
784 uint32_t io_base,
785 BlockDriverState **fds);
786 int fdctrl_get_drive_type(fdctrl_t *fdctrl, int drive_num);
788 /* ne2000.c */
790 void isa_ne2000_init(int base, int irq, NICInfo *nd);
791 void pci_ne2000_init(PCIBus *bus, NICInfo *nd);
793 /* rtl8139.c */
795 void pci_rtl8139_init(PCIBus *bus, NICInfo *nd);
797 /* pckbd.c */
799 void kbd_init(void);
801 /* mc146818rtc.c */
803 typedef struct RTCState RTCState;
805 RTCState *rtc_init(int base, int irq);
806 void rtc_set_memory(RTCState *s, int addr, int val);
807 void rtc_set_date(RTCState *s, const struct tm *tm);
809 /* serial.c */
811 typedef struct SerialState SerialState;
812 SerialState *serial_init(SetIRQFunc *set_irq, void *opaque,
813 int base, int irq, CharDriverState *chr);
814 SerialState *serial_mm_init (SetIRQFunc *set_irq, void *opaque,
815 target_ulong base, int it_shift,
816 int irq, CharDriverState *chr);
818 /* parallel.c */
820 typedef struct ParallelState ParallelState;
821 ParallelState *parallel_init(int base, int irq, CharDriverState *chr);
823 /* i8259.c */
825 typedef struct PicState2 PicState2;
826 extern PicState2 *isa_pic;
827 void pic_set_irq(int irq, int level);
828 void pic_set_irq_new(void *opaque, int irq, int level);
829 PicState2 *pic_init(IRQRequestFunc *irq_request, void *irq_request_opaque);
830 void pic_set_alt_irq_func(PicState2 *s, SetIRQFunc *alt_irq_func,
831 void *alt_irq_opaque);
832 int pic_read_irq(PicState2 *s);
833 void pic_update_irq(PicState2 *s);
834 uint32_t pic_intack_read(PicState2 *s);
835 void pic_info(void);
836 void irq_info(void);
837 void sp_info(void);
839 /* APIC */
840 typedef struct IOAPICState IOAPICState;
842 int apic_init(CPUState *env);
843 int apic_get_interrupt(CPUState *env);
844 IOAPICState *ioapic_init(void);
845 void ioapic_set_irq(void *opaque, int vector, int level);
847 /* i8254.c */
849 #define PIT_FREQ 1193182
851 typedef struct PITState PITState;
853 PITState *pit_init(int base, int irq);
854 void pit_set_gate(PITState *pit, int channel, int val);
855 int pit_get_gate(PITState *pit, int channel);
856 int pit_get_initial_count(PITState *pit, int channel);
857 int pit_get_mode(PITState *pit, int channel);
858 int pit_get_out(PITState *pit, int channel, int64_t current_time);
860 /* pcspk.c */
861 void pcspk_init(PITState *);
862 int pcspk_audio_init(AudioState *);
864 /* pc.c */
865 extern QEMUMachine pc_machine;
866 extern QEMUMachine isapc_machine;
868 void ioport_set_a20(int enable);
869 int ioport_get_a20(void);
871 /* ppc.c */
872 extern QEMUMachine prep_machine;
873 extern QEMUMachine core99_machine;
874 extern QEMUMachine heathrow_machine;
876 /* mips_r4k.c */
877 extern QEMUMachine mips_machine;
879 /* shix.c */
880 extern QEMUMachine shix_machine;
882 #ifdef TARGET_PPC
883 ppc_tb_t *cpu_ppc_tb_init (CPUState *env, uint32_t freq);
884 #endif
885 void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
887 extern CPUWriteMemoryFunc *PPC_io_write[];
888 extern CPUReadMemoryFunc *PPC_io_read[];
889 void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val);
891 /* sun4m.c */
892 extern QEMUMachine sun4m_machine;
893 uint32_t iommu_translate(uint32_t addr);
894 void pic_set_irq_cpu(int irq, int level, unsigned int cpu);
896 /* iommu.c */
897 void *iommu_init(uint32_t addr);
898 uint32_t iommu_translate_local(void *opaque, uint32_t addr);
900 /* lance.c */
901 void lance_init(NICInfo *nd, int irq, uint32_t leaddr, uint32_t ledaddr);
903 /* tcx.c */
904 void tcx_init(DisplayState *ds, uint32_t addr, uint8_t *vram_base,
905 unsigned long vram_offset, int vram_size, int width, int height);
907 /* slavio_intctl.c */
908 void *slavio_intctl_init(void);
909 void slavio_intctl_set_cpu(void *opaque, unsigned int cpu, CPUState *env);
910 void slavio_pic_info(void *opaque);
911 void slavio_irq_info(void *opaque);
912 void slavio_pic_set_irq(void *opaque, int irq, int level);
913 void slavio_pic_set_irq_cpu(void *opaque, int irq, int level, unsigned int cpu);
915 /* loader.c */
916 int get_image_size(const char *filename);
917 int load_image(const char *filename, uint8_t *addr);
918 int load_elf(const char *filename, int64_t virt_to_phys_addend, uint64_t *pentry);
919 int load_aout(const char *filename, uint8_t *addr);
921 /* slavio_timer.c */
922 void slavio_timer_init(uint32_t addr, int irq, int mode, unsigned int cpu);
924 /* slavio_serial.c */
925 SerialState *slavio_serial_init(int base, int irq, CharDriverState *chr1, CharDriverState *chr2);
926 void slavio_serial_ms_kbd_init(int base, int irq);
928 /* slavio_misc.c */
929 void *slavio_misc_init(uint32_t base, int irq);
930 void slavio_set_power_fail(void *opaque, int power_failing);
932 /* esp.c */
933 void esp_init(BlockDriverState **bd, int irq, uint32_t espaddr, uint32_t espdaddr);
935 /* sun4u.c */
936 extern QEMUMachine sun4u_machine;
938 /* NVRAM helpers */
939 #include "hw/m48t59.h"
941 void NVRAM_set_byte (m48t59_t *nvram, uint32_t addr, uint8_t value);
942 uint8_t NVRAM_get_byte (m48t59_t *nvram, uint32_t addr);
943 void NVRAM_set_word (m48t59_t *nvram, uint32_t addr, uint16_t value);
944 uint16_t NVRAM_get_word (m48t59_t *nvram, uint32_t addr);
945 void NVRAM_set_lword (m48t59_t *nvram, uint32_t addr, uint32_t value);
946 uint32_t NVRAM_get_lword (m48t59_t *nvram, uint32_t addr);
947 void NVRAM_set_string (m48t59_t *nvram, uint32_t addr,
948 const unsigned char *str, uint32_t max);
949 int NVRAM_get_string (m48t59_t *nvram, uint8_t *dst, uint16_t addr, int max);
950 void NVRAM_set_crc (m48t59_t *nvram, uint32_t addr,
951 uint32_t start, uint32_t count);
952 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
953 const unsigned char *arch,
954 uint32_t RAM_size, int boot_device,
955 uint32_t kernel_image, uint32_t kernel_size,
956 const char *cmdline,
957 uint32_t initrd_image, uint32_t initrd_size,
958 uint32_t NVRAM_image,
959 int width, int height, int depth);
961 /* adb.c */
963 #define MAX_ADB_DEVICES 16
965 #define ADB_MAX_OUT_LEN 16
967 typedef struct ADBDevice ADBDevice;
969 /* buf = NULL means polling */
970 typedef int ADBDeviceRequest(ADBDevice *d, uint8_t *buf_out,
971 const uint8_t *buf, int len);
972 typedef int ADBDeviceReset(ADBDevice *d);
974 struct ADBDevice {
975 struct ADBBusState *bus;
976 int devaddr;
977 int handler;
978 ADBDeviceRequest *devreq;
979 ADBDeviceReset *devreset;
980 void *opaque;
981 };
983 typedef struct ADBBusState {
984 ADBDevice devices[MAX_ADB_DEVICES];
985 int nb_devices;
986 int poll_index;
987 } ADBBusState;
989 int adb_request(ADBBusState *s, uint8_t *buf_out,
990 const uint8_t *buf, int len);
991 int adb_poll(ADBBusState *s, uint8_t *buf_out);
993 ADBDevice *adb_register_device(ADBBusState *s, int devaddr,
994 ADBDeviceRequest *devreq,
995 ADBDeviceReset *devreset,
996 void *opaque);
997 void adb_kbd_init(ADBBusState *bus);
998 void adb_mouse_init(ADBBusState *bus);
1000 /* cuda.c */
1002 extern ADBBusState adb_bus;
1003 int cuda_init(SetIRQFunc *set_irq, void *irq_opaque, int irq);
1005 #include "hw/usb.h"
1007 /* usb ports of the VM */
1009 #define MAX_VM_USB_PORTS 8
1011 extern USBPort *vm_usb_ports[MAX_VM_USB_PORTS];
1012 extern USBDevice *vm_usb_hub;
1014 void do_usb_add(const char *devname);
1015 void do_usb_del(const char *devname);
1016 void usb_info(void);
1018 /* integratorcp.c */
1019 extern QEMUMachine integratorcp926_machine;
1020 extern QEMUMachine integratorcp1026_machine;
1022 /* versatilepb.c */
1023 extern QEMUMachine versatilepb_machine;
1024 extern QEMUMachine versatileab_machine;
1026 /* ps2.c */
1027 void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg);
1028 void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg);
1029 void ps2_write_mouse(void *, int val);
1030 void ps2_write_keyboard(void *, int val);
1031 uint32_t ps2_read_data(void *);
1032 void ps2_queue(void *, int b);
1033 void ps2_keyboard_set_translation(void *opaque, int mode);
1035 /* smc91c111.c */
1036 void smc91c111_init(NICInfo *, uint32_t, void *, int);
1038 /* pl110.c */
1039 void *pl110_init(DisplayState *ds, uint32_t base, void *pic, int irq, int);
1041 /* pl011.c */
1042 void pl011_init(uint32_t base, void *pic, int irq, CharDriverState *chr);
1044 /* pl050.c */
1045 void pl050_init(uint32_t base, void *pic, int irq, int is_mouse);
1047 /* pl080.c */
1048 void *pl080_init(uint32_t base, void *pic, int irq);
1050 /* pl190.c */
1051 void *pl190_init(uint32_t base, void *parent, int irq, int fiq);
1053 /* arm-timer.c */
1054 void sp804_init(uint32_t base, void *pic, int irq);
1055 void icp_pit_init(uint32_t base, void *pic, int irq);
1057 /* arm_boot.c */
1059 void arm_load_kernel(int ram_size, const char *kernel_filename,
1060 const char *kernel_cmdline, const char *initrd_filename,
1061 int board_id);
1063 /* sh7750.c */
1064 struct SH7750State;
1066 struct SH7750State *sh7750_init(CPUState * cpu);
1068 typedef struct {
1069 /* The callback will be triggered if any of the designated lines change */
1070 uint16_t portamask_trigger;
1071 uint16_t portbmask_trigger;
1072 /* Return 0 if no action was taken */
1073 int (*port_change_cb) (uint16_t porta, uint16_t portb,
1074 uint16_t * periph_pdtra,
1075 uint16_t * periph_portdira,
1076 uint16_t * periph_pdtrb,
1077 uint16_t * periph_portdirb);
1078 } sh7750_io_device;
1080 int sh7750_register_io_device(struct SH7750State *s,
1081 sh7750_io_device * device);
1082 /* tc58128.c */
1083 int tc58128_init(struct SH7750State *s, char *zone1, char *zone2);
1085 #endif /* defined(QEMU_TOOL) */
1087 /* monitor.c */
1088 void monitor_init(CharDriverState *hd, int show_banner);
1089 void term_puts(const char *str);
1090 void term_vprintf(const char *fmt, va_list ap);
1091 void term_printf(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
1092 void term_flush(void);
1093 void term_print_help(void);
1094 void monitor_readline(const char *prompt, int is_password,
1095 char *buf, int buf_size);
1096 void do_eject(int force, const char *filename);
1097 void do_change(const char *device, const char *filename);
1099 /* readline.c */
1100 typedef void ReadLineFunc(void *opaque, const char *str);
1102 extern int completion_index;
1103 void add_completion(const char *str);
1104 void readline_handle_byte(int ch);
1105 void readline_find_completion(const char *cmdline);
1106 const char *readline_get_history(unsigned int index);
1107 void readline_start(const char *prompt, int is_password,
1108 ReadLineFunc *readline_func, void *opaque);
1110 /* xenstore.c */
1111 void xenstore_parse_domain_config(int domid);
1112 int xenstore_fd(void);
1113 void xenstore_process_event(void *opaque);
1114 void xenstore_check_new_media_present(int timeout);
1115 void xenstore_write_vncport(int vnc_display);
1118 void kqemu_record_dump(void);
1120 extern char domain_name[];
1122 void destroy_hvm_domain(void);
1124 #endif /* VL_H */