ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/usbback/common.h @ 6689:7d0fb56b4a91

merge?
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 07 19:01:31 2005 +0000 (2005-09-07)
parents 549f4256ab3c dd668f7527cb
children b2f4823b6ff0 b35215021b32 1936ccaccf5e
line source
2 #ifndef __USBIF__BACKEND__COMMON_H__
3 #define __USBIF__BACKEND__COMMON_H__
5 #include <linux/config.h>
6 #include <linux/version.h>
7 #include <linux/module.h>
8 #include <linux/rbtree.h>
9 #include <linux/interrupt.h>
10 #include <linux/slab.h>
11 #include <linux/blkdev.h>
12 #include <asm/io.h>
13 #include <asm/setup.h>
14 #include <asm/pgalloc.h>
15 #include <asm-xen/hypervisor.h>
17 #include <asm-xen/xen-public/io/usbif.h>
19 #if 0
20 #define ASSERT(_p) \
21 if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
22 __LINE__, __FILE__); *(int*)0=0; }
23 #define DPRINTK(_f, _a...) printk(KERN_ALERT "(file=%s, line=%d) " _f, \
24 __FILE__ , __LINE__ , ## _a )
25 #else
26 #define ASSERT(_p) ((void)0)
27 #define DPRINTK(_f, _a...) ((void)0)
28 #endif
30 typedef struct usbif_priv_st usbif_priv_t;
32 struct usbif_priv_st {
33 /* Unique identifier for this interface. */
34 domid_t domid;
35 unsigned int handle;
36 /* Physical parameters of the comms window. */
37 unsigned long shmem_frame;
38 unsigned int evtchn;
39 /* Comms Information */
40 usbif_back_ring_t usb_ring;
41 /* Private fields. */
42 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
43 /*
44 * DISCONNECT response is deferred until pending requests are ack'ed.
45 * We therefore need to store the id from the original request.
46 */
47 u8 disconnect_rspid;
48 usbif_priv_t *hash_next;
49 struct list_head usbif_list;
50 spinlock_t usb_ring_lock;
51 atomic_t refcnt;
53 struct work_struct work;
54 };
56 void usbif_create(usbif_be_create_t *create);
57 void usbif_destroy(usbif_be_destroy_t *destroy);
58 void usbif_connect(usbif_be_connect_t *connect);
59 int usbif_disconnect(usbif_be_disconnect_t *disconnect, u8 rsp_id);
60 void usbif_disconnect_complete(usbif_priv_t *up);
62 void usbif_release_port(usbif_be_release_port_t *msg);
63 int usbif_claim_port(usbif_be_claim_port_t *msg);
64 void usbif_release_ports(usbif_priv_t *up);
66 usbif_priv_t *usbif_find(domid_t domid);
67 #define usbif_get(_b) (atomic_inc(&(_b)->refcnt))
68 #define usbif_put(_b) \
69 do { \
70 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
71 usbif_disconnect_complete(_b); \
72 } while (0)
75 void usbif_interface_init(void);
76 void usbif_ctrlif_init(void);
78 void usbif_deschedule(usbif_priv_t *up);
79 void remove_from_usbif_list(usbif_priv_t *up);
81 irqreturn_t usbif_be_int(int irq, void *dev_id, struct pt_regs *regs);
83 #endif /* __USBIF__BACKEND__COMMON_H__ */