4 * @remark Copyright 2003 OProfile authors
5 * @remark Read the file COPYING
7 * @author John Levon <levon@movementarian.org>
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
;
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)
31 oprofile_add_sample(regs
, event
);
36 static int perfmon_start(void)
43 static void perfmon_stop(void)
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
;
65 return "ia64/itanium";
67 return "ia64/itanium2";
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
);
84 ops
->cpu_type
= get_cpu_type();
85 ops
->start
= perfmon_start
;
86 ops
->stop
= perfmon_stop
;
88 printk(KERN_INFO
"oprofile: using perfmon.\n");
93 void perfmon_exit(void)
98 pfm_unregister_buffer_fmt(oprofile_fmt
.fmt_uuid
);