ede57abfa5a05ca4d0cd5c920d53bbfa824e93ae
[linux-2.6.git] / drivers / xen / blkfront / block.h
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  */
31
32 #ifndef __XEN_DRIVERS_BLOCK_H__
33 #define __XEN_DRIVERS_BLOCK_H__
34
35 #include <linux/config.h>
36 #include <linux/module.h>
37 #include <linux/kernel.h>
38 #include <linux/sched.h>
39 #include <linux/slab.h>
40 #include <linux/string.h>
41 #include <linux/errno.h>
42 #include <linux/fs.h>
43 #include <linux/hdreg.h>
44 #include <linux/blkdev.h>
45 #include <linux/major.h>
46 #include <linux/devfs_fs_kernel.h>
47 #include <asm-xen/xen-public/xen.h>
48 #include <asm-xen/xen-public/io/blkif.h>
49 #include <asm-xen/xen-public/io/ring.h>
50 #include <asm/io.h>
51 #include <asm/atomic.h>
52 #include <asm/uaccess.h>
53
54 #if 0
55 #define DPRINTK(_f, _a...) printk ( KERN_ALERT _f , ## _a )
56 #else
57 #define DPRINTK(_f, _a...) ((void)0)
58 #endif
59
60 #if 0
61 #define DPRINTK_IOCTL(_f, _a...) printk ( KERN_ALERT _f , ## _a )
62 #else
63 #define DPRINTK_IOCTL(_f, _a...) ((void)0)
64 #endif
65
66 struct xlbd_type_info {
67     int partn_shift;
68     int partn_per_major;
69     int devs_per_major;
70     char *devname;
71     char *diskname;
72 };
73
74 /*
75  * We have one of these per vbd, whether ide, scsi or 'other'.  They
76  * hang in private_data off the gendisk structure. We may end up
77  * putting all kinds of interesting stuff here :-)
78  */
79 struct xlbd_major_info {
80     int major;
81     int index;
82     int usage;
83     struct xlbd_type_info *type;
84 };
85
86 struct xlbd_disk_info {
87     int xd_device;
88     struct xlbd_major_info *mi;
89 };
90
91 typedef struct xen_block {
92     int usage;
93 } xen_block_t;
94
95 extern struct request_queue *xlbd_blk_queue;
96 extern spinlock_t blkif_io_lock;
97
98 extern int blkif_open(struct inode *inode, struct file *filep);
99 extern int blkif_release(struct inode *inode, struct file *filep);
100 extern int blkif_ioctl(struct inode *inode, struct file *filep,
101                        unsigned command, unsigned long argument);
102 extern int blkif_check(dev_t dev);
103 extern int blkif_revalidate(dev_t dev);
104 extern void blkif_control_send(blkif_request_t *req, blkif_response_t *rsp);
105 #ifdef CONFIG_XEN_BLKDEV_GRANT
106 extern void blkif_control_probe_send(
107     blkif_request_t *req, blkif_response_t *rsp, unsigned long address);
108 #endif
109 extern void do_blkif_request (request_queue_t *rq); 
110
111 extern void xlvbd_update_vbds(void);
112
113 /* Virtual block-device subsystem. */
114 extern int  xlvbd_init(void);
115 extern void xlvbd_cleanup(void); 
116
117 #endif /* __XEN_DRIVERS_BLOCK_H__ */