aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc/kernel/perfmon.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/ppc/kernel/perfmon.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/ppc/kernel/perfmon.c')
-rw-r--r--arch/ppc/kernel/perfmon.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/arch/ppc/kernel/perfmon.c b/arch/ppc/kernel/perfmon.c
new file mode 100644
index 000000000000..918f6b252e45
--- /dev/null
+++ b/arch/ppc/kernel/perfmon.c
@@ -0,0 +1,93 @@
1/* kernel/perfmon.c
2 * PPC 32 Performance Monitor Infrastructure
3 *
4 * Author: Andy Fleming
5 * Copyright (c) 2004 Freescale Semiconductor, Inc
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/errno.h>
14#include <linux/sched.h>
15#include <linux/kernel.h>
16#include <linux/mm.h>
17#include <linux/stddef.h>
18#include <linux/unistd.h>
19#include <linux/ptrace.h>
20#include <linux/slab.h>
21#include <linux/user.h>
22#include <linux/a.out.h>
23#include <linux/interrupt.h>
24#include <linux/config.h>
25#include <linux/init.h>
26#include <linux/module.h>
27#include <linux/prctl.h>
28
29#include <asm/pgtable.h>
30#include <asm/uaccess.h>
31#include <asm/system.h>
32#include <asm/io.h>
33#include <asm/reg.h>
34#include <asm/xmon.h>
35
36/* A lock to regulate grabbing the interrupt */
37DEFINE_SPINLOCK(perfmon_lock);
38
39#ifdef CONFIG_FSL_BOOKE
40static void dummy_perf(struct pt_regs *regs)
41{
42 unsigned int pmgc0 = mfpmr(PMRN_PMGC0);
43
44 pmgc0 &= ~PMGC0_PMIE;
45 mtpmr(PMRN_PMGC0, pmgc0);
46}
47
48#else
49/* Ensure exceptions are disabled */
50
51static void dummy_perf(struct pt_regs *regs)
52{
53 unsigned int mmcr0 = mfspr(SPRN_MMCR0);
54
55 mmcr0 &= ~MMCR0_PMXE;
56 mtspr(SPRN_MMCR0, mmcr0);
57}
58#endif
59
60void (*perf_irq)(struct pt_regs *) = dummy_perf;
61
62/* Grab the interrupt, if it's free.
63 * Returns 0 on success, -1 if the interrupt is taken already */
64int request_perfmon_irq(void (*handler)(struct pt_regs *))
65{
66 int err = 0;
67
68 spin_lock(&perfmon_lock);
69
70 if (perf_irq == dummy_perf)
71 perf_irq = handler;
72 else {
73 pr_info("perfmon irq already handled by %p\n", perf_irq);
74 err = -1;
75 }
76
77 spin_unlock(&perfmon_lock);
78
79 return err;
80}
81
82void free_perfmon_irq(void)
83{
84 spin_lock(&perfmon_lock);
85
86 perf_irq = dummy_perf;
87
88 spin_unlock(&perfmon_lock);
89}
90
91EXPORT_SYMBOL(perf_irq);
92EXPORT_SYMBOL(request_perfmon_irq);
93EXPORT_SYMBOL(free_perfmon_irq);