root / block_int.h @ a8d3431a
History | View | Annotate | Download (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 | ea2384d3 | bellard | int (*bdrv_open)(BlockDriverState *bs, const char *filename); |
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 | ea2384d3 | bellard | int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num,
|
40 | ea2384d3 | bellard | int nb_sectors, int *pnum); |
41 | ea2384d3 | bellard | int (*bdrv_set_key)(BlockDriverState *bs, const char *key); |
42 | ea2384d3 | bellard | struct BlockDriver *next;
|
43 | ea2384d3 | bellard | }; |
44 | ea2384d3 | bellard | |
45 | ea2384d3 | bellard | struct BlockDriverState {
|
46 | ea2384d3 | bellard | int64_t total_sectors; |
47 | ea2384d3 | bellard | int read_only; /* if true, the media is read only */ |
48 | ea2384d3 | bellard | int inserted; /* if true, the media is present */ |
49 | ea2384d3 | bellard | int removable; /* if true, the media can be removed */ |
50 | ea2384d3 | bellard | int locked; /* if true, the media cannot temporarily be ejected */ |
51 | ea2384d3 | bellard | int encrypted; /* if true, the media is encrypted */ |
52 | ea2384d3 | bellard | /* event callback when inserting/removing */
|
53 | ea2384d3 | bellard | void (*change_cb)(void *opaque); |
54 | ea2384d3 | bellard | void *change_opaque;
|
55 | ea2384d3 | bellard | |
56 | ea2384d3 | bellard | BlockDriver *drv; |
57 | ea2384d3 | bellard | void *opaque;
|
58 | ea2384d3 | bellard | |
59 | ea2384d3 | bellard | int boot_sector_enabled;
|
60 | ea2384d3 | bellard | uint8_t boot_sector_data[512];
|
61 | ea2384d3 | bellard | |
62 | ea2384d3 | bellard | char filename[1024]; |
63 | ea2384d3 | bellard | char backing_file[1024]; /* if non zero, the image is a diff of |
64 | ea2384d3 | bellard | this file image */
|
65 | ea2384d3 | bellard | int is_temporary;
|
66 | ea2384d3 | bellard | |
67 | ea2384d3 | bellard | BlockDriverState *backing_hd; |
68 | ea2384d3 | bellard | |
69 | ea2384d3 | bellard | /* NOTE: the following infos are only hints for real hardware
|
70 | ea2384d3 | bellard | drivers. They are not used by the block driver */
|
71 | 46d4767d | bellard | int cyls, heads, secs, translation;
|
72 | ea2384d3 | bellard | int type;
|
73 | ea2384d3 | bellard | char device_name[32]; |
74 | ea2384d3 | bellard | BlockDriverState *next; |
75 | ea2384d3 | bellard | }; |
76 | ea2384d3 | bellard | |
77 | ea2384d3 | bellard | #endif /* BLOCK_INT_H */ |