1 /******************************************************************************
4 * Unified block-device I/O interface for Xen guest OSes.
6 * Copyright (c) 2003-2004, Keir Fraser
9 #ifndef __XEN_PUBLIC_IO_BLKIF_H__
10 #define __XEN_PUBLIC_IO_BLKIF_H__
13 #include "../grant_table.h"
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()).
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()).
28 #define blkif_vdev_t uint16_t
30 #define blkif_sector_t uint64_t
32 #define BLKIF_OP_READ 0
33 #define BLKIF_OP_WRITE 1
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.
40 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
42 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];
55 typedef struct blkif_request blkif_request_t;
57 struct blkif_response {
58 uint64_t id; /* copied from request */
59 uint8_t operation; /* copied from request */
60 int16_t status; /* BLKIF_RSP_??? */
62 typedef struct blkif_response blkif_response_t;
64 #define BLKIF_RSP_ERROR -1 /* non-specific 'error' */
65 #define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */
68 * Generate blkif ring structures and types.
71 DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response);
73 #define VDISK_CDROM 0x1
74 #define VDISK_REMOVABLE 0x2
75 #define VDISK_READONLY 0x4
77 #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */
85 * indent-tabs-mode: nil