Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / lib / libvirtio / virtio-blk.h
1 /******************************************************************************
2  * Copyright (c) 2011 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13 /*
14  * Virtio block device definitions.
15  * See Virtio Spec, Appendix D, for details
16  */
17
18 #ifndef _VIRTIO_BLK_H
19 #define _VIRTIO_BLK_H
20
21 #include <stdint.h>
22
23
24 struct virtio_blk_cfg {
25         uint64_t        capacity;
26         uint32_t        size_max;
27         uint32_t        seg_max;
28         struct  virtio_blk_geometry {
29                 uint16_t        cylinders;
30                 uint8_t         heads;
31                 uint8_t         sectors;
32         } geometry;
33         uint32_t        blk_size;
34         uint32_t        sectors_max;
35 } __attribute__ ((packed)) ;
36
37 /* Block request */
38 struct virtio_blk_req {
39         uint32_t  type ;
40         uint32_t  ioprio ;
41         uint64_t  sector ;
42 };
43
44 /* Block request types */
45 #define VIRTIO_BLK_T_IN                 0
46 #define VIRTIO_BLK_T_OUT                1
47 #define VIRTIO_BLK_T_SCSI_CMD           2
48 #define VIRTIO_BLK_T_SCSI_CMD_OUT       3
49 #define VIRTIO_BLK_T_FLUSH              4
50 #define VIRTIO_BLK_T_FLUSH_OUT          5
51 #define VIRTIO_BLK_T_BARRIER            0x80000000
52
53 /* VIRTIO_BLK Feature bits */
54 #define VIRTIO_BLK_F_BLK_SIZE       (1 << 6)
55
56 extern int virtioblk_init(struct virtio_device *dev);
57 extern void virtioblk_shutdown(struct virtio_device *dev);
58 extern int virtioblk_read(struct virtio_device *dev, char *buf, long blocknum, long cnt);
59
60 #endif  /* _VIRTIO_BLK_H */