ia64/linux-2.6.18-xen.hg

view drivers/xen/usbback/usbback.h @ 845:4c7eb2e71e9d

pvusb: Fix license headers.

Signed-off-by: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:11:23 2009 +0100 (2009-03-31)
parents f799db0570f2
children
line source
1 /*
2 * usbback.h
3 *
4 * This file is part of Xen USB backend driver.
5 *
6 * Copyright (C) 2009, FUJITSU LABORATORIES LTD.
7 * Author: Noboru Iwamatsu <n_iwamatsu@jp.fujitsu.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 *
22 * or, by your choice,
23 *
24 * When distributed separately from the Linux kernel or incorporated into
25 * other software packages, subject to the following license:
26 *
27 * Permission is hereby granted, free of charge, to any person obtaining a copy
28 * of this software and associated documentation files (the "Software"), to
29 * deal in the Software without restriction, including without limitation the
30 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
31 * sell copies of the Software, and to permit persons to whom the Software is
32 * furnished to do so, subject to the following conditions:
33 *
34 * The above copyright notice and this permission notice shall be included in
35 * all copies or substantial portions of the Software.
36 *
37 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
38 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
40 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
41 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
42 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
43 * DEALINGS IN THE SOFTWARE.
44 */
46 #ifndef __XEN_USBBACK_H__
47 #define __XEN_USBBACK_H__
49 #include <linux/module.h>
50 #include <linux/interrupt.h>
51 #include <linux/slab.h>
52 #include <linux/usb.h>
53 #include <linux/vmalloc.h>
54 #include <linux/kthread.h>
55 #include <linux/wait.h>
56 #include <linux/list.h>
57 #include <linux/kref.h>
58 #include <xen/evtchn.h>
59 #include <xen/gnttab.h>
60 #include <xen/driver_util.h>
61 #include <xen/interface/xen.h>
62 #include <xen/interface/io/usbif.h>
64 struct usbstub;
66 #define USB_DEV_ADDR_SIZE 128
68 typedef struct usbif_st {
69 domid_t domid;
70 unsigned int handle;
71 struct xenbus_device *xbdev;
72 struct list_head usbif_list;
74 unsigned int irq;
76 usbif_back_ring_t ring;
77 struct vm_struct *ring_area;
79 spinlock_t ring_lock;
80 atomic_t refcnt;
81 grant_handle_t shmem_handle;
82 grant_ref_t shmem_ref;
84 /* device address lookup table */
85 spinlock_t addr_lock;
86 struct usbstub *addr_table[USB_DEV_ADDR_SIZE];
88 /* plugged device list */
89 unsigned plaggable:1;
90 spinlock_t plug_lock;
91 struct list_head plugged_devices;
93 /* request schedule */
94 struct task_struct *xenusbd;
95 unsigned int waiting_reqs;
96 wait_queue_head_t waiting_to_free;
97 wait_queue_head_t wq;
99 } usbif_t;
101 struct usbstub_id
102 {
103 struct list_head id_list;
105 char bus_id[BUS_ID_SIZE];
106 int dom_id;
107 int dev_id;
108 int portnum;
109 };
111 struct usbstub
112 {
113 struct usbstub_id *id;
114 struct usb_device *udev;
115 struct usb_interface *interface;
116 usbif_t *usbif;
118 struct list_head grabbed_list;
120 unsigned plugged:1;
121 struct list_head plugged_list;
123 int addr;
125 spinlock_t submitting_lock;
126 struct list_head submitting_list;
127 };
129 usbif_t *usbif_alloc(domid_t domid, unsigned int handle);
130 void usbif_disconnect(usbif_t *usbif);
131 void usbif_free(usbif_t *usbif);
132 int usbif_map(usbif_t *usbif, unsigned long shared_page, unsigned int evtchn);
134 #define usbif_get(_b) (atomic_inc(&(_b)->refcnt))
135 #define usbif_put(_b) \
136 do { \
137 if (atomic_dec_and_test(&(_b)->refcnt)) \
138 wake_up(&(_b)->waiting_to_free); \
139 } while (0)
141 void usbback_xenbus_init(void);
142 void usbback_xenbus_exit(void);
144 irqreturn_t usbbk_be_int(int irq, void *dev_id, struct pt_regs *regs);
145 int usbbk_schedule(void *arg);
146 struct usbstub *find_attached_device(usbif_t *usbif, int port);
147 struct usbstub *find_grabbed_device(int dom_id, int dev_id, int port);
148 usbif_t *find_usbif(int dom_id, int dev_id);
149 void usbback_reconfigure(usbif_t *usbif);
150 void usbbk_plug_device(usbif_t *usbif, struct usbstub *stub);
151 void usbbk_unplug_device(usbif_t *usbif, struct usbstub *stub);
152 void detach_device_without_lock(usbif_t *usbif, struct usbstub *stub);
153 void usbbk_unlink_urbs(struct usbstub *stub);
155 int usbstub_init(void);
156 void usbstub_exit(void);
158 #endif /* __XEN_USBBACK_H__ */