Path: blob/master/arch/alpha/oprofile/op_model_ev6.c
10817 views
/**1* @file arch/alpha/oprofile/op_model_ev6.c2*3* @remark Copyright 2002 OProfile authors4* @remark Read the file COPYING5*6* @author Richard Henderson <[email protected]>7*/89#include <linux/oprofile.h>10#include <linux/init.h>11#include <linux/smp.h>12#include <asm/ptrace.h>13#include <asm/system.h>1415#include "op_impl.h"161718/* Compute all of the registers in preparation for enabling profiling. */1920static void21ev6_reg_setup(struct op_register_config *reg,22struct op_counter_config *ctr,23struct op_system_config *sys)24{25unsigned long ctl, reset, need_reset, i;2627/* Select desired events. We've mapped the event numbers28such that they fit directly into the event selection fields. */29ctl = 0;30if (ctr[0].enabled && ctr[0].event)31ctl |= (ctr[0].event & 1) << 4;32if (ctr[1].enabled)33ctl |= (ctr[1].event - 2) & 15;34reg->mux_select = ctl;3536/* Select logging options. */37/* ??? Need to come up with some mechanism to trace only38selected processes. EV6 does not have a mechanism to39select kernel or user mode only. For now, enable always. */40reg->proc_mode = 0;4142/* EV6 cannot change the width of the counters as with the43other implementations. But fortunately, we can write to44the counters and set the value such that it will overflow45at the right time. */46reset = need_reset = 0;47for (i = 0; i < 2; ++i) {48unsigned long count = ctr[i].count;49if (!ctr[i].enabled)50continue;5152if (count > 0x100000)53count = 0x100000;54ctr[i].count = count;55reset |= (0x100000 - count) << (i ? 6 : 28);56if (count != 0x100000)57need_reset |= 1 << i;58}59reg->reset_values = reset;60reg->need_reset = need_reset;61}6263/* Program all of the registers in preparation for enabling profiling. */6465static void66ev6_cpu_setup (void *x)67{68struct op_register_config *reg = x;6970wrperfmon(2, reg->mux_select);71wrperfmon(3, reg->proc_mode);72wrperfmon(6, reg->reset_values | 3);73}7475/* CTR is a counter for which the user has requested an interrupt count76in between one of the widths selectable in hardware. Reset the count77for CTR to the value stored in REG->RESET_VALUES. */7879static void80ev6_reset_ctr(struct op_register_config *reg, unsigned long ctr)81{82wrperfmon(6, reg->reset_values | (1 << ctr));83}8485static void86ev6_handle_interrupt(unsigned long which, struct pt_regs *regs,87struct op_counter_config *ctr)88{89/* Record the sample. */90oprofile_add_sample(regs, which);91}929394struct op_axp_model op_model_ev6 = {95.reg_setup = ev6_reg_setup,96.cpu_setup = ev6_cpu_setup,97.reset_ctr = ev6_reset_ctr,98.handle_interrupt = ev6_handle_interrupt,99.cpu_type = "alpha/ev6",100.num_counters = 2,101.can_set_proc_mode = 0,102};103104105