ia64/xen-unstable

view linux-2.6-xen-sparse/drivers/xen/tpmback/common.h @ 10076:18c3da3ad6f7

When doing local migration, a timing-related problem occurred due to the
frontend switching to the Closed state, which could end up having
the .remove function being called after the backend has shut down. This
now fixes the problem by switching to the Closing state.
The other part of the patch cleans up freeing of memory.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed May 17 23:28:22 2006 +0100 (2006-05-17)
parents 42a70a529753
children 48c0f5489d44
line source
1 /******************************************************************************
2 * drivers/xen/tpmback/common.h
3 */
5 #ifndef __NETIF__BACKEND__COMMON_H__
6 #define __NETIF__BACKEND__COMMON_H__
8 #include <linux/config.h>
9 #include <linux/version.h>
10 #include <linux/module.h>
11 #include <linux/interrupt.h>
12 #include <linux/slab.h>
13 #include <xen/evtchn.h>
14 #include <xen/driver_util.h>
15 #include <xen/interface/grant_table.h>
16 #include <xen/interface/io/tpmif.h>
17 #include <asm/io.h>
18 #include <asm/pgalloc.h>
20 #define DPRINTK(_f, _a...) pr_debug("(file=%s, line=%d) " _f, \
21 __FILE__ , __LINE__ , ## _a )
23 typedef struct tpmif_st {
24 struct list_head tpmif_list;
25 /* Unique identifier for this interface. */
26 domid_t domid;
27 unsigned int handle;
29 /* Physical parameters of the comms window. */
30 unsigned int evtchn;
31 unsigned int irq;
33 /* The shared rings and indexes. */
34 tpmif_tx_interface_t *tx;
35 struct vm_struct *tx_area;
37 /* Miscellaneous private stuff. */
38 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
39 int active;
41 struct tpmif_st *hash_next;
42 struct list_head list; /* scheduling list */
43 atomic_t refcnt;
45 long int tpm_instance;
46 unsigned long mmap_vstart;
48 grant_handle_t shmem_handle;
49 grant_ref_t shmem_ref;
50 struct page *pagerange;
52 char devname[20];
53 } tpmif_t;
55 void tpmif_disconnect_complete(tpmif_t * tpmif);
56 tpmif_t *tpmif_find(domid_t domid, long int instance);
57 void tpmif_interface_init(void);
58 void tpmif_interface_exit(void);
59 void tpmif_schedule_work(tpmif_t * tpmif);
60 void tpmif_deschedule_work(tpmif_t * tpmif);
61 void tpmif_xenbus_init(void);
62 void tpmif_xenbus_exit(void);
63 int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn);
64 irqreturn_t tpmif_be_int(int irq, void *dev_id, struct pt_regs *regs);
65 int tpmif_vtpm_open(tpmif_t *tpmif, domid_t domain, u32 instance);
66 int tpmif_vtpm_close(u32 instance);
68 int vtpm_release_packets(tpmif_t * tpmif, int send_msgs);
70 #define tpmif_get(_b) (atomic_inc(&(_b)->refcnt))
71 #define tpmif_put(_b) \
72 do { \
73 if ( atomic_dec_and_test(&(_b)->refcnt) ) \
74 tpmif_disconnect_complete(_b); \
75 } while (0)
78 extern int num_frontends;
80 #define MMAP_VADDR(t,_req) ((t)->mmap_vstart + ((_req) * PAGE_SIZE))
82 #endif /* __TPMIF__BACKEND__COMMON_H__ */
84 /*
85 * Local variables:
86 * c-file-style: "linux"
87 * indent-tabs-mode: t
88 * c-indent-level: 8
89 * c-basic-offset: 8
90 * tab-width: 8
91 * End:
92 */