x86, efi: Set runtime_version to the EFI spec revision
[linux/fpc-iii.git] / arch / ia64 / oprofile / perfmon.c
blob192d3e8e1f6597703a13203acc4ba5bdeac55e2e
1 /**
2 * @file perfmon.c
4 * @remark Copyright 2003 OProfile authors
5 * @remark Read the file COPYING
7 * @author John Levon <levon@movementarian.org>
8 */
10 #include <linux/kernel.h>
11 #include <linux/oprofile.h>
12 #include <linux/sched.h>
13 #include <asm/perfmon.h>
14 #include <asm/ptrace.h>
15 #include <asm/errno.h>
17 static int allow_ints;
19 static int
20 perfmon_handler(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg,
21 struct pt_regs *regs, unsigned long stamp)
23 int event = arg->pmd_eventid;
25 arg->ovfl_ctrl.bits.reset_ovfl_pmds = 1;
27 /* the owner of the oprofile event buffer may have exited
28 * without perfmon being shutdown (e.g. SIGSEGV)
30 if (allow_ints)
31 oprofile_add_sample(regs, event);
32 return 0;
36 static int perfmon_start(void)
38 allow_ints = 1;
39 return 0;
43 static void perfmon_stop(void)
45 allow_ints = 0;
49 #define OPROFILE_FMT_UUID { \
50 0x77, 0x7a, 0x6e, 0x61, 0x20, 0x65, 0x73, 0x69, 0x74, 0x6e, 0x72, 0x20, 0x61, 0x65, 0x0a, 0x6c }
52 static pfm_buffer_fmt_t oprofile_fmt = {
53 .fmt_name = "oprofile_format",
54 .fmt_uuid = OPROFILE_FMT_UUID,
55 .fmt_handler = perfmon_handler,
59 static char *get_cpu_type(void)
61 __u8 family = local_cpu_data->family;
63 switch (family) {
64 case 0x07:
65 return "ia64/itanium";
66 case 0x1f:
67 return "ia64/itanium2";
68 default:
69 return "ia64/ia64";
74 /* all the ops are handled via userspace for IA64 perfmon */
76 static int using_perfmon;
78 int perfmon_init(struct oprofile_operations *ops)
80 int ret = pfm_register_buffer_fmt(&oprofile_fmt);
81 if (ret)
82 return -ENODEV;
84 ops->cpu_type = get_cpu_type();
85 ops->start = perfmon_start;
86 ops->stop = perfmon_stop;
87 using_perfmon = 1;
88 printk(KERN_INFO "oprofile: using perfmon.\n");
89 return 0;
93 void perfmon_exit(void)
95 if (!using_perfmon)
96 return;
98 pfm_unregister_buffer_fmt(oprofile_fmt.fmt_uuid);