ia64/xen-unstable

view linux-2.6.7-xen-sparse/include/asm-xen/blkif.h @ 1820:3d4f8eb89670

bitkeeper revision 1.1106.1.2 (40faa780dekT3E5arFwcbQDu1MbX6g)

Cleaned up Xen's instruction emulator.
author kaf24@scramble.cl.cam.ac.uk
date Sun Jul 18 16:38:24 2004 +0000 (2004-07-18)
parents 002fc84add90
children
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 __SHARED_BLKIF_H__
10 #define __SHARED_BLKIF_H__
12 #define blkif_vdev_t u16
13 #define blkif_sector_t u64
15 #define BLKIF_OP_READ 0
16 #define BLKIF_OP_WRITE 1
17 #define BLKIF_OP_PROBE 2
19 /* NB. Ring size must be small enough for sizeof(blkif_ring_t) <= PAGE_SIZE. */
20 #define BLKIF_RING_SIZE 64
22 /*
23 * Maximum scatter/gather segments per request.
24 * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE.
25 * NB. This could be 12 if the ring indexes weren't stored in the same page.
26 */
27 #define BLKIF_MAX_SEGMENTS_PER_REQUEST 11
29 typedef struct {
30 u8 operation; /* 0: BLKIF_OP_??? */
31 u8 nr_segments; /* 1: number of segments */
32 blkif_vdev_t device; /* 2: only for read/write requests */
33 unsigned long id; /* 4: private guest value, echoed in resp */
34 blkif_sector_t sector_number; /* start sector idx on disk (r/w only) */
35 /* @f_a_s[2:0]=last_sect ; @f_a_s[5:3]=first_sect ; @f_a_s[:12]=frame. */
36 /* @first_sect: first sector in frame to transfer (inclusive). */
37 /* @last_sect: last sector in frame to transfer (inclusive). */
38 /* @frame: machine page frame number. */
39 unsigned long frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST];
40 } PACKED blkif_request_t;
42 #define blkif_first_sect(_fas) (((_fas)>>3)&7)
43 #define blkif_last_sect(_fas) ((_fas)&7)
45 typedef struct {
46 unsigned long id; /* copied from request */
47 u8 operation; /* copied from request */
48 s16 status; /* BLKIF_RSP_??? */
49 } PACKED blkif_response_t;
51 #define BLKIF_RSP_ERROR -1 /* non-specific 'error' */
52 #define BLKIF_RSP_OKAY 0 /* non-specific 'okay' */
54 /*
55 * We use a special capitalised type name because it is _essential_ that all
56 * arithmetic on indexes is done on an integer type of the correct size.
57 */
58 typedef u32 BLKIF_RING_IDX;
60 /*
61 * Ring indexes are 'free running'. That is, they are not stored modulo the
62 * size of the ring buffer. The following macro converts a free-running counter
63 * into a value that can directly index a ring-buffer array.
64 */
65 #define MASK_BLKIF_IDX(_i) ((_i)&(BLKIF_RING_SIZE-1))
67 typedef struct {
68 BLKIF_RING_IDX req_prod; /* 0: Request producer. Updated by front-end. */
69 BLKIF_RING_IDX resp_prod; /* 4: Response producer. Updated by back-end. */
70 union { /* 8 */
71 blkif_request_t req;
72 blkif_response_t resp;
73 } PACKED ring[BLKIF_RING_SIZE];
74 } PACKED blkif_ring_t;
77 /*
78 * BLKIF_OP_PROBE:
79 * The request format for a probe request is constrained as follows:
80 * @operation == BLKIF_OP_PROBE
81 * @nr_segments == size of probe buffer in pages
82 * @device == unused (zero)
83 * @id == any value (echoed in response message)
84 * @sector_num == unused (zero)
85 * @frame_and_sects == list of page-sized buffers.
86 * (i.e., @first_sect == 0, @last_sect == 7).
87 *
88 * The response is a list of vdisk_t elements copied into the out-of-band
89 * probe buffer. On success the response status field contains the number
90 * of vdisk_t elements.
91 */
93 /* XXX SMH: Type values below are chosen to match ide_xxx in Linux ide.h. */
94 #define VDISK_TYPE_FLOPPY 0x00
95 #define VDISK_TYPE_TAPE 0x01
96 #define VDISK_TYPE_CDROM 0x05
97 #define VDISK_TYPE_OPTICAL 0x07
98 #define VDISK_TYPE_DISK 0x20
100 #define VDISK_TYPE_MASK 0x3F
101 #define VDISK_TYPE(_x) ((_x) & VDISK_TYPE_MASK)
103 /* The top two bits of the type field encode various flags. */
104 #define VDISK_FLAG_RO 0x40
105 #define VDISK_FLAG_VIRT 0x80
106 #define VDISK_READONLY(_x) ((_x) & VDISK_FLAG_RO)
107 #define VDISK_VIRTUAL(_x) ((_x) & VDISK_FLAG_VIRT)
109 typedef struct {
110 blkif_sector_t capacity; /* 0: Size in terms of 512-byte sectors. */
111 blkif_vdev_t device; /* 8: Device number (opaque 16 bit value). */
112 u16 info; /* 10: Device type and flags (VDISK_*). */
113 } PACKED vdisk_t; /* 12 bytes */
115 #endif /* __SHARED_BLKIF_H__ */