blob: e10d89376f9b79140adaa44f7fb63f0681604482 [file] [log] [blame]
Paul Mundt60a51fb2008-12-16 09:33:53 +09001/*
2 * arch/sh/oprofile/init.c
3 *
4 * Copyright (C) 2003 - 2008 Paul Mundt
5 *
6 * Based on arch/mips/oprofile/common.c:
7 *
8 * Copyright (C) 2004, 2005 Ralf Baechle
9 * Copyright (C) 2005 MIPS Technologies, Inc.
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/kernel.h>
16#include <linux/oprofile.h>
17#include <linux/init.h>
18#include <linux/errno.h>
19#include <linux/smp.h>
Matt Fleming86c8c042010-09-10 20:36:23 +010020#include <linux/perf_event.h>
Paul Mundt60a51fb2008-12-16 09:33:53 +090021#include <asm/processor.h>
Paul Mundt60a51fb2008-12-16 09:33:53 +090022
Matt Fleming86c8c042010-09-10 20:36:23 +010023#ifdef CONFIG_HW_PERF_EVENTS
Dave Peverley40a8b422008-12-16 09:35:40 +090024extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
25
Matt Fleming86c8c042010-09-10 20:36:23 +010026char *op_name_from_perf_id(void)
Paul Mundt60a51fb2008-12-16 09:33:53 +090027{
Matt Fleming86c8c042010-09-10 20:36:23 +010028 const char *pmu;
29 char buf[20];
30 int size;
Paul Mundt60a51fb2008-12-16 09:33:53 +090031
Matt Fleming86c8c042010-09-10 20:36:23 +010032 pmu = perf_pmu_name();
33 if (!pmu)
34 return NULL;
Paul Mundt60a51fb2008-12-16 09:33:53 +090035
Matt Fleming86c8c042010-09-10 20:36:23 +010036 size = snprintf(buf, sizeof(buf), "sh/%s", pmu);
37 if (size > -1 && size < sizeof(buf))
38 return buf;
Paul Mundt60a51fb2008-12-16 09:33:53 +090039
Matt Fleming86c8c042010-09-10 20:36:23 +010040 return NULL;
Paul Mundt60a51fb2008-12-16 09:33:53 +090041}
42
43int __init oprofile_arch_init(struct oprofile_operations *ops)
44{
Dave Peverley40a8b422008-12-16 09:35:40 +090045 ops->backtrace = sh_backtrace;
46
Matt Fleming86c8c042010-09-10 20:36:23 +010047 return oprofile_perf_init(ops);
Paul Mundt60a51fb2008-12-16 09:33:53 +090048}
49
Matt Fleming86c8c042010-09-10 20:36:23 +010050void __exit oprofile_arch_exit(void)
Paul Mundt60a51fb2008-12-16 09:33:53 +090051{
Matt Fleming86c8c042010-09-10 20:36:23 +010052 oprofile_perf_exit();
Paul Mundt60a51fb2008-12-16 09:33:53 +090053}
Matt Fleming86c8c042010-09-10 20:36:23 +010054#else
55int __init oprofile_arch_init(struct oprofile_operations *ops)
56{
57 pr_info("oprofile: hardware counters not available\n");
58 return -ENODEV;
59}
60void __exit oprofile_arch_exit(void) {}
61#endif /* CONFIG_HW_PERF_EVENTS */