1
2
3
4
5
6
7
8
9
10#include <linux/oprofile.h>
11#include <linux/smp.h>
12#include <asm/ptrace.h>
13
14#include "op_impl.h"
15
16
17
18
19static void
20ev4_reg_setup(struct op_register_config *reg,
21 struct op_counter_config *ctr,
22 struct op_system_config *sys)
23{
24 unsigned long ctl = 0, count, hilo;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 ctl |= (ctr[0].enabled ? ctr[0].event << 8 : 14 << 8);
40 ctl |= (ctr[1].enabled ? (ctr[1].event - 16) << 32 : 7ul << 32);
41
42
43
44
45
46
47
48 count = ctr[0].count;
49 if (count <= 4096)
50 count = 4096, hilo = 1;
51 else
52 count = 65536, hilo = 0;
53 ctr[0].count = count;
54 ctl |= (ctr[0].enabled && hilo) << 3;
55
56 count = ctr[1].count;
57 if (count <= 256)
58 count = 256, hilo = 1;
59 else
60 count = 4096, hilo = 0;
61 ctr[1].count = count;
62 ctl |= (ctr[1].enabled && hilo);
63
64 reg->mux_select = ctl;
65
66
67
68
69
70 reg->proc_mode = 0;
71
72
73 reg->freq = 0;
74
75
76 reg->reset_values = 0;
77 reg->need_reset = 0;
78
79}
80
81
82
83static void
84ev4_cpu_setup(void *x)
85{
86 struct op_register_config *reg = x;
87
88 wrperfmon(2, reg->mux_select);
89 wrperfmon(3, reg->proc_mode);
90}
91
92static void
93ev4_handle_interrupt(unsigned long which, struct pt_regs *regs,
94 struct op_counter_config *ctr)
95{
96
97
98 if (!ctr[which].enabled)
99 return;
100
101
102 oprofile_add_sample(regs, which);
103}
104
105
106struct op_axp_model op_model_ev4 = {
107 .reg_setup = ev4_reg_setup,
108 .cpu_setup = ev4_cpu_setup,
109 .reset_ctr = NULL,
110 .handle_interrupt = ev4_handle_interrupt,
111 .cpu_type = "alpha/ev4",
112 .num_counters = 2,
113 .can_set_proc_mode = 0,
114};
115