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