usb_mon.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. /* Ref */
  22. int nreaders; /* Under mon_lock AND mbus->lock */
  23. struct list_head r_list; /* Chain of readers (usually one) */
  24. struct kref ref; /* Under mon_lock */
  25. /* Stats */
  26. unsigned int cnt_events;
  27. unsigned int cnt_text_lost;
  28. };
  29. /*
  30. * An instance of a process which opened a file (but can fork later)
  31. */
  32. struct mon_reader {
  33. struct list_head r_link;
  34. struct mon_bus *m_bus;
  35. void *r_data; /* Use container_of instead? */
  36. void (*rnf_submit)(void *data, struct urb *urb);
  37. void (*rnf_error)(void *data, struct urb *urb, int error);
  38. void (*rnf_complete)(void *data, struct urb *urb);
  39. };
  40. void mon_reader_add(struct mon_bus *mbus, struct mon_reader *r);
  41. void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
  42. struct mon_bus *mon_bus_lookup(unsigned int num);
  43. int /*bool*/ mon_text_add(struct mon_bus *mbus, int busnum);
  44. void mon_text_del(struct mon_bus *mbus);
  45. // void mon_bin_add(struct mon_bus *);
  46. int __init mon_text_init(void);
  47. void mon_text_exit(void);
  48. int __init mon_bin_init(void);
  49. void mon_bin_exit(void);
  50. /*
  51. * DMA interface.
  52. *
  53. * XXX The vectored side needs a serious re-thinking. Abstracting vectors,
  54. * like in Paolo's original patch, produces a double pkmap. We need an idea.
  55. */
  56. extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
  57. struct mon_reader_bin;
  58. extern void mon_dmapeek_vec(const struct mon_reader_bin *rp,
  59. unsigned int offset, dma_addr_t dma_addr, unsigned int len);
  60. extern unsigned int mon_copy_to_buff(const struct mon_reader_bin *rp,
  61. unsigned int offset, const unsigned char *from, unsigned int len);
  62. /*
  63. */
  64. extern struct mutex mon_lock;
  65. extern const struct file_operations mon_fops_stat;
  66. extern struct mon_bus mon_bus0; /* Only for redundant checks */
  67. #endif /* __USB_MON_H */