Code style fixing and adde some documentation
[qemu/ovp.git] / qemu-vio-blk.h
blob77b4527e0d4848723bf5fe35e8695fd9b0361bba
1 #ifndef QUEMU_VIO_BLK_H
2 #define QUEMU_VIO_BLK_H
4 #include <stdint.h>
6 #include "targphys.h"
7 #include "block.h"
8 #include "qemu-vio-virtio.h"
10 /* Flush the volatile write cache */
11 #define VIRTIO_BLK_T_FLUSH 4
13 /* This bit says it's a scsi command, not an actual read or write. */
14 #define VIRTIO_BLK_T_SCSI_CMD 2
16 #define QEMU_VIO_BLK_ID_LEN 256 /* length of identify u16 array */
18 /* These two define direction. */
19 #define VIRTIO_BLK_T_IN 0
20 #define VIRTIO_BLK_T_OUT 1
22 #define VIRTIO_BLK_S_OK 0
23 #define VIRTIO_BLK_S_IOERR 1
24 #define VIRTIO_BLK_S_UNSUPP 2
25 #define WAITING_ASYNC_RET 0xFF
27 /* Feature bits */
28 #define VIRTIO_BLK_F_BARRIER 0 /* Does host support barriers? */
29 #define VIRTIO_BLK_F_SIZE_MAX 1 /* Indicates maximum segment size */
30 #define VIRTIO_BLK_F_SEG_MAX 2 /* Indicates maximum # of segments */
31 #define VIRTIO_BLK_F_GEOMETRY 4 /* Indicates support of legacy geometry */
32 #define VIRTIO_BLK_F_RO 5 /* Disk is read-only */
33 #define VIRTIO_BLK_F_BLK_SIZE 6 /* Block size of disk is available*/
34 #define VIRTIO_BLK_F_SCSI 7 /* Supports scsi command passthru */
35 #define VIRTIO_BLK_F_IDENTIFY 8 /* ATA IDENTIFY supported */
36 #define VIRTIO_BLK_F_WCACHE 9 /* write cache enabled */
38 #define VIRTIO_BLK_ID_LEN 256 /* length of identify u16 array */
39 #define VIRTIO_BLK_ID_SN 10 /* start of char * serial# */
40 #define VIRTIO_BLK_ID_SN_BYTES 20 /* length in bytes of serial# */
43 struct qemu_vio_blk_config
45 uint64_t capacity;
46 uint32_t size_max;
47 uint32_t seg_max;
48 uint16_t cylinders;
49 uint8_t heads;
50 uint8_t sectors;
51 uint32_t _blk_size; /* structure pad, currently unused */
52 uint16_t identify[QEMU_VIO_BLK_ID_LEN];
53 } __attribute__((packed));
55 VirtIOBlockReq *virtio_blk_get_request(VirtIOBlock *s);
56 void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb);
57 void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq,int num_writes);
58 void do_aio_multiwrite(BlockDriverState *bs, MultiReqBuffer *mrb);
59 void qemu_vio_exit(BlockDriverState *bs);
60 void qemu_vio_guess_geometry(BlockDriverState *bs, int *pcyls, int *pheads, int *psecs);
61 int64_t qemu_vio_getlength(BlockDriverState *bs);
62 BlockErrorAction drive_get_on_error(BlockDriverState *bdrv, int is_read);
64 #endif /* QUEMU_VIO_H */