|
1 /* |
|
2 * Virtio Block Device |
|
3 * |
|
4 * Copyright IBM, Corp. 2007 |
|
5 * |
|
6 * Authors: |
|
7 * Anthony Liguori <aliguori@us.ibm.com> |
|
8 * |
|
9 * This work is licensed under the terms of the GNU GPL, version 2. See |
|
10 * the COPYING file in the top-level directory. |
|
11 * |
|
12 */ |
|
13 |
|
14 #ifndef _QEMU_VIRTIO_BLK_H |
|
15 #define _QEMU_VIRTIO_BLK_H |
|
16 |
|
17 #include "virtio.h" |
|
18 #include "block.h" |
|
19 |
|
20 /* from Linux's linux/virtio_blk.h */ |
|
21 |
|
22 /* The ID for virtio_block */ |
|
23 #define VIRTIO_ID_BLOCK 2 |
|
24 |
|
25 /* Feature bits */ |
|
26 #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */ |
|
27 #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */ |
|
28 #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */ |
|
29 #define VIRTIO_BLK_F_GEOMETRY 4 /* Indicates support of legacy geometry */ |
|
30 |
|
31 struct virtio_blk_config |
|
32 { |
|
33 uint64_t capacity; |
|
34 uint32_t size_max; |
|
35 uint32_t seg_max; |
|
36 uint16_t cylinders; |
|
37 uint8_t heads; |
|
38 uint8_t sectors; |
|
39 } __attribute__((packed)); |
|
40 |
|
41 /* These two define direction. */ |
|
42 #define VIRTIO_BLK_T_IN 0 |
|
43 #define VIRTIO_BLK_T_OUT 1 |
|
44 |
|
45 /* This bit says it's a scsi command, not an actual read or write. */ |
|
46 #define VIRTIO_BLK_T_SCSI_CMD 2 |
|
47 |
|
48 /* Barrier before this op. */ |
|
49 #define VIRTIO_BLK_T_BARRIER 0x80000000 |
|
50 |
|
51 /* This is the first element of the read scatter-gather list. */ |
|
52 struct virtio_blk_outhdr |
|
53 { |
|
54 /* VIRTIO_BLK_T* */ |
|
55 uint32_t type; |
|
56 /* io priority. */ |
|
57 uint32_t ioprio; |
|
58 /* Sector (ie. 512 byte offset) */ |
|
59 uint64_t sector; |
|
60 }; |
|
61 |
|
62 #define VIRTIO_BLK_S_OK 0 |
|
63 #define VIRTIO_BLK_S_IOERR 1 |
|
64 #define VIRTIO_BLK_S_UNSUPP 2 |
|
65 |
|
66 /* This is the first element of the write scatter-gather list */ |
|
67 struct virtio_blk_inhdr |
|
68 { |
|
69 unsigned char status; |
|
70 }; |
|
71 |
|
72 void virtio_blk_init(VirtIOBindFn bind, void *bind_arg, BlockDriverState *bs); |
|
73 |
|
74 #endif |