Only define __llseek if it is going to be used
[qemu/mini2440.git] / hw / virtio-blk.h
blobdff3e0c979ec4ae5353f86f322bdcbcee80c4ba6
1 /*
2 * Virtio Block Device
4 * Copyright IBM, Corp. 2007
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
14 #ifndef _QEMU_VIRTIO_BLK_H
15 #define _QEMU_VIRTIO_BLK_H
17 #include "virtio.h"
18 #include "block.h"
20 /* from Linux's linux/virtio_blk.h */
22 /* The ID for virtio_block */
23 #define VIRTIO_ID_BLOCK 2
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 #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 */
34 struct virtio_blk_config
36 uint64_t capacity;
37 uint32_t size_max;
38 uint32_t seg_max;
39 uint16_t cylinders;
40 uint8_t heads;
41 uint8_t sectors;
42 } __attribute__((packed));
44 /* These two define direction. */
45 #define VIRTIO_BLK_T_IN 0
46 #define VIRTIO_BLK_T_OUT 1
48 /* This bit says it's a scsi command, not an actual read or write. */
49 #define VIRTIO_BLK_T_SCSI_CMD 2
51 /* Barrier before this op. */
52 #define VIRTIO_BLK_T_BARRIER 0x80000000
54 /* This is the first element of the read scatter-gather list. */
55 struct virtio_blk_outhdr
57 /* VIRTIO_BLK_T* */
58 uint32_t type;
59 /* io priority. */
60 uint32_t ioprio;
61 /* Sector (ie. 512 byte offset) */
62 uint64_t sector;
65 #define VIRTIO_BLK_S_OK 0
66 #define VIRTIO_BLK_S_IOERR 1
67 #define VIRTIO_BLK_S_UNSUPP 2
69 /* This is the last element of the write scatter-gather list */
70 struct virtio_blk_inhdr
72 unsigned char status;
75 /* SCSI pass-through header */
76 struct virtio_scsi_inhdr
78 uint32_t errors;
79 uint32_t data_len;
80 uint32_t sense_len;
81 uint32_t residual;
84 #endif