2
* Copyright (C) 2001-2003 Hewlett-Packard Co
3
* Stephane Eranian <eranian@hpl.hp.com>
6
#ifndef _ASM_IA64_PERFMON_H
7
#define _ASM_IA64_PERFMON_H
10
#include <asm/config.h>
12
#define pt_regs cpu_user_regs
18
* perfmon comamnds supported on all CPU models
20
#define PFM_WRITE_PMCS 0x01
21
#define PFM_WRITE_PMDS 0x02
22
#define PFM_READ_PMDS 0x03
24
#define PFM_START 0x05
25
#define PFM_ENABLE 0x06 /* obsolete */
26
#define PFM_DISABLE 0x07 /* obsolete */
27
#define PFM_CREATE_CONTEXT 0x08
28
#define PFM_DESTROY_CONTEXT 0x09 /* obsolete use close() */
29
#define PFM_RESTART 0x0a
30
#define PFM_PROTECT_CONTEXT 0x0b /* obsolete */
31
#define PFM_GET_FEATURES 0x0c
32
#define PFM_DEBUG 0x0d
33
#define PFM_UNPROTECT_CONTEXT 0x0e /* obsolete */
34
#define PFM_GET_PMC_RESET_VAL 0x0f
35
#define PFM_LOAD_CONTEXT 0x10
36
#define PFM_UNLOAD_CONTEXT 0x11
39
* PMU model specific commands (may not be supported on all PMU models)
41
#define PFM_WRITE_IBRS 0x20
42
#define PFM_WRITE_DBRS 0x21
47
#define PFM_FL_NOTIFY_BLOCK 0x01 /* block task on user level notifications */
48
#define PFM_FL_SYSTEM_WIDE 0x02 /* create a system wide context */
49
#define PFM_FL_OVFL_NO_MSG 0x80 /* do not post overflow/end messages for notification */
54
#define PFM_SETFL_EXCL_IDLE 0x01 /* exclude idle task (syswide only) XXX: DO NOT USE YET */
59
#define PFM_REGFL_OVFL_NOTIFY 0x1 /* send notification on overflow */
60
#define PFM_REGFL_RANDOM 0x2 /* randomize sampling interval */
63
* PMD/PMC/IBR/DBR return flags (ignored on input)
65
* Those flags are used on output and must be checked in case EAGAIN is returned
66
* by any of the calls using a pfarg_reg_t or pfarg_dbreg_t structure.
68
#define PFM_REG_RETFL_NOTAVAIL (1UL<<31) /* set if register is implemented but not available */
69
#define PFM_REG_RETFL_EINVAL (1UL<<30) /* set if register entry is invalid */
70
#define PFM_REG_RETFL_MASK (PFM_REG_RETFL_NOTAVAIL|PFM_REG_RETFL_EINVAL)
72
#define PFM_REG_HAS_ERROR(flag) (((flag) & PFM_REG_RETFL_MASK) != 0)
74
typedef unsigned char pfm_uuid_t[16]; /* custom sampling buffer identifier type */
77
* Request structure used to define a context
80
pfm_uuid_t ctx_smpl_buf_id; /* which buffer format to use (if needed) */
81
unsigned long ctx_flags; /* noblock/block */
82
unsigned short ctx_nextra_sets; /* number of extra event sets (you always get 1) */
83
unsigned short ctx_reserved1; /* for future use */
84
int ctx_fd; /* return arg: unique identification for context */
85
void *ctx_smpl_vaddr; /* return arg: virtual address of sampling buffer, is used */
86
unsigned long ctx_reserved2[11];/* for future use */
90
* Request structure used to write/read a PMC or PMD
93
unsigned int reg_num; /* which register */
94
unsigned short reg_set; /* event set for this register */
95
unsigned short reg_reserved1; /* for future use */
97
unsigned long reg_value; /* initial pmc/pmd value */
98
unsigned long reg_flags; /* input: pmc/pmd flags, return: reg error */
100
unsigned long reg_long_reset; /* reset after buffer overflow notification */
101
unsigned long reg_short_reset; /* reset after counter overflow */
103
unsigned long reg_reset_pmds[4]; /* which other counters to reset on overflow */
104
unsigned long reg_random_seed; /* seed value when randomization is used */
105
unsigned long reg_random_mask; /* bitmask used to limit random value */
106
unsigned long reg_last_reset_val;/* return: PMD last reset value */
108
unsigned long reg_smpl_pmds[4]; /* which pmds are accessed when PMC overflows */
109
unsigned long reg_smpl_eventid; /* opaque sampling event identifier */
111
unsigned long reg_reserved2[3]; /* for future use */
115
unsigned int dbreg_num; /* which debug register */
116
unsigned short dbreg_set; /* event set for this register */
117
unsigned short dbreg_reserved1; /* for future use */
118
unsigned long dbreg_value; /* value for debug register */
119
unsigned long dbreg_flags; /* return: dbreg error */
120
unsigned long dbreg_reserved2[1]; /* for future use */
124
unsigned int ft_version; /* perfmon: major [16-31], minor [0-15] */
125
unsigned int ft_reserved; /* reserved for future use */
126
unsigned long reserved[4]; /* for future use */
130
pid_t load_pid; /* process to load the context into */
131
unsigned short load_set; /* first event set to load */
132
unsigned short load_reserved1; /* for future use */
133
unsigned long load_reserved2[3]; /* for future use */
137
int msg_type; /* generic message header */
138
int msg_ctx_fd; /* generic message header */
139
unsigned long msg_ovfl_pmds[4]; /* which PMDs overflowed */
140
unsigned short msg_active_set; /* active set at the time of overflow */
141
unsigned short msg_reserved1; /* for future use */
142
unsigned int msg_reserved2; /* for future use */
143
unsigned long msg_tstamp; /* for perf tuning/debug */
147
int msg_type; /* generic message header */
148
int msg_ctx_fd; /* generic message header */
149
unsigned long msg_tstamp; /* for perf tuning */
153
int msg_type; /* type of the message */
154
int msg_ctx_fd; /* unique identifier for the context */
155
unsigned long msg_tstamp; /* for perf tuning */
158
#define PFM_MSG_OVFL 1 /* an overflow happened */
159
#define PFM_MSG_END 2 /* task to which context was attached ended */
162
pfm_ovfl_msg_t pfm_ovfl_msg;
163
pfm_end_msg_t pfm_end_msg;
164
pfm_gen_msg_t pfm_gen_msg;
168
* Define the version numbers for both perfmon as a whole and the sampling buffer format.
170
#define PFM_VERSION_MAJ 2U
171
#define PFM_VERSION_MIN 0U
172
#define PFM_VERSION (((PFM_VERSION_MAJ&0xffff)<<16)|(PFM_VERSION_MIN & 0xffff))
173
#define PFM_VERSION_MAJOR(x) (((x)>>16) & 0xffff)
174
#define PFM_VERSION_MINOR(x) ((x) & 0xffff)
178
* miscellaneous architected definitions
180
#define PMU_FIRST_COUNTER 4 /* first counting monitor (PMC/PMD) */
181
#define PMU_MAX_PMCS 256 /* maximum architected number of PMC registers */
182
#define PMU_MAX_PMDS 256 /* maximum architected number of PMD registers */
186
extern long perfmonctl(int fd, int cmd, void *arg, int narg);
189
void (*handler)(int irq, void *arg, struct pt_regs *regs);
190
} pfm_intr_handler_desc_t;
192
extern void pfm_save_regs (struct task_struct *);
193
extern void pfm_load_regs (struct task_struct *);
195
extern void pfm_exit_thread(struct task_struct *);
196
extern int pfm_use_debug_registers(struct task_struct *);
197
extern int pfm_release_debug_registers(struct task_struct *);
198
extern void pfm_syst_wide_update_task(struct task_struct *, unsigned long info, int is_ctxswin);
199
extern void pfm_inherit(struct task_struct *task, struct pt_regs *regs);
200
extern void pfm_init_percpu(void);
201
extern void pfm_handle_work(void);
202
extern int pfm_install_alt_pmu_interrupt(pfm_intr_handler_desc_t *h);
203
extern int pfm_remove_alt_pmu_interrupt(pfm_intr_handler_desc_t *h);
208
* Reset PMD register flags
210
#define PFM_PMD_SHORT_RESET 0
211
#define PFM_PMD_LONG_RESET 1
216
unsigned int notify_user:1; /* notify user program of overflow */
217
unsigned int reset_ovfl_pmds:1; /* reset overflowed PMDs */
218
unsigned int block_task:1; /* block monitored task on kernel exit */
219
unsigned int mask_monitoring:1; /* mask monitors via PMCx.plm */
220
unsigned int reserved:28; /* for future use */
225
unsigned char ovfl_pmd; /* index of overflowed PMD */
226
unsigned char ovfl_notify; /* =1 if monitor requested overflow notification */
227
unsigned short active_set; /* event set active at the time of the overflow */
228
pfm_ovfl_ctrl_t ovfl_ctrl; /* return: perfmon controls to set by handler */
230
unsigned long pmd_last_reset; /* last reset value of of the PMD */
231
unsigned long smpl_pmds[4]; /* bitmask of other PMD of interest on overflow */
232
unsigned long smpl_pmds_values[PMU_MAX_PMDS]; /* values for the other PMDs of interest */
233
unsigned long pmd_value; /* current 64-bit value of the PMD */
234
unsigned long pmd_eventid; /* eventid associated with PMD */
242
unsigned long fmt_flags;
244
int (*fmt_validate)(struct task_struct *task, unsigned int flags, int cpu, void *arg);
245
int (*fmt_getsize)(struct task_struct *task, unsigned int flags, int cpu, void *arg, unsigned long *size);
246
int (*fmt_init)(struct task_struct *task, void *buf, unsigned int flags, int cpu, void *arg);
247
int (*fmt_handler)(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg, struct pt_regs *regs, unsigned long stamp);
248
int (*fmt_restart)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs);
249
int (*fmt_restart_active)(struct task_struct *task, pfm_ovfl_ctrl_t *ctrl, void *buf, struct pt_regs *regs);
250
int (*fmt_exit)(struct task_struct *task, void *buf, struct pt_regs *regs);
252
struct list_head fmt_list;
255
extern int pfm_register_buffer_fmt(pfm_buffer_fmt_t *fmt);
256
extern int pfm_unregister_buffer_fmt(pfm_uuid_t uuid);
259
* perfmon interface exported to modules
261
extern int pfm_mod_read_pmds(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs);
262
extern int pfm_mod_write_pmcs(struct task_struct *, void *req, unsigned int nreq, struct pt_regs *regs);
263
extern int pfm_mod_write_ibrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs);
264
extern int pfm_mod_write_dbrs(struct task_struct *task, void *req, unsigned int nreq, struct pt_regs *regs);
267
* describe the content of the local_cpu_date->pfm_syst_info field
269
#define PFM_CPUINFO_SYST_WIDE 0x1 /* if set a system wide session exists */
270
#define PFM_CPUINFO_DCR_PP 0x2 /* if set the system wide session has started */
271
#define PFM_CPUINFO_EXCL_IDLE 0x4 /* the system wide session excludes the idle task */
274
* sysctl control structure. visible to sampling formats
277
int debug; /* turn on/off debugging via syslog */
278
int debug_ovfl; /* turn on/off debug printk in overflow handler */
279
int fastctxsw; /* turn on/off fast (unsecure) ctxsw */
280
int expert_mode; /* turn on/off value checking */
282
extern pfm_sysctl_t pfm_sysctl;
285
#endif /* __KERNEL__ */
287
#endif /* _ASM_IA64_PERFMON_H */