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