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/config.h>
12 #include <linux/oprofile.h>
13 #include <linux/sched.h>
14 #include <asm/perfmon.h>
15 #include <asm/ptrace.h>
16 #include <asm/errno.h>
18 static int allow_ints
;
21 perfmon_handler(struct task_struct
*task
, void *buf
, pfm_ovfl_arg_t
*arg
,
22 struct pt_regs
*regs
, unsigned long stamp
)
24 int event
= arg
->pmd_eventid
;
26 arg
->ovfl_ctrl
.bits
.reset_ovfl_pmds
= 1;
28 /* the owner of the oprofile event buffer may have exited
29 * without perfmon being shutdown (e.g. SIGSEGV)
32 oprofile_add_sample(regs
, event
);
37 static int perfmon_start(void)
44 static void perfmon_stop(void)
50 #define OPROFILE_FMT_UUID { \
51 0x77, 0x7a, 0x6e, 0x61, 0x20, 0x65, 0x73, 0x69, 0x74, 0x6e, 0x72, 0x20, 0x61, 0x65, 0x0a, 0x6c }
53 static pfm_buffer_fmt_t oprofile_fmt
= {
54 .fmt_name
= "oprofile_format",
55 .fmt_uuid
= OPROFILE_FMT_UUID
,
56 .fmt_handler
= perfmon_handler
,
60 static char * get_cpu_type(void)
62 __u8 family
= local_cpu_data
->family
;
66 return "ia64/itanium";
68 return "ia64/itanium2";
75 /* all the ops are handled via userspace for IA64 perfmon */
77 static int using_perfmon
;
79 int perfmon_init(struct oprofile_operations
* ops
)
81 int ret
= pfm_register_buffer_fmt(&oprofile_fmt
);
85 ops
->cpu_type
= get_cpu_type();
86 ops
->start
= perfmon_start
;
87 ops
->stop
= perfmon_stop
;
89 printk(KERN_INFO
"oprofile: using perfmon.\n");
94 void perfmon_exit(void)
99 pfm_unregister_buffer_fmt(oprofile_fmt
.fmt_uuid
);