blob: 61d19e1b7a0b0684ec6799b1d2351e167f10a1ae [file] [log] [blame]
Pekka Paalanen8b7d89d2008-05-12 21:20:56 +02001#ifndef MMIOTRACE_H
2#define MMIOTRACE_H
3
Pekka Paalanen970e6fa2008-05-12 21:21:03 +02004#include <linux/types.h>
Pekka Paalanen0fd0e3d2008-05-12 21:20:57 +02005#include <linux/list.h>
6
7struct kmmio_probe;
8struct pt_regs;
9
10typedef void (*kmmio_pre_handler_t)(struct kmmio_probe *,
11 struct pt_regs *, unsigned long addr);
12typedef void (*kmmio_post_handler_t)(struct kmmio_probe *,
13 unsigned long condition, struct pt_regs *);
14
15struct kmmio_probe {
Pekka Paalanend61fc442008-05-12 21:20:57 +020016 struct list_head list; /* kmmio internal list */
Pekka Paalanen0fd0e3d2008-05-12 21:20:57 +020017 unsigned long addr; /* start location of the probe point */
18 unsigned long len; /* length of the probe region */
19 kmmio_pre_handler_t pre_handler; /* Called before addr is executed. */
20 kmmio_post_handler_t post_handler; /* Called after addr is executed */
Pekka Paalanena50445d2008-05-12 21:21:03 +020021 void *private;
Pekka Paalanen0fd0e3d2008-05-12 21:20:57 +020022};
23
24/* kmmio is active by some kmmio_probes? */
25static inline int is_kmmio_active(void)
26{
27 extern unsigned int kmmio_count;
28 return kmmio_count;
29}
30
Pekka Paalanen0fd0e3d2008-05-12 21:20:57 +020031extern int register_kmmio_probe(struct kmmio_probe *p);
32extern void unregister_kmmio_probe(struct kmmio_probe *p);
33
34/* Called from page fault handler. */
35extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
36
Pekka Paalanend61fc442008-05-12 21:20:57 +020037/* Called from ioremap.c */
38#ifdef CONFIG_MMIOTRACE
Pekka Paalanendee310d2008-05-12 21:21:03 +020039extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
40 void __iomem *addr);
Pekka Paalanend61fc442008-05-12 21:20:57 +020041extern void mmiotrace_iounmap(volatile void __iomem *addr);
42#else
Pekka Paalanendee310d2008-05-12 21:21:03 +020043static inline void mmiotrace_ioremap(resource_size_t offset,
44 unsigned long size, void __iomem *addr)
Pekka Paalanend61fc442008-05-12 21:20:57 +020045{
46}
Pekka Paalanendee310d2008-05-12 21:21:03 +020047
Pekka Paalanend61fc442008-05-12 21:20:57 +020048static inline void mmiotrace_iounmap(volatile void __iomem *addr)
49{
50}
51#endif /* CONFIG_MMIOTRACE_HOOKS */
52
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020053enum 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
62struct mmiotrace_rw {
Pekka Paalanendee310d2008-05-12 21:21:03 +020063 resource_size_t phys; /* PCI address of register */
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020064 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
71struct mmiotrace_map {
Pekka Paalanendee310d2008-05-12 21:21:03 +020072 resource_size_t phys; /* base address in PCI space */
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020073 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 Paalanenf984b512008-05-12 21:20:57 +020079/* in kernel/trace/trace_mmiotrace.c */
Pekka Paalanenf984b512008-05-12 21:20:57 +020080extern void enable_mmiotrace(void);
81extern void disable_mmiotrace(void);
Pekka Paalanenbd8ac682008-05-12 21:20:57 +020082extern void mmio_trace_rw(struct mmiotrace_rw *rw);
83extern void mmio_trace_mapping(struct mmiotrace_map *map);
Pekka Paalanenf984b512008-05-12 21:20:57 +020084
Pekka Paalanen8b7d89d2008-05-12 21:20:56 +020085#endif /* MMIOTRACE_H */