mmiotrace.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef MMIOTRACE_H
  2. #define MMIOTRACE_H
  3. #include <linux/types.h>
  4. #include <linux/list.h>
  5. struct kmmio_probe;
  6. struct pt_regs;
  7. typedef void (*kmmio_pre_handler_t)(struct kmmio_probe *,
  8. struct pt_regs *, unsigned long addr);
  9. typedef void (*kmmio_post_handler_t)(struct kmmio_probe *,
  10. unsigned long condition, struct pt_regs *);
  11. struct kmmio_probe {
  12. struct list_head list; /* kmmio internal list */
  13. unsigned long addr; /* start location of the probe point */
  14. unsigned long len; /* length of the probe region */
  15. kmmio_pre_handler_t pre_handler; /* Called before addr is executed. */
  16. kmmio_post_handler_t post_handler; /* Called after addr is executed */
  17. void *private;
  18. };
  19. /* kmmio is active by some kmmio_probes? */
  20. static inline int is_kmmio_active(void)
  21. {
  22. extern unsigned int kmmio_count;
  23. return kmmio_count;
  24. }
  25. extern int register_kmmio_probe(struct kmmio_probe *p);
  26. extern void unregister_kmmio_probe(struct kmmio_probe *p);
  27. /* Called from page fault handler. */
  28. extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
  29. #ifdef CONFIG_MMIOTRACE
  30. /* Called from ioremap.c */
  31. extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
  32. void __iomem *addr);
  33. extern void mmiotrace_iounmap(volatile void __iomem *addr);
  34. /* For anyone to insert markers. Remember trailing newline. */
  35. extern int mmiotrace_printk(const char *fmt, ...)
  36. __attribute__ ((format (printf, 1, 2)));
  37. #else
  38. static inline void mmiotrace_ioremap(resource_size_t offset,
  39. unsigned long size, void __iomem *addr)
  40. {
  41. }
  42. static inline void mmiotrace_iounmap(volatile void __iomem *addr)
  43. {
  44. }
  45. static inline int mmiotrace_printk(const char *fmt, ...)
  46. __attribute__ ((format (printf, 1, 0)));
  47. static inline int mmiotrace_printk(const char *fmt, ...)
  48. {
  49. return 0;
  50. }
  51. #endif /* CONFIG_MMIOTRACE */
  52. enum mm_io_opcode {
  53. MMIO_READ = 0x1, /* struct mmiotrace_rw */
  54. MMIO_WRITE = 0x2, /* struct mmiotrace_rw */
  55. MMIO_PROBE = 0x3, /* struct mmiotrace_map */
  56. MMIO_UNPROBE = 0x4, /* struct mmiotrace_map */
  57. MMIO_UNKNOWN_OP = 0x5, /* struct mmiotrace_rw */
  58. };
  59. struct mmiotrace_rw {
  60. resource_size_t phys; /* PCI address of register */
  61. unsigned long value;
  62. unsigned long pc; /* optional program counter */
  63. int map_id;
  64. unsigned char opcode; /* one of MMIO_{READ,WRITE,UNKNOWN_OP} */
  65. unsigned char width; /* size of register access in bytes */
  66. };
  67. struct mmiotrace_map {
  68. resource_size_t phys; /* base address in PCI space */
  69. unsigned long virt; /* base virtual address */
  70. unsigned long len; /* mapping size */
  71. int map_id;
  72. unsigned char opcode; /* MMIO_PROBE or MMIO_UNPROBE */
  73. };
  74. /* in kernel/trace/trace_mmiotrace.c */
  75. extern void enable_mmiotrace(void);
  76. extern void disable_mmiotrace(void);
  77. extern void mmio_trace_rw(struct mmiotrace_rw *rw);
  78. extern void mmio_trace_mapping(struct mmiotrace_map *map);
  79. extern int mmio_trace_printk(const char *fmt, va_list args);
  80. #endif /* MMIOTRACE_H */