op_x86_model.h 2.2 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8
/**
 * @file op_x86_model.h
 * interface to x86 model-specific MSR operations
 *
 * @remark Copyright 2002 OProfile authors
 * @remark Read the file COPYING
 *
 * @author Graydon Hoare
9
 * @author Robert Richter <robert.richter@amd.com>
L
Linus Torvalds 已提交
10 11 12 13 14
 */

#ifndef OP_X86_MODEL_H
#define OP_X86_MODEL_H

15
#include <asm/types.h>
16
#include <asm/perf_event.h>
17

L
Linus Torvalds 已提交
18
struct op_msr {
19 20
	unsigned long	addr;
	u64		saved;
L
Linus Torvalds 已提交
21 22 23
};

struct op_msrs {
R
Robert Richter 已提交
24 25
	struct op_msr *counters;
	struct op_msr *controls;
26
	struct op_msr *multiplex;
L
Linus Torvalds 已提交
27 28 29 30
};

struct pt_regs;

31 32
struct oprofile_operations;

L
Linus Torvalds 已提交
33
/* The model vtable abstracts the differences between
S
Simon Arlott 已提交
34
 * various x86 CPU models' perfctr support.
L
Linus Torvalds 已提交
35 36
 */
struct op_x86_model_spec {
37 38
	unsigned int	num_counters;
	unsigned int	num_controls;
39
	unsigned int	num_virt_counters;
40 41
	u64		reserved;
	u16		event_mask;
42 43 44
	int		(*init)(struct oprofile_operations *ops);
	void		(*exit)(void);
	void		(*fill_in_addresses)(struct op_msrs * const msrs);
45 46
	void		(*setup_ctrs)(struct op_x86_model_spec const *model,
				      struct op_msrs const * const msrs);
47 48 49 50 51
	int		(*check_ctrs)(struct pt_regs * const regs,
				      struct op_msrs const * const msrs);
	void		(*start)(struct op_msrs const * const msrs);
	void		(*stop)(struct op_msrs const * const msrs);
	void		(*shutdown)(struct op_msrs const * const msrs);
52 53 54 55
#ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
	void		(*switch_ctrl)(struct op_x86_model_spec const *model,
				       struct op_msrs const * const msrs);
#endif
L
Linus Torvalds 已提交
56 57
};

58 59
struct op_counter_config;

60 61 62 63 64 65 66 67 68 69 70
static inline void op_x86_warn_in_use(int counter)
{
	pr_warning("oprofile: counter #%d on cpu #%d may already be used\n",
		   counter, smp_processor_id());
}

static inline void op_x86_warn_reserved(int counter)
{
	pr_warning("oprofile: counter #%d is already reserved\n", counter);
}

71 72
extern u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
			   struct op_counter_config *counter_config);
73
extern int op_x86_phys_to_virt(int phys);
74
extern int op_x86_virt_to_phys(int virt);
75

76 77 78 79
extern struct op_x86_model_spec op_ppro_spec;
extern struct op_x86_model_spec op_p4_spec;
extern struct op_x86_model_spec op_p4_ht2_spec;
extern struct op_x86_model_spec op_amd_spec;
80 81
extern struct op_x86_model_spec op_arch_perfmon_spec;

L
Linus Torvalds 已提交
82
#endif /* OP_X86_MODEL_H */