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