Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /** |
2 | * @file nmi_timer_int.c | |
3 | * | |
4 | * @remark Copyright 2003 OProfile authors | |
5 | * @remark Read the file COPYING | |
6 | * | |
7 | * @author Zwane Mwaikambo <zwane@linuxpower.ca> | |
8 | */ | |
9 | ||
10 | #include <linux/init.h> | |
11 | #include <linux/smp.h> | |
ce3a161e | 12 | #include <linux/errno.h> |
1da177e4 LT |
13 | #include <linux/oprofile.h> |
14 | #include <linux/rcupdate.h> | |
1eeb66a1 | 15 | #include <linux/kdebug.h> |
1da177e4 LT |
16 | |
17 | #include <asm/nmi.h> | |
18 | #include <asm/apic.h> | |
19 | #include <asm/ptrace.h> | |
0fb90297 | 20 | |
9c48f1c6 | 21 | static int profile_timer_exceptions_notify(unsigned int val, struct pt_regs *regs) |
1da177e4 | 22 | { |
9c48f1c6 DZ |
23 | oprofile_add_sample(regs, 0); |
24 | return NMI_HANDLED; | |
1da177e4 LT |
25 | } |
26 | ||
27 | static int timer_start(void) | |
28 | { | |
9c48f1c6 DZ |
29 | if (register_nmi_handler(NMI_LOCAL, profile_timer_exceptions_notify, |
30 | 0, "oprofile-timer")) | |
2fbe7b25 | 31 | return 1; |
1da177e4 LT |
32 | return 0; |
33 | } | |
34 | ||
35 | ||
36 | static void timer_stop(void) | |
37 | { | |
9c48f1c6 | 38 | unregister_nmi_handler(NMI_LOCAL, "oprofile-timer"); |
fbd568a3 | 39 | synchronize_sched(); /* Allow already-started NMIs to complete. */ |
1da177e4 LT |
40 | } |
41 | ||
42 | ||
0fb90297 | 43 | int __init op_nmi_timer_init(struct oprofile_operations *ops) |
1da177e4 | 44 | { |
1da177e4 LT |
45 | ops->start = timer_start; |
46 | ops->stop = timer_stop; | |
47 | ops->cpu_type = "timer"; | |
48 | printk(KERN_INFO "oprofile: using NMI timer interrupt.\n"); | |
49 | return 0; | |
50 | } |