ia64/xen-unstable

view xen/include/public/io/blkif.h @ 8208:773735517d9d

Inclide grant_ref_t definition in split-driver struct
defns.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Sat Dec 03 10:50:22 2005 +0100 (2005-12-03)
parents d616f22ffdd9
children 4c588e255c85
line source
1 /******************************************************************************
2 * blkif.h
3 *
4 * Unified block-device I/O interface for Xen guest OSes.
5 *
6 * Copyright (c) 2003-2004, Keir Fraser
7 */
9 #ifndef __XEN_PUBLIC_IO_BLKIF_H__
10 #define __XEN_PUBLIC_IO_BLKIF_H__
12 #include "ring.h"
13 #include "../gnttab.h" /* for grant_ref_t */
15 /*
16 * Front->back notifications: When enqueuing a new request, sending a
17 * notification can be made conditional on req_event (i.e., the generic
18 * hold-off mechanism provided by the ring macros). Backends must set
19 * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).
20 *
21 * Back->front notifications: When enqueuing a new response, sending a
22 * notification can be made conditional on rsp_event (i.e., the generic
23 * hold-off mechanism provided by the ring macros). Frontends must set
24 * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).
25 */
27 #ifndef blkif_vdev_t
28 #define blkif_vdev_t uint16_t
29 #endif
30 #define blkif_sector_t uint64_t
32 #define BLKIF_OP_READ 0
33 #define BLKIF_OP_WRITE 1
35 /*
36 * Maximum scatter/gather segments per request.
37 * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
38 * NB. This could be 12 if the ring indexes weren't stored in the same page.
39 */
40 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
42 typedef struct blkif_request {
43 uint8_t operation; /* BLKIF_OP_??? */
44 uint8_t nr_segments; /* number of segments */
45 blkif_vdev_t handle; /* only for read/write requests */
46 uint64_t id; /* private guest value, echoed in resp */
47 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
48 struct blkif_request_segment {
49 grant_ref_t gref; /* reference to I/O buffer frame */
50 /* @first_sect: first sector in frame to transfer (inclusive). */
51 /* @last_sect: last sector in frame to transfer (inclusive). */
52 uint8_t first_sect, last_sect;
53 } seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
54 } blkif_request_t;
56 typedef struct blkif_response {
57 uint64_t id; /* copied from request */
58 uint8_t operation; /* copied from request */
59 int16_t status; /* BLKIF_RSP_??? */
60 } blkif_response_t;
62 #define BLKIF_RSP_ERROR -1 /* non-specific 'error' */
63 #define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */
65 /*
66 * Generate blkif ring structures and types.
67 */
69 DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t);
71 #define VDISK_CDROM 0x1
72 #define VDISK_REMOVABLE 0x2
73 #define VDISK_READONLY 0x4
75 #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
77 /*
78 * Local variables:
79 * mode: C
80 * c-set-style: "BSD"
81 * c-basic-offset: 4
82 * tab-width: 4
83 * indent-tabs-mode: nil
84 * End:
85 */