ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/blkfront/block.h @ 6432:b54144915ae6

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 16:26:30 2005 +0000 (2005-08-25)
parents 3428d58a85e1 be5c24f2709c
children 0610add7c3fe
line source
1 /******************************************************************************
2 * block.h
3 *
4 * Shared definitions between all levels of XenLinux Virtual block devices.
5 *
6 * Copyright (c) 2003-2004, Keir Fraser & Steve Hand
7 * Modifications by Mark A. Williamson are (c) Intel Research Cambridge
8 * Copyright (c) 2004-2005, Christian Limpach
9 *
10 * This file may be distributed separately from the Linux kernel, or
11 * incorporated into other software packages, subject to the following license:
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this source file (the "Software"), to deal in the Software without
15 * restriction, including without limitation the rights to use, copy, modify,
16 * merge, publish, distribute, sublicense, and/or sell copies of the Software,
17 * and to permit persons to whom the Software is furnished to do so, subject to
18 * the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be included in
21 * all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29 * IN THE SOFTWARE.
30 */
32 #ifndef __XEN_DRIVERS_BLOCK_H__
33 #define __XEN_DRIVERS_BLOCK_H__
35 #include <linux/config.h>
36 #include <linux/version.h>
37 #include <linux/module.h>
38 #include <linux/kernel.h>
39 #include <linux/sched.h>
40 #include <linux/slab.h>
41 #include <linux/string.h>
42 #include <linux/errno.h>
43 #include <linux/fs.h>
44 #include <linux/hdreg.h>
45 #include <linux/blkdev.h>
46 #include <linux/major.h>
47 #include <linux/devfs_fs_kernel.h>
48 #include <asm-xen/hypervisor.h>
49 #include <asm-xen/xenbus.h>
50 #include <asm-xen/xen-public/xen.h>
51 #include <asm-xen/xen-public/io/blkif.h>
52 #include <asm-xen/xen-public/io/ring.h>
53 #include <asm/io.h>
54 #include <asm/atomic.h>
55 #include <asm/uaccess.h>
57 #if 1
58 #define IPRINTK(fmt, args...) \
59 printk(KERN_INFO "xen_blk: " fmt, ##args)
60 #else
61 #define IPRINTK(fmt, args...) ((void)0)
62 #endif
64 #if 1
65 #define WPRINTK(fmt, args...) \
66 printk(KERN_WARNING "xen_blk: " fmt, ##args)
67 #else
68 #define WPRINTK(fmt, args...) ((void)0)
69 #endif
71 #if 0
72 #define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
73 #else
74 #define DPRINTK(_f, _a...) ((void)0)
75 #endif
77 #if 0
78 #define DPRINTK_IOCTL(_f, _a...) printk ( KERN_ALERT _f , ## _a )
79 #else
80 #define DPRINTK_IOCTL(_f, _a...) ((void)0)
81 #endif
83 struct xlbd_type_info
84 {
85 int partn_shift;
86 int disks_per_major;
87 char *devname;
88 char *diskname;
89 };
91 struct xlbd_major_info
92 {
93 int major;
94 int index;
95 int usage;
96 struct xlbd_type_info *type;
97 };
99 /*
100 * We have one of these per vbd, whether ide, scsi or 'other'. They
101 * hang in private_data off the gendisk structure. We may end up
102 * putting all kinds of interesting stuff here :-)
103 */
104 struct blkfront_info
105 {
106 struct xenbus_device *xbdev;
107 /* We watch the backend */
108 struct xenbus_watch watch;
109 dev_t dev;
110 int vdevice;
111 blkif_vdev_t handle;
112 int connected;
113 char *backend;
114 int backend_id;
115 int ring_ref;
116 blkif_front_ring_t ring;
117 unsigned int evtchn;
118 struct xlbd_major_info *mi;
119 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
120 request_queue_t *rq;
121 #endif
122 struct work_struct work;
123 struct gnttab_free_callback callback;
124 };
126 extern spinlock_t blkif_io_lock;
128 extern int blkif_open(struct inode *inode, struct file *filep);
129 extern int blkif_release(struct inode *inode, struct file *filep);
130 extern int blkif_ioctl(struct inode *inode, struct file *filep,
131 unsigned command, unsigned long argument);
132 extern int blkif_check(dev_t dev);
133 extern int blkif_revalidate(dev_t dev);
134 extern void do_blkif_request (request_queue_t *rq);
136 /* Virtual block-device subsystem. */
137 int xlvbd_add(blkif_sector_t capacity, int device,
138 u16 vdisk_info, u16 sector_size, struct blkfront_info *info);
139 void xlvbd_del(struct blkfront_info *info);
140 #endif /* __XEN_DRIVERS_BLOCK_H__ */