ia64/xen-unstable

view xen/include/public/io/blkif.h @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
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
22 /* NB. Ring size must be small enough for sizeof(blkif_ring_t) <= PAGE_SIZE. */
23 #define BLKIF_RING_SIZE 64
25 /*
26 * Maximum scatter/gather segments per request.
27 * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
28 * NB. This could be 12 if the ring indexes weren't stored in the same page.
29 */
30 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
32 typedef struct blkif_request {
33 u8 operation; /* BLKIF_OP_??? */
34 u8 nr_segments; /* number of segments */
35 blkif_vdev_t handle; /* only for read/write requests */
36 unsigned long id; /* private guest value, echoed in resp */
37 blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */
38 /* @f_a_s[4:0]=last_sect ; @f_a_s[9:5]=first_sect */
39 /* @f_a_s[:16]= grant reference (16 bits) */
40 /* @first_sect: first sector in frame to transfer (inclusive). */
41 /* @last_sect: last sector in frame to transfer (inclusive). */
42 unsigned long frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST];
43 } blkif_request_t;
45 #define blkif_fas(_addr, _fs, _ls) ((_addr)|((_fs)<<5)|(_ls))
46 #define blkif_first_sect(_fas) (((_fas)>>5)&31)
47 #define blkif_last_sect(_fas) ((_fas)&31)
49 #define blkif_fas_from_gref(_gref, _fs, _ls) (((_gref)<<16)|((_fs)<<5)|(_ls))
50 #define blkif_gref_from_fas(_fas) ((_fas)>>16)
52 typedef struct blkif_response {
53 unsigned long id; /* copied from request */
54 u8 operation; /* copied from request */
55 s16 status; /* BLKIF_RSP_??? */
56 } blkif_response_t;
58 #define BLKIF_RSP_ERROR -1 /* non-specific 'error' */
59 #define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */
61 #define BLKIF_MAJOR(dev) ((dev)>>8)
62 #define BLKIF_MINOR(dev) ((dev) & 0xff)
64 /*
65 * Generate blkif ring structures and types.
66 */
68 DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t);
70 #define VDISK_CDROM 0x1
71 #define VDISK_REMOVABLE 0x2
72 #define VDISK_READONLY 0x4
74 #endif /* __XEN_PUBLIC_IO_BLKIF_H__ */