usb_mon.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * The USB Monitor, inspired by Dave Harding's USBMon.
  3. *
  4. * Copyright (C) 2005 Pete Zaitcev (zaitcev@redhat.com)
  5. */
  6. #ifndef __USB_MON_H
  7. #define __USB_MON_H
  8. #include <linux/list.h>
  9. #include <linux/slab.h>
  10. #include <linux/kref.h>
  11. /* #include <linux/usb.h> */ /* We use struct pointers only in this header */
  12. #define TAG "usbmon"
  13. struct mon_bus {
  14. struct list_head bus_link;
  15. spinlock_t lock;
  16. struct usb_bus *u_bus;
  17. int text_inited;
  18. struct dentry *dent_s; /* Debugging file */
  19. struct dentry *dent_t; /* Text interface file */
  20. struct dentry *dent_u; /* Second text interface file */
  21. int uses_dma;
  22. /* Ref */
  23. int nreaders; /* Under mon_lock AND mbus->lock */
  24. struct list_head r_list; /* Chain of readers (usually one) */
  25. struct kref ref; /* Under mon_lock */
  26. /* Stats */
  27. unsigned int cnt_events;
  28. unsigned int cnt_text_lost;
  29. };
  30. /*
  31. * An instance of a process which opened a file (but can fork later)
  32. */
  33. struct mon_reader {
  34. struct list_head r_link;
  35. struct mon_bus *m_bus;
  36. void *r_data; /* Use container_of instead? */
  37. void (*rnf_submit)(void *data, struct urb *urb);
  38. void (*rnf_error)(void *data, struct urb *urb, int error);
  39. void (*rnf_complete)(void *data, struct urb *urb);
  40. };
  41. void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
  42. void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
  43. struct mon_bus *mon_bus_lookup(unsigned int num);
  44. int /*bool*/ mon_text_add(struct mon_bus *mbus, const struct usb_bus *ubus);
  45. void mon_text_del(struct mon_bus *mbus);
  46. // void mon_bin_add(struct mon_bus *);
  47. int __init mon_text_init(void);
  48. void mon_text_exit(void);
  49. int __init mon_bin_init(void);
  50. void mon_bin_exit(void);
  51. /*
  52. * DMA interface.
  53. *
  54. * XXX The vectored side needs a serious re-thinking. Abstracting vectors,
  55. * like in Paolo's original patch, produces a double pkmap. We need an idea.
  56. */
  57. extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
  58. struct mon_reader_bin;
  59. extern void mon_dmapeek_vec(const struct mon_reader_bin *rp,
  60. unsigned int offset, dma_addr_t dma_addr, unsigned int len);
  61. extern unsigned int mon_copy_to_buff(const struct mon_reader_bin *rp,
  62. unsigned int offset, const unsigned char *from, unsigned int len);
  63. /*
  64. */
  65. extern struct mutex mon_lock;
  66. extern const struct file_operations mon_fops_stat;
  67. #endif /* __USB_MON_H */