ia64/xen-unstable

view xen/include/public/io/blkif.h @ 6538:84ee014ebd41

Merge xen-vtx-unstable.hg
author adsharma@los-vmm.sc.intel.com
date Wed Aug 17 12:34:38 2005 -0800 (2005-08-17)
parents 23979fb12c49 8004acaa6684
children 99914b54f7bf
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"
14 #ifndef blkif_vdev_t
15 #define blkif_vdev_t u16
16 #endif
17 #define blkif_sector_t u64
19 #define BLKIF_OP_READ 0
20 #define BLKIF_OP_WRITE 1
21 #define BLKIF_OP_PROBE 2
23 /* NB. Ring size must be small enough for sizeof(blkif_ring_t) <= PAGE_SIZE. */
24 #define BLKIF_RING_SIZE 64
26 /*
27 * Maximum scatter/gather segments per request.
28 * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
29 * NB. This could be 12 if the ring indexes weren't stored in the same page.
30 */
31 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
33 typedef struct blkif_request {
34 u8 operation; /* BLKIF_OP_??? */
35 u8 nr_segments; /* number of segments */
36 blkif_vdev_t device; /* only for read/write requests */
37 unsigned long id; /* private guest value, echoed in resp */
38 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
39 /* @f_a_s[4:0]=last_sect ; @f_a_s[9:5]=first_sect */
40 #ifdef CONFIG_XEN_BLKDEV_GRANT
41 /* @f_a_s[:16]= grant reference (16 bits) */
42 #else
43 /* @f_a_s[:12]=@frame: machine page frame number. */
44 #endif
45 /* @first_sect: first sector in frame to transfer (inclusive). */
46 /* @last_sect: last sector in frame to transfer (inclusive). */
47 unsigned long frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST];
48 } blkif_request_t;
50 #define blkif_fas(_addr, _fs, _ls) ((_addr)|((_fs)<<5)|(_ls))
51 #define blkif_first_sect(_fas) (((_fas)>>5)&31)
52 #define blkif_last_sect(_fas) ((_fas)&31)
54 #ifdef CONFIG_XEN_BLKDEV_GRANT
55 #define blkif_fas_from_gref(_gref, _fs, _ls) (((_gref)<<16)|((_fs)<<5)|(_ls))
56 #define blkif_gref_from_fas(_fas) ((_fas)>>16)
57 #endif
59 typedef struct blkif_response {
60 unsigned long id; /* copied from request */
61 u8 operation; /* copied from request */
62 s16 status; /* BLKIF_RSP_??? */
63 } blkif_response_t;
65 #define BLKIF_RSP_ERROR -1 /* non-specific 'error' */
66 #define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */
68 /*
69 * Generate blkif ring structures and types.
70 */
72 DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t);
74 /*
75 * BLKIF_OP_PROBE:
76 * The request format for a probe request is constrained as follows:
77 * @operation == BLKIF_OP_PROBE
78 * @nr_segments == size of probe buffer in pages
79 * @device == unused (zero)
80 * @id == any value (echoed in response message)
81 * @sector_num == unused (zero)
82 * @frame_and_sects == list of page-sized buffers.
83 * (i.e., @first_sect == 0, @last_sect == 7).
84 *
85 * The response is a list of vdisk_t elements copied into the out-of-band
86 * probe buffer. On success the response status field contains the number
87 * of vdisk_t elements.
88 */
90 #define VDISK_CDROM 0x1
91 #define VDISK_REMOVABLE 0x2
92 #define VDISK_READONLY 0x4
94 typedef struct vdisk {
95 blkif_sector_t capacity; /* Size in terms of 512-byte sectors. */
96 blkif_vdev_t device; /* Device number (opaque 16 bit value). */
97 u16 info; /* Device type and flags (VDISK_*). */
98 u16 sector_size; /* Minimum alignment for requests. */
99 } vdisk_t; /* 16 bytes */
101 #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */