Revision faf07963 vl.h
b/vl.h | ||
---|---|---|
24 | 24 |
#ifndef VL_H |
25 | 25 |
#define VL_H |
26 | 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 |
|
|
41 |
#ifndef O_LARGEFILE |
|
42 |
#define O_LARGEFILE 0 |
|
43 |
#endif |
|
44 |
#ifndef O_BINARY |
|
45 |
#define O_BINARY 0 |
|
46 |
#endif |
|
47 |
|
|
48 |
#ifndef ENOMEDIUM |
|
49 |
#define ENOMEDIUM ENODEV |
|
50 |
#endif |
|
51 |
|
|
52 |
#ifdef _WIN32 |
|
53 |
#include <windows.h> |
|
54 |
#define fsync _commit |
|
55 |
#define lseek _lseeki64 |
|
56 |
#define ENOTSUP 4096 |
|
57 |
extern int qemu_ftruncate64(int, int64_t); |
|
58 |
#define ftruncate qemu_ftruncate64 |
|
59 |
|
|
60 |
|
|
61 |
static inline char *realpath(const char *path, char *resolved_path) |
|
62 |
{ |
|
63 |
_fullpath(resolved_path, path, _MAX_PATH); |
|
64 |
return resolved_path; |
|
65 |
} |
|
66 |
|
|
67 |
#define PRId64 "I64d" |
|
68 |
#define PRIx64 "I64x" |
|
69 |
#define PRIu64 "I64u" |
|
70 |
#define PRIo64 "I64o" |
|
71 |
#endif |
|
72 |
|
|
73 |
#ifdef QEMU_TOOL |
|
74 |
|
|
75 |
/* we use QEMU_TOOL on code which does not depend on the target CPU |
|
76 |
type */ |
|
77 |
#include "config-host.h" |
|
78 |
#include <setjmp.h> |
|
79 |
#include "osdep.h" |
|
80 |
#include "bswap.h" |
|
81 |
|
|
82 |
#else |
|
83 |
|
|
84 |
#include "cpu.h" |
|
27 |
#include "qemu-common.h" |
|
85 | 28 |
|
86 |
#endif /* !defined(QEMU_TOOL) */ |
|
29 |
/* FIXME: Remove this. */ |
|
30 |
#include "block.h" |
|
87 | 31 |
|
88 | 32 |
#ifndef glue |
89 | 33 |
#define xglue(x, y) x ## y |
... | ... | |
118 | 62 |
|
119 | 63 |
#include "audio/audio.h" |
120 | 64 |
|
121 |
/* cutils.c */ |
|
122 |
void pstrcpy(char *buf, int buf_size, const char *str); |
|
123 |
char *pstrcat(char *buf, int buf_size, const char *s); |
|
124 |
int strstart(const char *str, const char *val, const char **ptr); |
|
125 |
int stristart(const char *str, const char *val, const char **ptr); |
|
126 |
time_t mktimegm(struct tm *tm); |
|
127 |
|
|
128 | 65 |
/* vl.c */ |
129 | 66 |
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); |
130 | 67 |
|
... | ... | |
297 | 234 |
void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque); |
298 | 235 |
#endif |
299 | 236 |
|
300 |
typedef struct QEMUBH QEMUBH; |
|
301 |
|
|
302 | 237 |
/* character device */ |
303 | 238 |
|
304 | 239 |
#define CHR_EVENT_BREAK 0 /* serial break char */ |
... | ... | |
604 | 539 |
void do_delvm(const char *name); |
605 | 540 |
void do_info_snapshots(void); |
606 | 541 |
|
607 |
/* bottom halves */ |
|
608 |
typedef void QEMUBHFunc(void *opaque); |
|
609 |
|
|
610 |
QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque); |
|
611 |
void qemu_bh_schedule(QEMUBH *bh); |
|
612 |
void qemu_bh_cancel(QEMUBH *bh); |
|
613 |
void qemu_bh_delete(QEMUBH *bh); |
|
614 |
int qemu_bh_poll(void); |
|
615 |
|
|
616 |
/* block.c */ |
|
617 |
typedef struct BlockDriverState BlockDriverState; |
|
618 |
typedef struct BlockDriver BlockDriver; |
|
619 |
|
|
620 |
extern BlockDriver bdrv_raw; |
|
621 |
extern BlockDriver bdrv_host_device; |
|
622 |
extern BlockDriver bdrv_cow; |
|
623 |
extern BlockDriver bdrv_qcow; |
|
624 |
extern BlockDriver bdrv_vmdk; |
|
625 |
extern BlockDriver bdrv_cloop; |
|
626 |
extern BlockDriver bdrv_dmg; |
|
627 |
extern BlockDriver bdrv_bochs; |
|
628 |
extern BlockDriver bdrv_vpc; |
|
629 |
extern BlockDriver bdrv_vvfat; |
|
630 |
extern BlockDriver bdrv_qcow2; |
|
631 |
extern BlockDriver bdrv_parallels; |
|
632 |
|
|
633 |
typedef struct BlockDriverInfo { |
|
634 |
/* in bytes, 0 if irrelevant */ |
|
635 |
int cluster_size; |
|
636 |
/* offset at which the VM state can be saved (0 if not possible) */ |
|
637 |
int64_t vm_state_offset; |
|
638 |
} BlockDriverInfo; |
|
639 |
|
|
640 |
typedef struct QEMUSnapshotInfo { |
|
641 |
char id_str[128]; /* unique snapshot id */ |
|
642 |
/* the following fields are informative. They are not needed for |
|
643 |
the consistency of the snapshot */ |
|
644 |
char name[256]; /* user choosen name */ |
|
645 |
uint32_t vm_state_size; /* VM state info size */ |
|
646 |
uint32_t date_sec; /* UTC date of the snapshot */ |
|
647 |
uint32_t date_nsec; |
|
648 |
uint64_t vm_clock_nsec; /* VM clock relative to boot */ |
|
649 |
} QEMUSnapshotInfo; |
|
650 |
|
|
651 |
#define BDRV_O_RDONLY 0x0000 |
|
652 |
#define BDRV_O_RDWR 0x0002 |
|
653 |
#define BDRV_O_ACCESS 0x0003 |
|
654 |
#define BDRV_O_CREAT 0x0004 /* create an empty file */ |
|
655 |
#define BDRV_O_SNAPSHOT 0x0008 /* open the file read only and save writes in a snapshot */ |
|
656 |
#define BDRV_O_FILE 0x0010 /* open as a raw file (do not try to |
|
657 |
use a disk image format on top of |
|
658 |
it (default for |
|
659 |
bdrv_file_open()) */ |
|
660 |
|
|
661 |
void bdrv_init(void); |
|
662 |
BlockDriver *bdrv_find_format(const char *format_name); |
|
663 |
int bdrv_create(BlockDriver *drv, |
|
664 |
const char *filename, int64_t size_in_sectors, |
|
665 |
const char *backing_file, int flags); |
|
666 |
BlockDriverState *bdrv_new(const char *device_name); |
|
667 |
void bdrv_delete(BlockDriverState *bs); |
|
668 |
int bdrv_file_open(BlockDriverState **pbs, const char *filename, int flags); |
|
669 |
int bdrv_open(BlockDriverState *bs, const char *filename, int flags); |
|
670 |
int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, |
|
671 |
BlockDriver *drv); |
|
672 |
void bdrv_close(BlockDriverState *bs); |
|
673 |
int bdrv_read(BlockDriverState *bs, int64_t sector_num, |
|
674 |
uint8_t *buf, int nb_sectors); |
|
675 |
int bdrv_write(BlockDriverState *bs, int64_t sector_num, |
|
676 |
const uint8_t *buf, int nb_sectors); |
|
677 |
int bdrv_pread(BlockDriverState *bs, int64_t offset, |
|
678 |
void *buf, int count); |
|
679 |
int bdrv_pwrite(BlockDriverState *bs, int64_t offset, |
|
680 |
const void *buf, int count); |
|
681 |
int bdrv_truncate(BlockDriverState *bs, int64_t offset); |
|
682 |
int64_t bdrv_getlength(BlockDriverState *bs); |
|
683 |
void bdrv_get_geometry(BlockDriverState *bs, int64_t *nb_sectors_ptr); |
|
684 |
int bdrv_commit(BlockDriverState *bs); |
|
685 |
void bdrv_set_boot_sector(BlockDriverState *bs, const uint8_t *data, int size); |
|
686 |
/* async block I/O */ |
|
687 |
typedef struct BlockDriverAIOCB BlockDriverAIOCB; |
|
688 |
typedef void BlockDriverCompletionFunc(void *opaque, int ret); |
|
689 |
|
|
690 |
BlockDriverAIOCB *bdrv_aio_read(BlockDriverState *bs, int64_t sector_num, |
|
691 |
uint8_t *buf, int nb_sectors, |
|
692 |
BlockDriverCompletionFunc *cb, void *opaque); |
|
693 |
BlockDriverAIOCB *bdrv_aio_write(BlockDriverState *bs, int64_t sector_num, |
|
694 |
const uint8_t *buf, int nb_sectors, |
|
695 |
BlockDriverCompletionFunc *cb, void *opaque); |
|
696 |
void bdrv_aio_cancel(BlockDriverAIOCB *acb); |
|
697 |
|
|
698 |
void qemu_aio_init(void); |
|
699 |
void qemu_aio_poll(void); |
|
700 |
void qemu_aio_flush(void); |
|
701 |
void qemu_aio_wait_start(void); |
|
702 |
void qemu_aio_wait(void); |
|
703 |
void qemu_aio_wait_end(void); |
|
704 |
|
|
705 |
int qemu_key_check(BlockDriverState *bs, const char *name); |
|
706 |
|
|
707 |
/* Ensure contents are flushed to disk. */ |
|
708 |
void bdrv_flush(BlockDriverState *bs); |
|
709 |
|
|
710 |
#define BDRV_TYPE_HD 0 |
|
711 |
#define BDRV_TYPE_CDROM 1 |
|
712 |
#define BDRV_TYPE_FLOPPY 2 |
|
713 |
#define BIOS_ATA_TRANSLATION_AUTO 0 |
|
714 |
#define BIOS_ATA_TRANSLATION_NONE 1 |
|
715 |
#define BIOS_ATA_TRANSLATION_LBA 2 |
|
716 |
#define BIOS_ATA_TRANSLATION_LARGE 3 |
|
717 |
#define BIOS_ATA_TRANSLATION_RECHS 4 |
|
718 |
|
|
719 |
void bdrv_set_geometry_hint(BlockDriverState *bs, |
|
720 |
int cyls, int heads, int secs); |
|
721 |
void bdrv_set_type_hint(BlockDriverState *bs, int type); |
|
722 |
void bdrv_set_translation_hint(BlockDriverState *bs, int translation); |
|
723 |
void bdrv_get_geometry_hint(BlockDriverState *bs, |
|
724 |
int *pcyls, int *pheads, int *psecs); |
|
725 |
int bdrv_get_type_hint(BlockDriverState *bs); |
|
726 |
int bdrv_get_translation_hint(BlockDriverState *bs); |
|
727 |
int bdrv_is_removable(BlockDriverState *bs); |
|
728 |
int bdrv_is_read_only(BlockDriverState *bs); |
|
729 |
int bdrv_is_inserted(BlockDriverState *bs); |
|
730 |
int bdrv_media_changed(BlockDriverState *bs); |
|
731 |
int bdrv_is_locked(BlockDriverState *bs); |
|
732 |
void bdrv_set_locked(BlockDriverState *bs, int locked); |
|
733 |
void bdrv_eject(BlockDriverState *bs, int eject_flag); |
|
734 |
void bdrv_set_change_cb(BlockDriverState *bs, |
|
735 |
void (*change_cb)(void *opaque), void *opaque); |
|
736 |
void bdrv_get_format(BlockDriverState *bs, char *buf, int buf_size); |
|
737 |
void bdrv_info(void); |
|
738 |
BlockDriverState *bdrv_find(const char *name); |
|
739 |
void bdrv_iterate(void (*it)(void *opaque, const char *name), void *opaque); |
|
740 |
int bdrv_is_encrypted(BlockDriverState *bs); |
|
741 |
int bdrv_set_key(BlockDriverState *bs, const char *key); |
|
742 |
void bdrv_iterate_format(void (*it)(void *opaque, const char *name), |
|
743 |
void *opaque); |
|
744 |
const char *bdrv_get_device_name(BlockDriverState *bs); |
|
745 |
int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, |
|
746 |
const uint8_t *buf, int nb_sectors); |
|
747 |
int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); |
|
748 |
|
|
749 |
void bdrv_get_backing_filename(BlockDriverState *bs, |
|
750 |
char *filename, int filename_size); |
|
751 |
int bdrv_snapshot_create(BlockDriverState *bs, |
|
752 |
QEMUSnapshotInfo *sn_info); |
|
753 |
int bdrv_snapshot_goto(BlockDriverState *bs, |
|
754 |
const char *snapshot_id); |
|
755 |
int bdrv_snapshot_delete(BlockDriverState *bs, const char *snapshot_id); |
|
756 |
int bdrv_snapshot_list(BlockDriverState *bs, |
|
757 |
QEMUSnapshotInfo **psn_info); |
|
758 |
char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn); |
|
759 |
|
|
760 |
char *get_human_readable_size(char *buf, int buf_size, int64_t size); |
|
761 |
int path_is_absolute(const char *path); |
|
762 |
void path_combine(char *dest, int dest_size, |
|
763 |
const char *base_path, |
|
764 |
const char *filename); |
|
765 |
|
|
766 |
|
|
767 | 542 |
/* monitor.c */ |
768 | 543 |
void monitor_init(CharDriverState *hd, int show_banner); |
769 | 544 |
void term_puts(const char *str); |
... | ... | |
804 | 579 |
/* x_keymap.c */ |
805 | 580 |
extern uint8_t _translate_keycode(const int key); |
806 | 581 |
|
807 |
#ifndef QEMU_TOOL
|
|
582 |
#ifdef NEED_CPU_H
|
|
808 | 583 |
|
809 | 584 |
typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size, |
810 | 585 |
const char *boot_device, |
... | ... | |
1759 | 1534 |
|
1760 | 1535 |
#include "gdbstub.h" |
1761 | 1536 |
|
1762 |
#endif /* defined(QEMU_TOOL) */
|
|
1537 |
#endif /* defined(NEED_CPU_H) */
|
|
1763 | 1538 |
#endif /* VL_H */ |
Also available in: Unified diff