mmiotrace.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef MMIOTRACE_H
  2. #define MMIOTRACE_H
  3. #include <asm/types.h>
  4. #ifdef __KERNEL__
  5. #include <linux/list.h>
  6. struct kmmio_probe;
  7. struct pt_regs;
  8. typedef void (*kmmio_pre_handler_t)(struct kmmio_probe *,
  9. struct pt_regs *, unsigned long addr);
  10. typedef void (*kmmio_post_handler_t)(struct kmmio_probe *,
  11. unsigned long condition, struct pt_regs *);
  12. struct kmmio_probe {
  13. struct list_head list;
  14. unsigned long addr; /* start location of the probe point */
  15. unsigned long len; /* length of the probe region */
  16. kmmio_pre_handler_t pre_handler; /* Called before addr is executed. */
  17. kmmio_post_handler_t post_handler; /* Called after addr is executed */
  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 void reference_kmmio(void);
  26. extern void unreference_kmmio(void);
  27. extern int register_kmmio_probe(struct kmmio_probe *p);
  28. extern void unregister_kmmio_probe(struct kmmio_probe *p);
  29. /* Called from page fault handler. */
  30. extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
  31. #endif /* __KERNEL__ */
  32. /*
  33. * If you change anything here, you must bump MMIO_VERSION.
  34. * This is the relay data format for user space.
  35. */
  36. #define MMIO_VERSION 0x04
  37. /* mm_io_header.type */
  38. #define MMIO_OPCODE_MASK 0xff
  39. #define MMIO_OPCODE_SHIFT 0
  40. #define MMIO_WIDTH_MASK 0xff00
  41. #define MMIO_WIDTH_SHIFT 8
  42. #define MMIO_MAGIC (0x6f000000 | (MMIO_VERSION<<16))
  43. #define MMIO_MAGIC_MASK 0xffff0000
  44. enum mm_io_opcode { /* payload type: */
  45. MMIO_READ = 0x1, /* struct mm_io_rw */
  46. MMIO_WRITE = 0x2, /* struct mm_io_rw */
  47. MMIO_PROBE = 0x3, /* struct mm_io_map */
  48. MMIO_UNPROBE = 0x4, /* struct mm_io_map */
  49. MMIO_MARKER = 0x5, /* raw char data */
  50. MMIO_UNKNOWN_OP = 0x6, /* struct mm_io_rw */
  51. };
  52. struct mm_io_header {
  53. __u32 type; /* see MMIO_* macros above */
  54. __u32 sec; /* timestamp */
  55. __u32 nsec;
  56. __u32 pid; /* PID of the process, or 0 for kernel core */
  57. __u16 data_len; /* length of the following payload */
  58. };
  59. struct mm_io_rw {
  60. __u64 address; /* virtual address of register */
  61. __u64 value;
  62. __u64 pc; /* optional program counter */
  63. };
  64. struct mm_io_map {
  65. __u64 phys; /* base address in PCI space */
  66. __u64 addr; /* base virtual address */
  67. __u64 len; /* mapping size */
  68. __u64 pc; /* optional program counter */
  69. };
  70. /*
  71. * These structures are used to allow a single relay_write()
  72. * call to write a full packet.
  73. */
  74. struct mm_io_header_rw {
  75. struct mm_io_header header;
  76. struct mm_io_rw rw;
  77. } __attribute__((packed));
  78. struct mm_io_header_map {
  79. struct mm_io_header header;
  80. struct mm_io_map map;
  81. } __attribute__((packed));
  82. #endif /* MMIOTRACE_H */