543d2cb5f242fddf5cc50f09827e9dc4681f125d
[linux-2.6.git] / drivers / oprofile / timer_int.c
1 /**
2  * @file timer_int.c
3  *
4  * @remark Copyright 2002 OProfile authors
5  * @remark Read the file COPYING
6  *
7  * @author John Levon <levon@movementarian.org>
8  */
9
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>
17  
18 static int timer_notify(struct pt_regs *regs)
19 {
20         int cpu = smp_processor_id();
21         unsigned long eip = profile_pc(regs);
22  
23         oprofile_add_sample(eip, !user_mode(regs), 0, cpu);
24         return 0;
25 }
26
27 static int timer_start(void)
28 {
29         return register_timer_hook(timer_notify);
30 }
31
32
33 static void timer_stop(void)
34 {
35         unregister_timer_hook(timer_notify);
36 }
37
38
39 static struct oprofile_operations timer_ops = {
40         .start  = timer_start,
41         .stop   = timer_stop,
42         .cpu_type = "timer"
43 };
44
45  
46 void __init timer_init(struct oprofile_operations ** ops)
47 {
48         *ops = &timer_ops;
49         printk(KERN_INFO "oprofile: using timer interrupt.\n");
50 }