mmiotrace.h 2.5 KB
Newer Older
1 2 3
#ifndef MMIOTRACE_H
#define MMIOTRACE_H

P
Pekka Paalanen 已提交
4
#include <linux/types.h>
5 6 7 8 9 10 11 12 13 14 15
#include <linux/list.h>

struct kmmio_probe;
struct pt_regs;

typedef void (*kmmio_pre_handler_t)(struct kmmio_probe *,
				struct pt_regs *, unsigned long addr);
typedef void (*kmmio_post_handler_t)(struct kmmio_probe *,
				unsigned long condition, struct pt_regs *);

struct kmmio_probe {
P
Pekka Paalanen 已提交
16
	struct list_head list; /* kmmio internal list */
17 18 19 20
	unsigned long addr; /* start location of the probe point */
	unsigned long len; /* length of the probe region */
	kmmio_pre_handler_t pre_handler; /* Called before addr is executed. */
	kmmio_post_handler_t post_handler; /* Called after addr is executed */
P
Pekka Paalanen 已提交
21
	void *user_data;
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
};

/* kmmio is active by some kmmio_probes? */
static inline int is_kmmio_active(void)
{
	extern unsigned int kmmio_count;
	return kmmio_count;
}

extern int register_kmmio_probe(struct kmmio_probe *p);
extern void unregister_kmmio_probe(struct kmmio_probe *p);

/* Called from page fault handler. */
extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);

P
Pekka Paalanen 已提交
37 38
/* Called from ioremap.c */
#ifdef CONFIG_MMIOTRACE
39 40
extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
							void __iomem *addr);
P
Pekka Paalanen 已提交
41 42
extern void mmiotrace_iounmap(volatile void __iomem *addr);
#else
43 44
static inline void mmiotrace_ioremap(resource_size_t offset,
					unsigned long size, void __iomem *addr)
P
Pekka Paalanen 已提交
45 46
{
}
47

P
Pekka Paalanen 已提交
48 49 50 51 52
static inline void mmiotrace_iounmap(volatile void __iomem *addr)
{
}
#endif /* CONFIG_MMIOTRACE_HOOKS */

P
Pekka Paalanen 已提交
53 54 55 56 57
enum mm_io_opcode {
	MMIO_READ = 0x1,     /* struct mmiotrace_rw */
	MMIO_WRITE = 0x2,    /* struct mmiotrace_rw */
	MMIO_PROBE = 0x3,    /* struct mmiotrace_map */
	MMIO_UNPROBE = 0x4,  /* struct mmiotrace_map */
58
	MMIO_MARKER = 0x5,   /* raw char data */
P
Pekka Paalanen 已提交
59
	MMIO_UNKNOWN_OP = 0x6, /* struct mmiotrace_rw */
60 61
};

P
Pekka Paalanen 已提交
62
struct mmiotrace_rw {
63
	resource_size_t phys;	/* PCI address of register */
P
Pekka Paalanen 已提交
64 65 66 67 68
	unsigned long value;
	unsigned long pc;	/* optional program counter */
	int map_id;
	unsigned char opcode;	/* one of MMIO_{READ,WRITE,UNKNOWN_OP} */
	unsigned char width;	/* size of register access in bytes */
69 70
};

P
Pekka Paalanen 已提交
71
struct mmiotrace_map {
72
	resource_size_t phys;	/* base address in PCI space */
P
Pekka Paalanen 已提交
73 74 75 76
	unsigned long virt;	/* base virtual address */
	unsigned long len;	/* mapping size */
	int map_id;
	unsigned char opcode;	/* MMIO_PROBE or MMIO_UNPROBE */
77 78
};

P
Pekka Paalanen 已提交
79 80 81 82 83
/* in kernel/trace/trace_mmiotrace.c */
extern void enable_mmiotrace(void);
extern void disable_mmiotrace(void);
extern void mmio_trace_rw(struct mmiotrace_rw *rw);
extern void mmio_trace_mapping(struct mmiotrace_map *map);
84 85

#endif /* MMIOTRACE_H */