Linux 4.18.10
[linux/fpc-iii.git] / arch / alpha / oprofile / op_model_ev6.c
blob02edf59716144e0939eb2933cfb303fa457ecbd7
1 /**
2 * @file arch/alpha/oprofile/op_model_ev6.c
4 * @remark Copyright 2002 OProfile authors
5 * @remark Read the file COPYING
7 * @author Richard Henderson <rth@twiddle.net>
8 */
10 #include <linux/oprofile.h>
11 #include <linux/smp.h>
12 #include <asm/ptrace.h>
14 #include "op_impl.h"
17 /* Compute all of the registers in preparation for enabling profiling. */
19 static void
20 ev6_reg_setup(struct op_register_config *reg,
21 struct op_counter_config *ctr,
22 struct op_system_config *sys)
24 unsigned long ctl, reset, need_reset, i;
26 /* Select desired events. We've mapped the event numbers
27 such that they fit directly into the event selection fields. */
28 ctl = 0;
29 if (ctr[0].enabled && ctr[0].event)
30 ctl |= (ctr[0].event & 1) << 4;
31 if (ctr[1].enabled)
32 ctl |= (ctr[1].event - 2) & 15;
33 reg->mux_select = ctl;
35 /* Select logging options. */
36 /* ??? Need to come up with some mechanism to trace only
37 selected processes. EV6 does not have a mechanism to
38 select kernel or user mode only. For now, enable always. */
39 reg->proc_mode = 0;
41 /* EV6 cannot change the width of the counters as with the
42 other implementations. But fortunately, we can write to
43 the counters and set the value such that it will overflow
44 at the right time. */
45 reset = need_reset = 0;
46 for (i = 0; i < 2; ++i) {
47 unsigned long count = ctr[i].count;
48 if (!ctr[i].enabled)
49 continue;
51 if (count > 0x100000)
52 count = 0x100000;
53 ctr[i].count = count;
54 reset |= (0x100000 - count) << (i ? 6 : 28);
55 if (count != 0x100000)
56 need_reset |= 1 << i;
58 reg->reset_values = reset;
59 reg->need_reset = need_reset;
62 /* Program all of the registers in preparation for enabling profiling. */
64 static void
65 ev6_cpu_setup (void *x)
67 struct op_register_config *reg = x;
69 wrperfmon(2, reg->mux_select);
70 wrperfmon(3, reg->proc_mode);
71 wrperfmon(6, reg->reset_values | 3);
74 /* CTR is a counter for which the user has requested an interrupt count
75 in between one of the widths selectable in hardware. Reset the count
76 for CTR to the value stored in REG->RESET_VALUES. */
78 static void
79 ev6_reset_ctr(struct op_register_config *reg, unsigned long ctr)
81 wrperfmon(6, reg->reset_values | (1 << ctr));
84 static void
85 ev6_handle_interrupt(unsigned long which, struct pt_regs *regs,
86 struct op_counter_config *ctr)
88 /* Record the sample. */
89 oprofile_add_sample(regs, which);
93 struct op_axp_model op_model_ev6 = {
94 .reg_setup = ev6_reg_setup,
95 .cpu_setup = ev6_cpu_setup,
96 .reset_ctr = ev6_reset_ctr,
97 .handle_interrupt = ev6_handle_interrupt,
98 .cpu_type = "alpha/ev6",
99 .num_counters = 2,
100 .can_set_proc_mode = 0,