MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / oprofile / timer_int.c
blob5f031890859927f9673e3dbddad4fe67f0100db3
1 /**
2 * @file timer_int.c
4 * @remark Copyright 2002 OProfile authors
5 * @remark Read the file COPYING
7 * @author John Levon <levon@movementarian.org>
8 */
10 #include <linux/kernel.h>
11 #include <linux/notifier.h>
12 #include <linux/smp.h>
13 #include <linux/oprofile.h>
14 #include <linux/profile.h>
15 #include <linux/init.h>
16 #include <asm/ptrace.h>
18 static int timer_notify(struct notifier_block * self, unsigned long val, void * data)
20 struct pt_regs * regs = (struct pt_regs *)data;
21 int cpu = smp_processor_id();
22 unsigned long eip = profile_pc(regs);
24 oprofile_add_sample(eip, !user_mode(regs), 0, cpu);
25 return 0;
29 static struct notifier_block timer_notifier = {
30 .notifier_call = timer_notify,
34 static int timer_start(void)
36 return register_profile_notifier(&timer_notifier);
40 static void timer_stop(void)
42 unregister_profile_notifier(&timer_notifier);
46 static struct oprofile_operations timer_ops = {
47 .start = timer_start,
48 .stop = timer_stop,
49 .cpu_type = "timer"
53 void __init timer_init(struct oprofile_operations ** ops)
55 *ops = &timer_ops;
56 printk(KERN_INFO "oprofile: using timer interrupt.\n");