1 /******************************************************************************
2 * drivers/xen/tpmback/common.h
5 #ifndef __TPM__BACKEND__COMMON_H__
6 #define __TPM__BACKEND__COMMON_H__
8 #include <linux/module.h>
9 #include <linux/interrupt.h>
11 #include <linux/slab.h>
12 #include <xen/xenbus.h>
13 #include <xen/interface/event_channel.h>
14 #include <xen/interface/io/tpmif.h>
16 #define DPRINTK(_f, _a...) \
17 pr_debug("(file=%s, line=%d) " _f, \
18 __FILE__ , __LINE__ , ## _a )
22 struct xenbus_device *dev;
24 /* our communications channel */
25 struct tpmif_st *tpmif;
28 long int instance; // instance of TPM
29 u8 is_instance_set;// whether instance number has been set
31 /* watch front end for changes */
32 struct xenbus_watch backend_watch;
35 typedef struct tpmif_st {
36 struct list_head tpmif_list;
37 /* Unique identifier for this interface. */
41 /* Physical parameters of the comms window. */
44 /* The shared rings and indexes. */
45 tpmif_tx_interface_t *tx;
46 struct vm_struct *tx_area;
48 /* Miscellaneous private stuff. */
49 enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
52 struct tpmif_st *hash_next;
53 struct list_head list; /* scheduling list */
56 struct backend_info *bi;
58 struct page **mmap_pages;
63 void tpmif_disconnect_complete(tpmif_t * tpmif);
64 tpmif_t *tpmif_find(domid_t domid, struct backend_info *bi);
65 int tpmif_interface_init(void);
66 void tpmif_interface_exit(void);
67 void tpmif_schedule_work(tpmif_t * tpmif);
68 void tpmif_deschedule_work(tpmif_t * tpmif);
69 int tpmif_xenbus_init(void);
70 void tpmif_xenbus_exit(void);
71 int tpmif_map(tpmif_t *, grant_ref_t, evtchn_port_t);
72 irqreturn_t tpmif_be_int(int irq, void *dev_id);
74 long int tpmback_get_instance(struct backend_info *bi);
76 int vtpm_release_packets(tpmif_t * tpmif, int send_msgs);
79 #define tpmif_get(_b) (atomic_inc(&(_b)->refcnt))
80 #define tpmif_put(_b) \
82 if (atomic_dec_and_test(&(_b)->refcnt)) \
83 tpmif_disconnect_complete(_b); \
86 extern int num_frontends;
88 static inline unsigned long idx_to_kaddr(tpmif_t *t, unsigned int idx)
90 return (unsigned long)pfn_to_kaddr(page_to_pfn(t->mmap_pages[idx]));
93 #endif /* __TPMIF__BACKEND__COMMON_H__ */