tracing: x86, mmiotrace: refactor clearing/restore of page presence
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / linux / mmiotrace.h
CommitLineData
b814d41f
IM
1#ifndef _LINUX_MMIOTRACE_H
2#define _LINUX_MMIOTRACE_H
8b7d89d0 3
970e6fa0 4#include <linux/types.h>
0fd0e3da
PP
5#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 {
b814d41f
IM
16 /* kmmio internal list: */
17 struct list_head list;
18 /* start location of the probe point: */
19 unsigned long addr;
20 /* length of the probe region: */
21 unsigned long len;
22 /* Called before addr is executed: */
23 kmmio_pre_handler_t pre_handler;
24 /* Called after addr is executed: */
25 kmmio_post_handler_t post_handler;
26 void *private;
0fd0e3da
PP
27};
28
b814d41f
IM
29extern unsigned int kmmio_count;
30
31extern int register_kmmio_probe(struct kmmio_probe *p);
32extern void unregister_kmmio_probe(struct kmmio_probe *p);
33
34#ifdef CONFIG_MMIOTRACE
0fd0e3da
PP
35/* kmmio is active by some kmmio_probes? */
36static inline int is_kmmio_active(void)
37{
0fd0e3da
PP
38 return kmmio_count;
39}
40
0fd0e3da
PP
41/* Called from page fault handler. */
42extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
43
9e57fb35 44/* Called from ioremap.c */
dee310d0
PP
45extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
46 void __iomem *addr);
d61fc448 47extern void mmiotrace_iounmap(volatile void __iomem *addr);
9e57fb35
PP
48
49/* For anyone to insert markers. Remember trailing newline. */
50extern int mmiotrace_printk(const char *fmt, ...)
51 __attribute__ ((format (printf, 1, 2)));
b814d41f
IM
52#else /* !CONFIG_MMIOTRACE: */
53static inline int is_kmmio_active(void)
54{
55 return 0;
56}
57
58static inline int kmmio_handler(struct pt_regs *regs, unsigned long addr)
59{
60 return 0;
61}
62
dee310d0
PP
63static inline void mmiotrace_ioremap(resource_size_t offset,
64 unsigned long size, void __iomem *addr)
d61fc448
PP
65{
66}
dee310d0 67
d61fc448
PP
68static inline void mmiotrace_iounmap(volatile void __iomem *addr)
69{
70}
9e57fb35
PP
71
72static inline int mmiotrace_printk(const char *fmt, ...)
73 __attribute__ ((format (printf, 1, 0)));
74
75static inline int mmiotrace_printk(const char *fmt, ...)
76{
77 return 0;
78}
79#endif /* CONFIG_MMIOTRACE */
d61fc448 80
bd8ac686 81enum mm_io_opcode {
b814d41f
IM
82 MMIO_READ = 0x1, /* struct mmiotrace_rw */
83 MMIO_WRITE = 0x2, /* struct mmiotrace_rw */
84 MMIO_PROBE = 0x3, /* struct mmiotrace_map */
85 MMIO_UNPROBE = 0x4, /* struct mmiotrace_map */
86 MMIO_UNKNOWN_OP = 0x5, /* struct mmiotrace_rw */
8b7d89d0
PP
87};
88
bd8ac686 89struct mmiotrace_rw {
b814d41f
IM
90 resource_size_t phys; /* PCI address of register */
91 unsigned long value;
92 unsigned long pc; /* optional program counter */
93 int map_id;
94 unsigned char opcode; /* one of MMIO_{READ,WRITE,UNKNOWN_OP} */
95 unsigned char width; /* size of register access in bytes */
8b7d89d0
PP
96};
97
bd8ac686 98struct mmiotrace_map {
b814d41f
IM
99 resource_size_t phys; /* base address in PCI space */
100 unsigned long virt; /* base virtual address */
101 unsigned long len; /* mapping size */
102 int map_id;
103 unsigned char opcode; /* MMIO_PROBE or MMIO_UNPROBE */
8b7d89d0
PP
104};
105
bd8ac686
PP
106/* in kernel/trace/trace_mmiotrace.c */
107extern void enable_mmiotrace(void);
108extern void disable_mmiotrace(void);
109extern void mmio_trace_rw(struct mmiotrace_rw *rw);
110extern void mmio_trace_mapping(struct mmiotrace_map *map);
9e57fb35 111extern int mmio_trace_printk(const char *fmt, va_list args);
8b7d89d0 112
b814d41f 113#endif /* _LINUX_MMIOTRACE_H */