]>
Commit | Line | Data |
---|---|---|
6e02c38d AL |
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" | |
6e02c38d AL |
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 */ | |
1063b8b1 CH |
30 | #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */ |
31 | #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/ | |
32 | #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */ | |
bf011293 | 33 | #define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */ |
34 | ||
35 | #define VIRTIO_BLK_ID_LEN 256 /* length of identify u16 array */ | |
36 | #define VIRTIO_BLK_ID_SN 10 /* start of char * serial# */ | |
37 | #define VIRTIO_BLK_ID_SN_BYTES 20 /* length in bytes of serial# */ | |
6e02c38d AL |
38 | |
39 | struct virtio_blk_config | |
40 | { | |
41 | uint64_t capacity; | |
42 | uint32_t size_max; | |
43 | uint32_t seg_max; | |
44 | uint16_t cylinders; | |
45 | uint8_t heads; | |
46 | uint8_t sectors; | |
bf011293 | 47 | uint32_t _blk_size; /* structure pad, currently unused */ |
48 | uint16_t identify[VIRTIO_BLK_ID_LEN]; | |
6e02c38d AL |
49 | } __attribute__((packed)); |
50 | ||
51 | /* These two define direction. */ | |
52 | #define VIRTIO_BLK_T_IN 0 | |
53 | #define VIRTIO_BLK_T_OUT 1 | |
54 | ||
55 | /* This bit says it's a scsi command, not an actual read or write. */ | |
56 | #define VIRTIO_BLK_T_SCSI_CMD 2 | |
57 | ||
58 | /* Barrier before this op. */ | |
59 | #define VIRTIO_BLK_T_BARRIER 0x80000000 | |
60 | ||
61 | /* This is the first element of the read scatter-gather list. */ | |
62 | struct virtio_blk_outhdr | |
63 | { | |
64 | /* VIRTIO_BLK_T* */ | |
65 | uint32_t type; | |
66 | /* io priority. */ | |
67 | uint32_t ioprio; | |
68 | /* Sector (ie. 512 byte offset) */ | |
69 | uint64_t sector; | |
70 | }; | |
71 | ||
72 | #define VIRTIO_BLK_S_OK 0 | |
73 | #define VIRTIO_BLK_S_IOERR 1 | |
74 | #define VIRTIO_BLK_S_UNSUPP 2 | |
75 | ||
8b91408b | 76 | /* This is the last element of the write scatter-gather list */ |
6e02c38d AL |
77 | struct virtio_blk_inhdr |
78 | { | |
79 | unsigned char status; | |
80 | }; | |
81 | ||
1063b8b1 CH |
82 | /* SCSI pass-through header */ |
83 | struct virtio_scsi_inhdr | |
84 | { | |
85 | uint32_t errors; | |
86 | uint32_t data_len; | |
87 | uint32_t sense_len; | |
88 | uint32_t residual; | |
89 | }; | |
90 | ||
6e02c38d | 91 | #endif |