1 /*
2  * Copyright (c) 2008, XenSource Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the name of XenSource Inc. nor the names of its contributors
13  *       may be used to endorse or promote products derived from this software
14  *       without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
20  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef _TAPDISK_DRIVER_H_
29 #define _TAPDISK_DRIVER_H_
30 
31 #include "tapdisk.h"
32 #include "scheduler.h"
33 #include "tapdisk-queue.h"
34 
35 #define TD_DRIVER_OPEN               0x0001
36 #define TD_DRIVER_RDONLY             0x0002
37 
38 struct td_driver_handle {
39 	int                          type;
40 	char                        *name;
41 
42 	int                          storage;
43 
44 	int                          refcnt;
45 	td_flag_t                    state;
46 
47 	td_disk_info_t               info;
48 
49 	void                        *data;
50 	const struct tap_disk       *ops;
51 
52 	struct list_head             next;
53 };
54 
55 td_driver_t *tapdisk_driver_allocate(int, char *, td_flag_t, int);
56 void tapdisk_driver_free(td_driver_t *);
57 
58 void tapdisk_driver_queue_tiocb(td_driver_t *, struct tiocb *);
59 
60 void tapdisk_driver_debug(td_driver_t *);
61 
62 #endif
63