2008-12-16 07:33:53 +07:00
|
|
|
/*
|
|
|
|
* arch/sh/oprofile/init.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 - 2008 Paul Mundt
|
|
|
|
*
|
|
|
|
* Based on arch/mips/oprofile/common.c:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004, 2005 Ralf Baechle
|
|
|
|
* Copyright (C) 2005 MIPS Technologies, Inc.
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/oprofile.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/smp.h>
|
2010-09-11 02:36:23 +07:00
|
|
|
#include <linux/perf_event.h>
|
2008-12-16 07:33:53 +07:00
|
|
|
#include <asm/processor.h>
|
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
#ifdef CONFIG_HW_PERF_EVENTS
|
2008-12-16 07:35:40 +07:00
|
|
|
extern void sh_backtrace(struct pt_regs * const regs, unsigned int depth);
|
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
char *op_name_from_perf_id(void)
|
2008-12-16 07:33:53 +07:00
|
|
|
{
|
2010-09-11 02:36:23 +07:00
|
|
|
const char *pmu;
|
|
|
|
char buf[20];
|
|
|
|
int size;
|
2008-12-16 07:33:53 +07:00
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
pmu = perf_pmu_name();
|
|
|
|
if (!pmu)
|
|
|
|
return NULL;
|
2008-12-16 07:33:53 +07:00
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
size = snprintf(buf, sizeof(buf), "sh/%s", pmu);
|
|
|
|
if (size > -1 && size < sizeof(buf))
|
|
|
|
return buf;
|
2008-12-16 07:33:53 +07:00
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
return NULL;
|
2008-12-16 07:33:53 +07:00
|
|
|
}
|
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
int __init oprofile_arch_init(struct oprofile_operations *ops)
|
2008-12-16 07:33:53 +07:00
|
|
|
{
|
2010-09-11 02:36:23 +07:00
|
|
|
ops->backtrace = sh_backtrace;
|
2008-12-16 07:33:53 +07:00
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
return oprofile_perf_init(ops);
|
2008-12-16 07:33:53 +07:00
|
|
|
}
|
|
|
|
|
2010-09-11 02:36:23 +07:00
|
|
|
void __exit oprofile_arch_exit(void)
|
2008-12-16 07:33:53 +07:00
|
|
|
{
|
2010-09-11 02:36:23 +07:00
|
|
|
oprofile_perf_exit();
|
2008-12-16 07:33:53 +07:00
|
|
|
}
|
2010-09-11 02:36:23 +07:00
|
|
|
#else
|
2008-12-16 07:33:53 +07:00
|
|
|
int __init oprofile_arch_init(struct oprofile_operations *ops)
|
|
|
|
{
|
2010-09-11 02:36:23 +07:00
|
|
|
pr_info("oprofile: hardware counters not available\n");
|
|
|
|
return -ENODEV;
|
2008-12-16 07:33:53 +07:00
|
|
|
}
|
2010-09-11 02:36:23 +07:00
|
|
|
void __exit oprofile_arch_exit(void) {}
|
|
|
|
#endif /* CONFIG_HW_PERF_EVENTS */
|