root / block_int.h @ 86cc1ce0
History | View | Annotate | Download (5.3 kB)
1 | ea2384d3 | bellard | /*
|
---|---|---|---|
2 | ea2384d3 | bellard | * QEMU System Emulator block driver
|
3 | ea2384d3 | bellard | *
|
4 | ea2384d3 | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | ea2384d3 | bellard | *
|
6 | ea2384d3 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | ea2384d3 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | ea2384d3 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | ea2384d3 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | ea2384d3 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | ea2384d3 | bellard | * furnished to do so, subject to the following conditions:
|
12 | ea2384d3 | bellard | *
|
13 | ea2384d3 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | ea2384d3 | bellard | * all copies or substantial portions of the Software.
|
15 | ea2384d3 | bellard | *
|
16 | ea2384d3 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | ea2384d3 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | ea2384d3 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | ea2384d3 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | ea2384d3 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | ea2384d3 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | ea2384d3 | bellard | * THE SOFTWARE.
|
23 | ea2384d3 | bellard | */
|
24 | ea2384d3 | bellard | #ifndef BLOCK_INT_H
|
25 | ea2384d3 | bellard | #define BLOCK_INT_H
|
26 | ea2384d3 | bellard | |
27 | ea2384d3 | bellard | struct BlockDriver {
|
28 | ea2384d3 | bellard | const char *format_name; |
29 | ea2384d3 | bellard | int instance_size;
|
30 | ea2384d3 | bellard | int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); |
31 | 83f64091 | bellard | int (*bdrv_open)(BlockDriverState *bs, const char *filename, int flags); |
32 | ea2384d3 | bellard | int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num,
|
33 | ea2384d3 | bellard | uint8_t *buf, int nb_sectors);
|
34 | ea2384d3 | bellard | int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num,
|
35 | ea2384d3 | bellard | const uint8_t *buf, int nb_sectors); |
36 | e2731add | bellard | void (*bdrv_close)(BlockDriverState *bs);
|
37 | ea2384d3 | bellard | int (*bdrv_create)(const char *filename, int64_t total_sectors, |
38 | ea2384d3 | bellard | const char *backing_file, int flags); |
39 | 7a6cba61 | pbrook | void (*bdrv_flush)(BlockDriverState *bs);
|
40 | ea2384d3 | bellard | int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num,
|
41 | ea2384d3 | bellard | int nb_sectors, int *pnum); |
42 | ea2384d3 | bellard | int (*bdrv_set_key)(BlockDriverState *bs, const char *key); |
43 | 95389c86 | bellard | int (*bdrv_make_empty)(BlockDriverState *bs);
|
44 | 83f64091 | bellard | /* aio */
|
45 | ce1a14dc | pbrook | BlockDriverAIOCB *(*bdrv_aio_read)(BlockDriverState *bs, |
46 | ce1a14dc | pbrook | int64_t sector_num, uint8_t *buf, int nb_sectors,
|
47 | ce1a14dc | pbrook | BlockDriverCompletionFunc *cb, void *opaque);
|
48 | ce1a14dc | pbrook | BlockDriverAIOCB *(*bdrv_aio_write)(BlockDriverState *bs, |
49 | ce1a14dc | pbrook | int64_t sector_num, const uint8_t *buf, int nb_sectors, |
50 | ce1a14dc | pbrook | BlockDriverCompletionFunc *cb, void *opaque);
|
51 | 83f64091 | bellard | void (*bdrv_aio_cancel)(BlockDriverAIOCB *acb);
|
52 | ce1a14dc | pbrook | int aiocb_size;
|
53 | 83f64091 | bellard | |
54 | 83f64091 | bellard | const char *protocol_name; |
55 | 83f64091 | bellard | int (*bdrv_pread)(BlockDriverState *bs, int64_t offset,
|
56 | 83f64091 | bellard | uint8_t *buf, int count);
|
57 | 83f64091 | bellard | int (*bdrv_pwrite)(BlockDriverState *bs, int64_t offset,
|
58 | 83f64091 | bellard | const uint8_t *buf, int count); |
59 | 83f64091 | bellard | int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset);
|
60 | 83f64091 | bellard | int64_t (*bdrv_getlength)(BlockDriverState *bs); |
61 | faea38e7 | bellard | int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
|
62 | faea38e7 | bellard | const uint8_t *buf, int nb_sectors); |
63 | faea38e7 | bellard | |
64 | faea38e7 | bellard | int (*bdrv_snapshot_create)(BlockDriverState *bs,
|
65 | faea38e7 | bellard | QEMUSnapshotInfo *sn_info); |
66 | faea38e7 | bellard | int (*bdrv_snapshot_goto)(BlockDriverState *bs,
|
67 | faea38e7 | bellard | const char *snapshot_id); |
68 | faea38e7 | bellard | int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_id); |
69 | faea38e7 | bellard | int (*bdrv_snapshot_list)(BlockDriverState *bs,
|
70 | faea38e7 | bellard | QEMUSnapshotInfo **psn_info); |
71 | faea38e7 | bellard | int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
|
72 | 83f64091 | bellard | |
73 | 19cb3738 | bellard | /* removable device specific */
|
74 | 19cb3738 | bellard | int (*bdrv_is_inserted)(BlockDriverState *bs);
|
75 | 19cb3738 | bellard | int (*bdrv_media_changed)(BlockDriverState *bs);
|
76 | 19cb3738 | bellard | int (*bdrv_eject)(BlockDriverState *bs, int eject_flag); |
77 | 19cb3738 | bellard | int (*bdrv_set_locked)(BlockDriverState *bs, int locked); |
78 | 19cb3738 | bellard | |
79 | ce1a14dc | pbrook | BlockDriverAIOCB *free_aiocb; |
80 | ea2384d3 | bellard | struct BlockDriver *next;
|
81 | ea2384d3 | bellard | }; |
82 | ea2384d3 | bellard | |
83 | ea2384d3 | bellard | struct BlockDriverState {
|
84 | d15a771d | bellard | int64_t total_sectors; /* if we are reading a disk image, give its
|
85 | d15a771d | bellard | size in sectors */
|
86 | ea2384d3 | bellard | int read_only; /* if true, the media is read only */ |
87 | ea2384d3 | bellard | int removable; /* if true, the media can be removed */ |
88 | ea2384d3 | bellard | int locked; /* if true, the media cannot temporarily be ejected */ |
89 | ea2384d3 | bellard | int encrypted; /* if true, the media is encrypted */ |
90 | ea2384d3 | bellard | /* event callback when inserting/removing */
|
91 | ea2384d3 | bellard | void (*change_cb)(void *opaque); |
92 | ea2384d3 | bellard | void *change_opaque;
|
93 | ea2384d3 | bellard | |
94 | 19cb3738 | bellard | BlockDriver *drv; /* NULL means no media */
|
95 | ea2384d3 | bellard | void *opaque;
|
96 | ea2384d3 | bellard | |
97 | ea2384d3 | bellard | int boot_sector_enabled;
|
98 | ea2384d3 | bellard | uint8_t boot_sector_data[512];
|
99 | ea2384d3 | bellard | |
100 | ea2384d3 | bellard | char filename[1024]; |
101 | ea2384d3 | bellard | char backing_file[1024]; /* if non zero, the image is a diff of |
102 | ea2384d3 | bellard | this file image */
|
103 | ea2384d3 | bellard | int is_temporary;
|
104 | 19cb3738 | bellard | int media_changed;
|
105 | 19cb3738 | bellard | |
106 | ea2384d3 | bellard | BlockDriverState *backing_hd; |
107 | ce1a14dc | pbrook | /* async read/write emulation */
|
108 | 83f64091 | bellard | |
109 | ce1a14dc | pbrook | void *sync_aiocb;
|
110 | ea2384d3 | bellard | |
111 | ea2384d3 | bellard | /* NOTE: the following infos are only hints for real hardware
|
112 | ea2384d3 | bellard | drivers. They are not used by the block driver */
|
113 | 46d4767d | bellard | int cyls, heads, secs, translation;
|
114 | ea2384d3 | bellard | int type;
|
115 | ea2384d3 | bellard | char device_name[32]; |
116 | ea2384d3 | bellard | BlockDriverState *next; |
117 | ea2384d3 | bellard | }; |
118 | ea2384d3 | bellard | |
119 | 83f64091 | bellard | struct BlockDriverAIOCB {
|
120 | 83f64091 | bellard | BlockDriverState *bs; |
121 | 83f64091 | bellard | BlockDriverCompletionFunc *cb; |
122 | ce1a14dc | pbrook | void *opaque;
|
123 | ce1a14dc | pbrook | BlockDriverAIOCB *next; |
124 | 83f64091 | bellard | }; |
125 | 83f64091 | bellard | |
126 | 95389c86 | bellard | void get_tmp_filename(char *filename, int size); |
127 | 95389c86 | bellard | |
128 | ce1a14dc | pbrook | void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb,
|
129 | ce1a14dc | pbrook | void *opaque);
|
130 | ce1a14dc | pbrook | void qemu_aio_release(void *p); |
131 | ce1a14dc | pbrook | |
132 | ea2384d3 | bellard | #endif /* BLOCK_INT_H */ |