debuggers.hg

view xen/include/hypervisor-ifs/block.h @ 620:01725801761a

bitkeeper revision 1.322 (3f0d22cccb17_me9ZBYMkbZaFLovQg)

Get the new segment probing stuff to actually return useful
information...
author sos22@labyrinth.cl.cam.ac.uk
date Thu Jul 10 08:24:44 2003 +0000 (2003-07-10)
parents cc54519f9a1a
children 02306208d767 682f15023c2b
line source
1 /******************************************************************************
2 * block.h
3 *
4 * shared structures for block IO.
5 *
6 */
8 #ifndef __BLOCK_H__
9 #define __BLOCK_H__
11 /*
12 * Device numbers
13 */
15 #define XENDEV_TYPE_MASK 0xf000
16 #define XENDEV_IDX_MASK 0x0fff
17 #define XENDEV_TYPE_SHIFT 12
18 #define XENDEV_IDX_SHIFT 0
20 #define XENDEV_IDE (1 << XENDEV_TYPE_SHIFT)
21 #define XENDEV_SCSI (2 << XENDEV_TYPE_SHIFT)
22 #define XENDEV_VIRTUAL (3 << XENDEV_TYPE_SHIFT)
24 #define IS_IDE_XENDEV(_d) (((_d) & XENDEV_TYPE_MASK) == XENDEV_IDE)
25 #define IS_SCSI_XENDEV(_d) (((_d) & XENDEV_TYPE_MASK) == XENDEV_SCSI)
26 #define IS_VIRTUAL_XENDEV(_d) (((_d) & XENDEV_TYPE_MASK) == XENDEV_VIRTUAL)
28 #define MK_IDE_XENDEV(_i) ((_i) | XENDEV_IDE)
29 #define MK_SCSI_XENDEV(_i) ((_i) | XENDEV_SCSI)
30 #define MK_VIRTUAL_XENDEV(_i) ((_i) | XENDEV_VIRTUAL)
33 /*
34 *
35 * These are the ring data structures for buffering messages between
36 * the hypervisor and guestos's.
37 *
38 */
40 /* the first four definitions match fs.h */
41 #define XEN_BLOCK_READ 0
42 #define XEN_BLOCK_WRITE 1
43 #define XEN_BLOCK_READA 2
44 #define XEN_BLOCK_SPECIAL 4
45 #define XEN_BLOCK_PROBE_BLK 5 /* get xhd config from hypervisor */
46 #define XEN_BLOCK_DEBUG 6 /* debug */
47 #define XEN_BLOCK_SEG_CREATE 7 /* create segment (vhd) */
48 #define XEN_BLOCK_SEG_DELETE 8 /* delete segment (vhd) */
49 #define XEN_BLOCK_PROBE_SEG 9 /* get vhd config from hypervisor */
50 #define XEN_BLOCK_PHYSDEV_GRANT 10 /* grant access to range of disk blocks */
51 #define XEN_BLOCK_PHYSDEV_PROBE 11 /* probe for a domain's physdev
52 accesses */
53 #define XEN_BLOCK_PROBE_SEG_ALL 12 /* prove for every domain's segments,
54 not just ours. */
56 /* NB. Ring size must be small enough for sizeof(blk_ring_t) <= PAGE_SIZE. */
57 #define BLK_RING_SIZE 64
58 #define BLK_RING_INC(_i) (((_i)+1) & (BLK_RING_SIZE-1))
60 /*
61 * Maximum scatter/gather segments per request.
62 * This is carefully chosen so that sizeof(blk_ring_t) <= PAGE_SIZE.
63 */
64 #define MAX_BLK_SEGS 12
66 typedef struct blk_ring_req_entry
67 {
68 unsigned long id; /* private guest os value */
69 unsigned long sector_number; /* start sector idx on disk */
70 unsigned short device; /* XENDEV_??? + idx */
71 unsigned char operation; /* XEN_BLOCK_??? */
72 unsigned char nr_segments; /* number of segments */
73 /* Least 9 bits is 'nr_sects'. High 23 bits are the address. */
74 unsigned long buffer_and_sects[MAX_BLK_SEGS];
75 } blk_ring_req_entry_t;
77 typedef struct blk_ring_resp_entry
78 {
79 unsigned long id; /* copied from request */
80 unsigned short operation; /* copied from request */
81 unsigned long status; /* cuurently boolean good/bad */
82 } blk_ring_resp_entry_t;
84 typedef struct blk_ring_st
85 {
86 unsigned int req_prod; /* Request producer. Updated by guest OS. */
87 unsigned int resp_prod; /* Response producer. Updated by Xen. */
88 union {
89 blk_ring_req_entry_t req;
90 blk_ring_resp_entry_t resp;
91 } ring[BLK_RING_SIZE];
92 } blk_ring_t;
94 /*
95 *
96 * physical disk (xhd) info, used by XEN_BLOCK_PROBE
97 *
98 */
100 #define XEN_MAX_DISK_COUNT 100
102 /* XXX SMH: below types chosen to align with ide_xxx types in ide.h */
103 #define XD_TYPE_FLOPPY 0x00
104 #define XD_TYPE_TAPE 0x01
105 #define XD_TYPE_CDROM 0x05
106 #define XD_TYPE_OPTICAL 0x07
107 #define XD_TYPE_DISK 0x20
109 typedef struct xen_disk
110 {
111 unsigned short device; /* device number (see top of file) */
112 unsigned short type; /* device type, i.e. disk, cdrom, etc */
113 unsigned long capacity; /* size in terms of #512 byte sectors */
114 } xen_disk_t;
116 typedef struct xen_disk_info
117 {
118 int count;
119 xen_disk_t disks[XEN_MAX_DISK_COUNT];
120 } xen_disk_info_t;
122 /*
123 *
124 * virtual disk (vhd) structures, used by XEN_BLOCK_SEG_{CREATE, DELETE}
125 *
126 */
128 #define XEN_DISK_READ_WRITE 1
129 #define XEN_DISK_READ_ONLY 2
131 typedef struct xv_extent
132 {
133 int disk; /* physical disk number */
134 unsigned long offset; /* offset in blocks into physical disk */
135 unsigned long size; /* size in blocks */
136 } xv_extent_t;
138 #define XEN_SEGMENT_KEYSIZE 10
140 typedef struct xv_disk
141 {
142 int mode; /* XEN_DISK_READ_WRITE or XEN_DISK_READ_ONLY */
143 int domain; /* domain */
144 int segment; /* segment number */
145 char key[XEN_SEGMENT_KEYSIZE]; /* key for benefit of dom0 userspace */
146 int ext_count; /* number of xv_extent_t to follow */
147 xv_extent_t extents[XEN_MAX_DISK_COUNT]; /* arbitrary reuse of constant */
148 } xv_disk_t;
150 #define PHYSDISK_MODE_R 1
151 #define PHYSDISK_MODE_W 2
152 typedef struct xp_disk
153 {
154 int mode; /* 0 -> revoke existing access, otherwise bitmask of
155 PHYSDISK_MODE_? constants */
156 int domain;
157 unsigned short device; /* XENDEV_??? + idx */
158 unsigned short partition; /* partition number */
159 unsigned long start_sect;
160 unsigned long n_sectors;
161 } xp_disk_t;
163 #define PHYSDISK_MAX_ACES_PER_REQUEST 254 /* Make it fit in one page */
164 typedef struct {
165 int n_aces;
166 int domain;
167 int start_ind;
168 struct {
169 unsigned short device; /* XENDEV_??? + idx */
170 unsigned short partition; /* partition number */
171 unsigned long start_sect;
172 unsigned long n_sectors;
173 unsigned mode;
174 } entries[PHYSDISK_MAX_ACES_PER_REQUEST];
175 } physdisk_probebuf_t;
177 #endif